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

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

Issue 11628008: Provide NetworkChangeNotifierAndroid with the actual initial connection type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Ryan's comments + fix Java comment Created 7 years, 12 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 9bc633243b130ea74a82d59b8883fe43b81fee9d..0bea726d192dc1d6add6d32d6572457d3898de5c 100644
--- a/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java
+++ b/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java
@@ -40,15 +40,16 @@ public class NetworkChangeNotifierTest extends InstrumentationTestCase {
private int mNetworkType;
private int mNetworkSubtype;
- MockConnectivityManagerDelegate() {
- super(null);
- }
-
@Override
boolean activeNetworkExists() {
return mActiveNetworkExists;
}
+ @Override
+ boolean isConnected() {
+ return getNetworkType() != NetworkChangeNotifier.CONNECTION_NONE;
+ }
+
void setActiveNetworkExists(boolean networkExists) {
mActiveNetworkExists = networkExists;
}
@@ -82,7 +83,7 @@ public class NetworkChangeNotifierTest extends InstrumentationTestCase {
public void testNetworkChangeNotifierJavaObservers() throws InterruptedException {
// Create a new notifier that doesn't have a native-side counterpart.
Context context = getInstrumentation().getTargetContext();
- NetworkChangeNotifier.createInstance(context, 0);
+ NetworkChangeNotifier.resetInstanceForTests(context);
NetworkChangeNotifier.setAutoDetectConnectivityState(true);
NetworkChangeNotifierAutoDetect receiver = NetworkChangeNotifier.getAutoDetectorForTest();
@@ -109,7 +110,6 @@ public class NetworkChangeNotifierTest extends InstrumentationTestCase {
connectivityDelegate.setActiveNetworkExists(false);
connectivityDelegate.setNetworkType(NetworkChangeNotifier.CONNECTION_NONE);
Intent noConnectivityIntent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
- noConnectivityIntent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, true);
receiver.onReceive(getInstrumentation().getTargetContext(), noConnectivityIntent);
assertTrue(observer.hasReceivedNotification());
}

Powered by Google App Engine
This is Rietveld 408576698