Merge "Synchronize all WindowTestsBase and WindowTestUtils methods." into pi-dev
am: 5f6980af6e
Change-Id: I9f04085a6050e5df822ee3e64c1682d6fff064cc
This commit is contained in:
@@ -61,7 +61,7 @@ public class AppWindowTokenTests extends WindowTestsBase {
|
|||||||
|
|
||||||
mStack = createTaskStackOnDisplay(mDisplayContent);
|
mStack = createTaskStackOnDisplay(mDisplayContent);
|
||||||
mTask = createTaskInStack(mStack, 0 /* userId */);
|
mTask = createTaskInStack(mStack, 0 /* userId */);
|
||||||
mToken = new WindowTestUtils.TestAppWindowToken(mDisplayContent);
|
mToken = WindowTestUtils.createTestAppWindowToken(mDisplayContent);
|
||||||
|
|
||||||
mTask.addChild(mToken, 0);
|
mTask.addChild(mToken, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,7 +193,8 @@ public class DisplayContentTests extends WindowTestsBase {
|
|||||||
assertEquals(dc, stack.getDisplayContent());
|
assertEquals(dc, stack.getDisplayContent());
|
||||||
|
|
||||||
final Task task = createTaskInStack(stack, 0 /* userId */);
|
final Task task = createTaskInStack(stack, 0 /* userId */);
|
||||||
final WindowTestUtils.TestAppWindowToken token = new WindowTestUtils.TestAppWindowToken(dc);
|
final WindowTestUtils.TestAppWindowToken token = WindowTestUtils.createTestAppWindowToken(
|
||||||
|
dc);
|
||||||
task.addChild(token, 0);
|
task.addChild(token, 0);
|
||||||
assertEquals(dc, task.getDisplayContent());
|
assertEquals(dc, task.getDisplayContent());
|
||||||
assertEquals(dc, token.getDisplayContent());
|
assertEquals(dc, token.getDisplayContent());
|
||||||
@@ -265,14 +266,14 @@ public class DisplayContentTests extends WindowTestsBase {
|
|||||||
final TaskStack stack0 = createTaskStackOnDisplay(dc0);
|
final TaskStack stack0 = createTaskStackOnDisplay(dc0);
|
||||||
final Task task0 = createTaskInStack(stack0, 0 /* userId */);
|
final Task task0 = createTaskInStack(stack0, 0 /* userId */);
|
||||||
final WindowTestUtils.TestAppWindowToken token =
|
final WindowTestUtils.TestAppWindowToken token =
|
||||||
new WindowTestUtils.TestAppWindowToken(dc0);
|
WindowTestUtils.createTestAppWindowToken(dc0);
|
||||||
task0.addChild(token, 0);
|
task0.addChild(token, 0);
|
||||||
dc0.mTapDetector = new TaskTapPointerEventListener(sWm, dc0);
|
dc0.mTapDetector = new TaskTapPointerEventListener(sWm, dc0);
|
||||||
sWm.registerPointerEventListener(dc0.mTapDetector);
|
sWm.registerPointerEventListener(dc0.mTapDetector);
|
||||||
final TaskStack stack1 = createTaskStackOnDisplay(dc1);
|
final TaskStack stack1 = createTaskStackOnDisplay(dc1);
|
||||||
final Task task1 = createTaskInStack(stack1, 0 /* userId */);
|
final Task task1 = createTaskInStack(stack1, 0 /* userId */);
|
||||||
final WindowTestUtils.TestAppWindowToken token1 =
|
final WindowTestUtils.TestAppWindowToken token1 =
|
||||||
new WindowTestUtils.TestAppWindowToken(dc0);
|
WindowTestUtils.createTestAppWindowToken(dc0);
|
||||||
task1.addChild(token1, 0);
|
task1.addChild(token1, 0);
|
||||||
dc1.mTapDetector = new TaskTapPointerEventListener(sWm, dc0);
|
dc1.mTapDetector = new TaskTapPointerEventListener(sWm, dc0);
|
||||||
sWm.registerPointerEventListener(dc1.mTapDetector);
|
sWm.registerPointerEventListener(dc1.mTapDetector);
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class DragDropControllerTests extends WindowTestsBase {
|
|||||||
* Creates a window state which can be used as a drop target.
|
* Creates a window state which can be used as a drop target.
|
||||||
*/
|
*/
|
||||||
private WindowState createDropTargetWindow(String name, int ownerId) {
|
private WindowState createDropTargetWindow(String name, int ownerId) {
|
||||||
final WindowTestUtils.TestAppWindowToken token = new WindowTestUtils.TestAppWindowToken(
|
final WindowTestUtils.TestAppWindowToken token = WindowTestUtils.createTestAppWindowToken(
|
||||||
mDisplayContent);
|
mDisplayContent);
|
||||||
final TaskStack stack = createStackControllerOnStackOnDisplay(
|
final TaskStack stack = createStackControllerOnStackOnDisplay(
|
||||||
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, mDisplayContent).mContainer;
|
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, mDisplayContent).mContainer;
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ public class TaskStackContainersTests extends WindowTestsBase {
|
|||||||
// Stack should contain visible app window to be considered visible.
|
// Stack should contain visible app window to be considered visible.
|
||||||
final Task pinnedTask = createTaskInStack(mPinnedStack, 0 /* userId */);
|
final Task pinnedTask = createTaskInStack(mPinnedStack, 0 /* userId */);
|
||||||
assertFalse(mPinnedStack.isVisible());
|
assertFalse(mPinnedStack.isVisible());
|
||||||
final WindowTestUtils.TestAppWindowToken pinnedApp = new WindowTestUtils.TestAppWindowToken(
|
final WindowTestUtils.TestAppWindowToken pinnedApp =
|
||||||
mDisplayContent);
|
WindowTestUtils.createTestAppWindowToken(mDisplayContent);
|
||||||
pinnedTask.addChild(pinnedApp, 0 /* addPos */);
|
pinnedTask.addChild(pinnedApp, 0 /* addPos */);
|
||||||
assertTrue(mPinnedStack.isVisible());
|
assertTrue(mPinnedStack.isVisible());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,13 +65,13 @@ public class TaskStackTests extends WindowTestsBase {
|
|||||||
final TaskStack stack = createTaskStackOnDisplay(mDisplayContent);
|
final TaskStack stack = createTaskStackOnDisplay(mDisplayContent);
|
||||||
final Task task1 = createTaskInStack(stack, 0 /* userId */);
|
final Task task1 = createTaskInStack(stack, 0 /* userId */);
|
||||||
WindowTestUtils.TestAppWindowToken appWindowToken1 =
|
WindowTestUtils.TestAppWindowToken appWindowToken1 =
|
||||||
new WindowTestUtils.TestAppWindowToken(mDisplayContent);
|
WindowTestUtils.createTestAppWindowToken(mDisplayContent);
|
||||||
task1.addChild(appWindowToken1, 0);
|
task1.addChild(appWindowToken1, 0);
|
||||||
appWindowToken1.setOrientation(SCREEN_ORIENTATION_LANDSCAPE);
|
appWindowToken1.setOrientation(SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
|
|
||||||
final Task task2 = createTaskInStack(stack, 1 /* userId */);
|
final Task task2 = createTaskInStack(stack, 1 /* userId */);
|
||||||
WindowTestUtils.TestAppWindowToken appWindowToken2 =
|
WindowTestUtils.TestAppWindowToken appWindowToken2 =
|
||||||
new WindowTestUtils.TestAppWindowToken(mDisplayContent);
|
WindowTestUtils.createTestAppWindowToken(mDisplayContent);
|
||||||
task2.addChild(appWindowToken2, 0);
|
task2.addChild(appWindowToken2, 0);
|
||||||
appWindowToken2.setOrientation(SCREEN_ORIENTATION_PORTRAIT);
|
appWindowToken2.setOrientation(SCREEN_ORIENTATION_PORTRAIT);
|
||||||
|
|
||||||
@@ -85,13 +85,13 @@ public class TaskStackTests extends WindowTestsBase {
|
|||||||
final TaskStack stack = createTaskStackOnDisplay(mDisplayContent);
|
final TaskStack stack = createTaskStackOnDisplay(mDisplayContent);
|
||||||
final Task task1 = createTaskInStack(stack, 0 /* userId */);
|
final Task task1 = createTaskInStack(stack, 0 /* userId */);
|
||||||
WindowTestUtils.TestAppWindowToken appWindowToken1 =
|
WindowTestUtils.TestAppWindowToken appWindowToken1 =
|
||||||
new WindowTestUtils.TestAppWindowToken(mDisplayContent);
|
WindowTestUtils.createTestAppWindowToken(mDisplayContent);
|
||||||
task1.addChild(appWindowToken1, 0);
|
task1.addChild(appWindowToken1, 0);
|
||||||
appWindowToken1.setOrientation(SCREEN_ORIENTATION_LANDSCAPE);
|
appWindowToken1.setOrientation(SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
|
|
||||||
final Task task2 = createTaskInStack(stack, 1 /* userId */);
|
final Task task2 = createTaskInStack(stack, 1 /* userId */);
|
||||||
WindowTestUtils.TestAppWindowToken appWindowToken2 =
|
WindowTestUtils.TestAppWindowToken appWindowToken2 =
|
||||||
new WindowTestUtils.TestAppWindowToken(mDisplayContent);
|
WindowTestUtils.createTestAppWindowToken(mDisplayContent);
|
||||||
task2.addChild(appWindowToken2, 0);
|
task2.addChild(appWindowToken2, 0);
|
||||||
appWindowToken2.setOrientation(SCREEN_ORIENTATION_PORTRAIT);
|
appWindowToken2.setOrientation(SCREEN_ORIENTATION_PORTRAIT);
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class UnknownAppVisibilityControllerTest extends WindowTestsBase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFlow() throws Exception {
|
public void testFlow() throws Exception {
|
||||||
final AppWindowToken token = new WindowTestUtils.TestAppWindowToken(mDisplayContent);
|
final AppWindowToken token = WindowTestUtils.createTestAppWindowToken(mDisplayContent);
|
||||||
sWm.mUnknownAppVisibilityController.notifyLaunched(token);
|
sWm.mUnknownAppVisibilityController.notifyLaunched(token);
|
||||||
sWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token);
|
sWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token);
|
||||||
sWm.mUnknownAppVisibilityController.notifyRelayouted(token);
|
sWm.mUnknownAppVisibilityController.notifyRelayouted(token);
|
||||||
@@ -56,8 +56,8 @@ public class UnknownAppVisibilityControllerTest extends WindowTestsBase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultiple() throws Exception {
|
public void testMultiple() throws Exception {
|
||||||
final AppWindowToken token1 = new WindowTestUtils.TestAppWindowToken(mDisplayContent);
|
final AppWindowToken token1 = WindowTestUtils.createTestAppWindowToken(mDisplayContent);
|
||||||
final AppWindowToken token2 = new WindowTestUtils.TestAppWindowToken(mDisplayContent);
|
final AppWindowToken token2 = WindowTestUtils.createTestAppWindowToken(mDisplayContent);
|
||||||
sWm.mUnknownAppVisibilityController.notifyLaunched(token1);
|
sWm.mUnknownAppVisibilityController.notifyLaunched(token1);
|
||||||
sWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token1);
|
sWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token1);
|
||||||
sWm.mUnknownAppVisibilityController.notifyLaunched(token2);
|
sWm.mUnknownAppVisibilityController.notifyLaunched(token2);
|
||||||
@@ -72,7 +72,7 @@ public class UnknownAppVisibilityControllerTest extends WindowTestsBase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClear() throws Exception {
|
public void testClear() throws Exception {
|
||||||
final AppWindowToken token = new WindowTestUtils.TestAppWindowToken(mDisplayContent);
|
final AppWindowToken token = WindowTestUtils.createTestAppWindowToken(mDisplayContent);
|
||||||
sWm.mUnknownAppVisibilityController.notifyLaunched(token);
|
sWm.mUnknownAppVisibilityController.notifyLaunched(token);
|
||||||
sWm.mUnknownAppVisibilityController.clear();;
|
sWm.mUnknownAppVisibilityController.clear();;
|
||||||
assertTrue(sWm.mUnknownAppVisibilityController.allResolved());
|
assertTrue(sWm.mUnknownAppVisibilityController.allResolved());
|
||||||
@@ -80,7 +80,7 @@ public class UnknownAppVisibilityControllerTest extends WindowTestsBase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAppRemoved() throws Exception {
|
public void testAppRemoved() throws Exception {
|
||||||
final AppWindowToken token = new WindowTestUtils.TestAppWindowToken(mDisplayContent);
|
final AppWindowToken token = WindowTestUtils.createTestAppWindowToken(mDisplayContent);
|
||||||
sWm.mUnknownAppVisibilityController.notifyLaunched(token);
|
sWm.mUnknownAppVisibilityController.notifyLaunched(token);
|
||||||
sWm.mUnknownAppVisibilityController.appRemovedOrHidden(token);
|
sWm.mUnknownAppVisibilityController.appRemovedOrHidden(token);
|
||||||
assertTrue(sWm.mUnknownAppVisibilityController.allResolved());
|
assertTrue(sWm.mUnknownAppVisibilityController.allResolved());
|
||||||
|
|||||||
@@ -114,7 +114,8 @@ public class WindowFrameTests extends WindowTestsBase {
|
|||||||
// Just any non zero value.
|
// Just any non zero value.
|
||||||
sWm.mSystemDecorLayer = 10000;
|
sWm.mSystemDecorLayer = 10000;
|
||||||
|
|
||||||
mWindowToken = new WindowTestUtils.TestAppWindowToken(sWm.getDefaultDisplayContentLocked());
|
mWindowToken = WindowTestUtils.createTestAppWindowToken(
|
||||||
|
sWm.getDefaultDisplayContentLocked());
|
||||||
mStubStack = new TaskStack(sWm, 0, null);
|
mStubStack = new TaskStack(sWm, 0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ public class WindowStateTests extends WindowTestsBase {
|
|||||||
|
|
||||||
// Call prepareWindowToDisplayDuringRelayout for a windows that are not children of an
|
// Call prepareWindowToDisplayDuringRelayout for a windows that are not children of an
|
||||||
// appWindowToken. Both windows have the FLAG_TURNS_SCREEN_ON so both should call wakeup
|
// appWindowToken. Both windows have the FLAG_TURNS_SCREEN_ON so both should call wakeup
|
||||||
final WindowToken windowToken = new WindowTestUtils.TestWindowToken(FIRST_SUB_WINDOW,
|
final WindowToken windowToken = WindowTestUtils.createTestWindowToken(FIRST_SUB_WINDOW,
|
||||||
mDisplayContent);
|
mDisplayContent);
|
||||||
final WindowState firstWindow = createWindow(null, TYPE_APPLICATION, windowToken,
|
final WindowState firstWindow = createWindow(null, TYPE_APPLICATION, windowToken,
|
||||||
"firstWindow");
|
"firstWindow");
|
||||||
|
|||||||
@@ -87,10 +87,12 @@ public class WindowTestUtils {
|
|||||||
/** Creates a {@link Task} and adds it to the specified {@link TaskStack}. */
|
/** Creates a {@link Task} and adds it to the specified {@link TaskStack}. */
|
||||||
public static Task createTaskInStack(WindowManagerService service, TaskStack stack,
|
public static Task createTaskInStack(WindowManagerService service, TaskStack stack,
|
||||||
int userId) {
|
int userId) {
|
||||||
final Task newTask = new Task(sNextTaskId++, stack, userId, service, 0, false,
|
synchronized (service.mWindowMap) {
|
||||||
new ActivityManager.TaskDescription(), null);
|
final Task newTask = new Task(sNextTaskId++, stack, userId, service, 0, false,
|
||||||
stack.addTask(newTask, POSITION_TOP);
|
new ActivityManager.TaskDescription(), null);
|
||||||
return newTask;
|
stack.addTask(newTask, POSITION_TOP);
|
||||||
|
return newTask;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,11 +110,17 @@ public class WindowTestUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static TestAppWindowToken createTestAppWindowToken(DisplayContent dc) {
|
||||||
|
synchronized (dc.mService.mWindowMap) {
|
||||||
|
return new TestAppWindowToken(dc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Used so we can gain access to some protected members of the {@link AppWindowToken} class. */
|
/** Used so we can gain access to some protected members of the {@link AppWindowToken} class. */
|
||||||
public static class TestAppWindowToken extends AppWindowToken {
|
public static class TestAppWindowToken extends AppWindowToken {
|
||||||
boolean mOnTop = false;
|
boolean mOnTop = false;
|
||||||
|
|
||||||
TestAppWindowToken(DisplayContent dc) {
|
private TestAppWindowToken(DisplayContent dc) {
|
||||||
super(dc.mService, new IApplicationToken.Stub() {
|
super(dc.mService, new IApplicationToken.Stub() {
|
||||||
public String getName() {return null;}
|
public String getName() {return null;}
|
||||||
}, false, dc, true /* fillsParent */);
|
}, false, dc, true /* fillsParent */);
|
||||||
@@ -158,14 +166,21 @@ public class WindowTestUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static TestWindowToken createTestWindowToken(int type, DisplayContent dc) {
|
||||||
|
return createTestWindowToken(type, dc, false /* persistOnEmpty */);
|
||||||
|
}
|
||||||
|
|
||||||
|
static TestWindowToken createTestWindowToken(int type, DisplayContent dc,
|
||||||
|
boolean persistOnEmpty) {
|
||||||
|
synchronized (dc.mService.mWindowMap) {
|
||||||
|
return new TestWindowToken(type, dc, persistOnEmpty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Used so we can gain access to some protected members of the {@link WindowToken} class */
|
/* Used so we can gain access to some protected members of the {@link WindowToken} class */
|
||||||
public static class TestWindowToken extends WindowToken {
|
public static class TestWindowToken extends WindowToken {
|
||||||
|
|
||||||
TestWindowToken(int type, DisplayContent dc) {
|
private TestWindowToken(int type, DisplayContent dc, boolean persistOnEmpty) {
|
||||||
this(type, dc, false /* persistOnEmpty */);
|
|
||||||
}
|
|
||||||
|
|
||||||
TestWindowToken(int type, DisplayContent dc, boolean persistOnEmpty) {
|
|
||||||
super(dc.mService, mock(IBinder.class), type, persistOnEmpty, dc,
|
super(dc.mService, mock(IBinder.class), type, persistOnEmpty, dc,
|
||||||
false /* ownerCanManageAppTokens */);
|
false /* ownerCanManageAppTokens */);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ import java.util.LinkedList;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Common base class for window manager unit test classes.
|
* Common base class for window manager unit test classes.
|
||||||
|
*
|
||||||
|
* Make sure any requests to WM hold the WM lock if needed b/73966377
|
||||||
*/
|
*/
|
||||||
class WindowTestsBase {
|
class WindowTestsBase {
|
||||||
private static final String TAG = WindowTestsBase.class.getSimpleName();
|
private static final String TAG = WindowTestsBase.class.getSimpleName();
|
||||||
@@ -120,21 +122,24 @@ class WindowTestsBase {
|
|||||||
|
|
||||||
// Set-up some common windows.
|
// Set-up some common windows.
|
||||||
mCommonWindows = new HashSet();
|
mCommonWindows = new HashSet();
|
||||||
mWallpaperWindow = createCommonWindow(null, TYPE_WALLPAPER, "wallpaperWindow");
|
synchronized (sWm.mWindowMap) {
|
||||||
mImeWindow = createCommonWindow(null, TYPE_INPUT_METHOD, "mImeWindow");
|
mWallpaperWindow = createCommonWindow(null, TYPE_WALLPAPER, "wallpaperWindow");
|
||||||
sWm.mInputMethodWindow = mImeWindow;
|
mImeWindow = createCommonWindow(null, TYPE_INPUT_METHOD, "mImeWindow");
|
||||||
mImeDialogWindow = createCommonWindow(null, TYPE_INPUT_METHOD_DIALOG,
|
sWm.mInputMethodWindow = mImeWindow;
|
||||||
"mImeDialogWindow");
|
mImeDialogWindow = createCommonWindow(null, TYPE_INPUT_METHOD_DIALOG,
|
||||||
mStatusBarWindow = createCommonWindow(null, TYPE_STATUS_BAR, "mStatusBarWindow");
|
"mImeDialogWindow");
|
||||||
mNavBarWindow = createCommonWindow(null, TYPE_NAVIGATION_BAR, "mNavBarWindow");
|
mStatusBarWindow = createCommonWindow(null, TYPE_STATUS_BAR, "mStatusBarWindow");
|
||||||
mDockedDividerWindow = createCommonWindow(null, TYPE_DOCK_DIVIDER,
|
mNavBarWindow = createCommonWindow(null, TYPE_NAVIGATION_BAR, "mNavBarWindow");
|
||||||
"mDockedDividerWindow");
|
mDockedDividerWindow = createCommonWindow(null, TYPE_DOCK_DIVIDER,
|
||||||
mAppWindow = createCommonWindow(null, TYPE_BASE_APPLICATION, "mAppWindow");
|
"mDockedDividerWindow");
|
||||||
mChildAppWindowAbove = createCommonWindow(mAppWindow, TYPE_APPLICATION_ATTACHED_DIALOG,
|
mAppWindow = createCommonWindow(null, TYPE_BASE_APPLICATION, "mAppWindow");
|
||||||
"mChildAppWindowAbove");
|
mChildAppWindowAbove = createCommonWindow(mAppWindow,
|
||||||
mChildAppWindowBelow = createCommonWindow(mAppWindow, TYPE_APPLICATION_MEDIA_OVERLAY,
|
TYPE_APPLICATION_ATTACHED_DIALOG,
|
||||||
"mChildAppWindowBelow");
|
"mChildAppWindowAbove");
|
||||||
|
mChildAppWindowBelow = createCommonWindow(mAppWindow,
|
||||||
|
TYPE_APPLICATION_MEDIA_OVERLAY,
|
||||||
|
"mChildAppWindowBelow");
|
||||||
|
}
|
||||||
// Adding a display will cause freezing the display. Make sure to wait until it's
|
// 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.
|
// unfrozen to not run into race conditions with the tests.
|
||||||
waitUntilHandlersIdle();
|
waitUntilHandlersIdle();
|
||||||
@@ -187,11 +192,13 @@ class WindowTestsBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private WindowState createCommonWindow(WindowState parent, int type, String name) {
|
private WindowState createCommonWindow(WindowState parent, int type, String name) {
|
||||||
final WindowState win = createWindow(parent, type, name);
|
synchronized (sWm.mWindowMap) {
|
||||||
mCommonWindows.add(win);
|
final WindowState win = createWindow(parent, type, name);
|
||||||
// Prevent common windows from been IMe targets
|
mCommonWindows.add(win);
|
||||||
win.mAttrs.flags |= FLAG_NOT_FOCUSABLE;
|
// Prevent common windows from been IMe targets
|
||||||
return win;
|
win.mAttrs.flags |= FLAG_NOT_FOCUSABLE;
|
||||||
|
return win;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Asserts that the first entry is greater than the second entry. */
|
/** Asserts that the first entry is greater than the second entry. */
|
||||||
@@ -215,11 +222,13 @@ class WindowTestsBase {
|
|||||||
|
|
||||||
private WindowToken createWindowToken(
|
private WindowToken createWindowToken(
|
||||||
DisplayContent dc, int windowingMode, int activityType, int type) {
|
DisplayContent dc, int windowingMode, int activityType, int type) {
|
||||||
if (type < FIRST_APPLICATION_WINDOW || type > LAST_APPLICATION_WINDOW) {
|
synchronized (sWm.mWindowMap) {
|
||||||
return new WindowTestUtils.TestWindowToken(type, dc);
|
if (type < FIRST_APPLICATION_WINDOW || type > LAST_APPLICATION_WINDOW) {
|
||||||
}
|
return WindowTestUtils.createTestWindowToken(type, dc);
|
||||||
|
}
|
||||||
|
|
||||||
return createAppWindowToken(dc, windowingMode, activityType);
|
return createAppWindowToken(dc, windowingMode, activityType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AppWindowToken createAppWindowToken(DisplayContent dc, int windowingMode, int activityType) {
|
AppWindowToken createAppWindowToken(DisplayContent dc, int windowingMode, int activityType) {
|
||||||
@@ -227,81 +236,103 @@ class WindowTestsBase {
|
|||||||
dc).mContainer;
|
dc).mContainer;
|
||||||
final Task task = createTaskInStack(stack, 0 /* userId */);
|
final Task task = createTaskInStack(stack, 0 /* userId */);
|
||||||
final WindowTestUtils.TestAppWindowToken appWindowToken =
|
final WindowTestUtils.TestAppWindowToken appWindowToken =
|
||||||
new WindowTestUtils.TestAppWindowToken(mDisplayContent);
|
WindowTestUtils.createTestAppWindowToken(dc);
|
||||||
task.addChild(appWindowToken, 0);
|
task.addChild(appWindowToken, 0);
|
||||||
return appWindowToken;
|
return appWindowToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowState createWindow(WindowState parent, int type, String name) {
|
WindowState createWindow(WindowState parent, int type, String name) {
|
||||||
return (parent == null)
|
synchronized (sWm.mWindowMap) {
|
||||||
? createWindow(parent, type, mDisplayContent, name)
|
return (parent == null)
|
||||||
: createWindow(parent, type, parent.mToken, name);
|
? createWindow(parent, type, mDisplayContent, name)
|
||||||
|
: createWindow(parent, type, parent.mToken, name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowState createWindowOnStack(WindowState parent, int windowingMode, int activityType,
|
WindowState createWindowOnStack(WindowState parent, int windowingMode, int activityType,
|
||||||
int type, DisplayContent dc, String name) {
|
int type, DisplayContent dc, String name) {
|
||||||
final WindowToken token = createWindowToken(dc, windowingMode, activityType, type);
|
synchronized (sWm.mWindowMap) {
|
||||||
return createWindow(parent, type, token, name);
|
final WindowToken token = createWindowToken(dc, windowingMode, activityType, type);
|
||||||
|
return createWindow(parent, type, token, name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowState createAppWindow(Task task, int type, String name) {
|
WindowState createAppWindow(Task task, int type, String name) {
|
||||||
final AppWindowToken token = new WindowTestUtils.TestAppWindowToken(mDisplayContent);
|
synchronized (sWm.mWindowMap) {
|
||||||
task.addChild(token, 0);
|
final AppWindowToken token = WindowTestUtils.createTestAppWindowToken(mDisplayContent);
|
||||||
return createWindow(null, type, token, name);
|
task.addChild(token, 0);
|
||||||
|
return createWindow(null, type, token, name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowState createWindow(WindowState parent, int type, DisplayContent dc, String name) {
|
WindowState createWindow(WindowState parent, int type, DisplayContent dc, String name) {
|
||||||
final WindowToken token = createWindowToken(
|
synchronized (sWm.mWindowMap) {
|
||||||
dc, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, type);
|
final WindowToken token = createWindowToken(
|
||||||
return createWindow(parent, type, token, name);
|
dc, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, type);
|
||||||
|
return createWindow(parent, type, token, name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowState createWindow(WindowState parent, int type, DisplayContent dc, String name,
|
WindowState createWindow(WindowState parent, int type, DisplayContent dc, String name,
|
||||||
boolean ownerCanAddInternalSystemWindow) {
|
boolean ownerCanAddInternalSystemWindow) {
|
||||||
final WindowToken token = createWindowToken(
|
synchronized (sWm.mWindowMap) {
|
||||||
dc, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, type);
|
final WindowToken token = createWindowToken(
|
||||||
return createWindow(parent, type, token, name, 0 /* ownerId */,
|
dc, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, type);
|
||||||
ownerCanAddInternalSystemWindow);
|
return createWindow(parent, type, token, name, 0 /* ownerId */,
|
||||||
|
ownerCanAddInternalSystemWindow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static WindowState createWindow(WindowState parent, int type, WindowToken token, String name) {
|
static WindowState createWindow(WindowState parent, int type, WindowToken token, String name) {
|
||||||
return createWindow(parent, type, token, name, 0 /* ownerId */,
|
synchronized (sWm.mWindowMap) {
|
||||||
false /* ownerCanAddInternalSystemWindow */);
|
return createWindow(parent, type, token, name, 0 /* ownerId */,
|
||||||
|
false /* ownerCanAddInternalSystemWindow */);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static WindowState createWindow(WindowState parent, int type, WindowToken token, String name,
|
static WindowState createWindow(WindowState parent, int type, WindowToken token, String name,
|
||||||
int ownerId, boolean ownerCanAddInternalSystemWindow) {
|
int ownerId, boolean ownerCanAddInternalSystemWindow) {
|
||||||
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(type);
|
synchronized (sWm.mWindowMap) {
|
||||||
attrs.setTitle(name);
|
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(type);
|
||||||
|
attrs.setTitle(name);
|
||||||
|
|
||||||
final WindowState w = new WindowState(sWm, sMockSession, sIWindow, token, parent, OP_NONE,
|
final WindowState w = new WindowState(sWm, sMockSession, sIWindow, token, parent,
|
||||||
0, attrs, VISIBLE, ownerId, ownerCanAddInternalSystemWindow, mPowerManagerWrapper);
|
OP_NONE,
|
||||||
// TODO: Probably better to make this call in the WindowState ctor to avoid errors with
|
0, attrs, VISIBLE, ownerId, ownerCanAddInternalSystemWindow,
|
||||||
// adding it to the token...
|
mPowerManagerWrapper);
|
||||||
token.addWindow(w);
|
// TODO: Probably better to make this call in the WindowState ctor to avoid errors with
|
||||||
return w;
|
// adding it to the token...
|
||||||
|
token.addWindow(w);
|
||||||
|
return w;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates a {@link TaskStack} and adds it to the specified {@link DisplayContent}. */
|
/** Creates a {@link TaskStack} and adds it to the specified {@link DisplayContent}. */
|
||||||
TaskStack createTaskStackOnDisplay(DisplayContent dc) {
|
TaskStack createTaskStackOnDisplay(DisplayContent dc) {
|
||||||
return createStackControllerOnDisplay(dc).mContainer;
|
synchronized (sWm.mWindowMap) {
|
||||||
|
return createStackControllerOnDisplay(dc).mContainer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StackWindowController createStackControllerOnDisplay(DisplayContent dc) {
|
StackWindowController createStackControllerOnDisplay(DisplayContent dc) {
|
||||||
return createStackControllerOnStackOnDisplay(
|
synchronized (sWm.mWindowMap) {
|
||||||
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, dc);
|
return createStackControllerOnStackOnDisplay(
|
||||||
|
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, dc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StackWindowController createStackControllerOnStackOnDisplay(
|
StackWindowController createStackControllerOnStackOnDisplay(
|
||||||
int windowingMode, int activityType, DisplayContent dc) {
|
int windowingMode, int activityType, DisplayContent dc) {
|
||||||
final Configuration overrideConfig = new Configuration();
|
synchronized (sWm.mWindowMap) {
|
||||||
overrideConfig.windowConfiguration.setWindowingMode(windowingMode);
|
final Configuration overrideConfig = new Configuration();
|
||||||
overrideConfig.windowConfiguration.setActivityType(activityType);
|
overrideConfig.windowConfiguration.setWindowingMode(windowingMode);
|
||||||
final int stackId = ++sNextStackId;
|
overrideConfig.windowConfiguration.setActivityType(activityType);
|
||||||
final StackWindowController controller = new StackWindowController(stackId, null,
|
final int stackId = ++sNextStackId;
|
||||||
dc.getDisplayId(), true /* onTop */, new Rect(), sWm);
|
final StackWindowController controller = new StackWindowController(stackId, null,
|
||||||
controller.onOverrideConfigurationChanged(overrideConfig);
|
dc.getDisplayId(), true /* onTop */, new Rect(), sWm);
|
||||||
return controller;
|
controller.onOverrideConfigurationChanged(overrideConfig);
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates a {@link Task} and adds it to the specified {@link TaskStack}. */
|
/** Creates a {@link Task} and adds it to the specified {@link TaskStack}. */
|
||||||
@@ -314,14 +345,18 @@ class WindowTestsBase {
|
|||||||
final int displayId = sNextDisplayId++;
|
final int displayId = sNextDisplayId++;
|
||||||
final Display display = new Display(DisplayManagerGlobal.getInstance(), displayId,
|
final Display display = new Display(DisplayManagerGlobal.getInstance(), displayId,
|
||||||
mDisplayInfo, DEFAULT_DISPLAY_ADJUSTMENTS);
|
mDisplayInfo, DEFAULT_DISPLAY_ADJUSTMENTS);
|
||||||
return new DisplayContent(display, sWm, mWallpaperController,
|
synchronized (sWm.mWindowMap) {
|
||||||
mock(DisplayWindowController.class));
|
return new DisplayContent(display, sWm, mWallpaperController,
|
||||||
|
mock(DisplayWindowController.class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates a {@link com.android.server.wm.WindowTestUtils.TestWindowState} */
|
/** Creates a {@link com.android.server.wm.WindowTestUtils.TestWindowState} */
|
||||||
WindowTestUtils.TestWindowState createWindowState(WindowManager.LayoutParams attrs,
|
WindowTestUtils.TestWindowState createWindowState(WindowManager.LayoutParams attrs,
|
||||||
WindowToken token) {
|
WindowToken token) {
|
||||||
return new WindowTestUtils.TestWindowState(sWm, sMockSession, sIWindow, attrs, token);
|
synchronized (sWm.mWindowMap) {
|
||||||
|
return new WindowTestUtils.TestWindowState(sWm, sMockSession, sIWindow, attrs, token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class WindowTokenTests extends WindowTestsBase {
|
|||||||
@Test
|
@Test
|
||||||
public void testAddWindow() throws Exception {
|
public void testAddWindow() throws Exception {
|
||||||
final WindowTestUtils.TestWindowToken token =
|
final WindowTestUtils.TestWindowToken token =
|
||||||
new WindowTestUtils.TestWindowToken(0, mDisplayContent);
|
WindowTestUtils.createTestWindowToken(0, mDisplayContent);
|
||||||
|
|
||||||
assertEquals(0, token.getWindowsCount());
|
assertEquals(0, token.getWindowsCount());
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ public class WindowTokenTests extends WindowTestsBase {
|
|||||||
@Test
|
@Test
|
||||||
public void testChildRemoval() throws Exception {
|
public void testChildRemoval() throws Exception {
|
||||||
final DisplayContent dc = mDisplayContent;
|
final DisplayContent dc = mDisplayContent;
|
||||||
final WindowTestUtils.TestWindowToken token = new WindowTestUtils.TestWindowToken(0, dc);
|
final WindowTestUtils.TestWindowToken token = WindowTestUtils.createTestWindowToken(0, dc);
|
||||||
|
|
||||||
assertEquals(token, dc.getWindowToken(token.token));
|
assertEquals(token, dc.getWindowToken(token.token));
|
||||||
|
|
||||||
@@ -102,9 +102,8 @@ public class WindowTokenTests extends WindowTestsBase {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testTokenRemovalProcess() throws Exception {
|
public void testTokenRemovalProcess() throws Exception {
|
||||||
final WindowTestUtils.TestWindowToken token =
|
final WindowTestUtils.TestWindowToken token = WindowTestUtils.createTestWindowToken(
|
||||||
new WindowTestUtils.TestWindowToken(TYPE_TOAST, mDisplayContent,
|
TYPE_TOAST, mDisplayContent, true /* persistOnEmpty */);
|
||||||
true /* persistOnEmpty */);
|
|
||||||
|
|
||||||
// Verify that the token is on the display
|
// Verify that the token is on the display
|
||||||
assertNotNull(mDisplayContent.getWindowToken(token.token));
|
assertNotNull(mDisplayContent.getWindowToken(token.token));
|
||||||
|
|||||||
Reference in New Issue
Block a user