Merge "Do not remove the default display during tests."
This commit is contained in:
@@ -132,9 +132,10 @@ public class AppWindowTokenTests extends WindowTestsBase {
|
||||
sWm.mDisplayEnabled = true;
|
||||
|
||||
// Create an app window with token on a display.
|
||||
final TaskStack stack = createTaskStackOnDisplay(sDisplayContent);
|
||||
final DisplayContent defaultDisplayContent = sWm.getDefaultDisplayContentLocked();
|
||||
final TaskStack stack = createTaskStackOnDisplay(defaultDisplayContent);
|
||||
final Task task = createTaskInStack(stack, 0 /* userId */);
|
||||
final TestAppWindowToken appWindowToken = new TestAppWindowToken(sDisplayContent);
|
||||
final TestAppWindowToken appWindowToken = new TestAppWindowToken(defaultDisplayContent);
|
||||
task.addChild(appWindowToken, 0);
|
||||
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(
|
||||
TYPE_BASE_APPLICATION);
|
||||
|
||||
@@ -73,8 +73,8 @@ class WindowTestsBase {
|
||||
private final static Session sMockSession = mock(Session.class);
|
||||
// The default display is removed in {@link #setUp} and then we iterate over all displays to
|
||||
// make sure we don't collide with any existing display. If we run into no other display, the
|
||||
// added display should be treated as default.
|
||||
private static int sNextDisplayId = Display.DEFAULT_DISPLAY;
|
||||
// added display should be treated as default. This cannot be the default display
|
||||
private static int sNextDisplayId = Display.DEFAULT_DISPLAY + 1;
|
||||
static int sNextStackId = FIRST_DYNAMIC_STACK_ID;
|
||||
private static int sNextTaskId = 0;
|
||||
|
||||
@@ -105,17 +105,23 @@ class WindowTestsBase {
|
||||
sWm = TestWindowManagerPolicy.getWindowManagerService(context);
|
||||
sPolicy = (TestWindowManagerPolicy) sWm.mPolicy;
|
||||
sLayersController = new WindowLayersController(sWm);
|
||||
sDisplayContent = sWm.mRoot.getDisplayContent(context.getDisplay().getDisplayId());
|
||||
if (sDisplayContent != null) {
|
||||
sDisplayContent.removeImmediately();
|
||||
}
|
||||
|
||||
// Make sure that display ids don't overlap, so there won't be several displays with same
|
||||
// ids among RootWindowContainer children.
|
||||
for (DisplayContent dc : sWm.mRoot.mChildren) {
|
||||
if (dc.getDisplayId() >= sNextDisplayId) {
|
||||
sNextDisplayId = dc.getDisplayId() + 1;
|
||||
}
|
||||
|
||||
// The default display must be preserved as some tests require it to function
|
||||
// (such as policy rotation).
|
||||
if (dc.getDisplayId() != Display.DEFAULT_DISPLAY) {
|
||||
// It is safe to remove these displays as new displays will always be created with
|
||||
// new ids.
|
||||
dc.removeImmediately();
|
||||
}
|
||||
}
|
||||
|
||||
context.getDisplay().getDisplayInfo(sDisplayInfo);
|
||||
sDisplayContent = createNewDisplay();
|
||||
sWm.mDisplayEnabled = true;
|
||||
|
||||
Reference in New Issue
Block a user