summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2023-08-25 18:05:36 +0200
committerIvan Solovev <ivan.solovev@qt.io>2023-09-03 18:20:51 +0200
commit7d70edd31cb4c55471ad96e3a1d7114e2c081cf6 (patch)
treefd3a126a2866e7bb1a023c6595c8dcc785ab32b6 /tests/auto/corelib/kernel
parentcdb50edc9862679e8795a8404ce49fb26534f4bc (diff)
QTimer: extend property tests and fix binding loop
The bindable property tests were not using the QTestPrivate helpers, so add a new test which uses them. The new tests revealed a binding loop for the interval property. Fix it in a usual way by explicitly removing the binding and using {set}ValueBypassingBindings() in the setter. Task-number: QTBUG-116346 Pick-to: 6.6 6.5 Change-Id: If94f57938da449a68e3527aead5ebd55ba410adb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'tests/auto/corelib/kernel')
-rw-r--r--tests/auto/corelib/kernel/qtimer/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp38
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qtimer/CMakeLists.txt b/tests/auto/corelib/kernel/qtimer/CMakeLists.txt
index e7ac67d12e..4959caa2ad 100644
--- a/tests/auto/corelib/kernel/qtimer/CMakeLists.txt
+++ b/tests/auto/corelib/kernel/qtimer/CMakeLists.txt
@@ -16,6 +16,7 @@ qt_internal_add_test(tst_qtimer
tst_qtimer.cpp
LIBRARIES
Qt::CorePrivate
+ Qt::TestPrivate
)
if(QT_FEATURE_glib AND UNIX)
@@ -26,5 +27,6 @@ if(QT_FEATURE_glib AND UNIX)
DISABLE_GLIB
LIBRARIES
Qt::CorePrivate
+ Qt::TestPrivate
)
endif()
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index dcce526a35..4ece1dc2b4 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -12,6 +12,7 @@
#include <QtCore/private/qglobal_p.h>
#include <QTest>
#include <QSignalSpy>
+#include <QtTest/private/qpropertytesthelper_p.h>
#include <qtimer.h>
#include <qthread.h>
@@ -89,6 +90,7 @@ private slots:
void bindToTimer();
void bindTimer();
+ void automatedBindingTests();
};
void tst_QTimer::zeroTimer()
@@ -1326,6 +1328,42 @@ void tst_QTimer::bindTimer()
QCOMPARE(timer.timerType(), Qt::VeryCoarseTimer);
}
+void tst_QTimer::automatedBindingTests()
+{
+ QTimer timer;
+
+ QVERIFY(!timer.isSingleShot());
+ QTestPrivate::testReadWritePropertyBasics(timer, true, false, "singleShot");
+ if (QTest::currentTestFailed()) {
+ qDebug("Failed property test for QTimer::singleShot");
+ return;
+ }
+
+ QCOMPARE_NE(timer.interval(), 10);
+ QTestPrivate::testReadWritePropertyBasics(timer, 10, 20, "interval");
+ if (QTest::currentTestFailed()) {
+ qDebug("Failed property test for QTimer::interval");
+ return;
+ }
+
+ QCOMPARE_NE(timer.timerType(), Qt::PreciseTimer);
+ QTestPrivate::testReadWritePropertyBasics(timer, Qt::PreciseTimer, Qt::CoarseTimer,
+ "timerType");
+ if (QTest::currentTestFailed()) {
+ qDebug("Failed property test for QTimer::timerType");
+ return;
+ }
+
+ timer.start(1000);
+ QVERIFY(timer.isActive());
+ QTestPrivate::testReadOnlyPropertyBasics(timer, true, false, "active",
+ [&timer]() { timer.stop(); });
+ if (QTest::currentTestFailed()) {
+ qDebug("Failed property test for QTimer::active");
+ return;
+ }
+}
+
class OrderHelper : public QObject
{
Q_OBJECT