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