Changeset 143197 in webkit


Ignore:
Timestamp:
Feb 18, 2013 5:00:00 AM (11 years ago)
Author:
allan.jensen@digia.com
Message:

[Qt][WK2] Support WK2 API tests
https://bugs.webkit.org/show_bug.cgi?id=109843

Reviewed by Jocelyn Turcotte.

Source/WebKit2:

  • UIProcess/API/qt/qquickwebview_p.h:

(TestWebKitAPI):

Tools:

  • TestWebKitAPI/DerivedSources.pri: Added.
  • TestWebKitAPI/InjectedBundle.pri: Added.
  • TestWebKitAPI/PlatformWebView.h:
  • TestWebKitAPI/TestWebKitAPI.pri:
  • TestWebKitAPI/TestWebKitAPI.pro:
  • TestWebKitAPI/Tests/JavaScriptCore/JavaScriptCore.pro: Added.
  • TestWebKitAPI/Tests/WTF/WTF.pro:
  • TestWebKitAPI/Tests/WebKit2/WebKit2.pro: Added.
  • TestWebKitAPI/qt/PlatformUtilitiesQt.cpp:

(TestWebKitAPI::Util::sleep):
(TestWebKitAPI::Util::createInjectedBundlePath):
(TestWebKitAPI::Util::createURLForResource):
(TestWebKitAPI::Util::isKeyDown):
(Util):

  • TestWebKitAPI/qt/PlatformWebViewQt.cpp: Added.

(TestWebKitAPI):
(WrapperWindow):
(TestWebKitAPI::WrapperWindow::WrapperWindow):
(TestWebKitAPI::WrapperWindow::handleStatusChanged):
(TestWebKitAPI::PlatformWebView::PlatformWebView):
(TestWebKitAPI::PlatformWebView::~PlatformWebView):
(TestWebKitAPI::PlatformWebView::resizeTo):
(TestWebKitAPI::PlatformWebView::page):
(TestWebKitAPI::PlatformWebView::focus):
(TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress):
(TestWebKitAPI::PlatformWebView::simulateAltKeyPress):
(TestWebKitAPI::PlatformWebView::simulateMouseMove):
(TestWebKitAPI::PlatformWebView::simulateRightClick):

  • TestWebKitAPI/qt/main.cpp:

(addQtWebProcessToPath):
(main):

Location:
trunk
Files:
6 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r143195 r143197  
     12013-02-15  Allan Sandfeld Jensen  <allan.jensen@digia.com>
     2
     3        [Qt][WK2] Support WK2 API tests
     4        https://bugs.webkit.org/show_bug.cgi?id=109843
     5
     6        Reviewed by Jocelyn Turcotte.
     7
     8        * UIProcess/API/qt/qquickwebview_p.h:
     9        (TestWebKitAPI):
     10
    1112013-02-18  Andras Becsi  <andras.becsi@digia.com>
    212
  • trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h

    r142095 r143197  
    4646
    4747namespace WTR {
     48class PlatformWebView;
     49}
     50
     51namespace TestWebKitAPI {
    4852class PlatformWebView;
    4953}
     
    225229    friend class WebKit::QtWebPageUIClient;
    226230    friend class WTR::PlatformWebView;
     231    friend class TestWebKitAPI::PlatformWebView;
    227232    friend class QQuickWebViewExperimental;
    228233};
  • trunk/Tools/ChangeLog

    r143190 r143197  
     12013-02-15  Allan Sandfeld Jensen  <allan.jensen@digia.com>
     2
     3        [Qt][WK2] Support WK2 API tests
     4        https://bugs.webkit.org/show_bug.cgi?id=109843
     5
     6        Reviewed by Jocelyn Turcotte.
     7
     8        * TestWebKitAPI/DerivedSources.pri: Added.
     9        * TestWebKitAPI/InjectedBundle.pri: Added.
     10        * TestWebKitAPI/PlatformWebView.h:
     11        * TestWebKitAPI/TestWebKitAPI.pri:
     12        * TestWebKitAPI/TestWebKitAPI.pro:
     13        * TestWebKitAPI/Tests/JavaScriptCore/JavaScriptCore.pro: Added.
     14        * TestWebKitAPI/Tests/WTF/WTF.pro:
     15        * TestWebKitAPI/Tests/WebKit2/WebKit2.pro: Added.
     16        * TestWebKitAPI/qt/PlatformUtilitiesQt.cpp:
     17        (TestWebKitAPI::Util::sleep):
     18        (TestWebKitAPI::Util::createInjectedBundlePath):
     19        (TestWebKitAPI::Util::createURLForResource):
     20        (TestWebKitAPI::Util::isKeyDown):
     21        (Util):
     22        * TestWebKitAPI/qt/PlatformWebViewQt.cpp: Added.
     23        (TestWebKitAPI):
     24        (WrapperWindow):
     25        (TestWebKitAPI::WrapperWindow::WrapperWindow):
     26        (TestWebKitAPI::WrapperWindow::handleStatusChanged):
     27        (TestWebKitAPI::PlatformWebView::PlatformWebView):
     28        (TestWebKitAPI::PlatformWebView::~PlatformWebView):
     29        (TestWebKitAPI::PlatformWebView::resizeTo):
     30        (TestWebKitAPI::PlatformWebView::page):
     31        (TestWebKitAPI::PlatformWebView::focus):
     32        (TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress):
     33        (TestWebKitAPI::PlatformWebView::simulateAltKeyPress):
     34        (TestWebKitAPI::PlatformWebView::simulateMouseMove):
     35        (TestWebKitAPI::PlatformWebView::simulateRightClick):
     36        * TestWebKitAPI/qt/main.cpp:
     37        (addQtWebProcessToPath):
     38        (main):
     39
    1402013-02-18  Christophe Dumez  <ch.dumez@sisa.samsung.com>
    241
  • trunk/Tools/TestWebKitAPI/PlatformWebView.h

    r141836 r143197  
    5151typedef WKViewRef PlatformWKView;
    5252typedef Ecore_Evas* PlatformWindow;
     53#elif PLATFORM(QT)
     54QT_BEGIN_NAMESPACE
     55class QQuickView;
     56QT_END_NAMESPACE
     57class QQuickWebView;
     58typedef QQuickWebView* PlatformWKView;
     59typedef QQuickView* PlatformWindow;
    5360#endif
    5461
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.pri

    r142070 r143197  
    11
    22INCLUDEPATH += $$PWD $${ROOT_WEBKIT_DIR}/Source/ThirdParty/gtest/include
    3 WEBKIT += wtf javascriptcore
     3WEBKIT += wtf javascriptcore webkit2
    44
    55DEFINES += QT_NO_CAST_FROM_ASCII
    66
    7 QT += core gui webkit
     7QT += core core-private gui gui-private webkit quick quick-private
    88
    99CONFIG += compiling_thirdparty_code
    1010
    11 SOURCES += $$PWD/*.cpp
    12 SOURCES += $$PWD/qt/*.cpp
     11SOURCES += \
     12    $$PWD/JavaScriptTest.cpp \
     13    $$PWD/PlatformUtilities.cpp \
     14    $$PWD/TestsController.cpp \
     15    $$PWD/qt/main.cpp \
     16    $$PWD/qt/PlatformUtilitiesQt.cpp \
     17    $$PWD/qt/PlatformWebViewQt.cpp
    1318
    1419LIBS += -L$${ROOT_BUILD_DIR}/Source/ThirdParty/gtest/$$activeBuildConfig() -lgtest
     20
     21DEFINES += ROOT_BUILD_DIR=\\\"$${ROOT_BUILD_DIR}\\\"
     22
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.pro

    r142070 r143197  
    11TEMPLATE = subdirs
     2CONFIG += ordered
    23
    3 SUBDIRS += Tests/WTF
     4derived_sources.file = DerivedSources.pri
     5injected_bundle.file = InjectedBundle.pri
     6tests.file = Tests.pri
     7
     8SUBDIRS += derived_sources injected_bundle tests
     9
     10addStrictSubdirOrderBetween(derived_sources, injected_bundle)
     11addStrictSubdirOrderBetween(derived_sources, tests)
  • trunk/Tools/TestWebKitAPI/Tests/WTF/WTF.pro

    r142070 r143197  
    1919    StringOperators.cpp \
    2020    TemporaryChange.cpp \
     21    Vector.cpp \
    2122    VectorBasic.cpp \
    22     Vector.cpp \
    2323    VectorReverse.cpp \
    2424    WTFString.cpp
    2525
    2626include(../../TestWebKitAPI.pri)
     27
     28DEFINES += APITEST_SOURCE_DIR=\\\"$$PWD\\\"
     29
  • trunk/Tools/TestWebKitAPI/qt/PlatformUtilitiesQt.cpp

    r142070 r143197  
    2222#include "PlatformUtilities.h"
    2323
     24#include <WebKit2/WKStringQt.h>
     25#include <WebKit2/WKNativeEvent.h>
     26#include <WebKit2/WKURLQt.h>
     27
    2428#include <QCoreApplication>
    25 
    26 #include <unistd.h>
     29#include <QDir>
     30#include <QUrl>
     31#include <QThread>
    2732
    2833namespace TestWebKitAPI {
     
    3742void sleep(double seconds)
    3843{
    39     usleep(seconds * 1000000);
     44    QThread::sleep(seconds);
    4045}
    4146
    4247WKStringRef createInjectedBundlePath()
    4348{
    44     // ### FIXME.
    45     return WKStringCreateWithUTF8CString("");
     49    QString path = QFileInfo(QStringLiteral(ROOT_BUILD_DIR "/lib/libTestWebKitAPIInjectedBundle")).absoluteFilePath();
     50
     51    return WKStringCreateWithQString(path);
    4652}
    4753
    4854WKURLRef createURLForResource(const char* resource, const char* extension)
    4955{
    50     // ### FIXME.
    51     return WKURLCreateWithUTF8CString("");
     56    QDir path(QStringLiteral(APITEST_SOURCE_DIR));
     57    QString filename = QString::fromLocal8Bit(resource) + QStringLiteral(".") + QString::fromLocal8Bit(extension);
     58
     59    return WKURLCreateWithQUrl(QUrl::fromLocalFile(path.absoluteFilePath(filename)));
    5260}
    5361
     
    5765}
    5866
     67bool isKeyDown(WKNativeEventPtr event)
     68{
     69    return event->type() == QEvent::KeyPress;
     70}
     71
    5972} // namespace Util
    6073} // namespace TestWebKitAPI
  • trunk/Tools/TestWebKitAPI/qt/main.cpp

    r142070 r143197  
    2222#include "TestsController.h"
    2323
     24#include "qquickwebview_p.h"
    2425#include <QGuiApplication>
     26
     27void addQtWebProcessToPath()
     28{
     29    // Since tests won't find ./QtWebProcess, add it to PATH (at the end to prevent surprises).
     30    // ROOT_BUILD_DIR should be defined by qmake.
     31    qputenv("PATH", qgetenv("PATH") + QByteArray(":" ROOT_BUILD_DIR "/bin"));
     32}
     33
     34void messageHandler(QtMsgType type, const QMessageLogContext&, const QString& message)
     35{
     36    if (type == QtCriticalMsg) {
     37        fprintf(stderr, "%s\n", qPrintable(message));
     38        return;
     39    }
     40
     41    // Do nothing
     42}
    2543
    2644int main(int argc, char** argv)
    2745{
     46    bool suppressQtDebugOutput = true; // Suppress debug output from Qt if not started with --verbose.
     47    bool useDesktopBehavior = true; // Use traditional desktop behavior if not started with --flickable.
     48
     49    for (int i = 1; i < argc; ++i) {
     50        if (!qstrcmp(argv[i], "--verbose"))
     51            suppressQtDebugOutput = false;
     52        else if (!qstrcmp(argv[i], "--flickable"))
     53            useDesktopBehavior = false;
     54    }
     55
     56    QQuickWebViewExperimental::setFlickableViewportEnabled(!useDesktopBehavior);
     57
     58    // Has to be done before QApplication is constructed in case
     59    // QApplication itself produces debug output.
     60    if (suppressQtDebugOutput) {
     61        qInstallMessageHandler(messageHandler);
     62        if (qgetenv("QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT").isEmpty())
     63            qputenv("QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT", "1");
     64    }
     65
    2866    QGuiApplication app(argc, argv);
     67    addQtWebProcessToPath();
    2968
    3069    return TestWebKitAPI::TestsController::shared().run(argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE;
Note: See TracChangeset for help on using the changeset viewer.