Bug 784186 - Robocop: wait for paint in several tests; r=jmaher
authorGeoff Brown <gbrown@mozilla.com>
Thu, 23 Aug 2012 09:20:42 -0600
changeset 105209 78d6548c9c2340e6d974ca03911a894be412bc29
parent 105208 00ba8683d7c941db5035fbbc68f5a41540261e5f
child 105210 ef0db3592a2ede23738b37cb989b215cc023fed9
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersjmaher
bugs784186
milestone17.0a1
Bug 784186 - Robocop: wait for paint in several tests; r=jmaher
mobile/android/base/tests/testAboutPage.java.in
mobile/android/base/tests/testBookmark.java.in
mobile/android/base/tests/testBookmarklets.java.in
mobile/android/base/tests/testHistoryTab.java.in
--- a/mobile/android/base/tests/testAboutPage.java.in
+++ b/mobile/android/base/tests/testAboutPage.java.in
@@ -1,27 +1,27 @@
 #filter substitution
 package @ANDROID_PACKAGE_NAME@.tests;
 
 import @ANDROID_PACKAGE_NAME@.*;
 import android.app.Activity;
 import android.util.Log;
 
-public class testAboutPage extends BaseTest {
+public class testAboutPage extends PixelTest {
     @Override
     protected int getTestType() {
         return TEST_MOCHITEST;
     }
 
     public void testAboutPage() {
         mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();
 
         // Load the about: page
         String url = "about:";
-        loadUrl(url);
+        loadAndPaint(url);
 
         Element awesomebar = mDriver.findElement(getActivity(), "awesome_bar");
         mAsserter.isnot(awesomebar, null, "Got the awesomebar");
         assertMatches(awesomebar.getText(), "About (Fennec|Nightly|Aurora|Firefox|Firefox Beta)", "page title match");
 
         // Open a new page to remove the about: page from the current tab
         url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
         loadUrl(url);
--- a/mobile/android/base/tests/testBookmark.java.in
+++ b/mobile/android/base/tests/testBookmark.java.in
@@ -9,17 +9,17 @@ import android.widget.ListAdapter;
 import android.widget.ListView;
 import android.widget.TextView;
 import android.widget.TabHost;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.lang.reflect.Method;
 import android.content.ContentResolver;
 
-public class testBookmark extends BaseTest  {
+public class testBookmark extends PixelTest  {
     private static final int MAX_WAIT_MS = 3000; 
     private static final String ABOUT_HOME_URL = "about:firefox";
     private static String BOOKMARK_URL = "/robocop/robocop_blank_01.html";
     private static String BOOKMARK_TITLE = "Browser Blank Page 01";
 
     private ClassLoader mClassLoader;
     private Method mAddBookmark;
     private Method mRemoveBookmark;
@@ -67,16 +67,18 @@ public class testBookmark extends BaseTe
         } catch(java.lang.IllegalAccessException ex) {
             mAsserter.is(true, false, "Can not call addBookmark");
         } catch(java.lang.reflect.InvocationTargetException ex) {
             mAsserter.is(true, false, "Error calling addBookmark");
         }
     }
 
     public void runAwesomeScreenTest() {
+        final long PAINT_CLEAR_DELAY = 1000;  // milliseconds
+
         mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();
 
         // Open the bookmark list and check the root folder view
         ListView bookmarksList = openBookmarksList();
 
         // Clear VKB so that list is not obscured
         mActions.sendSpecialKey(Actions.SpecialKey.BACK);
 
@@ -107,19 +109,19 @@ public class testBookmark extends BaseTe
 
         insertOneBookmark();
         mSolo.waitForText(BOOKMARK_TITLE);
 
         mAsserter.is(bookmarksList.getChildCount(), 5,
             "bookmarks list has 5 children (the default bookmarks and the new one)");
  
         // Click on the bookmark we created and wait for the bookmarked page to load
-        Actions.EventExpecter contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
+        Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint();
         mSolo.clickInList(1);
-        contentEventExpecter.blockForEvent();
+        paintExpecter.blockUntilClear(PAINT_CLEAR_DELAY);
 
         // Clean up the bookmark we created
         deleteBookmark();
     }
 
     private boolean waitForBookmarked(final boolean isBookmarked) {
         waitForTest(new BooleanTest() {
             public boolean test() {
@@ -179,23 +181,23 @@ public class testBookmark extends BaseTe
         getInstrumentation().waitForIdleSync();
         mActions.sendSpecialKey(Actions.SpecialKey.MENU);
         mSolo.waitForText("Bookmark");
         mSolo.clickOnText("Bookmark");
     }
 
     private void setUpBookmark() {
         // Bookmark a page for the test
-        loadUrl(BOOKMARK_URL);
+        loadAndPaint(BOOKMARK_URL);
         toggleBookmark();
         mAsserter.is(mSolo.waitForText("Bookmark added"), true, "bookmark added sucessfully");
 
         // Navigate back to about:home for the test
-        loadUrl(ABOUT_HOME_URL);
+        loadAndPaint(ABOUT_HOME_URL);
     }
 
     private void cleanUpBookmark() {
         // Go back to the page we bookmarked
-        loadUrl(BOOKMARK_URL);
+        loadAndPaint(BOOKMARK_URL);
         toggleBookmark();
         mAsserter.is(mSolo.waitForText("Bookmark removed"), true, "bookmark removed successfully");
     }
 }
--- a/mobile/android/base/tests/testBookmarklets.java.in
+++ b/mobile/android/base/tests/testBookmarklets.java.in
@@ -4,32 +4,32 @@ package @ANDROID_PACKAGE_NAME@.tests;
 import @ANDROID_PACKAGE_NAME@.*;
 import android.app.Activity;
 import android.content.ContentValues;
 import android.content.ContentResolver;
 import android.database.Cursor;
 import android.net.Uri;
 import android.provider.Browser;
 
-public class testBookmarklets extends BaseTest {
+public class testBookmarklets extends PixelTest {
     @Override
     protected int getTestType() {
         return TEST_MOCHITEST;
     }
 
     public void testBookmarklets() {
         final String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
         final String title = "alertBookmarklet";
         final String js = "javascript:alert(12 + .34)";
         boolean alerted;
 
         mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();
 
         // load a standard page so bookmarklets work
-        loadUrl(url);
+        loadAndPaint(url);
 
         // verify that user-entered bookmarklets do *not* work
         enterUrl(js);
         mActions.sendSpecialKey(Actions.SpecialKey.ENTER);
         alerted = waitForTest(new BooleanTest() {
             public boolean test() {
                 return mSolo.searchButton("OK", true) || mSolo.searchText("12.34", true);
             }
--- a/mobile/android/base/tests/testHistoryTab.java.in
+++ b/mobile/android/base/tests/testHistoryTab.java.in
@@ -22,17 +22,17 @@ import android.net.Uri;
 import java.util.Arrays;
 import java.util.ArrayList;
 import java.io.File;
 
 /* Tests opening the history tab, that items look correct, clicking on an item
    and long tapping on an item
 */
 
-public class testHistoryTab extends BaseTest {
+public class testHistoryTab extends PixelTest {
     private static final String ABOUT_HOME_URL = "about:home";
     private static final String OPEN_NEW_TAB = "Open in New Tab";
     private static final int WAIT_FOR_CHILD_TIMEOUT = 2000;
     private String[] bookmarks = new String[] {
         "http://mochi.test:8888/tests/robocop/robocop_blank_01.html"
     };
 
     @Override
@@ -41,21 +41,21 @@ public class testHistoryTab extends Base
     }
 
     public void testHistoryTab() {
         mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();
 
         // load two pages so there is something in our history
         // bookmark one of them
         String url = getAbsoluteUrl("/robocop/robocop_big_link.html");
-        loadUrl(url);
+        loadAndPaint(url);
 
         url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
-        loadUrl(url);
-        getInstrumentation().waitForIdleSync();
+        loadAndPaint(url);
+
         mActions.sendSpecialKey(Actions.SpecialKey.MENU);
         mSolo.waitForText("Bookmark");
         mSolo.clickOnText("Bookmark");
         mAsserter.is(mSolo.waitForText("Bookmark added"), true, "bookmark added sucessfully");
 
         testList(url);
         testContextMenu(url);
         testClick(url);