| 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 e76a798472ab2fbebe7c78c96c78885086921097..b4b6564a18356665526b7a973bbf3f694cc92ad9 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
|
| @@ -20,9 +20,8 @@
|
| import org.junit.Before;
|
| import org.junit.Test;
|
| import org.junit.runner.RunWith;
|
| -import org.robolectric.RuntimeEnvironment;
|
| +import org.robolectric.Robolectric;
|
| import org.robolectric.annotation.Config;
|
| -import org.robolectric.shadows.ShadowLooper;
|
|
|
| import java.util.concurrent.TimeUnit;
|
|
|
| @@ -70,7 +69,7 @@
|
|
|
| @Before
|
| public void setUp() throws Exception {
|
| - mSharedPreferences = RuntimeEnvironment.application
|
| + mSharedPreferences = Robolectric.application
|
| .getSharedPreferences("webapp_test", Context.MODE_PRIVATE);
|
|
|
| // Set the last_used as if the web app had been registered by WebappRegistry.
|
| @@ -104,10 +103,10 @@
|
| public void testLastUsedRetrieval() throws Exception {
|
| mSharedPreferences.edit().putLong(WebappDataStorage.KEY_LAST_USED, 100L).apply();
|
|
|
| - WebappDataStorage.getLastUsedTime(RuntimeEnvironment.application, "test",
|
| + WebappDataStorage.getLastUsedTime(Robolectric.application, "test",
|
| new FetchCallback<Long>(new Long(100L)));
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
| - ShadowLooper.runUiThreadTasks();
|
| + Robolectric.runUiThreadTasks();
|
|
|
| assertTrue(mCallbackCalled);
|
| }
|
| @@ -119,8 +118,8 @@
|
| mSharedPreferences.edit()
|
| .putString(WebappDataStorage.KEY_SPLASH_ICON,
|
| ShortcutHelper.encodeBitmapAsString(expected))
|
| - .commit();
|
| - WebappDataStorage.open(RuntimeEnvironment.application, "test")
|
| + .apply();
|
| + WebappDataStorage.open(Robolectric.application, "test")
|
| .getSplashScreenImage(new WebappDataStorage.FetchCallback<Bitmap>() {
|
| @Override
|
| public void onDataRetrieved(Bitmap actual) {
|
| @@ -133,7 +132,7 @@
|
| }
|
| });
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
| - ShadowLooper.runUiThreadTasks();
|
| + Robolectric.runUiThreadTasks();
|
|
|
| assertTrue(mCallbackCalled);
|
| }
|
| @@ -142,7 +141,7 @@
|
| @Feature({"Webapp"})
|
| public void testSplashImageUpdate() throws Exception {
|
| final Bitmap expectedImage = createBitmap();
|
| - WebappDataStorage.open(RuntimeEnvironment.application, "test")
|
| + WebappDataStorage.open(Robolectric.application, "test")
|
| .updateSplashScreenImage(expectedImage);
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
|
|
| @@ -156,10 +155,10 @@
|
| final String scope = "http://drive.google.com";
|
| mSharedPreferences.edit().putString(WebappDataStorage.KEY_SCOPE, scope).apply();
|
|
|
| - WebappDataStorage.getScope(RuntimeEnvironment.application, "test",
|
| + WebappDataStorage.getScope(Robolectric.application, "test",
|
| new FetchCallback<String>(scope));
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
| - ShadowLooper.runUiThreadTasks();
|
| + Robolectric.runUiThreadTasks();
|
|
|
| assertTrue(mCallbackCalled);
|
| }
|
| @@ -170,10 +169,10 @@
|
| final String url = "https://www.google.com";
|
| mSharedPreferences.edit().putString(WebappDataStorage.KEY_URL, url).apply();
|
|
|
| - WebappDataStorage.getUrl(RuntimeEnvironment.application, "test",
|
| + WebappDataStorage.getUrl(Robolectric.application, "test",
|
| new FetchCallback<String>(url));
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
| - ShadowLooper.runUiThreadTasks();
|
| + Robolectric.runUiThreadTasks();
|
|
|
| assertTrue(mCallbackCalled);
|
| }
|
| @@ -185,15 +184,15 @@
|
| WebappDataStorage.setClockForTests(clock);
|
|
|
| // Opening a data storage doesn't count as a launch.
|
| - WebappDataStorage storage = WebappDataStorage.open(RuntimeEnvironment.application, "test");
|
| - BackgroundShadowAsyncTask.runBackgroundTasks();
|
| - ShadowLooper.runUiThreadTasks();
|
| + WebappDataStorage storage = WebappDataStorage.open(Robolectric.application, "test");
|
| + BackgroundShadowAsyncTask.runBackgroundTasks();
|
| + Robolectric.runUiThreadTasks();
|
| assertTrue(!storage.wasLaunchedRecently());
|
|
|
| // When the last used time is updated, then it is a launch.
|
| storage.updateLastUsedTime();
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
| - ShadowLooper.runUiThreadTasks();
|
| + Robolectric.runUiThreadTasks();
|
| assertTrue(storage.wasLaunchedRecently());
|
|
|
| long lastUsedTime = mSharedPreferences.getLong(WebappDataStorage.KEY_LAST_USED,
|
| @@ -250,10 +249,10 @@
|
| name, shortName, icon, ShortcutHelper.WEBAPP_SHORTCUT_VERSION, displayMode,
|
| orientation, themeColor, backgroundColor, isIconGenerated);
|
|
|
| - WebappDataStorage storage = WebappDataStorage.open(RuntimeEnvironment.application, "test");
|
| + WebappDataStorage storage = WebappDataStorage.open(Robolectric.application, "test");
|
| storage.updateFromShortcutIntent(shortcutIntent);
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
| - ShadowLooper.runUiThreadTasks();
|
| + Robolectric.runUiThreadTasks();
|
|
|
| assertEquals(action, mSharedPreferences.getString(WebappDataStorage.KEY_ACTION, null));
|
| assertEquals(url, mSharedPreferences.getString(WebappDataStorage.KEY_URL, null));
|
| @@ -302,7 +301,7 @@
|
| // Update again from the intent and ensure that the data is restored.
|
| storage.updateFromShortcutIntent(shortcutIntent);
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
| - ShadowLooper.runUiThreadTasks();
|
| + Robolectric.runUiThreadTasks();
|
|
|
| assertEquals(action, mSharedPreferences.getString(WebappDataStorage.KEY_ACTION, null));
|
| assertEquals(url, mSharedPreferences.getString(WebappDataStorage.KEY_URL, null));
|
|
|