Bug 965606 - Part 2: Update tests for new string and nested preference panels. r=margaret

This commit is contained in:
Chenxia Liu 2014-03-07 15:28:56 -08:00
Родитель 7090778b12
Коммит f11121a83f
1 изменённых файлов: 52 добавлений и 25 удалений

Просмотреть файл

@ -26,18 +26,27 @@ public class testSettingsMenuItems extends PixelTest {
* where defaultValue is optional, and there can be multiple options.
*
* These menu items are the ones that are always present - to test menu items that differ
* based on build (e.g., release vs. nightly), add the items in <code>addConditionalSettings</code>.
* based on build (e.g., release vs. nightly), add the items in <code>addConditionalSettings</code>.
*/
// Customize menu items.
String[] PATH_CUSTOMIZE = { "Customize" };
String[][] OPTIONS_CUSTOMIZE = {
{ "Home", "", "Panels" },
{ "Home" },
{ "Search", "", "Show search suggestions", "Installed search engines"},
{ "Tabs", "Don't restore after quitting " + BRAND_NAME, "Always restore", "Don't restore after quitting " + BRAND_NAME },
{ "Import from Android", "", "Bookmarks", "History", "Import" },
};
// Home panel menu items.
String[] PATH_HOME = { "Customize", "Home" };
String[][] OPTIONS_HOME = {
{ "Panels" },
{ "Automatic updates", "Enabled", "Enabled", "Only over Wi-Fi" },
};
// Display menu items.
String[] PATH_DISPLAY = { "Display" };
String[][] OPTIONS_DISPLAY = {
{ "Text size" },
{ "Title bar", "Show page title", "Show page title", "Show page address" },
@ -47,6 +56,7 @@ public class testSettingsMenuItems extends PixelTest {
};
// Privacy menu items.
String[] PATH_PRIVACY = { "Privacy" };
String[][] OPTIONS_PRIVACY = {
{ "Tracking", "Do not tell sites anything about my tracking preferences", "Tell sites that I do not want to be tracked", "Tell sites that I want to be tracked", "Do not tell sites anything about my tracking preferences" },
{ "Cookies", "Enabled", "Enabled, excluding 3rd party", "Disabled" },
@ -55,6 +65,8 @@ public class testSettingsMenuItems extends PixelTest {
{ "Clear private data", "", "Browsing & download history", "Downloaded files", "Form & search history", "Cookies & active logins", "Saved passwords", "Cache", "Offline website data", "Site settings", "Clear data" },
};
// Mozilla/vendor menu items.
String[] PATH_MOZILLA = { "Mozilla" };
String[][] OPTIONS_MOZILLA = {
{ "About " + BRAND_NAME },
{ "FAQs" },
@ -68,19 +80,21 @@ public class testSettingsMenuItems extends PixelTest {
/*
* This sets up a hierarchy of settings to test.
*
* The keys are the top-level settings categories, and each value is a
* List of menu items contained within each category.
* The keys are String arrays representing the path through menu items
* (the single-item arrays being top-level categories), and each value
* is a List of menu items contained within each category.
*
* Each menu item is itself an array as follows:
* - item title
* - default string value of item (optional)
* - string values of options that are displayed once clicked (optional).
*/
public void setupSettingsMap(Map<String, List<String[]>> settingsMap) {
settingsMap.put("Customize", new ArrayList<String[]>(Arrays.asList(OPTIONS_CUSTOMIZE)));
settingsMap.put("Display", new ArrayList<String[]>(Arrays.asList(OPTIONS_DISPLAY)));
settingsMap.put("Privacy", new ArrayList<String[]>(Arrays.asList(OPTIONS_PRIVACY)));
settingsMap.put("Mozilla", new ArrayList<String[]>(Arrays.asList(OPTIONS_MOZILLA)));
public void setupSettingsMap(Map<String[], List<String[]>> settingsMap) {
settingsMap.put(PATH_CUSTOMIZE, new ArrayList<String[]>(Arrays.asList(OPTIONS_CUSTOMIZE)));
settingsMap.put(PATH_HOME, new ArrayList<String[]>(Arrays.asList(OPTIONS_HOME)));
settingsMap.put(PATH_DISPLAY, new ArrayList<String[]>(Arrays.asList(OPTIONS_DISPLAY)));
settingsMap.put(PATH_PRIVACY, new ArrayList<String[]>(Arrays.asList(OPTIONS_PRIVACY)));
settingsMap.put(PATH_MOZILLA, new ArrayList<String[]>(Arrays.asList(OPTIONS_MOZILLA)));
}
@Override
@ -93,7 +107,7 @@ public class testSettingsMenuItems extends PixelTest {
mMidWidth = mDriver.getGeckoWidth()/2;
mMidHeight = mDriver.getGeckoHeight()/2;
Map<String, List<String[]>> settingsMenuItems = new HashMap<String, List<String[]>>();
Map<String[], List<String[]>> settingsMenuItems = new HashMap<String[], List<String[]>>();
setupSettingsMap(settingsMenuItems);
// Set special handling for Settings items that are conditionally built.
@ -137,46 +151,52 @@ public class testSettingsMenuItems extends PixelTest {
* Check for conditions for building certain settings, and add them to be tested
* if they are present.
*/
public void addConditionalSettings(Map<String, List<String[]>> settingsMap) {
public void addConditionalSettings(Map<String[], List<String[]>> settingsMap) {
// Preferences dependent on RELEASE_BUILD
if (!AppConstants.RELEASE_BUILD) {
// Text reflow - only built if *not* release build
String[] textReflowUi = { "Text reflow" };
settingsMap.get("Display").add(textReflowUi);
settingsMap.get(PATH_DISPLAY).add(textReflowUi);
// Anonymous cell tower/wifi collection - only built if *not* release build
String[] networkReportingUi = { "Mozilla location services", "Help improve geolocation services for the Open Web by letting " + BRAND_NAME + " collect and send anonymous cellular tower data" };
settingsMap.get("Mozilla").add(networkReportingUi);
settingsMap.get(PATH_MOZILLA).add(networkReportingUi);
}
// Automatic updates
if (AppConstants.MOZ_UPDATER) {
String[] autoUpdateUi = { "Download updates automatically", "Only over Wi-Fi", "Always", "Only over Wi-Fi", "Never" };
settingsMap.get("Customize").add(autoUpdateUi);
settingsMap.get(PATH_CUSTOMIZE).add(autoUpdateUi);
}
// Crash reporter
if (AppConstants.MOZ_CRASHREPORTER) {
String[] crashReporterUi = { "Crash Reporter", BRAND_NAME + " submits crash reports to help Mozilla make your browser more stable and secure" };
settingsMap.get("Mozilla").add(crashReporterUi);
settingsMap.get(PATH_MOZILLA).add(crashReporterUi);
}
// Telemetry
if (AppConstants.MOZ_TELEMETRY_REPORTING) {
String[] telemetryUi = { "Telemetry", "Shares performance, usage, hardware and customization data about your browser with Mozilla to help us make " + BRAND_NAME + " better" };
settingsMap.get("Mozilla").add(telemetryUi);
settingsMap.get(PATH_MOZILLA).add(telemetryUi);
}
}
public void checkMenuHierarchy(Map<String, List<String[]>> settingsMap) {
public void checkMenuHierarchy(Map<String[], List<String[]>> settingsMap) {
// Check the items within each category.
for (Entry<String, List<String[]>> e : settingsMap.entrySet()) {
String section = "^" + e.getKey() + "$";
List<String[]> sectionItems = e.getValue();
String section = null;
for (Entry<String[], List<String[]>> e : settingsMap.entrySet()) {
final String[] menuPath = e.getKey();
waitForEnabledText(section);
mSolo.clickOnText(section);
for (String menuItem : menuPath) {
section = "^" + menuItem + "$";
waitForEnabledText(section);
mSolo.clickOnText(section);
}
List<String[]> sectionItems = e.getValue();
// Check each item of the section.
for (String[] item : sectionItems) {
@ -209,6 +229,7 @@ public class testSettingsMenuItems extends PixelTest {
+ " in section " + section,
"The " + itemChoice + " choice is present in section " + section);
}
// Leave submenu after checking.
if (waitForText("^Cancel$")) {
mSolo.clickOnText("^Cancel$");
@ -218,10 +239,16 @@ public class testSettingsMenuItems extends PixelTest {
}
}
}
// Navigate back a screen if on a phone.
// Navigate back if on a phone. Tablets shouldn't do this because they use headers and fragments.
if (mDevice.type.equals("phone")) {
// Click back to return to previous menu. Tablets shouldn't do this because they use headers and fragments.
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
int menuDepth = menuPath.length;
while (menuDepth > 0) {
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
menuDepth--;
// Sleep so subsequent back actions aren't lost.
mSolo.sleep(50);
}
}
}
}