File indexing completed on 2024-09-15 03:35:04
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2013 Dennis Nienhüser <nienhueser@kde.org> 0004 // 0005 0006 #include <QObject> 0007 0008 #include <GeoDataDocument.h> 0009 #include <GeoDataPlacemark.h> 0010 #include <GeoDataTimeSpan.h> 0011 #include <GeoDataTimeStamp.h> 0012 #include <GeoDataCamera.h> 0013 #include <MarbleDebug.h> 0014 #include "TestUtils.h" 0015 0016 using namespace Marble; 0017 0018 class TestTimeStamp : public QObject 0019 { 0020 Q_OBJECT 0021 private Q_SLOTS: 0022 void initTestCase(); 0023 void simpleParseTest(); 0024 }; 0025 0026 void TestTimeStamp::initTestCase() 0027 { 0028 MarbleDebug::setEnabled( true ); 0029 } 0030 0031 void TestTimeStamp::simpleParseTest() 0032 { 0033 QString const centerContent ( 0034 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 0035 "<kml xmlns=\"http://www.opengis.net/kml/2.2\"" 0036 " xmlns:gx=\"http://www.google.com/kml/ext/2.2\">" 0037 "<Document>" 0038 "<Placemark><TimeSpan><begin>1988</begin><end>1999</end></TimeSpan></Placemark>" 0039 "<Placemark><TimeSpan><begin>1989-04</begin><end>1999-05</end></TimeSpan></Placemark>" 0040 "<Placemark><TimeSpan><begin>1990-02-03</begin><end>1999-04-08</end></TimeSpan></Placemark>" 0041 "<Placemark><TimeSpan><begin>1997-07-16T07:30:15Z</begin><end>1997-08-17T02:35:12Z</end></TimeSpan></Placemark>" 0042 "<Placemark><TimeSpan><begin>1997-07-16T10:30:15+03:00</begin><end>1998-07-16T10:30:15+03:00</end></TimeSpan></Placemark>" 0043 "</Document>" 0044 "</kml>" ); 0045 0046 GeoDataDocument* dataDocument = parseKml( centerContent ); 0047 QCOMPARE( dataDocument->placemarkList().size(), 5 ); 0048 GeoDataPlacemark* placemark1 = dataDocument->placemarkList().at( 0 ); 0049 QCOMPARE( placemark1->timeSpan().begin().when().date().year(), 1988 ); 0050 QCOMPARE( placemark1->timeSpan().end().when().date().year(), 1999 ); 0051 GeoDataPlacemark* placemark2 = dataDocument->placemarkList().at( 1 ); 0052 QCOMPARE( placemark2->timeSpan().begin().when().date().year(), 1989 ); 0053 QCOMPARE( placemark2->timeSpan().begin().when().date().month(), 4 ); 0054 QCOMPARE( placemark2->timeSpan().end().when().date().year(), 1999 ); 0055 QCOMPARE( placemark2->timeSpan().end().when().date().month(), 5 ); 0056 GeoDataPlacemark* placemark3 = dataDocument->placemarkList().at( 2 ); 0057 QCOMPARE( placemark3->timeSpan().begin().when().date().year(), 1990 ); 0058 QCOMPARE( placemark3->timeSpan().begin().when().date().month(), 2 ); 0059 QCOMPARE( placemark3->timeSpan().begin().when().date().day(), 3 ); 0060 QCOMPARE( placemark3->timeSpan().end().when().date().year(), 1999 ); 0061 QCOMPARE( placemark3->timeSpan().end().when().date().month(), 4 ); 0062 QCOMPARE( placemark3->timeSpan().end().when().date().day(), 8 ); 0063 GeoDataPlacemark* placemark4 = dataDocument->placemarkList().at( 3 ); 0064 QCOMPARE( placemark4->timeSpan().begin().when(), QDateTime::fromString( "1997-07-16T07:30:15Z", Qt::ISODate ) ); 0065 QCOMPARE( placemark4->timeSpan().end().when(), QDateTime::fromString( "1997-08-17T02:35:12Z", Qt::ISODate ) ); 0066 GeoDataPlacemark* placemark5 = dataDocument->placemarkList().at( 4 ); 0067 QCOMPARE( placemark5->timeSpan().begin().when(), QDateTime::fromString( "1997-07-16T10:30:15+03:00", Qt::ISODate ) ); 0068 QCOMPARE( placemark5->timeSpan().end().when(), QDateTime::fromString( "1998-07-16T10:30:15+03:00", Qt::ISODate ) ); 0069 0070 delete dataDocument; 0071 } 0072 0073 QTEST_MAIN( TestTimeStamp ) 0074 0075 #include "TestTimeSpan.moc" 0076