File: TestModel.cpp

package info (click to toggle)
marble 4%3A25.08.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 159,996 kB
  • sloc: cpp: 191,890; xml: 39,908; ansic: 7,204; python: 2,190; sh: 1,187; makefile: 235; perl: 218; ruby: 97; java: 66
file content (100 lines) | stat: -rw-r--r-- 3,047 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// SPDX-License-Identifier: LGPL-2.1-or-later
//
// SPDX-FileCopyrightText: 2013 Mayank Madan <maddiemadan@gmail.com>
// SPDX-FileCopyrightText: 2013 Sanjiban Bairagya <sanjiban22393@gmail.com>
//

#include <QObject>

#include <GeoDataDocument.h>
#include <GeoDataLink.h>
#include <GeoDataLocation.h>
#include <GeoDataModel.h>
#include <GeoDataOrientation.h>
#include <GeoDataPlacemark.h>
#include <GeoDataScale.h>
#include <MarbleDebug.h>

#include "TestUtils.h"

using namespace Marble;
class TestModel : public QObject
{
    Q_OBJECT
private Q_SLOTS:
    void initTestCase();
    void simpleParseTest();
};
void TestModel::initTestCase()
{
    MarbleDebug::setEnabled(true);
}

void TestModel::simpleParseTest()
{
    QString const centerContent(
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
        "<kml xmlns=\"http://www.opengis.net/kml/2.2\">"
        "<Placemark>"
        "<Model id=\"model_4\">"
        "<altitudeMode>relativeToGround</altitudeMode>"
        "<Location>"
        "<longitude>-105.27</longitude>"
        "<latitude>40.00</latitude>"
        "<altitude>23.4</altitude>"
        "</Location>"
        "<Orientation>"
        "<heading>1</heading>"
        "<tilt>2</tilt>"
        "<roll>3</roll>"
        "</Orientation>"
        "<Scale>"
        "<x>3</x>"
        "<y>4</y>"
        "<z>5</z>"
        "</Scale>"
        "<Link>"
        "<href>MackyBldg.kmz/files/CU Macky.dae</href>"
        "<refreshMode>onExpire</refreshMode>"
        "</Link>"
        "<ResourceMap id=\"resourcemap_for_model_4\">"
        "<Alias>"
        "<sourceHref>../files/CU-Macky-4sideturretnoCulling.jpg</sourceHref>"
        "<targetHref>../files/CU-Macky-4sideturretnoCulling.jpg</targetHref>"
        "</Alias>"
        "</ResourceMap>"
        "</Model>"
        "</Placemark>"
        "</kml>");
    GeoDataDocument *dataDocument = parseKml(centerContent);

    QCOMPARE(dataDocument->placemarkList().size(), 1);

    GeoDataPlacemark *placemark = dataDocument->placemarkList().at(0);

    auto model = dynamic_cast<GeoDataModel *>(placemark->geometry());

    QVERIFY(model != nullptr);

    QCOMPARE(model->altitudeMode(), RelativeToGround);

    QCOMPARE(model->location().altitude(), 23.4);
    QCOMPARE(model->location().latitude(GeoDataCoordinates::Degree), 40.00);
    QCOMPARE(model->location().longitude(GeoDataCoordinates::Degree), -105.27);

    QCOMPARE(model->orientation().heading(), 1.0);
    QCOMPARE(model->orientation().tilt(), 2.0);
    QCOMPARE(model->orientation().roll(), 3.0);
    QCOMPARE(model->scale().x(), 3.0);
    QCOMPARE(model->scale().y(), 4.0);
    QCOMPARE(model->scale().z(), 5.0);
    QCOMPARE(model->link().href(), QString("MackyBldg.kmz/files/CU Macky.dae"));
    QCOMPARE(model->link().refreshMode(), GeoDataLink::OnExpire);
    QCOMPARE(model->targetHref(), QString("../files/CU-Macky-4sideturretnoCulling.jpg"));
    QCOMPARE(model->sourceHref(), QString("../files/CU-Macky-4sideturretnoCulling.jpg"));

    delete dataDocument;
}
QTEST_MAIN(TestModel)

#include "TestModel.moc"