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
3 // found in the LICENSE file.
5 #ifndef CONTENT_SHELL_WEBKIT_TEST_RUNNER_H_
6 #define CONTENT_SHELL_WEBKIT_TEST_RUNNER_H_
8 #include "base/file_path.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "content/public/renderer/render_view_observer.h"
11 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebPreferences.h"
12 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h"
13 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h"
14 #include "v8/include/v8.h"
22 namespace WebTestRunner
{
23 class WebTestProxyBase
;
28 // This is the renderer side of the webkit test runner.
29 class WebKitTestRunner
: public RenderViewObserver
,
30 public WebTestRunner::WebTestDelegate
,
31 public WebTestRunner::WebTestRunner
{
33 explicit WebKitTestRunner(RenderView
* render_view
);
34 virtual ~WebKitTestRunner();
36 // RenderViewObserver implementation.
37 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
38 virtual void DidClearWindowObject(WebKit::WebFrame
* frame
) OVERRIDE
;
39 virtual void DidFinishLoad(WebKit::WebFrame
* frame
) OVERRIDE
;
40 virtual void DidRequestShowContextMenu(
41 WebKit::WebFrame
* frame
,
42 const WebKit::WebContextMenuData
& data
) OVERRIDE
;
44 // WebTestDelegate implementation.
45 virtual void clearContextMenuData();
46 virtual void clearEditCommand();
47 virtual void fillSpellingSuggestionList(
48 const WebKit::WebString
& word
,
49 WebKit::WebVector
<WebKit::WebString
>* suggestions
);
50 virtual void setEditCommand(const std::string
& name
,
51 const std::string
& value
);
52 virtual WebKit::WebContextMenuData
* lastContextMenuData() const;
53 virtual void setGamepadData(const WebKit::WebGamepads
& gamepads
);
54 virtual void printMessage(const std::string
& message
);
55 virtual void postTask(::WebTestRunner::WebTask
* task
);
56 virtual void postDelayedTask(::WebTestRunner::WebTask
* task
,
58 virtual WebKit::WebString
registerIsolatedFileSystem(
59 const WebKit::WebVector
<WebKit::WebString
>& absolute_filenames
);
60 virtual long long getCurrentTimeInMillisecond();
61 virtual WebKit::WebString
getAbsoluteWebStringFromUTF8Path(
62 const std::string
& utf8_path
);
63 virtual WebKit::WebURL
localFileToDataURL(const WebKit::WebURL
& file_url
);
64 virtual WebKit::WebURL
rewriteLayoutTestsURL(const std::string
& utf8_url
);
65 virtual ::WebTestRunner::WebPreferences
* preferences();
66 virtual void applyPreferences();
68 // WebTestRunner implementation.
69 virtual bool shouldDumpEditingCallbacks() const;
73 void SetXSSAuditorEnabled(bool enabled
);
76 void DumpChildFramesAsText();
78 void SetShouldStayOnPageAfterHandlingBeforeUnload(bool should_stay_on_page
);
80 void CanOpenWindows();
81 void ShowWebInspector();
82 void CloseWebInspector();
83 void EvaluateInWebInspector(int32_t call_id
, const std::string
& script
);
84 void ExecCommand(const std::string
& command
, const std::string
& value
);
85 void OverridePreference(const std::string
& key
, v8::Local
<v8::Value
> value
);
86 void DumpEditingCallbacks();
88 void NotImplemented(const std::string
& object
, const std::string
& method
);
90 void set_proxy(::WebTestRunner::WebTestProxyBase
* proxy
) { proxy_
= proxy
; }
94 void OnCaptureTextDump(bool as_text
, bool printing
, bool recursive
);
95 void OnCaptureImageDump(const std::string
& expected_pixel_hash
);
96 void OnSetCurrentWorkingDirectory(const FilePath
& current_working_directory
);
98 SkCanvas
* GetCanvas();
99 void PaintRect(const WebKit::WebRect
& rect
);
100 void PaintInvalidatedRegion();
101 void DisplayRepaintMask();
103 scoped_ptr
<SkCanvas
> canvas_
;
104 scoped_ptr
<WebKit::WebContextMenuData
> last_context_menu_data_
;
105 FilePath current_working_directory_
;
107 ::WebTestRunner::WebTestProxyBase
* proxy_
;
109 ::WebTestRunner::WebPreferences prefs_
;
111 bool dump_editing_callbacks_
;
113 DISALLOW_COPY_AND_ASSIGN(WebKitTestRunner
);
116 } // namespace content
118 #endif // CONTENT_SHELL_WEBKIT_TEST_RUNNER_H_