diff options
Diffstat (limited to 'qt5/tests/check_actualtext.cpp')
-rw-r--r-- | qt5/tests/check_actualtext.cpp | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/qt5/tests/check_actualtext.cpp b/qt5/tests/check_actualtext.cpp index f1128ee2..37fd5a9e 100644 --- a/qt5/tests/check_actualtext.cpp +++ b/qt5/tests/check_actualtext.cpp @@ -12,17 +12,18 @@ public: private slots: void checkActualText1(); void checkActualText2(); + void checkActualText2_data(); private: - void checkActualText(Poppler::Document *doc); + void checkActualText(Poppler::Document *doc, const QRectF &area, const QString &text); }; -void TestActualText::checkActualText(Poppler::Document *doc) +void TestActualText::checkActualText(Poppler::Document *doc, const QRectF &area, const QString &text) { Poppler::Page *page = doc->page(0); QVERIFY(page); - QCOMPARE(page->text(QRectF()), QLatin1String("The slow brown fox jumps over the black dog.")); + QCOMPARE(page->text(area), text); delete page; } @@ -33,13 +34,16 @@ void TestActualText::checkActualText1() doc = Poppler::Document::load(TESTDATADIR "/unittestcases/WithActualText.pdf"); QVERIFY(doc); - checkActualText(doc); + checkActualText(doc, QRectF {}, QStringLiteral("The slow brown fox jumps over the black dog.")); delete doc; } void TestActualText::checkActualText2() { + QFETCH(QRectF, area); + QFETCH(QString, text); + QFile file(TESTDATADIR "/unittestcases/WithActualText.pdf"); QVERIFY(file.open(QIODevice::ReadOnly)); @@ -47,11 +51,32 @@ void TestActualText::checkActualText2() doc = Poppler::Document::load(&file); QVERIFY(doc); - checkActualText(doc); + checkActualText(doc, area, text); delete doc; } +void TestActualText::checkActualText2_data() +{ + QTest::addColumn<QRectF>("area"); + QTest::addColumn<QString>("text"); + + // Line bounding box is [100.000 90.720 331.012110 102.350] + + QTest::newRow("full page") << QRectF {} << QStringLiteral("The slow brown fox jumps over the black dog."); + QTest::newRow("full line") << QRectF { 50.0, 90.0, 290.0, 20.0 } << QStringLiteral("The slow brown fox jumps over the black dog."); + QTest::newRow("full line [narrow]") << QRectF { 50.0, 95.0, 290.0, 5.0 } << QStringLiteral("The slow brown fox jumps over the black dog."); + QTest::newRow("above line") << QRectF { 50.0, 85.0, 290.0, 10.0 } << QString {}; + QTest::newRow("above line mid") << QRectF { 50.0, 90.0, 290.0, 5.0 } << QString {}; + QTest::newRow("first two words") << QRectF { 50.0, 90.0, 100.0, 20.0 } << QStringLiteral("The slow"); + QTest::newRow("first two words [narrow]") << QRectF { 50.0, 95.0, 100.0, 5.0 } << QStringLiteral("The slow"); + QTest::newRow("first character") << QRectF { 103.0, 95.0, 1.0, 5.0 } << QStringLiteral("T"); + QTest::newRow("last two words") << QRectF { 285.0, 90.0, 100.0, 20.0 } << QStringLiteral("black dog."); + QTest::newRow("last character") << QRectF { 320.0, 90.0, 8.0, 20.0 } << QStringLiteral("g"); + QTest::newRow("middle 'fox'") << QRectF { 190.0, 90.0, 15.0, 20.0 } << QStringLiteral("fox"); + QTest::newRow("middle 'x'") << QRectF { 200.0, 90.0, 5.0, 20.0 } << QStringLiteral("x"); +} + QTEST_GUILESS_MAIN(TestActualText) #include "check_actualtext.moc" |