aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickanimators/tst_qquickanimators.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-10-19 21:11:22 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-10-22 06:53:42 +0200
commitec9d125f553c073ec7a431114a568eaeb6534b63 (patch)
treebd1fc3cd74c0f26c82c76136f39a0f27ef716abb /tests/auto/quick/qquickanimators/tst_qquickanimators.cpp
parentdac2c8aec4917742aed6e311cf542dc37da60809 (diff)
Update and activate tst_animators
Amends a0f8be4021caa9bb5055923f0eea3bee0e345235; it's not clear if there's any reason we haven't been running this test all these years. But we need to use testFileUrl() for loading QML files, and some additional updates make it more like the other tests. Regenerated CMakeLists.txt from the .pro files: python3 ~/dev/qt6/qtbase/util/cmake/pro2cmake.py *.pro Pick-to: 5.15 Change-Id: I3ddcc993c4536c2d4d751a37c0425943c7d86766 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickanimators/tst_qquickanimators.cpp')
-rw-r--r--tests/auto/quick/qquickanimators/tst_qquickanimators.cpp47
1 files changed, 27 insertions, 20 deletions
diff --git a/tests/auto/quick/qquickanimators/tst_qquickanimators.cpp b/tests/auto/quick/qquickanimators/tst_qquickanimators.cpp
index 29142dee12..b35e4b4cc9 100644
--- a/tests/auto/quick/qquickanimators/tst_qquickanimators.cpp
+++ b/tests/auto/quick/qquickanimators/tst_qquickanimators.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -26,16 +26,20 @@
**
****************************************************************************/
-#include <qtest.h>
+#include <QtTest/QtTest>
+#include <QtQuickTest/quicktest.h>
-#include <QtQuick>
-#include <private/qquickanimator_p.h>
-#include <private/qquickrepeater_p.h>
-#include <private/qquicktransition_p.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/private/qquickanimator_p.h>
+#include <QtQuick/private/qquickrepeater_p.h>
+#include <QtQuick/private/qquicktransition_p.h>
-#include <QtQml>
+#include "../../shared/util.h"
+#include "../shared/viewtestutil.h"
-class tst_Animators: public QObject
+using namespace QQuickViewTestUtil;
+
+class tst_Animators: public QQmlDataTest
{
Q_OBJECT
@@ -58,10 +62,10 @@ void tst_Animators::testMultiWinAnimator()
QFETCH(int, count);
QQmlEngine engine;
- QQmlComponent component(&engine, "data/windowWithAnimator.qml");
+ QQmlComponent component(&engine, testFileUrl("windowWithAnimator.qml"));
QList<QQuickWindow *> windows;
- for (int i=0; i<count; ++i) {
+ for (int i = 0; i < count; ++i) {
QQuickWindow *win = qobject_cast<QQuickWindow *>(component.create());
windows << win;
@@ -71,9 +75,10 @@ void tst_Animators::testMultiWinAnimator()
// to ensure they are exposed and actually rendering.
if (i > 0) {
QPoint pos = win->position();
- if (pos == windows.first()->position())
+ if (pos == windows.first()->position()) {
pos += QPoint(10 * i, 10 * i);
win->setPosition(pos);
+ }
}
}
@@ -99,24 +104,26 @@ void tst_Animators::testMultiWinAnimator()
void tst_Animators::testTransitions()
{
- QQuickView view(QUrl::fromLocalFile("data/positionerWithAnimator.qml"));
- view.show();
- QVERIFY(QTest::qWaitForWindowExposed(&view));
- QVERIFY(view.rootObject());
-
- QQuickRepeater *repeater = view.rootObject()->property("repeater").value<QQuickRepeater *>();
+ QScopedPointer<QQuickView> view(createView());
+ view->setSource(testFileUrl("positionerWithAnimator.qml"));
+ view->show();
+ QVERIFY(QTest::qWaitForWindowExposed(view.data()));
+ QQuickItem *root = view->rootObject();
+ QVERIFY(root);
+
+ QQuickRepeater *repeater = root->property("repeater").value<QQuickRepeater *>();
QVERIFY(repeater);
QQuickItem *child = repeater->itemAt(0);
QVERIFY(child);
- QCOMPARE(child->scale(), qreal(0.0));
+ QCOMPARE(child->scale(), qreal(0));
- QQuickTransition *transition = view.rootObject()->property("transition").value<QQuickTransition *>();
+ QQuickTransition *transition = root->property("transition").value<QQuickTransition *>();
QVERIFY(transition);
QTRY_VERIFY(transition->running());
QTRY_VERIFY(!transition->running());
- QCOMPARE(child->scale(), qreal(1.0));
+ QCOMPARE(child->scale(), qreal(1));
}
#include "tst_qquickanimators.moc"