diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2012-01-09 11:50:31 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-10 05:45:57 +0100 |
commit | 20c1a963d5786c98a904c4c215073b74c9a112fc (patch) | |
tree | b6ea8edc9457fee5e0fe5aefe5bce3914fc95bca /tests/auto/declarative_core/tst_categorymodel.qml | |
parent | 61c66ae13af5836b438382108b5107eccf7aab13 (diff) | |
download | qtlocation-20c1a963d5786c98a904c4c215073b74c9a112fc.tar.gz |
Basic set/get tests for all Places QML elements.
Change-Id: I0cba5e3c14f22a07c7647571214b1bf66b557d94
Reviewed-by: abcd <amos.choy@nokia.com>
Diffstat (limited to 'tests/auto/declarative_core/tst_categorymodel.qml')
-rw-r--r-- | tests/auto/declarative_core/tst_categorymodel.qml | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/tests/auto/declarative_core/tst_categorymodel.qml b/tests/auto/declarative_core/tst_categorymodel.qml new file mode 100644 index 00000000..14b3cb02 --- /dev/null +++ b/tests/auto/declarative_core/tst_categorymodel.qml @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2012 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 QtQuick 2.0 +import QtTest 1.0 +import QtLocation 5.0 + +TestCase { + id: testCase + + name: "CategoryModel" + + CategoryModel { + id: testModel + } + + Plugin { + id: testPlugin + name: "qmlgeo.test.plugin" + } + + function test_setAndGet_data() { + return [ + { tag: "plugin", property: "plugin", signal: "pluginChanged", value: testPlugin }, + { tag: "hierarchical", property: "hierarchical", signal: "hierarchicalChanged", value: false, reset: true }, + ]; + } + + function test_setAndGet(data) { + var signalSpy = Qt.createQmlObject('import QtTest 1.0; SignalSpy {}', testCase, "SignalSpy"); + signalSpy.target = testModel; + signalSpy.signalName = data.signal; + + // set property to something new + testModel[data.property] = data.value; + compare(testModel[data.property], data.value); + compare(signalSpy.count, 1); + + // set property to the same value (signal spy should not increase) + testModel[data.property] = data.value; + compare(testModel[data.property], data.value); + compare(signalSpy.count, 1); + + // reset property + if (data.reset === undefined) { + testModel[data.property] = null; + compare(testModel[data.property], null); + } else { + testModel[data.property] = data.reset; + compare(testModel[data.property], data.reset); + } + compare(signalSpy.count, 2); + + signalSpy.destroy(); + } +} |