diff options
Diffstat (limited to 'WebKitTools/WebKitTestRunner/qt')
-rw-r--r-- | WebKitTools/WebKitTestRunner/qt/PlatformWebViewQt.cpp | 99 | ||||
-rw-r--r-- | WebKitTools/WebKitTestRunner/qt/TestControllerQt.cpp | 133 | ||||
-rw-r--r-- | WebKitTools/WebKitTestRunner/qt/WebKitTestRunner.pro | 68 | ||||
-rw-r--r-- | WebKitTools/WebKitTestRunner/qt/main.cpp | 69 |
4 files changed, 369 insertions, 0 deletions
diff --git a/WebKitTools/WebKitTestRunner/qt/PlatformWebViewQt.cpp b/WebKitTools/WebKitTestRunner/qt/PlatformWebViewQt.cpp new file mode 100644 index 0000000..d405a0f --- /dev/null +++ b/WebKitTools/WebKitTestRunner/qt/PlatformWebViewQt.cpp @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 University of Szeged. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * 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 "PlatformWebView.h" +#include "qgraphicswkview.h" +#include <QtGui> + +namespace WTR { + +class WebView : public QGraphicsView { +public: + WebView(WKPageNamespaceRef); + + QGraphicsWKView* wkView() const { return m_item; } + + virtual ~WebView() { delete m_item; } + +private: + QGraphicsWKView* m_item; +}; + +WebView::WebView(WKPageNamespaceRef namespaceRef) + : QGraphicsView() + , m_item(new QGraphicsWKView(namespaceRef)) +{ + setScene(new QGraphicsScene(this)); + scene()->addItem(m_item); +} + +PlatformWebView::PlatformWebView(WKPageNamespaceRef namespaceRef) + : m_view(new WebView(namespaceRef)) + , m_window(new QMainWindow()) +{ + m_view->setParent(m_window); + m_window->setCentralWidget(m_view); + m_window->setGeometry(0, 0, 800, 600); +} + +PlatformWebView::~PlatformWebView() +{ + delete m_window; +} + +void PlatformWebView::resizeTo(unsigned width, unsigned height) +{ + m_window->resize(width, height); +} + +WKPageRef PlatformWebView::page() +{ + return m_view->wkView()->page()->pageRef(); +} + +void PlatformWebView::focus() +{ + m_view->setFocus(Qt::OtherFocusReason); +} + +WKRect PlatformWebView::windowFrame() +{ + // Implement. + + WKRect wkFrame; + wkFrame.origin.x = 0; + wkFrame.origin.y = 0; + wkFrame.size.width = 0; + wkFrame.size.height = 0; + return wkFrame; +} + +void PlatformWebView::setWindowFrame(WKRect) +{ + // Implement. +} + +} // namespace WTR diff --git a/WebKitTools/WebKitTestRunner/qt/TestControllerQt.cpp b/WebKitTools/WebKitTestRunner/qt/TestControllerQt.cpp new file mode 100644 index 0000000..ca0a00c --- /dev/null +++ b/WebKitTools/WebKitTestRunner/qt/TestControllerQt.cpp @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 University of Szeged. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * 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 "TestController.h" + +#include "WKStringQt.h" + +#include <cstdlib> +#include <QCoreApplication> +#include <QEventLoop> +#include <QFileInfo> +#include <QLibrary> +#include <QObject> +#include <QtGlobal> +#include <wtf/Platform.h> +#include <wtf/text/WTFString.h> + +namespace WTR { + +class TestControllerRunLoop : public QObject { + Q_OBJECT +public: + static TestControllerRunLoop* instance() + { + static TestControllerRunLoop* result = new TestControllerRunLoop; + return result; + } + + void start(int msec) + { + m_timerID = startTimer(msec); + ASSERT(m_timerID); + m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents); + } + + void stop() + { + killTimer(m_timerID); + m_eventLoop.quit(); + } +private: + TestControllerRunLoop() {} + + void timerEvent(QTimerEvent*) + { + fprintf(stderr, "FAIL: TestControllerRunLoop timed out.\n"); + stop(); + } + + QEventLoop m_eventLoop; + int m_timerID; +}; + +void TestController::notifyDone() +{ + TestControllerRunLoop::instance()->stop(); +} + +void TestController::platformInitialize() +{ +} + +void TestController::platformRunUntil(bool&, double timeout) +{ + TestControllerRunLoop::instance()->start(static_cast<int>(timeout * 1000)); +} + +static bool isExistingLibrary(const QString& path) +{ +#if OS(WINDOWS) || OS(SYMBIAN) + const char* librarySuffixes[] = { ".dll" }; +#elif OS(MAC_OS_X) + const char* librarySuffixes[] = { ".bundle", ".dylib", ".so" }; +#elif OS(UNIX) + const char* librarySuffixes[] = { ".so" }; +#else +#error Library path suffix should be specified for this platform +#endif + for (unsigned i = 0; i < sizeof(librarySuffixes) / sizeof(const char*); ++i) { + if (QLibrary::isLibrary(path + librarySuffixes[i])) + return true; + } + + return false; +} + +void TestController::initializeInjectedBundlePath() +{ + QString path = QLatin1String(getenv("WTR_INJECTEDBUNDLE_PATH")); + if (path.isEmpty()) + path = QFileInfo(QCoreApplication::applicationDirPath() + "/../lib/libWTRInjectedBundle").absoluteFilePath(); + if (!isExistingLibrary(path)) + qFatal("Cannot find the injected bundle at %s\n", qPrintable(path)); + + m_injectedBundlePath = WKStringCreateWithQString(path); +} + +void TestController::initializeTestPluginDirectory() +{ + // This is called after initializeInjectedBundlePath. + m_testPluginDirectory = m_injectedBundlePath; +} + +void TestController::platformInitializeContext() +{ +} + +#include "TestControllerQt.moc" + +} // namespace WTR diff --git a/WebKitTools/WebKitTestRunner/qt/WebKitTestRunner.pro b/WebKitTools/WebKitTestRunner/qt/WebKitTestRunner.pro new file mode 100644 index 0000000..a638e65 --- /dev/null +++ b/WebKitTools/WebKitTestRunner/qt/WebKitTestRunner.pro @@ -0,0 +1,68 @@ +TARGET = WebKitTestRunner +CONFIG -= app_bundle + +BASEDIR = $$PWD/../ +isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../../.. + +include(../../../WebKit.pri) + +!CONFIG(release, debug|release) { + OBJECTS_DIR = obj/debug +} else { # Release + OBJECTS_DIR = obj/release +} + +DEFINES += USE_SYSTEM_MALLOC + +INCLUDEPATH += \ + $$BASEDIR \ + $$BASEDIR/../../JavaScriptCore \ + $$BASEDIR/../../WebKit2 \ + $$BASEDIR/../../WebKit2/Shared \ + $$BASEDIR/../../WebKit2/UIProcess/API/qt \ + $$BASEDIR/../../WebKit2/UIProcess/API/cpp/qt \ + +INCLUDEPATH += \ + $$OUTPUT_DIR/include \ + + +DESTDIR = $$OUTPUT_DIR/bin + +unix:!mac { + CONFIG += link_pkgconfig + PKGCONFIG += fontconfig +} + +QT = core gui network + +HEADERS = \ + $$BASEDIR/PlatformWebView.h \ + $$BASEDIR/StringFunctions.h \ + $$BASEDIR/TestController.h \ + $$BASEDIR/TestInvocation.h + +SOURCES = \ + main.cpp \ + PlatformWebViewQt.cpp \ + TestControllerQt.cpp \ + $$BASEDIR/TestController.cpp \ + $$BASEDIR/TestInvocation.cpp \ + +PREFIX_HEADER = $$BASEDIR/WebKitTestRunnerPrefix.h +QMAKE_CXXFLAGS += "-include $$PREFIX_HEADER" + +linux-* { + # From Creator's src/rpath.pri: + # Do the rpath by hand since it's not possible to use ORIGIN in QMAKE_RPATHDIR + # this expands to $ORIGIN (after qmake and make), it does NOT read a qmake var. + QMAKE_RPATHDIR = \$\$ORIGIN/../lib $$QMAKE_RPATHDIR + MY_RPATH = $$join(QMAKE_RPATHDIR, ":") + + QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,$${MY_RPATH}\' + QMAKE_RPATHDIR = +} else { + QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR +} + +include(../../../JavaScriptCore/JavaScriptCore.pri) +addJavaScriptCoreLib(../../../JavaScriptCore) diff --git a/WebKitTools/WebKitTestRunner/qt/main.cpp b/WebKitTools/WebKitTestRunner/qt/main.cpp new file mode 100644 index 0000000..4312a05 --- /dev/null +++ b/WebKitTools/WebKitTestRunner/qt/main.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 University of Szeged. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "TestController.h" + +#include <QApplication> +#include <QObject> +#include <QTimer> + +class Launcher : public QObject { + Q_OBJECT + +public: + Launcher(int argc, char** argv) + : m_argc(argc) + , m_argv(argv) + { + } + + ~Launcher() + { + delete m_controller; + } + +public slots: + void launch() + { + m_controller = new WTR::TestController(m_argc, const_cast<const char**>(m_argv)); + QApplication::exit(); + } + +private: + WTR::TestController* m_controller; + int m_argc; + char** m_argv; +}; + +int main(int argc, char** argv) +{ + QApplication app(argc, argv); + Launcher launcher(argc, argv); + QTimer::singleShot(0, &launcher, SLOT(launch())); + return app.exec();; +} + +#include "main.moc" |