diff options
Diffstat (limited to 'tests/auto/declarative/qquickanimatedimage')
14 files changed, 0 insertions, 451 deletions
diff --git a/tests/auto/declarative/qquickanimatedimage/data/colors.gif b/tests/auto/declarative/qquickanimatedimage/data/colors.gif Binary files differdeleted file mode 100644 index 1270bfaa79..0000000000 --- a/tests/auto/declarative/qquickanimatedimage/data/colors.gif +++ /dev/null diff --git a/tests/auto/declarative/qquickanimatedimage/data/colors.qml b/tests/auto/declarative/qquickanimatedimage/data/colors.qml deleted file mode 100644 index 5ccc0148dd..0000000000 --- a/tests/auto/declarative/qquickanimatedimage/data/colors.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -AnimatedImage { - source: "colors.gif" -} diff --git a/tests/auto/declarative/qquickanimatedimage/data/hearts.gif b/tests/auto/declarative/qquickanimatedimage/data/hearts.gif Binary files differdeleted file mode 100644 index cfb55f27f5..0000000000 --- a/tests/auto/declarative/qquickanimatedimage/data/hearts.gif +++ /dev/null diff --git a/tests/auto/declarative/qquickanimatedimage/data/hearts.qml b/tests/auto/declarative/qquickanimatedimage/data/hearts.qml deleted file mode 100644 index 717bab430b..0000000000 --- a/tests/auto/declarative/qquickanimatedimage/data/hearts.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -AnimatedImage { - source: "hearts.gif" - playing: false -} diff --git a/tests/auto/declarative/qquickanimatedimage/data/qmldir b/tests/auto/declarative/qquickanimatedimage/data/qmldir deleted file mode 100644 index ef7c1f44f3..0000000000 --- a/tests/auto/declarative/qquickanimatedimage/data/qmldir +++ /dev/null @@ -1 +0,0 @@ -# No local types diff --git a/tests/auto/declarative/qquickanimatedimage/data/qtbug-16520.qml b/tests/auto/declarative/qquickanimatedimage/data/qtbug-16520.qml deleted file mode 100644 index da77a4063b..0000000000 --- a/tests/auto/declarative/qquickanimatedimage/data/qtbug-16520.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 500 - height: 500 - - AnimatedImage { - objectName: "anim" - anchors.centerIn: parent - asynchronous: true - opacity: status == AnimatedImage.Ready ? 1 : 0 - - Behavior on opacity { - NumberAnimation { duration: 1000 } - } - } -} diff --git a/tests/auto/declarative/qquickanimatedimage/data/stickman.gif b/tests/auto/declarative/qquickanimatedimage/data/stickman.gif Binary files differdeleted file mode 100644 index 7c4cd18687..0000000000 --- a/tests/auto/declarative/qquickanimatedimage/data/stickman.gif +++ /dev/null diff --git a/tests/auto/declarative/qquickanimatedimage/data/stickman.qml b/tests/auto/declarative/qquickanimatedimage/data/stickman.qml deleted file mode 100644 index a47924de21..0000000000 --- a/tests/auto/declarative/qquickanimatedimage/data/stickman.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -AnimatedImage { - source: "stickman.gif" -} diff --git a/tests/auto/declarative/qquickanimatedimage/data/stickmanerror1.qml b/tests/auto/declarative/qquickanimatedimage/data/stickmanerror1.qml deleted file mode 100644 index 4f823b3d70..0000000000 --- a/tests/auto/declarative/qquickanimatedimage/data/stickmanerror1.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -AnimatedImage { - sourceSize: "240x180" - source: "stickman.gif" -} diff --git a/tests/auto/declarative/qquickanimatedimage/data/stickmanpause.qml b/tests/auto/declarative/qquickanimatedimage/data/stickmanpause.qml deleted file mode 100644 index ef771ed56f..0000000000 --- a/tests/auto/declarative/qquickanimatedimage/data/stickmanpause.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -AnimatedImage { - source: "stickman.gif" - paused: true - currentFrame: 2 -} diff --git a/tests/auto/declarative/qquickanimatedimage/data/stickmanscaled.qml b/tests/auto/declarative/qquickanimatedimage/data/stickmanscaled.qml deleted file mode 100644 index 1ef1f95165..0000000000 --- a/tests/auto/declarative/qquickanimatedimage/data/stickmanscaled.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -AnimatedImage { - width: 240 - height: 180 - source: "stickman.gif" -} diff --git a/tests/auto/declarative/qquickanimatedimage/data/stickmanstopped.qml b/tests/auto/declarative/qquickanimatedimage/data/stickmanstopped.qml deleted file mode 100644 index 0bf80b8972..0000000000 --- a/tests/auto/declarative/qquickanimatedimage/data/stickmanstopped.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -AnimatedImage { - source: "stickman.gif" - playing: false -} diff --git a/tests/auto/declarative/qquickanimatedimage/qquickanimatedimage.pro b/tests/auto/declarative/qquickanimatedimage/qquickanimatedimage.pro deleted file mode 100644 index d6a40e11ce..0000000000 --- a/tests/auto/declarative/qquickanimatedimage/qquickanimatedimage.pro +++ /dev/null @@ -1,13 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickanimatedimage -HEADERS += ../shared/testhttpserver.h -SOURCES += tst_qquickanimatedimage.cpp ../shared/testhttpserver.cpp -macx:CONFIG -= app_bundle - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private network testlib diff --git a/tests/auto/declarative/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/declarative/qquickanimatedimage/tst_qquickanimatedimage.cpp deleted file mode 100644 index 542811efc1..0000000000 --- a/tests/auto/declarative/qquickanimatedimage/tst_qquickanimatedimage.cpp +++ /dev/null @@ -1,378 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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$ -** -****************************************************************************/ -#include <qtest.h> -#include <QtDeclarative/qdeclarativeengine.h> -#include <QtDeclarative/qdeclarativecomponent.h> -#include <QtDeclarative/qquickview.h> -#include <private/qquickrectangle_p.h> -#include <private/qquickimage_p.h> -#include <private/qquickanimatedimage_p.h> -#include <QSignalSpy> -#include <QtDeclarative/qdeclarativecontext.h> - -#include "../shared/testhttpserver.h" -#include "../shared/util.h" - -Q_DECLARE_METATYPE(QQuickImageBase::Status) - -class tst_qquickanimatedimage : public QObject -{ - Q_OBJECT -public: - tst_qquickanimatedimage() {} - -private slots: - void play(); - void pause(); - void stopped(); - void setFrame(); - void frameCount(); - void mirror_running(); - void mirror_notRunning(); - void mirror_notRunning_data(); - void remote(); - void remote_data(); - void sourceSize(); - void sourceSizeReadOnly(); - void invalidSource(); - void qtbug_16520(); - void progressAndStatusChanges(); - -}; - -void tst_qquickanimatedimage::play() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickman.qml"))); - QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - - delete anim; -} - -void tst_qquickanimatedimage::pause() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickmanpause.qml"))); - QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - QVERIFY(anim->isPaused()); - - delete anim; -} - -void tst_qquickanimatedimage::stopped() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickmanstopped.qml"))); - QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create()); - QVERIFY(anim); - QVERIFY(!anim->isPlaying()); - QCOMPARE(anim->currentFrame(), 0); - - delete anim; -} - -void tst_qquickanimatedimage::setFrame() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickmanpause.qml"))); - QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - QCOMPARE(anim->currentFrame(), 2); - - delete anim; -} - -void tst_qquickanimatedimage::frameCount() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("colors.qml"))); - QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - QCOMPARE(anim->frameCount(), 3); - - delete anim; -} - -void tst_qquickanimatedimage::mirror_running() -{ - // test where mirror is set to true after animation has started - - QQuickView *canvas = new QQuickView; - canvas->show(); - - canvas->setSource(QUrl::fromLocalFile(TESTDATA("hearts.qml"))); - QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(canvas->rootObject()); - QVERIFY(anim); - - int width = anim->property("width").toInt(); - - QCOMPARE(anim->currentFrame(), 0); - QPixmap frame0 = QPixmap::fromImage(canvas->grabFrameBuffer()); - - anim->setCurrentFrame(1); - QPixmap frame1 = QPixmap::fromImage(canvas->grabFrameBuffer()); - - anim->setCurrentFrame(0); - - QSignalSpy spy(anim, SIGNAL(frameChanged())); - anim->setPlaying(true); - - QTRY_VERIFY(spy.count() == 1); spy.clear(); - anim->setProperty("mirror", true); - - QCOMPARE(anim->currentFrame(), 1); - QPixmap frame1_flipped = QPixmap::fromImage(canvas->grabFrameBuffer()); - - QTRY_VERIFY(spy.count() == 1); spy.clear(); - QCOMPARE(anim->currentFrame(), 0); // animation only has 2 frames, should cycle back to first - QPixmap frame0_flipped = QPixmap::fromImage(canvas->grabFrameBuffer()); - - QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved"); - - QTransform transform; - transform.translate(width, 0).scale(-1, 1.0); - QPixmap frame0_expected = frame0.transformed(transform); - QPixmap frame1_expected = frame1.transformed(transform); - - QCOMPARE(frame0_flipped, frame0_expected); - QCOMPARE(frame1_flipped, frame1_expected); - - delete canvas; -} - -void tst_qquickanimatedimage::mirror_notRunning() -{ - QFETCH(QUrl, fileUrl); - - QQuickView *canvas = new QQuickView; - canvas->show(); - - canvas->setSource(fileUrl); - QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(canvas->rootObject()); - QVERIFY(anim); - - int width = anim->property("width").toInt(); - QPixmap screenshot = QPixmap::fromImage(canvas->grabFrameBuffer()); - - QTransform transform; - transform.translate(width, 0).scale(-1, 1.0); - QPixmap expected = screenshot.transformed(transform); - - int frame = anim->currentFrame(); - bool playing = anim->isPlaying(); - bool paused = anim->isPlaying(); - - anim->setProperty("mirror", true); - screenshot = QPixmap::fromImage(canvas->grabFrameBuffer()); - - QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved"); - QCOMPARE(screenshot, expected); - - // mirroring should not change the current frame or playing status - QCOMPARE(anim->currentFrame(), frame); - QCOMPARE(anim->isPlaying(), playing); - QCOMPARE(anim->isPaused(), paused); - - delete canvas; -} - -void tst_qquickanimatedimage::mirror_notRunning_data() -{ - QTest::addColumn<QUrl>("fileUrl"); - - QTest::newRow("paused") << QUrl::fromLocalFile(TESTDATA("stickmanpause.qml")); - QTest::newRow("stopped") << QUrl::fromLocalFile(TESTDATA("stickmanstopped.qml")); -} - -void tst_qquickanimatedimage::remote() -{ - QFETCH(QString, fileName); - QFETCH(bool, paused); - - TestHTTPServer server(14449); - QVERIFY(server.isValid()); - server.serveDirectory(TESTDATA("")); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName)); - QTRY_VERIFY(component.isReady()); - - QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create()); - QVERIFY(anim); - - QTRY_VERIFY(anim->isPlaying()); - if (paused) { - QTRY_VERIFY(anim->isPaused()); - QCOMPARE(anim->currentFrame(), 2); - } - QVERIFY(anim->status() != QQuickAnimatedImage::Error); - - delete anim; -} - -void tst_qquickanimatedimage::sourceSize() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickmanscaled.qml"))); - QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create()); - QVERIFY(anim); - QCOMPARE(anim->width(),240.0); - QCOMPARE(anim->height(),180.0); - QCOMPARE(anim->sourceSize(),QSize(160,120)); - - delete anim; -} - -void tst_qquickanimatedimage::sourceSizeReadOnly() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickmanerror1.qml"))); - QVERIFY(component.isError()); - QCOMPARE(component.errors().at(0).description(), QString("Invalid property assignment: \"sourceSize\" is a read-only property")); -} - -void tst_qquickanimatedimage::remote_data() -{ - QTest::addColumn<QString>("fileName"); - QTest::addColumn<bool>("paused"); - - QTest::newRow("playing") << "stickman.qml" << false; - QTest::newRow("paused") << "stickmanpause.qml" << true; -} - -void tst_qquickanimatedimage::invalidSource() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl::fromLocalFile("")); - QVERIFY(component.isReady()); - - QTest::ignoreMessage(QtWarningMsg, "file::2:2: QML AnimatedImage: Error Reading Animated Image File file:no-such-file.gif"); - - QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create()); - QVERIFY(anim); - - QVERIFY(!anim->isPlaying()); - QVERIFY(!anim->isPaused()); - QCOMPARE(anim->currentFrame(), 0); - QCOMPARE(anim->frameCount(), 0); - QTRY_VERIFY(anim->status() == 3); -} - -void tst_qquickanimatedimage::qtbug_16520() -{ - TestHTTPServer server(14449); - QVERIFY(server.isValid()); - server.serveDirectory(TESTDATA("")); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("qtbug-16520.qml"))); - QTRY_VERIFY(component.isReady()); - - QQuickRectangle *root = qobject_cast<QQuickRectangle *>(component.create()); - QVERIFY(root); - QQuickAnimatedImage *anim = root->findChild<QQuickAnimatedImage*>("anim"); - - anim->setProperty("source", "http://127.0.0.1:14449/stickman.gif"); - - QTRY_VERIFY(anim->opacity() == 0); - QTRY_VERIFY(anim->opacity() == 1); - - delete anim; -} - -void tst_qquickanimatedimage::progressAndStatusChanges() -{ - TestHTTPServer server(14449); - QVERIFY(server.isValid()); - server.serveDirectory(TESTDATA("")); - - QDeclarativeEngine engine; - QString componentStr = "import QtQuick 2.0\nAnimatedImage { source: srcImage }"; - QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("stickman.gif"))); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickImage *obj = qobject_cast<QQuickImage*>(component.create()); - QVERIFY(obj != 0); - QVERIFY(obj->status() == QQuickImage::Ready); - QTRY_VERIFY(obj->progress() == 1.0); - - qRegisterMetaType<QQuickImageBase::Status>(); - QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &))); - QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal))); - QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status))); - - // Loading local file - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("colors.gif"))); - QTRY_VERIFY(obj->status() == QQuickImage::Ready); - QTRY_VERIFY(obj->progress() == 1.0); - QTRY_COMPARE(sourceSpy.count(), 1); - QTRY_COMPARE(progressSpy.count(), 0); - QTRY_COMPARE(statusSpy.count(), 0); - - // Loading remote file - ctxt->setContextProperty("srcImage", "http://127.0.0.1:14449/stickman.gif"); - QTRY_VERIFY(obj->status() == QQuickImage::Loading); - QTRY_VERIFY(obj->progress() == 0.0); - QTRY_VERIFY(obj->status() == QQuickImage::Ready); - QTRY_VERIFY(obj->progress() == 1.0); - QTRY_COMPARE(sourceSpy.count(), 2); - QTRY_VERIFY(progressSpy.count() > 1); - QTRY_COMPARE(statusSpy.count(), 2); - - ctxt->setContextProperty("srcImage", ""); - QTRY_VERIFY(obj->status() == QQuickImage::Null); - QTRY_VERIFY(obj->progress() == 0.0); - QTRY_COMPARE(sourceSpy.count(), 3); - QTRY_VERIFY(progressSpy.count() > 2); - QTRY_COMPARE(statusSpy.count(), 3); -} - -QTEST_MAIN(tst_qquickanimatedimage) - -#include "tst_qquickanimatedimage.moc" |