Content settings: remove some plugin-related code/resources when... there are no...
[chromium-blink-merge.git] / content / shell / renderer / layout_test / blink_test_runner.h
bloba4b07ceaf9fb09b145319674ae18c5143086218d
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_BLINK_TEST_RUNNER_H_
6 #define CONTENT_SHELL_RENDERER_LAYOUT_TEST_BLINK_TEST_RUNNER_H_
8 #include <vector>
10 #include "base/files/file_path.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "components/test_runner/test_preferences.h"
13 #include "components/test_runner/web_test_delegate.h"
14 #include "content/public/common/page_state.h"
15 #include "content/public/renderer/render_view_observer.h"
16 #include "content/public/renderer/render_view_observer_tracker.h"
17 #include "content/shell/common/shell_test_configuration.h"
18 #include "third_party/WebKit/public/platform/modules/screen_orientation/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 test_runner {
32 class WebTestProxyBase;
35 namespace content {
37 class LeakDetector;
38 struct LeakDetectionResult;
40 // This is the renderer side of the webkit test runner.
41 class BlinkTestRunner : public RenderViewObserver,
42 public RenderViewObserverTracker<BlinkTestRunner>,
43 public test_runner::WebTestDelegate {
44 public:
45 explicit BlinkTestRunner(RenderView* render_view);
46 ~BlinkTestRunner() override;
48 // RenderViewObserver implementation.
49 bool OnMessageReceived(const IPC::Message& message) override;
50 void DidClearWindowObject(blink::WebLocalFrame* frame) override;
51 void Navigate(const GURL& url) override;
52 void DidCommitProvisionalLoad(blink::WebLocalFrame* frame,
53 bool is_new_navigation) override;
54 void DidFailProvisionalLoad(blink::WebLocalFrame* frame,
55 const blink::WebURLError& error) override;
57 // WebTestDelegate implementation.
58 void ClearEditCommand() override;
59 void SetEditCommand(const std::string& name,
60 const std::string& value) override;
61 void SetGamepadProvider(test_runner::GamepadController* controller) override;
62 void SetDeviceLightData(const double data) override;
63 void SetDeviceMotionData(const blink::WebDeviceMotionData& data) override;
64 void SetDeviceOrientationData(
65 const blink::WebDeviceOrientationData& data) override;
66 void SetScreenOrientation(
67 const blink::WebScreenOrientationType& orientation) override;
68 void ResetScreenOrientation() override;
69 void DidChangeBatteryStatus(const blink::WebBatteryStatus& status) override;
70 void PrintMessage(const std::string& message) override;
71 void PostTask(test_runner::WebTask* task) override;
72 void PostDelayedTask(test_runner::WebTask* task, long long ms) override;
73 blink::WebString RegisterIsolatedFileSystem(
74 const blink::WebVector<blink::WebString>& absolute_filenames) override;
75 long long GetCurrentTimeInMillisecond() override;
76 blink::WebString GetAbsoluteWebStringFromUTF8Path(
77 const std::string& utf8_path) override;
78 blink::WebURL LocalFileToDataURL(const blink::WebURL& file_url) override;
79 blink::WebURL RewriteLayoutTestsURL(const std::string& utf8_url) override;
80 test_runner::TestPreferences* Preferences() override;
81 void ApplyPreferences() override;
82 virtual std::string makeURLErrorDescription(const blink::WebURLError& error);
83 void UseUnfortunateSynchronousResizeMode(bool enable) override;
84 void EnableAutoResizeMode(const blink::WebSize& min_size,
85 const blink::WebSize& max_size) override;
86 void DisableAutoResizeMode(const blink::WebSize& new_size) override;
87 void ClearDevToolsLocalStorage() override;
88 void ShowDevTools(const std::string& settings,
89 const std::string& frontend_url) override;
90 void CloseDevTools() override;
91 void EvaluateInWebInspector(long call_id, const std::string& script) override;
92 void ClearAllDatabases() override;
93 void SetDatabaseQuota(int quota) override;
94 void SimulateWebNotificationClick(const std::string& title,
95 int action_index) override;
96 void SetDeviceScaleFactor(float factor) override;
97 void SetDeviceColorProfile(const std::string& name) override;
98 void SetBluetoothMockDataSet(const std::string& name) override;
99 void SetBluetoothManualChooser() override;
100 std::vector<std::string> GetBluetoothManualChooserEvents() override;
101 void SendBluetoothManualChooserEvent(const std::string& event,
102 const std::string& argument) override;
103 void SetGeofencingMockProvider(bool service_available) override;
104 void ClearGeofencingMockProvider() override;
105 void SetGeofencingMockPosition(double latitude, double longitude) override;
106 void SetFocus(test_runner::WebTestProxyBase* proxy, bool focus) override;
107 void SetAcceptAllCookies(bool accept) override;
108 std::string PathToLocalResource(const std::string& resource) override;
109 void SetLocale(const std::string& locale) override;
110 void TestFinished() override;
111 void CloseRemainingWindows() override;
112 void DeleteAllCookies() override;
113 int NavigationEntryCount() override;
114 void GoToOffset(int offset) override;
115 void Reload() override;
116 void LoadURLForFrame(const blink::WebURL& url,
117 const std::string& frame_name) override;
118 bool AllowExternalPages() override;
119 std::string DumpHistoryForWindow(
120 test_runner::WebTestProxyBase* proxy) override;
121 void FetchManifest(
122 blink::WebView* view,
123 const GURL& url,
124 const base::Callback<void(const blink::WebURLResponse& response,
125 const std::string& data)>& callback) override;
126 void SetPermission(const std::string& name,
127 const std::string& value,
128 const GURL& origin,
129 const GURL& embedding_origin) override;
130 void ResetPermissions() override;
131 cc::SharedBitmapManager* GetSharedBitmapManager() override;
132 void DispatchBeforeInstallPromptEvent(
133 int request_id,
134 const std::vector<std::string>& event_platforms,
135 const base::Callback<void(bool)>& callback) override;
136 void ResolveBeforeInstallPromptPromise(
137 int request_id,
138 const std::string& platform) override;
139 blink::WebPlugin* CreatePluginPlaceholder(
140 blink::WebLocalFrame* frame,
141 const blink::WebPluginParams& params) override;
142 void OnWebTestProxyBaseDestroy(test_runner::WebTestProxyBase* proxy) override;
144 void Reset();
146 void set_proxy(test_runner::WebTestProxyBase* proxy) { proxy_ = proxy; }
147 test_runner::WebTestProxyBase* proxy() const { return proxy_; }
149 void ReportLeakDetectionResult(const LeakDetectionResult& result);
151 private:
152 // Message handlers.
153 void OnSetTestConfiguration(const ShellTestConfiguration& params);
154 void OnSessionHistory(
155 const std::vector<int>& routing_ids,
156 const std::vector<std::vector<PageState> >& session_histories,
157 const std::vector<unsigned>& current_entry_indexes);
158 void OnReset();
159 void OnNotifyDone();
160 void OnTryLeakDetection();
162 // After finishing the test, retrieves the audio, text, and pixel dumps from
163 // the TestRunner library and sends them to the browser process.
164 void CaptureDump();
165 void CaptureDumpPixels(const SkBitmap& snapshot);
166 void CaptureDumpComplete();
168 test_runner::WebTestProxyBase* proxy_;
170 RenderView* focused_view_;
172 test_runner::TestPreferences prefs_;
174 ShellTestConfiguration test_config_;
176 std::vector<int> routing_ids_;
177 std::vector<std::vector<PageState> > session_histories_;
178 std::vector<unsigned> current_entry_indexes_;
180 bool is_main_window_;
182 bool focus_on_next_commit_;
184 scoped_ptr<LeakDetector> leak_detector_;
185 bool needs_leak_detector_;
187 DISALLOW_COPY_AND_ASSIGN(BlinkTestRunner);
190 } // namespace content
192 #endif // CONTENT_SHELL_RENDERER_LAYOUT_TEST_BLINK_TEST_RUNNER_H_