Commit 63783fff authored by Volker Krause's avatar Volker Krause
Browse files

Fix unit tests issues on Windows due to different line breaks for PDFs

Poppler gives us platform line breaks, our tests didn't expect that.
parent 4c5ee248
......@@ -19,6 +19,12 @@ using namespace KItinerary;
#define s(x) QStringLiteral(x)
#ifdef Q_OS_WINDOWS
#define LINEBREAK "\r\n"
#else
#define LINEBREAK "\n"
#endif
class ExtractorDocumentNodeTest : public QObject
{
Q_OBJECT
......@@ -69,7 +75,7 @@ private Q_SLOTS:
auto c3 = root.childNodes()[2];
QVERIFY(!c3.isNull());
QCOMPARE(c3.mimeType(), QLatin1String("text/plain"));
QCOMPARE(c3.content<QString>(), QLatin1String("This is the first page.\nIt contains a PDF 417 barcode.\nThis is the second page.\nIt contains an Aztec code.\n"));
QCOMPARE(c3.content<QString>(), QLatin1String("This is the first page." LINEBREAK "It contains a PDF 417 barcode." LINEBREAK "This is the second page." LINEBREAK "It contains an Aztec code." LINEBREAK));
auto c1 = root.childNodes()[0];
QVERIFY(!c1.isNull());
......
......@@ -13,6 +13,12 @@
using namespace KItinerary;
#ifdef Q_OS_WINDOWS
#define LINEBREAK "\r\n"
#else
#define LINEBREAK "\n"
#endif
class PdfDocumentTest : public QObject
{
Q_OBJECT
......@@ -31,16 +37,16 @@ private Q_SLOTS:
f.seek(0);
std::unique_ptr<PdfDocument> doc(PdfDocument::fromData(f.readAll()));
QVERIFY(doc);
QCOMPARE(doc->text(), QStringLiteral("This is the first page.\nIt contains a PDF 417 barcode.\nThis is the second page.\nIt contains an Aztec code.\n"));
QCOMPARE(doc->text(), QLatin1String("This is the first page." LINEBREAK "It contains a PDF 417 barcode." LINEBREAK "This is the second page." LINEBREAK "It contains an Aztec code." LINEBREAK));
QCOMPARE(doc->pageCount(), 2);
QCOMPARE(doc->property("pages").toList().size(), 2);
auto page = doc->page(0);
QCOMPARE(page.text(), QStringLiteral("This is the first page.\nIt contains a PDF 417 barcode.\n"));
QCOMPARE(page.text(), QLatin1String("This is the first page." LINEBREAK "It contains a PDF 417 barcode." LINEBREAK));
QCOMPARE(page.imageCount(), 1);
QCOMPARE(PdfPage::staticMetaObject.property(1).readOnGadget(&page).toList().size(), 1);
QCOMPARE(page.textInRect(0, 0, 1, 0.5), QStringLiteral("This is the first page.\nIt contains a PDF 417 barcode.\n"));
QCOMPARE(page.textInRect(0, 0, 1, 0.5), QLatin1String("This is the first page." LINEBREAK "It contains a PDF 417 barcode." LINEBREAK));
QCOMPARE(page.textInRect(0, 0.5, 1, 1), QString());
auto img = page.image(0);
......@@ -52,7 +58,7 @@ private Q_SLOTS:
QCOMPARE(img.image().height(), 152);
page = doc->page(1);
QCOMPARE(page.text(), QStringLiteral("This is the second page.\nIt contains an Aztec code.\n"));
QCOMPARE(page.text(), QLatin1String("This is the second page." LINEBREAK "It contains an Aztec code." LINEBREAK));
QCOMPARE(page.imageCount(), 1);
img = page.image(0);
QCOMPARE(img.width(), 93);
......
......@@ -8,10 +8,11 @@ function dumpValue(value, depth)
{
if (value === undefined || value === null
|| typeof value == "boolean"
|| typeof value == "number"
|| typeof value == "string")
|| typeof value == "number")
{
return value;
} else if (typeof value == "string") {
return value.replace('\r\n', '\n');
} else if (typeof value == "object") {
if (depth == 0) {
return "[...]";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment