Skip to content

Commit

Permalink
[composer] Add tests for expression based picture source (sponsored b…
Browse files Browse the repository at this point in the history
…y City of Uster, Switzerland)
  • Loading branch information
nyalldawson committed Apr 28, 2014
1 parent ddfb697 commit 3afee3c
Show file tree
Hide file tree
Showing 4 changed files with 322 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/src/core/testqgscomposerpicture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class TestQgsComposerPicture: public QObject
void pictureSvgZoomAndResize();
void pictureSvgFrameToImage();

void pictureExpression();
void pictureInvalidExpression();

private:
QgsComposition* mComposition;
QgsComposerPicture* mComposerPicture;
Expand Down Expand Up @@ -275,5 +278,38 @@ void TestQgsComposerPicture::pictureSvgFrameToImage()
mComposerPicture->setPictureFile( mPngImage );
}

void TestQgsComposerPicture::pictureExpression()
{
//test picture source via expression
mComposition->addComposerPicture( mComposerPicture );

QString expr = QString( "'" ) + QString( TEST_DATA_DIR ) + QDir::separator()
+ QString( "' || 'sample_svg.svg'" );
mComposerPicture->setPictureExpression( expr );
mComposerPicture->setUsePictureExpression( true );

QgsCompositionChecker checker( "composerpicture_expression", mComposition );
QVERIFY( checker.testComposition( mReport, 0, 100 ) );

mComposition->removeItem( mComposerPicture );
mComposerPicture->setUsePictureExpression( false );
}

void TestQgsComposerPicture::pictureInvalidExpression()
{
//test picture source via bad expression
mComposition->addComposerPicture( mComposerPicture );

QString expr = QString( "bad expression" );
mComposerPicture->setPictureExpression( expr );
mComposerPicture->setUsePictureExpression( true );

QgsCompositionChecker checker( "composerpicture_badexpression", mComposition );
QVERIFY( checker.testComposition( mReport, 0, 100 ) );

mComposition->removeItem( mComposerPicture );
mComposerPicture->setUsePictureExpression( false );
}

QTEST_MAIN( TestQgsComposerPicture )
#include "moc_testqgscomposerpicture.cxx"
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.
286 changes: 286 additions & 0 deletions tests/testdata/sample_svg.svg
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 3afee3c

Please sign in to comment.