From c63d98b8234c1c1f5dd8a6798cfa77b5e4a48c06 Mon Sep 17 00:00:00 2001 From: Shivam Agrawal Date: Tue, 23 Mar 2021 11:00:53 -0400 Subject: [PATCH] Ensure DisplayPolicyInsetsTests Check Correct Nav Bar Position [1] introduced different navigation bar behavior on displays with smallest width (sw) >= 600dp or with gesture nav enabled, where the navigation bar would stay fixed to the bottom when the display rotates to landscape/seascape. To ensure that DisplayPolicyInsetsTests do not fail in these cases, modify the tests to check the correct position navigation bar. [1] I770cf207c08ba0d36de6e3b6ab378e94498a02bd Bug: b/182499175 Test: atest DisplayPolicyInsetsTests Change-Id: I9a84f25838166a343a8ed9e17a1e1b6584db574b --- .../server/wm/DisplayPolicyInsetsTests.java | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyInsetsTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyInsetsTests.java index 402fd22416fcc..004e45a8be4bc 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyInsetsTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyInsetsTests.java @@ -66,8 +66,14 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase { public void landscape() { final DisplayInfo di = displayInfoForRotation(ROTATION_90, false /* withCutout */); - verifyStableInsets(di, 0, STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT, 0); - verifyNonDecorInsets(di, 0, 0, NAV_BAR_HEIGHT, 0); + if (mDisplayPolicy.navigationBarCanMove()) { + verifyStableInsets(di, 0, STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT, 0); + verifyNonDecorInsets(di, 0, 0, NAV_BAR_HEIGHT, 0); + } else { + // if the navigation bar cannot move then it is always on the bottom + verifyStableInsets(di, 0, STATUS_BAR_HEIGHT, 0, NAV_BAR_HEIGHT); + verifyNonDecorInsets(di, 0, 0, 0, NAV_BAR_HEIGHT); + } verifyConsistency(di); } @@ -75,8 +81,14 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase { public void landscape_withCutout() { final DisplayInfo di = displayInfoForRotation(ROTATION_90, true /* withCutout */); - verifyStableInsets(di, DISPLAY_CUTOUT_HEIGHT, STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT, 0); - verifyNonDecorInsets(di, DISPLAY_CUTOUT_HEIGHT, 0, NAV_BAR_HEIGHT, 0); + if (mDisplayPolicy.navigationBarCanMove()) { + verifyStableInsets(di, DISPLAY_CUTOUT_HEIGHT, STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT, 0); + verifyNonDecorInsets(di, DISPLAY_CUTOUT_HEIGHT, 0, NAV_BAR_HEIGHT, 0); + } else { + // if the navigation bar cannot move then it is always on the bottom + verifyStableInsets(di, DISPLAY_CUTOUT_HEIGHT, STATUS_BAR_HEIGHT, 0, NAV_BAR_HEIGHT); + verifyNonDecorInsets(di, DISPLAY_CUTOUT_HEIGHT, 0, 0, NAV_BAR_HEIGHT); + } verifyConsistency(di); } @@ -84,8 +96,14 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase { public void seascape() { final DisplayInfo di = displayInfoForRotation(ROTATION_270, false /* withCutout */); - verifyStableInsets(di, NAV_BAR_HEIGHT, STATUS_BAR_HEIGHT, 0, 0); - verifyNonDecorInsets(di, NAV_BAR_HEIGHT, 0, 0, 0); + if (mDisplayPolicy.navigationBarCanMove()) { + verifyStableInsets(di, NAV_BAR_HEIGHT, STATUS_BAR_HEIGHT, 0, 0); + verifyNonDecorInsets(di, NAV_BAR_HEIGHT, 0, 0, 0); + } else { + // if the navigation bar cannot move then it is always on the bottom + verifyStableInsets(di, 0, STATUS_BAR_HEIGHT, 0, NAV_BAR_HEIGHT); + verifyNonDecorInsets(di, 0, 0, 0, NAV_BAR_HEIGHT); + } verifyConsistency(di); } @@ -93,8 +111,14 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase { public void seascape_withCutout() { final DisplayInfo di = displayInfoForRotation(ROTATION_270, true /* withCutout */); - verifyStableInsets(di, NAV_BAR_HEIGHT, STATUS_BAR_HEIGHT, DISPLAY_CUTOUT_HEIGHT, 0); - verifyNonDecorInsets(di, NAV_BAR_HEIGHT, 0, DISPLAY_CUTOUT_HEIGHT, 0); + if (mDisplayPolicy.navigationBarCanMove()) { + verifyStableInsets(di, NAV_BAR_HEIGHT, STATUS_BAR_HEIGHT, DISPLAY_CUTOUT_HEIGHT, 0); + verifyNonDecorInsets(di, NAV_BAR_HEIGHT, 0, DISPLAY_CUTOUT_HEIGHT, 0); + } else { + // if the navigation bar cannot move then it is always on the bottom + verifyStableInsets(di, 0, STATUS_BAR_HEIGHT, DISPLAY_CUTOUT_HEIGHT, NAV_BAR_HEIGHT); + verifyNonDecorInsets(di, 0, 0, DISPLAY_CUTOUT_HEIGHT, NAV_BAR_HEIGHT); + } verifyConsistency(di); }