OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.net; | 5 package org.chromium.net; |
6 | 6 |
7 import static org.chromium.base.CollectionUtil.newHashSet; | 7 import static org.chromium.base.CollectionUtil.newHashSet; |
8 | 8 |
9 import android.content.Context; | 9 import android.content.Context; |
10 import android.content.ContextWrapper; | 10 import android.content.ContextWrapper; |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 builder.setDataReductionProxyOptions("mnop", "qrst", "uvwx"); | 953 builder.setDataReductionProxyOptions("mnop", "qrst", "uvwx"); |
954 builder.setStoragePath(CronetTestFramework.getTestStorage(getContext()))
; | 954 builder.setStoragePath(CronetTestFramework.getTestStorage(getContext()))
; |
955 nativeVerifyUrlRequestContextConfig( | 955 nativeVerifyUrlRequestContextConfig( |
956 CronetUrlRequestContext.createNativeUrlRequestContextConfig(buil
der), | 956 CronetUrlRequestContext.createNativeUrlRequestContextConfig(buil
der), |
957 CronetTestFramework.getTestStorage(getContext())); | 957 CronetTestFramework.getTestStorage(getContext())); |
958 } | 958 } |
959 | 959 |
960 // Verifies that CronetEngine.Builder config from testCronetEngineBuilderCon
fig() is properly | 960 // Verifies that CronetEngine.Builder config from testCronetEngineBuilderCon
fig() is properly |
961 // translated to a native UrlRequestContextConfig. | 961 // translated to a native UrlRequestContextConfig. |
962 private static native void nativeVerifyUrlRequestContextConfig(long config,
String storagePath); | 962 private static native void nativeVerifyUrlRequestContextConfig(long config,
String storagePath); |
963 | |
964 private static class TestBadLibraryLoader extends CronetEngine.Builder.Libra
ryLoader { | |
965 private boolean mWasCalled = false; | |
966 | |
967 public void loadLibrary(String libName) { | |
968 // Report that this method was called, but don't load the library | |
969 mWasCalled = true; | |
970 } | |
971 | |
972 boolean wasCalled() { | |
973 return mWasCalled; | |
974 } | |
975 } | |
976 | |
977 @SmallTest | |
978 @Feature({"Cronet"}) | |
979 public void testSkipLibraryLoading() throws Exception { | |
980 CronetEngine.Builder builder = new CronetEngine.Builder(getContext()); | |
981 TestBadLibraryLoader loader = new TestBadLibraryLoader(); | |
982 builder.setLibraryLoader(loader).setLibraryName("cronet_tests"); | |
983 try { | |
984 // ensureInitialized() calls native code to check the version right
after library load | |
985 // and will error with the message below if library loading was skip
ped | |
986 CronetLibraryLoader.ensureInitialized(getContext(), builder); | |
987 fail("Native library should not be loaded"); | |
988 } catch (UnsatisfiedLinkError e) { | |
989 assertTrue(e.getMessage().contains( | |
990 "No implementation found for java.lang.String org.chromium.n
et")); | |
991 assertTrue(loader.wasCalled()); | |
992 } | |
993 } | |
994 } | 963 } |
OLD | NEW |