Merge "Update CtsPreference2TestCases to prevent test app in landscape mode will fail" into pie-cts-dev
am: 453c6d2bea
Change-Id: I29f695ab1975131cad1d88f1cd9eabe49c311760
diff --git a/tests/tests/preference2/src/android/preference2/cts/TestUtils.java b/tests/tests/preference2/src/android/preference2/cts/TestUtils.java
index e00e658..dd25f59 100644
--- a/tests/tests/preference2/src/android/preference2/cts/TestUtils.java
+++ b/tests/tests/preference2/src/android/preference2/cts/TestUtils.java
@@ -69,10 +69,16 @@
// Crop the right side for scrollbar which might or might not be visible. On wearable
// devices the scroll bar is a curve and occupies 20% of the right side.
int xToCut = isOnWatchUiMode() ? bt.getWidth() / 5 : bt.getWidth() / 20;
+ int yToCut = statusBarHeight;
+
+ if (isLandscape()) {
+ xToCut += navigationBarHeight;
+ } else {
+ yToCut += navigationBarHeight;
+ }
bt = Bitmap.createBitmap(
- bt, 0, statusBarHeight, bt.getWidth() - xToCut,
- bt.getHeight() - statusBarHeight - navigationBarHeight);
+ bt, 0, statusBarHeight, bt.getWidth() - xToCut, bt.getHeight() - yToCut);
return bt;
}
@@ -240,4 +246,9 @@
throw new RuntimeException("Failed to run command: " + cmd, e);
}
}
+
+ private boolean isLandscape() {
+ return mInstrumentation.getTargetContext().getResources().getConfiguration().orientation ==
+ Configuration.ORIENTATION_LANDSCAPE;
+ }
}