[email protected] | dca629c | 2012-03-22 03:40:38 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | d82abb9 | 2010-05-04 17:21:32 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
[email protected] | 4d9bdfaf | 2008-08-26 05:53:57 | [diff] [blame] | 4 | |
[email protected] | 567d30e | 2012-07-13 21:48:29 | [diff] [blame] | 5 | #include "base/metrics/statistics_recorder.h" |
[email protected] | ee881f40 | 2013-10-04 21:51:50 | [diff] [blame] | 6 | #include "base/test/launcher/unit_test_launcher.h" |
[email protected] | 331c251 | 2010-05-04 18:15:56 | [diff] [blame] | 7 | #include "build/build_config.h" |
[email protected] | 4b559b4d | 2011-04-14 17:37:14 | [diff] [blame] | 8 | #include "crypto/nss_util.h" |
[email protected] | 636b825 | 2011-04-08 19:56:54 | [diff] [blame] | 9 | #include "net/socket/client_socket_pool_base.h" |
[email protected] | a4965c88 | 2012-06-13 20:19:44 | [diff] [blame] | 10 | #include "net/socket/ssl_server_socket.h" |
[email protected] | 8753a12 | 2011-10-16 08:05:08 | [diff] [blame] | 11 | #include "net/spdy/spdy_session.h" |
[email protected] | 8efa4ba4 | 2013-03-18 21:14:14 | [diff] [blame] | 12 | #include "net/test/net_test_suite.h" |
[email protected] | 636b825 | 2011-04-08 19:56:54 | [diff] [blame] | 13 | |
[email protected] | 6e4cc8f | 2012-06-27 02:21:02 | [diff] [blame] | 14 | #if defined(OS_ANDROID) |
| 15 | #include "base/android/jni_android.h" |
[email protected] | 847aaab8 | 2014-05-07 14:05:46 | [diff] [blame] | 16 | #include "base/android/jni_registrar.h" |
[email protected] | f12d1e1 | 2013-11-20 07:04:55 | [diff] [blame] | 17 | #include "base/test/test_file_util.h" |
aberent | ec894a5 | 2015-07-09 14:45:53 | [diff] [blame] | 18 | #include "base/test/test_ui_thread_android.h" |
| 19 | #include "net/android/dummy_spnego_authenticator.h" |
[email protected] | 6e4cc8f | 2012-06-27 02:21:02 | [diff] [blame] | 20 | #include "net/android/net_jni_registrar.h" |
asanka | ca61186 | 2015-09-29 20:26:32 | [diff] [blame] | 21 | #endif |
| 22 | |
| 23 | #if defined(USE_ICU_ALTERNATIVES_ON_ANDROID) |
[email protected] | 847aaab8 | 2014-05-07 14:05:46 | [diff] [blame] | 24 | #include "url/android/url_jni_registrar.h" |
[email protected] | 6e4cc8f | 2012-06-27 02:21:02 | [diff] [blame] | 25 | #endif |
| 26 | |
amistry | 7e6ebfdc8 | 2015-02-13 04:19:11 | [diff] [blame] | 27 | #if !defined(OS_ANDROID) && !defined(OS_IOS) |
rockot | c637caf9b | 2016-02-10 09:57:08 | [diff] [blame] | 28 | #include "mojo/edk/embedder/embedder.h" |
amistry | 7e6ebfdc8 | 2015-02-13 04:19:11 | [diff] [blame] | 29 | #endif |
| 30 | |
[email protected] | 636b825 | 2011-04-08 19:56:54 | [diff] [blame] | 31 | using net::internal::ClientSocketPoolBaseHelper; |
[email protected] | 8753a12 | 2011-10-16 08:05:08 | [diff] [blame] | 32 | using net::SpdySession; |
[email protected] | 4d9bdfaf | 2008-08-26 05:53:57 | [diff] [blame] | 33 | |
| 34 | int main(int argc, char** argv) { |
[email protected] | 26a6459 | 2009-12-15 08:04:40 | [diff] [blame] | 35 | // Record histograms, so we can get histograms data in tests. |
[email protected] | fce44c1 | 2012-07-19 19:17:32 | [diff] [blame] | 36 | base::StatisticsRecorder::Initialize(); |
[email protected] | 6e4cc8f | 2012-06-27 02:21:02 | [diff] [blame] | 37 | |
| 38 | #if defined(OS_ANDROID) |
[email protected] | 847aaab8 | 2014-05-07 14:05:46 | [diff] [blame] | 39 | const base::android::RegistrationMethod kNetTestRegisteredMethods[] = { |
asanka | ca61186 | 2015-09-29 20:26:32 | [diff] [blame] | 40 | {"DummySpnegoAuthenticator", |
| 41 | net::android::DummySpnegoAuthenticator::RegisterJni}, |
| 42 | {"NetAndroid", net::android::RegisterJni}, |
| 43 | {"TestFileUtil", base::RegisterContentUriTestUtils}, |
| 44 | {"TestUiThreadAndroid", base::RegisterTestUiThreadAndroid}, |
| 45 | #if defined(USE_ICU_ALTERNATIVES_ON_ANDROID) |
| 46 | {"UrlAndroid", url::android::RegisterJni}, |
| 47 | #endif |
[email protected] | 847aaab8 | 2014-05-07 14:05:46 | [diff] [blame] | 48 | }; |
| 49 | |
[email protected] | 6e4cc8f | 2012-06-27 02:21:02 | [diff] [blame] | 50 | // Register JNI bindings for android. Doing it early as the test suite setup |
| 51 | // may initiate a call to Java. |
[email protected] | 847aaab8 | 2014-05-07 14:05:46 | [diff] [blame] | 52 | base::android::RegisterNativeMethods( |
| 53 | base::android::AttachCurrentThread(), |
| 54 | kNetTestRegisteredMethods, |
| 55 | arraysize(kNetTestRegisteredMethods)); |
[email protected] | 6e4cc8f | 2012-06-27 02:21:02 | [diff] [blame] | 56 | #endif |
| 57 | |
[email protected] | 47c196b | 2009-12-02 20:04:27 | [diff] [blame] | 58 | NetTestSuite test_suite(argc, argv); |
[email protected] | 636b825 | 2011-04-08 19:56:54 | [diff] [blame] | 59 | ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(false); |
[email protected] | d82abb9 | 2010-05-04 17:21:32 | [diff] [blame] | 60 | |
davidben | d558741 | 2014-10-30 21:44:16 | [diff] [blame] | 61 | #if defined(OS_WIN) && !defined(USE_OPENSSL) |
[email protected] | d82abb9 | 2010-05-04 17:21:32 | [diff] [blame] | 62 | // We want to be sure to init NSPR on the main thread. |
[email protected] | 4b559b4d | 2011-04-14 17:37:14 | [diff] [blame] | 63 | crypto::EnsureNSPRInit(); |
[email protected] | d82abb9 | 2010-05-04 17:21:32 | [diff] [blame] | 64 | #endif |
| 65 | |
[email protected] | a4965c88 | 2012-06-13 20:19:44 | [diff] [blame] | 66 | // Enable support for SSL server sockets, which must be done while |
| 67 | // single-threaded. |
| 68 | net::EnableSSLServerSockets(); |
| 69 | |
amistry | 7e6ebfdc8 | 2015-02-13 04:19:11 | [diff] [blame] | 70 | #if !defined(OS_ANDROID) && !defined(OS_IOS) |
rockot | c637caf9b | 2016-02-10 09:57:08 | [diff] [blame] | 71 | mojo::edk::Init(); |
amistry | 7e6ebfdc8 | 2015-02-13 04:19:11 | [diff] [blame] | 72 | #endif |
| 73 | |
[email protected] | d85fe1e | 2013-09-05 18:20:36 | [diff] [blame] | 74 | return base::LaunchUnitTests( |
| 75 | argc, argv, base::Bind(&NetTestSuite::Run, |
| 76 | base::Unretained(&test_suite))); |
[email protected] | 4d9bdfaf | 2008-08-26 05:53:57 | [diff] [blame] | 77 | } |