Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit df47a146 authored by Yan Zhu's avatar Yan Zhu
Browse files

Separate out test for bound widget package from setup

- setup fails when AppWidgetManager is disabled
- therefore, make a seperate test for bound widget package and skip the
test when app widget manager is disabled

Bug: 137217082
Test: run atest com.android.server.usage.AppStandbyControllerTests
ASSUMPTION_FAILED for testBoundWidgetPackageExempt and PASS for the rest

Change-Id: If1575d297d395bbd1e9dfb8b4729998a4dc036e0
parent 1234469c
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.doReturn;
@@ -297,9 +298,6 @@ public class AppStandbyControllerTests {
        mInjector.setDisplayOn(true);
        setChargingState(controller, false);
        controller.checkIdleStates(USER_ID);
        assertEquals(STANDBY_BUCKET_EXEMPTED,
                controller.getAppStandbyBucket(PACKAGE_EXEMPTED_1, USER_ID,
                        mInjector.mElapsedRealtime, false));
        assertNotEquals(STANDBY_BUCKET_EXEMPTED,
                controller.getAppStandbyBucket(PACKAGE_1, USER_ID,
                        mInjector.mElapsedRealtime, false));
@@ -377,6 +375,14 @@ public class AppStandbyControllerTests {
        }
    }

    @Test
    public void testBoundWidgetPackageExempt() throws Exception {
        assumeTrue(mInjector.getContext().getSystemService(AppWidgetManager.class) != null);
        assertEquals(STANDBY_BUCKET_EXEMPTED,
                mController.getAppStandbyBucket(PACKAGE_EXEMPTED_1, USER_ID,
                        mInjector.mElapsedRealtime, false));
    }

    @Test
    public void testCharging() throws Exception {
        long startTime;