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

Unified Diff: components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java

Issue 1619673004: Add API for custom library loading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months 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
« no previous file with comments | « components/cronet/android/java/src/org/chromium/net/CronetLibraryLoader.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java
index ce07d6bdca5eb22145ced74721f3991f8d7bd926..28d02f35128ca4872c648fa9165c934d5c1f53ea 100644
--- a/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java
+++ b/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java
@@ -960,4 +960,33 @@ public class CronetUrlRequestContextTest extends CronetTestBase {
// Verifies that CronetEngine.Builder config from testCronetEngineBuilderConfig() is properly
// translated to a native UrlRequestContextConfig.
private static native void nativeVerifyUrlRequestContextConfig(long config, String storagePath);
+
+ private static class TestBadLibraryLoader extends CronetEngine.Builder.LibraryLoader {
+ private boolean mWasCalled = false;
+
+ public void loadLibrary(String libName) {
+ // Report that this method was called, but don't load the library
+ mWasCalled = true;
+ }
+
+ boolean wasCalled() {
+ return mWasCalled;
+ }
+ }
+
+ @SmallTest
+ @Feature({"Cronet"})
+ public void testSkipLibraryLoading() throws Exception {
+ CronetEngine.Builder builder = new CronetEngine.Builder(getContext());
+ TestBadLibraryLoader loader = new TestBadLibraryLoader();
+ builder.setLibraryLoader(loader).setLibraryName("cronet_tests");
+ try {
+ // ensureInitialized() calls native code to check the version right after library load
+ // and will error with the message below if library loading was skipped
+ CronetLibraryLoader.ensureInitialized(getContext(), builder);
+ fail("Native library should not be loaded");
+ } catch (UnsatisfiedLinkError e) {
+ assertTrue(loader.wasCalled());
+ }
+ }
}
« no previous file with comments | « components/cronet/android/java/src/org/chromium/net/CronetLibraryLoader.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698