File indexing completed on 2025-01-19 03:57:45

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2010-05-07
0007  * Description : Test for the geonames based altitude lookup class
0008  *
0009  * SPDX-FileCopyrightText: 2010-2011 by Michael G. Hansen <mike at mghansen dot de>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #include "lookup_altitude_geonames_utest.h"
0016 
0017 // Local includes
0018 
0019 #include "lookupaltitudegeonames.h"
0020 #include "lookupfactory.h"
0021 #include "geoifacecommon.h"
0022 
0023 using namespace Digikam;
0024 
0025 void TestLookupAltitudeGeonames::testNoOp()
0026 {
0027 }
0028 
0029 void TestLookupAltitudeGeonames::testSimpleLookup()
0030 {
0031     LookupAltitude* const myLookup = LookupFactory::getAltitudeLookup(QString::fromLatin1("geonames"), this);
0032 
0033     QSignalSpy spyRequestsReady(myLookup, SIGNAL(signalRequestsReady(QList<int>)));
0034     QSignalSpy spyLookupDone(myLookup, SIGNAL(signalDone()));
0035 
0036     LookupAltitude::Request::List requestsList;
0037     const int nRequests = 30;
0038 
0039     // add different requests
0040     for (qreal i = 0; i < nRequests; ++i)
0041     {
0042         LookupAltitude::Request myRequest;
0043         myRequest.coordinates = GeoCoordinates(52.0, 6.0+i);
0044         requestsList << myRequest;
0045     }
0046 
0047     // add those same requests again, expecting them to be merged into the existing requests:
0048     for (qreal i = 0; i < nRequests; ++i)
0049     {
0050         LookupAltitude::Request myRequest;
0051         myRequest.coordinates = GeoCoordinates(52.0, 6.0+i);
0052         requestsList << myRequest;
0053     }
0054 
0055     myLookup->addRequests(requestsList);
0056     myLookup->startLookup();
0057 
0058     // wait until the files are loaded:
0059     while (spyLookupDone.isEmpty())
0060     {
0061         QTest::qWait(100);
0062     }
0063 
0064     QCOMPARE(spyRequestsReady.count(), 2);
0065 }
0066 
0067 QTEST_GUILESS_MAIN(TestLookupAltitudeGeonames)
0068 
0069 #include "moc_lookup_altitude_geonames_utest.cpp"