| 1 | /**************************************************************************** |
|---|---|
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the test suite of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
| 21 | ** included in the packaging of this file. Please review the following |
| 22 | ** information to ensure the GNU General Public License requirements will |
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 24 | ** |
| 25 | ** $QT_END_LICENSE$ |
| 26 | ** |
| 27 | ****************************************************************************/ |
| 28 | |
| 29 | #include <QtCore/QString> |
| 30 | #include <QtTest/QtTest> |
| 31 | |
| 32 | #include <QtLocation/QPlaceMatchReply> |
| 33 | |
| 34 | QT_USE_NAMESPACE |
| 35 | |
| 36 | class TestMatchReply : public QPlaceMatchReply |
| 37 | { |
| 38 | Q_OBJECT |
| 39 | public: |
| 40 | TestMatchReply(QObject *parent) : QPlaceMatchReply(parent) {} |
| 41 | TestMatchReply() {} |
| 42 | |
| 43 | void setPlaces(const QList<QPlace> &places) { |
| 44 | QPlaceMatchReply::setPlaces(places); |
| 45 | } |
| 46 | |
| 47 | void setRequest(const QPlaceMatchRequest &request) { |
| 48 | QPlaceMatchReply::setRequest(request); |
| 49 | } |
| 50 | }; |
| 51 | |
| 52 | class tst_QPlaceMatchReply : public QObject |
| 53 | { |
| 54 | Q_OBJECT |
| 55 | |
| 56 | public: |
| 57 | tst_QPlaceMatchReply(); |
| 58 | |
| 59 | private Q_SLOTS: |
| 60 | void constructorTest(); |
| 61 | void typeTest(); |
| 62 | void requestTest(); |
| 63 | // void resultsTest(); |
| 64 | }; |
| 65 | |
| 66 | tst_QPlaceMatchReply::tst_QPlaceMatchReply() |
| 67 | { |
| 68 | } |
| 69 | |
| 70 | void tst_QPlaceMatchReply::constructorTest() |
| 71 | { |
| 72 | QPlaceMatchReply *reply = new TestMatchReply(this); |
| 73 | QVERIFY(reply->parent() == this); |
| 74 | delete reply; |
| 75 | } |
| 76 | |
| 77 | void tst_QPlaceMatchReply::typeTest() |
| 78 | { |
| 79 | TestMatchReply *reply = new TestMatchReply(this); |
| 80 | QVERIFY(reply->type() == QPlaceReply::MatchReply); |
| 81 | delete reply; |
| 82 | } |
| 83 | |
| 84 | void tst_QPlaceMatchReply::requestTest() |
| 85 | { |
| 86 | TestMatchReply *reply = new TestMatchReply(this); |
| 87 | QPlaceMatchRequest request; |
| 88 | |
| 89 | QPlace place1; |
| 90 | place1.setName(QStringLiteral("place1")); |
| 91 | |
| 92 | QPlace place2; |
| 93 | place2.setName(QStringLiteral("place2")); |
| 94 | |
| 95 | QList<QPlace> places; |
| 96 | places << place1 << place2; |
| 97 | |
| 98 | request.setPlaces(places); |
| 99 | |
| 100 | reply->setRequest(request); |
| 101 | QCOMPARE(reply->request(), request); |
| 102 | |
| 103 | reply->setRequest(QPlaceMatchRequest()); |
| 104 | QCOMPARE(reply->request(), QPlaceMatchRequest()); |
| 105 | delete reply; |
| 106 | } |
| 107 | |
| 108 | |
| 109 | QTEST_APPLESS_MAIN(tst_QPlaceMatchReply) |
| 110 | |
| 111 | #include "tst_qplacematchreply.moc" |
| 112 |
