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

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

Issue 2352943003: Remove the context argument from all WebappRegistry/WebappDataStorage methods. (Closed)
Patch Set: Address comments Created 4 years, 3 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/WebappRegistryTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappRegistryTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappRegistryTest.java
index 65e175c52ea57aea8a5025a4d3b53c9ae2b22ab2..7be71ccd88e44b470d573ca5fa6ccb165e701e6d 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappRegistryTest.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappRegistryTest.java
@@ -13,11 +13,13 @@ import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.text.TextUtils;
+import org.chromium.base.ContextUtils;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.browser.ShortcutHelper;
import org.chromium.chrome.browser.browsing_data.UrlFilters;
import org.chromium.testing.local.BackgroundShadowAsyncTask;
import org.chromium.testing.local.LocalRobolectricTestRunner;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -136,13 +138,19 @@ public class WebappRegistryTest {
@Before
public void setUp() throws Exception {
- mSharedPreferences = RuntimeEnvironment.application
- .getSharedPreferences(REGISTRY_FILE_NAME, Context.MODE_PRIVATE);
+ ContextUtils.initApplicationContextForTests(RuntimeEnvironment.application);
+ mSharedPreferences = ContextUtils.getApplicationContext().getSharedPreferences(
+ REGISTRY_FILE_NAME, Context.MODE_PRIVATE);
mSharedPreferences.edit().putLong(KEY_LAST_CLEANUP, INITIAL_TIME).commit();
mCallbackCalled = false;
}
+ @After
+ public void tearDown() {
+ mSharedPreferences.edit().clear().apply();
+ }
+
@Test
@Feature({"Webapp"})
public void testBackwardCompatibility() {
@@ -154,7 +162,7 @@ public class WebappRegistryTest {
@Test
@Feature({"Webapp"})
public void testWebappRegistrationAddsToSharedPrefs() throws Exception {
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, "test", null);
+ WebappRegistry.registerWebapp("test", null);
BackgroundShadowAsyncTask.runBackgroundTasks();
@@ -167,12 +175,12 @@ public class WebappRegistryTest {
@Test
@Feature({"Webapp"})
public void testWebappRegistrationUpdatesLastUsed() throws Exception {
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, "test", null);
+ WebappRegistry.registerWebapp("test", null);
BackgroundShadowAsyncTask.runBackgroundTasks();
long after = System.currentTimeMillis();
- SharedPreferences webAppPrefs = RuntimeEnvironment.application.getSharedPreferences(
+ SharedPreferences webAppPrefs = ContextUtils.getApplicationContext().getSharedPreferences(
WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "test", Context.MODE_PRIVATE);
long actual = webAppPrefs.getLong(WebappDataStorage.KEY_LAST_USED,
WebappDataStorage.LAST_USED_INVALID);
@@ -185,7 +193,7 @@ public class WebappRegistryTest {
final Set<String> expected = addWebappsToRegistry("first", "second");
FetchCallback callback = new FetchCallback(expected);
- WebappRegistry.getRegisteredWebappIds(RuntimeEnvironment.application, callback);
+ WebappRegistry.getRegisteredWebappIds(callback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
@@ -199,14 +207,14 @@ public class WebappRegistryTest {
final Set<String> expected = addWebappsToRegistry("first");
FetchCallback callback = new FetchCallback(expected);
- WebappRegistry.getRegisteredWebappIds(RuntimeEnvironment.application, callback);
+ WebappRegistry.getRegisteredWebappIds(callback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(callback.getCallbackCalled());
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, "second", null);
+ WebappRegistry.registerWebapp("second", null);
BackgroundShadowAsyncTask.runBackgroundTasks();
@@ -216,7 +224,7 @@ public class WebappRegistryTest {
secondExpected.add("second");
callback = new FetchCallback(secondExpected);
- WebappRegistry.getRegisteredWebappIds(RuntimeEnvironment.application, callback);
+ WebappRegistry.getRegisteredWebappIds(callback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
@@ -228,8 +236,7 @@ public class WebappRegistryTest {
@Feature({"Webapp"})
public void testUnregisterRunsCallback() throws Exception {
CallbackRunner callback = new CallbackRunner();
- WebappRegistry.unregisterWebappsForUrls(
- RuntimeEnvironment.application, new UrlFilters.AllUrls(), callback);
+ WebappRegistry.unregisterWebappsForUrls(new UrlFilters.AllUrls(), callback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
@@ -245,8 +252,8 @@ public class WebappRegistryTest {
apps.put("webapp3", "https://www.chrome.com");
for (Map.Entry<String, String> app : apps.entrySet()) {
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, app.getKey(),
- new FetchStorageCallback(createShortcutIntent(app.getValue())));
+ WebappRegistry.registerWebapp(
+ app.getKey(), new FetchStorageCallback(createShortcutIntent(app.getValue())));
}
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
@@ -254,7 +261,6 @@ public class WebappRegistryTest {
// Partial deletion.
CallbackRunner callback = new CallbackRunner();
WebappRegistry.unregisterWebappsForUrls(
- RuntimeEnvironment.application,
new UrlFilters.OneUrl("http://example.com/index.html"), callback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
@@ -269,8 +275,7 @@ public class WebappRegistryTest {
// Full deletion.
callback = new CallbackRunner();
- WebappRegistry.unregisterWebappsForUrls(
- RuntimeEnvironment.application, new UrlFilters.AllUrls(), callback);
+ WebappRegistry.unregisterWebappsForUrls(new UrlFilters.AllUrls(), callback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
@@ -287,37 +292,41 @@ public class WebappRegistryTest {
apps.put("webapp3", "https://www.chrome.com");
for (Map.Entry<String, String> app : apps.entrySet()) {
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, app.getKey(),
- new FetchStorageCallback(createShortcutIntent(app.getValue())));
+ WebappRegistry.registerWebapp(
+ app.getKey(), new FetchStorageCallback(createShortcutIntent(app.getValue())));
}
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
for (String appName : apps.keySet()) {
- SharedPreferences webAppPrefs = RuntimeEnvironment.application.getSharedPreferences(
- WebappDataStorage.SHARED_PREFS_FILE_PREFIX + appName, Context.MODE_PRIVATE);
+ SharedPreferences webAppPrefs =
+ ContextUtils.getApplicationContext().getSharedPreferences(
+ WebappDataStorage.SHARED_PREFS_FILE_PREFIX + appName,
+ Context.MODE_PRIVATE);
webAppPrefs.edit().putLong(WebappDataStorage.KEY_LAST_USED, 100L).apply();
}
// Partial deletion.
WebappRegistry.unregisterWebappsForUrls(
- RuntimeEnvironment.application,
new UrlFilters.OneUrl("http://example.com/index.html"), null);
BackgroundShadowAsyncTask.runBackgroundTasks();
for (String appName : apps.keySet()) {
- SharedPreferences webAppPrefs = RuntimeEnvironment.application.getSharedPreferences(
- WebappDataStorage.SHARED_PREFS_FILE_PREFIX + appName, Context.MODE_PRIVATE);
+ SharedPreferences webAppPrefs =
+ ContextUtils.getApplicationContext().getSharedPreferences(
+ WebappDataStorage.SHARED_PREFS_FILE_PREFIX + appName,
+ Context.MODE_PRIVATE);
assertEquals(TextUtils.equals(appName, "webapp1"), webAppPrefs.getAll().isEmpty());
}
// Full deletion.
- WebappRegistry.unregisterWebappsForUrls(
- RuntimeEnvironment.application, new UrlFilters.AllUrls(), null);
+ WebappRegistry.unregisterWebappsForUrls(new UrlFilters.AllUrls(), null);
BackgroundShadowAsyncTask.runBackgroundTasks();
for (String appName : apps.keySet()) {
- SharedPreferences webAppPrefs = RuntimeEnvironment.application.getSharedPreferences(
- WebappDataStorage.SHARED_PREFS_FILE_PREFIX + appName, Context.MODE_PRIVATE);
+ SharedPreferences webAppPrefs =
+ ContextUtils.getApplicationContext().getSharedPreferences(
+ WebappDataStorage.SHARED_PREFS_FILE_PREFIX + appName,
+ Context.MODE_PRIVATE);
assertTrue(webAppPrefs.getAll().isEmpty());
}
}
@@ -329,11 +338,11 @@ public class WebappRegistryTest {
long currentTime = INITIAL_TIME + WebappRegistry.FULL_CLEANUP_DURATION - 1;
addWebappsToRegistry("oldWebapp");
- SharedPreferences webAppPrefs = RuntimeEnvironment.application.getSharedPreferences(
+ SharedPreferences webAppPrefs = ContextUtils.getApplicationContext().getSharedPreferences(
WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "oldWebapp", Context.MODE_PRIVATE);
webAppPrefs.edit().putLong(WebappDataStorage.KEY_LAST_USED, Long.MIN_VALUE).apply();
- WebappRegistry.unregisterOldWebapps(RuntimeEnvironment.application, currentTime);
+ WebappRegistry.unregisterOldWebapps(currentTime);
BackgroundShadowAsyncTask.runBackgroundTasks();
Set<String> actual = mSharedPreferences.getStringSet(
@@ -357,7 +366,7 @@ public class WebappRegistryTest {
// Put the last used time just inside the no-cleanup window.
addWebappsToRegistry("recentWebapp");
- SharedPreferences webAppPrefs = RuntimeEnvironment.application.getSharedPreferences(
+ SharedPreferences webAppPrefs = ContextUtils.getApplicationContext().getSharedPreferences(
WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "recentWebapp", Context.MODE_PRIVATE);
long lastUsed = currentTime - WebappRegistry.WEBAPP_UNOPENED_CLEANUP_DURATION + 1;
webAppPrefs.edit().putLong(WebappDataStorage.KEY_LAST_USED, lastUsed).apply();
@@ -365,7 +374,7 @@ public class WebappRegistryTest {
// Because the time is just inside the window, there should be a cleanup but the web app
// should not be deleted as it was used recently. The last cleanup time should also be
// set to the current time.
- WebappRegistry.unregisterOldWebapps(RuntimeEnvironment.application, currentTime);
+ WebappRegistry.unregisterOldWebapps(currentTime);
BackgroundShadowAsyncTask.runBackgroundTasks();
Set<String> actual = mSharedPreferences.getStringSet(
@@ -388,14 +397,14 @@ public class WebappRegistryTest {
// Put the last used time just outside the no-cleanup window.
addWebappsToRegistry("oldWebapp");
- SharedPreferences webAppPrefs = RuntimeEnvironment.application.getSharedPreferences(
+ SharedPreferences webAppPrefs = ContextUtils.getApplicationContext().getSharedPreferences(
WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "oldWebapp", Context.MODE_PRIVATE);
long lastUsed = currentTime - WebappRegistry.WEBAPP_UNOPENED_CLEANUP_DURATION;
webAppPrefs.edit().putLong(WebappDataStorage.KEY_LAST_USED, lastUsed).apply();
// Because the time is just inside the window, there should be a cleanup of old web apps and
// the last cleaned up time should be set to the current time.
- WebappRegistry.unregisterOldWebapps(RuntimeEnvironment.application, currentTime);
+ WebappRegistry.unregisterOldWebapps(currentTime);
BackgroundShadowAsyncTask.runBackgroundTasks();
Set<String> actual = mSharedPreferences.getStringSet(
@@ -420,14 +429,14 @@ public class WebappRegistryTest {
FetchStorageCallback storageCallback1 = new FetchStorageCallback(
createWebApkIntent(webappId1, webApkPackage1));
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, webappId1, storageCallback1);
+ WebappRegistry.registerWebapp(webappId1, storageCallback1);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(storageCallback1.getCallbackCalled());
FetchStorageCallback storageCallback2 = new FetchStorageCallback(
createWebApkIntent(webappId1, webApkPackage2));
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, webappId2, storageCallback2);
+ WebappRegistry.registerWebapp(webappId2, storageCallback2);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(storageCallback2.getCallbackCalled());
@@ -444,7 +453,7 @@ public class WebappRegistryTest {
// Because the time is just inside the window, there should be a cleanup of
// uninstalled WebAPKs and the last cleaned up time should be set to the
// current time.
- WebappRegistry.unregisterOldWebapps(RuntimeEnvironment.application, currentTime);
+ WebappRegistry.unregisterOldWebapps(currentTime);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
@@ -467,15 +476,14 @@ public class WebappRegistryTest {
FetchStorageCallback storageCallback = new FetchStorageCallback(
createWebApkIntent(webappId, webApkPackage));
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, webappId, storageCallback);
+ WebappRegistry.registerWebapp(webappId, storageCallback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(storageCallback.getCallbackCalled());
FetchStorageCallback storageCallback2 = new FetchStorageCallback(
createWebApkIntent(uninstalledWebappId, uninstalledWebApkPackage));
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, uninstalledWebappId,
- storageCallback2);
+ WebappRegistry.registerWebapp(uninstalledWebappId, storageCallback2);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(storageCallback2.getCallbackCalled());
@@ -494,7 +502,7 @@ public class WebappRegistryTest {
// Because the time is just inside the window, there should be a cleanup of
// uninstalled WebAPKs and the last cleaned up time should be set to the
// current time.
- WebappRegistry.unregisterOldWebapps(RuntimeEnvironment.application, currentTime);
+ WebappRegistry.unregisterOldWebapps(currentTime);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
@@ -512,8 +520,7 @@ public class WebappRegistryTest {
@Feature({"Webapp"})
public void testClearWebappHistoryRunsCallback() throws Exception {
CallbackRunner callback = new CallbackRunner();
- WebappRegistry.clearWebappHistoryForUrls(
- RuntimeEnvironment.application, new UrlFilters.AllUrls(), callback);
+ WebappRegistry.clearWebappHistoryForUrls(new UrlFilters.AllUrls(), callback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
@@ -529,20 +536,20 @@ public class WebappRegistryTest {
Intent shortcutIntent2 = createShortcutIntent(webapp2Url);
FetchStorageCallback storageCallback1 = new FetchStorageCallback(shortcutIntent1);
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, "webapp1", storageCallback1);
+ WebappRegistry.registerWebapp("webapp1", storageCallback1);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(storageCallback1.getCallbackCalled());
FetchStorageCallback storageCallback2 = new FetchStorageCallback(shortcutIntent2);
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, "webapp2", storageCallback2);
+ WebappRegistry.registerWebapp("webapp2", storageCallback2);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(storageCallback2.getCallbackCalled());
- SharedPreferences webapp1Prefs = RuntimeEnvironment.application.getSharedPreferences(
+ SharedPreferences webapp1Prefs = ContextUtils.getApplicationContext().getSharedPreferences(
WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "webapp1", Context.MODE_PRIVATE);
- SharedPreferences webapp2Prefs = RuntimeEnvironment.application.getSharedPreferences(
+ SharedPreferences webapp2Prefs = ContextUtils.getApplicationContext().getSharedPreferences(
WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "webapp2", Context.MODE_PRIVATE);
long webapp1OriginalLastUsed = webapp2Prefs.getLong(
@@ -554,8 +561,7 @@ public class WebappRegistryTest {
// Clear data for |webapp1Url|.
CallbackRunner callback = new CallbackRunner();
- WebappRegistry.clearWebappHistoryForUrls(
- RuntimeEnvironment.application, new UrlFilters.OneUrl(webapp1Url), callback);
+ WebappRegistry.clearWebappHistoryForUrls(new UrlFilters.OneUrl(webapp1Url), callback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(callback.getCallbackCalled());
@@ -592,8 +598,7 @@ public class WebappRegistryTest {
// Clear data for all urls.
callback = new CallbackRunner();
- WebappRegistry.clearWebappHistoryForUrls(
- RuntimeEnvironment.application, new UrlFilters.AllUrls(), callback);
+ WebappRegistry.clearWebappHistoryForUrls(new UrlFilters.AllUrls(), callback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(callback.getCallbackCalled());
@@ -624,22 +629,20 @@ public class WebappRegistryTest {
@Test
@Feature({"Webapp"})
public void testGetAfterClearWebappHistory() throws Exception {
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, "webapp", null);
+ WebappRegistry.registerWebapp("webapp", null);
BackgroundShadowAsyncTask.runBackgroundTasks();
- SharedPreferences webappPrefs = RuntimeEnvironment.application.getSharedPreferences(
+ SharedPreferences webappPrefs = ContextUtils.getApplicationContext().getSharedPreferences(
WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "webapp", Context.MODE_PRIVATE);
CallbackRunner callback = new CallbackRunner();
- WebappRegistry.clearWebappHistoryForUrls(
- RuntimeEnvironment.application, new UrlFilters.AllUrls(), callback);
+ WebappRegistry.clearWebappHistoryForUrls(new UrlFilters.AllUrls(), callback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(callback.getCallbackCalled());
// Open the webapp up to set the last used time.
FetchStorageCallback storageCallback = new FetchStorageCallback(null);
- WebappRegistry.getWebappDataStorage(
- RuntimeEnvironment.application, "webapp", storageCallback);
+ WebappRegistry.getWebappDataStorage("webapp", storageCallback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(storageCallback.getCallbackCalled());
@@ -657,12 +660,11 @@ public class WebappRegistryTest {
final String webappUrl = "http://www.google.com";
final String webappScope = "http://www.google.com/";
final Intent shortcutIntent = createShortcutIntent(webappUrl);
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, "webapp",
- new FetchStorageCallback(shortcutIntent));
+ WebappRegistry.registerWebapp("webapp", new FetchStorageCallback(shortcutIntent));
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
- SharedPreferences webappPrefs = RuntimeEnvironment.application.getSharedPreferences(
+ SharedPreferences webappPrefs = ContextUtils.getApplicationContext().getSharedPreferences(
WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "webapp", Context.MODE_PRIVATE);
// Verify that the URL and scope match the original in the intent.
@@ -673,14 +675,12 @@ public class WebappRegistryTest {
WebappDataStorage.KEY_SCOPE, WebappDataStorage.URL_INVALID);
assertEquals(webappScope, actualScope);
- WebappRegistry.clearWebappHistoryForUrls(
- RuntimeEnvironment.application, new UrlFilters.AllUrls(), new CallbackRunner());
+ WebappRegistry.clearWebappHistoryForUrls(new UrlFilters.AllUrls(), new CallbackRunner());
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
// Update the webapp from the intent again.
- WebappRegistry.getWebappDataStorage(RuntimeEnvironment.application, "webapp",
- new FetchStorageCallback(shortcutIntent));
+ WebappRegistry.getWebappDataStorage("webapp", new FetchStorageCallback(shortcutIntent));
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
@@ -718,62 +718,53 @@ public class WebappRegistryTest {
Intent shortcutIntent4 = createShortcutIntent(webapp4Url);
// Register the four web apps.
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, "webapp1",
- new FetchStorageCallback(shortcutIntent1));
+ WebappRegistry.registerWebapp("webapp1", new FetchStorageCallback(shortcutIntent1));
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, "webapp2",
- new FetchStorageCallback(shortcutIntent2));
+ WebappRegistry.registerWebapp("webapp2", new FetchStorageCallback(shortcutIntent2));
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, "webapp3",
- new FetchStorageCallback(shortcutIntent3));
+ WebappRegistry.registerWebapp("webapp3", new FetchStorageCallback(shortcutIntent3));
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
- WebappRegistry.registerWebapp(RuntimeEnvironment.application, "webapp4",
- new FetchStorageCallback(shortcutIntent4));
+ WebappRegistry.registerWebapp("webapp4", new FetchStorageCallback(shortcutIntent4));
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
// test1Url should return webapp1.
FetchStorageByUrlCallback callback = new FetchStorageByUrlCallback(webapp1Url, webapp1Url);
- WebappRegistry.getWebappDataStorageForUrl(
- RuntimeEnvironment.application, test1Url, callback);
+ WebappRegistry.getWebappDataStorageForUrl(test1Url, callback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(callback.getCallbackCalled());
// test2Url should return webapp3.
callback = new FetchStorageByUrlCallback(webapp3Url, webapp3Scope);
- WebappRegistry.getWebappDataStorageForUrl(
- RuntimeEnvironment.application, test2Url, callback);
+ WebappRegistry.getWebappDataStorageForUrl(test2Url, callback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(callback.getCallbackCalled());
// test3Url should return webapp4.
callback = new FetchStorageByUrlCallback(webapp4Url, webapp4Scope);
- WebappRegistry.getWebappDataStorageForUrl(
- RuntimeEnvironment.application, test3Url, callback);
+ WebappRegistry.getWebappDataStorageForUrl(test3Url, callback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(callback.getCallbackCalled());
// test4Url should return webapp4.
callback = new FetchStorageByUrlCallback(webapp4Url, webapp4Scope);
- WebappRegistry.getWebappDataStorageForUrl(
- RuntimeEnvironment.application, test4Url, callback);
+ WebappRegistry.getWebappDataStorageForUrl(test4Url, callback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(callback.getCallbackCalled());
// test5Url should return webapp2.
callback = new FetchStorageByUrlCallback(webapp2Url, webapp2Url);
- WebappRegistry.getWebappDataStorageForUrl(
- RuntimeEnvironment.application, test5Url, callback);
+ WebappRegistry.getWebappDataStorageForUrl(test5Url, callback);
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(callback.getCallbackCalled());
@@ -782,15 +773,14 @@ public class WebappRegistryTest {
// This must use a member variable; local variables must be final or effectively final to be
// accessible inside an inner class.
mCallbackCalled = false;
- WebappRegistry.getWebappDataStorageForUrl(RuntimeEnvironment.application, test6Url,
- new WebappRegistry.FetchWebappDataStorageCallback() {
+ WebappRegistry.getWebappDataStorageForUrl(
+ test6Url, new WebappRegistry.FetchWebappDataStorageCallback() {
@Override
public void onWebappDataStorageRetrieved(WebappDataStorage storage) {
assertEquals(null, storage);
mCallbackCalled = true;
}
- }
- );
+ });
BackgroundShadowAsyncTask.runBackgroundTasks();
ShadowLooper.runUiThreadTasks();
assertTrue(mCallbackCalled);

Powered by Google App Engine
This is Rietveld 408576698