OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef NET_BASE_NET_TEST_SUITE_H_ | 5 #ifndef NET_BASE_NET_TEST_SUITE_H_ |
6 #define NET_BASE_NET_TEST_SUITE_H_ | 6 #define NET_BASE_NET_TEST_SUITE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/test/test_suite.h" | 10 #include "base/test/test_suite.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "net/base/mock_host_resolver.h" | 12 #include "net/base/mock_host_resolver.h" |
13 | 13 |
14 class MessageLoop; | 14 class MessageLoop; |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 class NetworkChangeNotifier; | 17 class NetworkChangeNotifier; |
18 } | 18 } |
19 | 19 |
20 class NetTestSuite : public base::TestSuite { | 20 class NetTestSuite : public base::TestSuite { |
21 public: | 21 public: |
22 NetTestSuite(int argc, char** argv); | 22 NetTestSuite(int argc, char** argv); |
23 virtual ~NetTestSuite(); | 23 virtual ~NetTestSuite(); |
24 | 24 |
25 virtual void Initialize() OVERRIDE; | 25 virtual void Initialize() OVERRIDE; |
26 | 26 |
27 virtual void Shutdown() OVERRIDE; | 27 virtual void Shutdown() OVERRIDE; |
28 | 28 |
29 protected: | 29 protected: |
| 30 // This constructor is only accessible to specialized net test |
| 31 // implementations which need to control the creation of an AtExitManager |
| 32 // instance for the duration of the test. |
| 33 NetTestSuite(int argc, char** argv, bool create_at_exit_manager); |
30 | 34 |
31 // Called from within Initialize(), but separate so that derived classes | 35 // Called from within Initialize(), but separate so that derived classes |
32 // can initialize the NetTestSuite instance only and not | 36 // can initialize the NetTestSuite instance only and not |
33 // TestSuite::Initialize(). TestSuite::Initialize() performs some global | 37 // TestSuite::Initialize(). TestSuite::Initialize() performs some global |
34 // initialization that can only be done once. | 38 // initialization that can only be done once. |
35 void InitializeTestThread(); | 39 void InitializeTestThread(); |
36 | 40 |
37 // Same as above, except it does not create a mock | 41 // Same as above, except it does not create a mock |
38 // NetworkChangeNotifier. Use this if your test needs to create and | 42 // NetworkChangeNotifier. Use this if your test needs to create and |
39 // manage its own mock NetworkChangeNotifier, or if your test uses | 43 // manage its own mock NetworkChangeNotifier, or if your test uses |
40 // the production NetworkChangeNotifier. | 44 // the production NetworkChangeNotifier. |
41 void InitializeTestThreadNoNetworkChangeNotifier(); | 45 void InitializeTestThreadNoNetworkChangeNotifier(); |
42 | 46 |
43 private: | 47 private: |
44 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 48 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
45 scoped_ptr<MessageLoop> message_loop_; | 49 scoped_ptr<MessageLoop> message_loop_; |
46 scoped_refptr<net::RuleBasedHostResolverProc> host_resolver_proc_; | 50 scoped_refptr<net::RuleBasedHostResolverProc> host_resolver_proc_; |
47 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_; | 51 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_; |
48 }; | 52 }; |
49 | 53 |
50 #endif // NET_BASE_NET_TEST_SUITE_H_ | 54 #endif // NET_BASE_NET_TEST_SUITE_H_ |
OLD | NEW |