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

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

Issue 1606: hodgepodge for test_shell.cc (Closed)
Patch Set: update some comments 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
« no previous file with comments | « webkit/tools/test_shell/run_all_tests.cc ('k') | webkit/tools/test_shell/test_shell.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 22 matching lines...) Expand all
33 33
34 #include "base/ref_counted.h" 34 #include "base/ref_counted.h"
35 #include "webkit/tools/test_shell/event_sending_controller.h" 35 #include "webkit/tools/test_shell/event_sending_controller.h"
36 #include "webkit/tools/test_shell/layout_test_controller.h" 36 #include "webkit/tools/test_shell/layout_test_controller.h"
37 #include "webkit/tools/test_shell/resource.h" 37 #include "webkit/tools/test_shell/resource.h"
38 #include "webkit/tools/test_shell/text_input_controller.h" 38 #include "webkit/tools/test_shell/text_input_controller.h"
39 #include "webkit/tools/test_shell/test_webview_delegate.h" 39 #include "webkit/tools/test_shell/test_webview_delegate.h"
40 #include "webkit/tools/test_shell/webview_host.h" 40 #include "webkit/tools/test_shell/webview_host.h"
41 #include "webkit/tools/test_shell/webwidget_host.h" 41 #include "webkit/tools/test_shell/webwidget_host.h"
42 42
43 typedef std::list<HWND> WindowList; 43 #if defined(OS_WIN)
44 typedef HWND WindowHandle;
45 #else // null port.
46 typedef void* WindowHandle;
47 #endif
48 typedef std::list<WindowHandle> WindowList;
44 49
45 struct WebPreferences; 50 struct WebPreferences;
46 class TestNavigationEntry; 51 class TestNavigationEntry;
47 class TestNavigationController; 52 class TestNavigationController;
53 class TestShellImpl;
48 54
49 class TestShell { 55 class TestShell {
50 public: 56 public:
51 struct TestParams { 57 struct TestParams {
52 // Load the test defaults. 58 // Load the test defaults.
53 TestParams() : dump_tree(true), dump_pixels(false) { 59 TestParams() : dump_tree(true), dump_pixels(false) {
54 } 60 }
55 61
56 // The kind of output we want from this test. 62 // The kind of output we want from this test.
57 bool dump_tree; 63 bool dump_tree;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 void LoadURLForFrame(const wchar_t* url, const wchar_t* frame_name); 143 void LoadURLForFrame(const wchar_t* url, const wchar_t* frame_name);
138 void GoBackOrForward(int offset); 144 void GoBackOrForward(int offset);
139 void Reload(); 145 void Reload();
140 bool Navigate(const TestNavigationEntry& entry, bool reload); 146 bool Navigate(const TestNavigationEntry& entry, bool reload);
141 147
142 bool PromptForSaveFile(const wchar_t* prompt_title, std::wstring* result); 148 bool PromptForSaveFile(const wchar_t* prompt_title, std::wstring* result);
143 std::wstring GetDocumentText(); 149 std::wstring GetDocumentText();
144 void DumpDocumentText(); 150 void DumpDocumentText();
145 void DumpRenderTree(); 151 void DumpRenderTree();
146 152
147 HWND mainWnd() const { return m_mainWnd; } 153 WindowHandle mainWnd() const { return m_mainWnd; }
148 HWND webViewWnd() const { return m_webViewHost->window_handle(); } 154 WindowHandle webViewWnd() const { return m_webViewHost->window_handle(); }
149 HWND editWnd() const { return m_editWnd; } 155 WindowHandle editWnd() const { return m_editWnd; }
150 HWND popupWnd() const { return m_popupHost->window_handle(); } 156 WindowHandle popupWnd() const { return m_popupHost->window_handle(); }
151 157
152 static WindowList* windowList() { return window_list_; } 158 static WindowList* windowList() { return window_list_; }
153 159
154 // If shell is non-null, then *shell is assigned upon successful return 160 // If shell is non-null, then *shell is assigned upon successful return
155 static bool CreateNewWindow(const std::wstring& startingURL, 161 static bool CreateNewWindow(const std::wstring& startingURL,
156 TestShell** shell = NULL); 162 TestShell** shell = NULL);
157 163
158 // Implements CreateWebView for TestWebViewDelegate, which in turn 164 // Implements CreateWebView for TestWebViewDelegate, which in turn
159 // is called as a WebViewDelegate. 165 // is called as a WebViewDelegate.
160 WebView* CreateWebView(WebView* webview); 166 WebView* CreateWebView(WebView* webview);
161 WebWidget* CreatePopupWidget(WebView* webview); 167 WebWidget* CreatePopupWidget(WebView* webview);
162 void ClosePopup(); 168 void ClosePopup();
163 169
170 #if defined(OS_WIN)
164 static ATOM RegisterWindowClass(); 171 static ATOM RegisterWindowClass();
172 #endif
165 173
166 // Called by the WebView delegate WindowObjectCleared() method, this 174 // Called by the WebView delegate WindowObjectCleared() method, this
167 // binds the layout_test_controller_ and other C++ controller classes to 175 // binds the layout_test_controller_ and other C++ controller classes to
168 // window JavaScript objects so they can be accessed by layout tests. 176 // window JavaScript objects so they can be accessed by layout tests.
169 virtual void BindJSObjectsToWindow(WebFrame* frame); 177 virtual void BindJSObjectsToWindow(WebFrame* frame);
170 178
171 // Runs a layout test. Loads a single file into the first available 179 // Runs a layout test. Loads a single file into the first available
172 // window, then dumps the requested text representation to stdout. 180 // window, then dumps the requested text representation to stdout.
173 // Returns false if the test cannot be run because no windows are open. 181 // Returns false if the test cannot be run because no windows are open.
174 static bool RunFileTest(const char* filename, const TestParams& params); 182 static bool RunFileTest(const char* filename, const TestParams& params);
(...skipping 15 matching lines...) Expand all
190 static std::string RewriteLocalUrl(const std::string& url); 198 static std::string RewriteLocalUrl(const std::string& url);
191 199
192 // Set the timeout for running a test. 200 // Set the timeout for running a test.
193 static void SetFileTestTimeout(int timeout_ms) { 201 static void SetFileTestTimeout(int timeout_ms) {
194 file_test_timeout_ms_ = timeout_ms; 202 file_test_timeout_ms_ = timeout_ms;
195 } 203 }
196 204
197 // Get the timeout for running a test. 205 // Get the timeout for running a test.
198 static int GetFileTestTimeout() { return file_test_timeout_ms_; } 206 static int GetFileTestTimeout() { return file_test_timeout_ms_; }
199 207
208 #if defined(OS_WIN)
200 // Access to the finished event. Used by the static WatchDog 209 // Access to the finished event. Used by the static WatchDog
201 // thread. 210 // thread.
202 HANDLE finished_event() { return finished_event_; } 211 HANDLE finished_event() { return finished_event_; }
212 #endif
203 213
204 // Have the shell print the StatsTable to stdout on teardown. 214 // Have the shell print the StatsTable to stdout on teardown.
205 void DumpStatsTableOnExit() { dump_stats_table_on_exit_ = true; } 215 void DumpStatsTableOnExit() { dump_stats_table_on_exit_ = true; }
206 216
207 void CallJSGC(); 217 void CallJSGC();
208 218
209 void set_is_modal(bool value) { is_modal_ = value; } 219 void set_is_modal(bool value) { is_modal_ = value; }
210 bool is_modal() const { return is_modal_; } 220 bool is_modal() const { return is_modal_; }
211 221
212 protected: 222 protected:
213 bool Initialize(const std::wstring& startingURL); 223 bool Initialize(const std::wstring& startingURL);
214 void SizeToDefault(); 224 void SizeToDefault();
215 void SizeTo(int width, int height); 225 void SizeTo(int width, int height);
216 void ResizeSubViews(); 226 void ResizeSubViews();
217 227
218 static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); 228 protected:
219 static LRESULT CALLBACK EditWndProc(HWND, UINT, WPARAM, LPARAM); 229 scoped_ptr<TestShellImpl> m_impl;
220 230
221 protected: 231 WindowHandle m_mainWnd;
222 HWND m_mainWnd; 232 WindowHandle m_editWnd;
223 HWND m_editWnd;
224 scoped_ptr<WebViewHost> m_webViewHost; 233 scoped_ptr<WebViewHost> m_webViewHost;
225 WebWidgetHost* m_popupHost; 234 WebWidgetHost* m_popupHost;
226 WNDPROC default_edit_wnd_proc_;
227 235
228 // Primitive focus controller for layout test mode. 236 // Primitive focus controller for layout test mode.
229 WebWidgetHost* m_focusedWidgetHost; 237 WebWidgetHost* m_focusedWidgetHost;
230 238
231 private: 239 private:
232 // A set of all our windows. 240 // A set of all our windows.
233 static WindowList* window_list_; 241 static WindowList* window_list_;
234 242
235 static HINSTANCE instance_handle_;
236
237 // False when the app is being run using the --layout-tests switch. 243 // False when the app is being run using the --layout-tests switch.
238 static bool interactive_; 244 static bool interactive_;
239 245
240 // Timeout for page load when running non-interactive file tests, in ms. 246 // Timeout for page load when running non-interactive file tests, in ms.
241 static int file_test_timeout_ms_; 247 static int file_test_timeout_ms_;
242 248
243 scoped_ptr<LayoutTestController> layout_test_controller_; 249 scoped_ptr<LayoutTestController> layout_test_controller_;
244 250
245 scoped_ptr<EventSendingController> event_sending_controller_; 251 scoped_ptr<EventSendingController> event_sending_controller_;
246 252
247 scoped_ptr<TextInputController> text_input_controller_; 253 scoped_ptr<TextInputController> text_input_controller_;
248 254
249 scoped_ptr<TestNavigationController> navigation_controller_; 255 scoped_ptr<TestNavigationController> navigation_controller_;
250 256
251 scoped_refptr<TestWebViewDelegate> delegate_; 257 scoped_refptr<TestWebViewDelegate> delegate_;
252 258
253 // True while a test is preparing to run 259 // True while a test is preparing to run
254 bool test_is_preparing_; 260 bool test_is_preparing_;
255 261
256 // True while a test is running 262 // True while a test is running
257 bool test_is_pending_; 263 bool test_is_pending_;
258 264
259 // True if driven from a nested message loop. 265 // True if driven from a nested message loop.
260 bool is_modal_; 266 bool is_modal_;
261 267
262 // The preferences for the test shell. 268 // The preferences for the test shell.
263 static WebPreferences* web_prefs_; 269 static WebPreferences* web_prefs_;
264 270
271 #if defined(OS_WIN)
265 // Used by the watchdog to know when it's finished. 272 // Used by the watchdog to know when it's finished.
266 HANDLE finished_event_; 273 HANDLE finished_event_;
274 #endif
267 275
268 // Dump the stats table counters on exit. 276 // Dump the stats table counters on exit.
269 bool dump_stats_table_on_exit_; 277 bool dump_stats_table_on_exit_;
270 }; 278 };
271 279
272 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H__ 280 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H__
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/run_all_tests.cc ('k') | webkit/tools/test_shell/test_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698