Bug 1161820 - Replace all back button presses with Solo.goBack in tests. r=liuche CLOSED TREE

--HG--
extra : amend_source : d3bdbfb4a990b187c633988f96f5bb3cc759403e
This commit is contained in:
Jonathan Almeida 2015-06-17 17:24:48 -07:00
Родитель 6f3f2252cf
Коммит 11fd2b4a90
16 изменённых файлов: 45 добавлений и 41 удалений

Просмотреть файл

@ -9,7 +9,17 @@ public interface Actions {
/** Special keys supported by sendSpecialKey() */
public enum SpecialKey {
DOWN, UP, LEFT, RIGHT, ENTER, MENU, BACK
DOWN,
UP,
LEFT,
RIGHT,
ENTER,
MENU,
/**
* @deprecated Use Solo.goBack() in Robocop instead.
*/
@Deprecated
BACK
}
public interface EventExpecter {
@ -40,7 +50,7 @@ public interface Actions {
/**
* Sends an event to Gecko.
*
*
* @param geckoEvent The geckoEvent JSONObject's type
*/
void sendGeckoEvent(String geckoEvent, String data);
@ -72,7 +82,7 @@ public interface Actions {
* Listens for a gecko event to be sent from the Gecko instance.
* The returned object can be used to test if the event has been
* received. Note that only one event is listened for.
*
*
* @param geckoEvent The geckoEvent JSONObject's type
*/
RepeatedEventExpecter expectGeckoEvent(String geckoEvent);
@ -85,9 +95,9 @@ public interface Actions {
*/
RepeatedEventExpecter expectPaint();
/**
* Send a string to the application
*
/**
* Send a string to the application
*
* @param keysToSend The string to send
*/
void sendKeys(String keysToSend);

Просмотреть файл

@ -801,7 +801,7 @@ abstract class BaseTest extends BaseRobocopTest {
Element backBtn = mDriver.findElement(getActivity(), R.id.back);
backBtn.click();
} else {
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
}
pageShowExpecter.blockForEvent();
@ -869,7 +869,7 @@ abstract class BaseTest extends BaseRobocopTest {
// item. Close it here.
private void ensureMenuClosed() {
if (mSolo.searchText("^New Tab$")) {
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
}
}
}

Просмотреть файл

@ -98,7 +98,7 @@ abstract class ContentContextMenuTest extends PixelTest {
mAsserter.ok(waitForText(shareOption), "Checking that the share pop-up is displayed", "The pop-up has been displayed");
// Close the Share Link option menu and wait for the page to be focused again
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
waitForText(pageTitle);
}

Просмотреть файл

@ -114,6 +114,6 @@ public class testAboutHomePageNavigation extends UITest {
mSolo.scrollToSide(Solo.RIGHT);
mAsserter.is(pager.getCurrentItem(), 0, "Dragging right is not allowed when searching");
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
*/
}

Просмотреть файл

@ -161,7 +161,7 @@ public class testAddSearchEngine extends AboutHomeTest {
}, MAX_WAIT_TEST_MS);
// Exit about:home
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
waitForText(mStringHelper.ROBOCOP_BLANK_PAGE_01_TITLE);
mAsserter.ok(correctNumSearchEnginesDisplayed, expectedCount + " Search Engines should be displayed" , "The correct number of Search Engines has been displayed");
}

Просмотреть файл

@ -43,7 +43,7 @@ public class testAddonManager extends PixelTest {
verifyUrlBarTitle(aboutAddonsURL);
// Close the Add-on Manager
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
// Load the about:addons page and verify it was loaded
loadAndPaint(aboutAddonsURL);

Просмотреть файл

@ -110,7 +110,7 @@ public class testBookmarksPanel extends AboutHomeTest {
}
// Close the menu.
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
openBookmarkContextMenu(nonShareableURL);
for (String contextMenuOption : mStringHelper.BOOKMARK_CONTEXT_MENU_ITEMS) {
@ -131,7 +131,7 @@ public class testBookmarksPanel extends AboutHomeTest {
"Share option is not present");
// Close the menu.
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
}
/**

Просмотреть файл

@ -4,7 +4,6 @@
package org.mozilla.gecko.tests;
import org.mozilla.gecko.Actions;
import org.mozilla.gecko.R;
import com.jayway.android.robotium.solo.Condition;
@ -90,10 +89,10 @@ public class testClearPrivateData extends PixelTest {
public void checkDevice(final String title, final String url) {
clearPrivateData();
if (mDevice.type.equals("phone")) {
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
mAsserter.ok(waitForText(mStringHelper.PRIVACY_SECTION_LABEL), "waiting to perform one back", "one back");
}
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
verifyUrlBarTitle(url);
}

Просмотреть файл

@ -6,7 +6,6 @@ package org.mozilla.gecko.tests;
import java.util.ArrayList;
import org.mozilla.gecko.Actions;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.GeckoProfile;
@ -55,7 +54,7 @@ public class testImportFromAndroid extends AboutHomeTest {
firefoxBookmarks = mDatabaseHelper.getBrowserDBUrls(DatabaseHelper.BrowserDataType.BOOKMARKS);
/**
* Add a delay to make sure the imported items are added to the array lists
* Add a delay to make sure the imported items are added to the array lists
* if there are a lot of history items in the Android Browser database
*/
boolean success = waitForCondition(new Condition() {
@ -157,10 +156,10 @@ public class testImportFromAndroid extends AboutHomeTest {
if ("phone".equals(mDevice.type)) {
// Phones don't have headers like tablets, so we need to pop up one more level.
waitForText(mStringHelper.IMPORT_FROM_ANDROID_LABEL);
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
}
waitForText(mStringHelper.PRIVACY_SECTION_LABEL); // Settings is a header for the settings menu page. Waiting for Privacy ensures we are back in the top Settings view
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Exit Settings
mSolo.goBack(); // Exit Settings
// Make sure the settings menu has been closed.
mAsserter.ok(mSolo.waitForText(mStringHelper.TITLE_PLACE_HOLDER), "Waiting for search bar", "Search bar found");

Просмотреть файл

@ -88,10 +88,10 @@ public final class testInputUrlBar extends BaseTest {
assertUrlBarText("uv");
// Dismiss the VKB
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
// Dismiss editing mode
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
waitForText(mStringHelper.TITLE_PLACE_HOLDER);

Просмотреть файл

@ -77,10 +77,10 @@ public class testMasterPassword extends PixelTest {
if ("phone".equals(mDevice.type)) {
// Phones don't have headers like tablets, so we need to pop up one more level.
waitForText("Use master password");
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
}
waitForText(mStringHelper.SETTINGS_LABEL);
mActions.sendSpecialKey(Actions.SpecialKey.BACK);// Close the Settings Menu
mSolo.goBack();// Close the Settings Menu
}
public void disableMasterPassword(String password, String badPassword) {
@ -171,10 +171,10 @@ public class testMasterPassword extends PixelTest {
if ("phone".equals(mDevice.type)) {
// Phones don't have headers like tablets, so we need to pop up one more level.
waitForText("Use master password");
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
}
waitForText(mStringHelper.SETTINGS_LABEL);
mActions.sendSpecialKey(Actions.SpecialKey.BACK);// Close the Settings Menu
mSolo.goBack();// Close the Settings Menu
// Make sure the settings menu has been closed.
mAsserter.ok(mSolo.waitForText("Browser Blank Page 01"), "Waiting for blank browser page after exiting settings", "Blank browser page present");
}

Просмотреть файл

@ -4,8 +4,6 @@
package org.mozilla.gecko.tests;
import org.mozilla.gecko.Actions;
public class testPromptGridInput extends BaseTest {
protected int index = 1;
public void testPromptGridInput() {
@ -29,7 +27,7 @@ public class testPromptGridInput extends BaseTest {
mSolo.clickOnText("OK");
mAsserter.ok(waitForText("PASS"), "test passed", "PASS");
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
}
public void testGridItem(String title) {

Просмотреть файл

@ -7,7 +7,6 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.mozilla.gecko.Actions;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.util.HardwareUtils;
@ -144,7 +143,7 @@ public class testSettingsMenuItems extends PixelTest {
"The Settings menu did not load", mStringHelper.SETTINGS_LABEL);
// Dismiss the Settings screen and verify that the view is returned to about:home page
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
// Waiting for page title to appear to be sure that is fully loaded before opening the menu
mAsserter.ok(mSolo.waitForText(mStringHelper.TITLE_PLACE_HOLDER), "about:home did not load",
@ -281,7 +280,7 @@ public class testSettingsMenuItems extends PixelTest {
mSolo.clickOnText("^Cancel$");
} else {
// Some submenus aren't dialogs, but are nested screens; exit using "back".
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
}
}
}
@ -290,7 +289,7 @@ public class testSettingsMenuItems extends PixelTest {
if (mDevice.type.equals("phone")) {
int menuDepth = menuPath.length;
while (menuDepth > 0) {
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
menuDepth--;
// Sleep so subsequent back actions aren't lost.
mSolo.sleep(150);

Просмотреть файл

@ -56,7 +56,7 @@ public class testShareLink extends AboutHomeTest {
}
// Test share from the urlbar context menu
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Close the share menu
mSolo.goBack(); // Close the share menu
mSolo.clickLongOnText(urlTitle);
verifySharePopup(shareOptions,"urlbar");
@ -145,7 +145,7 @@ public class testShareLink extends AboutHomeTest {
// Verify if the option is present in the list of displayed share options
mAsserter.ok(optionDisplayed(option, displayedOptions), "Share option for " + openedFrom + (openedFrom.equals("urlbar") ? "" : " item") + " found", option);
}
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
/**
* Adding a wait for the page title to make sure the Awesomebar will be dismissed
* Because of Bug 712370 the Awesomescreen will be dismissed when the Share Menu is closed

Просмотреть файл

@ -35,7 +35,7 @@ public class testSystemPages extends PixelTest {
loadAndPaint(mStringHelper.ABOUT_ABOUT_URL);
// Press back to verify if the keyboard is dismissed or the previous about: page loads
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
// may not get a paint on Back...pause briefly to make sure it completes
mSolo.sleep(AFTER_BACK_SLEEP_MS);

Просмотреть файл

@ -1,6 +1,5 @@
package org.mozilla.gecko.tests;
import org.mozilla.gecko.Actions;
import org.mozilla.gecko.util.HardwareUtils;
/**
@ -45,13 +44,13 @@ public class testTitleBar extends PixelTest {
mSolo.clickOnText(option);
mAsserter.ok(waitForText(mStringHelper.CHARACTER_ENCODING_LABEL), "Waiting to press the option", "The pop-up is dismissed once clicked");
if (mDevice.type.equals("phone")) {
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
mAsserter.ok(waitForText(mStringHelper.CUSTOMIZE_SECTION_LABEL), "Waiting to perform one back", "One back performed");
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
mAsserter.ok(waitForText(mStringHelper.ROBOCOP_BLANK_PAGE_01_URL), "Waiting to exit settings", "Exit settings done");
}
else {
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
mSolo.goBack();
mAsserter.ok(waitForText(mStringHelper.ROBOCOP_BLANK_PAGE_01_URL), "Waiting to exit settings", "Exit settings done");
}
}