Backed out changeset 0b6f43cbb7dd (bug 899187) for causing a couple of new intermittent failures
authorEd Morley <emorley@mozilla.com>
Tue, 15 Oct 2013 17:22:34 +0100
changeset 165652 79360e1c33a56ca48ac62548c7f436fa445a04ab
parent 165604 1960e499d49ff65ed613b0ed1dbc5f95c98b5502
child 165653 082357277604d2f50f852f9b7d0d733d894dda9a
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs899187
milestone27.0a1
backs out0b6f43cbb7ddaea2bbc357847bb2e7fc331d8f09
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
Backed out changeset 0b6f43cbb7dd (bug 899187) for causing a couple of new intermittent failures
mobile/android/base/tests/AboutHomeTest.java.in
mobile/android/base/tests/StringHelper.java.in
mobile/android/base/tests/robocop.ini
mobile/android/base/tests/testBookmarksPage.java.in
--- a/mobile/android/base/tests/AboutHomeTest.java.in
+++ b/mobile/android/base/tests/AboutHomeTest.java.in
@@ -15,17 +15,16 @@ import android.widget.GridView;
 import android.widget.LinearLayout;
 import android.widget.TabWidget;
 import android.widget.ListAdapter;
 import android.widget.ListView;
 import android.widget.TextView;
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.Arrays;
 
 /**
  * This class is an extension of BaseTest that helps with interaction with about:home
  * This class contains methods that access the different tabs from about:home, methods that get information like history and bookmarks from the database, edit and remove bookmarks and history items
  * The purpose of this class is to collect all the logically connected methods that deal with about:home
  * To use any of these methods in your test make sure it extends AboutHomeTest instead of BaseTest
  */
 abstract class AboutHomeTest extends BaseTest {
@@ -93,20 +92,16 @@ abstract class AboutHomeTest extends Bas
         } else {
             mAsserter.ok(false, url + " is not one of the displayed bookmarks", "Please make sure the url provided is bookmarked");
         }
     }
 
     // @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);
-        if (!mDevice.type.equals("tablet")) {
-            toggleVKB(); // dismiss the keyboard to make sure this works on small screen devices
-        }
-        getInstrumentation().waitForIdleSync();
         ListView bookmarksTabList = findListViewWithTag("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);
@@ -177,40 +172,69 @@ abstract class AboutHomeTest extends Bas
                 return listView;
             }
         }
 
         return null;
     }
 
    /**
-    * @param1 a String with the original url
-    * @param2 a String array with the new values for all fields
+    * FIXME: rewrite this to work with fig when rewriting the testBookmarksTab test
+    * 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
     */
-    protected void editBookmark(String originalUrl, String[] newValues) {
-        openBookmarkContextMenu(originalUrl);
+    protected 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("Switch to tab");
+        mSolo.clickLongOnView(child);
+        waitForText("Share");
         mSolo.clickOnText("Edit");
         waitForText("Edit Bookmark");
-        for (String value:newValues) {
-            mSolo.clearEditText(Arrays.asList(newValues).indexOf(value));
-            mSolo.clickOnEditText(Arrays.asList(newValues).indexOf(value));
-            mActions.sendKeys(value);
-        }
-        mSolo.clickOnButton("OK");
+
+        // Clear the Field
+        mSolo.clearEditText(fieldIndex);
+
+        // Enter the new text
+        mSolo.clickOnEditText(fieldIndex);
+        mActions.sendKeys(addedText);
+        mSolo.clickOnText("OK");
         waitForText("Bookmark updated");
     }
 
-    protected void checkBookmarkEdit(String bookmarkUrl, String[] values) {
-        openBookmarkContextMenu(bookmarkUrl);
+    // FIXME: rewrite this to work with fig when rewriting the testBookmarksTab test
+    protected boolean checkBookmarkEdit(int bookmarkIndex, String addedText, ListView list) {
+        // 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("Switch to tab");
+        mSolo.clickLongOnView(child);
+        waitForText("Share");
         mSolo.clickOnText("Edit");
-        for (String value:values) {
-            mAsserter.ok(mSolo.searchText(value), "Checking that the value is correct", "The value = " + value + " is correct");
+        waitForText("Edit Bookmark");
+
+        // Check if the new text was added
+        if (mSolo.searchText(addedText)) {
+            clickOnButton("Cancel");
+            waitForText("about:home");
+            return true;
+        } else {
+            clickOnButton("Cancel");
+            waitForText("about:home");
+            return false;
         }
-        clickOnButton("Cancel");
-        waitForText("BOOKMARKS");
     }
 
     // A wait in order for the about:home tab to be rendered after drag/tab selection
     private void waitForAboutHomeTab(final int tabIndex) {
         boolean correctTab = waitForCondition(new Condition() {
             @Override
             public boolean isSatisfied() {
                 ViewPager pager = (ViewPager)mSolo.getView(ViewPager.class, 0);
--- a/mobile/android/base/tests/StringHelper.java.in
+++ b/mobile/android/base/tests/StringHelper.java.in
@@ -40,18 +40,16 @@ class StringHelper {
         "Bookmark Link"
     };
 
     public static final String[] BOOKMARKS_OPTIONS_CONTEXTMENU_ITEMS = new String[] {
         "Edit",
         "Add to Home Screen"
     };
 
-    public static final String[] BOOKMARK_CONTEXT_MENU_ITEMS = {"Open in New Tab", "Open in Private Tab", "Share", "Edit", "Remove", "Add to Home Screen"};
-
     // Robocop page urls
     // Note: please use getAbsoluteUrl(String url) on each robocop url to get the correct url
     public static final String ROBOCOP_BIG_LINK_URL = "/robocop/robocop_big_link.html";
     public static final String ROBOCOP_BIG_MAILTO_URL = "/robocop/robocop_big_mailto.html";
     public static final String ROBOCOP_BLANK_PAGE_01_URL = "/robocop/robocop_blank_01.html";
     public static final String ROBOCOP_BLANK_PAGE_02_URL = "/robocop/robocop_blank_02.html";
     public static final String ROBOCOP_BLANK_PAGE_03_URL = "/robocop/robocop_blank_03.html";
     public static final String ROBOCOP_BOXES_URL = "/robocop/robocop_boxes.html";
--- a/mobile/android/base/tests/robocop.ini
+++ b/mobile/android/base/tests/robocop.ini
@@ -1,12 +1,11 @@
 [testAwesomebar]
 # [testAwesomebarSwipes] # disabled on fig - bug 880060
 [testBookmark]
-[testBookmarksPage]
 # [testBookmarklets] # see bug 915350
 # [testBookmarkKeyword] # see bug 915350
 [testBrowserSearchVisibility]
 [testJNI]
 [testLoad]
 [testNewTab]
 [testOrderedBroadcast]
 [testPrefsObserver]
deleted file mode 100644
--- a/mobile/android/base/tests/testBookmarksPage.java.in
+++ /dev/null
@@ -1,223 +0,0 @@
-#filter substitution
-package @ANDROID_PACKAGE_NAME@.tests;
-
-import @ANDROID_PACKAGE_NAME@.*;
-
-import com.jayway.android.robotium.solo.Condition;
-
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.ContentUris;
-import android.database.Cursor;
-import android.net.Uri;
-import android.view.View;
-import android.widget.ListAdapter;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-public class testBookmarksPage extends AboutHomeTest {
-    private static String BOOKMARK_URL;
-    private static String DESKTOP_BOOKMARK_URL;
-
-    @Override
-    protected int getTestType() {
-        return TEST_MOCHITEST;
-    }
-
-    public void testBookmarksPage() {
-        BOOKMARK_URL = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
-        DESKTOP_BOOKMARK_URL = getAbsoluteUrl(StringHelper.ROBOCOP_BLANK_PAGE_02_URL);
-
-        setUpDesktopBookmarks();
-        checkBookmarkList();
-        checkBookmarkContextMenu();
-    }
-
-    private void checkBookmarkList() {
-        // Check that the default bookmarks are displayed
-        for (String url:StringHelper.DEFAULT_BOOKMARKS_URLS) {
-            mAsserter.ok(isBookmarkDisplayed(url), "Checking that default bookmark: " + url + " is displayed in the bookmarks list", url + " is displayed as a bookmark");
-        }
-        mAsserter.ok(isBookmarkDisplayed(BOOKMARK_URL), "Checking that added bookmark: " + BOOKMARK_URL + " is displayed in the bookmarks list", BOOKMARK_URL + " is displayed as a bookmark");
-
-        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");
-        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);
-
-        // Go up in the bookmark folder hierarchy
-        clickOnBookmarkFolder(StringHelper.TOOLBAR_FOLDER_LABEL);
-        mAsserter.ok(waitForText(StringHelper.BOOKMARKS_MENU_FOLDER_LABEL), "Going up in the folder hierarchy", "We are back in the Desktop Bookmarks folder");
-
-        clickOnBookmarkFolder(StringHelper.DESKTOP_FOLDER_LABEL);
-        mAsserter.ok(waitForText(StringHelper.DESKTOP_FOLDER_LABEL), "Going up in the folder hierarchy", "We are back in the main Bookmarks List View");
-
-        clickOnBookmarkFolder(StringHelper.DESKTOP_FOLDER_LABEL);
-        clickOnBookmarkFolder(StringHelper.TOOLBAR_FOLDER_LABEL);
-        mAsserter.ok(isBookmarkDisplayed(DESKTOP_BOOKMARK_URL), "Checking that added bookmark: " + DESKTOP_BOOKMARK_URL + " is displayed in the bookmarks list", DESKTOP_BOOKMARK_URL + " is displayed as a bookmark");
-
-        // Open the bookmark from a bookmark folder hierarchy
-        loadBookmark(DESKTOP_BOOKMARK_URL);
-        waitForText(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE);
-        verifyPageTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE);
-        openAboutHomeTab(AboutHomeTabs.BOOKMARKS);
-
-        // Check that folders don't have a context menu
-        boolean success = waitForCondition(new Condition() {
-            @Override
-            public boolean isSatisfied() {
-                View desktopFolder = getBookmarkFolderView(StringHelper.DESKTOP_FOLDER_LABEL);
-                if (desktopFolder != null) {
-                     mSolo.clickLongOnView(desktopFolder);
-                    return true;
-                }
-                return false;
-            }
-        }, MAX_WAIT_MS);
-        mAsserter.ok(success, "Trying to long click on the Desktop Bookmarks","Desktop Bookmarks folder could not be long clicked");
-        mAsserter.ok(!waitForText("Share"), "Folders do not have context menus", "The context menu was not opened");
-
-        // Even if no context menu is opened long clicking a folder still opens it. We need to close it.
-        clickOnBookmarkFolder(StringHelper.DESKTOP_FOLDER_LABEL);
-    }
-
-    private void checkBookmarkContextMenu() {
-        // Open default bookmarks in a new tab and a new private tab since the url is substituted with "Switch to tab" after opening the link
-        openBookmarkContextMenu(StringHelper.DEFAULT_BOOKMARKS_URLS[1]);
-
-        // Test that the options are all displayed
-        for (String contextMenuOption:StringHelper.BOOKMARK_CONTEXT_MENU_ITEMS) {
-            mAsserter.ok(mSolo.searchText(contextMenuOption), "Checking that the context menu option is present", contextMenuOption + " is present");
-        }
-
-        // Test that "Open in New Tab" works
-        final Element tabCount = mDriver.findElement(getActivity(), "tabs_counter");
-        final int tabCountInt = Integer.parseInt(tabCount.getText());
-        Actions.EventExpecter tabEventExpecter = mActions.expectGeckoEvent("Tab:Added");
-        mSolo.clickOnText(StringHelper.BOOKMARK_CONTEXT_MENU_ITEMS[0]);
-        tabEventExpecter.blockForEvent();
-        tabEventExpecter.unregisterListener();
-
-        // Test that "Open in Private Tab" works
-        openBookmarkContextMenu(StringHelper.DEFAULT_BOOKMARKS_URLS[2]);
-        tabEventExpecter = mActions.expectGeckoEvent("Tab:Added");
-        mSolo.clickOnText(StringHelper.BOOKMARK_CONTEXT_MENU_ITEMS[1]);
-        tabEventExpecter.blockForEvent();
-        tabEventExpecter.unregisterListener();
-
-        // Test that "Share" works
-        openBookmarkContextMenu(BOOKMARK_URL);
-        mSolo.clickOnText(StringHelper.BOOKMARK_CONTEXT_MENU_ITEMS[2]);
-        mAsserter.ok(waitForText("Share via"), "Checking to see if the share menu has been opened","The share menu has been opened");
-        mActions.sendSpecialKey(Actions.SpecialKey.BACK);
-        waitForText(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE);
-
-        // Test that "Edit" works
-        String[] editedBookmarkValues = {"New bookmark title", "www.NewBookmark.url", "newBookmarkKeyword"};
-        editBookmark(BOOKMARK_URL,editedBookmarkValues);
-        checkBookmarkEdit(editedBookmarkValues[1],editedBookmarkValues);
-
-        // Test that "Remove" works
-        openBookmarkContextMenu(editedBookmarkValues[1]);
-        mSolo.clickOnText(StringHelper.BOOKMARK_CONTEXT_MENU_ITEMS[4]);
-        waitForText("Bookmark removed");
-        mAsserter.ok(!mDatabaseHelper.isBookmark(editedBookmarkValues[1]), "Checking that the bookmark was removed", "The bookmark was removed");
-    }
-
-    private void clickOnBookmarkFolder(final String folderName) {
-        boolean success = waitForCondition(new Condition() {
-            @Override
-            public boolean isSatisfied() {
-                View bookmarksFolder = getBookmarkFolderView(folderName);
-                if (bookmarksFolder != null) {
-                    mSolo.clickOnView(bookmarksFolder);
-                    return true;
-                }
-                return false;
-            }
-        }, MAX_WAIT_MS);
-        mAsserter.ok(success, "Trying to click on the " + folderName + " folder","The " + folderName + " folder was clicked");
-    }
-
-    private View getBookmarkFolderView(String folderName) {
-        ListView bookmarksTabList = findListViewWithTag("bookmarks");
-        ListAdapter adapter = bookmarksTabList.getAdapter();
-        if (adapter != null) {
-            for (int i = 0; i < adapter.getCount(); i++ ) {
-                View bookmarkView = bookmarksTabList.getChildAt(i);
-                if (bookmarkView instanceof TextView) {
-                    TextView folderTextView = (TextView) bookmarkView;
-                    if (folderTextView.getText().equals(folderName)) {
-                        return bookmarkView;
-                    }
-                }
-            }
-        }
-        return null;
-    }
-
-    // Add a bookmark in the Desktop folder so we can check the folder navigation in the bookmarks page
-    private void setUpDesktopBookmarks() {
-        // Get the folder id of the StringHelper.DESKTOP_FOLDER_LABEL folder
-        Long desktopFolderId = mDatabaseHelper.getFolderIdFromGuid("toolbar");
-
-        // Generate a Guid for the bookmark
-        String generatedGuid = null;
-        try {
-            ClassLoader classLoader = getActivity().getClassLoader();
-            Class syncUtilityClass = classLoader.loadClass("org.mozilla.gecko.sync.Utils");
-            Method generateGuid = syncUtilityClass.getMethod("generateGuid", (Class[]) null);
-            generatedGuid = (String)generateGuid.invoke(null);
-        } catch (Exception e) {
-            mAsserter.dumpLog("Exception in setUpDesktopBookmarks" + e);
-        }
-        mAsserter.ok((generatedGuid != null), "Generating a random Guid for the bookmark", "We could not generate a Guid for the bookmark");
-
-        // Insert the bookmark
-        ContentResolver resolver = getActivity().getContentResolver();
-        Uri bookmarksUri = mDatabaseHelper.buildUri(DatabaseHelper.BrowserDataType.BOOKMARKS);
-        ContentValues values = new ContentValues();
-        values.put("title", StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE);
-        values.put("url", DESKTOP_BOOKMARK_URL);
-        values.put("parent", desktopFolderId);
-        long now = System.currentTimeMillis();
-        values.put("modified", now);
-        values.put("type", 1);
-        values.put("guid", generatedGuid);
-        values.put("position", 10);
-        values.put("created", now);
-        int updated = resolver.update(bookmarksUri,
-                                      values,
-                                      "url = ?",
-                                      new String[] { DESKTOP_BOOKMARK_URL });
-        if (updated == 0) {
-            Uri uri = resolver.insert(bookmarksUri, values);
-            mAsserter.ok(true, "Inserted at: ", uri.toString());
-        } else {
-            mAsserter.ok(false, "Failed to insert the Desktop bookmark", "Something went wrong");
-        }
-
-        // Add a mobile bookmark
-        mDatabaseHelper.addOrUpdateMobileBookmark(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, BOOKMARK_URL);
-    }
-
-    @Override
-    public void tearDown() throws Exception {
-        mDatabaseHelper.deleteBookmark(DESKTOP_BOOKMARK_URL);
-        super.tearDown();
-    }
-}