summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2020-01-06 13:23:42 +0100
committerMorten Johan Sørvig <morten.sorvig@qt.io>2020-01-09 13:52:25 +0100
commit5507d0f1b04ea6b1d91be9ade30bc31d1830c220 (patch)
tree95a7709e4b2201fd9df351b575b7efa0a61366ad /tests
parent89c4bb5f2473b4616fdccbcc616eedfaa5d628cc (diff)
Make setReadOnly track ReadOnlyChange events only
The test was previously tracking all Change events, which made it fragile. Change-Id: I17872341237009a9a0a2ad2fd5482f917991d7b2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
index 30c57c73e5..f8022559b2 100644
--- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
+++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
@@ -500,26 +500,27 @@ void tst_QSpinBox::valueChangedHelper(int value)
actualValues << value;
}
-class MySpinBox: public QSpinBox
+class ReadOnlyChangeTracker: public QSpinBox
{
public:
- MySpinBox(QWidget *parent = 0) : QSpinBox(parent) {}
+ ReadOnlyChangeTracker(QWidget *parent = 0) : QSpinBox(parent) {}
void changeEvent(QEvent *ev) {
- eventsReceived.append(ev->type());
+ if (ev->type() == QEvent::ReadOnlyChange)
+ ++readOnlyChangeEventCount;
}
- QList<QEvent::Type> eventsReceived;
+ int readOnlyChangeEventCount = 0;
};
void tst_QSpinBox::setReadOnly()
{
- MySpinBox spin(0);
+ ReadOnlyChangeTracker spin(0);
spin.show();
QTest::keyClick(&spin, Qt::Key_Up);
QCOMPARE(spin.value(), 1);
spin.setReadOnly(true);
#ifndef Q_OS_WINRT // QTBUG-68297
- QCOMPARE(spin.eventsReceived, QList<QEvent::Type>() << QEvent::ReadOnlyChange);
+ QCOMPARE(spin.readOnlyChangeEventCount, 1);
#endif
QTest::keyClick(&spin, Qt::Key_Up);
QCOMPARE(spin.value(), 1);
@@ -527,7 +528,7 @@ void tst_QSpinBox::setReadOnly()
QCOMPARE(spin.value(), 2);
spin.setReadOnly(false);
#ifndef Q_OS_WINRT // QTBUG-68297
- QCOMPARE(spin.eventsReceived, QList<QEvent::Type>() << QEvent::ReadOnlyChange << QEvent::ReadOnlyChange);
+ QCOMPARE(spin.readOnlyChangeEventCount, 2);
#endif
QTest::keyClick(&spin, Qt::Key_Up);
QCOMPARE(spin.value(), 3);