2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Sami Rämö - sami.ramo@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 #include <QtCore/QString>
24 #include <QtTest/QtTest>
26 #include "coordinates/geocoordinate.h"
27 #include "coordinates/scenecoordinate.h"
28 #include "map/maprouteitem.h"
29 #include "routing/route.h"
31 class TestMapRouteItem : public QObject
44 GeoCoordinate coordinates[3];
47 TestMapRouteItem::TestMapRouteItem()
50 coordinates[0] = GeoCoordinate(12.3456, 54.3210);
51 coordinates[1] = GeoCoordinate(65.5000, 25.0000);
52 coordinates[2] = GeoCoordinate(-23.4567, 43.0987);
54 // append points to route
55 route.appendGeometryPoint(coordinates[0]);
56 route.appendGeometryPoint(coordinates[1]);
57 route.appendGeometryPoint(coordinates[2]);
60 void TestMapRouteItem::testCase1()
63 item.setRoute(&route);
65 // check amount of lines
66 QList<QGraphicsItem *> lines = item.childItems();
67 QCOMPARE(lines.count(), 2);
70 for (int i = 0; i < lines.count(); i++) {
71 // check if the item really is a line item
72 QGraphicsLineItem *lineItem = dynamic_cast<QGraphicsLineItem *>(lines.at(i));
75 // check begin and end point scene coordinates of the line
76 QLineF line = lineItem->line();
77 QCOMPARE(line.p1(), SceneCoordinate(coordinates[i]).toPointF());
78 QCOMPARE(line.p2(), SceneCoordinate(coordinates[i + 1]).toPointF());
80 // check visual properties of the line
81 QPen pen = lineItem->pen();
82 QVERIFY(pen.isCosmetic());
83 QCOMPARE(pen.width(), 5);
84 QCOMPARE(pen.color(), QColor(Qt::red));
88 QTEST_APPLESS_MAIN(TestMapRouteItem);
90 #include "testmaprouteitem.moc"