1 // Copyright 2011 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_TEST_NET_TEST_SUITE_H_ 6 #define NET_TEST_NET_TEST_SUITE_H_ 7 8 #include <memory> 9 10 #include "base/memory/scoped_refptr.h" 11 #include "base/test/test_suite.h" 12 #include "build/build_config.h" 13 #include "net/dns/mock_host_resolver.h" 14 15 namespace net { 16 class NetworkChangeNotifier; 17 } 18 19 class NetTestSuite : public base::TestSuite { 20 public: 21 NetTestSuite(int argc, char** argv); 22 ~NetTestSuite() override; 23 24 void Initialize() override; 25 26 void Shutdown() override; 27 28 protected: 29 // Called from within Initialize(), but separate so that derived classes 30 // can initialize the NetTestSuite instance only and not 31 // TestSuite::Initialize(). TestSuite::Initialize() performs some global 32 // initialization that can only be done once. 33 void InitializeTestThread(); 34 35 // Same as above, except it does not create a mock 36 // NetworkChangeNotifier. Use this if your test needs to create and 37 // manage its own mock NetworkChangeNotifier, or if your test uses 38 // the production NetworkChangeNotifier. 39 void InitializeTestThreadNoNetworkChangeNotifier(); 40 41 private: 42 std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier_; 43 scoped_refptr<net::RuleBasedHostResolverProc> host_resolver_proc_; 44 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_; 45 }; 46 47 #endif // NET_TEST_NET_TEST_SUITE_H_ 48