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

Commit 6bc08e3f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Mock resolveSecondaryHomeActivity for test"

parents 5ff1b20f 5995498a
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -502,6 +502,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
    @Test
    public void testStartHomeOnAllDisplays() {
        mockResolveHomeActivity();
        mockResolveSecondaryHomeActivity();

        // Create secondary displays.
        final TestActivityDisplay secondDisplay = spy(createNewActivityDisplay());
@@ -817,7 +818,7 @@ public class RootActivityContainerTests extends ActivityTestsBase {
    }

    /**
     * Mock {@link RootActivityContainerTests#resolveHomeActivity} for returning consistent activity
     * Mock {@link RootActivityContainer#resolveHomeActivity} for returning consistent activity
     * info for test cases (the original implementation will resolve from the real package manager).
     */
    private ActivityInfo mockResolveHomeActivity() {
@@ -830,4 +831,20 @@ public class RootActivityContainerTests extends ActivityTestsBase {
                refEq(homeIntent));
        return aInfoDefault;
    }

    /**
     * Mock {@link RootActivityContainer#resolveSecondaryHomeActivity} for returning consistent
     * activity info for test cases (the original implementation will resolve from the real package
     * manager).
     */
    private void mockResolveSecondaryHomeActivity() {
        final Intent secondaryHomeIntent = mService
                .getSecondaryHomeIntent(null /* preferredPackage */);
        final ActivityInfo aInfoSecondary = new ActivityInfo();
        aInfoSecondary.name = "fakeSecondaryHomeActivity";
        aInfoSecondary.applicationInfo = new ApplicationInfo();
        aInfoSecondary.applicationInfo.packageName = "fakeSecondaryHomePackage";
        doReturn(Pair.create(aInfoSecondary, secondaryHomeIntent)).when(mRootActivityContainer)
                .resolveSecondaryHomeActivity(anyInt(), anyInt());
    }
}