Commit 4c128b4c authored by Peter Kotwicz's avatar Peter Kotwicz Committed by Commit Bot

[Android Testing] Disable WebAPK updates by default in tests

This CL changes WebApkActivityTestRule to disable WebAPK updates.

BUG=1054718

Change-Id: I193827f09fed1a6d9f7f93d78fc2a37f845df748
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2098769Reviewed-by: default avatarGlenn Hartmann <hartmanng@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750578}
parent 7c60ad5c
......@@ -12,6 +12,7 @@ import android.support.test.InstrumentationRegistry;
import android.support.test.filters.LargeTest;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -30,7 +31,6 @@ import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.ApplicationTestUtils;
import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.chrome.test.util.browser.webapps.WebApkInfoBuilder;
import org.chromium.content_public.browser.test.NativeLibraryTestRule;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.webapk.lib.common.WebApkConstants;
......@@ -42,12 +42,11 @@ public final class WebApkActivityTest {
private static final String TEST_WEBAPK_ID =
WebApkConstants.WEBAPK_ID_PREFIX + TEST_WEBAPK_PACKAGE_NAME;
@Rule
public final WebApkActivityTestRule mActivityTestRule = new WebApkActivityTestRule();
public final NativeLibraryTestRule mNativeLibraryTestRule = new NativeLibraryTestRule();
@Before
public void setUp() {
WebApkUpdateManager.setUpdatesEnabledForTesting(false);
mActivityTestRule.getEmbeddedTestServerRule().setServerUsesHttps(true);
// WebAPK is not installed. Ensure that WebappRegistry#unregisterOldWebapps() does not
......
......@@ -8,6 +8,8 @@ import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import org.junit.Assert;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.test.util.ScalableTimeout;
......@@ -27,6 +29,21 @@ public class WebApkActivityTestRule extends ChromeActivityTestRule<WebApkActivit
super(WebApkActivity.class);
}
@Override
public Statement apply(final Statement base, Description description) {
Statement webApkUpdateManagerStatement = new Statement() {
@Override
public void evaluate() throws Throwable {
WebApkUpdateManager.setUpdatesEnabledForTesting(false);
base.evaluate();
WebApkUpdateManager.setUpdatesEnabledForTesting(true);
}
};
return super.apply(webApkUpdateManagerStatement, description);
}
/**
* Launches WebApkActivity and waits for the page to have finished loading and for the splash
* screen to be hidden.
......
......@@ -21,7 +21,6 @@ import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.test.MockCertVerifierRuleAndroid;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.content_public.browser.test.NativeLibraryTestRule;
import org.chromium.content_public.common.ContentSwitches;
......@@ -32,8 +31,7 @@ import org.chromium.webapk.lib.common.WebApkConstants;
@RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class WebApkIntegrationTest {
public final ChromeActivityTestRule<WebApkActivity> mActivityTestRule =
new ChromeActivityTestRule<>(WebApkActivity.class);
public final WebApkActivityTestRule mActivityTestRule = new WebApkActivityTestRule();
public final NativeLibraryTestRule mNativeLibraryTestRule = new NativeLibraryTestRule();
......@@ -53,7 +51,6 @@ public class WebApkIntegrationTest {
@Before
public void setUp() {
WebApkUpdateManager.setUpdatesEnabledForTesting(false);
mActivityTestRule.getEmbeddedTestServerRule().setServerUsesHttps(true);
Uri mapToUri =
Uri.parse(mActivityTestRule.getEmbeddedTestServerRule().getServer().getURL("/"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment