Merge "Reduce creating unnecessary display for unit test"
This commit is contained in:
@@ -2415,7 +2415,7 @@ public class ActivityRecordTests extends WindowTestsBase {
|
||||
activity.removeImmediately();
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_ACTIVITY)
|
||||
@SetupWindows(addWindows = W_ACTIVITY)
|
||||
@Test
|
||||
public void testLandscapeSeascapeRotationByApp() {
|
||||
final Task task = new TaskBuilder(mSupervisor)
|
||||
@@ -2448,14 +2448,14 @@ public class ActivityRecordTests extends WindowTestsBase {
|
||||
appWindow.removeImmediately();
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_ACTIVITY)
|
||||
@SetupWindows(addWindows = W_ACTIVITY)
|
||||
@Test
|
||||
public void testLandscapeSeascapeRotationByPolicy() {
|
||||
final Task task = new TaskBuilder(mSupervisor)
|
||||
.setDisplay(mDisplayContent).setCreateActivity(true).build();
|
||||
final ActivityRecord activity = task.getTopNonFinishingActivity();
|
||||
// This instance has been spied in {@link TestDisplayContent}.
|
||||
final DisplayRotation displayRotation = mDisplayContent.getDisplayRotation();
|
||||
spyOn(displayRotation);
|
||||
|
||||
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(
|
||||
TYPE_BASE_APPLICATION);
|
||||
@@ -2572,7 +2572,6 @@ public class ActivityRecordTests extends WindowTestsBase {
|
||||
mWm.mDisplayFrozen = false;
|
||||
}
|
||||
|
||||
@UseTestDisplay
|
||||
@Test
|
||||
public void testRespectTopFullscreenOrientation() {
|
||||
final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true).build();
|
||||
@@ -2595,7 +2594,6 @@ public class ActivityRecordTests extends WindowTestsBase {
|
||||
assertEquals(Configuration.ORIENTATION_LANDSCAPE, activityConfig.orientation);
|
||||
}
|
||||
|
||||
@UseTestDisplay
|
||||
@Test
|
||||
public void testReportOrientationChange() {
|
||||
final Task task = new TaskBuilder(mSupervisor)
|
||||
@@ -3119,7 +3117,7 @@ public class ActivityRecordTests extends WindowTestsBase {
|
||||
assertFalse(app.mActivityRecord.mImeInsetsFrozenUntilStartInput);
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testImeInsetsFrozenFlag_resetWhenResized() {
|
||||
final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
|
||||
@@ -3137,7 +3135,7 @@ public class ActivityRecordTests extends WindowTestsBase {
|
||||
assertFalse(app.mActivityRecord.mImeInsetsFrozenUntilStartInput);
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testImeInsetsFrozenFlag_resetWhenNoImeFocusableInActivity() {
|
||||
final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
|
||||
@@ -3165,7 +3163,7 @@ public class ActivityRecordTests extends WindowTestsBase {
|
||||
assertFalse(app.mActivityRecord.mImeInsetsFrozenUntilStartInput);
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testImeInsetsFrozenFlag_resetWhenReportedToBeImeInputTarget() {
|
||||
final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
|
||||
@@ -3202,7 +3200,7 @@ public class ActivityRecordTests extends WindowTestsBase {
|
||||
assertEquals(state.getSource(ITYPE_IME).getFrame(), imeSource.getFrame());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = {W_ACTIVITY, W_INPUT_METHOD})
|
||||
@SetupWindows(addWindows = { W_ACTIVITY, W_INPUT_METHOD })
|
||||
@Test
|
||||
public void testImeInsetsFrozenFlag_noDispatchVisibleInsetsWhenAppNotRequest()
|
||||
throws RemoteException {
|
||||
|
||||
@@ -170,7 +170,7 @@ import java.util.List;
|
||||
@RunWith(WindowTestRunner.class)
|
||||
public class DisplayContentTests extends WindowTestsBase {
|
||||
|
||||
@UseTestDisplay(addAllCommonWindows = true)
|
||||
@SetupWindows(addAllCommonWindows = true)
|
||||
@Test
|
||||
public void testForAllWindows() {
|
||||
final WindowState exitingAppWindow = createWindow(null, TYPE_BASE_APPLICATION,
|
||||
@@ -203,7 +203,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
assertForAllWindowsOrder(windows);
|
||||
}
|
||||
|
||||
@UseTestDisplay(addAllCommonWindows = true)
|
||||
@SetupWindows(addAllCommonWindows = true)
|
||||
@Test
|
||||
public void testForAllWindows_WithAppImeTarget() {
|
||||
final WindowState imeAppTarget =
|
||||
@@ -225,7 +225,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
mNavBarWindow));
|
||||
}
|
||||
|
||||
@UseTestDisplay(addAllCommonWindows = true)
|
||||
@SetupWindows(addAllCommonWindows = true)
|
||||
@Test
|
||||
public void testForAllWindows_WithChildWindowImeTarget() throws Exception {
|
||||
mDisplayContent.setImeLayeringTarget(mChildAppWindowAbove);
|
||||
@@ -243,7 +243,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
mNavBarWindow));
|
||||
}
|
||||
|
||||
@UseTestDisplay(addAllCommonWindows = true)
|
||||
@SetupWindows(addAllCommonWindows = true)
|
||||
@Test
|
||||
public void testForAllWindows_WithStatusBarImeTarget() throws Exception {
|
||||
mDisplayContent.setImeLayeringTarget(mStatusBarWindow);
|
||||
@@ -261,7 +261,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
mNavBarWindow));
|
||||
}
|
||||
|
||||
@UseTestDisplay(addAllCommonWindows = true)
|
||||
@SetupWindows(addAllCommonWindows = true)
|
||||
@Test
|
||||
public void testForAllWindows_WithNotificationShadeImeTarget() throws Exception {
|
||||
mDisplayContent.setImeLayeringTarget(mNotificationShadeWindow);
|
||||
@@ -279,7 +279,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
mNavBarWindow));
|
||||
}
|
||||
|
||||
@UseTestDisplay(addAllCommonWindows = true)
|
||||
@SetupWindows(addAllCommonWindows = true)
|
||||
@Test
|
||||
public void testForAllWindows_WithInBetweenWindowToken() {
|
||||
// This window is set-up to be z-ordered between some windows that go in the same token like
|
||||
@@ -301,7 +301,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
mNavBarWindow));
|
||||
}
|
||||
|
||||
@UseTestDisplay(addAllCommonWindows = true)
|
||||
@SetupWindows(addAllCommonWindows = true)
|
||||
@Test
|
||||
public void testComputeImeTarget() {
|
||||
// Verify that an app window can be an ime target.
|
||||
@@ -321,7 +321,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
assertEquals(childWin, imeTarget);
|
||||
}
|
||||
|
||||
@UseTestDisplay(addAllCommonWindows = true)
|
||||
@SetupWindows(addAllCommonWindows = true)
|
||||
@Test
|
||||
public void testComputeImeTarget_startingWindow() {
|
||||
ActivityRecord activity = createActivityRecord(mDisplayContent);
|
||||
@@ -985,7 +985,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
assertFalse(isOptionsPanelAtRight(landscapeDisplay.getDisplayId()));
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testInputMethodTargetUpdateWhenSwitchingOnDisplays() {
|
||||
final DisplayContent newDisplay = createNewDisplay();
|
||||
@@ -1020,7 +1020,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
mDisplayContent.getImeTarget(IME_TARGET_LAYERING));
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testInputMethodSet_listenOnDisplayAreaConfigurationChanged() {
|
||||
spyOn(mAtm);
|
||||
@@ -1159,7 +1159,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
assertEquals(dc.getImeContainer().getParentSurfaceControl(), dc.computeImeParent());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_ACTIVITY)
|
||||
@SetupWindows(addWindows = W_ACTIVITY)
|
||||
@Test
|
||||
public void testComputeImeParent_app_notMatchParentBounds() {
|
||||
spyOn(mAppWindow.mActivityRecord);
|
||||
@@ -1178,7 +1178,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
assertEquals(dc.getImeContainer().getParentSurfaceControl(), dc.computeImeParent());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_ACTIVITY)
|
||||
@SetupWindows(addWindows = W_ACTIVITY)
|
||||
@Test
|
||||
public void testComputeImeParent_inputTargetNotUpdate() throws Exception {
|
||||
WindowState app1 = createWindow(null, TYPE_BASE_APPLICATION, "app1");
|
||||
@@ -1193,7 +1193,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
assertNull(mDisplayContent.computeImeParent());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_ACTIVITY)
|
||||
@SetupWindows(addWindows = W_ACTIVITY)
|
||||
@Test
|
||||
public void testComputeImeParent_updateParentWhenTargetNotUseIme() throws Exception {
|
||||
WindowState overlay = createWindow(null, TYPE_APPLICATION_OVERLAY, "overlay");
|
||||
@@ -1268,7 +1268,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
dc.computeImeControlTarget());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testImeSecureFlagGetUpdatedAfterImeInputTarget() {
|
||||
// Verify IME window can get up-to-date secure flag update when the IME input target
|
||||
@@ -1282,7 +1282,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
verify(t).setSecure(eq(mDisplayContent.mInputMethodWindow.mSurfaceControl), eq(true));
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_ACTIVITY)
|
||||
@SetupWindows(addWindows = W_ACTIVITY)
|
||||
@Test
|
||||
public void testComputeImeControlTarget_notMatchParentBounds() throws Exception {
|
||||
spyOn(mAppWindow.mActivityRecord);
|
||||
@@ -1426,7 +1426,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
win.setHasSurface(false);
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = { W_ABOVE_ACTIVITY, W_ACTIVITY})
|
||||
@SetupWindows(addWindows = { W_ABOVE_ACTIVITY, W_ACTIVITY })
|
||||
@Test
|
||||
public void testRequestResizeForEmptyFrames() {
|
||||
final WindowState win = mChildAppWindowAbove;
|
||||
@@ -1501,11 +1501,12 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
assertNull(displayContent.getAsyncRotationController());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = { W_ACTIVITY, W_WALLPAPER, W_STATUS_BAR, W_NAVIGATION_BAR,
|
||||
@SetupWindows(addWindows = { W_ACTIVITY, W_WALLPAPER, W_STATUS_BAR, W_NAVIGATION_BAR,
|
||||
W_INPUT_METHOD, W_NOTIFICATION_SHADE })
|
||||
@Test
|
||||
public void testApplyTopFixedRotationTransform() {
|
||||
final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
|
||||
spyOn(displayPolicy);
|
||||
// Only non-movable (gesture) navigation bar will be animated by fixed rotation animation.
|
||||
doReturn(false).when(displayPolicy).navigationBarCanMove();
|
||||
displayPolicy.addWindowLw(mStatusBarWindow, mStatusBarWindow.mAttrs);
|
||||
@@ -1624,6 +1625,8 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
// The display should be rotated after the launch is finished.
|
||||
doReturn(false).when(app).isAnimating(anyInt(), anyInt());
|
||||
mDisplayContent.mAppTransition.notifyAppTransitionFinishedLocked(app.token);
|
||||
mStatusBarWindow.finishSeamlessRotation(t);
|
||||
mNavBarWindow.finishSeamlessRotation(t);
|
||||
|
||||
// The fixed rotation should be cleared and the new rotation is applied to display.
|
||||
assertFalse(app.hasFixedRotationTransform());
|
||||
@@ -1655,7 +1658,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
assertFalse(mDisplayContent.hasTopFixedRotationLaunchingApp());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_ACTIVITY)
|
||||
@SetupWindows(addWindows = W_ACTIVITY)
|
||||
@Test
|
||||
public void testRotateSeamlesslyWithFixedRotation() {
|
||||
final DisplayRotation displayRotation = mDisplayContent.getDisplayRotation();
|
||||
@@ -2081,7 +2084,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
verifySizes(dc, forcedWidth, forcedHeight, forcedDensity);
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = { W_ACTIVITY, W_INPUT_METHOD })
|
||||
@SetupWindows(addWindows = { W_ACTIVITY, W_INPUT_METHOD })
|
||||
@Test
|
||||
public void testComputeImeTarget_shouldNotCheckOutdatedImeTargetLayerWhenRemoved() {
|
||||
final WindowState child1 = createWindow(mAppWindow, FIRST_SUB_WINDOW, "child1");
|
||||
@@ -2104,7 +2107,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
verify(child1, never()).needsRelativeLayeringToIme();
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = {W_INPUT_METHOD}, addAllCommonWindows = true)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testAttachAndShowImeScreenshotOnTarget() {
|
||||
// Preparation: Simulate screen state is on.
|
||||
@@ -2155,7 +2158,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
assertNotNull(mDisplayContent.mImeScreenshot);
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = {W_INPUT_METHOD}, addAllCommonWindows = true)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testShowImeScreenshot() {
|
||||
final Task rootTask = createTask(mDisplayContent);
|
||||
@@ -2181,7 +2184,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
verify(mDisplayContent, never()).showImeScreenshot();
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = {W_INPUT_METHOD})
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testShowImeScreenshot_removeCurSnapshotBeforeCreateNext() {
|
||||
final Task rootTask = createTask(mDisplayContent);
|
||||
@@ -2471,7 +2474,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
ACTIVITY_TYPE_STANDARD));
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testImeChildWindowFocusWhenImeLayeringTargetChanges() {
|
||||
final WindowState imeChildWindow =
|
||||
@@ -2496,7 +2499,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
assertNotEquals(imeChildWindow, mDisplayContent.findFocusedWindow());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testImeMenuDialogFocusWhenImeLayeringTargetChanges() {
|
||||
final WindowState imeMenuDialog =
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.junit.runner.RunWith;
|
||||
|
||||
@SmallTest
|
||||
@Presubmit
|
||||
@WindowTestsBase.UseTestDisplay(
|
||||
@WindowTestsBase.SetupWindows(
|
||||
addWindows = { WindowTestsBase.W_STATUS_BAR, WindowTestsBase.W_NAVIGATION_BAR })
|
||||
@RunWith(WindowTestRunner.class)
|
||||
public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@@ -67,7 +67,7 @@ import java.io.StringWriter;
|
||||
*/
|
||||
@SmallTest
|
||||
@Presubmit
|
||||
@WindowTestsBase.UseTestDisplay(
|
||||
@WindowTestsBase.SetupWindows(
|
||||
addWindows = { WindowTestsBase.W_STATUS_BAR, WindowTestsBase.W_NAVIGATION_BAR })
|
||||
@RunWith(WindowTestRunner.class)
|
||||
public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@@ -167,7 +167,7 @@ public class DisplayPolicyTests extends WindowTestsBase {
|
||||
dimmingNonImTarget, imeNonDrawNavBar, NAV_BAR_BOTTOM));
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = { W_NAVIGATION_BAR })
|
||||
@SetupWindows(addWindows = W_NAVIGATION_BAR)
|
||||
@Test
|
||||
public void testUpdateLightNavigationBarLw() {
|
||||
DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
|
||||
@@ -204,7 +204,7 @@ public class DisplayPolicyTests extends WindowTestsBase {
|
||||
APPEARANCE_LIGHT_NAVIGATION_BARS, opaqueLightNavBar));
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = {W_ACTIVITY, W_STATUS_BAR})
|
||||
@SetupWindows(addWindows = { W_ACTIVITY, W_STATUS_BAR })
|
||||
@Test
|
||||
public void testComputeTopFullscreenOpaqueWindow() {
|
||||
final WindowManager.LayoutParams attrs = mAppWindow.mAttrs;
|
||||
@@ -292,7 +292,7 @@ public class DisplayPolicyTests extends WindowTestsBase {
|
||||
return win;
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = { W_NAVIGATION_BAR, W_INPUT_METHOD })
|
||||
@SetupWindows(addWindows = { W_NAVIGATION_BAR, W_INPUT_METHOD })
|
||||
@Test
|
||||
public void testImeMinimalSourceFrame() {
|
||||
final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
|
||||
@@ -328,7 +328,7 @@ public class DisplayPolicyTests extends WindowTestsBase {
|
||||
assertTrue(imeSource.getFrame().contains(navBarSource.getFrame()));
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = { W_NAVIGATION_BAR })
|
||||
@SetupWindows(addWindows = W_NAVIGATION_BAR)
|
||||
@Test
|
||||
public void testInsetsGivenContentFrame() {
|
||||
final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
|
||||
|
||||
@@ -253,7 +253,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
assertEquals(ITYPE_NAVIGATION_BAR, panelControls[0].getType());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_ACTIVITY)
|
||||
@SetupWindows(addWindows = W_ACTIVITY)
|
||||
@Test
|
||||
public void testShowTransientBars_bothCanBeTransient_appGetsBothFakeControls() {
|
||||
final WindowState statusBar = addNonFocusableWindow(TYPE_STATUS_BAR, "statusBar");
|
||||
@@ -295,7 +295,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
.getSource(ITYPE_NAVIGATION_BAR).isVisible());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_ACTIVITY)
|
||||
@SetupWindows(addWindows = W_ACTIVITY)
|
||||
@Test
|
||||
public void testShowTransientBars_statusBarCanBeTransient_appGetsStatusBarFakeControl() {
|
||||
addNonFocusableWindow(TYPE_STATUS_BAR, "statusBar")
|
||||
@@ -325,7 +325,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
}
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_ACTIVITY)
|
||||
@SetupWindows(addWindows = W_ACTIVITY)
|
||||
@Test
|
||||
public void testAbortTransientBars_bothCanBeAborted_appGetsBothRealControls() {
|
||||
final InsetsSource statusBarSource = addNonFocusableWindow(TYPE_STATUS_BAR, "statusBar")
|
||||
|
||||
@@ -131,7 +131,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {
|
||||
assertNull(app.getInsetsState().peekSource(ITYPE_NAVIGATION_BAR));
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testStripForDispatch_independentSources() {
|
||||
getController().getSourceProvider(ITYPE_IME).setWindowContainer(mImeWindow, null, null);
|
||||
@@ -148,7 +148,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {
|
||||
.isVisible());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testStripForDispatch_belowIme() {
|
||||
getController().getSourceProvider(ITYPE_IME).setWindowContainer(mImeWindow, null, null);
|
||||
@@ -161,7 +161,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {
|
||||
assertTrue(app.getInsetsState().getSource(ITYPE_IME).isVisible());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testStripForDispatch_aboveIme() {
|
||||
getController().getSourceProvider(ITYPE_IME).setWindowContainer(mImeWindow, null, null);
|
||||
@@ -173,7 +173,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {
|
||||
.isVisible());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testStripForDispatch_imeOrderChanged() {
|
||||
// This can be the IME z-order target while app cannot be the IME z-order target.
|
||||
@@ -228,7 +228,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {
|
||||
assertTrue(app.getInsetsState().getSource(ITYPE_IME).isVisible());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testStripForDispatch_childWindow_altFocusable() {
|
||||
getController().getSourceProvider(ITYPE_IME).setWindowContainer(mImeWindow, null, null);
|
||||
@@ -249,7 +249,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {
|
||||
.isVisible());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testStripForDispatch_childWindow_splitScreen() {
|
||||
getController().getSourceProvider(ITYPE_IME).setWindowContainer(mImeWindow, null, null);
|
||||
@@ -456,7 +456,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {
|
||||
assertNotNull(app.getInsetsState().peekSource(ITYPE_NAVIGATION_BAR));
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testGetInsetsHintForNewControl() {
|
||||
final WindowState app1 = createTestWindow("app1");
|
||||
|
||||
@@ -749,7 +749,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
|
||||
}
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testLaunchRemoteAnimationWithoutImeBehind() {
|
||||
final WindowState win1 = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin1");
|
||||
|
||||
@@ -190,7 +190,7 @@ public class TaskSnapshotControllerTest extends WindowTestsBase {
|
||||
}
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = {W_ACTIVITY, W_INPUT_METHOD})
|
||||
@SetupWindows(addWindows = { W_ACTIVITY, W_INPUT_METHOD })
|
||||
@Test
|
||||
public void testCreateTaskSnapshotWithExcludingIme() {
|
||||
Task task = mAppWindow.mActivityRecord.getTask();
|
||||
@@ -209,7 +209,7 @@ public class TaskSnapshotControllerTest extends WindowTestsBase {
|
||||
}
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = {W_ACTIVITY, W_INPUT_METHOD})
|
||||
@SetupWindows(addWindows = { W_ACTIVITY, W_INPUT_METHOD })
|
||||
@Test
|
||||
public void testCreateTaskSnapshotWithIncludingIme() {
|
||||
Task task = mAppWindow.mActivityRecord.getTask();
|
||||
@@ -237,7 +237,7 @@ public class TaskSnapshotControllerTest extends WindowTestsBase {
|
||||
}
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_ACTIVITY)
|
||||
@SetupWindows(addWindows = W_ACTIVITY)
|
||||
@Test
|
||||
public void testPrepareTaskSnapshot() {
|
||||
mAppWindow.mWinAnimator.mLastAlpha = 1f;
|
||||
|
||||
@@ -45,7 +45,7 @@ import java.util.function.Consumer;
|
||||
@RunWith(WindowTestRunner.class)
|
||||
public class WindowContainerTraversalTests extends WindowTestsBase {
|
||||
|
||||
@UseTestDisplay(addWindows = { W_DOCK_DIVIDER, W_INPUT_METHOD })
|
||||
@SetupWindows(addWindows = { W_DOCK_DIVIDER, W_INPUT_METHOD })
|
||||
@Test
|
||||
public void testDockedDividerPosition() {
|
||||
final WindowState splitScreenWindow = createWindow(null,
|
||||
|
||||
@@ -810,7 +810,6 @@ public class WindowOrganizerTests extends WindowTestsBase {
|
||||
assertThat(navigationBarInsetsReceiverTask.mLocalInsetsSourceProviders.size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@UseTestDisplay
|
||||
@Test
|
||||
public void testTaskInfoCallback() {
|
||||
final ArrayList<RunningTaskInfo> lastReportedTiles = new ArrayList<>();
|
||||
@@ -842,8 +841,7 @@ public class WindowOrganizerTests extends WindowTestsBase {
|
||||
|
||||
lastReportedTiles.clear();
|
||||
called[0] = false;
|
||||
final Task rootTask2 = createTask(
|
||||
mDisplayContent, WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_HOME);
|
||||
final Task rootTask2 = mDisplayContent.getDefaultTaskDisplayArea().getRootHomeTask();
|
||||
wct = new WindowContainerTransaction();
|
||||
wct.reparent(rootTask2.mRemoteToken.toWindowContainerToken(),
|
||||
info1.token, true /* onTop */);
|
||||
@@ -869,7 +867,6 @@ public class WindowOrganizerTests extends WindowTestsBase {
|
||||
assertEquals(ACTIVITY_TYPE_UNDEFINED, lastReportedTiles.get(0).topActivityType);
|
||||
}
|
||||
|
||||
@UseTestDisplay
|
||||
@Test
|
||||
public void testHierarchyTransaction() {
|
||||
final ArrayMap<IBinder, RunningTaskInfo> lastReportedTiles = new ArrayMap<>();
|
||||
@@ -890,23 +887,22 @@ public class WindowOrganizerTests extends WindowTestsBase {
|
||||
// Ensure events dispatch to organizer.
|
||||
mWm.mAtmService.mTaskOrganizerController.dispatchPendingEvents();
|
||||
|
||||
// 2 + 1 (home) = 3
|
||||
final int initialRootTaskCount = mWm.mAtmService.mTaskOrganizerController.getRootTasks(
|
||||
mDisplayContent.mDisplayId, null /* activityTypes */).size();
|
||||
|
||||
final Task rootTask = createTask(
|
||||
mDisplayContent, WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_STANDARD);
|
||||
final Task rootTask2 = createTask(
|
||||
mDisplayContent, WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_HOME);
|
||||
|
||||
// Check getRootTasks works
|
||||
List<RunningTaskInfo> roots = mWm.mAtmService.mTaskOrganizerController.getRootTasks(
|
||||
mDisplayContent.mDisplayId, null /* activityTypes */);
|
||||
assertEquals(initialRootTaskCount + 2, roots.size());
|
||||
assertEquals(initialRootTaskCount + 1, roots.size());
|
||||
|
||||
lastReportedTiles.clear();
|
||||
WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
wct.reparent(rootTask.mRemoteToken.toWindowContainerToken(),
|
||||
info1.token, true /* onTop */);
|
||||
final Task rootTask2 = mDisplayContent.getDefaultTaskDisplayArea().getRootHomeTask();
|
||||
wct.reparent(rootTask2.mRemoteToken.toWindowContainerToken(),
|
||||
info2.token, true /* onTop */);
|
||||
mWm.mAtmService.mWindowOrganizerController.applyTransaction(wct);
|
||||
@@ -940,7 +936,8 @@ public class WindowOrganizerTests extends WindowTestsBase {
|
||||
// Check that getRootTasks doesn't include children of tiles
|
||||
roots = mWm.mAtmService.mTaskOrganizerController.getRootTasks(mDisplayContent.mDisplayId,
|
||||
null /* activityTypes */);
|
||||
assertEquals(initialRootTaskCount, roots.size());
|
||||
// Home (rootTask2) was moved into task1, so only remain 2 roots: task1 and task2.
|
||||
assertEquals(initialRootTaskCount - 1, roots.size());
|
||||
|
||||
lastReportedTiles.clear();
|
||||
wct = new WindowContainerTransaction();
|
||||
|
||||
@@ -418,7 +418,7 @@ public class WindowStateTests extends WindowTestsBase {
|
||||
assertFalse(app.canAffectSystemUiFlags());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = {W_ACTIVITY, W_STATUS_BAR})
|
||||
@SetupWindows(addWindows = { W_ACTIVITY, W_STATUS_BAR })
|
||||
@Test
|
||||
public void testVisibleWithInsetsProvider() {
|
||||
final WindowState statusBar = mStatusBarWindow;
|
||||
@@ -694,7 +694,7 @@ public class WindowStateTests extends WindowTestsBase {
|
||||
verify(t).setMatrix(child2.mSurfaceControl, w.mInvGlobalScale, 0, 0, w.mInvGlobalScale);
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = {W_ABOVE_ACTIVITY, W_NOTIFICATION_SHADE})
|
||||
@SetupWindows(addWindows = { W_ABOVE_ACTIVITY, W_NOTIFICATION_SHADE })
|
||||
@Test
|
||||
public void testRequestDrawIfNeeded() {
|
||||
final WindowState startingApp = createWindow(null /* parent */,
|
||||
@@ -739,7 +739,7 @@ public class WindowStateTests extends WindowTestsBase {
|
||||
assertFalse(startingApp.getOrientationChanging());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_ABOVE_ACTIVITY)
|
||||
@SetupWindows(addWindows = W_ABOVE_ACTIVITY)
|
||||
@Test
|
||||
public void testReportResizedWithRemoteException() {
|
||||
final WindowState win = mChildAppWindowAbove;
|
||||
@@ -769,7 +769,7 @@ public class WindowStateTests extends WindowTestsBase {
|
||||
assertFalse(win.getOrientationChanging());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = W_ABOVE_ACTIVITY)
|
||||
@SetupWindows(addWindows = W_ABOVE_ACTIVITY)
|
||||
@Test
|
||||
public void testRequestResizeForBlastSync() {
|
||||
final WindowState win = mChildAppWindowAbove;
|
||||
@@ -907,7 +907,7 @@ public class WindowStateTests extends WindowTestsBase {
|
||||
assertTrue(mAtm.mActiveUids.hasNonAppVisibleWindow(uid));
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = {W_ACTIVITY, W_INPUT_METHOD})
|
||||
@SetupWindows(addWindows = { W_ACTIVITY, W_INPUT_METHOD })
|
||||
@Test
|
||||
public void testNeedsRelativeLayeringToIme_notAttached() {
|
||||
WindowState sameTokenWindow = createWindow(null, TYPE_BASE_APPLICATION, mAppWindow.mToken,
|
||||
@@ -920,7 +920,7 @@ public class WindowStateTests extends WindowTestsBase {
|
||||
assertFalse(sameTokenWindow.needsRelativeLayeringToIme());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = {W_ACTIVITY, W_INPUT_METHOD})
|
||||
@SetupWindows(addWindows = { W_ACTIVITY, W_INPUT_METHOD })
|
||||
@Test
|
||||
public void testNeedsRelativeLayeringToIme_startingWindow() {
|
||||
WindowState sameTokenWindow = createWindow(null, TYPE_APPLICATION_STARTING,
|
||||
@@ -963,7 +963,7 @@ public class WindowStateTests extends WindowTestsBase {
|
||||
assertFalse(overlay.getWindowFrames().hasInsetsChanged());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = {W_INPUT_METHOD, W_ACTIVITY})
|
||||
@SetupWindows(addWindows = { W_INPUT_METHOD, W_ACTIVITY })
|
||||
@Test
|
||||
public void testImeAlwaysReceivesVisibleNavigationBarInsets() {
|
||||
final InsetsSource navSource = new InsetsSource(ITYPE_NAVIGATION_BAR);
|
||||
@@ -1053,7 +1053,7 @@ public class WindowStateTests extends WindowTestsBase {
|
||||
assertFalse(app2.getInsetsState().getSource(ITYPE_IME).isVisible());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = {W_ACTIVITY})
|
||||
@SetupWindows(addWindows = W_ACTIVITY)
|
||||
@Test
|
||||
public void testUpdateImeControlTargetWhenLeavingMultiWindow() {
|
||||
WindowState app = createWindow(null, TYPE_BASE_APPLICATION,
|
||||
@@ -1079,7 +1079,7 @@ public class WindowStateTests extends WindowTestsBase {
|
||||
assertEquals(mAppWindow, mDisplayContent.getImeTarget(IME_TARGET_CONTROL).getWindow());
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = {W_ACTIVITY, W_INPUT_METHOD, W_NOTIFICATION_SHADE})
|
||||
@SetupWindows(addWindows = { W_ACTIVITY, W_INPUT_METHOD, W_NOTIFICATION_SHADE })
|
||||
@Test
|
||||
public void testNotificationShadeHasImeInsetsWhenMultiWindow() {
|
||||
WindowState app = createWindow(null, TYPE_BASE_APPLICATION,
|
||||
|
||||
@@ -110,6 +110,7 @@ import org.junit.BeforeClass;
|
||||
import org.junit.runner.Description;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -151,7 +152,8 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
||||
*/
|
||||
DisplayContent mDisplayContent;
|
||||
|
||||
// The following fields are only available depending on the usage of annotation UseTestDisplay.
|
||||
// The following fields are only available depending on the usage of annotation UseTestDisplay
|
||||
// and UseCommonWindows.
|
||||
WindowState mWallpaperWindow;
|
||||
WindowState mImeWindow;
|
||||
WindowState mImeDialogWindow;
|
||||
@@ -214,14 +216,15 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
||||
// Only create an additional test display for annotated test class/method because it may
|
||||
// significantly increase the execution time.
|
||||
final Description description = mSystemServicesTestRule.getDescription();
|
||||
UseTestDisplay testDisplayAnnotation = description.getAnnotation(UseTestDisplay.class);
|
||||
if (testDisplayAnnotation == null) {
|
||||
testDisplayAnnotation = description.getTestClass().getAnnotation(UseTestDisplay.class);
|
||||
}
|
||||
if (testDisplayAnnotation != null) {
|
||||
createTestDisplay(testDisplayAnnotation);
|
||||
final UseTestDisplay useTestDisplay = getAnnotation(description, UseTestDisplay.class);
|
||||
if (useTestDisplay != null) {
|
||||
createTestDisplay(useTestDisplay);
|
||||
} else {
|
||||
mDisplayContent = mDefaultDisplay;
|
||||
final SetupWindows setupWindows = getAnnotation(description, SetupWindows.class);
|
||||
if (setupWindows != null) {
|
||||
addCommonWindows(setupWindows.addAllCommonWindows(), setupWindows.addWindows());
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure letterbox aspect ratio is not overridden on any device target.
|
||||
@@ -290,10 +293,15 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
||||
private void createTestDisplay(UseTestDisplay annotation) {
|
||||
beforeCreateTestDisplay();
|
||||
mDisplayContent = createNewDisplayWithImeSupport(DISPLAY_IME_POLICY_LOCAL);
|
||||
addCommonWindows(annotation.addAllCommonWindows(), annotation.addWindows());
|
||||
mDisplayContent.getInsetsPolicy().setRemoteInsetsControllerControlsSystemBars(false);
|
||||
|
||||
final boolean addAll = annotation.addAllCommonWindows();
|
||||
final @CommonTypes int[] requestedWindows = annotation.addWindows();
|
||||
// Adding a display will cause freezing the display. Make sure to wait until it's
|
||||
// unfrozen to not run into race conditions with the tests.
|
||||
waitUntilHandlersIdle();
|
||||
}
|
||||
|
||||
private void addCommonWindows(boolean addAll, @CommonTypes int[] requestedWindows) {
|
||||
if (addAll || ArrayUtils.contains(requestedWindows, W_WALLPAPER)) {
|
||||
mWallpaperWindow = createCommonWindow(null, TYPE_WALLPAPER, "wallpaperWindow");
|
||||
}
|
||||
@@ -346,12 +354,6 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
||||
mChildAppWindowBelow = createCommonWindow(mAppWindow, TYPE_APPLICATION_MEDIA_OVERLAY,
|
||||
"mChildAppWindowBelow");
|
||||
}
|
||||
|
||||
mDisplayContent.getInsetsPolicy().setRemoteInsetsControllerControlsSystemBars(false);
|
||||
|
||||
// Adding a display will cause freezing the display. Make sure to wait until it's
|
||||
// unfrozen to not run into race conditions with the tests.
|
||||
waitUntilHandlersIdle();
|
||||
}
|
||||
|
||||
private WindowManager.LayoutParams getNavBarLayoutParamsForRotation(int rotation) {
|
||||
@@ -876,12 +878,22 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
||||
@interface CommonTypes {
|
||||
}
|
||||
|
||||
/**
|
||||
* The annotation to provide common windows on default display. This is mutually exclusive
|
||||
* with {@link UseTestDisplay}.
|
||||
*/
|
||||
@Target({ ElementType.METHOD, ElementType.TYPE })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface SetupWindows {
|
||||
boolean addAllCommonWindows() default false;
|
||||
@CommonTypes int[] addWindows() default {};
|
||||
}
|
||||
|
||||
/**
|
||||
* The annotation for class and method (higher priority) to create a non-default display that
|
||||
* will be assigned to {@link #mDisplayContent}. It is used if the test needs
|
||||
* <ul>
|
||||
* <li>Pure empty display.</li>
|
||||
* <li>Configured common windows.</li>
|
||||
* <li>Independent and customizable orientation.</li>
|
||||
* <li>Cross display operation.</li>
|
||||
* </ul>
|
||||
@@ -896,6 +908,12 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
||||
@CommonTypes int[] addWindows() default {};
|
||||
}
|
||||
|
||||
static <T extends Annotation> T getAnnotation(Description desc, Class<T> type) {
|
||||
final T annotation = desc.getAnnotation(type);
|
||||
if (annotation != null) return annotation;
|
||||
return desc.getTestClass().getAnnotation(type);
|
||||
}
|
||||
|
||||
/** Creates and adds a {@link TestDisplayContent} to supervisor at the given position. */
|
||||
TestDisplayContent addNewDisplayContentAt(int position) {
|
||||
return new TestDisplayContent.Builder(mAtm, 1000, 1500).setPosition(position).build();
|
||||
|
||||
@@ -258,7 +258,7 @@ public class WindowTokenTests extends WindowTestsBase {
|
||||
* states for its children windows and by default it shouldn't let IME window setting
|
||||
* the frozen insets state even the window of the window token is the IME layering target.
|
||||
*/
|
||||
@UseTestDisplay(addWindows = W_INPUT_METHOD)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testSetInsetsFrozen_notAffectImeWindowState() {
|
||||
// Pre-condition: make the IME window be controlled by IME insets provider.
|
||||
|
||||
Reference in New Issue
Block a user