diff options
Diffstat (limited to 'tests/auto/pdf')
-rw-r--r-- | tests/auto/pdf/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/auto/pdf/qpdfbookmarkmodel/tst_qpdfbookmarkmodel.cpp | 159 | ||||
-rw-r--r-- | tests/auto/pdf/qpdfdocument/BLACKLIST | 6 | ||||
-rw-r--r-- | tests/auto/pdf/qpdfdocument/test.pdf | bin | 0 -> 76633 bytes | |||
-rw-r--r-- | tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp | 161 | ||||
-rw-r--r-- | tests/auto/pdf/qpdfpagenavigation/CMakeLists.txt | 8 | ||||
-rw-r--r-- | tests/auto/pdf/qpdfpagenavigation/pdf-sample.pagenavigation.pdf | bin | 27523 -> 0 bytes | |||
-rw-r--r-- | tests/auto/pdf/qpdfpagenavigation/tst_qpdfpagenavigation.cpp | 203 | ||||
-rw-r--r-- | tests/auto/pdf/qpdfpagerenderer/tst_qpdfpagerenderer.cpp | 46 | ||||
-rw-r--r-- | tests/auto/pdf/qpdfsearchmodel/test.pdf | bin | 80045 -> 76633 bytes | |||
-rw-r--r-- | tests/auto/pdf/qpdfsearchmodel/tst_qpdfsearchmodel.cpp | 40 |
11 files changed, 119 insertions, 506 deletions
diff --git a/tests/auto/pdf/CMakeLists.txt b/tests/auto/pdf/CMakeLists.txt index 1220581ca..e2ba73c6e 100644 --- a/tests/auto/pdf/CMakeLists.txt +++ b/tests/auto/pdf/CMakeLists.txt @@ -1,5 +1,5 @@ add_subdirectory(qpdfbookmarkmodel) -add_subdirectory(qpdfpagenavigation) +#add_subdirectory(qpdfpagenavigator) add_subdirectory(qpdfpagerenderer) if(TARGET Qt::PrintSupport) add_subdirectory(qpdfdocument) diff --git a/tests/auto/pdf/qpdfbookmarkmodel/tst_qpdfbookmarkmodel.cpp b/tests/auto/pdf/qpdfbookmarkmodel/tst_qpdfbookmarkmodel.cpp index 72d2383f1..e3b778396 100644 --- a/tests/auto/pdf/qpdfbookmarkmodel/tst_qpdfbookmarkmodel.cpp +++ b/tests/auto/pdf/qpdfbookmarkmodel/tst_qpdfbookmarkmodel.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU 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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QtTest/QtTest> @@ -60,8 +24,8 @@ private slots: void setLoadedDocument(); void unloadDocument(); void testTreeStructure(); - void testListStructure(); void testPageNumberRole(); + void testLocationAndZoomRoles(); }; void tst_QPdfBookmarkModel::emptyModel() @@ -69,7 +33,6 @@ 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); @@ -83,7 +46,6 @@ void tst_QPdfBookmarkModel::setEmptyDocument() 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); @@ -99,7 +61,7 @@ void tst_QPdfBookmarkModel::setEmptyDocumentAndLoad() QSignalSpy modelAboutToBeResetSpy(&model, SIGNAL(modelAboutToBeReset())); QSignalSpy modelResetSpy(&model, SIGNAL(modelReset())); - QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks.pdf")), QPdfDocument::NoError); + QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks.pdf")), QPdfDocument::Error::None); QCOMPARE(modelAboutToBeResetSpy.count(), 1); QCOMPARE(modelResetSpy.count(), 1); @@ -110,7 +72,7 @@ void tst_QPdfBookmarkModel::setEmptyDocumentAndLoad() void tst_QPdfBookmarkModel::setLoadedDocument() { QPdfDocument document; - QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks.pdf")), QPdfDocument::NoError); + QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks.pdf")), QPdfDocument::Error::None); QPdfBookmarkModel model; @@ -128,7 +90,7 @@ void tst_QPdfBookmarkModel::setLoadedDocument() void tst_QPdfBookmarkModel::unloadDocument() { QPdfDocument document; - QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks.pdf")), QPdfDocument::NoError); + QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks.pdf")), QPdfDocument::Error::None); QPdfBookmarkModel model; model.setDocument(&document); @@ -149,7 +111,7 @@ void tst_QPdfBookmarkModel::unloadDocument() void tst_QPdfBookmarkModel::testTreeStructure() { QPdfDocument document; - QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks.pdf")), QPdfDocument::NoError); + QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks.pdf")), QPdfDocument::Error::None); QPdfBookmarkModel model; model.setDocument(&document); @@ -157,115 +119,76 @@ void tst_QPdfBookmarkModel::testTreeStructure() 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(index1.data(int(QPdfBookmarkModel::Role::Title)).toString(), QLatin1String("Section 1")); + QCOMPARE(index1.data(int(QPdfBookmarkModel::Role::Level)).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(index1_1.data(int(QPdfBookmarkModel::Role::Title)).toString(), QLatin1String("Section 1.1")); + QCOMPARE(index1_1.data(int(QPdfBookmarkModel::Role::Level)).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(index1_2.data(int(QPdfBookmarkModel::Role::Title)).toString(), QLatin1String("Section 1.2")); + QCOMPARE(index1_2.data(int(QPdfBookmarkModel::Role::Level)).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(index2.data(int(QPdfBookmarkModel::Role::Title)).toString(), QLatin1String("Section 2")); + QCOMPARE(index2.data(int(QPdfBookmarkModel::Role::Level)).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(index2_1.data(int(QPdfBookmarkModel::Role::Title)).toString(), QLatin1String("Section 2.1")); + QCOMPARE(index2_1.data(int(QPdfBookmarkModel::Role::Level)).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(index2_1_1.data(int(QPdfBookmarkModel::Role::Title)).toString(), QLatin1String("Section 2.1.1")); + QCOMPARE(index2_1_1.data(int(QPdfBookmarkModel::Role::Level)).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(index2_2.data(int(QPdfBookmarkModel::Role::Title)).toString(), QLatin1String("Section 2.2")); + QCOMPARE(index2_2.data(int(QPdfBookmarkModel::Role::Level)).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(index3.data(int(QPdfBookmarkModel::Role::Title)).toString(), QLatin1String("Section 3")); + QCOMPARE(index3.data(int(QPdfBookmarkModel::Role::Level)).toInt(), 0); QCOMPARE(model.rowCount(index3), 0); const QModelIndex index4 = model.index(3, 0); QCOMPARE(index4, QModelIndex()); } -void tst_QPdfBookmarkModel::testListStructure() +void tst_QPdfBookmarkModel::testPageNumberRole() { QPdfDocument document; - QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks.pdf")), QPdfDocument::NoError); + QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks_pages.pdf")), QPdfDocument::Error::None); 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); + 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), 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); + QCOMPARE(index1.data(int(QPdfBookmarkModel::Role::Page)).toInt(), 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 index2 = model.index(1, 0); + QCOMPARE(index2.data(int(QPdfBookmarkModel::Role::Page)).toInt(), 1); - 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 index2_1 = model.index(0, 0, index2); + QCOMPARE(index2_1.data(int(QPdfBookmarkModel::Role::Page)).toInt(), 1); - const QModelIndex index4 = model.index(8, 0); - QCOMPARE(index4, QModelIndex()); + const QModelIndex index3 = model.index(2, 0); + QCOMPARE(index3.data(int(QPdfBookmarkModel::Role::Page)).toInt(), 2); } -void tst_QPdfBookmarkModel::testPageNumberRole() +void tst_QPdfBookmarkModel::testLocationAndZoomRoles() { QPdfDocument document; - QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks_pages.pdf")), QPdfDocument::NoError); + QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.bookmarks_pages.pdf")), QPdfDocument::Error::None); QPdfBookmarkModel model; model.setDocument(&document); @@ -273,16 +196,20 @@ void tst_QPdfBookmarkModel::testPageNumberRole() QCOMPARE(model.rowCount(), 3); const QModelIndex index1 = model.index(0, 0); - QCOMPARE(index1.data(QPdfBookmarkModel::PageNumberRole).toInt(), 0); + QCOMPARE(index1.data(int(QPdfBookmarkModel::Role::Location)).toPoint(), QPoint(57, 69)); + QCOMPARE(index1.data(int(QPdfBookmarkModel::Role::Zoom)).toInt(), 0); const QModelIndex index2 = model.index(1, 0); - QCOMPARE(index2.data(QPdfBookmarkModel::PageNumberRole).toInt(), 1); + QCOMPARE(index2.data(int(QPdfBookmarkModel::Role::Location)).toPoint(), QPoint(57, 57)); + QCOMPARE(index2.data(int(QPdfBookmarkModel::Role::Zoom)).toInt(), 0); const QModelIndex index2_1 = model.index(0, 0, index2); - QCOMPARE(index2_1.data(QPdfBookmarkModel::PageNumberRole).toInt(), 1); + QCOMPARE(index2_1.data(int(QPdfBookmarkModel::Role::Location)).toPoint(), QPoint(57, 526)); + QCOMPARE(index2_1.data(int(QPdfBookmarkModel::Role::Zoom)).toInt(), 0); const QModelIndex index3 = model.index(2, 0); - QCOMPARE(index3.data(QPdfBookmarkModel::PageNumberRole).toInt(), 2); + QCOMPARE(index3.data(int(QPdfBookmarkModel::Role::Location)).toPoint(), QPoint(57, 402)); + QCOMPARE(index3.data(int(QPdfBookmarkModel::Role::Zoom)).toInt(), 0); } QTEST_MAIN(tst_QPdfBookmarkModel) diff --git a/tests/auto/pdf/qpdfdocument/BLACKLIST b/tests/auto/pdf/qpdfdocument/BLACKLIST deleted file mode 100644 index b8db556d6..000000000 --- a/tests/auto/pdf/qpdfdocument/BLACKLIST +++ /dev/null @@ -1,6 +0,0 @@ -[password] -* - -[passwordClearedOnClose] -* - diff --git a/tests/auto/pdf/qpdfdocument/test.pdf b/tests/auto/pdf/qpdfdocument/test.pdf Binary files differnew file mode 100644 index 000000000..0832dfbed --- /dev/null +++ b/tests/auto/pdf/qpdfdocument/test.pdf diff --git a/tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp b/tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp index a0f73bb88..975708f65 100644 --- a/tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp +++ b/tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU 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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QtTest/QtTest> @@ -69,6 +33,7 @@ private slots: void status(); void passwordClearedOnClose(); void metaData(); + void pageLabels(); private: void consistencyCheck(QPdfDocument &doc) const; @@ -89,7 +54,7 @@ struct TemporaryPdf: public QTemporaryFile }; -TemporaryPdf::TemporaryPdf() +TemporaryPdf::TemporaryPdf():QTemporaryFile(QStringLiteral("qpdfdocument")) { open(); pageLayout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF()); @@ -119,12 +84,12 @@ void tst_QPdfDocument::pageCount() QSignalSpy pageCountChangedSpy(&doc, SIGNAL(pageCountChanged(int))); QCOMPARE(doc.pageCount(), 0); - QCOMPARE(doc.load(tempPdf.fileName()), QPdfDocument::NoError); + QCOMPARE(doc.load(tempPdf.fileName()), QPdfDocument::Error::None); QCOMPARE(doc.pageCount(), 2); QCOMPARE(pageCountChangedSpy.count(), 1); QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount()); - QCOMPARE(doc.pageSize(0).toSize(), tempPdf.pageLayout.fullRectPoints().size()); + QCOMPARE(doc.pagePointSize(0).toSize(), tempPdf.pageLayout.fullRectPoints().size()); } void tst_QPdfDocument::loadFromIODevice() @@ -135,9 +100,9 @@ void tst_QPdfDocument::loadFromIODevice() 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(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Loading); + QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Ready); + QCOMPARE(doc.error(), QPdfDocument::Error::None); QCOMPARE(doc.pageCount(), 2); QCOMPARE(pageCountChangedSpy.count(), 1); QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount()); @@ -172,8 +137,8 @@ void tst_QPdfDocument::loadAsync() 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(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Loading); + QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Ready); QCOMPARE(doc.pageCount(), 2); QCOMPARE(pageCountChangedSpy.count(), 1); QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount()); @@ -187,15 +152,15 @@ void tst_QPdfDocument::password() QSignalSpy passwordChangedSpy(&doc, SIGNAL(passwordChanged())); QCOMPARE(doc.pageCount(), 0); - QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.protected.pdf")), QPdfDocument::IncorrectPasswordError); + QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.protected.pdf")), QPdfDocument::Error::IncorrectPassword); 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); + QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.protected.pdf")), QPdfDocument::Error::IncorrectPassword); + QCOMPARE(doc.status(), QPdfDocument::Status::Error); doc.setPassword(QStringLiteral("Qt")); QCOMPARE(passwordChangedSpy.count(), 2); - QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.protected.pdf")), QPdfDocument::NoError); + QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.protected.pdf")), QPdfDocument::Error::None); QCOMPARE(doc.pageCount(), 1); } @@ -210,8 +175,8 @@ void tst_QPdfDocument::close() 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(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Loading); + QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Ready); QCOMPARE(pageCountChangedSpy.count(), 1); QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount()); @@ -224,8 +189,8 @@ void tst_QPdfDocument::close() 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(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Unloading); + QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Null); QCOMPARE(doc.pageCount(), 0); QCOMPARE(pageCountChangedSpy.count(), 1); QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount()); @@ -241,8 +206,8 @@ void tst_QPdfDocument::loadAfterClose() 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(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Loading); + QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Ready); QCOMPARE(pageCountChangedSpy.count(), 1); QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount()); statusChangedSpy.clear(); @@ -250,8 +215,8 @@ void tst_QPdfDocument::loadAfterClose() 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(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Unloading); + QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Null); QCOMPARE(pageCountChangedSpy.count(), 1); QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount()); statusChangedSpy.clear(); @@ -259,9 +224,9 @@ void tst_QPdfDocument::loadAfterClose() 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(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Loading); + QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Ready); + QCOMPARE(doc.error(), QPdfDocument::Error::None); QCOMPARE(doc.pageCount(), 2); QCOMPARE(pageCountChangedSpy.count(), 1); QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount()); @@ -285,8 +250,8 @@ void tst_QPdfDocument::closeOnDestroy() 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(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Unloading); + QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Null); QCOMPARE(pageCountChangedSpy.count(), 1); QCOMPARE(pageCountChangedSpy[0][0].toInt(), 0); } @@ -312,35 +277,35 @@ void tst_QPdfDocument::status() TemporaryPdf tempPdf; QPdfDocument doc; - QCOMPARE(doc.status(), QPdfDocument::Null); + QCOMPARE(doc.status(), QPdfDocument::Status::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); + QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Loading); + QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Ready); statusChangedSpy.clear(); - QCOMPARE(doc.status(), QPdfDocument::Ready); + QCOMPARE(doc.status(), QPdfDocument::Status::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); + QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Unloading); + QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Null); statusChangedSpy.clear(); - QCOMPARE(doc.status(), QPdfDocument::Null); + QCOMPARE(doc.status(), QPdfDocument::Status::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); + QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Loading); + QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Error); + QCOMPARE(doc.status(), QPdfDocument::Status::Error); statusChangedSpy.clear(); // try to open non-existing document asynchronously @@ -362,8 +327,8 @@ void tst_QPdfDocument::status() } QCOMPARE(statusChangedSpy.count(), 2); - QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Loading); - QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Error); + QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Loading); + QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Error); statusChangedSpy.clear(); } @@ -376,7 +341,7 @@ void tst_QPdfDocument::passwordClearedOnClose() doc.setPassword(QStringLiteral("Qt")); QCOMPARE(passwordChangedSpy.count(), 1); - QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.protected.pdf")), QPdfDocument::NoError); + QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.protected.pdf")), QPdfDocument::Error::None); passwordChangedSpy.clear(); doc.close(); // password is cleared on close @@ -393,26 +358,36 @@ 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.metaData(QPdfDocument::MetaDataField::Title).toString(), QString()); + QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::Subject).toString(), QString()); + QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::Author).toString(), QString()); + QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::Keywords).toString(), QString()); + QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::Producer).toString(), QString()); + QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::Creator).toString(), QString()); + QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::CreationDate).toDateTime(), QDateTime()); + QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::ModificationDate).toDateTime(), QDateTime()); - QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.metadata.pdf")), QPdfDocument::NoError); + QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.metadata.pdf")), QPdfDocument::Error::None); // 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)); + QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::Title).toString(), QString::fromLatin1("Qt PDF Unit Test Document")); + QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::Subject).toString(), QString::fromLatin1("A test for meta data access")); + QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::Author).toString(), QString::fromLatin1("John Doe")); + QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::Keywords).toString(), QString::fromLatin1("meta data keywords")); + QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::Producer).toString(), QString::fromLatin1("LibreOffice 5.1")); + QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::Creator).toString(), QString::fromLatin1("Writer")); + QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::CreationDate).toDateTime(), QDateTime(QDate(2016, 8, 7), QTime(7, 3, 6), Qt::UTC)); + QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::ModificationDate).toDateTime(), QDateTime(QDate(2016, 8, 8), QTime(8, 3, 6), Qt::UTC)); +} + +void tst_QPdfDocument::pageLabels() +{ + QPdfDocument doc; + QCOMPARE(doc.load(QFINDTESTDATA("test.pdf")), QPdfDocument::Error::None); + QCOMPARE(doc.pageCount(), 3); + QCOMPARE(doc.pageLabel(0), "Qt"); + QCOMPARE(doc.pageLabel(1), "1"); + QCOMPARE(doc.pageLabel(2), "i"); // i of the tiger! } QTEST_MAIN(tst_QPdfDocument) diff --git a/tests/auto/pdf/qpdfpagenavigation/CMakeLists.txt b/tests/auto/pdf/qpdfpagenavigation/CMakeLists.txt deleted file mode 100644 index 12ece7507..000000000 --- a/tests/auto/pdf/qpdfpagenavigation/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -qt_internal_add_test(tst_qpdfpagenavigation - SOURCES - tst_qpdfpagenavigation.cpp - PUBLIC_LIBRARIES - Qt::Gui - Qt::Network - Qt::Pdf -) diff --git a/tests/auto/pdf/qpdfpagenavigation/pdf-sample.pagenavigation.pdf b/tests/auto/pdf/qpdfpagenavigation/pdf-sample.pagenavigation.pdf Binary files differdeleted file mode 100644 index c4e1aa36e..000000000 --- a/tests/auto/pdf/qpdfpagenavigation/pdf-sample.pagenavigation.pdf +++ /dev/null diff --git a/tests/auto/pdf/qpdfpagenavigation/tst_qpdfpagenavigation.cpp b/tests/auto/pdf/qpdfpagenavigation/tst_qpdfpagenavigation.cpp deleted file mode 100644 index c4d481ca5..000000000 --- a/tests/auto/pdf/qpdfpagenavigation/tst_qpdfpagenavigation.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU 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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.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/tst_qpdfpagerenderer.cpp b/tests/auto/pdf/qpdfpagerenderer/tst_qpdfpagerenderer.cpp index b1d1433cd..a958123c7 100644 --- a/tests/auto/pdf/qpdfpagerenderer/tst_qpdfpagerenderer.cpp +++ b/tests/auto/pdf/qpdfpagerenderer/tst_qpdfpagerenderer.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias König <tobias.koenig@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPDF module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU 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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias König <tobias.koenig@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QPdfDocument> #include <QPdfPageRenderer> @@ -92,7 +56,7 @@ void tst_QPdfPageRenderer::withLoadedDocumentSingleThreaded() QPdfPageRenderer pageRenderer; pageRenderer.setDocument(&document); - QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.pagerenderer.pdf")), QPdfDocument::NoError); + QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.pagerenderer.pdf")), QPdfDocument::Error::None); QSignalSpy pageRenderedSpy(&pageRenderer, &QPdfPageRenderer::pageRendered); @@ -115,7 +79,7 @@ void tst_QPdfPageRenderer::withLoadedDocumentMultiThreaded() pageRenderer.setDocument(&document); pageRenderer.setRenderMode(QPdfPageRenderer::RenderMode::MultiThreaded); - QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.pagerenderer.pdf")), QPdfDocument::NoError); + QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.pagerenderer.pdf")), QPdfDocument::Error::None); QSignalSpy pageRenderedSpy(&pageRenderer, &QPdfPageRenderer::pageRendered); @@ -136,7 +100,7 @@ void tst_QPdfPageRenderer::switchingRenderMode() QPdfPageRenderer pageRenderer; pageRenderer.setDocument(&document); - QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.pagerenderer.pdf")), QPdfDocument::NoError); + QCOMPARE(document.load(QFINDTESTDATA("pdf-sample.pagerenderer.pdf")), QPdfDocument::Error::None); QSignalSpy pageRenderedSpy(&pageRenderer, &QPdfPageRenderer::pageRendered); diff --git a/tests/auto/pdf/qpdfsearchmodel/test.pdf b/tests/auto/pdf/qpdfsearchmodel/test.pdf Binary files differindex a9dc1bc29..0832dfbed 100644 --- a/tests/auto/pdf/qpdfsearchmodel/test.pdf +++ b/tests/auto/pdf/qpdfsearchmodel/test.pdf diff --git a/tests/auto/pdf/qpdfsearchmodel/tst_qpdfsearchmodel.cpp b/tests/auto/pdf/qpdfsearchmodel/tst_qpdfsearchmodel.cpp index 3f115f03c..0bdb9296b 100644 --- a/tests/auto/pdf/qpdfsearchmodel/tst_qpdfsearchmodel.cpp +++ b/tests/auto/pdf/qpdfsearchmodel/tst_qpdfsearchmodel.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU 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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QtTest/QtTest> |