Reviewed by Kenneth Rohde Christiansen.
[Qt][WK2] Add a way to test the WebKit 2 APIs
https://bugs.webkit.org/show_bug.cgi?id=55408
Add the build file for test to the build system.
* Source/WebKit.pri: Add the include path for WebKit 2 APIs.
* Source/WebKit.pro: Add the dependency to build the new test project.
2011-02-28 Benjamin Poulain <benjamin.poulain@nokia.com>
Reviewed by Kenneth Rohde Christiansen.
[Qt][WK2] Add a way to test the WebKit 2 APIs
https://bugs.webkit.org/show_bug.cgi?id=55408
Add an initial test for the WebKit 2 APIs of Qt.
* UIProcess/API/qt/tests/html/basic_page.html: Added.
* UIProcess/API/qt/tests/qgraphicswkview/qgraphicswkview.pro: Added.
* UIProcess/API/qt/tests/qgraphicswkview/tst_qgraphicswkview.cpp: Added.
(View::View):
(View::resizeEvent):
(tst_QGraphicsWKView::init):
(tst_QGraphicsWKView::cleanup):
(tst_QGraphicsWKView::loadEmptyPage):
* UIProcess/API/qt/tests/tests.pri: Added.
* UIProcess/API/qt/tests/tests.pro: Added.
* UIProcess/API/qt/tests/util.h: Added.
(waitForSignal):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@79945
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-02-28 Benjamin Poulain <benjamin.poulain@nokia.com>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ [Qt][WK2] Add a way to test the WebKit 2 APIs
+ https://bugs.webkit.org/show_bug.cgi?id=55408
+
+ Add the build file for test to the build system.
+
+ * Source/WebKit.pri: Add the include path for WebKit 2 APIs.
+ * Source/WebKit.pro: Add the dependency to build the new test project.
+
2011-02-28 Balazs Kelemen <kbalazs@webkit.org>
Reviewed by Anders Carlsson.
$$OUTPUT_DIR/include
INCLUDEPATH += $$QT.script.includes
+webkit2 {
+ INCLUDEPATH += $$OUTPUT_DIR/include/WebKit2
+ # FIXME: Once the public header are well defined for WebKit2, this must go away.
+ INCLUDEPATH += $$PWD/WebKit2/
+}
+
CONFIG -= warn_on
*-g++*:QMAKE_CXXFLAGS += -Wall -Wextra -Wreturn-type -fno-strict-aliasing -Wcast-align -Wchar-subscripts -Wformat-security -Wreturn-type -Wno-unused-parameter -Wno-sign-compare -Wno-switch -Wno-switch-enum -Wundef -Wmissing-noreturn -Winit-self
SUBDIRS += WebCore
SUBDIRS += WebKit/qt/QtWebKit.pro
-webkit2:exists($$PWD/WebKit2/WebProcess.pro): SUBDIRS += WebKit2/WebProcess.pro
+webkit2 {
+ exists($$PWD/WebKit2/WebProcess.pro): SUBDIRS += WebKit2/WebProcess.pro
+ exists($$PWD/WebKit2/UIProcess/API/qt/tests): SUBDIRS += WebKit2/UIProcess/API/qt/tests
+}
contains(QT_CONFIG, declarative) {
exists($$PWD/WebKit/qt/declarative): SUBDIRS += WebKit/qt/declarative
+2011-02-28 Benjamin Poulain <benjamin.poulain@nokia.com>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ [Qt][WK2] Add a way to test the WebKit 2 APIs
+ https://bugs.webkit.org/show_bug.cgi?id=55408
+
+ Add an initial test for the WebKit 2 APIs of Qt.
+
+ * UIProcess/API/qt/tests/html/basic_page.html: Added.
+ * UIProcess/API/qt/tests/qgraphicswkview/qgraphicswkview.pro: Added.
+ * UIProcess/API/qt/tests/qgraphicswkview/tst_qgraphicswkview.cpp: Added.
+ (View::View):
+ (View::resizeEvent):
+ (tst_QGraphicsWKView::init):
+ (tst_QGraphicsWKView::cleanup):
+ (tst_QGraphicsWKView::loadEmptyPage):
+ * UIProcess/API/qt/tests/tests.pri: Added.
+ * UIProcess/API/qt/tests/tests.pro: Added.
+ * UIProcess/API/qt/tests/util.h: Added.
+ (waitForSignal):
+
2011-02-28 Anders Carlsson <andersca@apple.com>
Fix clang build.
--- /dev/null
+<h1>Basic page</h1>
--- /dev/null
+include(../tests.pri)
--- /dev/null
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "../util.h"
+#include <QGraphicsScene>
+#include <QGraphicsView>
+#include <QResizeEvent>
+#include <QSignalSpy>
+#include <QtTest/QtTest>
+#include <qgraphicswkview.h>
+#include <qwkcontext.h>
+
+class View;
+
+class tst_QGraphicsWKView : public QObject {
+ Q_OBJECT
+
+private slots:
+ void init();
+ void cleanup();
+
+ void loadEmptyPage();
+
+private:
+ View* m_view;
+};
+
+class View : public QGraphicsView {
+public:
+ View();
+ QGraphicsWKView* m_webView;
+
+protected:
+ void resizeEvent(QResizeEvent*);
+};
+
+View::View()
+{
+ QGraphicsScene* const scene = new QGraphicsScene(this);
+ setScene(scene);
+
+ QWKContext* context = new QWKContext(this);
+ m_webView = new QGraphicsWKView(context);
+ scene->addItem(m_webView);
+}
+
+void View::resizeEvent(QResizeEvent* event)
+{
+ QGraphicsView::resizeEvent(event);
+ QRectF rect(QPoint(0, 0), event->size());
+ m_webView->setGeometry(rect);
+ scene()->setSceneRect(rect);
+}
+
+void tst_QGraphicsWKView::init()
+{
+ m_view = new View;
+}
+
+void tst_QGraphicsWKView::cleanup()
+{
+ delete m_view;
+ m_view = 0;
+}
+
+void tst_QGraphicsWKView::loadEmptyPage()
+{
+ m_view->show();
+
+ m_view->m_webView-> load(QUrl::fromLocalFile(TESTDIR "/html/basic_page.html"));
+ QVERIFY(waitForSignal(m_view->m_webView, SIGNAL(loadFinished(bool))));
+}
+
+QTEST_MAIN(tst_QGraphicsWKView)
+
+#include "tst_qgraphicswkview.moc"
+
--- /dev/null
+TEMPLATE = app
+CONFIG -= app_bundle
+
+VPATH += $$_PRO_FILE_PWD_
+# Add the tst_ prefix, In QTDIR_build it's done by qttest_p4.prf
+CONFIG(QTDIR_build) { load(qttest_p4) }
+ELSE { TARGET = tst_$$TARGET }
+
+SOURCES += $${TARGET}.cpp
+INCLUDEPATH += $$PWD
+
+include(../../../../../WebKit.pri)
+QT += testlib
+
+QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
+DEFINES += TESTDIR=\\\"$$PWD\\\"
--- /dev/null
+TEMPLATE = subdirs
+SUBDIRS = qgraphicswkview
--- /dev/null
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+// Functions and macros that really need to be in QTestLib
+
+#include <QEventLoop>
+#include <QSignalSpy>
+#include <QTimer>
+
+#if !defined(TESTS_SOURCE_DIR)
+#define TESTS_SOURCE_DIR ""
+#endif
+
+/**
+ * Starts an event loop that runs until the given signal is received.
+ * Optionally the event loop
+ * can return earlier on a timeout.
+ *
+ * \return \p true if the requested signal was received
+ * \p false on timeout
+ */
+static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000)
+{
+ QEventLoop loop;
+ QObject::connect(obj, signal, &loop, SLOT(quit()));
+ QTimer timer;
+ QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
+ if (timeout > 0) {
+ QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ timer.setSingleShot(true);
+ timer.start(timeout);
+ }
+ loop.exec();
+ return timeoutSpy.isEmpty();
+}
+
+// Will try to wait for the condition while allowing event processing
+#define QTRY_VERIFY(__expr) \
+ do { \
+ const int __step = 50; \
+ const int __timeout = 5000; \
+ if (!(__expr)) { \
+ QTest::qWait(0); \
+ } \
+ for (int __i = 0; __i < __timeout && !(__expr); __i+=__step) { \
+ QTest::qWait(__step); \
+ } \
+ QVERIFY(__expr); \
+ } while(0)
+
+// Will try to wait for the condition while allowing event processing
+#define QTRY_COMPARE(__expr, __expected) \
+ do { \
+ const int __step = 50; \
+ const int __timeout = 5000; \
+ if ((__expr) != (__expected)) { \
+ QTest::qWait(0); \
+ } \
+ for (int __i = 0; __i < __timeout && ((__expr) != (__expected)); __i+=__step) { \
+ QTest::qWait(__step); \
+ } \
+ QCOMPARE(__expr, __expected); \
+ } while(0)