diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-12-14 07:33:04 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-12-14 07:33:04 (GMT) |
commit | 690b72b7c3707f3a8f0120c35f3a4c34b58ff596 (patch) | |
tree | 2d452f2eaa9a7b56f42f34e9d912e8d1c62be4cc | |
parent | 087bfb51618e8a02a3fad263a963c3485d08294a (diff) | |
download | Qt-690b72b7c3707f3a8f0120c35f3a4c34b58ff596.zip Qt-690b72b7c3707f3a8f0120c35f3a4c34b58ff596.tar.gz Qt-690b72b7c3707f3a8f0120c35f3a4c34b58ff596.tar.bz2 |
Fix image and pixmapcache tests.
-rw-r--r-- | src/declarative/util/qmlpixmapcache.cpp | 4 | ||||
-rw-r--r-- | tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp | 2 | ||||
-rw-r--r-- | tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp | 32 |
3 files changed, 23 insertions, 15 deletions
diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp index 0115a7c..99bcb7b 100644 --- a/src/declarative/util/qmlpixmapcache.cpp +++ b/src/declarative/util/qmlpixmapcache.cpp @@ -262,6 +262,8 @@ void QmlPixmapReply::networkRequestDone() if (d->reply->error()) { d->pixmap = QPixmap(); d->status = Error; + QPixmapCache::insert(d->urlKey, d->pixmap); + qWarning() << "Network error loading" << d->urlKey << d->reply->errorString(); emit finished(); } else { qmlImageReader()->read(this); @@ -278,11 +280,11 @@ bool QmlPixmapReply::event(QEvent *event) d->status = de->error ? Error : Ready; if (d->status == Ready) { d->pixmap = QPixmap::fromImage(de->image); - QPixmapCache::insert(d->urlKey, d->pixmap); d->image = QImage(); } else { qWarning() << "Error decoding" << d->urlKey; } + QPixmapCache::insert(d->urlKey, d->pixmap); emit finished(); } return true; diff --git a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp b/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp index c8a2d3f..26f5175 100644 --- a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp +++ b/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp @@ -118,7 +118,7 @@ void tst_qmlgraphicsimage::imageSource_data() << "Cannot open QUrl( \"file://" SRCDIR "/data/no-such-file.png\" ) "; QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << ""; QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true - << "Network error loading QUrl( \"" SERVER_ADDR "/no-such-file.png\" ) " + << "Network error loading \"" SERVER_ADDR "/no-such-file.png\" " "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" "; } diff --git a/tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp b/tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp index a26b097..1951833 100644 --- a/tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp +++ b/tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp @@ -122,8 +122,8 @@ void tst_qmlpixmapcache::single() QFETCH(bool, neterror); if (neterror) { - QString expected = "Network error loading QUrl( \"" - +target.toString()+"\" ) \"Error downloading " + QString expected = "Network error loading \"" + +target.toString()+"\" \"Error downloading " +target.toString()+" - server replied: Not Found\" "; QTest::ignoreMessage(QtWarningMsg, expected.toLatin1()); } else if (!exists) { @@ -133,15 +133,18 @@ void tst_qmlpixmapcache::single() QPixmap pixmap; QVERIFY(pixmap.width() <= 0); // Check Qt assumption - QNetworkReply *reply= QmlPixmapCache::get(&engine, target, &pixmap); + QmlPixmapReply::Status status = QmlPixmapCache::get(target, &pixmap); if (incache) { - QVERIFY(!reply); - if (exists) + if (exists) { + QVERIFY(status == QmlPixmapReply::Ready); QVERIFY(pixmap.width() > 0); - else + } else { + QVERIFY(status == QmlPixmapReply::Error); QVERIFY(pixmap.width() <= 0); + } } else { + QmlPixmapReply *reply = QmlPixmapCache::request(&engine, target); QVERIFY(reply); QVERIFY(pixmap.width() <= 0); @@ -151,10 +154,10 @@ void tst_qmlpixmapcache::single() QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(getter.gotslot); if (exists) { - QVERIFY(QmlPixmapCache::find(target, &pixmap)); + QVERIFY(QmlPixmapCache::get(target, &pixmap) == QmlPixmapReply::Ready); QVERIFY(pixmap.width() > 0); } else { - QVERIFY(!QmlPixmapCache::find(target, &pixmap)); + QVERIFY(QmlPixmapCache::get(target, &pixmap) == QmlPixmapReply::Error); QVERIFY(pixmap.width() <= 0); } } @@ -225,12 +228,15 @@ void tst_qmlpixmapcache::parallel() QList<QUrl> targets; targets << target1 << target2; - QList<QNetworkReply*> replies; + QList<QmlPixmapReply*> replies; QList<Slotter*> getters; for (int i=0; i<targets.count(); ++i) { QUrl target = targets.at(i); QPixmap pixmap; - QNetworkReply *reply = QmlPixmapCache::get(&engine, target, &pixmap); + QmlPixmapReply::Status status = QmlPixmapCache::get(target, &pixmap); + QmlPixmapReply *reply = 0; + if (status != QmlPixmapReply::Error && status != QmlPixmapReply::Ready) + reply = QmlPixmapCache::request(&engine, target); replies.append(reply); if (!reply) { QVERIFY(pixmap.width() > 0); @@ -246,7 +252,7 @@ void tst_qmlpixmapcache::parallel() QCOMPARE(QmlPixmapCache::pendingRequests(), requests); if (cancel >= 0) { - QmlPixmapCache::cancelGet(targets.at(cancel), getters[cancel]); + QmlPixmapCache::cancel(targets.at(cancel), getters[cancel]); slotters--; } @@ -256,14 +262,14 @@ void tst_qmlpixmapcache::parallel() } for (int i=0; i<targets.count(); ++i) { - QNetworkReply *reply = replies[i]; + QmlPixmapReply *reply = replies[i]; if (reply) { if (i == cancel) { QVERIFY(!getters[i]->gotslot); } else { QVERIFY(getters[i]->gotslot); QPixmap pixmap; - QVERIFY(QmlPixmapCache::find(targets[i], &pixmap)); + QVERIFY(QmlPixmapCache::get(targets[i], &pixmap) == QmlPixmapReply::Ready); QVERIFY(pixmap.width() > 0); } delete getters[i]; |