diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-09 14:21:51 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-14 13:20:15 +0200 |
commit | 517e4f284e1808ecddc998d73b4b554880733381 (patch) | |
tree | 52e01d085fb0d7ca997ee1d25e1f9fa856fcd112 /tests | |
parent | 1d8897b32148057246a779ad7cf18aeed1c2acc3 (diff) | |
download | qtlocation-517e4f284e1808ecddc998d73b4b554880733381.tar.gz |
Register QPlaceIcon as a QML value type
Make QPlaceIcon a gadget, and register it as a value type with the QML
engine. Remove declarative wrapper, and consolidate the documentation.
Adjust the tests and remove tests that verify that the type behaves like
an object. Initialize placeIcon properties as a grouped property, or via
a converter from QJSValue. That converter is a temporary solution to
enable tests, and can hopefully be removed once the QML engine supports
property-initialization of value types.
Task-number: QTBUG-106482
Change-Id: I2aa29102ee232afb3d71396bcd3288e2f99c0fc6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative_location_core/tst_category.qml | 12 | ||||
-rw-r--r-- | tests/auto/declarative_location_core/tst_place.qml | 58 | ||||
-rw-r--r-- | tests/auto/declarative_location_core/tst_placeicon.qml | 57 | ||||
-rw-r--r-- | tests/auto/declarative_location_core/tst_supplier.qml | 23 | ||||
-rw-r--r-- | tests/auto/qmlinterface/data/TestIcon.qml | 7 | ||||
-rw-r--r-- | tests/auto/qmlinterface/data/TestPlace.qml | 2 | ||||
-rw-r--r-- | tests/auto/qmlinterface/data/TestSupplier.qml | 2 |
7 files changed, 18 insertions, 143 deletions
diff --git a/tests/auto/declarative_location_core/tst_category.qml b/tests/auto/declarative_location_core/tst_category.qml index afecafe6..4c9b72c7 100644 --- a/tests/auto/declarative_location_core/tst_category.qml +++ b/tests/auto/declarative_location_core/tst_category.qml @@ -57,11 +57,7 @@ TestCase { name: "Test Category" visibility: Category.DeviceVisibility - icon: Icon { - Component.onCompleted: { - parameters.singleUrl = "http://example.com/icons/test-category.png" - } - } + icon: ({ parameters: { singleUrl: "http://example.com/icons/test-category.png" }}) } function test_qmlConstructedCategory() { @@ -73,7 +69,6 @@ TestCase { verify(qmlCategory.icon); compare(qmlCategory.icon.url(), "http://example.com/icons/test-category.png"); compare(qmlCategory.icon.parameters.singleUrl, "http://example.com/icons/test-category.png"); - compare(qmlCategory.icon.plugin, qmlCategory.plugin); } Category { @@ -90,9 +85,7 @@ TestCase { id: invalidPlugin } - Icon { - id: testIcon - } + property icon testIcon: ({ parameters: { singleUrl: "example.com" } }) Category { id: saveCategory @@ -116,7 +109,6 @@ TestCase { { tag: "categoryId", property: "categoryId", signal: "categoryIdChanged", value: "test-category-id-1", reset: "" }, { tag: "visibility", property: "visibility", signal: "visibilityChanged", value: Place.PublicVisibility, reset: Place.UnspecifiedVisibility }, { tag: "plugin", property: "plugin", signal: "pluginChanged", value: testPlugin }, - { tag: "icon", property: "icon", signal: "iconChanged", value: testIcon } ]; } diff --git a/tests/auto/declarative_location_core/tst_place.qml b/tests/auto/declarative_location_core/tst_place.qml index 871f10c1..ef0baa93 100644 --- a/tests/auto/declarative_location_core/tst_place.qml +++ b/tests/auto/declarative_location_core/tst_place.qml @@ -88,12 +88,7 @@ TestCase { name: "Supplier 1" supplierId: "supplier-id-1" url: "http://www.example.com/supplier-id-1/" - icon: Icon{ - plugin: testPlugin - Component.onCompleted: { - parameters.singleUrl = "http://www.example.com/supplier-id-1/icon" - } - } + icon: ({ parameters: { singleUrl: "http://www.example.com/supplier-id-1/icon" }}) } categories: [ @@ -109,11 +104,7 @@ TestCase { } ] - icon: Icon { - Component.onCompleted: { - savePlace.icon.parameters.singleUrl = "http://example.com/test-place.png"; - } - } + icon: ({ parameters: { singleUrl: "http://example.com/test-place.png" } }) } Place { @@ -158,24 +149,8 @@ TestCase { return false; // check supplier icon - if (place1.supplier.icon === null && place2.supplier.icon !== null) - return false; - if (place1.supplier.icon !== null && place2.supplier.icon === null) + if (place1.supplier.icon !== place2.supplier.icon) { return false; - if (place1.supplier.icon !== null && place2.supplier.icon !== null) { - if (place1.supplier.icon.parameters.keys().length !== place2.supplier.icon.parameters.keys().length) { - return false; - } - - var keys = place1.supplier.icon.parameters.keys() + place2.supplier.icon.parameters.keys(); - for (var i = 0; i < keys.length; ++i) { - if (place1.supplier.icon.parameters[keys[i]] != place2.supplier.icon.parameters[keys[i]]) { - return false; - } - } - - if (place1.supplier.icon.plugin !== place2.supplier.icon.plugin) - return false; } } @@ -214,30 +189,9 @@ TestCase { } // check icon - if (place1.icon === null && place2.icon !== null) { + if (place1.icon !== place2.icon) { return false; } - if (place1.icon !== null && place2.icon === null) { - return false; - } - if (place1.icon !== null && place2.icon !== null) { - if (place1.icon.plugin !== place2.icon.plugin) { - console.log(place1.icon.plugin + " " + place2.icon.plugin); - return false; - } - - if (place1.icon.parameters.keys().length !== place2.icon.parameters.keys().length) { - return false; - } - - var keys = place1.icon.parameters.keys() + place2.icon.parameters.keys(); - for (var i = 0; i < keys.length; ++i) { - if (place1.icon.parameters[keys[i]] - != place2.icon.parameters[keys[i]]) { - return false; - } - } - } // check extended attributes @@ -268,14 +222,10 @@ TestCase { compare(emptyPlace.location.address.state, ''); compare(emptyPlace.location.address.country, ''); - compare(emptyPlace.icon.plugin, null); - compare(emptyPlace.supplier.name, ''); compare(emptyPlace.supplier.supplierId, ''); compare(emptyPlace.supplier.url, ''); - compare(emptyPlace.supplier.icon.plugin, null); - compare(emptyPlace.reviewModel.totalCount, -1); compare(emptyPlace.imageModel.totalCount, -1); compare(emptyPlace.editorialModel.totalCount, -1); diff --git a/tests/auto/declarative_location_core/tst_placeicon.qml b/tests/auto/declarative_location_core/tst_placeicon.qml index e8597bb7..9d97962a 100644 --- a/tests/auto/declarative_location_core/tst_placeicon.qml +++ b/tests/auto/declarative_location_core/tst_placeicon.qml @@ -36,71 +36,26 @@ TestCase { name: "Icon" - Icon { id: emptyIcon } + property icon emptyIcon function test_empty() { - compare(emptyIcon.plugin, null); - compare(emptyIcon.parameters.keys().length, 0) + compare(emptyIcon.parameters, {}) } - Icon { - id: qmlIconSingleUrl - } + property icon qmlIconSingleUrl: ({ parameters: { singleUrl: "http://example.com/icon.png" }}) function test_qmlSingleUrlIcon() { - qmlIconSingleUrl.parameters.singleUrl = "http://example.com/icon.png" - var u = qmlIconSingleUrl.url(Qt.size(64, 64)); compare(u, "http://example.com/icon.png"); u = qmlIconSingleUrl.url(Qt.size(20, 20)); compare(u, "http://example.com/icon.png"); - qmlIconSingleUrl.parameters.singleUrl = "/home/user/icon.png" + var params = qmlIconSingleUrl.parameters + params.singleUrl = "/home/user/icon.png" + qmlIconSingleUrl.parameters = params u = qmlIconSingleUrl.url(Qt.size(20, 20)); compare(u, "file:///home/user/icon.png"); } - - Plugin { - id: testPlugin - name: "qmlgeo.test.plugin" - allowExperimental: true - } - - Icon { - id: qmlIconParams - plugin: testPlugin - } - - function test_qmlIconParams() { - compare(qmlIconParams.plugin, testPlugin); - qmlIconParams.parameters.s = "http://example.com/icon_small.png" - qmlIconParams.parameters.m = "http://example.com/icon_medium.png" - qmlIconParams.parameters.l = "http://example.com/icon_large.png" - - compare(qmlIconParams.url(Qt.size(10, 10)), "http://example.com/icon_small.png"); - compare(qmlIconParams.url(Qt.size(20, 20)), "http://example.com/icon_small.png"); - compare(qmlIconParams.url(Qt.size(24, 24)), "http://example.com/icon_small.png"); - compare(qmlIconParams.url(Qt.size(25, 25)), "http://example.com/icon_medium.png"); - compare(qmlIconParams.url(Qt.size(30, 30)), "http://example.com/icon_medium.png"); - compare(qmlIconParams.url(Qt.size(39, 39)), "http://example.com/icon_medium.png"); - compare(qmlIconParams.url(Qt.size(40, 40)), "http://example.com/icon_large.png"); - compare(qmlIconParams.url(Qt.size(50, 50)), "http://example.com/icon_large.png"); - compare(qmlIconParams.url(Qt.size(60, 60)), "http://example.com/icon_large.png"); - } - - Icon { - id: testIcon - } - - function test_setAndGet_data() { - return [ - { tag: "plugin", property: "plugin", signal: "pluginChanged", value: testPlugin }, - ]; - } - - function test_setAndGet(data) { - Utils.testObjectProperties(testCase, testIcon, data); - } } diff --git a/tests/auto/declarative_location_core/tst_supplier.qml b/tests/auto/declarative_location_core/tst_supplier.qml index 8cb6f584..226cde54 100644 --- a/tests/auto/declarative_location_core/tst_supplier.qml +++ b/tests/auto/declarative_location_core/tst_supplier.qml @@ -52,11 +52,7 @@ TestCase { name: "Test Supplier" url: "http://example.com/test-supplier-id" - icon: Icon { - Component.onCompleted: { - parameters.singleUrl = "http://example.com/icons/test-supplier.png" - } - } + icon: ({ parameters: { singleUrl: "http://example.com/icons/test-supplier.png" }}) } function test_qmlConstructedSupplier() { @@ -80,21 +76,4 @@ TestCase { Plugin { id: invalidPlugin } - - Icon { - id: testIcon - } - - function test_setAndGet_data() { - return [ - { tag: "name", property: "name", signal: "nameChanged", value: "Test Supplier", reset: "" }, - { tag: "supplierId", property: "supplierId", signal: "supplierIdChanged", value: "test-supplier-id-1", reset: "" }, - { tag: "url", property: "url", signal: "urlChanged", value: "http://example.com/test-supplier-id-1", reset: "" }, - { tag: "icon", property: "icon", signal: "iconChanged", value: testIcon } - ]; - } - - function test_setAndGet(data) { - Utils.testObjectProperties(testCase, testSupplier, data); - } } diff --git a/tests/auto/qmlinterface/data/TestIcon.qml b/tests/auto/qmlinterface/data/TestIcon.qml index 8053da61..1d8a10b6 100644 --- a/tests/auto/qmlinterface/data/TestIcon.qml +++ b/tests/auto/qmlinterface/data/TestIcon.qml @@ -29,8 +29,7 @@ import QtQuick import QtLocation -Icon { - Component.onCompleted: { - parameters.singleUrl = "http://www.example.com/test-icon.png" - } +Item { + id: testIcon + property icon icon: ({ parameters: { singleUrl: "http://www.example.com/test-icon.png" }}) } diff --git a/tests/auto/qmlinterface/data/TestPlace.qml b/tests/auto/qmlinterface/data/TestPlace.qml index 1cce22af..a3c40c14 100644 --- a/tests/auto/qmlinterface/data/TestPlace.qml +++ b/tests/auto/qmlinterface/data/TestPlace.qml @@ -44,7 +44,7 @@ Place { ] location: TestLocation { } ratings: ({ average: 3.5, maximum: 5.0, count: 10 }) - icon: TestIcon { } + icon: ({ parameters: { singleUrl: "http://www.example.com/test-icon.png" }}) supplier: TestSupplier { } visibility: Place.PrivateVisibility } diff --git a/tests/auto/qmlinterface/data/TestSupplier.qml b/tests/auto/qmlinterface/data/TestSupplier.qml index 0a682fdf..7f4cc451 100644 --- a/tests/auto/qmlinterface/data/TestSupplier.qml +++ b/tests/auto/qmlinterface/data/TestSupplier.qml @@ -32,5 +32,5 @@ Supplier { name: "Test supplier" supplierId: "test-supplier-id" url: "http://www.example.com/test-supplier" - icon: TestIcon { } + icon: ({ parameters: { singleUrl: "http://www.example.com/test-icon.png" }}) } |