diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-12-14 11:12:30 +0100 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2021-01-26 21:47:47 +0100 |
commit | 519420641fabeeb7a372ed6157a7bc01f43b1b3b (patch) | |
tree | fa8e95f080040de2ef4e95d3d130de1e42c6f011 /tests/auto/corelib | |
parent | feb20459bd795338d2247f2f97681c8bbc97b159 (diff) |
Port QPauseAnimation to the new property system
Task-number: QTBUG-85520
Change-Id: I8c0ee86598f4c0f093f64b2891ee835a43964b84
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp index a10930b517..0688eafda8 100644 --- a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp +++ b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp @@ -105,6 +105,7 @@ private slots: void sequentialGroupWithPause(); void multipleSequentialGroups(); void zeroDuration(); + void bindings(); }; void tst_QPauseAnimation::initTestCase() @@ -442,5 +443,45 @@ void tst_QPauseAnimation::zeroDuration() QCOMPARE(animation.m_updateCurrentTimeCount, 1); } +void tst_QPauseAnimation::bindings() +{ + TestablePauseAnimation animation; + + QProperty<int> duration; + animation.bindableDuration().setBinding(Qt::makePropertyBinding(duration)); + + duration = 42; + QCOMPARE(animation.duration(), 42); + + // negative values must be ignored + QTest::ignoreMessage(QtWarningMsg, + "QPauseAnimation::setDuration: cannot set a negative duration"); + duration = -1; + QCOMPARE(animation.duration(), 42); + QCOMPARE(duration, -1); + + // Setting an invalid value shouldn't clear the binding + QTest::ignoreMessage(QtWarningMsg, + "QPauseAnimation::setDuration: cannot set a negative duration"); + animation.setDuration(-1); + QVERIFY(animation.bindableDuration().hasBinding()); + QCOMPARE(animation.duration(), 42); + + QProperty<int> durationObserver; + durationObserver.setBinding(animation.bindableDuration().makeBinding()); + + animation.setDuration(46); + QCOMPARE(durationObserver, 46); + + // Setting a valid value should clear the binding + QVERIFY(!animation.bindableDuration().hasBinding()); + + // Setting an invalid value also doesn't affect the observer + QTest::ignoreMessage(QtWarningMsg, + "QPauseAnimation::setDuration: cannot set a negative duration"); + animation.setDuration(-1); + QCOMPARE(durationObserver, 46); +} + QTEST_MAIN(tst_QPauseAnimation) #include "tst_qpauseanimation.moc" |