mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 903535 - Tests. r=bnicholson
This commit is contained in:
parent
44f02d578e
commit
9578cec2c9
@ -75,6 +75,8 @@ abstract class BaseTest extends BaseRobocopTest {
|
|||||||
public Device mDevice;
|
public Device mDevice;
|
||||||
protected DatabaseHelper mDatabaseHelper;
|
protected DatabaseHelper mDatabaseHelper;
|
||||||
protected StringHelper mStringHelper;
|
protected StringHelper mStringHelper;
|
||||||
|
protected int mScreenMidWidth;
|
||||||
|
protected int mScreenMidHeight;
|
||||||
|
|
||||||
protected void blockForGeckoReady() {
|
protected void blockForGeckoReady() {
|
||||||
try {
|
try {
|
||||||
@ -364,6 +366,27 @@ abstract class BaseTest extends BaseRobocopTest {
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// waitForText usually scrolls down in a view when text is not visible.
|
||||||
|
// For PreferenceScreens and dialogs, Solo.waitForText scrolling does not
|
||||||
|
// work, so we use this hack to do the same thing.
|
||||||
|
protected boolean waitForPreferencesText(String txt) {
|
||||||
|
boolean foundText = waitForText(txt);
|
||||||
|
if (!foundText) {
|
||||||
|
if ((mScreenMidWidth == 0) || (mScreenMidHeight == 0)) {
|
||||||
|
mScreenMidWidth = mDriver.getGeckoWidth()/2;
|
||||||
|
mScreenMidHeight = mDriver.getGeckoHeight()/2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we don't see the item, scroll down once in case it's off-screen.
|
||||||
|
// Hacky way to scroll down. solo.scroll* does not work in dialogs.
|
||||||
|
MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop());
|
||||||
|
meh.dragSync(mScreenMidWidth, mScreenMidHeight+100, mScreenMidWidth, mScreenMidHeight-100);
|
||||||
|
|
||||||
|
foundText = mSolo.waitForText(txt);
|
||||||
|
}
|
||||||
|
return foundText;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait for <text> to be visible and also be enabled/clickable.
|
* Wait for <text> to be visible and also be enabled/clickable.
|
||||||
*/
|
*/
|
||||||
@ -415,7 +438,7 @@ abstract class BaseTest extends BaseRobocopTest {
|
|||||||
if (listLength > 1) {
|
if (listLength > 1) {
|
||||||
for (int i = 1; i < listLength; i++) {
|
for (int i = 1; i < listLength; i++) {
|
||||||
String itemName = "^" + listItems[i] + "$";
|
String itemName = "^" + listItems[i] + "$";
|
||||||
if (!waitForEnabledText(itemName)) {
|
if (!waitForPreferencesText(itemName)) {
|
||||||
mSolo.scrollDown();
|
mSolo.scrollDown();
|
||||||
}
|
}
|
||||||
mSolo.clickOnText(itemName);
|
mSolo.clickOnText(itemName);
|
||||||
|
@ -14,8 +14,6 @@ import org.mozilla.gecko.AppConstants;
|
|||||||
* default values for them
|
* default values for them
|
||||||
*/
|
*/
|
||||||
public class testSettingsMenuItems extends PixelTest {
|
public class testSettingsMenuItems extends PixelTest {
|
||||||
int mMidWidth;
|
|
||||||
int mMidHeight;
|
|
||||||
String BRAND_NAME = "(Fennec|Nightly|Aurora|Firefox|Firefox Beta)";
|
String BRAND_NAME = "(Fennec|Nightly|Aurora|Firefox|Firefox Beta)";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,8 +98,6 @@ public class testSettingsMenuItems extends PixelTest {
|
|||||||
|
|
||||||
public void testSettingsMenuItems() {
|
public void testSettingsMenuItems() {
|
||||||
blockForGeckoReady();
|
blockForGeckoReady();
|
||||||
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);
|
setupSettingsMap(settingsMenuItems);
|
||||||
@ -155,9 +151,11 @@ public class testSettingsMenuItems extends PixelTest {
|
|||||||
settingsMap.get(PATH_DISPLAY).add(textReflowUi);
|
settingsMap.get(PATH_DISPLAY).add(textReflowUi);
|
||||||
|
|
||||||
// Anonymous cell tower/wifi collection - only built if *not* release build
|
// 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" };
|
String[] networkReportingUi = { "Mozilla Location Service", "Receives Wi-Fi and cellular location data when running in the background and shares it with Mozilla to improve our geolocation service" };
|
||||||
settingsMap.get(PATH_MOZILLA).add(networkReportingUi);
|
settingsMap.get(PATH_MOZILLA).add(networkReportingUi);
|
||||||
|
|
||||||
|
String[] learnMoreUi = { "Learn more" };
|
||||||
|
settingsMap.get(PATH_MOZILLA).add(learnMoreUi);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automatic updates
|
// Automatic updates
|
||||||
@ -203,13 +201,14 @@ public class testSettingsMenuItems extends PixelTest {
|
|||||||
|
|
||||||
// Check item title.
|
// Check item title.
|
||||||
String itemTitle = "^" + item[0] + "$";
|
String itemTitle = "^" + item[0] + "$";
|
||||||
boolean foundText = waitExtraForText(itemTitle);
|
boolean foundText = waitForPreferencesText(itemTitle);
|
||||||
|
|
||||||
mAsserter.ok(foundText, "Waiting for settings item " + itemTitle + " in section " + section,
|
mAsserter.ok(foundText, "Waiting for settings item " + itemTitle + " in section " + section,
|
||||||
"The " + itemTitle + " option is present in section " + section);
|
"The " + itemTitle + " option is present in section " + section);
|
||||||
// Check item default, if it exists.
|
// Check item default, if it exists.
|
||||||
if (itemLen > 1) {
|
if (itemLen > 1) {
|
||||||
String itemDefault = "^" + item[1] + "$";
|
String itemDefault = "^" + item[1] + "$";
|
||||||
foundText = waitExtraForText(itemDefault);
|
foundText = waitForPreferencesText(itemDefault);
|
||||||
mAsserter.ok(foundText, "Waiting for settings item default " + itemDefault
|
mAsserter.ok(foundText, "Waiting for settings item default " + itemDefault
|
||||||
+ " in section " + section,
|
+ " in section " + section,
|
||||||
"The " + itemDefault + " default is present in section " + section);
|
"The " + itemDefault + " default is present in section " + section);
|
||||||
@ -220,7 +219,7 @@ public class testSettingsMenuItems extends PixelTest {
|
|||||||
mSolo.clickOnText(itemTitle);
|
mSolo.clickOnText(itemTitle);
|
||||||
for (int i = 2; i < itemLen; i++) {
|
for (int i = 2; i < itemLen; i++) {
|
||||||
String itemChoice = "^" + item[i] + "$";
|
String itemChoice = "^" + item[i] + "$";
|
||||||
foundText = waitExtraForText(itemChoice);
|
foundText = waitForPreferencesText(itemChoice);
|
||||||
mAsserter.ok(foundText, "Waiting for settings item choice " + itemChoice
|
mAsserter.ok(foundText, "Waiting for settings item choice " + itemChoice
|
||||||
+ " in section " + section,
|
+ " in section " + section,
|
||||||
"The " + itemChoice + " choice is present in section " + section);
|
"The " + itemChoice + " choice is present in section " + section);
|
||||||
@ -248,20 +247,4 @@ public class testSettingsMenuItems extends PixelTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Solo.waitForText usually scrolls down in a view when text is not visible.
|
|
||||||
// In this test, Solo.waitForText scrolling does not work, so we use this
|
|
||||||
// hack to do the same thing.
|
|
||||||
private boolean waitExtraForText(String txt) {
|
|
||||||
boolean foundText = waitForText(txt);
|
|
||||||
if (!foundText) {
|
|
||||||
// If we don't see the item, scroll down once in case it's off-screen.
|
|
||||||
// Hacky way to scroll down. solo.scroll* does not work in dialogs.
|
|
||||||
MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop());
|
|
||||||
meh.dragSync(mMidWidth, mMidHeight+100, mMidWidth, mMidHeight-100);
|
|
||||||
|
|
||||||
foundText = mSolo.waitForText(txt);
|
|
||||||
}
|
|
||||||
return foundText;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user