Home | History | Annotate | Download | only in base
      1 // Copyright (c) 2011 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 "net/base/net_test_suite.h"
      6 
      7 #include "base/message_loop.h"
      8 #if defined(USE_NSS)
      9 #include "net/ocsp/nss_ocsp.h"
     10 #endif
     11 
     12 NetTestSuite::NetTestSuite(int argc, char** argv)
     13     : TestSuite(argc, argv) {
     14 }
     15 
     16 NetTestSuite::~NetTestSuite() {}
     17 
     18 void NetTestSuite::Initialize() {
     19   TestSuite::Initialize();
     20   InitializeTestThread();
     21 }
     22 
     23 void NetTestSuite::Shutdown() {
     24 #if defined(USE_NSS)
     25   net::ShutdownOCSP();
     26 #endif
     27 
     28   // We want to destroy this here before the TestSuite continues to tear down
     29   // the environment.
     30   message_loop_.reset();
     31 
     32   TestSuite::Shutdown();
     33 }
     34 
     35 void NetTestSuite::InitializeTestThread() {
     36   network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock());
     37 
     38   host_resolver_proc_ = new net::RuleBasedHostResolverProc(NULL);
     39   scoped_host_resolver_proc_.Init(host_resolver_proc_.get());
     40   // In case any attempts are made to resolve host names, force them all to
     41   // be mapped to localhost.  This prevents DNS queries from being sent in
     42   // the process of running these unit tests.
     43   host_resolver_proc_->AddRule("*", "127.0.0.1");
     44 
     45   message_loop_.reset(new MessageLoopForIO());
     46 }
     47