Remove PlatformFile from profile_browsertest
[chromium-blink-merge.git] / content / shell / renderer / webkit_test_runner.h
blob0492d33fd8babae9a1c19a34171433734e59a410
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/WebPreferences.h"
17 #include "content/shell/renderer/test_runner/WebTestDelegate.h"
18 #include "third_party/WebKit/public/platform/WebScreenOrientation.h"
19 #include "v8/include/v8.h"
21 class SkCanvas;
23 namespace blink {
24 class WebDeviceMotionData;
25 class WebDeviceOrientationData;
26 struct WebRect;
29 namespace WebTestRunner {
30 class WebTestProxyBase;
33 namespace content {
35 class LeakDetector;
37 // This is the renderer side of the webkit test runner.
38 class WebKitTestRunner : public RenderViewObserver,
39 public RenderViewObserverTracker<WebKitTestRunner>,
40 public WebTestRunner::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::WebFrame* frame,
48 int world_id) OVERRIDE;
49 virtual void Navigate(const GURL& url) OVERRIDE;
50 virtual void DidCommitProvisionalLoad(blink::WebFrame* frame,
51 bool is_new_navigation) OVERRIDE;
52 virtual void DidFailProvisionalLoad(
53 blink::WebFrame* frame, const blink::WebURLError& error) OVERRIDE;
55 // WebTestDelegate implementation.
56 virtual void clearEditCommand() OVERRIDE;
57 virtual void setEditCommand(const std::string& name,
58 const std::string& value) OVERRIDE;
59 virtual void setGamepadData(const blink::WebGamepads& gamepads) OVERRIDE;
60 virtual void didConnectGamepad(int index,
61 const blink::WebGamepad& gamepad) OVERRIDE;
62 virtual void didDisconnectGamepad(int index,
63 const blink::WebGamepad& gamepad) OVERRIDE;
64 virtual void setDeviceMotionData(
65 const blink::WebDeviceMotionData& data) OVERRIDE;
66 virtual void setDeviceOrientationData(
67 const blink::WebDeviceOrientationData& data) OVERRIDE;
68 virtual void setScreenOrientation(
69 const blink::WebScreenOrientation& orientation) OVERRIDE;
70 virtual void printMessage(const std::string& message) OVERRIDE;
71 virtual void postTask(::WebTestRunner::WebTask* task) OVERRIDE;
72 virtual void postDelayedTask(::WebTestRunner::WebTask* task,
73 long long ms) OVERRIDE;
74 virtual blink::WebString registerIsolatedFileSystem(
75 const blink::WebVector<blink::WebString>& absolute_filenames) OVERRIDE;
76 virtual long long getCurrentTimeInMillisecond() OVERRIDE;
77 virtual blink::WebString getAbsoluteWebStringFromUTF8Path(
78 const std::string& utf8_path) OVERRIDE;
79 virtual blink::WebURL localFileToDataURL(
80 const blink::WebURL& file_url) OVERRIDE;
81 virtual blink::WebURL rewriteLayoutTestsURL(
82 const std::string& utf8_url) OVERRIDE;
83 virtual ::WebTestRunner::WebPreferences* preferences() OVERRIDE;
84 virtual void applyPreferences() OVERRIDE;
85 virtual std::string makeURLErrorDescription(const blink::WebURLError& error);
86 virtual void useUnfortunateSynchronousResizeMode(bool enable) OVERRIDE;
87 virtual void enableAutoResizeMode(const blink::WebSize& min_size,
88 const blink::WebSize& max_size) OVERRIDE;
89 virtual void disableAutoResizeMode(const blink::WebSize& new_size) OVERRIDE;
90 virtual void clearDevToolsLocalStorage() OVERRIDE;
91 virtual void showDevTools(const std::string& settings) OVERRIDE;
92 virtual void closeDevTools() OVERRIDE;
93 virtual void evaluateInWebInspector(long call_id,
94 const std::string& script) OVERRIDE;
95 virtual void clearAllDatabases() OVERRIDE;
96 virtual void setDatabaseQuota(int quota) OVERRIDE;
97 virtual void setDeviceScaleFactor(float factor) OVERRIDE;
98 virtual void setFocus(WebTestRunner::WebTestProxyBase* proxy,
99 bool focus) OVERRIDE;
100 virtual void setAcceptAllCookies(bool accept) OVERRIDE;
101 virtual std::string pathToLocalResource(const std::string& resource) OVERRIDE;
102 virtual void setLocale(const std::string& locale) OVERRIDE;
103 virtual void testFinished() OVERRIDE;
104 virtual void closeRemainingWindows() OVERRIDE;
105 virtual void deleteAllCookies() OVERRIDE;
106 virtual int navigationEntryCount() OVERRIDE;
107 virtual void goToOffset(int offset) OVERRIDE;
108 virtual void reload() OVERRIDE;
109 virtual void loadURLForFrame(const blink::WebURL& url,
110 const std::string& frame_name) OVERRIDE;
111 virtual bool allowExternalPages() OVERRIDE;
112 virtual void captureHistoryForWindow(
113 WebTestRunner::WebTestProxyBase* proxy,
114 blink::WebVector<blink::WebHistoryItem>* history,
115 size_t* currentEntryIndex) OVERRIDE;
117 void Reset();
119 void set_proxy(::WebTestRunner::WebTestProxyBase* proxy) { proxy_ = proxy; }
120 ::WebTestRunner::WebTestProxyBase* proxy() const { return proxy_; }
122 private:
123 // Message handlers.
124 void OnSetTestConfiguration(const ShellTestConfiguration& params);
125 void OnSessionHistory(
126 const std::vector<int>& routing_ids,
127 const std::vector<std::vector<PageState> >& session_histories,
128 const std::vector<unsigned>& current_entry_indexes);
129 void OnReset();
130 void OnNotifyDone();
131 void OnTryLeakDetection();
133 // After finishing the test, retrieves the audio, text, and pixel dumps from
134 // the TestRunner library and sends them to the browser process.
135 void CaptureDump();
137 void TryLeakDetection();
139 ::WebTestRunner::WebTestProxyBase* proxy_;
141 RenderView* focused_view_;
143 ::WebTestRunner::WebPreferences prefs_;
145 ShellTestConfiguration test_config_;
147 std::vector<int> routing_ids_;
148 std::vector<std::vector<PageState> > session_histories_;
149 std::vector<unsigned> current_entry_indexes_;
151 bool is_main_window_;
153 bool focus_on_next_commit_;
155 scoped_ptr<LeakDetector> leak_detector_;
156 bool needs_leak_detector_;
158 DISALLOW_COPY_AND_ASSIGN(WebKitTestRunner);
161 } // namespace content
163 #endif // CONTENT_SHELL_WEBKIT_TEST_RUNNER_H_