Index: chrome_frame/test/net/fake_external_tab.h |
diff --git a/chrome_frame/test/net/fake_external_tab.h b/chrome_frame/test/net/fake_external_tab.h |
index e3eb6b147f732643b46fff9d065eecce48b2bdf8..b0089a818ce7c265114232024c14191e1ed3bc54 100644 |
--- a/chrome_frame/test/net/fake_external_tab.h |
+++ b/chrome_frame/test/net/fake_external_tab.h |
@@ -10,6 +10,7 @@ |
#include "base/file_path.h" |
#include "base/message_loop.h" |
+#include "base/process.h" |
#include "base/win/scoped_handle.h" |
#include "chrome/app/scoped_ole_initializer.h" |
#include "chrome/browser/browser_process_impl.h" |
@@ -17,9 +18,11 @@ |
#include "chrome_frame/test/net/test_automation_provider.h" |
#include "chrome_frame/test/test_server.h" |
#include "chrome_frame/test_utils.h" |
-#include "content/test/test_browser_thread.h" |
+#include "content/public/browser/browser_main_parts.h" |
+#include "content/public/browser/browser_thread.h" |
#include "net/base/net_test_suite.h" |
+class FakeBrowserProcessImpl; |
class ProcessSingleton; |
namespace content { |
@@ -39,27 +42,33 @@ class FakeExternalTab { |
return user_data_dir_; |
} |
- MessageLoopForUI* ui_loop() { |
- return &loop_; |
- } |
+ FakeBrowserProcessImpl* browser_process() const; |
protected: |
- MessageLoopForUI loop_; |
- scoped_ptr<BrowserProcess> browser_process_; |
+ scoped_ptr<FakeBrowserProcessImpl> browser_process_; |
FilePath overridden_user_dir_; |
FilePath user_data_dir_; |
scoped_ptr<ProcessSingleton> process_singleton_; |
scoped_ptr<content::NotificationService> notificaton_service_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(FakeExternalTab); |
}; |
// The "master class" that spins the UI and test threads. |
+// |
+// In this weird test executable that pretends to almost be Chrome, it |
+// plays a similar role to ChromeBrowserMainParts, and must fulfill |
+// the existing contract between ChromeBrowserMainParts and |
+// BrowserProcessImpl, i.e. poking BrowserProcessImpl at certain |
+// lifetime events. |
class CFUrlRequestUnittestRunner |
: public NetTestSuite, |
public ProcessSingletonSubclassDelegate, |
- public TestAutomationProviderDelegate { |
+ public TestAutomationProviderDelegate, |
+ public content::BrowserMainParts { |
public: |
CFUrlRequestUnittestRunner(int argc, char** argv); |
- ~CFUrlRequestUnittestRunner(); |
+ virtual ~CFUrlRequestUnittestRunner(); |
virtual void StartChromeFrameInHostBrowser(); |
@@ -76,8 +85,6 @@ class CFUrlRequestUnittestRunner |
// TestAutomationProviderDelegate. |
virtual void OnInitialTabLoaded(); |
- void RunMainUIThread(); |
- |
void StartTests(); |
// Borrowed from TestSuite::Initialize(). |
@@ -87,6 +94,27 @@ class CFUrlRequestUnittestRunner |
return test_result_; |
} |
+ void set_crash_service(base::ProcessHandle handle) { |
+ crash_service_ = handle; |
+ } |
+ |
+ // content::BrowserMainParts implementation. |
+ virtual void PreEarlyInitialization() OVERRIDE; |
+ virtual void PostEarlyInitialization() OVERRIDE {} |
+ virtual void PreMainMessageLoopStart() OVERRIDE {} |
+ virtual void PostMainMessageLoopStart() OVERRIDE {} |
+ virtual void ToolkitInitialized() OVERRIDE {} |
+ virtual void PreCreateThreads() OVERRIDE; |
+ virtual void PreStartThread(content::BrowserThread::ID identifier) OVERRIDE; |
+ virtual void PostStartThread( |
+ content::BrowserThread::ID identifier) OVERRIDE; |
+ virtual void PreMainMessageLoopRun() OVERRIDE; |
+ virtual bool MainMessageLoopRun(int* result_code) OVERRIDE; |
+ virtual void PostMainMessageLoopRun() OVERRIDE; |
+ virtual void PreStopThread(content::BrowserThread::ID identifier) OVERRIDE; |
+ virtual void PostStopThread(content::BrowserThread::ID identifier) OVERRIDE; |
+ virtual void PostDestroyThreads() OVERRIDE; |
+ |
protected: |
// This is the thread that runs all the UrlRequest tests. |
// Within its context, the Initialize() and Shutdown() routines above |
@@ -97,24 +125,19 @@ class CFUrlRequestUnittestRunner |
protected: |
base::win::ScopedHandle test_thread_; |
+ base::ProcessHandle crash_service_; |
DWORD test_thread_id_; |
scoped_ptr<test_server::SimpleWebServer> test_http_server_; |
test_server::SimpleResponse chrome_frame_html_; |
- // The fake chrome instance. This instance owns the UI message loop |
- // on the main thread. |
- FakeExternalTab fake_chrome_; |
+ // The fake chrome instance. |
+ scoped_ptr<FakeExternalTab> fake_chrome_; |
scoped_ptr<ProcessSingletonSubclass> pss_subclass_; |
- scoped_ptr<content::TestBrowserThread> main_thread_; |
ScopedChromeFrameRegistrar registrar_; |
int test_result_; |
- // TODO(joi): This should be fixed so that this test executable uses |
- // content::BrowserMainParts. As it stands it is a horrible hack. |
- scoped_ptr<content::TestBrowserThread> db_thread_; |
- scoped_ptr<content::TestBrowserThread> file_thread_; |
- scoped_ptr<content::TestBrowserThread> io_thread_; |
+ DISALLOW_COPY_AND_ASSIGN(CFUrlRequestUnittestRunner); |
}; |
#endif // CHROME_FRAME_TEST_NET_FAKE_EXTERNAL_TAB_H_ |