Scroll to bottom of screen when adding preferences via code
Otherwise, on some watches with small screen, the new preferences aren't
visible and the test fails.
Change-Id: Ib19a458d6faa280aae25c8ca3690fc6f3c91fbcd
FIXES: 64724186
diff --git a/tests/tests/preference2/src/android/preference2/cts/PreferenceRecycleTest.java b/tests/tests/preference2/src/android/preference2/cts/PreferenceRecycleTest.java
index 9d0242d..598780ce 100644
--- a/tests/tests/preference2/src/android/preference2/cts/PreferenceRecycleTest.java
+++ b/tests/tests/preference2/src/android/preference2/cts/PreferenceRecycleTest.java
@@ -127,6 +127,12 @@
screen.addPreference(noRecyclePref);
});
+ // Select the last item in the list to make sure the newly added prefs is actually
+ // displayed even on small screen like watches.
+ mActivityRule.runOnUiThread(() -> {
+ mActivity.getListView().setSelection(mActivity.getListView().getCount() - 1);
+ });
+
// Grab the preferences we just created on the Ui thread.
RecycleCheckPreference recyclePref =
(RecycleCheckPreference)screen.findPreference("recyclePref");