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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java

Issue 2854943005: Converts WebApkIntegrationTest to JUnit4. (Closed)
Patch Set: Uses InstrumentationRegistry now 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java
index 708c14eef670b66fa09aa270479f20fda6058d96..afa5078c503317197ce212e0abd4d253d9f32af9 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java
@@ -5,13 +5,23 @@
package org.chromium.chrome.browser.webapps;
import android.content.Intent;
+import android.support.test.InstrumentationRegistry;
import android.support.test.filters.LargeTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.base.test.util.ScalableTimeout;
+import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.ShortcutHelper;
-import org.chromium.chrome.test.ChromeActivityTestCaseBase;
+import org.chromium.chrome.test.ChromeActivityTestRule;
+import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
@@ -19,32 +29,39 @@ import org.chromium.net.test.EmbeddedTestServer;
import org.chromium.webapk.lib.common.WebApkConstants;
/** Integration tests for WebAPK feature. */
-public class WebApkIntegrationTest extends ChromeActivityTestCaseBase<WebApkActivity> {
+@RunWith(ChromeJUnit4ClassRunner.class)
+@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
+ ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
+public class WebApkIntegrationTest {
+ @Rule
+ public final ChromeActivityTestRule<WebApkActivity> mActivityTestRule =
+ new ChromeActivityTestRule<>(WebApkActivity.class);
+
private static final long STARTUP_TIMEOUT = ScalableTimeout.scaleTimeout(10000);
private EmbeddedTestServer mTestServer;
- public WebApkIntegrationTest() {
- super(WebApkActivity.class);
- }
-
public void startWebApkActivity(String webApkPackageName, final String startUrl)
throws InterruptedException {
- Intent intent = new Intent(getInstrumentation().getTargetContext(), WebApkActivity.class);
+ Intent intent =
+ new Intent(InstrumentationRegistry.getTargetContext(), WebApkActivity.class);
intent.putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, webApkPackageName);
intent.putExtra(ShortcutHelper.EXTRA_URL, startUrl);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- setActivity(getInstrumentation().startActivitySync(intent));
- getInstrumentation().waitForIdleSync();
+ mActivityTestRule.setActivity(
+ (WebApkActivity) InstrumentationRegistry.getInstrumentation().startActivitySync(
+ intent));
+ InstrumentationRegistry.getInstrumentation().waitForIdleSync();
CriteriaHelper.pollInstrumentationThread(new Criteria() {
@Override
public boolean isSatisfied() {
- return getActivity().getActivityTab() != null;
+ return mActivityTestRule.getActivity().getActivityTab() != null;
}
}, STARTUP_TIMEOUT, CriteriaHelper.DEFAULT_POLLING_INTERVAL);
- ChromeTabUtils.waitForTabPageLoaded(getActivity().getActivityTab(), startUrl);
+ ChromeTabUtils.waitForTabPageLoaded(
+ mActivityTestRule.getActivity().getActivityTab(), startUrl);
}
/** Waits for the splash screen to be hidden. */
@@ -52,33 +69,28 @@ public class WebApkIntegrationTest extends ChromeActivityTestCaseBase<WebApkActi
CriteriaHelper.pollInstrumentationThread(new Criteria() {
@Override
public boolean isSatisfied() {
- return !getActivity().isSplashScreenVisibleForTests();
+ return !mActivityTestRule.getActivity().isSplashScreenVisibleForTests();
}
});
}
- @Override
- public final void startMainActivity() throws InterruptedException {
- // Do nothing
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext());
+ @Before
+ public void setUp() throws Exception {
+ mTestServer = EmbeddedTestServer.createAndStartServer(
+ InstrumentationRegistry.getInstrumentation().getContext());
WebApkUpdateManager.setUpdatesEnabledForTesting(false);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
mTestServer.stopAndDestroyServer();
- super.tearDown();
}
/**
* Test launching a WebAPK. Test that loading the start page works and that the splashscreen
* eventually hides.
*/
+ @Test
@LargeTest
@Feature({"WebApk"})
@RetryOnFailure
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698