diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2012-10-23 10:25:11 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-10-23 10:25:11 +0200 |
commit | 5ea819f80c6840c492386bfafbffb059c7e2091f (patch) | |
tree | 42ad0b1d82eff090d14278a088ea0f4840a0f938 /Tools/DumpRenderTree | |
parent | 43a42f108af6bcbd91f2672731c3047c26213af1 (diff) | |
download | qtwebkit-5ea819f80c6840c492386bfafbffb059c7e2091f.tar.gz |
Imported WebKit commit 20434eb8eb95065803473139d8794e98a7672f75 (http://svn.webkit.org/repository/webkit/trunk@132191)
New snapshot that should fix build with latest qtbase and the QPlastiqueStyle removal
Diffstat (limited to 'Tools/DumpRenderTree')
32 files changed, 402 insertions, 181 deletions
diff --git a/Tools/DumpRenderTree/DumpRenderTree.gypi b/Tools/DumpRenderTree/DumpRenderTree.gypi index 7e7d69bad..26722ece7 100644 --- a/Tools/DumpRenderTree/DumpRenderTree.gypi +++ b/Tools/DumpRenderTree/DumpRenderTree.gypi @@ -30,6 +30,8 @@ 'chromium/MockWebSpeechRecognizer.h', 'chromium/NotificationPresenter.h', 'chromium/NotificationPresenter.cpp', + 'chromium/Task.h', + 'chromium/Task.cpp', 'chromium/TestEventPrinter.h', 'chromium/TestEventPrinter.cpp', 'chromium/TestNavigationController.cpp', @@ -67,6 +69,7 @@ 'chromium/TestRunner/public/WebAccessibilityController.h', 'chromium/TestRunner/public/WebTestDelegate.h', 'chromium/TestRunner/public/WebEventSender.h', + 'chromium/TestRunner/public/WebTask.h', 'chromium/TestRunner/public/WebTestInterfaces.h', 'chromium/TestRunner/src/AccessibilityControllerChromium.cpp', 'chromium/TestRunner/src/AccessibilityControllerChromium.h', @@ -80,8 +83,6 @@ 'chromium/TestRunner/src/EventSender.h', 'chromium/TestRunner/src/GamepadController.cpp', 'chromium/TestRunner/src/GamepadController.h', - 'chromium/TestRunner/src/Task.cpp', - 'chromium/TestRunner/src/Task.h', 'chromium/TestRunner/src/TestInterfaces.cpp', 'chromium/TestRunner/src/TestInterfaces.h', 'chromium/TestRunner/src/TextInputController.cpp', @@ -90,6 +91,7 @@ 'chromium/TestRunner/src/TestRunner.h', 'chromium/TestRunner/src/WebAccessibilityController.cpp', 'chromium/TestRunner/src/WebEventSender.cpp', + 'chromium/TestRunner/src/WebTask.cpp', 'chromium/TestRunner/src/WebTestInterfaces.cpp', ], 'test_plugin_files': [ diff --git a/Tools/DumpRenderTree/chromium/DRTDevToolsAgent.cpp b/Tools/DumpRenderTree/chromium/DRTDevToolsAgent.cpp index b6659a47f..eb21b2c85 100644 --- a/Tools/DumpRenderTree/chromium/DRTDevToolsAgent.cpp +++ b/Tools/DumpRenderTree/chromium/DRTDevToolsAgent.cpp @@ -33,12 +33,14 @@ #include "DRTDevToolsClient.h" +#include "Task.h" #include "platform/WebCString.h" #include "WebDevToolsAgent.h" #include "WebView.h" #include "webkit/support/webkit_support.h" using namespace WebKit; +using namespace WebTestRunner; DRTDevToolsAgent::DRTDevToolsAgent() : m_drtDevToolsClient(0) diff --git a/Tools/DumpRenderTree/chromium/DRTDevToolsAgent.h b/Tools/DumpRenderTree/chromium/DRTDevToolsAgent.h index d066b7a71..c13aef7fa 100644 --- a/Tools/DumpRenderTree/chromium/DRTDevToolsAgent.h +++ b/Tools/DumpRenderTree/chromium/DRTDevToolsAgent.h @@ -31,8 +31,8 @@ #ifndef DRTDevToolsAgent_h #define DRTDevToolsAgent_h -#include "TestRunner/src/Task.h" #include "WebDevToolsAgentClient.h" +#include "WebTask.h" #include "platform/WebString.h" #include <wtf/HashMap.h> #include <wtf/Noncopyable.h> @@ -69,23 +69,23 @@ public: void detach(); bool evaluateInWebInspector(long callID, const std::string& script); - TaskList* taskList() { return &m_taskList; } + WebTestRunner::WebTaskList* taskList() { return &m_taskList; } private: void call(const WebKit::WebString& args); WebKit::WebDevToolsAgent* webDevToolsAgent(); - class AsyncCallTask: public MethodTask<DRTDevToolsAgent> { + class AsyncCallTask: public WebTestRunner::WebMethodTask<DRTDevToolsAgent> { public: AsyncCallTask(DRTDevToolsAgent* object, const WebKit::WebString& args) - : MethodTask<DRTDevToolsAgent>(object), m_args(args) { } + : WebTestRunner::WebMethodTask<DRTDevToolsAgent>(object), m_args(args) { } virtual void runIfValid() { m_object->call(m_args); } private: WebKit::WebString m_args; }; - TaskList m_taskList; + WebTestRunner::WebTaskList m_taskList; DRTDevToolsClient* m_drtDevToolsClient; int m_routingID; WebKit::WebView* m_webView; diff --git a/Tools/DumpRenderTree/chromium/DRTDevToolsClient.cpp b/Tools/DumpRenderTree/chromium/DRTDevToolsClient.cpp index a7fc4d048..08df1d52a 100644 --- a/Tools/DumpRenderTree/chromium/DRTDevToolsClient.cpp +++ b/Tools/DumpRenderTree/chromium/DRTDevToolsClient.cpp @@ -32,6 +32,7 @@ #include "DRTDevToolsClient.h" #include "DRTDevToolsAgent.h" +#include "Task.h" #include "WebDevToolsAgent.h" #include "WebDevToolsFrontend.h" #include "WebFrame.h" @@ -41,6 +42,7 @@ #include <wtf/PassOwnPtr.h> using namespace WebKit; +using namespace WebTestRunner; DRTDevToolsClient::DRTDevToolsClient(DRTDevToolsAgent* agent, WebView* webView) : m_webView(webView) diff --git a/Tools/DumpRenderTree/chromium/DRTDevToolsClient.h b/Tools/DumpRenderTree/chromium/DRTDevToolsClient.h index ead396379..5f486ddd0 100644 --- a/Tools/DumpRenderTree/chromium/DRTDevToolsClient.h +++ b/Tools/DumpRenderTree/chromium/DRTDevToolsClient.h @@ -31,8 +31,8 @@ #ifndef DRTDevToolsClient_h #define DRTDevToolsClient_h -#include "TestRunner/src/Task.h" #include "WebDevToolsFrontendClient.h" +#include "WebTask.h" #include "platform/WebString.h" #include <wtf/Noncopyable.h> #include <wtf/OwnPtr.h> @@ -64,21 +64,21 @@ public: void asyncCall(const WebKit::WebString& args); void allMessagesProcessed(); - TaskList* taskList() { return &m_taskList; } + WebTestRunner::WebTaskList* taskList() { return &m_taskList; } private: void call(const WebKit::WebString& args); - class AsyncCallTask: public MethodTask<DRTDevToolsClient> { + class AsyncCallTask: public WebTestRunner::WebMethodTask<DRTDevToolsClient> { public: AsyncCallTask(DRTDevToolsClient* object, const WebKit::WebString& args) - : MethodTask<DRTDevToolsClient>(object), m_args(args) { } + : WebTestRunner::WebMethodTask<DRTDevToolsClient>(object), m_args(args) { } virtual void runIfValid() { m_object->call(m_args); } private: WebKit::WebString m_args; }; - TaskList m_taskList; + WebTestRunner::WebTaskList m_taskList; WebKit::WebView* m_webView; DRTDevToolsAgent* m_drtDevToolsAgent; WTF::OwnPtr<WebKit::WebDevToolsFrontend> m_webDevToolsFrontend; diff --git a/Tools/DumpRenderTree/chromium/DRTTestRunner.cpp b/Tools/DumpRenderTree/chromium/DRTTestRunner.cpp index 082597a11..b31d7da70 100644 --- a/Tools/DumpRenderTree/chromium/DRTTestRunner.cpp +++ b/Tools/DumpRenderTree/chromium/DRTTestRunner.cpp @@ -36,6 +36,7 @@ #include "DRTDevToolsAgent.h" #include "MockWebSpeechInputController.h" #include "MockWebSpeechRecognizer.h" +#include "Task.h" #include "TestShell.h" #include "WebAnimationController.h" #include "WebBindings.h" @@ -83,6 +84,7 @@ using namespace WebCore; using namespace WebKit; +using namespace WebTestRunner; using namespace std; class EmptyWebDeliveredIntentClient : public WebKit::WebDeliveredIntentClient { @@ -2114,10 +2116,10 @@ void DRTTestRunner::setTextSubpixelPositioning(const CppArgumentList& arguments, result->setNull(); } -class InvokeCallbackTask : public MethodTask<DRTTestRunner> { +class InvokeCallbackTask : public WebMethodTask<DRTTestRunner> { public: InvokeCallbackTask(DRTTestRunner* object, PassOwnArrayPtr<CppVariant> callbackArguments, uint32_t numberOfArguments) - : MethodTask<DRTTestRunner>(object) + : WebMethodTask<DRTTestRunner>(object) , m_callbackArguments(callbackArguments) , m_numberOfArguments(numberOfArguments) { diff --git a/Tools/DumpRenderTree/chromium/DRTTestRunner.h b/Tools/DumpRenderTree/chromium/DRTTestRunner.h index 60a038a27..ec4778fd5 100644 --- a/Tools/DumpRenderTree/chromium/DRTTestRunner.h +++ b/Tools/DumpRenderTree/chromium/DRTTestRunner.h @@ -43,6 +43,7 @@ #define DRTTestRunner_h #include "TestRunner/src/TestRunner.h" +#include "WebTask.h" class TestShell; @@ -511,7 +512,7 @@ public: virtual bool run(TestShell*) = 0; }; - TaskList* taskList() { return &m_taskList; } + WebTestRunner::WebTaskList* taskList() { return &m_taskList; } bool shouldStayOnPageAfterHandlingBeforeUnload() const { return m_shouldStayOnPageAfterHandlingBeforeUnload; } @@ -534,17 +535,17 @@ private: void setFrozen(bool frozen) { m_frozen = frozen; } bool isEmpty() { return m_queue.isEmpty(); } - TaskList* taskList() { return &m_taskList; } + WebTestRunner::WebTaskList* taskList() { return &m_taskList; } private: void processWork(); - class WorkQueueTask: public MethodTask<WorkQueue> { + class WorkQueueTask: public WebTestRunner::WebMethodTask<WorkQueue> { public: - WorkQueueTask(WorkQueue* object): MethodTask<WorkQueue>(object) { } + WorkQueueTask(WorkQueue* object): WebTestRunner::WebMethodTask<WorkQueue>(object) { } virtual void runIfValid() { m_object->processWork(); } }; - TaskList m_taskList; + WebTestRunner::WebTaskList m_taskList; Deque<WorkItem*> m_queue; bool m_frozen; DRTTestRunner* m_controller; @@ -558,9 +559,9 @@ private: void logErrorToConsole(const std::string&); void completeNotifyDone(bool isTimeout); - class NotifyDoneTimedOutTask: public MethodTask<DRTTestRunner> { + class NotifyDoneTimedOutTask: public WebTestRunner::WebMethodTask<DRTTestRunner> { public: - NotifyDoneTimedOutTask(DRTTestRunner* object): MethodTask<DRTTestRunner>(object) { } + NotifyDoneTimedOutTask(DRTTestRunner* object): WebTestRunner::WebMethodTask<DRTTestRunner>(object) { } virtual void runIfValid() { m_object->completeNotifyDone(true); } }; @@ -571,7 +572,7 @@ private: int numberOfActiveAnimations(); // Used for test timeouts. - TaskList m_taskList; + WebTestRunner::WebTaskList m_taskList; // Non-owning pointer. The DRTTestRunner is owned by the host. TestShell* m_shell; diff --git a/Tools/DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.cpp b/Tools/DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.cpp index d6e5e7f05..6eaf9d603 100644 --- a/Tools/DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.cpp +++ b/Tools/DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.cpp @@ -34,6 +34,7 @@ #include "MockWebRTCPeerConnectionHandler.h" #include "MockConstraints.h" +#include "Task.h" #include <public/WebMediaConstraints.h> #include <public/WebMediaStreamComponent.h> #include <public/WebMediaStreamDescriptor.h> @@ -48,11 +49,12 @@ #include <wtf/DateMath.h> using namespace WebKit; +using namespace WebTestRunner; -class RTCSessionDescriptionRequestSuccededTask : public MethodTask<MockWebRTCPeerConnectionHandler> { +class RTCSessionDescriptionRequestSuccededTask : public WebMethodTask<MockWebRTCPeerConnectionHandler> { public: RTCSessionDescriptionRequestSuccededTask(MockWebRTCPeerConnectionHandler* object, const WebRTCSessionDescriptionRequest& request, const WebRTCSessionDescription& result) - : MethodTask<MockWebRTCPeerConnectionHandler>(object) + : WebMethodTask<MockWebRTCPeerConnectionHandler>(object) , m_request(request) , m_result(result) { @@ -68,10 +70,10 @@ private: WebRTCSessionDescription m_result; }; -class RTCSessionDescriptionRequestFailedTask : public MethodTask<MockWebRTCPeerConnectionHandler> { +class RTCSessionDescriptionRequestFailedTask : public WebMethodTask<MockWebRTCPeerConnectionHandler> { public: RTCSessionDescriptionRequestFailedTask(MockWebRTCPeerConnectionHandler* object, const WebRTCSessionDescriptionRequest& request) - : MethodTask<MockWebRTCPeerConnectionHandler>(object) + : WebMethodTask<MockWebRTCPeerConnectionHandler>(object) , m_request(request) { } @@ -85,10 +87,10 @@ private: WebRTCSessionDescriptionRequest m_request; }; -class RTCStatsRequestSucceededTask : public MethodTask<MockWebRTCPeerConnectionHandler> { +class RTCStatsRequestSucceededTask : public WebMethodTask<MockWebRTCPeerConnectionHandler> { public: RTCStatsRequestSucceededTask(MockWebRTCPeerConnectionHandler* object, const WebKit::WebRTCStatsRequest& request, const WebKit::WebRTCStatsResponse& response) - : MethodTask<MockWebRTCPeerConnectionHandler>(object) + : WebMethodTask<MockWebRTCPeerConnectionHandler>(object) , m_request(request) , m_response(response) { @@ -104,10 +106,10 @@ private: WebKit::WebRTCStatsResponse m_response; }; -class RTCVoidRequestTask : public MethodTask<MockWebRTCPeerConnectionHandler> { +class RTCVoidRequestTask : public WebMethodTask<MockWebRTCPeerConnectionHandler> { public: RTCVoidRequestTask(MockWebRTCPeerConnectionHandler* object, const WebRTCVoidRequest& request, bool succeeded) - : MethodTask<MockWebRTCPeerConnectionHandler>(object) + : WebMethodTask<MockWebRTCPeerConnectionHandler>(object) , m_request(request) , m_succeeded(succeeded) { @@ -126,10 +128,10 @@ private: bool m_succeeded; }; -class StringDataTask : public MethodTask<MockWebRTCPeerConnectionHandler> { +class StringDataTask : public WebMethodTask<MockWebRTCPeerConnectionHandler> { public: StringDataTask(MockWebRTCPeerConnectionHandler* object, const WebRTCDataChannel& dataChannel, const WebString& data) - : MethodTask<MockWebRTCPeerConnectionHandler>(object) + : WebMethodTask<MockWebRTCPeerConnectionHandler>(object) , m_dataChannel(dataChannel) , m_data(data) { @@ -145,10 +147,10 @@ private: WebString m_data; }; -class CharPtrDataTask : public MethodTask<MockWebRTCPeerConnectionHandler> { +class CharPtrDataTask : public WebMethodTask<MockWebRTCPeerConnectionHandler> { public: CharPtrDataTask(MockWebRTCPeerConnectionHandler* object, const WebRTCDataChannel& dataChannel, const char* data, size_t length) - : MethodTask<MockWebRTCPeerConnectionHandler>(object) + : WebMethodTask<MockWebRTCPeerConnectionHandler>(object) , m_dataChannel(dataChannel) , m_length(length) { @@ -168,10 +170,10 @@ private: size_t m_length; }; -class DataChannelReadyStateTask : public MethodTask<MockWebRTCPeerConnectionHandler> { +class DataChannelReadyStateTask : public WebMethodTask<MockWebRTCPeerConnectionHandler> { public: DataChannelReadyStateTask(MockWebRTCPeerConnectionHandler* object, const WebRTCDataChannel& dataChannel, WebRTCDataChannel::ReadyState state) - : MethodTask<MockWebRTCPeerConnectionHandler>(object) + : WebMethodTask<MockWebRTCPeerConnectionHandler>(object) , m_dataChannel(dataChannel) , m_state(state) { @@ -187,10 +189,10 @@ private: WebRTCDataChannel::ReadyState m_state; }; -class RTCPeerConnectionReadyStateTask : public MethodTask<MockWebRTCPeerConnectionHandler> { +class RTCPeerConnectionReadyStateTask : public WebMethodTask<MockWebRTCPeerConnectionHandler> { public: RTCPeerConnectionReadyStateTask(MockWebRTCPeerConnectionHandler* object, WebRTCPeerConnectionHandlerClient* client, WebRTCPeerConnectionHandlerClient::ReadyState state) - : MethodTask<MockWebRTCPeerConnectionHandler>(object) + : WebMethodTask<MockWebRTCPeerConnectionHandler>(object) , m_client(client) , m_state(state) { diff --git a/Tools/DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.h b/Tools/DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.h index 5ddd2fc45..a1522f4fb 100644 --- a/Tools/DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.h +++ b/Tools/DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.h @@ -33,7 +33,7 @@ #if ENABLE(MEDIA_STREAM) -#include "TestRunner/src/Task.h" +#include "WebTask.h" #include <public/WebRTCDataChannel.h> #include <public/WebRTCPeerConnectionHandler.h> #include <public/WebRTCSessionDescription.h> @@ -68,15 +68,15 @@ public: virtual bool sendRawData(const WebKit::WebRTCDataChannel&, const char*, size_t) OVERRIDE; virtual void closeDataChannel(const WebKit::WebRTCDataChannel&) OVERRIDE; - // Task related methods - TaskList* taskList() { return &m_taskList; } + // WebTask related methods + WebTestRunner::WebTaskList* taskList() { return &m_taskList; } private: MockWebRTCPeerConnectionHandler() { } WebKit::WebRTCPeerConnectionHandlerClient* m_client; bool m_stopped; - TaskList m_taskList; + WebTestRunner::WebTaskList m_taskList; WebKit::WebRTCSessionDescription m_localDescription; WebKit::WebRTCSessionDescription m_remoteDescription; int m_streamCount; diff --git a/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.cpp b/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.cpp index 13c8ff1ec..528455bd6 100644 --- a/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.cpp +++ b/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "MockWebSpeechInputController.h" +#include "Task.h" #include "WebSpeechInputListener.h" #include "platform/WebCString.h" #include "platform/WebVector.h" @@ -35,6 +36,7 @@ #if ENABLE(INPUT_SPEECH) using namespace WebKit; +using namespace WebTestRunner; PassOwnPtr<MockWebSpeechInputController> MockWebSpeechInputController::create(WebSpeechInputListener* listener) { @@ -182,7 +184,7 @@ void MockWebSpeechInputController::speechTaskFired() } MockWebSpeechInputController::SpeechTask::SpeechTask(MockWebSpeechInputController* mock) - : MethodTask<MockWebSpeechInputController>::MethodTask(mock) + : WebMethodTask<MockWebSpeechInputController>::WebMethodTask(mock) { } diff --git a/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.h b/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.h index 6494a7f25..075f2541f 100644 --- a/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.h +++ b/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.h @@ -28,7 +28,7 @@ #if ENABLE(INPUT_SPEECH) -#include "TestRunner/src/Task.h" +#include "WebTask.h" #include "platform/WebRect.h" #include "WebSpeechInputController.h" #include "WebSpeechInputResult.h" @@ -58,13 +58,13 @@ public: virtual void cancelRecognition(int requestId) OVERRIDE; virtual void stopRecording(int requestId) OVERRIDE; - TaskList* taskList() { return &m_taskList; } + WebTestRunner::WebTaskList* taskList() { return &m_taskList; } private: MockWebSpeechInputController(WebKit::WebSpeechInputListener*); void speechTaskFired(); - class SpeechTask : public MethodTask<MockWebSpeechInputController> { + class SpeechTask : public WebTestRunner::WebMethodTask<MockWebSpeechInputController> { public: SpeechTask(MockWebSpeechInputController*); void stop(); @@ -75,7 +75,7 @@ private: WebKit::WebSpeechInputListener* m_listener; - TaskList m_taskList; + WebTestRunner::WebTaskList m_taskList; SpeechTask* m_speechTask; bool m_recording; diff --git a/Tools/DumpRenderTree/chromium/MockWebSpeechRecognizer.cpp b/Tools/DumpRenderTree/chromium/MockWebSpeechRecognizer.cpp index 502addea9..88143c0ba 100644 --- a/Tools/DumpRenderTree/chromium/MockWebSpeechRecognizer.cpp +++ b/Tools/DumpRenderTree/chromium/MockWebSpeechRecognizer.cpp @@ -28,10 +28,12 @@ #if ENABLE(SCRIPTED_SPEECH) +#include "Task.h" #include "WebSpeechRecognitionResult.h" #include "WebSpeechRecognizerClient.h" using namespace WebKit; +using namespace WebTestRunner; namespace { diff --git a/Tools/DumpRenderTree/chromium/MockWebSpeechRecognizer.h b/Tools/DumpRenderTree/chromium/MockWebSpeechRecognizer.h index 4cc045669..419c5e504 100644 --- a/Tools/DumpRenderTree/chromium/MockWebSpeechRecognizer.h +++ b/Tools/DumpRenderTree/chromium/MockWebSpeechRecognizer.h @@ -28,8 +28,8 @@ #if ENABLE(SCRIPTED_SPEECH) -#include "TestRunner/src/Task.h" #include "WebSpeechRecognizer.h" +#include "WebTask.h" #include <wtf/Compiler.h> #include <wtf/PassOwnPtr.h> #include <wtf/Vector.h> @@ -58,7 +58,7 @@ public: // Methods accessed from Task objects: WebKit::WebSpeechRecognizerClient* client() { return m_client; } WebKit::WebSpeechRecognitionHandle& handle() { return m_handle; } - TaskList* taskList() { return &m_taskList; } + WebTestRunner::WebTaskList* taskList() { return &m_taskList; } class Task { public: @@ -74,7 +74,7 @@ private: void startTaskQueue(); void clearTaskQueue(); - TaskList m_taskList; + WebTestRunner::WebTaskList m_taskList; WebKit::WebSpeechRecognitionHandle m_handle; WebKit::WebSpeechRecognizerClient* m_client; Vector<WebKit::WebString> m_mockTranscripts; @@ -86,9 +86,9 @@ private: bool m_taskQueueRunning; // Task for stepping the queue. - class StepTask : public MethodTask<MockWebSpeechRecognizer> { + class StepTask : public WebTestRunner::WebMethodTask<MockWebSpeechRecognizer> { public: - StepTask(MockWebSpeechRecognizer* object) : MethodTask<MockWebSpeechRecognizer>(object) { } + StepTask(MockWebSpeechRecognizer* object) : WebTestRunner::WebMethodTask<MockWebSpeechRecognizer>(object) { } virtual void runIfValid() OVERRIDE; }; }; diff --git a/Tools/DumpRenderTree/chromium/Task.cpp b/Tools/DumpRenderTree/chromium/Task.cpp new file mode 100644 index 000000000..a619017f5 --- /dev/null +++ b/Tools/DumpRenderTree/chromium/Task.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Task.h" + +#include "WebKit.h" +#include "WebTask.h" +#include "platform/WebKitPlatformSupport.h" +#include "webkit/support/webkit_support.h" +#include <wtf/OwnPtr.h> +#include <wtf/PassOwnPtr.h> + +using namespace WebKit; +using namespace WebTestRunner; + +namespace { + +void invokeTask(void* context) +{ + WebTask* task = static_cast<WebTask*>(context); + task->run(); + delete task; +} + +class TaskWrapper : public webkit_support::TaskAdaptor { +public: + explicit TaskWrapper(WebTask* task) + : m_task(adoptPtr(task)) + { + } + virtual ~TaskWrapper() { } + virtual void Run() + { + m_task->run(); + } + +private: + OwnPtr<WebTask> m_task; +}; + +} + +void postTask(WebTask* task) +{ + webKitPlatformSupport()->callOnMainThread(invokeTask, static_cast<void*>(task)); +} + +void postDelayedTask(WebTask* task, long long ms) +{ + webkit_support::PostDelayedTask(new TaskWrapper(task), ms); +} diff --git a/Tools/DumpRenderTree/chromium/Task.h b/Tools/DumpRenderTree/chromium/Task.h new file mode 100644 index 000000000..c8755a83c --- /dev/null +++ b/Tools/DumpRenderTree/chromium/Task.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef Task_h +#define Task_h + +namespace WebTestRunner { +class WebTask; +} + +void postTask(WebTestRunner::WebTask*); +void postDelayedTask(WebTestRunner::WebTask*, long long ms); + +#endif // Task_h diff --git a/Tools/DumpRenderTree/chromium/TestRunner/src/Task.h b/Tools/DumpRenderTree/chromium/TestRunner/public/WebTask.h index 0b32c472b..ef73e177e 100644 --- a/Tools/DumpRenderTree/chromium/TestRunner/src/Task.h +++ b/Tools/DumpRenderTree/chromium/TestRunner/public/WebTask.h @@ -28,69 +28,75 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef Task_h -#define Task_h +#ifndef WebTask_h +#define WebTask_h -#include "webkit/support/webkit_support.h" -#include <wtf/OwnPtr.h> -#include <wtf/Vector.h> +namespace WebTestRunner { -class TaskList; +class WebTaskList; -// WebTask represents a task which can run by postTask() or postDelayedTask(). -// it is named "WebTask", not "Task", to avoid conflist with base/task.h. -class WebTask : public webkit_support::TaskAdaptor { +// WebTask represents a task which can run by WebTestDelegate::postTask() or +// WebTestDelegate::postDelayedTask(). +class WebTask { public: - WebTask(TaskList*); + explicit WebTask(WebTaskList*); + virtual ~WebTask(); + // The main code of this task. // An implementation of run() should return immediately if cancel() was called. virtual void run() = 0; virtual void cancel() = 0; - virtual ~WebTask(); - -private: - virtual void Run() { run(); } protected: - TaskList* m_taskList; + WebTaskList* m_taskList; }; -class TaskList { +class WebTaskList { public: - TaskList() { } - ~TaskList() { revokeAll(); } - void registerTask(WebTask* task) { m_tasks.append(task); } + WebTaskList(); + ~WebTaskList(); + void registerTask(WebTask*); void unregisterTask(WebTask*); void revokeAll(); private: - Vector<WebTask*> m_tasks; + class Private; + Private* m_private; }; -// A task containing an object pointer of class T. Is is supposed that -// runifValid() calls a member function of the object pointer. -// Class T must have "TaskList* taskList()". -template<class T> class MethodTask: public WebTask { +// A task containing an object pointer of class T. Derived classes should +// override runIfValid() which in turn can safely invoke methods on the +// m_object. The Class T must have "WebTaskList* taskList()". +template<class T> +class WebMethodTask : public WebTask { public: - MethodTask(T* object): WebTask(object->taskList()), m_object(object) { } + explicit WebMethodTask(T* object) + : WebTask(object->taskList()) + , m_object(object) + { + } + + virtual ~WebMethodTask() { } + virtual void run() { if (m_object) runIfValid(); } + virtual void cancel() { m_object = 0; m_taskList->unregisterTask(this); m_taskList = 0; } + virtual void runIfValid() = 0; protected: T* m_object; }; -void postTask(WebTask*); -void postDelayedTask(WebTask*, int64_t ms); +} -#endif // Task_h +#endif // WebTask_h diff --git a/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h b/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h index a4f62021c..dd3303352 100644 --- a/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h +++ b/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h @@ -41,6 +41,8 @@ class WebGamepads; namespace WebTestRunner { +class WebTask; + class WebTestDelegate { public: virtual void clearContextMenuData() = 0; @@ -49,6 +51,14 @@ public: virtual void setEditCommand(const std::string& name, const std::string& value) = 0; virtual WebKit::WebContextMenuData* lastContextMenuData() const = 0; virtual void setGamepadData(const WebKit::WebGamepads&) = 0; + virtual void printMessage(const std::string& message) const = 0; + + // The delegate takes ownership of the WebTask objects and is responsible + // for deleting them. + virtual void postTask(WebTask*) = 0; + virtual void postDelayedTask(WebTask*, long long ms) = 0; + + virtual WebKit::WebString registerIsolatedFileSystem(const WebKit::WebVector<WebKit::WebString>& absoluteFilenames) = 0; }; } diff --git a/Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityControllerChromium.cpp b/Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityControllerChromium.cpp index 8e25db2d2..5f1b4f9a9 100644 --- a/Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityControllerChromium.cpp +++ b/Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityControllerChromium.cpp @@ -31,6 +31,7 @@ #include "config.h" #include "AccessibilityControllerChromium.h" +#include "TestDelegate.h" #include "WebAccessibilityObject.h" #include "WebElement.h" #include "WebFrame.h" @@ -197,8 +198,7 @@ void AccessibilityController::accessibleElementByIdGetterCallback(const CppArgum void AccessibilityController::fallbackCallback(const CppArgumentList&, CppVariant* result) { - printf("CONSOLE MESSAGE: JavaScript ERROR: unknown method called on " - "AccessibilityController\n"); + m_delegate->printMessage("CONSOLE MESSAGE: JavaScript ERROR: unknown method called on AccessibilityController\n"); result->setNull(); } diff --git a/Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityControllerChromium.h b/Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityControllerChromium.h index 4dd7f8705..35bf06c56 100644 --- a/Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityControllerChromium.h +++ b/Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityControllerChromium.h @@ -40,6 +40,8 @@ class WebFrame; class WebView; } +class TestDelegate; + namespace WebTestRunner { class AccessibilityController : public CppBoundClass { @@ -59,6 +61,7 @@ public: void notificationReceived(const WebKit::WebAccessibilityObject& target, const char* notificationName); + void setDelegate(TestDelegate* delegate) { m_delegate = delegate; } void setWebView(WebKit::WebView* webView) { m_webView = webView; } private: @@ -84,6 +87,7 @@ private: std::vector<CppVariant> m_notificationCallbacks; + TestDelegate* m_delegate; WebKit::WebView* m_webView; }; diff --git a/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp b/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp index 310ae6c48..2f4a0554c 100644 --- a/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp +++ b/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp @@ -51,6 +51,7 @@ #include "platform/WebDragData.h" #include "platform/WebPoint.h" #include "platform/WebString.h" +#include "platform/WebVector.h" #include "webkit/support/webkit_support.h" #include <wtf/Deque.h> #include <wtf/StringExtras.h> @@ -369,7 +370,7 @@ void EventSender::dumpFilenameBeingDragged(const CppArgumentList&, CppVariant*) break; } } - printf("Filename being dragged: %s\n", filename.utf8().data()); + m_delegate->printMessage(std::string("Filename being dragged: ") + filename.utf8().data() + "\n"); } WebMouseEvent::Button EventSender::getButtonTypeFromButtonNumber(int buttonCode) @@ -854,20 +855,20 @@ void EventSender::contextClick(const CppArgumentList& arguments, CppVariant* res result->set(WebBindings::makeStringArray(makeMenuItemStringsFor(lastContextMenu, m_delegate))); } -class MouseDownTask: public MethodTask<EventSender> { +class MouseDownTask: public WebMethodTask<EventSender> { public: MouseDownTask(EventSender* obj, const CppArgumentList& arg) - : MethodTask<EventSender>(obj), m_arguments(arg) { } + : WebMethodTask<EventSender>(obj), m_arguments(arg) { } virtual void runIfValid() { m_object->mouseDown(m_arguments, 0); } private: CppArgumentList m_arguments; }; -class MouseUpTask: public MethodTask<EventSender> { +class MouseUpTask: public WebMethodTask<EventSender> { public: MouseUpTask(EventSender* obj, const CppArgumentList& arg) - : MethodTask<EventSender>(obj), m_arguments(arg) { } + : WebMethodTask<EventSender>(obj), m_arguments(arg) { } virtual void runIfValid() { m_object->mouseUp(m_arguments, 0); } private: @@ -877,14 +878,14 @@ private: void EventSender::scheduleAsynchronousClick(const CppArgumentList& arguments, CppVariant* result) { result->setNull(); - postTask(new MouseDownTask(this, arguments)); - postTask(new MouseUpTask(this, arguments)); + m_delegate->postTask(new MouseDownTask(this, arguments)); + m_delegate->postTask(new MouseUpTask(this, arguments)); } -class KeyDownTask : public MethodTask<EventSender> { +class KeyDownTask : public WebMethodTask<EventSender> { public: KeyDownTask(EventSender* obj, const CppArgumentList& arg) - : MethodTask<EventSender>(obj), m_arguments(arg) { } + : WebMethodTask<EventSender>(obj), m_arguments(arg) { } virtual void runIfValid() { m_object->keyDown(m_arguments, 0); } private: @@ -894,22 +895,22 @@ private: void EventSender::scheduleAsynchronousKeyDown(const CppArgumentList& arguments, CppVariant* result) { result->setNull(); - postTask(new KeyDownTask(this, arguments)); + m_delegate->postTask(new KeyDownTask(this, arguments)); } void EventSender::beginDragWithFiles(const CppArgumentList& arguments, CppVariant* result) { currentDragData.initialize(); Vector<string> files = arguments[0].toStringVector(); - Vector<WebString> absoluteFilenames; + WebVector<WebString> absoluteFilenames(files.size()); for (size_t i = 0; i < files.size(); ++i) { WebDragData::Item item; item.storageType = WebDragData::Item::StorageTypeFilename; item.filenameData = webkit_support::GetAbsoluteWebStringFromUTF8Path(files[i]); currentDragData.addItem(item); - absoluteFilenames.append(item.filenameData); + absoluteFilenames[i] = item.filenameData; } - currentDragData.setFilesystemId(webkit_support::RegisterIsolatedFileSystem(absoluteFilenames)); + currentDragData.setFilesystemId(m_delegate->registerIsolatedFileSystem(absoluteFilenames)); currentDragEffectsAllowed = WebKit::WebDragOperationCopy; // Provide a drag source. diff --git a/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.h b/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.h index 65dfccb8c..d07e14cc6 100644 --- a/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.h +++ b/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.h @@ -38,9 +38,9 @@ #define EventSender_h #include "CppBoundClass.h" -#include "Task.h" #include "WebDragOperation.h" #include "WebInputEvent.h" +#include "WebTask.h" #include "platform/WebPoint.h" namespace WebKit { @@ -131,7 +131,7 @@ public: CppVariant wmSysDeadChar; #endif - TaskList* taskList() { return &m_taskList; } + WebTaskList* taskList() { return &m_taskList; } private: WebKit::WebView* webview() { return m_webView; } @@ -165,7 +165,7 @@ private: // Handle a request to send a wheel event. void handleMouseWheel(const CppArgumentList&, CppVariant*, bool continuous); - TaskList m_taskList; + WebTaskList m_taskList; TestDelegate* m_delegate; WebKit::WebView* m_webView; diff --git a/Tools/DumpRenderTree/chromium/TestRunner/src/GamepadController.cpp b/Tools/DumpRenderTree/chromium/TestRunner/src/GamepadController.cpp index cb36bfdfb..282ce44de 100644 --- a/Tools/DumpRenderTree/chromium/TestRunner/src/GamepadController.cpp +++ b/Tools/DumpRenderTree/chromium/TestRunner/src/GamepadController.cpp @@ -67,7 +67,7 @@ void GamepadController::reset() void GamepadController::connect(const CppArgumentList& args, CppVariant* result) { if (args.size() < 1) { - printf("Invalid args"); + m_delegate->printMessage("Invalid args"); return; } int index = args[0].toInt32(); @@ -85,7 +85,7 @@ void GamepadController::connect(const CppArgumentList& args, CppVariant* result) void GamepadController::disconnect(const CppArgumentList& args, CppVariant* result) { if (args.size() < 1) { - printf("Invalid args"); + m_delegate->printMessage("Invalid args"); return; } int index = args[0].toInt32(); @@ -103,7 +103,7 @@ void GamepadController::disconnect(const CppArgumentList& args, CppVariant* resu void GamepadController::setId(const CppArgumentList& args, CppVariant* result) { if (args.size() < 2) { - printf("Invalid args"); + m_delegate->printMessage("Invalid args"); return; } int index = args[0].toInt32(); @@ -121,7 +121,7 @@ void GamepadController::setId(const CppArgumentList& args, CppVariant* result) void GamepadController::setButtonCount(const CppArgumentList& args, CppVariant* result) { if (args.size() < 2) { - printf("Invalid args"); + m_delegate->printMessage("Invalid args"); return; } int index = args[0].toInt32(); @@ -138,7 +138,7 @@ void GamepadController::setButtonCount(const CppArgumentList& args, CppVariant* void GamepadController::setButtonData(const CppArgumentList& args, CppVariant* result) { if (args.size() < 3) { - printf("Invalid args"); + m_delegate->printMessage("Invalid args"); return; } int index = args[0].toInt32(); @@ -156,7 +156,7 @@ void GamepadController::setButtonData(const CppArgumentList& args, CppVariant* r void GamepadController::setAxisCount(const CppArgumentList& args, CppVariant* result) { if (args.size() < 2) { - printf("Invalid args"); + m_delegate->printMessage("Invalid args"); return; } int index = args[0].toInt32(); @@ -173,7 +173,7 @@ void GamepadController::setAxisCount(const CppArgumentList& args, CppVariant* re void GamepadController::setAxisData(const CppArgumentList& args, CppVariant* result) { if (args.size() < 3) { - printf("Invalid args"); + m_delegate->printMessage("Invalid args"); return; } int index = args[0].toInt32(); @@ -190,7 +190,6 @@ void GamepadController::setAxisData(const CppArgumentList& args, CppVariant* res void GamepadController::fallbackCallback(const CppArgumentList&, CppVariant* result) { - printf("CONSOLE MESSAGE: JavaScript ERROR: unknown method called on " - "GamepadController\n"); + m_delegate->printMessage("CONSOLE MESSAGE: JavaScript ERROR: unknown method called on GamepadController\n"); result->setNull(); } diff --git a/Tools/DumpRenderTree/chromium/TestRunner/src/TestDelegate.h b/Tools/DumpRenderTree/chromium/TestRunner/src/TestDelegate.h index 0b0d9622e..218bbdf42 100644 --- a/Tools/DumpRenderTree/chromium/TestRunner/src/TestDelegate.h +++ b/Tools/DumpRenderTree/chromium/TestRunner/src/TestDelegate.h @@ -39,6 +39,10 @@ struct WebContextMenuData; class WebGamepads; } +namespace WebTestRunner { +class WebTask; +} + class TestDelegate { public: virtual void clearContextMenuData() = 0; @@ -47,6 +51,10 @@ public: virtual void setEditCommand(const std::string& name, const std::string& value) = 0; virtual WebKit::WebContextMenuData* lastContextMenuData() const = 0; virtual void setGamepadData(const WebKit::WebGamepads&) = 0; + virtual void printMessage(const std::string& message) const = 0; + virtual void postTask(WebTestRunner::WebTask*) = 0; + virtual void postDelayedTask(WebTestRunner::WebTask*, long long ms) = 0; + virtual WebKit::WebString registerIsolatedFileSystem(const WebKit::WebVector<WebKit::WebString>& absoluteFilenames) = 0; }; #endif // TestDelegate_h diff --git a/Tools/DumpRenderTree/chromium/TestRunner/src/TestInterfaces.cpp b/Tools/DumpRenderTree/chromium/TestRunner/src/TestInterfaces.cpp index cc821214b..8959bb1ba 100644 --- a/Tools/DumpRenderTree/chromium/TestRunner/src/TestInterfaces.cpp +++ b/Tools/DumpRenderTree/chromium/TestRunner/src/TestInterfaces.cpp @@ -58,7 +58,7 @@ TestInterfaces::~TestInterfaces() // m_gamepadController doesn't depend on WebView. m_textInputController->setWebView(0); - // m_accessibilityController doesn't depend on TestDelegate. + m_accessibilityController->setDelegate(0); m_eventSender->setDelegate(0); m_gamepadController->setDelegate(0); // m_textInputController doesn't depend on TestDelegate. @@ -74,7 +74,7 @@ void TestInterfaces::setWebView(WebView* webView) void TestInterfaces::setDelegate(TestDelegate* delegate) { - // m_accessibilityController doesn't depend on TestDelegate. + m_accessibilityController->setDelegate(delegate); m_eventSender->setDelegate(delegate); m_gamepadController->setDelegate(delegate); // m_textInputController doesn't depend on TestDelegate. diff --git a/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h b/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h index f7069401a..39e19d573 100644 --- a/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h +++ b/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h @@ -33,7 +33,6 @@ #define TestRunner_h #include "CppBoundClass.h" -#include "Task.h" #include "WebDeliveredIntentClient.h" #include "WebTextDirection.h" #include "platform/WebArrayBufferView.h" diff --git a/Tools/DumpRenderTree/chromium/TestRunner/src/Task.cpp b/Tools/DumpRenderTree/chromium/TestRunner/src/WebTask.cpp index d80beef34..97531c80d 100644 --- a/Tools/DumpRenderTree/chromium/TestRunner/src/Task.cpp +++ b/Tools/DumpRenderTree/chromium/TestRunner/src/WebTask.cpp @@ -29,12 +29,14 @@ */ #include "config.h" -#include "Task.h" +#include "WebTask.h" #include "WebKit.h" -#include "platform/WebKitPlatformSupport.h" +#include <wtf/Vector.h> -WebTask::WebTask(TaskList* list) +namespace WebTestRunner { + +WebTask::WebTask(WebTaskList* list) : m_taskList(list) { m_taskList->registerTask(this); @@ -46,34 +48,36 @@ WebTask::~WebTask() m_taskList->unregisterTask(this); } -void TaskList::unregisterTask(WebTask* task) +class WebTaskList::Private : public Vector<WebTask*> { +}; + +WebTaskList::WebTaskList() + : m_private(new Private) { - size_t index = m_tasks.find(task); - if (index != notFound) - m_tasks.remove(index); } -void TaskList::revokeAll() +WebTaskList::~WebTaskList() { - while (!m_tasks.isEmpty()) - m_tasks[0]->cancel(); + revokeAll(); + delete m_private; } -static void invokeTask(void* context) +void WebTaskList::registerTask(WebTask* task) { - WebTask* task = static_cast<WebTask*>(context); - task->run(); - delete task; + m_private->append(task); } -void postTask(WebTask* task) +void WebTaskList::unregisterTask(WebTask* task) { - WebKit::webKitPlatformSupport()->callOnMainThread(invokeTask, static_cast<void*>(task)); + size_t index = m_private->find(task); + if (index != notFound) + m_private->remove(index); } -void postDelayedTask(WebTask* task, int64_t ms) +void WebTaskList::revokeAll() { - webkit_support::PostDelayedTask(task, ms); + while (!m_private->isEmpty()) + (*m_private)[0]->cancel(); } - +} diff --git a/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestInterfaces.cpp b/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestInterfaces.cpp index 3d5b0de3e..632d9664b 100644 --- a/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestInterfaces.cpp +++ b/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestInterfaces.cpp @@ -63,6 +63,10 @@ public: virtual void setEditCommand(const std::string& name, const std::string& value); virtual WebContextMenuData* lastContextMenuData() const; virtual void setGamepadData(const WebGamepads&); + virtual void printMessage(const std::string& message) const; + virtual void postTask(WebTask*); + virtual void postDelayedTask(WebTask*, long long ms); + virtual WebString registerIsolatedFileSystem(const WebVector<WebString>& absoluteFilenames); private: TestInterfaces m_interfaces; @@ -123,6 +127,26 @@ void WebTestInterfaces::Internal::setGamepadData(const WebGamepads& pads) m_delegate->setGamepadData(pads); } +void WebTestInterfaces::Internal::printMessage(const std::string& message) const +{ + m_delegate->printMessage(message); +} + +void WebTestInterfaces::Internal::postTask(WebTask* task) +{ + m_delegate->postTask(task); +} + +void WebTestInterfaces::Internal::postDelayedTask(WebTask* task, long long ms) +{ + m_delegate->postDelayedTask(task, ms); +} + +WebString WebTestInterfaces::Internal::registerIsolatedFileSystem(const WebVector<WebString>& absoluteFilenames) +{ + return m_delegate->registerIsolatedFileSystem(absoluteFilenames); +} + WebTestInterfaces::WebTestInterfaces() { m_internal = new Internal; diff --git a/Tools/DumpRenderTree/chromium/TestShell.cpp b/Tools/DumpRenderTree/chromium/TestShell.cpp index 4854f5ea3..2692e7458 100644 --- a/Tools/DumpRenderTree/chromium/TestShell.cpp +++ b/Tools/DumpRenderTree/chromium/TestShell.cpp @@ -68,6 +68,7 @@ using namespace WebKit; +using namespace WebTestRunner; using namespace std; // Content area size for newly created windows. @@ -154,7 +155,7 @@ TestShell::TestShell() void TestShell::initialize() { m_webPermissions = adoptPtr(new WebPermissions(this)); - m_testInterfaces = adoptPtr(new WebTestRunner::WebTestInterfaces()); + m_testInterfaces = adoptPtr(new WebTestInterfaces()); m_testRunner = adoptPtr(new DRTTestRunner(this)); #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) m_notificationPresenter = adoptPtr(new NotificationPresenter(this)); diff --git a/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.cpp b/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.cpp index ed13ffa58..3878ff167 100644 --- a/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.cpp +++ b/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.cpp @@ -34,6 +34,7 @@ #include "WebUserMediaClientMock.h" #include "MockConstraints.h" +#include "Task.h" #include "WebDocument.h" #include "WebMediaStreamRegistry.h" #include "WebUserMediaRequest.h" @@ -44,11 +45,12 @@ #include <wtf/Assertions.h> using namespace WebKit; +using namespace WebTestRunner; -class UserMediaRequestTask : public MethodTask<WebUserMediaClientMock> { +class UserMediaRequestTask : public WebMethodTask<WebUserMediaClientMock> { public: UserMediaRequestTask(WebUserMediaClientMock* object, const WebUserMediaRequest& request, const WebMediaStreamDescriptor result) - : MethodTask<WebUserMediaClientMock>(object) + : WebMethodTask<WebUserMediaClientMock>(object) , m_request(request) , m_result(result) { diff --git a/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.h b/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.h index f43875976..ef4cb51d1 100644 --- a/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.h +++ b/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.h @@ -33,7 +33,7 @@ #if ENABLE(MEDIA_STREAM) -#include "TestRunner/src/Task.h" +#include "WebTask.h" #include "WebUserMediaClient.h" #include "webkit/support/test_media_stream_client.h" #include <public/WebCommon.h> @@ -50,12 +50,12 @@ public: virtual void cancelUserMediaRequest(const WebKit::WebUserMediaRequest&); // Task related methods - TaskList* taskList() { return &m_taskList; } + WebTestRunner::WebTaskList* taskList() { return &m_taskList; } private: WebUserMediaClientMock() { } - TaskList m_taskList; + WebTestRunner::WebTaskList m_taskList; }; #endif // ENABLE(MEDIA_STREAM) diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.cpp b/Tools/DumpRenderTree/chromium/WebViewHost.cpp index 106caa978..18422db58 100644 --- a/Tools/DumpRenderTree/chromium/WebViewHost.cpp +++ b/Tools/DumpRenderTree/chromium/WebViewHost.cpp @@ -35,6 +35,7 @@ #include "MockGrammarCheck.h" #include "MockWebSpeechInputController.h" #include "MockWebSpeechRecognizer.h" +#include "Task.h" #include "TestNavigationController.h" #include "TestShell.h" #include "TestWebPlugin.h" @@ -88,6 +89,7 @@ using namespace WebCore; using namespace WebKit; +using namespace WebTestRunner; using namespace std; static const int screenWidth = 1920; @@ -579,16 +581,6 @@ void WebViewHost::showContextMenu(WebFrame*, const WebContextMenuData& contextMe m_lastContextMenuData = adoptPtr(new WebContextMenuData(contextMenuData)); } -void WebViewHost::clearContextMenuData() -{ - m_lastContextMenuData.clear(); -} - -WebContextMenuData* WebViewHost::lastContextMenuData() const -{ - return m_lastContextMenuData.get(); -} - void WebViewHost::setStatusText(const WebString& text) { if (!testRunner()->shouldDumpStatusCallbacks()) @@ -774,11 +766,6 @@ MockSpellCheck* WebViewHost::mockSpellCheck() return &m_spellcheck; } -void WebViewHost::fillSpellingSuggestionList(const WebKit::WebString& word, WebKit::WebVector<WebKit::WebString>* suggestions) -{ - mockSpellCheck()->fillSuggestionList(word, suggestions); -} - WebDeviceOrientationClient* WebViewHost::deviceOrientationClient() { return deviceOrientationClientMock(); @@ -1459,6 +1446,60 @@ void WebViewHost::deliveredIntentFailure(WebFrame* frame, int id, const WebSeria printf("Web intent failure for id %d\n", id); } +// WebTestDelegate ------------------------------------------------------------ + +WebContextMenuData* WebViewHost::lastContextMenuData() const +{ + return m_lastContextMenuData.get(); +} + +void WebViewHost::clearContextMenuData() +{ + m_lastContextMenuData.clear(); +} + +void WebViewHost::setEditCommand(const string& name, const string& value) +{ + m_editCommandName = name; + m_editCommandValue = value; +} + +void WebViewHost::clearEditCommand() +{ + m_editCommandName.clear(); + m_editCommandValue.clear(); +} + +void WebViewHost::fillSpellingSuggestionList(const WebKit::WebString& word, WebKit::WebVector<WebKit::WebString>* suggestions) +{ + mockSpellCheck()->fillSuggestionList(word, suggestions); +} + +void WebViewHost::setGamepadData(const WebGamepads& pads) +{ + webkit_support::SetGamepadData(pads); +} + +void WebViewHost::printMessage(const std::string& message) const +{ + printf("%s", message.c_str()); +} + +void WebViewHost::postTask(WebTask* task) +{ + ::postTask(task); +} + +void WebViewHost::postDelayedTask(WebTask* task, long long ms) +{ + ::postDelayedTask(task, ms); +} + +WebString WebViewHost::registerIsolatedFileSystem(const WebVector<WebString>& absoluteFilenames) +{ + return webkit_support::RegisterIsolatedFileSystem(absoluteFilenames); +} + // Public functions ----------------------------------------------------------- WebViewHost::WebViewHost(TestShell* shell) @@ -1594,18 +1635,6 @@ void WebViewHost::waitForPolicyDelegate() m_policyDelegateShouldNotifyDone = true; } -void WebViewHost::setEditCommand(const string& name, const string& value) -{ - m_editCommandName = name; - m_editCommandValue = value; -} - -void WebViewHost::clearEditCommand() -{ - m_editCommandName.clear(); - m_editCommandValue.clear(); -} - void WebViewHost::loadURLForFrame(const WebURL& url, const WebString& frameName) { if (!url.isValid()) @@ -1790,11 +1819,6 @@ void WebViewHost::setDeviceScaleFactor(float deviceScaleFactor) discardBackingStore(); } -void WebViewHost::setGamepadData(const WebGamepads& pads) -{ - webkit_support::SetGamepadData(pads); -} - void WebViewHost::setPageTitle(const WebString&) { // Nothing to do in layout test. diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.h b/Tools/DumpRenderTree/chromium/WebViewHost.h index ba763503a..41237cba9 100644 --- a/Tools/DumpRenderTree/chromium/WebViewHost.h +++ b/Tools/DumpRenderTree/chromium/WebViewHost.h @@ -33,13 +33,13 @@ #include "MockSpellCheck.h" #include "TestNavigationController.h" -#include "TestRunner/src/Task.h" #include "WebAccessibilityNotification.h" #include "WebCursorInfo.h" #include "WebFrameClient.h" #include "WebIntentRequest.h" #include "WebPrerendererClient.h" #include "WebSpellCheckClient.h" +#include "WebTask.h" #include "WebTestDelegate.h" #include "WebViewClient.h" #include <wtf/HashMap.h> @@ -95,13 +95,9 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, WebKit::WebFrame* topLoadingFrame() { return m_topLoadingFrame; } void setBlockRedirects(bool block) { m_blocksRedirects = block; } void setRequestReturnNull(bool returnNull) { m_requestReturnNull = returnNull; } - virtual void setEditCommand(const std::string& name, const std::string& value) OVERRIDE; - virtual void clearEditCommand() OVERRIDE; void setPendingExtraData(PassOwnPtr<TestShellExtraData>); void setDeviceScaleFactor(float); - virtual void setGamepadData(const WebKit::WebGamepads&); - void paintRect(const WebKit::WebRect&); void updatePaintRect(const WebKit::WebRect&); void paintInvalidatedRegion(); @@ -116,9 +112,6 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, const HashSet<WTF::String>& clearHeaders() const { return m_clearHeaders; } void closeWidget(); - virtual WebKit::WebContextMenuData* lastContextMenuData() const OVERRIDE; - virtual void clearContextMenuData() OVERRIDE; - #if ENABLE(INPUT_SPEECH) MockWebSpeechInputController* speechInputControllerMock() { return m_speechInputControllerMock.get(); } #endif @@ -135,6 +128,18 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, void setPointerLockWillFailSynchronously() { m_pointerLockPlannedResult = PointerLockWillFailSync; } #endif + // WebTestDelegate. + virtual WebKit::WebContextMenuData* lastContextMenuData() const OVERRIDE; + virtual void clearContextMenuData() OVERRIDE; + virtual void setEditCommand(const std::string& name, const std::string& value) OVERRIDE; + virtual void clearEditCommand() OVERRIDE; + virtual void fillSpellingSuggestionList(const WebKit::WebString& word, WebKit::WebVector<WebKit::WebString>* suggestions) OVERRIDE; + virtual void setGamepadData(const WebKit::WebGamepads&) OVERRIDE; + virtual void printMessage(const std::string& message) const OVERRIDE; + virtual void postTask(WebTestRunner::WebTask*) OVERRIDE; + virtual void postDelayedTask(WebTestRunner::WebTask*, long long ms) OVERRIDE; + virtual WebKit::WebString registerIsolatedFileSystem(const WebKit::WebVector<WebKit::WebString>& absoluteFilenames) OVERRIDE; + // NavigationHost virtual bool navigate(const TestNavigationEntry&, bool reload); @@ -281,24 +286,23 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, // Spellcheck related helper APIs MockSpellCheck* mockSpellCheck(); void finishLastTextCheck(); - virtual void fillSpellingSuggestionList(const WebKit::WebString& word, WebKit::WebVector<WebKit::WebString>* suggestions) OVERRIDE; // Geolocation client mocks for DRTTestRunner WebKit::WebGeolocationClientMock* geolocationClientMock(); - // Pending task list, Note taht the method is referred from MethodTask class. - TaskList* taskList() { return &m_taskList; } + // Pending task list, Note taht the method is referred from WebMethodTask class. + WebTestRunner::WebTaskList* taskList() { return &m_taskList; } // The current web intents request. WebKit::WebIntentRequest* currentIntentRequest() { return &m_currentRequest; } private: - class HostMethodTask : public MethodTask<WebViewHost> { + class HostMethodTask : public WebTestRunner::WebMethodTask<WebViewHost> { public: typedef void (WebViewHost::*CallbackMethodType)(); HostMethodTask(WebViewHost* object, CallbackMethodType callback) - : MethodTask<WebViewHost>(object) + : WebTestRunner::WebMethodTask<WebViewHost>(object) , m_callback(callback) { } @@ -441,7 +445,7 @@ private: WebKit::WebString m_lastRequestedTextCheckString; WebKit::WebTextCheckingCompletion* m_lastRequestedTextCheckingCompletion; - TaskList m_taskList; + WebTestRunner::WebTaskList m_taskList; Vector<WebKit::WebWidget*> m_popupmenus; #if ENABLE(POINTER_LOCK) |