Bug 794070 - Robocop: allow for date change during testHistoryTab; r=jmaher
authorGeoff Brown <gbrown@mozilla.com>
Wed, 26 Sep 2012 07:30:09 -0600
changeset 108140 15cd63bd65d53094a4f1b41495aec6d057c78348
parent 108139 ed7f4ba92ab03c9c6087749c31ee84bf9b4ffd77
child 108141 4dfa1754f818d123305f55c3e9fee6449a0294eb
push id23539
push userryanvm@gmail.com
push dateWed, 26 Sep 2012 22:55:55 +0000
treeherdermozilla-central@ec079fd92224 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs794070
milestone18.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 794070 - Robocop: allow for date change during testHistoryTab; r=jmaher
mobile/android/base/tests/testHistoryTab.java.in
--- a/mobile/android/base/tests/testHistoryTab.java.in
+++ b/mobile/android/base/tests/testHistoryTab.java.in
@@ -17,38 +17,45 @@ import android.text.TextUtils;
 import android.content.ContentValues;
 import android.content.ContentResolver;
 import android.database.Cursor;
 import android.net.Uri;
 
 import java.util.Arrays;
 import java.util.ArrayList;
 import java.io.File;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
 
 /* Tests opening the history tab, that items look correct, clicking on an item
    and long tapping on an item
 */
 
 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"
     };
     private View mFirstChild;
+    private boolean mNearMidnight;
 
     @Override
     protected int getTestType() {
         return TEST_MOCHITEST;
     }
 
     public void testHistoryTab() {
         mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();
 
+        // very approximate date-rollover detection
+        Calendar cal = new GregorianCalendar();
+        mNearMidnight = (cal.get(Calendar.HOUR_OF_DAY) == 23);
+
         // load two pages so there is something in our history
         // bookmark one of them
         String url = getAbsoluteUrl("/robocop/robocop_big_link.html");
         loadAndPaint(url);
 
         url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
         loadAndPaint(url);
 
@@ -84,17 +91,21 @@ public class testHistoryTab extends Pixe
 
             int expectedImages = 1;
             for (int j = 0; j < views.size(); j++) {
                 View v = views.get(j);
                 if (i == 0) {
                     ArrayList<TextView> views2 = mSolo.getCurrentTextViews(v);
                     TextView t = views2.get(0);
                     String string = t.getText().toString();
-                    mAsserter.ok(string.equals("Today"), "First row has Today header", string);
+                    boolean headerTextOK = string.equals("Today");
+                    if (!headerTextOK && mNearMidnight && string.equals("Yesterday")) {
+                        headerTextOK = true;
+                    }
+                    mAsserter.ok(headerTextOK, "First row has Today header", string);
                     expectedImages = 0;
                 } else if (v instanceof TextView) {
                     TextView t = (TextView)v;
                     String string = t.getText().toString();
                     mAsserter.ok(!TextUtils.isEmpty(string), "TextView is filled in", string);
                     if (i == 1 || string.startsWith("http")) {
                         loadUrl = string;
                     }