Bug 923109 - Load pages differently in many robocop tests; r=margaret
authorGeoff Brown <gbrown@mozilla.com>
Tue, 24 Mar 2015 06:51:46 -0600
changeset 264099 e609a7d24a153a916ac261527b1d9b35ebb2170d
parent 264098 e4214ff58dab8060a336c3ef8d7cf36ea4bd02df
child 264100 5627301b95de8f603d8a1624d1a9f826474cef20
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs923109
milestone39.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 923109 - Load pages differently in many robocop tests; r=margaret
mobile/android/base/tests/BaseTest.java
mobile/android/base/tests/PixelTest.java
mobile/android/base/tests/testAboutPage.java
mobile/android/base/tests/testClearPrivateData.java
mobile/android/base/tests/testDoorHanger.java
mobile/android/base/tests/testGetUserMedia.java
mobile/android/base/tests/testLinkContextMenu.java
mobile/android/base/tests/testMailToContextMenu.java
mobile/android/base/tests/testTitleBar.java
--- a/mobile/android/base/tests/BaseTest.java
+++ b/mobile/android/base/tests/BaseTest.java
@@ -235,38 +235,53 @@ abstract class BaseTest extends BaseRobo
         contentEventExpecter.unregisterListener();
     }
 
     /**
      * Load <code>url</code> by sending key strokes to the URL bar UI.
      *
      * This method waits synchronously for the <code>DOMContentLoaded</code>
      * message from Gecko before returning.
+     *
+     * Unless you need to test text entry in the url bar, consider using loadUrl
+     * instead -- it loads pages more directly and quickly.
      */
     protected final void inputAndLoadUrl(String url) {
         enterUrl(url);
         hitEnterAndWait();
     }
 
     /**
-     * Load <code>url</code> using reflection and the internal
+     * Load <code>url</code> using the internal
      * <code>org.mozilla.gecko.Tabs</code> API.
      *
      * This method does not wait for any confirmation from Gecko before
-     * returning.
+     * returning -- consider using verifyUrlBarTitle or a similar approach
+     * to wait for the page to load, or at least use loadUrlAndWait.
      */
     protected final void loadUrl(final String url) {
         try {
             Tabs.getInstance().loadUrl(url);
         } catch (Exception e) {
             mAsserter.dumpLog("Exception in loadUrl", e);
             throw new RuntimeException(e);
         }
     }
 
+    /**
+     * Load <code>url</code> using the internal
+     * <code>org.mozilla.gecko.Tabs</code> API and wait for DOMContentLoaded.
+     */
+    protected final void loadUrlAndWait(final String url) {
+        Actions.EventExpecter contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
+        loadUrl(url);
+        contentEventExpecter.blockForEvent();
+        contentEventExpecter.unregisterListener();
+    }
+
     protected final void closeTab(int tabId) {
         Tabs tabs = Tabs.getInstance();
         Tab tab = tabs.getTab(tabId);
         tabs.closeTab(tab);
     }
 
     public final void verifyUrl(String url) {
         final EditText urlEditText = (EditText) mSolo.getView(R.id.url_edit_text);
--- a/mobile/android/base/tests/PixelTest.java
+++ b/mobile/android/base/tests/PixelTest.java
@@ -7,17 +7,17 @@ package org.mozilla.gecko.tests;
 import org.mozilla.gecko.Actions;
 import org.mozilla.gecko.PaintedSurface;
 
 abstract class PixelTest extends BaseTest {
     private static final long PAINT_CLEAR_DELAY = 10000; // milliseconds
 
     protected final PaintedSurface loadAndGetPainted(String url) {
         Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint();
-        inputAndLoadUrl(url);
+        loadUrl(url);
         verifyHomePagerHidden();
         paintExpecter.blockUntilClear(PAINT_CLEAR_DELAY);
         paintExpecter.unregisterListener();
         PaintedSurface p = mDriver.getPaintedSurface();
         if (p == null) {
             mAsserter.ok(p != null, "checking that painted surface loaded", 
                  "painted surface loaded");
         }
--- a/mobile/android/base/tests/testAboutPage.java
+++ b/mobile/android/base/tests/testAboutPage.java
@@ -23,17 +23,17 @@ public class testAboutPage extends Pixel
         // Load the about: page and verify its title.
         String url = StringHelper.ABOUT_SCHEME;
         loadAndPaint(url);
 
         verifyUrlBarTitle(url);
 
         // Open a new page to remove the about: page from the current tab.
         url = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
-        inputAndLoadUrl(url);
+        loadUrl(url);
 
         // At this point the page title should have been set.
         verifyUrlBarTitle(url);
 
         // Set up listeners to catch the page load we're about to do.
         Actions.EventExpecter tabEventExpecter = mActions.expectGeckoEvent("Tab:Added");
         Actions.EventExpecter contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
 
--- a/mobile/android/base/tests/testClearPrivateData.java
+++ b/mobile/android/base/tests/testClearPrivateData.java
@@ -32,17 +32,17 @@ public class testClearPrivateData extend
 
     private void clearHistory() {
 
         // Loading a page and adding a second one as bookmark to have user made bookmarks and history
         String blank1 = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
         String blank2 = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_02_URL);
         String title = StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE;
 
-        inputAndLoadUrl(blank1);
+        loadUrl(blank1);
         verifyUrlBarTitle(blank1);
         mDatabaseHelper.addOrUpdateMobileBookmark(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE, blank2);
 
         // Checking that the history list is not empty
         verifyHistoryCount(1);
 
         //clear and check for device
         checkDevice(title, blank1);
@@ -96,17 +96,17 @@ public class testClearPrivateData extend
             mAsserter.ok(waitForText(StringHelper.PRIVACY_SECTION_LABEL), "waiting to perform one back", "one back");
         }
         mActions.sendSpecialKey(Actions.SpecialKey.BACK);
         verifyUrlBarTitle(url);
     }
 
     // Load a URL, verify that the doorhanger appears and dismiss it
     public void loadCheckDismiss(String option, String url, String message) {
-        inputAndLoadUrl(url);
+        loadUrlAndWait(url);
         waitForText(message);
         mAsserter.is(mSolo.searchText(message), true, "Doorhanger:" + message + " has been displayed");
         mSolo.clickOnButton(option);
         mAsserter.is(mSolo.searchText(message), false, "Doorhanger:" + message + " has been hidden");
     }
 
     //Verify if there are settings to be clear if so clear them from the URL bar context menu
     public void checkOption(String option, String button) {
--- a/mobile/android/base/tests/testDoorHanger.java
+++ b/mobile/android/base/tests/testDoorHanger.java
@@ -24,41 +24,41 @@ public class testDoorHanger extends Base
         String GEO_URL = getAbsoluteUrl(StringHelper.ROBOCOP_GEOLOCATION_URL);
         String BLANK_URL = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
         String OFFLINE_STORAGE_URL = getAbsoluteUrl(StringHelper.ROBOCOP_OFFLINE_STORAGE_URL);
         String LOGIN_URL = getAbsoluteUrl(StringHelper.ROBOCOP_LOGIN_URL);
 
         blockForGeckoReady();
 
         // Test geolocation notification
-        inputAndLoadUrl(GEO_URL);
+        loadUrlAndWait(GEO_URL);
         waitForText(StringHelper.GEO_MESSAGE);
         mAsserter.is(mSolo.searchText(StringHelper.GEO_MESSAGE), true, "Geolocation doorhanger has been displayed");
 
         // Test "Share" button hides the notification
         waitForCheckBox();
         mSolo.clickOnCheckBox(0);
         mSolo.clickOnButton(StringHelper.GEO_ALLOW);
         waitForTextDismissed(StringHelper.GEO_MESSAGE);
         mAsserter.is(mSolo.searchText(StringHelper.GEO_MESSAGE), false, "Geolocation doorhanger has been hidden when allowing share");
 
         // Re-trigger geolocation notification
-        inputAndLoadUrl(GEO_URL);
+        loadUrlAndWait(GEO_URL);
         waitForText(StringHelper.GEO_MESSAGE);
 
         // Test "Don't share" button hides the notification
         waitForCheckBox();
         mSolo.clickOnCheckBox(0);
         mSolo.clickOnButton(StringHelper.GEO_DENY);
         waitForTextDismissed(StringHelper.GEO_MESSAGE);
         mAsserter.is(mSolo.searchText(StringHelper.GEO_MESSAGE), false, "Geolocation doorhanger has been hidden when denying share");
 
         /* FIXME: disabled on fig - bug 880060 (for some reason this fails because of some raciness)
         // Re-trigger geolocation notification
-        inputAndLoadUrl(GEO_URL);
+        loadUrlAndWait(GEO_URL);
         waitForText(GEO_MESSAGE);
 
         // Add a new tab
         addTab(BLANK_URL);
 
         // Make sure doorhanger is hidden
         mAsserter.is(mSolo.searchText(GEO_MESSAGE), false, "Geolocation doorhanger notification is hidden when opening a new tab");
         */
@@ -93,60 +93,60 @@ public class testDoorHanger extends Base
             jsonPref.put("type", "bool");
             jsonPref.put("value", false);
             setPreferenceAndWaitForChange(jsonPref);
         } catch (JSONException e) {
             mAsserter.ok(false, "exception getting preference", e.toString());
         }
 
         // Load offline storage page
-        inputAndLoadUrl(OFFLINE_STORAGE_URL);
+        loadUrlAndWait(OFFLINE_STORAGE_URL);
         waitForText(StringHelper.OFFLINE_MESSAGE);
 
         // Test doorhanger dismissed when tapping "Don't share"
         waitForCheckBox();
         mSolo.clickOnCheckBox(0);
         mSolo.clickOnButton(StringHelper.OFFLINE_DENY);
         waitForTextDismissed(StringHelper.OFFLINE_MESSAGE);
         mAsserter.is(mSolo.searchText(StringHelper.OFFLINE_MESSAGE), false, "Offline storage doorhanger notification is hidden when denying storage");
 
         // Load offline storage page
-        inputAndLoadUrl(OFFLINE_STORAGE_URL);
+        loadUrlAndWait(OFFLINE_STORAGE_URL);
         waitForText(StringHelper.OFFLINE_MESSAGE);
 
         // Test doorhanger dismissed when tapping "Allow" and is not displayed again
         mSolo.clickOnButton(StringHelper.OFFLINE_ALLOW);
         waitForTextDismissed(StringHelper.OFFLINE_MESSAGE);
         mAsserter.is(mSolo.searchText(StringHelper.OFFLINE_MESSAGE), false, "Offline storage doorhanger notification is hidden when allowing storage");
-        inputAndLoadUrl(OFFLINE_STORAGE_URL);
+        loadUrlAndWait(OFFLINE_STORAGE_URL);
         mAsserter.is(mSolo.searchText(StringHelper.OFFLINE_MESSAGE), false, "Offline storage doorhanger is no longer triggered");
 
         try {
             // Revert offline setting
             JSONObject jsonPref = new JSONObject();
             jsonPref.put("name", "offline-apps.allow_by_default");
             jsonPref.put("type", "bool");
             jsonPref.put("value", offlineAllowedByDefault);
             setPreferenceAndWaitForChange(jsonPref);
         } catch (JSONException e) {
             mAsserter.ok(false, "exception setting preference", e.toString());
         }
 
 
         // Load login page
-        inputAndLoadUrl(LOGIN_URL);
+        loadUrlAndWait(LOGIN_URL);
         waitForText(StringHelper.LOGIN_MESSAGE);
 
         // Test doorhanger is dismissed when tapping "Don't save"
         mSolo.clickOnButton(StringHelper.LOGIN_DENY);
         waitForTextDismissed(StringHelper.LOGIN_MESSAGE);
         mAsserter.is(mSolo.searchText(StringHelper.LOGIN_MESSAGE), false, "Login doorhanger notification is hidden when denying saving password");
 
         // Load login page
-        inputAndLoadUrl(LOGIN_URL);
+        loadUrlAndWait(LOGIN_URL);
         waitForText(StringHelper.LOGIN_MESSAGE);
 
         // Test doorhanger is dismissed when tapping "Save" and is no longer triggered
         mSolo.clickOnButton(StringHelper.LOGIN_ALLOW);
         waitForTextDismissed(StringHelper.LOGIN_MESSAGE);
         mAsserter.is(mSolo.searchText(StringHelper.LOGIN_MESSAGE), false, "Login doorhanger notification is hidden when allowing saving password");
 
         testPopupBlocking();
@@ -161,17 +161,17 @@ public class testDoorHanger extends Base
             jsonPref.put("type", "bool");
             jsonPref.put("value", true);
             setPreferenceAndWaitForChange(jsonPref);
         } catch (JSONException e) {
             mAsserter.ok(false, "exception setting preference", e.toString());
         }
 
         // Load page with popup
-        inputAndLoadUrl(POPUP_URL);
+        loadUrlAndWait(POPUP_URL);
         waitForText(StringHelper.POPUP_MESSAGE);
         mAsserter.is(mSolo.searchText(StringHelper.POPUP_MESSAGE), true, "Popup blocker is displayed");
 
         // Wait for the popup to be shown.
         Actions.EventExpecter tabEventExpecter = mActions.expectGeckoEvent("Tab:Added");
 
         waitForCheckBox();
         mSolo.clickOnCheckBox(0);
@@ -189,17 +189,17 @@ public class testDoorHanger extends Base
             closeTab(data.getInt("tabID"));
 
         } catch (JSONException e) {
             mAsserter.ok(false, "exception getting event data", e.toString());
         }
         tabEventExpecter.unregisterListener();
 
         // Load page with popup
-        inputAndLoadUrl(POPUP_URL);
+        loadUrlAndWait(POPUP_URL);
         waitForText(StringHelper.POPUP_MESSAGE);
         mAsserter.is(mSolo.searchText(StringHelper.POPUP_MESSAGE), true, "Popup blocker is displayed");
 
         waitForCheckBox();
         mSolo.clickOnCheckBox(0);
         mSolo.clickOnButton(StringHelper.POPUP_DENY);
         waitForTextDismissed(StringHelper.POPUP_MESSAGE);
         mAsserter.is(mSolo.searchText(StringHelper.POPUP_MESSAGE), false, "Popup blocker is hidden when popup denied");
--- a/mobile/android/base/tests/testGetUserMedia.java
+++ b/mobile/android/base/tests/testGetUserMedia.java
@@ -49,29 +49,29 @@ public class testGetUserMedia extends Ba
         // Browser constraint needs HTTPS
         final String GUM_TAB_HTTPS_URL = GUM_TAB_URL.replace("http://mochi.test:8888", "https://example.com");
 
         // Tests on Camera page will test camera enumeration code, but
         // the actual cameras don't seem to work on the emulators, so
         // the enumeration is all that gets tested.
 
         // Test GUM notification showing
-        inputAndLoadUrl(GUM_CAMERA_URL);
+        loadUrlAndWait(GUM_CAMERA_URL);
         waitForText(GUM_MESSAGE);
         mAsserter.is(mSolo.searchText(GUM_MESSAGE), true, "getUserMedia doorhanger has been displayed");
         waitForSpinner();
         // At least one camera detected
         mAsserter.is(mSolo.searchText(GUM_BACK_CAMERA), true, "getUserMedia found a camera");
         mSolo.clickOnButton(GUM_DENY);
         waitForTextDismissed(GUM_MESSAGE);
         mAsserter.is(mSolo.searchText(GUM_MESSAGE), false, "getUserMedia doorhanger hidden after dismissal");
         verifyUrlBarTitle(GUM_CAMERA_URL);
 
         // Cameras don't work on the testing hardware, so stream a tab
-        inputAndLoadUrl(GUM_TAB_HTTPS_URL);
+        loadUrlAndWait(GUM_TAB_HTTPS_URL);
         waitForText(GUM_MESSAGE);
         mAsserter.is(mSolo.searchText(GUM_MESSAGE), true, "getUserMedia doorhanger has been displayed");
         waitForSpinner();
         mAsserter.is(mSolo.searchText(GUM_SELECT_TAB), true, "Video source selection available");
         mAsserter.is(mSolo.searchText("MICROPHONE TO USE"), true, "Microphone selection available");
         mAsserter.is(mSolo.searchText("Microphone 1"), true, "Microphone 1 available");
         mSolo.clickOnText("Microphone 1");
         waitForText("No Audio");
@@ -92,32 +92,32 @@ public class testGetUserMedia extends Ba
 
         // Android 2.3 testers fail because of audio issues:
         // E/AudioRecord(  650): Unsupported configuration: sampleRate 44100, format 1, channelCount 1
         // E/libOpenSLES(  650): android_audioRecorder_realize(0x26d7d8) error creating AudioRecord object
         if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
             return;
         }
 
-        inputAndLoadUrl(GUM_TAB_HTTPS_URL);
+        loadUrlAndWait(GUM_TAB_HTTPS_URL);
         waitForText(GUM_MESSAGE);
         mAsserter.is(mSolo.searchText(GUM_MESSAGE), true, "getUserMedia doorhanger has been displayed");
 
         waitForSpinner();
         mAsserter.is(mSolo.searchText(GUM_SELECT_TAB), true, "Video source selection available");
         mSolo.clickOnButton(GUM_ALLOW);
         waitForTextDismissed(GUM_MESSAGE);
         waitForText(GUM_SELECT_TAB);
         mAsserter.is(mSolo.searchText(GUM_SELECT_TAB), true, "Tab selection dialog displayed");
         mSolo.clickOnText(GUM_PAGE_TITLE);
         waitForTextDismissed(GUM_SELECT_TAB);
         mAsserter.is(mSolo.searchText(GUM_SELECT_TAB), false, "Tab selection dialog hidden");
         verifyUrlBarTitle(GUM_TAB_HTTPS_URL);
 
-        inputAndLoadUrl(GUM_TAB_HTTPS_URL);
+        loadUrlAndWait(GUM_TAB_HTTPS_URL);
         waitForText(GUM_MESSAGE);
         mAsserter.is(mSolo.searchText(GUM_MESSAGE), true, "getUserMedia doorhanger has been displayed");
 
         waitForSpinner();
         mAsserter.is(mSolo.searchText(GUM_SELECT_TAB), true, "Video source selection available");
         mSolo.clickOnText(GUM_SELECT_TAB);
         waitForText("No Video");
         mAsserter.is(mSolo.searchText("No Video"), true, "'No video' source selection available");
--- a/mobile/android/base/tests/testLinkContextMenu.java
+++ b/mobile/android/base/tests/testLinkContextMenu.java
@@ -13,17 +13,17 @@ public class testLinkContextMenu extends
     private static final String LINK_PAGE_TITLE = "Big Link";
     private static final String linkMenuItems [] = StringHelper.CONTEXT_MENU_ITEMS_IN_NORMAL_TAB;
 
     public void testLinkContextMenu() {
         blockForGeckoReady();
 
         LINK_PAGE_URL=getAbsoluteUrl(StringHelper.ROBOCOP_BIG_LINK_URL);
         BLANK_PAGE_URL=getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
-        inputAndLoadUrl(LINK_PAGE_URL);
+        loadUrlAndWait(LINK_PAGE_URL);
         waitForText(LINK_PAGE_TITLE);
 
         verifyContextMenuItems(linkMenuItems); // Verify context menu items are correct
         openTabFromContextMenu(linkMenuItems[0],2); // Test the "Open in New Tab" option - expecting 2 tabs: the original and the new one
         openTabFromContextMenu(linkMenuItems[1],2); // Test the "Open in Private Tab" option - expecting only 2 tabs in normal mode
         verifyCopyOption(linkMenuItems[2], BLANK_PAGE_URL); // Test the "Copy Link" option
         verifyShareOption(linkMenuItems[3], LINK_PAGE_TITLE); // Test the "Share Link" option
         verifyBookmarkLinkOption(linkMenuItems[4], BLANK_PAGE_URL); // Test the "Bookmark Link" option
--- a/mobile/android/base/tests/testMailToContextMenu.java
+++ b/mobile/android/base/tests/testMailToContextMenu.java
@@ -11,16 +11,16 @@ public class testMailToContextMenu exten
     private static String MAILTO_PAGE_URL;
     private static final String MAILTO_PAGE_TITLE = StringHelper.ROBOCOP_BIG_MAILTO_TITLE;
     private static final String mailtoMenuItems [] = {"Copy Email Address", "Share Email Address"};
 
     public void testMailToContextMenu() {
         blockForGeckoReady();
 
         MAILTO_PAGE_URL=getAbsoluteUrl(StringHelper.ROBOCOP_BIG_MAILTO_URL);
-        inputAndLoadUrl(MAILTO_PAGE_URL);
+        loadUrlAndWait(MAILTO_PAGE_URL);
         waitForText(MAILTO_PAGE_TITLE);
 
         verifyContextMenuItems(mailtoMenuItems);
         verifyCopyOption(mailtoMenuItems[0], "foo.bar@example.com"); // Test the "Copy Email Address" option
         verifyShareOption(mailtoMenuItems[1], MAILTO_PAGE_TITLE); // Test the "Share Email Address" option
     }
 }
--- a/mobile/android/base/tests/testTitleBar.java
+++ b/mobile/android/base/tests/testTitleBar.java
@@ -19,27 +19,27 @@ public class testTitleBar extends PixelT
     }
 
     public void checkOption() {
 
         String blank1 = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
         String title = StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE;
 
         // Loading a page
-        inputAndLoadUrl(blank1);
+        loadUrl(blank1);
         verifyUrlBarTitle(blank1);
 
         // Ensure the title is displayed in the URL Bar
         selectOption(StringHelper.SHOW_PAGE_TITLE_LABEL);
-        inputAndLoadUrl(blank1);
+        loadUrl(blank1);
         verifyUrlBarTitle(title);
 
         // Ensure the full URL is displayed in the URL Bar
         selectOption(StringHelper.SHOW_PAGE_ADDRESS_LABEL);
-        inputAndLoadUrl(blank1);
+        loadUrl(blank1);
         verifyUrlBarTitle(blank1);
     }
 
     // Entering settings, changing the options: show title/page address option and verifing the device type because for phone there is an extra back action to exit the settings menu
     public void selectOption(String option) {
         selectSettingsItem(StringHelper.DISPLAY_SECTION_LABEL, StringHelper.TITLE_BAR_LABEL);
         mAsserter.ok(waitForText(StringHelper.SHOW_PAGE_TITLE_LABEL), "Waiting for the pop-up to open", "Pop up with the options was openend");
         mSolo.clickOnText(option);