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

Unified Diff: components/cronet/android/test/smoketests/src/org/chromium/net/smoke/MissingNativeLibraryTest.java

Issue 2561803002: Cronet smoke tests (Closed)
Patch Set: Moved to android.support.test.filters & added support for network-security-config Created 4 years 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: components/cronet/android/test/smoketests/src/org/chromium/net/smoke/MissingNativeLibraryTest.java
diff --git a/components/cronet/android/test/smoketests/src/org/chromium/net/smoke/MissingNativeLibraryTest.java b/components/cronet/android/test/smoketests/src/org/chromium/net/smoke/MissingNativeLibraryTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..23803b7ef28dbd349c94d39f4469c74ea0ab3ec7
--- /dev/null
+++ b/components/cronet/android/test/smoketests/src/org/chromium/net/smoke/MissingNativeLibraryTest.java
@@ -0,0 +1,48 @@
+// Copyright 2016 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.smoke;
+
+import android.support.test.filters.SmallTest;
+
+import org.chromium.net.CronetEngine;
+import org.chromium.net.ExperimentalCronetEngine;
+
+/**
+ * Tests scenarios when the native shared library file is missing in the APK or was built for a
+ * wrong architecture.
+ */
+public class MissingNativeLibraryTest extends CronetSmokeTestCase {
+ /**
+ * If the ".so" file is missing, instantiating the Cronet engine should throw an exception.
+ */
+ @SmallTest
+ public void testExceptionWhenSoFileIsAbsent() throws Exception {
+ ExperimentalCronetEngine.Builder builder =
+ new ExperimentalCronetEngine.Builder(getContext());
+ try {
+ builder.build();
+ fail("Expected exception since the shared library '.so' file is absent");
+ } catch (Throwable t) {
+ // Find the root cause.
+ while (t.getCause() != null) {
+ t = t.getCause();
+ }
+ assertEquals(UnsatisfiedLinkError.class, t.getClass());
+ }
+ }
+
+ /**
+ * Tests the enableLegacyMode API that allows the embedder to force JavaCronetEngine
+ * instantiation even when the native Cronet engine implementation is available.
+ */
+ @SmallTest
+ public void testEnableLegacyMode() throws Exception {
+ ExperimentalCronetEngine.Builder builder =
+ new ExperimentalCronetEngine.Builder(getContext());
+ builder.enableLegacyMode(true);
+ CronetEngine engine = builder.build();
+ assertJavaEngine(engine);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698