Removed obsolete unittest
[situare] / tests / situareservice / testfetchlocations / testfetchlocations.cpp
1  /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Henri Lampela - henri.lampela@ixonos.com
6
7     Situare is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     version 2 as published by the Free Software Foundation.
10
11     Situare is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with Situare; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19     USA.
20  */
21
22 #include <QtTest/QtTest>
23 #include <QtCore>
24 #include "../../../src/situareservice/situareservice.h"
25 #include "../../../src/situareservice/situarecommon.h"
26
27 class testFetchLocations : public QObject
28 {
29     Q_OBJECT
30 public:
31     ~testFetchLocations();
32 private:
33     SituareService *situare;
34     QList<QNetworkReply *> currentRequests;
35
36 private slots:
37     void testFetchLocationsCase();
38 };
39
40 testFetchLocations::~testFetchLocations()
41 {
42     delete situare;
43 }
44
45 //void testFetchLocations::testIncorrectUrl()
46 //{
47 //    QNetworkAccessManager *manager = new QNetworkAccessManager();
48 //    managerMock = new NetworkAccessManagerMock(manager, this);
49 //    situare = new SituareService(this, manager);
50 //
51 //    managerMock->setMode(NetworkAccessManagerMock::INCORRECT);
52 //
53 //    QSignalSpy receivedErrorSpy(situare, SIGNAL(error(QString)));
54 //
55 //    QVERIFY(receivedErrorSpy.isValid());
56 //
57 //    // incorrect url
58 //
59 //    situare->sendRequest(QUrl("http://client.situare.nett"), COOKIE, QString(""));
60 //    QTest::qWait(1000);
61 //    QCOMPARE(receivedErrorSpy.count(), 1);
62 //
63 //    delete manager;
64 //}
65
66 //void testFetchLocations::testCorrectUrl()
67 //{
68 //    QNetworkAccessManager *manager = new QNetworkAccessManager();
69 //    managerMock = new NetworkAccessManagerMock(manager, this);
70 //    situare = new SituareService(this, manager);
71 //
72 //    managerMock->setMode(NetworkAccessManagerMock::CORRECT);
73 //
74 //    QSignalSpy receivedErrorSpy(situare, SIGNAL(error(QString)));
75 //
76 //    QVERIFY(receivedErrorSpy.isValid());
77 //
78 //    QUrl url = QUrl("http://client.situare.net");
79 //
80 //    situare->sendRequest(url, COOKIE, QString(""));
81 //    QTest::qWait(1000);
82 //
83 //    QCOMPARE(receivedErrorSpy.count(), 0);
84 //
85 //    delete manager;
86 //}
87
88 void testFetchLocations::testFetchLocationsCase()
89 {
90     situare = new SituareService(this);
91
92     QSignalSpy receivedErrorSpy(situare, SIGNAL(error(QString)));
93
94     situare->fetchLocations();
95     QTest::qWait(1000);
96
97     QCOMPARE(receivedErrorSpy.count(), 0);
98 }
99
100 QTEST_MAIN(testFetchLocations)
101 #include "testfetchlocations.moc"