diff options
author | abcd <qt-info@nokia.com> | 2011-06-27 15:03:54 +1000 |
---|---|---|
committer | abcd <qt-info@nokia.com> | 2011-06-27 15:03:54 +1000 |
commit | 3304b9fe9e61d81fe04631737ff0d0212b0e0c78 (patch) | |
tree | 3b8ec0ccb98092dfb29d7ab98dde153246347754 /tests/auto/qplacereview | |
parent | f87d30cc33a36a8e5ececba27671c7457f3d9cd2 (diff) | |
download | qtlocation-3304b9fe9e61d81fe04631737ff0d0212b0e0c78.tar.gz |
Add in QPlaceReview unit test
Diffstat (limited to 'tests/auto/qplacereview')
-rw-r--r-- | tests/auto/qplacereview/qplacereview.pro | 7 | ||||
-rw-r--r-- | tests/auto/qplacereview/tst_qplacereview.cpp | 172 |
2 files changed, 179 insertions, 0 deletions
diff --git a/tests/auto/qplacereview/qplacereview.pro b/tests/auto/qplacereview/qplacereview.pro new file mode 100644 index 00000000..950e7a3b --- /dev/null +++ b/tests/auto/qplacereview/qplacereview.pro @@ -0,0 +1,7 @@ +TEMPLATE = app +CONFIG += testcase +TARGET = tst_qplacereview + +SOURCES += tst_qplacereview.cpp + +QT += location testlib diff --git a/tests/auto/qplacereview/tst_qplacereview.cpp b/tests/auto/qplacereview/tst_qplacereview.cpp new file mode 100644 index 00000000..94c6d720 --- /dev/null +++ b/tests/auto/qplacereview/tst_qplacereview.cpp @@ -0,0 +1,172 @@ +#include <QtCore/QString> +#include <QtTest/QtTest> + +#include <qplacereview.h> + +QTM_USE_NAMESPACE + +class tst_QPlaceReview : public QObject +{ + Q_OBJECT + +public: + tst_QPlaceReview(); + +private Q_SLOTS: + void constructorTest(); + void supplierTest(); + void dateTest(); + void descriptionTest(); + void languageTest(); + void helpfulVotingsTest(); + void mediaIdsTest(); + void unhelpfulVotingsTest(); + void ratingTest(); + void reviewIdTest(); + void titleTest(); + void userIdTest(); + void userNameTest(); + void originatorUrlTest(); + void operatorsTest(); +}; + +tst_QPlaceReview::tst_QPlaceReview() +{ +} + +void tst_QPlaceReview::constructorTest() +{ + QPlaceReview testObj; + testObj.setLanguage("testId"); + QPlaceReview *testObjPtr = new QPlaceReview(testObj); + QVERIFY2(testObjPtr != NULL, "Copy constructor - null"); + QVERIFY2(*testObjPtr == testObj, "Copy constructor - compare"); + delete testObjPtr; +} + +void tst_QPlaceReview::supplierTest() +{ + QPlaceReview testObj; + QVERIFY2(testObj.supplier().supplierId() == QString(), "Wrong default value"); + QPlaceSupplier sup; + sup.setName("testName1"); + sup.setSupplierId("testId"); + testObj.setSupplier(sup); + QVERIFY2(testObj.supplier() == sup, "Wrong value returned"); +} + +void tst_QPlaceReview::dateTest() +{ + QPlaceReview testObj; + QVERIFY2(testObj.date() == QString(), "Wrong default value"); + testObj.setDate("testText"); + QVERIFY2(testObj.date() == "testText", "Wrong value returned"); +} + +void tst_QPlaceReview::descriptionTest() +{ + QPlaceReview testObj; + QVERIFY2(testObj.description() == QString(), "Wrong default value"); + testObj.setDescription("testText"); + QVERIFY2(testObj.description() == "testText", "Wrong value returned"); +} + +void tst_QPlaceReview::languageTest() +{ + QPlaceReview testObj; + QVERIFY2(testObj.language() == QString(), "Wrong default value"); + testObj.setLanguage("testText"); + QVERIFY2(testObj.language() == "testText", "Wrong value returned"); +} + +void tst_QPlaceReview::helpfulVotingsTest() +{ + QPlaceReview testObj; + QVERIFY2(testObj.helpfulVotings() == 0, "Wrong default value"); + testObj.setHelpfulVotings(-10); + QVERIFY2(testObj.helpfulVotings() == -10, "Wrong value returned"); + testObj.setHelpfulVotings(3); + QVERIFY2(testObj.helpfulVotings() == 3, "Wrong value returned"); +} + +void tst_QPlaceReview::mediaIdsTest() +{ + QPlaceReview testObj; + QVERIFY2(testObj.mediaIds().count() == 0, "Wrong default value"); + QStringList list; + list << "1" << "2" << "3"; + testObj.setMediaIds(list); + QVERIFY2(testObj.mediaIds().count() == 3, "Wrong value returned"); + QVERIFY2(testObj.mediaIds()[1] == "2", "Wrong [1] value returned"); +} + +void tst_QPlaceReview::unhelpfulVotingsTest() +{ + QPlaceReview testObj; + QVERIFY2(testObj.unhelpfulVotings() == 0, "Wrong default value"); + testObj.setUnhelpfulVotings(-10); + QVERIFY2(testObj.unhelpfulVotings() == -10, "Wrong value returned"); + testObj.setUnhelpfulVotings(3); + QVERIFY2(testObj.unhelpfulVotings() == 3, "Wrong value returned"); +} + +void tst_QPlaceReview::ratingTest() +{ + QPlaceReview testObj; + QVERIFY2(testObj.rating() == 0, "Wrong default value"); + testObj.setRating(-10); + QVERIFY2(testObj.rating() == -10, "Wrong value returned"); + testObj.setRating(3.4); + QVERIFY2(testObj.rating() == 3.4, "Wrong value returned"); +} + +void tst_QPlaceReview::operatorsTest() +{ + QPlaceReview testObj; + testObj.setDescription("testValue"); + QPlaceReview testObj2; + testObj2 = testObj; + QVERIFY2(testObj == testObj2, "Not copied correctly"); + testObj2.setLanguage("testValue2"); + QVERIFY2(testObj != testObj2, "Object should be different"); +} + +void tst_QPlaceReview::reviewIdTest() +{ + QPlaceReview testObj; + QVERIFY2(testObj.reviewId() == QString(), "Wrong default value"); + testObj.setReviewId("testText"); + QVERIFY2(testObj.reviewId() == "testText", "Wrong value returned"); +} +void tst_QPlaceReview::titleTest() +{ + QPlaceReview testObj; + QVERIFY2(testObj.title() == QString(), "Wrong default value"); + testObj.setTitle("testText"); + QVERIFY2(testObj.title() == "testText", "Wrong value returned"); +} +void tst_QPlaceReview::userIdTest() +{ + QPlaceReview testObj; + QVERIFY2(testObj.userId() == QString(), "Wrong default value"); + testObj.setUserId("testText"); + QVERIFY2(testObj.userId() == "testText", "Wrong value returned"); +} +void tst_QPlaceReview::userNameTest() +{ + QPlaceReview testObj; + QVERIFY2(testObj.userName() == QString(), "Wrong default value"); + testObj.setUserName("testText"); + QVERIFY2(testObj.userName() == "testText", "Wrong value returned"); +} +void tst_QPlaceReview::originatorUrlTest() +{ + QPlaceReview testObj; + QVERIFY2(testObj.originatorUrl() == QString(), "Wrong default value"); + testObj.setOriginatorUrl("testText"); + QVERIFY2(testObj.originatorUrl() == "testText", "Wrong value returned"); +} + +QTEST_APPLESS_MAIN(tst_QPlaceReview); + +#include "tst_qplacereview.moc" |