1
1
/* **************************************************************************
2
- testqgsapplication.cpp
3
- --------------------------------------
4
- Date : Sun Sep 16 12:22:49 AKDT 2007
5
- Copyright : (C) 2007 by Gary E. Sherman
6
- Email : sherman at mrcc dot com
2
+ testqgsapplication.cpp
3
+ --------------------------------------
4
+ Date : Sun Sep 16 12:22:49 AKDT 2007
5
+ Copyright : (C) 2007 by Gary E. Sherman
6
+ Email : sherman at mrcc dot com
7
7
***************************************************************************
8
8
* *
9
9
* This program is free software; you can redistribute it and/or modify *
13
13
* *
14
14
***************************************************************************/
15
15
#include < QtTest>
16
- #include < QObject>
17
- #include < QString>
18
- #include < QStringList>
19
- #include < QObject>
20
16
#include < iostream>
21
17
22
- #include < QApplication>
23
- #include < QImage>
24
- #include < QPainter>
18
+ #include < QPixmap>
25
19
26
20
#include < qgsapplication.h>
27
- #include < qgsmaplayerregistry.h>
28
- #include < qgsmaprender.h>
29
- #include < qgsspatialrefsys.h>
30
- #include < qgsvectorlayer.h>
31
21
32
22
// header for class being tested
33
23
#include < qgsapplication.h>
@@ -36,127 +26,40 @@ class TestQgsApplication: public QObject
36
26
{
37
27
Q_OBJECT;
38
28
private slots:
39
- void QgsApplicationQgsApplication ()
40
- {
41
- // init QGIS's paths - true means that all path will be inited from prefix
42
- QString qgisPath = QCoreApplication::applicationDirPath ();
43
- QgsApplication::setPrefixPath (qgisPath, TRUE );
44
-
45
- std::cout << " Prefix PATH: " << QgsApplication::prefixPath ().toLocal8Bit ().data () << std::endl;
46
- std::cout << " Plugin PATH: " << QgsApplication::pluginPath ().toLocal8Bit ().data () << std::endl;
47
- std::cout << " PkgData PATH: " << QgsApplication::pkgDataPath ().toLocal8Bit ().data () << std::endl;
48
- std::cout << " User DB PATH: " << QgsApplication::qgisUserDbFilePath ().toLocal8Bit ().data () << std::endl;
49
-
50
- QgsApplication::initQgis ();
51
- /* QStringList myLayerList;
52
- myLayerList << "../../../points.shp";
53
- QStringList::Iterator myIterator = myLayerList.begin();
54
- while( myIterator!= myLayerList.end() )
55
- {
56
- QString myLayerName=*myIterator;
57
- QgsVectorLayer* layer = new QgsVectorLayer(myLayerName, myLayerName, "ogr");
58
- if (layer && layer->isValid())
59
- {
60
- std::cout << "Added layer is valid " << std::endl;
61
- }
62
- // something's wrong
63
- else if (layer)
64
- {
65
- //test must be failed here!
66
- delete layer;
67
- }
68
- //Register this layer with the layers registry
69
- QgsMapLayerRegistry::instance()->addMapLayer(layer);
70
- ++myIterator;
71
-
72
- }
73
-
74
-
75
- // create image and painter for it
76
- QImage img(QSize(800,600), QImage::Format_ARGB32_Premultiplied);
77
- QColor bgColor(255,255,255);
78
- img.fill(bgColor.rgb());
79
- QPainter p;
80
- p.begin(&img);
81
- p.setRenderHint(QPainter::Antialiasing); // use antialiasing!
82
-
83
- QgsMapRender mapRender;
84
-
85
- // set layers
86
- mapRender.setLayerSet(myLayerList);
87
-
88
- // use projection
89
- mapRender.setProjectionsEnabled(TRUE);
90
- QgsSpatialRefSys srs(32633); // postgis srid: wgs84 / utm zone 33N
91
- mapRender.setDestinationSrs(srs);
92
-
93
- // set extent
94
- QgsRect r = mapRender.fullExtent();
95
- r.scale(1.1); // make rectangle a bit bigger
96
- mapRender.setExtent(r);
97
-
98
- // set output size
99
- mapRender.setOutputSize(img.size(), img.logicalDpiX());
100
-
101
- // render!
102
- mapRender.render(&p);
103
-
104
- // painting done
105
- p.end();
106
-
107
- // delete layers
108
- QgsMapLayerRegistry::instance()->removeAllMapLayers();
109
-
110
- // save image
111
- img.save("render.png","png");*/
112
- QgsApplication::exitQgis ();
113
- };
114
- void QgsApplicationselectTheme ()
115
- {
116
-
117
- };
118
- void QgsApplicationauthorsFilePath ()
119
- {
120
-
29
+ void getPaths ();
30
+ void checkTheme ();
121
31
};
122
- void QgsApplicationdeveloperPath ()
123
- {
124
32
125
- };
126
- void QgsApplicationhelpAppPath ()
127
- {
128
-
129
- };
130
- void QgsApplicationi18nPath ()
33
+ void TestQgsApplication::getPaths ()
131
34
{
35
+ // init QGIS's paths - true means that all path will be inited from prefix
36
+ QString qgisPath = QCoreApplication::applicationDirPath () + " /../" ;
37
+ QgsApplication::setPrefixPath (qgisPath, TRUE );
132
38
133
- };
134
- void QgsApplicationqgisMasterDbFilePath ()
135
- {
39
+ std::cout << " Prefix PATH: " << QgsApplication::prefixPath ().toLocal8Bit ().data () << std::endl;
40
+ std::cout << " Plugin PATH: " << QgsApplication::pluginPath ().toLocal8Bit ().data () << std::endl;
41
+ std::cout << " PkgData PATH: " << QgsApplication::pkgDataPath ().toLocal8Bit ().data () << std::endl;
42
+ std::cout << " User DB PATH: " << QgsApplication::qgisUserDbFilePath ().toLocal8Bit ().data () << std::endl;
136
43
137
44
};
138
- void QgsApplicationqgisSettingsDirPath ()
139
- {
140
45
141
- };
142
- void QgsApplicationqgisUserDbFilePath ()
46
+ void TestQgsApplication::checkTheme ()
143
47
{
48
+ QString qgisPath = QCoreApplication::applicationDirPath () + " /../" ;
49
+ QgsApplication::setPrefixPath (qgisPath, TRUE );
50
+ std::cout << " Prefix PATH: " << QgsApplication::prefixPath ().toLocal8Bit ().data () << std::endl;
51
+ std::cout << " Plugin PATH: " << QgsApplication::pluginPath ().toLocal8Bit ().data () << std::endl;
52
+ std::cout << " PkgData PATH: " << QgsApplication::pkgDataPath ().toLocal8Bit ().data () << std::endl;
53
+ std::cout << " User DB PATH: " << QgsApplication::qgisUserDbFilePath ().toLocal8Bit ().data () << std::endl;
54
+ QString myIconPath = QgsApplication::themePath ();
55
+ QPixmap myPixmap;
56
+ myPixmap.load (myIconPath+" /mIconProjectionDisabled.png" );
57
+ qDebug (" Checking if a theme icon exists:" );
58
+ qDebug (myIconPath.toLocal8Bit ()+" /mIconProjectionDisabled.png" );
59
+ QVERIFY (!myPixmap.isNull ());
144
60
145
61
};
146
- void QgsApplicationsplashPath ()
147
- {
148
62
149
- };
150
- void QgsApplicationsrsDbFilePath ()
151
- {
152
-
153
- };
154
- void QgsApplicationsvgPath ()
155
- {
156
-
157
- };
158
-
159
- };
160
63
161
64
QTEST_MAIN (TestQgsApplication)
162
65
#include " moc_testqgsapplication.cxx"
0 commit comments