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

Commit 7eb03b60 authored by Tiger Huang's avatar Tiger Huang Committed by Android (Google) Code Review
Browse files

Merge "Test more about InsetsSourceProvider.updateControlForTarget"

parents 7d36a8d3 c88227fe
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -112,11 +112,44 @@ public class InsetsSourceProviderTest extends WindowTestsBase {
        final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
        final WindowState target = createWindow(null, TYPE_APPLICATION, "target");
        statusBar.getFrameLw().set(0, 0, 500, 100);

        // We must not have control or control target before we have the insets source window.
        mProvider.updateControlForTarget(target, true /* force */);
        assertNull(mProvider.getControl(target));
        assertNull(mProvider.getControlTarget());

        // We can have the control or the control target after we have the insets source window.
        mProvider.setWindow(statusBar, null, null);
        mProvider.updateControlForTarget(target, false /* force */);
        assertNotNull(mProvider.getControl(target));
        assertNotNull(mProvider.getControlTarget());

        // We must not have control or control target while we are performing seamless rotation.
        // And the control and the control target must not be updated during that.
        mProvider.startSeamlessRotation();
        assertNull(mProvider.getControl(target));
        assertNull(mProvider.getControlTarget());
        mProvider.updateControlForTarget(target, true /* force */);
        assertNull(mProvider.getControl(target));
        assertNull(mProvider.getControlTarget());

        // We can have the control and the control target after seamless rotation.
        mProvider.finishSeamlessRotation(false /* timeout */);
        mProvider.updateControlForTarget(target, false /* force */);
        assertNotNull(mProvider.getControl(target));
        assertNotNull(mProvider.getControlTarget());

        // We can clear the control and the control target.
        mProvider.updateControlForTarget(null, false /* force */);
        assertNull(mProvider.getControl(target));
        assertNull(mProvider.getControlTarget());

        // We must not have control or control target if the insets source window doesn't have a
        // surface.
        statusBar.setSurfaceControl(null);
        mProvider.updateControlForTarget(target, true /* force */);
        assertNull(mProvider.getControl(target));
        assertNull(mProvider.getControlTarget());
    }

    @Test