diff options
author | abcd <amos.choy@nokia.com> | 2011-12-12 18:10:02 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-14 01:40:27 +0100 |
commit | 7ed8f59882c0a2a505e8d450056a83ad75a9e7de (patch) | |
tree | 206f04ef08b9cc05f6214018608dd1fecc63ba59 /tests | |
parent | beb0c33b1eee258898361c8ebf4b29606c8b371e (diff) | |
download | qtlocation-7ed8f59882c0a2a505e8d450056a83ad75a9e7de.tar.gz |
Unit test for QPlaceContactDetail
Change-Id: I590df0ddf5bd1bb30d4186ac2b0d7f4ceb73ac28
Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/auto.pro | 1 | ||||
-rw-r--r-- | tests/auto/qplacecontactdetail/qplacecontactdetail.pro | 7 | ||||
-rw-r--r-- | tests/auto/qplacecontactdetail/tst_qplacecontactdetail.cpp | 159 |
3 files changed, 167 insertions, 0 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index dae65b84..7407fb45 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -3,6 +3,7 @@ TEMPLATE = subdirs #Place unit tests SUBDIRS += qplace \ qplacecategory \ + qplacecontactdetail \ qplacecontentrequest \ qplaceeditorial \ qplacemanager \ diff --git a/tests/auto/qplacecontactdetail/qplacecontactdetail.pro b/tests/auto/qplacecontactdetail/qplacecontactdetail.pro new file mode 100644 index 00000000..ab49471f --- /dev/null +++ b/tests/auto/qplacecontactdetail/qplacecontactdetail.pro @@ -0,0 +1,7 @@ +TEMPLATE = app +CONFIG += testcase +TARGET = tst_qplacecontactdetail + +SOURCES += tst_qplacecontactdetail.cpp + +QT += location testlib diff --git a/tests/auto/qplacecontactdetail/tst_qplacecontactdetail.cpp b/tests/auto/qplacecontactdetail/tst_qplacecontactdetail.cpp new file mode 100644 index 00000000..4bd59b92 --- /dev/null +++ b/tests/auto/qplacecontactdetail/tst_qplacecontactdetail.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include <QtCore/QString> +#include <QtTest/QtTest> + +#include <QtLocation/QPlaceContactDetail> + +QT_USE_NAMESPACE + +class tst_QPlaceContactDetail : public QObject +{ + Q_OBJECT + +public: + tst_QPlaceContactDetail(); + +private Q_SLOTS: + void constructorTest(); + void labelTest(); + void valueTest(); + void clearTest(); + void operatorsTest(); + void operatorsTest_data(); +}; + +tst_QPlaceContactDetail::tst_QPlaceContactDetail() +{ +} + +void tst_QPlaceContactDetail::constructorTest() +{ + QPlaceContactDetail detail; + QVERIFY(detail.label().isEmpty()); + QVERIFY(detail.value().isEmpty()); + + detail.setLabel(QLatin1String("Emergency Services")); + detail.setValue(QLatin1String("0118 999")); + + QPlaceContactDetail detail2(detail); + QCOMPARE(detail2.label(), QLatin1String("Emergency Services")); + QCOMPARE(detail2.value(), QLatin1String("0118 999")); +} + +void tst_QPlaceContactDetail::labelTest() +{ + QPlaceContactDetail detail; + detail.setLabel(QLatin1String("home")); + QCOMPARE(detail.label(), QLatin1String("home")); + detail.setLabel(QString()); + QVERIFY(detail.label().isEmpty()); +} + +void tst_QPlaceContactDetail::valueTest() +{ + QPlaceContactDetail detail; + detail.setValue(QLatin1String("555-5555")); + QCOMPARE(detail.value(), QLatin1String("555-5555")); + detail.setValue(QString()); + QVERIFY(detail.value().isEmpty()); +} + +void tst_QPlaceContactDetail::clearTest() +{ + QPlaceContactDetail detail; + detail.setLabel(QLatin1String("Ghostbusters")); + detail.setValue(QLatin1String("555-2368")); + detail.clear(); + QVERIFY(detail.label().isEmpty()); + QVERIFY(detail.value().isEmpty()); +} + +void tst_QPlaceContactDetail::operatorsTest() +{ + QPlaceContactDetail detail1; + detail1.setLabel(QLatin1String("Kramer")); + detail1.setValue(QLatin1String("555-filk")); + + QPlaceContactDetail detail2; + detail2.setLabel(QLatin1String("Kramer")); + detail2.setValue(QLatin1String("555-filk")); + + QVERIFY(detail1 == detail2); + QVERIFY(!(detail1 != detail2)); + QVERIFY(detail2 == detail1); + QVERIFY(!(detail2 != detail1)); + + QPlaceContactDetail detail3; + QVERIFY(!(detail1 == detail3)); + QVERIFY(detail1 != detail3); + QVERIFY(!(detail1 == detail3)); + QVERIFY(detail1 != detail3); + + detail3 = detail1; + QVERIFY(detail1 == detail3); + QVERIFY(!(detail1 != detail3)); + QVERIFY(detail3 == detail1); + QVERIFY(!(detail3 != detail1)); + + QFETCH(QString, field); + if (field == QLatin1String("label")) + detail3.setLabel(QLatin1String("Cosmo")); + else if (field == QLatin1String("value")) + detail3.setValue(QLatin1String("555-5555")); + + QVERIFY(!(detail1 == detail3)); + QVERIFY(detail1 != detail3); + QVERIFY(!(detail3 == detail1)); + QVERIFY(detail3 != detail1); +} + +void tst_QPlaceContactDetail::operatorsTest_data() +{ + QTest::addColumn<QString>("field"); + QTest::newRow("label") << "label"; + QTest::newRow("value") << "value"; +} + +QTEST_APPLESS_MAIN(tst_QPlaceContactDetail) + +#include "tst_qplacecontactdetail.moc" |