Prefer QSKIP to QTEST_NOOP_MAIN.
authorJason McDonald <jason.mcdonald@nokia.com>
Mon, 17 Oct 2011 05:06:58 +0000 (15:06 +1000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 18 Oct 2011 01:10:24 +0000 (03:10 +0200)
Use QSKIP instead of QTEST_NOOP_MAIN so that the user receives a clear
indication that these tests aren't testing anything when the required
defines are not defined.

Change-Id: I977e24205a1bb7787ecddbdb1ebbeda1f2ded321
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
tests/auto/gui/painting/qprinter/tst_qprinter.cpp
tests/auto/gui/painting/qprinterinfo/tst_qprinterinfo.cpp
tests/auto/qabstractprintdialog/tst_qabstractprintdialog.cpp

index a3d5f10..508d0ea 100644 (file)
@@ -63,22 +63,14 @@ QT_FORWARD_DECLARE_CLASS(QPrinter)
 //TESTED_CLASS=
 //TESTED_FILES=
 
-#ifndef QT_NO_PRINTER
-
 class tst_QPrinter : public QObject
 {
     Q_OBJECT
 
-public:
-    tst_QPrinter();
-    virtual ~tst_QPrinter();
-
-
+#ifdef QT_NO_PRINTER
 public slots:
     void initTestCase();
-    void cleanupTestCase();
-    void init();
-    void cleanup();
+#else
 private slots:
     void getSetCheck();
 // Add your testfunctions and testdata create functions here
@@ -113,8 +105,17 @@ private slots:
 
     void taskQTBUG4497_reusePrinterOnDifferentFiles();
     void testPdfTitle();
+#endif
 };
 
+#ifdef QT_NO_PRINTER
+void tst_QPrinter::initTestCase()
+{
+    QSKIP("This test requires printing support", SkipAll);
+}
+
+#else
+
 // Testing get/set functions
 void tst_QPrinter::getSetCheck()
 {
@@ -211,47 +212,6 @@ void tst_QPrinter::getSetCheck()
     QCOMPARE(QPrinter::PrintRange(QPrinter::PageRange), obj1.printRange());
 }
 
-tst_QPrinter::tst_QPrinter()
-{
-}
-
-tst_QPrinter::~tst_QPrinter()
-{
-}
-
-// initTestCase will be executed once before the first testfunction is executed.
-void tst_QPrinter::initTestCase()
-{
-// TODO: Add testcase generic initialization code here.
-// suggestion:
-//    testWidget = new QPrinter(0,"testWidget");
-//    testWidget->setFixedSize(200, 200);
-//    qApp->setMainWidget(testWidget);
-//    testWidget->show();
-}
-
-// cleanupTestCase will be executed once after the last testfunction is executed.
-void tst_QPrinter::cleanupTestCase()
-{
-// TODO: Add testcase generic cleanup code here.
-// suggestion:
-//    testWidget->hide();
-//    qApp->setMainWidget(0);
-//    delete testWidget;
-}
-
-// init() will be executed immediately before each testfunction is run.
-void tst_QPrinter::init()
-{
-// TODO: Add testfunction specific initialization code here.
-}
-
-// cleanup() will be executed immediately after each testfunction is run.
-void tst_QPrinter::cleanup()
-{
-// TODO: Add testfunction specific cleanup code here.
-}
-
 #define MYCOMPARE(a, b) QCOMPARE(QVariant((int)a), QVariant((int)b))
 
 void tst_QPrinter::testPageSetupDialog()
@@ -1033,11 +993,7 @@ void tst_QPrinter::testPdfTitle()
     QVERIFY(file.readAll().contains(QByteArray(expected, 26)));
 }
 
+#endif
+
 QTEST_MAIN(tst_QPrinter)
 #include "tst_qprinter.moc"
-
-#else //QT_NO_PRINTER
-
-QTEST_NOOP_MAIN
-
-#endif //QT_NO_PRINTER
index f4579cf..2976649 100644 (file)
@@ -44,8 +44,6 @@
 #include <QtGlobal>
 #include <QtAlgorithms>
 #include <QtNetwork/QHostInfo>
-
-#ifndef QT_NO_PRINTER
 #include <qprinterinfo.h>
 
 #ifdef Q_OS_UNIX
@@ -63,16 +61,10 @@ class tst_QPrinterInfo : public QObject
 {
     Q_OBJECT
 
-public:
-    //tst_QPrinterInfo();
-    //virtual ~tst_QPrinterInfo();
-
-
+#ifdef QT_NO_PRINTER
 public slots:
-    //void initTestCase();
-    //void cleanupTestCase();
-    //void init();
-    //void cleanup();
+    void initTestCase();
+#else
 private slots:
 #if defined(Q_OS_UNIX) || defined(Q_OS_WIN32)
     void testForDefaultPrinter();
@@ -88,8 +80,17 @@ private:
     QStringList getPrintersFromSystem();
 
     QString getOutputFromCommand(const QStringList& command);
+#endif
 };
 
+#ifdef QT_NO_PRINTER
+void tst_QPrinterInfo::initTestCase()
+{
+    QSKIP("This test requires printing support", SkipAll);
+}
+
+#else
+
 void tst_QPrinterInfo::macFixNameFormat(QString *printerName)
 {
 // Modify the format of the printer name to match Qt, lpstat returns
@@ -386,8 +387,7 @@ void tst_QPrinterInfo::testAssignment()
     }
 }
 
+#endif
+
 QTEST_MAIN(tst_QPrinterInfo)
 #include "tst_qprinterinfo.moc"
-#else
-QTEST_NOOP_MAIN
-#endif
index a72b12e..5d6165d 100644 (file)
 //TESTED_CLASS=
 //TESTED_FILES=
 
-#if !defined(QT_NO_PRINTER) && !defined(QT_NO_PRINTDIALOG)
-
 class tst_QAbstractPrintDialog : public QObject
 {
 Q_OBJECT
 
-public:
-    tst_QAbstractPrintDialog();
-    virtual ~tst_QAbstractPrintDialog();
-
+#if defined(QT_NO_PRINTER) || defined(QT_NO_PRINTDIALOG)
+public slots:
+    void initTestCase();
+#else
 private slots:
     void getSetCheck();
     void setMinMax();
     void setFromTo();
+#endif
 };
 
+#if defined(QT_NO_PRINTER) || defined(QT_NO_PRINTDIALOG)
+void tst_QAbstractPrintDialog::initTestCase()
+{
+    QSKIP("This test requires printing and print dialog support", SkipAll);
+}
+
+#else
+
 class MyAbstractPrintDialog : public QAbstractPrintDialog
 {
 public:
@@ -73,14 +80,6 @@ public:
     int exec() { return 0; }
 };
 
-tst_QAbstractPrintDialog::tst_QAbstractPrintDialog()
-{
-}
-
-tst_QAbstractPrintDialog::~tst_QAbstractPrintDialog()
-{
-}
-
 // Testing get/set functions
 void tst_QAbstractPrintDialog::getSetCheck()
 {
@@ -141,11 +140,7 @@ void tst_QAbstractPrintDialog::setFromTo()
     QCOMPARE(obj1.maxPage(), 50);
 }
 
+#endif
+
 QTEST_MAIN(tst_QAbstractPrintDialog)
 #include "tst_qabstractprintdialog.moc"
-
-#else
-
-QTEST_NOOP_MAIN
-
-#endif