Give names to all utility processes.
[chromium-blink-merge.git] / content / shell / renderer / layout_test / webkit_test_runner.h
blob5ec0881233574c1f26ef2c88f697dd79163a639b
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_RENDERER_LAYOUT_TEST_WEBKIT_TEST_RUNNER_H_
6 #define CONTENT_SHELL_RENDERER_LAYOUT_TEST_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 SetPushMessagingPermission(const GURL& origin, bool allowed) override;
96 void ClearPushMessagingPermissions() override;
97 void SetDeviceScaleFactor(float factor) override;
98 void SetDeviceColorProfile(const std::string& name) override;
99 void SetBluetoothMockDataSet(const std::string& name) override;
100 void SetGeofencingMockProvider(bool service_available) override;
101 void ClearGeofencingMockProvider() override;
102 void SetGeofencingMockPosition(double latitude, double longitude) override;
103 void SetFocus(WebTestProxyBase* proxy, bool focus) override;
104 void SetAcceptAllCookies(bool accept) override;
105 std::string PathToLocalResource(const std::string& resource) override;
106 void SetLocale(const std::string& locale) override;
107 void TestFinished() override;
108 void CloseRemainingWindows() override;
109 void DeleteAllCookies() override;
110 int NavigationEntryCount() override;
111 void GoToOffset(int offset) override;
112 void Reload() override;
113 void LoadURLForFrame(const blink::WebURL& url,
114 const std::string& frame_name) override;
115 bool AllowExternalPages() override;
116 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_RENDERER_LAYOUT_TEST_WEBKIT_TEST_RUNNER_H_