summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nergi Rahardi <nergi@google.com> 2024-12-24 13:56:40 +0900
committer Nergi Rahardi <nergi@google.com> 2024-12-24 13:58:23 +0900
commitf7d45e84649b17f2742332688418b67c7cfbfd9f (patch)
tree87349854c270819fc20c2973818cf6019aa3bd40
parent393f5840791579ec9e451fb7a9b64203b08b4efb (diff)
Refactor various tests to use newWindowBuilder
Bug: 383480021 Test: atest WmTests:ActivityStarterTests Test: atest WmTests:FrameRateSelectionPriority Test: atest WmTests:RefreshRatePolicyTest Test: atest WmTests:RemoteAnimationControllerTest Test: atest WmTests:SizeCompatTests Test: atest WmTests:SyncEngineTests Test: atest WmTests:TransitionTests Test: atest WmTests:WallpaperControllerTests Flag: EXEMPT cleaning up tests Change-Id: I263163640b2471ba8652b07f924ee671fda95d33
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java6
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/FrameRateSelectionPriorityTests.java2
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RefreshRatePolicyTest.java2
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java47
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java15
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/SyncEngineTests.java10
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TransitionTests.java24
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java24
8 files changed, 64 insertions, 66 deletions
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
index 94a40020cfc8..e3e9cc426bb3 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
@@ -361,12 +361,6 @@ public class ActivityStarterTests extends WindowTestsBase {
return prepareStarter(launchFlags, mockGetRootTask, LAUNCH_MULTIPLE);
}
- private void setupImeWindow() {
- final WindowState imeWindow = createWindow(null, W_INPUT_METHOD,
- "mImeWindow", CURRENT_IME_UID);
- mDisplayContent.mInputMethodWindow = imeWindow;
- }
-
/**
* Creates a {@link ActivityStarter} with default parameters and necessary mocks.
*
diff --git a/services/tests/wmtests/src/com/android/server/wm/FrameRateSelectionPriorityTests.java b/services/tests/wmtests/src/com/android/server/wm/FrameRateSelectionPriorityTests.java
index c016c5ead23c..de0716885214 100644
--- a/services/tests/wmtests/src/com/android/server/wm/FrameRateSelectionPriorityTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/FrameRateSelectionPriorityTests.java
@@ -73,7 +73,7 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase {
private static final float MID_REFRESH_RATE = 70;
private static final float LOW_REFRESH_RATE = 60;
WindowState createWindow(String name) {
- WindowState window = createWindow(null, TYPE_APPLICATION, name);
+ WindowState window = newWindowBuilder(name, TYPE_APPLICATION).build();
when(window.mWmService.mDisplayManagerInternal.getRefreshRateSwitchingType())
.thenReturn(DisplayManager.SWITCHING_TYPE_WITHIN_GROUPS);
return window;
diff --git a/services/tests/wmtests/src/com/android/server/wm/RefreshRatePolicyTest.java b/services/tests/wmtests/src/com/android/server/wm/RefreshRatePolicyTest.java
index 73e5f58fa7e0..45436e47e881 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RefreshRatePolicyTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RefreshRatePolicyTest.java
@@ -108,7 +108,7 @@ public class RefreshRatePolicyTest extends WindowTestsBase {
}
WindowState createWindow(String name) {
- WindowState window = createWindow(null, TYPE_BASE_APPLICATION, name);
+ WindowState window = newWindowBuilder(name, TYPE_BASE_APPLICATION).build();
when(window.getDisplayInfo()).thenReturn(mDisplayInfo);
when(window.mWmService.mDisplayManagerInternal.getRefreshRateSwitchingType())
.thenReturn(DisplayManager.SWITCHING_TYPE_WITHIN_GROUPS);
diff --git a/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java
index c5cbedb9193c..20381ba21758 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java
@@ -114,8 +114,8 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
}
private WindowState createAppOverlayWindow() {
- final WindowState win = createWindow(null /* parent */, TYPE_APPLICATION_OVERLAY,
- "testOverlayWindow");
+ final WindowState win = newWindowBuilder("testOverlayWindow",
+ TYPE_APPLICATION_OVERLAY).build();
win.mActivityRecord = null;
win.mHasSurface = true;
return win;
@@ -123,7 +123,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
@Test
public void testForwardsShowBackdrop() throws Exception {
- final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
+ final WindowState win = createTestWindow();
mDisplayContent.mOpeningApps.add(win.mActivityRecord);
final WindowState overlayWin = createAppOverlayWindow();
try {
@@ -156,7 +156,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
@Test
public void testRun() throws Exception {
- final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
+ final WindowState win = createTestWindow();
mDisplayContent.mOpeningApps.add(win.mActivityRecord);
final WindowState overlayWin = createAppOverlayWindow();
try {
@@ -200,7 +200,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
@Test
public void testCancel() throws Exception {
- final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
+ final WindowState win = createTestWindow();
final AnimationAdapter adapter = mController.createRemoteAnimationRecord(
win.mActivityRecord,
new Point(50, 100), null, new Rect(50, 100, 150, 150), null, false).mAdapter;
@@ -214,7 +214,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
@Test
public void testTimeout() throws Exception {
- final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
+ final WindowState win = createTestWindow();
final AnimationAdapter adapter = mController.createRemoteAnimationRecord(
win.mActivityRecord,
new Point(50, 100), null, new Rect(50, 100, 150, 150), null, false).mAdapter;
@@ -234,8 +234,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
public void testTimeout_scaled() throws Exception {
try {
mWm.setAnimationScale(2, 5.0f);
- final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION,
- "testWin");
+ final WindowState win = createTestWindow();
final AnimationAdapter adapter = mController.createRemoteAnimationRecord(
win.mActivityRecord, new Point(50, 100), null, new Rect(50, 100, 150, 150),
null, false).mAdapter;
@@ -268,7 +267,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
@Test
public void testNotReallyStarted() throws Exception {
- final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
+ final WindowState win = createTestWindow();
mController.createRemoteAnimationRecord(win.mActivityRecord,
new Point(50, 100), null, new Rect(50, 100, 150, 150), null, false);
mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN);
@@ -278,8 +277,8 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
@Test
public void testOneNotStarted() throws Exception {
- final WindowState win1 = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin1");
- final WindowState win2 = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin2");
+ final WindowState win1 = newWindowBuilder("testWin1", TYPE_BASE_APPLICATION).build();
+ final WindowState win2 = newWindowBuilder("testWin2", TYPE_BASE_APPLICATION).build();
mController.createRemoteAnimationRecord(win1.mActivityRecord,
new Point(50, 100), null, new Rect(50, 100, 150, 150), null, false);
final AnimationAdapter adapter = mController.createRemoteAnimationRecord(
@@ -306,7 +305,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
@Test
public void testRemovedBeforeStarted() throws Exception {
- final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
+ final WindowState win = createTestWindow();
final AnimationAdapter adapter = mController.createRemoteAnimationRecord(
win.mActivityRecord,
new Point(50, 100), null, new Rect(50, 100, 150, 150), null, false).mAdapter;
@@ -322,7 +321,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
@Test
public void testOpeningTaskWithTopFinishingActivity() {
- final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "win");
+ final WindowState win = createTestWindow();
final Task task = win.getTask();
final ActivityRecord topFinishing = new ActivityBuilder(mAtm).setTask(task).build();
// Now the task contains:
@@ -348,7 +347,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
@Test
public void testChangeToSmallerSize() throws Exception {
- final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
+ final WindowState win = createTestWindow();
mDisplayContent.mChangingContainers.add(win.mActivityRecord);
try {
final RemoteAnimationRecord record = mController.createRemoteAnimationRecord(
@@ -402,7 +401,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
@Test
public void testChangeTolargerSize() throws Exception {
- final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
+ final WindowState win = createTestWindow();
mDisplayContent.mChangingContainers.add(win.mActivityRecord);
try {
final RemoteAnimationRecord record = mController.createRemoteAnimationRecord(
@@ -456,7 +455,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
@Test
public void testChangeToDifferentPosition() throws Exception {
- final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
+ final WindowState win = createTestWindow();
mDisplayContent.mChangingContainers.add(win.mActivityRecord);
try {
final RemoteAnimationRecord record = mController.createRemoteAnimationRecord(
@@ -515,7 +514,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
true, mDisplayContent, true /* ownerCanManageAppTokens */);
spyOn(mDisplayContent.mWallpaperController);
doReturn(true).when(mDisplayContent.mWallpaperController).isWallpaperVisible();
- final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
+ final WindowState win = createTestWindow();
mDisplayContent.mOpeningApps.add(win.mActivityRecord);
try {
final AnimationAdapter adapter = mController.createRemoteAnimationRecord(
@@ -548,7 +547,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
true, mDisplayContent, true /* ownerCanManageAppTokens */);
spyOn(mDisplayContent.mWallpaperController);
doReturn(true).when(mDisplayContent.mWallpaperController).isWallpaperVisible();
- final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
+ final WindowState win = createTestWindow();
mDisplayContent.mOpeningApps.add(win.mActivityRecord);
try {
final AnimationAdapter adapter = mController.createRemoteAnimationRecord(
@@ -581,7 +580,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
@Test
public void testNonAppIncluded_keygaurdGoingAway() throws Exception {
- final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
+ final WindowState win = createTestWindow();
mDisplayContent.mOpeningApps.add(win.mActivityRecord);
// Add overlay window hidden by the keyguard.
final WindowState overlayWin = createAppOverlayWindow();
@@ -631,7 +630,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
true, mDisplayContent, true /* ownerCanManageAppTokens */);
spyOn(mDisplayContent.mWallpaperController);
doReturn(true).when(mDisplayContent.mWallpaperController).isWallpaperVisible();
- final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
+ final WindowState win = createTestWindow();
mDisplayContent.mOpeningApps.add(win.mActivityRecord);
// Add overlay window hidden by the keyguard.
final WindowState overlayWin = createAppOverlayWindow();
@@ -729,9 +728,9 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
}
private AnimationAdapter setupForNonAppTargetNavBar(int transit, boolean shouldAttachNavBar) {
- final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin");
+ final WindowState win = createTestWindow();
mDisplayContent.mOpeningApps.add(win.mActivityRecord);
- final WindowState navBar = createWindow(null, TYPE_NAVIGATION_BAR, "NavigationBar");
+ final WindowState navBar = newWindowBuilder("NavigationBar", TYPE_NAVIGATION_BAR).build();
mDisplayContent.getDisplayPolicy().addWindowLw(navBar, navBar.mAttrs);
final DisplayPolicy policy = mDisplayContent.getDisplayPolicy();
spyOn(policy);
@@ -751,4 +750,8 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
verify(binder, atLeast(0)).asBinder();
verifyNoMoreInteractions(binder);
}
+
+ private WindowState createTestWindow() {
+ return newWindowBuilder("testWin", TYPE_BASE_APPLICATION).build();
+ }
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
index 6a738ae54dcd..9d9f24cb50f2 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
@@ -673,7 +673,8 @@ public class SizeCompatTests extends WindowTestsBase {
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
prepareUnresizable(mActivity, SCREEN_ORIENTATION_LANDSCAPE);
- final WindowState window = createWindow(null, TYPE_BASE_APPLICATION, mActivity, "window");
+ final WindowState window = newWindowBuilder("window", TYPE_BASE_APPLICATION).setWindowToken(
+ mActivity).build();
assertEquals(window, mActivity.findMainWindow());
@@ -3996,8 +3997,8 @@ public class SizeCompatTests extends WindowTestsBase {
resizeDisplay(display, 2200, 2280);
display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
// Simulate insets, final app bounds are (0, 0, 2200, 2130) - landscape.
- final WindowState navbar = createWindow(null, TYPE_NAVIGATION_BAR, mDisplayContent,
- "navbar");
+ final WindowState navbar = newWindowBuilder("navbar", TYPE_NAVIGATION_BAR).setDisplay(
+ mDisplayContent).build();
final Binder owner = new Binder();
navbar.mAttrs.providedInsets = new InsetsFrameProvider[] {
new InsetsFrameProvider(owner, 0, WindowInsets.Type.navigationBars())
@@ -4030,8 +4031,8 @@ public class SizeCompatTests extends WindowTestsBase {
resizeDisplay(display, 2200, 2280);
display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
// Simulate taskbar, final app bounds are (0, 0, 2200, 2130) - landscape
- final WindowState navbar = createWindow(null, TYPE_NAVIGATION_BAR, mDisplayContent,
- "navbar");
+ final WindowState navbar = newWindowBuilder("navbar", TYPE_NAVIGATION_BAR).setDisplay(
+ mDisplayContent).build();
final Binder owner = new Binder();
navbar.mAttrs.providedInsets = new InsetsFrameProvider[] {
new InsetsFrameProvider(owner, 0, WindowInsets.Type.navigationBars())
@@ -4059,8 +4060,8 @@ public class SizeCompatTests extends WindowTestsBase {
resizeDisplay(dc, 2200, 2280);
dc.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
// Simulate taskbar, final app bounds are (0, 0, 2200, 2130) - landscape
- final WindowState navbar = createWindow(null, TYPE_NAVIGATION_BAR, mDisplayContent,
- "navbar");
+ final WindowState navbar = newWindowBuilder("navbar", TYPE_NAVIGATION_BAR).setDisplay(
+ mDisplayContent).build();
final Binder owner = new Binder();
navbar.mAttrs.providedInsets = new InsetsFrameProvider[] {
new InsetsFrameProvider(owner, 0, WindowInsets.Type.navigationBars())
diff --git a/services/tests/wmtests/src/com/android/server/wm/SyncEngineTests.java b/services/tests/wmtests/src/com/android/server/wm/SyncEngineTests.java
index 1c32980aac91..da5210cfa7e6 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SyncEngineTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SyncEngineTests.java
@@ -152,9 +152,9 @@ public class SyncEngineTests extends WindowTestsBase {
final Task task = taskRoot.getTask();
final ActivityRecord translucentTop = new ActivityBuilder(mAtm).setTask(task)
.setActivityTheme(android.R.style.Theme_Translucent).build();
- createWindow(null, TYPE_BASE_APPLICATION, taskRoot, "win");
- final WindowState startingWindow = createWindow(null, TYPE_APPLICATION_STARTING,
- translucentTop, "starting");
+ newWindowBuilder("win", TYPE_BASE_APPLICATION).setWindowToken(taskRoot).build();
+ final WindowState startingWindow = newWindowBuilder("starting",
+ TYPE_APPLICATION_STARTING).setWindowToken(translucentTop).build();
startingWindow.mStartingData = new SnapshotStartingData(mWm, null, 0);
task.mSharedStartingData = startingWindow.mStartingData;
task.prepareSync();
@@ -355,7 +355,7 @@ public class SyncEngineTests extends WindowTestsBase {
assertEquals(SYNC_STATE_NONE, botChildWC.mSyncState);
// If the appearance of window won't change after reparenting, its sync state can be kept.
- final WindowState w = createWindow(null, TYPE_BASE_APPLICATION, "win");
+ final WindowState w = newWindowBuilder("win", TYPE_BASE_APPLICATION).build();
parentWC.onRequestedOverrideConfigurationChanged(w.getConfiguration());
w.reparent(botChildWC, POSITION_TOP);
parentWC.prepareSync();
@@ -435,7 +435,7 @@ public class SyncEngineTests extends WindowTestsBase {
@Test
public void testNonBlastMethod() {
- mAppWindow = createWindow(null, TYPE_BASE_APPLICATION, "mAppWindow");
+ mAppWindow = newWindowBuilder("mAppWindow", TYPE_BASE_APPLICATION).build();
final BLASTSyncEngine bse = createTestBLASTSyncEngine();
diff --git a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java
index 143cf551a28e..2ee34d3a4b36 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java
@@ -433,8 +433,8 @@ public class TransitionTests extends WindowTestsBase {
final WallpaperWindowToken wallpaperWindowToken = spy(new WallpaperWindowToken(mWm,
mock(IBinder.class), true, mDisplayContent, true /* ownerCanManageAppTokens */));
- final WindowState wallpaperWindow = createWindow(null, TYPE_WALLPAPER, wallpaperWindowToken,
- "wallpaperWindow");
+ final WindowState wallpaperWindow = newWindowBuilder("wallpaperWindow",
+ TYPE_WALLPAPER).setWindowToken(wallpaperWindowToken).build();
wallpaperWindowToken.setVisibleRequested(false);
transition.collect(wallpaperWindowToken);
wallpaperWindowToken.setVisibleRequested(true);
@@ -630,8 +630,8 @@ public class TransitionTests extends WindowTestsBase {
// Make DA organized so we can check that they don't get included.
WindowContainer parent = wallpaperWindowToken.getParent();
makeDisplayAreaOrganized(parent, mDisplayContent);
- final WindowState wallpaperWindow = createWindow(null, TYPE_WALLPAPER, wallpaperWindowToken,
- "wallpaperWindow");
+ final WindowState wallpaperWindow = newWindowBuilder("wallpaperWindow",
+ TYPE_WALLPAPER).setWindowToken(wallpaperWindowToken).build();
wallpaperWindowToken.setVisibleRequested(false);
transition.collect(wallpaperWindowToken);
wallpaperWindowToken.setVisibleRequested(true);
@@ -1114,15 +1114,15 @@ public class TransitionTests extends WindowTestsBase {
// Simulate gesture navigation (non-movable) so it is not seamless.
doReturn(false).when(displayPolicy).navigationBarCanMove();
final Task task = createActivityRecord(mDisplayContent).getTask();
- final WindowState statusBar = createWindow(null, TYPE_STATUS_BAR, "statusBar");
- final WindowState navBar = createWindow(null, TYPE_NAVIGATION_BAR, "navBar");
- final WindowState ime = createWindow(null, TYPE_INPUT_METHOD, "ime");
+ final WindowState statusBar = newWindowBuilder("statusBar", TYPE_STATUS_BAR).build();
+ final WindowState navBar = newWindowBuilder("navBar", TYPE_NAVIGATION_BAR).build();
+ final WindowState ime = newWindowBuilder("ime", TYPE_INPUT_METHOD).build();
final WindowToken decorToken = new WindowToken.Builder(mWm, mock(IBinder.class),
TYPE_NAVIGATION_BAR_PANEL).setDisplayContent(mDisplayContent)
.setRoundedCornerOverlay(true).build();
- final WindowState screenDecor =
- createWindow(null, decorToken.windowType, decorToken, "screenDecor");
- final WindowState[] windows = { statusBar, navBar, ime, screenDecor };
+ final WindowState screenDecor = newWindowBuilder("screenDecor",
+ decorToken.windowType).setWindowToken(decorToken).build();
+ final WindowState[] windows = {statusBar, navBar, ime, screenDecor};
makeWindowVisible(windows);
mDisplayContent.getDisplayPolicy().addWindowLw(statusBar, statusBar.mAttrs);
mDisplayContent.getDisplayPolicy().addWindowLw(navBar, navBar.mAttrs);
@@ -1191,7 +1191,7 @@ public class TransitionTests extends WindowTestsBase {
}
private void testShellRotationOpen(TestTransitionPlayer player) {
- final WindowState statusBar = createWindow(null, TYPE_STATUS_BAR, "statusBar");
+ final WindowState statusBar = newWindowBuilder("statusBar", TYPE_STATUS_BAR).build();
makeWindowVisible(statusBar);
mDisplayContent.getDisplayPolicy().addWindowLw(statusBar, statusBar.mAttrs);
final ActivityRecord app = createActivityRecord(mDisplayContent);
@@ -1239,7 +1239,7 @@ public class TransitionTests extends WindowTestsBase {
}
private void testFixedRotationOpen(TestTransitionPlayer player) {
- final WindowState statusBar = createWindow(null, TYPE_STATUS_BAR, "statusBar");
+ final WindowState statusBar = newWindowBuilder("statusBar", TYPE_STATUS_BAR).build();
makeWindowVisible(statusBar);
mDisplayContent.getDisplayPolicy().addWindowLw(statusBar, statusBar.mAttrs);
final WindowState navBar = createNavBarWithProvidedInsets(mDisplayContent);
diff --git a/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java
index eb89a9fb20c5..358448e709f3 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java
@@ -243,8 +243,8 @@ public class WallpaperControllerTests extends WindowTestsBase {
final WindowState homeWindow = createWallpaperTargetWindow(dc);
- WindowState otherWindow = createWindow(null /* parent */, TYPE_APPLICATION, dc,
- "otherWindow");
+ WindowState otherWindow = newWindowBuilder("otherWindow", TYPE_APPLICATION).setDisplay(
+ dc).build();
dc.mWallpaperController.adjustWallpaperWindows();
@@ -275,7 +275,7 @@ public class WallpaperControllerTests extends WindowTestsBase {
public void testUpdateWallpaperTarget() {
final DisplayContent dc = mDisplayContent;
final WindowState homeWin = createWallpaperTargetWindow(dc);
- final WindowState appWin = createWindow(null, TYPE_BASE_APPLICATION, "app");
+ final WindowState appWin = newWindowBuilder("app", TYPE_BASE_APPLICATION).build();
appWin.mAttrs.flags |= FLAG_SHOW_WALLPAPER;
makeWindowVisible(appWin);
@@ -290,9 +290,9 @@ public class WallpaperControllerTests extends WindowTestsBase {
public void testShowWhenLockedWallpaperTarget() {
final WindowState wallpaperWindow = createWallpaperWindow(mDisplayContent);
wallpaperWindow.mToken.asWallpaperToken().setShowWhenLocked(true);
- final WindowState behind = createWindow(null, TYPE_BASE_APPLICATION, "behind");
- final WindowState topTranslucent = createWindow(null, TYPE_BASE_APPLICATION,
- "topTranslucent");
+ final WindowState behind = newWindowBuilder("behind", TYPE_BASE_APPLICATION).build();
+ final WindowState topTranslucent = newWindowBuilder("topTranslucent",
+ TYPE_BASE_APPLICATION).build();
behind.mAttrs.width = behind.mAttrs.height = topTranslucent.mAttrs.width =
topTranslucent.mAttrs.height = WindowManager.LayoutParams.MATCH_PARENT;
topTranslucent.mAttrs.flags |= WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
@@ -314,8 +314,8 @@ public class WallpaperControllerTests extends WindowTestsBase {
// Only transient-launch transition will make notification shade as last resort target.
// This verifies that regular transition won't choose invisible keyguard as the target.
- final WindowState keyguard = createWindow(null /* parent */,
- WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE, "keyguard");
+ final WindowState keyguard = newWindowBuilder("keyguard",
+ WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE).build();
keyguard.mAttrs.flags |= FLAG_SHOW_WALLPAPER;
registerTestTransitionPlayer();
final Transition transition = wallpaperWindow.mTransitionController.createTransition(
@@ -568,8 +568,8 @@ public class WallpaperControllerTests extends WindowTestsBase {
private WindowState createWallpaperWindow(DisplayContent dc) {
final WindowToken wallpaperWindowToken = new WallpaperWindowToken(mWm, mock(IBinder.class),
true /* explicit */, dc, true /* ownerCanManageAppTokens */);
- return createWindow(null /* parent */, TYPE_WALLPAPER, wallpaperWindowToken,
- "wallpaperWindow");
+ return newWindowBuilder("wallpaperWindow", TYPE_WALLPAPER).setWindowToken(
+ wallpaperWindowToken).build();
}
private WindowState createWallpaperTargetWindow(DisplayContent dc) {
@@ -578,8 +578,8 @@ public class WallpaperControllerTests extends WindowTestsBase {
.build();
homeActivity.setVisibility(true);
- WindowState appWindow = createWindow(null /* parent */, TYPE_BASE_APPLICATION,
- homeActivity, "wallpaperTargetWindow");
+ WindowState appWindow = newWindowBuilder("wallpaperTargetWindow",
+ TYPE_BASE_APPLICATION).setWindowToken(homeActivity).build();
appWindow.getAttrs().flags |= FLAG_SHOW_WALLPAPER;
appWindow.mHasSurface = true;
spyOn(appWindow);