OLD | NEW |
| (Empty) |
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 #ifndef CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_ | |
6 #define CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 | |
11 #include "build/build_config.h" | |
12 | |
13 #include "base/file_util.h" | |
14 #include "base/memory/ref_counted.h" | |
15 #include "base/path_service.h" | |
16 #include "base/test/test_suite.h" | |
17 #include "chrome/app/scoped_ole_initializer.h" | |
18 #include "chrome/browser/chrome_content_browser_client.h" | |
19 #include "chrome/common/chrome_content_client.h" | |
20 #include "testing/gtest/include/gtest/gtest.h" | |
21 #include "net/base/mock_host_resolver.h" | |
22 #include "net/base/net_util.h" | |
23 | |
24 namespace base { | |
25 class StatsTable; | |
26 } | |
27 | |
28 // In many cases it may be not obvious that a test makes a real DNS lookup. | |
29 // We generally don't want to rely on external DNS servers for our tests, | |
30 // so this host resolver procedure catches external queries and returns a failed | |
31 // lookup result. | |
32 class LocalHostResolverProc : public net::HostResolverProc { | |
33 public: | |
34 LocalHostResolverProc(); | |
35 virtual ~LocalHostResolverProc(); | |
36 | |
37 virtual int Resolve(const std::string& host, | |
38 net::AddressFamily address_family, | |
39 net::HostResolverFlags host_resolver_flags, | |
40 net::AddressList* addrlist, | |
41 int* os_error); | |
42 }; | |
43 | |
44 class ChromeTestSuite : public base::TestSuite { | |
45 public: | |
46 ChromeTestSuite(int argc, char** argv); | |
47 virtual ~ChromeTestSuite(); | |
48 | |
49 protected: | |
50 virtual void Initialize(); | |
51 virtual void Shutdown(); | |
52 | |
53 void SetBrowserDirectory(const FilePath& browser_dir) { | |
54 browser_dir_ = browser_dir; | |
55 } | |
56 | |
57 // Client for embedding content in Chrome. | |
58 chrome::ChromeContentClient chrome_content_client_; | |
59 chrome::ChromeContentBrowserClient chrome_browser_content_client_; | |
60 | |
61 base::StatsTable* stats_table_; | |
62 | |
63 // The name used for the stats file so it can be cleaned up on posix during | |
64 // test shutdown. | |
65 std::string stats_filename_; | |
66 | |
67 // Alternative path to browser binaries. | |
68 FilePath browser_dir_; | |
69 | |
70 ScopedOleInitializer ole_initializer_; | |
71 scoped_refptr<LocalHostResolverProc> host_resolver_proc_; | |
72 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_; | |
73 }; | |
74 | |
75 #endif // CHROME_TEST_UNIT_CHROME_TEST_SUITE_H_ | |
OLD | NEW |