Per-test WindowManagerService instance
This CL starts using a WindowManagerService instance for each test method,
instead of sharing a single instance within a test class. It also starts
resetting mocks after each test method. With a MockTrack hack, it reduces
memory leaks happening in extended inline Mockito (b/123984854).
Bug: 123652272
Test: Pass all non-flaky presubmit tests in WmTests.
$ tradefed.sh run commandAndExit WmTests \
--include-annotation android.platform.test.annotations.Presubmit \
--exclude-annotation androidx.test.filters.FlakyTest
Change-Id: Icbfd5c5d726e4c29a623682deac852c5b14667dd
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskPositioningControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskPositioningControllerTests.java
index 1e58e41..1b396f5 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskPositioningControllerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskPositioningControllerTests.java
@@ -18,6 +18,8 @@
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyInt;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.when;
@@ -26,7 +28,6 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.anyInt;
import android.platform.test.annotations.Presubmit;
import android.view.InputChannel;
@@ -63,8 +64,7 @@
}
spyOn(mDisplayContent);
- InputMonitor inputMonitor = mock(InputMonitor.class);
- when(mDisplayContent.getInputMonitor()).thenReturn(inputMonitor);
+ doReturn(mock(InputMonitor.class)).when(mDisplayContent).getInputMonitor();
}
@Test