Skip to content

Commit

Permalink
Added unit test for setting raster qml which sets bands rgb as 875
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8046 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Jan 25, 2008
1 parent 9f026c7 commit d44a8cf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions tests/src/core/testqgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ class TestQgsRasterLayer: public QObject
void isValid();
void pseudoColor();
void landsatBasic();
void landsatBasic875Qml();
void checkDimensions();
private:
bool render(QString theFileName);
bool setQml (QString theType);
QString mTestDataDir;
QgsRasterLayer * mpRasterLayer;
QgsRasterLayer * mpLandsatRasterLayer;
QgsMapRender * mpMapRenderer;
Expand All @@ -79,9 +82,9 @@ void TestQgsRasterLayer::initTestCase()
std::cout << "User DB PATH: " << QgsApplication::qgisUserDbFilePath().toLocal8Bit().data() << std::endl;

//create a raster layer that will be used in all tests...
QString myTestDir (TEST_DATA_DIR); //defined in CmakeLists.txt
QString myFileName = myTestDir + QDir::separator() + "tenbytenraster.asc";
QString myLandsatFileName = myTestDir + QDir::separator() + "landsat_clip.tif";
mTestDataDir = QString(TEST_DATA_DIR) + QDir::separator(); //defined in CmakeLists.txt
QString myFileName = mTestDataDir + "tenbytenraster.asc";
QString myLandsatFileName = mTestDataDir + "landsat_clip.tif";
QFileInfo myRasterFileInfo ( myFileName );
mpRasterLayer = new QgsRasterLayer ( myRasterFileInfo.filePath(),
myRasterFileInfo.completeBaseName() );
Expand Down Expand Up @@ -140,6 +143,16 @@ void TestQgsRasterLayer::landsatBasic()
mpMapRenderer->setExtent(mpLandsatRasterLayer->extent());
QVERIFY(render("landsat_basic"));
}
void TestQgsRasterLayer::landsatBasic875Qml()
{
//a qml that orders the rgb bands as 8,7,5
QStringList myLayers;
myLayers << mpLandsatRasterLayer->getLayerID();
mpMapRenderer->setLayerSet(myLayers);
mpMapRenderer->setExtent(mpLandsatRasterLayer->extent());
QVERIFY(setQml("875"));
QVERIFY(render("landsat_875"));
}
void TestQgsRasterLayer::checkDimensions()
{
QVERIFY ( mpRasterLayer->getRasterXDim() == 10 );
Expand All @@ -162,6 +175,26 @@ bool TestQgsRasterLayer::render(QString theTestType)
return myResultFlag;
}

bool TestQgsRasterLayer::setQml (QString theType)
{
//load a qml style and apply to our layer
// huh? this is failing but shouldnt!
//if (! mpLandsatRasterLayer->isValid() )
//{
// qDebug(" **** setQml -> mpLandsatRasterLayer is invalid");
// return false;
//}
QString myFileName = mTestDataDir + "landsat_" + theType + ".qml";
bool myStyleFlag=false;
mpLandsatRasterLayer->loadNamedStyle ( myFileName , myStyleFlag );
if (!myStyleFlag)
{
qDebug(" **** setQml -> mpLandsatRasterLayer is invalid");
qDebug("Qml File :" + myFileName.toLocal8Bit());
}
return myStyleFlag;
}

QTEST_MAIN(TestQgsRasterLayer)
#include "moc_testqgsrasterlayer.cxx"

Binary file added tests/testdata/expected_landsat_875.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.

0 comments on commit d44a8cf

Please sign in to comment.