Remove the old Web Notification code-path (Chromium)
[chromium-blink-merge.git] / content / shell / renderer / layout_test / webkit_test_runner.h
blobac9508bb3020ed871cc16f16e7478db9155402df
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/web_test_delegate.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 ~WebKitTestRunner() override;
45 // RenderViewObserver implementation.
46 bool OnMessageReceived(const IPC::Message& message) override;
47 void DidClearWindowObject(blink::WebLocalFrame* frame) override;
48 void Navigate(const GURL& url) override;
49 void DidCommitProvisionalLoad(blink::WebLocalFrame* frame,
50 bool is_new_navigation) override;
51 void DidFailProvisionalLoad(blink::WebLocalFrame* frame,
52 const blink::WebURLError& error) override;
54 // WebTestDelegate implementation.
55 void ClearEditCommand() override;
56 void SetEditCommand(const std::string& name,
57 const std::string& value) override;
58 void SetGamepadProvider(scoped_ptr<RendererGamepadProvider>) override;
59 void SetDeviceLightData(const double data) override;
60 void SetDeviceMotionData(const blink::WebDeviceMotionData& data) override;
61 void SetDeviceOrientationData(
62 const blink::WebDeviceOrientationData& data) override;
63 void SetScreenOrientation(
64 const blink::WebScreenOrientationType& orientation) override;
65 void ResetScreenOrientation() override;
66 void DidChangeBatteryStatus(const blink::WebBatteryStatus& status) override;
67 void PrintMessage(const std::string& message) override;
68 void PostTask(WebTask* task) override;
69 void PostDelayedTask(WebTask* task, long long ms) override;
70 blink::WebString RegisterIsolatedFileSystem(
71 const blink::WebVector<blink::WebString>& absolute_filenames) override;
72 long long GetCurrentTimeInMillisecond() override;
73 blink::WebString GetAbsoluteWebStringFromUTF8Path(
74 const std::string& utf8_path) override;
75 blink::WebURL LocalFileToDataURL(const blink::WebURL& file_url) override;
76 blink::WebURL RewriteLayoutTestsURL(const std::string& utf8_url) override;
77 TestPreferences* Preferences() override;
78 void ApplyPreferences() override;
79 virtual std::string makeURLErrorDescription(const blink::WebURLError& error);
80 void UseUnfortunateSynchronousResizeMode(bool enable) override;
81 void EnableAutoResizeMode(const blink::WebSize& min_size,
82 const blink::WebSize& max_size) override;
83 void DisableAutoResizeMode(const blink::WebSize& new_size) override;
84 void ClearDevToolsLocalStorage() override;
85 void ShowDevTools(const std::string& settings,
86 const std::string& frontend_url) override;
87 void CloseDevTools() override;
88 void EvaluateInWebInspector(long call_id, const std::string& script) override;
89 void ClearAllDatabases() override;
90 void SetDatabaseQuota(int quota) override;
91 void GrantWebNotificationPermission(const GURL& origin,
92 bool permission_granted) override;
93 void ClearWebNotificationPermissions() override;
94 void SimulateWebNotificationClick(const std::string& title) override;
95 void SetDeviceScaleFactor(float factor) override;
96 void SetDeviceColorProfile(const std::string& name) override;
97 void SetBluetoothMockDataSet(const std::string& name) override;
98 void SetFocus(WebTestProxyBase* proxy, bool focus) override;
99 void SetAcceptAllCookies(bool accept) override;
100 std::string PathToLocalResource(const std::string& resource) override;
101 void SetLocale(const std::string& locale) override;
102 void TestFinished() override;
103 void CloseRemainingWindows() override;
104 void DeleteAllCookies() override;
105 int NavigationEntryCount() override;
106 void GoToOffset(int offset) override;
107 void Reload() override;
108 void LoadURLForFrame(const blink::WebURL& url,
109 const std::string& frame_name) override;
110 bool AllowExternalPages() override;
111 std::string DumpHistoryForWindow(WebTestProxyBase* proxy) override;
113 void Reset();
115 void set_proxy(WebTestProxyBase* proxy) { proxy_ = proxy; }
116 WebTestProxyBase* proxy() const { return proxy_; }
118 void ReportLeakDetectionResult(const LeakDetectionResult& result);
120 private:
121 // Message handlers.
122 void OnSetTestConfiguration(const ShellTestConfiguration& params);
123 void OnSessionHistory(
124 const std::vector<int>& routing_ids,
125 const std::vector<std::vector<PageState> >& session_histories,
126 const std::vector<unsigned>& current_entry_indexes);
127 void OnReset();
128 void OnNotifyDone();
129 void OnTryLeakDetection();
131 // After finishing the test, retrieves the audio, text, and pixel dumps from
132 // the TestRunner library and sends them to the browser process.
133 void CaptureDump();
134 void CaptureDumpPixels(const SkBitmap& snapshot);
135 void CaptureDumpComplete();
137 WebTestProxyBase* proxy_;
139 RenderView* focused_view_;
141 TestPreferences prefs_;
143 ShellTestConfiguration test_config_;
145 std::vector<int> routing_ids_;
146 std::vector<std::vector<PageState> > session_histories_;
147 std::vector<unsigned> current_entry_indexes_;
149 bool is_main_window_;
151 bool focus_on_next_commit_;
153 scoped_ptr<LeakDetector> leak_detector_;
154 bool needs_leak_detector_;
156 DISALLOW_COPY_AND_ASSIGN(WebKitTestRunner);
159 } // namespace content
161 #endif // CONTENT_SHELL_WEBKIT_TEST_RUNNER_H_