diff options
| author | 2023-06-02 15:14:24 +0000 | |
|---|---|---|
| committer | 2023-06-02 15:14:24 +0000 | |
| commit | daf028959da806e1a124ece25cc84d22f022899c (patch) | |
| tree | 65ee31bfe3ec050251955b4111372b1c30ad8140 | |
| parent | 76039598a38bd6a9f116f9e919ff74edb424553e (diff) | |
| parent | f0b39f5c93294594025019b56b31568aab0ed803 (diff) | |
Merge "Reduce dependency of real device for wm unit test" into udc-dev
4 files changed, 15 insertions, 9 deletions
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index cb984f814f1a..3ff433e546d8 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -1996,7 +1996,8 @@ public class ActivityRecordTests extends WindowTestsBase { assertTrue(activity.isSnapshotCompatible(snapshot)); - setRotatedScreenOrientationSilently(activity); + doReturn(task.getWindowConfiguration().getRotation() + 1).when(mDisplayContent) + .rotationForActivityInDifferentOrientation(activity); assertFalse(activity.isSnapshotCompatible(snapshot)); } 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 2dd34eb5ac4d..e74ad3364b63 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -4654,14 +4654,6 @@ public class SizeCompatTests extends WindowTestsBase { return c; } - private static void resizeDisplay(DisplayContent displayContent, int width, int height) { - displayContent.updateBaseDisplayMetrics(width, height, displayContent.mBaseDisplayDensity, - displayContent.mBaseDisplayPhysicalXDpi, displayContent.mBaseDisplayPhysicalYDpi); - final Configuration c = new Configuration(); - displayContent.computeScreenConfiguration(c); - displayContent.onRequestedOverrideConfigurationChanged(c); - } - private static void setNeverConstrainDisplayApisFlag(@Nullable String value, boolean makeDefault) { DeviceConfig.setProperty(NAMESPACE_CONSTRAIN_DISPLAY_APIS, 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 01ddcca99300..f3d8114b9e94 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java @@ -127,6 +127,10 @@ public class WallpaperControllerTests extends WindowTestsBase { public void testWallpaperSizeWithFixedTransform() { // No wallpaper final DisplayContent dc = mDisplayContent; + if (dc.mBaseDisplayHeight == dc.mBaseDisplayWidth) { + // Make sure the size is different when changing orientation. + resizeDisplay(dc, 500, 1000); + } // No wallpaper WSA Surface final WindowState wallpaperWindow = createWallpaperWindow(dc); diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java index ddc729f773b2..be8ee7832a5d 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java @@ -71,6 +71,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; +import android.content.res.Configuration; import android.graphics.Insets; import android.graphics.Rect; import android.hardware.HardwareBuffer; @@ -946,6 +947,14 @@ class WindowTestsBase extends SystemServiceTestsBase { dc.setRotationAnimation(null); } + static void resizeDisplay(DisplayContent displayContent, int width, int height) { + displayContent.updateBaseDisplayMetrics(width, height, displayContent.mBaseDisplayDensity, + displayContent.mBaseDisplayPhysicalXDpi, displayContent.mBaseDisplayPhysicalYDpi); + final Configuration c = new Configuration(); + displayContent.computeScreenConfiguration(c); + displayContent.onRequestedOverrideConfigurationChanged(c); + } + // The window definition for UseTestDisplay#addWindows. The test can declare to add only // necessary windows, that avoids adding unnecessary overhead of unused windows. static final int W_NOTIFICATION_SHADE = TYPE_NOTIFICATION_SHADE; |