Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1013)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/preferences/privacy/ClearBrowsingDataPreferencesTest.java

Issue 1845233002: Store standalone web app data in WebappDataStorage as well as the homescreen intent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@notification-deep-linking
Patch Set: Final nit Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 2b83f9a2d1f2ce6f76aa48fd35ce776e60182594..a7208347c95551c8d246da4691ff751140199850 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
@@ -11,6 +11,7 @@ import android.test.suitebuilder.annotation.MediumTest;
import org.chromium.base.ThreadUtils;
import org.chromium.chrome.browser.ChromeActivity;
+import org.chromium.chrome.browser.ShortcutHelper;
import org.chromium.chrome.browser.preferences.ButtonPreference;
import org.chromium.chrome.browser.preferences.PrefServiceBridge;
import org.chromium.chrome.browser.preferences.Preferences;
@@ -34,6 +35,21 @@ public class ClearBrowsingDataPreferencesTest
private boolean mCallbackCalled;
+ private class CallbackCriteria extends Criteria {
+ public CallbackCriteria() {
+ mCallbackCalled = false;
+ }
+
+ @Override
+ public boolean isSatisfied() {
+ if (mCallbackCalled) {
+ mCallbackCalled = false;
+ return true;
+ }
+ return false;
+ }
+ }
+
public ClearBrowsingDataPreferencesTest() {
super(ChromeActivity.class);
}
@@ -48,7 +64,7 @@ public class ClearBrowsingDataPreferencesTest
*/
@MediumTest
public void testClearingSiteDataClearsWebapps() throws Exception {
- WebappRegistry.registerWebapp(getActivity(), "first", "https://www.google.com");
+ WebappRegistry.registerWebapp(getActivity(), "first", null);
WebappRegistry.getRegisteredWebappIds(getActivity(), new WebappRegistry.FetchCallback() {
@Override
public void onWebappIdsRetrieved(Set<String> ids) {
@@ -56,13 +72,7 @@ public class ClearBrowsingDataPreferencesTest
mCallbackCalled = true;
}
});
- CriteriaHelper.pollUiThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return mCallbackCalled;
- }
- });
- mCallbackCalled = false;
+ CriteriaHelper.pollUiThread(new CallbackCriteria());
setDataTypesToClear(Arrays.asList(DialogOption.CLEAR_COOKIES_AND_SITE_DATA));
final Preferences preferences =
@@ -95,12 +105,7 @@ public class ClearBrowsingDataPreferencesTest
mCallbackCalled = true;
}
});
- CriteriaHelper.pollUiThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return mCallbackCalled;
- }
- });
+ CriteriaHelper.pollUiThread(new CallbackCriteria());
}
/**
@@ -109,7 +114,19 @@ public class ClearBrowsingDataPreferencesTest
*/
@MediumTest
public void testClearingHistoryClearsWebappScopesAndLaunchTimes() throws Exception {
- WebappRegistry.registerWebapp(getActivity(), "first", "https://www.google.com");
+ WebappRegistry.registerWebapp(getActivity(), "first",
+ new WebappRegistry.FetchWebappDataStorageCallback() {
+ @Override
+ public void onWebappDataStorageRetrieved(WebappDataStorage storage) {
+ storage.updateFromShortcutIntent(ShortcutHelper.createWebappShortcutIntent(
+ "id", "action", "url", "scope", "name", "shortName", null,
+ ShortcutHelper.WEBAPP_SHORTCUT_VERSION, 0, 0, 0, false));
+ mCallbackCalled = true;
+ }
+ }
+ );
+ CriteriaHelper.pollUiThread(new CallbackCriteria());
+
WebappRegistry.getRegisteredWebappIds(getActivity(), new WebappRegistry.FetchCallback() {
@Override
public void onWebappIdsRetrieved(Set<String> ids) {
@@ -117,13 +134,7 @@ public class ClearBrowsingDataPreferencesTest
mCallbackCalled = true;
}
});
- CriteriaHelper.pollUiThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return mCallbackCalled;
- }
- });
- mCallbackCalled = false;
+ CriteriaHelper.pollUiThread(new CallbackCriteria());
setDataTypesToClear(Arrays.asList(DialogOption.CLEAR_HISTORY));
final Preferences preferences =
@@ -157,15 +168,9 @@ public class ClearBrowsingDataPreferencesTest
mCallbackCalled = true;
}
});
- CriteriaHelper.pollUiThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return mCallbackCalled;
- }
- });
- mCallbackCalled = false;
+ CriteriaHelper.pollUiThread(new CallbackCriteria());
- // Scope should be empty.
+ // URL and scope should be empty.
WebappDataStorage.getScope(getActivity(), "first",
new WebappDataStorage.FetchCallback<String>() {
@Override
@@ -175,13 +180,18 @@ public class ClearBrowsingDataPreferencesTest
}
}
);
- CriteriaHelper.pollUiThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return mCallbackCalled;
- }
- });
- mCallbackCalled = false;
+ CriteriaHelper.pollUiThread(new CallbackCriteria());
+
+ WebappDataStorage.getURL(getActivity(), "first",
+ new WebappDataStorage.FetchCallback<String>() {
+ @Override
+ public void onDataRetrieved(String readObject) {
+ assertEquals(readObject, "");
+ mCallbackCalled = true;
+ }
+ }
+ );
+ CriteriaHelper.pollUiThread(new CallbackCriteria());
// The last used time should be 0.
WebappDataStorage.getLastUsedTime(getActivity(), "first",
@@ -194,12 +204,7 @@ public class ClearBrowsingDataPreferencesTest
}
}
);
- CriteriaHelper.pollUiThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return mCallbackCalled;
- }
- });
+ CriteriaHelper.pollUiThread(new CallbackCriteria());
}
/**

Powered by Google App Engine
This is Rietveld 408576698