summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro5
-rw-r--r--tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp8
-rw-r--r--tests/auto/pdf/pdf.pro8
-rw-r--r--tests/auto/pdf/qpdfbookmarkmodel/pdf-sample.bookmarks.pdfbin0 -> 8925 bytes
-rw-r--r--tests/auto/pdf/qpdfbookmarkmodel/pdf-sample.bookmarks_pages.pdfbin0 -> 27523 bytes
-rw-r--r--tests/auto/pdf/qpdfbookmarkmodel/qpdfbookmarkmodel.pro5
-rw-r--r--tests/auto/pdf/qpdfbookmarkmodel/tst_qpdfbookmarkmodel.cpp287
-rw-r--r--tests/auto/pdf/qpdfdocument/BLACKLIST6
-rw-r--r--tests/auto/pdf/qpdfdocument/pdf-sample.metadata.pdfbin0 -> 9298 bytes
-rw-r--r--tests/auto/pdf/qpdfdocument/pdf-sample.protected.pdfbin0 -> 9138 bytes
-rw-r--r--tests/auto/pdf/qpdfdocument/qpdfdocument.pro6
-rw-r--r--tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp386
-rw-r--r--tests/auto/pdf/qpdfpagenavigation/pdf-sample.pagenavigation.pdfbin0 -> 27523 bytes
-rw-r--r--tests/auto/pdf/qpdfpagenavigation/qpdfpagenavigation.pro5
-rw-r--r--tests/auto/pdf/qpdfpagenavigation/tst_qpdfpagenavigation.cpp200
-rw-r--r--tests/auto/pdf/qpdfpagerenderer/pdf-sample.pagerenderer.pdfbin0 -> 27523 bytes
-rw-r--r--tests/auto/pdf/qpdfpagerenderer/qpdfpagerenderer.pro5
-rw-r--r--tests/auto/pdf/qpdfpagerenderer/tst_qpdfpagerenderer.cpp184
-rw-r--r--tests/auto/pdf/qpdfsearchmodel/qpdfsearchmodel.pro5
-rw-r--r--tests/auto/pdf/qpdfsearchmodel/test.pdfbin0 -> 80045 bytes
-rw-r--r--tests/auto/pdf/qpdfsearchmodel/tst_qpdfsearchmodel.cpp69
-rw-r--r--tests/auto/quick/publicapi/tst_publicapi.cpp3
-rw-r--r--tests/auto/quick/qmltests/data/test4.html200
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadUrl.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_navigationHistory.qml7
-rw-r--r--tests/auto/quick/qquickwebengineview/BLACKLIST3
-rw-r--r--tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp10
-rw-r--r--tests/auto/widgets/accessibility/tst_accessibility.cpp5
-rw-r--r--tests/auto/widgets/origins/tst_origins.cpp22
-rw-r--r--tests/auto/widgets/proxypac/proxypac.pro4
-rw-r--r--tests/auto/widgets/qwebenginepage/BLACKLIST6
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp84
-rw-r--r--tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp45
-rw-r--r--tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp105
-rw-r--r--tests/auto/widgets/schemes/tst_schemes.cpp76
-rw-r--r--tests/auto/widgets/spellchecking/tst_spellchecking.cpp8
-rw-r--r--tests/auto/widgets/util.h2
-rw-r--r--tests/manual/quick/pdf/listview.qml95
-rw-r--r--tests/manual/quick/pdf/pessimizedListView.qml174
-rw-r--r--tests/manual/quick/pdf/simplest.qml66
-rw-r--r--tests/manual/quick/pdf/test.pdfbin0 -> 80045 bytes
-rw-r--r--tests/manual/quick/pdf/withdoc.qml206
42 files changed, 2072 insertions, 230 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 59bcd5aef..9b71e1183 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -7,3 +7,8 @@ qtHaveModule(webengine) {
qtHaveModule(webenginewidgets) {
SUBDIRS += core widgets
}
+
+qtHaveModule(pdf) {
+ SUBDIRS += pdf
+}
+
diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp
index a7b44602f..5effb2abf 100644
--- a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp
+++ b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp
@@ -290,18 +290,21 @@ void tst_QWebEngineUrlRequestInterceptor::requestedUrl()
page.setUrl(QUrl("qrc:///resources/__placeholder__"));
QVERIFY(spy.wait());
QTRY_COMPARE(spy.count(), 1);
+ QVERIFY(interceptor.requestInfos.count() >= 1);
QCOMPARE(interceptor.requestInfos.at(0).requestUrl, QUrl("qrc:///resources/content.html"));
QCOMPARE(page.requestedUrl(), QUrl("qrc:///resources/__placeholder__"));
QCOMPARE(page.url(), QUrl("qrc:///resources/content.html"));
page.setUrl(QUrl("qrc:/non-existent.html"));
QTRY_COMPARE(spy.count(), 2);
+ QVERIFY(interceptor.requestInfos.count() >= 3);
QCOMPARE(interceptor.requestInfos.at(2).requestUrl, QUrl("qrc:/non-existent.html"));
QCOMPARE(page.requestedUrl(), QUrl("qrc:///resources/__placeholder__"));
QCOMPARE(page.url(), QUrl("qrc:///resources/content.html"));
page.setUrl(QUrl("http://abcdef.abcdef"));
QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 3, 15000);
+ QVERIFY(interceptor.requestInfos.count() >= 4);
QCOMPARE(interceptor.requestInfos.at(3).requestUrl, QUrl("http://abcdef.abcdef/"));
QCOMPARE(page.requestedUrl(), QUrl("qrc:///resources/__placeholder__"));
QCOMPARE(page.url(), QUrl("qrc:///resources/content.html"));
@@ -359,6 +362,7 @@ void tst_QWebEngineUrlRequestInterceptor::firstPartyUrl()
page.setUrl(QUrl("qrc:///resources/firstparty.html"));
QVERIFY(spy.wait());
+ QVERIFY(interceptor.requestInfos.count() >= 2);
QCOMPARE(interceptor.requestInfos.at(0).requestUrl, QUrl("qrc:///resources/firstparty.html"));
QCOMPARE(interceptor.requestInfos.at(1).requestUrl, QUrl("qrc:///resources/content.html"));
QCOMPARE(interceptor.requestInfos.at(0).firstPartyUrl, QUrl("qrc:///resources/firstparty.html"));
@@ -393,16 +397,19 @@ void tst_QWebEngineUrlRequestInterceptor::firstPartyUrlNestedIframes()
page.setUrl(requestUrl);
QTRY_COMPARE(loadSpy.count(), 1);
+ QVERIFY(interceptor.requestInfos.count() >= 1);
RequestInfo info = interceptor.requestInfos.at(0);
QCOMPARE(info.requestUrl, requestUrl);
QCOMPARE(info.firstPartyUrl, requestUrl);
QCOMPARE(info.resourceType, QWebEngineUrlRequestInfo::ResourceTypeMainFrame);
+ QVERIFY(interceptor.requestInfos.count() >= 2);
info = interceptor.requestInfos.at(1);
QCOMPARE(info.requestUrl, QUrl(adjustedUrl + "iframe2.html"));
QCOMPARE(info.firstPartyUrl, requestUrl);
QCOMPARE(info.resourceType, QWebEngineUrlRequestInfo::ResourceTypeSubFrame);
+ QVERIFY(interceptor.requestInfos.count() >= 3);
info = interceptor.requestInfos.at(2);
QCOMPARE(info.requestUrl, QUrl(adjustedUrl + "iframe3.html"));
QCOMPARE(info.firstPartyUrl, requestUrl);
@@ -456,6 +463,7 @@ void tst_QWebEngineUrlRequestInterceptor::requestInterceptorByResourceType()
QTRY_COMPARE(interceptor.getUrlRequestForType(static_cast<QWebEngineUrlRequestInfo::ResourceType>(resourceType)).count(), 1);
QList<RequestInfo> infos = interceptor.getUrlRequestForType(static_cast<QWebEngineUrlRequestInfo::ResourceType>(resourceType));
+ QVERIFY(infos.count() >= 1);
QCOMPARE(infos.at(0).requestUrl, requestUrl);
QCOMPARE(infos.at(0).firstPartyUrl, firstPartyUrl);
QCOMPARE(infos.at(0).resourceType, resourceType);
diff --git a/tests/auto/pdf/pdf.pro b/tests/auto/pdf/pdf.pro
new file mode 100644
index 000000000..a2b3fcff2
--- /dev/null
+++ b/tests/auto/pdf/pdf.pro
@@ -0,0 +1,8 @@
+TEMPLATE = subdirs
+
+SUBDIRS = \
+ qpdfbookmarkmodel \
+ qpdfpagenavigation \
+ qpdfpagerenderer
+
+qtHaveModule(printsupport): SUBDIRS += qpdfdocument
diff --git a/tests/auto/pdf/qpdfbookmarkmodel/pdf-sample.bookmarks.pdf b/tests/auto/pdf/qpdfbookmarkmodel/pdf-sample.bookmarks.pdf
new file mode 100644
index 000000000..bd27c18b6
--- /dev/null
+++ b/tests/auto/pdf/qpdfbookmarkmodel/pdf-sample.bookmarks.pdf
Binary files differ
diff --git a/tests/auto/pdf/qpdfbookmarkmodel/pdf-sample.bookmarks_pages.pdf b/tests/auto/pdf/qpdfbookmarkmodel/pdf-sample.bookmarks_pages.pdf
new file mode 100644
index 000000000..c4e1aa36e
--- /dev/null
+++ b/tests/auto/pdf/qpdfbookmarkmodel/pdf-sample.bookmarks_pages.pdf
Binary files differ
diff --git a/tests/auto/pdf/qpdfbookmarkmodel/qpdfbookmarkmodel.pro b/tests/auto/pdf/qpdfbookmarkmodel/qpdfbookmarkmodel.pro
new file mode 100644
index 000000000..11a010637
--- /dev/null
+++ b/tests/auto/pdf/qpdfbookmarkmodel/qpdfbookmarkmodel.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase
+TARGET = tst_qpdfbookmarkmodel
+QT += pdf testlib network
+macos:CONFIG -= app_bundle
+SOURCES += tst_qpdfbookmarkmodel.cpp
diff --git a/tests/auto/pdf/qpdfbookmarkmodel/tst_qpdfbookmarkmodel.cpp b/tests/auto/pdf/qpdfbookmarkmodel/tst_qpdfbookmarkmodel.cpp
new file mode 100644
index 000000000..fddc98011
--- /dev/null
+++ b/tests/auto/pdf/qpdfbookmarkmodel/tst_qpdfbookmarkmodel.cpp
@@ -0,0 +1,287 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <QPdfDocument>
+#include <QPdfBookmarkModel>
+
+class tst_QPdfBookmarkModel: public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QPdfBookmarkModel()
+ {
+ qRegisterMetaType<QPdfDocument::Status>();
+ }
+
+private slots:
+ void emptyModel();
+ void setEmptyDocument();
+ void setEmptyDocumentAndLoad();
+ void setLoadedDocument();
+ void unloadDocument();
+ void testTreeStructure();
+ void testListStructure();
+ void testPageNumberRole();
+};
+
+void tst_QPdfBookmarkModel::emptyModel()
+{
+ QPdfBookmarkModel model;
+
+ QVERIFY(!model.document());
+ QCOMPARE(model.structureMode(), QPdfBookmarkModel::TreeMode);
+ QCOMPARE(model.rowCount(), 0);
+ QCOMPARE(model.columnCount(), 1);
+ QCOMPARE(model.index(0, 0).isValid(), false);
+}
+
+void tst_QPdfBookmarkModel::setEmptyDocument()
+{
+ QPdfDocument document;
+ QPdfBookmarkModel model;
+
+ model.setDocument(&document);
+
+ QCOMPARE(model.document(), &document);
+ QCOMPARE(model.structureMode(), QPdfBookmarkModel::TreeMode);
+ QCOMPARE(model.rowCount(), 0);
+ QCOMPARE(model.columnCount(), 1);
+ QCOMPARE(model.index(0, 0).isValid(), false);
+}
+
+void tst_QPdfBookmarkModel::setEmptyDocumentAndLoad()
+{
+ QPdfDocument document;
+ QPdfBookmarkModel model;
+
+ model.setDocument(&document);
+
+ QSignalSpy modelAboutToBeResetSpy(&model, SIGNAL(modelAboutToBeReset()));
+ QSignalSpy modelResetSpy(&model, SIGNAL(modelReset()));
+
+ QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks.pdf")), QPdfDocument::NoError);
+
+ QCOMPARE(modelAboutToBeResetSpy.count(), 1);
+ QCOMPARE(modelResetSpy.count(), 1);
+
+ QCOMPARE(model.rowCount(), 3);
+}
+
+void tst_QPdfBookmarkModel::setLoadedDocument()
+{
+ QPdfDocument document;
+ QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks.pdf")), QPdfDocument::NoError);
+
+ QPdfBookmarkModel model;
+
+ QSignalSpy modelAboutToBeResetSpy(&model, SIGNAL(modelAboutToBeReset()));
+ QSignalSpy modelResetSpy(&model, SIGNAL(modelReset()));
+
+ model.setDocument(&document);
+
+ QCOMPARE(modelAboutToBeResetSpy.count(), 1);
+ QCOMPARE(modelResetSpy.count(), 1);
+
+ QCOMPARE(model.rowCount(), 3);
+}
+
+void tst_QPdfBookmarkModel::unloadDocument()
+{
+ QPdfDocument document;
+ QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks.pdf")), QPdfDocument::NoError);
+
+ QPdfBookmarkModel model;
+ model.setDocument(&document);
+
+ QCOMPARE(model.rowCount(), 3);
+
+ QSignalSpy modelAboutToBeResetSpy(&model, SIGNAL(modelAboutToBeReset()));
+ QSignalSpy modelResetSpy(&model, SIGNAL(modelReset()));
+
+ document.close();
+
+ QCOMPARE(modelAboutToBeResetSpy.count(), 1);
+ QCOMPARE(modelResetSpy.count(), 1);
+
+ QCOMPARE(model.rowCount(), 0);
+}
+
+void tst_QPdfBookmarkModel::testTreeStructure()
+{
+ QPdfDocument document;
+ QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks.pdf")), QPdfDocument::NoError);
+
+ QPdfBookmarkModel model;
+ model.setDocument(&document);
+
+ QCOMPARE(model.rowCount(), 3);
+
+ const QModelIndex index1 = model.index(0, 0);
+ QCOMPARE(index1.data(QPdfBookmarkModel::TitleRole).toString(), QLatin1String("Section 1"));
+ QCOMPARE(index1.data(QPdfBookmarkModel::LevelRole).toInt(), 0);
+ QCOMPARE(model.rowCount(index1), 2);
+
+ const QModelIndex index1_1 = model.index(0, 0, index1);
+ QCOMPARE(index1_1.data(QPdfBookmarkModel::TitleRole).toString(), QLatin1String("Section 1.1"));
+ QCOMPARE(index1_1.data(QPdfBookmarkModel::LevelRole).toInt(), 1);
+ QCOMPARE(model.rowCount(index1_1), 0);
+
+ const QModelIndex index1_2 = model.index(1, 0, index1);
+ QCOMPARE(index1_2.data(QPdfBookmarkModel::TitleRole).toString(), QLatin1String("Section 1.2"));
+ QCOMPARE(index1_2.data(QPdfBookmarkModel::LevelRole).toInt(), 1);
+ QCOMPARE(model.rowCount(index1_2), 0);
+
+ const QModelIndex index2 = model.index(1, 0);
+ QCOMPARE(index2.data(QPdfBookmarkModel::TitleRole).toString(), QLatin1String("Section 2"));
+ QCOMPARE(index2.data(QPdfBookmarkModel::LevelRole).toInt(), 0);
+ QCOMPARE(model.rowCount(index2), 2);
+
+ const QModelIndex index2_1 = model.index(0, 0, index2);
+ QCOMPARE(index2_1.data(QPdfBookmarkModel::TitleRole).toString(), QLatin1String("Section 2.1"));
+ QCOMPARE(index2_1.data(QPdfBookmarkModel::LevelRole).toInt(), 1);
+ QCOMPARE(model.rowCount(index2_1), 1);
+
+ const QModelIndex index2_1_1 = model.index(0, 0, index2_1);
+ QCOMPARE(index2_1_1.data(QPdfBookmarkModel::TitleRole).toString(), QLatin1String("Section 2.1.1"));
+ QCOMPARE(index2_1_1.data(QPdfBookmarkModel::LevelRole).toInt(), 2);
+ QCOMPARE(model.rowCount(index2_1_1), 0);
+
+ const QModelIndex index2_2 = model.index(1, 0, index2);
+ QCOMPARE(index2_2.data(QPdfBookmarkModel::TitleRole).toString(), QLatin1String("Section 2.2"));
+ QCOMPARE(index2_2.data(QPdfBookmarkModel::LevelRole).toInt(), 1);
+ QCOMPARE(model.rowCount(index2_2), 0);
+
+ const QModelIndex index3 = model.index(2, 0);
+ QCOMPARE(index3.data(QPdfBookmarkModel::TitleRole).toString(), QLatin1String("Section 3"));
+ QCOMPARE(index3.data(QPdfBookmarkModel::LevelRole).toInt(), 0);
+ QCOMPARE(model.rowCount(index3), 0);
+
+ const QModelIndex index4 = model.index(3, 0);
+ QCOMPARE(index4, QModelIndex());
+}
+
+void tst_QPdfBookmarkModel::testListStructure()
+{
+ QPdfDocument document;
+ QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks.pdf")), QPdfDocument::NoError);
+
+ QPdfBookmarkModel model;
+ model.setDocument(&document);
+
+ QSignalSpy modelAboutToBeResetSpy(&model, SIGNAL(modelAboutToBeReset()));
+ QSignalSpy modelResetSpy(&model, SIGNAL(modelReset()));
+
+ model.setStructureMode(QPdfBookmarkModel::ListMode);
+
+ QCOMPARE(modelAboutToBeResetSpy.count(), 1);
+ QCOMPARE(modelResetSpy.count(), 1);
+
+ QCOMPARE(model.rowCount(), 8);
+
+ const QModelIndex index1 = model.index(0, 0);
+ QCOMPARE(index1.data(QPdfBookmarkModel::TitleRole).toString(), QLatin1String("Section 1"));
+ QCOMPARE(index1.data(QPdfBookmarkModel::LevelRole).toInt(), 0);
+ QCOMPARE(model.rowCount(index1), 0);
+
+ const QModelIndex index1_1 = model.index(1, 0);
+ QCOMPARE(index1_1.data(QPdfBookmarkModel::TitleRole).toString(), QLatin1String("Section 1.1"));
+ QCOMPARE(index1_1.data(QPdfBookmarkModel::LevelRole).toInt(), 1);
+ QCOMPARE(model.rowCount(index1_1), 0);
+
+ const QModelIndex index1_2 = model.index(2, 0);
+ QCOMPARE(index1_2.data(QPdfBookmarkModel::TitleRole).toString(), QLatin1String("Section 1.2"));
+ QCOMPARE(index1_2.data(QPdfBookmarkModel::LevelRole).toInt(), 1);
+ QCOMPARE(model.rowCount(index1_2), 0);
+
+ const QModelIndex index2 = model.index(3, 0);
+ QCOMPARE(index2.data(QPdfBookmarkModel::TitleRole).toString(), QLatin1String("Section 2"));
+ QCOMPARE(index2.data(QPdfBookmarkModel::LevelRole).toInt(), 0);
+ QCOMPARE(model.rowCount(index2), 0);
+
+ const QModelIndex index2_1 = model.index(4, 0);
+ QCOMPARE(index2_1.data(QPdfBookmarkModel::TitleRole).toString(), QLatin1String("Section 2.1"));
+ QCOMPARE(index2_1.data(QPdfBookmarkModel::LevelRole).toInt(), 1);
+ QCOMPARE(model.rowCount(index2_1), 0);
+
+ const QModelIndex index2_1_1 = model.index(5, 0);
+ QCOMPARE(index2_1_1.data(QPdfBookmarkModel::TitleRole).toString(), QLatin1String("Section 2.1.1"));
+ QCOMPARE(index2_1_1.data(QPdfBookmarkModel::LevelRole).toInt(), 2);
+ QCOMPARE(model.rowCount(index2_1_1), 0);
+
+ const QModelIndex index2_2 = model.index(6, 0);
+ QCOMPARE(index2_2.data(QPdfBookmarkModel::TitleRole).toString(), QLatin1String("Section 2.2"));
+ QCOMPARE(index2_2.data(QPdfBookmarkModel::LevelRole).toInt(), 1);
+ QCOMPARE(model.rowCount(index2_2), 0);
+
+ const QModelIndex index3 = model.index(7, 0);
+ QCOMPARE(index3.data(QPdfBookmarkModel::TitleRole).toString(), QLatin1String("Section 3"));
+ QCOMPARE(index3.data(QPdfBookmarkModel::LevelRole).toInt(), 0);
+ QCOMPARE(model.rowCount(index3), 0);
+
+ const QModelIndex index4 = model.index(8, 0);
+ QCOMPARE(index4, QModelIndex());
+}
+
+void tst_QPdfBookmarkModel::testPageNumberRole()
+{
+ QPdfDocument document;
+ QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks_pages.pdf")), QPdfDocument::NoError);
+
+ QPdfBookmarkModel model;
+ model.setDocument(&document);
+
+ QCOMPARE(model.rowCount(), 3);
+
+ const QModelIndex index1 = model.index(0, 0);
+ QCOMPARE(index1.data(QPdfBookmarkModel::PageNumberRole).toInt(), 0);
+
+ const QModelIndex index2 = model.index(1, 0);
+ QCOMPARE(index2.data(QPdfBookmarkModel::PageNumberRole).toInt(), 1);
+
+ const QModelIndex index2_1 = model.index(0, 0, index2);
+ QCOMPARE(index2_1.data(QPdfBookmarkModel::PageNumberRole).toInt(), 1);
+
+ const QModelIndex index3 = model.index(2, 0);
+ QCOMPARE(index3.data(QPdfBookmarkModel::PageNumberRole).toInt(), 2);
+}
+
+QTEST_MAIN(tst_QPdfBookmarkModel)
+
+#include "tst_qpdfbookmarkmodel.moc"
diff --git a/tests/auto/pdf/qpdfdocument/BLACKLIST b/tests/auto/pdf/qpdfdocument/BLACKLIST
new file mode 100644
index 000000000..b8db556d6
--- /dev/null
+++ b/tests/auto/pdf/qpdfdocument/BLACKLIST
@@ -0,0 +1,6 @@
+[password]
+*
+
+[passwordClearedOnClose]
+*
+
diff --git a/tests/auto/pdf/qpdfdocument/pdf-sample.metadata.pdf b/tests/auto/pdf/qpdfdocument/pdf-sample.metadata.pdf
new file mode 100644
index 000000000..c3350ba5f
--- /dev/null
+++ b/tests/auto/pdf/qpdfdocument/pdf-sample.metadata.pdf
Binary files differ
diff --git a/tests/auto/pdf/qpdfdocument/pdf-sample.protected.pdf b/tests/auto/pdf/qpdfdocument/pdf-sample.protected.pdf
new file mode 100644
index 000000000..d76fdd1a6
--- /dev/null
+++ b/tests/auto/pdf/qpdfdocument/pdf-sample.protected.pdf
Binary files differ
diff --git a/tests/auto/pdf/qpdfdocument/qpdfdocument.pro b/tests/auto/pdf/qpdfdocument/qpdfdocument.pro
new file mode 100644
index 000000000..8382a25e3
--- /dev/null
+++ b/tests/auto/pdf/qpdfdocument/qpdfdocument.pro
@@ -0,0 +1,6 @@
+CONFIG += testcase
+TARGET = tst_qpdfdocument
+QT += pdf printsupport testlib network
+macx:CONFIG -= app_bundle
+SOURCES += tst_qpdfdocument.cpp
+
diff --git a/tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp b/tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp
new file mode 100644
index 000000000..29b85fc89
--- /dev/null
+++ b/tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp
@@ -0,0 +1,386 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <QPainter>
+#include <QPdfDocument>
+#include <QPrinter>
+#include <QTemporaryFile>
+#include <QNetworkAccessManager>
+#include <QNetworkRequest>
+#include <QNetworkReply>
+
+class tst_QPdfDocument: public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QPdfDocument()
+ {
+ qRegisterMetaType<QPdfDocument::Status>();
+ }
+
+private slots:
+ void pageCount();
+ void loadFromIODevice();
+ void loadAsync();
+ void password();
+ void close();
+ void loadAfterClose();
+ void closeOnDestroy();
+ void status();
+ void passwordClearedOnClose();
+ void metaData();
+};
+
+struct TemporaryPdf: public QTemporaryFile
+{
+ TemporaryPdf();
+ QPageLayout pageLayout;
+};
+
+
+TemporaryPdf::TemporaryPdf()
+{
+ open();
+ pageLayout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF());
+
+ {
+ QPrinter printer;
+ printer.setOutputFormat(QPrinter::PdfFormat);
+ printer.setOutputFileName(fileName());
+ printer.setPageLayout(pageLayout);
+
+ {
+ QPainter painter(&printer);
+ painter.drawText(100, 100, QStringLiteral("Hello Page 1"));
+ printer.newPage();
+ painter.drawText(100, 100, QStringLiteral("Hello Page 2"));
+ }
+ }
+
+ seek(0);
+}
+
+void tst_QPdfDocument::pageCount()
+{
+ TemporaryPdf tempPdf;
+
+ QPdfDocument doc;
+ QSignalSpy pageCountChangedSpy(&doc, SIGNAL(pageCountChanged(int)));
+
+ QCOMPARE(doc.pageCount(), 0);
+ QCOMPARE(doc.load(tempPdf.fileName()), QPdfDocument::NoError);
+ QCOMPARE(doc.pageCount(), 2);
+ QCOMPARE(pageCountChangedSpy.count(), 1);
+ QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount());
+
+ QCOMPARE(doc.pageSize(0).toSize(), tempPdf.pageLayout.fullRectPoints().size());
+}
+
+void tst_QPdfDocument::loadFromIODevice()
+{
+ TemporaryPdf tempPdf;
+ QPdfDocument doc;
+ QSignalSpy statusChangedSpy(&doc, SIGNAL(statusChanged(QPdfDocument::Status)));
+ QSignalSpy pageCountChangedSpy(&doc, SIGNAL(pageCountChanged(int)));
+ doc.load(&tempPdf);
+ QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Loading);
+ QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Ready);
+ QCOMPARE(doc.error(), QPdfDocument::NoError);
+ QCOMPARE(doc.pageCount(), 2);
+ QCOMPARE(pageCountChangedSpy.count(), 1);
+ QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount());
+}
+
+void tst_QPdfDocument::loadAsync()
+{
+ TemporaryPdf tempPdf;
+
+ QNetworkAccessManager nam;
+
+ QUrl url = QUrl::fromLocalFile(tempPdf.fileName());
+ QScopedPointer<QNetworkReply> reply(nam.get(QNetworkRequest(url)));
+
+ QPdfDocument doc;
+ QSignalSpy statusChangedSpy(&doc, SIGNAL(statusChanged(QPdfDocument::Status)));
+ QSignalSpy pageCountChangedSpy(&doc, SIGNAL(pageCountChanged(int)));
+
+ doc.load(reply.data());
+
+ QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Loading);
+ QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Ready);
+ QCOMPARE(doc.pageCount(), 2);
+ QCOMPARE(pageCountChangedSpy.count(), 1);
+ QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount());
+}
+
+void tst_QPdfDocument::password()
+{
+ QPdfDocument doc;
+ QSignalSpy passwordChangedSpy(&doc, SIGNAL(passwordChanged()));
+
+ QCOMPARE(doc.pageCount(), 0);
+ QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.protected.pdf")), QPdfDocument::IncorrectPasswordError);
+ QCOMPARE(passwordChangedSpy.count(), 0);
+ doc.setPassword(QStringLiteral("WrongPassword"));
+ QCOMPARE(passwordChangedSpy.count(), 1);
+ QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.protected.pdf")), QPdfDocument::IncorrectPasswordError);
+ QCOMPARE(doc.status(), QPdfDocument::Error);
+ doc.setPassword(QStringLiteral("Qt"));
+ QCOMPARE(passwordChangedSpy.count(), 2);
+ QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.protected.pdf")), QPdfDocument::NoError);
+ QCOMPARE(doc.pageCount(), 1);
+}
+
+void tst_QPdfDocument::close()
+{
+ TemporaryPdf tempPdf;
+ QPdfDocument doc;
+
+ QSignalSpy statusChangedSpy(&doc, SIGNAL(statusChanged(QPdfDocument::Status)));
+ QSignalSpy pageCountChangedSpy(&doc, SIGNAL(pageCountChanged(int)));
+
+ doc.load(&tempPdf);
+
+ QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Loading);
+ QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Ready);
+ QCOMPARE(pageCountChangedSpy.count(), 1);
+ QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount());
+
+ statusChangedSpy.clear();
+ pageCountChangedSpy.clear();
+
+ doc.close();
+ QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Unloading);
+ QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Null);
+ QCOMPARE(doc.pageCount(), 0);
+ QCOMPARE(pageCountChangedSpy.count(), 1);
+ QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount());
+}
+
+void tst_QPdfDocument::loadAfterClose()
+{
+ TemporaryPdf tempPdf;
+ QPdfDocument doc;
+
+ QSignalSpy statusChangedSpy(&doc, SIGNAL(statusChanged(QPdfDocument::Status)));
+ QSignalSpy pageCountChangedSpy(&doc, SIGNAL(pageCountChanged(int)));
+
+ doc.load(&tempPdf);
+ QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Loading);
+ QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Ready);
+ QCOMPARE(pageCountChangedSpy.count(), 1);
+ QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount());
+ statusChangedSpy.clear();
+ pageCountChangedSpy.clear();
+
+ doc.close();
+ QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Unloading);
+ QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Null);
+ QCOMPARE(pageCountChangedSpy.count(), 1);
+ QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount());
+ statusChangedSpy.clear();
+ pageCountChangedSpy.clear();
+
+ doc.load(&tempPdf);
+ QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Loading);
+ QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Ready);
+ QCOMPARE(doc.error(), QPdfDocument::NoError);
+ QCOMPARE(doc.pageCount(), 2);
+ QCOMPARE(pageCountChangedSpy.count(), 1);
+ QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount());
+}
+
+void tst_QPdfDocument::closeOnDestroy()
+{
+ TemporaryPdf tempPdf;
+
+ // deleting an open document should automatically close it
+ {
+ QPdfDocument *doc = new QPdfDocument;
+
+ doc->load(&tempPdf);
+
+ QSignalSpy statusChangedSpy(doc, SIGNAL(statusChanged(QPdfDocument::Status)));
+ QSignalSpy pageCountChangedSpy(doc, SIGNAL(pageCountChanged(int)));
+
+ delete doc;
+
+ QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Unloading);
+ QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Null);
+ QCOMPARE(pageCountChangedSpy.count(), 1);
+ QCOMPARE(pageCountChangedSpy[0][0].toInt(), 0);
+ }
+
+ // deleting a closed document should not emit any signal
+ {
+ QPdfDocument *doc = new QPdfDocument;
+ doc->load(&tempPdf);
+ doc->close();
+
+ QSignalSpy statusChangedSpy(doc, SIGNAL(statusChanged(QPdfDocument::Status)));
+ QSignalSpy pageCountChangedSpy(doc, SIGNAL(pageCountChanged(int)));
+
+ delete doc;
+
+ QCOMPARE(statusChangedSpy.count(), 0);
+ QCOMPARE(pageCountChangedSpy.count(), 0);
+ }
+}
+
+void tst_QPdfDocument::status()
+{
+ TemporaryPdf tempPdf;
+
+ QPdfDocument doc;
+ QCOMPARE(doc.status(), QPdfDocument::Null);
+
+ QSignalSpy statusChangedSpy(&doc, SIGNAL(statusChanged(QPdfDocument::Status)));
+
+ // open existing document
+ doc.load(&tempPdf);
+ QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Loading);
+ QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Ready);
+ statusChangedSpy.clear();
+
+ QCOMPARE(doc.status(), QPdfDocument::Ready);
+
+ // close document
+ doc.close();
+
+ QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Unloading);
+ QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Null);
+ statusChangedSpy.clear();
+
+ QCOMPARE(doc.status(), QPdfDocument::Null);
+
+ // try to open non-existing document
+ doc.load(QFINDTESTDATA("does-not-exist.pdf"));
+ QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Loading);
+ QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Error);
+ QCOMPARE(doc.status(), QPdfDocument::Error);
+ statusChangedSpy.clear();
+
+ // try to open non-existing document asynchronously
+ QNetworkAccessManager accessManager;
+
+ const QUrl url("http://doesnotexist.qt.io");
+ QScopedPointer<QNetworkReply> reply(accessManager.get(QNetworkRequest(url)));
+
+ doc.load(reply.data());
+
+ QElapsedTimer stopWatch;
+ stopWatch.start();
+ forever {
+ QCoreApplication::instance()->processEvents();
+ if (statusChangedSpy.count() == 2)
+ break;
+ if (stopWatch.elapsed() >= 30000)
+ break;
+ }
+
+ QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Loading);
+ QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Error);
+ statusChangedSpy.clear();
+}
+
+void tst_QPdfDocument::passwordClearedOnClose()
+{
+ TemporaryPdf tempPdf;
+ QPdfDocument doc;
+
+ QSignalSpy passwordChangedSpy(&doc, SIGNAL(passwordChanged()));
+
+ doc.setPassword(QStringLiteral("Qt"));
+ QCOMPARE(passwordChangedSpy.count(), 1);
+ QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.protected.pdf")), QPdfDocument::NoError);
+ passwordChangedSpy.clear();
+
+ doc.close(); // password is cleared on close
+ QCOMPARE(passwordChangedSpy.count(), 1);
+ passwordChangedSpy.clear();
+
+ doc.load(&tempPdf);
+ doc.close(); // signal is not emitted if password didn't change
+ QCOMPARE(passwordChangedSpy.count(), 0);
+}
+
+void tst_QPdfDocument::metaData()
+{
+ QPdfDocument doc;
+
+ // a closed document does not return any meta data
+ QCOMPARE(doc.metaData(QPdfDocument::Title).toString(), QString());
+ QCOMPARE(doc.metaData(QPdfDocument::Subject).toString(), QString());
+ QCOMPARE(doc.metaData(QPdfDocument::Author).toString(), QString());
+ QCOMPARE(doc.metaData(QPdfDocument::Keywords).toString(), QString());
+ QCOMPARE(doc.metaData(QPdfDocument::Producer).toString(), QString());
+ QCOMPARE(doc.metaData(QPdfDocument::Creator).toString(), QString());
+ QCOMPARE(doc.metaData(QPdfDocument::CreationDate).toDateTime(), QDateTime());
+ QCOMPARE(doc.metaData(QPdfDocument::ModificationDate).toDateTime(), QDateTime());
+
+ QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.metadata.pdf")), QPdfDocument::NoError);
+
+ // check for proper meta data from sample document
+ QCOMPARE(doc.metaData(QPdfDocument::Title).toString(), QString::fromLatin1("Qt PDF Unit Test Document"));
+ QCOMPARE(doc.metaData(QPdfDocument::Subject).toString(), QString::fromLatin1("A test for meta data access"));
+ QCOMPARE(doc.metaData(QPdfDocument::Author).toString(), QString::fromLatin1("John Doe"));
+ QCOMPARE(doc.metaData(QPdfDocument::Keywords).toString(), QString::fromLatin1("meta data keywords"));
+ QCOMPARE(doc.metaData(QPdfDocument::Producer).toString(), QString::fromLatin1("LibreOffice 5.1"));
+ QCOMPARE(doc.metaData(QPdfDocument::Creator).toString(), QString::fromLatin1("Writer"));
+ QCOMPARE(doc.metaData(QPdfDocument::CreationDate).toDateTime(), QDateTime(QDate(2016, 8, 7), QTime(7, 3, 6), Qt::UTC));
+ QCOMPARE(doc.metaData(QPdfDocument::ModificationDate).toDateTime(), QDateTime(QDate(2016, 8, 8), QTime(8, 3, 6), Qt::UTC));
+}
+
+QTEST_MAIN(tst_QPdfDocument)
+
+#include "tst_qpdfdocument.moc"
+
diff --git a/tests/auto/pdf/qpdfpagenavigation/pdf-sample.pagenavigation.pdf b/tests/auto/pdf/qpdfpagenavigation/pdf-sample.pagenavigation.pdf
new file mode 100644
index 000000000..c4e1aa36e
--- /dev/null
+++ b/tests/auto/pdf/qpdfpagenavigation/pdf-sample.pagenavigation.pdf
Binary files differ
diff --git a/tests/auto/pdf/qpdfpagenavigation/qpdfpagenavigation.pro b/tests/auto/pdf/qpdfpagenavigation/qpdfpagenavigation.pro
new file mode 100644
index 000000000..8de99543f
--- /dev/null
+++ b/tests/auto/pdf/qpdfpagenavigation/qpdfpagenavigation.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase
+TARGET = tst_qpdfpagenavigation
+QT += pdf testlib network
+macos:CONFIG -= app_bundle
+SOURCES += tst_qpdfpagenavigation.cpp
diff --git a/tests/auto/pdf/qpdfpagenavigation/tst_qpdfpagenavigation.cpp b/tests/auto/pdf/qpdfpagenavigation/tst_qpdfpagenavigation.cpp
new file mode 100644
index 000000000..ff6a02750
--- /dev/null
+++ b/tests/auto/pdf/qpdfpagenavigation/tst_qpdfpagenavigation.cpp
@@ -0,0 +1,200 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <QPdfDocument>
+#include <QPdfPageNavigation>
+
+class tst_QPdfPageNavigation: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void defaultValues();
+ void setEmptyDocument();
+ void setEmptyDocumentAndLoad();
+ void setLoadedDocument();
+ void unloadDocument();
+ void navigate();
+};
+
+void tst_QPdfPageNavigation::defaultValues()
+{
+ QPdfPageNavigation pageNavigation;
+
+ QCOMPARE(pageNavigation.document(), nullptr);
+ QCOMPARE(pageNavigation.currentPage(), 0);
+ QCOMPARE(pageNavigation.pageCount(), 0);
+ QCOMPARE(pageNavigation.canGoToPreviousPage(), false);
+ QCOMPARE(pageNavigation.canGoToNextPage(), false);
+}
+
+void tst_QPdfPageNavigation::setEmptyDocument()
+{
+ QPdfDocument document;
+ QPdfPageNavigation pageNavigation;
+
+ pageNavigation.setDocument(&document);
+
+ QCOMPARE(pageNavigation.document(), &document);
+ QCOMPARE(pageNavigation.currentPage(), 0);
+ QCOMPARE(pageNavigation.pageCount(), 0);
+ QCOMPARE(pageNavigation.canGoToPreviousPage(), false);
+ QCOMPARE(pageNavigation.canGoToNextPage(), false);
+}
+
+void tst_QPdfPageNavigation::setEmptyDocumentAndLoad()
+{
+ QPdfDocument document;
+ QPdfPageNavigation pageNavigation;
+
+ pageNavigation.setDocument(&document);
+
+ QSignalSpy currentPageChangedSpy(&pageNavigation, &QPdfPageNavigation::currentPageChanged);
+ QSignalSpy pageCountChangedSpy(&pageNavigation, &QPdfPageNavigation::pageCountChanged);
+ QSignalSpy canGoToPreviousPageChangedSpy(&pageNavigation, &QPdfPageNavigation::canGoToPreviousPageChanged);
+ QSignalSpy canGoToNextPageChangedSpy(&pageNavigation, &QPdfPageNavigation::canGoToNextPageChanged);
+
+ QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.pagenavigation.pdf")), QPdfDocument::NoError);
+
+ QCOMPARE(currentPageChangedSpy.count(), 0); // current page stays '0'
+ QCOMPARE(pageCountChangedSpy.count(), 1);
+ QCOMPARE(pageCountChangedSpy[0][0].toInt(), 3);
+ QCOMPARE(canGoToPreviousPageChangedSpy.count(), 0); // still no previous page available
+ QCOMPARE(canGoToNextPageChangedSpy.count(), 1);
+ QCOMPARE(canGoToNextPageChangedSpy[0][0].toBool(), true);
+}
+
+void tst_QPdfPageNavigation::setLoadedDocument()
+{
+ QPdfDocument document;
+ QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.pagenavigation.pdf")), QPdfDocument::NoError);
+
+ QPdfPageNavigation pageNavigation;
+
+ QSignalSpy currentPageChangedSpy(&pageNavigation, &QPdfPageNavigation::currentPageChanged);
+ QSignalSpy pageCountChangedSpy(&pageNavigation, &QPdfPageNavigation::pageCountChanged);
+ QSignalSpy canGoToPreviousPageChangedSpy(&pageNavigation, &QPdfPageNavigation::canGoToPreviousPageChanged);
+ QSignalSpy canGoToNextPageChangedSpy(&pageNavigation, &QPdfPageNavigation::canGoToNextPageChanged);
+
+ pageNavigation.setDocument(&document);
+
+ QCOMPARE(currentPageChangedSpy.count(), 0); // current page stays '0'
+ QCOMPARE(pageCountChangedSpy.count(), 1);
+ QCOMPARE(pageCountChangedSpy[0][0].toInt(), 3);
+ QCOMPARE(canGoToPreviousPageChangedSpy.count(), 0); // still no previous page available
+ QCOMPARE(canGoToNextPageChangedSpy.count(), 1);
+ QCOMPARE(canGoToNextPageChangedSpy[0][0].toBool(), true);
+}
+
+void tst_QPdfPageNavigation::unloadDocument()
+{
+ QPdfDocument document;
+ QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.pagenavigation.pdf")), QPdfDocument::NoError);
+
+ QPdfPageNavigation pageNavigation;
+ pageNavigation.setDocument(&document);
+
+ QSignalSpy currentPageChangedSpy(&pageNavigation, &QPdfPageNavigation::currentPageChanged);
+ QSignalSpy pageCountChangedSpy(&pageNavigation, &QPdfPageNavigation::pageCountChanged);
+ QSignalSpy canGoToPreviousPageChangedSpy(&pageNavigation, &QPdfPageNavigation::canGoToPreviousPageChanged);
+ QSignalSpy canGoToNextPageChangedSpy(&pageNavigation, &QPdfPageNavigation::canGoToNextPageChanged);
+
+ document.close();
+
+ QCOMPARE(currentPageChangedSpy.count(), 0); // current page stays '0'
+ QCOMPARE(pageCountChangedSpy.count(), 1);
+ QCOMPARE(pageCountChangedSpy[0][0].toInt(), 0);
+ QCOMPARE(canGoToPreviousPageChangedSpy.count(), 0); // still no previous page available
+ QCOMPARE(canGoToNextPageChangedSpy.count(), 1);
+ QCOMPARE(canGoToNextPageChangedSpy[0][0].toBool(), false);
+}
+
+void tst_QPdfPageNavigation::navigate()
+{
+ QPdfDocument document;
+ QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.pagenavigation.pdf")), QPdfDocument::NoError);
+
+ QPdfPageNavigation pageNavigation;
+ pageNavigation.setDocument(&document);
+
+ QSignalSpy currentPageChangedSpy(&pageNavigation, &QPdfPageNavigation::currentPageChanged);
+ QSignalSpy canGoToPreviousPageChangedSpy(&pageNavigation, &QPdfPageNavigation::canGoToPreviousPageChanged);
+ QSignalSpy canGoToNextPageChangedSpy(&pageNavigation, &QPdfPageNavigation::canGoToNextPageChanged);
+
+ QCOMPARE(pageNavigation.currentPage(), 0);
+
+ // try to go to previous page while there is none
+ QCOMPARE(pageNavigation.canGoToPreviousPage(), false);
+ pageNavigation.goToPreviousPage();
+ QCOMPARE(canGoToPreviousPageChangedSpy.count(), 0);
+ QCOMPARE(pageNavigation.currentPage(), 0);
+ QCOMPARE(pageNavigation.canGoToPreviousPage(), false);
+
+ // try to go to next page
+ QCOMPARE(pageNavigation.canGoToNextPage(), true);
+ pageNavigation.goToNextPage();
+ QCOMPARE(canGoToPreviousPageChangedSpy.count(), 1);
+ QCOMPARE(canGoToNextPageChangedSpy.count(), 0);
+ QCOMPARE(currentPageChangedSpy.count(), 1);
+ QCOMPARE(pageNavigation.currentPage(), 1);
+ QCOMPARE(pageNavigation.canGoToPreviousPage(), true);
+
+ currentPageChangedSpy.clear();
+ canGoToPreviousPageChangedSpy.clear();
+ canGoToNextPageChangedSpy.clear();
+
+ // try to go to last page
+ pageNavigation.setCurrentPage(2);
+ QCOMPARE(canGoToPreviousPageChangedSpy.count(), 0);
+ QCOMPARE(canGoToNextPageChangedSpy.count(), 1);
+ QCOMPARE(currentPageChangedSpy.count(), 1);
+ QCOMPARE(pageNavigation.currentPage(), 2);
+ QCOMPARE(pageNavigation.canGoToNextPage(), false);
+
+ // check that invalid requests are ignored
+ pageNavigation.setCurrentPage(-1);
+ QCOMPARE(pageNavigation.currentPage(), 2);
+
+ pageNavigation.setCurrentPage(3);
+ QCOMPARE(pageNavigation.currentPage(), 2);
+}
+
+QTEST_MAIN(tst_QPdfPageNavigation)
+
+#include "tst_qpdfpagenavigation.moc"
diff --git a/tests/auto/pdf/qpdfpagerenderer/pdf-sample.pagerenderer.pdf b/tests/auto/pdf/qpdfpagerenderer/pdf-sample.pagerenderer.pdf
new file mode 100644
index 000000000..c4e1aa36e
--- /dev/null
+++ b/tests/auto/pdf/qpdfpagerenderer/pdf-sample.pagerenderer.pdf
Binary files differ
diff --git a/tests/auto/pdf/qpdfpagerenderer/qpdfpagerenderer.pro b/tests/auto/pdf/qpdfpagerenderer/qpdfpagerenderer.pro
new file mode 100644
index 000000000..9ccb4e82c
--- /dev/null
+++ b/tests/auto/pdf/qpdfpagerenderer/qpdfpagerenderer.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase
+TARGET = tst_qpdfpagerenderer
+QT += pdf testlib network
+macos:CONFIG -= app_bundle
+SOURCES += tst_qpdfpagerenderer.cpp
diff --git a/tests/auto/pdf/qpdfpagerenderer/tst_qpdfpagerenderer.cpp b/tests/auto/pdf/qpdfpagerenderer/tst_qpdfpagerenderer.cpp
new file mode 100644
index 000000000..8eaef7c6e
--- /dev/null
+++ b/tests/auto/pdf/qpdfpagerenderer/tst_qpdfpagerenderer.cpp
@@ -0,0 +1,184 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias König <tobias.koenig@kdab.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtPDF module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QPdfDocument>
+#include <QPdfPageRenderer>
+
+#include <QtTest/QtTest>
+
+class tst_QPdfPageRenderer: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void defaultValues();
+ void withNoDocument();
+ void withEmptyDocument();
+ void withLoadedDocumentSingleThreaded();
+ void withLoadedDocumentMultiThreaded();
+ void switchingRenderMode();
+};
+
+void tst_QPdfPageRenderer::defaultValues()
+{
+ QPdfPageRenderer pageRenderer;
+
+ QCOMPARE(pageRenderer.document(), nullptr);
+ QCOMPARE(pageRenderer.renderMode(), QPdfPageRenderer::SingleThreadedRenderMode);
+}
+
+void tst_QPdfPageRenderer::withNoDocument()
+{
+ QPdfPageRenderer pageRenderer;
+
+ const QSize imageSize(100, 100);
+ const quint64 requestId = pageRenderer.requestPage(0, imageSize);
+
+ QCOMPARE(requestId, quint64(0));
+}
+
+void tst_QPdfPageRenderer::withEmptyDocument()
+{
+ QPdfDocument document;
+ QPdfPageRenderer pageRenderer;
+
+ pageRenderer.setDocument(&document);
+
+ const QSize imageSize(100, 100);
+ const quint64 requestId = pageRenderer.requestPage(0, imageSize);
+
+ QCOMPARE(requestId, quint64(0));
+}
+
+void tst_QPdfPageRenderer::withLoadedDocumentSingleThreaded()
+{
+ QPdfDocument document;
+ QPdfPageRenderer pageRenderer;
+ pageRenderer.setDocument(&document);
+
+ QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.pagerenderer.pdf")), QPdfDocument::NoError);
+
+ QSignalSpy pageRenderedSpy(&pageRenderer, &QPdfPageRenderer::pageRendered);
+
+ const QSize imageSize(100, 100);
+ const quint64 requestId = pageRenderer.requestPage(0, imageSize);
+
+ QCOMPARE(requestId, quint64(1));
+ QTRY_COMPARE(pageRenderedSpy.count(), 1);
+ QCOMPARE(pageRenderedSpy[0][0].toInt(), 0);
+ QCOMPARE(pageRenderedSpy[0][1].toSize(), imageSize);
+ QCOMPARE(pageRenderedSpy[0][2].value<QImage>().size(), imageSize);
+ QCOMPARE(pageRenderedSpy[0][4].toULongLong(), requestId);
+}
+
+void tst_QPdfPageRenderer::withLoadedDocumentMultiThreaded()
+{
+ QPdfDocument document;
+
+ QPdfPageRenderer pageRenderer;
+ pageRenderer.setDocument(&document);
+ pageRenderer.setRenderMode(QPdfPageRenderer::MultiThreadedRenderMode);
+
+ QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.pagerenderer.pdf")), QPdfDocument::NoError);
+
+ QSignalSpy pageRenderedSpy(&pageRenderer, &QPdfPageRenderer::pageRendered);
+
+ const QSize imageSize(100, 100);
+ const quint64 requestId = pageRenderer.requestPage(0, imageSize);
+
+ QCOMPARE(requestId, quint64(1));
+ QTRY_COMPARE(pageRenderedSpy.count(), 1);
+ QCOMPARE(pageRenderedSpy[0][0].toInt(), 0);
+ QCOMPARE(pageRenderedSpy[0][1].toSize(), imageSize);
+ QCOMPARE(pageRenderedSpy[0][2].value<QImage>().size(), imageSize);
+ QCOMPARE(pageRenderedSpy[0][4].toULongLong(), requestId);
+}
+
+void tst_QPdfPageRenderer::switchingRenderMode()
+{
+ QPdfDocument document;
+ QPdfPageRenderer pageRenderer;
+ pageRenderer.setDocument(&document);
+
+ QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.pagerenderer.pdf")), QPdfDocument::NoError);
+
+ QSignalSpy pageRenderedSpy(&pageRenderer, &QPdfPageRenderer::pageRendered);
+
+ // render single threaded
+ const QSize imageSize(100, 100);
+ const quint64 firstRequestId = pageRenderer.requestPage(0, imageSize);
+
+ QTRY_COMPARE(pageRenderedSpy.count(), 1);
+ QCOMPARE(pageRenderedSpy[0][0].toInt(), 0);
+ QCOMPARE(pageRenderedSpy[0][1].toSize(), imageSize);
+ QCOMPARE(pageRenderedSpy[0][2].value<QImage>().size(), imageSize);
+ QCOMPARE(pageRenderedSpy[0][4].toULongLong(), firstRequestId);
+
+ const QImage image = pageRenderedSpy[0][2].value<QImage>();
+
+ pageRenderedSpy.clear();
+
+ // switch to multi threaded
+ pageRenderer.setRenderMode(QPdfPageRenderer::MultiThreadedRenderMode);
+
+ const quint64 secondRequestId = pageRenderer.requestPage(0, imageSize);
+
+ QVERIFY(firstRequestId != secondRequestId);
+ QTRY_COMPARE(pageRenderedSpy.count(), 1);
+ QCOMPARE(pageRenderedSpy[0][0].toInt(), 0);
+ QCOMPARE(pageRenderedSpy[0][1].toSize(), imageSize);
+ QCOMPARE(pageRenderedSpy[0][2].value<QImage>(), image);
+ QCOMPARE(pageRenderedSpy[0][2].value<QImage>().size(), imageSize);
+ QCOMPARE(pageRenderedSpy[0][4].toULongLong(), secondRequestId);
+
+ pageRenderedSpy.clear();
+
+ // switch back to single threaded
+ pageRenderer.setRenderMode(QPdfPageRenderer::SingleThreadedRenderMode);
+
+ const quint64 thirdRequestId = pageRenderer.requestPage(0, imageSize);
+
+ QTRY_COMPARE(pageRenderedSpy.count(), 1);
+ QCOMPARE(pageRenderedSpy[0][0].toInt(), 0);
+ QCOMPARE(pageRenderedSpy[0][1].toSize(), imageSize);
+ QCOMPARE(pageRenderedSpy[0][2].value<QImage>(), image);
+ QCOMPARE(pageRenderedSpy[0][2].value<QImage>().size(), imageSize);
+ QCOMPARE(pageRenderedSpy[0][4].toULongLong(), thirdRequestId);
+}
+
+QTEST_MAIN(tst_QPdfPageRenderer)
+
+#include "tst_qpdfpagerenderer.moc"
diff --git a/tests/auto/pdf/qpdfsearchmodel/qpdfsearchmodel.pro b/tests/auto/pdf/qpdfsearchmodel/qpdfsearchmodel.pro
new file mode 100644
index 000000000..205fef175
--- /dev/null
+++ b/tests/auto/pdf/qpdfsearchmodel/qpdfsearchmodel.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase
+TARGET = tst_qpdfsearchmodel
+QT += pdf testlib network
+macos:CONFIG -= app_bundle
+SOURCES += tst_qpdfsearchmodel.cpp
diff --git a/tests/auto/pdf/qpdfsearchmodel/test.pdf b/tests/auto/pdf/qpdfsearchmodel/test.pdf
new file mode 100644
index 000000000..a9dc1bc29
--- /dev/null
+++ b/tests/auto/pdf/qpdfsearchmodel/test.pdf
Binary files differ
diff --git a/tests/auto/pdf/qpdfsearchmodel/tst_qpdfsearchmodel.cpp b/tests/auto/pdf/qpdfsearchmodel/tst_qpdfsearchmodel.cpp
new file mode 100644
index 000000000..e690bfc11
--- /dev/null
+++ b/tests/auto/pdf/qpdfsearchmodel/tst_qpdfsearchmodel.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <QPdfDocument>
+#include <QPdfSearchModel>
+
+class tst_QPdfSearchModel: public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QPdfSearchModel() {}
+
+private slots:
+ void findText();
+};
+
+void tst_QPdfSearchModel::findText()
+{
+ QPdfDocument document;
+ QCOMPARE(document.load(QFINDTESTDATA("test.pdf")), QPdfDocument::NoError);
+
+ QPdfSearchModel model;
+ model.setDocument(&document);
+ QVector<QRectF> matches = model.matches(1, "ai");
+
+ qDebug() << matches;
+ QCOMPARE(matches.count(), 3);
+}
+
+QTEST_MAIN(tst_QPdfSearchModel)
+
+#include "tst_qpdfsearchmodel.moc"
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp
index 321972057..aaca7997b 100644
--- a/tests/auto/quick/publicapi/tst_publicapi.cpp
+++ b/tests/auto/quick/publicapi/tst_publicapi.cpp
@@ -300,6 +300,7 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineFullScreenRequest.reject() --> void"
<< "QQuickWebEngineFullScreenRequest.toggleOn --> bool"
<< "QQuickWebEngineHistory.backItems --> QQuickWebEngineHistoryListModel*"
+ << "QQuickWebEngineHistory.clear() --> void"
<< "QQuickWebEngineHistory.forwardItems --> QQuickWebEngineHistoryListModel*"
<< "QQuickWebEngineHistory.items --> QQuickWebEngineHistoryListModel*"
<< "QQuickWebEngineJavaScriptDialogRequest.DialogTypeAlert --> DialogType"
@@ -740,6 +741,8 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.quotaRequested(QWebEngineQuotaRequest) --> void"
<< "QQuickWebEngineView.recentlyAudible --> bool"
<< "QQuickWebEngineView.recentlyAudibleChanged(bool) --> void"
+ << "QQuickWebEngineView.renderProcessPid --> qlonglong"
+ << "QQuickWebEngineView.renderProcessPidChanged(qlonglong) --> void"
<< "QQuickWebEngineView.recommendedState --> LifecycleState"
<< "QQuickWebEngineView.recommendedStateChanged(LifecycleState) --> void"
<< "QQuickWebEngineView.registerProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest) --> void"
diff --git a/tests/auto/quick/qmltests/data/test4.html b/tests/auto/quick/qmltests/data/test4.html
index afda71bc5..c9b395ee5 100644
--- a/tests/auto/quick/qmltests/data/test4.html
+++ b/tests/auto/quick/qmltests/data/test4.html
@@ -24,106 +24,106 @@
}
</script>
<div id="content">
- bla00<br/>
- bla01<br/>
- bla02<br/>
- bla03<br/>
- bla04<br/>
- bla05<br/>
- bla06<br/>
- bla07<br/>
- bla08<br/>
- bla09<br/>
- bla10<br/>
- bla11<br/>
- bla12<br/>
- bla13<br/>
- bla14<br/>
- bla15<br/>
- bla16<br/>
- bla17<br/>
- bla18<br/>
- bla19<br/>
- bla20<br/>
- bla21<br/>
- bla22<br/>
- bla23<br/>
- bla24<br/>
- bla25<br/>
- bla26<br/>
- bla27<br/>
- bla28<br/>
- bla29<br/>
- bla30<br/>
- bla31<br/>
- bla32<br/>
- bla33<br/>
- bla34<br/>
- bla35<br/>
- bla36<br/>
- bla37<br/>
- bla38<br/>
- bla39<br/>
- bla40<br/>
- bla41<br/>
- bla42<br/>
- bla43<br/>
- bla44<br/>
- bla45<br/>
- bla46<br/>
- bla47<br/>
- bla48<br/>
- bla49<br/>
- bla50<br/>
- bla51<br/>
- bla52<br/>
- bla53<br/>
- bla54<br/>
- bla55<br/>
- bla56<br/>
- bla57<br/>
- bla58<br/>
- bla59<br/>
- bla60<br/>
- bla61<br/>
- bla62<br/>
- bla63<br/>
- bla64<br/>
- bla65<br/>
- bla66<br/>
- bla67<br/>
- bla68<br/>
- bla69<br/>
- bla70<br/>
- bla71<br/>
- bla72<br/>
- bla73<br/>
- bla74<br/>
- bla75<br/>
- bla76<br/>
- bla77<br/>
- bla78<br/>
- bla79<br/>
- bla80<br/>
- bla81<br/>
- bla82<br/>
- bla83<br/>
- bla84<br/>
- bla85<br/>
- bla86<br/>
- bla87<br/>
- bla88<br/>
- bla89<br/>
- bla90<br/>
- bla91<br/>
- bla92<br/>
- bla93<br/>
- bla94<br/>
- bla95<br/>
- bla96<br/>
- bla97<br/>
- bla98<br/>
- bla99<br/>
+ <p>bla00
+ <p>bla01
+ <p>bla02
+ <p>bla03
+ <p>bla04
+ <p>bla05
+ <p>bla06
+ <p>bla07
+ <p>bla08
+ <p>bla09
+ <p>bla10
+ <p>bla11
+ <p>bla12
+ <p>bla13
+ <p>bla14
+ <p>bla15
+ <p>bla16
+ <p>bla17
+ <p>bla18
+ <p>bla19
+ <p>bla20
+ <p>bla21
+ <p>bla22
+ <p>bla23
+ <p>bla24
+ <p>bla25
+ <p>bla26
+ <p>bla27
+ <p>bla28
+ <p>bla29
+ <p>bla30
+ <p>bla31
+ <p>bla32
+ <p>bla33
+ <p>bla34
+ <p>bla35
+ <p>bla36
+ <p>bla37
+ <p>bla38
+ <p>bla39
+ <p>bla40
+ <p>bla41
+ <p>bla42
+ <p>bla43
+ <p>bla44
+ <p>bla45
+ <p>bla46
+ <p>bla47
+ <p>bla48
+ <p>bla49
+ <p>bla50
+ <p>bla51
+ <p>bla52
+ <p>bla53
+ <p>bla54
+ <p>bla55
+ <p>bla56
+ <p>bla57
+ <p>bla58
+ <p>bla59
+ <p>bla60
+ <p>bla61
+ <p>bla62
+ <p>bla63
+ <p>bla64
+ <p>bla65
+ <p>bla66
+ <p>bla67
+ <p>bla68
+ <p>bla69
+ <p>bla70
+ <p>bla71
+ <p>bla72
+ <p>bla73
+ <p>bla74
+ <p>bla75
+ <p>bla76
+ <p>bla77
+ <p>bla78
+ <p>bla79
+ <p>bla80
+ <p>bla81
+ <p>bla82
+ <p>bla83
+ <p>bla84
+ <p>bla85
+ <p>bla86
+ <p>bla87
+ <p>bla88
+ <p>bla89
+ <p>bla90
+ <p>bla91
+ <p>bla92
+ <p>bla93
+ <p>bla94
+ <p>bla95
+ <p>bla96
+ <p>bla97
+ <p>bla98
+ <p>bla99
</div>
</body>
</html>
diff --git a/tests/auto/quick/qmltests/data/tst_loadUrl.qml b/tests/auto/quick/qmltests/data/tst_loadUrl.qml
index 7bdd0c761..872c46641 100644
--- a/tests/auto/quick/qmltests/data/tst_loadUrl.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadUrl.qml
@@ -230,7 +230,7 @@ TestWebEngineView {
compare(loadRequest.activeUrl, aboutBlank);
loadRequest = loadRequestArray[2];
compare(loadRequest.status, WebEngineView.LoadStartedStatus);
- compare(loadRequest.activeUrl, "data:text/html;charset=UTF-8,load failed");
+ compare(loadRequest.activeUrl, bogusSite);
compare(loadRequest.url, "data:text/html;charset=UTF-8,load failed")
loadRequest = loadRequestArray[3];
compare(loadRequest.status, WebEngineView.LoadSucceededStatus);
diff --git a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
index 77664e645..6ed232589 100644
--- a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
+++ b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
@@ -134,6 +134,13 @@ TestWebEngineView {
compare(forwardItemsList.count, 1)
compare(backItemsList.currentItem.text, Qt.resolvedUrl("test1.html"))
compare(forwardItemsList.currentItem.text, Qt.resolvedUrl("javascript.html"))
+
+ webEngineView.navigationHistory.clear()
+ compare(webEngineView.url, Qt.resolvedUrl("test2.html"))
+ compare(webEngineView.canGoBack, false)
+ compare(webEngineView.canGoForward, false)
+ compare(backItemsList.count, 0)
+ compare(forwardItemsList.count, 0)
}
}
}
diff --git a/tests/auto/quick/qquickwebengineview/BLACKLIST b/tests/auto/quick/qquickwebengineview/BLACKLIST
index e69de29bb..af97422a9 100644
--- a/tests/auto/quick/qquickwebengineview/BLACKLIST
+++ b/tests/auto/quick/qquickwebengineview/BLACKLIST
@@ -0,0 +1,3 @@
+# until qt5.git is updated with new qtdeclarative
+[focusChild]
+*
diff --git a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
index 04be25abe..5ee30f165 100644
--- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
+++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
@@ -581,7 +581,7 @@ void tst_QQuickWebEngineView::interruptImeTextComposition()
QFETCH(QString, eventType);
if (eventType == "MouseButton") {
QPoint textInputCenter = elementCenter(view, QStringLiteral("input2"));
- QTest::mouseClick(view->window(), Qt::LeftButton, 0, textInputCenter);
+ QTest::mouseClick(view->window(), Qt::LeftButton, {}, textInputCenter);
} else if (eventType == "Touch") {
QPoint textInputCenter = elementCenter(view, QStringLiteral("input2"));
QTouchDevice *touchDevice = QTest::createTouchDevice();
@@ -618,7 +618,7 @@ void tst_QQuickWebEngineView::inputContextQueryInput()
// Set focus on an input field.
QPoint textInputCenter = elementCenter(view, "input1");
- QTest::mouseClick(view->window(), Qt::LeftButton, 0, textInputCenter);
+ QTest::mouseClick(view->window(), Qt::LeftButton, {}, textInputCenter);
QTRY_COMPARE(testContext.infos.count(), 2);
QCOMPARE(evaluateJavaScriptSync(view, "document.activeElement.id").toString(), QStringLiteral("input1"));
foreach (const InputMethodInfo &info, testContext.infos) {
@@ -1003,7 +1003,7 @@ void tst_QQuickWebEngineView::changeLocale()
QTRY_VERIFY(!evaluateJavaScriptSync(viewDE.data(), "document.body").isNull());
QTRY_VERIFY(!evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").isNull());
- errorLines = evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").toString().split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts);
+ errorLines = evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").toString().split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts);
QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("Die Website ist nicht erreichbar"));
QLocale::setDefault(QLocale("en"));
@@ -1013,7 +1013,7 @@ void tst_QQuickWebEngineView::changeLocale()
QTRY_VERIFY(!evaluateJavaScriptSync(viewEN.data(), "document.body").isNull());
QTRY_VERIFY(!evaluateJavaScriptSync(viewEN.data(), "document.body.innerText").isNull());
- errorLines = evaluateJavaScriptSync(viewEN.data(), "document.body.innerText").toString().split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts);
+ errorLines = evaluateJavaScriptSync(viewEN.data(), "document.body.innerText").toString().split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts);
QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("This site can\xE2\x80\x99t be reached"));
// Reset error page
@@ -1026,7 +1026,7 @@ void tst_QQuickWebEngineView::changeLocale()
QTRY_VERIFY(!evaluateJavaScriptSync(viewDE.data(), "document.body").isNull());
QTRY_VERIFY(!evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").isNull());
- errorLines = evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").toString().split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts);
+ errorLines = evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").toString().split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts);
QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("Die Website ist nicht erreichbar"));
}
diff --git a/tests/auto/widgets/accessibility/tst_accessibility.cpp b/tests/auto/widgets/accessibility/tst_accessibility.cpp
index 117a9e573..80defb248 100644
--- a/tests/auto/widgets/accessibility/tst_accessibility.cpp
+++ b/tests/auto/widgets/accessibility/tst_accessibility.cpp
@@ -339,12 +339,12 @@ void tst_Accessibility::roles_data()
QTest::newRow("AX_ROLE_ABBR") << QString("<abbr>a</abbr>") << false << QAccessible::StaticText;
QTest::newRow("AX_ROLE_ALERT") << QString("<div role='alert'>alert</div>") << true << QAccessible::AlertMessage;
QTest::newRow("AX_ROLE_ALERT_DIALOG") << QString("<div role='alertdialog'>alert</div>") << true << QAccessible::AlertMessage;
- //QTest::newRow("AX_ROLE_ANCHOR") << QString("<a>target</a>") << false << QAccessible::Link; // FIXME: The test case might be wrong (see https://codereview.chromium.org/2713193003)
+ QTest::newRow("AX_ROLE_ANCHOR") << QString("<a id='a'>Chapter a</a>") << false << QAccessible::Link;
QTest::newRow("AX_ROLE_ANNOTATION") << QString("<rt>a</rt>") << false << QAccessible::StaticText;
QTest::newRow("AX_ROLE_APPLICATION") << QString("<div role='application'>landmark</div>") << true << QAccessible::Document;
QTest::newRow("AX_ROLE_ARTICLE") << QString("<article>a</article>") << true << QAccessible::Section;
QTest::newRow("AX_ROLE_AUDIO") << QString("<audio controls><source src='test.mp3' type='audio/mpeg'></audio>") << false << QAccessible::Sound;
- QTest::newRow("AX_ROLE_BANNER") << QString("<header>a</header>") << true << QAccessible::Section;
+ QTest::newRow("AX_ROLE_BANNER") << QString("<div role=banner>a</div>") << true << QAccessible::Section;
QTest::newRow("AX_ROLE_BLOCKQUOTE") << QString("<blockquote>a</blockquote>") << true << QAccessible::Section;
QTest::newRow("AX_ROLE_BUTTON") << QString("<button>a</button>") << false << QAccessible::Button;
//QTest::newRow("AX_ROLE_BUTTON_DROP_DOWN"); // TODO: Remove this during the next Chromium update: https://chromium-review.googlesource.com/842475
@@ -383,6 +383,7 @@ void tst_Accessibility::roles_data()
QTest::newRow("AX_ROLE_FORM") << QString("<form></form>") << true << QAccessible::Form;
QTest::newRow("AX_ROLE_GRID") << QString("<div role='grid'></div>") << true << QAccessible::Table;
QTest::newRow("AX_ROLE_GROUP") << QString("<fieldset></fieldset>") << true << QAccessible::Grouping;
+ QTest::newRow("AX_ROLE_HEADER)") << QString("<header>a</header>") << true << QAccessible::Section;
QTest::newRow("AX_ROLE_HEADING") << QString("<h1>a</h1>") << true << QAccessible::Heading;
QTest::newRow("AX_ROLE_IFRAME") << QString("<iframe>a</iframe>") << true << QAccessible::Section;
QTest::newRow("AX_ROLE_IFRAME_PRESENTATIONAL") << QString("<iframe role='presentation'>a</iframe>") << false << QAccessible::NoRole;
diff --git a/tests/auto/widgets/origins/tst_origins.cpp b/tests/auto/widgets/origins/tst_origins.cpp
index c63f4d690..e3927f763 100644
--- a/tests/auto/widgets/origins/tst_origins.cpp
+++ b/tests/auto/widgets/origins/tst_origins.cpp
@@ -481,6 +481,8 @@ void tst_Origins::subdirWithoutAccess()
{
ScopedAttribute sa(m_page->settings(), QWebEngineSettings::LocalContentCanAccessFileUrls, false);
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
QVERIFY(verifyLoad(QSL("file:" THIS_DIR "resources/subdir/index.html")));
QCOMPARE(eval(QSL("msg[0]")), QVariant());
QCOMPARE(eval(QSL("msg[1]")), QVariant());
@@ -507,22 +509,28 @@ void tst_Origins::mixedSchemes()
QVERIFY(verifyLoad(QSL("file:" THIS_DIR "resources/mixedSchemes.html")));
eval(QSL("setIFrameUrl('file:" THIS_DIR "resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadAndAccess")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
eval(QSL("setIFrameUrl('qrc:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
eval(QSL("setIFrameUrl('tst:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
QVERIFY(verifyLoad(QSL("qrc:/resources/mixedSchemes.html")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
eval(QSL("setIFrameUrl('file:" THIS_DIR "resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
eval(QSL("setIFrameUrl('qrc:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadAndAccess")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
eval(QSL("setIFrameUrl('tst:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
QVERIFY(verifyLoad(QSL("tst:/resources/mixedSchemes.html")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Not allowed to load local resource")));
eval(QSL("setIFrameUrl('file:" THIS_DIR "resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("cannotLoad")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
eval(QSL("setIFrameUrl('qrc:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
eval(QSL("setIFrameUrl('tst:/resources/mixedSchemes_frame.html')"));
@@ -531,36 +539,47 @@ void tst_Origins::mixedSchemes()
QVERIFY(verifyLoad(QSL("PathSyntax:/resources/mixedSchemes.html")));
eval(QSL("setIFrameUrl('PathSyntax:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadAndAccess")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Not allowed to load local resource")));
eval(QSL("setIFrameUrl('PathSyntax-Local:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("cannotLoad")));
eval(QSL("setIFrameUrl('PathSyntax-LocalAccessAllowed:/resources/mixedSchemes_frame.html')"));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
eval(QSL("setIFrameUrl('PathSyntax-NoAccessAllowed:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
QVERIFY(verifyLoad(QSL("PathSyntax-LocalAccessAllowed:/resources/mixedSchemes.html")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
eval(QSL("setIFrameUrl('PathSyntax:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
eval(QSL("setIFrameUrl('PathSyntax-Local:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
eval(QSL("setIFrameUrl('PathSyntax-LocalAccessAllowed:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadAndAccess")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
eval(QSL("setIFrameUrl('PathSyntax-NoAccessAllowed:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
QVERIFY(verifyLoad(QSL("PathSyntax-NoAccessAllowed:/resources/mixedSchemes.html")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
eval(QSL("setIFrameUrl('PathSyntax:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Not allowed to load local resource")));
eval(QSL("setIFrameUrl('PathSyntax-Local:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("cannotLoad")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
eval(QSL("setIFrameUrl('PathSyntax-LocalAccessAllowed:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
eval(QSL("setIFrameUrl('PathSyntax-NoAccessAllowed:/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
QVERIFY(verifyLoad(QSL("HostSyntax://a/resources/mixedSchemes.html")));
eval(QSL("setIFrameUrl('HostSyntax://a/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadAndAccess")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
eval(QSL("setIFrameUrl('HostSyntax://b/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
}
@@ -569,14 +588,17 @@ void tst_Origins::mixedSchemes()
void tst_Origins::mixedSchemesWithCsp()
{
QVERIFY(verifyLoad(QSL("HostSyntax://a/resources/mixedSchemesWithCsp.html")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("violates the following Content Security Policy")));
eval(QSL("setIFrameUrl('HostSyntax://a/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("violates the following Content Security Policy")));
eval(QSL("setIFrameUrl('HostSyntax://b/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
QVERIFY(verifyLoad(QSL("HostSyntax-ContentSecurityPolicyIgnored://a/resources/mixedSchemesWithCsp.html")));
eval(QSL("setIFrameUrl('HostSyntax-ContentSecurityPolicyIgnored://a/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadAndAccess")));
+ QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("Uncaught SecurityError")));
eval(QSL("setIFrameUrl('HostSyntax-ContentSecurityPolicyIgnored://b/resources/mixedSchemes_frame.html')"));
QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("canLoadButNotAccess")));
}
diff --git a/tests/auto/widgets/proxypac/proxypac.pro b/tests/auto/widgets/proxypac/proxypac.pro
index 4dbcd9365..2aacb4366 100644
--- a/tests/auto/widgets/proxypac/proxypac.pro
+++ b/tests/auto/widgets/proxypac/proxypac.pro
@@ -4,8 +4,10 @@ HEADERS += proxyserver.h
SOURCES += proxyserver.cpp
proxy_pac.name = QTWEBENGINE_CHROMIUM_FLAGS
+
+win32:proxy_pac.value = --proxy-pac-url="file:///$$PWD/proxy.pac"
+else:proxy_pac.value = --proxy-pac-url="file://$$PWD/proxy.pac"
boot2qt:proxy_pac.value = "--single-process --no-sandbox --proxy-pac-url=file://$$PWD/proxy.pac"
-else: proxy_pac.value = --proxy-pac-url="file://$$PWD/proxy.pac"
QT_TOOL_ENV += proxy_pac
diff --git a/tests/auto/widgets/qwebenginepage/BLACKLIST b/tests/auto/widgets/qwebenginepage/BLACKLIST
index 2498ed765..02b297d5a 100644
--- a/tests/auto/widgets/qwebenginepage/BLACKLIST
+++ b/tests/auto/widgets/qwebenginepage/BLACKLIST
@@ -4,3 +4,9 @@ osx
[mouseMovementProperties]
windows
macos # Can't move cursor (QTBUG-76312)
+
+[devTools]
+msvc-2019
+
+[setLifecycleStateWithDevTools]
+msvc-2019
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index d0453e1e6..6a01a2bed 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -226,6 +226,7 @@ private Q_SLOTS:
void customUserAgentInNewTab();
void renderProcessCrashed();
+ void renderProcessPid();
private:
static QPoint elementCenter(QWebEnginePage *page, const QString &id);
@@ -798,7 +799,7 @@ void tst_QWebEnginePage::backActionUpdate()
};
QVERIFY(evaluateJavaScriptSync(page, "document.getElementsByName('frame_b')[0].contentDocument == undefined").toBool());
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, firstAnchorCenterInFrame(page, "frame_c"));
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, firstAnchorCenterInFrame(page, "frame_c"));
QTRY_VERIFY(evaluateJavaScriptSync(page, "document.getElementsByName('frame_b')[0].contentDocument != undefined").toBool());
QTRY_VERIFY(action->isEnabled());
}
@@ -982,7 +983,7 @@ void tst_QWebEnginePage::findText()
{
CallbackSpy<bool> callbackSpy;
QSignalSpy signalSpy(m_view->page(), &QWebEnginePage::findTextFinished);
- m_view->findText("", 0, callbackSpy.ref());
+ m_view->findText("", {}, callbackSpy.ref());
QVERIFY(callbackSpy.wasCalled());
QCOMPARE(signalSpy.count(), 1);
QTRY_COMPARE(m_view->selectedText(), QString("foo bar"));
@@ -993,7 +994,7 @@ void tst_QWebEnginePage::findText()
{
CallbackSpy<bool> callbackSpy;
QSignalSpy signalSpy(m_view->page(), &QWebEnginePage::findTextFinished);
- m_view->findText("Will not be found", 0, callbackSpy.ref());
+ m_view->findText("Will not be found", {}, callbackSpy.ref());
QCOMPARE(callbackSpy.waitForResult(), false);
QTRY_COMPARE(signalSpy.count(), 1);
auto result = signalSpy.takeFirst().value(0).value<QWebEngineFindTextResult>();
@@ -1010,7 +1011,7 @@ void tst_QWebEnginePage::findText()
{
CallbackSpy<bool> callbackSpy;
QSignalSpy signalSpy(m_view->page(), &QWebEnginePage::findTextFinished);
- m_view->findText("foo", 0, callbackSpy.ref());
+ m_view->findText("foo", {}, callbackSpy.ref());
QVERIFY(callbackSpy.waitForResult());
QTRY_COMPARE(signalSpy.count(), 1);
QTRY_VERIFY(m_view->selectedText().isEmpty());
@@ -1021,7 +1022,7 @@ void tst_QWebEnginePage::findText()
{
CallbackSpy<bool> callbackSpy;
QSignalSpy signalSpy(m_view->page(), &QWebEnginePage::findTextFinished);
- m_view->findText("", 0, callbackSpy.ref());
+ m_view->findText("", {}, callbackSpy.ref());
QTRY_VERIFY(callbackSpy.wasCalled());
QTRY_COMPARE(signalSpy.count(), 1);
QTRY_COMPARE(m_view->selectedText(), QString("foo"));
@@ -1031,8 +1032,8 @@ void tst_QWebEnginePage::findText()
// should interrupt the first one.
{
QSignalSpy signalSpy(m_view->page(), &QWebEnginePage::findTextFinished);
- m_view->findText("foo", 0);
- m_view->findText("foo", 0);
+ m_view->findText("foo", {});
+ m_view->findText("foo", {});
QTRY_COMPARE(signalSpy.count(), 2);
QTRY_VERIFY(m_view->selectedText().isEmpty());
@@ -1087,11 +1088,11 @@ void tst_QWebEnginePage::findTextSuccessiveShouldCallAllCallbacks()
QSignalSpy loadSpy(m_view, SIGNAL(loadFinished(bool)));
m_view->setHtml(QString("<html><head></head><body><div>abcdefg abcdefg abcdefg abcdefg abcdefg</div></body></html>"));
QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 1, 20000);
- m_page->findText("abcde", 0, spy1.ref());
- m_page->findText("abcd", 0, spy2.ref());
- m_page->findText("abc", 0, spy3.ref());
- m_page->findText("ab", 0, spy4.ref());
- m_page->findText("a", 0, spy5.ref());
+ m_page->findText("abcde", {}, spy1.ref());
+ m_page->findText("abcd", {}, spy2.ref());
+ m_page->findText("abc", {}, spy3.ref());
+ m_page->findText("ab", {}, spy4.ref());
+ m_page->findText("a", {}, spy5.ref());
spy5.waitForResult();
QVERIFY(spy1.wasCalled());
QVERIFY(spy2.wasCalled());
@@ -1112,10 +1113,10 @@ void tst_QWebEnginePage::findTextCalledOnMatch()
// CALLBACK
bool callbackCalled = false;
- m_view->page()->findText("foo", 0, [this, &callbackCalled](bool found) {
+ m_view->page()->findText("foo", {}, [this, &callbackCalled](bool found) {
QVERIFY(found);
- m_view->page()->findText("bar", 0, [&callbackCalled](bool found) {
+ m_view->page()->findText("bar", {}, [&callbackCalled](bool found) {
QVERIFY(found);
callbackCalled = true;
});
@@ -1149,7 +1150,7 @@ void tst_QWebEnginePage::findTextActiveMatchOrdinal()
// Iterate over all "foo" matches.
for (int i = 1; i <= 3; ++i) {
- m_view->page()->findText("foo", 0);
+ m_view->page()->findText("foo", {});
QTRY_COMPARE(findTextSpy.count(), 1);
result = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>();
QCOMPARE(result.numberOfMatches(), 3);
@@ -1157,7 +1158,7 @@ void tst_QWebEnginePage::findTextActiveMatchOrdinal()
}
// The last match is followed by the fist one.
- m_view->page()->findText("foo", 0);
+ m_view->page()->findText("foo", {});
QTRY_COMPARE(findTextSpy.count(), 1);
result = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>();
QCOMPARE(result.numberOfMatches(), 3);
@@ -1171,14 +1172,14 @@ void tst_QWebEnginePage::findTextActiveMatchOrdinal()
QCOMPARE(result.activeMatch(), 3);
// Finding another word resets the activeMatch.
- m_view->page()->findText("bar", 0);
+ m_view->page()->findText("bar", {});
QTRY_COMPARE(findTextSpy.count(), 1);
result = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>();
QCOMPARE(result.numberOfMatches(), 2);
QCOMPARE(result.activeMatch(), 1);
// If no match activeMatch is 0.
- m_view->page()->findText("bla", 0);
+ m_view->page()->findText("bla", {});
QTRY_COMPARE(findTextSpy.count(), 1);
result = findTextSpy.takeFirst().value(0).value<QWebEngineFindTextResult>();
QCOMPARE(result.numberOfMatches(), 0);
@@ -1965,8 +1966,7 @@ void tst_QWebEnginePage::urlChange()
QUrl testUrl("http://test.qt.io/");
m_view->setHtml(QStringLiteral("<h1>Test</h1"), testUrl);
- QTRY_COMPARE(urlSpy.size(), 2);
- QCOMPARE(urlSpy.takeFirst().value(0).toUrl(), QUrl("data:text/html;charset=UTF-8,%3Ch1%3ETest%3C%2Fh1"));
+ QTRY_COMPARE(urlSpy.size(), 1);
QCOMPARE(urlSpy.takeFirst().value(0).toUrl(), testUrl);
}
@@ -2026,7 +2026,7 @@ private Q_SLOTS:
void continueError()
{
- emit error(this->error());
+ emit error(this->networkError());
emit finished();
}
};
@@ -2078,7 +2078,7 @@ void tst_QWebEnginePage::requestedUrlAfterSetAndLoadFailures()
page.load(second);
QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 2, 20000);
- QCOMPARE(page.url(), second);
+ QCOMPARE(page.url(), first);
QCOMPARE(page.requestedUrl(), second);
QVERIFY(!spy.at(1).first().toBool());
}
@@ -2778,8 +2778,8 @@ void tst_QWebEnginePage::setUrlThenLoads()
QCOMPARE(baseUrlSync(m_page), extractBaseUrl(urlToLoad1));
m_page->load(urlToLoad2);
- QTRY_COMPARE(m_page->url(), urlToLoad2);
- QTRY_COMPARE(m_page->requestedUrl(), urlToLoad2);
+ QCOMPARE(m_page->url(), urlToLoad1);
+ QCOMPARE(m_page->requestedUrl(), urlToLoad2);
QCOMPARE(baseUrlSync(m_page), extractBaseUrl(urlToLoad1));
QTRY_COMPARE(startedSpy.count(), 3);
@@ -3292,7 +3292,7 @@ void tst_QWebEnginePage::dataURLFragment()
QTRY_COMPARE(loadFinishedSpy.count(), 1);
QSignalSpy urlChangedSpy(m_page, SIGNAL(urlChanged(QUrl)));
- QTest::mouseClick(m_view->focusProxy(), Qt::LeftButton, 0, elementCenter(m_page, "link"));
+ QTest::mouseClick(m_view->focusProxy(), Qt::LeftButton, {}, elementCenter(m_page, "link"));
QVERIFY(urlChangedSpy.wait());
QCOMPARE(m_page->url().fragment(), QStringLiteral("anchor"));
@@ -3302,7 +3302,7 @@ void tst_QWebEnginePage::dataURLFragment()
"</body></html>", QUrl("http://test.qt.io/mytest.html"));
QTRY_COMPARE(loadFinishedSpy.count(), 2);
- QTest::mouseClick(m_view->focusProxy(), Qt::LeftButton, 0, elementCenter(m_page, "link"));
+ QTest::mouseClick(m_view->focusProxy(), Qt::LeftButton, {}, elementCenter(m_page, "link"));
QVERIFY(urlChangedSpy.wait());
QCOMPARE(m_page->url(), QUrl("http://test.qt.io/mytest.html#anchor"));
}
@@ -3324,7 +3324,7 @@ void tst_QWebEnginePage::devTools()
QCOMPARE(devToolsPage.devToolsPage(), nullptr);
QCOMPARE(devToolsPage.inspectedPage(), &inspectedPage1);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 30000);
QVERIFY(spy.takeFirst().value(0).toBool());
devToolsPage.setInspectedPage(&inspectedPage2);
@@ -3336,7 +3336,7 @@ void tst_QWebEnginePage::devTools()
QCOMPARE(devToolsPage.devToolsPage(), nullptr);
QCOMPARE(devToolsPage.inspectedPage(), &inspectedPage2);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 30000);
QVERIFY(spy.takeFirst().value(0).toBool());
devToolsPage.setInspectedPage(nullptr);
@@ -3372,7 +3372,7 @@ void tst_QWebEnginePage::openLinkInDifferentProfile()
QTRY_COMPARE(spy1.count(), 1);
QVERIFY(spy1.takeFirst().value(0).toBool());
page1.targetPage = &page2;
- QTest::mouseClick(view.focusProxy(), Qt::MiddleButton, 0, elementCenter(&page1, "link"));
+ QTest::mouseClick(view.focusProxy(), Qt::MiddleButton, {}, elementCenter(&page1, "link"));
QTRY_COMPARE(spy2.count(), 1);
QVERIFY(spy2.takeFirst().value(0).toBool());
}
@@ -3816,9 +3816,9 @@ void tst_QWebEnginePage::setLifecycleStateWithDevTools()
// Ensure pages are initialized
inspectedPage.load(QStringLiteral("about:blank"));
devToolsPage.load(QStringLiteral("about:blank"));
- QTRY_COMPARE(inspectedSpy.count(), 1);
+ QTRY_COMPARE_WITH_TIMEOUT(inspectedSpy.count(), 1, 30000);
QCOMPARE(inspectedSpy.takeFirst().value(0), QVariant(true));
- QTRY_COMPARE(devToolsSpy.count(), 1);
+ QTRY_COMPARE_WITH_TIMEOUT(devToolsSpy.count(), 1, 30000);
QCOMPARE(devToolsSpy.takeFirst().value(0), QVariant(true));
// Open DevTools with Frozen inspectedPage
@@ -4329,7 +4329,7 @@ void tst_QWebEnginePage::customUserAgentInNewTab()
QTRY_COMPARE(spy.count(), 1);
QVERIFY(spy.takeFirst().value(0).toBool());
QCOMPARE(evaluateJavaScriptSync(&page, QStringLiteral("navigator.userAgent")).toString(), profile1.httpUserAgent());
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, elementCenter(&page, "link"));
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, elementCenter(&page, "link"));
QTRY_VERIFY(page.newPage);
QTRY_VERIFY(!lastUserAgent.isEmpty());
QCOMPARE(lastUserAgent, profile1.httpUserAgent().toUtf8());
@@ -4344,7 +4344,7 @@ void tst_QWebEnginePage::customUserAgentInNewTab()
QString("'>link</a></body></html>"));
QTRY_COMPARE(spy.count(), 1);
QVERIFY(spy.takeFirst().value(0).toBool());
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, elementCenter(&page, "link"));
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, elementCenter(&page, "link"));
QTRY_VERIFY(page.newPage);
QTRY_VERIFY(!lastUserAgent.isEmpty());
QCOMPARE(lastUserAgent, profile2.httpUserAgent().toUtf8());
@@ -4370,6 +4370,24 @@ void tst_QWebEnginePage::renderProcessCrashed()
status == QWebEnginePage::AbnormalTerminationStatus);
}
+void tst_QWebEnginePage::renderProcessPid()
+{
+ QCOMPARE(m_page->renderProcessPid(), 0);
+
+ m_page->load(QUrl("about:blank"));
+ QSignalSpy spyFinished(m_page, &QWebEnginePage::loadFinished);
+ QVERIFY(spyFinished.wait());
+
+ QVERIFY(m_page->renderProcessPid() > 1);
+
+ bool crashed = false;
+ connect(m_page, &QWebEnginePage::renderProcessTerminated, [&]() { crashed = true; });
+ m_page->load(QUrl("chrome://crash"));
+ QTRY_VERIFY_WITH_TIMEOUT(crashed, 20000);
+
+ QCOMPARE(m_page->renderProcessPid(), 0);
+}
+
static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")};
W_QTEST_MAIN(tst_QWebEnginePage, params)
diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
index 128cf7ab9..1f8162941 100644
--- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
+++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
@@ -71,6 +71,7 @@ private Q_SLOTS:
void urlSchemeHandlerInstallation();
void urlSchemeHandlerXhrStatus();
void urlSchemeHandlerScriptModule();
+ void urlSchemeHandlerLongReply();
void customUserAgent();
void httpAcceptLanguage();
void downloadItem();
@@ -172,7 +173,6 @@ public:
~AutoDir() { removeRecursively(); }
};
-
qint64 totalSize(QDir dir)
{
qint64 sum = 0;
@@ -355,7 +355,7 @@ protected:
memcpy(data, m_data.constData() + m_bytesRead, len);
m_bytesAvailable -= len;
m_bytesRead += len;
- } else if (m_data.size() > 0)
+ } else if (atEnd())
return -1;
return len;
@@ -760,6 +760,31 @@ void tst_QWebEngineProfile::urlSchemeHandlerScriptModule()
QCOMPARE(evaluateJavaScriptSync(&page, QStringLiteral("test")).toString(), QStringLiteral("SUCCESS"));
}
+class LongReplyUrlSchemeHandler : public QWebEngineUrlSchemeHandler
+{
+public:
+ LongReplyUrlSchemeHandler(QObject *parent = nullptr) : QWebEngineUrlSchemeHandler(parent) {}
+ ~LongReplyUrlSchemeHandler() {}
+
+ void requestStarted(QWebEngineUrlRequestJob *job)
+ {
+ QBuffer *buffer = new QBuffer(job);
+ buffer->setData(QByteArray(128 * 1024, ' ') +
+ "<html><head><title>Minify this!</title></head></html>");
+ job->reply("text/html", buffer);
+ }
+};
+
+void tst_QWebEngineProfile::urlSchemeHandlerLongReply()
+{
+ LongReplyUrlSchemeHandler handler;
+ QWebEngineProfile profile;
+ profile.installUrlSchemeHandler("aviancarrier", &handler);
+ QWebEnginePage page(&profile);
+ page.load(QUrl("aviancarrier:/"));
+ QTRY_COMPARE(page.title(), QString("Minify this!"));
+}
+
void tst_QWebEngineProfile::customUserAgent()
{
QString defaultUserAgent = QWebEngineProfile::defaultProfile()->httpUserAgent();
@@ -965,26 +990,32 @@ void tst_QWebEngineProfile::initiator()
InitiatorSpy handler;
QWebEngineProfile profile;
profile.installUrlSchemeHandler("foo", &handler);
- QWebEnginePage page(&profile);
+ QWebEnginePage page(&profile, nullptr);
QSignalSpy loadFinishedSpy(&page, SIGNAL(loadFinished(bool)));
+ page.load(QUrl("about:blank"));
+ QTRY_COMPARE(loadFinishedSpy.count(), 1);
+ loadFinishedSpy.clear();
// about:blank has a unique origin, so initiator should be QUrl("null")
evaluateJavaScriptSync(&page, "window.location = 'foo:bar'");
- QVERIFY(loadFinishedSpy.wait());
+ QTRY_COMPARE(loadFinishedSpy.count(), 1);
+ loadFinishedSpy.clear();
QCOMPARE(handler.initiator, QUrl("null"));
page.setHtml("", QUrl("http://test:123/foo%20bar"));
- QVERIFY(loadFinishedSpy.wait());
+ QTRY_COMPARE(loadFinishedSpy.count(), 1);
+ loadFinishedSpy.clear();
// baseUrl determines the origin, so QUrl("http://test:123")
evaluateJavaScriptSync(&page, "window.location = 'foo:bar'");
- QVERIFY(loadFinishedSpy.wait());
+ QTRY_COMPARE(loadFinishedSpy.count(), 1);
+ loadFinishedSpy.clear();
QCOMPARE(handler.initiator, QUrl("http://test:123"));
// Directly calling load/setUrl should have initiator QUrl(), meaning
// browser-initiated, trusted.
page.load(QUrl("foo:bar"));
- QVERIFY(loadFinishedSpy.wait());
+ QTRY_COMPARE(loadFinishedSpy.count(), 1);
QCOMPARE(handler.initiator, QUrl());
}
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
index 2862be1dd..5e16361c5 100644
--- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
+++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
@@ -538,7 +538,7 @@ void tst_QWebEngineView::focusInputTypes()
// 'text' field
QPoint textInputCenter = elementCenter(webView.page(), "textInput");
- QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, 0, textInputCenter);
+ QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, {}, textInputCenter);
QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("textInput"));
VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), Qt::ImhPreferLowercase);
QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled));
@@ -546,7 +546,7 @@ void tst_QWebEngineView::focusInputTypes()
// 'password' field
QPoint passwordInputCenter = elementCenter(webView.page(), "passwordInput");
- QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, 0, passwordInputCenter);
+ QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, {}, passwordInputCenter);
QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("passwordInput"));
VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), (Qt::ImhSensitiveData | Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase | Qt::ImhHiddenText));
QVERIFY(!webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled));
@@ -554,7 +554,7 @@ void tst_QWebEngineView::focusInputTypes()
// 'tel' field
QPoint telInputCenter = elementCenter(webView.page(), "telInput");
- QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, 0, telInputCenter);
+ QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, {}, telInputCenter);
QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("telInput"));
VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), Qt::ImhDialableCharactersOnly);
QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled));
@@ -562,7 +562,7 @@ void tst_QWebEngineView::focusInputTypes()
// 'number' field
QPoint numberInputCenter = elementCenter(webView.page(), "numberInput");
- QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, 0, numberInputCenter);
+ QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, {}, numberInputCenter);
QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("numberInput"));
VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), Qt::ImhFormattedNumbersOnly);
QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled));
@@ -570,7 +570,7 @@ void tst_QWebEngineView::focusInputTypes()
// 'email' field
QPoint emailInputCenter = elementCenter(webView.page(), "emailInput");
- QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, 0, emailInputCenter);
+ QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, {}, emailInputCenter);
QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("emailInput"));
VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), Qt::ImhEmailCharactersOnly);
QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled));
@@ -578,28 +578,28 @@ void tst_QWebEngineView::focusInputTypes()
// 'url' field
QPoint urlInputCenter = elementCenter(webView.page(), "urlInput");
- QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, 0, urlInputCenter);
+ QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, {}, urlInputCenter);
QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("urlInput"));
VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), (Qt::ImhUrlCharactersOnly | Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase));
QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled));
QTRY_VERIFY(inputMethodQuery(Qt::ImEnabled).toBool());
// 'password' field
- QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, 0, passwordInputCenter);
+ QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, {}, passwordInputCenter);
QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("passwordInput"));
VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), (Qt::ImhSensitiveData | Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase | Qt::ImhHiddenText));
QVERIFY(!webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled));
QTRY_COMPARE(inputMethodQuery(Qt::ImEnabled).toBool(), imeHasHiddenTextCapability);
// 'text' type
- QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, 0, textInputCenter);
+ QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, {}, textInputCenter);
QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("textInput"));
VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), Qt::ImhPreferLowercase);
QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled));
QTRY_VERIFY(inputMethodQuery(Qt::ImEnabled).toBool());
// 'password' field
- QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, 0, passwordInputCenter);
+ QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, {}, passwordInputCenter);
QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("passwordInput"));
VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), (Qt::ImhSensitiveData | Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase | Qt::ImhHiddenText));
QVERIFY(!webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled));
@@ -607,7 +607,7 @@ void tst_QWebEngineView::focusInputTypes()
// 'text area' field
QPoint textAreaCenter = elementCenter(webView.page(), "textArea");
- QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, 0, textAreaCenter);
+ QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, {}, textAreaCenter);
QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("textArea"));
VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), (Qt::ImhMultiLine | Qt::ImhPreferLowercase));
QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled));
@@ -696,12 +696,12 @@ void tst_QWebEngineView::horizontalScrollbarTest()
QSignalSpy scrollSpy(view.page(), SIGNAL(scrollPositionChanged(QPointF)));
// Note: The test below assumes that the layout direction is Qt::LeftToRight.
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, QPoint(550, 595));
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, QPoint(550, 595));
scrollSpy.wait();
QVERIFY(view.page()->scrollPosition().x() > 0);
// Note: The test below assumes that the layout direction is Qt::LeftToRight.
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, QPoint(20, 595));
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, QPoint(20, 595));
scrollSpy.wait();
QVERIFY(view.page()->scrollPosition() == QPoint(0, 0));
}
@@ -1213,7 +1213,7 @@ void tst_QWebEngineView::changeLocale()
QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpyDE.count(), 1, 20000);
QTRY_VERIFY(!toPlainTextSync(viewDE.page()).isEmpty());
- errorLines = toPlainTextSync(viewDE.page()).split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts);
+ errorLines = toPlainTextSync(viewDE.page()).split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts);
QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("Die Website ist nicht erreichbar"));
QLocale::setDefault(QLocale("en"));
@@ -1223,7 +1223,7 @@ void tst_QWebEngineView::changeLocale()
QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpyEN.count(), 1, 20000);
QTRY_VERIFY(!toPlainTextSync(viewEN.page()).isEmpty());
- errorLines = toPlainTextSync(viewEN.page()).split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts);
+ errorLines = toPlainTextSync(viewEN.page()).split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts);
QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("This site can\xE2\x80\x99t be reached"));
// Reset error page
@@ -1236,7 +1236,7 @@ void tst_QWebEngineView::changeLocale()
QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpyDE.count(), 1, 20000);
QTRY_VERIFY(!toPlainTextSync(viewDE.page()).isEmpty());
- errorLines = toPlainTextSync(viewDE.page()).split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts);
+ errorLines = toPlainTextSync(viewDE.page()).split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts);
QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("Die Website ist nicht erreichbar"));
}
@@ -1472,7 +1472,7 @@ void tst_QWebEngineView::mouseClick()
QVERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty());
textInputCenter = elementCenter(view.page(), "input");
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, textInputCenter);
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, textInputCenter);
QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input"));
QCOMPARE(selectionChangedSpy.count(), 0);
QVERIFY(view.focusProxy()->inputMethodQuery(Qt::ImCurrentSelection).toString().isEmpty());
@@ -1493,7 +1493,7 @@ void tst_QWebEngineView::mouseClick()
QCOMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input"));
QCOMPARE(view.focusProxy()->inputMethodQuery(Qt::ImCurrentSelection).toString(), QStringLiteral("Company"));
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, textInputCenter);
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, textInputCenter);
QVERIFY(selectionChangedSpy.wait());
QCOMPARE(selectionChangedSpy.count(), 2);
QVERIFY(view.focusProxy()->inputMethodQuery(Qt::ImCurrentSelection).toString().isEmpty());
@@ -1514,7 +1514,7 @@ void tst_QWebEngineView::mouseClick()
QCOMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input"));
QCOMPARE(view.focusProxy()->inputMethodQuery(Qt::ImCurrentSelection).toString(), QStringLiteral("The Qt Company"));
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, textInputCenter);
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, textInputCenter);
QVERIFY(selectionChangedSpy.wait());
QCOMPARE(selectionChangedSpy.count(), 3);
QVERIFY(view.focusProxy()->inputMethodQuery(Qt::ImCurrentSelection).toString().isEmpty());
@@ -1709,7 +1709,7 @@ void tst_QWebEngineView::postData()
QStringList lines = QString::fromLocal8Bit(rawData).split("\r\n");
// examine request
- QStringList request = lines[0].split(" ", QString::SkipEmptyParts);
+ QStringList request = lines[0].split(" ", Qt::SkipEmptyParts);
bool requestOk = request.length() > 2
&& request[2].toUpper().startsWith("HTTP/")
&& request[0].toUpper() == "POST"
@@ -1991,7 +1991,7 @@ void tst_QWebEngineView::softwareInputPanel()
QVERIFY(loadFinishedSpy.wait());
QPoint textInputCenter = elementCenter(view.page(), "input1");
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, textInputCenter);
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, textInputCenter);
QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input1"));
// This part of the test checks if the SIP (Software Input Panel) is triggered,
@@ -2010,7 +2010,7 @@ void tst_QWebEngineView::softwareInputPanel()
QTRY_VERIFY(!testContext.isInputPanelVisible());
testContext.hideInputPanel();
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, textInputCenter);
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, textInputCenter);
QTRY_VERIFY(testContext.isInputPanelVisible());
view.setHtml("<html><body><p id='para'>nothing to input here</p></body></html>");
@@ -2018,7 +2018,7 @@ void tst_QWebEngineView::softwareInputPanel()
testContext.hideInputPanel();
QPoint paraCenter = elementCenter(view.page(), "para");
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, paraCenter);
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, paraCenter);
QVERIFY(!testContext.isInputPanelVisible());
@@ -2030,7 +2030,7 @@ void tst_QWebEngineView::softwareInputPanel()
QVERIFY(loadFinishedSpy.wait());
QPoint btnDivCenter = elementCenter(view.page(), "btnDiv");
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, btnDivCenter);
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, btnDivCenter);
QVERIFY(!testContext.isInputPanelVisible());
}
@@ -2055,7 +2055,7 @@ void tst_QWebEngineView::inputContextQueryInput()
// Set focus on an input field.
QPoint textInputCenter = elementCenter(view.page(), "input1");
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, textInputCenter);
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, textInputCenter);
QTRY_COMPARE(testContext.infos.count(), 2);
QCOMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input1"));
foreach (const InputMethodInfo &info, testContext.infos) {
@@ -2204,7 +2204,7 @@ void tst_QWebEngineView::inputMethods()
QTRY_COMPARE(loadFinishedSpy.size(), 1);
QPoint textInputCenter = elementCenter(view.page(), "input1");
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, textInputCenter);
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, textInputCenter);
QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input1"));
// ImCursorRectangle
@@ -2305,7 +2305,7 @@ void tst_QWebEngineView::textSelectionInInputField()
// LEFT to RIGHT selection
// Mouse click event moves the current cursor to the end of the text
QPoint textInputCenter = elementCenter(view.page(), "input1");
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, textInputCenter);
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, textInputCenter);
QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input1"));
QTRY_COMPARE(view.focusProxy()->inputMethodQuery(Qt::ImCursorPosition).toInt(), 11);
QTRY_COMPARE(view.focusProxy()->inputMethodQuery(Qt::ImAnchorPosition).toInt(), 11);
@@ -2347,7 +2347,7 @@ void tst_QWebEngineView::textSelectionInInputField()
// RIGHT to LEFT selection
// Deselect the selection (this moves the current cursor to the end of the text)
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, textInputCenter);
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, textInputCenter);
QVERIFY(selectionChangedSpy.wait());
QCOMPARE(selectionChangedSpy.count(), 2);
@@ -2387,7 +2387,7 @@ void tst_QWebEngineView::textSelectionOutOfInputField()
QVERIFY(view.page()->selectedText().isEmpty());
// Simple click should not update text selection, however it updates selection bounds in Chromium
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, view.geometry().center());
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, view.geometry().center());
QCOMPARE(selectionChangedSpy.count(), 0);
QVERIFY(!view.hasSelection());
QVERIFY(view.page()->selectedText().isEmpty());
@@ -2400,7 +2400,7 @@ void tst_QWebEngineView::textSelectionOutOfInputField()
QCOMPARE(view.page()->selectedText(), QString("This is a text"));
// Deselect text by mouse click
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, view.geometry().center());
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, view.geometry().center());
QVERIFY(selectionChangedSpy.wait());
QCOMPARE(selectionChangedSpy.count(), 2);
QVERIFY(!view.hasSelection());
@@ -2447,7 +2447,7 @@ void tst_QWebEngineView::textSelectionOutOfInputField()
// Remove selection by clicking into an input field
QPoint textInputCenter = elementCenter(view.page(), "input1");
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, textInputCenter);
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, textInputCenter);
QVERIFY(selectionChangedSpy.wait());
QCOMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input1"));
QCOMPARE(selectionChangedSpy.count(), 2);
@@ -2462,7 +2462,7 @@ void tst_QWebEngineView::textSelectionOutOfInputField()
QCOMPARE(view.page()->selectedText(), QString("QtWebEngine"));
// Deselect input field's text by mouse click
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, view.geometry().center());
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, view.geometry().center());
QVERIFY(selectionChangedSpy.wait());
QCOMPARE(selectionChangedSpy.count(), 4);
QVERIFY(!view.hasSelection());
@@ -2483,14 +2483,14 @@ void tst_QWebEngineView::hiddenText()
QVERIFY(loadFinishedSpy.wait());
QPoint passwordInputCenter = elementCenter(view.page(), "password1");
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, passwordInputCenter);
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, passwordInputCenter);
QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("password1"));
QVERIFY(!view.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled));
QVERIFY(view.focusProxy()->inputMethodHints() & Qt::ImhHiddenText);
QPoint textInputCenter = elementCenter(view.page(), "input1");
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, textInputCenter);
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, textInputCenter);
QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input1"));
QVERIFY(!(view.focusProxy()->inputMethodHints() & Qt::ImhHiddenText));
}
@@ -3108,7 +3108,7 @@ void tst_QWebEngineView::globalMouseSelection()
// Deselect the selection (this moves the current cursor to the end of the text)
QPoint textInputCenter = elementCenter(view.page(), "input1");
- QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, textInputCenter);
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, textInputCenter);
QVERIFY(selectionChangedSpy.wait());
QCOMPARE(selectionChangedSpy.count(), 2);
QVERIFY(QApplication::clipboard()->text(QClipboard::Selection).isEmpty());
@@ -3149,36 +3149,55 @@ void tst_QWebEngineView::noContextMenu()
void tst_QWebEngineView::contextMenu_data()
{
QTest::addColumn<int>("childrenCount");
+ QTest::addColumn<bool>("isCustomMenu");
QTest::addColumn<Qt::ContextMenuPolicy>("contextMenuPolicy");
- QTest::newRow("defaultContextMenu") << 1 << Qt::DefaultContextMenu;
- QTest::newRow("customContextMenu") << 1 << Qt::CustomContextMenu;
- QTest::newRow("preventContextMenu") << 0 << Qt::PreventContextMenu;
+ QTest::newRow("defaultContextMenu") << 1 << false << Qt::DefaultContextMenu;
+ QTest::newRow("customContextMenu") << 1 << true << Qt::CustomContextMenu;
+ QTest::newRow("preventContextMenu") << 0 << false << Qt::PreventContextMenu;
}
void tst_QWebEngineView::contextMenu()
{
QFETCH(int, childrenCount);
+ QFETCH(bool, isCustomMenu);
QFETCH(Qt::ContextMenuPolicy, contextMenuPolicy);
QWebEngineView view;
+ QMenu *customMenu = nullptr;
if (contextMenuPolicy == Qt::CustomContextMenu) {
- connect(&view, &QWebEngineView::customContextMenuRequested, [&view](const QPoint &pt) {
- QMenu* menu = new QMenu(&view);
- menu->addAction("Action1");
- menu->addAction("Action2");
- menu->popup(pt);
+ connect(&view, &QWebEngineView::customContextMenuRequested, [&view, &customMenu] (const QPoint &pt) {
+ Q_ASSERT(!customMenu);
+ customMenu = new QMenu(&view);
+ customMenu->addAction("Action1");
+ customMenu->addAction("Action2");
+ customMenu->popup(pt);
});
}
view.setContextMenuPolicy(contextMenuPolicy);
+
+ // input is supposed to be skipped before first real navigation in >= 79
+ QSignalSpy loadSpy(&view, &QWebEngineView::loadFinished);
+ view.load(QUrl("about:blank"));
view.resize(640, 480);
view.show();
+ QTRY_COMPARE(loadSpy.count(), 1);
QVERIFY(view.findChildren<QMenu *>().isEmpty());
QTest::mouseMove(view.windowHandle(), QPoint(10,10));
QTest::mouseClick(view.windowHandle(), Qt::RightButton);
- QTRY_COMPARE(view.findChildren<QMenu *>().count(), childrenCount);
+
+ // verify for zero children will always succeed, so should be tested with at least minor timeout
+ if (childrenCount <= 0) {
+ QVERIFY(!QTest::qWaitFor([&view] () { return view.findChildren<QMenu *>().count() > 0; }, 500));
+ } else {
+ QTRY_COMPARE(view.findChildren<QMenu *>().count(), childrenCount);
+ if (isCustomMenu) {
+ QCOMPARE(view.findChildren<QMenu *>().first(), customMenu);
+ }
+ }
+ QCOMPARE(!!customMenu, isCustomMenu);
}
void tst_QWebEngineView::mouseLeave()
diff --git a/tests/auto/widgets/schemes/tst_schemes.cpp b/tests/auto/widgets/schemes/tst_schemes.cpp
index 1b6093571..a4a0e34ff 100644
--- a/tests/auto/widgets/schemes/tst_schemes.cpp
+++ b/tests/auto/widgets/schemes/tst_schemes.cpp
@@ -38,6 +38,7 @@ class tst_Schemes : public QObject
Q_OBJECT
private Q_SLOTS:
+ void unknownUrlSchemePolicy_data();
void unknownUrlSchemePolicy();
};
@@ -58,8 +59,27 @@ public:
}
};
+Q_DECLARE_METATYPE(QWebEngineSettings::UnknownUrlSchemePolicy)
+
+void tst_Schemes::unknownUrlSchemePolicy_data()
+{
+ QTest::addColumn<QWebEngineSettings::UnknownUrlSchemePolicy>("policy");
+ QTest::addColumn<bool>("userAction");
+ QTest::newRow("DisallowUnknownUrlSchemes, script") << QWebEngineSettings::DisallowUnknownUrlSchemes << false;
+ QTest::newRow("DisallowUnknownUrlSchemes, user") << QWebEngineSettings::DisallowUnknownUrlSchemes << true;
+ QTest::newRow("AllowUnknownUrlSchemesFromUserInteraction, script") << QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction << false;
+ QTest::newRow("AllowUnknownUrlSchemesFromUserInteraction, user") << QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction << true;
+ QTest::newRow("AllowAllUnknownUrlSchemes, script") << QWebEngineSettings::AllowAllUnknownUrlSchemes << false;
+ QTest::newRow("AllowAllUnknownUrlSchemes, user") << QWebEngineSettings::AllowAllUnknownUrlSchemes << true;
+ QTest::newRow("default UnknownUrlSchemePolicy, script") << QWebEngineSettings::UnknownUrlSchemePolicy(0) << false;
+ QTest::newRow("default UnknownUrlSchemePolicy, user") << QWebEngineSettings::UnknownUrlSchemePolicy(0) << true;
+}
+
void tst_Schemes::unknownUrlSchemePolicy()
{
+ QFETCH(QWebEngineSettings::UnknownUrlSchemePolicy, policy);
+ QFETCH(bool, userAction);
+
QWebEngineView view;
AcceptNavigationRequestHandler page;
QSignalSpy loadFinishedSpy(&page, &QWebEnginePage::loadFinished);
@@ -71,41 +91,31 @@ void tst_Schemes::unknownUrlSchemePolicy()
settings->setAttribute(QWebEngineSettings::ErrorPageEnabled, true);
settings->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, true);
- QWebEngineSettings::UnknownUrlSchemePolicy policies[6] = {QWebEngineSettings::DisallowUnknownUrlSchemes,
- QWebEngineSettings::DisallowUnknownUrlSchemes,
- QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction,
- QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction,
- QWebEngineSettings::AllowAllUnknownUrlSchemes,
- QWebEngineSettings::AllowAllUnknownUrlSchemes};
- // even iterations are for navigation-requests from javascript,
- // odd iterations are for navigations-requests from user-interaction
- for (int i = 0; i < 8; i++) {
- if (i <= 5)
- settings->setUnknownUrlSchemePolicy(policies[i]);
- else
- settings->resetUnknownUrlSchemePolicy();
- loadFinishedSpy.clear();
- page.acceptNavigationRequestCalls = 0;
- bool shouldAccept;
-
- if (i % 2 == 0) { // navigation request coming from javascript
- shouldAccept = (4 <= i && i <= 5); // only case AllowAllUnknownUrlSchemes
- view.setHtml("<html><script>setTimeout(function(){ window.location.href='nonexistentscheme://somewhere'; }, 10);</script><body>testing...</body></html>");
- } else { // navigation request coming from user interaction
- shouldAccept = (2 <= i); // all cases except DisallowUnknownUrlSchemes
- view.setHtml("<html><body><a id='nonexlink' href='nonexistentscheme://somewhere'>nonexistentscheme://somewhere</a></body></html>");
- QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.size(), 1, 15000);
- // focus and trigger the link
- view.page()->runJavaScript("document.getElementById('nonexlink').focus();", [&view](const QVariant &result) {
- Q_UNUSED(result);
- QTest::sendKeyEvent(QTest::Press, view.focusProxy(), Qt::Key_Return, QString("\r"), Qt::NoModifier);
- QTest::sendKeyEvent(QTest::Release, view.focusProxy(), Qt::Key_Return, QString("\r"), Qt::NoModifier);
- });
- }
+ if (policy > 0)
+ settings->setUnknownUrlSchemePolicy(policy);
+ else
+ settings->resetUnknownUrlSchemePolicy();
+ loadFinishedSpy.clear();
+ page.acceptNavigationRequestCalls = 0;
+ bool shouldAccept;
- QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.size(), 2, 60000);
- QCOMPARE(page.acceptNavigationRequestCalls, shouldAccept ? 1 : 0);
+ if (!userAction) { // navigation request coming from javascript
+ shouldAccept = (policy == QWebEngineSettings::AllowAllUnknownUrlSchemes);
+ view.setHtml("<html><script>setTimeout(function(){ window.location.href='nonexistentscheme://somewhere'; }, 10);</script><body>testing...</body></html>");
+ } else { // navigation request coming from user interaction
+ shouldAccept = (policy != QWebEngineSettings::DisallowUnknownUrlSchemes);
+ view.setHtml("<html><body><a id='nonexlink' href='nonexistentscheme://somewhere'>nonexistentscheme://somewhere</a></body></html>");
+ QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.size(), 1, 15000);
+ // focus and trigger the link
+ view.page()->runJavaScript("document.getElementById('nonexlink').focus();", [&view](const QVariant &result) {
+ Q_UNUSED(result);
+ QTest::sendKeyEvent(QTest::Press, view.focusProxy(), Qt::Key_Return, QString("\r"), Qt::NoModifier);
+ QTest::sendKeyEvent(QTest::Release, view.focusProxy(), Qt::Key_Return, QString("\r"), Qt::NoModifier);
+ });
}
+
+ QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.size(), 2, 60000);
+ QCOMPARE(page.acceptNavigationRequestCalls, shouldAccept ? 1 : 0);
}
QTEST_MAIN(tst_Schemes)
diff --git a/tests/auto/widgets/spellchecking/tst_spellchecking.cpp b/tests/auto/widgets/spellchecking/tst_spellchecking.cpp
index 64df05d89..801e2a76c 100644
--- a/tests/auto/widgets/spellchecking/tst_spellchecking.cpp
+++ b/tests/auto/widgets/spellchecking/tst_spellchecking.cpp
@@ -41,10 +41,10 @@ public:
void activateMenu(QWidget *widget, const QPoint &position)
{
QTest::mouseMove(widget, position);
- QTest::mousePress(widget, Qt::RightButton, 0, position);
+ QTest::mousePress(widget, Qt::RightButton, {}, position);
QContextMenuEvent evcont(QContextMenuEvent::Mouse, position, mapToGlobal(position));
event(&evcont);
- QTest::mouseRelease(widget, Qt::RightButton, 0, position);
+ QTest::mouseRelease(widget, Qt::RightButton, {}, position);
}
const QWebEngineContextMenuData& data()
@@ -175,8 +175,8 @@ void tst_Spellchecking::spellcheck()
//type text, spellchecker needs time
QTest::mouseMove(m_view->focusWidget(), QPoint(20,20));
- QTest::mousePress(m_view->focusWidget(), Qt::LeftButton, 0, QPoint(20,20));
- QTest::mouseRelease(m_view->focusWidget(), Qt::LeftButton, 0, QPoint(20,20));
+ QTest::mousePress(m_view->focusWidget(), Qt::LeftButton, {}, QPoint(20,20));
+ QTest::mouseRelease(m_view->focusWidget(), Qt::LeftButton, {}, QPoint(20,20));
QString text("I lowe Qt ....");
for (int i = 0; i < text.length(); i++) {
QTest::keyClicks(m_view->focusWidget(), text.at(i));
diff --git a/tests/auto/widgets/util.h b/tests/auto/widgets/util.h
index eba974f33..20241be8b 100644
--- a/tests/auto/widgets/util.h
+++ b/tests/auto/widgets/util.h
@@ -132,7 +132,7 @@ static inline QString toHtmlSync(QWebEnginePage *page)
static inline bool findTextSync(QWebEnginePage *page, const QString &subString)
{
CallbackSpy<bool> spy;
- page->findText(subString, 0, spy.ref());
+ page->findText(subString, {}, spy.ref());
return spy.waitForResult();
}
diff --git a/tests/manual/quick/pdf/listview.qml b/tests/manual/quick/pdf/listview.qml
new file mode 100644
index 000000000..361ae7d89
--- /dev/null
+++ b/tests/manual/quick/pdf/listview.qml
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.14
+import QtQuick.Window 2.14
+import QtQuick.Pdf 5.15
+
+Window {
+ width: 600
+ height: 440
+ color: "lightgrey"
+ title: doc.source
+ visible: true
+
+ PdfDocument {
+ id: doc
+ source: "test.pdf"
+ }
+
+ ListView {
+ id: listView
+ anchors.fill: parent
+ model: doc.pageCount
+ spacing: 6
+ delegate: Column {
+ Rectangle {
+ id: paper
+ width: image.width
+ height: image.height
+ Image {
+ id: image
+ objectName: "PDF page " + index
+ source: doc.source
+ currentFrame: index
+ asynchronous: true
+ }
+ }
+ Text {
+ text: "Page " + (image.currentFrame + 1)
+ }
+ }
+ }
+
+ Text {
+ anchors.bottom: parent.bottom
+ anchors.right: parent.right
+ text: "page " + Math.max(1, (listView.indexAt(0, listView.contentY) + 1)) + " of " + doc.pageCount
+ }
+}
diff --git a/tests/manual/quick/pdf/pessimizedListView.qml b/tests/manual/quick/pdf/pessimizedListView.qml
new file mode 100644
index 000000000..4ae0edabe
--- /dev/null
+++ b/tests/manual/quick/pdf/pessimizedListView.qml
@@ -0,0 +1,174 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.14
+import QtQuick.Controls 2.14
+import QtQuick.Layouts 1.14
+import QtQuick.Pdf 5.15
+import Qt.labs.platform 1.1 as P
+
+ApplicationWindow {
+ width: 900
+ height: 1000
+ color: "lightgrey"
+ title: doc.source + " scale " + imageScale.toFixed(2)
+ visible: true
+ property real imageScale: 1
+
+ header: ToolBar {
+ RowLayout {
+ anchors.fill: parent
+ anchors.rightMargin: 6
+ ToolButton {
+ action: Action {
+ text: "🗁"
+ shortcut: StandardKey.Open
+ onTriggered: fileDialog.open()
+ }
+ }
+ ToolButton {
+ action: Action {
+ text: "⊕"
+ shortcut: StandardKey.ZoomIn
+ onTriggered: imageScale *= Math.sqrt(2)
+ }
+ }
+ ToolButton {
+ action: Action {
+ text: "⊖"
+ shortcut: StandardKey.ZoomOut
+ onTriggered: imageScale /= Math.sqrt(2)
+ }
+ }
+ ToolButton {
+ action: Action {
+ text: "1x"
+ shortcut: "Ctrl+0"
+ onTriggered: imageScale = 1
+ }
+ }
+
+ Label {
+ text: "Pixels/point:"
+ }
+ SpinBox {
+ id: oversamplingSB
+ from: 1; to: 8; value: 4
+ }
+
+ Label {
+ text: "cacheBuffer:"
+ }
+ SpinBox {
+ id: cacheBufferSB
+ from: 0; to: 1000; stepSize: 50; value: 100
+ }
+
+ CheckBox {
+ id: asyncCB
+ text: "async"
+ }
+
+ CheckBox {
+ id: cacheCB
+ text: "cache"
+ }
+ }
+ }
+
+ PdfDocument {
+ id: doc
+ source: "test.pdf"
+ }
+
+ P.FileDialog {
+ id: fileDialog
+ title: "Open a PDF file"
+ nameFilters: [ "PDF files (*.pdf)" ]
+ onAccepted: doc.source = file
+ }
+
+ ListView {
+ id: listView
+ anchors.fill: parent
+ anchors.margins: 10
+ model: doc.pageCount
+ spacing: 6
+ cacheBuffer: cacheBufferSB.value
+ ScrollBar.vertical: ScrollBar { }
+ delegate: Rectangle {
+ id: paper
+ width: Math.max(60, image.width) * imageScale
+ height: 100 * imageScale
+ BusyIndicator {
+ anchors.centerIn: parent
+ running: image.status === Image.Loading
+ }
+ Image {
+ id: image
+ scale: imageScale
+ anchors.centerIn: parent
+ sourceSize.width: doc.pagePointSize(index).width * oversamplingSB.value
+ height: 100
+ fillMode: Image.PreserveAspectFit
+ objectName: "PDF page " + index
+ source: doc.source
+ currentFrame: index
+ asynchronous: asyncCB.checked
+ cache: cacheCB.checked
+ }
+ }
+ }
+
+ Text {
+ anchors.bottom: parent.bottom
+ anchors.right: parent.right
+ text: "page " + Math.max(1, (listView.indexAt(0, listView.contentY) + 1)) + " of " + doc.pageCount
+ }
+}
diff --git a/tests/manual/quick/pdf/simplest.qml b/tests/manual/quick/pdf/simplest.qml
new file mode 100644
index 000000000..0571493af
--- /dev/null
+++ b/tests/manual/quick/pdf/simplest.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.14
+
+Image {
+ id: image
+ source: "test.pdf"
+ fillMode: Image.PreserveAspectFit
+ Shortcut {
+ sequence: StandardKey.MoveToNextPage
+ enabled: image.currentFrame < image.frameCount - 1
+ onActivated: image.currentFrame++
+ }
+ Shortcut {
+ sequence: StandardKey.MoveToPreviousPage
+ enabled: image.currentFrame > 0
+ onActivated: image.currentFrame--
+ }
+}
diff --git a/tests/manual/quick/pdf/test.pdf b/tests/manual/quick/pdf/test.pdf
new file mode 100644
index 000000000..a9dc1bc29
--- /dev/null
+++ b/tests/manual/quick/pdf/test.pdf
Binary files differ
diff --git a/tests/manual/quick/pdf/withdoc.qml b/tests/manual/quick/pdf/withdoc.qml
new file mode 100644
index 000000000..2d82a6abf
--- /dev/null
+++ b/tests/manual/quick/pdf/withdoc.qml
@@ -0,0 +1,206 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.14
+import QtQuick.Controls 2.14
+import Qt.labs.platform 1.1 as Platform
+import QtQuick.Pdf 5.15
+import QtQuick.Shapes 1.14
+import QtQuick.Window 2.14
+
+Window {
+ width: 800
+ height: 940
+ color: "lightgrey"
+ title: doc.source
+ visible: true
+
+ PdfDocument {
+ id: doc
+ source: "test.pdf"
+ }
+
+ Platform.FileDialog {
+ id: fileDialog
+ title: "Open a PDF file"
+ nameFilters: [ "PDF files (*.pdf)" ]
+ onAccepted: doc.source = file
+ }
+
+ PdfSelection {
+ id: selection
+ document: doc
+ page: image.currentFrame
+ fromPoint: dragHandler.centroid.pressPosition
+ toPoint: dragHandler.centroid.position
+ hold: !dragHandler.active
+ }
+
+ Column {
+ id: column
+ anchors.fill: parent
+ anchors.margins: 6
+ spacing: 6
+ Text { text: "title: " + doc.title; visible: doc.title !== "" }
+ Text { text: "author: " + doc.author; visible: doc.author !== "" }
+ Text { text: "subject: " + doc.subject; visible: doc.subject !== "" }
+ Text { text: "keywords: " + doc.keywords; visible: doc.keywords !== "" }
+ Text { text: "producer: " + doc.producer; visible: doc.producer !== "" }
+ Text { text: "creator: " + doc.creator; visible: doc.creator !== "" }
+ Text { text: "creationDate: " + doc.creationDate; visible: doc.creationDate !== "" }
+ Text { text: "modificationDate: " + doc.modificationDate; visible: doc.modificationDate !== "" }
+ Text { text: "implicit size: " + image.implicitWidth + "x" + image.implicitHeight }
+ Text { text: "source size: " + image.sourceSize.width + "x" + image.sourceSize.height }
+ Text { text: "painted size: " + image.paintedWidth + "x" + image.paintedHeight }
+
+ Flickable {
+ width: column.width
+ height: width
+ contentWidth: paper.width
+ contentHeight: paper.height
+ z: -1
+ Rectangle {
+ id: paper
+ width: image.width
+ height: image.height
+ Image {
+ id: image
+ source: doc.status === PdfDocument.Ready ? doc.source : ""
+
+ property real zoomFactor: Math.sqrt(2)
+
+ DragHandler {
+ id: dragHandler
+ target: null
+ }
+
+ Shortcut {
+ sequence: StandardKey.MoveToNextPage
+ enabled: image.currentFrame < image.frameCount - 1
+ onActivated: image.currentFrame++
+ }
+ Shortcut {
+ sequence: StandardKey.MoveToPreviousPage
+ enabled: image.currentFrame > 0
+ onActivated: image.currentFrame--
+ }
+ Shortcut {
+ sequence: StandardKey.ZoomIn
+ enabled: image.sourceSize.width < 5000
+ onActivated: {
+ image.sourceSize.width = image.implicitWidth * image.zoomFactor
+ image.sourceSize.height = image.implicitHeight * image.zoomFactor
+ }
+ }
+ Shortcut {
+ sequence: StandardKey.ZoomOut
+ enabled: image.width > 50
+ onActivated: {
+ image.sourceSize.width = image.implicitWidth / image.zoomFactor
+ image.sourceSize.height = image.implicitHeight / image.zoomFactor
+ }
+ }
+ Shortcut {
+ sequence: "Ctrl+0"
+ onActivated: image.sourceSize = undefined
+ }
+ Shortcut {
+ sequence: StandardKey.Open
+ onActivated: fileDialog.open()
+ }
+ Shortcut {
+ sequence: StandardKey.Quit
+ onActivated: Qt.quit()
+ }
+ }
+
+ Shape {
+ anchors.fill: parent
+ opacity: 0.25
+ ShapePath {
+ fillColor: "cyan"
+ PathMultiline {
+ id: selectionBoundaries
+ paths: selection.geometry
+ }
+ }
+ }
+
+ Repeater {
+ model: PdfLinkModel {
+ id: linkModel
+ document: doc
+ page: image.currentFrame
+ }
+ delegate: Rectangle {
+ color: "transparent"
+ border.color: "lightgrey"
+ x: rect.x
+ y: rect.y
+ width: rect.width
+ height: rect.height
+// HoverHandler { cursorShape: Qt.PointingHandCursor } // 5.15 onward (QTBUG-68073)
+ TapHandler {
+ onTapped: {
+ if (page >= 0)
+ image.currentFrame = page
+ else
+ Qt.openUrlExternally(url)
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ Text {
+ anchors.bottom: parent.bottom
+ text: "page " + (image.currentFrame + 1) + " of " + doc.pageCount
+ }
+}