Add support to content shell for app banner event layout tests.
[chromium-blink-merge.git] / content / shell / renderer / layout_test / blink_test_runner.h
blobaa08e03d1ba68649dd11ae4137168aac3def2a3d
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 "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 BlinkTestRunner : public RenderViewObserver,
39 public RenderViewObserverTracker<BlinkTestRunner>,
40 public WebTestDelegate {
41 public:
42 explicit BlinkTestRunner(RenderView* render_view);
43 ~BlinkTestRunner() 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(GamepadController* controller) 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 SimulateWebNotificationClick(const std::string& title) override;
92 void SetDeviceScaleFactor(float factor) override;
93 void SetDeviceColorProfile(const std::string& name) override;
94 void SetBluetoothMockDataSet(const std::string& name) override;
95 void SetGeofencingMockProvider(bool service_available) override;
96 void ClearGeofencingMockProvider() override;
97 void SetGeofencingMockPosition(double latitude, double longitude) 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;
112 void FetchManifest(
113 blink::WebView* view,
114 const GURL& url,
115 const base::Callback<void(const blink::WebURLResponse& response,
116 const std::string& data)>& callback) override;
117 void SetPermission(const std::string& name,
118 const std::string& value,
119 const GURL& origin,
120 const GURL& embedding_origin) override;
121 void ResetPermissions() override;
122 blink::WebLayer* InstantiateWebLayer(
123 scoped_refptr<cc::TextureLayer> layer) override;
124 cc::SharedBitmapManager* GetSharedBitmapManager() override;
125 void DispatchBeforeInstallPromptEvent(
126 int request_id,
127 const std::vector<std::string>& event_platforms,
128 const base::Callback<void(bool)>& callback) override;
129 void ResolveBeforeInstallPromptPromise(
130 int request_id,
131 const std::string& platform) override;
133 void Reset();
135 void set_proxy(WebTestProxyBase* proxy) { proxy_ = proxy; }
136 WebTestProxyBase* proxy() const { return proxy_; }
138 void ReportLeakDetectionResult(const LeakDetectionResult& result);
140 private:
141 // Message handlers.
142 void OnSetTestConfiguration(const ShellTestConfiguration& params);
143 void OnSessionHistory(
144 const std::vector<int>& routing_ids,
145 const std::vector<std::vector<PageState> >& session_histories,
146 const std::vector<unsigned>& current_entry_indexes);
147 void OnReset();
148 void OnNotifyDone();
149 void OnTryLeakDetection();
151 // After finishing the test, retrieves the audio, text, and pixel dumps from
152 // the TestRunner library and sends them to the browser process.
153 void CaptureDump();
154 void CaptureDumpPixels(const SkBitmap& snapshot);
155 void CaptureDumpComplete();
157 WebTestProxyBase* proxy_;
159 RenderView* focused_view_;
161 TestPreferences prefs_;
163 ShellTestConfiguration test_config_;
165 std::vector<int> routing_ids_;
166 std::vector<std::vector<PageState> > session_histories_;
167 std::vector<unsigned> current_entry_indexes_;
169 bool is_main_window_;
171 bool focus_on_next_commit_;
173 scoped_ptr<LeakDetector> leak_detector_;
174 bool needs_leak_detector_;
176 DISALLOW_COPY_AND_ASSIGN(BlinkTestRunner);
179 } // namespace content
181 #endif // CONTENT_SHELL_RENDERER_LAYOUT_TEST_BLINK_TEST_RUNNER_H_