Showing with 19 additions and 14 deletions.
  1. +19 −14 tests/src/core/testziplayer.cpp
  2. BIN tests/testdata/zip/testtar.tgz
  3. BIN tests/testdata/zip/testzip.zip
33 changes: 19 additions & 14 deletions tests/src/core/testziplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class TestZipLayer: public QObject
// test item(s) in zip item (supply name or test all)
bool testZipItem( QString myFileName, QString myChildName = "", QString myDriverName = "" );
// get layer transparency to test for .qml loading
// int getLayerTransparency( QString myFileName, QString myProviderKey, QString myScanZipSetting = "basic" );
// bool testZipItemTransparency( QString myFileName, QString myProviderKey, int myTarget );
int getLayerTransparency( QString myFileName, QString myProviderKey, QString myScanZipSetting = "basic" );
bool testZipItemTransparency( QString myFileName, QString myProviderKey, int myTarget );

private slots:

Expand All @@ -77,15 +77,16 @@ class TestZipLayer: public QObject
void testTarItemVector();
void testZipItemAll();
void testTarItemAll();
#if 0
// test that styles are loaded from .qml files outside zip files
#if 0
// TODO - find a simple way to test vector style loading
void testZipItemVectorTransparency();
void testTarItemVectorTransparency();
void testGzipItemVectorTransparency();
#endif
void testZipItemRasterTransparency();
void testTarItemRasterTransparency();
void testGzipItemRasterTransparency();
#endif
//make sure items inside subfolders can be read
void testZipItemSubfolder();
void testTarItemSubfolder();
Expand Down Expand Up @@ -154,14 +155,12 @@ bool TestZipLayer::testZipItem( QString myFileName, QString myChildName, QString
if ( myChildren.size() > 0 )
{
QgsDebugMsg( QString( "has %1 items" ).arg( myChildren.size() ) );
QWARN( QString( "has %1 items" ).arg( myChildren.size() ).toLocal8Bit().data() );
foreach ( QgsDataItem* item, myChildren )
{
QgsDebugMsg( QString( "child name=%1" ).arg( item->name() ) );
QgsLayerItem *layerItem = dynamic_cast<QgsLayerItem*>( item );
if ( layerItem )
{
QWARN( QString( "child %1" ).arg( layerItem->path() ).toLocal8Bit().data() );
QgsDebugMsg( QString( "child name=%1 provider=%2 path=%3" ).arg( layerItem->name() ).arg( layerItem->providerKey() ).arg( layerItem->path() ) );
if ( myChildName == "" || myChildName == item->name() )
{
Expand All @@ -177,8 +176,6 @@ bool TestZipLayer::testZipItem( QString myFileName, QString myChildName, QString
{
QWARN( QString( "Invalid layer %1" ).arg( layerItem->path() ).toLocal8Bit().data() );
}
else
QWARN( QString( "Valid layer %1" ).arg( layerItem->path() ).toLocal8Bit().data() );
if ( myChildName == "" )
{
if ( ! ok )
Expand Down Expand Up @@ -217,7 +214,6 @@ bool TestZipLayer::testZipItem( QString myFileName, QString myChildName, QString
return ok;
}

#if 0
int TestZipLayer::getLayerTransparency( QString myFileName, QString myProviderKey, QString myScanZipSetting )
{
int myTransparency = -1;
Expand All @@ -232,7 +228,17 @@ int TestZipLayer::getLayerTransparency( QString myFileName, QString myProviderKe
else
myLayer = getZipLayer( myFileName, "" );
if ( myLayer && myLayer->isValid() )
myTransparency = myLayer->getTransparency();
{
// myTransparency = myLayer->getTransparency();
if ( myLayer->type() == QgsMapLayer::RasterLayer )
{
QgsRasterLayer* layer = dynamic_cast<QgsRasterLayer*>( myLayer );
if ( layer && layer->renderer() )
{
myTransparency = ceil(layer->renderer()->opacity() * 255);
}
}
}
else
QWARN( QString( "Could not open filename %1 using %2 provider" ).arg( myFileName ).arg( myProviderKey ).toLocal8Bit().data() );
if ( myLayer )
Expand All @@ -254,7 +260,6 @@ bool TestZipLayer::testZipItemTransparency( QString myFileName, QString myProvid
}
return true;
}
#endif


// slots
Expand Down Expand Up @@ -425,10 +430,10 @@ void TestZipLayer::testTarItemVector()

void TestZipLayer::testZipItemAll()
{
// test file contains invalid items (tmp1.tif, tmp1.txt and tmp1.xml)
// test for all items inside zip, using zipSetting 3 (Full Scan) which will ignore invalid items
// using zipSetting 2 (Basic Scan) would raise errors, because QgsZipItem would not test for valid items
// and return child names of the invalid items
// test file does not contain invalid items (some of dash tests failed because of them)
QSettings settings;
settings.setValue( mSettingsKey, "full" );
QVERIFY( "full" == settings.value( mSettingsKey ).toString() );
Expand Down Expand Up @@ -470,6 +475,7 @@ void TestZipLayer::testGzipItemVectorTransparency()
#endif
QVERIFY( testZipItemTransparency( mDataDir + "points3.geojson.gz", "ogr", 250 ) );
}
#endif

void TestZipLayer::testZipItemRasterTransparency()
{
Expand All @@ -488,7 +494,6 @@ void TestZipLayer::testGzipItemRasterTransparency()
{
QVERIFY( testZipItemTransparency( mDataDir + "landsat_b1.tif.gz", "gdal", 250 ) );
}
#endif

void TestZipLayer::testZipItemSubfolder()
{
Expand Down Expand Up @@ -526,7 +531,7 @@ void TestZipLayer::testZipItemVRT()
{
settings.setValue( mSettingsKey, s );
QVERIFY( s == settings.value( mSettingsKey ).toString() );
QVERIFY( testZipItem( QDir::tempPath() + "/testzip.zip", "landsat.vrt", "gdal" ) );
QVERIFY( testZipItem( QDir::tempPath() + "/testzip.zip", "landsat_b1.vrt", "gdal" ) );
// this file is buggy with gdal svn - skip for now
// QVERIFY( testZipItem( QDir::tempPath() + "/testzip.zip", "points.vrt", "ogr" ) );
}
Expand Down
Binary file modified tests/testdata/zip/testtar.tgz
Binary file not shown.
Binary file modified tests/testdata/zip/testzip.zip
Binary file not shown.