From 355fb46f5c0ff3fe663d8cf34fc6d3607f3ab011 Mon Sep 17 00:00:00 2001 From: Jussi Laitinen Date: Thu, 1 Apr 2010 11:28:08 +0300 Subject: [PATCH] Deleted files under tests/testMap and testMap. --- Situare.pro | 5 +- src/map/mapfetcher.cpp | 2 +- tests/testMap/networkaccessmanagermock.cpp | 45 ------------- tests/testMap/networkreplymock.cpp | 36 ----------- tests/testMap/testmapengine.cpp | 56 ---------------- tests/testMap/testmapfetcher.cpp | 96 ---------------------------- tests/testmap/testmapfetcher.cpp | 22 +++---- 7 files changed, 14 insertions(+), 248 deletions(-) delete mode 100644 tests/testMap/networkaccessmanagermock.cpp delete mode 100644 tests/testMap/networkreplymock.cpp delete mode 100644 tests/testMap/testmapengine.cpp delete mode 100644 tests/testMap/testmapfetcher.cpp diff --git a/Situare.pro b/Situare.pro index 2b09e4c..c134f5d 100644 --- a/Situare.pro +++ b/Situare.pro @@ -8,10 +8,9 @@ QT += network \ INCLUDEPATH += . \ src/tests/testmap/ \ src/map/ -SOURCES += src/main.cpp \ -src/map/mapfetcher.cpp \ +SOURCES += src/map/mapfetcher.cpp \ src/map/mapengine.cpp \ -# tests/testmap/testmapfetcher.cpp \ + tests/testmap/testmapfetcher.cpp \ # tests/testmap/testmapengine.cpp \ src/ui/mainwindow.cpp \ tests/testmap/networkaccessmanagermock.cpp \ diff --git a/src/map/mapfetcher.cpp b/src/map/mapfetcher.cpp index 2c730b8..807b2fa 100644 --- a/src/map/mapfetcher.cpp +++ b/src/map/mapfetcher.cpp @@ -42,7 +42,7 @@ MapFetcher::MapFetcher(QObject *parent, QNetworkAccessManager *manager) m_manager->setCache(diskCache); - connect(m_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloadFinished(QNetworkReply*))); //Change to QNetworkReply + connect(m_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloadFinished(QNetworkReply*))); } void MapFetcher::fetchMapImage(const QUrl &url) diff --git a/tests/testMap/networkaccessmanagermock.cpp b/tests/testMap/networkaccessmanagermock.cpp deleted file mode 100644 index e36d895..0000000 --- a/tests/testMap/networkaccessmanagermock.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - Situare - A location system for Facebook - Copyright (C) 2010 Ixonos Plc. Authors: - - Jussi Laitinen - jussi.laitinen@ixonos.com - - Situare is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - version 2 as published by the Free Software Foundation. - - Situare is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Situare; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include - -class NetworkAccessManagerMock : public QNetworkAccessManager -{ - Q_OBJECT - -public: - NetworkAccessManagerMock(); - - void get(const QNetworkRequest &request); -}; - -NetworkAccessManagerMock::NetworkAccessManagerMock() - : QNetworkAccessManager() -{ - -} - -void NetworkAccessManagerMock::get(const QNetworkRequest &request) -{ - QNetworkReply *reply = new QNetworkReply(); -} - - diff --git a/tests/testMap/networkreplymock.cpp b/tests/testMap/networkreplymock.cpp deleted file mode 100644 index ca55c4d..0000000 --- a/tests/testMap/networkreplymock.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - Situare - A location system for Facebook - Copyright (C) 2010 Ixonos Plc. Authors: - - Jussi Laitinen - jussi.laitinen@ixonos.com - - Situare is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - version 2 as published by the Free Software Foundation. - - Situare is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Situare; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include - -class NetworkReplyMock : public QNetworkReply -{ - Q_OBJECT - -public: - NetworkReplyMock(); -}; - -NetworkReplyMock::NetworkReplyMock() - : QNetworkReply() -{ - -} diff --git a/tests/testMap/testmapengine.cpp b/tests/testMap/testmapengine.cpp deleted file mode 100644 index 9a5a690..0000000 --- a/tests/testMap/testmapengine.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include -#include - -#include "mapengine.h" - -/** -* @brief Test class for MapEngine. -* -* @class TestMapEngine testmapengine.cpp "tests/testmapengine.cpp" -*/ -class TestMapEngine : public QObject -{ - Q_OBJECT -public: - TestMapEngine(); - -private slots: - void coordinatesToTiles(); - void longitudeFromTiles(); - void latitudeFromTiles(); - -private: - MapEngine *mapEngine; -}; - -TestMapEngine::TestMapEngine() -{ - mapEngine = new MapEngine(); -} - - -void TestMapEngine::coordinatesToTiles() -{ - //QPoint point1 = mapEngine->coordinateToTile(47.629, 7.262, 1); - QPoint point1 = MapEngine::latLonToTile(47.629, 7.262, 1); - QCOMPARE(point1, QPoint(1, 0)); - /*QPoint point2 = mapEngine->coordinateToTile(65.013379, 25.472059, 13); - QCOMPARE(point2, QPoint(4675, 2131)); - QPoint point3 = mapEngine->coordinateToTile(65.013379, 25.472059, 10); - QCOMPARE(point3, QPoint(584, 266));*/ -} - -void TestMapEngine::longitudeFromTiles() -{ - qreal longitude = mapEngine->tileXToLongitude(4675, 13); - QCOMPARE(longitude, 25.47059); -} - -void TestMapEngine::latitudeFromTiles() -{ - -} - -QTEST_MAIN(TestMapEngine) -#include "testmapengine.moc" diff --git a/tests/testMap/testmapfetcher.cpp b/tests/testMap/testmapfetcher.cpp deleted file mode 100644 index 7dbb366..0000000 --- a/tests/testMap/testmapfetcher.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include -#include -#include -#include - -#include "mapfetcher.h" - -class TestMapFetcher : public QObject -{ - Q_OBJECT -public: - TestMapFetcher(); - - -private slots: - void testFetchImage(); - //void testDownloadFinished(); - void testSignals(); - - -private: - MapFetcher *mapFetcher; -}; - -TestMapFetcher::TestMapFetcher() -{ - mapFetcher = new MapFetcher(); -} - -void TestMapFetcher::testFetchImage() -{ - QUrl url(""); - mapFetcher->fetchMapImage(url); -} - -/*void TestMapFetcher::testDownloadFinished() -{ - NetworkReplyDummy *reply = new NetworkReplyDummy(); - reply->setError(QNetworkReply::ConnectionRefusedError, QString("Connection refused")); - - QSignalSpy errorSpy(mapFetcher, SIGNAL(error(QString))); - mapFetcher->downloadFinished(reply); - QTest::qWait(500); - - QCOMPARE(errorSpy.count(), 1); - - QSignalSpy imageReceivedSpy(mapFetcher, SIGNAL(mapImageReceived(QUrl,QPixmap))); - //QList signalArgs1 = imageReceivedErrorSpy.takeFirst(); -}*/ - -void TestMapFetcher::testSignals() -{ - QSignalSpy imageReceivedSpy(mapFetcher, SIGNAL(mapImageReceived(QUrl,QPixmap))); - QSignalSpy imageReceivedErrorSpy(mapFetcher, SIGNAL(error(QString))); - - QVERIFY(imageReceivedSpy.isValid()); - - //Incorrect URL - QUrl url1("http://tile.openstreetmap.org/7/63/22.gi"); - mapFetcher->fetchMapImage(url1); - QTest::qWait(1000); - QCOMPARE(imageReceivedErrorSpy.count(), 1); - QList signalArgs1 = imageReceivedErrorSpy.takeFirst(); - qDebug() << signalArgs1.at(0).toString(); - - /*//Correct URL - QUrl url2("http://tile.openstreetmap.org/7/63/42.png"); - mapFetcher->fetchMapImage(url2); - QTest::qWait(1000); - QCOMPARE(imageReceivedSpy.count(), 1); - QList signalArgs2 = imageReceivedSpy.takeLast(); - QCOMPARE(url2, signalArgs2.at(0).toUrl()); - - //20 requests immediately - for (int i = 1; i < 3; ++i) { - for (int j = 0; j < 10; ++j) { - QUrl url(QString("http://tile.openstreetmap.org/7/53/%1%2.png").arg(i).arg(j)); - mapFetcher->fetchMapImage(url); - } - } - QTest::qWait(400); - - //50 requests immediately - for (int i = 1; i < 6; ++i) { - for (int j = 0; j < 10; ++j) { - QUrl url(QString("http://tile.openstreetmap.org/7/63/%1%2.png").arg(i).arg(j)); - mapFetcher->fetchMapImage(url); - } - } - - QTest::qWait(2000);*/ - -} - -QTEST_MAIN(TestMapFetcher) -#include "testmapfetcher.moc" diff --git a/tests/testmap/testmapfetcher.cpp b/tests/testmap/testmapfetcher.cpp index a18142d..205b2eb 100644 --- a/tests/testmap/testmapfetcher.cpp +++ b/tests/testmap/testmapfetcher.cpp @@ -115,17 +115,17 @@ void TestMapFetcher::testFetchImageIncorrectURL() void TestMapFetcher::testFetchImageCorrectURL() { -// QSignalSpy imageReceivedSpy(mapFetcher, SIGNAL(mapImageReceived(QUrl,QPixmap))); -// -// QVERIFY(imageReceivedSpy.isValid()); -// -// //Correct URL -// QUrl url2("http://tile.openstreetmap.org/7/63/42.png"); -// mapFetcher->fetchMapImage(url2); -// QTest::qWait(2000); -// QCOMPARE(imageReceivedSpy.count(), 1); -// QList signalArgs2 = imageReceivedSpy.takeLast(); -// QCOMPARE(url2, signalArgs2.at(0).toUrl()); + QSignalSpy imageReceivedSpy(mapFetcher, SIGNAL(mapImageReceived(QUrl,QPixmap))); + + QVERIFY(imageReceivedSpy.isValid()); + + //Correct URL + QUrl url2("http://tile.openstreetmap.org/7/63/42.png"); + mapFetcher->fetchMapImage(url2); + QTest::qWait(2000); + QCOMPARE(imageReceivedSpy.count(), 1); + QList signalArgs2 = imageReceivedSpy.takeLast(); + QCOMPARE(url2, signalArgs2.at(0).toUrl()); } void TestMapFetcher::testFetchCorruptedImage() -- 1.7.9.5