Bug 1028728 - Update findListViewWithTag consumers to use strings from HomePager. r=mcomella
authorFranz Sarmiento <franzks@gmail.com>
Tue, 24 Jun 2014 21:41:00 -0400
changeset 191175 183f367cda864554f76278e5dfb0c470f11b05a4
parent 191174 24d194587ab58506b7a818ee173fe14366b93798
child 191176 7cb69ef00dbb44062cd6872730f278fbbfad3c20
push id27035
push userkwierso@gmail.com
push dateFri, 27 Jun 2014 23:52:01 +0000
treeherdermozilla-central@f127b565e53f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella
bugs1028728
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1028728 - Update findListViewWithTag consumers to use strings from HomePager. r=mcomella
mobile/android/base/home/HomePager.java
mobile/android/base/tests/AboutHomeTest.java
mobile/android/base/tests/testAddSearchEngine.java
mobile/android/base/tests/testBookmarkFolders.java
mobile/android/base/tests/testBookmarklets.java
mobile/android/base/tests/testHistory.java
mobile/android/base/tests/testReaderMode.java
mobile/android/base/tests/testShareLink.java
--- a/mobile/android/base/home/HomePager.java
+++ b/mobile/android/base/home/HomePager.java
@@ -59,22 +59,22 @@ public class HomePager extends ViewPager
     // Current load state of HomePager.
     private LoadState mLoadState;
 
     // Listens for when the current panel changes.
     private OnPanelChangeListener mPanelChangedListener;
 
     // This is mostly used by UI tests to easily fetch
     // specific list views at runtime.
-    static final String LIST_TAG_HISTORY = "history";
-    static final String LIST_TAG_BOOKMARKS = "bookmarks";
-    static final String LIST_TAG_READING_LIST = "reading_list";
-    static final String LIST_TAG_TOP_SITES = "top_sites";
-    static final String LIST_TAG_RECENT_TABS = "recent_tabs";
-    static final String LIST_TAG_BROWSER_SEARCH = "browser_search";
+    public static final String LIST_TAG_HISTORY = "history";
+    public static final String LIST_TAG_BOOKMARKS = "bookmarks";
+    public static final String LIST_TAG_READING_LIST = "reading_list";
+    public static final String LIST_TAG_TOP_SITES = "top_sites";
+    public static final String LIST_TAG_RECENT_TABS = "recent_tabs";
+    public static final String LIST_TAG_BROWSER_SEARCH = "browser_search";
 
     public interface OnUrlOpenListener {
         public enum Flags {
             ALLOW_SWITCH_TO_TAB,
             OPEN_WITH_INTENT
         }
 
         public void onUrlOpen(String url, EnumSet<Flags> flags);
--- a/mobile/android/base/tests/AboutHomeTest.java
+++ b/mobile/android/base/tests/AboutHomeTest.java
@@ -2,16 +2,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.tests;
 
 import java.util.ArrayList;
 
 import org.mozilla.gecko.Actions;
+import org.mozilla.gecko.home.HomePager;
 
 import android.support.v4.view.ViewPager;
 import android.text.TextUtils;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ListAdapter;
 import android.widget.ListView;
 import android.widget.TabWidget;
@@ -105,17 +106,17 @@ abstract class AboutHomeTest extends Pix
         }
     }
 
     // @return the View associated with bookmark for the provided url or null if the link is not bookmarked
     protected View getDisplayedBookmark(String url) {
         openAboutHomeTab(AboutHomeTabs.BOOKMARKS);
         mSolo.hideSoftKeyboard();
         getInstrumentation().waitForIdleSync();
-        ListView bookmarksTabList = findListViewWithTag("bookmarks");
+        ListView bookmarksTabList = findListViewWithTag(HomePager.LIST_TAG_BOOKMARKS);
         waitForNonEmptyListToLoad(bookmarksTabList);
         ListAdapter adapter = bookmarksTabList.getAdapter();
         if (adapter != null) {
             for (int i = 0; i < adapter.getCount(); i++ ) {
                 // I am unable to click the view taken with getView for some reason so getting the child at i
                 bookmarksTabList.smoothScrollToPosition(i);
                 View bookmarkView = bookmarksTabList.getChildAt(i);
                 if (bookmarkView instanceof android.widget.LinearLayout) {
--- a/mobile/android/base/tests/testAddSearchEngine.java
+++ b/mobile/android/base/tests/testAddSearchEngine.java
@@ -1,16 +1,17 @@
 package org.mozilla.gecko.tests;
 
 import java.util.ArrayList;
 
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.mozilla.gecko.Actions;
+import org.mozilla.gecko.home.HomePager;
 
 import android.widget.ImageView;
 import android.widget.ListAdapter;
 import android.widget.ListView;
 
 /**
  * Test adding a search engine from an input field context menu.
  * 1. Get the number of existing search engines from the SearchEngine:Data event and as displayed in about:home.
@@ -127,17 +128,17 @@ public class testAddSearchEngine extends
      * @param expectedCount The expected number of search engines.
      */
     public void verifyDisplayedSearchEnginesCount(final int expectedCount) {
         mSolo.clearEditText(0);
         mActions.sendKeys(SEARCH_TEXT);
         boolean correctNumSearchEnginesDisplayed = waitForTest(new BooleanTest() {
             @Override
             public boolean test() {
-                ListView list = findListViewWithTag("browser_search");
+                ListView list = findListViewWithTag(HomePager.LIST_TAG_BROWSER_SEARCH);
                 if (list == null) {
                     return false;
                 }
                 ListAdapter adapter = list.getAdapter();
                 if (adapter == null) {
                     return false;
                 }
                 return (adapter.getCount() == expectedCount);
--- a/mobile/android/base/tests/testBookmarkFolders.java
+++ b/mobile/android/base/tests/testBookmarkFolders.java
@@ -1,11 +1,12 @@
 package org.mozilla.gecko.tests;
 
 import org.mozilla.gecko.sync.Utils;
+import org.mozilla.gecko.home.HomePager;
 
 import android.content.ContentResolver;
 import android.content.ContentValues;
 import android.net.Uri;
 import android.view.View;
 import android.widget.ListAdapter;
 import android.widget.ListView;
 import android.widget.TextView;
@@ -24,17 +25,17 @@ public class testBookmarkFolders extends
 
     private void checkBookmarkList() {
         openAboutHomeTab(AboutHomeTabs.BOOKMARKS);
         waitForText(StringHelper.DESKTOP_FOLDER_LABEL);
         clickOnBookmarkFolder(StringHelper.DESKTOP_FOLDER_LABEL);
         waitForText(StringHelper.TOOLBAR_FOLDER_LABEL);
 
         // Verify the number of folders displayed in the Desktop Bookmarks folder is correct
-        ListView desktopFolderContent = findListViewWithTag("bookmarks");
+        ListView desktopFolderContent = findListViewWithTag(HomePager.LIST_TAG_BOOKMARKS);
         ListAdapter adapter = desktopFolderContent.getAdapter();
         if (mDevice.type.equals("tablet")) { // On tablets it's 4 folders and 1 view for top padding
             mAsserter.is(adapter.getCount(), 5, "Checking that the correct number of folders is displayed in the Desktop Bookmarks folder");
         } else { // On phones it's just the 4 folders
             mAsserter.is(adapter.getCount(), 4, "Checking that the correct number of folders is displayed in the Desktop Bookmarks folder");
         }
 
         clickOnBookmarkFolder(StringHelper.TOOLBAR_FOLDER_LABEL);
@@ -93,17 +94,17 @@ public class testBookmarkFolders extends
         mAsserter.ok(success, "Trying to click on the " + folderName + " folder","The " + folderName + " folder was clicked");
     }
 
     private View getBookmarkFolderView(String folderName) {
         openAboutHomeTab(AboutHomeTabs.BOOKMARKS);
         mSolo.hideSoftKeyboard();
         getInstrumentation().waitForIdleSync();
 
-        ListView bookmarksTabList = findListViewWithTag("bookmarks");
+        ListView bookmarksTabList = findListViewWithTag(HomePager.LIST_TAG_BOOKMARKS);
         if (!waitForNonEmptyListToLoad(bookmarksTabList)) {
             return null;
         }
 
         ListAdapter adapter = bookmarksTabList.getAdapter();
         if (adapter == null) {
             return null;
         }
--- a/mobile/android/base/tests/testBookmarklets.java
+++ b/mobile/android/base/tests/testBookmarklets.java
@@ -1,11 +1,12 @@
 package org.mozilla.gecko.tests;
 
 import org.mozilla.gecko.Actions;
+import org.mozilla.gecko.home.HomePager;
 
 import android.database.Cursor;
 import android.widget.ListView;
 
 
 public class testBookmarklets extends AboutHomeTest {
     public void testBookmarklets() {
         final String url = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
@@ -32,17 +33,17 @@ public class testBookmarklets extends Ab
 
         // add the bookmarklet to the database. there's currently no way to
         // add this using the UI, so we go through the content provider.
         mDatabaseHelper.addOrUpdateMobileBookmark(title, js);
 
         // Open about:home in the Bookmarks page
         openAboutHomeTab(AboutHomeTabs.BOOKMARKS);
 
-        ListView bookmarks = findListViewWithTag("bookmarks");
+        ListView bookmarks = findListViewWithTag(HomePager.LIST_TAG_BOOKMARKS);
         mAsserter.is(waitForNonEmptyListToLoad(bookmarks), true, "list is properly loaded");
 
         int width = mDriver.getGeckoWidth();
         int height = mDriver.getGeckoHeight();
 
         // Scroll down so that the bookmarks list has more items on screen.
         mActions.drag(width / 2, width / 2, height - 10, height / 2);
 
--- a/mobile/android/base/tests/testHistory.java
+++ b/mobile/android/base/tests/testHistory.java
@@ -1,14 +1,16 @@
 package org.mozilla.gecko.tests;
 
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ListView;
 
+import org.mozilla.gecko.home.HomePager;
+
 public class testHistory extends AboutHomeTest {
     private View mFirstChild;
 
     public void testHistory() {
         blockForGeckoReady();
 
         String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
         String url2 = getAbsoluteUrl("/robocop/robocop_blank_02.html");
@@ -18,17 +20,17 @@ public class testHistory extends AboutHo
         verifyPageTitle("Browser Blank Page 01");
         inputAndLoadUrl(url2);
         verifyPageTitle("Browser Blank Page 02");
         inputAndLoadUrl(url3);
         verifyPageTitle("Browser Blank Page 03");
 
         openAboutHomeTab(AboutHomeTabs.HISTORY);
 
-        final ListView hList = findListViewWithTag("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
         mFirstChild = null;
         boolean success = waitForTest(new BooleanTest() {
             @Override
             public boolean test() {
--- a/mobile/android/base/tests/testReaderMode.java
+++ b/mobile/android/base/tests/testReaderMode.java
@@ -1,13 +1,14 @@
 package org.mozilla.gecko.tests;
 
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.mozilla.gecko.Actions;
+import org.mozilla.gecko.home.HomePager;
 import org.mozilla.gecko.R;
 
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ListView;
 
 import com.jayway.android.robotium.solo.Condition;
 import com.jayway.android.robotium.solo.Solo;
@@ -102,34 +103,34 @@ public class testReaderMode extends Abou
         contentEventExpecter.blockForEvent();
         contentEventExpecter.unregisterListener();
 
         // Check if the page is present in the Reading List
         mAsserter.ok(mSolo.waitForText("Robocop Text Page"), "Verify if the page is added to your Reading List", "The page is present in your Reading List");
 
         // Check if the page is added in History tab like a Reading List item
         openAboutHomeTab(AboutHomeTabs.HISTORY);
-        list = findListViewWithTag("history");
+        list = findListViewWithTag(HomePager.LIST_TAG_HISTORY);
         child = list.getChildAt(1);
         mAsserter.ok(child != null, "item can be retrieved", child != null ? child.toString() : "null!");
         mSolo.clickLongOnView(child);
         mAsserter.ok(mSolo.waitForText("Open in Reader"), "Verify if the page is present in history as a Reading List item", "The page is present in history as a Reading List item");
         mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Dismiss the context menu
         mSolo.waitForText("Robocop Text Page");
 
         // Verify separately the Reading List entries for tablets and phone because for tablets there is an extra child in UI design
         if (devType.equals("phone")) {
             childNo = 1;
         }
         else {
             childNo = 2;
         }
         // Verify if the page is present to your Reading List
         openAboutHomeTab(AboutHomeTabs.READING_LIST);
-        list = findListViewWithTag("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("Robocop Text Page");
 
@@ -138,17 +139,17 @@ public class testReaderMode extends Abou
         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("Robocop Text Page");
 
         //Check if the Reading List is empty
         openAboutHomeTab(AboutHomeTabs.READING_LIST);
-        list = findListViewWithTag("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");
     }
 
     // Get the reader icon method
     protected View getReaderIcon() {
         View pageActionLayout = mSolo.getView(R.id.page_action_layout);
         final ViewGroup actionLayoutEntry = (ViewGroup)pageActionLayout;
--- a/mobile/android/base/tests/testShareLink.java
+++ b/mobile/android/base/tests/testShareLink.java
@@ -1,14 +1,15 @@
 package org.mozilla.gecko.tests;
 
 import java.util.ArrayList;
 import java.util.List;
 
 import org.mozilla.gecko.Actions;
+import org.mozilla.gecko.home.HomePager;
 
 import android.app.Activity;
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.os.Build;
 import android.view.View;
 import android.view.ViewGroup;
@@ -63,17 +64,17 @@ public class testShareLink extends About
         float top = mDriver.getGeckoTop() + 30 * mDevice.density;
         float left = mDriver.getGeckoLeft() + mDriver.getGeckoWidth() / 2;
         mSolo.clickLongOnScreen(left, top);
         verifySharePopup("Share Link",shareOptions,"Link");
 
         // Test the share popup in the Bookmarks page
         openAboutHomeTab(AboutHomeTabs.BOOKMARKS);
 
-        final ListView bookmarksList = findListViewWithTag("bookmarks");
+        final ListView bookmarksList = findListViewWithTag(HomePager.LIST_TAG_BOOKMARKS);
         mAsserter.is(waitForNonEmptyListToLoad(bookmarksList), true, "list is properly loaded");
 
         int headerViewsCount = bookmarksList.getHeaderViewsCount();
         View bookmarksItem = bookmarksList.getChildAt(headerViewsCount);
         if (bookmarksItem == null) {
             mAsserter.dumpLog("no child at index " + headerViewsCount + "; waiting for one...");
             Condition listWaitCondition = new Condition() {
                 @Override
@@ -108,26 +109,26 @@ public class testShareLink extends About
         // Test the share popup in Top Sites.
         openAboutHomeTab(AboutHomeTabs.TOP_SITES);
 
         // Scroll down a bit so that the top sites list has more items on screen.
         int width = mDriver.getGeckoWidth();
         int height = mDriver.getGeckoHeight();
         mActions.drag(width / 2, width / 2, height - 10, height / 2);
 
-        ListView topSitesList = findListViewWithTag("top_sites");
+        ListView topSitesList = findListViewWithTag(HomePager.LIST_TAG_TOP_SITES);
         mAsserter.is(waitForNonEmptyListToLoad(topSitesList), true, "list is properly loaded");
         View mostVisitedItem = topSitesList.getChildAt(topSitesList.getHeaderViewsCount());
         mSolo.clickLongOnView(mostVisitedItem);
         verifySharePopup(shareOptions,"top_sites");
 
         // Test the share popup in the history tab
         openAboutHomeTab(AboutHomeTabs.HISTORY);
 
-        ListView mostRecentList = findListViewWithTag("history");
+        ListView mostRecentList = findListViewWithTag(HomePager.LIST_TAG_HISTORY);
         mAsserter.is(waitForNonEmptyListToLoad(mostRecentList), true, "list is properly loaded");
 
         // Getting second child after header views because the first is the "Today" label
         View mostRecentItem = mostRecentList.getChildAt(mostRecentList.getHeaderViewsCount() + 1);
         mSolo.clickLongOnView(mostRecentItem);
         verifySharePopup(shareOptions,"most recent");
     }