Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / shell / renderer / webkit_test_runner.h
blob1108666c97272aead9fc8d38a192c2a0d08a64db
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 <vector>
10 #include "base/files/file_path.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/public/common/page_state.h"
13 #include "content/public/renderer/render_view_observer.h"
14 #include "content/public/renderer/render_view_observer_tracker.h"
15 #include "content/shell/common/shell_test_configuration.h"
16 #include "content/shell/common/test_runner/test_preferences.h"
17 #include "content/shell/renderer/test_runner/WebTestDelegate.h"
18 #include "third_party/WebKit/public/platform/WebScreenOrientationType.h"
19 #include "v8/include/v8.h"
21 class SkBitmap;
22 class SkCanvas;
24 namespace blink {
25 class WebBatteryStatus;
26 class WebDeviceMotionData;
27 class WebDeviceOrientationData;
28 struct WebRect;
31 namespace content {
33 class LeakDetector;
34 class WebTestProxyBase;
35 struct LeakDetectionResult;
37 // This is the renderer side of the webkit test runner.
38 class WebKitTestRunner : public RenderViewObserver,
39 public RenderViewObserverTracker<WebKitTestRunner>,
40 public WebTestDelegate {
41 public:
42 explicit WebKitTestRunner(RenderView* render_view);
43 virtual ~WebKitTestRunner();
45 // RenderViewObserver implementation.
46 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
47 virtual void DidClearWindowObject(blink::WebLocalFrame* frame) OVERRIDE;
48 virtual void Navigate(const GURL& url) OVERRIDE;
49 virtual void DidCommitProvisionalLoad(blink::WebLocalFrame* frame,
50 bool is_new_navigation) OVERRIDE;
51 virtual void DidFailProvisionalLoad(blink::WebLocalFrame* frame,
52 const blink::WebURLError& error) OVERRIDE;
54 // WebTestDelegate implementation.
55 virtual void clearEditCommand() OVERRIDE;
56 virtual void setEditCommand(const std::string& name,
57 const std::string& value) OVERRIDE;
58 virtual void setGamepadProvider(scoped_ptr<RendererGamepadProvider>) OVERRIDE;
59 virtual void setDeviceLightData(const double data) OVERRIDE;
60 virtual void setDeviceMotionData(
61 const blink::WebDeviceMotionData& data) OVERRIDE;
62 virtual void setDeviceOrientationData(
63 const blink::WebDeviceOrientationData& data) OVERRIDE;
64 virtual void setScreenOrientation(
65 const blink::WebScreenOrientationType& orientation) OVERRIDE;
66 virtual void resetScreenOrientation() OVERRIDE;
67 virtual void didChangeBatteryStatus(
68 const blink::WebBatteryStatus& status) OVERRIDE;
69 virtual void printMessage(const std::string& message) OVERRIDE;
70 virtual void postTask(WebTask* task) OVERRIDE;
71 virtual void postDelayedTask(WebTask* task, long long ms) OVERRIDE;
72 virtual blink::WebString registerIsolatedFileSystem(
73 const blink::WebVector<blink::WebString>& absolute_filenames) OVERRIDE;
74 virtual long long getCurrentTimeInMillisecond() OVERRIDE;
75 virtual blink::WebString getAbsoluteWebStringFromUTF8Path(
76 const std::string& utf8_path) OVERRIDE;
77 virtual blink::WebURL localFileToDataURL(
78 const blink::WebURL& file_url) OVERRIDE;
79 virtual blink::WebURL rewriteLayoutTestsURL(
80 const std::string& utf8_url) OVERRIDE;
81 virtual TestPreferences* preferences() OVERRIDE;
82 virtual void applyPreferences() OVERRIDE;
83 virtual std::string makeURLErrorDescription(const blink::WebURLError& error);
84 virtual void useUnfortunateSynchronousResizeMode(bool enable) OVERRIDE;
85 virtual void enableAutoResizeMode(const blink::WebSize& min_size,
86 const blink::WebSize& max_size) OVERRIDE;
87 virtual void disableAutoResizeMode(const blink::WebSize& new_size) OVERRIDE;
88 virtual void clearDevToolsLocalStorage() OVERRIDE;
89 virtual void showDevTools(const std::string& settings,
90 const std::string& frontend_url) OVERRIDE;
91 virtual void closeDevTools() OVERRIDE;
92 virtual void evaluateInWebInspector(long call_id,
93 const std::string& script) OVERRIDE;
94 virtual void clearAllDatabases() OVERRIDE;
95 virtual void setDatabaseQuota(int quota) OVERRIDE;
96 virtual blink::WebNotificationPresenter::Permission
97 checkWebNotificationPermission(const GURL& origin) OVERRIDE;
98 virtual void grantWebNotificationPermission(const GURL& origin,
99 bool permission_granted) OVERRIDE;
100 virtual void clearWebNotificationPermissions() OVERRIDE;
101 virtual void setDeviceScaleFactor(float factor) OVERRIDE;
102 virtual void setDeviceColorProfile(const std::string& name) OVERRIDE;
103 virtual void setFocus(WebTestProxyBase* proxy, bool focus) OVERRIDE;
104 virtual void setAcceptAllCookies(bool accept) OVERRIDE;
105 virtual std::string pathToLocalResource(const std::string& resource) OVERRIDE;
106 virtual void setLocale(const std::string& locale) OVERRIDE;
107 virtual void testFinished() OVERRIDE;
108 virtual void closeRemainingWindows() OVERRIDE;
109 virtual void deleteAllCookies() OVERRIDE;
110 virtual int navigationEntryCount() OVERRIDE;
111 virtual void goToOffset(int offset) OVERRIDE;
112 virtual void reload() OVERRIDE;
113 virtual void loadURLForFrame(const blink::WebURL& url,
114 const std::string& frame_name) OVERRIDE;
115 virtual bool allowExternalPages() OVERRIDE;
116 virtual std::string dumpHistoryForWindow(WebTestProxyBase* proxy) OVERRIDE;
118 void Reset();
120 void set_proxy(WebTestProxyBase* proxy) { proxy_ = proxy; }
121 WebTestProxyBase* proxy() const { return proxy_; }
123 void ReportLeakDetectionResult(const LeakDetectionResult& result);
125 private:
126 // Message handlers.
127 void OnSetTestConfiguration(const ShellTestConfiguration& params);
128 void OnSessionHistory(
129 const std::vector<int>& routing_ids,
130 const std::vector<std::vector<PageState> >& session_histories,
131 const std::vector<unsigned>& current_entry_indexes);
132 void OnReset();
133 void OnNotifyDone();
134 void OnTryLeakDetection();
136 // After finishing the test, retrieves the audio, text, and pixel dumps from
137 // the TestRunner library and sends them to the browser process.
138 void CaptureDump();
139 void CaptureDumpPixels(const SkBitmap& snapshot);
140 void CaptureDumpComplete();
142 WebTestProxyBase* proxy_;
144 RenderView* focused_view_;
146 TestPreferences prefs_;
148 ShellTestConfiguration test_config_;
150 std::vector<int> routing_ids_;
151 std::vector<std::vector<PageState> > session_histories_;
152 std::vector<unsigned> current_entry_indexes_;
154 bool is_main_window_;
156 bool focus_on_next_commit_;
158 scoped_ptr<LeakDetector> leak_detector_;
159 bool needs_leak_detector_;
161 DISALLOW_COPY_AND_ASSIGN(WebKitTestRunner);
164 } // namespace content
166 #endif // CONTENT_SHELL_WEBKIT_TEST_RUNNER_H_