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

Commit 6ae49f6a authored by Yunfan Chen's avatar Yunfan Chen
Browse files

Make test compatible with relative insets flags

This change removes the original verification of the caption insets but
instead using a flag awared method to verify the behavior for both of
the flag values to make the test compatible with the flag.

Flag: com.android.window.flags.relative_insets
Bug: 420611475
Bug: 277292497
Test: WindowDecorationTests
Change-Id: I6abb9164a9c04f2b903cfffab14181f614ff21c0
parent 56b7341b
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -315,14 +315,8 @@ public class WindowDecorationTests extends ShellTestCase {
                any(),
                eq(null) /* onDrawTransaction */);
        verify(mMockView).setTaskFocusState(true);
        verify(mMockWindowContainerTransaction).addInsetsSource(
                eq(taskInfo.token),
                any(),
                eq(0 /* index */),
                eq(WindowInsets.Type.captionBar()),
                eq(new Rect(100, 300, 400, 364)),
                any(),
                anyInt());
        verifyAddedInsets(1, taskInfo.token, 0 /* index */, WindowInsets.Type.captionBar(),
                new Rect(100, 300, 400, 364));

        if (Flags.enableFreeformBoxShadows()) {
            if (inSyncWithTransition) {
@@ -1281,6 +1275,18 @@ public class WindowDecorationTests extends ShellTestCase {
        }
    }

    private void verifyAddedInsets(int times, WindowContainerToken token, int index, int type,
            Rect attachedRect) {
        if (com.android.window.flags.Flags.relativeInsets()) {
            verify(mMockWindowContainerTransaction, times(times)).addInsetsSource(eq(token), any(),
                    eq(index), eq(type), eq(Insets.of(0, attachedRect.height(), 0, 0)), any(),
                    anyInt());
        } else {
            verify(mMockWindowContainerTransaction, times(times)).addInsetsSource(eq(token), any(),
                    eq(index), eq(type), eq(attachedRect), any(), anyInt());
        }
    }

    private static class TestView extends View implements TaskFocusStateConsumer {
        private TestView(Context context) {
            super(context);