Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: webkit/tools/test_shell/test_shell.h

Issue 1818: Bulk fixes to get Mac Test Shell more compile-happy. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H__ 26 #ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H_
27 #define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H__ 27 #define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H_
28 28
29 #pragma once 29 #pragma once
30 30
31 #include <string> 31 #include <string>
32 #include <list> 32 #include <list>
33 33
34 #include "base/basictypes.h"
35 #include "base/gfx/native_widget_types.h"
34 #include "base/ref_counted.h" 36 #include "base/ref_counted.h"
35 #include "webkit/tools/test_shell/event_sending_controller.h" 37 #include "webkit/tools/test_shell/event_sending_controller.h"
36 #include "webkit/tools/test_shell/layout_test_controller.h" 38 #include "webkit/tools/test_shell/layout_test_controller.h"
37 #include "webkit/tools/test_shell/resource.h" 39 #include "webkit/tools/test_shell/resource.h"
38 #include "webkit/tools/test_shell/text_input_controller.h" 40 #include "webkit/tools/test_shell/text_input_controller.h"
39 #include "webkit/tools/test_shell/test_webview_delegate.h" 41 #include "webkit/tools/test_shell/test_webview_delegate.h"
40 #include "webkit/tools/test_shell/webview_host.h" 42 #include "webkit/tools/test_shell/webview_host.h"
41 #include "webkit/tools/test_shell/webwidget_host.h" 43 #include "webkit/tools/test_shell/webwidget_host.h"
42 44
43 typedef std::list<HWND> WindowList; 45 typedef std::list<gfx::WindowHandle> WindowList;
44 46
45 struct WebPreferences; 47 struct WebPreferences;
46 class TestNavigationEntry; 48 class TestNavigationEntry;
47 class TestNavigationController; 49 class TestNavigationController;
48 50
49 class TestShell { 51 class TestShell {
50 public: 52 public:
51 struct TestParams { 53 struct TestParams {
52 // Load the test defaults. 54 // Load the test defaults.
53 TestParams() : dump_tree(true), dump_pixels(false) { 55 TestParams() : dump_tree(true), dump_pixels(false) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 void LoadURLForFrame(const wchar_t* url, const wchar_t* frame_name); 139 void LoadURLForFrame(const wchar_t* url, const wchar_t* frame_name);
138 void GoBackOrForward(int offset); 140 void GoBackOrForward(int offset);
139 void Reload(); 141 void Reload();
140 bool Navigate(const TestNavigationEntry& entry, bool reload); 142 bool Navigate(const TestNavigationEntry& entry, bool reload);
141 143
142 bool PromptForSaveFile(const wchar_t* prompt_title, std::wstring* result); 144 bool PromptForSaveFile(const wchar_t* prompt_title, std::wstring* result);
143 std::wstring GetDocumentText(); 145 std::wstring GetDocumentText();
144 void DumpDocumentText(); 146 void DumpDocumentText();
145 void DumpRenderTree(); 147 void DumpRenderTree();
146 148
147 HWND mainWnd() const { return m_mainWnd; } 149 gfx::WindowHandle mainWnd() const { return m_mainWnd; }
148 HWND webViewWnd() const { return m_webViewHost->window_handle(); } 150 gfx::ViewHandle webViewWnd() const { return m_webViewHost->window_handle(); }
149 HWND editWnd() const { return m_editWnd; } 151 gfx::EditViewHandle editWnd() const { return m_editWnd; }
150 HWND popupWnd() const { return m_popupHost->window_handle(); } 152 gfx::ViewHandle popupWnd() const { return m_popupHost->window_handle(); }
151 153
152 static WindowList* windowList() { return window_list_; } 154 static WindowList* windowList() { return window_list_; }
153 155
154 // If shell is non-null, then *shell is assigned upon successful return 156 // If shell is non-null, then *shell is assigned upon successful return
155 static bool CreateNewWindow(const std::wstring& startingURL, 157 static bool CreateNewWindow(const std::wstring& startingURL,
156 TestShell** shell = NULL); 158 TestShell** shell = NULL);
157 159
158 // Implements CreateWebView for TestWebViewDelegate, which in turn 160 // Implements CreateWebView for TestWebViewDelegate, which in turn
159 // is called as a WebViewDelegate. 161 // is called as a WebViewDelegate.
160 WebView* CreateWebView(WebView* webview); 162 WebView* CreateWebView(WebView* webview);
161 WebWidget* CreatePopupWidget(WebView* webview); 163 WebWidget* CreatePopupWidget(WebView* webview);
162 void ClosePopup(); 164 void ClosePopup();
163 165
166 #if defined(OS_WIN)
164 static ATOM RegisterWindowClass(); 167 static ATOM RegisterWindowClass();
168 #endif
165 169
166 // Called by the WebView delegate WindowObjectCleared() method, this 170 // Called by the WebView delegate WindowObjectCleared() method, this
167 // binds the layout_test_controller_ and other C++ controller classes to 171 // binds the layout_test_controller_ and other C++ controller classes to
168 // window JavaScript objects so they can be accessed by layout tests. 172 // window JavaScript objects so they can be accessed by layout tests.
169 virtual void BindJSObjectsToWindow(WebFrame* frame); 173 virtual void BindJSObjectsToWindow(WebFrame* frame);
170 174
171 // Runs a layout test. Loads a single file into the first available 175 // Runs a layout test. Loads a single file into the first available
172 // window, then dumps the requested text representation to stdout. 176 // window, then dumps the requested text representation to stdout.
173 // Returns false if the test cannot be run because no windows are open. 177 // Returns false if the test cannot be run because no windows are open.
174 static bool RunFileTest(const char* filename, const TestParams& params); 178 static bool RunFileTest(const char* filename, const TestParams& params);
(...skipping 15 matching lines...) Expand all
190 static std::string RewriteLocalUrl(const std::string& url); 194 static std::string RewriteLocalUrl(const std::string& url);
191 195
192 // Set the timeout for running a test. 196 // Set the timeout for running a test.
193 static void SetFileTestTimeout(int timeout_ms) { 197 static void SetFileTestTimeout(int timeout_ms) {
194 file_test_timeout_ms_ = timeout_ms; 198 file_test_timeout_ms_ = timeout_ms;
195 } 199 }
196 200
197 // Get the timeout for running a test. 201 // Get the timeout for running a test.
198 static int GetFileTestTimeout() { return file_test_timeout_ms_; } 202 static int GetFileTestTimeout() { return file_test_timeout_ms_; }
199 203
204 #if defined(OS_WIN)
200 // Access to the finished event. Used by the static WatchDog 205 // Access to the finished event. Used by the static WatchDog
201 // thread. 206 // thread.
202 HANDLE finished_event() { return finished_event_; } 207 HANDLE finished_event() { return finished_event_; }
208 #endif
203 209
204 // Have the shell print the StatsTable to stdout on teardown. 210 // Have the shell print the StatsTable to stdout on teardown.
205 void DumpStatsTableOnExit() { dump_stats_table_on_exit_ = true; } 211 void DumpStatsTableOnExit() { dump_stats_table_on_exit_ = true; }
206 212
207 void CallJSGC(); 213 void CallJSGC();
208 214
209 void set_is_modal(bool value) { is_modal_ = value; } 215 void set_is_modal(bool value) { is_modal_ = value; }
210 bool is_modal() const { return is_modal_; } 216 bool is_modal() const { return is_modal_; }
211 217
212 protected: 218 protected:
213 bool Initialize(const std::wstring& startingURL); 219 bool Initialize(const std::wstring& startingURL);
214 void SizeToDefault(); 220 void SizeToDefault();
215 void SizeTo(int width, int height); 221 void SizeTo(int width, int height);
216 void ResizeSubViews(); 222 void ResizeSubViews();
217 223
224 #if defined(OS_WIN)
218 static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); 225 static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
219 static LRESULT CALLBACK EditWndProc(HWND, UINT, WPARAM, LPARAM); 226 static LRESULT CALLBACK EditWndProc(HWND, UINT, WPARAM, LPARAM);
227 #endif
220 228
221 protected: 229 protected:
222 HWND m_mainWnd; 230 gfx::WindowHandle m_mainWnd;
223 HWND m_editWnd; 231 gfx::EditViewHandle m_editWnd;
224 scoped_ptr<WebViewHost> m_webViewHost; 232 scoped_ptr<WebViewHost> m_webViewHost;
225 WebWidgetHost* m_popupHost; 233 WebWidgetHost* m_popupHost;
234 #if defined(OS_WIN)
226 WNDPROC default_edit_wnd_proc_; 235 WNDPROC default_edit_wnd_proc_;
236 #endif
227 237
228 // Primitive focus controller for layout test mode. 238 // Primitive focus controller for layout test mode.
229 WebWidgetHost* m_focusedWidgetHost; 239 WebWidgetHost* m_focusedWidgetHost;
230 240
231 private: 241 private:
232 // A set of all our windows. 242 // A set of all our windows.
233 static WindowList* window_list_; 243 static WindowList* window_list_;
244 #if defined(OS_MACOSX)
245 static std::map<gfx::WindowHandle, TestShell *> window_map_;
246 #endif
234 247
248 #if defined(OS_WIN)
235 static HINSTANCE instance_handle_; 249 static HINSTANCE instance_handle_;
250 #endif
236 251
237 // False when the app is being run using the --layout-tests switch. 252 // False when the app is being run using the --layout-tests switch.
238 static bool interactive_; 253 static bool interactive_;
239 254
240 // Timeout for page load when running non-interactive file tests, in ms. 255 // Timeout for page load when running non-interactive file tests, in ms.
241 static int file_test_timeout_ms_; 256 static int file_test_timeout_ms_;
242 257
243 scoped_ptr<LayoutTestController> layout_test_controller_; 258 scoped_ptr<LayoutTestController> layout_test_controller_;
244 259
245 scoped_ptr<EventSendingController> event_sending_controller_; 260 scoped_ptr<EventSendingController> event_sending_controller_;
246 261
247 scoped_ptr<TextInputController> text_input_controller_; 262 scoped_ptr<TextInputController> text_input_controller_;
248 263
249 scoped_ptr<TestNavigationController> navigation_controller_; 264 scoped_ptr<TestNavigationController> navigation_controller_;
250 265
251 scoped_refptr<TestWebViewDelegate> delegate_; 266 scoped_refptr<TestWebViewDelegate> delegate_;
252 267
253 // True while a test is preparing to run 268 // True while a test is preparing to run
254 bool test_is_preparing_; 269 bool test_is_preparing_;
255 270
256 // True while a test is running 271 // True while a test is running
257 bool test_is_pending_; 272 bool test_is_pending_;
258 273
259 // True if driven from a nested message loop. 274 // True if driven from a nested message loop.
260 bool is_modal_; 275 bool is_modal_;
261 276
262 // The preferences for the test shell. 277 // The preferences for the test shell.
263 static WebPreferences* web_prefs_; 278 static WebPreferences* web_prefs_;
264 279
280 #if defined(OS_WIN)
265 // Used by the watchdog to know when it's finished. 281 // Used by the watchdog to know when it's finished.
266 HANDLE finished_event_; 282 HANDLE finished_event_;
283 #endif
267 284
268 // Dump the stats table counters on exit. 285 // Dump the stats table counters on exit.
269 bool dump_stats_table_on_exit_; 286 bool dump_stats_table_on_exit_;
270 }; 287 };
271 288
272 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H__ 289 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H_
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj ('k') | webkit/tools/test_shell/test_webview_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698