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