| 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 70bcb192a3c2c5009b63762365783a76518f5d63..81e01bf3eb392fe03ccedf64795a48d336ba29a1 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
|
| @@ -21,8 +21,9 @@ import org.chromium.testing.local.LocalRobolectricTestRunner;
|
| import org.junit.Before;
|
| import org.junit.Test;
|
| import org.junit.runner.RunWith;
|
| -import org.robolectric.Robolectric;
|
| +import org.robolectric.RuntimeEnvironment;
|
| import org.robolectric.annotation.Config;
|
| +import org.robolectric.shadows.ShadowLooper;
|
|
|
| import java.util.concurrent.TimeUnit;
|
|
|
| @@ -70,7 +71,7 @@ public class WebappDataStorageTest {
|
|
|
| @Before
|
| public void setUp() throws Exception {
|
| - mSharedPreferences = Robolectric.application
|
| + mSharedPreferences = RuntimeEnvironment.application
|
| .getSharedPreferences("webapp_test", Context.MODE_PRIVATE);
|
|
|
| // Set the last_used as if the web app had been registered by WebappRegistry.
|
| @@ -104,10 +105,10 @@ public class WebappDataStorageTest {
|
| public void testLastUsedRetrieval() throws Exception {
|
| mSharedPreferences.edit().putLong(WebappDataStorage.KEY_LAST_USED, 100L).apply();
|
|
|
| - WebappDataStorage.getLastUsedTime(Robolectric.application, "test",
|
| + WebappDataStorage.getLastUsedTime(RuntimeEnvironment.application, "test",
|
| new FetchCallback<Long>(new Long(100L)));
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
| - Robolectric.runUiThreadTasks();
|
| + ShadowLooper.runUiThreadTasks();
|
|
|
| assertTrue(mCallbackCalled);
|
| }
|
| @@ -119,8 +120,8 @@ public class WebappDataStorageTest {
|
| mSharedPreferences.edit()
|
| .putString(WebappDataStorage.KEY_SPLASH_ICON,
|
| ShortcutHelper.encodeBitmapAsString(expected))
|
| - .apply();
|
| - WebappDataStorage.open(Robolectric.application, "test")
|
| + .commit();
|
| + WebappDataStorage.open(RuntimeEnvironment.application, "test")
|
| .getSplashScreenImage(new WebappDataStorage.FetchCallback<Bitmap>() {
|
| @Override
|
| public void onDataRetrieved(Bitmap actual) {
|
| @@ -133,7 +134,7 @@ public class WebappDataStorageTest {
|
| }
|
| });
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
| - Robolectric.runUiThreadTasks();
|
| + ShadowLooper.runUiThreadTasks();
|
|
|
| assertTrue(mCallbackCalled);
|
| }
|
| @@ -142,7 +143,7 @@ public class WebappDataStorageTest {
|
| @Feature({"Webapp"})
|
| public void testSplashImageUpdate() throws Exception {
|
| final Bitmap expectedImage = createBitmap();
|
| - WebappDataStorage.open(Robolectric.application, "test")
|
| + WebappDataStorage.open(RuntimeEnvironment.application, "test")
|
| .updateSplashScreenImage(expectedImage);
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
|
|
| @@ -156,10 +157,10 @@ public class WebappDataStorageTest {
|
| final String scope = "http://drive.google.com";
|
| mSharedPreferences.edit().putString(WebappDataStorage.KEY_SCOPE, scope).apply();
|
|
|
| - WebappDataStorage.getScope(Robolectric.application, "test",
|
| + WebappDataStorage.getScope(RuntimeEnvironment.application, "test",
|
| new FetchCallback<String>(scope));
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
| - Robolectric.runUiThreadTasks();
|
| + ShadowLooper.runUiThreadTasks();
|
|
|
| assertTrue(mCallbackCalled);
|
| }
|
| @@ -170,10 +171,10 @@ public class WebappDataStorageTest {
|
| final String url = "https://www.google.com";
|
| mSharedPreferences.edit().putString(WebappDataStorage.KEY_URL, url).apply();
|
|
|
| - WebappDataStorage.getUrl(Robolectric.application, "test",
|
| + WebappDataStorage.getUrl(RuntimeEnvironment.application, "test",
|
| new FetchCallback<String>(url));
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
| - Robolectric.runUiThreadTasks();
|
| + ShadowLooper.runUiThreadTasks();
|
|
|
| assertTrue(mCallbackCalled);
|
| }
|
| @@ -185,15 +186,15 @@ public class WebappDataStorageTest {
|
| WebappDataStorage.setClockForTests(clock);
|
|
|
| // Opening a data storage doesn't count as a launch.
|
| - WebappDataStorage storage = WebappDataStorage.open(Robolectric.application, "test");
|
| + WebappDataStorage storage = WebappDataStorage.open(RuntimeEnvironment.application, "test");
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
| - Robolectric.runUiThreadTasks();
|
| + ShadowLooper.runUiThreadTasks();
|
| assertTrue(!storage.wasLaunchedRecently());
|
|
|
| // When the last used time is updated, then it is a launch.
|
| storage.updateLastUsedTime();
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
| - Robolectric.runUiThreadTasks();
|
| + ShadowLooper.runUiThreadTasks();
|
| assertTrue(storage.wasLaunchedRecently());
|
|
|
| long lastUsedTime = mSharedPreferences.getLong(WebappDataStorage.KEY_LAST_USED,
|
| @@ -256,10 +257,10 @@ public class WebappDataStorageTest {
|
| };
|
| Intent shortcutIntent = shortcutIntentTask.execute().get();
|
|
|
| - WebappDataStorage storage = WebappDataStorage.open(Robolectric.application, "test");
|
| + WebappDataStorage storage = WebappDataStorage.open(RuntimeEnvironment.application, "test");
|
| storage.updateFromShortcutIntent(shortcutIntent);
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
| - Robolectric.runUiThreadTasks();
|
| + ShadowLooper.runUiThreadTasks();
|
|
|
| assertEquals(action, mSharedPreferences.getString(WebappDataStorage.KEY_ACTION, null));
|
| assertEquals(url, mSharedPreferences.getString(WebappDataStorage.KEY_URL, null));
|
| @@ -308,7 +309,7 @@ public class WebappDataStorageTest {
|
| // Update again from the intent and ensure that the data is restored.
|
| storage.updateFromShortcutIntent(shortcutIntent);
|
| BackgroundShadowAsyncTask.runBackgroundTasks();
|
| - Robolectric.runUiThreadTasks();
|
| + ShadowLooper.runUiThreadTasks();
|
|
|
| assertEquals(action, mSharedPreferences.getString(WebappDataStorage.KEY_ACTION, null));
|
| assertEquals(url, mSharedPreferences.getString(WebappDataStorage.KEY_URL, null));
|
|
|