Bug 899614 - Make tab count check more robust in testNewTab; r=jmaher

--HG--
extra : rebase_source : 1e354f8d8d6d1b21c9b9af365dbfd605f8f4bc15
This commit is contained in:
Geoff Brown 2013-07-31 08:50:14 -07:00
parent aa4c443b24
commit 6cf4ba231e

View File

@ -34,20 +34,17 @@ public class testNewTab extends BaseTest {
"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
@ -103,5 +100,18 @@ public class testNewTab extends BaseTest {
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);
}
}