summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp10
-rw-r--r--tests/auto/declarative/anchors/data/anchors.qml13
-rw-r--r--tests/auto/declarative/anchors/tst_anchors.cpp24
-rw-r--r--tests/auto/declarative/animatedimage/animatedimage.pro5
-rw-r--r--tests/auto/declarative/animatedimage/tst_animatedimage.cpp66
-rw-r--r--tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp62
6 files changed, 145 insertions, 35 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp b/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp
index 97fdc6a..f389295 100644
--- a/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp
@@ -209,7 +209,7 @@ void QmlGraphicsAnimatedImage::setSource(const QUrl &url)
//### should be unified with movieRequestFinished
d->_movie = new QMovie(lf);
if (!d->_movie->isValid()){
- qWarning() << "Error Reading Animated Image File " << d->url;
+ qWarning() << "Error Reading Animated Image File" << d->url;
delete d->_movie;
d->_movie = 0;
return;
@@ -261,7 +261,7 @@ void QmlGraphicsAnimatedImage::movieRequestFinished()
d->_movie->setCacheMode(QMovie::CacheAll);
if(d->playing)
d->_movie->start();
- else {
+ if (d->paused || !d->playing) {
d->_movie->jumpToFrame(d->preset_currentframe);
d->preset_currentframe = 0;
}
@@ -293,8 +293,10 @@ void QmlGraphicsAnimatedImage::playingStatusChanged()
void QmlGraphicsAnimatedImage::componentComplete()
{
Q_D(QmlGraphicsAnimatedImage);
- setCurrentFrame(d->preset_currentframe);
- d->preset_currentframe = 0;
+ if (!d->reply) {
+ setCurrentFrame(d->preset_currentframe);
+ d->preset_currentframe = 0;
+ }
}
QT_END_NAMESPACE
diff --git a/tests/auto/declarative/anchors/data/anchors.qml b/tests/auto/declarative/anchors/data/anchors.qml
index b64d0b0..e6bed48 100644
--- a/tests/auto/declarative/anchors/data/anchors.qml
+++ b/tests/auto/declarative/anchors/data/anchors.qml
@@ -120,7 +120,7 @@ Rectangle {
anchors.centerIn: masterRect
}
Rectangle {
- id: rect23; objectName: "rect23"
+ id: rect23a; objectName: "rect23a"
anchors.left: masterRect.left
anchors.leftMargin: 5
anchors.right: masterRect.right
@@ -131,6 +131,17 @@ Rectangle {
anchors.bottomMargin: 5
}
Rectangle {
+ id: rect23b; objectName: "rect23b"
+ anchors.left: rect23a.anchors.left
+ anchors.leftMargin: rect23a.anchors.leftMargin
+ anchors.right: rect23a.anchors.right
+ anchors.rightMargin: rect23a.anchors.rightMargin
+ anchors.top: rect23a.anchors.top
+ anchors.topMargin: rect23a.anchors.topMargin
+ anchors.bottom: rect23a.anchors.bottom
+ anchors.bottomMargin: rect23a.anchors.bottomMargin
+ }
+ Rectangle {
id: rect24; objectName: "rect24"
width: 10; height: 10
anchors.horizontalCenter: masterRect.left
diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp
index d340a7d..d65d289 100644
--- a/tests/auto/declarative/anchors/tst_anchors.cpp
+++ b/tests/auto/declarative/anchors/tst_anchors.cpp
@@ -143,16 +143,20 @@ void tst_anchors::basicAnchors()
QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect22"))->x(), 69.0);
QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect22"))->y(), 5.0);
- //margins
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->x(), 31.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->y(), 5.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->width(), 86.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->height(), 10.0);
-
- // offsets
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect24"))->x(), 26.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect25"))->y(), 60.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect26"))->y(), 5.0);
+ //margins
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23a"))->x(), 31.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23a"))->y(), 5.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23a"))->width(), 86.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23a"))->height(), 10.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23b"))->x(), 31.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23b"))->y(), 5.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23b"))->width(), 86.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23b"))->height(), 10.0);
+
+ // offsets
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect24"))->x(), 26.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect25"))->y(), 60.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect26"))->y(), 5.0);
//baseline
QmlGraphicsText *text1 = findItem<QmlGraphicsText>(view->root(), QLatin1String("text1"));
diff --git a/tests/auto/declarative/animatedimage/animatedimage.pro b/tests/auto/declarative/animatedimage/animatedimage.pro
index 4ff9db4..5a8ec6c 100644
--- a/tests/auto/declarative/animatedimage/animatedimage.pro
+++ b/tests/auto/declarative/animatedimage/animatedimage.pro
@@ -1,6 +1,7 @@
load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_animatedimage.cpp
+contains(QT_CONFIG,declarative): QT += declarative network
+HEADERS += ../shared/testhttpserver.h
+SOURCES += tst_animatedimage.cpp ../shared/testhttpserver.cpp
macx:CONFIG -= app_bundle
DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/animatedimage/tst_animatedimage.cpp b/tests/auto/declarative/animatedimage/tst_animatedimage.cpp
index 484fd1a..5ba0068 100644
--- a/tests/auto/declarative/animatedimage/tst_animatedimage.cpp
+++ b/tests/auto/declarative/animatedimage/tst_animatedimage.cpp
@@ -46,6 +46,18 @@
#include <private/qmlgraphicsimage_p.h>
#include <private/qmlgraphicsanimatedimage_p.h>
+#include "../shared/testhttpserver.h"
+
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 6; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(50); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
+
class tst_animatedimage : public QObject
{
Q_OBJECT
@@ -58,6 +70,9 @@ private slots:
void stopped();
void setFrame();
void frameCount();
+ void remote();
+ void remote_data();
+ void invalidSource();
};
void tst_animatedimage::play()
@@ -121,6 +136,57 @@ void tst_animatedimage::frameCount()
delete anim;
}
+void tst_animatedimage::remote()
+{
+ QFETCH(QString, fileName);
+ QFETCH(bool, paused);
+
+ TestHTTPServer server(14445);
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+
+ QmlEngine engine;
+ QmlComponent component(&engine, QUrl("http://127.0.0.1:14445/" + fileName));
+ TRY_WAIT(component.isReady());
+
+ QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
+ QVERIFY(anim);
+
+ TRY_WAIT(anim->isPlaying());
+ if (paused) {
+ TRY_WAIT(anim->isPaused());
+ QCOMPARE(anim->currentFrame(), 2);
+ }
+
+ delete anim;
+}
+
+void tst_animatedimage::remote_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<bool>("paused");
+
+ QTest::newRow("playing") << "stickman.qml" << false;
+ QTest::newRow("paused") << "stickmanpause.qml" << true;
+}
+
+void tst_animatedimage::invalidSource()
+{
+ QmlEngine engine;
+ QmlComponent component(&engine, "import Qt 4.6\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl("file://"));
+ QVERIFY(component.isReady());
+
+ QTest::ignoreMessage(QtWarningMsg, "Error Reading Animated Image File QUrl( \"file:no-such-file.gif\" ) ");
+
+ QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
+ QVERIFY(anim);
+
+ QVERIFY(!anim->isPlaying());
+ QVERIFY(!anim->isPaused());
+ QCOMPARE(anim->currentFrame(), 0);
+ QCOMPARE(anim->frameCount(), 0);
+}
+
QTEST_MAIN(tst_animatedimage)
#include "tst_animatedimage.moc"
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
index a0860c5..f23c7d7 100644
--- a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
+++ b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
@@ -86,6 +86,8 @@ private slots:
void sciSource();
void sciSource_data();
void invalidSciFile();
+ void pendingRemoteRequest();
+ void pendingRemoteRequest_data();
private:
QmlEngine engine;
@@ -113,13 +115,14 @@ void tst_qmlgraphicsborderimage::noSource()
void tst_qmlgraphicsborderimage::imageSource()
{
QFETCH(QString, source);
- QFETCH(bool, remote);
QFETCH(bool, valid);
- TestHTTPServer server(SERVER_PORT);
+ bool remote = source.startsWith("http");
+ TestHTTPServer *server = 0;
if (remote) {
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
+ server = new TestHTTPServer(SERVER_PORT);
+ QVERIFY(server->isValid());
+ server->serveDirectory(SRCDIR "/data");
}
QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }";
@@ -143,6 +146,7 @@ void tst_qmlgraphicsborderimage::imageSource()
}
delete obj;
+ delete server;
}
void tst_qmlgraphicsborderimage::clearSource()
@@ -167,13 +171,12 @@ void tst_qmlgraphicsborderimage::clearSource()
void tst_qmlgraphicsborderimage::imageSource_data()
{
QTest::addColumn<QString>("source");
- QTest::addColumn<bool>("remote");
QTest::addColumn<bool>("valid");
- QTest::newRow("local") << SRCDIR "/data/colors.png" << false << true;
- QTest::newRow("local not found") << SRCDIR "/data/no-such-file.png" << false << false;
- QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << true;
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true << false;
+ QTest::newRow("local") << SRCDIR "/data/colors.png" << true;
+ QTest::newRow("local not found") << SRCDIR "/data/no-such-file.png" << false;
+ QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true;
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << false;
}
void tst_qmlgraphicsborderimage::resized()
@@ -236,13 +239,14 @@ void tst_qmlgraphicsborderimage::tileModes()
void tst_qmlgraphicsborderimage::sciSource()
{
QFETCH(QString, source);
- QFETCH(bool, remote);
QFETCH(bool, valid);
- TestHTTPServer server(SERVER_PORT);
+ bool remote = source.startsWith("http");
+ TestHTTPServer *server = 0;
if (remote) {
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
+ server = new TestHTTPServer(SERVER_PORT);
+ QVERIFY(server->isValid());
+ server->serveDirectory(SRCDIR "/data");
}
QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
@@ -270,18 +274,18 @@ void tst_qmlgraphicsborderimage::sciSource()
}
delete obj;
+ delete server;
}
void tst_qmlgraphicsborderimage::sciSource_data()
{
QTest::addColumn<QString>("source");
- QTest::addColumn<bool>("remote");
QTest::addColumn<bool>("valid");
- QTest::newRow("local") << SRCDIR "/data/colors-round.sci" << false << true;
- QTest::newRow("local not found") << SRCDIR "/data/no-such-file.sci" << false << false;
- QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true << true;
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << true << false;
+ QTest::newRow("local") << SRCDIR "/data/colors-round.sci" << true;
+ QTest::newRow("local not found") << SRCDIR "/data/no-such-file.sci" << false;
+ QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false;
}
void tst_qmlgraphicsborderimage::invalidSciFile()
@@ -299,7 +303,29 @@ void tst_qmlgraphicsborderimage::invalidSciFile()
delete obj;
}
+void tst_qmlgraphicsborderimage::pendingRemoteRequest()
+{
+ QFETCH(QString, source);
+
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }";
+ QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
+ QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->status(), QmlGraphicsBorderImage::Loading);
+ // verify no crash
+ // This will cause a delayed "QThread: Destroyed while thread is still running" warning
+ delete obj;
+ QTest::qWait(50);
+}
+
+void tst_qmlgraphicsborderimage::pendingRemoteRequest_data()
+{
+ QTest::addColumn<QString>("source");
+
+ QTest::newRow("png file") << "http://no-such-qt-server-like-this/none.png";
+ QTest::newRow("sci file") << "http://no-such-qt-server-like-this/none.sci";
+}
QTEST_MAIN(tst_qmlgraphicsborderimage)