Bug 912519 - (1) Update robocop testSettingsMenuItems to allow for partially obscured menu item; r=liuche
authorGeoff Brown <gbrown@mozilla.com>
Tue, 10 Sep 2013 18:18:04 -0600
changeset 146480 380a028c1a60edc10bab98fb8fef1bc857014d95
parent 146479 057ef596d743e8de54ad812462edebbe98813652
child 146481 c856007f844e5793077dc1e4cf62d8e875ea0682
push id25261
push usercbook@mozilla.com
push dateWed, 11 Sep 2013 07:31:01 +0000
treeherdermozilla-central@f9e8e8ce552c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersliuche
bugs912519
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 912519 - (1) Update robocop testSettingsMenuItems to allow for partially obscured menu item; r=liuche
mobile/android/base/tests/testSettingsMenuItems.java.in
--- a/mobile/android/base/tests/testSettingsMenuItems.java.in
+++ b/mobile/android/base/tests/testSettingsMenuItems.java.in
@@ -10,18 +10,18 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.HashMap;
 
 /** This patch tests the Sections present in the Settings Menu and the
  *  default values for them
  */
 public class testSettingsMenuItems extends PixelTest {
-    int midWidth;
-    int midHeight;
+    int mMidWidth;
+    int mMidHeight;
     String BRAND_NAME = "(Fennec|Nightly|Aurora|Firefox|Firefox Beta)";
 
     /**
      * The following String[][] (arrays) match the menu hierarchy for each section.
      * Each String[] (array) represents the menu items/choices in the following order:
      *
      * itemTitle { defaultValue [options] }
      *
@@ -86,18 +86,18 @@ public class testSettingsMenuItems exten
 
     @Override
     protected int getTestType() {
         return TEST_MOCHITEST;
     }
 
     public void testSettingsMenuItems() {
         blockForGeckoReady();
-        midWidth = mDriver.getGeckoWidth()/2;
-        midHeight = mDriver.getGeckoHeight()/2;
+        mMidWidth = mDriver.getGeckoWidth()/2;
+        mMidHeight = mDriver.getGeckoHeight()/2;
 
         Map<String, List<String[]>> settingsMenuItems = new HashMap<String, List<String[]>>();
         setupSettingsMap(settingsMenuItems);
 
         // Set special handling for Settings items that are conditionally built.
         addConditionalSettings(settingsMenuItems);
 
         selectMenuItem("Settings");
@@ -207,50 +207,60 @@ public class testSettingsMenuItems exten
             for (String[] item : sectionItems) {
                 int itemLen = item.length;
 
                 // Each item must at least have a title.
                 mAsserter.ok(item.length > 0, "Section-item", "Each item must at least have a title");
 
                 // Check item title.
                 String itemTitle = "^" + item[0] + "$";
-                if (!waitForText(itemTitle)) {
+                boolean foundText = waitForText(itemTitle);
+                if (!foundText) {
                     // If we don't see the item, scroll down once in case it's off-screen.
                     scrollDown();
+                    foundText = mSolo.waitForText(itemTitle);
                 }
-                mAsserter.ok(mSolo.waitForText(itemTitle), "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);
                 // Check item default, if it exists.
                 if (itemLen > 1) {
                     String itemDefault = "^" + item[1] + "$";
-                    mAsserter.ok(mSolo.waitForText(itemDefault), "Waiting for settings item default " + itemDefault
+                    foundText = waitForText(itemDefault);
+                    if (!foundText) {
+                        // If we don't see the item, scroll down once in case it's off-screen.
+                        scrollDown();
+                        foundText = mSolo.waitForText(itemDefault);
+                    }
+                    mAsserter.ok(foundText, "Waiting for settings item default " + itemDefault
                                  + " in section " + section,
                                  "The " + itemDefault + " default is present in section " + section);
                 }
                 // Check item choices, if they exist.
                 if (itemLen > 2) {
-                  waitForEnabledText(itemTitle);
-                  mSolo.clickOnText(itemTitle);
-                  for (int i = 2; i < itemLen; i++) {
-                      String itemChoice = "^" + item[i] + "$";
-                      if (!waitForText(itemChoice)) {
-                          // If we don't see the item, scroll down once in case it's off-screen.
-                          scrollDown();
-                      }
-                      mAsserter.ok(mSolo.waitForText(itemChoice), "Waiting for settings item choice " + itemChoice
-                                   + " in section " + section,
-                                   "The " + itemChoice + " choice is present in section " + section);
-                  }
-                  // Leave submenu after checking.
-                  if (waitForText("^Cancel$")) {
-                      mSolo.clickOnText("^Cancel$");
-                  } else {
-                      // Some submenus aren't dialogs, but are nested screens; exit using "back".
-                      mActions.sendSpecialKey(Actions.SpecialKey.BACK);
-                  }
+                    waitForEnabledText(itemTitle);
+                    mSolo.clickOnText(itemTitle);
+                    for (int i = 2; i < itemLen; i++) {
+                        String itemChoice = "^" + item[i] + "$";
+                        foundText = waitForText(itemChoice);
+                        if (!foundText) {
+                            // If we don't see the item, scroll down once in case it's off-screen.
+                            scrollDown();
+                            foundText = mSolo.waitForText(itemChoice);
+                        }
+                        mAsserter.ok(foundText, "Waiting for settings item choice " + itemChoice
+                                     + " in section " + section,
+                                     "The " + itemChoice + " choice is present in section " + section);
+                    }
+                    // Leave submenu after checking.
+                    if (waitForText("^Cancel$")) {
+                        mSolo.clickOnText("^Cancel$");
+                    } else {
+                        // Some submenus aren't dialogs, but are nested screens; exit using "back".
+                        mActions.sendSpecialKey(Actions.SpecialKey.BACK);
+                    }
                 }
             }
             // Navigate back a screen if on a phone.
             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);
             }
         }
@@ -258,11 +268,11 @@ public class testSettingsMenuItems exten
 
     /**
      * Hacky way to scroll down.
      *
      * solo.scroll* does not work in dialogs.
      */
     private void scrollDown() {
         MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop());
-        meh.dragSync(midWidth, midHeight+100, midWidth, midHeight-100);
+        meh.dragSync(mMidWidth, mMidHeight+100, mMidWidth, mMidHeight-100);
     }
 }