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 #ifndef CHROME_FRAME_TEST_NET_FAKE_EXTERNAL_TAB_H_ | 5 #ifndef CHROME_FRAME_TEST_NET_FAKE_EXTERNAL_TAB_H_ |
6 #define CHROME_FRAME_TEST_NET_FAKE_EXTERNAL_TAB_H_ | 6 #define CHROME_FRAME_TEST_NET_FAKE_EXTERNAL_TAB_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/process.h" | 13 #include "base/process.h" |
14 #include "base/win/scoped_handle.h" | 14 #include "base/win/scoped_handle.h" |
15 #include "chrome/browser/browser_process_impl.h" | 15 #include "chrome/browser/browser_process_impl.h" |
16 #include "chrome_frame/test/ie_configurator.h" | |
17 #include "chrome_frame/test/net/process_singleton_subclass.h" | |
18 #include "chrome_frame/test/net/test_automation_provider.h" | 16 #include "chrome_frame/test/net/test_automation_provider.h" |
19 #include "chrome_frame/test/test_server.h" | 17 #include "chrome_frame/test/test_server.h" |
20 #include "chrome_frame/test_utils.h" | 18 #include "chrome_frame/test_utils.h" |
21 #include "content/public/browser/browser_main_parts.h" | 19 #include "content/public/browser/browser_main_parts.h" |
22 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
23 #include "net/base/net_test_suite.h" | 21 #include "net/base/net_test_suite.h" |
24 #include "net/url_request/url_request_test_util.h" | |
25 | 22 |
| 23 class CommandLine; |
26 class FakeBrowserProcessImpl; | 24 class FakeBrowserProcessImpl; |
27 class ProcessSingleton; | 25 class ProcessSingleton; |
| 26 class ScopedCustomUrlRequestTestHttpHost; |
28 | 27 |
29 namespace content { | 28 namespace content { |
30 class NotificationService; | 29 class NotificationService; |
31 } // namespace content | 30 } // namespace content |
32 | 31 |
33 namespace logging_win { | 32 namespace logging_win { |
34 class FileLogger; | 33 class FileLogger; |
35 } // namespace logging_win | 34 } // namespace logging_win |
36 | 35 |
| 36 namespace chrome_frame_test { |
| 37 class IEConfigurator; |
| 38 } // namespace chrome_frame_test |
| 39 |
37 class FakeExternalTab { | 40 class FakeExternalTab { |
38 public: | 41 public: |
39 FakeExternalTab(); | 42 FakeExternalTab(); |
40 virtual ~FakeExternalTab(); | 43 virtual ~FakeExternalTab(); |
41 | 44 |
42 virtual void Initialize(); | 45 virtual void Initialize(); |
43 virtual void InitializePostThreadsCreated(); | 46 virtual void InitializePostThreadsCreated(); |
44 virtual void Shutdown(); | 47 virtual void Shutdown(); |
45 | 48 |
46 const FilePath& user_data() const { | 49 const FilePath& user_data() const { |
47 return user_data_dir_; | 50 return user_data_dir_; |
48 } | 51 } |
49 | 52 |
50 FakeBrowserProcessImpl* browser_process() const; | 53 FakeBrowserProcessImpl* browser_process() const; |
51 | 54 |
52 protected: | 55 protected: |
53 scoped_ptr<FakeBrowserProcessImpl> browser_process_; | 56 scoped_ptr<FakeBrowserProcessImpl> browser_process_; |
54 FilePath overridden_user_dir_; | 57 FilePath overridden_user_dir_; |
55 FilePath user_data_dir_; | 58 FilePath user_data_dir_; |
56 scoped_ptr<ProcessSingleton> process_singleton_; | |
57 scoped_ptr<content::NotificationService> notificaton_service_; | 59 scoped_ptr<content::NotificationService> notificaton_service_; |
58 | 60 |
59 DISALLOW_COPY_AND_ASSIGN(FakeExternalTab); | 61 DISALLOW_COPY_AND_ASSIGN(FakeExternalTab); |
60 }; | 62 }; |
61 | 63 |
62 // The "master class" that spins the UI and test threads. | 64 // The "master class" that spins the UI and test threads. |
63 // | 65 // |
64 // In this weird test executable that pretends to almost be Chrome, it | 66 // In this weird test executable that pretends to almost be Chrome, it |
65 // plays a similar role to ChromeBrowserMainParts, and must fulfill | 67 // plays a similar role to ChromeBrowserMainParts, and must fulfill |
66 // the existing contract between ChromeBrowserMainParts and | 68 // the existing contract between ChromeBrowserMainParts and |
67 // BrowserProcessImpl, i.e. poking BrowserProcessImpl at certain | 69 // BrowserProcessImpl, i.e. poking BrowserProcessImpl at certain |
68 // lifetime events. | 70 // lifetime events. |
69 class CFUrlRequestUnittestRunner | 71 class CFUrlRequestUnittestRunner |
70 : public NetTestSuite, | 72 : public NetTestSuite, |
71 public ProcessSingletonSubclassDelegate, | |
72 public TestAutomationProviderDelegate, | 73 public TestAutomationProviderDelegate, |
73 public content::BrowserMainParts { | 74 public content::BrowserMainParts { |
74 public: | 75 public: |
75 CFUrlRequestUnittestRunner(int argc, char** argv); | 76 CFUrlRequestUnittestRunner(int argc, char** argv); |
76 virtual ~CFUrlRequestUnittestRunner(); | 77 virtual ~CFUrlRequestUnittestRunner(); |
77 | 78 |
78 virtual void StartChromeFrameInHostBrowser(); | 79 virtual void StartChromeFrameInHostBrowser(); |
79 | 80 |
80 virtual void ShutDownHostBrowser(); | 81 virtual void ShutDownHostBrowser(); |
81 | 82 |
82 // Overrides to not call icu initialize | 83 // Overrides to not call icu initialize |
83 virtual void Initialize(); | 84 virtual void Initialize(); |
84 virtual void Shutdown(); | 85 virtual void Shutdown(); |
85 | 86 |
86 // ProcessSingletonSubclassDelegate. | |
87 virtual void OnConnectAutomationProviderToChannel( | |
88 const std::string& channel_id); | |
89 | |
90 // TestAutomationProviderDelegate. | 87 // TestAutomationProviderDelegate. |
91 virtual void OnInitialTabLoaded(); | 88 virtual void OnInitialTabLoaded(); |
92 virtual void OnProviderDestroyed(); | 89 virtual void OnProviderDestroyed(); |
93 | 90 |
94 void StartTests(); | 91 void StartTests(); |
95 | 92 |
96 // Borrowed from TestSuite::Initialize(). | 93 // Borrowed from TestSuite::Initialize(). |
97 void InitializeLogging(); | 94 void InitializeLogging(); |
98 | 95 |
99 int test_result() const { | 96 int test_result() const { |
(...skipping 25 matching lines...) Expand all Loading... |
125 base::ProcessHandle crash_service_; | 122 base::ProcessHandle crash_service_; |
126 DWORD test_thread_id_; | 123 DWORD test_thread_id_; |
127 | 124 |
128 scoped_ptr<ScopedCustomUrlRequestTestHttpHost> override_http_host_; | 125 scoped_ptr<ScopedCustomUrlRequestTestHttpHost> override_http_host_; |
129 | 126 |
130 scoped_ptr<test_server::SimpleWebServer> test_http_server_; | 127 scoped_ptr<test_server::SimpleWebServer> test_http_server_; |
131 test_server::SimpleResponse chrome_frame_html_; | 128 test_server::SimpleResponse chrome_frame_html_; |
132 | 129 |
133 // The fake chrome instance. | 130 // The fake chrome instance. |
134 scoped_ptr<FakeExternalTab> fake_chrome_; | 131 scoped_ptr<FakeExternalTab> fake_chrome_; |
135 scoped_ptr<ProcessSingletonSubclass> pss_subclass_; | |
136 ScopedChromeFrameRegistrar registrar_; | 132 ScopedChromeFrameRegistrar registrar_; |
137 int test_result_; | 133 int test_result_; |
138 | 134 |
139 private: | 135 private: |
140 // Causes HTTP tests to run over an external address rather than 127.0.0.1. | 136 // Causes HTTP tests to run over an external address rather than 127.0.0.1. |
141 // See http://crbug.com/114369 . | 137 // See http://crbug.com/114369 . |
142 void OverrideHttpHost(); | 138 void OverrideHttpHost(); |
143 void StartFileLogger(); | 139 void StartFileLogger(); |
144 void StopFileLogger(bool print); | 140 void StopFileLogger(bool print); |
145 void OnIEShutdownFailure(); | 141 void OnIEShutdownFailure(); |
146 | 142 |
147 void CancelInitializationTimeout(); | 143 void CancelInitializationTimeout(); |
148 void StartInitializationTimeout(); | 144 void StartInitializationTimeout(); |
149 void OnInitializationTimeout(); | 145 void OnInitializationTimeout(); |
150 | 146 |
| 147 bool ProcessSingletonNotificationCallback(const CommandLine& command_line, |
| 148 const FilePath& current_directory); |
| 149 |
151 bool launch_browser_; | 150 bool launch_browser_; |
152 bool prompt_after_setup_; | 151 bool prompt_after_setup_; |
153 bool tests_ran_; | 152 bool tests_ran_; |
| 153 scoped_ptr<ProcessSingleton> process_singleton_; |
154 base::CancelableClosure timeout_closure_; | 154 base::CancelableClosure timeout_closure_; |
155 scoped_ptr<logging_win::FileLogger> file_logger_; | 155 scoped_ptr<logging_win::FileLogger> file_logger_; |
156 FilePath log_file_; | 156 FilePath log_file_; |
157 scoped_ptr<chrome_frame_test::IEConfigurator> ie_configurator_; | 157 scoped_ptr<chrome_frame_test::IEConfigurator> ie_configurator_; |
158 | 158 |
159 DISALLOW_COPY_AND_ASSIGN(CFUrlRequestUnittestRunner); | 159 DISALLOW_COPY_AND_ASSIGN(CFUrlRequestUnittestRunner); |
160 }; | 160 }; |
161 | 161 |
162 #endif // CHROME_FRAME_TEST_NET_FAKE_EXTERNAL_TAB_H_ | 162 #endif // CHROME_FRAME_TEST_NET_FAKE_EXTERNAL_TAB_H_ |
OLD | NEW |