author | Ryan VanderMeulen <ryanvm@gmail.com> |
Fri, 10 Oct 2014 17:14:20 -0400 | |
changeset 209806 | 97cea18fba09be4cc9b46414e8f19da8edce3e1f |
parent 209805 | 5e285d8e2ac19ca63a79239692aa8f38d771d8a2 |
child 209807 | e545c792a0bdf3182132ad4d0b84d8e1d90d1fdf |
push id | 1 |
push user | root |
push date | Mon, 20 Oct 2014 17:29:22 +0000 |
bugs | 1075531 |
milestone | 35.0a1 |
backs out | 59c761f6c0eb8d0777ff2a53b343f43d08f0aae1 132f861349a26b0f988352ff58f3d8243f0f58ed |
--- a/mobile/android/base/tests/BaseTest.java +++ b/mobile/android/base/tests/BaseTest.java @@ -20,17 +20,16 @@ import org.mozilla.gecko.Driver; import org.mozilla.gecko.Element; import org.mozilla.gecko.FennecNativeActions; import org.mozilla.gecko.FennecNativeDriver; import org.mozilla.gecko.GeckoAppShell; import org.mozilla.gecko.GeckoEvent; import org.mozilla.gecko.GeckoProfile; import org.mozilla.gecko.GeckoThread; import org.mozilla.gecko.GeckoThread.LaunchState; -import org.mozilla.gecko.NewTabletUI; import org.mozilla.gecko.R; import org.mozilla.gecko.RobocopUtils; import org.mozilla.gecko.Tab; import org.mozilla.gecko.Tabs; import android.app.Activity; import android.content.ContentValues; import android.content.Intent; @@ -64,18 +63,16 @@ abstract class BaseTest extends BaseRobo private static final int MAX_WAIT_ENABLED_TEXT_MS = 10000; private static final int MAX_WAIT_HOME_PAGER_HIDDEN_MS = 15000; private static final int MAX_WAIT_VERIFY_PAGE_TITLE_MS = 15000; public static final int MAX_WAIT_MS = 4500; public static final int LONG_PRESS_TIME = 6000; private static final int GECKO_READY_WAIT_MS = 180000; public static final int MAX_WAIT_BLOCK_FOR_EVENT_DATA_MS = 90000; - private static final String URL_HTTP_PREFIX = "http://"; - private Activity mActivity; private int mPreferenceRequestID = 0; protected Solo mSolo; protected Driver mDriver; protected Actions mActions; protected String mBaseUrl; protected String mRawBaseUrl; protected String mProfile; @@ -444,17 +441,17 @@ abstract class BaseTest extends BaseRobo // log out failed wait for diagnostic purposes only; // failures are sometimes expected/normal mAsserter.dumpLog("waitForEnabledText timeout on "+text); } return rc; } - /** + /** * Select <item> from Menu > "Settings" > <section>. */ public void selectSettingsItem(String section, String item) { String[] itemPath = { "Settings", section, item }; selectMenuItemByPath(itemPath); } /** @@ -502,44 +499,26 @@ abstract class BaseTest extends BaseRobo } }, MAX_WAIT_HOME_PAGER_HIDDEN_MS); if (!rc) { mAsserter.ok(rc, "Verify HomePager is hidden", "HomePager is hidden"); } } - public final void verifyPageTitle(final String title, String url) { - // We are asserting visible state - we shouldn't know if the title is null. - mAsserter.isnot(title, null, "The title argument is not null"); - mAsserter.isnot(url, null, "The url argument is not null"); - - // TODO: We should also check the title bar preference. - final String expected; - if (!NewTabletUI.isEnabled(mActivity)) { - expected = title; - } else { - if (StringHelper.ABOUT_HOME_URL.equals(url)) { - expected = StringHelper.ABOUT_HOME_TITLE; - } else if (url.startsWith(URL_HTTP_PREFIX)) { - expected = url.substring(URL_HTTP_PREFIX.length()); - } else { - expected = url; - } - } - + public final void verifyPageTitle(String title) { final TextView urlBarTitle = (TextView) mSolo.getView(R.id.url_bar_title); String pageTitle = null; if (urlBarTitle != null) { // Wait for the title to make sure it has been displayed in case the view // does not update fast enough waitForCondition(new VerifyTextViewText(urlBarTitle, title), MAX_WAIT_VERIFY_PAGE_TITLE_MS); pageTitle = urlBarTitle.getText().toString(); } - mAsserter.is(pageTitle, expected, "Page title is correct"); + mAsserter.is(pageTitle, title, "Page title is correct"); } public final void verifyTabCount(int expectedTabCount) { Element tabCount = mDriver.findElement(getActivity(), R.id.tabs_counter); String tabCountText = tabCount.getText(); int tabCountInt = Integer.parseInt(tabCountText); mAsserter.is(tabCountInt, expectedTabCount, "The correct number of tabs are opened"); } @@ -951,17 +930,17 @@ abstract class BaseTest extends BaseRobo } /** * Set the preference and wait for it to change before proceeding with the test. */ public void setPreferenceAndWaitForChange(final JSONObject jsonPref) { mActions.sendGeckoEvent("Preferences:Set", jsonPref.toString()); - // Get the preference name from the json and store it in an array. This array + // Get the preference name from the json and store it in an array. This array // will be used later while fetching the preference data. String[] prefNames = new String[1]; try { prefNames[0] = jsonPref.getString("name"); } catch (JSONException e) { mAsserter.ok(false, "Exception in setPreferenceAndWaitForChange", getStackTraceString(e)); }
--- a/mobile/android/base/tests/SessionTest.java +++ b/mobile/android/base/tests/SessionTest.java @@ -192,17 +192,17 @@ public abstract class SessionTest extend (new NavigationWalker<PageInfo>(tab) { @Override public void onItem(PageInfo page, int currentIndex) { if (page.url.equals(StringHelper.ABOUT_HOME_URL)) { waitForText("Enter Search or Address"); verifyUrl(page.url); } else { waitForText(page.title); - verifyPageTitle(page.title, page.url); + verifyPageTitle(page.title); } } @Override public void goBack() { mNavigation.back(); }
--- a/mobile/android/base/tests/components/ToolbarComponent.java +++ b/mobile/android/base/tests/components/ToolbarComponent.java @@ -4,73 +4,48 @@ package org.mozilla.gecko.tests.components; import static org.mozilla.gecko.tests.helpers.AssertionHelper.fAssertEquals; import static org.mozilla.gecko.tests.helpers.AssertionHelper.fAssertFalse; import static org.mozilla.gecko.tests.helpers.AssertionHelper.fAssertNotNull; import static org.mozilla.gecko.tests.helpers.AssertionHelper.fAssertTrue; -import org.mozilla.gecko.NewTabletUI; import org.mozilla.gecko.R; -import org.mozilla.gecko.tests.StringHelper; import org.mozilla.gecko.tests.UITestContext; import org.mozilla.gecko.tests.helpers.DeviceHelper; -import org.mozilla.gecko.tests.helpers.NavigationHelper; import org.mozilla.gecko.tests.helpers.WaitHelper; import android.view.View; import android.widget.EditText; import android.widget.ImageButton; import android.widget.TextView; import com.jayway.android.robotium.solo.Condition; import com.jayway.android.robotium.solo.Solo; /** * A class representing any interactions that take place on the Toolbar. */ public class ToolbarComponent extends BaseComponent { - - private static final String URL_HTTP_PREFIX = "http://"; - public ToolbarComponent(final UITestContext testContext) { super(testContext); } public ToolbarComponent assertIsEditing() { fAssertTrue("The toolbar is in the editing state", isEditing()); return this; } public ToolbarComponent assertIsNotEditing() { fAssertFalse("The toolbar is not in the editing state", isEditing()); return this; } - public ToolbarComponent assertTitle(final String title, final String url) { - // We are asserting visible state - we shouldn't know if the title is null. - fAssertNotNull("The title argument is not null", title); - fAssertNotNull("The url argument is not null", url); - - // TODO: We should also check the title bar preference. - final String expected; - if (!NewTabletUI.isEnabled(mActivity)) { - expected = title; - } else { - final String absoluteURL = NavigationHelper.adjustUrl(url); - if (StringHelper.ABOUT_HOME_URL.equals(absoluteURL)) { - expected = StringHelper.ABOUT_HOME_TITLE; - } else if (absoluteURL.startsWith(URL_HTTP_PREFIX)) { - expected = absoluteURL.substring(URL_HTTP_PREFIX.length()); - } else { - expected = absoluteURL; - } - } - + public ToolbarComponent assertTitle(final String expected) { fAssertEquals("The Toolbar title is " + expected, expected, getTitle()); return this; } public ToolbarComponent assertUrl(final String expected) { assertIsEditing(); fAssertEquals("The Toolbar url is " + expected, expected, getUrlEditText().getText()); return this; @@ -111,35 +86,35 @@ public class ToolbarComponent extends Ba } /** * Returns the View for the edit cancel button in the browser toolbar. */ private ImageButton getEditCancelButton() { return (ImageButton) getToolbarView().findViewById(R.id.edit_cancel); } - private String getTitle() { + private CharSequence getTitle() { return getTitleHelper(true); } /** * Returns the title of the page. Note that this makes no assertions to Toolbar state and * may return a value that may never be visible to the user. Callers likely want to use * {@link assertTitle} instead. */ - public String getPotentiallyInconsistentTitle() { + public CharSequence getPotentiallyInconsistentTitle() { return getTitleHelper(false); } - private String getTitleHelper(final boolean shouldAssertNotEditing) { + private CharSequence getTitleHelper(final boolean shouldAssertNotEditing) { if (shouldAssertNotEditing) { assertIsNotEditing(); } - return getUrlTitleText().getText().toString(); + return getUrlTitleText().getText(); } private boolean isEditing() { return getUrlDisplayLayout().getVisibility() != View.VISIBLE && getUrlEditText().getVisibility() == View.VISIBLE; } public ToolbarComponent enterEditingMode() {
--- a/mobile/android/base/tests/helpers/NavigationHelper.java +++ b/mobile/android/base/tests/helpers/NavigationHelper.java @@ -39,17 +39,17 @@ final public class NavigationHelper { sToolbar.enterEditingMode() .enterUrl(url) .commitEditingMode(); } /** * Returns a new URL with the docshell HTTP server host prefix. */ - public static String adjustUrl(final String url) { + private static String adjustUrl(final String url) { fAssertNotNull("url is not null", url); if (url.startsWith("about:") || url.startsWith("chrome:")) { return url; } return sContext.getAbsoluteHostnameUrl(url); }
--- a/mobile/android/base/tests/testAboutHomeVisibility.java +++ b/mobile/android/base/tests/testAboutHomeVisibility.java @@ -8,48 +8,48 @@ import org.mozilla.gecko.tests.helpers.N /** * Tests the visibility of about:home after various interactions with the browser. */ public class testAboutHomeVisibility extends UITest { public void testAboutHomeVisibility() { GeckoHelper.blockForReady(); // Check initial state on about:home. - mToolbar.assertTitle(StringHelper.ABOUT_HOME_TITLE, StringHelper.ABOUT_HOME_URL); + mToolbar.assertTitle(StringHelper.ABOUT_HOME_TITLE); mAboutHome.assertVisible() .assertCurrentPanel(PanelType.TOP_SITES); // Go to blank 01. NavigationHelper.enterAndLoadUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL); - mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, - StringHelper.ROBOCOP_BLANK_PAGE_01_URL); + mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE); mAboutHome.assertNotVisible(); // Go to blank 02. NavigationHelper.enterAndLoadUrl(StringHelper.ROBOCOP_BLANK_PAGE_02_URL); - mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE, - StringHelper.ROBOCOP_BLANK_PAGE_02_URL); + mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE); mAboutHome.assertNotVisible(); // Enter editing mode, where the about:home UI should be visible. mToolbar.enterEditingMode(); mAboutHome.assertVisible() .assertCurrentPanel(PanelType.TOP_SITES); // Dismiss editing mode, where the about:home UI should be gone. mToolbar.dismissEditingMode(); mAboutHome.assertNotVisible(); // Loading about:home should show about:home again. NavigationHelper.enterAndLoadUrl(StringHelper.ABOUT_HOME_URL); - mToolbar.assertTitle(StringHelper.ABOUT_HOME_TITLE, StringHelper.ABOUT_HOME_URL); + mToolbar.assertTitle(StringHelper.ABOUT_HOME_TITLE); mAboutHome.assertVisible() .assertCurrentPanel(PanelType.TOP_SITES); // We can navigate to about:home panels by panel UUID. mAboutHome.navigateToBuiltinPanelType(PanelType.BOOKMARKS) .assertVisible() .assertCurrentPanel(PanelType.BOOKMARKS); mAboutHome.navigateToBuiltinPanelType(PanelType.HISTORY) .assertVisible() .assertCurrentPanel(PanelType.HISTORY); + + // TODO: Type in a url and assert the go button is visible. } }
--- a/mobile/android/base/tests/testAboutPage.java +++ b/mobile/android/base/tests/testAboutPage.java @@ -1,57 +1,50 @@ package org.mozilla.gecko.tests; import org.mozilla.gecko.Actions; import org.mozilla.gecko.Element; -import org.mozilla.gecko.NewTabletUI; import org.mozilla.gecko.R; -import android.app.Activity; - /* Tests related to the about: page: * - check that about: loads from the URL bar * - check that about: loads from Settings/About... */ public class testAboutPage extends PixelTest { - private void ensureTitleMatches(final String titleRegex, final String urlRegex) { - final Activity activity = getActivity(); - final Element urlBarTitle = mDriver.findElement(activity, R.id.url_bar_title); - - // TODO: We should also be testing what the page title preference value is. - final String expectedTitle = NewTabletUI.isEnabled(activity) ? urlRegex : titleRegex; + private void ensureTitleMatches(final String regex) { + Element urlBarTitle = mDriver.findElement(getActivity(), R.id.url_bar_title); mAsserter.isnot(urlBarTitle, null, "Got the URL bar title"); - assertMatches(urlBarTitle.getText(), expectedTitle, "page title match"); + assertMatches(urlBarTitle.getText(), regex, "page title match"); } public void testAboutPage() { blockForGeckoReady(); // Load the about: page and verify its title. - String url = StringHelper.ABOUT_SCHEME; + String url = "about:"; loadAndPaint(url); - verifyPageTitle(StringHelper.ABOUT_LABEL, url); + ensureTitleMatches(StringHelper.ABOUT_LABEL); // Open a new page to remove the about: page from the current tab. url = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL); inputAndLoadUrl(url); // At this point the page title should have been set. - verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, url); + ensureTitleMatches(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE); // Set up listeners to catch the page load we're about to do. Actions.EventExpecter tabEventExpecter = mActions.expectGeckoEvent("Tab:Added"); Actions.EventExpecter contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded"); selectSettingsItem(StringHelper.MOZILLA_SECTION_LABEL, StringHelper.ABOUT_LABEL); // Wait for the new tab and page to load tabEventExpecter.blockForEvent(); contentEventExpecter.blockForEvent(); tabEventExpecter.unregisterListener(); contentEventExpecter.unregisterListener(); // Grab the title to make sure the about: page was loaded. - verifyPageTitle(StringHelper.ABOUT_LABEL, StringHelper.ABOUT_SCHEME); + ensureTitleMatches(StringHelper.ABOUT_LABEL); } }
--- a/mobile/android/base/tests/testAddSearchEngine.java +++ b/mobile/android/base/tests/testAddSearchEngine.java @@ -56,17 +56,17 @@ public class testAddSearchEngine extends mAsserter.dumpLog("Search Engines list = " + searchEngines.toString()); // Verify that the number of displayed search engines is the same as the one received through the SearchEngines:Data event. verifyDisplayedSearchEnginesCount(initialNumSearchEngines); // Load the page for the search engine to add. inputAndLoadUrl(searchEngineURL); waitForText(StringHelper.ROBOCOP_SEARCH_TITLE); - verifyPageTitle(StringHelper.ROBOCOP_SEARCH_TITLE, searchEngineURL); + verifyPageTitle(StringHelper.ROBOCOP_SEARCH_TITLE); // Used to long-tap on the search input box for the search engine to add. getInstrumentation().waitForIdleSync(); mAsserter.dumpLog("Long Clicking at width = " + String.valueOf(width) + " and height = " + String.valueOf(height)); mSolo.clickLongOnScreen(width,height); ImageView view = waitForViewWithDescription(ImageView.class, ADD_SEARCHENGINE_OPTION_TEXT); mAsserter.isnot(view, null, "The action mode was opened"); @@ -94,17 +94,17 @@ public class testAddSearchEngine extends searchEngines = getSearchEnginesNames(eventData); } catch (JSONException e) { mAsserter.ok(false, "Fatal exception in testAddSearchEngine while decoding JSON search engine string from Gecko after adding of new engine.", e.toString()); return; } mAsserter.dumpLog("Search Engines list = " + searchEngines.toString()); mAsserter.is(searchEngines.size(), initialNumSearchEngines + 1, "Checking the number of Search Engines has increased"); - + // Verify that the number of displayed searchengines is the same as the one received through the SearchEngines:Data event. verifyDisplayedSearchEnginesCount(initialNumSearchEngines + 1); searchEngineDataEventExpector.unregisterListener(); // Verify that the search plugin XML file for the new engine ended up where we expected it to. // This file name is created in nsSearchService.js based on the name of the new engine. final File f = GeckoProfile.get(getActivity()).getFile("searchplugins/robocop-search-engine.xml"); mAsserter.ok(f.exists(), "Checking that new search plugin file exists", ""); @@ -146,15 +146,15 @@ public class testAddSearchEngine extends } ListAdapter adapter = list.getAdapter(); if (adapter == null) { return false; } return (adapter.getCount() == expectedCount); } }, MAX_WAIT_TEST_MS); - + // Exit about:home mActions.sendSpecialKey(Actions.SpecialKey.BACK); waitForText(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE); mAsserter.ok(correctNumSearchEnginesDisplayed, expectedCount + " Search Engines should be displayed" , "The correct number of Search Engines has been displayed"); } }
--- a/mobile/android/base/tests/testAddonManager.java +++ b/mobile/android/base/tests/testAddonManager.java @@ -12,17 +12,17 @@ import android.util.DisplayMetrics; * 2) Open the Add-on Manager by visiting about:addons in the URL bar. * 3) Open a new tab, select the Add-ons menu item, then verify that the existing * Add-on Manager tab was selected, instead of opening a new tab. */ public class testAddonManager extends PixelTest { public void testAddonManager() { Actions.EventExpecter tabEventExpecter; Actions.EventExpecter contentEventExpecter; - final String aboutAddonsURL = StringHelper.ABOUT_ADDONS_URL; + String url = StringHelper.ABOUT_ADDONS_URL; blockForGeckoReady(); // Use the menu to open the Addon Manger selectMenuItem(StringHelper.ADDONS_LABEL); // Set up listeners to catch the page load we're about to do tabEventExpecter = mActions.expectGeckoEvent("Tab:Added"); @@ -31,45 +31,44 @@ public class testAddonManager extends Pi // Wait for the new tab and page to load tabEventExpecter.blockForEvent(); contentEventExpecter.blockForEvent(); tabEventExpecter.unregisterListener(); contentEventExpecter.unregisterListener(); // Verify the url - verifyPageTitle(StringHelper.ADDONS_LABEL, aboutAddonsURL); + verifyPageTitle(StringHelper.ADDONS_LABEL); // Close the Add-on Manager mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Load the about:addons page and verify it was loaded - loadAndPaint(aboutAddonsURL); - verifyPageTitle(StringHelper.ADDONS_LABEL, aboutAddonsURL); + loadAndPaint(url); + verifyPageTitle(StringHelper.ADDONS_LABEL); // Setup wait for tab to spawn and load tabEventExpecter = mActions.expectGeckoEvent("Tab:Added"); contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded"); // Open a new tab - final String blankURL = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL); - addTab(blankURL); + addTab(getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL)); // Wait for the new tab and page to load tabEventExpecter.blockForEvent(); contentEventExpecter.blockForEvent(); tabEventExpecter.unregisterListener(); contentEventExpecter.unregisterListener(); // Verify tab count has increased verifyTabCount(2); // Verify the page was opened - verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, blankURL); + verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE); // Addons Manager is not opened 2 separate times when opened from the menu selectMenuItem(StringHelper.ADDONS_LABEL); // Verify tab count not increased verifyTabCount(2); } }
--- a/mobile/android/base/tests/testAppMenuPathways.java +++ b/mobile/android/base/tests/testAppMenuPathways.java @@ -43,17 +43,16 @@ public class testAppMenuPathways extends Tabs.getInstance().handleMessage("Content:LocationChange", message); // Save as pdf menu is disabled while playing video. mAppMenu.assertMenuItemIsDisabledAndVisible(AppMenuComponent.PageMenuItem.SAVE_AS_PDF); // The above mock video playback test changes Java state, but not the associated JS state. // Navigate to a new page so that the Java state is cleared. NavigationHelper.enterAndLoadUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL); - mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, - StringHelper.ROBOCOP_BLANK_PAGE_01_URL); + mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE); // Test save as pdf functionality. // The following call doesn't wait for the resulting pdf but checks that no exception are thrown. // NOTE: save as pdf functionality must be done at the end as it is slow and cause other test operations to fail. mAppMenu.pressMenuItem(AppMenuComponent.PageMenuItem.SAVE_AS_PDF); } } \ No newline at end of file
--- a/mobile/android/base/tests/testBookmark.java +++ b/mobile/android/base/tests/testBookmark.java @@ -27,18 +27,17 @@ public class testBookmark extends AboutH } mDatabaseHelper.addOrUpdateMobileBookmark(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, BOOKMARK_URL); waitForBookmarked(true); isBookmarkDisplayed(BOOKMARK_URL); loadBookmark(BOOKMARK_URL); waitForText(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE); - verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, - StringHelper.ROBOCOP_BLANK_PAGE_01_URL); + verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE); mDatabaseHelper.deleteBookmark(BOOKMARK_URL); waitForBookmarked(false); } private void waitForBookmarked(final boolean isBookmarked) { boolean bookmarked = waitForTest(new BooleanTest() { @Override
--- a/mobile/android/base/tests/testBookmarkFolders.java +++ b/mobile/android/base/tests/testBookmarkFolders.java @@ -47,17 +47,17 @@ public class testBookmarkFolders extends clickOnBookmarkFolder(StringHelper.DESKTOP_FOLDER_LABEL); clickOnBookmarkFolder(StringHelper.TOOLBAR_FOLDER_LABEL); isBookmarkDisplayed(DESKTOP_BOOKMARK_URL); // Open the bookmark from a bookmark folder hierarchy loadBookmark(DESKTOP_BOOKMARK_URL); waitForText(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE); - verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE, DESKTOP_BOOKMARK_URL); + verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE); openAboutHomeTab(AboutHomeTabs.BOOKMARKS); // Check that folders don't have a context menu boolean success = waitForCondition(new Condition() { @Override public boolean isSatisfied() { View desktopFolder = getBookmarkFolderView(StringHelper.DESKTOP_FOLDER_LABEL); if (desktopFolder == null) {
--- a/mobile/android/base/tests/testBookmarkKeyword.java +++ b/mobile/android/base/tests/testBookmarkKeyword.java @@ -14,15 +14,14 @@ public class testBookmarkKeyword extends // Enter the keyword in the urlbar. inputAndLoadUrl(keyword); // Wait for the page to load. waitForText(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE); // Make sure the title of the page appeared. - verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, - StringHelper.ROBOCOP_BLANK_PAGE_01_URL); + verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE); // Delete the bookmark to clean up. mDatabaseHelper.deleteBookmark(url); } }
--- a/mobile/android/base/tests/testBookmarklets.java +++ b/mobile/android/base/tests/testBookmarklets.java @@ -13,19 +13,17 @@ public class testBookmarklets extends Ab final String title = "alertBookmarklet"; final String js = "javascript:alert(12 + .34)"; boolean alerted; blockForGeckoReady(); // load a standard page so bookmarklets work inputAndLoadUrl(url); - // Waiting for page title to ensure the page is loaded - verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, - StringHelper.ROBOCOP_BLANK_PAGE_01_URL); + verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE); // Waiting for page title to ensure the page is loaded // verify that user-entered bookmarklets do *not* work enterUrl(js); mActions.sendSpecialKey(Actions.SpecialKey.ENTER); alerted = waitForTest(new BooleanTest() { @Override public boolean test() { return mSolo.searchButton("OK", true) || mSolo.searchText("12.34", true);
--- a/mobile/android/base/tests/testClearPrivateData.java +++ b/mobile/android/base/tests/testClearPrivateData.java @@ -25,24 +25,24 @@ public class testClearPrivateData extend private void clearHistory() { // Loading a page and adding a second one as bookmark to have user made bookmarks and history String blank1 = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL); String blank2 = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_02_URL); String title = StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE; inputAndLoadUrl(blank1); - verifyPageTitle(title, blank1); + verifyPageTitle(title); mDatabaseHelper.addOrUpdateMobileBookmark(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE, blank2); // Checking that the history list is not empty verifyHistoryCount(1); //clear and check for device - checkDevice(title, blank1); + checkDevice(title); // Checking that history list is empty verifyHistoryCount(0); // Checking that the user made bookmark is not removed mAsserter.ok(mDatabaseHelper.isBookmark(blank2), "Checking that bookmarks have not been removed", "User made bookmarks were not removed with private data"); } @@ -59,40 +59,44 @@ public class testClearPrivateData extend String shareStrings[] = {"Share your location with", "Share", "Don't share", "There are no settings to clear"}; String titleGeolocation = StringHelper.ROBOCOP_GEOLOCATION_TITLE; String url = getAbsoluteUrl(StringHelper.ROBOCOP_GEOLOCATION_URL); loadCheckDismiss(shareStrings[1], url, shareStrings[0]); checkOption(shareStrings[1], "Clear"); checkOption(shareStrings[3], "Cancel"); loadCheckDismiss(shareStrings[2], url, shareStrings[0]); checkOption(shareStrings[2], "Cancel"); - checkDevice(titleGeolocation, url); + checkDevice(titleGeolocation); } public void clearPassword(){ String passwordStrings[] = {"Save password", "Save", "Don't save"}; String title = StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE; String loginUrl = getAbsoluteUrl(StringHelper.ROBOCOP_LOGIN_URL); loadCheckDismiss(passwordStrings[1], loginUrl, passwordStrings[0]); checkOption(passwordStrings[1], "Clear"); loadCheckDismiss(passwordStrings[2], loginUrl, passwordStrings[0]); - checkDevice(title, getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL)); + checkDevice(title); } // clear private data and verify the device type because for phone there is an extra back action to exit the settings menu - public void checkDevice(final String title, final String url) { + public void checkDevice(String title) { clearPrivateData(); if (mDevice.type.equals("phone")) { mActions.sendSpecialKey(Actions.SpecialKey.BACK); mAsserter.ok(waitForText(StringHelper.PRIVACY_SECTION_LABEL), "waiting to perform one back", "one back"); + mActions.sendSpecialKey(Actions.SpecialKey.BACK); + verifyPageTitle(title); } - mActions.sendSpecialKey(Actions.SpecialKey.BACK); - verifyPageTitle(title, url); + else { + mActions.sendSpecialKey(Actions.SpecialKey.BACK); + verifyPageTitle(title); + } } - + // Load a URL, verify that the doorhanger appears and dismiss it public void loadCheckDismiss(String option, String url, String message) { inputAndLoadUrl(url); waitForText(message); mAsserter.is(mSolo.searchText(message), true, "Doorhanger:" + message + " has been displayed"); mSolo.clickOnButton(option); mAsserter.is(mSolo.searchText(message), false, "Doorhanger:" + message + " has been hidden"); }
--- a/mobile/android/base/tests/testHistory.java +++ b/mobile/android/base/tests/testHistory.java @@ -12,21 +12,21 @@ public class testHistory extends AboutHo public void testHistory() { blockForGeckoReady(); String url = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL); String url2 = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_02_URL); String url3 = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_03_URL); inputAndLoadUrl(url); - verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_URL, url); + verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_URL); inputAndLoadUrl(url2); - verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_URL, url2); + verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_URL); inputAndLoadUrl(url3); - verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_03_URL, url3); + verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_03_URL); openAboutHomeTab(AboutHomeTabs.HISTORY); final ListView hList = findListViewWithTag(HomePager.LIST_TAG_HISTORY); mAsserter.is(waitForNonEmptyListToLoad(hList), true, "list is properly loaded"); // Click on the history item and wait for the page to load // wait for the history list to be populated @@ -57,12 +57,12 @@ public class testHistory extends AboutHo } }, MAX_WAIT_MS); mAsserter.isnot(mFirstChild, null, "Got history item"); mSolo.clickOnView(mFirstChild); // The first item here (since it was just visited) should be a "Switch to tab" item // i.e. don't expect a DOMCOntentLoaded event - verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_03_URL, StringHelper.ROBOCOP_BLANK_PAGE_03_URL); + verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_03_URL); verifyUrl(url3); } }
--- a/mobile/android/base/tests/testInputConnection.java +++ b/mobile/android/base/tests/testInputConnection.java @@ -19,19 +19,18 @@ import android.view.inputmethod.InputCon */ public class testInputConnection extends UITest { private static final String INITIAL_TEXT = "foo"; public void testInputConnection() throws InterruptedException { GeckoHelper.blockForReady(); - final String url = StringHelper.ROBOCOP_INPUT_URL + "#" + INITIAL_TEXT; - NavigationHelper.enterAndLoadUrl(url); - mToolbar.assertTitle(StringHelper.ROBOCOP_INPUT_TITLE, url); + NavigationHelper.enterAndLoadUrl(StringHelper.ROBOCOP_INPUT_URL + "#" + INITIAL_TEXT); + mToolbar.assertTitle(StringHelper.ROBOCOP_INPUT_TITLE); mGeckoView.mTextInput .waitForInputConnection() .testInputConnection(new BasicInputConnectionTest()); } private class BasicInputConnectionTest implements InputConnectionTest { @Override
--- a/mobile/android/base/tests/testPictureLinkContextMenu.java +++ b/mobile/android/base/tests/testPictureLinkContextMenu.java @@ -13,17 +13,17 @@ public class testPictureLinkContextMenu private static final String imageTitle = "^Image$"; public void testPictureLinkContextMenu() { blockForGeckoReady(); PICTURE_PAGE_URL=getAbsoluteUrl(StringHelper.ROBOCOP_PICTURE_LINK_URL); BLANK_PAGE_URL=getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_02_URL); loadAndPaint(PICTURE_PAGE_URL); - verifyPageTitle(PICTURE_PAGE_TITLE, PICTURE_PAGE_URL); + verifyPageTitle(PICTURE_PAGE_TITLE); switchTabs(imageTitle); verifyContextMenuItems(photoMenuItems); verifyTabs(tabs); switchTabs(imageTitle); verifyCopyOption(photoMenuItems[0], "Firefox.jpg"); // Test the "Copy Image Location" option switchTabs(imageTitle); verifyShareOption(photoMenuItems[1], PICTURE_PAGE_TITLE); // Test the "Share Image" option
--- a/mobile/android/base/tests/testReaderMode.java +++ b/mobile/android/base/tests/testReaderMode.java @@ -68,17 +68,17 @@ public class testReaderMode extends Abou // Changing devices orientation to be sure that all devices are in portrait when will access the reader toolbar mSolo.setActivityOrientation(Solo.PORTRAIT); faviconExpecter.blockForEvent(); faviconExpecter.unregisterListener(); contentPageShowExpecter.blockForEvent(); contentPageShowExpecter.unregisterListener(); paintExpecter.blockUntilClear(EVENT_CLEAR_DELAY_MS); paintExpecter.unregisterListener(); - verifyPageTitle(StringHelper.ROBOCOP_TEXT_PAGE_TITLE, StringHelper.ROBOCOP_TEXT_PAGE_URL); + verifyPageTitle(StringHelper.ROBOCOP_TEXT_PAGE_TITLE); // Open the share menu for the reader toolbar height = mDriver.getGeckoTop() + mDriver.getGeckoHeight() - 10; width = mDriver.getGeckoLeft() + mDriver.getGeckoWidth() - 10; mAsserter.dumpLog("Long Clicking at width = " + String.valueOf(width) + " and height = " + String.valueOf(height)); mSolo.clickOnScreen(width,height); mAsserter.ok(mSolo.waitForText("Share via"), "Waiting for the share menu", "The share menu is present"); mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Close the share menu @@ -129,25 +129,25 @@ public class testReaderMode extends Abou openAboutHomeTab(AboutHomeTabs.READING_LIST); list = findListViewWithTag(HomePager.LIST_TAG_READING_LIST); child = list.getChildAt(childNo-1); mAsserter.ok(child != null, "Verify if the page is present to your Reading List", "The page is present in your Reading List"); contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded"); mSolo.clickOnView(child); contentEventExpecter.blockForEvent(); contentEventExpecter.unregisterListener(); - verifyPageTitle(StringHelper.ROBOCOP_TEXT_PAGE_TITLE, StringHelper.ROBOCOP_TEXT_PAGE_URL); + verifyPageTitle(StringHelper.ROBOCOP_TEXT_PAGE_TITLE); // Verify that we are in reader mode and remove the page from Reading List height = mDriver.getGeckoTop() + mDriver.getGeckoHeight() - 10; width = mDriver.getGeckoLeft() + 50; mAsserter.dumpLog("Long Clicking at width = " + String.valueOf(width) + " and height = " + String.valueOf(height)); mSolo.clickOnScreen(width,height); mAsserter.ok(mSolo.waitForText("Page removed from your Reading List"), "Waiting for the page to removed from your Reading List", "The page is removed from your Reading List"); - verifyPageTitle(StringHelper.ROBOCOP_TEXT_PAGE_TITLE, StringHelper.ROBOCOP_TEXT_PAGE_URL); + verifyPageTitle(StringHelper.ROBOCOP_TEXT_PAGE_TITLE); //Check if the Reading List is empty openAboutHomeTab(AboutHomeTabs.READING_LIST); list = findListViewWithTag(HomePager.LIST_TAG_READING_LIST); child = list.getChildAt(childNo-1); mAsserter.ok(child == null, "Verify if the Reading List is empty", "The Reading List is empty"); }
--- a/mobile/android/base/tests/testSelectionHandler.java +++ b/mobile/android/base/tests/testSelectionHandler.java @@ -11,19 +11,18 @@ import org.json.JSONObject; public class testSelectionHandler extends UITest { public void testSelectionHandler() { GeckoHelper.blockForReady(); Actions.EventExpecter robocopTestExpecter = getActions().expectGeckoEvent("Robocop:testSelectionHandler"); - final String url = "chrome://roboextender/content/testSelectionHandler.html"; - NavigationHelper.enterAndLoadUrl(url); - mToolbar.assertTitle(StringHelper.ROBOCOP_SELECTION_HANDLER_TITLE, url); + NavigationHelper.enterAndLoadUrl("chrome://roboextender/content/testSelectionHandler.html"); + mToolbar.assertTitle(StringHelper.ROBOCOP_SELECTION_HANDLER_TITLE); while (!test(robocopTestExpecter)) { // do nothing } robocopTestExpecter.unregisterListener(); }
--- a/mobile/android/base/tests/testSessionHistory.java +++ b/mobile/android/base/tests/testSessionHistory.java @@ -5,37 +5,30 @@ import org.mozilla.gecko.tests.helpers.N /** * Tests that navigating through session history (ex: forward, back) sets the correct UI state. */ public class testSessionHistory extends UITest { public void testSessionHistory() { GeckoHelper.blockForReady(); - String url = StringHelper.ROBOCOP_BLANK_PAGE_01_URL; - NavigationHelper.enterAndLoadUrl(url); - mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, url); + NavigationHelper.enterAndLoadUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL); + mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE); - url = StringHelper.ROBOCOP_BLANK_PAGE_02_URL; - NavigationHelper.enterAndLoadUrl(url); - mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE, url); + NavigationHelper.enterAndLoadUrl(StringHelper.ROBOCOP_BLANK_PAGE_02_URL); + mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE); - url = StringHelper.ROBOCOP_BLANK_PAGE_03_URL; - NavigationHelper.enterAndLoadUrl(url); - mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_03_TITLE, url); + NavigationHelper.enterAndLoadUrl(StringHelper.ROBOCOP_BLANK_PAGE_03_URL); + mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_03_TITLE); NavigationHelper.goBack(); - mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE, - StringHelper.ROBOCOP_BLANK_PAGE_02_URL); + mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE); NavigationHelper.goBack(); - mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, - StringHelper.ROBOCOP_BLANK_PAGE_01_URL); + mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE); NavigationHelper.goForward(); - mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE, - StringHelper.ROBOCOP_BLANK_PAGE_02_URL); + mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE); NavigationHelper.reload(); - mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE, - StringHelper.ROBOCOP_BLANK_PAGE_02_URL); + mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE); } }
--- a/mobile/android/base/tests/testShareLink.java +++ b/mobile/android/base/tests/testShareLink.java @@ -32,17 +32,17 @@ public class testShareLink extends About url = getAbsoluteUrl(StringHelper.ROBOCOP_BIG_LINK_URL); ArrayList<String> shareOptions; blockForGeckoReady(); // FIXME: This is a temporary hack workaround for a permissions problem. openAboutHomeTab(AboutHomeTabs.READING_LIST); inputAndLoadUrl(url); - verifyPageTitle(urlTitle, url); // Waiting for page title to ensure the page is loaded + verifyPageTitle(urlTitle); // Waiting for page title to ensure the page is loaded selectMenuItem(StringHelper.SHARE_LABEL); if (Build.VERSION.SDK_INT >= 14) { // Check for our own sync in the submenu. waitForText("Sync$"); } else { waitForText("Share via"); } @@ -243,17 +243,17 @@ public class testShareLink extends About private AbsListView getDisplayedShareList() { mViewGroup = null; boolean success = waitForTest(new BooleanTest() { @Override public boolean test() { ArrayList<View> views = mSolo.getCurrentViews(); for (View view : views) { - // List may be displayed in different view formats. + // List may be displayed in different view formats. // On JB, GridView is common; on ICS-, ListView is common. if (view instanceof ListView || view instanceof GridView) { mViewGroup = (AbsListView)view; return true; } } return false;
--- a/mobile/android/base/tests/testTitleBar.java +++ b/mobile/android/base/tests/testTitleBar.java @@ -1,44 +1,39 @@ package org.mozilla.gecko.tests; import org.mozilla.gecko.Actions; -import org.mozilla.gecko.NewTabletUI; /** * This patch tests the option that shows the full URL and title in the URL Bar */ public class testTitleBar extends PixelTest { public void testTitleBar() { - // Because there is no title bar option on new tablet, we don't need to run this test. - if (NewTabletUI.isEnabled(getActivity())) { - return; - } - blockForGeckoReady(); checkOption(); } public void checkOption() { + String blank1 = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL); String title = StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE; // Loading a page inputAndLoadUrl(blank1); - verifyPageTitle(title, blank1); + verifyPageTitle(title); // Verifing the full URL is displayed in the URL Bar selectOption(StringHelper.SHOW_PAGE_ADDRESS_LABEL); inputAndLoadUrl(blank1); verifyUrl(blank1); // Verifing the title is displayed in the URL Bar selectOption(StringHelper.SHOW_PAGE_TITLE_LABEL); inputAndLoadUrl(blank1); - verifyPageTitle(title, blank1); + verifyPageTitle(title); } // Entering settings, changing the options: show title/page address option and verifing the device type because for phone there is an extra back action to exit the settings menu public void selectOption(String option) { selectSettingsItem(StringHelper.DISPLAY_SECTION_LABEL, StringHelper.TITLE_BAR_LABEL); mAsserter.ok(waitForText(StringHelper.SHOW_PAGE_TITLE_LABEL), "Waiting for the pop-up to open", "Pop up with the options was openend"); mSolo.clickOnText(option); mAsserter.ok(waitForText(StringHelper.CHARACTER_ENCODING_LABEL), "Waiting to press the option", "The pop-up is dismissed once clicked");