Bug 817440 - Intermittent testAddonManager | GeckoEventExpecter - blockForEvent timeout: Tab:Added r=gbrown
authorMark Finkle <mfinkle@mozilla.com>
Fri, 04 Jan 2013 15:11:57 -0500
changeset 126767 ac059cbb93ed257e03dc12805a3d727e99c37a45
parent 126766 a8654766039861bf981654f59a1cd1bac04117ee
child 126768 7e9a42a9cec735be02fc8dd654751ffc394be1f0
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown
bugs817440
milestone20.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 817440 - Intermittent testAddonManager | GeckoEventExpecter - blockForEvent timeout: Tab:Added r=gbrown
mobile/android/base/tests/robocop.ini
mobile/android/base/tests/testAddonManager.java.in
--- a/mobile/android/base/tests/robocop.ini
+++ b/mobile/android/base/tests/robocop.ini
@@ -17,17 +17,17 @@
 [testWebContentContextMenu]
 [testPasswordProvider]
 [testPasswordEncrypt]
 [testFormHistory]
 [testBrowserProvider]
 [testSearchSuggestions]
 [testTabsTrayMenu]
 # [testThumbnails] # see bug 813107
-# [testAddonManager] # see bug 817440
+[testAddonManager]
 [testHistory]
 [testVkbOverlap]
 [testDoorHanger]
 [testTabHistory]
 [testShareLink]
 # [testPermissions] # see bug 757475
 # [testJarReader] # see bug 738890
 
--- a/mobile/android/base/tests/testAddonManager.java.in
+++ b/mobile/android/base/tests/testAddonManager.java.in
@@ -5,16 +5,20 @@ import @ANDROID_PACKAGE_NAME@.*;
 import android.app.Activity;
 import android.view.MenuItem;
 import android.widget.TextView;
 import android.widget.TabHost;
 import android.content.ContentResolver;
 import android.app.Instrumentation;
 import android.util.DisplayMetrics;
 
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
 public class testAddonManager extends PixelTest  {
     Actions.EventExpecter tabEventExpecter;
     Actions.EventExpecter contentEventExpecter;
     String url = "about:addons";
 
     @Override
     protected int getTestType() {
         return TEST_MOCHITEST;
@@ -45,16 +49,44 @@ 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("Add-ons");
 
+        // 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("/robocop/robocop_blank_01.html"));
+            mActions.sendGeckoEvent("Preferences:Set", jsonPref.toString());
+
+            // Wait for confirmation of the pref change before proceeding with the test.
+            JSONArray getPrefData = new JSONArray();
+            getPrefData.put("extensions.getAddons.browseAddons");
+            JSONObject message = new JSONObject();
+            message.put("requestId", "testAddonManager");
+            message.put("preferences", getPrefData);
+            Actions.RepeatedEventExpecter contentEventExpecter = mActions.expectGeckoEvent("Preferences:Data");
+            mActions.sendGeckoEvent("Preferences:Get", message.toString());
+            // Receiving a Preferences:Data event is not conclusive evidence that *our*
+            // preference has been set -- another component may be changing preferences
+            // at the same time. Mitigate this risk by waiting for a Preference:Data
+            // and then waiting for a period of time in which no more Preference:Data
+            // events are received.
+            // TODO: add a new expectGeckoEvent function that listens for a Preferences:Data
+            // message with a specific requestId
+            contentEventExpecter.blockUntilClear(2000);
+        } 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;;
@@ -70,17 +102,17 @@ public class testAddonManager extends Pi
         // Wait for the new tab and page to load
         tabEventExpecter.blockForEvent();
         contentEventExpecter.blockForEvent();
 
         // Verify tab count has increased
         verifyTabCount(2);
 
         // Verify the page was opened
-        verifyPageTitle("Add-ons for Android");
+        verifyPageTitle("Browser Blank Page 01");
 
         // Addons Manager is not opened 2 separate times when opened from the menu
         selectMenuItem("Add-ons");        
         contentEventExpecter.blockForEvent();
 
         // Verify tab count not increased
         verifyTabCount(2);
     }