Fixed monkey test failure
Avoid duplicate attempt to remove WindowToken from its parent
container when removeImmediately is called by first removing the
token from the display before calling super.removeImmediately
which only tries to remove the child from the parent container
if it is still attached to the parent.
Also, added test for the failure case the monkey test was
triggering.
Bug: 32239922
Test: WindowTokenTests.testChildRemoval passes
Change-Id: I4153669d18260d956c4b570944d2f48516d692ac
diff --git a/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java b/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java
index fee4783..03cbb43 100644
--- a/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java
+++ b/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java
@@ -17,6 +17,7 @@
package com.android.server.wm;
import com.android.internal.policy.IShortcutService;
+import com.android.server.input.InputManagerService;
import android.content.Context;
import android.content.res.CompatibilityInfo;
@@ -79,7 +80,9 @@
import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
-public class TestWindowManagerPolicy implements WindowManagerPolicy {
+import static org.mockito.Mockito.mock;
+
+class TestWindowManagerPolicy implements WindowManagerPolicy {
private static final String TAG = "TestWindowManagerPolicy";
private static WindowManagerService sWm = null;
@@ -88,8 +91,8 @@
if (sWm == null) {
// We only want to do this once for the test process as we don't want WM to try to
// register a bunch of local services again.
- sWm = WindowManagerService.main(
- context, null, true, false, false, new TestWindowManagerPolicy());
+ sWm = WindowManagerService.main(context, mock(InputManagerService.class), true, false,
+ false, new TestWindowManagerPolicy());
}
return sWm;
}