[content shell] implement testRunner.overridePreference
[chromium-blink-merge.git] / content / shell / webkit_test_runner.h
blob72fdba41153a0d8fe571a73001cd3da3bac5598a
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 "v8/include/v8.h"
15 class SkCanvas;
17 namespace WebKit {
18 struct WebRect;
21 namespace WebTestRunner {
22 class WebTestProxyBase;
25 namespace content {
27 // This is the renderer side of the webkit test runner.
28 class WebKitTestRunner : public RenderViewObserver,
29 public WebTestRunner::WebTestDelegate {
30 public:
31 explicit WebKitTestRunner(RenderView* render_view);
32 virtual ~WebKitTestRunner();
34 // RenderViewObserver implementation.
35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
36 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE;
37 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE;
38 virtual void DidRequestShowContextMenu(
39 WebKit::WebFrame* frame,
40 const WebKit::WebContextMenuData& data) OVERRIDE;
42 // WebTestDelegate implementation.
43 virtual void clearContextMenuData();
44 virtual void clearEditCommand();
45 virtual void fillSpellingSuggestionList(
46 const WebKit::WebString& word,
47 WebKit::WebVector<WebKit::WebString>* suggestions);
48 virtual void setEditCommand(const std::string& name,
49 const std::string& value);
50 virtual WebKit::WebContextMenuData* lastContextMenuData() const;
51 virtual void setGamepadData(const WebKit::WebGamepads& gamepads);
52 virtual void printMessage(const std::string& message);
53 virtual void postTask(WebTestRunner::WebTask* task);
54 virtual void postDelayedTask(WebTestRunner::WebTask* task,
55 long long ms);
56 virtual WebKit::WebString registerIsolatedFileSystem(
57 const WebKit::WebVector<WebKit::WebString>& absolute_filenames);
58 virtual long long getCurrentTimeInMillisecond();
59 virtual WebKit::WebString getAbsoluteWebStringFromUTF8Path(
60 const std::string& utf8_path);
61 virtual WebKit::WebURL localFileToDataURL(const WebKit::WebURL& file_url);
62 virtual WebKit::WebURL rewriteLayoutTestsURL(const std::string& utf8_url);
63 virtual WebTestRunner::WebPreferences* preferences();
64 virtual void applyPreferences();
66 void Reset();
67 void Display();
68 void SetXSSAuditorEnabled(bool enabled);
69 void NotifyDone();
70 void DumpAsText();
71 void DumpChildFramesAsText();
72 void SetPrinting();
73 void SetShouldStayOnPageAfterHandlingBeforeUnload(bool should_stay_on_page);
74 void WaitUntilDone();
75 void CanOpenWindows();
76 void ShowWebInspector();
77 void CloseWebInspector();
78 void EvaluateInWebInspector(int32_t call_id, const std::string& script);
79 void ExecCommand(const std::string& command, const std::string& value);
80 void OverridePreference(const std::string& key, v8::Local<v8::Value> value);
82 void NotImplemented(const std::string& object, const std::string& method);
84 void set_proxy(WebTestRunner::WebTestProxyBase* proxy) { proxy_ = proxy; }
86 private:
87 // Message handlers.
88 void OnCaptureTextDump(bool as_text, bool printing, bool recursive);
89 void OnCaptureImageDump(const std::string& expected_pixel_hash);
90 void OnSetCurrentWorkingDirectory(const FilePath& current_working_directory);
92 SkCanvas* GetCanvas();
93 void PaintRect(const WebKit::WebRect& rect);
94 void PaintInvalidatedRegion();
95 void DisplayRepaintMask();
97 scoped_ptr<SkCanvas> canvas_;
98 scoped_ptr<WebKit::WebContextMenuData> last_context_menu_data_;
99 FilePath current_working_directory_;
101 WebTestRunner::WebTestProxyBase* proxy_;
103 WebTestRunner::WebPreferences prefs_;
105 DISALLOW_COPY_AND_ASSIGN(WebKitTestRunner);
108 } // namespace content
110 #endif // CONTENT_SHELL_WEBKIT_TEST_RUNNER_H_