Chromium Code Reviews| 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 1bd21923a8ab11a152f37babff4e9e4494fee4ac..cd1e4253683a8299b8b1899766bb0036e1128389 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,31 +55,28 @@ import java.util.List; |
| /** |
| * Integration tests for ClearBrowsingDataPreferences. |
| */ |
| +@RunWith(ChromeJUnit4ClassRunner.class) |
| @RetryOnFailure |
| -public class ClearBrowsingDataPreferencesTest |
| - extends ChromeActivityTestCaseBase<ChromeActivity> { |
| +@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, |
| + ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG}) |
| +public class ClearBrowsingDataPreferencesTest { |
| + @Rule |
| + public ChromeActivityTestRule<ChromeActivity> mActivityTestRule = |
| + new ChromeActivityTestRule<>(ChromeActivity.class); |
| + |
| private EmbeddedTestServer mTestServer; |
| - @Override |
| - protected void setUp() throws Exception { |
| - 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(); |
| - } |
| - |
| - public ClearBrowsingDataPreferencesTest() { |
| - super(ChromeActivity.class); |
| - } |
| - |
| - @Override |
| - public void startMainActivity() throws InterruptedException { |
| - SigninTestUtil.setUpAuthForTest(getInstrumentation()); |
| - startMainActivityOnBlankPage(); |
| } |
| /** Waits for the progress dialog to disappear from the given CBD preference. */ |
| @@ -86,18 +93,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() { |
| @@ -111,13 +119,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>() { |
| @@ -133,13 +142,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() { |
| @@ -153,27 +162,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() { |
| @@ -187,12 +197,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); |
| } |
| }); |
| @@ -203,12 +213,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 |
| @@ -217,9 +228,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)); |
| } |
| }); |
| @@ -229,13 +240,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 |
| @@ -244,24 +256,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) |
|
Ted C
2017/04/27 18:05:27
this should be assertEquals, but I guess we can fi
the real yoland
2017/04/28 02:03:28
Rebased this file, I think someone else changed be
|
| + || ((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); |
| } |
| }); |
| } |
| @@ -292,7 +310,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); |
| } |
| } |
| @@ -326,17 +344,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)); |
| @@ -347,7 +367,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)); |
| @@ -380,7 +400,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)); |
| @@ -398,7 +418,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); |
| } |
| }; |
| @@ -410,7 +430,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(); |
| @@ -427,7 +447,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; |
| @@ -454,13 +474,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"); |
| @@ -470,18 +491,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. |
| @@ -494,20 +518,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"); |
| @@ -517,12 +543,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)); |
| @@ -532,21 +561,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"); |
| @@ -558,13 +589,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(); |
| @@ -596,7 +629,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) { |