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

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/ContentViewMiscTest.java

Issue 2828353002: Android: Remove GetApplicationContext part 3 (Closed)
Patch Set: Fix android webview tests 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: android_webview/javatests/src/org/chromium/android_webview/test/ContentViewMiscTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/ContentViewMiscTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/ContentViewMiscTest.java
index afec3f4060f27b229873609d22153623d7dd675f..926a818d4ffb8aa881601eb884c307b524c713e2 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/ContentViewMiscTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/ContentViewMiscTest.java
@@ -5,16 +5,16 @@
package org.chromium.android_webview.test;
import android.content.BroadcastReceiver;
-import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Proxy;
import android.support.test.filters.SmallTest;
-import android.test.mock.MockContext;
import org.chromium.android_webview.AwContents;
import org.chromium.android_webview.AwContentsStatics;
+import org.chromium.base.ContextUtils;
import org.chromium.base.annotations.SuppressFBWarnings;
+import org.chromium.base.test.util.AdvancedMockContext;
import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.ContentViewStatics;
@@ -60,19 +60,15 @@ public class ContentViewMiscTest extends AwTestBase {
// Set up mock contexts to use with the listener
final AtomicReference<BroadcastReceiver> receiverRef =
new AtomicReference<BroadcastReceiver>();
- final MockContext appContext = new MockContext() {
+ final AdvancedMockContext appContext = new AdvancedMockContext(
+ getInstrumentation().getTargetContext().getApplicationContext()) {
@Override
public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
receiverRef.set(receiver);
return null;
}
};
- final MockContext context = new MockContext() {
- @Override
- public Context getApplicationContext() {
- return appContext;
- }
- };
+ ContextUtils.initApplicationContextForTests(appContext);
// Set up a delegate so we know when native code is about to get
// informed of a proxy change.
@@ -87,7 +83,7 @@ public class ContentViewMiscTest extends AwTestBase {
intent.setAction(Proxy.PROXY_CHANGE_ACTION);
// Create the listener that's going to be used for the test
- ProxyChangeListener listener = ProxyChangeListener.create(context);
+ ProxyChangeListener listener = ProxyChangeListener.create();
listener.setDelegateForTesting(delegate);
listener.start(0);
@@ -95,19 +91,19 @@ public class ContentViewMiscTest extends AwTestBase {
// Make sure everything works by default
proxyChanged.set(false);
- receiverRef.get().onReceive(context, intent);
+ receiverRef.get().onReceive(appContext, intent);
assertEquals(true, proxyChanged.get());
// Now disable platform notifications and make sure we don't notify
// native code.
proxyChanged.set(false);
ContentViewStatics.disablePlatformNotifications();
- receiverRef.get().onReceive(context, intent);
+ receiverRef.get().onReceive(appContext, intent);
assertEquals(false, proxyChanged.get());
// Now re-enable notifications to make sure they work again.
ContentViewStatics.enablePlatformNotifications();
- receiverRef.get().onReceive(context, intent);
+ receiverRef.get().onReceive(appContext, intent);
assertEquals(true, proxyChanged.get());
}
}

Powered by Google App Engine
This is Rietveld 408576698