Skip to content

Commit 75eef25

Browse files
committed
First little test case
1 parent c3e4ff7 commit 75eef25

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed

tests/src/gui/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,5 @@ ADD_QGIS_TEST(zoomtest testqgsmaptoolzoom.cpp)
118118
#ADD_EXECUTABLE(qgis_rendererv2gui ${rendererv2gui_SRCS} ${rendererv2gui_MOC_SRCS})
119119
120120
ADD_QGIS_TEST(histogramtest testqgsrasterhistogram.cpp)
121+
ADD_QGIS_TEST(projectionissues testprojectionissues.cpp)
121122
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/***************************************************************************
2+
testprojectionissues.cpp
3+
---------------------------
4+
begin : September 2012
5+
copyright : (C) 2012 by Magnus Homann
6+
email : magnus at homann dot se
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#include "qgsapplication.h"
19+
#include "qgsmapcanvas.h"
20+
#include "qgsmaplayerregistry.h"
21+
#include "qgsmaprenderer.h"
22+
#include "qgsmultibandcolorrenderer.h"
23+
#include "qgsrasterlayer.h"
24+
#include <QObject>
25+
#include <QtTest>
26+
27+
class TestProjectionIssues: public QObject
28+
{
29+
Q_OBJECT;
30+
private slots:
31+
void initTestCase();// will be called before the first testfunction is executed.
32+
void cleanupTestCase();// will be called after the last testfunction was executed.
33+
void init();// will be called before each testfunction is executed.
34+
void cleanup();// will be called after every testfunction.
35+
void issue5895();// test for #5895
36+
private:
37+
QgsRasterLayer* mRasterLayer;
38+
QgsMapCanvas* mMapCanvas;
39+
};
40+
41+
void TestProjectionIssues::initTestCase()
42+
{
43+
QgsApplication::init();
44+
QgsApplication::initQgis();
45+
46+
//create maplayer from testdata and add to layer registry
47+
QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "issue5895_world.tif" );
48+
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
49+
rasterFileInfo.completeBaseName() );
50+
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 2, 3, 4 );
51+
mRasterLayer->setRenderer( rasterRenderer );
52+
53+
QList<QgsMapLayer *> mapLayers;
54+
mapLayers.append( mRasterLayer );
55+
QgsMapLayerRegistry::instance()->addMapLayers( mapLayers );
56+
57+
// Add all layers in registry to the canvas
58+
QList<QgsMapCanvasLayer> canvasLayers;
59+
foreach ( QgsMapLayer* layer, QgsMapLayerRegistry::instance()->mapLayers().values() )
60+
{
61+
canvasLayers.append( QgsMapCanvasLayer( layer ) );
62+
}
63+
64+
// create canvas
65+
mMapCanvas = new QgsMapCanvas();
66+
mMapCanvas->setLayerSet( canvasLayers );
67+
68+
//reproject to SWEDREF 99 TM
69+
QgsCoordinateReferenceSystem destCRS;
70+
destCRS.createFromId( 3006, QgsCoordinateReferenceSystem::EpsgCrsId );
71+
mMapCanvas->mapRenderer()->setDestinationCrs( destCRS );
72+
mMapCanvas->mapRenderer()->setProjectionsEnabled( true );
73+
74+
};
75+
76+
void TestProjectionIssues::cleanupTestCase()
77+
{
78+
delete mMapCanvas;
79+
delete mRasterLayer;
80+
};
81+
82+
void TestProjectionIssues::init()
83+
{
84+
85+
};
86+
87+
void TestProjectionIssues::cleanup()
88+
{
89+
90+
};
91+
92+
void TestProjectionIssues::issue5895()
93+
{
94+
QgsRectangle largeExtent( -610861, 5101721, 2523921, 6795055 );
95+
mMapCanvas->setExtent( largeExtent );
96+
mMapCanvas->zoomByFactor( 2.0 ); // Zoom out. This should exceed the transform limits.
97+
};
98+
99+
QTEST_MAIN( TestProjectionIssues )
100+
#include "moc_testprojectionissues.cxx"

tests/testdata/issue5895_world.tif

254 KB
Binary file not shown.

0 commit comments

Comments
 (0)