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

Unified Diff: net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java

Issue 2247143004: Remove app context init from LibraryLoader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better formatting. Created 4 years, 3 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: net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java
diff --git a/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java b/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java
index 3deeb5fd6636875fd561ae53cc6c5f36ab5ba6f9..fd894983d2e15434bf080be24249f50d46061ada 100644
--- a/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java
+++ b/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java
@@ -25,6 +25,7 @@ import android.test.UiThreadTest;
import android.test.suitebuilder.annotation.MediumTest;
import org.chromium.base.ApplicationState;
+import org.chromium.base.ContextUtils;
import org.chromium.base.ThreadUtils;
import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.base.library_loader.LibraryProcessType;
@@ -145,7 +146,7 @@ public class NetworkChangeNotifierTest extends InstrumentationTestCase {
}
// List of networks we're pretending are currently connected.
- private final ArrayList<MockNetwork> mMockNetworks = new ArrayList<MockNetwork>();
+ private final ArrayList<MockNetwork> mMockNetworks = new ArrayList<>();
private boolean mActiveNetworkExists;
private int mNetworkType;
@@ -315,7 +316,7 @@ public class NetworkChangeNotifierTest extends InstrumentationTestCase {
private static class TestNetworkChangeNotifierAutoDetectObserver
implements NetworkChangeNotifierAutoDetect.Observer {
// The list of network changes that have been witnessed.
- final ArrayList<ChangeInfo> mChanges = new ArrayList<ChangeInfo>();
+ final ArrayList<ChangeInfo> mChanges = new ArrayList<>();
@Override
public void onConnectionTypeChanged(int newConnectionType) {}
@@ -424,13 +425,15 @@ public class NetworkChangeNotifierTest extends InstrumentationTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER)
- .ensureInitialized(getInstrumentation().getTargetContext());
+ ContextUtils.initApplicationContext(
+ getInstrumentation().getTargetContext().getApplicationContext());
+ LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Find Network.Network(int netId) using reflection.
mNetworkConstructor = Network.class.getConstructor(Integer.TYPE);
}
ThreadUtils.postOnUiThread(new Runnable() {
+ @Override
public void run() {
createTestNotifier(WatchForChanges.ONLY_WHEN_APP_IN_FOREGROUND);
}
@@ -831,6 +834,7 @@ public class NetworkChangeNotifierTest extends InstrumentationTestCase {
new TestNetworkChangeNotifierAutoDetectObserver();
Callable<NetworkChangeNotifierAutoDetect> callable =
new Callable<NetworkChangeNotifierAutoDetect>() {
+ @Override
public NetworkChangeNotifierAutoDetect call() {
return new NetworkChangeNotifierAutoDetect(
observer, context, new RegistrationPolicyApplicationStatus() {
@@ -846,8 +850,7 @@ public class NetworkChangeNotifierTest extends InstrumentationTestCase {
});
}
};
- FutureTask<NetworkChangeNotifierAutoDetect> task =
- new FutureTask<NetworkChangeNotifierAutoDetect>(callable);
+ FutureTask<NetworkChangeNotifierAutoDetect> task = new FutureTask<>(callable);
ThreadUtils.postOnUiThread(task);
NetworkChangeNotifierAutoDetect ncn = task.get();

Powered by Google App Engine
This is Rietveld 408576698