diff options
author | Szabolcs David <davidsz@inf.u-szeged.hu> | 2015-07-14 02:37:26 -0700 |
---|---|---|
committer | Szabolcs David <davidsz@inf.u-szeged.hu> | 2016-03-25 10:53:54 +0000 |
commit | b6dc12bbb5059441363dcea3bcae94d17da482ec (patch) | |
tree | fc15f08b7a31a05e739b6bee5756b5fb346bdb7e | |
parent | 963f90b7a07236d81d7bb65798c641556501ab10 (diff) |
Move loadVisuallyCommitted signal to the test support API
Change-Id: I877bbd8bc5c710370f135a27bcd7f0f7c95a7292
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
-rw-r--r-- | src/webengine/api/qquickwebenginetestsupport_p.h | 1 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview.cpp | 5 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview_p_p.h | 1 | ||||
-rw-r--r-- | tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp | 13 | ||||
-rw-r--r-- | tests/auto/quick/shared/util.h | 11 | ||||
-rw-r--r-- | tests/auto/quick/tests.pri | 4 |
6 files changed, 30 insertions, 5 deletions
diff --git a/src/webengine/api/qquickwebenginetestsupport_p.h b/src/webengine/api/qquickwebenginetestsupport_p.h index d4b50ac2d..8ea023b63 100644 --- a/src/webengine/api/qquickwebenginetestsupport_p.h +++ b/src/webengine/api/qquickwebenginetestsupport_p.h @@ -81,6 +81,7 @@ public: Q_SIGNALS: void validationMessageShown(const QString &mainText, const QString &subText); void windowCloseRejected(); + void loadVisuallyCommitted(); private: QScopedPointer<QQuickWebEngineErrorPage> m_errorPage; diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 25c4d28ed..066a45d07 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -420,7 +420,10 @@ void QQuickWebEngineViewPrivate::loadCommitted() void QQuickWebEngineViewPrivate::loadVisuallyCommitted() { - Q_EMIT e->loadVisuallyCommitted(); +#ifdef ENABLE_QML_TESTSUPPORT_API + if (m_testSupport) + Q_EMIT m_testSupport->loadVisuallyCommitted(); +#endif } Q_STATIC_ASSERT(static_cast<int>(WebEngineError::NoErrorDomain) == static_cast<int>(QQuickWebEngineView::NoErrorDomain)); diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index dbbbf9168..65059c837 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -101,7 +101,6 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineViewExperimental : public QObjec Q_SIGNALS: void extraContextMenuEntriesComponentChanged(); - void loadVisuallyCommitted(); private: QQuickWebEngineViewExperimental(QQuickWebEngineViewPrivate* viewPrivate); diff --git a/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp b/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp index 6fd967d5a..bb09f890e 100644 --- a/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp +++ b/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp @@ -47,6 +47,7 @@ #include <QQuickItem> #include <QPainter> #include <qtwebengineglobal.h> +#include <private/qquickwebenginetestsupport_p.h> #include <private/qquickwebengineview_p.h> class TestView : public QQuickView { @@ -91,6 +92,9 @@ private Q_SLOTS: private: void setHtml(const QString &html); QScopedPointer<TestView> m_view; +#ifdef ENABLE_QML_TESTSUPPORT_API + QScopedPointer<QQuickWebEngineTestSupport> m_testSupport; +#endif }; static const QString greenSquare("<div style=\"background-color: #00ff00; position:absolute; left:50px; top: 50px; width: 50px; height: 50px;\"></div>"); @@ -121,6 +125,9 @@ tst_QQuickWebEngineViewGraphics::~tst_QQuickWebEngineViewGraphics() void tst_QQuickWebEngineViewGraphics::initTestCase() { QtWebEngine::initialize(); +#ifdef ENABLE_QML_TESTSUPPORT_API + m_testSupport.reset(new QQuickWebEngineTestSupport); +#endif } void tst_QQuickWebEngineViewGraphics::init() @@ -196,9 +203,11 @@ void tst_QQuickWebEngineViewGraphics::setHtml(const QString &html) m_view->create(); QQuickWebEngineView *webEngineView = static_cast<QQuickWebEngineView *>(m_view->rootObject()); - QSignalSpy spy(reinterpret_cast<QObject *>(webEngineView->experimental()), SIGNAL(loadVisuallyCommitted())); webEngineView->setProperty("url", QUrl(QStringLiteral("data:text/html,%1").arg(htmlData))); - QVERIFY(!spy.isEmpty() || spy.wait()); +#ifdef ENABLE_QML_TESTSUPPORT_API + webEngineView->setTestSupport(m_testSupport.data()); +#endif + QVERIFY(waitForViewportReady(webEngineView)); QCOMPARE(m_view->rootObject()->property("loading"), QVariant(false)); } diff --git a/tests/auto/quick/shared/util.h b/tests/auto/quick/shared/util.h index 8f7a85f68..66b42d010 100644 --- a/tests/auto/quick/shared/util.h +++ b/tests/auto/quick/shared/util.h @@ -119,7 +119,16 @@ inline bool waitForLoadFailed(QQuickWebEngineView *webEngineView, int timeout = inline bool waitForViewportReady(QQuickWebEngineView *webEngineView, int timeout = 10000) { - return waitForSignal(reinterpret_cast<QObject *>(webEngineView->experimental()), SIGNAL(loadVisuallyCommitted()), timeout); +#ifdef ENABLE_QML_TESTSUPPORT_API + return waitForSignal(reinterpret_cast<QObject *>(webEngineView->testSupport()), SIGNAL(loadVisuallyCommitted()), timeout); +#else + Q_UNUSED(webEngineView) + Q_UNUSED(timeout) + qFatal("Test Support API is disabled. The result is not reliable.\ + Use the following command to build Test Support module and rebuild WebEngineView API:\ + qmake -r WEBENGINE_CONFIG+=testsupport && make"); + return false; +#endif } #endif /* UTIL_H */ diff --git a/tests/auto/quick/tests.pri b/tests/auto/quick/tests.pri index 3c56aef97..efe9ff9d0 100644 --- a/tests/auto/quick/tests.pri +++ b/tests/auto/quick/tests.pri @@ -17,3 +17,7 @@ macx: CONFIG -= app_bundle # This define is used by some tests to look up resources in the source tree DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD/\\\" + +isQMLTestSupportApiEnabled() { + DEFINES += ENABLE_QML_TESTSUPPORT_API +} |