1 /* ============================================================ 2 * 3 * This file is a part of digiKam project 4 * https://www.digikam.org 5 * 6 * Date : 2010-05-07 7 * Description : Test for the geonames based altitude lookup class 8 * 9 * Copyright (C) 2010-2011 by Michael G. Hansen <mike at mghansen dot de> 10 * 11 * This program is free software; you can redistribute it 12 * and/or modify it under the terms of the GNU General 13 * Public License as published by the Free Software Foundation; 14 * either version 2, or (at your option) 15 * any later version. 16 * 17 * This program is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 * 22 * ============================================================ */ 23 24 #include "lookup_altitude_geonames_utest.h" 25 26 // Local includes 27 28 #include "lookupaltitudegeonames.h" 29 #include "lookupfactory.h" 30 #include "geoifacecommon.h" 31 32 using namespace Digikam; 33 testNoOp()34void TestLookupAltitudeGeonames::testNoOp() 35 { 36 } 37 testSimpleLookup()38void TestLookupAltitudeGeonames::testSimpleLookup() 39 { 40 LookupAltitude* const myLookup = LookupFactory::getAltitudeLookup(QString::fromLatin1("geonames"), this); 41 42 QSignalSpy spyRequestsReady(myLookup, SIGNAL(signalRequestsReady(QList<int>))); 43 QSignalSpy spyLookupDone(myLookup, SIGNAL(signalDone())); 44 45 LookupAltitude::Request::List requestsList; 46 const int nRequests = 30; 47 48 // add different requests 49 for (qreal i = 0; i < nRequests; ++i) 50 { 51 LookupAltitude::Request myRequest; 52 myRequest.coordinates = GeoCoordinates(52.0, 6.0+i); 53 requestsList << myRequest; 54 } 55 56 // add those same requests again, expecting them to be merged into the existing requests: 57 for (qreal i = 0; i < nRequests; ++i) 58 { 59 LookupAltitude::Request myRequest; 60 myRequest.coordinates = GeoCoordinates(52.0, 6.0+i); 61 requestsList << myRequest; 62 } 63 64 myLookup->addRequests(requestsList); 65 myLookup->startLookup(); 66 67 // wait until the files are loaded: 68 while (spyLookupDone.isEmpty()) 69 { 70 QTest::qWait(100); 71 } 72 73 QCOMPARE(spyRequestsReady.count(), 2); 74 } 75 76 QTEST_GUILESS_MAIN(TestLookupAltitudeGeonames) 77