diff options
author | Adnan Begovic <adnan@cyngn.com> | 2016-04-27 15:54:32 -0700 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2016-05-02 10:33:21 -0700 |
commit | 94dd91a34c42ba991651a11665fa2fc1806af43e (patch) | |
tree | 497b76d2e5dc2a90b5d201e0694e199bb25d7144 /tests | |
parent | c6550fd803fe80595c9f60b5980d4d1621efaa54 (diff) | |
download | vendor_cmsdk-94dd91a34c42ba991651a11665fa2fc1806af43e.zip vendor_cmsdk-94dd91a34c42ba991651a11665fa2fc1806af43e.tar.gz vendor_cmsdk-94dd91a34c42ba991651a11665fa2fc1806af43e.tar.bz2 |
cmsdk: Fix PerformanceManagerTest expectations.
Since the API for PerformanceManager returns the number
of profiles supported we can assume what the profiles are
since the HAL provides them in an ordered manner. Thus,
iterate through the size of the number of profiles and verify
each one that's possible.
Change-Id: I87f6d1a847c849bd9e544c1e89a666726c61fe83
TICKET: CYNGNOS-2603
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/org/cyanogenmod/tests/power/unit/PerfomanceManagerTest.java | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/tests/src/org/cyanogenmod/tests/power/unit/PerfomanceManagerTest.java b/tests/src/org/cyanogenmod/tests/power/unit/PerfomanceManagerTest.java index 7bc3430..ade7bea 100644 --- a/tests/src/org/cyanogenmod/tests/power/unit/PerfomanceManagerTest.java +++ b/tests/src/org/cyanogenmod/tests/power/unit/PerfomanceManagerTest.java @@ -56,9 +56,15 @@ public class PerfomanceManagerTest extends AndroidTestCase { } @SmallTest - public void testGetNumberOfPerformanceProfiles() { - // Assert that we can even set perf profiles - assertTrue(mCMPerformanceManager.getNumberOfProfiles() > 0); + public void testPowerProfileCantBeSetIfNoneSupported() { + // Assert that if we attempt to set a power profile if none supported + // then we receive a failed response from the service. + if (mCMPerformanceManager.getNumberOfProfiles() == 0) { + for (int powerProfile = 0; powerProfile < + PerformanceManager.POSSIBLE_POWER_PROFILES.length; powerProfile++) { + assertFalse(mCMPerformanceManager.setPowerProfile(powerProfile)); + } + } } @SmallTest @@ -68,18 +74,20 @@ public class PerfomanceManagerTest extends AndroidTestCase { @SmallTest public void testSetAndGetPowerProfile() { - int[] expectedStates = new int[] { PerformanceManager.PROFILE_POWER_SAVE, - PerformanceManager.PROFILE_BALANCED, - PerformanceManager.PROFILE_HIGH_PERFORMANCE}; - - // Set the state - for (int profile : expectedStates) { - // If the target perf profile is the same as the current one, - // setPowerProfile will noop, ignore that scenario - if (mCMPerformanceManager.getPowerProfile() != profile) { - mCMPerformanceManager.setPowerProfile(profile); - // Verify that it was set correctly. - assertEquals(profile, mCMPerformanceManager.getPowerProfile()); + // Identify what power profiles are supported. The api currently returns + // the total number of profiles supported in an ordered manner, thus we can + // assume what they are and if we can set everything correctly. + for (int powerProfile = 0; powerProfile < + PerformanceManager.POSSIBLE_POWER_PROFILES.length; powerProfile++) { + if (powerProfile < mCMPerformanceManager.getNumberOfProfiles()) { + //It is supported, set it and test if it was set + if (mCMPerformanceManager.getPowerProfile() != powerProfile) { + mCMPerformanceManager.setPowerProfile(powerProfile); + // Verify that it was set correctly. + assertEquals(powerProfile, mCMPerformanceManager.getPowerProfile()); + } + } else { + assertFalse(mCMPerformanceManager.setPowerProfile(powerProfile)); } } } |