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

Commit dcbcebda authored by Ang Li's avatar Ang Li Committed by Android (Google) Code Review
Browse files

Merge "Add tests for IME user animation request tracking in InsetsController" into main

parents 16a5642c 51c28c61
Loading
Loading
Loading
Loading
+43 −0
Original line number Original line Diff line number Diff line
@@ -534,6 +534,49 @@ public class InsetsControllerTest {
        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
    }
    }


    @Test
    public void testControlWindowInsetsAnimation_ime_createsStatsToken() {
        // Arrange
        prepareControls();
        clearInvocations(mTestHost);

        // Act: Control the IME insets, which should trigger ImeTracker.
        InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
            WindowInsetsAnimationControlListener listener =
                    mock(WindowInsetsAnimationControlListener.class);
            mController.controlWindowInsetsAnimation(ime(), 0, new LinearInterpolator(),
                    null /* cancellationSignal */, listener);
        });

        // Assert: Verify that the host is updated with a non-null stats token.
        ArgumentCaptor<ImeTracker.Token> tokenCaptor =
                ArgumentCaptor.forClass(ImeTracker.Token.class);
        verify(mTestHost).updateRequestedVisibleTypes(anyInt(), tokenCaptor.capture());
        assertNotNull("A statsToken should be created for IME animations", tokenCaptor.getValue());
    }

    @Test
    public void testControlWindowInsetsAnimation_nonIme_noStatsToken() {
        // Arrange
        prepareControls();
        clearInvocations(mTestHost);

        // Act: Control non-IME insets, which should not trigger ImeTracker.
        InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
            WindowInsetsAnimationControlListener listener =
                    mock(WindowInsetsAnimationControlListener.class);
            mController.controlWindowInsetsAnimation(statusBars(), 0, new LinearInterpolator(),
                    null /* cancellationSignal */, listener);
        });

        // Assert: Verify that the host is updated with a null stats token.
        ArgumentCaptor<ImeTracker.Token> tokenCaptor =
                ArgumentCaptor.forClass(ImeTracker.Token.class);
        verify(mTestHost).updateRequestedVisibleTypes(anyInt(), tokenCaptor.capture());
        assertNull("No statsToken should be created for non-IME animations",
                tokenCaptor.getValue());
    }

    @Test
    @Test
    public void testControlImeNotReady() {
    public void testControlImeNotReady() {
        // With the flag on, the IME control should not contain a leash, otherwise the custom
        // With the flag on, the IME control should not contain a leash, otherwise the custom