diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2012-05-10 20:26:13 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-12 05:25:30 +0200 |
commit | 754905afb1d16f9cec274b3ce3ff2b937bc13e84 (patch) | |
tree | 2d0a92c8ecb919023ec0fff206d8c8f9e918b7a0 /tests/auto/quick/qquickanimatedsprite | |
parent | e8206bf6ab6ef62b5dd24bf002aa56edecbcec97 (diff) |
Emit currentFrameChanged signal when needed
Task-number: QTBUG-25039
Change-Id: I8bd5fd40a5fee1314f0401ed4708d73ed1cfad94
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquickanimatedsprite')
-rw-r--r-- | tests/auto/quick/qquickanimatedsprite/data/frameChange.qml | 59 | ||||
-rw-r--r-- | tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp | 34 |
2 files changed, 93 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickanimatedsprite/data/frameChange.qml b/tests/auto/quick/qquickanimatedsprite/data/frameChange.qml new file mode 100644 index 0000000000..74ff09533b --- /dev/null +++ b/tests/auto/quick/qquickanimatedsprite/data/frameChange.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + AnimatedSprite { + objectName: "sprite" + source: "squarefacesprite.png" + frameCount: 6 + loops: 3 + frameSync: true + running: false + width: 160 + height: 160 + } +} diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp index 37625cfed6..b45b5d53be 100644 --- a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp +++ b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp @@ -41,6 +41,7 @@ #include <QtTest/QtTest> #include "../../shared/util.h" #include <QtQuick/qquickview.h> +#include <private/qabstractanimation_p.h> #include <private/qquickanimatedsprite_p.h> class tst_qquickanimatedsprite : public QQmlDataTest @@ -50,9 +51,17 @@ public: tst_qquickanimatedsprite(){} private slots: + void initTestCase(); void test_properties(); + void test_frameChangedSignal(); }; +void tst_qquickanimatedsprite::initTestCase() +{ + QQmlDataTest::initTestCase(); + QUnifiedTimer::instance()->setConsistentTiming(true); +} + void tst_qquickanimatedsprite::test_properties() { QQuickView *canvas = new QQuickView(0); @@ -78,6 +87,31 @@ void tst_qquickanimatedsprite::test_properties() delete canvas; } +void tst_qquickanimatedsprite::test_frameChangedSignal() +{ + QQuickView *canvas = new QQuickView(0); + + canvas->setSource(testFileUrl("frameChange.qml")); + canvas->show(); + QTest::qWaitForWindowShown(canvas); + + QVERIFY(canvas->rootObject()); + QQuickAnimatedSprite* sprite = canvas->rootObject()->findChild<QQuickAnimatedSprite*>("sprite"); + QVERIFY(sprite); + + QVERIFY(!sprite->running()); + QVERIFY(!sprite->paused()); + QCOMPARE(sprite->loops(), 3); + QCOMPARE(sprite->frameCount(), 6); + + QSignalSpy frameChangedSpy(sprite, SIGNAL(currentFrameChanged(int))); + sprite->setRunning(true); + QTRY_COMPARE(frameChangedSpy.count(), 3*6); + QTRY_VERIFY(!sprite->running()); + + delete canvas; +} + QTEST_MAIN(tst_qquickanimatedsprite) #include "tst_qquickanimatedsprite.moc" |