Skip to content

Commit

Permalink
Add some missing tests for QgsImageOperation
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 27, 2015
1 parent 6dd42ca commit e0adf89
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/src/core/testqgsimageoperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class TestQgsImageOperation : public QObject
void distanceTransformMaxDist();
void distanceTransformSetSpread();
void distanceTransformInterior();
void distanceTransformMisc();

//stack blur
void stackBlur();
Expand All @@ -73,6 +74,7 @@ class TestQgsImageOperation : public QObject
//gaussian blur
void gaussianBlur();
void gaussianBlurSmall();
void gaussianBlurNoChange();

//flip
void flipHorizontal();
Expand Down Expand Up @@ -322,6 +324,31 @@ void TestQgsImageOperation::distanceTransformInterior()
QVERIFY( result );
}

void TestQgsImageOperation::distanceTransformMisc()
{
//no ramp
QImage image( mSampleImage );
QgsImageOperation::DistanceTransformProperties props;
props.useMaxDistance = true;
props.ramp = NULL;
props.shadeExterior = false;
QgsImageOperation::distanceTransform( image, props );
bool result = imageCheck( QString( "imageop_nochange" ), image, 0 );
QVERIFY( result );

//zero spread
QImage image2( mSampleImage );
QgsImageOperation::DistanceTransformProperties props2;
QgsVectorGradientColorRampV2 ramp;
props2.useMaxDistance = false;
props2.spread = 0;
props2.ramp = &ramp;
props2.shadeExterior = false;
QgsImageOperation::distanceTransform( image2, props2 );
result = imageCheck( QString( "imageop_zerospread" ), image2, 0 );
QVERIFY( result );
}

void TestQgsImageOperation::stackBlur()
{
QImage image( mSampleImage );
Expand Down Expand Up @@ -386,6 +413,16 @@ void TestQgsImageOperation::gaussianBlurSmall()
QVERIFY( result );
}

void TestQgsImageOperation::gaussianBlurNoChange()
{
QImage image( mSampleImage );
QImage* blurredImage = QgsImageOperation::gaussianBlur( image, 0 );

bool result = imageCheck( QString( "imageop_nochange" ), *blurredImage, 0 );
delete blurredImage;
QVERIFY( result );
}

void TestQgsImageOperation::flipHorizontal()
{
QImage image( mSampleImage );
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e0adf89

Please sign in to comment.