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
This commit is contained in:
Yunfan Chen
2021-07-29 16:13:01 +09:00
parent b132353410
commit 8aeff92e67
2 changed files with 4 additions and 1 deletions

View File

@@ -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;

View File

@@ -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();