Index: chrome/android/javatests/src/org/chromium/chrome/browser/preferences/website/ManageSpaceActivityTest.java |
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/website/ManageSpaceActivityTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/website/ManageSpaceActivityTest.java |
index c8dd3a62ec10002845ed27718e81e2ad373a41c7..59bea9610c34bb421dfe372341a6af1aab856449 100644 |
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/website/ManageSpaceActivityTest.java |
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/website/ManageSpaceActivityTest.java |
@@ -7,18 +7,28 @@ package org.chromium.chrome.browser.preferences.website; |
import android.annotation.TargetApi; |
import android.content.Intent; |
import android.os.Build; |
+import android.support.test.InstrumentationRegistry; |
import android.support.test.filters.MediumTest; |
import android.support.test.filters.SmallTest; |
import android.support.v7.app.AlertDialog; |
+import org.junit.After; |
+import org.junit.Assert; |
+import org.junit.Before; |
+import org.junit.Rule; |
+import org.junit.Test; |
+import org.junit.runner.RunWith; |
+ |
import org.chromium.base.ThreadUtils; |
import org.chromium.base.test.util.CommandLineFlags; |
import org.chromium.base.test.util.Feature; |
import org.chromium.base.test.util.MinAndroidSdkLevel; |
import org.chromium.base.test.util.RetryOnFailure; |
import org.chromium.chrome.browser.ChromeActivity; |
+import org.chromium.chrome.browser.ChromeSwitches; |
import org.chromium.chrome.browser.preferences.privacy.BrowsingDataBridge; |
-import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
+import org.chromium.chrome.test.ChromeActivityTestRule; |
+import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
import org.chromium.content.browser.test.util.Criteria; |
import org.chromium.content.browser.test.util.CriteriaHelper; |
import org.chromium.net.test.EmbeddedTestServer; |
@@ -26,42 +36,39 @@ import org.chromium.net.test.EmbeddedTestServer; |
/** |
* Tests for ManageSpaceActivity. |
*/ |
+@RunWith(ChromeJUnit4ClassRunner.class) |
@TargetApi(Build.VERSION_CODES.KITKAT) |
-@CommandLineFlags.Add({"enable-site-engagement"}) |
@MinAndroidSdkLevel(Build.VERSION_CODES.KITKAT) |
-public class ManageSpaceActivityTest extends ChromeActivityTestCaseBase<ChromeActivity> { |
- private EmbeddedTestServer mTestServer; |
+@CommandLineFlags.Add({"enable-site-engagement", ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, |
+ ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG}) |
+public class ManageSpaceActivityTest { |
+ @Rule |
+ public ChromeActivityTestRule<ChromeActivity> mActivityTestRule = |
+ new ChromeActivityTestRule<>(ChromeActivity.class); |
- public ManageSpaceActivityTest() { |
- super(ChromeActivity.class); |
- } |
+ private EmbeddedTestServer mTestServer; |
- @Override |
- protected void setUp() throws Exception { |
- super.setUp(); |
- mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext()); |
+ @Before |
+ public void setUp() throws Exception { |
+ if (!mActivityTestRule.getName().equals("testClearUnimporantWithoutChromeStart")) { |
+ mActivityTestRule.startMainActivityOnBlankPage(); |
+ } |
+ mTestServer = EmbeddedTestServer.createAndStartServer( |
+ InstrumentationRegistry.getInstrumentation().getContext()); |
} |
- @Override |
- protected void tearDown() throws Exception { |
+ @After |
+ public void tearDown() throws Exception { |
mTestServer.stopAndDestroyServer(); |
- super.tearDown(); |
- } |
- |
- @Override |
- public void startMainActivity() throws InterruptedException { |
- if (getName().equals("testClearUnimporantWithoutChromeStart")) { |
- return; |
- } |
- startMainActivityOnBlankPage(); |
} |
private ManageSpaceActivity startManageSpaceActivity() { |
- Intent intent = |
- new Intent(getInstrumentation().getTargetContext(), ManageSpaceActivity.class); |
+ Intent intent = new Intent(InstrumentationRegistry.getInstrumentation().getTargetContext(), |
+ ManageSpaceActivity.class); |
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
- return (ManageSpaceActivity) getInstrumentation().startActivitySync(intent); |
+ return (ManageSpaceActivity) InstrumentationRegistry.getInstrumentation().startActivitySync( |
+ intent); |
} |
public void waitForClearButtonEnabled(final ManageSpaceActivity activity) { |
@@ -100,12 +107,14 @@ public class ManageSpaceActivityTest extends ChromeActivityTestCaseBase<ChromeAc |
}; |
} |
+ @Test |
@SmallTest |
@RetryOnFailure |
public void testLaunchActivity() { |
startManageSpaceActivity(); |
} |
+ @Test |
@MediumTest |
@RetryOnFailure |
@Feature({"SiteEngagement"}) |
@@ -114,11 +123,13 @@ public class ManageSpaceActivityTest extends ChromeActivityTestCaseBase<ChromeAc |
mTestServer.getURL("/chrome/test/data/android/storage_persistance.html"); |
final String serverOrigin = mTestServer.getURL("/"); |
- loadUrl(cookiesUrl + "#clear"); |
- assertEquals("false", runJavaScriptCodeInCurrentTab("hasAllStorage()")); |
- runJavaScriptCodeInCurrentTab("setStorage()"); |
- assertEquals("true", runJavaScriptCodeInCurrentTab("hasAllStorage()")); |
- loadUrl("about:blank"); |
+ mActivityTestRule.loadUrl(cookiesUrl + "#clear"); |
+ Assert.assertEquals( |
+ "false", mActivityTestRule.runJavaScriptCodeInCurrentTab("hasAllStorage()")); |
+ mActivityTestRule.runJavaScriptCodeInCurrentTab("setStorage()"); |
+ Assert.assertEquals( |
+ "true", mActivityTestRule.runJavaScriptCodeInCurrentTab("hasAllStorage()")); |
+ mActivityTestRule.loadUrl("about:blank"); |
// Now we set the origin as important, and check that we don't clear it. |
ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
@@ -139,10 +150,12 @@ public class ManageSpaceActivityTest extends ChromeActivityTestCaseBase<ChromeAc |
waitForClearButtonEnabled(manageSpaceActivity); |
manageSpaceActivity.finish(); |
- loadUrl(cookiesUrl); |
- assertEquals("true", runJavaScriptCodeInCurrentTab("hasAllStorage()")); |
+ mActivityTestRule.loadUrl(cookiesUrl); |
+ Assert.assertEquals( |
+ "true", mActivityTestRule.runJavaScriptCodeInCurrentTab("hasAllStorage()")); |
} |
+ @Test |
@MediumTest |
@Feature({"SiteEngagement"}) |
public void testClearUnimporantWithoutChromeStart() throws Exception { |