File indexing completed on 2024-12-08 12:14:54
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 <GeoDataTimeStamp.h> 0011 #include <GeoDataCamera.h> 0012 #include <MarbleDebug.h> 0013 #include "TestUtils.h" 0014 0015 using namespace Marble; 0016 0017 class TestTimeStamp : public QObject 0018 { 0019 Q_OBJECT 0020 private Q_SLOTS: 0021 void initTestCase(); 0022 void simpleParseTest(); 0023 }; 0024 0025 void TestTimeStamp::initTestCase() 0026 { 0027 MarbleDebug::setEnabled( true ); 0028 } 0029 0030 void TestTimeStamp::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><TimeStamp><when>1988</when></TimeStamp></Placemark>" 0038 "<Placemark><TimeStamp><when>1989-04</when></TimeStamp></Placemark>" 0039 "<Placemark><TimeStamp><when>1990-02-03</when></TimeStamp></Placemark>" 0040 "<Placemark><TimeStamp><when>1997-07-16T07:30:15Z</when></TimeStamp></Placemark>" 0041 "<Placemark><TimeStamp><when>1997-07-16T10:30:15+03:00</when></TimeStamp></Placemark>" 0042 "</Document>" 0043 "</kml>" ); 0044 0045 GeoDataDocument* dataDocument = parseKml( centerContent ); 0046 QCOMPARE( dataDocument->placemarkList().size(), 5 ); 0047 GeoDataPlacemark* placemark1 = dataDocument->placemarkList().at( 0 ); 0048 QCOMPARE( placemark1->timeStamp().when().date().year(), 1988 ); 0049 QCOMPARE( placemark1->timeStamp().resolution(), GeoDataTimeStamp::YearResolution ); 0050 GeoDataPlacemark* placemark2 = dataDocument->placemarkList().at( 1 ); 0051 QCOMPARE( placemark2->timeStamp().when().date().year(), 1989 ); 0052 QCOMPARE( placemark2->timeStamp().when().date().month(), 4 ); 0053 QCOMPARE( placemark2->timeStamp().resolution(), GeoDataTimeStamp::MonthResolution ); 0054 GeoDataPlacemark* placemark3 = dataDocument->placemarkList().at( 2 ); 0055 QCOMPARE( placemark3->timeStamp().when().date().year(), 1990 ); 0056 QCOMPARE( placemark3->timeStamp().when().date().month(), 2 ); 0057 QCOMPARE( placemark3->timeStamp().when().date().day(), 3 ); 0058 QCOMPARE( placemark3->timeStamp().resolution(), GeoDataTimeStamp::DayResolution ); 0059 GeoDataPlacemark* placemark4 = dataDocument->placemarkList().at( 3 ); 0060 QCOMPARE( placemark4->timeStamp().when(), QDateTime::fromString( "1997-07-16T07:30:15Z", Qt::ISODate ) ); 0061 QCOMPARE( placemark4->timeStamp().resolution(), GeoDataTimeStamp::SecondResolution ); 0062 GeoDataPlacemark* placemark5 = dataDocument->placemarkList().at( 4 ); 0063 QCOMPARE( placemark5->timeStamp().when(), QDateTime::fromString( "1997-07-16T10:30:15+03:00", Qt::ISODate ) ); 0064 QCOMPARE( placemark5->timeStamp().resolution(), GeoDataTimeStamp::SecondResolution ); 0065 0066 delete dataDocument; 0067 } 0068 0069 QTEST_MAIN( TestTimeStamp ) 0070 0071 #include "TestTimeStamp.moc" 0072