Merge "Fix AppWindowTokenTests#testLandscapeSeascapeRotationByPolicy"

This commit is contained in:
Bryce Lee
2017-03-16 21:39:16 +00:00
committed by Android (Google) Code Review
2 changed files with 14 additions and 8 deletions

View File

@@ -126,8 +126,6 @@ public class AppWindowTokenTests extends WindowTestsBase {
}
@Test
@Ignore
// TODO(b/35034729): Need to fix before re-enabling
public void testLandscapeSeascapeRotationByPolicy() throws Exception {
// Some plumbing to get the service ready for rotation updates.
sWm.mDisplayReady = true;
@@ -145,15 +143,20 @@ public class AppWindowTokenTests extends WindowTestsBase {
appWindowToken.addWindow(appWindow);
// Set initial orientation and update.
((TestWindowManagerPolicy) sWm.mPolicy).rotationToReport = Surface.ROTATION_90;
sWm.updateRotation(false, false);
performRotation(Surface.ROTATION_90);
appWindow.resizeReported = false;
// Update the rotation to perform 180 degree rotation and check that resize was reported.
((TestWindowManagerPolicy) sWm.mPolicy).rotationToReport = Surface.ROTATION_270;
sWm.updateRotation(false, false);
sWm.mRoot.performSurfacePlacement(false /* recoveringMemory */);
performRotation(Surface.ROTATION_270);
assertTrue(appWindow.resizeReported);
appWindow.removeImmediately();
}
private void performRotation(int rotationToReport) {
((TestWindowManagerPolicy) sWm.mPolicy).rotationToReport = rotationToReport;
sWm.updateRotation(false, false);
// Simulate animator finishing orientation change
sWm.mRoot.mOrientationChangeComplete = true;
sWm.mRoot.performSurfacePlacement(false /* recoveringMemory */);
}
}

View File

@@ -71,7 +71,10 @@ class WindowTestsBase {
static TestWindowManagerPolicy sPolicy = null;
private final static IWindow sIWindow = new TestIWindow();
private final static Session sMockSession = mock(Session.class);
private static int sNextDisplayId = Display.DEFAULT_DISPLAY + 1;
// 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;
static int sNextStackId = FIRST_DYNAMIC_STACK_ID;
private static int sNextTaskId = 0;