diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-01-31 16:52:36 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-03 00:39:18 +0100 |
commit | 01dc7e2ea476e0e6dcdce2e72979bbc858f4057d (patch) | |
tree | d8796f7695bbf8ad42abf47cd84c1b5e000ef795 /tests/auto/qtquick1/qdeclarativeanimatedimage | |
parent | 5e07b57b818326da47a46d384415041fa4cea0ba (diff) |
Remove QtQuick1 elements from qtdeclarative
QtQuick1 is now contained in a separate repository.
Task-number: QTBUG-23737
Change-Id: I09eae67af5693a22b896b916f816f73ccc3a89b1
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/qtquick1/qdeclarativeanimatedimage')
14 files changed, 0 insertions, 452 deletions
diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.gif b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.gif Binary files differdeleted file mode 100644 index 1270bfaa79..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.gif +++ /dev/null diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.qml deleted file mode 100644 index 51deb56b18..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -AnimatedImage { - source: "colors.gif" -} diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.gif b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.gif Binary files differdeleted file mode 100644 index cfb55f27f5..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.gif +++ /dev/null diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.qml deleted file mode 100644 index 8729dd2ef2..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 1.0 - -AnimatedImage { - source: "hearts.gif" - playing: false -} diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qmldir b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qmldir deleted file mode 100644 index ef7c1f44f3..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qmldir +++ /dev/null @@ -1 +0,0 @@ -# No local types diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qtbug-16520.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qtbug-16520.qml deleted file mode 100644 index cf5b60110b..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qtbug-16520.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 1.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/qtquick1/qdeclarativeanimatedimage/data/stickman.gif b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.gif Binary files differdeleted file mode 100644 index 7c4cd18687..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.gif +++ /dev/null diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.qml deleted file mode 100644 index d44937f913..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -AnimatedImage { - source: "stickman.gif" -} diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanerror1.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanerror1.qml deleted file mode 100644 index f08f74da56..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanerror1.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 1.0 - -AnimatedImage { - sourceSize: "240x180" - source: "stickman.gif" -} diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanpause.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanpause.qml deleted file mode 100644 index 1d7e25909f..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanpause.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -AnimatedImage { - source: "stickman.gif" - paused: true - currentFrame: 2 -} diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanscaled.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanscaled.qml deleted file mode 100644 index 8b24d73715..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanscaled.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -AnimatedImage { - width: 240 - height: 180 - source: "stickman.gif" -} diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanstopped.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanstopped.qml deleted file mode 100644 index c5b14137e3..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanstopped.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 1.0 - -AnimatedImage { - source: "stickman.gif" - playing: false -} diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro b/tests/auto/qtquick1/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro deleted file mode 100644 index 21c846b4eb..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeanimatedimage -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qdeclarativeanimatedimage.cpp ../../shared/testhttpserver.cpp -macx:CONFIG -= app_bundle - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private declarative-private qtquick1-private network testlib diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/qtquick1/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp deleted file mode 100644 index 5545705341..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp +++ /dev/null @@ -1,381 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ -#include <qtest.h> -#include <QtDeclarative/qdeclarativeengine.h> -#include <QtDeclarative/qdeclarativecomponent.h> -#include <QtQuick1/qdeclarativeview.h> -#include <private/qdeclarativerectangle_p.h> -#include <private/qdeclarativeimage_p.h> -#include <private/qdeclarativeanimatedimage_p.h> -#include <QSignalSpy> -#include <QtDeclarative/qdeclarativecontext.h> - -#include "../../shared/testhttpserver.h" - -class tst_qdeclarativeanimatedimage : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativeanimatedimage() {} - -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(); - -private: - QPixmap grabScene(QGraphicsScene *scene, int width, int height); -}; - -QPixmap tst_qdeclarativeanimatedimage::grabScene(QGraphicsScene *scene, int width, int height) -{ - QPixmap screenshot(width, height); - screenshot.fill(); - QPainter p_screenshot(&screenshot); - scene->render(&p_screenshot, QRect(0, 0, width, height), QRect(0, 0, width, height)); - return screenshot; -} - -void tst_qdeclarativeanimatedimage::play() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickman.qml")); - QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - - delete anim; -} - -void tst_qdeclarativeanimatedimage::pause() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml")); - QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - QVERIFY(anim->isPaused()); - - delete anim; -} - -void tst_qdeclarativeanimatedimage::stopped() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml")); - QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create()); - QVERIFY(anim); - QVERIFY(!anim->isPlaying()); - QCOMPARE(anim->currentFrame(), 0); - - delete anim; -} - -void tst_qdeclarativeanimatedimage::setFrame() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml")); - QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - QCOMPARE(anim->currentFrame(), 2); - - delete anim; -} - -void tst_qdeclarativeanimatedimage::frameCount() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/colors.qml")); - QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - QCOMPARE(anim->frameCount(), 3); - - delete anim; -} - -void tst_qdeclarativeanimatedimage::mirror_running() -{ - // test where mirror is set to true after animation has started - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/hearts.qml")); - QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create()); - QVERIFY(anim); - - QGraphicsScene scene; - int width = anim->property("width").toInt(); - int height = anim->property("height").toInt(); - scene.addItem(qobject_cast<QGraphicsObject *>(anim)); - - QCOMPARE(anim->currentFrame(), 0); - QPixmap frame0 = grabScene(&scene, width, height); - anim->setCurrentFrame(1); - QPixmap frame1 = grabScene(&scene, width, height); - - 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 = grabScene(&scene, width, height); - - QTRY_VERIFY(spy.count() == 1); spy.clear(); - QCOMPARE(anim->currentFrame(), 0); // animation only has 2 frames, should cycle back to first - QPixmap frame0_flipped = grabScene(&scene, width, height); - - 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); -} - -void tst_qdeclarativeanimatedimage::mirror_notRunning() -{ - QFETCH(QUrl, fileUrl); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, fileUrl); - QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create()); - QVERIFY(anim); - - QGraphicsScene scene; - int width = anim->property("width").toInt(); - int height = anim->property("height").toInt(); - scene.addItem(qobject_cast<QGraphicsObject *>(anim)); - QPixmap screenshot = grabScene(&scene, width, height); - - 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 = grabScene(&scene, width, height); - - 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 anim; -} - -void tst_qdeclarativeanimatedimage::mirror_notRunning_data() -{ - QTest::addColumn<QUrl>("fileUrl"); - - QTest::newRow("paused") << QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml"); - QTest::newRow("stopped") << QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml"); -} - -void tst_qdeclarativeanimatedimage::remote() -{ - QFETCH(QString, fileName); - QFETCH(bool, paused); - - TestHTTPServer server(14449); - QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName)); - QTRY_VERIFY(component.isReady()); - - QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create()); - QVERIFY(anim); - - QTRY_VERIFY(anim->isPlaying()); - if (paused) { - QTRY_VERIFY(anim->isPaused()); - QCOMPARE(anim->currentFrame(), 2); - } - QVERIFY(anim->status() != QDeclarative1AnimatedImage::Error); - - delete anim; -} - -void tst_qdeclarativeanimatedimage::sourceSize() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanscaled.qml")); - QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create()); - QVERIFY(anim); - QCOMPARE(anim->width(),240.0); - QCOMPARE(anim->height(),180.0); - QCOMPARE(anim->sourceSize(),QSize(160,120)); - - delete anim; -} - -void tst_qdeclarativeanimatedimage::sourceSizeReadOnly() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanerror1.qml")); - QVERIFY(component.isError()); - QCOMPARE(component.errors().at(0).description(), QString("Invalid property assignment: \"sourceSize\" is a read-only property")); -} - -void tst_qdeclarativeanimatedimage::remote_data() -{ - QTest::addColumn<QString>("fileName"); - QTest::addColumn<bool>("paused"); - - QTest::newRow("playing") << "stickman.qml" << false; - QTest::newRow("paused") << "stickmanpause.qml" << true; -} - -void tst_qdeclarativeanimatedimage::invalidSource() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.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"); - - QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(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_qdeclarativeanimatedimage::qtbug_16520() -{ - TestHTTPServer server(14449); - QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/qtbug-16520.qml")); - QTRY_VERIFY(component.isReady()); - - QDeclarative1Rectangle *root = qobject_cast<QDeclarative1Rectangle *>(component.create()); - QVERIFY(root); - QDeclarative1AnimatedImage *anim = root->findChild<QDeclarative1AnimatedImage*>("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_qdeclarativeanimatedimage::progressAndStatusChanges() -{ - TestHTTPServer server(14449); - QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); - - QDeclarativeEngine engine; - QString componentStr = "import QtQuick 1.0\nAnimatedImage { source: srcImage }"; - QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/stickman.gif")); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create()); - QVERIFY(obj != 0); - QVERIFY(obj->status() == QDeclarative1Image::Ready); - QTRY_VERIFY(obj->progress() == 1.0); - - QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &))); - QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal))); - QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QDeclarative1ImageBase::Status))); - - // Loading local file - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.gif")); - QTRY_VERIFY(obj->status() == QDeclarative1Image::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() == QDeclarative1Image::Loading); - QTRY_VERIFY(obj->progress() == 0.0); - QTRY_VERIFY(obj->status() == QDeclarative1Image::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() == QDeclarative1Image::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_qdeclarativeanimatedimage) - -#include "tst_qdeclarativeanimatedimage.moc" |