| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "net/test/net_test_suite.h" | 5 #include "net/test/net_test_suite.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "net/base/network_change_notifier.h" | 8 #include "net/base/network_change_notifier.h" |
| 9 #include "net/http/http_stream_factory.h" | 9 #include "net/http/http_stream_factory.h" |
| 10 #include "net/spdy/spdy_session.h" | 10 #include "net/spdy/spdy_session.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 #if defined(USE_NSS_CERTS) | 13 #if defined(USE_NSS_CERTS) |
| 14 #include "net/cert_net/nss_ocsp.h" | 14 #include "net/cert_net/nss_ocsp.h" |
| 15 #endif | 15 #endif |
| 16 | 16 |
| 17 class StaticReset : public ::testing::EmptyTestEventListener { | |
| 18 void OnTestStart(const ::testing::TestInfo& test_info) override { | |
| 19 net::HttpStreamFactory::ResetStaticSettingsToInit(); | |
| 20 } | |
| 21 }; | |
| 22 | |
| 23 NetTestSuite::NetTestSuite(int argc, char** argv) | 17 NetTestSuite::NetTestSuite(int argc, char** argv) |
| 24 : TestSuite(argc, argv) { | 18 : TestSuite(argc, argv) { |
| 25 } | 19 } |
| 26 | 20 |
| 27 NetTestSuite::~NetTestSuite() {} | 21 NetTestSuite::~NetTestSuite() {} |
| 28 | 22 |
| 29 void NetTestSuite::Initialize() { | 23 void NetTestSuite::Initialize() { |
| 30 TestSuite::Initialize(); | 24 TestSuite::Initialize(); |
| 31 ::testing::UnitTest::GetInstance()->listeners().Append(new StaticReset()); | |
| 32 InitializeTestThread(); | 25 InitializeTestThread(); |
| 33 } | 26 } |
| 34 | 27 |
| 35 void NetTestSuite::Shutdown() { | 28 void NetTestSuite::Shutdown() { |
| 36 #if defined(USE_NSS_CERTS) | 29 #if defined(USE_NSS_CERTS) |
| 37 net::ShutdownNSSHttpIO(); | 30 net::ShutdownNSSHttpIO(); |
| 38 #endif | 31 #endif |
| 39 | 32 |
| 40 // We want to destroy this here before the TestSuite continues to tear down | 33 // We want to destroy this here before the TestSuite continues to tear down |
| 41 // the environment. | 34 // the environment. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 53 void NetTestSuite::InitializeTestThreadNoNetworkChangeNotifier() { | 46 void NetTestSuite::InitializeTestThreadNoNetworkChangeNotifier() { |
| 54 host_resolver_proc_ = new net::RuleBasedHostResolverProc(NULL); | 47 host_resolver_proc_ = new net::RuleBasedHostResolverProc(NULL); |
| 55 scoped_host_resolver_proc_.Init(host_resolver_proc_.get()); | 48 scoped_host_resolver_proc_.Init(host_resolver_proc_.get()); |
| 56 // In case any attempts are made to resolve host names, force them all to | 49 // In case any attempts are made to resolve host names, force them all to |
| 57 // be mapped to localhost. This prevents DNS queries from being sent in | 50 // be mapped to localhost. This prevents DNS queries from being sent in |
| 58 // the process of running these unit tests. | 51 // the process of running these unit tests. |
| 59 host_resolver_proc_->AddRule("*", "127.0.0.1"); | 52 host_resolver_proc_->AddRule("*", "127.0.0.1"); |
| 60 | 53 |
| 61 message_loop_.reset(new base::MessageLoopForIO()); | 54 message_loop_.reset(new base::MessageLoopForIO()); |
| 62 } | 55 } |
| OLD | NEW |