diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-11-10 16:50:46 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-11-12 10:23:12 +0100 |
commit | bf547fb272f568e438ed9c2fe48427b5a054f93a (patch) | |
tree | 0d4c8a6f1579a6d50fdb196410502e2028d5025d /tests | |
parent | 6a605df673380ffe4e7ee24417175f58ba7972a4 (diff) |
ListModel: support URLs
Fixes: QTBUG-88379
Change-Id: I6e2ea550d8f8972c5fdcdc21a5e3851992c591a5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qqmllistmodel/data/urls.qml | 19 | ||||
-rw-r--r-- | tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp | 11 |
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllistmodel/data/urls.qml b/tests/auto/qml/qqmllistmodel/data/urls.qml new file mode 100644 index 0000000000..b7fe57402e --- /dev/null +++ b/tests/auto/qml/qqmllistmodel/data/urls.qml @@ -0,0 +1,19 @@ +import QtQuick 2 +import QtQml.Models 2 + +Item { + id: root + readonly property url url1: "http://qt-project.org" + property var result1 + property var result2 + ListModel {id: myModel} + + Component.onCompleted: { + myModel.append({"url": new URL("http://qt.io")}) + myModel.append({"url": url1}) + const entry1 = myModel.get(0) + root.result1 = entry1.url; + const entry2 = myModel.get(1) + root.result2 = entry2.url; + } +} diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index c2f9cfbc11..3d0aaf1147 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -121,6 +121,7 @@ private slots: void empty_element_warning_data(); void datetime(); void datetime_data(); + void url(); void about_to_be_signals(); void modify_through_delegate(); void bindingsOnGetResult(); @@ -1392,6 +1393,16 @@ void tst_qqmllistmodel::datetime_data() QTest::newRow("dt4") << "{append({'date':dt0});setProperty(0,'date',dt1);get(0).date}" << dt1; } +void tst_qqmllistmodel::url() +{ + QQmlEngine engine; + QQmlComponent comp(&engine, testFileUrl("urls.qml")); + QScopedPointer<QObject> o {comp.create()}; + QVERIFY(o); + QCOMPARE(o->property("result1").toUrl(), QUrl("http://qt.io")); + QCOMPARE(o->property("result2").toUrl(), QUrl("http://qt-project.org")); +} + void tst_qqmllistmodel::datetime() { QFETCH(QString, qml); |