From b204fd2bc702e0ff3823b2b74de338c5be4ac0b3 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 15:45:39 +1000 Subject: Check error messages returned. --- .../qmlgraphicsimage/tst_qmlgraphicsimage.cpp | 34 +++++++++++++--------- 1 file 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("source"); + QTest::addColumn("remote"); + QTest::addColumn("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(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("source"); - QTest::addColumn("remote"); - QTest::addColumn("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 }"; -- cgit v0.12