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

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

Issue 2239003002: Revert of [Android] Update all Robolectric tests to Robolectric 3.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 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));

Powered by Google App Engine
This is Rietveld 408576698