[power manager] Switching from auto to normal scheme is fixed

This commit is contained in:
Arsentiy Milchakov 2019-02-13 19:03:21 +03:00 committed by Aleksey Belousov
parent 9d88229c2a
commit 6107dd2487
2 changed files with 19 additions and 4 deletions

View file

@ -96,9 +96,10 @@ UNIT_TEST(PowerManager_SetFacility)
TEST_EQUAL(subscriber.m_onShemeEvents.size(), 0, ());
}
UNIT_TEST(PowerManager_SetConfig)
UNIT_TEST(PowerManager_SetScheme)
{
ScopedFile sf("power_manager_config", ScopedFile::Mode::DoNotCreate);
Platform::ThreadRunner m_runner;
PowerManager manager;
SubscriberForTesting subscriber;
@ -161,6 +162,23 @@ UNIT_TEST(PowerManager_SetConfig)
TEST_EQUAL(subscriber.m_onFacilityEvents[4].m_state, true, ());
TEST_EQUAL(subscriber.m_onFacilityEvents[5].m_facility, Facility::UgcUploading, ());
TEST_EQUAL(subscriber.m_onFacilityEvents[5].m_state, true, ());
subscriber.m_onShemeEvents.clear();
subscriber.m_onFacilityEvents.clear();
manager.SetScheme(Scheme::Auto);
TEST_EQUAL(subscriber.m_onShemeEvents.size(), 1, ());
TEST_EQUAL(subscriber.m_onShemeEvents[0], Scheme::Auto, ());
subscriber.m_onShemeEvents.clear();
subscriber.m_onFacilityEvents.clear();
manager.SetScheme(Scheme::Normal);
TEST_EQUAL(subscriber.m_onShemeEvents.size(), 1, ());
TEST_EQUAL(subscriber.m_onShemeEvents[0], Scheme::Normal, ());
TEST_EQUAL(subscriber.m_onFacilityEvents.size(), 0, ());
}
UNIT_TEST(PowerManager_OnBatteryLevelChanged)

View file

@ -122,9 +122,6 @@ void PowerManager::SetScheme(Scheme const scheme)
auto actualState = GetFacilitiesState(scheme);
if (m_config.m_facilities == actualState)
return;
std::swap(m_config.m_facilities, actualState);
if (!Save())