summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp')
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp54
1 files changed, 22 insertions, 32 deletions
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
index a506bbb114..d8c70a0cc1 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -34,8 +34,6 @@
#include <private/qstylesheetstyle_p.h>
-#include "../../../qtest-config.h"
-
static inline void centerOnScreen(QWidget *w)
{
const QPoint offset = QPoint(w->width() / 2, w->height() / 2);
@@ -76,7 +74,7 @@ private slots:
void onWidgetDestroyed();
void fontPrecedence();
void focusColors();
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void hoverColors();
#endif
void background();
@@ -819,6 +817,24 @@ static bool testForColors(const QImage& image, const QColor& color, bool ensureP
return false;
}
+static const QList<QWidget*> sample_widgets() // returning const to avoid detaching when passing to range-for
+{
+ QList<QWidget *> widgets;
+ widgets << new QPushButton("TESTING TESTING");
+ widgets << new QLineEdit("TESTING TESTING");
+ widgets << new QLabel("TESTING TESTING");
+ QSpinBox *spinbox = new QSpinBox;
+ spinbox->setMaximum(1000000000);
+ spinbox->setValue(123456789);
+ widgets << spinbox;
+ QComboBox *combobox = new QComboBox;
+ combobox->setEditable(true);
+ combobox->addItems(QStringList() << "TESTING TESTING");
+ widgets << combobox;
+ widgets << new QLabel("<b>TESTING TESTING</b>");
+ return widgets;
+}
+
void tst_QStyleSheetStyle::focusColors()
{
// Tests if colors can be changed by altering the focus of the widget.
@@ -835,22 +851,9 @@ void tst_QStyleSheetStyle::focusColors()
" (for example, QTBUG-33959)."
"That doesn't mean that the feature doesn't work in practice.");
#endif
- QList<QWidget *> widgets;
- widgets << new QPushButton("TESTING TESTING");
- widgets << new QLineEdit("TESTING TESTING");
- widgets << new QLabel("TESTING TESTING");
- QSpinBox *spinbox = new QSpinBox;
- spinbox->setMaximum(1000000000);
- spinbox->setValue(123456789);
- widgets << spinbox;
- QComboBox *combobox = new QComboBox;
- combobox->setEditable(true);
- combobox->addItems(QStringList() << "TESTING TESTING");
- widgets << combobox;
- widgets << new QLabel("TESTING TESTING");
- foreach (QWidget *widget, widgets) {
+ for (QWidget *widget : sample_widgets()) {
QDialog frame;
QLayout* layout = new QGridLayout;
@@ -887,27 +890,14 @@ void tst_QStyleSheetStyle::focusColors()
}
}
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void tst_QStyleSheetStyle::hoverColors()
{
#ifdef Q_OS_OSX
QSKIP("This test is fragile on Mac, most likely due to QTBUG-33959.");
#endif
- QList<QWidget *> widgets;
- widgets << new QPushButton("TESTING TESTING");
- widgets << new QLineEdit("TESTING TESTING");
- widgets << new QLabel("TESTING TESTING");
- QSpinBox *spinbox = new QSpinBox;
- spinbox->setMaximum(1000000000);
- spinbox->setValue(123456789);
- widgets << spinbox;
- QComboBox *combobox = new QComboBox;
- combobox->setEditable(true);
- combobox->addItems(QStringList() << "TESTING TESTING");
- widgets << combobox;
- widgets << new QLabel("<b>TESTING TESTING</b>");
- foreach (QWidget *widget, widgets) {
+ for (QWidget *widget : sample_widgets()) {
//without Qt::X11BypassWindowManagerHint the window manager may move the window after we moved the cursor
QDialog frame(0, Qt::X11BypassWindowManagerHint);
QLayout* layout = new QGridLayout;