From 9ebb64735775974bb376a3f58ba9fd3bba72a968 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 19 Oct 2020 21:11:22 +0200 Subject: 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. Change-Id: I3ddcc993c4536c2d4d751a37c0425943c7d86766 Reviewed-by: Mitch Curtis (cherry picked from commit ec9d125f553c073ec7a431114a568eaeb6534b63) Reviewed-by: Ulf Hermann --- .../auto/quick/qquickanimators/qquickanimators.pro | 5 +++ .../quick/qquickanimators/tst_qquickanimators.cpp | 47 +++++++++++++--------- tests/auto/quick/quick.pro | 1 + 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/tests/auto/quick/qquickanimators/qquickanimators.pro b/tests/auto/quick/qquickanimators/qquickanimators.pro index 4ff2471fde..3cc3067e77 100644 --- a/tests/auto/quick/qquickanimators/qquickanimators.pro +++ b/tests/auto/quick/qquickanimators/qquickanimators.pro @@ -4,3 +4,8 @@ CONFIG += testcase macx: CONFIG -= app_bundle SOURCES += tst_qquickanimators.cpp +include (../../shared/util.pri) +include (../shared/util.pri) + +TESTDATA = data/* +DISTFILES += data/* 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 +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#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 windows; - for (int i=0; i(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(); + QScopedPointer 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(); 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 *transition = root->property("transition").value(); 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" diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro index 2c41528efa..541bfdd527 100644 --- a/tests/auto/quick/quick.pro +++ b/tests/auto/quick/quick.pro @@ -51,6 +51,7 @@ QUICKTESTS += \ qquickaccessible \ qquickanchors \ qquickanimatedimage \ + qquickanimators \ qquickdynamicpropertyanimation \ qquickborderimage \ qquickwindow \ -- cgit v1.2.3