summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro2
-rw-r--r--tests/auto/qpdfdocument/qpdfdocument.pro6
-rw-r--r--tests/auto/qpdfdocument/tst_qpdfdocument.cpp46
-rw-r--r--tests/tests.pro2
4 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
new file mode 100644
index 0000000..41c081c
--- /dev/null
+++ b/tests/auto/auto.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS = qpdfdocument
diff --git a/tests/auto/qpdfdocument/qpdfdocument.pro b/tests/auto/qpdfdocument/qpdfdocument.pro
new file mode 100644
index 0000000..28e56e0
--- /dev/null
+++ b/tests/auto/qpdfdocument/qpdfdocument.pro
@@ -0,0 +1,6 @@
+CONFIG += testcase
+TARGET = tst_qpdfdocument
+QT += pdf printsupport testlib
+macx:CONFIG -= app_bundle
+SOURCES += tst_qpdfdocument.cpp
+
diff --git a/tests/auto/qpdfdocument/tst_qpdfdocument.cpp b/tests/auto/qpdfdocument/tst_qpdfdocument.cpp
new file mode 100644
index 0000000..080f808
--- /dev/null
+++ b/tests/auto/qpdfdocument/tst_qpdfdocument.cpp
@@ -0,0 +1,46 @@
+
+#include <QtTest/QtTest>
+
+#include <QPainter>
+#include <QPdfDocument>
+#include <QPrinter>
+#include <QTemporaryFile>
+
+class tst_QPdfDocument: public QObject
+{
+ Q_OBJECT
+public:
+
+private slots:
+ void pageCount();
+};
+
+
+void tst_QPdfDocument::pageCount()
+{
+ QTemporaryFile tempPdf;
+ tempPdf.setAutoRemove(true);
+ QVERIFY(tempPdf.open());
+ {
+ QPrinter printer;
+ printer.setOutputFormat(QPrinter::PdfFormat);
+ printer.setOutputFileName(tempPdf.fileName());
+
+ {
+ QPainter painter(&printer);
+ painter.drawText(0, 0, QStringLiteral("Hello Page 1"));
+ printer.newPage();
+ painter.drawText(0, 0, QStringLiteral("Hello Page 2"));
+ }
+ }
+
+ QPdfDocument doc;
+ QCOMPARE(doc.pageCount(), 0);
+ QCOMPARE(doc.load(tempPdf.fileName()), QPdfDocument::NoError);
+ QCOMPARE(doc.pageCount(), 2);
+}
+
+QTEST_MAIN(tst_QPdfDocument)
+
+#include "tst_qpdfdocument.moc"
+
diff --git a/tests/tests.pro b/tests/tests.pro
new file mode 100644
index 0000000..7fbc8a9
--- /dev/null
+++ b/tests/tests.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS = auto