IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / shell / renderer / webkit_test_runner.h
blobab29437106613df05953e0b99efd3f4f960475e1
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 "v8/include/v8.h"
20 class SkCanvas;
22 namespace blink {
23 class WebDeviceMotionData;
24 class WebDeviceOrientationData;
25 struct WebRect;
28 namespace WebTestRunner {
29 class WebTestProxyBase;
32 namespace content {
34 // This is the renderer side of the webkit test runner.
35 class WebKitTestRunner : public RenderViewObserver,
36 public RenderViewObserverTracker<WebKitTestRunner>,
37 public WebTestRunner::WebTestDelegate {
38 public:
39 explicit WebKitTestRunner(RenderView* render_view);
40 virtual ~WebKitTestRunner();
42 // RenderViewObserver implementation.
43 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
44 virtual void DidClearWindowObject(blink::WebFrame* frame) OVERRIDE;
45 virtual void Navigate(const GURL& url) OVERRIDE;
46 virtual void DidCommitProvisionalLoad(blink::WebFrame* frame,
47 bool is_new_navigation) OVERRIDE;
48 virtual void DidFailProvisionalLoad(
49 blink::WebFrame* frame, const blink::WebURLError& error) OVERRIDE;
51 // WebTestDelegate implementation.
52 virtual void clearEditCommand() OVERRIDE;
53 virtual void setEditCommand(const std::string& name,
54 const std::string& value) OVERRIDE;
55 virtual void setGamepadData(const blink::WebGamepads& gamepads) OVERRIDE;
56 virtual void setDeviceMotionData(
57 const blink::WebDeviceMotionData& data) OVERRIDE;
58 virtual void setDeviceOrientationData(
59 const blink::WebDeviceOrientationData& data) OVERRIDE;
60 virtual void printMessage(const std::string& message) OVERRIDE;
61 virtual void postTask(::WebTestRunner::WebTask* task) OVERRIDE;
62 virtual void postDelayedTask(::WebTestRunner::WebTask* task,
63 long long ms) OVERRIDE;
64 virtual blink::WebString registerIsolatedFileSystem(
65 const blink::WebVector<blink::WebString>& absolute_filenames) OVERRIDE;
66 virtual long long getCurrentTimeInMillisecond() OVERRIDE;
67 virtual blink::WebString getAbsoluteWebStringFromUTF8Path(
68 const std::string& utf8_path) OVERRIDE;
69 virtual blink::WebURL localFileToDataURL(
70 const blink::WebURL& file_url) OVERRIDE;
71 virtual blink::WebURL rewriteLayoutTestsURL(
72 const std::string& utf8_url) OVERRIDE;
73 virtual ::WebTestRunner::WebPreferences* preferences() OVERRIDE;
74 virtual void applyPreferences() OVERRIDE;
75 virtual std::string makeURLErrorDescription(const blink::WebURLError& error);
76 virtual void useUnfortunateSynchronousResizeMode(bool enable) OVERRIDE;
77 virtual void enableAutoResizeMode(const blink::WebSize& min_size,
78 const blink::WebSize& max_size) OVERRIDE;
79 virtual void disableAutoResizeMode(const blink::WebSize& new_size) OVERRIDE;
80 virtual void showDevTools() OVERRIDE;
81 virtual void closeDevTools() OVERRIDE;
82 virtual void evaluateInWebInspector(long call_id,
83 const std::string& script) OVERRIDE;
84 virtual void clearAllDatabases() OVERRIDE;
85 virtual void setDatabaseQuota(int quota) OVERRIDE;
86 virtual void setDeviceScaleFactor(float factor) OVERRIDE;
87 virtual void setFocus(WebTestRunner::WebTestProxyBase* proxy,
88 bool focus) OVERRIDE;
89 virtual void setAcceptAllCookies(bool accept) OVERRIDE;
90 virtual std::string pathToLocalResource(const std::string& resource) OVERRIDE;
91 virtual void setLocale(const std::string& locale) OVERRIDE;
92 virtual void testFinished() OVERRIDE;
93 virtual void closeRemainingWindows() OVERRIDE;
94 virtual void deleteAllCookies() OVERRIDE;
95 virtual int navigationEntryCount() OVERRIDE;
96 virtual void goToOffset(int offset) OVERRIDE;
97 virtual void reload() OVERRIDE;
98 virtual void loadURLForFrame(const blink::WebURL& url,
99 const std::string& frame_name) OVERRIDE;
100 virtual bool allowExternalPages() OVERRIDE;
101 virtual void captureHistoryForWindow(
102 WebTestRunner::WebTestProxyBase* proxy,
103 blink::WebVector<blink::WebHistoryItem>* history,
104 size_t* currentEntryIndex) OVERRIDE;
106 void Reset();
108 void set_proxy(::WebTestRunner::WebTestProxyBase* proxy) { proxy_ = proxy; }
109 ::WebTestRunner::WebTestProxyBase* proxy() const { return proxy_; }
111 private:
112 // Message handlers.
113 void OnSetTestConfiguration(const ShellTestConfiguration& params);
114 void OnSessionHistory(
115 const std::vector<int>& routing_ids,
116 const std::vector<std::vector<PageState> >& session_histories,
117 const std::vector<unsigned>& current_entry_indexes);
118 void OnReset();
119 void OnNotifyDone();
121 // After finishing the test, retrieves the audio, text, and pixel dumps from
122 // the TestRunner library and sends them to the browser process.
123 void CaptureDump();
125 ::WebTestRunner::WebTestProxyBase* proxy_;
127 RenderView* focused_view_;
129 ::WebTestRunner::WebPreferences prefs_;
131 ShellTestConfiguration test_config_;
133 std::vector<int> routing_ids_;
134 std::vector<std::vector<PageState> > session_histories_;
135 std::vector<unsigned> current_entry_indexes_;
137 bool is_main_window_;
139 bool focus_on_next_commit_;
141 DISALLOW_COPY_AND_ASSIGN(WebKitTestRunner);
144 } // namespace content
146 #endif // CONTENT_SHELL_WEBKIT_TEST_RUNNER_H_