Stabilize qprinter test
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Mon, 10 Sep 2012 13:05:28 +0000 (15:05 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 12 Sep 2012 08:14:10 +0000 (10:14 +0200)
The CreationDate entry in the two PDF files can potentially
be different depending on when the test is run. We ignore the
line for this entry when comparing the two results.

Task-number: QTBUG-27171
Change-Id: I8978678295217edd537edb0d2c25260813aa3d93
Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org>
Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp

index ca7fd4f..6977bbe 100644 (file)
@@ -985,7 +985,16 @@ void tst_QPrinter::taskQTBUG4497_reusePrinterOnDifferentFiles()
     QFile file2("out2.ps");
     QVERIFY(file2.open(QIODevice::ReadOnly));
 
-    QCOMPARE(file1.readAll(), file2.readAll());
+    while (!file1.atEnd() && !file2.atEnd()) {
+        QByteArray file1Line = file1.readLine();
+        QByteArray file2Line = file2.readLine();
+
+        if (!file1Line.startsWith("%%CreationDate"))
+            QCOMPARE(file1Line, file2Line);
+    }
+
+    QVERIFY(file1.atEnd());
+    QVERIFY(file2.atEnd());
 }
 
 void tst_QPrinter::testCurrentPage()