blob: 860378db2b8bcc35ae392977fb4b1252685e84f5 [file] [log] [blame]
[email protected]cccb5cf2012-06-06 22:20:041// 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.
4
[email protected]9b4c6cd2012-08-20 10:47:455#ifndef CONTENT_SHELL_WEBKIT_TEST_RUNNER_H_
6#define CONTENT_SHELL_WEBKIT_TEST_RUNNER_H_
[email protected]cccb5cf2012-06-06 22:20:047
[email protected]8f722692013-02-23 14:14:068#include <vector>
9
[email protected]57999812013-02-24 05:40:5210#include "base/files/file_path.h"
[email protected]b2324b092012-11-01 10:34:1111#include "base/memory/scoped_ptr.h"
[email protected]cccb5cf2012-06-06 22:20:0412#include "content/public/renderer/render_view_observer.h"
[email protected]075366912013-02-18 07:13:2413#include "content/public/renderer/render_view_observer_tracker.h"
[email protected]4f92df82013-03-07 13:21:1314#include "content/shell/shell_test_configuration.h"
[email protected]55915a72012-12-18 11:55:2515#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebPreferences.h"
[email protected]b2324b092012-11-01 10:34:1116#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h"
[email protected]375db13a2012-12-18 21:42:5817#include "v8/include/v8.h"
[email protected]cccb5cf2012-06-06 22:20:0418
[email protected]b9fad24c2012-11-15 08:22:1019class SkCanvas;
20
21namespace WebKit {
22struct WebRect;
23}
24
25namespace WebTestRunner {
26class WebTestProxyBase;
27}
28
[email protected]cccb5cf2012-06-06 22:20:0429namespace content {
30
[email protected]9b4c6cd2012-08-20 10:47:4531// This is the renderer side of the webkit test runner.
[email protected]b2324b092012-11-01 10:34:1132class WebKitTestRunner : public RenderViewObserver,
[email protected]075366912013-02-18 07:13:2433 public RenderViewObserverTracker<WebKitTestRunner>,
[email protected]18dd1512013-01-31 11:37:0834 public WebTestRunner::WebTestDelegate {
[email protected]cccb5cf2012-06-06 22:20:0435 public:
[email protected]9b4c6cd2012-08-20 10:47:4536 explicit WebKitTestRunner(RenderView* render_view);
37 virtual ~WebKitTestRunner();
[email protected]cccb5cf2012-06-06 22:20:0438
39 // RenderViewObserver implementation.
40 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
[email protected]96b80b472012-07-03 19:41:5641 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE;
[email protected]37d9dcce2013-03-22 22:27:4542 virtual void Navigate(const GURL& url) OVERRIDE;
43 virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame,
44 bool is_new_navigation) OVERRIDE;
45 virtual void DidFailProvisionalLoad(
46 WebKit::WebFrame* frame, const WebKit::WebURLError& error) OVERRIDE;
[email protected]b2324b092012-11-01 10:34:1147
48 // WebTestDelegate implementation.
[email protected]0c3ec6f32012-11-07 22:23:2849 virtual void clearEditCommand();
[email protected]b2324b092012-11-01 10:34:1150 virtual void setEditCommand(const std::string& name,
[email protected]0c3ec6f32012-11-07 22:23:2851 const std::string& value);
[email protected]0c3ec6f32012-11-07 22:23:2852 virtual void setGamepadData(const WebKit::WebGamepads& gamepads);
53 virtual void printMessage(const std::string& message);
[email protected]0b0e31462012-12-18 21:57:1854 virtual void postTask(::WebTestRunner::WebTask* task);
55 virtual void postDelayedTask(::WebTestRunner::WebTask* task,
[email protected]0c3ec6f32012-11-07 22:23:2856 long long ms);
[email protected]b2324b092012-11-01 10:34:1157 virtual WebKit::WebString registerIsolatedFileSystem(
[email protected]0c3ec6f32012-11-07 22:23:2858 const WebKit::WebVector<WebKit::WebString>& absolute_filenames);
59 virtual long long getCurrentTimeInMillisecond();
[email protected]b2324b092012-11-01 10:34:1160 virtual WebKit::WebString getAbsoluteWebStringFromUTF8Path(
[email protected]0c3ec6f32012-11-07 22:23:2861 const std::string& utf8_path);
[email protected]09ec9f92012-12-17 09:46:3662 virtual WebKit::WebURL localFileToDataURL(const WebKit::WebURL& file_url);
63 virtual WebKit::WebURL rewriteLayoutTestsURL(const std::string& utf8_url);
[email protected]0b0e31462012-12-18 21:57:1864 virtual ::WebTestRunner::WebPreferences* preferences();
[email protected]b3dbcb5e2012-12-17 00:16:3765 virtual void applyPreferences();
[email protected]9d9ec982013-01-10 18:53:3966 virtual std::string makeURLErrorDescription(const WebKit::WebURLError& error);
[email protected]29e82702013-02-14 12:56:4067 virtual void setClientWindowRect(const WebKit::WebRect& rect);
68 virtual void showDevTools();
69 virtual void closeDevTools();
70 virtual void evaluateInWebInspector(long call_id, const std::string& script);
71 virtual void clearAllDatabases();
72 virtual void setDatabaseQuota(int quota);
73 virtual void setDeviceScaleFactor(float factor);
[email protected]83654ec2013-03-04 15:58:5374 virtual void setFocus(WebTestRunner::WebTestProxyBase* proxy, bool focus);
[email protected]29e82702013-02-14 12:56:4075 virtual void setAcceptAllCookies(bool accept);
76 virtual std::string pathToLocalResource(const std::string& resource);
77 virtual void setLocale(const std::string& locale);
[email protected]29e82702013-02-14 12:56:4078 virtual void testFinished();
79 virtual void testTimedOut();
80 virtual bool isBeingDebugged();
81 virtual int layoutTestTimeout();
82 virtual void closeRemainingWindows();
83 virtual int navigationEntryCount();
[email protected]29e82702013-02-14 12:56:4084 virtual void goToOffset(int offset);
85 virtual void reload();
86 virtual void loadURLForFrame(const WebKit::WebURL& url,
87 const std::string& frame_name);
88 virtual bool allowExternalPages();
89 virtual void captureHistoryForWindow(
[email protected]9063bf62013-02-20 19:42:0190 WebTestRunner::WebTestProxyBase* proxy,
[email protected]29e82702013-02-14 12:56:4091 WebKit::WebVector<WebKit::WebHistoryItem>* history,
92 size_t* currentEntryIndex);
[email protected]cccb5cf2012-06-06 22:20:0493
[email protected]324825d2012-11-30 12:37:1594 void Reset();
[email protected]b9fad24c2012-11-15 08:22:1095
[email protected]0b0e31462012-12-18 21:57:1896 void set_proxy(::WebTestRunner::WebTestProxyBase* proxy) { proxy_ = proxy; }
[email protected]5f20df362013-02-15 19:48:1997 ::WebTestRunner::WebTestProxyBase* proxy() const { return proxy_; }
[email protected]b9fad24c2012-11-15 08:22:1098
[email protected]cccb5cf2012-06-06 22:20:0499 private:
100 // Message handlers.
[email protected]4f92df82013-03-07 13:21:13101 void OnSetTestConfiguration(const ShellTestConfiguration& params);
[email protected]8f722692013-02-23 14:14:06102 void OnSessionHistory(
103 const std::vector<int>& routing_ids,
104 const std::vector<std::vector<std::string> >& session_histories,
105 const std::vector<unsigned>& current_entry_indexes);
[email protected]1afb9af2013-03-18 15:30:32106 void OnReset();
[email protected]b2324b092012-11-01 10:34:11107
[email protected]8f722692013-02-23 14:14:06108 // After finishing the test, retrieves the audio, text, and pixel dumps from
109 // the TestRunner library and sends them to the browser process.
[email protected]0ac1a032013-02-12 12:53:37110 void CaptureDump();
[email protected]b9fad24c2012-11-15 08:22:10111
[email protected]0b0e31462012-12-18 21:57:18112 ::WebTestRunner::WebTestProxyBase* proxy_;
[email protected]b9fad24c2012-11-15 08:22:10113
[email protected]95026a02013-03-05 08:34:30114 RenderView* focused_view_;
115
[email protected]0b0e31462012-12-18 21:57:18116 ::WebTestRunner::WebPreferences prefs_;
117
[email protected]4f92df82013-03-07 13:21:13118 ShellTestConfiguration test_config_;
[email protected]b9fad24c2012-11-15 08:22:10119
[email protected]8f722692013-02-23 14:14:06120 std::vector<int> routing_ids_;
121 std::vector<std::vector<std::string> > session_histories_;
122 std::vector<unsigned> current_entry_indexes_;
123
[email protected]5f20df362013-02-15 19:48:19124 bool is_main_window_;
125
[email protected]37d9dcce2013-03-22 22:27:45126 bool focus_on_next_commit_;
127
[email protected]9b4c6cd2012-08-20 10:47:45128 DISALLOW_COPY_AND_ASSIGN(WebKitTestRunner);
[email protected]cccb5cf2012-06-06 22:20:04129};
130
131} // namespace content
132
[email protected]9b4c6cd2012-08-20 10:47:45133#endif // CONTENT_SHELL_WEBKIT_TEST_RUNNER_H_