summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKurt Korbatits <kurt.korbatits@nokia.com>2012-01-23 10:53:15 +1000
committerQt by Nokia <qt-info@nokia.com>2012-01-24 06:59:09 +0100
commit1509739d4328d9eb049b899e24546821567005bf (patch)
treee15a29a412d5fd4fcb14ffcc65503eba2e1bbe2a /tests
parent5f22288346fd69ecaa0128d83bf87d011d1572b3 (diff)
Changed painting unittests to remove created files after run.
- qpainter cleans up temp files dest.png, expected.png and foo.png - qpainterpath clean up temp file data - qprinter cleans up silly, out1.ps, out2.ps, test.pdf and file.pdf Change-Id: Id434bea0bae5b970355206a250456e4beeca8060 Reviewed-by: Kurt Korbatits <kurt.korbatits@nokia.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com> Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp8
-rw-r--r--tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp8
-rw-r--r--tests/auto/gui/painting/qprinter/tst_qprinter.cpp26
3 files changed, 41 insertions, 1 deletions
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 5440d7783c..4e4e9a9313 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -89,6 +89,7 @@ public:
public slots:
void init();
void cleanup();
+ void cleanupTestCase();
private slots:
void getSetCheck();
void drawPixmap_comp_data();
@@ -364,6 +365,13 @@ void tst_QPainter::cleanup()
{
}
+void tst_QPainter::cleanupTestCase()
+{
+ QFile::remove(QLatin1String("dest.png"));
+ QFile::remove(QLatin1String("expected.png"));
+ QFile::remove(QLatin1String("foo.png"));
+}
+
static const char* const maskSource_data[] = {
"16 13 6 1",
". c None",
diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
index d745c8e45d..d30ed8674f 100644
--- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
+++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
@@ -54,7 +54,8 @@ class tst_QPainterPath : public QObject
Q_OBJECT
public:
-
+public slots:
+ void cleanupTestCase();
private slots:
void getSetCheck();
void swap();
@@ -115,6 +116,11 @@ private slots:
void lineWithinBounds();
};
+void tst_QPainterPath::cleanupTestCase()
+{
+ QFile::remove(QLatin1String("data"));
+}
+
// Testing get/set functions
void tst_QPainterPath::getSetCheck()
{
diff --git a/tests/auto/gui/painting/qprinter/tst_qprinter.cpp b/tests/auto/gui/painting/qprinter/tst_qprinter.cpp
index 90a8fd5319..e9ad780a36 100644
--- a/tests/auto/gui/painting/qprinter/tst_qprinter.cpp
+++ b/tests/auto/gui/painting/qprinter/tst_qprinter.cpp
@@ -60,6 +60,23 @@ Q_DECLARE_METATYPE(QRect)
QT_FORWARD_DECLARE_CLASS(QPrinter)
+// Helper class to make sure temp files are cleaned up after test complete
+class TempFileCleanup
+{
+public:
+ TempFileCleanup(const QString &file)
+ : m_file(file)
+ {
+ }
+
+ ~TempFileCleanup()
+ {
+ QFile::remove(m_file);
+ }
+private:
+ QString m_file;
+};
+
class tst_QPrinter : public QObject
{
Q_OBJECT
@@ -288,6 +305,7 @@ void tst_QPrinter::testPageRectAndPaperRect()
QPrinter printer(QPrinter::HighResolution);
printer.setOrientation(QPrinter::Orientation(orientation));
printer.setOutputFileName("silly");
+ TempFileCleanup tmpFile("silly");
QRect pageRect = doPaperRect ? printer.paperRect() : printer.pageRect();
float inchesX = float(pageRect.width()) / float(printer.resolution());
@@ -376,6 +394,7 @@ void tst_QPrinter::testMargins()
if (painter)
delete painter;
+ QFile::remove("silly");
}
void tst_QPrinter::testNonExistentPrinter()
@@ -505,6 +524,7 @@ void tst_QPrinter::outputFormatFromSuffix()
QPrinter p;
QVERIFY(p.outputFormat() == QPrinter::NativeFormat);
p.setOutputFileName("test.pdf");
+ TempFileCleanup tmpFile("test.pdf");
QVERIFY(p.outputFormat() == QPrinter::PdfFormat);
p.setOutputFileName(QString());
QVERIFY(p.outputFormat() == QPrinter::NativeFormat);
@@ -865,6 +885,7 @@ void tst_QPrinter::errorReporting()
QCOMPARE(painter.begin(&p), false); // it should check the output file is writable
#endif
p.setOutputFileName("test.pdf");
+ TempFileCleanup tmpFile("test.pdf");
QCOMPARE(painter.begin(&p), true); // it should check the output
QCOMPARE(p.isValid(), true);
painter.end();
@@ -891,6 +912,7 @@ void tst_QPrinter::printDialogCompleter()
{
QPrintDialog dialog;
dialog.printer()->setOutputFileName("file.pdf");
+ TempFileCleanup tmpFile("file.pdf");
dialog.setEnabledOptions(QAbstractPrintDialog::PrintToFile);
dialog.show();
@@ -917,6 +939,9 @@ static void printPage(QPainter *painter)
void tst_QPrinter::taskQTBUG4497_reusePrinterOnDifferentFiles()
{
+ TempFileCleanup tmpFile1("out1.ps");
+ TempFileCleanup tmpFile2("out2.ps");
+
QPrinter printer;
{
@@ -978,6 +1003,7 @@ void tst_QPrinter::testPdfTitle()
painter.begin(&printer);
painter.end();
}
+ TempFileCleanup tmpFile("file.pdf");
QFile file("file.pdf");
QVERIFY(file.open(QIODevice::ReadOnly));
// The we expect the title to appear in the PDF as: