diff options
Diffstat (limited to 'Tools/DumpRenderTree/chromium/TestRunner/src')
| -rw-r--r-- | Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityControllerChromium.cpp | 4 | ||||
| -rw-r--r-- | Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityControllerChromium.h | 4 | ||||
| -rw-r--r-- | Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp | 27 | ||||
| -rw-r--r-- | Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.h | 6 | ||||
| -rw-r--r-- | Tools/DumpRenderTree/chromium/TestRunner/src/GamepadController.cpp | 17 | ||||
| -rw-r--r-- | Tools/DumpRenderTree/chromium/TestRunner/src/Task.h | 96 | ||||
| -rw-r--r-- | Tools/DumpRenderTree/chromium/TestRunner/src/TestDelegate.h | 8 | ||||
| -rw-r--r-- | Tools/DumpRenderTree/chromium/TestRunner/src/TestInterfaces.cpp | 4 | ||||
| -rw-r--r-- | Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h | 1 | ||||
| -rw-r--r-- | Tools/DumpRenderTree/chromium/TestRunner/src/WebTask.cpp (renamed from Tools/DumpRenderTree/chromium/TestRunner/src/Task.cpp) | 42 | ||||
| -rw-r--r-- | Tools/DumpRenderTree/chromium/TestRunner/src/WebTestInterfaces.cpp | 24 |
11 files changed, 88 insertions, 145 deletions
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/Task.h b/Tools/DumpRenderTree/chromium/TestRunner/src/Task.h deleted file mode 100644 index 0b32c472b..000000000 --- a/Tools/DumpRenderTree/chromium/TestRunner/src/Task.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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 - -#include "webkit/support/webkit_support.h" -#include <wtf/OwnPtr.h> -#include <wtf/Vector.h> - -class TaskList; - -// 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 { -public: - WebTask(TaskList*); - // 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; -}; - -class TaskList { -public: - TaskList() { } - ~TaskList() { revokeAll(); } - void registerTask(WebTask* task) { m_tasks.append(task); } - void unregisterTask(WebTask*); - void revokeAll(); - -private: - Vector<WebTask*> m_tasks; -}; - -// 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 { -public: - MethodTask(T* object): WebTask(object->taskList()), m_object(object) { } - 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 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; |
