From b4eafda7de11276522946d13e5860652aacccd4c Mon Sep 17 00:00:00 2001 From: Adnan Begovic Date: Mon, 7 Mar 2016 11:49:52 -0800 Subject: cmsdk: Add PerformanceManager tests, Change target permission. Since PerformanceManager is strictly a CyanogenMod construct, it doesn't make sense to enforce the interfaces with an android specific permission (even though the implementation is delegated to power manager). To keep consistency with the other api's, modify the enforcing permission to a cm specific declaration. Also add test cases for the PerformanceManager public interfaces. Change-Id: I430b69dbee73bf94bb60932d1942ab97e3ba193e --- tests/AndroidManifest.xml | 1 + .../tests/power/unit/PerfomanceManagerTest.java | 95 ++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 tests/src/org/cyanogenmod/tests/power/unit/PerfomanceManagerTest.java (limited to 'tests') diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml index 5016a35..28fc932 100644 --- a/tests/AndroidManifest.xml +++ b/tests/AndroidManifest.xml @@ -20,6 +20,7 @@ + 0); + } + + @SmallTest + public void testGetPowerProfile() { + assertNotSame(IMPOSSIBLE_POWER_PROFILE, mSavedPerfProfile); + } + + @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()); + } + } + } + + @SmallTest + public void testGetPerfProfileHasAppProfiles() { + // No application has power save by default + assertEquals(false, mCMPerformanceManager.getProfileHasAppProfiles( + PerformanceManager.PROFILE_POWER_SAVE)); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + // Reset + mCMPerformanceManager.setPowerProfile(mSavedPerfProfile); + } +} -- cgit v1.1