diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-04-13 17:25:16 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-04-13 17:25:16 +0200 |
commit | 2dce0008ce53d27d281ad2dc00eb32d25ae5fc84 (patch) | |
tree | 55d97b68f56b78f3388cdaaa4ae69648b7057f68 /tests | |
parent | 919dd97e835f469609a0710eb91f829a6d70e88c (diff) | |
parent | 8fe660ecbbe1f126ce0da694adff956ad7159870 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: Ia01415e5a44b1df9ed8b3966ff3b39a414b1563c
Diffstat (limited to 'tests')
5 files changed, 71 insertions, 77 deletions
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp index a4c478991..1b4d06aac 100644 --- a/tests/auto/quick/publicapi/tst_publicapi.cpp +++ b/tests/auto/quick/publicapi/tst_publicapi.cpp @@ -680,7 +680,9 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineView.backgroundColor --> QColor" << "QQuickWebEngineView.backgroundColorChanged() --> void" << "QQuickWebEngineView.canGoBack --> bool" + << "QQuickWebEngineView.canGoBackChanged() --> void" << "QQuickWebEngineView.canGoForward --> bool" + << "QQuickWebEngineView.canGoForwardChanged() --> void" << "QQuickWebEngineView.certificateError(QWebEngineCertificateError) --> void" << "QQuickWebEngineView.colorDialogRequested(QQuickWebEngineColorDialogRequest*) --> void" << "QQuickWebEngineView.contentsSize --> QSizeF" diff --git a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml index 6ed232589..47be2f47d 100644 --- a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml +++ b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml @@ -26,7 +26,8 @@ ** ****************************************************************************/ -import QtQuick 2.0 +import QtQuick 2.15 +import QtQuick.Controls 2.15 import QtTest 1.0 import QtWebEngine 1.2 @@ -59,11 +60,25 @@ TestWebEngineView { } } + Button { + id: backButton + text: "Back" + enabled: webEngineView.canGoBack + onClicked: webEngineView.goBack() + } + + Button { + id: forwardButton + text: "Forward" + enabled: webEngineView.canGoForward + onClicked: webEngineView.goForward() + } + TestCase { name: "WebEngineViewNavigationHistory" function test_navigationHistory() { - compare(webEngineView.loadProgress, 0) + webEngineView.navigationHistory.clear() webEngineView.url = Qt.resolvedUrl("test1.html") verify(webEngineView.waitForLoadSucceeded()) @@ -142,5 +157,34 @@ TestWebEngineView { compare(backItemsList.count, 0) compare(forwardItemsList.count, 0) } + + function test_navigationButtons() { + webEngineView.navigationHistory.clear() + + webEngineView.url = Qt.resolvedUrl("test1.html") + verify(webEngineView.waitForLoadSucceeded()) + compare(backButton.enabled, false) + compare(forwardButton.enabled, false) + + webEngineView.url = Qt.resolvedUrl("test2.html") + verify(webEngineView.waitForLoadSucceeded()) + compare(backButton.enabled, true) + compare(forwardButton.enabled, false) + + webEngineView.url = Qt.resolvedUrl("test3.html") + verify(webEngineView.waitForLoadSucceeded()) + compare(backButton.enabled, true) + compare(forwardButton.enabled, false) + + backButton.clicked() + verify(webEngineView.waitForLoadSucceeded()) + compare(backButton.enabled, true) + compare(forwardButton.enabled, true) + + webEngineView.url = Qt.resolvedUrl("test1.html") + verify(webEngineView.waitForLoadSucceeded()) + compare(backButton.enabled, true) + compare(forwardButton.enabled, false) + } } } diff --git a/tests/auto/quick/qquickwebengineprofile/qquickwebengineprofile.pro b/tests/auto/quick/qquickwebengineprofile/qquickwebengineprofile.pro deleted file mode 100644 index e99c7f493..000000000 --- a/tests/auto/quick/qquickwebengineprofile/qquickwebengineprofile.pro +++ /dev/null @@ -1 +0,0 @@ -include(../tests.pri) diff --git a/tests/auto/quick/qquickwebengineprofile/tst_qquickwebengineprofile.cpp b/tests/auto/quick/qquickwebengineprofile/tst_qquickwebengineprofile.cpp deleted file mode 100644 index ea0469aef..000000000 --- a/tests/auto/quick/qquickwebengineprofile/tst_qquickwebengineprofile.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtQml/QQmlEngine> -#include <QtTest/QtTest> -#include <QtWebEngineQuick/QQuickWebEngineProfile> - -class tst_QQuickWebEngineProfile : public QObject { - Q_OBJECT -public: - tst_QQuickWebEngineProfile(); - - // TODO: Many tests missings - void usedForGlobalCertificateVerification(); - -private Q_SLOTS: - void init(); - void cleanup(); -}; - -tst_QQuickWebEngineProfile::tst_QQuickWebEngineProfile() -{ - QtWebEngine::initialize(); - QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true); -} - - -void tst_QQuickWebEngineProfile::init() -{ -} - -void tst_QQuickWebEngineProfile::cleanup() -{ -} - -void tst_QQuickWebEngineProfile::usedForGlobalCertificateVerification() -{ - QQuickWebEngineProfile *profile1 = new QQuickWebEngineProfile(); - QQuickWebEngineProfile *profile2 = new QQuickWebEngineProfile(); - QVERIFY(!profile1->isUsedForGlobalVerification()); - QVERIFY(!profile2->isUsedForGlobalVerification()); - - -} - - -QTEST_MAIN(tst_QQuickWebEngineProfile) -#include "tst_qquickwebengineprofile.moc" diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index fd17f401b..7af08dbde 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -42,6 +42,7 @@ #include <QQuickItem> #include <QQuickWidget> #include <QtWebEngineCore/qwebenginehttprequest.h> +#include <QScopeGuard> #include <QTcpServer> #include <QTcpSocket> #include <QStyle> @@ -161,6 +162,7 @@ private Q_SLOTS: void jsKeyboardEvent_data(); void jsKeyboardEvent(); void deletePage(); + void autoDeleteOnExternalPageDelete(); void closeOpenerTab(); void switchPage(); void setPageDeletesImplicitPage(); @@ -3137,7 +3139,7 @@ void tst_QWebEngineView::webUIURLs_data() QTest::newRow("media-engagement") << QUrl("chrome://media-engagement") << false; QTest::newRow("media-internals") << QUrl("chrome://media-internals") << true; QTest::newRow("net-export") << QUrl("chrome://net-export") << false; - QTest::newRow("net-internals") << QUrl("chrome://net-internals") << false; + QTest::newRow("net-internals") << QUrl("chrome://net-internals") << true; QTest::newRow("network-error") << QUrl("chrome://network-error") << false; QTest::newRow("network-errors") << QUrl("chrome://network-errors") << true; QTest::newRow("ntp-tiles-internals") << QUrl("chrome://ntp-tiles-internals") << false; @@ -3288,6 +3290,26 @@ void tst_QWebEngineView::deletePage() QTRY_VERIFY(spy.count()); } +void tst_QWebEngineView::autoDeleteOnExternalPageDelete() +{ + QPointer<QWebEngineView> view = new QWebEngineView; + QPointer<QWebEnginePage> page = new QWebEnginePage; + auto sg = qScopeGuard([&] () { delete view; delete page; }); + + QSignalSpy spy(page, &QWebEnginePage::loadFinished); + view->setPage(page); + view->show(); + view->resize(320, 240); + page->load(QUrl("about:blank")); + QTRY_VERIFY(spy.count()); + QVERIFY(page->parent() != view); + + auto sc = QObject::connect(page, &QWebEnginePage::destroyed, view, &QWebEngineView::deleteLater); + QTimer::singleShot(0, page, &QObject::deleteLater); + QTRY_VERIFY(!page); + QTRY_VERIFY(!view); +} + class TestView : public QWebEngineView { Q_OBJECT public: |