Bug 1210409 - testImportFromAndroid: Inline functionality that has been in android.provider.Browser previously. r=jmaher
authorSebastian Kaspari <s.kaspari@gmail.com>
Fri, 02 Oct 2015 13:59:44 +0200
changeset 265659 a2227abb5c3fabf97fc6d5e6df46fa14966306f7
parent 265658 43e9af14107814b83f01a16d13616e6533d47ee3
child 265660 f6282e8237022ee0e6f81341efa862df596c750f
push id15474
push users.kaspari@gmail.com
push dateFri, 02 Oct 2015 12:01:12 +0000
treeherderfx-team@f6282e823702 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs1210409
milestone44.0a1
Bug 1210409 - testImportFromAndroid: Inline functionality that has been in android.provider.Browser previously. r=jmaher
mobile/android/tests/browser/robocop/testImportFromAndroid.java
--- a/mobile/android/tests/browser/robocop/testImportFromAndroid.java
+++ b/mobile/android/tests/browser/robocop/testImportFromAndroid.java
@@ -167,19 +167,19 @@ public class testImportFromAndroid exten
 
     public ArrayList<String> getAndroidUrls(String data) {
         // Return bookmarks or history depending on what the user asks for
         ArrayList<String> urls = new ArrayList<String>();
         ContentResolver resolver = getActivity().getContentResolver();
         Cursor cursor = null;
         try {
             if (data.equals("history")) {
-                cursor = Browser.getAllVisitedUrls(resolver);
+                cursor = getAllVisitedUrls(resolver);
             } else if (data.equals("bookmarks")) {
-                cursor = Browser.getAllBookmarks(resolver);
+                cursor = getAllBookmarks(resolver);
             }
             if (cursor != null) {
                 cursor.moveToFirst();
                 for (int i = 0; i < cursor.getCount(); i++ ) {
                      urls.add(cursor.getString(cursor.getColumnIndex("url")));
                      if(!cursor.isLast()) {
                         cursor.moveToNext();
                      }
@@ -200,14 +200,31 @@ public class testImportFromAndroid exten
              mDatabaseHelper.deleteBookmark(url);
         }
         // History
         for (String url:androidData) {
              mDatabaseHelper.deleteHistoryItem(url);
         }
     }
 
+    private static Cursor getAllVisitedUrls(ContentResolver resolver) {
+        final Uri authorityUri = Uri.parse("content://com.android.browser");
+        final Uri contentUri = Uri.withAppendedPath(authorityUri, "combined");
+
+        return resolver.query(contentUri,
+                new String[] { "url" }, null, null,
+                "created ASC");
+    }
+
+    private static Cursor getAllBookmarks(ContentResolver resolver) {
+        final Uri bookmarksUri = Uri.parse("content://browser/bookmarks");
+
+        return resolver.query(bookmarksUri,
+            new String[] { "url" },
+            "folder = 0", null, null);
+    }
+
     @Override
     public void tearDown() throws Exception {
         deleteImportedData();
         super.tearDown();
     }
 }