[email protected] | cccb5cf | 2012-06-06 22:20:04 | [diff] [blame] | 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. |
| 4 | |
[email protected] | 9b4c6cd | 2012-08-20 10:47:45 | [diff] [blame] | 5 | #ifndef CONTENT_SHELL_WEBKIT_TEST_RUNNER_H_ |
| 6 | #define CONTENT_SHELL_WEBKIT_TEST_RUNNER_H_ |
[email protected] | cccb5cf | 2012-06-06 22:20:04 | [diff] [blame] | 7 | |
[email protected] | 8f72269 | 2013-02-23 14:14:06 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 10 | #include "base/files/file_path.h" |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 11 | #include "base/memory/scoped_ptr.h" |
[email protected] | cccb5cf | 2012-06-06 22:20:04 | [diff] [blame] | 12 | #include "content/public/renderer/render_view_observer.h" |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 13 | #include "content/public/renderer/render_view_observer_tracker.h" |
[email protected] | 4f92df8 | 2013-03-07 13:21:13 | [diff] [blame] | 14 | #include "content/shell/shell_test_configuration.h" |
[email protected] | 55915a7 | 2012-12-18 11:55:25 | [diff] [blame] | 15 | #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebPreferences.h" |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 16 | #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h" |
[email protected] | 375db13a | 2012-12-18 21:42:58 | [diff] [blame] | 17 | #include "v8/include/v8.h" |
[email protected] | cccb5cf | 2012-06-06 22:20:04 | [diff] [blame] | 18 | |
[email protected] | b9fad24c | 2012-11-15 08:22:10 | [diff] [blame] | 19 | class SkCanvas; |
| 20 | |
| 21 | namespace WebKit { |
| 22 | struct WebRect; |
| 23 | } |
| 24 | |
| 25 | namespace WebTestRunner { |
| 26 | class WebTestProxyBase; |
| 27 | } |
| 28 | |
[email protected] | cccb5cf | 2012-06-06 22:20:04 | [diff] [blame] | 29 | namespace content { |
| 30 | |
[email protected] | 9b4c6cd | 2012-08-20 10:47:45 | [diff] [blame] | 31 | // This is the renderer side of the webkit test runner. |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 32 | class WebKitTestRunner : public RenderViewObserver, |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 33 | public RenderViewObserverTracker<WebKitTestRunner>, |
[email protected] | 18dd151 | 2013-01-31 11:37:08 | [diff] [blame] | 34 | public WebTestRunner::WebTestDelegate { |
[email protected] | cccb5cf | 2012-06-06 22:20:04 | [diff] [blame] | 35 | public: |
[email protected] | 9b4c6cd | 2012-08-20 10:47:45 | [diff] [blame] | 36 | explicit WebKitTestRunner(RenderView* render_view); |
| 37 | virtual ~WebKitTestRunner(); |
[email protected] | cccb5cf | 2012-06-06 22:20:04 | [diff] [blame] | 38 | |
| 39 | // RenderViewObserver implementation. |
| 40 | virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
[email protected] | 96b80b47 | 2012-07-03 19:41:56 | [diff] [blame] | 41 | virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; |
[email protected] | 37d9dcce | 2013-03-22 22:27:45 | [diff] [blame] | 42 | 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] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 47 | |
| 48 | // WebTestDelegate implementation. |
[email protected] | 0c3ec6f3 | 2012-11-07 22:23:28 | [diff] [blame] | 49 | virtual void clearEditCommand(); |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 50 | virtual void setEditCommand(const std::string& name, |
[email protected] | 0c3ec6f3 | 2012-11-07 22:23:28 | [diff] [blame] | 51 | const std::string& value); |
[email protected] | 0c3ec6f3 | 2012-11-07 22:23:28 | [diff] [blame] | 52 | virtual void setGamepadData(const WebKit::WebGamepads& gamepads); |
| 53 | virtual void printMessage(const std::string& message); |
[email protected] | 0b0e3146 | 2012-12-18 21:57:18 | [diff] [blame] | 54 | virtual void postTask(::WebTestRunner::WebTask* task); |
| 55 | virtual void postDelayedTask(::WebTestRunner::WebTask* task, |
[email protected] | 0c3ec6f3 | 2012-11-07 22:23:28 | [diff] [blame] | 56 | long long ms); |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 57 | virtual WebKit::WebString registerIsolatedFileSystem( |
[email protected] | 0c3ec6f3 | 2012-11-07 22:23:28 | [diff] [blame] | 58 | const WebKit::WebVector<WebKit::WebString>& absolute_filenames); |
| 59 | virtual long long getCurrentTimeInMillisecond(); |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 60 | virtual WebKit::WebString getAbsoluteWebStringFromUTF8Path( |
[email protected] | 0c3ec6f3 | 2012-11-07 22:23:28 | [diff] [blame] | 61 | const std::string& utf8_path); |
[email protected] | 09ec9f9 | 2012-12-17 09:46:36 | [diff] [blame] | 62 | virtual WebKit::WebURL localFileToDataURL(const WebKit::WebURL& file_url); |
| 63 | virtual WebKit::WebURL rewriteLayoutTestsURL(const std::string& utf8_url); |
[email protected] | 0b0e3146 | 2012-12-18 21:57:18 | [diff] [blame] | 64 | virtual ::WebTestRunner::WebPreferences* preferences(); |
[email protected] | b3dbcb5e | 2012-12-17 00:16:37 | [diff] [blame] | 65 | virtual void applyPreferences(); |
[email protected] | 9d9ec98 | 2013-01-10 18:53:39 | [diff] [blame] | 66 | virtual std::string makeURLErrorDescription(const WebKit::WebURLError& error); |
[email protected] | 29e8270 | 2013-02-14 12:56:40 | [diff] [blame] | 67 | 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] | 83654ec | 2013-03-04 15:58:53 | [diff] [blame] | 74 | virtual void setFocus(WebTestRunner::WebTestProxyBase* proxy, bool focus); |
[email protected] | 29e8270 | 2013-02-14 12:56:40 | [diff] [blame] | 75 | virtual void setAcceptAllCookies(bool accept); |
| 76 | virtual std::string pathToLocalResource(const std::string& resource); |
| 77 | virtual void setLocale(const std::string& locale); |
[email protected] | 29e8270 | 2013-02-14 12:56:40 | [diff] [blame] | 78 | 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] | 29e8270 | 2013-02-14 12:56:40 | [diff] [blame] | 84 | 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] | 9063bf6 | 2013-02-20 19:42:01 | [diff] [blame] | 90 | WebTestRunner::WebTestProxyBase* proxy, |
[email protected] | 29e8270 | 2013-02-14 12:56:40 | [diff] [blame] | 91 | WebKit::WebVector<WebKit::WebHistoryItem>* history, |
| 92 | size_t* currentEntryIndex); |
[email protected] | cccb5cf | 2012-06-06 22:20:04 | [diff] [blame] | 93 | |
[email protected] | 324825d | 2012-11-30 12:37:15 | [diff] [blame] | 94 | void Reset(); |
[email protected] | b9fad24c | 2012-11-15 08:22:10 | [diff] [blame] | 95 | |
[email protected] | 0b0e3146 | 2012-12-18 21:57:18 | [diff] [blame] | 96 | void set_proxy(::WebTestRunner::WebTestProxyBase* proxy) { proxy_ = proxy; } |
[email protected] | 5f20df36 | 2013-02-15 19:48:19 | [diff] [blame] | 97 | ::WebTestRunner::WebTestProxyBase* proxy() const { return proxy_; } |
[email protected] | b9fad24c | 2012-11-15 08:22:10 | [diff] [blame] | 98 | |
[email protected] | cccb5cf | 2012-06-06 22:20:04 | [diff] [blame] | 99 | private: |
| 100 | // Message handlers. |
[email protected] | 4f92df8 | 2013-03-07 13:21:13 | [diff] [blame] | 101 | void OnSetTestConfiguration(const ShellTestConfiguration& params); |
[email protected] | 8f72269 | 2013-02-23 14:14:06 | [diff] [blame] | 102 | 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] | 1afb9af | 2013-03-18 15:30:32 | [diff] [blame] | 106 | void OnReset(); |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 107 | |
[email protected] | 8f72269 | 2013-02-23 14:14:06 | [diff] [blame] | 108 | // 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] | 0ac1a03 | 2013-02-12 12:53:37 | [diff] [blame] | 110 | void CaptureDump(); |
[email protected] | b9fad24c | 2012-11-15 08:22:10 | [diff] [blame] | 111 | |
[email protected] | 0b0e3146 | 2012-12-18 21:57:18 | [diff] [blame] | 112 | ::WebTestRunner::WebTestProxyBase* proxy_; |
[email protected] | b9fad24c | 2012-11-15 08:22:10 | [diff] [blame] | 113 | |
[email protected] | 95026a0 | 2013-03-05 08:34:30 | [diff] [blame] | 114 | RenderView* focused_view_; |
| 115 | |
[email protected] | 0b0e3146 | 2012-12-18 21:57:18 | [diff] [blame] | 116 | ::WebTestRunner::WebPreferences prefs_; |
| 117 | |
[email protected] | 4f92df8 | 2013-03-07 13:21:13 | [diff] [blame] | 118 | ShellTestConfiguration test_config_; |
[email protected] | b9fad24c | 2012-11-15 08:22:10 | [diff] [blame] | 119 | |
[email protected] | 8f72269 | 2013-02-23 14:14:06 | [diff] [blame] | 120 | std::vector<int> routing_ids_; |
| 121 | std::vector<std::vector<std::string> > session_histories_; |
| 122 | std::vector<unsigned> current_entry_indexes_; |
| 123 | |
[email protected] | 5f20df36 | 2013-02-15 19:48:19 | [diff] [blame] | 124 | bool is_main_window_; |
| 125 | |
[email protected] | 37d9dcce | 2013-03-22 22:27:45 | [diff] [blame] | 126 | bool focus_on_next_commit_; |
| 127 | |
[email protected] | 9b4c6cd | 2012-08-20 10:47:45 | [diff] [blame] | 128 | DISALLOW_COPY_AND_ASSIGN(WebKitTestRunner); |
[email protected] | cccb5cf | 2012-06-06 22:20:04 | [diff] [blame] | 129 | }; |
| 130 | |
| 131 | } // namespace content |
| 132 | |
[email protected] | 9b4c6cd | 2012-08-20 10:47:45 | [diff] [blame] | 133 | #endif // CONTENT_SHELL_WEBKIT_TEST_RUNNER_H_ |