Bug 1058243 - (Part 2) Update testAddonManager to open a blank new tab instead of trying to click link in about:addons. r=nalexander
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Tue, 07 Oct 2014 11:52:56 -0700
changeset 209202 92bcf77b60ed876b8277d5b67526c2d8ad1bc836
parent 209201 c1cef1625a48b4c5354041d3b451ae85d2648905
child 209203 9c56c35657b9eb4f115c4423b2acb435c5ce0d40
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersnalexander
bugs1058243
milestone35.0a1
Bug 1058243 - (Part 2) Update testAddonManager to open a blank new tab instead of trying to click link in about:addons. r=nalexander
mobile/android/base/tests/testAddonManager.java
--- a/mobile/android/base/tests/testAddonManager.java
+++ b/mobile/android/base/tests/testAddonManager.java
@@ -1,22 +1,24 @@
 package org.mozilla.gecko.tests;
 
 import org.json.JSONObject;
 import org.mozilla.gecko.Actions;
 
 import android.util.DisplayMetrics;
 
+/**
+ * This test performs the following steps to check the behavior of the Add-on Manager:
+ *
+ * 1) Open the Add-on Manager from the Add-ons menu item, and then close it.
+ * 2) Open the Add-on Manager by visiting about:addons in the URL bar.
+ * 3) Open a new tab, select the Add-ons menu item, then verify that the existing
+ *    Add-on Manager tab was selected, instead of opening a new tab.
+ */
 public class testAddonManager extends PixelTest  {
-    /* This test will check the behavior of the Addons Manager:
-    First the test will open the Addons Manager from the Menu and then close it
-    Then the test will open the Addons Manager by visiting about:addons
-    The test will tap/click on the addons.mozilla.org icon to open the AMO page in a new tab
-    With the Addons Manager open the test will verify that when it is opened again from the menu no new tab will be opened*/
-
     public void testAddonManager() {
         Actions.EventExpecter tabEventExpecter;
         Actions.EventExpecter contentEventExpecter;
         String url = StringHelper.ABOUT_ADDONS_URL;
 
         blockForGeckoReady();
 
         // Use the menu to open the Addon Manger
@@ -38,44 +40,22 @@ public class testAddonManager extends Pi
 
         // Close the Add-on Manager
         mActions.sendSpecialKey(Actions.SpecialKey.BACK);
 
         // Load the about:addons page and verify it was loaded
         loadAndPaint(url);
         verifyPageTitle(StringHelper.ADDONS_LABEL);
 
-        // Change the AMO URL so we do not try to navigate to a live webpage
-        JSONObject jsonPref = new JSONObject();
-        try {
-            jsonPref.put("name", "extensions.getAddons.browseAddons");
-            jsonPref.put("type", "string");
-            jsonPref.put("value", getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL));
-            setPreferenceAndWaitForChange(jsonPref);
-
-        } catch (Exception ex) { 
-            mAsserter.ok(false, "exception in testAddonManager", ex.toString());
-        }
-
-        // Load AMO page by clicking the AMO icon
-        DisplayMetrics dm = new DisplayMetrics();
-        getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
-
-        /* Setup the tap to top value + 25px and right value - 25px.
-        Since the AMO icon is 50x50px this values should set the tap
-        in the middle of the icon */
-        float top = mDriver.getGeckoTop() + 25 * dm.density;;
-        float right = mDriver.getGeckoLeft() + mDriver.getGeckoWidth() - 25 * dm.density;;
-
         // Setup wait for tab to spawn and load
         tabEventExpecter = mActions.expectGeckoEvent("Tab:Added");
         contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
 
-        // Tap on the AMO icon
-        mSolo.clickOnScreen(right, top);
+        // Open a new tab
+        addTab(getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL));
 
         // Wait for the new tab and page to load
         tabEventExpecter.blockForEvent();
         contentEventExpecter.blockForEvent();
 
         tabEventExpecter.unregisterListener();
         contentEventExpecter.unregisterListener();