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

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/superviseduser/SupervisedUserContentProviderUnitTest.java

Issue 2710343003: Update Robolectric to 3.2.2 (Closed)
Patch Set: Update Robolectric to 3.2 Created 3 years, 9 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/superviseduser/SupervisedUserContentProviderUnitTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/superviseduser/SupervisedUserContentProviderUnitTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/superviseduser/SupervisedUserContentProviderUnitTest.java
index bab8d55ffe0f81b183533584d87a44ef668acc19..df30f67f2f08eabc26effa24826316cb3fb0b2fd 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/superviseduser/SupervisedUserContentProviderUnitTest.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/superviseduser/SupervisedUserContentProviderUnitTest.java
@@ -16,6 +16,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.accounts.Account;
+import android.content.ContentProvider;
import android.content.Context;
import org.junit.After;
@@ -28,6 +29,9 @@ import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+import org.robolectric.shadows.ShadowContentProvider;
import org.chromium.base.Callback;
import org.chromium.base.ContextUtils;
@@ -55,8 +59,21 @@ public class SupervisedUserContentProviderUnitTest {
private static final String DEFAULT_CALLING_PACKAGE = "com.example.some.app";
+ /**
+ * Robolectric ShadowContentProvider that implements getContext.
+ */
+ @Implements(ContentProvider.class)
+ public static class MyShadowContentProvider extends ShadowContentProvider {
nyquist 2017/03/14 21:20:37 It seems like we are calling getContext() a few pl
mikecase (-- gone --) 2017/03/14 22:07:07 So for some info, in this commit they removed getC
nyquist 2017/03/14 22:17:30 Right; but it seems like they are attaching the co
+ @Implementation
+ public final Context getContext() {
+ return RuntimeEnvironment.application;
+ }
+ }
+
@Before
public void setUp() {
+ ContextUtils.initApplicationContextForTests(RuntimeEnvironment.application);
+
// Ensure clean state (in particular not signed in).
ContextUtils.getAppSharedPreferences().edit().clear().apply();
@@ -183,6 +200,7 @@ public class SupervisedUserContentProviderUnitTest {
eq("url"));
}
+ @Config(shadows = MyShadowContentProvider.class)
@Test
public void testShouldProceed_withStartupSignedIn() throws ProcessInitException {
// Set up a signed in user
@@ -202,6 +220,7 @@ public class SupervisedUserContentProviderUnitTest {
eq("url"));
}
+ @Config(shadows = MyShadowContentProvider.class)
@SuppressWarnings("unchecked")
@Test
public void testShouldProceed_notSignedIn() throws ProcessInitException {
@@ -229,6 +248,7 @@ public class SupervisedUserContentProviderUnitTest {
eq("url"));
}
+ @Config(shadows = MyShadowContentProvider.class)
@Test
public void testShouldProceed_cannotSignIn() {
// Mock things called during startup

Powered by Google App Engine
This is Rietveld 408576698