summaryrefslogtreecommitdiffstats
path: root/tests/auto/pdf/qpdfdocument
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/pdf/qpdfdocument')
-rw-r--r--tests/auto/pdf/qpdfdocument/CMakeLists.txt11
-rw-r--r--tests/auto/pdf/qpdfdocument/rotated_text.pdf70
-rw-r--r--tests/auto/pdf/qpdfdocument/tagged_mcr_multipage.pdf136
-rw-r--r--tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp154
4 files changed, 337 insertions, 34 deletions
diff --git a/tests/auto/pdf/qpdfdocument/CMakeLists.txt b/tests/auto/pdf/qpdfdocument/CMakeLists.txt
index 4551fdb6c..b8300ef27 100644
--- a/tests/auto/pdf/qpdfdocument/CMakeLists.txt
+++ b/tests/auto/pdf/qpdfdocument/CMakeLists.txt
@@ -1,9 +1,18 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
qt_internal_add_test(tst_qpdfdocument
SOURCES
tst_qpdfdocument.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::Network
Qt::PrintSupport
Qt::Pdf
+ TESTDATA
+ pdf-sample.protected.pdf
+ pdf-sample.metadata.pdf
+ rotated_text.pdf
+ tagged_mcr_multipage.pdf
+ test.pdf
)
diff --git a/tests/auto/pdf/qpdfdocument/rotated_text.pdf b/tests/auto/pdf/qpdfdocument/rotated_text.pdf
new file mode 100644
index 000000000..d6d8db84e
--- /dev/null
+++ b/tests/auto/pdf/qpdfdocument/rotated_text.pdf
@@ -0,0 +1,70 @@
+%PDF-1.7
+% ò¤ô
+1 0 obj <<
+ /Type /Catalog
+ /Pages 2 0 R
+>>
+endobj
+2 0 obj <<
+ /Type /Pages
+ /MediaBox [ 0 0 200 200 ]
+ /Count 1
+ /Kids [ 3 0 R ]
+>>
+endobj
+3 0 obj <<
+ /Type /Page
+ /Parent 2 0 R
+ /Resources <<
+ /Font <<
+ /F1 4 0 R
+ >>
+ >>
+ /Contents 5 0 R
+>>
+endobj
+4 0 obj <<
+ /Type /Font
+ /Subtype /Type1
+ /BaseFont /Times-Roman
+>>
+endobj
+5 0 obj <<
+ /Length 406
+>>
+stream
+BT
+0 0 Td
+/F1 12 Tf
+0.70710678118 -0.70710678118 0.70710678118 0.70710678118 100 100 Tm
+(Hello,) Tj
+0 0 Td
+/F1 12 Tf
+-0.70710678118 -0.70710678118 0.70710678118 -0.70710678118 100 100 Tm
+( world!\r\n) Tj
+0 0 Td
+/F1 12 Tf
+-0.70710678118 0.70710678118 -0.70710678118 -0.70710678118 100 100 Tm
+(Goodbye,) Tj
+0 0 Td
+/F1 12 Tf
+0.70710678118 0.70710678118 -0.70710678118 0.70710678118 100 100 Tm
+( world!) Tj
+ET
+endstream
+endobj
+xref
+0 6
+0000000000 65535 f
+0000000015 00000 n
+0000000068 00000 n
+0000000161 00000 n
+0000000287 00000 n
+0000000365 00000 n
+trailer <<
+ /Root 1 0 R
+ /Size 6
+>>
+startxref
+823
+%%EOF
diff --git a/tests/auto/pdf/qpdfdocument/tagged_mcr_multipage.pdf b/tests/auto/pdf/qpdfdocument/tagged_mcr_multipage.pdf
new file mode 100644
index 000000000..fcc5fafda
--- /dev/null
+++ b/tests/auto/pdf/qpdfdocument/tagged_mcr_multipage.pdf
@@ -0,0 +1,136 @@
+%PDF-1.7
+% ò¤ô
+1 0 obj <<
+ /Type /Catalog
+ /MarkInfo <<
+ /Type /MarkInfo
+ /Marked true
+ >>
+ /Pages 2 0 R
+ /StructTreeRoot 8 0 R
+>>
+endobj
+2 0 obj <<
+ /Type /Pages
+ /CropBox [ 10.8197 8.459 605.705 801.639 ]
+ /MediaBox [ 0.0 0.0 616.721 809.902 ]
+ /Count 2
+ /Kids [
+ 4 0 R
+ 6 0 R
+ ]
+>>
+endobj
+3 0 obj <<
+ /Type /Font
+ /Subtype /Type1
+ /BaseFont /Times-Roman
+>>
+endobj
+4 0 obj <<
+ /Type /Page
+ /Tabs /S
+ /Parent 2 0 R
+ /StructParents 0
+ /Contents 5 0 R
+ /Resources <<
+ /ProcSet [/PDF /Text]
+ /Font <<
+ /F1 3 0 R
+ >>
+ >>
+>>
+endobj
+5 0 obj <<
+ /Length 83
+>>
+stream
+BT
+/Document <</MCID 0 >>BDC
+0 i
+/F1 1 Tf
+12 0 0 12 43.073 771.625 Tm
+(1)Tj
+EMC
+ET
+endstream
+endobj
+6 0 obj <<
+ /Type /Page
+ /Tabs /S
+ /Parent 2 0 R
+ /StructParents 1
+ /Contents 7 0 R
+ /Resources <<
+ /ProcSet [/PDF /Text]
+ /Font <<
+ /F1 3 0 R
+ >>
+ >>
+>>
+endobj
+7 0 obj <<
+ /Length 83
+>>
+stream
+BT
+/Document <</MCID 0 >>BDC
+0 i
+/F1 1 Tf
+12 0 0 12 43.073 771.625 Tm
+(2)Tj
+EMC
+ET
+endstream
+endobj
+8 0 obj <<
+ /Type /StructTreeRoot
+ /K 10 0 R
+ /ParentTree 9 0 R
+ /ParentTreeNextKey 2
+>>
+endobj
+9 0 obj <<
+ /Nums [
+ 0
+ [10 0 R]
+ 1
+ [10 0 R]
+ ]
+>>
+endobj
+10 0 obj <<
+ /T ()
+ /S /Document
+ /P 8 0 R
+ /Pg 4 0 R
+ /K [
+ 0
+ <<
+ /MCID 0
+ /Pg 6 0 R
+ /Type /MCR
+ >>
+ ]
+>>
+%endobj
+xref
+0 11
+0000000000 65535 f
+0000000015 00000 n
+0000000149 00000 n
+0000000315 00000 n
+0000000393 00000 n
+0000000575 00000 n
+0000000709 00000 n
+0000000891 00000 n
+0000001025 00000 n
+0000001125 00000 n
+0000001198 00000 n
+trailer <<
+ /Root 1 0 R
+ /Size 11
+>>
+startxref
+1345
+%%EOF
diff --git a/tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp b/tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp
index a481ee57c..d222bff0c 100644
--- a/tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp
+++ b/tests/auto/pdf/qpdfdocument/tst_qpdfdocument.cpp
@@ -7,7 +7,9 @@
#include <QPainter>
#include <QPdfDocument>
#include <QPrinter>
+#include <QDateTime>
#include <QTemporaryFile>
+#include <QTimeZone>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
@@ -34,6 +36,10 @@ private slots:
void passwordClearedOnClose();
void metaData();
void pageLabels();
+ void getSelection_data();
+ void getSelection();
+ void getSelectionAtIndex_data();
+ void getSelectionAtIndex();
private:
void consistencyCheck(QPdfDocument &doc) const;
@@ -54,7 +60,7 @@ struct TemporaryPdf: public QTemporaryFile
};
-TemporaryPdf::TemporaryPdf()
+TemporaryPdf::TemporaryPdf():QTemporaryFile(QStringLiteral("qpdfdocument"))
{
open();
pageLayout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF());
@@ -86,7 +92,7 @@ void tst_QPdfDocument::pageCount()
QCOMPARE(doc.pageCount(), 0);
QCOMPARE(doc.load(tempPdf.fileName()), QPdfDocument::Error::None);
QCOMPARE(doc.pageCount(), 2);
- QCOMPARE(pageCountChangedSpy.count(), 1);
+ QCOMPARE(pageCountChangedSpy.size(), 1);
QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount());
QCOMPARE(doc.pagePointSize(0).toSize(), tempPdf.pageLayout.fullRectPoints().size());
@@ -99,12 +105,12 @@ void tst_QPdfDocument::loadFromIODevice()
QSignalSpy statusChangedSpy(&doc, SIGNAL(statusChanged(QPdfDocument::Status)));
QSignalSpy pageCountChangedSpy(&doc, SIGNAL(pageCountChanged(int)));
doc.load(&tempPdf);
- QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy.size(), 2);
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.size(), 1);
QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount());
consistencyCheck(doc);
@@ -136,11 +142,11 @@ void tst_QPdfDocument::loadAsync()
doc.load(reply.data());
- QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy.size(), 2);
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.size(), 1);
QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount());
consistencyCheck(doc);
@@ -153,13 +159,13 @@ void tst_QPdfDocument::password()
QCOMPARE(doc.pageCount(), 0);
QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.protected.pdf")), QPdfDocument::Error::IncorrectPassword);
- QCOMPARE(passwordChangedSpy.count(), 0);
+ QCOMPARE(passwordChangedSpy.size(), 0);
doc.setPassword(QStringLiteral("WrongPassword"));
- QCOMPARE(passwordChangedSpy.count(), 1);
+ QCOMPARE(passwordChangedSpy.size(), 1);
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(passwordChangedSpy.size(), 2);
QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.protected.pdf")), QPdfDocument::Error::None);
QCOMPARE(doc.pageCount(), 1);
}
@@ -174,10 +180,10 @@ void tst_QPdfDocument::close()
doc.load(&tempPdf);
- QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy.size(), 2);
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.size(), 1);
QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount());
statusChangedSpy.clear();
@@ -188,11 +194,11 @@ void tst_QPdfDocument::close()
return;
doc.close();
- QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy.size(), 2);
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.size(), 1);
QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount());
}
@@ -205,30 +211,30 @@ void tst_QPdfDocument::loadAfterClose()
QSignalSpy pageCountChangedSpy(&doc, SIGNAL(pageCountChanged(int)));
doc.load(&tempPdf);
- QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy.size(), 2);
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.size(), 1);
QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount());
statusChangedSpy.clear();
pageCountChangedSpy.clear();
doc.close();
- QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy.size(), 2);
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.size(), 1);
QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount());
statusChangedSpy.clear();
pageCountChangedSpy.clear();
doc.load(&tempPdf);
- QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy.size(), 2);
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.size(), 1);
QCOMPARE(pageCountChangedSpy[0][0].toInt(), doc.pageCount());
consistencyCheck(doc);
@@ -249,10 +255,10 @@ void tst_QPdfDocument::closeOnDestroy()
delete doc;
- QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy.size(), 2);
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.size(), 1);
QCOMPARE(pageCountChangedSpy[0][0].toInt(), 0);
}
@@ -267,8 +273,8 @@ void tst_QPdfDocument::closeOnDestroy()
delete doc;
- QCOMPARE(statusChangedSpy.count(), 0);
- QCOMPARE(pageCountChangedSpy.count(), 0);
+ QCOMPARE(statusChangedSpy.size(), 0);
+ QCOMPARE(pageCountChangedSpy.size(), 0);
}
}
@@ -283,7 +289,7 @@ void tst_QPdfDocument::status()
// open existing document
doc.load(&tempPdf);
- QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy.size(), 2);
QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Loading);
QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Ready);
statusChangedSpy.clear();
@@ -293,7 +299,7 @@ void tst_QPdfDocument::status()
// close document
doc.close();
- QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy.size(), 2);
QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Unloading);
QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Null);
statusChangedSpy.clear();
@@ -302,7 +308,7 @@ void tst_QPdfDocument::status()
// try to open non-existing document
doc.load(QFINDTESTDATA("does-not-exist.pdf"));
- QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy.size(), 2);
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);
@@ -320,13 +326,13 @@ void tst_QPdfDocument::status()
stopWatch.start();
forever {
QCoreApplication::instance()->processEvents();
- if (statusChangedSpy.count() == 2)
+ if (statusChangedSpy.size() == 2)
break;
if (stopWatch.elapsed() >= 30000)
break;
}
- QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(statusChangedSpy.size(), 2);
QCOMPARE(statusChangedSpy[0][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Loading);
QCOMPARE(statusChangedSpy[1][0].value<QPdfDocument::Status>(), QPdfDocument::Status::Error);
statusChangedSpy.clear();
@@ -340,17 +346,17 @@ void tst_QPdfDocument::passwordClearedOnClose()
QSignalSpy passwordChangedSpy(&doc, SIGNAL(passwordChanged()));
doc.setPassword(QStringLiteral("Qt"));
- QCOMPARE(passwordChangedSpy.count(), 1);
+ QCOMPARE(passwordChangedSpy.size(), 1);
QCOMPARE(doc.load(QFINDTESTDATA("pdf-sample.protected.pdf")), QPdfDocument::Error::None);
passwordChangedSpy.clear();
doc.close(); // password is cleared on close
- QCOMPARE(passwordChangedSpy.count(), 1);
+ QCOMPARE(passwordChangedSpy.size(), 1);
passwordChangedSpy.clear();
doc.load(&tempPdf);
doc.close(); // signal is not emitted if password didn't change
- QCOMPARE(passwordChangedSpy.count(), 0);
+ QCOMPARE(passwordChangedSpy.size(), 0);
}
void tst_QPdfDocument::metaData()
@@ -376,8 +382,10 @@ void tst_QPdfDocument::metaData()
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));
+ QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::CreationDate).toDateTime(),
+ QDateTime(QDate(2016, 8, 7), QTime(7, 3, 6), QTimeZone::UTC));
+ QCOMPARE(doc.metaData(QPdfDocument::MetaDataField::ModificationDate).toDateTime(),
+ QDateTime(QDate(2016, 8, 8), QTime(8, 3, 6), QTimeZone::UTC));
}
void tst_QPdfDocument::pageLabels()
@@ -390,6 +398,86 @@ void tst_QPdfDocument::pageLabels()
QCOMPARE(doc.pageLabel(2), "i"); // i of the tiger!
}
+void tst_QPdfDocument::getSelection_data()
+{
+ QTest::addColumn<QString>("pdfPath");
+ QTest::addColumn<int>("page");
+ QTest::addColumn<QPointF>("start");
+ QTest::addColumn<QPointF>("end");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<int>("expectedStartIndex");
+ QTest::addColumn<int>("expectedEndIndex");
+ QTest::addColumn<QRect>("expectedBounds");
+ QTest::addColumn<int>("expectedPolygonCount");
+
+ QTest::newRow("raid") << QFINDTESTDATA("test.pdf")
+ << 1 << QPointF(316.4, 206) << QPointF(339, 201)
+ << "raid" << 80 << 84 << QRect(316, 201, 21, 12) << 1;
+ QTest::newRow("rotated text") << QFINDTESTDATA("rotated_text.pdf")
+ << 0 << QPointF(102, 94) << QPointF(125, 73)
+ << "world!" << 25 << 31 << QRect(98, 70, 26, 28) << 1;
+}
+
+void tst_QPdfDocument::getSelection()
+{
+ QFETCH(QString, pdfPath);
+ QFETCH(int, page);
+ QFETCH(QPointF, start);
+ QFETCH(QPointF, end);
+ QFETCH(QString, expectedText);
+ QFETCH(int, expectedStartIndex);
+ QFETCH(int, expectedEndIndex);
+ QFETCH(QRect, expectedBounds);
+ QFETCH(int, expectedPolygonCount);
+
+ QPdfDocument doc;
+ QCOMPARE(doc.load(pdfPath), QPdfDocument::Error::None);
+
+ QPdfSelection sel = doc.getSelection(page, start, end);
+ QCOMPARE(sel.text(), expectedText);
+ QCOMPARE(sel.startIndex(), expectedStartIndex);
+ QCOMPARE(sel.endIndex(), expectedEndIndex);
+ QCOMPARE(sel.boundingRectangle().toRect(), expectedBounds);
+ QCOMPARE(sel.bounds().size(), expectedPolygonCount);
+}
+
+void tst_QPdfDocument::getSelectionAtIndex_data()
+{
+ QTest::addColumn<QString>("pdfPath");
+ QTest::addColumn<int>("page");
+ QTest::addColumn<int>("start");
+ QTest::addColumn<int>("maxLen");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<QRect>("expectedBounds");
+ QTest::addColumn<int>("expectedPolygonCount");
+
+ QTest::newRow("raid") << QFINDTESTDATA("test.pdf")
+ << 1 << 80 << 4 << "raid" << QRect(316, 201, 21, 12) << 1;
+ QTest::newRow("rotated text") << QFINDTESTDATA("rotated_text.pdf")
+ << 0 << 7 << 6 << "world!" << QRect(76, 102, 26, 28) << 1;
+ QTest::newRow("displaced text") << QFINDTESTDATA("tagged_mcr_multipage.pdf")
+ << 0 << 0 << 10 << "1" << QRect(34, 22, 3, 8) << 1;
+}
+
+void tst_QPdfDocument::getSelectionAtIndex()
+{
+ QFETCH(QString, pdfPath);
+ QFETCH(int, page);
+ QFETCH(int, start);
+ QFETCH(int, maxLen);
+ QFETCH(QString, expectedText);
+ QFETCH(QRect, expectedBounds);
+ QFETCH(int, expectedPolygonCount);
+
+ QPdfDocument doc;
+ QCOMPARE(doc.load(pdfPath), QPdfDocument::Error::None);
+
+ QPdfSelection sel = doc.getSelectionAtIndex(page, start, maxLen);
+ QCOMPARE(sel.text(), expectedText);
+ QCOMPARE(sel.boundingRectangle().toRect(), expectedBounds);
+ QCOMPARE(sel.bounds().size(), expectedPolygonCount);
+}
+
QTEST_MAIN(tst_QPdfDocument)
#include "tst_qpdfdocument.moc"