OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 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_FRAME_TEST_NET_FAKE_EXTERNAL_TAB_H_ |
| 6 #define CHROME_FRAME_TEST_NET_FAKE_EXTERNAL_TAB_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/file_path.h" |
| 11 #include "base/message_loop.h" |
| 12 |
| 13 #include "chrome/app/scoped_ole_initializer.h" |
| 14 #include "chrome/browser/browser_process_impl.h" |
| 15 |
| 16 #include "chrome_frame/test/test_server.h" |
| 17 #include "chrome_frame/test/net/test_automation_provider.h" |
| 18 #include "chrome_frame/test/net/process_singleton_subclass.h" |
| 19 |
| 20 #include "net/base/net_test_suite.h" |
| 21 |
| 22 class ProcessSingleton; |
| 23 |
| 24 class FakeExternalTab { |
| 25 public: |
| 26 FakeExternalTab(); |
| 27 ~FakeExternalTab(); |
| 28 |
| 29 virtual std::wstring GetProfileName(); |
| 30 |
| 31 virtual std::wstring GetProfilePath(); |
| 32 virtual void Initialize(); |
| 33 virtual void Shutdown(); |
| 34 |
| 35 const FilePath& user_data() const { |
| 36 return user_data_dir_; |
| 37 } |
| 38 |
| 39 MessageLoopForUI* ui_loop() { |
| 40 return &loop_; |
| 41 } |
| 42 |
| 43 protected: |
| 44 MessageLoopForUI loop_; |
| 45 scoped_ptr<BrowserProcess> browser_process_; |
| 46 FilePath overridden_user_dir_; |
| 47 FilePath user_data_dir_; |
| 48 ScopedOleInitializer ole_initializer_; // For RegisterDropTarget etc to work. |
| 49 scoped_ptr<ProcessSingleton> process_singleton_; |
| 50 }; |
| 51 |
| 52 // The "master class" that spins the UI and test threads. |
| 53 class CFUrlRequestUnittestRunner |
| 54 : public NetTestSuite, |
| 55 public ProcessSingletonSubclassDelegate, |
| 56 public TestAutomationProviderDelegate { |
| 57 public: |
| 58 CFUrlRequestUnittestRunner(int argc, char** argv); |
| 59 ~CFUrlRequestUnittestRunner(); |
| 60 |
| 61 virtual void StartChromeFrameInHostBrowser(); |
| 62 |
| 63 virtual void ShutDownHostBrowser(); |
| 64 |
| 65 // Overrides to not call icu initialize |
| 66 virtual void Initialize(); |
| 67 virtual void Shutdown(); |
| 68 |
| 69 // ProcessSingletonSubclassDelegate. |
| 70 virtual void OnConnectAutomationProviderToChannel( |
| 71 const std::string& channel_id); |
| 72 |
| 73 // TestAutomationProviderDelegate. |
| 74 virtual void OnInitialTabLoaded(); |
| 75 |
| 76 void RunMainUIThread(); |
| 77 |
| 78 void StartTests(); |
| 79 |
| 80 protected: |
| 81 // This is the thread that runs all the UrlRequest tests. |
| 82 // Within its context, the Initialize() and Shutdown() routines above |
| 83 // will be called. |
| 84 static DWORD WINAPI RunAllUnittests(void* param); |
| 85 |
| 86 static void TakeDownBrowser(CFUrlRequestUnittestRunner* me); |
| 87 |
| 88 protected: |
| 89 // Borrowed from TestSuite::Initialize(). |
| 90 void InitializeLogging(); |
| 91 |
| 92 protected: |
| 93 ScopedHandle test_thread_; |
| 94 DWORD test_thread_id_; |
| 95 scoped_ptr<MessageLoop> test_thread_message_loop_; |
| 96 |
| 97 scoped_ptr<test_server::SimpleWebServer> test_http_server_; |
| 98 test_server::SimpleResponse chrome_frame_html_; |
| 99 |
| 100 // The fake chrome instance. This instance owns the UI message loop |
| 101 // on the main thread. |
| 102 FakeExternalTab fake_chrome_; |
| 103 scoped_ptr<ProcessSingletonSubclass> pss_subclass_; |
| 104 }; |
| 105 |
| 106 #endif // CHROME_FRAME_TEST_NET_FAKE_EXTERNAL_TAB_H_ |
OLD | NEW |