Bug 899614 - Make tab count check more robust in testNewTab; r=jmaher
authorGeoff Brown <gbrown@mozilla.com>
Wed, 31 Jul 2013 08:50:14 -0700
changeset 140770 e8d0ffd59e68e4f795f47a8876a067bb7d2b47b3
parent 140769 373ae7605a75f4f6921c9f0dd089e1bb631fb948
child 140771 af4a04fe4ff50e3d5366fd21527082894d04781a
push id31859
push usergbrown@mozilla.com
push dateWed, 31 Jul 2013 15:53:15 +0000
treeherdermozilla-inbound@af4a04fe4ff5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs899614
milestone25.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 899614 - Make tab count check more robust in testNewTab; r=jmaher
mobile/android/base/tests/testNewTab.java.in
--- a/mobile/android/base/tests/testNewTab.java.in
+++ b/mobile/android/base/tests/testNewTab.java.in
@@ -29,30 +29,27 @@ public class testNewTab extends BaseTest
         tabs = mDriver.findElement(activity, "tabs");
         addTab = mDriver.findElement(activity, "add_tab");
         mAsserter.ok(tabCount != null &&
                      tabs != null &&
                      addTab != null, 
                      "Checking elements", "all elements present");
 
         int expectedTabCount = 1;
-        String tabCountText = tabCount.getText();
-        tabCountInt = Integer.parseInt(tabCountText);
+        getTabCount(expectedTabCount);
         mAsserter.is(tabCountInt, expectedTabCount, "Initial number of tabs correct");
 
         addTab(url);
         expectedTabCount++;
-        tabCountText = tabCount.getText();
-        tabCountInt = Integer.parseInt(tabCountText);
+        getTabCount(expectedTabCount);
         mAsserter.is(tabCountInt, expectedTabCount, "Number of tabs increased");
 
         addTab(url2);
         expectedTabCount++;
-        tabCountText = tabCount.getText();
-        tabCountInt = Integer.parseInt(tabCountText);
+        getTabCount(expectedTabCount);
         mAsserter.is(tabCountInt, expectedTabCount, "Number of tabs increased");
 
         // cleanup: close all opened tabs
         //closeTabs();
     }
 
     private void closeTabs() {
         final int closeTabId = closeTab.getId();
@@ -98,10 +95,23 @@ public class testNewTab extends BaseTest
                         return true;
                     }
                     return false;
                 }
             }, MAX_WAIT_MS);
             mAsserter.ok(success, "Checking tab closed", "number of tabs now "+tabCountInt);
         }
     }
+
+    private void getTabCount(final int expected) {
+        waitForTest(new BooleanTest() {
+            @Override
+            public boolean test() {
+                String newTabCountText = tabCount.getText();
+                tabCountInt = Integer.parseInt(newTabCountText);
+                if (tabCountInt == expected) {
+                    return true;
+                }
+                return false;
+            }
+        }, MAX_WAIT_MS);
+    }
 }
-