@@ -53,9 +53,12 @@ class TestQgsRasterLayer: public QObject
53
53
void isValid ();
54
54
void pseudoColor ();
55
55
void landsatBasic ();
56
+ void landsatBasic875Qml ();
56
57
void checkDimensions ();
57
58
private:
58
59
bool render (QString theFileName);
60
+ bool setQml (QString theType);
61
+ QString mTestDataDir ;
59
62
QgsRasterLayer * mpRasterLayer;
60
63
QgsRasterLayer * mpLandsatRasterLayer;
61
64
QgsMapRender * mpMapRenderer;
@@ -79,9 +82,9 @@ void TestQgsRasterLayer::initTestCase()
79
82
std::cout << " User DB PATH: " << QgsApplication::qgisUserDbFilePath ().toLocal8Bit ().data () << std::endl;
80
83
81
84
// create a raster layer that will be used in all tests...
82
- QString myTestDir (TEST_DATA_DIR); // defined in CmakeLists.txt
83
- QString myFileName = myTestDir + QDir::separator () + " tenbytenraster.asc" ;
84
- QString myLandsatFileName = myTestDir + QDir::separator () + " landsat_clip.tif" ;
85
+ mTestDataDir = QString (TEST_DATA_DIR) + QDir::separator ( ); // defined in CmakeLists.txt
86
+ QString myFileName = mTestDataDir + " tenbytenraster.asc" ;
87
+ QString myLandsatFileName = mTestDataDir + " landsat_clip.tif" ;
85
88
QFileInfo myRasterFileInfo ( myFileName );
86
89
mpRasterLayer = new QgsRasterLayer ( myRasterFileInfo.filePath (),
87
90
myRasterFileInfo.completeBaseName () );
@@ -140,6 +143,16 @@ void TestQgsRasterLayer::landsatBasic()
140
143
mpMapRenderer->setExtent (mpLandsatRasterLayer->extent ());
141
144
QVERIFY (render (" landsat_basic" ));
142
145
}
146
+ void TestQgsRasterLayer::landsatBasic875Qml ()
147
+ {
148
+ // a qml that orders the rgb bands as 8,7,5
149
+ QStringList myLayers;
150
+ myLayers << mpLandsatRasterLayer->getLayerID ();
151
+ mpMapRenderer->setLayerSet (myLayers);
152
+ mpMapRenderer->setExtent (mpLandsatRasterLayer->extent ());
153
+ QVERIFY (setQml (" 875" ));
154
+ QVERIFY (render (" landsat_875" ));
155
+ }
143
156
void TestQgsRasterLayer::checkDimensions ()
144
157
{
145
158
QVERIFY ( mpRasterLayer->getRasterXDim () == 10 );
@@ -162,6 +175,26 @@ bool TestQgsRasterLayer::render(QString theTestType)
162
175
return myResultFlag;
163
176
}
164
177
178
+ bool TestQgsRasterLayer::setQml (QString theType)
179
+ {
180
+ // load a qml style and apply to our layer
181
+ // huh? this is failing but shouldnt!
182
+ // if (! mpLandsatRasterLayer->isValid() )
183
+ // {
184
+ // qDebug(" **** setQml -> mpLandsatRasterLayer is invalid");
185
+ // return false;
186
+ // }
187
+ QString myFileName = mTestDataDir + " landsat_" + theType + " .qml" ;
188
+ bool myStyleFlag=false ;
189
+ mpLandsatRasterLayer->loadNamedStyle ( myFileName , myStyleFlag );
190
+ if (!myStyleFlag)
191
+ {
192
+ qDebug (" **** setQml -> mpLandsatRasterLayer is invalid" );
193
+ qDebug (" Qml File :" + myFileName.toLocal8Bit ());
194
+ }
195
+ return myStyleFlag;
196
+ }
197
+
165
198
QTEST_MAIN (TestQgsRasterLayer)
166
199
#include " moc_testqgsrasterlayer.cxx"
167
200
0 commit comments