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

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappDataStorageTest.java

Issue 1749603002: Store URLs in WebappDataStorage, and purge them when history is cleared. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add @VisibleForTesting to address test failures Created 4 years, 10 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/junit/src/org/chromium/chrome/browser/webapps/WebappDataStorageTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappDataStorageTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappDataStorageTest.java
index 6cfc8f4a7e177f798de10627a3ca106856d5d93b..d617ee0cf462a18ce69709c8f071eadef2d68107 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappDataStorageTest.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappDataStorageTest.java
@@ -49,6 +49,7 @@ public class WebappDataStorageTest {
assertEquals("webapp_", WebappDataStorage.SHARED_PREFS_FILE_PREFIX);
assertEquals("splash_icon", WebappDataStorage.KEY_SPLASH_ICON);
assertEquals("last_used", WebappDataStorage.KEY_LAST_USED);
+ assertEquals("origin_url", WebappDataStorage.KEY_ORIGIN_URL);
}
@Test
@@ -143,4 +144,38 @@ public class WebappDataStorageTest {
private static Bitmap createBitmap() {
return Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_4444);
}
-}
+
+ @Test
+ @Feature({"Webapp"})
+ public void testOriginUrlRetrieval() throws Exception {
+ final String origin = "http://drive.google.com";
+ mSharedPreferences.edit()
+ .putString(WebappDataStorage.KEY_ORIGIN_URL, origin)
+ .commit();
+
+ WebappDataStorage.getOriginUrl(Robolectric.application, "test",
gone 2016/03/08 23:03:52 Maybe it'd make sense to create and declare the Fe
dominickn 2016/03/09 08:18:32 Done.
+ new WebappDataStorage.FetchCallback<String>() {
+ @Override
+ public void onDataRetrieved(String readObject) {
+ mCallbackCalled = true;
+ assertEquals(origin, readObject);
+ }
+ });
+ BackgroundShadowAsyncTask.runBackgroundTasks();
+ Robolectric.runUiThreadTasks();
+
+ assertTrue(mCallbackCalled);
+ }
+
+ @Test
+ @Feature({"Webapp"})
+ public void testOriginUrlUpdate() throws Exception {
+ final String origin = "http://maps.google.com";
+
+ WebappDataStorage.updateOriginUrl(Robolectric.application, "test", origin);
+ BackgroundShadowAsyncTask.runBackgroundTasks();
+ Robolectric.runUiThreadTasks();
+
+ assertEquals(origin, mSharedPreferences.getString(WebappDataStorage.KEY_ORIGIN_URL, null));
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698