diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2011-10-05 15:10:37 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-06 05:28:32 +0200 |
commit | a55034062ba2bf73a9f1ed3d9cf31745b38149e3 (patch) | |
tree | b5bd49241b240abdb39e5df956372b9ce6f58516 | |
parent | 7232bc0e1c56dc95fe8affaff1155486cf84e0b7 (diff) |
Avoid QSKIP in lieu of compile-time check.
Omit focusColors test function at compile-time in preference to
skipping at run-time. Also removed commented out code.
Change-Id: Ib8955656f5a43b30df95b4c9865e52902dbd6b1e
Reviewed-on: http://codereview.qt-project.org/6010
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
-rw-r--r-- | tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp | 127 |
1 files changed, 52 insertions, 75 deletions
diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index 0ff28396d5..98e64eb17d 100644 --- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -79,7 +79,9 @@ private slots: void fontPropagation(); void onWidgetDestroyed(); void fontPrecedence(); +#if defined(Q_OS_WIN32) || defined(Q_OS_MAC) || (defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(Q_CC_INTEL)) void focusColors(); +#endif void hoverColors(); void background(); void tabAlignement(); @@ -724,6 +726,9 @@ static bool testForColors(const QImage& image, const QColor& color, bool ensureP return false; } +// This is a fragile test which fails on many esoteric platforms +// because of focus problems. Test only on Windows, Mac, and Linux/gcc. +#if defined(Q_OS_WIN32) || defined(Q_OS_MAC) || (defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(Q_CC_INTEL)) void tst_QStyleSheetStyle::focusColors() { // Tests if colors can be changed by altering the focus of the widget. @@ -731,92 +736,64 @@ void tst_QStyleSheetStyle::focusColors() // is reached if at least ten pixels of the right color can be found in // the image. // For this reason, we use unusual and extremely ugly colors! :-) - -#if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC) && !(defined(Q_OS_LINUX) && defined(Q_CC_GNU) \ - && !defined(Q_CC_INTEL)) - QSKIP("This is a fragile test which fails on many esoteric platforms " - "because of focus problems. " - "That doesn't mean that the feature doesn't work in practice.", SkipAll); -#endif -/* Disabled changing style in order not to mess with the application style -#ifdef Q_OS_MAC - int styleCount = 3; - QStyle *styles[3]; -#else - int styleCount = 2; - QStyle *styles[2]; -#endif - - styles[0] = new QPlastiqueStyle; - styles[1] = new QWindowsStyle; - -#ifdef Q_OS_MAC - styles[2] = new QMacStyle; -#endif - - - for (int i = 0; i < styleCount; ++i) { - qApp->setStyle(styles[i]); -*/ - QList<QWidget *> widgets; - widgets << new QPushButton("TESTING"); - widgets << new QLineEdit("TESTING"); - widgets << new QLabel("TESTING"); - QSpinBox *spinbox = new QSpinBox; - spinbox->setValue(8888); - widgets << spinbox; - QComboBox *combobox = new QComboBox; - combobox->setEditable(true); - combobox->addItems(QStringList() << "TESTING"); - widgets << combobox; - widgets << new QLabel("TESTING"); + QList<QWidget *> widgets; + widgets << new QPushButton("TESTING"); + widgets << new QLineEdit("TESTING"); + widgets << new QLabel("TESTING"); + QSpinBox *spinbox = new QSpinBox; + spinbox->setValue(8888); + widgets << spinbox; + QComboBox *combobox = new QComboBox; + combobox->setEditable(true); + combobox->addItems(QStringList() << "TESTING"); + widgets << combobox; + widgets << new QLabel("TESTING"); #ifdef Q_WS_QWS - // QWS has its own special focus logic which is slightly different - // and I don't dare change it at this point, because someone will - // be relying on it. It means that setFocus() on a NoFocus widget (i.e. - // a QLabel) will not work before the window is activated. - widgets[2]->setFocusPolicy(Qt::StrongFocus); + // QWS has its own special focus logic which is slightly different + // and I don't dare change it at this point, because someone will + // be relying on it. It means that setFocus() on a NoFocus widget (i.e. + // a QLabel) will not work before the window is activated. + widgets[2]->setFocusPolicy(Qt::StrongFocus); #endif - foreach (QWidget *widget, widgets) { - QDialog frame; - QLayout* layout = new QGridLayout; - - QLineEdit* dummy = new QLineEdit; // Avoids initial focus. + foreach (QWidget *widget, widgets) { + QDialog frame; + QLayout* layout = new QGridLayout; - widget->setStyleSheet("*:focus { border:none; background: #e8ff66; color: #ff0084 }"); + QLineEdit* dummy = new QLineEdit; // Avoids initial focus. - layout->addWidget(dummy); - layout->addWidget(widget); - frame.setLayout(layout); + widget->setStyleSheet("*:focus { border:none; background: #e8ff66; color: #ff0084 }"); - frame.show(); - QTest::qWaitForWindowShown(&frame); - QApplication::setActiveWindow(&frame); - widget->setFocus(); - QApplication::processEvents(); + layout->addWidget(dummy); + layout->addWidget(widget); + frame.setLayout(layout); - QImage image(frame.width(), frame.height(), QImage::Format_ARGB32); - frame.render(&image); - if (image.depth() < 24) { - QSKIP("Test doesn't support color depth < 24", SkipAll); - } + frame.show(); + QTest::qWaitForWindowShown(&frame); + QApplication::setActiveWindow(&frame); + widget->setFocus(); + QApplication::processEvents(); - QVERIFY2(testForColors(image, QColor(0xe8, 0xff, 0x66)), - (QString::fromLatin1(widget->metaObject()->className()) - + " did not contain background color #e8ff66, using style " - + QString::fromLatin1(qApp->style()->metaObject()->className())) - .toLocal8Bit().constData()); - QVERIFY2(testForColors(image, QColor(0xff, 0x00, 0x84)), - (QString::fromLatin1(widget->metaObject()->className()) - + " did not contain text color #ff0084, using style " - + QString::fromLatin1(qApp->style()->metaObject()->className())) - .toLocal8Bit().constData()); + QImage image(frame.width(), frame.height(), QImage::Format_ARGB32); + frame.render(&image); + if (image.depth() < 24) { + QSKIP("Test doesn't support color depth < 24", SkipAll); } - // } -} + QVERIFY2(testForColors(image, QColor(0xe8, 0xff, 0x66)), + (QString::fromLatin1(widget->metaObject()->className()) + + " did not contain background color #e8ff66, using style " + + QString::fromLatin1(qApp->style()->metaObject()->className())) + .toLocal8Bit().constData()); + QVERIFY2(testForColors(image, QColor(0xff, 0x00, 0x84)), + (QString::fromLatin1(widget->metaObject()->className()) + + " did not contain text color #ff0084, using style " + + QString::fromLatin1(qApp->style()->metaObject()->className())) + .toLocal8Bit().constData()); + } +} +#endif void tst_QStyleSheetStyle::hoverColors() { |