Skip to content

Commit

Permalink
Merge remote-tracking branch 'rouault/fix_qt5_wfs_ogcutils_tests'
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed May 15, 2016
2 parents 63cab56 + 9a49c6a commit c4819ad
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 44 deletions.
2 changes: 0 additions & 2 deletions ci/travis/linux/qt5/blacklist.txt
Expand Up @@ -15,8 +15,6 @@ PyQgsSipCoverage
PyQgsSpatialiteProvider PyQgsSpatialiteProvider
PyQgsVirtualLayerDefinition PyQgsVirtualLayerDefinition
PyQgsVirtualLayerProvider PyQgsVirtualLayerProvider
PyQgsWFSProvider
PyQgsWFSProviderGUI
qgis_composermapgridtest qgis_composermapgridtest
qgis_composertabletest qgis_composertabletest
qgis_composertablev2test qgis_composertablev2test
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wfs/qgswfssourceselect.cpp
Expand Up @@ -277,7 +277,7 @@ void QgsWFSSourceSelect::capabilitiesReplyFinished()
treeView->setColumnWidth( MODEL_IDX_ABSTRACT, 150 ); treeView->setColumnWidth( MODEL_IDX_ABSTRACT, 150 );
} }
btnChangeSpatialRefSys->setEnabled( true ); btnChangeSpatialRefSys->setEnabled( true );
treeView->selectionModel()->select( mModel->index( 0, 0 ), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows ); treeView->selectionModel()->setCurrentIndex( mModelProxy->index( 0, 0 ), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows );
treeView->setFocus(); treeView->setFocus();
} }
else else
Expand Down
24 changes: 11 additions & 13 deletions tests/src/core/testqgsogcutils.cpp
Expand Up @@ -32,6 +32,9 @@ class TestQgsOgcUtils : public QObject


void initTestCase() void initTestCase()
{ {
// Needed on Qt 5 so that the serialization of XML is consistant among all executions
qputenv( "QT_HASH_SEED", "1" );

// //
// Runs once before any tests are run // Runs once before any tests are run
// //
Expand All @@ -57,10 +60,8 @@ class TestQgsOgcUtils : public QObject
void testExpressionToOgcFilterWFS11(); void testExpressionToOgcFilterWFS11();
void testExpressionToOgcFilterWFS11_data(); void testExpressionToOgcFilterWFS11_data();


#if QT_VERSION < 0x050000
void testExpressionToOgcFilterWFS20(); void testExpressionToOgcFilterWFS20();
void testExpressionToOgcFilterWFS20_data(); void testExpressionToOgcFilterWFS20_data();
#endif


void testSQLStatementToOgcFilter(); void testSQLStatementToOgcFilter();
void testSQLStatementToOgcFilter_data(); void testSQLStatementToOgcFilter_data();
Expand Down Expand Up @@ -428,8 +429,12 @@ void TestQgsOgcUtils::testExpressionToOgcFilterWFS11_data()
"</ogc:Filter>" ); "</ogc:Filter>" );
} }


// There's an issue with QT 5 that appears to reverse the order of multiple attributes static QString normalizeXML( const QString& xmlText )
#if QT_VERSION < 0x050000 {
QDomDocument doc;
doc.setContent( xmlText, true );
return doc.toString( -1 );
}


void TestQgsOgcUtils::testExpressionToOgcFilterWFS20() void TestQgsOgcUtils::testExpressionToOgcFilterWFS20()
{ {
Expand All @@ -456,7 +461,7 @@ void TestQgsOgcUtils::testExpressionToOgcFilterWFS20()
qDebug( "SRSNAME: %s", srsName.toAscii().data() ); qDebug( "SRSNAME: %s", srsName.toAscii().data() );
qDebug( "OGC : %s", doc.toString( -1 ).toAscii().data() ); qDebug( "OGC : %s", doc.toString( -1 ).toAscii().data() );


QCOMPARE( xmlText, doc.toString( -1 ) ); QCOMPARE( normalizeXML( xmlText ), normalizeXML( doc.toString( -1 ) ) );
} }


void TestQgsOgcUtils::testExpressionToOgcFilterWFS20_data() void TestQgsOgcUtils::testExpressionToOgcFilterWFS20_data()
Expand Down Expand Up @@ -504,8 +509,6 @@ void TestQgsOgcUtils::testExpressionToOgcFilterWFS20_data()
"</fes:Filter>" ); "</fes:Filter>" );
} }


#endif

Q_DECLARE_METATYPE( QgsOgcUtils::GMLVersion ) Q_DECLARE_METATYPE( QgsOgcUtils::GMLVersion )
Q_DECLARE_METATYPE( QgsOgcUtils::FilterVersion ) Q_DECLARE_METATYPE( QgsOgcUtils::FilterVersion )
Q_DECLARE_METATYPE( QList<QgsOgcUtils::LayerProperties> ) Q_DECLARE_METATYPE( QList<QgsOgcUtils::LayerProperties> )
Expand Down Expand Up @@ -558,7 +561,7 @@ void TestQgsOgcUtils::testSQLStatementToOgcFilter()
filterVersion == QgsOgcUtils::FILTER_FES_2_0 ? "FES 2.0" : "unknown" ); filterVersion == QgsOgcUtils::FILTER_FES_2_0 ? "FES 2.0" : "unknown" );
qDebug( "OGC : %s", doc.toString( -1 ).toAscii().data() ); qDebug( "OGC : %s", doc.toString( -1 ).toAscii().data() );


QCOMPARE( doc.toString( -1 ), xmlText ); QCOMPARE( normalizeXML( xmlText ), normalizeXML( doc.toString( -1 ) ) );
} }


void TestQgsOgcUtils::testSQLStatementToOgcFilter_data() void TestQgsOgcUtils::testSQLStatementToOgcFilter_data()
Expand Down Expand Up @@ -742,9 +745,6 @@ void TestQgsOgcUtils::testSQLStatementToOgcFilter_data()
"</ogc:BBOX>" "</ogc:BBOX>"
"</ogc:Filter>" ); "</ogc:Filter>" );


// There's an issue with QT 5 that appears to reverse the order of multiple attributes
#if QT_VERSION < 0x050000

QTest::newRow( "intersects + wkt + explicit srs" ) << QString( "SELECT * FROM t WHERE ST_Intersects(geom, ST_GeometryFromText('POINT (5 6)', 'urn:ogc:def:crs:EPSG::4326'))" ) << QTest::newRow( "intersects + wkt + explicit srs" ) << QString( "SELECT * FROM t WHERE ST_Intersects(geom, ST_GeometryFromText('POINT (5 6)', 'urn:ogc:def:crs:EPSG::4326'))" ) <<
QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString(
"<fes:Filter xmlns:fes=\"http://www.opengis.net/fes/2.0\" xmlns:gml=\"http://www.opengis.net/gml/3.2\">" "<fes:Filter xmlns:fes=\"http://www.opengis.net/fes/2.0\" xmlns:gml=\"http://www.opengis.net/gml/3.2\">"
Expand Down Expand Up @@ -852,9 +852,7 @@ void TestQgsOgcUtils::testSQLStatementToOgcFilter_data()
"</fes:PropertyIsEqualTo>" "</fes:PropertyIsEqualTo>"
"</fes:And>" "</fes:And>"
"</fes:Filter>" ); "</fes:Filter>" );
#endif
} }



QTEST_MAIN( TestQgsOgcUtils ) QTEST_MAIN( TestQgsOgcUtils )
#include "testqgsogcutils.moc" #include "testqgsogcutils.moc"

0 comments on commit c4819ad

Please sign in to comment.