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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/invalidation/InvalidationServiceTest.java

Issue 2801033002: Revert of Android: Remove GetApplicationContext part 2 (Closed)
Patch Set: Created 3 years, 8 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/javatests/src/org/chromium/chrome/browser/invalidation/InvalidationServiceTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/invalidation/InvalidationServiceTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/invalidation/InvalidationServiceTest.java
index 57d675ea4e33efb9797939881b6d3896b219e871..df4ae0027797468aa52eb817f9a2878a3067dc69 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/invalidation/InvalidationServiceTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/invalidation/InvalidationServiceTest.java
@@ -17,7 +17,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.chromium.base.ContextUtils;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.test.invalidation.IntentSavingContext;
@@ -42,21 +41,18 @@
@Rule
public UiThreadTestRule mUiThreadTestRule = new UiThreadTestRule();
- private IntentSavingContext mAppContext;
+ private IntentSavingContext mContext;
@Before
public void setUp() throws Exception {
mActivityTestRule.loadNativeLibraryAndInitBrowserProcess();
- mAppContext = new IntentSavingContext(InstrumentationRegistry.getInstrumentation()
- .getTargetContext()
- .getApplicationContext());
- // TODO(wnwen): Remove mAppContext and just use application context.
+ mContext = new IntentSavingContext(
+ InstrumentationRegistry.getInstrumentation().getTargetContext());
// We don't want to use the system content resolver, so we override it.
MockSyncContentResolverDelegate delegate = new MockSyncContentResolverDelegate();
// Android master sync can safely always be on.
delegate.setMasterSyncAutomatically(true);
- AndroidSyncSettings.overrideForTests(mAppContext, delegate);
- ContextUtils.initApplicationContextForTests(mAppContext);
+ AndroidSyncSettings.overrideForTests(mContext, delegate);
}
@Test
@@ -66,14 +62,14 @@
mUiThreadTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
- InvalidationService service = InvalidationServiceFactory.getForTest();
+ InvalidationService service = InvalidationServiceFactory.getForTest(mContext);
ObjectId bookmark = ModelTypeHelper.toObjectId(ModelType.BOOKMARKS);
service.setRegisteredObjectIds(new int[] {1, 2, bookmark.getSource()},
new String[] {"a", "b", new String(bookmark.getName())});
- Assert.assertEquals(1, mAppContext.getNumStartedIntents());
+ Assert.assertEquals(1, mContext.getNumStartedIntents());
// Validate destination.
- Intent intent = mAppContext.getStartedIntent(0);
+ Intent intent = mContext.getStartedIntent(0);
validateIntentComponent(intent);
Assert.assertEquals(InvalidationIntentProtocol.ACTION_REGISTER, intent.getAction());

Powered by Google App Engine
This is Rietveld 408576698