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

Side by Side Diff: content/shell/renderer/test_runner/TestRunner.h

Issue 110533009: Import TestRunner library into chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years 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
(Empty)
1 // Copyright 2013 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 /*
6 * Copyright (C) 2010 Google Inc. All rights reserved.
7 * Copyright (C) 2010 Pawel Hajdan (phajdan.jr@chromium.org)
8 * Copyright (C) 2012 Apple Inc. All Rights Reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are
12 * met:
13 *
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following disclaimer
18 * in the documentation and/or other materials provided with the
19 * distribution.
20 * * Neither the name of Google Inc. nor the names of its
21 * contributors may be used to endorse or promote products derived from
22 * this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 #ifndef TestRunner_h
38 #define TestRunner_h
39
40 #include <deque>
41 #include <set>
42 #include <string>
43
44 #include "content/shell/renderer/test_runner/CppBoundClass.h"
45 #include "content/shell/renderer/test_runner/TestCommon.h"
46 #include "content/shell/renderer/test_runner/WebScopedPtr.h"
47 #include "content/shell/renderer/test_runner/WebTask.h"
48 #include "content/shell/renderer/test_runner/WebTestRunner.h"
49 #include "third_party/WebKit/public/platform/WebCanvas.h"
50 #include "third_party/WebKit/public/platform/WebURL.h"
51 #include "third_party/WebKit/public/web/WebArrayBufferView.h"
52 #include "third_party/WebKit/public/web/WebPageOverlay.h"
53 #include "third_party/WebKit/public/web/WebTextDirection.h"
54 #include "third_party/skia/include/core/SkCanvas.h"
55
56 namespace blink {
57 class WebArrayBufferView;
58 class WebNotificationPresenter;
59 class WebPageOverlay;
60 class WebPermissionClient;
61 class WebView;
62 }
63
64 namespace WebTestRunner {
65
66 class NotificationPresenter;
67 class TestInterfaces;
68 class WebPermissions;
69 class WebTestDelegate;
70 class WebTestProxyBase;
71
72 class TestRunner : public WebTestRunner, public CppBoundClass {
73 public:
74 explicit TestRunner(TestInterfaces*);
75 virtual ~TestRunner();
76
77 void setDelegate(WebTestDelegate*);
78 void setWebView(blink::WebView*, WebTestProxyBase*);
79
80 void reset();
81
82 WebTaskList* taskList() { return &m_taskList; }
83
84 void setTestIsRunning(bool);
85 bool testIsRunning() const { return m_testIsRunning; }
86
87 // WebTestRunner implementation.
88 virtual bool shouldGeneratePixelResults() OVERRIDE;
89 virtual bool shouldDumpAsAudio() const OVERRIDE;
90 virtual const blink::WebArrayBufferView* audioData() const OVERRIDE;
91 virtual bool shouldDumpBackForwardList() const OVERRIDE;
92 virtual blink::WebPermissionClient* webPermissions() const OVERRIDE;
93
94 // Methods used by WebTestProxyBase.
95 bool shouldDumpSelectionRect() const;
96 bool testRepaint() const;
97 bool sweepHorizontally() const;
98 bool isPrinting() const;
99 bool shouldDumpAsText();
100 bool shouldDumpAsTextWithPixelResults();
101 bool shouldDumpAsMarkup();
102 bool shouldDumpChildFrameScrollPositions() const;
103 bool shouldDumpChildFramesAsText() const;
104 void showDevTools();
105 void setShouldDumpAsText(bool);
106 void setShouldDumpAsMarkup(bool);
107 void setShouldGeneratePixelResults(bool);
108 void setShouldDumpFrameLoadCallbacks(bool);
109 void setShouldDumpPingLoaderCallbacks(bool);
110 void setShouldEnableViewSource(bool);
111 bool shouldDumpEditingCallbacks() const;
112 bool shouldDumpFrameLoadCallbacks() const;
113 bool shouldDumpPingLoaderCallbacks() const;
114 bool shouldDumpUserGestureInFrameLoadCallbacks() const;
115 bool shouldDumpTitleChanges() const;
116 bool shouldDumpIconChanges() const;
117 bool shouldDumpCreateView() const;
118 bool canOpenWindows() const;
119 bool shouldDumpResourceLoadCallbacks() const;
120 bool shouldDumpResourceRequestCallbacks() const;
121 bool shouldDumpResourceResponseMIMETypes() const;
122 bool shouldDumpStatusCallbacks() const;
123 bool shouldDumpProgressFinishedCallback() const;
124 bool shouldDumpSpellCheckCallbacks() const;
125 bool shouldStayOnPageAfterHandlingBeforeUnload() const;
126 const std::set<std::string>* httpHeadersToClear() const;
127 void setTopLoadingFrame(blink::WebFrame*, bool);
128 blink::WebFrame* topLoadingFrame() const;
129 void policyDelegateDone();
130 bool policyDelegateEnabled() const;
131 bool policyDelegateIsPermissive() const;
132 bool policyDelegateShouldNotifyDone() const;
133 bool shouldInterceptPostMessage() const;
134 bool shouldDumpResourcePriorities() const;
135 blink::WebNotificationPresenter* notificationPresenter() const;
136 bool requestPointerLock();
137 void requestPointerUnlock();
138 bool isPointerLocked();
139 void setToolTipText(const blink::WebString&);
140
141 bool midiAccessorResult();
142
143 // A single item in the work queue.
144 class WorkItem {
145 public:
146 virtual ~WorkItem() { }
147
148 // Returns true if this started a load.
149 virtual bool run(WebTestDelegate*, blink::WebView*) = 0;
150 };
151
152 private:
153 friend class WorkQueue;
154
155 // Helper class for managing events queued by methods like queueLoad or
156 // queueScript.
157 class WorkQueue {
158 public:
159 WorkQueue(TestRunner* controller) : m_frozen(false), m_controller(contro ller) { }
160 virtual ~WorkQueue();
161 void processWorkSoon();
162
163 // Reset the state of the class between tests.
164 void reset();
165
166 void addWork(WorkItem*);
167
168 void setFrozen(bool frozen) { m_frozen = frozen; }
169 bool isEmpty() { return m_queue.empty(); }
170 WebTaskList* taskList() { return &m_taskList; }
171
172 private:
173 void processWork();
174 class WorkQueueTask: public WebMethodTask<WorkQueue> {
175 public:
176 WorkQueueTask(WorkQueue* object): WebMethodTask<WorkQueue>(object) { }
177 virtual void runIfValid() { m_object->processWork(); }
178 };
179
180 WebTaskList m_taskList;
181 std::deque<WorkItem*> m_queue;
182 bool m_frozen;
183 TestRunner* m_controller;
184 };
185 ///////////////////////////////////////////////////////////////////////////
186 // Methods dealing with the test logic
187
188 // By default, tests end when page load is complete. These methods are used
189 // to delay the completion of the test until notifyDone is called.
190 void waitUntilDone(const CppArgumentList&, CppVariant*);
191 void notifyDone(const CppArgumentList&, CppVariant*);
192
193 // Methods for adding actions to the work queue. Used in conjunction with
194 // waitUntilDone/notifyDone above.
195 void queueBackNavigation(const CppArgumentList&, CppVariant*);
196 void queueForwardNavigation(const CppArgumentList&, CppVariant*);
197 void queueReload(const CppArgumentList&, CppVariant*);
198 void queueLoadingScript(const CppArgumentList&, CppVariant*);
199 void queueNonLoadingScript(const CppArgumentList&, CppVariant*);
200 void queueLoad(const CppArgumentList&, CppVariant*);
201 void queueLoadHTMLString(const CppArgumentList&, CppVariant*);
202
203
204 // Causes navigation actions just printout the intended navigation instead
205 // of taking you to the page. This is used for cases like mailto, where you
206 // don't actually want to open the mail program.
207 void setCustomPolicyDelegate(const CppArgumentList&, CppVariant*);
208
209 // Delays completion of the test until the policy delegate runs.
210 void waitForPolicyDelegate(const CppArgumentList&, CppVariant*);
211
212 // Functions for dealing with windows. By default we block all new windows.
213 void windowCount(const CppArgumentList&, CppVariant*);
214 void setCloseRemainingWindowsWhenComplete(const CppArgumentList&, CppVariant *);
215
216 void resetTestHelperControllers(const CppArgumentList&, CppVariant*);
217
218 ///////////////////////////////////////////////////////////////////////////
219 // Methods implemented entirely in terms of chromium's public WebKit API
220
221 // Method that controls whether pressing Tab key cycles through page element s
222 // or inserts a '\t' char in text area
223 void setTabKeyCyclesThroughElements(const CppArgumentList&, CppVariant*);
224
225 // Executes an internal command (superset of document.execCommand() commands ).
226 void execCommand(const CppArgumentList&, CppVariant*);
227
228 // Checks if an internal command is currently available.
229 void isCommandEnabled(const CppArgumentList&, CppVariant*);
230
231 void callShouldCloseOnWebView(const CppArgumentList&, CppVariant*);
232 void setDomainRelaxationForbiddenForURLScheme(const CppArgumentList&, CppVar iant*);
233 void evaluateScriptInIsolatedWorldAndReturnValue(const CppArgumentList&, Cpp Variant*);
234 void evaluateScriptInIsolatedWorld(const CppArgumentList&, CppVariant*);
235 void setIsolatedWorldSecurityOrigin(const CppArgumentList&, CppVariant*);
236 void setIsolatedWorldContentSecurityPolicy(const CppArgumentList&, CppVarian t*);
237
238 // Allows layout tests to manage origins' whitelisting.
239 void addOriginAccessWhitelistEntry(const CppArgumentList&, CppVariant*);
240 void removeOriginAccessWhitelistEntry(const CppArgumentList&, CppVariant*);
241
242 // Returns true if the current page box has custom page size style for
243 // printing.
244 void hasCustomPageSizeStyle(const CppArgumentList&, CppVariant*);
245
246 // Forces the selection colors for testing under Linux.
247 void forceRedSelectionColors(const CppArgumentList&, CppVariant*);
248
249 // Adds a style sheet to be injected into new documents.
250 void injectStyleSheet(const CppArgumentList&, CppVariant*);
251
252 void startSpeechInput(const CppArgumentList&, CppVariant*);
253
254 void findString(const CppArgumentList&, CppVariant*);
255
256 // Expects the first argument to be an input element and the second argument to be a string value.
257 // Forwards the setValueForUser() call to the element.
258 void setValueForUser(const CppArgumentList&, CppVariant*);
259
260 void selectionAsMarkup(const CppArgumentList&, CppVariant*);
261
262 // Enables or disables subpixel positioning (i.e. fractional X positions for
263 // glyphs) in text rendering on Linux. Since this method changes global
264 // settings, tests that call it must use their own custom font family for
265 // all text that they render. If not, an already-cached style will be used,
266 // resulting in the changed setting being ignored.
267 void setTextSubpixelPositioning(const CppArgumentList&, CppVariant*);
268
269 // Switch the visibility of the page.
270 void setPageVisibility(const CppArgumentList&, CppVariant*);
271
272 // Changes the direction of the focused element.
273 void setTextDirection(const CppArgumentList&, CppVariant*);
274
275 // Retrieves the text surrounding a position in a text node.
276 // Expects the first argument to be a text node, the second and third to be
277 // point coordinates relative to the node and the fourth the maximum text
278 // length to retrieve.
279 void textSurroundingNode(const CppArgumentList&, CppVariant*);
280
281 // After this function is called, all window-sizing machinery is
282 // short-circuited inside the renderer. This mode is necessary for
283 // some tests that were written before browsers had multi-process architectu re
284 // and rely on window resizes to happen synchronously.
285 // The function has "unfortunate" it its name because we must strive to remo ve all tests
286 // that rely on this... well, unfortunate behavior. See http://crbug.com/309 760 for the plan.
287 void useUnfortunateSynchronousResizeMode(const CppArgumentList&, CppVariant* );
288
289 void enableAutoResizeMode(const CppArgumentList&, CppVariant*);
290 void disableAutoResizeMode(const CppArgumentList&, CppVariant*);
291
292 // Device Motion / Device Orientation related functions
293 void setMockDeviceMotion(const CppArgumentList&, CppVariant*);
294 void setMockDeviceOrientation(const CppArgumentList&, CppVariant*);
295
296 void didAcquirePointerLock(const CppArgumentList&, CppVariant*);
297 void didNotAcquirePointerLock(const CppArgumentList&, CppVariant*);
298 void didLosePointerLock(const CppArgumentList&, CppVariant*);
299 void setPointerLockWillFailSynchronously(const CppArgumentList&, CppVariant* );
300 void setPointerLockWillRespondAsynchronously(const CppArgumentList&, CppVari ant*);
301
302 ///////////////////////////////////////////////////////////////////////////
303 // Methods modifying WebPreferences.
304
305 // Set the WebPreference that controls webkit's popup blocking.
306 void setPopupBlockingEnabled(const CppArgumentList&, CppVariant*);
307
308 void setJavaScriptCanAccessClipboard(const CppArgumentList&, CppVariant*);
309 void setXSSAuditorEnabled(const CppArgumentList&, CppVariant*);
310 void setAllowUniversalAccessFromFileURLs(const CppArgumentList&, CppVariant* );
311 void setAllowFileAccessFromFileURLs(const CppArgumentList&, CppVariant*);
312 void overridePreference(const CppArgumentList&, CppVariant*);
313
314 // Enable or disable plugins.
315 void setPluginsEnabled(const CppArgumentList&, CppVariant*);
316
317 ///////////////////////////////////////////////////////////////////////////
318 // Methods that modify the state of TestRunner
319
320 // This function sets a flag that tells the test_shell to print a line of
321 // descriptive text for each editing command. It takes no arguments, and
322 // ignores any that may be present.
323 void dumpEditingCallbacks(const CppArgumentList&, CppVariant*);
324
325 // This function sets a flag that tells the test_shell to dump pages as
326 // plain text, rather than as a text representation of the renderer's state.
327 // The pixel results will not be generated for this test.
328 void dumpAsText(const CppArgumentList&, CppVariant*);
329
330 // This function sets a flag that tells the test_shell to dump pages as
331 // plain text, rather than as a text representation of the renderer's state.
332 // It will also generate a pixel dump for the test.
333 void dumpAsTextWithPixelResults(const CppArgumentList&, CppVariant*);
334
335 // This function sets a flag that tells the test_shell to print out the
336 // scroll offsets of the child frames. It ignores all.
337 void dumpChildFrameScrollPositions(const CppArgumentList&, CppVariant*);
338
339 // This function sets a flag that tells the test_shell to recursively
340 // dump all frames as plain text if the dumpAsText flag is set.
341 // It takes no arguments, and ignores any that may be present.
342 void dumpChildFramesAsText(const CppArgumentList&, CppVariant*);
343
344 // This function sets a flag that tells the test_shell to print out the
345 // information about icon changes notifications from WebKit.
346 void dumpIconChanges(const CppArgumentList&, CppVariant*);
347
348 // Deals with Web Audio WAV file data.
349 void setAudioData(const CppArgumentList&, CppVariant*);
350
351 // This function sets a flag that tells the test_shell to print a line of
352 // descriptive text for each frame load callback. It takes no arguments, and
353 // ignores any that may be present.
354 void dumpFrameLoadCallbacks(const CppArgumentList&, CppVariant*);
355
356 // This function sets a flag that tells the test_shell to print a line of
357 // descriptive text for each PingLoader dispatch. It takes no arguments, and
358 // ignores any that may be present.
359 void dumpPingLoaderCallbacks(const CppArgumentList&, CppVariant*);
360
361 // This function sets a flag that tells the test_shell to print a line of
362 // user gesture status text for some frame load callbacks. It takes no
363 // arguments, and ignores any that may be present.
364 void dumpUserGestureInFrameLoadCallbacks(const CppArgumentList&, CppVariant* );
365
366 void dumpTitleChanges(const CppArgumentList&, CppVariant*);
367
368 // This function sets a flag that tells the test_shell to dump all calls to
369 // WebViewClient::createView().
370 // It takes no arguments, and ignores any that may be present.
371 void dumpCreateView(const CppArgumentList&, CppVariant*);
372
373 void setCanOpenWindows(const CppArgumentList&, CppVariant*);
374
375 // This function sets a flag that tells the test_shell to dump a descriptive
376 // line for each resource load callback. It takes no arguments, and ignores
377 // any that may be present.
378 void dumpResourceLoadCallbacks(const CppArgumentList&, CppVariant*);
379
380 // This function sets a flag that tells the test_shell to print a line of
381 // descriptive text for each element that requested a resource. It takes no
382 // arguments, and ignores any that may be present.
383 void dumpResourceRequestCallbacks(const CppArgumentList&, CppVariant*);
384
385 // This function sets a flag that tells the test_shell to dump the MIME type
386 // for each resource that was loaded. It takes no arguments, and ignores any
387 // that may be present.
388 void dumpResourceResponseMIMETypes(const CppArgumentList&, CppVariant*);
389
390 // WebPermissionClient related.
391 void setImagesAllowed(const CppArgumentList&, CppVariant*);
392 void setScriptsAllowed(const CppArgumentList&, CppVariant*);
393 void setStorageAllowed(const CppArgumentList&, CppVariant*);
394 void setPluginsAllowed(const CppArgumentList&, CppVariant*);
395 void setAllowDisplayOfInsecureContent(const CppArgumentList&, CppVariant*);
396 void setAllowRunningOfInsecureContent(const CppArgumentList&, CppVariant*);
397 void dumpPermissionClientCallbacks(const CppArgumentList&, CppVariant*);
398
399 // This function sets a flag that tells the test_shell to dump all calls
400 // to window.status().
401 // It takes no arguments, and ignores any that may be present.
402 void dumpWindowStatusChanges(const CppArgumentList&, CppVariant*);
403
404 // This function sets a flag that tells the test_shell to print a line of
405 // descriptive text for the progress finished callback. It takes no
406 // arguments, and ignores any that may be present.
407 void dumpProgressFinishedCallback(const CppArgumentList&, CppVariant*);
408
409 // This function sets a flag that tells the test_shell to dump all
410 // the lines of descriptive text about spellcheck execution.
411 void dumpSpellCheckCallbacks(const CppArgumentList&, CppVariant*);
412
413 // This function sets a flag that tells the test_shell to print out a text
414 // representation of the back/forward list. It ignores all arguments.
415 void dumpBackForwardList(const CppArgumentList&, CppVariant*);
416
417 void dumpSelectionRect(const CppArgumentList&, CppVariant*);
418 void testRepaint(const CppArgumentList&, CppVariant*);
419 void repaintSweepHorizontally(const CppArgumentList&, CppVariant*);
420
421 // Causes layout to happen as if targetted to printed pages.
422 void setPrinting(const CppArgumentList&, CppVariant*);
423
424 void setShouldStayOnPageAfterHandlingBeforeUnload(const CppArgumentList&, Cp pVariant*);
425
426 // Causes WillSendRequest to clear certain headers.
427 void setWillSendRequestClearHeader(const CppArgumentList&, CppVariant*);
428
429 // This function sets a flag that tells the test_shell to dump a descriptive
430 // line for each resource load's priority and any time that priority
431 // changes. It takes no arguments, and ignores any that may be present.
432 void dumpResourceRequestPriorities(const CppArgumentList&, CppVariant*);
433
434 ///////////////////////////////////////////////////////////////////////////
435 // Methods interacting with the WebTestProxy
436
437 ///////////////////////////////////////////////////////////////////////////
438 // Methods forwarding to the WebTestDelegate
439
440 // Shows DevTools window.
441 void showWebInspector(const CppArgumentList&, CppVariant*);
442 void closeWebInspector(const CppArgumentList&, CppVariant*);
443
444 // Inspect chooser state
445 void isChooserShown(const CppArgumentList&, CppVariant*);
446
447 // Allows layout tests to exec scripts at WebInspector side.
448 void evaluateInWebInspector(const CppArgumentList&, CppVariant*);
449
450 // Clears all databases.
451 void clearAllDatabases(const CppArgumentList&, CppVariant*);
452 // Sets the default quota for all origins
453 void setDatabaseQuota(const CppArgumentList&, CppVariant*);
454
455 // Changes the cookie policy from the default to allow all cookies.
456 void setAlwaysAcceptCookies(const CppArgumentList&, CppVariant*);
457
458 // Gives focus to the window.
459 void setWindowIsKey(const CppArgumentList&, CppVariant*);
460
461 // Converts a URL starting with file:///tmp/ to the local mapping.
462 void pathToLocalResource(const CppArgumentList&, CppVariant*);
463
464 // Used to set the device scale factor.
465 void setBackingScaleFactor(const CppArgumentList&, CppVariant*);
466
467 // Calls setlocale(LC_ALL, ...) for a specified locale.
468 // Resets between tests.
469 void setPOSIXLocale(const CppArgumentList&, CppVariant*);
470
471 // Gets the number of geolocation permissions requests pending.
472 void numberOfPendingGeolocationPermissionRequests(const CppArgumentList&, Cp pVariant*);
473
474 // Geolocation related functions.
475 void setGeolocationPermission(const CppArgumentList&, CppVariant*);
476 void setMockGeolocationPosition(const CppArgumentList&, CppVariant*);
477 void setMockGeolocationPositionUnavailableError(const CppArgumentList&, CppV ariant*);
478
479 // MIDI function to control permission handling.
480 void setMIDIAccessorResult(const CppArgumentList&, CppVariant*);
481 void setMIDISysExPermission(const CppArgumentList&, CppVariant*);
482
483 // Grants permission for desktop notifications to an origin
484 void grantWebNotificationPermission(const CppArgumentList&, CppVariant*);
485 // Simulates a click on a desktop notification.
486 void simulateLegacyWebNotificationClick(const CppArgumentList&, CppVariant*) ;
487 // Cancel all active desktop notifications.
488 void cancelAllActiveNotifications(const CppArgumentList& arguments, CppVaria nt* result);
489
490 // Speech input related functions.
491 void addMockSpeechInputResult(const CppArgumentList&, CppVariant*);
492 void setMockSpeechInputDumpRect(const CppArgumentList&, CppVariant*);
493 void addMockSpeechRecognitionResult(const CppArgumentList&, CppVariant*);
494 void setMockSpeechRecognitionError(const CppArgumentList&, CppVariant*);
495 void wasMockSpeechRecognitionAborted(const CppArgumentList&, CppVariant*);
496
497 // WebPageOverlay related functions. Permits the adding and removing of only
498 // one opaque overlay.
499 void addWebPageOverlay(const CppArgumentList&, CppVariant*);
500 void removeWebPageOverlay(const CppArgumentList&, CppVariant*);
501
502 void display(const CppArgumentList&, CppVariant*);
503 void displayInvalidatedRegion(const CppArgumentList&, CppVariant*);
504
505 //////////////////////////////////////////////////////////////////////////
506 // Fallback and stub methods
507
508 // The fallback method is called when a nonexistent method is called on
509 // the layout test controller object.
510 // It is usefull to catch typos in the JavaScript code (a few layout tests
511 // do have typos in them) and it allows the script to continue running in
512 // that case (as the Mac does).
513 void fallbackMethod(const CppArgumentList&, CppVariant*);
514
515 // Stub for not implemented methods.
516 void notImplemented(const CppArgumentList&, CppVariant*);
517
518 ///////////////////////////////////////////////////////////////////////////
519 // Internal helpers
520 void checkResponseMimeType();
521 void completeNotifyDone();
522 class HostMethodTask : public WebMethodTask<TestRunner> {
523 public:
524 typedef void (TestRunner::*CallbackMethodType)();
525 HostMethodTask(TestRunner* object, CallbackMethodType callback)
526 : WebMethodTask<TestRunner>(object)
527 , m_callback(callback)
528 { }
529
530 virtual void runIfValid() { (m_object->*m_callback)(); }
531
532 private:
533 CallbackMethodType m_callback;
534 };
535 class TestPageOverlay : public blink::WebPageOverlay {
536 public:
537 explicit TestPageOverlay(blink::WebView*);
538 virtual void paintPageOverlay(blink::WebCanvas*) OVERRIDE;
539 virtual ~TestPageOverlay();
540 private:
541 blink::WebView* m_webView;
542 };
543 void didAcquirePointerLockInternal();
544 void didNotAcquirePointerLockInternal();
545 void didLosePointerLockInternal();
546
547 bool cppVariantToBool(const CppVariant&);
548 int32_t cppVariantToInt32(const CppVariant&);
549 blink::WebString cppVariantToWebString(const CppVariant&);
550
551 void printErrorMessage(const std::string&);
552
553 // In the Mac code, this is called to trigger the end of a test after the
554 // page has finished loading. From here, we can generate the dump for the
555 // test.
556 void locationChangeDone();
557
558 bool m_testIsRunning;
559
560 // When reset is called, go through and close all but the main test shell
561 // window. By default, set to true but toggled to false using
562 // setCloseRemainingWindowsWhenComplete().
563 bool m_closeRemainingWindows;
564
565 // If true, don't dump output until notifyDone is called.
566 bool m_waitUntilDone;
567
568 // Causes navigation actions just printout the intended navigation instead
569 // of taking you to the page. This is used for cases like mailto, where you
570 // don't actually want to open the mail program.
571 bool m_policyDelegateEnabled;
572
573 // Toggles the behavior of the policy delegate. If true, then navigations
574 // will be allowed. Otherwise, they will be ignored (dropped).
575 bool m_policyDelegateIsPermissive;
576
577 // If true, the policy delegate will signal layout test completion.
578 bool m_policyDelegateShouldNotifyDone;
579
580 WorkQueue m_workQueue;
581
582 // globalFlag is used by a number of layout tests in http/tests/security/dat aURL.
583 CppVariant m_globalFlag;
584
585 // Bound variable to return the name of this platform (chromium).
586 CppVariant m_platformName;
587
588 // Bound variable counting the number of top URLs visited.
589 CppVariant m_webHistoryItemCount;
590
591 // Bound variable to set whether postMessages should be intercepted or not
592 CppVariant m_interceptPostMessage;
593
594 // Bound variable to store the last tooltip text
595 CppVariant m_tooltipText;
596
597 // Bound variable to disable notifyDone calls. This is used in GC leak
598 // tests, where existing LayoutTests are loaded within an iframe. The GC
599 // test harness will set this flag to ignore the notifyDone calls from the
600 // target LayoutTest.
601 CppVariant m_disableNotifyDone;
602
603 // If true, the test_shell will write a descriptive line for each editing
604 // command.
605 bool m_dumpEditingCallbacks;
606
607 // If true, the test_shell will generate pixel results in dumpAsText mode
608 bool m_generatePixelResults;
609
610 // If true, the test_shell will produce a plain text dump rather than a
611 // text representation of the renderer.
612 bool m_dumpAsText;
613
614 // If true and if dump_as_text_ is true, the test_shell will recursively
615 // dump all frames as plain text.
616 bool m_dumpChildFramesAsText;
617
618 // If true, the test_shell will produce a dump of the DOM rather than a text
619 // representation of the renderer.
620 bool m_dumpAsMarkup;
621
622 // If true, the test_shell will print out the child frame scroll offsets as
623 // well.
624 bool m_dumpChildFrameScrollPositions;
625
626 // If true, the test_shell will print out the icon change notifications.
627 bool m_dumpIconChanges;
628
629 // If true, the test_shell will output a base64 encoded WAVE file.
630 bool m_dumpAsAudio;
631
632 // If true, the test_shell will output a descriptive line for each frame
633 // load callback.
634 bool m_dumpFrameLoadCallbacks;
635
636 // If true, the test_shell will output a descriptive line for each
637 // PingLoader dispatched.
638 bool m_dumpPingLoaderCallbacks;
639
640 // If true, the test_shell will output a line of the user gesture status
641 // text for some frame load callbacks.
642 bool m_dumpUserGestureInFrameLoadCallbacks;
643
644 // If true, output a message when the page title is changed.
645 bool m_dumpTitleChanges;
646
647 // If true, output a descriptive line each time WebViewClient::createView
648 // is invoked.
649 bool m_dumpCreateView;
650
651 // If true, new windows can be opened via javascript or by plugins. By
652 // default, set to false and can be toggled to true using
653 // setCanOpenWindows().
654 bool m_canOpenWindows;
655
656 // If true, the test_shell will output a descriptive line for each resource
657 // load callback.
658 bool m_dumpResourceLoadCallbacks;
659
660 // If true, the test_shell will output a descriptive line for each resource
661 // request callback.
662 bool m_dumpResourceRequestCallbacks;
663
664 // If true, the test_shell will output the MIME type for each resource that
665 // was loaded.
666 bool m_dumpResourceResponseMIMETypes;
667
668 // If true, the test_shell will dump all changes to window.status.
669 bool m_dumpWindowStatusChanges;
670
671 // If true, the test_shell will output a descriptive line for the progress
672 // finished callback.
673 bool m_dumpProgressFinishedCallback;
674
675 // If true, the test_shell will output descriptive test for spellcheck
676 // execution.
677 bool m_dumpSpellCheckCallbacks;
678
679 // If true, the test_shell will produce a dump of the back forward list as
680 // well.
681 bool m_dumpBackForwardList;
682
683 // If true, the test_shell will draw the bounds of the current selection rec t
684 // taking possible transforms of the selection rect into account.
685 bool m_dumpSelectionRect;
686
687 // If true, pixel dump will be produced as a series of 1px-tall, view-wide
688 // individual paints over the height of the view.
689 bool m_testRepaint;
690
691 // If true and test_repaint_ is true as well, pixel dump will be produced as
692 // a series of 1px-wide, view-tall paints across the width of the view.
693 bool m_sweepHorizontally;
694
695 // If true, layout is to target printed pages.
696 bool m_isPrinting;
697
698 // If false, MockWebMIDIAccessor fails on startSession() for testing.
699 bool m_midiAccessorResult;
700
701 bool m_shouldStayOnPageAfterHandlingBeforeUnload;
702
703 bool m_shouldDumpResourcePriorities;
704
705 std::set<std::string> m_httpHeadersToClear;
706
707 // WAV audio data is stored here.
708 blink::WebArrayBufferView m_audioData;
709
710 // Used for test timeouts.
711 WebTaskList m_taskList;
712
713 TestInterfaces* m_testInterfaces;
714 WebTestDelegate* m_delegate;
715 blink::WebView* m_webView;
716 TestPageOverlay* m_pageOverlay;
717 WebTestProxyBase* m_proxy;
718
719 // This is non-0 IFF a load is in progress.
720 blink::WebFrame* m_topLoadingFrame;
721
722 // WebPermissionClient mock object.
723 WebScopedPtr<WebPermissions> m_webPermissions;
724
725 WebScopedPtr<NotificationPresenter> m_notificationPresenter;
726
727 bool m_pointerLocked;
728 enum {
729 PointerLockWillSucceed,
730 PointerLockWillRespondAsync,
731 PointerLockWillFailSync,
732 } m_pointerLockPlannedResult;
733 };
734
735 }
736
737 #endif // TestRunner_h
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/TestPlugin.cpp ('k') | content/shell/renderer/test_runner/TestRunner.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698