From 9e6553e0853868c374a042bf61c03e17ddc4efda Mon Sep 17 00:00:00 2001 From: Louis Chang Date: Tue, 28 Jun 2022 06:57:09 +0000 Subject: [PATCH] Fix WM presubmit failures The changes in SizeConfigurationBuckets in commit 8ec32dd was not verified by wm presubmit and therefore broke a few wm unit tests. Bug: 235774601 Bug: 237348419 Test: ActivityRecordTests Test: SizeConfigurationBucketsTest Change-Id: I23299e329c2bf2ca94fc156859993ea31ad3dc75 --- .../window/SizeConfigurationBucketsTest.java | 15 ++------------- .../android/server/wm/ActivityRecordTests.java | 10 ++++++++-- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/core/tests/mockingcoretests/src/android/window/SizeConfigurationBucketsTest.java b/core/tests/mockingcoretests/src/android/window/SizeConfigurationBucketsTest.java index fa4aa803c75ee..ed857e8fc9600 100644 --- a/core/tests/mockingcoretests/src/android/window/SizeConfigurationBucketsTest.java +++ b/core/tests/mockingcoretests/src/android/window/SizeConfigurationBucketsTest.java @@ -88,26 +88,15 @@ public class SizeConfigurationBucketsTest { } /** - * Tests that null size configuration buckets unflips the correct configuration flags. + * Tests that {@code null} size configuration buckets do not unflip the configuration flags. */ @Test public void testNullSizeConfigurationBuckets() { - // Check that all 3 size configurations are filtered out of the diff if the buckets are null - // and non-size attributes of screen layout are unchanged. Add a non-size related config - // change (i.e. CONFIG_LOCALE) to test that the diff is not set to zero. final int diff = CONFIG_SCREEN_SIZE | CONFIG_SMALLEST_SCREEN_SIZE | CONFIG_SCREEN_LAYOUT | CONFIG_LOCALE; final int filteredDiffNonSizeLayoutUnchanged = SizeConfigurationBuckets.filterDiff(diff, Configuration.EMPTY, Configuration.EMPTY, null); - assertEquals(CONFIG_LOCALE, filteredDiffNonSizeLayoutUnchanged); - - // Check that only screen size and smallest screen size are filtered out of the diff if the - // buckets are null and non-size attributes of screen layout are changed. - final Configuration newConfig = new Configuration(); - newConfig.screenLayout |= SCREENLAYOUT_ROUND_YES; - final int filteredDiffNonSizeLayoutChanged = SizeConfigurationBuckets.filterDiff(diff, - Configuration.EMPTY, newConfig, null); - assertEquals(CONFIG_SCREEN_LAYOUT | CONFIG_LOCALE, filteredDiffNonSizeLayoutChanged); + assertEquals(diff, filteredDiffNonSizeLayoutUnchanged); } /** 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 cfeaf850da03c..6aeb9fa02a8e3 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -29,6 +29,8 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION; import static android.content.pm.ActivityInfo.CONFIG_SCREEN_LAYOUT; +import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE; +import static android.content.pm.ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE; import static android.content.pm.ActivityInfo.FLAG_SUPPORTS_PICTURE_IN_PICTURE; import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_ALWAYS; import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_DEFAULT; @@ -182,6 +184,10 @@ public class ActivityRecordTests extends WindowTestsBase { private final String mPackageName = getInstrumentation().getTargetContext().getPackageName(); + private static final int ORIENTATION_CONFIG_CHANGES = + CONFIG_ORIENTATION | CONFIG_SCREEN_LAYOUT | CONFIG_SCREEN_SIZE + | CONFIG_SMALLEST_SCREEN_SIZE; + @Before public void setUp() throws Exception { setBooted(mAtm); @@ -487,7 +493,7 @@ public class ActivityRecordTests extends WindowTestsBase { public void testSetRequestedOrientationUpdatesConfiguration() throws Exception { final ActivityRecord activity = new ActivityBuilder(mAtm) .setCreateTask(true) - .setConfigChanges(CONFIG_ORIENTATION | CONFIG_SCREEN_LAYOUT) + .setConfigChanges(ORIENTATION_CONFIG_CHANGES) .build(); activity.setState(RESUMED, "Testing"); @@ -710,7 +716,7 @@ public class ActivityRecordTests extends WindowTestsBase { final ActivityRecord activity = new ActivityBuilder(mAtm) .setCreateTask(true) .setLaunchTaskBehind(true) - .setConfigChanges(CONFIG_ORIENTATION | CONFIG_SCREEN_LAYOUT) + .setConfigChanges(ORIENTATION_CONFIG_CHANGES) .build(); final Task task = activity.getTask(); activity.setState(STOPPED, "Testing");