Skip to content
Permalink
Browse files

[tests] Update composer scalebar tests, fix exception causing test to…

… fail
  • Loading branch information
nyalldawson committed Dec 28, 2013
1 parent a1a92cd commit cfd9a669c8de56635f9754d3269ebb55e74fe942
@@ -279,7 +279,8 @@ void QgsComposerMap::cache( void )
double horizontalVScaleFactor = horizontalViewScaleFactor();
if ( horizontalVScaleFactor < 0 )
{
horizontalVScaleFactor = mLastValidViewScaleFactor;
//make sure scale factor is positive
horizontalVScaleFactor = mLastValidViewScaleFactor > 0 ? mLastValidViewScaleFactor : 1;
}

int w = requestExtent.width() * mapUnitsToMM() * horizontalVScaleFactor;
@@ -46,6 +46,7 @@ class TestQgsComposerScaleBar: public QObject
QgsComposerScaleBar* mComposerScaleBar;
QgsRasterLayer* mRasterLayer;
QgsMapRenderer* mMapRenderer;
QString mReport;
};

void TestQgsComposerScaleBar::initTestCase()
@@ -90,13 +91,24 @@ void TestQgsComposerScaleBar::initTestCase()
mComposerScaleBar->setHeight( 5 );

qWarning() << "scalebar font: " << mComposerScaleBar->font().toString() << " exactMatch:" << mComposerScaleBar->font().exactMatch();

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

void TestQgsComposerScaleBar::cleanupTestCase()
{
delete mComposition;
delete mMapRenderer;
delete mRasterLayer;

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 TestQgsComposerScaleBar::init()
@@ -112,33 +124,29 @@ void TestQgsComposerScaleBar::cleanup()
void TestQgsComposerScaleBar::singleBox()
{
mComposerScaleBar->setStyle( "Single Box" );
QgsCompositionChecker checker( "Composer scalebar singleBox", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
"control_images" + QDir::separator() + "expected_composerscalebar" + QDir::separator() + "composerscalebar_singlebox.png" ) );
QVERIFY( checker.testComposition() );
QgsCompositionChecker checker( "composerscalebar_singlebox", mComposition );
QVERIFY( checker.testComposition( mReport ) );
};

void TestQgsComposerScaleBar::doubleBox()
{
mComposerScaleBar->setStyle( "Double Box" );
QgsCompositionChecker checker( "Composer scalebar doubleBox", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
"control_images" + QDir::separator() + "expected_composerscalebar" + QDir::separator() + "composerscalebar_doublebox.png" ) );
QVERIFY( checker.testComposition() );
QgsCompositionChecker checker( "composerscalebar_doublebox", mComposition );
QVERIFY( checker.testComposition( mReport ) );
};

void TestQgsComposerScaleBar::numeric()
{
mComposerScaleBar->setStyle( "Numeric" );
QgsCompositionChecker checker( "Composer scalebar numeric", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
"control_images" + QDir::separator() + "expected_composerscalebar" + QDir::separator() + "composerscalebar_numeric.png" ) );
QVERIFY( checker.testComposition() );
QgsCompositionChecker checker( "composerscalebar_numeric", mComposition );
QVERIFY( checker.testComposition( mReport ) );
};

void TestQgsComposerScaleBar::tick()
{
mComposerScaleBar->setStyle( "Line Ticks Up" );
QgsCompositionChecker checker( "Composer scalebar tick", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
"control_images" + QDir::separator() + "expected_composerscalebar" + QDir::separator() + "composerscalebar_tick.png" ) );
QVERIFY( checker.testComposition() );
QgsCompositionChecker checker( "composerscalebar_tick", mComposition );
QVERIFY( checker.testComposition( mReport ) );
};

QTEST_MAIN( TestQgsComposerScaleBar )
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 cfd9a66

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