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

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

Issue 2561803002: Cronet smoke tests (Closed)
Patch Set: Got rid of //base/android/proguard/chromium_apk.flags proguard 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/BrokenNativeLibraryTest.java
diff --git a/components/cronet/android/test/smoketests/src/org/chromium/net/smoke/BrokenNativeLibraryTest.java b/components/cronet/android/test/smoketests/src/org/chromium/net/smoke/BrokenNativeLibraryTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..d7ff638ae6b899aface2401078189e3189313881
--- /dev/null
+++ b/components/cronet/android/test/smoketests/src/org/chromium/net/smoke/BrokenNativeLibraryTest.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.test.suitebuilder.annotation.Smoke;
+
+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 BrokenNativeLibraryTest extends CronetTestBase {
mef 2016/12/20 20:17:45 Nit: Maybe s/Broken/Missing/ as we are actually te
kapishnikov 2016/12/22 19:21:13 Done.
+ /**
+ * If the ".so" file is absent, instantiating the Cronet engine should throw an exception.
mef 2016/12/20 20:17:45 nit: Maybe s/absent/missing/ for consistency?
kapishnikov 2016/12/22 19:21:13 Done.
+ */
+ @Smoke
+ 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.
+ */
+ @Smoke
+ 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