| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "cronet_url_request_context_config_test.h" | 5 #include "cronet_url_request_context_config_test.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "components/cronet/url_request_context_config.h" | 13 #include "components/cronet/url_request_context_config.h" |
| 14 #include "components/cronet/version.h" |
| 14 #include "jni/CronetUrlRequestContextTest_jni.h" | 15 #include "jni/CronetUrlRequestContextTest_jni.h" |
| 15 | 16 |
| 16 namespace cronet { | 17 namespace cronet { |
| 17 | 18 |
| 18 // Verifies that all the configuration options set by | 19 // Verifies that all the configuration options set by |
| 19 // CronetUrlRequestContextTest.testCronetEngineBuilderConfig | 20 // CronetUrlRequestContextTest.testCronetEngineBuilderConfig |
| 20 // made it from the CronetEngine.Builder to the URLRequestContextConfig. | 21 // made it from the CronetEngine.Builder to the URLRequestContextConfig. |
| 21 static void VerifyUrlRequestContextConfig( | 22 static void VerifyUrlRequestContextConfig( |
| 22 JNIEnv* env, | 23 JNIEnv* env, |
| 23 const JavaParamRef<jclass>& jcaller, | 24 const JavaParamRef<jclass>& jcaller, |
| 24 jlong jurl_request_context_config, | 25 jlong jurl_request_context_config, |
| 25 const JavaParamRef<jstring>& jstorage_path) { | 26 const JavaParamRef<jstring>& jstorage_path) { |
| 26 URLRequestContextConfig* config = | 27 URLRequestContextConfig* config = |
| 27 reinterpret_cast<URLRequestContextConfig*>(jurl_request_context_config); | 28 reinterpret_cast<URLRequestContextConfig*>(jurl_request_context_config); |
| 28 CHECK_EQ(config->enable_spdy, false); | 29 CHECK_EQ(config->enable_spdy, false); |
| 29 CHECK_EQ(config->enable_quic, true); | 30 CHECK_EQ(config->enable_quic, true); |
| 30 CHECK_EQ(config->enable_sdch, true); | 31 CHECK_EQ(config->enable_sdch, true); |
| 31 CHECK_EQ(config->quic_hints.size(), 1u); | 32 CHECK_EQ(config->quic_hints.size(), 1u); |
| 32 CHECK_EQ((*config->quic_hints.begin())->host, "example.com"); | 33 CHECK_EQ((*config->quic_hints.begin())->host, "example.com"); |
| 33 CHECK_EQ((*config->quic_hints.begin())->port, 12); | 34 CHECK_EQ((*config->quic_hints.begin())->port, 12); |
| 34 CHECK_EQ((*config->quic_hints.begin())->alternate_port, 34); | 35 CHECK_EQ((*config->quic_hints.begin())->alternate_port, 34); |
| 36 CHECK_NE(config->quic_user_agent_id.find("Cronet/" CRONET_VERSION), |
| 37 std::string::npos); |
| 35 CHECK_EQ(config->load_disable_cache, false); | 38 CHECK_EQ(config->load_disable_cache, false); |
| 36 CHECK_EQ(config->http_cache, URLRequestContextConfig::HttpCacheType::MEMORY); | 39 CHECK_EQ(config->http_cache, URLRequestContextConfig::HttpCacheType::MEMORY); |
| 37 CHECK_EQ(config->http_cache_max_size, 54321); | 40 CHECK_EQ(config->http_cache_max_size, 54321); |
| 38 CHECK_EQ(config->data_reduction_proxy_key, "abcd"); | 41 CHECK_EQ(config->data_reduction_proxy_key, "abcd"); |
| 39 CHECK_EQ(config->user_agent, "efgh"); | 42 CHECK_EQ(config->user_agent, "efgh"); |
| 40 CHECK_EQ(config->experimental_options, "ijkl"); | 43 CHECK_EQ(config->experimental_options, "ijkl"); |
| 41 CHECK_EQ(config->data_reduction_primary_proxy, "mnop"); | 44 CHECK_EQ(config->data_reduction_primary_proxy, "mnop"); |
| 42 CHECK_EQ(config->data_reduction_fallback_proxy, "qrst"); | 45 CHECK_EQ(config->data_reduction_fallback_proxy, "qrst"); |
| 43 CHECK_EQ(config->data_reduction_secure_proxy_check_url, "uvwx"); | 46 CHECK_EQ(config->data_reduction_secure_proxy_check_url, "uvwx"); |
| 44 CHECK_EQ(config->storage_path, | 47 CHECK_EQ(config->storage_path, |
| 45 base::android::ConvertJavaStringToUTF8(env, jstorage_path)); | 48 base::android::ConvertJavaStringToUTF8(env, jstorage_path)); |
| 46 } | 49 } |
| 47 | 50 |
| 48 bool RegisterCronetUrlRequestContextConfigTest(JNIEnv* env) { | 51 bool RegisterCronetUrlRequestContextConfigTest(JNIEnv* env) { |
| 49 return RegisterNativesImpl(env); | 52 return RegisterNativesImpl(env); |
| 50 } | 53 } |
| 51 | 54 |
| 52 } // namespace cronet | 55 } // namespace cronet |
| OLD | NEW |