From 8aeff92e67e8a822d04b65a9c727a57faa226d89 Mon Sep 17 00:00:00 2001 From: Yunfan Chen Date: Thu, 29 Jul 2021 16:13:01 +0900 Subject: [PATCH] Make sure nav bar has height in test display In TestDisplayContent, it set the hasNavigationBar flag to true when the test needs one. However, this may not has the correct configuration when the navigation bar height is criticle, e.g., when the screen is in square. The new flexible insets won't have any bar height if there's no bar, even if the flag says there's one. To make the tests work as before, make the bar height method always return a value. Test: atest ActivityRecordTests#testCloseToSquareFixedOrientationLandscape Test: atest DisplayConfigTests Test: atest TaskLaunchParamsModifierTests Bug: 194763108 Change-Id: Ife259c106f4ae7c7dbb6baebd26f8f98037c898a --- services/core/java/com/android/server/wm/DisplayPolicy.java | 3 ++- .../wmtests/src/com/android/server/wm/TestDisplayContent.java | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 3df1bfc5e331e..cc7e8b1bc8613 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -2291,7 +2291,8 @@ public class DisplayPolicy { return width; } - private int getNavigationBarHeight(int rotation, int uiMode) { + @VisibleForTesting + int getNavigationBarHeight(int rotation, int uiMode) { if (INSETS_LAYOUT_GENERALIZATION) { if (mNavigationBar == null) { return 0; diff --git a/services/tests/wmtests/src/com/android/server/wm/TestDisplayContent.java b/services/tests/wmtests/src/com/android/server/wm/TestDisplayContent.java index ce2d748599316..0d919d109587a 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TestDisplayContent.java +++ b/services/tests/wmtests/src/com/android/server/wm/TestDisplayContent.java @@ -20,6 +20,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.view.DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS; import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyBoolean; +import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyInt; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; @@ -153,6 +154,7 @@ class TestDisplayContent extends DisplayContent { if (mSystemDecorations) { doReturn(true).when(newDisplay).supportsSystemDecorations(); doReturn(true).when(displayPolicy).hasNavigationBar(); + doReturn(20).when(displayPolicy).getNavigationBarHeight(anyInt(), anyInt()); } else { doReturn(false).when(displayPolicy).hasNavigationBar(); doReturn(false).when(displayPolicy).hasStatusBar();