diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2012-01-17 10:42:26 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-19 11:11:02 +0100 |
commit | de0a5f28bc565c971989e68a19c8621a2309ed91 (patch) | |
tree | c1508783394682a2aab90fba81d7871a9c9a6036 /tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp | |
parent | bab2eaf3da299c471dd898c89cf356984b077412 (diff) |
Add a baseUrl property to Text and TextEdit.
Specifies the base URL which embedded links in rich text are resolved
against. By default this is the URL of the item.
Task-number: QTBUG-23655
Change-Id: Ib51b8503a18d9ac4e1801c77b77b3595d8f4912a
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp')
-rw-r--r-- | tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp index fa9549afc7..60dab3380a 100644 --- a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp @@ -75,6 +75,7 @@ private slots: void alignments_data(); void alignments(); + void baseUrl(); void embeddedImages_data(); void embeddedImages(); @@ -1282,6 +1283,32 @@ void tst_qquicktext::clickLink() } } +void tst_qquicktext::baseUrl() +{ + QUrl localUrl("file:///tests/text.qml"); + QUrl remoteUrl("http://qt.nokia.com/test.qml"); + + QDeclarativeComponent textComponent(&engine); + textComponent.setData("import QtQuick 2.0\n Text {}", localUrl); + QQuickText *textObject = qobject_cast<QQuickText *>(textComponent.create()); + + QCOMPARE(textObject->baseUrl(), localUrl); + + QSignalSpy spy(textObject, SIGNAL(baseUrlChanged())); + + textObject->setBaseUrl(localUrl); + QCOMPARE(textObject->baseUrl(), localUrl); + QCOMPARE(spy.count(), 0); + + textObject->setBaseUrl(remoteUrl); + QCOMPARE(textObject->baseUrl(), remoteUrl); + QCOMPARE(spy.count(), 1); + + textObject->resetBaseUrl(); + QCOMPARE(textObject->baseUrl(), localUrl); + QCOMPARE(spy.count(), 2); +} + void tst_qquicktext::embeddedImages_data() { QTest::addColumn<QUrl>("qmlfile"); @@ -1289,9 +1316,11 @@ void tst_qquicktext::embeddedImages_data() QTest::newRow("local") << testFileUrl("embeddedImagesLocal.qml") << ""; QTest::newRow("local-error") << testFileUrl("embeddedImagesLocalError.qml") << testFileUrl("embeddedImagesLocalError.qml").toString()+":3:1: QML Text: Cannot open: " + testFileUrl("http/notexists.png").toString(); + QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << ""; QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << ""; QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml") << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found"; + QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << ""; } void tst_qquicktext::embeddedImages() |