diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-09 17:46:01 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-15 18:22:17 +0200 |
commit | f170e6edbd6960abd8bc0b269118211c515c8587 (patch) | |
tree | 6b4b0f83838d0835786ce6ec645b7f252a194dbf /tests | |
parent | 38fb82bfef8f5a599ee374958a20b9d271002c88 (diff) | |
download | qtlocation-f170e6edbd6960abd8bc0b269118211c515c8587.tar.gz |
Register QPlaceContactDetail as a QML value type
Make QPlaceContactDetail 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 contactDetail properties as a grouped property.
The QDeclarativeContactDetails implementation of QQmlPropertyMap has to
stay, so rename the sources accordingly.
Change-Id: I473d29405963bbe594cd5f26168a237c189d1d3e
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative_location_core/tst_contactdetail.qml | 25 | ||||
-rw-r--r-- | tests/auto/declarative_location_core/tst_place.qml | 40 | ||||
-rw-r--r-- | tests/auto/qmlinterface/data/TestContactDetail.qml | 10 |
3 files changed, 35 insertions, 40 deletions
diff --git a/tests/auto/declarative_location_core/tst_contactdetail.qml b/tests/auto/declarative_location_core/tst_contactdetail.qml index a71586f4..e9c93178 100644 --- a/tests/auto/declarative_location_core/tst_contactdetail.qml +++ b/tests/auto/declarative_location_core/tst_contactdetail.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -28,23 +28,21 @@ import QtTest import QtLocation -import "utils.js" as Utils TestCase { id: testCase name: "ContactDetail" - ContactDetail { id: emptyContactDetail } + property contactDetail emptyContactDetail function test_empty() { compare(emptyContactDetail.label, ""); compare(emptyContactDetail.value, ""); } - ContactDetail { - id: qmlContactDetail - + property contactDetail qmlContactDetail + qmlContactDetail { label: "Phone" value: "12345" } @@ -53,19 +51,4 @@ TestCase { compare(qmlContactDetail.label, "Phone"); compare(qmlContactDetail.value, "12345"); } - - ContactDetail { - id: testContactDetail - } - - function test_setAndGet_data() { - return [ - { tag: "label", property: "label", signal: "labelChanged", value: "Phone", reset: "" }, - { tag: "value", property: "value", signal: "valueChanged", value: "12345", reset: "" }, - ]; - } - - function test_setAndGet(data) { - Utils.testObjectProperties(testCase, testContactDetail, data); - } } diff --git a/tests/auto/declarative_location_core/tst_place.qml b/tests/auto/declarative_location_core/tst_place.qml index 916b036e..a8294673 100644 --- a/tests/auto/declarative_location_core/tst_place.qml +++ b/tests/auto/declarative_location_core/tst_place.qml @@ -369,10 +369,15 @@ TestCase { verify(!testPlace.extendedAttributes.foo); } + property contactDetail testDetail + testDetail { + label: "Test Label" + value: "Detail Value" + } function test_contactDetailsProperty() { verify(testPlace.contactDetails); - testPlace.contactDetails["phone"] = Qt.createQmlObject('import QtLocation 5.3; ContactDetail { label: "Test Label"; value: "Detail Value" }', testCase, 'ContactDetail'); + testPlace.contactDetails["phone"] = testDetail; verify(testPlace.contactDetails.phone); compare(testPlace.contactDetails.phone[0].label, "Test Label"); @@ -493,6 +498,17 @@ TestCase { compare(place.visibility, Place.UnspecifiedVisibility); } + property contactDetail detail1 + detail1 { + label: "Detail1" + value: "555-detail1" + } + property contactDetail detail2 + detail2 { + label: "Detail2" + value: "555-detail2" + } + function test_contactDetails(data) { var place = Qt.createQmlObject('import QtLocation 5.3; Place {}', this); @@ -500,14 +516,10 @@ TestCase { signalSpy.target = place; signalSpy.signalName = data.signalName; - var detail1 = Qt.createQmlObject('import QtLocation 5.3; ContactDetail {}', this); - detail1.label = "Detail1"; - detail1.value = "555-detail1"; - place.contactDetails[data.contactType] = detail1; compare(place.contactDetails[data.contactType].length, 1); - compare(place.contactDetails[data.contactType][0].label, "Detail1"); - compare(place.contactDetails[data.contactType][0].value, "555-detail1"); + compare(place.contactDetails[data.contactType][0].label, detail1.label); + compare(place.contactDetails[data.contactType][0].value, detail1.value); compare(place[data.primaryValue], "555-detail1"); compare(signalSpy.count, 1); @@ -517,22 +529,18 @@ TestCase { listView.model = place.contactDetails[data.contactType]; compare(listView.count, 1); - var detail2 = Qt.createQmlObject('import QtLocation 5.3; ContactDetail {}', this); - detail2.label = "Detail2"; - detail2.value = "555-detail2"; - var details = new Array(); details.push(detail2); details.push(detail1); place.contactDetails[data.contactType] = details; compare(place.contactDetails[data.contactType].length, 2); - compare(place.contactDetails[data.contactType][0].label, "Detail2"); - compare(place.contactDetails[data.contactType][0].value, "555-detail2"); - compare(place.contactDetails[data.contactType][1].label, "Detail1"); - compare(place.contactDetails[data.contactType][1].value, "555-detail1"); + compare(place.contactDetails[data.contactType][0].label, detail2.label); + compare(place.contactDetails[data.contactType][0].value, detail2.value); + compare(place.contactDetails[data.contactType][1].label, detail1.label); + compare(place.contactDetails[data.contactType][1].value, detail1.value); - compare(place[data.primaryValue], "555-detail2"); + compare(place[data.primaryValue], detail2.value); compare(signalSpy.count, 1); signalSpy.clear(); listView.model = place.contactDetails[data.contactType]; diff --git a/tests/auto/qmlinterface/data/TestContactDetail.qml b/tests/auto/qmlinterface/data/TestContactDetail.qml index fbfa3c3f..c8f82870 100644 --- a/tests/auto/qmlinterface/data/TestContactDetail.qml +++ b/tests/auto/qmlinterface/data/TestContactDetail.qml @@ -27,8 +27,12 @@ ****************************************************************************/ import QtLocation +import QtQuick -ContactDetail { - label: "Test Contact Detail" - value: "Test contact detail value" +Item { + property contactDetail contactDetail + contactDetail { + label: "Test Contact Detail" + value: "Test contact detail value" + } } |