summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2011-12-20 15:31:18 +1000
committerQt by Nokia <qt-info@nokia.com>2012-01-04 06:31:24 +0100
commitf2cc8b9398f149e1faf366c6a6b8501a02732735 (patch)
treea38099ad191143708d1aba923ba3eb71f348aa37 /tests
parent19e1baf69b8a9b9d594b59a33ea3400e1e595f49 (diff)
downloadqtlocation-f2cc8b9398f149e1faf366c6a6b8501a02732735.tar.gz
Improve unit test for Place element.
Attribution property testing. Icon property testing. Remove unnecesary property setters for detailsFetched, extendedAttributes and contactDetails. Change-Id: Iae93bffa8b9f6ffdf798418e99baceb76159df28 Reviewed-by: abcd <amos.choy@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative_core/tst_contactdetail.qml102
-rw-r--r--tests/auto/declarative_core/tst_place.qml69
2 files changed, 149 insertions, 22 deletions
diff --git a/tests/auto/declarative_core/tst_contactdetail.qml b/tests/auto/declarative_core/tst_contactdetail.qml
new file mode 100644
index 00000000..5e307814
--- /dev/null
+++ b/tests/auto/declarative_core/tst_contactdetail.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtTest 1.0
+import QtLocation 5.0
+
+TestCase {
+ id: testCase
+
+ name: "ContactDetail"
+
+ ContactDetail { id: emptyContactDetail }
+
+ function test_empty() {
+ compare(emptyContactDetail.label, "");
+ compare(emptyContactDetail.value, "");
+ }
+
+ ContactDetail {
+ id: qmlContactDetail
+
+ label: "Phone"
+ value: "12345"
+ }
+
+ function test_qmlConstructedContactDetail() {
+ 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) {
+ var signalSpy = Qt.createQmlObject('import QtTest 1.0; SignalSpy {}', testCase, "SignalSpy");
+ signalSpy.target = testContactDetail;
+ signalSpy.signalName = data.signal;
+
+ // set property to something new
+ testContactDetail[data.property] = data.value;
+ compare(testContactDetail[data.property], data.value);
+ compare(signalSpy.count, 1);
+
+ // set property to the same value (signal spy should not increase)
+ testContactDetail[data.property] = data.value;
+ compare(testContactDetail[data.property], data.value);
+ compare(signalSpy.count, 1);
+
+ // reset property
+ testContactDetail[data.property] = data.reset;
+ compare(testContactDetail[data.property], data.reset);
+ compare(signalSpy.count, 2);
+
+ signalSpy.destroy();
+ }
+}
diff --git a/tests/auto/declarative_core/tst_place.qml b/tests/auto/declarative_core/tst_place.qml
index 10ed8eeb..a5c36832 100644
--- a/tests/auto/declarative_core/tst_place.qml
+++ b/tests/auto/declarative_core/tst_place.qml
@@ -123,17 +123,9 @@ TestCase {
}
]
- // fixme, how is this meant to work?
- /*extendedAttributes: ExtendedAttributes {
- foo: PlaceAttribute {
- text: "Attribute 1"
- label: "Attribute Label 1"
- }
- other: PlaceAttribute {
- text: "Attribute 2"
- label: "Attribute Label 2"
- }
- }*/
+ icon: Icon {
+ fullUrl: "http://example.com/test-place.png"
+ }
}
Place {
@@ -263,6 +255,31 @@ TestCase {
*/
}
+ // check icon
+ if (place1.icon === null && place2.icon !== null) {
+ console.log("f1");
+ return false;
+ }
+ if (place1.icon !== null && place2.icon === null) {
+ console.log("f2");
+ return false;
+ }
+ if (place1.icon !== null && place2.icon !== null) {
+ if (place1.icon.plugin !== place2.icon.plugin) {
+ console.log("f3");
+ console.log(place1.icon.plugin + " " + place2.icon.plugin);
+ return false;
+ }
+ if (place1.icon.baseUrl !== place2.icon.baseUrl) {
+ console.log("f4");
+ return false;
+ }
+ if (place1.icon.fullUrl !== place2.icon.fullUrl) {
+ console.log("f5");
+ return false;
+ }
+ }
+
// check extended attributes
return true;
@@ -281,6 +298,7 @@ TestCase {
compare(emptyPlace.primaryEmail, "");
compare(emptyPlace.primaryWebsite, "");
compare(emptyPlace.visibility, Place.UnspecifiedVisibility);
+ compare(emptyPlace.attribution, "");
// complex properties
compare(emptyPlace.ratings.average, 0);
@@ -291,6 +309,10 @@ TestCase {
compare(emptyPlace.location.address.state, '');
compare(emptyPlace.location.address.country, '');
+ compare(emptyPlace.icon.fullUrl, '');
+ compare(emptyPlace.icon.baseUrl, '');
+ compare(emptyPlace.icon.plugin, null);
+
compare(emptyPlace.supplier.name, '');
compare(emptyPlace.supplier.supplierId, '');
compare(emptyPlace.supplier.url, '');
@@ -313,6 +335,7 @@ TestCase {
{ tag: "name", property: "name", signal: "nameChanged", value: "Test Place", reset: "" },
{ tag: "placeId", property: "placeId", signal: "placeIdChanged", value: "test-place-id-1", reset: "" },
{ tag: "visibility", property: "visibility", signal: "visibilityChanged", value: Place.PublicVisibility, reset: Place.UnspecifiedVisibility },
+ { tag: "attribution", property: "attribution", signal: "attributionChanged", value: "Place data from...", reset: "" }
];
}
@@ -460,10 +483,6 @@ TestCase {
}
function test_extendedAttributes() {
- var signalSpy = Qt.createQmlObject('import QtTest 1.0; SignalSpy {}', testCase, "SignalSpy");
- signalSpy.target = testPlace;
- signalSpy.signalName = "extendedAttributesChanged";
-
verify(testPlace.extendedAttributes);
testPlace.extendedAttributes["foo"] = Qt.createQmlObject('import QtLocation 5.0; PlaceAttribute { text: "Foo"; label: "Foo label" }', testCase, 'PlaceAttribute');
@@ -472,16 +491,21 @@ TestCase {
compare(testPlace.extendedAttributes.foo.text, "Foo");
compare(testPlace.extendedAttributes.foo.label, "Foo label");
- testPlace.extendedAttributes = Qt.createQmlObject('import QtLocation 5.0; ExtendedAttributes { }', testPlace, 'ExtendedAttributes1');
+ testPlace.extendedAttributes["foo"] = null;
+ verify(!testPlace.extendedAttributes.foo);
+ }
- compare(signalSpy.count, 1);
- verify(testPlace.extendedAttributes);
- compare(testPlace.extendedAttributes.foo, undefined);
+ function test_contactDetailsProperty() {
+ verify(testPlace.contactDetails);
- testPlace.extendedAttributes = testPlace.extendedAttributes
- compare(signalSpy.count, 1);
+ testPlace.contactDetails["phone"] = Qt.createQmlObject('import QtLocation 5.0; ContactDetail { label: "Test Label"; value: "Detail Value" }', testCase, 'ContactDetail');
- signalSpy.destroy();
+ verify(testPlace.contactDetails.phone);
+ compare(testPlace.contactDetails.phone[0].label, "Test Label");
+ compare(testPlace.contactDetails.phone[0].value, "Detail Value");
+
+ testPlace.contactDetails["phone"] = null;
+ verify(!testPlace.contactDetails.phone);
}
function test_saveload() {
@@ -491,6 +515,7 @@ TestCase {
signalSpy.signalName = "statusChanged";
savePlace.plugin = testPlugin;
+ savePlace.icon.plugin = testPlugin;
savePlace.placeId = "invalid-place-id";
savePlace.save();