Bug 874985 - Part 1: Robustify existing test methods. r=gbrown

This commit is contained in:
Brian Nicholson 2013-11-15 22:59:16 -08:00
parent 1bcc3feb09
commit 7b3c098ad0

View File

@ -674,15 +674,22 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
}
public void back() {
Actions.EventExpecter pageShowExpecter = mActions.expectGeckoEvent("Content:PageShow");
if (devType.equals("tablet")) {
Element backBtn = mDriver.findElement(getActivity(), "back");
backBtn.click();
} else {
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
}
pageShowExpecter.blockForEvent();
pageShowExpecter.unregisterListener();
}
public void forward() {
Actions.EventExpecter pageShowExpecter = mActions.expectGeckoEvent("Content:PageShow");
if (devType.equals("tablet")) {
Element fwdBtn = mDriver.findElement(getActivity(), "forward");
fwdBtn.click();
@ -695,7 +702,11 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
} else {
mSolo.clickOnText("^Forward$");
}
ensureMenuClosed();
}
pageShowExpecter.blockForEvent();
pageShowExpecter.unregisterListener();
}
public void reload() {
@ -711,6 +722,7 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
} else {
mSolo.clickOnText("^Reload$");
}
ensureMenuClosed();
}
}
@ -729,6 +741,15 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
bookmarkBtn.click();
}
}
ensureMenuClosed();
}
// On some devices, the menu may not be dismissed after clicking on an
// item. Close it here.
private void ensureMenuClosed() {
if (mSolo.searchText("^New Tab$")) {
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
}
}
}
}