| Index: chrome/android/javatests/src/org/chromium/chrome/browser/preferences/privacy/ClearBrowsingDataPreferencesTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/privacy/ClearBrowsingDataPreferencesTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/privacy/ClearBrowsingDataPreferencesTest.java
|
| index f481eb1da65c495d5b21745a79ff02f188330898..4e16616a5e61d1c53acce1bda16ff61edbd9e458 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/privacy/ClearBrowsingDataPreferencesTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/privacy/ClearBrowsingDataPreferencesTest.java
|
| @@ -9,6 +9,7 @@ import android.os.AsyncTask;
|
| import android.preference.CheckBoxPreference;
|
| import android.preference.Preference;
|
| import android.preference.PreferenceScreen;
|
| +import android.support.test.InstrumentationRegistry;
|
| import android.support.test.filters.LargeTest;
|
| import android.support.test.filters.MediumTest;
|
| import android.support.test.filters.SmallTest;
|
| @@ -16,12 +17,20 @@ import android.support.v7.app.AlertDialog;
|
| import android.text.SpannableString;
|
| import android.widget.ListView;
|
|
|
| +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.RetryOnFailure;
|
| import org.chromium.chrome.browser.ChromeActivity;
|
| import org.chromium.chrome.browser.ChromeFeatureList;
|
| +import org.chromium.chrome.browser.ChromeSwitches;
|
| import org.chromium.chrome.browser.ShortcutHelper;
|
| import org.chromium.chrome.browser.browsing_data.ClearBrowsingDataTab;
|
| import org.chromium.chrome.browser.preferences.ButtonPreference;
|
| @@ -31,7 +40,8 @@ import org.chromium.chrome.browser.preferences.privacy.ClearBrowsingDataPreferen
|
| import org.chromium.chrome.browser.webapps.TestFetchStorageCallback;
|
| import org.chromium.chrome.browser.webapps.WebappDataStorage;
|
| import org.chromium.chrome.browser.webapps.WebappRegistry;
|
| -import org.chromium.chrome.test.ChromeActivityTestCaseBase;
|
| +import org.chromium.chrome.test.ChromeActivityTestRule;
|
| +import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
|
| import org.chromium.chrome.test.util.browser.signin.SigninTestUtil;
|
| import org.chromium.content.browser.test.util.Criteria;
|
| import org.chromium.content.browser.test.util.CriteriaHelper;
|
| @@ -45,36 +55,31 @@ import java.util.List;
|
| /**
|
| * Integration tests for ClearBrowsingDataPreferences.
|
| */
|
| +@RunWith(ChromeJUnit4ClassRunner.class)
|
| @RetryOnFailure
|
| -public class ClearBrowsingDataPreferencesTest
|
| - extends ChromeActivityTestCaseBase<ChromeActivity> {
|
| - private EmbeddedTestServer mTestServer;
|
| +@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
|
| + ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
|
| +public class ClearBrowsingDataPreferencesTest {
|
| + @Rule
|
| + public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
|
| + new ChromeActivityTestRule<>(ChromeActivity.class);
|
|
|
| - @Override
|
| - protected void setUp() throws Exception {
|
| - SigninTestUtil.setUpAuthForTest(getInstrumentation());
|
| + private EmbeddedTestServer mTestServer;
|
|
|
| - super.setUp();
|
| - mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext());
|
| + @Before
|
| + public void setUp() throws Exception {
|
| + SigninTestUtil.setUpAuthForTest(InstrumentationRegistry.getInstrumentation());
|
| + mActivityTestRule.startMainActivityOnBlankPage();
|
| + mTestServer = EmbeddedTestServer.createAndStartServer(
|
| + InstrumentationRegistry.getInstrumentation().getContext());
|
| }
|
|
|
| - @Override
|
| - protected void tearDown() throws Exception {
|
| + @After
|
| + public void tearDown() throws Exception {
|
| mTestServer.stopAndDestroyServer();
|
| - super.tearDown();
|
| -
|
| SigninTestUtil.tearDownAuthForTest();
|
| }
|
|
|
| - public ClearBrowsingDataPreferencesTest() {
|
| - super(ChromeActivity.class);
|
| - }
|
| -
|
| - @Override
|
| - public void startMainActivity() throws InterruptedException {
|
| - startMainActivityOnBlankPage();
|
| - }
|
| -
|
| /** Waits for the progress dialog to disappear from the given CBD preference. */
|
| private void waitForProgressToComplete(final ClearBrowsingDataPreferences preferences)
|
| throws Exception {
|
| @@ -89,18 +94,19 @@ public class ClearBrowsingDataPreferencesTest
|
| /**
|
| * Tests that web apps are cleared when the "cookies and site data" option is selected.
|
| */
|
| + @Test
|
| @MediumTest
|
| public void testClearingSiteDataClearsWebapps() throws Exception {
|
| TestFetchStorageCallback callback = new TestFetchStorageCallback();
|
| WebappRegistry.getInstance().register("first", callback);
|
| callback.waitForCallback(0);
|
| - assertEquals(new HashSet<String>(Arrays.asList("first")),
|
| + Assert.assertEquals(new HashSet<String>(Arrays.asList("first")),
|
| WebappRegistry.getRegisteredWebappIdsForTesting());
|
|
|
| setDataTypesToClear(Arrays.asList(DialogOption.CLEAR_COOKIES_AND_SITE_DATA));
|
| final ClearBrowsingDataPreferences preferences =
|
| - (ClearBrowsingDataPreferences) startPreferences(
|
| - ClearBrowsingDataPreferences.class.getName())
|
| + (ClearBrowsingDataPreferences) mActivityTestRule
|
| + .startPreferences(ClearBrowsingDataPreferences.class.getName())
|
| .getFragmentForTest();
|
|
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @@ -114,13 +120,14 @@ public class ClearBrowsingDataPreferencesTest
|
| });
|
| waitForProgressToComplete(preferences);
|
|
|
| - assertTrue(WebappRegistry.getRegisteredWebappIdsForTesting().isEmpty());
|
| + Assert.assertTrue(WebappRegistry.getRegisteredWebappIdsForTesting().isEmpty());
|
| }
|
|
|
| /**
|
| * Tests that web app scopes and last launch times are cleared when the "history" option is
|
| * selected. However, the web app is not removed from the registry.
|
| */
|
| + @Test
|
| @MediumTest
|
| public void testClearingHistoryClearsWebappScopesAndLaunchTimes() throws Exception {
|
| AsyncTask<Void, Void, Intent> shortcutIntentTask = new AsyncTask<Void, Void, Intent>() {
|
| @@ -136,13 +143,13 @@ public class ClearBrowsingDataPreferencesTest
|
| callback.waitForCallback(0);
|
| callback.getStorage().updateFromShortcutIntent(shortcutIntent);
|
|
|
| - assertEquals(new HashSet<String>(Arrays.asList("first")),
|
| + Assert.assertEquals(new HashSet<String>(Arrays.asList("first")),
|
| WebappRegistry.getRegisteredWebappIdsForTesting());
|
|
|
| setDataTypesToClear(Arrays.asList(DialogOption.CLEAR_HISTORY));
|
| final ClearBrowsingDataPreferences preferences =
|
| - (ClearBrowsingDataPreferences) startPreferences(
|
| - ClearBrowsingDataPreferences.class.getName())
|
| + (ClearBrowsingDataPreferences) mActivityTestRule
|
| + .startPreferences(ClearBrowsingDataPreferences.class.getName())
|
| .getFragmentForTest();
|
|
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @@ -156,27 +163,28 @@ public class ClearBrowsingDataPreferencesTest
|
| });
|
| waitForProgressToComplete(preferences);
|
|
|
| - assertEquals(new HashSet<String>(Arrays.asList("first")),
|
| + Assert.assertEquals(new HashSet<String>(Arrays.asList("first")),
|
| WebappRegistry.getRegisteredWebappIdsForTesting());
|
|
|
| // URL and scope should be empty, and last used time should be 0.
|
| WebappDataStorage storage = WebappRegistry.getInstance().getWebappDataStorage("first");
|
| - assertEquals("", storage.getScope());
|
| - assertEquals("", storage.getUrl());
|
| - assertEquals(0, storage.getLastUsedTime());
|
| + Assert.assertEquals("", storage.getScope());
|
| + Assert.assertEquals("", storage.getUrl());
|
| + Assert.assertEquals(0, storage.getLastUsedTime());
|
| }
|
|
|
| /**
|
| * Tests that a fragment with all options preselected indeed has all checkboxes checked
|
| * on startup, and that deletion with all checkboxes checked completes successfully.
|
| */
|
| + @Test
|
| @MediumTest
|
| public void testClearingEverything() throws Exception {
|
| setDataTypesToClear(Arrays.asList(DialogOption.values()));
|
|
|
| final ClearBrowsingDataPreferences preferences =
|
| - (ClearBrowsingDataPreferences) startPreferences(
|
| - ClearBrowsingDataPreferences.class.getName())
|
| + (ClearBrowsingDataPreferences) mActivityTestRule
|
| + .startPreferences(ClearBrowsingDataPreferences.class.getName())
|
| .getFragmentForTest();
|
|
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @@ -190,12 +198,12 @@ public class ClearBrowsingDataPreferencesTest
|
| continue;
|
| }
|
| CheckBoxPreference checkbox = (CheckBoxPreference) pref;
|
| - assertTrue(checkbox.isChecked());
|
| + Assert.assertTrue(checkbox.isChecked());
|
| }
|
|
|
| ButtonPreference clearButton = (ButtonPreference) screen.findPreference(
|
| ClearBrowsingDataPreferences.PREF_CLEAR_BUTTON);
|
| - assertTrue(clearButton.isEnabled());
|
| + Assert.assertTrue(clearButton.isEnabled());
|
| clearButton.getOnPreferenceClickListener().onPreferenceClick(clearButton);
|
| }
|
| });
|
| @@ -206,12 +214,13 @@ public class ClearBrowsingDataPreferencesTest
|
| /**
|
| * Tests that for users who are not signed in, only the general footnote is shown.
|
| */
|
| + @Test
|
| @SmallTest
|
| public void testFooterNonsigned() throws Exception {
|
| SigninTestUtil.resetSigninState();
|
|
|
| final Preferences preferences =
|
| - startPreferences(ClearBrowsingDataPreferences.class.getName());
|
| + mActivityTestRule.startPreferences(ClearBrowsingDataPreferences.class.getName());
|
|
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| @@ -220,9 +229,9 @@ public class ClearBrowsingDataPreferencesTest
|
| (ClearBrowsingDataPreferences) preferences.getFragmentForTest();
|
| PreferenceScreen screen = fragment.getPreferenceScreen();
|
|
|
| - assertNotNull(
|
| + Assert.assertNotNull(
|
| screen.findPreference(ClearBrowsingDataPreferences.PREF_GENERAL_SUMMARY));
|
| - assertNull(
|
| + Assert.assertNull(
|
| screen.findPreference(ClearBrowsingDataPreferences.PREF_GOOGLE_SUMMARY));
|
| }
|
| });
|
| @@ -232,13 +241,14 @@ public class ClearBrowsingDataPreferencesTest
|
| * Tests that for users who are signed in, both the general and the Google-specific footnotes
|
| * are shown.
|
| */
|
| + @Test
|
| @MediumTest
|
| public void testFooterSigned() throws Exception {
|
| // Sign in.
|
| SigninTestUtil.addAndSignInTestAccount();
|
|
|
| final Preferences preferences =
|
| - startPreferences(ClearBrowsingDataPreferences.class.getName());
|
| + mActivityTestRule.startPreferences(ClearBrowsingDataPreferences.class.getName());
|
|
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| @@ -247,24 +257,30 @@ public class ClearBrowsingDataPreferencesTest
|
| (ClearBrowsingDataPreferences) preferences.getFragmentForTest();
|
| PreferenceScreen screen = fragment.getPreferenceScreen();
|
|
|
| - assertNotNull(
|
| + Assert.assertNotNull(
|
| screen.findPreference(ClearBrowsingDataPreferences.PREF_GENERAL_SUMMARY));
|
|
|
| Preference google_summary =
|
| screen.findPreference(ClearBrowsingDataPreferences.PREF_GOOGLE_SUMMARY);
|
| - assertNotNull(google_summary);
|
| + Assert.assertNotNull(google_summary);
|
|
|
| // There is currently no clickable link in the Google-specific summary.
|
| - assertTrue(!(google_summary.getSummary() instanceof SpannableString)
|
| - || ((SpannableString) google_summary.getSummary()).getSpans(
|
| - 0, google_summary.getSummary().length(), Object.class).length == 0);
|
| + Assert.assertTrue(!(google_summary.getSummary() instanceof SpannableString)
|
| + || ((SpannableString) google_summary.getSummary())
|
| + .getSpans(0, google_summary.getSummary().length(),
|
| + Object.class)
|
| + .length
|
| + == 0);
|
|
|
| // When the web history service reports that there are other forms of browsing
|
| // history, we should show a link to them.
|
| fragment.showNoticeAboutOtherFormsOfBrowsingHistory();
|
| - assertTrue(google_summary.getSummary() instanceof SpannableString);
|
| - assertTrue(((SpannableString) google_summary.getSummary()).getSpans(
|
| - 0, google_summary.getSummary().length(), Object.class).length == 1);
|
| + Assert.assertTrue(google_summary.getSummary() instanceof SpannableString);
|
| + Assert.assertTrue(
|
| + ((SpannableString) google_summary.getSummary())
|
| + .getSpans(0, google_summary.getSummary().length(), Object.class)
|
| + .length
|
| + == 1);
|
| }
|
| });
|
| }
|
| @@ -295,7 +311,7 @@ public class ClearBrowsingDataPreferencesTest
|
| fragment.enableDialogAboutOtherFormsOfBrowsingHistory();
|
| ButtonPreference clearButton = (ButtonPreference) screen.findPreference(
|
| ClearBrowsingDataPreferences.PREF_CLEAR_BUTTON);
|
| - assertTrue(clearButton.isEnabled());
|
| + Assert.assertTrue(clearButton.isEnabled());
|
| clearButton.getOnPreferenceClickListener().onPreferenceClick(clearButton);
|
| }
|
| }
|
| @@ -329,17 +345,19 @@ public class ClearBrowsingDataPreferencesTest
|
| * after the deletion completes, if and only if browsing history was checked for deletion
|
| * and it has not been shown before.
|
| */
|
| + @Test
|
| @LargeTest
|
| public void testDialogAboutOtherFormsOfBrowsingHistory() throws Exception {
|
| // Sign in.
|
| SigninTestUtil.addAndSignInTestAccount();
|
| - OtherFormsOfHistoryDialogFragment.clearShownPreferenceForTesting(getActivity());
|
| + OtherFormsOfHistoryDialogFragment.clearShownPreferenceForTesting(
|
| + mActivityTestRule.getActivity());
|
|
|
| // History is not selected. We still need to select some other datatype, otherwise the
|
| // "Clear" button won't be enabled.
|
| setDataTypesToClear(Arrays.asList(DialogOption.CLEAR_CACHE));
|
| final Preferences preferences1 =
|
| - startPreferences(ClearBrowsingDataPreferences.class.getName());
|
| + mActivityTestRule.startPreferences(ClearBrowsingDataPreferences.class.getName());
|
| ThreadUtils.runOnUiThreadBlocking(
|
| new OpenPreferencesEnableDialogAndClickClearRunnable(preferences1));
|
|
|
| @@ -350,7 +368,7 @@ public class ClearBrowsingDataPreferencesTest
|
| // Reopen Clear Browsing Data preferences, this time with history selected for clearing.
|
| setDataTypesToClear(Arrays.asList(DialogOption.CLEAR_HISTORY));
|
| final Preferences preferences2 =
|
| - startPreferences(ClearBrowsingDataPreferences.class.getName());
|
| + mActivityTestRule.startPreferences(ClearBrowsingDataPreferences.class.getName());
|
| ThreadUtils.runOnUiThreadBlocking(
|
| new OpenPreferencesEnableDialogAndClickClearRunnable(preferences2));
|
|
|
| @@ -383,7 +401,7 @@ public class ClearBrowsingDataPreferencesTest
|
| // Reopen Clear Browsing Data preferences and clear history once again.
|
| setDataTypesToClear(Arrays.asList(DialogOption.CLEAR_HISTORY));
|
| final Preferences preferences3 =
|
| - startPreferences(ClearBrowsingDataPreferences.class.getName());
|
| + mActivityTestRule.startPreferences(ClearBrowsingDataPreferences.class.getName());
|
| ThreadUtils.runOnUiThreadBlocking(
|
| new OpenPreferencesEnableDialogAndClickClearRunnable(preferences3));
|
|
|
| @@ -401,7 +419,7 @@ public class ClearBrowsingDataPreferencesTest
|
| PreferenceScreen screen = preferences.getPreferenceScreen();
|
| ButtonPreference clearButton = (ButtonPreference) screen.findPreference(
|
| ClearBrowsingDataPreferences.PREF_CLEAR_BUTTON);
|
| - assertTrue(clearButton.isEnabled());
|
| + Assert.assertTrue(clearButton.isEnabled());
|
| clearButton.getOnPreferenceClickListener().onPreferenceClick(clearButton);
|
| }
|
| };
|
| @@ -413,7 +431,7 @@ public class ClearBrowsingDataPreferencesTest
|
| return new Runnable() {
|
| @Override
|
| public void run() {
|
| - assertNotNull(preferences);
|
| + Assert.assertNotNull(preferences);
|
| ConfirmImportantSitesDialogFragment dialog =
|
| preferences.getImportantSitesDialogFragment();
|
| ((AlertDialog) dialog.getDialog()).getButton(whichButton).performClick();
|
| @@ -430,7 +448,7 @@ public class ClearBrowsingDataPreferencesTest
|
| CriteriaHelper.pollUiThread(new Criteria() {
|
| @Override
|
| public boolean isSatisfied() {
|
| - assertNotNull(preferences);
|
| + Assert.assertNotNull(preferences);
|
| if (preferences.getImportantSitesDialogFragment() == null
|
| || !preferences.getImportantSitesDialogFragment().getDialog().isShowing()) {
|
| return false;
|
| @@ -457,13 +475,14 @@ public class ClearBrowsingDataPreferencesTest
|
| * Tests that the important sites dialog is shown, and if we don't deselect anything we
|
| * correctly clear everything.
|
| */
|
| + @Test
|
| @CommandLineFlags.Add({"enable-features=ImportantSitesInCBD", "enable-site-engagement"})
|
| @MediumTest
|
| @Feature({"SiteEngagement"})
|
| public void testImportantSitesDialogNoFiltering() throws Exception {
|
| // Sign in.
|
| SigninTestUtil.addAndSignInTestAccount();
|
| - assertTrue(ChromeFeatureList.isEnabled(ChromeFeatureList.IMPORTANT_SITES_IN_CBD));
|
| + Assert.assertTrue(ChromeFeatureList.isEnabled(ChromeFeatureList.IMPORTANT_SITES_IN_CBD));
|
|
|
| final String testUrl =
|
| mTestServer.getURL("/chrome/test/data/android/storage_persistance.html");
|
| @@ -473,18 +492,21 @@ public class ClearBrowsingDataPreferencesTest
|
| ThreadUtils.runOnUiThreadBlocking(getMarkOriginsAsImportantRunnable(importantOrigins));
|
|
|
| // Load the page and clear any set storage.
|
| - loadUrl(testUrl + "#clear");
|
| - assertEquals("false", runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| - runJavaScriptCodeInCurrentTab("setStorage()");
|
| - assertEquals("true", runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| + mActivityTestRule.loadUrl(testUrl + "#clear");
|
| + Assert.assertEquals(
|
| + "false", mActivityTestRule.runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| + mActivityTestRule.runJavaScriptCodeInCurrentTab("setStorage()");
|
| + Assert.assertEquals(
|
| + "true", mActivityTestRule.runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
|
|
| // Load the page again and ensure the cookie still is set.
|
| - loadUrl(testUrl);
|
| - assertEquals("true", runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| + mActivityTestRule.loadUrl(testUrl);
|
| + Assert.assertEquals(
|
| + "true", mActivityTestRule.runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
|
|
| ClearBrowsingDataPreferences preferences =
|
| - (ClearBrowsingDataPreferences) startPreferences(
|
| - ClearBrowsingDataPreferences.class.getName())
|
| + (ClearBrowsingDataPreferences) mActivityTestRule
|
| + .startPreferences(ClearBrowsingDataPreferences.class.getName())
|
| .getFragmentForTest();
|
|
|
| // Clear in root preference.
|
| @@ -497,20 +519,22 @@ public class ClearBrowsingDataPreferencesTest
|
| waitForProgressToComplete(preferences);
|
|
|
| // Verify we don't have storage.
|
| - loadUrl(testUrl);
|
| - assertEquals("false", runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| + mActivityTestRule.loadUrl(testUrl);
|
| + Assert.assertEquals(
|
| + "false", mActivityTestRule.runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| }
|
|
|
| /**
|
| * Tests that the important sites dialog is shown and if we cancel nothing happens.
|
| */
|
| + @Test
|
| @CommandLineFlags.Add({"enable-features=ImportantSitesInCBD", "enable-site-engagement"})
|
| @MediumTest
|
| @Feature({"SiteEngagement"})
|
| public void testImportantSitesDialogNoopOnCancel() throws Exception {
|
| // Sign in.
|
| SigninTestUtil.addAndSignInTestAccount();
|
| - assertTrue(ChromeFeatureList.isEnabled(ChromeFeatureList.IMPORTANT_SITES_IN_CBD));
|
| + Assert.assertTrue(ChromeFeatureList.isEnabled(ChromeFeatureList.IMPORTANT_SITES_IN_CBD));
|
|
|
| final String testUrl =
|
| mTestServer.getURL("/chrome/test/data/android/storage_persistance.html");
|
| @@ -520,12 +544,15 @@ public class ClearBrowsingDataPreferencesTest
|
| ThreadUtils.runOnUiThreadBlocking(getMarkOriginsAsImportantRunnable(importantOrigins));
|
|
|
| // Load the page and clear any set storage.
|
| - loadUrl(testUrl + "#clear");
|
| - assertEquals("false", runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| - runJavaScriptCodeInCurrentTab("setStorage()");
|
| - assertEquals("true", runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| -
|
| - Preferences preferences = startPreferences(ClearBrowsingDataPreferences.class.getName());
|
| + mActivityTestRule.loadUrl(testUrl + "#clear");
|
| + Assert.assertEquals(
|
| + "false", mActivityTestRule.runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| + mActivityTestRule.runJavaScriptCodeInCurrentTab("setStorage()");
|
| + Assert.assertEquals(
|
| + "true", mActivityTestRule.runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| +
|
| + Preferences preferences =
|
| + mActivityTestRule.startPreferences(ClearBrowsingDataPreferences.class.getName());
|
| ClearBrowsingDataPreferences fragment =
|
| (ClearBrowsingDataPreferences) preferences.getFragmentForTest();
|
| ThreadUtils.runOnUiThreadBlocking(getPressClearRunnable(fragment));
|
| @@ -535,21 +562,23 @@ public class ClearBrowsingDataPreferencesTest
|
| ThreadUtils.runOnUiThreadBlocking(
|
| getPressButtonInImportantDialogRunnable(fragment, AlertDialog.BUTTON_NEGATIVE));
|
| preferences.finish();
|
| - loadUrl(testUrl);
|
| - assertEquals("true", runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| + mActivityTestRule.loadUrl(testUrl);
|
| + Assert.assertEquals(
|
| + "true", mActivityTestRule.runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| }
|
|
|
| /**
|
| * Tests that the important sites dialog is shown, we can successfully uncheck options, and
|
| * clicking clear doesn't clear the protected domain.
|
| */
|
| + @Test
|
| @CommandLineFlags.Add({"enable-features=ImportantSitesInCBD", "enable-site-engagement"})
|
| @MediumTest
|
| @Feature({"SiteEngagement"})
|
| public void testImportantSitesDialog() throws Exception {
|
| // Sign in.
|
| SigninTestUtil.addAndSignInTestAccount();
|
| - assertTrue(ChromeFeatureList.isEnabled(ChromeFeatureList.IMPORTANT_SITES_IN_CBD));
|
| + Assert.assertTrue(ChromeFeatureList.isEnabled(ChromeFeatureList.IMPORTANT_SITES_IN_CBD));
|
|
|
| final String testUrl =
|
| mTestServer.getURL("/chrome/test/data/android/storage_persistance.html");
|
| @@ -561,13 +590,15 @@ public class ClearBrowsingDataPreferencesTest
|
| ThreadUtils.runOnUiThreadBlocking(getMarkOriginsAsImportantRunnable(importantOrigins));
|
|
|
| // Load the page and clear any set storage.
|
| - loadUrl(testUrl + "#clear");
|
| - assertEquals("false", runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| - runJavaScriptCodeInCurrentTab("setStorage()");
|
| - assertEquals("true", runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| + mActivityTestRule.loadUrl(testUrl + "#clear");
|
| + Assert.assertEquals(
|
| + "false", mActivityTestRule.runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| + mActivityTestRule.runJavaScriptCodeInCurrentTab("setStorage()");
|
| + Assert.assertEquals(
|
| + "true", mActivityTestRule.runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
|
|
| final Preferences preferences =
|
| - startPreferences(ClearBrowsingDataPreferences.class.getName());
|
| + mActivityTestRule.startPreferences(ClearBrowsingDataPreferences.class.getName());
|
| final ClearBrowsingDataPreferences fragment =
|
| (ClearBrowsingDataPreferences) preferences.getFragmentForTest();
|
|
|
| @@ -599,7 +630,8 @@ public class ClearBrowsingDataPreferencesTest
|
|
|
| waitForProgressToComplete(fragment);
|
| // And check we didn't clear our cookies.
|
| - assertEquals("true", runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| + Assert.assertEquals(
|
| + "true", mActivityTestRule.runJavaScriptCodeInCurrentTab("hasAllStorage()"));
|
| }
|
|
|
| private void setDataTypesToClear(final List<DialogOption> typesToClear) {
|
|
|