mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -04:00
Update/enhance unit tests for CRS validation
This commit is contained in:
parent
b6596cde30
commit
c43381139a
@ -99,8 +99,23 @@ class TestQgsCoordinateReferenceSystem: public QObject
|
|||||||
QStringList myAuthIdStrings;
|
QStringList myAuthIdStrings;
|
||||||
QString mTempFolder;
|
QString mTempFolder;
|
||||||
QString testESRIWkt( int i, QgsCoordinateReferenceSystem &crs );
|
QString testESRIWkt( int i, QgsCoordinateReferenceSystem &crs );
|
||||||
|
|
||||||
|
static bool sValidateCalled;
|
||||||
|
|
||||||
|
static void testValidationCrs( QgsCoordinateReferenceSystem &crs )
|
||||||
|
{
|
||||||
|
sValidateCalled = true;
|
||||||
|
|
||||||
|
crs.createFromString( QStringLiteral( "EPSG:3111" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void testNoActionValidationCrs( QgsCoordinateReferenceSystem & )
|
||||||
|
{
|
||||||
|
sValidateCalled = true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool TestQgsCoordinateReferenceSystem::sValidateCalled = false;
|
||||||
|
|
||||||
void TestQgsCoordinateReferenceSystem::initTestCase()
|
void TestQgsCoordinateReferenceSystem::initTestCase()
|
||||||
{
|
{
|
||||||
@ -625,6 +640,7 @@ void TestQgsCoordinateReferenceSystem::fromStringCache()
|
|||||||
QgsCoordinateReferenceSystem::invalidateCache();
|
QgsCoordinateReferenceSystem::invalidateCache();
|
||||||
QVERIFY( !QgsCoordinateReferenceSystem::sStringCache.contains( "EPSG:3113" ) );
|
QVERIFY( !QgsCoordinateReferenceSystem::sStringCache.contains( "EPSG:3113" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsCoordinateReferenceSystem::isValid()
|
void TestQgsCoordinateReferenceSystem::isValid()
|
||||||
{
|
{
|
||||||
QgsCoordinateReferenceSystem myCrs;
|
QgsCoordinateReferenceSystem myCrs;
|
||||||
@ -632,14 +648,36 @@ void TestQgsCoordinateReferenceSystem::isValid()
|
|||||||
QVERIFY( myCrs.isValid() );
|
QVERIFY( myCrs.isValid() );
|
||||||
debugPrint( myCrs );
|
debugPrint( myCrs );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsCoordinateReferenceSystem::validate()
|
void TestQgsCoordinateReferenceSystem::validate()
|
||||||
{
|
{
|
||||||
QgsCoordinateReferenceSystem myCrs;
|
// no validator set
|
||||||
myCrs.createFromSrid( GEOSRID );
|
QgsCoordinateReferenceSystem::setCustomCrsValidation( nullptr );
|
||||||
|
QgsCoordinateReferenceSystem myCrs( QStringLiteral( "EPSG:28356" ) );
|
||||||
myCrs.validate();
|
myCrs.validate();
|
||||||
QVERIFY( myCrs.isValid() );
|
QVERIFY( myCrs.isValid() );
|
||||||
debugPrint( myCrs );
|
QCOMPARE( myCrs.authid(), QStringLiteral( "EPSG:28356" ) );
|
||||||
|
myCrs = QgsCoordinateReferenceSystem();
|
||||||
|
myCrs.validate();
|
||||||
|
// no change, no custom function
|
||||||
|
QVERIFY( !myCrs.isValid() );
|
||||||
|
|
||||||
|
QgsCoordinateReferenceSystem::setCustomCrsValidation( &TestQgsCoordinateReferenceSystem::testValidationCrs );
|
||||||
|
myCrs.validate();
|
||||||
|
QVERIFY( myCrs.isValid() );
|
||||||
|
QCOMPARE( myCrs.authid(), QStringLiteral( "EPSG:3111" ) );
|
||||||
|
QVERIFY( sValidateCalled );
|
||||||
|
sValidateCalled = false;
|
||||||
|
|
||||||
|
myCrs = QgsCoordinateReferenceSystem();
|
||||||
|
QgsCoordinateReferenceSystem::setCustomCrsValidation( &TestQgsCoordinateReferenceSystem::testNoActionValidationCrs );
|
||||||
|
myCrs.validate();
|
||||||
|
QVERIFY( !myCrs.isValid() );
|
||||||
|
QVERIFY( sValidateCalled );
|
||||||
|
|
||||||
|
QgsCoordinateReferenceSystem::setCustomCrsValidation( nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsCoordinateReferenceSystem::equality()
|
void TestQgsCoordinateReferenceSystem::equality()
|
||||||
{
|
{
|
||||||
QgsCoordinateReferenceSystem myCrs;
|
QgsCoordinateReferenceSystem myCrs;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user