Chromium Code Reviews| 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(); |
| + } |
| +} |