QtPrintSupport: allow slight deviations from pre-defined paper sizes in tests
authorTeemu Katajisto <teemu.katajisto@digia.com>
Tue, 21 Aug 2012 07:53:31 +0000 (10:53 +0300)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 26 Sep 2012 08:08:59 +0000 (10:08 +0200)
CUPS paper sizes may differ from Qt paper sizes slightly and thus fail
the strict comparison in qprinter tests. This is needed for the
followup patch which initializes the cupsplugin with CUPS/PPD defaults.

Change-Id: Ie66f77ead0204de0fc7c7913005fa516d57d34eb
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp

index cd1ff6f..7f872a4 100644 (file)
@@ -491,8 +491,8 @@ void tst_QPrinter::testMulitpleSets()
         return;
     }
 
-    QCOMPARE(printer.widthMM(), widthMMAfter);
-    QCOMPARE(printer.heightMM(), heightMMAfter);
+    QVERIFY(qAbs(printer.widthMM() - widthMMAfter) <= 2);
+    QVERIFY(qAbs(printer.heightMM() - heightMMAfter) <= 2);
 
     computePageValue(printer, paperWidth, paperHeight);
 
@@ -501,8 +501,8 @@ void tst_QPrinter::testMulitpleSets()
 
     // Set it again and see if it still works.
     printer.setPageSize(printerPageSize);
-    QCOMPARE(printer.widthMM(), widthMMAfter);
-    QCOMPARE(printer.heightMM(), heightMMAfter);
+    QVERIFY(qAbs(printer.widthMM() - widthMMAfter) <= 2);
+    QVERIFY(qAbs(printer.heightMM() - heightMMAfter) <= 2);
 
     printer.setOrientation(QPrinter::Landscape);
     computePageValue(printer, paperWidth, paperHeight);