summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-08-07 15:32:40 +0300
committerMarc Mutz <marc.mutz@kdab.com>2016-08-17 08:58:50 +0000
commitaf5ccb7f8c91591ef9dec1ccf0ca211962002a94 (patch)
tree5060a8098b3e2117a370e8c82c41e954241cbb31 /tests
parent3d39c66369300569fa596e2d44b3d7887b6a9005 (diff)
tst_QStyleSheetStyle: Extract Method sample_widgets()
The only difference between the sample widget sets was: - widgets << new QLabel("TESTING TESTING"); + widgets << new QLabel("<b>TESTING TESTING</b>"); I chose the latter, because it's the more complex example and neither the hoverColors nor focusColors tests suggest the boldness of the text matters. Part of port away from Q_FOREACH. Change-Id: I9a928de4e781b96ad00a8c9515977c35ebfa6c24 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp48
1 files changed, 20 insertions, 28 deletions
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 8d84addedb..b95a17bd4e 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -817,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.
@@ -833,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;
@@ -891,21 +896,8 @@ 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;