Skip to content

Commit

Permalink
Use a simpler image for testing composer map rotation and overview
Browse files Browse the repository at this point in the history
Update expected results and configuration of new image
Add rendering anomalies, as determined by travis ubuntu 12.02
  • Loading branch information
Sandro Santilli committed Feb 5, 2015
1 parent 32ab967 commit fb344ff
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 39 deletions.
30 changes: 15 additions & 15 deletions tests/src/core/testqgscomposermapoverview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ void TestQgsComposerMapOverview::initTestCase()
QgsApplication::initQgis();

//create maplayers from testdata and add to layer registry
QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "landsat.tif" );
QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "rgb256x256.png" );
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
rasterFileInfo.completeBaseName() );
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 2, 3, 4 );
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 1, 2, 3 );
mRasterLayer->setRenderer( rasterRenderer );

QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << mRasterLayer );
Expand Down Expand Up @@ -103,11 +103,11 @@ void TestQgsComposerMapOverview::cleanup()

void TestQgsComposerMapOverview::overviewMap()
{
QgsComposerMap* overviewMap = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
QgsComposerMap* overviewMap = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
overviewMap->setFrameEnabled( true );
mComposition->addComposerMap( overviewMap );
mComposerMap->setNewExtent( QgsRectangle( 785462.375, 3341423.125, 789262.375, 3343323.125 ) ); //zoom in
overviewMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3350923.125 ) );
mComposerMap->setNewExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in
overviewMap->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
overviewMap->overview()->setFrameMap( mComposerMap->id() );
QgsCompositionChecker checker( "composermap_overview", mComposition );

Expand All @@ -121,9 +121,9 @@ void TestQgsComposerMapOverview::overviewMapRotated()
QgsComposerMap* overviewMap = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
overviewMap->setFrameEnabled( true );
mComposition->addComposerMap( overviewMap );
mComposerMap->setNewExtent( QgsRectangle( 785462.375, 3341423.125, 789262.375, 3343323.125 ) ); //zoom in
mComposerMap->setNewExtent( QgsRectangle( 96, -144, 160, -112 ) ); //zoom in
mComposerMap->setMapRotation( 30 );
overviewMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3350923.125 ) );
overviewMap->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
overviewMap->overview()->setFrameMap( mComposerMap->id() );
QgsCompositionChecker checker( "composermap_overview_rotated", mComposition );

Expand All @@ -138,9 +138,9 @@ void TestQgsComposerMapOverview::overviewMapRotated2()
QgsComposerMap* overviewMap = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
overviewMap->setFrameEnabled( true );
mComposition->addComposerMap( overviewMap );
mComposerMap->setNewExtent( QgsRectangle( 785462.375, 3341423.125, 789262.375, 3343323.125 ) ); //zoom in
mComposerMap->setNewExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in
overviewMap->setMapRotation( 30 );
overviewMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3350923.125 ) );
overviewMap->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
overviewMap->overview()->setFrameMap( mComposerMap->id() );
QgsCompositionChecker checker( "composermap_overview_rotated2", mComposition );

Expand All @@ -154,8 +154,8 @@ void TestQgsComposerMapOverview::overviewMapBlending()
QgsComposerMap* overviewMapBlend = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
overviewMapBlend->setFrameEnabled( true );
mComposition->addComposerMap( overviewMapBlend );
mComposerMap->setNewExtent( QgsRectangle( 785462.375, 3341423.125, 789262.375, 3343323.125 ) ); //zoom in
overviewMapBlend->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3350923.125 ) );
mComposerMap->setNewExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in
overviewMapBlend->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
overviewMapBlend->overview()->setFrameMap( mComposerMap->id() );
overviewMapBlend->overview()->setBlendMode( QPainter::CompositionMode_Multiply );

Expand All @@ -171,8 +171,8 @@ void TestQgsComposerMapOverview::overviewMapInvert()
QgsComposerMap* overviewMapInvert = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
overviewMapInvert->setFrameEnabled( true );
mComposition->addComposerMap( overviewMapInvert );
mComposerMap->setNewExtent( QgsRectangle( 785462.375, 3341423.125, 789262.375, 3343323.125 ) ); //zoom in
overviewMapInvert->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3350923.125 ) );
mComposerMap->setNewExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in
overviewMapInvert->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
overviewMapInvert->overview()->setFrameMap( mComposerMap->id() );
overviewMapInvert->overview()->setInverted( true );

Expand All @@ -188,8 +188,8 @@ void TestQgsComposerMapOverview::overviewMapCenter()
QgsComposerMap* overviewMapCenter = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
overviewMapCenter->setFrameEnabled( true );
mComposition->addComposerMap( overviewMapCenter );
mComposerMap->setNewExtent( QgsRectangle( 785462.375 + 5000, 3341423.125, 789262.375 + 5000, 3343323.125 ) ); //zoom in
overviewMapCenter->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3350923.125 ) );
mComposerMap->setNewExtent( QgsRectangle( 192, -288, 320, -224 ) );
overviewMapCenter->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
overviewMapCenter->overview()->setFrameMap( mComposerMap->id() );
overviewMapCenter->overview()->setCentered( true );

Expand Down
12 changes: 6 additions & 6 deletions tests/src/core/testqgscomposerrotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ void TestQgsComposerRotation::initTestCase()
QgsApplication::initQgis();

//create maplayers from testdata and add to layer registry
QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "landsat.tif" );
QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "rgb256x256.png" );
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
rasterFileInfo.completeBaseName() );
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 2, 3, 4 );
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 1, 2, 3 );
mRasterLayer->setRenderer( rasterRenderer );

QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << mRasterLayer );
Expand Down Expand Up @@ -180,10 +180,10 @@ void TestQgsComposerRotation::oldLabelRotationApi()
void TestQgsComposerRotation::mapRotation()
{
//test map rotation
QgsComposerMap* composerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
QgsComposerMap* composerMap = new QgsComposerMap( mComposition, 20, 20, 100, 50 );
composerMap->setFrameEnabled( true );
mComposition->addItem( composerMap );
composerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
composerMap->setNewExtent( QgsRectangle( 0, -192, 256, -64 ) );
composerMap->setMapRotation( 90 );

QgsCompositionChecker checker( "composerrotation_maprotation", mComposition );
Expand All @@ -196,10 +196,10 @@ void TestQgsComposerRotation::mapRotation()
void TestQgsComposerRotation::mapItemRotation()
{
//test map item rotation
QgsComposerMap* composerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
QgsComposerMap* composerMap = new QgsComposerMap( mComposition, 20, 50, 100, 50 );
composerMap->setFrameEnabled( true );
mComposition->addItem( composerMap );
composerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
composerMap->setNewExtent( QgsRectangle( 0, -192, 256, -64 ) );
composerMap->setItemRotation( 90, true );

QgsCompositionChecker checker( "composerrotation_mapitemrotation", mComposition );
Expand Down
28 changes: 10 additions & 18 deletions tests/src/python/test_qgscomposermap.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ class TestQgsComposerMap(TestCase):
def __init__(self, methodName):
"""Run once on class initialisation."""
unittest.TestCase.__init__(self, methodName)
myPath = os.path.join(TEST_DATA_DIR, 'landsat.tif')
myPath = os.path.join(TEST_DATA_DIR, 'rgb256x256.png')
rasterFileInfo = QFileInfo(myPath)
mRasterLayer = QgsRasterLayer(rasterFileInfo.filePath(),
rasterFileInfo.completeBaseName())
rasterRenderer = QgsMultiBandColorRenderer(
mRasterLayer.dataProvider(), 2, 3, 4)
mRasterLayer.dataProvider(), 1, 2, 3)
mRasterLayer.setRenderer(rasterRenderer)
#pipe = mRasterLayer.pipe()
#assert pipe.set(rasterRenderer), 'Cannot set pipe renderer'
Expand All @@ -73,11 +73,9 @@ def testOverviewMap(self):
overviewMap.setFrameEnabled(True)
self.mComposition.addComposerMap(overviewMap)
# zoom in
myRectangle = QgsRectangle(785462.375, 3341423.125,
789262.375, 3343323.125)
myRectangle = QgsRectangle(96, -152, 160, -120)
self.mComposerMap.setNewExtent(myRectangle)
myRectangle2 = QgsRectangle(781662.375, 3339523.125,
793062.375, 3350923.125)
myRectangle2 = QgsRectangle(0, -256, 256, 0)
overviewMap.setNewExtent(myRectangle2)
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
checker = QgsCompositionChecker('composermap_overview', self.mComposition)
Expand All @@ -90,11 +88,9 @@ def testOverviewMapBlend(self):
overviewMap.setFrameEnabled(True)
self.mComposition.addComposerMap(overviewMap)
# zoom in
myRectangle = QgsRectangle(785462.375, 3341423.125,
789262.375, 3343323.125)
myRectangle = QgsRectangle(96, -152, 160, -120)
self.mComposerMap.setNewExtent(myRectangle)
myRectangle2 = QgsRectangle(781662.375, 3339523.125,
793062.375, 3350923.125)
myRectangle2 = QgsRectangle(0, -256, 256, 0)
overviewMap.setNewExtent(myRectangle2)
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
overviewMap.setOverviewBlendMode(QPainter.CompositionMode_Multiply)
Expand All @@ -108,11 +104,9 @@ def testOverviewMapInvert(self):
overviewMap.setFrameEnabled(True)
self.mComposition.addComposerMap(overviewMap)
# zoom in
myRectangle = QgsRectangle(785462.375, 3341423.125,
789262.375, 3343323.125)
myRectangle = QgsRectangle(96, -152, 160, -120)
self.mComposerMap.setNewExtent(myRectangle)
myRectangle2 = QgsRectangle(781662.375, 3339523.125,
793062.375, 3350923.125)
myRectangle2 = QgsRectangle(0, -256, 256, 0)
overviewMap.setNewExtent(myRectangle2)
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
overviewMap.setOverviewInverted(True)
Expand All @@ -126,11 +120,9 @@ def testOverviewMapCenter(self):
overviewMap.setFrameEnabled(True)
self.mComposition.addComposerMap(overviewMap)
# zoom in
myRectangle = QgsRectangle(785462.375+5000, 3341423.125,
789262.375+5000, 3343323.125)
myRectangle = QgsRectangle(192, -288, 320, -224)
self.mComposerMap.setNewExtent(myRectangle)
myRectangle2 = QgsRectangle(781662.375, 3339523.125,
793062.375, 3350923.125)
myRectangle2 = QgsRectangle(0, -256, 256, 0)
overviewMap.setNewExtent(myRectangle2)
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
overviewMap.setOverviewInverted(False)
Expand Down
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.
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.
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.
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.
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.
Binary file added tests/testdata/rgb256x256.png
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 fb344ff

Please sign in to comment.