diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-02-24 05:23:23 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-02-24 05:23:23 (GMT) |
commit | 8848b63187cf1b073891bdd6998273a8869bb033 (patch) | |
tree | 08e9934d033c474c5cb03e2dfbf277be90d62c9f /tests | |
parent | 915ab7d8c75a190003db97bc0a92656ee65f5b4b (diff) | |
download | Qt-8848b63187cf1b073891bdd6998273a8869bb033.zip Qt-8848b63187cf1b073891bdd6998273a8869bb033.tar.gz Qt-8848b63187cf1b073891bdd6998273a8869bb033.tar.bz2 |
Add an "asynchonous" property to Image.
Allows loading/decoding local images in an asynchronous thread (already
the case for network images).
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativeimage/data/colors1.png | bin | 0 -> 1655 bytes | |||
-rw-r--r-- | tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp | 18 |
2 files changed, 12 insertions, 6 deletions
diff --git a/tests/auto/declarative/qdeclarativeimage/data/colors1.png b/tests/auto/declarative/qdeclarativeimage/data/colors1.png Binary files differnew file mode 100644 index 0000000..dfb62f3 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimage/data/colors1.png diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index f38fca9..62793e7 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -112,13 +112,17 @@ void tst_qdeclarativeimage::imageSource_data() { QTest::addColumn<QString>("source"); QTest::addColumn<bool>("remote"); + QTest::addColumn<bool>("async"); QTest::addColumn<QString>("error"); - QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << ""; + QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << false << ""; + QTest::newRow("local async") << QUrl::fromLocalFile(SRCDIR "/data/colors1.png").toString() << false << true << ""; QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false - << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() + "\" ) "; - QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << ""; - QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true + << false << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() + "\" ) "; + QTest::newRow("local async not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() << false + << true << "\"Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() + "\" "; + QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << false << ""; + QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true << false << "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" "; } @@ -126,6 +130,7 @@ void tst_qdeclarativeimage::imageSource() { QFETCH(QString, source); QFETCH(bool, remote); + QFETCH(bool, async); QFETCH(QString, error); TestHTTPServer server(SERVER_PORT); @@ -137,13 +142,14 @@ void tst_qdeclarativeimage::imageSource() if (!error.isEmpty()) QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); - QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\" }"; + QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\"; asynchronous: " + + (async ? QLatin1String("true") : QLatin1String("false")) + " }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create()); QVERIFY(obj != 0); - if (remote) + if (remote || async) TRY_WAIT(obj->status() == QDeclarativeImage::Loading); QCOMPARE(obj->source(), remote ? source : QUrl(source)); |