Bug 906221 - [Fig] AboutHomeTest.updateBookmarks uses incorrect reflection. r=margaret
authorChenxia Liu <liuche@mozilla.com>
Fri, 23 Aug 2013 10:35:18 -0700
changeset 144073 df05f5edf8caf2d4d2056cd41e25918b44d28d96
parent 144072 9459d5c2e605aebf95c0fb2ff1e2e3f34c55477e
child 144074 984f2350c97f16a52f40998bf168a9b862ebdea5
push id2331
push usercliu@mozilla.com
push dateFri, 23 Aug 2013 17:35:44 +0000
treeherderfx-team@df05f5edf8ca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs906221
milestone26.0a1
Bug 906221 - [Fig] AboutHomeTest.updateBookmarks uses incorrect reflection. r=margaret
mobile/android/base/tests/AboutHomeTest.java.in
mobile/android/base/tests/testImportFromAndroid.java.in
--- a/mobile/android/base/tests/AboutHomeTest.java.in
+++ b/mobile/android/base/tests/AboutHomeTest.java.in
@@ -116,50 +116,36 @@ abstract class AboutHomeTest extends Bas
             if (TextUtils.equals(listTag, tag)) {
                 return listView;
             }
         }
 
         return null;
     }
 
+    /**
+     * Adds a bookmark, or updates the bookmark title if the url already exists.
+     *
+     * The LocalBrowserDB.addBookmark implementation handles updating existing bookmarks.
+     * Since we don't modify bookmark keywords in tests, we don't need a separate
+     * implemention of updateBookmark.
+     */
     protected void addOrUpdateMobileBookmark(String title, String url) {
-        if (isBookmark(url)) {
-            updateBookmark(title, url, null);
-        } else {
-            addMobileBookmark(title, url);
-        }
-    }
-
-    protected void addMobileBookmark(String title, String url) {
         try {
             ContentResolver resolver = getActivity().getContentResolver();
             ClassLoader classLoader = getActivity().getClassLoader();
             Class browserDB = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
             Method addBookmark = browserDB.getMethod("addBookmark", ContentResolver.class, String.class, String.class);
             addBookmark.invoke(null, resolver, title, url);
-            mAsserter.ok(true, "Inserting a new bookmark", "Inserter the bookmark with the title = " + title + " and the url = " + url);
+            mAsserter.ok(true, "Inserting/updating a new bookmark", "Inserting/updating the bookmark with the title = " + title + " and the url = " + url);
         } catch (Exception e) {
             mAsserter.ok(false, "Exception adding bookmark: ", e.toString());
         }
     }
 
-    protected void updateBookmark(String title, String url, String keyword) {
-        try {
-            ContentResolver resolver = getActivity().getContentResolver();
-            ClassLoader classLoader = getActivity().getClassLoader();
-            Class browserDB = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
-            Method updateBookmark = browserDB.getMethod("updateBookmark", ContentResolver.class, String.class, String.class);
-            updateBookmark.invoke(null, resolver, title, url, keyword);
-            mAsserter.ok(true, "Updating existing bookmark", "Setting the values to title = " + title + ", url = " + url + " and keyword = " + keyword);
-        } catch (Exception e) {
-            mAsserter.ok(false, "Exception updating bookmark: ", e.toString());
-        }
-    }
-
     protected void deleteBookmark(String url) {
         try {
             ContentResolver resolver = getActivity().getContentResolver();
             ClassLoader classLoader = getActivity().getClassLoader();
             Class browserDB = classLoader.loadClass("org.mozilla.gecko.db.BrowserDB");
             Method removeBookmark = browserDB.getMethod("removeBookmarksWithURL", ContentResolver.class, String.class);
             removeBookmark.invoke(null, resolver, url);
         } catch (Exception e) {
--- a/mobile/android/base/tests/testImportFromAndroid.java.in
+++ b/mobile/android/base/tests/testImportFromAndroid.java.in
@@ -105,17 +105,17 @@ public class testImportFromAndroid exten
 
     private void addData() {
         ArrayList<String> androidBookmarks = getAndroidUrls("bookmarks");
 
         // Add a few Bookmarks from Android to Firefox Mobile
         for (String url:androidBookmarks) {
             // Add every 3rd bookmark to Firefox Mobile
             if ((androidBookmarks.indexOf(url) % 3) == 0) {
-                 addOrUpdateMobileBookmark("Bookmar Number" + String.valueOf(androidBookmarks.indexOf(url)), url);
+                 addOrUpdateMobileBookmark("Bookmark Number " + String.valueOf(androidBookmarks.indexOf(url)), url);
             }
         }
 
         // Add a few history items in Firefox Mobile
         ContentResolver resolver = getActivity().getContentResolver();
         Uri uri = Uri.parse("content://@ANDROID_PACKAGE_NAME@.db.browser/history");
         uri = uri.buildUpon().appendQueryParameter("profile", "default")
                              .appendQueryParameter("sync", "true").build();