Skip to content

Commit

Permalink
add a few cpt-city svg files to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennesky committed Aug 6, 2012
1 parent 3391f42 commit 6861078
Show file tree
Hide file tree
Showing 21 changed files with 487 additions and 26 deletions.
3 changes: 2 additions & 1 deletion tests/src/core/testqgsrasterlayer.cpp
Expand Up @@ -254,7 +254,8 @@ void TestQgsRasterLayer::colorRamp2()

void TestQgsRasterLayer::colorRamp3()
{
// cpt-city ramp
// cpt-city ramp, small selection available in <testdir>/cpt-city
QgsCptCityColorRampV2::setBaseDir( mTestDataDir + "cpt-city" );
QVERIFY( testColorRamp( "raster_colorRamp3",
new QgsCptCityColorRampV2( "gmt/GMT_panoply", "" ),
QgsColorRampShader::DISCRETE, 10 ) );
Expand Down
52 changes: 27 additions & 25 deletions tests/src/core/testqgsstylev2.cpp
Expand Up @@ -37,6 +37,7 @@ class TestStyleV2: public QObject
private:

QgsStyleV2 *mStyle;
QString mTestDataDir;

bool testValidColor( QgsVectorColorRampV2 *ramp, double value, QColor expected );

Expand All @@ -58,9 +59,10 @@ class TestStyleV2: public QObject
// slots
void TestStyleV2::initTestCase()
{
// initialize with test directory so we don't mess with user's stuff
// initialize with test settings directory so we don't mess with user's stuff
QgsApplication::init( QDir::homePath() + QString( "/.qgis_test" ) );
QgsApplication::initQgis();
mTestDataDir = QString( TEST_DATA_DIR ) + QDir::separator(); //defined in CmakeLists.txt

// output test environment
QgsApplication::showSettings();
Expand All @@ -79,6 +81,10 @@ void TestStyleV2::initTestCase()
}
mStyle = QgsStyleV2::defaultStyle();
// mStyle->clear();

// cpt-city ramp, small selection available in <testdir>/cpt-city
QgsCptCityColorRampV2::setBaseDir( mTestDataDir + "cpt-city" );
QgsCptCityColorRampV2::loadSchemes( "" );
}

void TestStyleV2::cleanupTestCase()
Expand Down Expand Up @@ -119,21 +125,17 @@ void TestStyleV2::testCreateColorRamps()
QgsVectorColorBrewerColorRampV2* cb2Ramp = new QgsVectorColorBrewerColorRampV2( "RdYlGn", 6 );
QVERIFY( mStyle->addColorRamp( "test_cb2", cb2Ramp ) == true );

// cpt-city ramp - use gradients that are free to distribute
// set base dir because we are using a test home path - change this if we distribute a minimal set with qgis
QgsCptCityColorRampV2::setBaseDir( QDir::homePath() + QString( "/.qgis/cpt-city" ) );
QgsCptCityColorRampV2::loadSchemes( "" );
if ( QgsCptCityColorRampV2::hasBasicSchemes() )
{
QgsCptCityColorRampV2* cc1Ramp = new QgsCptCityColorRampV2( "jjg/misc/temperature", "" );
QVERIFY( mStyle->addColorRamp( "test_cc1", cc1Ramp ) == true );
QgsCptCityColorRampV2* cc2Ramp = new QgsCptCityColorRampV2( "cb/div/PiYG", "_10" );
QVERIFY( mStyle->addColorRamp( "test_cc2", cc2Ramp ) == true );
}
else
{
QWARN( "cpt-city support files not found - skipping cpt-city color ramp tests" );
}
// if ( QgsCptCityColorRampV2::hasBasicSchemes() )
// {
QgsCptCityColorRampV2* cc1Ramp = new QgsCptCityColorRampV2( "jjg/misc/temperature", "" );
QVERIFY( mStyle->addColorRamp( "test_cc1", cc1Ramp ) == true );
QgsCptCityColorRampV2* cc2Ramp = new QgsCptCityColorRampV2( "cb/div/PiYG", "_10" );
QVERIFY( mStyle->addColorRamp( "test_cc2", cc2Ramp ) == true );
// }
// else
// {
// QWARN( "cpt-city support files not found - skipping cpt-city color ramp tests" );
// }
}

void TestStyleV2::testLoadColorRamps()
Expand All @@ -154,15 +156,15 @@ void TestStyleV2::testLoadColorRamps()
colorTests.insert( "test_cb2", qMakePair( 0.66, QColor( "#d9ef8b" ) ) );

// cpt-city
if ( QgsCptCityColorRampV2::hasAllSchemes() )
{
colorRampsTest << "test_cc1";
colorTests.insert( "test_cc1", qMakePair( 0.25, QColor( "#466fcf" ) ) );
colorTests.insert( "test_cc1", qMakePair( 0.66, QColor( "#dbc85b" ) ) );
colorRampsTest << "test_cc2";
colorTests.insert( "test_cc2", qMakePair( 0.25, QColor( "#de77ae" ) ) );
colorTests.insert( "test_cc2", qMakePair( 0.66, QColor( "#b8e186" ) ) );
}
// if ( QgsCptCityColorRampV2::hasAllSchemes() )
// {
colorRampsTest << "test_cc1";
colorTests.insert( "test_cc1", qMakePair( 0.25, QColor( "#466fcf" ) ) );
colorTests.insert( "test_cc1", qMakePair( 0.66, QColor( "#dbc85b" ) ) );
colorRampsTest << "test_cc2";
colorTests.insert( "test_cc2", qMakePair( 0.25, QColor( "#de77ae" ) ) );
colorTests.insert( "test_cc2", qMakePair( 0.66, QColor( "#b8e186" ) ) );
// }

foreach ( QString name, colorRampsTest )
{
Expand Down
64 changes: 64 additions & 0 deletions tests/testdata/cpt-city/cb/COPYING.xml
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<copying>
<authors>
<author href="http://www.personal.psu.edu/cab38/">
<name>Cynthia Brewer</name>
<org>Pennsylvania State University</org>
</author>
<author href="http://www.geography.wisc.edu/~harrower/">
<name>Mark Harrower</name>
<org>University of Wisconsin-Madison</org>
</author>
</authors>
<license>
<informal>Apache-style</informal>
<year>2002</year>
<text>
Apache-Style Software License for ColorBrewer software and ColorBrewer
Color Schemes

Version 1.1

Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania
State University. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions as source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. The end-user documentation included with the redistribution, if any,
must include the following acknowledgment:

"This product includes color specifications and designs developed by
Cynthia Brewer (http://colorbrewer.org/)."

Alternately, this acknowledgment may appear in the software
itself, if and wherever such third-party acknowledgments normally appear.

4. The name "ColorBrewer" must not be used to endorse or promote products derived
from this software without prior written permission. For written permission, please
contact Cynthia Brewer at cbrewer@psu.edu.

5. Products derived from this software may not be called "ColorBrewer", nor may "ColorBrewer"
appear in their name, without prior written permission of Cynthia Brewer.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CYNTHIA BREWER, MARK HARROWER, OR THE
PENNSYLVANIA STATE UNIVERSITY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</text>
</license>
<src>
<format>Excel spreadsheet</format>
<link href="http://colorbrewer2.org/">ColorBrewer site</link>
<link href="http://www.personal.psu.edu/cab38/ColorBrewer/ColorBrewer_RGB.html">
Excel spreadsheet download</link>
</src>
</copying>
11 changes: 11 additions & 0 deletions tests/testdata/cpt-city/cb/DESC.xml
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<description>
<dir>cb</dir>
<name>Colour schemes by Cynthia Brewer</name>
<full>
Colour schemes were designed by Cynthia Brewer,
Associate Professor of Geography at the Pennsylvania
State University.
</full>
<date>01/08/2012</date>
</description>
9 changes: 9 additions & 0 deletions tests/testdata/cpt-city/cb/div/DESC.xml
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<description>
<dir>div</dir>
<name>Diverging</name>
<full>
Diverging colour schemes designed by Cynthia Brewer
</full>
<date>01/08/2012</date>
</description>
15 changes: 15 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_03.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_04.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_05.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_06.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_07.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_08.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_09.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_10.svg
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 6861078

Please sign in to comment.