Bug 903478 - Add findListViewWithTag() to BaseTest (r=margaret)
authorLucas Rocha <lucasr@mozilla.com>
Sat, 17 Aug 2013 14:23:52 +0100
changeset 143556 fbbc87078c3c5375d4f3edb2fe0219bd6bb5dedc
parent 143555 45ed1f18184f947c0ed5c174ee9dcbc5949c8ffb
child 143557 c67df6233bd1c9cf553fc6ddd5b37aad7219d45b
push id25130
push userlrocha@mozilla.com
push dateWed, 21 Aug 2013 09:41:27 +0000
treeherdermozilla-central@b2486721572e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs903478
milestone26.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 903478 - Add findListViewWithTag() to BaseTest (r=margaret)
mobile/android/base/tests/AboutHomeTest.java.in
--- a/mobile/android/base/tests/AboutHomeTest.java.in
+++ b/mobile/android/base/tests/AboutHomeTest.java.in
@@ -2,16 +2,17 @@
 package @ANDROID_PACKAGE_NAME@.tests;
 
 import @ANDROID_PACKAGE_NAME@.*;
 
 import android.content.ContentResolver;
 import android.database.Cursor;
 import android.net.Uri;
 import android.support.v4.view.ViewPager;
+import android.text.TextUtils;
 import android.view.View;
 import android.widget.TabWidget;
 import android.widget.ListView;
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 
 /**
@@ -69,16 +70,36 @@ abstract class AboutHomeTest extends Bas
         } else {
             mAsserter.ok(false, "The wrong data type has been provided = " + dataType.toString(), "Please provide a BrowserDataType value");
         }
         uri = uri.buildUpon().appendQueryParameter("profile", "default")
                              .appendQueryParameter("sync", "true").build();
         return uri;
     }
 
+    /**
+     * Get an active ListView with the specified tag .
+     *
+     * This method uses the predefined tags in HomePager.
+     */
+    protected final ListView findListViewWithTag(String tag) {
+        for (ListView listView : mSolo.getCurrentListViews()) {
+            final String listTag = (String) listView.getTag();
+            if (TextUtils.isEmpty(listTag)) {
+                continue;
+            }
+
+            if (TextUtils.equals(listTag, tag)) {
+                return listView;
+            }
+        }
+
+        return null;
+    }
+
     protected void addOrUpdateMobileBookmark(String title, String url) {
         if (isBookmark(url)) {
             updateBookmark(title, url, null);
         } else {
             addMobileBookmark(title, url);
         }
     }