diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-04-15 04:47:10 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-04-15 04:48:55 (GMT) |
commit | aad82abd84022f5401c6b79ab15d24abebf082af (patch) | |
tree | be1bd4efd7f1b7b20b207696ee05a608f49efd27 /tests | |
parent | 35afac3d3a275aa69c74e174cfeb5e411816e94a (diff) | |
download | Qt-aad82abd84022f5401c6b79ab15d24abebf082af.zip Qt-aad82abd84022f5401c6b79ab15d24abebf082af.tar.gz Qt-aad82abd84022f5401c6b79ab15d24abebf082af.tar.bz2 |
Correctly resolve, and load, IMG tags in Text element.
Task-number: QTBUG-9900
Reviewed-by: Martin Jones
Diffstat (limited to 'tests')
7 files changed, 72 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocal.qml b/tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocal.qml new file mode 100644 index 0000000..5aeea56 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocal.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +Text { + text: "<img src='http/exists.png'>" +} diff --git a/tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocalError.qml b/tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocalError.qml new file mode 100644 index 0000000..17bb21c --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocalError.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +Text { + text: "<img src='http/notexists.png'>" +} diff --git a/tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemote.qml b/tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemote.qml new file mode 100644 index 0000000..53b0266 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemote.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +Text { + text: "<img src='http://127.0.0.1:14453/exists.png'>" +} diff --git a/tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemoteError.qml b/tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemoteError.qml new file mode 100644 index 0000000..48c7a95 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemoteError.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +Text { + text: "<img src='http://127.0.0.1:14453/notexists.png'>" +} diff --git a/tests/auto/declarative/qdeclarativetext/data/http/exists.png b/tests/auto/declarative/qdeclarativetext/data/http/exists.png Binary files differnew file mode 100644 index 0000000..399bd0b --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/http/exists.png diff --git a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro index 73c05b5..e70443e 100644 --- a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro +++ b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro @@ -1,8 +1,15 @@ load(qttest_p4) contains(QT_CONFIG,declarative): QT += declarative gui +QT += network macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativetext.cpp +INCLUDEPATH += ../shared/ +HEADERS += ../shared/testhttpserver.h +SOURCES += ../shared/testhttpserver.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" + CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index 6637415..53640d0 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -48,6 +48,9 @@ #include <QGraphicsSceneMouseEvent> #include <qmath.h> +#include "../../../shared/util.h" +#include "testhttpserver.h" + class tst_qdeclarativetext : public QObject { @@ -62,6 +65,9 @@ private slots: void elide(); void textFormat(); + void embeddedImages_data(); + void embeddedImages(); + // ### these tests may be trivial void horizontalAlignment(); void verticalAlignment(); @@ -859,6 +865,45 @@ void tst_qdeclarativetext::clickLink() } } +void tst_qdeclarativetext::embeddedImages_data() +{ + QTest::addColumn<QUrl>("qmlfile"); + QTest::addColumn<QString>("error"); + QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocal.qml") << ""; + QTest::newRow("local-error") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocalError.qml") + << "\"Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/http/notexists.png").toString() + "\" "; + QTest::newRow("remote") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemote.qml") << ""; + QTest::newRow("remote-error") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemoteError.qml") + << "\"Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found\" "; +} + +void tst_qdeclarativetext::embeddedImages() +{ + // Tests QTBUG-9900 + + QFETCH(QUrl, qmlfile); + QFETCH(QString, error); + + TestHTTPServer server(14453); + server.serveDirectory(SRCDIR "/data/http"); + + if (!error.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, error.toLatin1()); + + QDeclarativeComponent textComponent(&engine, qmlfile); + QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create()); + + QVERIFY(textObject != 0); + + QTRY_COMPARE(textObject->resourcesLoading(), 0); + + if (error.isEmpty()) { + QPixmap pm(SRCDIR "/data/http/exists.png"); + QCOMPARE(textObject->width(), double(pm.width())); + QCOMPARE(textObject->height(), double(pm.height())); + } +} + QTEST_MAIN(tst_qdeclarativetext) #include "tst_qdeclarativetext.moc" |