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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.test.util;
6
7 import android.annotation.TargetApi;
8 import android.os.Build;
9
10 import org.chromium.chrome.browser.Tab;
11 import org.chromium.chrome.browser.ntp.IncognitoNewTabPage;
12 import org.chromium.chrome.browser.ntp.NewTabPage;
13 import org.chromium.chrome.browser.util.FeatureUtilities;
14 import org.chromium.content.browser.test.util.Criteria;
15 import org.chromium.content.browser.test.util.CriteriaHelper;
16
17 /**
18 * Utilities for testing the NTP.
19 */
20 public class NewTabPageTestUtils {
21
22 /**
23 * Waits for the NTP owned by the passed in tab to be fully loaded.
24 *
25 * @param tab The tab to be monitored for NTP loading.
26 * @return Whether the NTP has fully loaded.
27 */
28 @TargetApi(Build.VERSION_CODES.LOLLIPOP)
29 public static boolean waitForNtpLoaded(final Tab tab) throws InterruptedExce ption {
30 return CriteriaHelper.pollForUIThreadCriteria(new Criteria() {
31 @Override
32 public boolean isSatisfied() {
33 if (!tab.isIncognito()) {
34 // TODO(tedchoc): Make MostVisitedPage also have a isLoaded( ) concept.
35 if (FeatureUtilities.isDocumentMode(
36 tab.getWindowAndroid().getApplicationContext())) {
37 return tab.getView().isAttachedToWindow();
38 }
39 if (!(tab.getNativePage() instanceof NewTabPage)) {
40 return false;
41 }
42 return ((NewTabPage) tab.getNativePage()).isLoadedForTests() ;
43 } else {
44 if (!(tab.getNativePage() instanceof IncognitoNewTabPage)) {
45 return false;
46 }
47 return ((IncognitoNewTabPage) tab.getNativePage()).isLoadedF orTests();
48 }
49 }
50 });
51 }
52
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698