Test: remove QSKIP from printsupport tests

Exclude printsupport tests from the build when QT_NO_PRINTER is
defined.

Change-Id: Iedae91666a599f4b77250abc8aac14c256fde34e
Reviewed-by: J-P Nurmi <j-p.nurmi@nokia.com>
Reviewed-by: Sergio Ahumada <sergio.ahumada@nokia.com>
This commit is contained in:
Caroline Chao 2012-09-07 14:59:15 +02:00 committed by Qt by Nokia
parent 97b4c5a574
commit 5704cbc462
3 changed files with 18 additions and 46 deletions

View File

@ -16,7 +16,7 @@ SUBDIRS += \
printsupport \ printsupport \
cmake cmake
wince*: SUBDIRS -= printsupport wince*|contains(DEFINES, QT_NO_PRINTER): SUBDIRS -= printsupport
cross_compile: SUBDIRS -= tools cross_compile: SUBDIRS -= tools
isEmpty(QT.opengl.name): SUBDIRS -= opengl isEmpty(QT.opengl.name): SUBDIRS -= opengl
!unix|embedded|!contains(QT_CONFIG, dbus): SUBDIRS -= dbus !unix|embedded|!contains(QT_CONFIG, dbus): SUBDIRS -= dbus

View File

@ -81,20 +81,18 @@ class tst_QPrinter : public QObject
{ {
Q_OBJECT Q_OBJECT
#ifdef QT_NO_PRINTER
public slots:
void initTestCase();
#else
private slots: private slots:
void getSetCheck(); void getSetCheck();
// Add your testfunctions and testdata create functions here // Add your testfunctions and testdata create functions here
#ifdef Q_OS_WIN
void testPageSize(); void testPageSize();
void testNonExistentPrinter();
#endif
void testPageRectAndPaperRect(); void testPageRectAndPaperRect();
void testPageRectAndPaperRect_data(); void testPageRectAndPaperRect_data();
void testSetOptions(); void testSetOptions();
void testMargins_data(); void testMargins_data();
void testMargins(); void testMargins();
void testNonExistentPrinter();
void testPageSetupDialog(); void testPageSetupDialog();
void testMulitpleSets_data(); void testMulitpleSets_data();
void testMulitpleSets(); void testMulitpleSets();
@ -115,17 +113,8 @@ private slots:
void taskQTBUG4497_reusePrinterOnDifferentFiles(); void taskQTBUG4497_reusePrinterOnDifferentFiles();
void testPdfTitle(); void testPdfTitle();
#endif
}; };
#ifdef QT_NO_PRINTER
void tst_QPrinter::initTestCase()
{
QSKIP("This test requires printing support");
}
#else
// Testing get/set functions // Testing get/set functions
void tst_QPrinter::getSetCheck() void tst_QPrinter::getSetCheck()
{ {
@ -233,11 +222,10 @@ void tst_QPrinter::testPageSetupDialog()
} }
} }
#ifdef Q_OS_WIN
// QPrinter::winPageSize(): Windows only.
void tst_QPrinter::testPageSize() void tst_QPrinter::testPageSize()
{ {
#ifndef Q_OS_WIN
QSKIP("QPrinter::winPageSize(): Windows only.");
#else
QPrinter prn; QPrinter prn;
prn.setPageSize(QPrinter::Letter); prn.setPageSize(QPrinter::Letter);
@ -255,8 +243,8 @@ void tst_QPrinter::testPageSize()
prn.setWinPageSize(DMPAPER_A4); prn.setWinPageSize(DMPAPER_A4);
MYCOMPARE(prn.winPageSize(), DMPAPER_A4); MYCOMPARE(prn.winPageSize(), DMPAPER_A4);
MYCOMPARE(prn.pageSize(), QPrinter::A4); MYCOMPARE(prn.pageSize(), QPrinter::A4);
#endif // Q_OS_WIN
} }
#endif // Q_OS_WIN
void tst_QPrinter::testPageRectAndPaperRect_data() void tst_QPrinter::testPageRectAndPaperRect_data()
{ {
@ -397,11 +385,10 @@ void tst_QPrinter::testMargins()
QFile::remove("silly"); QFile::remove("silly");
} }
#ifdef Q_OS_WIN
// QPrinter::testNonExistentPrinter() is not relevant for this platform
void tst_QPrinter::testNonExistentPrinter() void tst_QPrinter::testNonExistentPrinter()
{ {
#ifndef Q_OS_WIN
QSKIP("QPrinter::testNonExistentPrinter() is not relevant for this platform");
#else
QPrinter printer; QPrinter printer;
QPainter painter; QPainter painter;
@ -429,8 +416,8 @@ void tst_QPrinter::testNonExistentPrinter()
QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmPhysicalDpiY), 0); QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmPhysicalDpiY), 0);
QVERIFY(!painter.begin(&printer)); QVERIFY(!painter.begin(&printer));
#endif
} }
#endif
void tst_QPrinter::testMulitpleSets_data() void tst_QPrinter::testMulitpleSets_data()
{ {
@ -1047,7 +1034,5 @@ void tst_QPrinter::testPdfTitle()
QVERIFY(file.readAll().contains(QByteArray(expected, 26))); QVERIFY(file.readAll().contains(QByteArray(expected, 26)));
} }
#endif
QTEST_MAIN(tst_QPrinter) QTEST_MAIN(tst_QPrinter)
#include "tst_qprinter.moc" #include "tst_qprinter.moc"

View File

@ -39,7 +39,6 @@
** **
****************************************************************************/ ****************************************************************************/
#include <QtTest/QtTest> #include <QtTest/QtTest>
#include <QtGlobal> #include <QtGlobal>
#include <QtAlgorithms> #include <QtAlgorithms>
@ -57,12 +56,11 @@ class tst_QPrinterInfo : public QObject
{ {
Q_OBJECT Q_OBJECT
public slots:
void initTestCase();
#ifndef QT_NO_PRINTER
private slots: private slots:
#ifndef Q_OS_WIN32
void testForDefaultPrinter(); void testForDefaultPrinter();
void testForPrinters(); void testForPrinters();
#endif
void testForPaperSizes(); void testForPaperSizes();
void testConstructors(); void testConstructors();
void testAssignment(); void testAssignment();
@ -75,17 +73,8 @@ private:
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
QString getOutputFromCommand(const QStringList& command); QString getOutputFromCommand(const QStringList& command);
#endif // Q_OS_UNIX #endif // Q_OS_UNIX
#endif // QT_NO_PRINTER
}; };
void tst_QPrinterInfo::initTestCase()
{
#ifdef QT_NO_PRINTER
QSKIP("This test requires printing support");
#endif // QT_NO_PRINTER
}
#ifndef QT_NO_PRINTER
QString tst_QPrinterInfo::getDefaultPrinterFromSystem() QString tst_QPrinterInfo::getDefaultPrinterFromSystem()
{ {
QString printer; QString printer;
@ -200,11 +189,10 @@ QString tst_QPrinterInfo::getOutputFromCommand(const QStringList& command)
} }
#endif #endif
// Windows test support not yet implemented
#ifndef Q_OS_WIN32
void tst_QPrinterInfo::testForDefaultPrinter() void tst_QPrinterInfo::testForDefaultPrinter()
{ {
#ifdef Q_OS_WIN32
QSKIP("Windows test support not yet implemented");
#endif // Q_OS_WIN32
QString testPrinter = getDefaultPrinterFromSystem(); QString testPrinter = getDefaultPrinterFromSystem();
QString defaultPrinter = QPrinterInfo::defaultPrinter().printerName(); QString defaultPrinter = QPrinterInfo::defaultPrinter().printerName();
QString availablePrinter; QString availablePrinter;
@ -227,12 +215,12 @@ void tst_QPrinterInfo::testForDefaultPrinter()
if (!availablePrinter.isEmpty()) if (!availablePrinter.isEmpty())
QCOMPARE(availablePrinterDefaults, 1); QCOMPARE(availablePrinterDefaults, 1);
} }
#endif
// Windows test support not yet implemented
#ifndef Q_OS_WIN32
void tst_QPrinterInfo::testForPrinters() void tst_QPrinterInfo::testForPrinters()
{ {
#ifdef Q_OS_WIN32
QSKIP("Windows test support not yet implemented");
#endif // Q_OS_WIN32
QStringList testPrinters = getPrintersFromSystem(); QStringList testPrinters = getPrintersFromSystem();
QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters(); QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters();
@ -251,6 +239,7 @@ void tst_QPrinterInfo::testForPrinters()
for (int i = 0; i < testPrinters.size(); ++i) for (int i = 0; i < testPrinters.size(); ++i)
QCOMPARE(qtPrinters.at(i), testPrinters.at(i)); QCOMPARE(qtPrinters.at(i), testPrinters.at(i));
} }
#endif
void tst_QPrinterInfo::testForPaperSizes() void tst_QPrinterInfo::testForPaperSizes()
{ {
@ -324,7 +313,5 @@ void tst_QPrinterInfo::namedPrinter()
} }
} }
#endif // QT_NO_PRINTER
QTEST_MAIN(tst_QPrinterInfo) QTEST_MAIN(tst_QPrinterInfo)
#include "tst_qprinterinfo.moc" #include "tst_qprinterinfo.moc"