File indexing completed on 2024-04-14 14:16:36

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 <GeoDataPlacemark.h>
0010 #include <GeoDataTimeStamp.h>
0011 #include <GeoDataCamera.h>
0012 #include <MarbleDebug.h>
0013 #include "TestUtils.h"
0014 
0015 using namespace Marble;
0016 
0017 class TestGxTimeStamp : public QObject
0018 {
0019     Q_OBJECT
0020 private Q_SLOTS:
0021     void initTestCase();
0022     void simpleParseTest();
0023 };
0024 
0025 void TestGxTimeStamp::initTestCase()
0026 {
0027     MarbleDebug::setEnabled( true );
0028 }
0029 
0030 void TestGxTimeStamp::simpleParseTest()
0031 {
0032   QString const centerContent (
0033               "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
0034               "<kml xmlns=\"http://www.opengis.net/kml/2.2\""
0035               " xmlns:gx=\"http://www.google.com/kml/ext/2.2\">"
0036               "<Document>"
0037                   "<Placemark>"
0038                     "<Camera>"
0039                       "<gx:TimeStamp>"
0040                         "<when>1987-06-05T04:03:02-01:00</when>"
0041                       "</gx:TimeStamp>"
0042                     "</Camera>"
0043                   "</Placemark>"
0044               "</Document>"
0045               "</kml>" );
0046 
0047     GeoDataDocument* dataDocument = parseKml( centerContent );
0048     QCOMPARE( dataDocument->placemarkList().size(), 1 );
0049     GeoDataPlacemark *placemark = dataDocument->placemarkList().at( 0 );
0050     GeoDataAbstractView* view = placemark->abstractView();
0051     QVERIFY( view != nullptr );
0052     GeoDataCamera* camera = dynamic_cast<GeoDataCamera*>( view );
0053     QVERIFY( camera != nullptr );
0054     QCOMPARE( camera->timeStamp().when().toUTC(), QDateTime::fromString( "1987-06-05T04:03:02-01:00", Qt::ISODate).toUTC() );
0055 
0056     delete dataDocument;
0057 }
0058 
0059 QTEST_MAIN( TestGxTimeStamp )
0060 
0061 #include "TestGxTimeStamp.moc"
0062