Skip to content

Commit

Permalink
test fixes:
Browse files Browse the repository at this point in the history
* use compareWkt in PyGeometry nad PyQgsRectangle
* skip PySpatialiteProvider if pyspatialite is unavailable
* show information about used fonts
  • Loading branch information
jef-n committed Jul 21, 2013
1 parent 454778c commit 4b6bc3d
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 10 deletions.
5 changes: 3 additions & 2 deletions tests/src/core/testqgsatlascomposition.cpp
Expand Up @@ -129,6 +129,9 @@ void TestQgsAtlasComposition::initTestCase()
mLabel2->setText( "# [%$feature || ' / ' || $numfeatures%]" );
mLabel2->adjustSizeToText();
mLabel2->setItemPosition( 150, 200 );

qWarning() << "header label font: " << mLabel1->font().toString() << " exactMatch:" << mLabel1->font().exactMatch();
qWarning() << "feature number label font: " << mLabel2->font().toString() << " exactMatch:" << mLabel2->font().exactMatch();
}

void TestQgsAtlasComposition::cleanupTestCase()
Expand All @@ -140,12 +143,10 @@ void TestQgsAtlasComposition::cleanupTestCase()

void TestQgsAtlasComposition::init()
{

}

void TestQgsAtlasComposition::cleanup()
{

}

void TestQgsAtlasComposition::filename()
Expand Down
5 changes: 3 additions & 2 deletions tests/src/core/testqgscomposerlabel.cpp
Expand Up @@ -22,6 +22,7 @@
#include "qgsmaprenderer.h"
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"

#include <QObject>
#include <QtTest>

Expand Down Expand Up @@ -68,6 +69,8 @@ void TestQgsComposerLabel::initTestCase()

mComposerLabel = new QgsComposerLabel( mComposition );
mComposition->addComposerLabel( mComposerLabel );

qWarning() << "composer label font: " << mComposerLabel->font().toString() << " exactMatch:" << mComposerLabel->font().exactMatch();
}

void TestQgsComposerLabel::cleanupTestCase()
Expand All @@ -79,12 +82,10 @@ void TestQgsComposerLabel::cleanupTestCase()

void TestQgsComposerLabel::init()
{

}

void TestQgsComposerLabel::cleanup()
{

}

void TestQgsComposerLabel::evaluation()
Expand Down
1 change: 1 addition & 0 deletions tests/src/core/testqgscomposermap.cpp
Expand Up @@ -117,6 +117,7 @@ void TestQgsComposerMap::grid()
mComposerMap->setGridAnnotationDirection( QgsComposerMap::Horizontal, QgsComposerMap::Bottom );
mComposerMap->setAnnotationFontColor( QColor( 255, 0, 0, 150 ) );
mComposerMap->setGridBlendMode( QPainter::CompositionMode_Overlay );
qWarning() << "grid annotation font: " << mComposerMap->gridAnnotationFont().toString() << " exactMatch:" << mComposerMap->gridAnnotationFont().exactMatch();
QgsCompositionChecker checker( "Composer map grid", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
"control_images" + QDir::separator() + "expected_composermap" + QDir::separator() + "composermap_landsat_grid.png" ) );
bool testResult = checker.testComposition();
Expand Down
4 changes: 3 additions & 1 deletion tests/src/core/testqgscomposerscalebar.cpp
Expand Up @@ -88,7 +88,9 @@ void TestQgsComposerScaleBar::initTestCase()
mComposerScaleBar->setNumSegmentsLeft( 0 );
mComposerScaleBar->setNumSegments( 2 );
mComposerScaleBar->setHeight( 5 );
};

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

void TestQgsComposerScaleBar::cleanupTestCase()
{
Expand Down
4 changes: 4 additions & 0 deletions tests/src/python/test_qgsatlascomposition.py
Expand Up @@ -85,13 +85,17 @@ def testCase(self):
self.mLabel1.adjustSizeToText()
self.mLabel1.setItemPosition( 150, 5 )

qWarning( "header label font: %s exactMatch:%s" % ( self.mLabel1.font().toString(), self.mLabel1.font().exactMatch() ) )

# feature number label
self.mLabel2 = QgsComposerLabel( self.mComposition )
self.mComposition.addComposerLabel( self.mLabel2 )
self.mLabel2.setText( "# [%$feature || ' / ' || $numfeatures%]" )
self.mLabel2.adjustSizeToText()
self.mLabel2.setItemPosition( 150, 200 )

qWarning( "feature number label font: %s exactMatch:%s" % ( self.mLabel2.font().toString(), self.mLabel2.font().exactMatch() ) )

self.filename_test()
self.autoscale_render_test()
self.fixedscale_render_test()
Expand Down
5 changes: 3 additions & 2 deletions tests/src/python/test_qgsgeometry.py
Expand Up @@ -25,6 +25,7 @@
from utilities import (getQgisTestApp,
TestCase,
unittest,
compareWkt,
expectedFailure,
unitTestDataPath,
writeShape)
Expand Down Expand Up @@ -324,8 +325,8 @@ def testClipping(self):
myExpectedWkt = 'LINESTRING(20 20, 30 30)'
# There should only be one feature that intersects this clip
# poly so this assertion should work.
self.assertEqual(myExpectedWkt,
mySymmetricalGeometry.exportToWkt())
assert compareWkt( myExpectedWkt,
mySymmetricalGeometry.exportToWkt() )

myNewFeature = QgsFeature()
myNewFeature.setAttributes(myFeature.attributes())
Expand Down
5 changes: 3 additions & 2 deletions tests/src/python/test_qgsrectangle.py
Expand Up @@ -18,6 +18,7 @@

from utilities import (unitTestDataPath,
getQgisTestApp,
compareWkt,
TestCase,
unittest,
expectedFailure
Expand Down Expand Up @@ -185,7 +186,7 @@ def testAsWktCoordinates(self):
myWkt = rect1.asWktCoordinates()
myMessage = ('Expected: %s\nGot: %s\n' %
(myExpectedWkt, myWkt))
self.assertEquals(myWkt, myExpectedWkt, myMessage)
assert compareWkt( myWkt, myExpectedWkt ), myMessage

def testAsWktPolygon(self):
"""Test that we can get a proper rect wkt polygon representation for rect"""
Expand All @@ -198,7 +199,7 @@ def testAsWktPolygon(self):
myWkt = rect1.asWktPolygon()
myMessage = ('Expected: %s\nGot: %s\n' %
(myExpectedWkt, myWkt))
self.assertEquals(myWkt, myExpectedWkt, myMessage)
assert compareWkt( myWkt, myExpectedWkt ), myMessage


if __name__ == '__main__':
Expand Down
7 changes: 6 additions & 1 deletion tests/src/python/test_qgsspatialiteprovider.py
Expand Up @@ -15,6 +15,7 @@
import os
import tempfile
import qgis
import sys

from qgis.core import *

Expand All @@ -23,7 +24,11 @@
unittest
)

from pyspatialite import dbapi2 as sqlite3
try:
from pyspatialite import dbapi2 as sqlite3
except ImportError:
print "You should install pyspatialite to run the tests"
sys.exit(0)

# Convenience instances in case you may need them
QGISAPP, CANVAS, IFACE, PARENT = getQgisTestApp()
Expand Down

0 comments on commit 4b6bc3d

Please sign in to comment.