diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-09 16:23:30 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-15 18:22:10 +0200 |
commit | 38fb82bfef8f5a599ee374958a20b9d271002c88 (patch) | |
tree | 9038b1be13017be3276bda52b0f4c9911690c22c /tests | |
parent | 6af3cc27235a67420d32dbe0146d94ada6b25028 (diff) | |
download | qtlocation-38fb82bfef8f5a599ee374958a20b9d271002c88.tar.gz |
Register QPlaceSupplier as a QML value type
Make QPlaceSupplier 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 placeSupplier properties as a grouped property, or
via a converter from QJSValue.
Change-Id: Id35ac1d9f03ce831013e4a7231302abd7b6cd7c8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative_location_core/tst_place.qml | 35 | ||||
-rw-r--r-- | tests/auto/declarative_location_core/tst_supplier.qml | 22 | ||||
-rw-r--r-- | tests/auto/qmlinterface/data/TestPlace.qml | 7 | ||||
-rw-r--r-- | tests/auto/qmlinterface/data/TestSupplier.qml | 14 |
4 files changed, 28 insertions, 50 deletions
diff --git a/tests/auto/declarative_location_core/tst_place.qml b/tests/auto/declarative_location_core/tst_place.qml index ef0baa93..916b036e 100644 --- a/tests/auto/declarative_location_core/tst_place.qml +++ b/tests/auto/declarative_location_core/tst_place.qml @@ -84,13 +84,12 @@ TestCase { ratings: ({ average: 3.5, count: 10 }) - supplier: Supplier { - name: "Supplier 1" - supplierId: "supplier-id-1" - url: "http://www.example.com/supplier-id-1/" - icon: ({ parameters: { singleUrl: "http://www.example.com/supplier-id-1/icon" }}) - } - + supplier: ({ + name: "Supplier 1", + supplierId: "supplier-id-1", + url: "http://www.example.com/supplier-id-1/", + icon: ({ parameters : { singleUrl: "http://www.example.com/supplier-id-1/icon" }}) + }) categories: [ Category { name: "Category 1" @@ -136,22 +135,8 @@ TestCase { } // check supplier - if (place1.supplier === null && place2.supplier !== null) - return false; - if (place1.supplier !== null && place2.supplier === null) + if (place1.supplier !== place2.supplier) { return false; - if (place1.supplier !== null && place2.supplier !== null) { - if (place1.supplier.supplierId !== place2.supplier.supplierId) - return false; - if (place1.supplier.name !== place2.supplier.name) - return false; - if (place1.supplier.url !== place2.supplier.url) - return false; - - // check supplier icon - if (place1.supplier.icon !== place2.supplier.icon) { - return false; - } } // check ratings @@ -289,7 +274,7 @@ TestCase { } function test_supplier() { - var supplier = Qt.createQmlObject('import QtLocation 5.3; Supplier { supplierId: "sup-id-1"; name: "Category 1" }', testCase, "Supplier1"); + var supplier = savePlace.supplier; var signalSpy = Qt.createQmlObject('import QtTest 1.0; SignalSpy {}', testCase, "SignalSpy"); signalSpy.target = testPlace; @@ -314,8 +299,8 @@ TestCase { compare(signalSpy.count, 1); // reset by assignment - testPlace.supplier = null; - compare(testPlace.supplier, null); + testPlace.supplier = emptyPlace.supplier; + compare(testPlace.supplier, emptyPlace.supplier); compare(signalSpy.count, 2); signalSpy.destroy(); diff --git a/tests/auto/declarative_location_core/tst_supplier.qml b/tests/auto/declarative_location_core/tst_supplier.qml index 226cde54..eb0f8eb1 100644 --- a/tests/auto/declarative_location_core/tst_supplier.qml +++ b/tests/auto/declarative_location_core/tst_supplier.qml @@ -29,14 +29,13 @@ import QtQuick import QtTest import QtLocation -import "utils.js" as Utils TestCase { id: testCase name: "Supplier" - Supplier { id: emptySupplier } + property supplier emptySupplier; function test_empty() { compare(emptySupplier.supplierId, ""); @@ -45,9 +44,8 @@ TestCase { verify(emptySupplier.icon); } - Supplier { - id: qmlSupplier - + property supplier qmlSupplier + qmlSupplier { supplierId: "test-supplier-id" name: "Test Supplier" url: "http://example.com/test-supplier-id" @@ -62,18 +60,4 @@ TestCase { verify(qmlSupplier.icon); compare(qmlSupplier.icon.parameters.singleUrl, "http://example.com/icons/test-supplier.png"); } - - Supplier { - id: testSupplier - } - - Plugin { - id: testPlugin - name: "qmlgeo.test.plugin" - allowExperimental: true - } - - Plugin { - id: invalidPlugin - } } diff --git a/tests/auto/qmlinterface/data/TestPlace.qml b/tests/auto/qmlinterface/data/TestPlace.qml index a3c40c14..0665435b 100644 --- a/tests/auto/qmlinterface/data/TestPlace.qml +++ b/tests/auto/qmlinterface/data/TestPlace.qml @@ -45,6 +45,11 @@ Place { location: TestLocation { } ratings: ({ average: 3.5, maximum: 5.0, count: 10 }) icon: ({ parameters: { singleUrl: "http://www.example.com/test-icon.png" }}) - supplier: TestSupplier { } + supplier: ({ + name: "Test supplier", + supplierId: "test-supplier-id", + url: "http://www.example.com/test-supplier", + icon: ({ parameters : { singleUrl: "http://www.example.com/test-icon.png" }}) + }) visibility: Place.PrivateVisibility } diff --git a/tests/auto/qmlinterface/data/TestSupplier.qml b/tests/auto/qmlinterface/data/TestSupplier.qml index 7f4cc451..f94f7f7b 100644 --- a/tests/auto/qmlinterface/data/TestSupplier.qml +++ b/tests/auto/qmlinterface/data/TestSupplier.qml @@ -27,10 +27,14 @@ ****************************************************************************/ import QtLocation +import QtQuick -Supplier { - name: "Test supplier" - supplierId: "test-supplier-id" - url: "http://www.example.com/test-supplier" - icon: ({ parameters: { singleUrl: "http://www.example.com/test-icon.png" }}) +Item { + property supplier supplier + supplier { + name: "Test supplier" + supplierId: "test-supplier-id" + url: "http://www.example.com/test-supplier" + icon: ({ parameters: { singleUrl: "http://www.example.com/test-icon.png" }}) + } } |