Skip to content

Commit 332961f

Browse files
committed
Add test for map edit tool. Test the correctness of getting default z.
1 parent d780ba7 commit 332961f

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

tests/src/gui/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ MACRO (ADD_QGIS_TEST testname testsrc)
119119
ENDMACRO (ADD_QGIS_TEST)
120120
121121
ADD_QGIS_TEST(zoomtest testqgsmaptoolzoom.cpp)
122+
ADD_QGIS_TEST(edittooltest testqgsmaptooledit.cpp)
122123
123124
# a simple app for testing GUI of renderers
124125
# These tests are old and are never run so removed for now.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/***************************************************************************
2+
testqgsmaptooledit.cpp
3+
--------------------------------------
4+
Date : 6.2.2017
5+
Copyright : (C) 2017 Alexander Lisovenko
6+
Email : alexander.lisovenko@gmail.com
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
#include <QCoreApplication>
16+
17+
#include "qgstest.h"
18+
#include <qgisgui.h>
19+
#include <qgsmaptooledit.h>
20+
#include <qgsapplication.h>
21+
#include <qgsmapcanvas.h>
22+
#include <qgslogger.h>
23+
24+
class TestQgsMapToolEdit : public QObject
25+
{
26+
Q_OBJECT
27+
public:
28+
TestQgsMapToolEdit()
29+
: mCanvas( 0 )
30+
{}
31+
32+
private slots:
33+
void initTestCase(); // will be called before the first testfunction is executed.
34+
void cleanupTestCase(); // will be called after the last testfunction was executed.
35+
void init(); // will be called before each testfunction is executed.
36+
void cleanup(); // will be called after every testfunction.
37+
38+
void checkDefaultZValue();
39+
40+
private:
41+
QgsMapCanvas* mCanvas;
42+
43+
};
44+
45+
void TestQgsMapToolEdit::initTestCase()
46+
{
47+
QgsApplication::init();
48+
QgsApplication::initQgis();
49+
QgsApplication::showSettings();
50+
}
51+
52+
void TestQgsMapToolEdit::cleanupTestCase()
53+
{
54+
QgsApplication::exitQgis();
55+
}
56+
57+
void TestQgsMapToolEdit::init()
58+
{
59+
mCanvas = new QgsMapCanvas();
60+
}
61+
62+
void TestQgsMapToolEdit::cleanup()
63+
{
64+
delete mCanvas;
65+
}
66+
67+
void TestQgsMapToolEdit::checkDefaultZValue()
68+
{
69+
QSettings settings;
70+
settings.remove( "/qgis/digitizing/default_z_value" );
71+
72+
QgsMapToolEdit* tool = new QgsMapToolEdit( mCanvas );
73+
QCOMPARE( tool->defaultZValue(), Qgis::DEFAULT_Z_COORDINATE );
74+
75+
double z_value_for_test = Qgis::DEFAULT_Z_COORDINATE + 1;
76+
settings.setValue( QStringLiteral( "/qgis/digitizing/default_z_value" ), z_value_for_test );
77+
78+
79+
QCOMPARE( tool->defaultZValue(), z_value_for_test );
80+
}
81+
82+
QGSTEST_MAIN( TestQgsMapToolEdit )
83+
#include "testqgsmaptooledit.moc"

0 commit comments

Comments
 (0)