File indexing completed on 2022-10-04 14:00:26

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2013 Mayank Madan <maddiemadan@gmail.com>
0004 //
0005 
0006 #include <QObject>
0007 
0008 #include <GeoDataDocument.h>
0009 #include <GeoDataTimeSpan.h>
0010 #include <GeoDataTimeStamp.h>
0011 #include <MarbleDebug.h>
0012 #include "TestUtils.h"
0013 #include <GeoDataLookAt.h>
0014 #include <GeoDataCamera.h>
0015 #include <GeoDataPlacemark.h>
0016 
0017 using namespace Marble;
0018 
0019 class TestGxTimeSpan : public QObject
0020 {
0021     Q_OBJECT
0022 private Q_SLOTS:
0023     void initTestCase();
0024     void simpleParseTest();
0025 };
0026 
0027 void TestGxTimeSpan::initTestCase()
0028 {
0029     MarbleDebug::setEnabled( true );
0030 }
0031 
0032 
0033 void TestGxTimeSpan::simpleParseTest()
0034 {
0035   QString const centerContent (
0036       "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
0037       "<kml xmlns=\"http://www.opengis.net/kml/2.2\""
0038       " xmlns:gx=\"http://www.google.com/kml/ext/2.2\">"
0039       "<Document>"
0040       "<Placemark>"
0041        "<LookAt>"
0042         "<gx:TimeSpan>"
0043           "<begin>2010-05-28T02:02:09Z</begin>"
0044           "<end>2010-05-28T02:02:56Z</end>"
0045         "</gx:TimeSpan>"
0046       "</LookAt>"
0047       "</Placemark>"
0048       "</Document>"
0049       "</kml>" );
0050 
0051     GeoDataDocument* dataDocument = parseKml( centerContent );
0052     QCOMPARE( dataDocument->placemarkList().size(), 1 );
0053     GeoDataPlacemark *placemark = dataDocument->placemarkList().at( 0 );
0054     QVERIFY( placemark->lookAt() != nullptr );
0055     QCOMPARE( placemark->lookAt()->timeSpan().begin().when(), QDateTime::fromString( "2010-05-28T02:02:09Z", Qt::ISODate) );
0056     QCOMPARE( placemark->lookAt()->timeSpan().end().when(), QDateTime::fromString( "2010-05-28T02:02:56Z", Qt::ISODate) );
0057 
0058     delete dataDocument;
0059 }
0060 
0061 QTEST_MAIN( TestGxTimeSpan )
0062 
0063 #include "TestGxTimeSpan.moc"