Skip to content

Commit

Permalink
Boost coverage of raster fill unit tests
Browse files Browse the repository at this point in the history
Also add missing sip bindings for GUI widget
  • Loading branch information
nyalldawson committed Nov 19, 2014
1 parent 3c2d45f commit 09ab569
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 4 deletions.
18 changes: 18 additions & 0 deletions python/gui/symbology-ng/qgssymbollayerv2widget.sip
Expand Up @@ -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();

};

///////////

Expand Down
58 changes: 54 additions & 4 deletions tests/src/core/testqgsrasterfill.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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
//
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 09ab569

Please sign in to comment.