Skip to content

Commit 05d79f5

Browse files
committedDec 21, 2012
Merge branch 'master' of github.com:qgis/Quantum-GIS
2 parents 79947fe + a9de654 commit 05d79f5

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed
 

‎tests/src/core/testqgsrastersublayer.cpp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ void TestQgsRasterSubLayer::initTestCase()
8787

8888
mReport += "<h1>Raster Sub Layer Tests</h1>\n";
8989
//mReport += "<p>" + mySettings + "</p>";
90-
91-
if ( mHasNetCDF )
92-
{
90+
91+
if ( mHasNetCDF )
92+
{
9393
QFileInfo myRasterFileInfo( mFileName );
9494
mpRasterLayer = new QgsRasterLayer( myRasterFileInfo.filePath(),
9595
myRasterFileInfo.completeBaseName() );
@@ -125,12 +125,19 @@ void TestQgsRasterSubLayer::subLayersList()
125125
// Layer with sublayers is not valid
126126
//QVERIFY( mpRasterLayer->isValid() );
127127
QStringList expected;
128-
expected << "NETCDF:\"" + mFileName + "\":Band1";
129-
expected << "NETCDF:\"" + mFileName + "\":Band2";
130-
131-
QStringList sublayers = mpRasterLayer->subLayers();
132-
mReport += QString( "sublayers:<br>%1<br>\n" ).arg( sublayers.join("<br>") );
133-
mReport += QString( "expected:<br>%1<br>\n" ).arg( expected.join("<br>") );
128+
// Sublayer format: NETCDF:"/path/to/landsat2.nc":Band1
129+
// File path is delicate on Windows -> compare only sublayers
130+
expected << "Band1";
131+
expected << "Band2";
132+
133+
QStringList sublayers;
134+
foreach ( QString s, mpRasterLayer->subLayers() )
135+
{
136+
sublayers << s.split( ':' ).value( 2 );
137+
}
138+
qDebug() << "sublayers: " << sublayers.join( "," );
139+
mReport += QString( "sublayers:<br>%1<br>\n" ).arg( sublayers.join( "<br>" ) );
140+
mReport += QString( "expected:<br>%1<br>\n" ).arg( expected.join( "<br>" ) );
134141
QVERIFY( sublayers == expected );
135142
mReport += "<p>Passed</p>";
136143
}
@@ -141,7 +148,7 @@ void TestQgsRasterSubLayer::checkStats()
141148
if ( mHasNetCDF )
142149
{
143150
mReport += "<h2>Check Stats</h2>\n";
144-
QString sublayerUri = mpRasterLayer->subLayers().value(0);
151+
QString sublayerUri = mpRasterLayer->subLayers().value( 0 );
145152
mReport += "sublayer: " + sublayerUri + "<br>\n";
146153

147154
QgsRasterLayer *sublayer = new QgsRasterLayer( sublayerUri, "Sublayer 1" );
@@ -159,8 +166,8 @@ void TestQgsRasterSubLayer::checkStats()
159166

160167
QVERIFY( sublayer->width() == width );
161168
QVERIFY( sublayer->height() == height );
162-
QVERIFY( doubleNear ( myStatistics.minimumValue, min ) );
163-
QVERIFY( doubleNear ( myStatistics.maximumValue, max ) );
169+
QVERIFY( doubleNear( myStatistics.minimumValue, min ) );
170+
QVERIFY( doubleNear( myStatistics.maximumValue, max ) );
164171
mReport += "<p>Passed</p>";
165172
delete sublayer;
166173
}

0 commit comments

Comments
 (0)