Revert "WM: Cleanup TestAppWindowToken code and promote ZOrderingTests to non-flaky"

This reverts commit 469dcbf77b.

Reason for revert: ZOrderingTests are still flaky in postsubmit (go/wm-tests)

Change-Id: I30c8ed06986da7327324e1db749f79c7a7eb4da8
This commit is contained in:
Vishnu Nair
2019-03-12 15:25:38 +00:00
parent 469dcbf77b
commit 5658951cf0
6 changed files with 74 additions and 6 deletions

View File

@@ -59,7 +59,7 @@ public class AppChangeTransitionTests extends WindowTestsBase {
public void setUpOnDisplay(DisplayContent dc) {
mStack = createTaskStackOnDisplay(WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_STANDARD, dc);
mTask = createTaskInStack(mStack, 0 /* userId */);
mToken = WindowTestUtils.createTestAppWindowToken(dc);
mToken = WindowTestUtils.createTestAppWindowToken(dc, false /* skipOnParentChanged */);
mTask.addChild(mToken, 0);

View File

@@ -60,7 +60,7 @@ public class AppWindowTokenAnimationTests extends WindowTestsBase {
MockitoAnnotations.initMocks(this);
mToken = createTestAppWindowToken(mDisplayContent, WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD);
ACTIVITY_TYPE_STANDARD, false /* skipOnParentChanged */);
}
@Test

View File

@@ -81,7 +81,8 @@ public class AppWindowTokenTests extends WindowTestsBase {
public void setUp() throws Exception {
mStack = createTaskStackOnDisplay(mDisplayContent);
mTask = createTaskInStack(mStack, 0 /* userId */);
mToken = WindowTestUtils.createTestAppWindowToken(mDisplayContent);
mToken = WindowTestUtils.createTestAppWindowToken(mDisplayContent,
false /* skipOnParentChanged */);
mTask.addChild(mToken, 0);
}
@@ -218,6 +219,9 @@ public class AppWindowTokenTests extends WindowTestsBase {
@Test
public void testSizeCompatBounds() {
// The real surface transaction is unnecessary.
mToken.setSkipPrepareSurfaces(true);
final Rect fixedBounds = mToken.getRequestedOverrideConfiguration().windowConfiguration
.getBounds();
fixedBounds.set(0, 0, 1200, 1600);

View File

@@ -56,15 +56,24 @@ class WindowTestUtils {
static TestAppWindowToken createTestAppWindowToken(DisplayContent dc) {
synchronized (dc.mWmService.mGlobalLock) {
return new TestAppWindowToken(dc);
return new TestAppWindowToken(dc, true /* skipOnParentChanged */);
}
}
static TestAppWindowToken createTestAppWindowToken(DisplayContent dc,
boolean skipOnParentChanged) {
synchronized (dc.mWmService.mGlobalLock) {
return new TestAppWindowToken(dc, skipOnParentChanged);
}
}
/** Used so we can gain access to some protected members of the {@link AppWindowToken} class. */
static class TestAppWindowToken extends AppWindowToken {
boolean mOnTop = false;
private boolean mSkipPrepareSurfaces;
boolean mSkipOnParentChanged = true;
private TestAppWindowToken(DisplayContent dc) {
private TestAppWindowToken(DisplayContent dc, boolean skipOnParentChanged) {
super(dc.mWmService, new IApplicationToken.Stub() {
@Override
public String getName() {
@@ -72,6 +81,7 @@ class WindowTestUtils {
}
}, new ComponentName("", ""), false, dc, true /* fillsParent */);
mTargetSdk = Build.VERSION_CODES.CUR_DEVELOPMENT;
mSkipOnParentChanged = skipOnParentChanged;
mActivityRecord = mock(ActivityRecord.class);
mActivityRecord.app = mock(WindowProcessController.class);
}
@@ -92,11 +102,45 @@ class WindowTestUtils {
return mChildren.peekLast();
}
@Override
void onParentChanged() {
if (!mSkipOnParentChanged) {
super.onParentChanged();
} else {
updateConfigurationFromParent(this);
}
}
@Override
boolean isOnTop() {
return mOnTop;
}
@Override
void prepareSurfaces() {
if (!mSkipPrepareSurfaces) {
super.prepareSurfaces();
}
}
void setSkipPrepareSurfaces(boolean ignore) {
mSkipPrepareSurfaces = ignore;
}
}
/**
* Used when we don't want to perform surface related operation in
* {@link WindowContainer#onParentChanged} or the overridden method, but the configuration
* still needs to propagate from parent.
*
* @see ConfigurationContainer#onParentChanged
*/
static void updateConfigurationFromParent(WindowContainer container) {
final WindowContainer parent = container.getParent();
if (parent != null) {
container.onConfigurationChanged(parent.getConfiguration());
container.onMergedOverrideConfigurationChanged();
}
}
static TestWindowToken createTestWindowToken(int type, DisplayContent dc) {
@@ -202,5 +246,10 @@ class WindowTestUtils {
mHasSurface = hadSurface;
}
@Override
void onParentChanged() {
updateConfigurationFromParent(this);
}
}
}

View File

@@ -269,10 +269,16 @@ class WindowTestsBase {
WindowTestUtils.TestAppWindowToken createTestAppWindowToken(DisplayContent dc, int
windowingMode, int activityType) {
return createTestAppWindowToken(dc, windowingMode, activityType,
false /*skipOnParentChanged */);
}
WindowTestUtils.TestAppWindowToken createTestAppWindowToken(DisplayContent dc, int
windowingMode, int activityType, boolean skipOnParentChanged) {
final TaskStack stack = createTaskStackOnDisplay(windowingMode, activityType, dc);
final Task task = createTaskInStack(stack, 0 /* userId */);
final WindowTestUtils.TestAppWindowToken appWindowToken =
WindowTestUtils.createTestAppWindowToken(dc);
WindowTestUtils.createTestAppWindowToken(dc, skipOnParentChanged);
task.addChild(appWindowToken, 0);
return appWindowToken;
}

View File

@@ -43,6 +43,7 @@ import android.platform.test.annotations.Presubmit;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
import androidx.test.filters.FlakyTest;
import androidx.test.filters.SmallTest;
import org.junit.After;
@@ -211,6 +212,7 @@ public class ZOrderingTests extends WindowTestsBase {
return createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, name);
}
@FlakyTest(bugId = 124088319)
@Test
public void testAssignWindowLayers_ForImeWithNoTarget() {
mDisplayContent.mInputMethodTarget = null;
@@ -228,6 +230,7 @@ public class ZOrderingTests extends WindowTestsBase {
assertWindowHigher(mImeDialogWindow, mImeWindow);
}
@FlakyTest(bugId = 124088319)
@Test
public void testAssignWindowLayers_ForImeWithAppTarget() {
final WindowState imeAppTarget = createWindow("imeAppTarget");
@@ -247,6 +250,7 @@ public class ZOrderingTests extends WindowTestsBase {
assertWindowHigher(mImeDialogWindow, mImeWindow);
}
@FlakyTest(bugId = 124088319)
@Test
public void testAssignWindowLayers_ForImeWithAppTargetWithChildWindows() {
final WindowState imeAppTarget = createWindow("imeAppTarget");
@@ -273,6 +277,7 @@ public class ZOrderingTests extends WindowTestsBase {
assertWindowHigher(mImeDialogWindow, mImeWindow);
}
@FlakyTest(bugId = 124088319)
@Test
public void testAssignWindowLayers_ForImeWithAppTargetAndAppAbove() {
final WindowState appBelowImeTarget = createWindow("appBelowImeTarget");
@@ -296,6 +301,7 @@ public class ZOrderingTests extends WindowTestsBase {
assertWindowHigher(mImeDialogWindow, mImeWindow);
}
@FlakyTest(bugId = 124088319)
@Test
public void testAssignWindowLayers_ForImeNonAppImeTarget() {
final WindowState imeSystemOverlayTarget = createWindow(null, TYPE_SYSTEM_OVERLAY,
@@ -323,6 +329,7 @@ public class ZOrderingTests extends WindowTestsBase {
assertWindowHigher(mImeDialogWindow, mImeWindow);
}
@FlakyTest(bugId = 124088319)
@Test
public void testAssignWindowLayers_ForStatusBarImeTarget() {
mDisplayContent.mInputMethodTarget = mStatusBarWindow;
@@ -337,6 +344,7 @@ public class ZOrderingTests extends WindowTestsBase {
assertWindowHigher(mImeDialogWindow, mImeWindow);
}
@FlakyTest(bugId = 124088319)
@Test
public void testStackLayers() {
final WindowState anyWindow1 = createWindow("anyWindow");
@@ -424,6 +432,7 @@ public class ZOrderingTests extends WindowTestsBase {
}
}
@FlakyTest(bugId = 124088319)
@Test
public void testDockedDividerPosition() {
final WindowState pinnedStackWindow = createWindowOnStack(null, WINDOWING_MODE_PINNED,