Enable new time zone picker
- Change the UI test due to UI changes
Bug: 73952488
Test: m RunSettingsRoboTest
Test: atest SettingsUITests:ZonePickerSettingsTest
Change-Id: I6d5716347e9debf429b757f1edd4118e86b70fab
(cherry picked from commit 335c0621d2521d3801c13dafdbfc2e632d171104)
diff --git a/src/com/android/settings/datetime/TimeZonePreferenceController.java b/src/com/android/settings/datetime/TimeZonePreferenceController.java
index e29e245..aff204d 100644
--- a/src/com/android/settings/datetime/TimeZonePreferenceController.java
+++ b/src/com/android/settings/datetime/TimeZonePreferenceController.java
@@ -19,11 +19,11 @@
import android.content.Context;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
-
import android.util.FeatureFlagUtils;
+
import com.android.settings.core.FeatureFlags;
import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.datetime.timezone.ZonePicker;
+import com.android.settings.datetime.timezone.TimeZoneSettings;
import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.datetime.ZoneGetter;
@@ -51,7 +51,7 @@
return;
}
if (mZonePickerV2) {
- preference.setFragment(ZonePicker.class.getName());
+ preference.setFragment(TimeZoneSettings.class.getName());
}
preference.setSummary(getTimeZoneOffsetAndName());
if( !((RestrictedPreference) preference).isDisabledByAdmin()) {
diff --git a/tests/uitests/src/com/android/settings/ui/ZonePickerSettingsTest.java b/tests/uitests/src/com/android/settings/ui/ZonePickerSettingsTest.java
index 109c3bc..30206bc 100644
--- a/tests/uitests/src/com/android/settings/ui/ZonePickerSettingsTest.java
+++ b/tests/uitests/src/com/android/settings/ui/ZonePickerSettingsTest.java
@@ -32,8 +32,6 @@
import android.support.test.uiautomator.Until;
import android.system.helpers.SettingsHelper;
import android.system.helpers.SettingsHelper.SettingsType;
-import android.widget.ListView;
-import android.widget.Spinner;
import org.junit.After;
import org.junit.Before;
@@ -102,16 +100,16 @@
// Test 2 time zones with no DST
@Test
public void testSelectReykjavik() throws Exception {
- testSelectTimeZone("Iceland", "Reykjavik", "GMT+00:00", "Atlantic/Reykjavik");
+ testSelectTimeZone("Iceland", "Reykjavik", "GMT+00:00", "Atlantic/Reykjavik", true);
}
@Test
public void testSelectPhoenix() throws Exception {
- testSelectTimeZone("United States", "Phoenix", "GMT-07:00", "America/Phoenix");
+ testSelectTimeZone("United States", "Phoenix", "GMT-07:00", "America/Phoenix", false);
}
private void testSelectTimeZone(String region, String timezone, String expectedTimeZoneOffset,
- String expectedTimeZoneId) throws Exception {
+ String expectedTimeZoneId, boolean assumeOneTimeZoneInRegion) throws Exception {
mHelper.setIntSetting(SettingsType.GLOBAL, Settings.Global.AUTO_TIME_ZONE, 0);
SettingsHelper.launchSettingsPage(
@@ -121,16 +119,21 @@
assertTrue(selectTimeZone.isEnabled());
selectTimeZone.click();
- // Select region in the dropdown list
- selectScrollableItem(selectDropDownInSpinner(By.clazz(Spinner.class)),
- new UiSelector().textContains(region))
+ wait(By.text("Region")).click();
+ // Speed-up the test by searching with the first 2 characters of the region name
+ wait(By.res("android", "search_src_text")).setText(region.substring(0, 2));
+ // Select region in the list
+ selectItemInList(new UiSelector().textContains(region))
.click();
- // Select time zone
- selectScrollableItem(selectTimeZoneList(),
- new UiSelector().textContains(timezone))
- .click();
+ // Only select time zone explicitly if there are more than one time zones in a region
+ if (!assumeOneTimeZoneInRegion) {
+ wait(By.text("Time Zone"));
+ selectItemInList(new UiSelector().textContains(timezone))
+ .click();
+ }
+ mDevice.pressBack();
// The select button should include the GMT offset in the summary
BySelector summarySelector = By.res("android:id/summary");
UiObject2 selectedTimeZone = selectTimeZone.findObject(summarySelector);
@@ -162,21 +165,10 @@
assertEquals(expectedTimeZoneId, TimeZone.getDefault().getID());
}
- /**
- * Perform click on {@link Spinner} and return the pop-up dropdown list.
- * @return UiScrollable representing the pop-up dropdown after clicking on the spinner
- */
- private UiScrollable selectDropDownInSpinner(BySelector spinnerSelector)
- throws UiObjectNotFoundException {
- UiObject2 spinner = wait(spinnerSelector);
- spinner.click();
-
- UiSelector dropDownSelector = new UiSelector().className(ListView.class);
- return new UiScrollable(dropDownSelector);
- }
-
- private UiScrollable selectTimeZoneList() {
- return new UiScrollable(new UiSelector().resourceId(SETTINGS_PACKAGE + ":id/tz_list"));
+ private UiObject selectItemInList(UiSelector childSelector) throws UiObjectNotFoundException {
+ UiScrollable recyclerView = new UiScrollable(
+ new UiSelector().resourceId(SETTINGS_PACKAGE + ":id/recycler_view"));
+ return selectScrollableItem(recyclerView, childSelector);
}
/**