| 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 WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H_ | 5 #ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H_ |
| 6 #define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H_ | 6 #define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H_ |
| 7 | 7 |
| 8 #pragma once | 8 #pragma once |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| 11 #include <map> |
| 11 #include <string> | 12 #include <string> |
| 12 #include <vector> | 13 #include <vector> |
| 13 | 14 |
| 14 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 15 #include "base/file_path.h" | 16 #include "base/file_path.h" |
| 16 #include "base/scoped_temp_dir.h" | 17 #include "base/scoped_temp_dir.h" |
| 17 #include "base/string_piece.h" | 18 #include "base/string_piece.h" |
| 18 #if defined(OS_MACOSX) | 19 #if defined(OS_MACOSX) |
| 19 #include "base/lazy_instance.h" | 20 #include "base/lazy_instance.h" |
| 20 #endif | 21 #endif |
| 21 #include "base/memory/ref_counted.h" | 22 #include "base/memory/ref_counted.h" |
| 22 #include "base/memory/weak_ptr.h" | 23 #include "base/memory/weak_ptr.h" |
| 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNavigationPolicy.h
" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNavigationPolicy.h
" |
| 24 #include "ui/gfx/native_widget_types.h" | 25 #include "ui/gfx/native_widget_types.h" |
| 25 #include "webkit/tools/test_shell/layout_test_controller.h" | |
| 26 #include "webkit/tools/test_shell/webview_host.h" | 26 #include "webkit/tools/test_shell/webview_host.h" |
| 27 #include "webkit/tools/test_shell/webwidget_host.h" | 27 #include "webkit/tools/test_shell/webwidget_host.h" |
| 28 | 28 |
| 29 typedef std::list<gfx::NativeWindow> WindowList; | 29 typedef std::list<gfx::NativeWindow> WindowList; |
| 30 | 30 |
| 31 namespace webkit_glue { | 31 namespace webkit_glue { |
| 32 struct WebPreferences; | 32 struct WebPreferences; |
| 33 } | 33 } |
| 34 | 34 |
| 35 class GURL; | 35 class GURL; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 void set_allow_scripts(bool allow) { allow_scripts_ = allow; } | 107 void set_allow_scripts(bool allow) { allow_scripts_ = allow; } |
| 108 | 108 |
| 109 void UpdateNavigationControls(); | 109 void UpdateNavigationControls(); |
| 110 | 110 |
| 111 // A new TestShell window will be opened with devtools url. | 111 // A new TestShell window will be opened with devtools url. |
| 112 // DevTools window can be opened manually via menu or automatically when | 112 // DevTools window can be opened manually via menu or automatically when |
| 113 // inspector's layout test url is passed from command line or console. | 113 // inspector's layout test url is passed from command line or console. |
| 114 void ShowDevTools(); | 114 void ShowDevTools(); |
| 115 void CloseDevTools(); | 115 void CloseDevTools(); |
| 116 | 116 |
| 117 // Called by the LayoutTestController to signal test completion. | 117 // Called to signal test completion. |
| 118 void TestFinished(); | 118 void TestFinished(); |
| 119 | 119 |
| 120 // Called by LayoutTestController when a test hits the timeout, but does not | 120 // Called when a test hits the timeout, but does not cause a hang. We can |
| 121 // cause a hang. We can avoid killing TestShell in this case and still dump | 121 // avoid killing TestShell in this case and still dump the test results. |
| 122 // the test results. | |
| 123 void TestTimedOut(); | 122 void TestTimedOut(); |
| 124 | 123 |
| 125 // Called to block the calling thread until TestFinished is called. | 124 // Called to block the calling thread until TestFinished is called. |
| 126 void WaitTestFinished(); | 125 void WaitTestFinished(); |
| 127 | 126 |
| 128 void Show(WebKit::WebNavigationPolicy policy); | 127 void Show(WebKit::WebNavigationPolicy policy); |
| 129 | 128 |
| 130 // We use this to avoid relying on Windows focus during layout test mode. | 129 // We use this to avoid relying on Windows focus during layout test mode. |
| 131 void SetFocus(WebWidgetHost* host, bool enable); | 130 void SetFocus(WebWidgetHost* host, bool enable); |
| 132 | 131 |
| 133 LayoutTestController* layout_test_controller() { | |
| 134 return layout_test_controller_.get(); | |
| 135 } | |
| 136 TestWebViewDelegate* delegate() { return delegate_.get(); } | 132 TestWebViewDelegate* delegate() { return delegate_.get(); } |
| 137 TestWebViewDelegate* popup_delegate() { return popup_delegate_.get(); } | 133 TestWebViewDelegate* popup_delegate() { return popup_delegate_.get(); } |
| 138 TestNavigationController* navigation_controller() { | 134 TestNavigationController* navigation_controller() { |
| 139 return navigation_controller_.get(); | 135 return navigation_controller_.get(); |
| 140 } | 136 } |
| 141 TestNotificationPresenter* notification_presenter() { | 137 TestNotificationPresenter* notification_presenter() { |
| 142 return notification_presenter_.get(); | 138 return notification_presenter_.get(); |
| 143 } | 139 } |
| 144 | 140 |
| 145 // Resets the LayoutTestController and EventSendingController. Should be | 141 // Resets TestWebViewDelegate. Should be called before loading a page, |
| 146 // called before loading a page, since some end-editing event notifications | 142 // since some end-editing event notifications may arrive after the previous |
| 147 // may arrive after the previous page has finished dumping its text and | 143 // page has finished dumping its text and therefore end up in the next |
| 148 // therefore end up in the next test's results if the messages are still | 144 // test's results if the messages are still enabled. |
| 149 // enabled. | |
| 150 void ResetTestController(); | 145 void ResetTestController(); |
| 151 | 146 |
| 152 // Passes options from LayoutTestController through to the delegate (or | |
| 153 // any other caller). | |
| 154 bool AcceptsEditing() { | 147 bool AcceptsEditing() { |
| 155 return layout_test_controller_->AcceptsEditing(); | 148 return true; |
| 156 } | 149 } |
| 157 | 150 |
| 158 void LoadFile(const FilePath& file); | 151 void LoadFile(const FilePath& file); |
| 159 void LoadURL(const GURL& url); | 152 void LoadURL(const GURL& url); |
| 160 void LoadURLForFrame(const GURL& url, const string16& frame_name); | 153 void LoadURLForFrame(const GURL& url, const string16& frame_name); |
| 161 void GoBackOrForward(int offset); | 154 void GoBackOrForward(int offset); |
| 162 void Reload(); | 155 void Reload(); |
| 163 bool Navigate(const TestNavigationEntry& entry, bool reload); | 156 bool Navigate(const TestNavigationEntry& entry, bool reload); |
| 164 | 157 |
| 165 bool PromptForSaveFile(const wchar_t* prompt_title, FilePath* result); | 158 bool PromptForSaveFile(const wchar_t* prompt_title, FilePath* result); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 187 // Implements CreateWebView for TestWebViewDelegate, which in turn | 180 // Implements CreateWebView for TestWebViewDelegate, which in turn |
| 188 // is called as a WebViewDelegate. | 181 // is called as a WebViewDelegate. |
| 189 WebKit::WebView* CreateWebView(); | 182 WebKit::WebView* CreateWebView(); |
| 190 WebKit::WebWidget* CreatePopupWidget(); | 183 WebKit::WebWidget* CreatePopupWidget(); |
| 191 void ClosePopup(); | 184 void ClosePopup(); |
| 192 | 185 |
| 193 #if defined(OS_WIN) | 186 #if defined(OS_WIN) |
| 194 static ATOM RegisterWindowClass(); | 187 static ATOM RegisterWindowClass(); |
| 195 #endif | 188 #endif |
| 196 | 189 |
| 197 // Called by the WebView delegate WindowObjectCleared() method, this | |
| 198 // binds the layout_test_controller_ and other C++ controller classes to | |
| 199 // window JavaScript objects so they can be accessed by layout tests. | |
| 200 virtual void BindJSObjectsToWindow(WebKit::WebFrame* frame); | |
| 201 | |
| 202 // Writes the back-forward list data for every open window into result. | 190 // Writes the back-forward list data for every open window into result. |
| 203 // Should call DumpBackForwardListOfWindow on each TestShell window. | 191 // Should call DumpBackForwardListOfWindow on each TestShell window. |
| 204 static void DumpAllBackForwardLists(string16* result); | 192 static void DumpAllBackForwardLists(string16* result); |
| 205 | 193 |
| 206 // Writes the single back-forward entry into result. | 194 // Writes the single back-forward entry into result. |
| 207 void DumpBackForwardEntry(int index, string16* result); | 195 void DumpBackForwardEntry(int index, string16* result); |
| 208 | 196 |
| 209 // Writes the back-forward list data for this test shell into result. | 197 // Writes the back-forward list data for this test shell into result. |
| 210 void DumpBackForwardList(string16* result); | 198 void DumpBackForwardList(string16* result); |
| 211 | 199 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 static bool layout_test_mode_; | 341 static bool layout_test_mode_; |
| 354 | 342 |
| 355 // True when we wish to allow test shell to load external pages like | 343 // True when we wish to allow test shell to load external pages like |
| 356 // www.google.com even when in --layout-test mode (used for QA to | 344 // www.google.com even when in --layout-test mode (used for QA to |
| 357 // produce images of the rendered page) | 345 // produce images of the rendered page) |
| 358 static bool allow_external_pages_; | 346 static bool allow_external_pages_; |
| 359 | 347 |
| 360 // Default timeout in ms for file page loads when in layout test mode. | 348 // Default timeout in ms for file page loads when in layout test mode. |
| 361 static int file_test_timeout_ms_; | 349 static int file_test_timeout_ms_; |
| 362 | 350 |
| 363 scoped_ptr<LayoutTestController> layout_test_controller_; | |
| 364 scoped_ptr<TestNavigationController> navigation_controller_; | 351 scoped_ptr<TestNavigationController> navigation_controller_; |
| 365 scoped_ptr<TestNotificationPresenter> notification_presenter_; | 352 scoped_ptr<TestNotificationPresenter> notification_presenter_; |
| 366 | 353 |
| 367 scoped_ptr<TestWebViewDelegate> delegate_; | 354 scoped_ptr<TestWebViewDelegate> delegate_; |
| 368 scoped_ptr<TestWebViewDelegate> popup_delegate_; | 355 scoped_ptr<TestWebViewDelegate> popup_delegate_; |
| 369 | 356 |
| 370 base::WeakPtr<TestShell> devtools_shell_; | 357 base::WeakPtr<TestShell> devtools_shell_; |
| 371 scoped_ptr<TestShellDevToolsAgent> dev_tools_agent_; | 358 scoped_ptr<TestShellDevToolsAgent> dev_tools_agent_; |
| 372 scoped_ptr<TestShellDevToolsClient> dev_tools_client_; | 359 scoped_ptr<TestShellDevToolsClient> dev_tools_client_; |
| 373 scoped_ptr<WebKit::WebDeviceOrientationClientMock> | 360 scoped_ptr<WebKit::WebDeviceOrientationClientMock> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 #if defined(OS_WIN) | 399 #if defined(OS_WIN) |
| 413 // Used by the watchdog to know when it's finished. | 400 // Used by the watchdog to know when it's finished. |
| 414 HANDLE finished_event_; | 401 HANDLE finished_event_; |
| 415 #endif | 402 #endif |
| 416 | 403 |
| 417 // Dump the stats table counters on exit. | 404 // Dump the stats table counters on exit. |
| 418 bool dump_stats_table_on_exit_; | 405 bool dump_stats_table_on_exit_; |
| 419 }; | 406 }; |
| 420 | 407 |
| 421 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H_ | 408 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H_ |
| OLD | NEW |