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

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 <MarbleDebug.h>
0010 #include <GeoDataCamera.h>
0011 #include "TestUtils.h"
0012 
0013 using namespace Marble;
0014 
0015 class TestCamera : public QObject
0016 {
0017     Q_OBJECT
0018 private Q_SLOTS:
0019     void initTestCase();
0020     void simpleParseTest();
0021 };
0022 
0023 void TestCamera::initTestCase()
0024 {
0025     MarbleDebug::setEnabled( true );
0026 }
0027 
0028 void TestCamera::simpleParseTest()
0029 {
0030   QString const kmlContent (
0031         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
0032         "<kml xmlns=\"http://www.opengis.net/kml/2.2\""
0033         " xmlns:gx=\"http://www.google.com/kml/ext/2.2\">"
0034         "<Document>"
0035         "   <Camera id=\"myCam\">"
0036         "     <longitude>1</longitude>"
0037         "     <latitude>2</latitude>"
0038         "     <altitude>3</altitude>"
0039         "     <heading>4</heading>"
0040         "     <tilt>5</tilt>"
0041         "     <roll>6</roll>"
0042         "     <altitudeMode>relativeToGround</altitudeMode>"
0043         "   </Camera>"
0044         "</Document>"
0045         "</kml>" );
0046 
0047     GeoDataDocument* dataDocument = parseKml( kmlContent );
0048     GeoDataCamera *camera = dynamic_cast<GeoDataCamera*>( dataDocument->abstractView() );
0049 
0050     QVERIFY( camera != nullptr);
0051 
0052     GeoDataCoordinates::Unit const degree = GeoDataCoordinates::Degree;
0053     QCOMPARE( camera->longitude( degree ), 1.0 );
0054     QCOMPARE( camera->latitude( degree ), 2.0 );
0055     QCOMPARE( camera->altitude(), 3.0 );
0056     QCOMPARE( camera->heading(), 4.0 );
0057     QCOMPARE( camera->tilt(), 5.0 );
0058     QCOMPARE( camera->roll(), 6.0 );
0059     QCOMPARE( camera->altitudeMode(), RelativeToGround );
0060 
0061     delete dataDocument;
0062 }
0063 
0064 QTEST_MAIN( TestCamera )
0065 
0066 #include "TestCamera.moc"
0067