diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-04-08 05:07:54 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-04-08 05:07:54 (GMT) |
commit | 9fd2d52881356fb214213f139a2f25081fc848e4 (patch) | |
tree | 41902768ff80a3ba81df3fe75cf25a12bd241822 | |
parent | 31ec693cd6ae4cf5a2533092f45ba9bb154ba152 (diff) | |
download | Qt-9fd2d52881356fb214213f139a2f25081fc848e4.zip Qt-9fd2d52881356fb214213f139a2f25081fc848e4.tar.gz Qt-9fd2d52881356fb214213f139a2f25081fc848e4.tar.bz2 |
Fix AnimatedImage for remote image test. Fix and test sourceSize property.
6 files changed, 44 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp index f14f773..cc062f0 100644 --- a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp @@ -312,7 +312,7 @@ void QDeclarativeAnimatedImage::playingStatusChanged() void QDeclarativeAnimatedImage::componentComplete() { Q_D(QDeclarativeAnimatedImage); - QDeclarativeImage::componentComplete(); + QDeclarativeItem::componentComplete(); // NOT QDeclarativeImage if (!d->reply) { setCurrentFrame(d->preset_currentframe); d->preset_currentframe = 0; diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h b/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h index 6ab66b3..9d8087c 100644 --- a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h +++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h @@ -61,6 +61,10 @@ class Q_DECLARATIVE_EXPORT QDeclarativeAnimatedImage : public QDeclarativeImage Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged) Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY frameChanged) Q_PROPERTY(int frameCount READ frameCount) + + // read-only for AnimatedImage + Q_PROPERTY(QSize sourceSize READ sourceSize NOTIFY sourceSizeChanged) + public: QDeclarativeAnimatedImage(QDeclarativeItem *parent=0); ~QDeclarativeAnimatedImage(); @@ -83,6 +87,7 @@ Q_SIGNALS: void playingChanged(); void pausedChanged(); void frameChanged(); + void sourceSizeChanged(); private Q_SLOTS: void movieUpdate(); diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h index 6c84456..49b1c58 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h +++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h @@ -73,7 +73,7 @@ public: bool asynchronous() const; void setAsynchronous(bool); - void setSourceSize(const QSize&); + virtual void setSourceSize(const QSize&); QSize sourceSize() const; Q_SIGNALS: diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanerror1.qml b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanerror1.qml new file mode 100644 index 0000000..5b0bdcb --- /dev/null +++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanerror1.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +AnimatedImage { + sourceSize: "240x180" + source: "stickman.gif" +} diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanscaled.qml b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanscaled.qml new file mode 100644 index 0000000..f4d277a --- /dev/null +++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanscaled.qml @@ -0,0 +1,7 @@ +import Qt 4.6 + +AnimatedImage { + width: 240 + height: 180 + source: "stickman.gif" +} diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp index 31efc64..39ce9eb 100644 --- a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp +++ b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp @@ -72,6 +72,8 @@ private slots: void frameCount(); void remote(); void remote_data(); + void sourceSize(); + void sourceSizeReadOnly(); void invalidSource(); }; @@ -155,10 +157,32 @@ void tst_qdeclarativeanimatedimage::remote() TRY_WAIT(anim->isPaused()); QCOMPARE(anim->currentFrame(), 2); } + QVERIFY(anim->status() != QDeclarativeAnimatedImage::Error); delete anim; } +void tst_qdeclarativeanimatedimage::sourceSize() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanscaled.qml")); + QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(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"); |