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 59bea9610c34bb421dfe372341a6af1aab856449..c8dd3a62ec10002845ed27718e81e2ad373a41c7 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,17 +7,9 @@ |
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; |
@@ -25,10 +17,8 @@ |
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.ChromeActivityTestRule; |
-import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
+import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
import org.chromium.content.browser.test.util.Criteria; |
import org.chromium.content.browser.test.util.CriteriaHelper; |
import org.chromium.net.test.EmbeddedTestServer; |
@@ -36,39 +26,42 @@ |
/** |
* Tests for ManageSpaceActivity. |
*/ |
-@RunWith(ChromeJUnit4ClassRunner.class) |
@TargetApi(Build.VERSION_CODES.KITKAT) |
+@CommandLineFlags.Add({"enable-site-engagement"}) |
@MinAndroidSdkLevel(Build.VERSION_CODES.KITKAT) |
-@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 class ManageSpaceActivityTest extends ChromeActivityTestCaseBase<ChromeActivity> { |
private EmbeddedTestServer mTestServer; |
- @Before |
- public void setUp() throws Exception { |
- if (!mActivityTestRule.getName().equals("testClearUnimporantWithoutChromeStart")) { |
- mActivityTestRule.startMainActivityOnBlankPage(); |
- } |
- mTestServer = EmbeddedTestServer.createAndStartServer( |
- InstrumentationRegistry.getInstrumentation().getContext()); |
+ public ManageSpaceActivityTest() { |
+ super(ChromeActivity.class); |
} |
- @After |
- public void tearDown() throws Exception { |
+ @Override |
+ protected void setUp() throws Exception { |
+ super.setUp(); |
+ mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext()); |
+ } |
+ |
+ @Override |
+ protected 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(InstrumentationRegistry.getInstrumentation().getTargetContext(), |
- ManageSpaceActivity.class); |
+ Intent intent = |
+ new Intent(getInstrumentation().getTargetContext(), ManageSpaceActivity.class); |
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
- return (ManageSpaceActivity) InstrumentationRegistry.getInstrumentation().startActivitySync( |
- intent); |
+ return (ManageSpaceActivity) getInstrumentation().startActivitySync(intent); |
} |
public void waitForClearButtonEnabled(final ManageSpaceActivity activity) { |
@@ -107,14 +100,12 @@ |
}; |
} |
- @Test |
@SmallTest |
@RetryOnFailure |
public void testLaunchActivity() { |
startManageSpaceActivity(); |
} |
- @Test |
@MediumTest |
@RetryOnFailure |
@Feature({"SiteEngagement"}) |
@@ -123,13 +114,11 @@ |
mTestServer.getURL("/chrome/test/data/android/storage_persistance.html"); |
final String serverOrigin = mTestServer.getURL("/"); |
- mActivityTestRule.loadUrl(cookiesUrl + "#clear"); |
- Assert.assertEquals( |
- "false", mActivityTestRule.runJavaScriptCodeInCurrentTab("hasAllStorage()")); |
- mActivityTestRule.runJavaScriptCodeInCurrentTab("setStorage()"); |
- Assert.assertEquals( |
- "true", mActivityTestRule.runJavaScriptCodeInCurrentTab("hasAllStorage()")); |
- mActivityTestRule.loadUrl("about:blank"); |
+ loadUrl(cookiesUrl + "#clear"); |
+ assertEquals("false", runJavaScriptCodeInCurrentTab("hasAllStorage()")); |
+ runJavaScriptCodeInCurrentTab("setStorage()"); |
+ assertEquals("true", runJavaScriptCodeInCurrentTab("hasAllStorage()")); |
+ loadUrl("about:blank"); |
// Now we set the origin as important, and check that we don't clear it. |
ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
@@ -150,12 +139,10 @@ |
waitForClearButtonEnabled(manageSpaceActivity); |
manageSpaceActivity.finish(); |
- mActivityTestRule.loadUrl(cookiesUrl); |
- Assert.assertEquals( |
- "true", mActivityTestRule.runJavaScriptCodeInCurrentTab("hasAllStorage()")); |
+ loadUrl(cookiesUrl); |
+ assertEquals("true", runJavaScriptCodeInCurrentTab("hasAllStorage()")); |
} |
- @Test |
@MediumTest |
@Feature({"SiteEngagement"}) |
public void testClearUnimporantWithoutChromeStart() throws Exception { |