Skip to content

Commit

Permalink
[tests] Update composer shape tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 28, 2013
1 parent 3b1f789 commit ab42edc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions tests/src/core/testqgscomposershapes.cpp
Expand Up @@ -40,6 +40,7 @@ class TestQgsComposerShapes: public QObject
private:
QgsComposition* mComposition;
QgsComposerShape* mComposerShape;
QString mReport;
};

void TestQgsComposerShapes::initTestCase()
Expand All @@ -53,11 +54,22 @@ void TestQgsComposerShapes::initTestCase()
mComposerShape = new QgsComposerShape( 20, 20, 150, 100, mComposition );
mComposerShape->setBackgroundColor( QColor::fromRgb( 255, 150, 0 ) );
mComposition->addComposerShape( mComposerShape );

mReport = "<h1>Composer Shape Tests</h1>\n";
}

void TestQgsComposerShapes::cleanupTestCase()
{
delete mComposition;

QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html";
QFile myFile( myReportFile );
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )
{
QTextStream myQTextStream( &myFile );
myQTextStream << mReport;
myFile.close();
}
}

void TestQgsComposerShapes::init()
Expand All @@ -74,37 +86,33 @@ void TestQgsComposerShapes::rectangle()
{
mComposerShape->setShapeType( QgsComposerShape::Rectangle );

QgsCompositionChecker checker( "Composer shapes", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
"control_images" + QDir::separator() + "expected_composershapes" + QDir::separator() + "composershape_rectangle.png" ) );
QVERIFY( checker.testComposition() );
QgsCompositionChecker checker( "composershapes_rectangle", mComposition );
QVERIFY( checker.testComposition( mReport ) );
}

void TestQgsComposerShapes::triangle()
{
mComposerShape->setShapeType( QgsComposerShape::Triangle );

QgsCompositionChecker checker( "Composer shapes", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
"control_images" + QDir::separator() + "expected_composershapes" + QDir::separator() + "composershape_triangle.png" ) );
QVERIFY( checker.testComposition() );
QgsCompositionChecker checker( "composershapes_triangle", mComposition );
QVERIFY( checker.testComposition( mReport ) );
}

void TestQgsComposerShapes::ellipse()
{
mComposerShape->setShapeType( QgsComposerShape::Ellipse );

QgsCompositionChecker checker( "Composer shapes", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
"control_images" + QDir::separator() + "expected_composershapes" + QDir::separator() + "composershape_ellipse.png" ) );
QVERIFY( checker.testComposition() );
QgsCompositionChecker checker( "composershapes_ellipse", mComposition );
QVERIFY( checker.testComposition( mReport ) );
}

void TestQgsComposerShapes::roundedRectangle()
{
mComposerShape->setShapeType( QgsComposerShape::Rectangle );
mComposerShape->setCornerRadius( 30 );

QgsCompositionChecker checker( "Composer shapes", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
"control_images" + QDir::separator() + "expected_composershapes" + QDir::separator() + "composershape_roundedrectangle.png" ) );
QVERIFY( checker.testComposition() );
QgsCompositionChecker checker( "composershapes_roundedrect", mComposition );
QVERIFY( checker.testComposition( mReport ) );
mComposerShape->setCornerRadius( 0 );
}

Expand Down

0 comments on commit ab42edc

Please sign in to comment.