Skip to content
Permalink
Browse files

Boost coverage of raster fill unit tests

Also add missing sip bindings for GUI widget
  • Loading branch information
nyalldawson committed Nov 19, 2014
1 parent 3c2d45f commit 09ab5696b1972096ed1bc974bbb17bd1e839f629
@@ -253,6 +253,24 @@ class QgsSvgMarkerSymbolLayerV2Widget : QgsSymbolLayerV2Widget
void setGuiForSvg( const QgsSvgMarkerSymbolLayerV2* layer );
};

///////////

class QgsRasterFillSymbolLayerWidget : QgsSymbolLayerV2Widget
{
%TypeHeaderCode
#include <qgssymbollayerv2widget.h>
%End

public:
QgsRasterFillSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) /Factory/;

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
virtual QgsSymbolLayerV2* symbolLayer();

};

///////////

@@ -45,10 +45,14 @@ class TestQgsRasterFill: public QObject
private slots:
void initTestCase();// will be called before the first testfunction is executed.
void cleanupTestCase();// will be called after the last testfunction was executed.
void init() {};// will be called before each testfunction is executed.
void cleanup() {};// will be called after every testfunction.
void init(); // will be called before each testfunction is executed.
void cleanup();// will be called after every testfunction.

void rasterFillSymbol();
void coordinateMode();
void alpha();
void offset();
void width();

private:
bool mTestHasError;
@@ -119,15 +123,61 @@ void TestQgsRasterFill::cleanupTestCase()
}
}

void TestQgsRasterFill::rasterFillSymbol()
void TestQgsRasterFill::init()
{
mReport += "<h2>Raster fill symbol renderer test</h2>\n";
mRasterFill->setImageFilePath( mTestDataDir + QString( "sample_image.png" ) );
mRasterFill->setWidth( 30.0 );
mRasterFill->setWidthUnit( QgsSymbolV2::Pixel );
mRasterFill->setCoordinateMode( QgsRasterFillSymbolLayer::Feature );
mRasterFill->setAlpha( 1.0 );
mRasterFill->setOffset( QPointF( 0, 0 ) );
}

void TestQgsRasterFill::cleanup()
{

}

void TestQgsRasterFill::rasterFillSymbol()
{
mReport += "<h2>Raster fill symbol renderer test</h2>\n";
bool result = imageCheck( "rasterfill" );
QVERIFY( result );
}

void TestQgsRasterFill::coordinateMode()
{
mReport += "<h2>Raster fill viewport mode</h2>\n";
mRasterFill->setCoordinateMode( QgsRasterFillSymbolLayer::Viewport );
bool result = imageCheck( "rasterfill_viewport" );
QVERIFY( result );
}

void TestQgsRasterFill::alpha()
{
mReport += "<h2>Raster fill alpha</h2>\n";
mRasterFill->setAlpha( 0.5 );
bool result = imageCheck( "rasterfill_alpha" );
QVERIFY( result );
}

void TestQgsRasterFill::offset()
{
mReport += "<h2>Raster fill offset</h2>\n";
mRasterFill->setOffset( QPointF( 5, 10 ) );;
bool result = imageCheck( "rasterfill_offset" );
QVERIFY( result );
}

void TestQgsRasterFill::width()
{
mReport += "<h2>Raster fill width</h2>\n";
mRasterFill->setWidthUnit( QgsSymbolV2::MM );
mRasterFill->setWidth( 5.0 );
bool result = imageCheck( "rasterfill_width" );
QVERIFY( result );
}

//
// Private helper functions not called directly by CTest
//
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 09ab569

Please sign in to comment.
You can’t perform that action at this time.