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 <QtTest/QtTest>
24 #include "map/mapview.h"
26 class TestMapView: public QObject
36 void zoomLevelChange_data();
37 void zoomLevelChange();
44 * @brief Constructor for setting pointer to MapView to NULL
46 TestMapView::TestMapView() : m_mapView(NULL)
52 * @brief Test case initialization
54 void TestMapView::init()
56 m_mapView = new MapView();
61 * @brief Test case cleanup
63 void TestMapView::cleanup()
70 * @brief Test view double click
72 void TestMapView::doubleClick()
74 QSignalSpy doubleClickSpy(m_mapView, SIGNAL(zoomIn()));
75 QVERIFY(doubleClickSpy.isValid());
77 QTest::mouseDClick(m_mapView, Qt::Key_Tab);
78 QCOMPARE(doubleClickSpy.count(), 1);
82 * @brief Test data for zoom level change test
84 void TestMapView::zoomLevelChange_data()
86 QTest::addColumn<int>("zoomLevel");
87 QTest::addColumn<qreal>("result");
89 QTest::newRow("zoom 18") << 18 << 1.0;
90 QTest::newRow("zoom 17") << 17 << 0.5;
91 QTest::newRow("zoom 16") << 16 << 0.25;
92 QTest::newRow("zoom 15") << 15 << 0.125;
96 * @brief Test view zoom level scaling
98 void TestMapView::zoomLevelChange()
100 QFETCH(int, zoomLevel);
101 QFETCH(qreal, result);
103 m_mapView->setZoomLevel(zoomLevel);
105 QCOMPARE(m_mapView->transform().m11(), result);
106 QCOMPARE(m_mapView->transform().m22(), result);
109 QTEST_MAIN(TestMapView)
110 #include "testmapview.moc"