Bug 914377 - Avoid testShareLink intermittent failures; r=liuche
authorGeoff Brown <gbrown@mozilla.com>
Wed, 23 Oct 2013 20:36:21 -0600
changeset 165734 3b601d64426bd495caad66a39a5bd68e7673639e
parent 165731 9d1266f5c051ad7f05c9df990dc39dca18dfa08f
child 165735 a03b6f30006f5f8073a9ae311f51bd2508e8ea81
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersliuche
bugs914377
milestone27.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 914377 - Avoid testShareLink intermittent failures; r=liuche
mobile/android/base/tests/testShareLink.java.in
--- a/mobile/android/base/tests/testShareLink.java.in
+++ b/mobile/android/base/tests/testShareLink.java.in
@@ -1,11 +1,12 @@
 #filter substitution
 package @ANDROID_PACKAGE_NAME@.tests;
 
+import com.jayway.android.robotium.solo.Condition;
 import @ANDROID_PACKAGE_NAME@.*;
 import android.app.Activity;
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.os.Build;
 import android.util.DisplayMetrics;
 import android.view.View;
@@ -66,20 +67,36 @@ public class testShareLink extends About
         float top = mDriver.getGeckoTop() + 30 * mDevice.density;
         float left = mDriver.getGeckoLeft() + mDriver.getGeckoWidth() / 2;
         mSolo.clickLongOnScreen(left, top);
         verifySharePopup("Share Link",shareOptions,"Link");
 
         // Test the share popup in the Bookmarks page
         openAboutHomeTab(AboutHomeTabs.BOOKMARKS);
 
-        ListView bookmarksList = findListViewWithTag("bookmarks");
+        final ListView bookmarksList = findListViewWithTag("bookmarks");
         mAsserter.is(waitForNonEmptyListToLoad(bookmarksList), true, "list is properly loaded");
 
-        View bookmarksItem = bookmarksList.getChildAt(bookmarksList.getHeaderViewsCount());
+        int headerViewsCount = bookmarksList.getHeaderViewsCount();
+        View bookmarksItem = bookmarksList.getChildAt(headerViewsCount);
+        if (bookmarksItem == null) {
+            mAsserter.dumpLog("no child at index " + headerViewsCount + "; waiting for one...");
+            Condition listWaitCondition = new Condition() {
+                @Override
+                public boolean isSatisfied() {
+                    if (bookmarksList.getChildAt(bookmarksList.getHeaderViewsCount()) == null)
+                        return false;
+                    return true;
+                }
+            };
+            waitForCondition(listWaitCondition, MAX_WAIT_MS);
+            headerViewsCount = bookmarksList.getHeaderViewsCount();
+            bookmarksItem = bookmarksList.getChildAt(headerViewsCount);
+        }
+
         mSolo.clickLongOnView(bookmarksItem);
         verifySharePopup(shareOptions,"bookmarks");
 
         // Prepopulate top sites with history items to overflow tiles.
         // We are trying to move away from using reflection and doing more black-box testing.
         inputAndLoadUrl(getAbsoluteUrl("/robocop/robocop_blank_01.html"));
         inputAndLoadUrl(getAbsoluteUrl("/robocop/robocop_blank_02.html"));
         inputAndLoadUrl(getAbsoluteUrl("/robocop/robocop_blank_03.html"));