diff options
author | John Layt <jlayt@kde.org> | 2013-04-11 10:25:45 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-12 11:46:01 +0200 |
commit | 839a9c11de9b639d3e19ca62fd363a9db3a63d11 (patch) | |
tree | ecec226c8a7e3e9a252175264cf48c8865e2cea6 /tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp | |
parent | 47ce14cf74d673aa3d12f055e42f5fd4acc6ba3a (diff) |
QPagedPaintDevice: Fix setPageSize() to set correct metrics
Use the correct metrics for the requested PageSize instead of always
defaulting to A4.
Task-number: QTBUG-30494
Change-Id: Ia3978afe3f7cc9b1ded1065416e5c3def44e7a05
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp')
-rw-r--r-- | tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp index c8ea74e6b2..b117edddd4 100644 --- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp +++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp @@ -119,6 +119,8 @@ private slots: void taskQTBUG4497_reusePrinterOnDifferentFiles(); void testPdfTitle(); + void testPageMetrics_data(); + void testPageMetrics(); #endif }; @@ -1108,6 +1110,42 @@ void tst_QPrinter::testPdfTitle() const char *expected = reinterpret_cast<const char*>(expectedBuf); QVERIFY(file.readAll().contains(QByteArray(expected, 26))); } + +void tst_QPrinter::testPageMetrics_data() +{ + QTest::addColumn<int>("pageSize"); + QTest::addColumn<int>("widthMM"); + QTest::addColumn<int>("heightMM"); + QTest::addColumn<float>("widthMMf"); + QTest::addColumn<float>("heightMMf"); + + QTest::newRow("A4") << int(QPrinter::A4) << 210 << 297 << 210.0f << 297.0f; + QTest::newRow("A5") << int(QPrinter::A5) << 148 << 210 << 148.0f << 210.0f; + QTest::newRow("Letter") << int(QPrinter::Letter) << 216 << 279 << 215.9f << 279.4f; +} + +void tst_QPrinter::testPageMetrics() +{ + QFETCH(int, pageSize); + QFETCH(int, widthMM); + QFETCH(int, heightMM); + QFETCH(float, widthMMf); + QFETCH(float, heightMMf); + + QPrinter printer(QPrinter::HighResolution); + printer.setFullPage(true); + printer.setPageSize(QPrinter::PageSize(pageSize)); + + if (printer.pageSize() != pageSize) { + QSKIP("Current page size is not supported on this printer"); + return; + } + + QCOMPARE(printer.widthMM(), int(widthMM)); + QCOMPARE(printer.heightMM(), int(heightMM)); + QCOMPARE(printer.pageSizeMM(), QSizeF(widthMMf, heightMMf)); +} + #endif // QT_NO_PRINTER QTEST_MAIN(tst_QPrinter) |