| 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 {
|
| + /**
|
| + * If the ".so" file is absent, instantiating the Cronet engine should throw an exception.
|
| + */
|
| + @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);
|
| + }
|
| +}
|
|
|