summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp46
1 files changed, 45 insertions, 1 deletions
diff --git a/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp b/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp
index 8fd5237606..083324bdd8 100644
--- a/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp
+++ b/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp
@@ -58,6 +58,8 @@ private slots:
void loopCount();
void state();
void totalDuration();
+ void avoidJumpAtStart();
+ void avoidJumpAtStartWithStop();
};
class TestableQAbstractAnimation : public QAbstractAnimation
@@ -65,10 +67,15 @@ class TestableQAbstractAnimation : public QAbstractAnimation
Q_OBJECT
public:
+ TestableQAbstractAnimation() : m_duration(10) {}
virtual ~TestableQAbstractAnimation() {};
- int duration() const { return 10; }
+ int duration() const { return m_duration; }
virtual void updateCurrentTime(int) {}
+
+ void setDuration(int duration) { m_duration = duration; }
+private:
+ int m_duration;
};
class DummyQAnimationGroup : public QAnimationGroup
@@ -150,6 +157,43 @@ void tst_QAbstractAnimation::totalDuration()
QCOMPARE(anim.totalDuration(), 50);
}
+void tst_QAbstractAnimation::avoidJumpAtStart()
+{
+ TestableQAbstractAnimation anim;
+ anim.setDuration(1000);
+
+ /*
+ the timer shouldn't actually start until we hit the event loop,
+ so the sleep should have no effect
+ */
+ anim.start();
+ QTest::qSleep(300);
+ QCoreApplication::processEvents();
+ QVERIFY(anim.currentTime() < 50);
+}
+
+void tst_QAbstractAnimation::avoidJumpAtStartWithStop()
+{
+ TestableQAbstractAnimation anim;
+ anim.setDuration(1000);
+
+ TestableQAbstractAnimation anim2;
+ anim2.setDuration(1000);
+
+ anim.start();
+ QTest::qWait(300);
+ anim.stop();
+
+ /*
+ same test as avoidJumpAtStart, but after there is a
+ running animation that is stopped
+ */
+ anim2.start();
+ QTest::qSleep(300);
+ QCoreApplication::processEvents();
+ QVERIFY(anim2.currentTime() < 50);
+}
+
QTEST_MAIN(tst_QAbstractAnimation)
#include "tst_qabstractanimation.moc"