aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquickanimations/tst_qquickanimations.cpp')
-rw-r--r--tests/auto/quick/qquickanimations/tst_qquickanimations.cpp70
1 files changed, 66 insertions, 4 deletions
diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
index 6bc8a05607..313f478820 100644
--- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
+++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
@@ -46,13 +46,13 @@
#include <limits.h>
#include <math.h>
-#include "../../shared/util.h"
+#include <QtQuickTestUtils/private/qmlutils_p.h>
class tst_qquickanimations : public QQmlDataTest
{
Q_OBJECT
public:
- tst_qquickanimations() {}
+ tst_qquickanimations() : QQmlDataTest(QT_QMLTEST_DATADIR) {}
private slots:
void initTestCase() override
@@ -116,8 +116,9 @@ private slots:
void fastFlickingBug();
void opacityAnimationFromZero();
void alwaysRunToEndInSequentialAnimationBug();
+ void cleanupWhenRenderThreadStops();
+ void infiniteLoopsWithoutFrom();
};
-
#define QTIMED_COMPARE(lhs, rhs) do { \
for (int ii = 0; ii < 5; ++ii) { \
if (lhs == rhs) \
@@ -1898,7 +1899,7 @@ void tst_qquickanimations::opacityAnimationFromZero()
void tst_qquickanimations::alwaysRunToEndInSequentialAnimationBug()
{
- QQuickView view(QUrl::fromLocalFile("data/alwaysRunToEndInSequentialAnimationBug.qml"));
+ QQuickView view(testFileUrl("alwaysRunToEndInSequentialAnimationBug.qml"));
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
@@ -1998,6 +1999,67 @@ void tst_qquickanimations::alwaysRunToEndInSequentialAnimationBug()
QCOMPARE(whiteRect->property("opacity").value<qreal>(),1.0);
}
+void tst_qquickanimations::cleanupWhenRenderThreadStops()
+{
+ QQuickView view(testFileUrl("cleanupWhenRenderThreadStops.qml"));
+ view.show();
+ view.setPersistentGraphics(false);
+ view.setPersistentSceneGraph(false);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QTest::qWait(50);
+ view.hide();
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+}
+
+void tst_qquickanimations::infiniteLoopsWithoutFrom()
+{
+ // This test checks QTBUG-84375
+ QQuickView view(testFileUrl("infiniteAnimationWithoutFrom.qml"));
+ view.show();
+
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QVERIFY(view.rootObject());
+
+ QObject *root = view.rootObject();
+ QQuickAbstractAnimation *animation = root->findChild<QQuickAbstractAnimation *>("anim");
+ QVERIFY(animation);
+ QQuickRectangle *rectangle = root->findChild<QQuickRectangle *>("rect");
+ QVERIFY(rectangle);
+
+ qreal prevRotation = rectangle->rotation();
+ int numsCrossedZero = 0;
+ connect(rectangle, &QQuickRectangle::rotationChanged, this, [&]() {
+ const auto rotation = rectangle->rotation();
+ // We take a large range of (180; 360] here, because the animation in
+ // the test runs for a short time, and so there can be huge gaps between
+ // rotation values.
+ const bool prevRotationOldLoop = prevRotation > 180.0 && prevRotation <= 360.0;
+ const bool currRotationNewLoop = rotation >= 0.0 && rotation <= 180.0;
+ if (prevRotationOldLoop && currRotationNewLoop)
+ numsCrossedZero++;
+ prevRotation = rotation;
+ });
+
+ // The logic in lamdba function above requires at least two positions in
+ // a rotation animation - one in [0; 180] range, and another in (180; 360]
+ // range
+ animation->start();
+ animation->pause();
+ QCOMPARE(numsCrossedZero, 0);
+ animation->setCurrentTime(40);
+ animation->setCurrentTime(90);
+ QCOMPARE(numsCrossedZero, 0);
+ animation->setCurrentTime(140);
+ animation->setCurrentTime(190);
+ QCOMPARE(numsCrossedZero, 1);
+ animation->setCurrentTime(240);
+ animation->setCurrentTime(290);
+ QCOMPARE(numsCrossedZero, 2);
+
+ animation->stop();
+}
+
QTEST_MAIN(tst_qquickanimations)
#include "tst_qquickanimations.moc"