diff options
Diffstat (limited to 'tests/auto/widgets/qwebenginepage')
-rw-r--r-- | tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 797d4e4e7..6a4a5a965 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -31,11 +31,12 @@ #include <QMenu> #include <QMimeDatabase> #include <QNetworkProxy> -#include <QOpenGLWidget> #include <QPaintEngine> #include <QPushButton> #include <QScreen> -#include <QStateMachine> +#if defined(QT_STATEMACHINE_LIB) +# include <QStateMachine> +#endif #include <QtGui/QClipboard> #include <QtTest/QtTest> #include <QTextCharFormat> @@ -46,7 +47,7 @@ #include <qnetworkcookiejar.h> #include <qnetworkreply.h> #include <qnetworkrequest.h> -#include <qwebenginedownloaditem.h> +#include <qwebenginedownloadrequest.h> #include <qwebenginefindtextresult.h> #include <qwebenginefullscreenrequest.h> #include <qwebenginehistory.h> @@ -130,8 +131,10 @@ private Q_SLOTS: void findTextCalledOnMatch(); void findTextActiveMatchOrdinal(); void deleteQWebEngineViewTwice(); +#if defined(QT_STATEMACHINE_LIB) void loadSignalsOrder_data(); void loadSignalsOrder(); +#endif void openWindowDefaultSize(); #ifdef Q_OS_MAC @@ -381,7 +384,7 @@ void tst_QWebEnginePage::geolocationRequestJS() QFETCH(int, errorCode); QWebEngineView view; JSTestPage *newPage = new JSTestPage(&view); - newPage->setView(&view); + view.setPage(newPage); newPage->setGeolocationPermission(allowed); connect(newPage, SIGNAL(featurePermissionRequested(const QUrl&, QWebEnginePage::Feature)), @@ -1069,11 +1072,11 @@ void tst_QWebEnginePage::findText() void tst_QWebEnginePage::findTextResult() { QSignalSpy findTextSpy(m_view->page(), &QWebEnginePage::findTextFinished); - auto signalResult = [&findTextSpy]() -> QVector<int> { + auto signalResult = [&findTextSpy]() -> QList<int> { if (findTextSpy.count() != 1) - return QVector<int>({-1, -1}); + return QList<int>({-1, -1}); auto r = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>(); - return QVector<int>({ r.numberOfMatches(), r.activeMatch() }); + return QList<int>({ r.numberOfMatches(), r.activeMatch() }); }; // findText will abort in blink if the view has an empty size. @@ -1085,21 +1088,21 @@ void tst_QWebEnginePage::findTextResult() QTRY_COMPARE(loadSpy.count(), 1); QCOMPARE(findTextSync(m_page, ""), false); - QCOMPARE(signalResult(), QVector<int>({0, 0})); + QCOMPARE(signalResult(), QList<int>({0, 0})); const QStringList words = { "foo", "bar" }; for (const QString &subString : words) { QCOMPARE(findTextSync(m_page, subString), true); - QCOMPARE(signalResult(), QVector<int>({1, 1})); + QCOMPARE(signalResult(), QList<int>({1, 1})); QCOMPARE(findTextSync(m_page, ""), false); - QCOMPARE(signalResult(), QVector<int>({0, 0})); + QCOMPARE(signalResult(), QList<int>({0, 0})); } QCOMPARE(findTextSync(m_page, "blahhh"), false); - QCOMPARE(signalResult(), QVector<int>({0, 0})); + QCOMPARE(signalResult(), QList<int>({0, 0})); QCOMPARE(findTextSync(m_page, ""), false); - QCOMPARE(signalResult(), QVector<int>({0, 0})); + QCOMPARE(signalResult(), QList<int>({0, 0})); } void tst_QWebEnginePage::findTextSuccessiveShouldCallAllCallbacks() @@ -1358,6 +1361,8 @@ void tst_QWebEnginePage::deleteQWebEngineViewTwice() } } +// TODO: Reimplement test without QStateMachine or add qtscxml module dependency +#if defined(QT_STATEMACHINE_LIB) class SpyForLoadSignalsOrder : public QStateMachine { Q_OBJECT public: @@ -1415,6 +1420,7 @@ void tst_QWebEnginePage::loadSignalsOrder() page.load(url); QTRY_VERIFY_WITH_TIMEOUT(loadSpy.isFinished(), 20000); } +#endif // defined(QT_STATEMACHINE_LIB) void tst_QWebEnginePage::renderWidgetHostViewNotShowTopLevel() { @@ -1681,9 +1687,9 @@ void tst_QWebEnginePage::savePage() QWebEnginePage *page = view.page(); connect(page->profile(), &QWebEngineProfile::downloadRequested, - [] (QWebEngineDownloadItem *item) + [] (QWebEngineDownloadRequest *item) { - connect(item, &QWebEngineDownloadItem::finished, + connect(item, &QWebEngineDownloadRequest::isFinishedChanged, &QTestEventLoop::instance(), &QTestEventLoop::exitLoop, Qt::QueuedConnection); }); @@ -1697,7 +1703,7 @@ void tst_QWebEnginePage::savePage() // Save the loaded page as HTML. QTemporaryDir tempDir(QDir::tempPath() + "/tst_qwebengineview-XXXXXX"); const QString filePath = tempDir.path() + "/thingumbob.html"; - page->save(filePath, QWebEngineDownloadItem::CompleteHtmlSaveFormat); + page->save(filePath, QWebEngineDownloadRequest::CompleteHtmlSaveFormat); QTestEventLoop::instance().enterLoop(10); // Load something else. @@ -1717,9 +1723,9 @@ void tst_QWebEnginePage::openWindowDefaultSize() QSignalSpy spyFinished(&page, &QWebEnginePage::loadFinished); QSignalSpy windowCreatedSpy(&page, SIGNAL(windowCreated())); QWebEngineView view; - page.setView(&view); + view.setPage(&page); page.settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, true); - page.setUrl(QUrl("about:blank")); + view.setUrl(QUrl("about:blank")); view.show(); QTRY_COMPARE(spyFinished.count(), 1); @@ -2061,7 +2067,7 @@ private Q_SLOTS: void continueError() { - emit error(this->error()); + emit errorOccurred(this->error()); emit finished(); } }; @@ -2417,9 +2423,13 @@ void tst_QWebEnginePage::setContent_data() QString str = QString::fromUtf8("ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει"); QTest::newRow("UTF-8 plain text") << "text/plain; charset=utf-8" << str.toUtf8() << str; - QTextCodec *utf16 = QTextCodec::codecForName("UTF-16"); - if (utf16) - QTest::newRow("UTF-16 plain text") << "text/plain; charset=utf-16" << utf16->fromUnicode(str) << str; + QBuffer out16; + out16.open(QIODevice::WriteOnly); + QTextStream stream16(&out16); + stream16.setEncoding(QStringConverter::Utf16); + stream16 << str; + stream16.flush(); + QTest::newRow("UTF-16 plain text") << "text/plain; charset=utf-16" << out16.buffer() << str; str = QString::fromUtf8("Une chaîne de caractères à sa façon."); QTest::newRow("latin-1 plain text") << "text/plain; charset=iso-8859-1" << str.toLatin1() << str; @@ -4715,7 +4725,7 @@ void tst_QWebEnginePage::closeContents() QWebEngineView *dialogView = new QWebEngineView; QWebEnginePage *dialogPage = page.createdWindows[0]; - dialogPage->setView(dialogView); + dialogView->setPage(dialogPage); QCOMPARE(dialogPage->lifecycleState(), QWebEnginePage::LifecycleState::Active); // This should not crash. |