@@ -53,9 +53,12 @@ class TestQgsRasterLayer: public QObject
5353 void isValid ();
5454 void pseudoColor ();
5555 void landsatBasic ();
56+ void landsatBasic875Qml ();
5657 void checkDimensions ();
5758 private:
5859 bool render (QString theFileName);
60+ bool setQml (QString theType);
61+ QString mTestDataDir ;
5962 QgsRasterLayer * mpRasterLayer;
6063 QgsRasterLayer * mpLandsatRasterLayer;
6164 QgsMapRender * mpMapRenderer;
@@ -79,9 +82,9 @@ void TestQgsRasterLayer::initTestCase()
7982 std::cout << " User DB PATH: " << QgsApplication::qgisUserDbFilePath ().toLocal8Bit ().data () << std::endl;
8083
8184 // 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" ;
8588 QFileInfo myRasterFileInfo ( myFileName );
8689 mpRasterLayer = new QgsRasterLayer ( myRasterFileInfo.filePath (),
8790 myRasterFileInfo.completeBaseName () );
@@ -140,6 +143,16 @@ void TestQgsRasterLayer::landsatBasic()
140143 mpMapRenderer->setExtent (mpLandsatRasterLayer->extent ());
141144 QVERIFY (render (" landsat_basic" ));
142145}
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+ }
143156void TestQgsRasterLayer::checkDimensions ()
144157{
145158 QVERIFY ( mpRasterLayer->getRasterXDim () == 10 );
@@ -162,6 +175,26 @@ bool TestQgsRasterLayer::render(QString theTestType)
162175 return myResultFlag;
163176}
164177
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+
165198QTEST_MAIN (TestQgsRasterLayer)
166199#include " moc_testqgsrasterlayer.cxx"
167200
0 commit comments