diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-11-23 05:45:39 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-11-23 05:45:39 (GMT) |
commit | b204fd2bc702e0ff3823b2b74de338c5be4ac0b3 (patch) | |
tree | f7e9a0b45d64ea7fc759241205c3e6bcd9699d12 /tests | |
parent | 2a93f7ce631702ec17b87e23d7efa8a0ae6f5458 (diff) | |
download | Qt-b204fd2bc702e0ff3823b2b74de338c5be4ac0b3.zip Qt-b204fd2bc702e0ff3823b2b74de338c5be4ac0b3.tar.gz Qt-b204fd2bc702e0ff3823b2b74de338c5be4ac0b3.tar.bz2 |
Check error messages returned.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp b/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp index 5ce5faf..784ad42 100644 --- a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp +++ b/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp @@ -106,11 +106,26 @@ void tst_qmlgraphicsimage::noSource() delete obj; } +void tst_qmlgraphicsimage::imageSource_data() +{ + QTest::addColumn<QString>("source"); + QTest::addColumn<bool>("remote"); + QTest::addColumn<QString>("error"); + + QTest::newRow("local") << SRCDIR "/data/colors.png" << false << ""; + QTest::newRow("local not found") << SRCDIR "/data/no-such-file.png" << false + << "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\" ) " + "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" "; +} + void tst_qmlgraphicsimage::imageSource() { QFETCH(QString, source); QFETCH(bool, remote); - QFETCH(bool, valid); + QFETCH(QString, error); TestHTTPServer server(SERVER_PORT); if (remote) { @@ -118,6 +133,9 @@ void tst_qmlgraphicsimage::imageSource() server.serveDirectory(SRCDIR "/data"); } + if (!error.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); + QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\" }"; QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create()); @@ -128,7 +146,7 @@ void tst_qmlgraphicsimage::imageSource() QCOMPARE(obj->source(), remote ? source : QUrl::fromLocalFile(source)); - if (valid) { + if (error.isEmpty()) { TRY_WAIT(obj->status() == QmlGraphicsImage::Ready); QCOMPARE(obj->width(), 120.); QCOMPARE(obj->height(), 120.); @@ -162,18 +180,6 @@ void tst_qmlgraphicsimage::clearSource() QCOMPARE(obj->progress(), 0.0); } -void tst_qmlgraphicsimage::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; -} - void tst_qmlgraphicsimage::resized() { QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }"; |