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()); |
} |
/** |