diff options
Diffstat (limited to 'tests/auto/widgets/qwebengineview')
-rw-r--r-- | tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index d86810713..7af08dbde 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -28,8 +28,9 @@ #include <qwebengineview.h> #include <qwebenginepage.h> #include <qwebenginesettings.h> -#include <qnetworkrequest.h> +#include <qaction.h> #include <qdiriterator.h> +#include <qnetworkrequest.h> #include <qstackedlayout.h> #include <qtemporarydir.h> #include <QClipboard> @@ -45,7 +46,6 @@ #include <QTcpServer> #include <QTcpSocket> #include <QStyle> -#include <QtWidgets/qaction.h> #include <QWebEngineProfile> #include <QtCore/qregularexpression.h> @@ -311,7 +311,7 @@ void tst_QWebEngineView::changePage() if (!fromIsNullPage) { QVERIFY(!pageFrom->iconUrl().isEmpty()); QCOMPARE(spyIconUrl.last().value(0).toUrl(), pageFrom->iconUrl()); - QCOMPARE(spyIcon.last().value(0), QVariant::fromValue(pageFrom->icon())); + QCOMPARE(spyIcon.last().value(0).value<QIcon>(), pageFrom->icon()); } QScopedPointer<QWebEnginePage> pageTo(new QWebEnginePage); @@ -340,7 +340,7 @@ void tst_QWebEngineView::changePage() QCOMPARE(pageFrom->iconUrl() == pageTo->iconUrl(), iconIsSame); if (!iconIsSame) { QCOMPARE(spyIconUrl.last().value(0).toUrl(), pageTo->iconUrl()); - QCOMPARE(spyIcon.last().value(0), QVariant::fromValue(pageTo->icon())); + QCOMPARE(spyIcon.last().value(0).value<QIcon>(), pageTo->icon()); } // verify no emits on destroy with the same number of signals in spy @@ -577,10 +577,10 @@ void tst_QWebEngineView::focusInputTypes() class KeyEventRecordingWidget : public QWidget { public: - QList<QKeyEvent> pressEvents; - QList<QKeyEvent> releaseEvents; - void keyPressEvent(QKeyEvent *e) override { pressEvents << *e; } - void keyReleaseEvent(QKeyEvent *e) override { releaseEvents << *e; } + QList<QKeyEvent *> pressEvents; + QList<QKeyEvent *> releaseEvents; + void keyPressEvent(QKeyEvent *e) override { pressEvents << e->clone(); } + void keyReleaseEvent(QKeyEvent *e) override { releaseEvents << e->clone(); } }; void tst_QWebEngineView::unhandledKeyEventPropagation() @@ -626,15 +626,15 @@ void tst_QWebEngineView::unhandledKeyEventPropagation() // The page will consume the Tab key to change focus between elements while the arrow // keys won't be used. QCOMPARE(parentWidget.pressEvents.size(), 3); - QCOMPARE(parentWidget.pressEvents[0].key(), (int)Qt::Key_Right); - QCOMPARE(parentWidget.pressEvents[1].key(), (int)Qt::Key_Left); - QCOMPARE(parentWidget.pressEvents[2].key(), (int)Qt::Key_Y); + QCOMPARE(parentWidget.pressEvents[0]->key(), (int)Qt::Key_Right); + QCOMPARE(parentWidget.pressEvents[1]->key(), (int)Qt::Key_Left); + QCOMPARE(parentWidget.pressEvents[2]->key(), (int)Qt::Key_Y); // Key releases will all come back unconsumed. - QCOMPARE(parentWidget.releaseEvents[0].key(), (int)Qt::Key_Right); - QCOMPARE(parentWidget.releaseEvents[1].key(), (int)Qt::Key_Tab); - QCOMPARE(parentWidget.releaseEvents[2].key(), (int)Qt::Key_Left); - QCOMPARE(parentWidget.releaseEvents[3].key(), (int)Qt::Key_Y); + QCOMPARE(parentWidget.releaseEvents[0]->key(), (int)Qt::Key_Right); + QCOMPARE(parentWidget.releaseEvents[1]->key(), (int)Qt::Key_Tab); + QCOMPARE(parentWidget.releaseEvents[2]->key(), (int)Qt::Key_Left); + QCOMPARE(parentWidget.releaseEvents[3]->key(), (int)Qt::Key_Y); } void tst_QWebEngineView::horizontalScrollbarTest() @@ -922,7 +922,7 @@ public: private: int m_eventCounter; - QVector<QString> m_eventHistory; + QList<QString> m_eventHistory; }; void tst_QWebEngineView::doNotSendMouseKeyboardEventsWhenDisabled() @@ -1216,7 +1216,7 @@ void tst_QWebEngineView::changeLocale() void tst_QWebEngineView::mixLangLocale() { for (QString locale : { "en_DK", "de_CH", "eu_ES" }) { - QLocale::setDefault(locale); + QLocale::setDefault(QLocale(locale)); QWebEngineView view; QSignalSpy loadSpy(&view, &QWebEngineView::loadFinished); @@ -1683,7 +1683,7 @@ void tst_QWebEngineView::inputFieldOverridesShortcuts() }; // The input form is not focused. The action is triggered on pressing Shift+Delete. - action->setShortcut(Qt::SHIFT + Qt::Key_Delete); + action->setShortcut(Qt::SHIFT | Qt::Key_Delete); QTest::keyClick(view.windowHandle(), Qt::Key_Delete, Qt::ShiftModifier); QTRY_VERIFY(actionTriggered); QCOMPARE(inputFieldValue(), QString("x")); @@ -1719,7 +1719,7 @@ void tst_QWebEngineView::inputFieldOverridesShortcuts() // A Ctrl-1 action is no default Qt key binding and should be triggerable. evaluateJavaScriptSync(view.page(), "document.getElementById('input1').focus();"); QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input1")); - action->setShortcut(Qt::CTRL + Qt::Key_1); + action->setShortcut(Qt::CTRL | Qt::Key_1); QTest::keyClick(view.windowHandle(), Qt::Key_1, Qt::ControlModifier); QTRY_VERIFY(actionTriggered); QCOMPARE(inputFieldValue(), QString("yxx")); @@ -3353,6 +3353,12 @@ void tst_QWebEngineView::switchPage() QWebEnginePage page2(&profile); QSignalSpy loadFinishedSpy1(&page1, SIGNAL(loadFinished(bool))); QSignalSpy loadFinishedSpy2(&page2, SIGNAL(loadFinished(bool))); + // TODO fixme: page without the view has no real widget behind, so + // reading graphical content will fail, add view for now. + QWebEngineView webView1; + QWebEngineView webView2; + webView1.setPage(&page1); + webView2.setPage(&page2); page1.setHtml("<html><body bgcolor=\"#000000\"></body></html>"); page2.setHtml("<html><body bgcolor=\"#ffffff\"></body></html>"); QTRY_VERIFY(loadFinishedSpy1.count() && loadFinishedSpy2.count()); @@ -3396,7 +3402,7 @@ void tst_QWebEngineView::setViewDeletesImplicitPage() QWebEngineView view; QPointer<QWebEnginePage> implicitPage = view.page(); QWebEnginePage explicitPage; - explicitPage.setView(&view); + view.setPage(&explicitPage); QCOMPARE(view.page(), &explicitPage); QVERIFY(!implicitPage); // should be deleted } @@ -3417,8 +3423,8 @@ void tst_QWebEngineView::setViewPreservesExplicitPage() QWebEngineView view; QPointer<QWebEnginePage> explicitPage1 = new QWebEnginePage(&view); QPointer<QWebEnginePage> explicitPage2 = new QWebEnginePage(&view); - explicitPage1->setView(&view); - explicitPage2->setView(&view); + view.setPage(explicitPage1.data()); + view.setPage(explicitPage2.data()); QCOMPARE(view.page(), explicitPage2.data()); QVERIFY(explicitPage1); // should not be deleted } |