run_all_unittests.cc revision 6e8cce623b6e4fe0c9e4af605d675dd9d0338c38
1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "base/metrics/statistics_recorder.h"
6#include "base/test/launcher/unit_test_launcher.h"
7#include "build/build_config.h"
8#include "crypto/nss_util.h"
9#include "net/socket/client_socket_pool_base.h"
10#include "net/socket/ssl_server_socket.h"
11#include "net/spdy/spdy_session.h"
12#include "net/test/net_test_suite.h"
13
14#if defined(OS_ANDROID)
15#include "base/android/jni_android.h"
16#include "base/android/jni_registrar.h"
17#include "base/test/test_file_util.h"
18#include "net/android/net_jni_registrar.h"
19#include "url/android/url_jni_registrar.h"
20#endif
21
22#if !defined(OS_IOS)
23#include "net/proxy/proxy_resolver_v8.h"
24#endif
25
26using net::internal::ClientSocketPoolBaseHelper;
27using net::SpdySession;
28
29int main(int argc, char** argv) {
30  // Record histograms, so we can get histograms data in tests.
31  base::StatisticsRecorder::Initialize();
32
33#if defined(OS_ANDROID)
34  const base::android::RegistrationMethod kNetTestRegisteredMethods[] = {
35    {"NetAndroid", net::android::RegisterJni},
36    {"TestFileUtil", base::RegisterContentUriTestUtils},
37    {"UrlAndroid", url::android::RegisterJni},
38  };
39
40  // Register JNI bindings for android. Doing it early as the test suite setup
41  // may initiate a call to Java.
42  base::android::RegisterNativeMethods(
43      base::android::AttachCurrentThread(),
44      kNetTestRegisteredMethods,
45      arraysize(kNetTestRegisteredMethods));
46#endif
47
48  NetTestSuite test_suite(argc, argv);
49  ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(false);
50
51#if defined(OS_WIN)
52  // We want to be sure to init NSPR on the main thread.
53  crypto::EnsureNSPRInit();
54#endif
55
56  // Enable support for SSL server sockets, which must be done while
57  // single-threaded.
58  net::EnableSSLServerSockets();
59
60#if !defined(OS_IOS)
61  net::ProxyResolverV8::EnsureIsolateCreated();
62#endif
63
64  return base::LaunchUnitTests(
65      argc, argv, base::Bind(&NetTestSuite::Run,
66                             base::Unretained(&test_suite)));
67}
68