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

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

Issue 2866253002: Refactor NetworkChangeNotifierAndroid (Closed)
Patch Set: Add test to make sure NCN doesn't call native functions during startup Created 3 years, 7 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/NetworkChangeNotifierNoNativeTest.java
diff --git a/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierNoNativeTest.java b/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierNoNativeTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..5391a6f9ad326eebbc683d09995f1c2047d14c05
--- /dev/null
+++ b/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierNoNativeTest.java
@@ -0,0 +1,33 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.net;
+
+import android.os.Looper;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.MediumTest;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.chromium.base.test.BaseJUnit4ClassRunner;
+
+/**
+ * Tests for org.chromium.net.NetworkChangeNotifier without native code. This class specifically
+ * does not have a setUp() method that loads native libraries.
+ */
+@RunWith(BaseJUnit4ClassRunner.class)
xunjieli 2017/05/11 16:17:51 Nice! LGTM. Thanks for adding the test.
+public class NetworkChangeNotifierNoNativeTest {
+ /**
+ * Verify NetworkChangeNotifier can initialize without calling into native code. This test
+ * will crash if any native calls are made during NetworkChangeNotifier initialization.
+ */
+ @Test
+ @MediumTest
+ public void testNoNativeDependence() {
+ Looper.prepare();
+ NetworkChangeNotifier.init(InstrumentationRegistry.getInstrumentation().getTargetContext());
+ NetworkChangeNotifier.registerToReceiveNotificationsAlways();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698