Skip to content

Commit

Permalink
Moved control images one per directory and updated render checker to …
Browse files Browse the repository at this point in the history
…generate paths and filenames more cleanly. All tests pass for me.
  • Loading branch information
timlinux committed Apr 13, 2012
1 parent 0180715 commit 83b1bf5
Show file tree
Hide file tree
Showing 25 changed files with 31 additions and 12 deletions.
7 changes: 7 additions & 0 deletions tests/src/core/qgsrenderchecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ QString QgsRenderChecker::controlImagePath() const
return myControlImageDir;
}

void QgsRenderChecker::setControlName(const QString theName)
{
mControlName = theName;
mExpectedImageFile = controlImagePath() + theName + QDir::separator() +
theName + ".png";
}

bool QgsRenderChecker::runTest( QString theTestName,
unsigned int theMismatchCount )
{
Expand Down
7 changes: 6 additions & 1 deletion tests/src/core/qgsrenderchecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ class QgsRenderChecker
//only records time for actual render part
int elapsedTime() { return mElapsedTime; };
void setElapsedTimeTarget(int theTarget) { mElapsedTimeTarget = theTarget; };
void setExpectedImage (QString theImageFileName) { mExpectedImageFile = theImageFileName; };
/** Base directory name for the control image (with control image path
* suffixed) the path to the image will be constructed like this:
* controlImagePath + '/' + mControlName + '/' + mControlName + '.png'
*/
void setControlName(const QString theName);
void setRenderedImage (QString theImageFileName) { mRenderedImageFile = theImageFileName; };
void setMapRenderer ( QgsMapRenderer * thepMapRenderer) { mpMapRenderer = thepMapRenderer; };
/**
Expand Down Expand Up @@ -73,6 +77,7 @@ class QgsRenderChecker
private:
QString mReport;
QString mExpectedImageFile;
QString mControlName;
QString mRenderedImageFile;
unsigned int mMismatchCount;
unsigned int mMatchTarget;
Expand Down
3 changes: 1 addition & 2 deletions tests/src/core/regression992.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ void Regression992::regression992()
QVERIFY( mpRasterLayer->isValid() );
mpMapRenderer->setExtent( mpRasterLayer->extent() );
QgsRenderChecker myChecker;
myChecker.setExpectedImage( myChecker.controlImagePath() +
"expected_rgbwcmyk01_YeGeo.jp2.png" );
myChecker.setControlName( "expected_rgbwcmyk01_YeGeo.jp2" );
myChecker.setMapRenderer( mpMapRenderer );
// allow up to 300 mismatched pixels
bool myResultFlag = myChecker.runTest( "regression992", 300 );
Expand Down
3 changes: 1 addition & 2 deletions tests/src/core/testqgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,7 @@ bool TestQgsGeometry::renderCheck( QString theTestName, QString theComment )
QString myFileName = myTmpDir + theTestName + ".png";
mImage.save( myFileName, "PNG" );
QgsRenderChecker myChecker;
myChecker.setExpectedImage( myChecker.controlImagePath() +
"expected_" + theTestName + ".png" );
myChecker.setControlName( "expected_" + theTestName );
myChecker.setRenderedImage( myFileName );
bool myResultFlag = myChecker.compareImages( theTestName );
mReport += myChecker.report();
Expand Down
3 changes: 1 addition & 2 deletions tests/src/core/testqgsmaprenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ void TestQgsMapRenderer::performanceTest()
{
mpMapRenderer->setExtent( mpPolysLayer->extent() );
QgsRenderChecker myChecker;
myChecker.setExpectedImage(
myChecker.controlImagePath() + "expected_maprender.png" );
myChecker.setControlName( "expected_maprender" );
myChecker.setMapRenderer( mpMapRenderer );
bool myResultFlag = myChecker.runTest( "maprender" );
mReport += myChecker.report();
Expand Down
3 changes: 1 addition & 2 deletions tests/src/core/testqgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ bool TestQgsRasterLayer::render( QString theTestType )
{
mReport += "<h2>" + theTestType + "</h2>\n";
QgsRenderChecker myChecker;
myChecker.setExpectedImage( myChecker.controlImagePath()
+ "expected_" + theTestType + ".png" );
myChecker.setControlName( "expected_" + theTestType );
myChecker.setMapRenderer( mpMapRenderer );
bool myResultFlag = myChecker.runTest( theTestType );
mReport += "\n\n\n" + myChecker.report();
Expand Down
4 changes: 1 addition & 3 deletions tests/src/core/testqgsrenderers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,7 @@ bool TestQgsRenderers::imageCheck( QString theTestType )
//ensure the rendered output matches our control image
mpMapRenderer->setExtent( mpPointsLayer->extent() );
QgsRenderChecker myChecker;
QString myExpectedImage = myChecker.controlImagePath() +
"expected_" + theTestType + ".png";
myChecker.setExpectedImage( myExpectedImage );
myChecker.setControlName( "expected_" + theTestType );
myChecker.setMapRenderer( mpMapRenderer );
bool myResultFlag = myChecker.runTest( theTestType );
mReport += myChecker.report();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<PAMDataset>
<Metadata domain="IMAGE_STRUCTURE">
<MDI key="INTERLEAVE">PIXEL</MDI>
</Metadata>
<PAMRasterBand band="1">
<Metadata>
<MDI key="STATISTICS_MINIMUM">0</MDI>
<MDI key="STATISTICS_MAXIMUM">255</MDI>
<MDI key="STATISTICS_MEAN">127.2</MDI>
<MDI key="STATISTICS_STDDEV">81.364365664583</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>

0 comments on commit 83b1bf5

Please sign in to comment.