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
|
// SPDX-License-Identifier: LGPL-2.1-or-later
//
// SPDX-FileCopyrightText: 2012 Mohammed Nafees <nafees.technocool@gmail.com>
//
#include <QObject>
#include "TestUtils.h"
#include <GeoDataDocument.h>
#include <GeoDataFolder.h>
#include <GeoDataItemIcon.h>
#include <GeoDataListStyle.h>
#include <GeoDataPlacemark.h>
#include <GeoDataStyle.h>
#include <MarbleDebug.h>
using namespace Marble;
class TestListStyle : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void simpleParseTest();
};
void TestListStyle::initTestCase()
{
MarbleDebug::setEnabled(true);
}
void TestListStyle::simpleParseTest()
{
QString const content(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<kml xmlns=\"http://www.opengis.net/kml/2.2\""
" xmlns:gx=\"http://www.google.com/kml/ext/2.2\">"
"<Document>"
" <name>The one and only BalloonStyle test case</name>"
" <Style id=\"my-list-style\">"
" <ListStyle>"
" <listItemType>checkOffOnly</listItemType>"
" <bgColor>aa112233</bgColor>"
" <ItemIcon>"
" <state>open error</state>"
" <href>https://developers.google.com/kml/documentation/images/itemicons.jpg</href>"
" </ItemIcon>"
" <ItemIcon>"
" <state>closed</state>"
" <href>https://developers.google.com/kml/documentation/images/itemicons1.jpg</href>"
" </ItemIcon>"
" </ListStyle>"
" </Style>"
" <Folder>"
" <Placemark>"
" <name>The first placemark</name>"
" <styleUrl>#my-list-style</styleUrl>"
" <Point><coordinates>80.0,30.0</coordinates></Point>"
" </Placemark>"
" </Folder>"
"</Document>"
"</kml>");
GeoDataDocument *dataDocument = parseKml(content);
QCOMPARE(dataDocument->folderList().size(), 1);
GeoDataFolder *folder = dataDocument->folderList().at(0);
QCOMPARE(folder->size(), 1);
auto placemark1 = dynamic_cast<GeoDataPlacemark *>(folder->child(0));
QVERIFY(placemark1 != nullptr);
QCOMPARE(placemark1->name(), QString("The first placemark"));
QCOMPARE(placemark1->style()->listStyle().listItemType(), GeoDataListStyle::CheckOffOnly);
QCOMPARE(placemark1->style()->listStyle().backgroundColor().red(), 51);
QCOMPARE(placemark1->style()->listStyle().itemIconList().at(0)->state(), GeoDataItemIcon::Open | GeoDataItemIcon::Error);
QCOMPARE(placemark1->style()->listStyle().itemIconList().at(0)->iconPath(),
QString("https://developers.google.com/kml/documentation/images/itemicons.jpg"));
QCOMPARE(placemark1->style()->listStyle().itemIconList().at(1)->state(), GeoDataItemIcon::Closed);
QCOMPARE(placemark1->style()->listStyle().itemIconList().at(1)->iconPath(),
QString("https://developers.google.com/kml/documentation/images/itemicons1.jpg"));
delete dataDocument;
}
QTEST_MAIN(TestListStyle)
#include "TestListStyle.moc"
|