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