Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8377)

Unified Diff: chrome/test/android/javatests_staging/src/org/chromium/chrome/test/util/NewTabPageTestUtils.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/android/javatests_staging/src/org/chromium/chrome/test/util/NewTabPageTestUtils.java
diff --git a/chrome/test/android/javatests_staging/src/org/chromium/chrome/test/util/NewTabPageTestUtils.java b/chrome/test/android/javatests_staging/src/org/chromium/chrome/test/util/NewTabPageTestUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..ea72aa230a4764e51517ed0d7669ff25d82ab89f
--- /dev/null
+++ b/chrome/test/android/javatests_staging/src/org/chromium/chrome/test/util/NewTabPageTestUtils.java
@@ -0,0 +1,53 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.test.util;
+
+import android.annotation.TargetApi;
+import android.os.Build;
+
+import org.chromium.chrome.browser.Tab;
+import org.chromium.chrome.browser.ntp.IncognitoNewTabPage;
+import org.chromium.chrome.browser.ntp.NewTabPage;
+import org.chromium.chrome.browser.util.FeatureUtilities;
+import org.chromium.content.browser.test.util.Criteria;
+import org.chromium.content.browser.test.util.CriteriaHelper;
+
+/**
+ * Utilities for testing the NTP.
+ */
+public class NewTabPageTestUtils {
+
+ /**
+ * Waits for the NTP owned by the passed in tab to be fully loaded.
+ *
+ * @param tab The tab to be monitored for NTP loading.
+ * @return Whether the NTP has fully loaded.
+ */
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ public static boolean waitForNtpLoaded(final Tab tab) throws InterruptedException {
+ return CriteriaHelper.pollForUIThreadCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ if (!tab.isIncognito()) {
+ // TODO(tedchoc): Make MostVisitedPage also have a isLoaded() concept.
+ if (FeatureUtilities.isDocumentMode(
+ tab.getWindowAndroid().getApplicationContext())) {
+ return tab.getView().isAttachedToWindow();
+ }
+ if (!(tab.getNativePage() instanceof NewTabPage)) {
+ return false;
+ }
+ return ((NewTabPage) tab.getNativePage()).isLoadedForTests();
+ } else {
+ if (!(tab.getNativePage() instanceof IncognitoNewTabPage)) {
+ return false;
+ }
+ return ((IncognitoNewTabPage) tab.getNativePage()).isLoadedForTests();
+ }
+ }
+ });
+ }
+
+}

Powered by Google App Engine
This is Rietveld 408576698