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

Commit d1718991 authored by Ben Murdoch's avatar Ben Murdoch
Browse files

ModifierShortcutTest improvement

 - After each assertion of shortcut role/category, reset invocation
   count rather than the whole mock (which clears all the stubbing).
   This is needed for an upcoming change where we will need to keep stubs
   intact during test cases
 - Correct ordering for expected, actual in assertion

Flag: TEST_ONLY
Bug: 351963350
Test: atest ModifierShortcutTests
Change-Id: Ib99310a4a310ae40a6eea4c6089e172aeb8f1cbb
parent 5b9571a3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ public class ModifierShortcutTests extends ShortcutKeyTestBase {
            mPhoneWindowManager.assertLaunchCategory(category);
        }

        mPhoneWindowManager.overrideRoleManager();
        for (int i = 0; i < ROLE_SHORTCUTS.size(); i++) {
            final int keyCode = ROLE_SHORTCUTS.keyAt(i);
            final String role = ROLE_SHORTCUTS.valueAt(i);
+10 −4
Original line number Diff line number Diff line
@@ -568,6 +568,12 @@ class TestPhoneWindowManager {
        doReturn(isShowing).when(mKeyguardServiceDelegate).isShowing();
    }

    void overrideRoleManager() {
        doReturn(mContext).when(mContext).createContextAsUser(any(), anyInt());
        doReturn(mRoleManager).when(mContext).getSystemService(eq(RoleManager.class));
        doReturn(mPackageManager).when(mContext).getPackageManager();
    }

    void setupAssistForLaunch() {
        doNothing().when(mPhoneWindowManager).sendCloseSystemWindows();
        doReturn(true).when(mPhoneWindowManager).isUserSetupComplete();
@@ -709,7 +715,7 @@ class TestPhoneWindowManager {
            throw new AssertionError("failed to assert " + category, t);
        }
        // Reset verifier for next call.
        Mockito.reset(mContext);
        Mockito.clearInvocations(mContext);
    }

    void assertLaunchRole(String role) {
@@ -719,10 +725,10 @@ class TestPhoneWindowManager {
            verify(mContext).startActivityAsUser(intentCaptor.capture(), any());
            switch (role) {
                case RoleManager.ROLE_BROWSER:
                    Assert.assertEquals(intentCaptor.getValue(), mBrowserIntent);
                    Assert.assertEquals(mBrowserIntent, intentCaptor.getValue());
                    break;
                case RoleManager.ROLE_SMS:
                    Assert.assertEquals(intentCaptor.getValue(), mSmsIntent);
                    Assert.assertEquals(mSmsIntent, intentCaptor.getValue());
                    break;
                default:
                    throw new AssertionError("Role " + role + " not supported in tests.");
@@ -731,7 +737,7 @@ class TestPhoneWindowManager {
            throw new AssertionError("failed to assert " + role, t);
        }
        // Reset verifier for next call.
        Mockito.reset(mContext);
        Mockito.clearInvocations(mContext);
    }