public slots:
void init();
void cleanup();
+ void cleanupTestCase();
private slots:
void getSetCheck();
void drawPixmap_comp_data();
{
}
+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",
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
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());
if (painter)
delete painter;
+ QFile::remove("silly");
}
void tst_QPrinter::testNonExistentPrinter()
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);
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();
{
QPrintDialog dialog;
dialog.printer()->setOutputFileName("file.pdf");
+ TempFileCleanup tmpFile("file.pdf");
dialog.setEnabledOptions(QAbstractPrintDialog::PrintToFile);
dialog.show();
void tst_QPrinter::taskQTBUG4497_reusePrinterOnDifferentFiles()
{
+ TempFileCleanup tmpFile1("out1.ps");
+ TempFileCleanup tmpFile2("out2.ps");
+
QPrinter printer;
{
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: