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

Unified Diff: components/policy/android/junit/src/org/chromium/policy/AbstractAppRestrictionsProviderTest.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: components/policy/android/junit/src/org/chromium/policy/AbstractAppRestrictionsProviderTest.java
diff --git a/components/policy/android/junit/src/org/chromium/policy/AbstractAppRestrictionsProviderTest.java b/components/policy/android/junit/src/org/chromium/policy/AbstractAppRestrictionsProviderTest.java
index 4dc6887cb6872d7a342b1d4e58e68b0bfebb15ce..33f26cf3a6a48840b823c010c897156e4d73735d 100644
--- a/components/policy/android/junit/src/org/chromium/policy/AbstractAppRestrictionsProviderTest.java
+++ b/components/policy/android/junit/src/org/chromium/policy/AbstractAppRestrictionsProviderTest.java
@@ -26,10 +26,8 @@
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.ShadowApplication;
-import org.robolectric.shadows.ShadowLooper;
import java.util.concurrent.Executor;
@@ -48,7 +46,7 @@
private class TestExecutor implements Executor {
@Override
public void execute(Runnable command) {
- Robolectric.getBackgroundThreadScheduler().post(command);
+ Robolectric.getBackgroundScheduler().post(command);
}
}
@@ -79,9 +77,9 @@
@Test
public void testRefresh() {
// We want to control precisely when background tasks run
- Robolectric.getBackgroundThreadScheduler().pause();
+ Robolectric.getBackgroundScheduler().pause();
- Context context = RuntimeEnvironment.application;
+ Context context = Robolectric.application;
ContextUtils.initApplicationContextForTests(context);
// Clear the preferences
@@ -110,12 +108,12 @@
verify(combinedProvider, never()).onSettingsAvailable(anyInt(), any(Bundle.class));
// Let the Async task run and return its result.
- Robolectric.getBackgroundThreadScheduler().advanceBy(0);
+ Robolectric.runBackgroundTasks();
// The AsyncTask should now have got the restrictions.
verify(provider).getApplicationRestrictions(anyString());
verify(provider).recordStartTimeHistogram(anyInt());
- ShadowLooper.runUiThreadTasks();
+ Robolectric.runUiThreadTasks();
// The policies should now have been set.
verify(combinedProvider).onSettingsAvailable(0, b1);
@@ -128,8 +126,8 @@
provider.refresh();
verify(combinedProvider, times(2)).onSettingsAvailable(0, b1);
- Robolectric.getBackgroundThreadScheduler().advanceBy(0);
- ShadowLooper.runUiThreadTasks();
+ Robolectric.runBackgroundTasks();
+ Robolectric.runUiThreadTasks();
verify(combinedProvider).onSettingsAvailable(0, b2);
}
@@ -138,10 +136,10 @@
*/
@Test
public void testStartListeningForPolicyChanges() {
- Context context = RuntimeEnvironment.application;
+ Context context = Robolectric.application;
AbstractAppRestrictionsProvider provider = spy(new DummyAppRestrictionsProvider(context));
Intent intent = new Intent("org.chromium.test.policy.Hello");
- ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ ShadowApplication shadowApplication = Robolectric.getShadowApplication();
// If getRestrictionsChangeIntentAction returns null then we should not start a broadcast
// receiver.
@@ -160,10 +158,10 @@
*/
@Test
public void testStopListening() {
- Context context = RuntimeEnvironment.application;
+ Context context = Robolectric.application;
AbstractAppRestrictionsProvider provider = spy(new DummyAppRestrictionsProvider(context));
Intent intent = new Intent("org.chromium.test.policy.Hello");
- ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ ShadowApplication shadowApplication = Robolectric.getShadowApplication();
// First try with null result from getRestrictionsChangeIntentAction, only test here is no
// crash.

Powered by Google App Engine
This is Rietveld 408576698