diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2009-10-06 07:55:12 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2009-10-06 08:02:24 (GMT) |
commit | 39dc3026d1da03d5fcf8e5c516fadd7e4ea8a861 (patch) | |
tree | 83d3044cdf90e765c8aa34c4b8a38e708b206595 /tests/auto | |
parent | b1c5547c5682e57b746e3bc8ac616ebbd23c12b8 (diff) | |
download | Qt-39dc3026d1da03d5fcf8e5c516fadd7e4ea8a861.zip Qt-39dc3026d1da03d5fcf8e5c516fadd7e4ea8a861.tar.gz Qt-39dc3026d1da03d5fcf8e5c516fadd7e4ea8a861.tar.bz2 |
Don't output redundant setPen command when reusing PS printer
If you reused a printer to paint to several different files, the
results would sometimes be different, as the subsequent runs would have
redundant setPen commands in its output. This was because the simplePen
flag was not reset to its initial value when reusing the print engine.
Task-number: QTBUG-4479
Reviewed-by: Trond
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qprinter/tst_qprinter.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qprinter/tst_qprinter.cpp b/tests/auto/qprinter/tst_qprinter.cpp index d6df94b..3c05d90 100644 --- a/tests/auto/qprinter/tst_qprinter.cpp +++ b/tests/auto/qprinter/tst_qprinter.cpp @@ -108,6 +108,8 @@ private slots: void testActualNumCopies(); + void taskQTBUG4497_reusePrinterOnDifferentFiles(); + private: }; @@ -971,5 +973,37 @@ void tst_QPrinter::testActualNumCopies() QCOMPARE(p.actualNumCopies(), 15); } +static void printPage(QPainter *painter) +{ + painter->setPen(QPen(Qt::black, 4)); + painter->drawRect(50, 60, 70, 80); +} + +void tst_QPrinter::taskQTBUG4497_reusePrinterOnDifferentFiles() +{ + QPrinter printer; + { + + printer.setOutputFileName("out1.ps"); + QPainter painter(&printer); + printPage(&painter); + + } + { + + printer.setOutputFileName("out2.ps"); + QPainter painter(&printer); + printPage(&painter); + + } + QFile file1("out1.ps"); + QVERIFY(file1.open(QIODevice::ReadOnly)); + + QFile file2("out2.ps"); + QVERIFY(file2.open(QIODevice::ReadOnly)); + + QCOMPARE(file1.readAll(), file2.readAll()); +} + QTEST_MAIN(tst_QPrinter) #include "tst_qprinter.moc" |