Bug 820276 - Robocop: Make editBookmark and checkBookmarkEdit methods available to other tests. r=jmaher
authorAdrian Tamas <adrian.tamas@softvision.ro>
Tue, 19 Mar 2013 16:12:43 +0200
changeset 126385 5a569ac82c3611b1284758dd4918a451068bee7a
parent 126384 50d01a77718e91b8d68173fba070c722626f7f05
child 126386 508256893af740c62a7a9682a48035fbd8e26a18
push id24482
push userryanvm@gmail.com
push dateWed, 27 Mar 2013 21:03:24 +0000
treeherdermozilla-central@279078670022 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs820276
milestone22.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 820276 - Robocop: Make editBookmark and checkBookmarkEdit methods available to other tests. r=jmaher
mobile/android/base/tests/BaseTest.java.in
mobile/android/base/tests/testBookmarksTab.java.in
--- a/mobile/android/base/tests/BaseTest.java.in
+++ b/mobile/android/base/tests/BaseTest.java.in
@@ -561,16 +561,79 @@ abstract class BaseTest extends Activity
         mAsserter.ok(addTab.click(), "checking that add_tab clicked", "add_tab element clicked");
         // must pause before sending keys, until awesome bar is displayed; waiting for known text is simple
         waitForText("History");
         // cannot use loadUrl(): getText fails because we are using a different urlbar
         mActions.sendKeys(url);
         hitEnterAndWait();
     }
 
+    /**
+    * This method will edit the bookmark with index = bookmarkIndex from the list of bookmarks
+    * For the field index:
+    *     fieldIndex = 1 - the Bookmark name
+    *     fieldIndex = 2 - the Bookmark url
+    *     fieldIndex = 3 - the Bookmark keyword
+    */
+    public void editBookmark(int bookmarkIndex, int fieldIndex, String addedText, ListView list) {
+
+        // Open the Edit Bookmark context menu
+        View child;
+        mSolo.clickOnText("Bookmarks");
+        child = list.getChildAt(bookmarkIndex);
+        mAsserter.ok(child != null, "edit item can be retrieved", child != null ? child.toString() : "null!");
+        waitForText("about:home|Firefox");
+        mSolo.clickLongOnView(child);
+        waitForText("Open in New Tab");
+        mSolo.clickOnText("Edit");
+        waitForText("Edit Bookmark");
+
+        // Clear the Field
+        mSolo.clearEditText(fieldIndex);
+
+        // Enter the new text
+        mSolo.clickOnEditText(fieldIndex);
+        mActions.sendKeys(addedText);
+        mSolo.clickOnText("OK");
+        waitForText("Bookmark updated");
+        mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
+    }
+
+    public boolean checkBookmarkEdit(int bookmarkIndex, String addedText, ListView list) {
+        Device mDevice = new Device();
+        // Open the Edit Bookmark context menu
+        View child;
+        mSolo.clickOnText("Bookmarks");
+        child = list.getChildAt(bookmarkIndex);
+        mAsserter.ok(child != null, "check item can be retrieved", child != null ? child.toString() : "null!");
+        waitForText("about:home|Firefox");
+        mSolo.clickLongOnView(child);
+        waitForText("Open in New Tab");
+        mSolo.clickOnText("Edit");
+        waitForText("Edit Bookmark");
+
+        // If the OS is not Gingerbread the vkb will be opened so we need to close it in order to press the "Cancel" button
+        if (!(mDevice.version.equals("2.x"))) {
+            mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
+        }
+
+        // Check if the new text was added
+        if (mSolo.searchText(addedText)) {
+            mSolo.clickOnText("Cancel");
+            waitForText("about:home");
+            mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
+            return true;
+        } else {
+            mSolo.clickOnText("Cancel");
+            waitForText("about:home");
+            mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
+            return false;
+        }
+    }
+
     class Device {
         Build.VERSION mBuildVersion;
         public String version; // 2.x or 3.x or 4.x
         public String type; // "tablet" or "phone"
         public int width;
         public int height;
 
         public Device() {
--- a/mobile/android/base/tests/testBookmarksTab.java.in
+++ b/mobile/android/base/tests/testBookmarksTab.java.in
@@ -138,26 +138,26 @@ public class testBookmarksTab extends Ba
             mAsserter.is(mSolo.waitForText("Open in New Tab"), false, "Folders have no context menu");
         } else {
             mAsserter.ok(false, "waiting for bookmark item", "bookmark item available");
         }
 
         list = getBookmarksList(url);
 
         // Test edit bookmark name
-        editBookmark(1,0," Bookmark Name ");
-        mAsserter.is(checkBookmarkEdit(1," Bookmark Name "), true, "Bookmark Name was changed");
+        editBookmark(1,0," Bookmark Name ",list);
+        mAsserter.is(checkBookmarkEdit(1," Bookmark Name ",list), true, "Bookmark Name was changed");
 
         // Test edit bookmark link
-        editBookmark(1,1," Bookmark Link ");
-        mAsserter.is(checkBookmarkEdit(1,"Bookmark Link"), true, "Bookmark Link was changed");
+        editBookmark(1,1," Bookmark Link ",list);
+        mAsserter.is(checkBookmarkEdit(1,"Bookmark Link",list), true, "Bookmark Link was changed");
 
         // Test edit bookmark keyword
-        editBookmark(1,2," Bookmark Keyword ");
-        mAsserter.is(checkBookmarkEdit(1,"Bookmark Keyword"), true, "Bookmark Keyword was changed");
+        editBookmark(1,2," Bookmark Keyword ",list);
+        mAsserter.is(checkBookmarkEdit(1,"Bookmark Keyword",list), true, "Bookmark Keyword was changed");
 
         // Remove Bookmark from Context Menu
         waitForText("Bookmarks");
         child = list.getChildAt(1);
         mAsserter.ok(child != null, "second list item can be retrieved", child != null ? child.toString() : "null!");
         mSolo.clickLongOnView(child);
         waitForText("Open in New Tab");
         mSolo.clickOnText("Remove");
@@ -172,72 +172,16 @@ public class testBookmarksTab extends Ba
         waitForText("Open in New Tab");
         mAsserter.is(mSolo.searchText("Bookmark Name"), false, "Removed bookmark has been deleted");
         mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Exit the Context Menu
 
         // back again to exit the awesomebar
         mActions.sendSpecialKey(Actions.SpecialKey.BACK);
     }
 
-    private void editBookmark(int bookmarkIndex, int fieldIndex, String addedText) {
-
-        // Open the Edit Bookmark context menu
-        View child;
-        mSolo.clickOnText("Bookmarks");
-        child = list.getChildAt(bookmarkIndex);
-        mAsserter.ok(child != null, "edit item can be retrieved", child != null ? child.toString() : "null!");
-        waitForText("about:home");
-        mSolo.clickLongOnView(child);
-        waitForText("Open in New Tab");
-        mSolo.clickOnText("Edit");
-        waitForText("Edit Bookmark");
-
-        // Clear the Field
-        mSolo.clearEditText(fieldIndex);
-
-        // Enter the new text
-        mSolo.clickOnEditText(fieldIndex);
-        mActions.sendKeys(addedText);
-        mSolo.clickOnText("OK");
-        waitForText("Bookmark updated");
-        mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
-    }
-
-    private boolean checkBookmarkEdit(int bookmarkIndex, String addedText) {
-        Device mDevice = new Device();
-        // Open the Edit Bookmark context menu
-        View child;
-        mSolo.clickOnText("Bookmarks");
-        child = list.getChildAt(bookmarkIndex);
-        mAsserter.ok(child != null, "check item can be retrieved", child != null ? child.toString() : "null!");
-        waitForText("about:home");
-        mSolo.clickLongOnView(child);
-        waitForText("Open in New Tab");
-        mSolo.clickOnText("Edit");
-        waitForText("Edit Bookmark");
-
-        // If the OS is not Gingerbread the vkb will be opened so we need to close it in order to press the "Cancel" button
-        if (!(mDevice.version.equals("2.x"))) {
-            mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
-        }
-
-        // Check if the new text was added
-        if (mSolo.searchText(addedText)) {
-           mSolo.clickOnText("Cancel");
-           waitForText("about:home");
-           mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
-           return true;
-        } else {
-           mSolo.clickOnText("Cancel");
-           waitForText("about:home");
-           mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
-           return false;
-        }
-    }
-
     private void compareRow(View child, int numTextViews, int numImageViews) {
         if (child == null) {
             // this list item may be obscured or offscreen
             mAsserter.dumpLog("ListView child not available for comparison - offscreen?");
             return;
         }
         ArrayList<View> views = mSolo.getViews(child);
         ArrayList<ImageView> imageViews = new ArrayList<ImageView>();