summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorabcd <amos.choy@nokia.com>2011-12-16 13:46:05 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-20 09:05:20 +0100
commit64d20321bee9b0494fa72c857bce0b858a798ccb (patch)
tree69da5634feea01c59f7515273a106a65b6ffaa4e /tests
parentdde0e41e6fd9d777d9f5a2b834a46782a7da1613 (diff)
downloadqtlocation-64d20321bee9b0494fa72c857bce0b858a798ccb.tar.gz
Unit tests + corrections for Contact Details in QML
The behaviour for contact details wasn't quite correct in the instance where a single detail is assigned rather than a list. For now there is a workaround by listening to the valueChanged signal of the QDeclarativePropertyMap to detect if a single item is being added and if so turn it into a list with one element. The correction solution would be to override the write behaviour of QDeclaratiePropertyMap but this can't be done until QTBUG-23183 is addressed. Also add some extra examples for contact detail assignment and a correction for when contact details are viewed by a ListView, we need to have modelData.label rather than just label when dealing with an object list. Change-Id: I10555b9536ae4c4172b9b49347b7b6be12c5c1ab Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative_core/tst_place.qml54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/auto/declarative_core/tst_place.qml b/tests/auto/declarative_core/tst_place.qml
index 57b38136..10ed8eeb 100644
--- a/tests/auto/declarative_core/tst_place.qml
+++ b/tests/auto/declarative_core/tst_place.qml
@@ -621,4 +621,58 @@ TestCase {
compare(place.visibility, Place.UnspecifiedVisibility);
}
+ function test_contactDetails(data) {
+ var place = Qt.createQmlObject('import QtLocation 5.0; Place {}', this);
+
+ var signalSpy = Qt.createQmlObject('import QtTest 1.0; SignalSpy {}', testCase, "SignalSpy");
+ signalSpy.target = place;
+ signalSpy.signalName = data.signalName;
+
+ var detail1 = Qt.createQmlObject('import QtLocation 5.0; 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[data.primaryValue], "555-detail1");
+ compare(signalSpy.count, 1);
+ signalSpy.clear();
+
+ var listView = Qt.createQmlObject('import QtQuick 2.0; ListView { delegate:Text{text:modelData.label + ":" + modelData.value } }', this);
+ listView.model = place.contactDetails[data.contactType];
+ compare(listView.count, 1);
+
+ var detail2 = Qt.createQmlObject('import QtLocation 5.0; 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[data.primaryValue], "555-detail2");
+ compare(signalSpy.count, 1);
+ signalSpy.clear();
+ listView.model = place.contactDetails[data.contactType];
+ compare(listView.count, 2);
+ }
+
+ function test_contactDetails_data() {
+ return [
+ { tag: "phone", contactType: "phone", signalName: "primaryPhoneChanged", primaryValue: "primaryPhone"},
+ { tag: "fax", contactType: "fax", signalName: "primaryFaxChanged", primaryValue: "primaryFax"},
+ { tag: "email", contactType: "email", signalName: "primaryEmailChanged", primaryValue: "primaryEmail"},
+ { tag: "website", contactType: "website", signalName: "primaryWebsiteChanged", primaryValue: "primaryWebsite"}
+ ];
+ }
}