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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappActivityTestRule.java

Issue 2905073002: Revert of Redirecting off-origin navigations in PWAs to CCT. (Closed)
Patch Set: Created 3 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.webapps; 5 package org.chromium.chrome.browser.webapps;
6 6
7 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; 7 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
8 8
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.net.Uri; 10 import android.net.Uri;
11 import android.view.ViewGroup; 11 import android.view.ViewGroup;
12 12
13 import org.junit.Assert; 13 import org.junit.Assert;
14 import org.junit.runner.Description; 14 import org.junit.runner.Description;
15 import org.junit.runners.model.Statement; 15 import org.junit.runners.model.Statement;
16 16
17 import org.chromium.base.test.util.UrlUtils; 17 import org.chromium.base.test.util.UrlUtils;
18 import org.chromium.chrome.browser.ChromeActivity;
19 import org.chromium.chrome.browser.ShortcutHelper; 18 import org.chromium.chrome.browser.ShortcutHelper;
20 import org.chromium.chrome.test.ChromeActivityTestRule; 19 import org.chromium.chrome.test.ChromeActivityTestRule;
21 import org.chromium.content.browser.test.util.Criteria; 20 import org.chromium.content.browser.test.util.Criteria;
22 import org.chromium.content.browser.test.util.CriteriaHelper; 21 import org.chromium.content.browser.test.util.CriteriaHelper;
23 22
24 /** 23 /**
25 * Custom {@link ChromeActivityTestRule} for tests using {@link WebappActivity}. 24 * Custom {@link ChromeActivityTestRule} for tests using {@link WebappActivity}.
26 */ 25 */
27 public class WebappActivityTestRule extends ChromeActivityTestRule<WebappActivit y0> { 26 public class WebappActivityTestRule extends ChromeActivityTestRule<WebappActivit y0> {
28 public static final String WEBAPP_ID = "webapp_id"; 27 public static final String WEBAPP_ID = "webapp_id";
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 109
111 /** 110 /**
112 * Starts up the WebappActivity with a specific Intent and sets up the test observer. 111 * Starts up the WebappActivity with a specific Intent and sets up the test observer.
113 */ 112 */
114 public final void startWebappActivity(Intent intent) throws Exception { 113 public final void startWebappActivity(Intent intent) throws Exception {
115 launchActivity(intent); 114 launchActivity(intent);
116 waitUntilIdle(); 115 waitUntilIdle();
117 } 116 }
118 117
119 /** 118 /**
120 * Waits until any loads in progress of the activity under test have complet ed. 119 * Waits until any loads in progress have completed.
121 */ 120 */
122 protected void waitUntilIdle() { 121 public void waitUntilIdle() {
123 waitUntilIdle(getActivity());
124 }
125
126 /**
127 * Waits until any loads in progress of a selected activity have completed.
128 */
129 protected void waitUntilIdle(final ChromeActivity activity) {
130 getInstrumentation().waitForIdleSync(); 122 getInstrumentation().waitForIdleSync();
131 CriteriaHelper.pollInstrumentationThread(new Criteria() { 123 CriteriaHelper.pollInstrumentationThread(new Criteria() {
132 @Override 124 @Override
133 public boolean isSatisfied() { 125 public boolean isSatisfied() {
134 return activity.getActivityTab() != null && !activity.getActivit yTab().isLoading(); 126 return getActivity().getActivityTab() != null
127 && !getActivity().getActivityTab().isLoading();
135 } 128 }
136 }, STARTUP_TIMEOUT, CriteriaHelper.DEFAULT_POLLING_INTERVAL); 129 }, STARTUP_TIMEOUT, CriteriaHelper.DEFAULT_POLLING_INTERVAL);
137 130
138 getInstrumentation().waitForIdleSync(); 131 getInstrumentation().waitForIdleSync();
139 } 132 }
140 133
141 /** 134 /**
142 * Waits for the splash screen to be hidden. 135 * Waits for the splash screen to be hidden.
143 */ 136 */
144 public void waitUntilSplashscreenHides() { 137 public void waitUntilSplashscreenHides() {
(...skipping 13 matching lines...) Expand all
158 } 151 }
159 }); 152 });
160 153
161 ViewGroup splashScreen = getActivity().getSplashScreenForTests(); 154 ViewGroup splashScreen = getActivity().getSplashScreenForTests();
162 if (splashScreen == null) { 155 if (splashScreen == null) {
163 Assert.fail("No splash screen available."); 156 Assert.fail("No splash screen available.");
164 } 157 }
165 return splashScreen; 158 return splashScreen;
166 } 159 }
167 } 160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698