Bug 995696 - Wait for Content:PageShow after adding tab in testNewTab. r=snorp, a=test-only
--- a/mobile/android/base/tests/BaseTest.java
+++ b/mobile/android/base/tests/BaseTest.java
@@ -533,17 +533,20 @@ abstract class BaseTest extends BaseRobo
View addTabView = mSolo.getView(R.id.add_tab);
if (addTabView == null) {
return false;
}
return true;
}
}, MAX_WAIT_MS);
mAsserter.ok(success, "waiting for add tab view", "add tab view available");
+ Actions.EventExpecter pageShowExpecter = mActions.expectGeckoEvent("Content:PageShow");
mSolo.clickOnView(mSolo.getView(R.id.add_tab));
+ pageShowExpecter.blockForEvent();
+ pageShowExpecter.unregisterListener();
}
public void addTab(String url) {
addTab();
// Adding a new tab opens about:home, so now we just need to load the url in it.
inputAndLoadUrl(url);
}
--- a/mobile/android/base/tests/SessionTest.java
+++ b/mobile/android/base/tests/SessionTest.java
@@ -142,20 +142,17 @@ public abstract class SessionTest extend
// New tabs always start with about:home, so make sure about:home
// is always the first entry.
mAsserter.is(pages[0].url, "about:home", "first page in tab is about:home");
// If this is the first tab, the tab already exists, so no need to
// create a new one. Otherwise, create a new tab if we're loading
// the first the first page in the set.
if (i > 0) {
- Actions.EventExpecter pageShowExpecter = mActions.expectGeckoEvent("Content:PageShow");
addTab();
- pageShowExpecter.blockForEvent();
- pageShowExpecter.unregisterListener();
}
for (int j = 1; j < pages.length; j++) {
Actions.EventExpecter pageShowExpecter = mActions.expectGeckoEvent("Content:PageShow");
loadUrl(pages[j].url);
pageShowExpecter.blockForEvent();
--- a/mobile/android/base/tests/robocop.ini
+++ b/mobile/android/base/tests/robocop.ini
@@ -56,18 +56,16 @@ skip-if = android_version == "10" || pro
[testHomeProvider]
[testLoad]
[testMailToContextMenu]
[testMasterPassword]
# disabled on 2.3; bug 979603
# disabled on 4.0; bug 1006242
skip-if = android_version == "10" || android_version == "15"
[testNewTab]
-# disabled on 2.3; bug 979621
-skip-if = android_version == "10"
[testOverscroll]
# disabled on 2.3; bug 836818
skip-if = android_version == "10"
[testPanCorrectness]
# disabled on x86 only; bug 927476
skip-if = processor == "x86"
# [testPasswordEncrypt] # see bug 824067
[testPasswordProvider]
--- a/mobile/android/base/tests/testNewTab.java
+++ b/mobile/android/base/tests/testNewTab.java
@@ -1,37 +1,35 @@
package org.mozilla.gecko.tests;
import org.mozilla.gecko.Element;
import org.mozilla.gecko.R;
import android.app.Activity;
import android.view.View;
+import com.jayway.android.robotium.solo.Condition;
+
/* A simple test that creates 2 new tabs and checks that the tab count increases. */
public class testNewTab extends BaseTest {
private Element tabCount = null;
private Element tabs = null;
- private Element addTab = null;
private Element closeTab = null;
private int tabCountInt = 0;
public void testNewTab() {
String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
String url2 = getAbsoluteUrl("/robocop/robocop_blank_02.html");
blockForGeckoReady();
Activity activity = getActivity();
tabCount = mDriver.findElement(activity, R.id.tabs_counter);
tabs = mDriver.findElement(activity, R.id.tabs);
- addTab = mDriver.findElement(activity, R.id.add_tab);
- mAsserter.ok(tabCount != null &&
- tabs != null &&
- addTab != null,
+ mAsserter.ok(tabCount != null && tabs != null,
"Checking elements", "all elements present");
int expectedTabCount = 1;
getTabCount(expectedTabCount);
mAsserter.is(tabCountInt, expectedTabCount, "Initial number of tabs correct");
addTab(url);
expectedTabCount++;
@@ -76,36 +74,36 @@ public class testNewTab extends BaseTest
tabCountText = tabCount.getText();
tabCountInt = Integer.parseInt(tabCountText);
while (tabCountInt > 1) {
clicked = closeTab.click();
if (!clicked) {
mAsserter.ok(clicked != false, "checking that close_tab clicked", "close_tab element clicked");
}
- success = waitForTest(new BooleanTest() {
+ success = waitForCondition(new Condition() {
@Override
- public boolean test() {
+ public boolean isSatisfied() {
String newTabCountText = tabCount.getText();
int newTabCount = Integer.parseInt(newTabCountText);
if (newTabCount < tabCountInt) {
tabCountInt = newTabCount;
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() {
+ waitForCondition(new Condition() {
@Override
- public boolean test() {
+ public boolean isSatisfied() {
String newTabCountText = tabCount.getText();
tabCountInt = Integer.parseInt(newTabCountText);
if (tabCountInt == expected) {
return true;
}
return false;
}
}, MAX_WAIT_MS);