mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Reactivate ogcutils tests and update its
This commit is contained in:
parent
1d6e5d28e6
commit
52a78def7f
@ -21,5 +21,5 @@ export CCACHE_TEMPDIR=/tmp
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
xvfb-run ctest -V -E "qgis_openstreetmaptest|qgis_wcsprovidertest|PyQgsWFSProviderGUI|qgis_ziplayertest|qgis_ogcutilstest|$(cat ${DIR}/blacklist.txt | paste -sd '|' -)" -S ./qgis-test-travis.ctest --output-on-failure
|
||||
xvfb-run ctest -V -E "qgis_openstreetmaptest|qgis_wcsprovidertest|PyQgsWFSProviderGUI|qgis_ziplayertest|$(cat ${DIR}/blacklist.txt | paste -sd '|' -)" -S ./qgis-test-travis.ctest --output-on-failure
|
||||
# xvfb-run ctest -V -E "qgis_openstreetmaptest|qgis_wcsprovidertest" -S ./qgis-test-travis.ctest --output-on-failure
|
||||
|
@ -93,12 +93,126 @@ void TestQgsOgcUtils::testGeometryFromGML()
|
||||
QVERIFY( geomBox.wkbType() == QgsWkbTypes::Polygon );
|
||||
}
|
||||
|
||||
static bool compareElements( QDomElement& element1, QDomElement& element2 )
|
||||
{
|
||||
QString tag1 = element1.tagName();
|
||||
tag1.replace( QRegExp( ".*:" ), "" );
|
||||
QString tag2 = element2.tagName();
|
||||
tag2.replace( QRegExp( ".*:" ), "" );
|
||||
if ( tag1 != tag2 )
|
||||
{
|
||||
qDebug( "Different tag names: %s, %s", tag1.toAscii().data(), tag2.toAscii().data() );
|
||||
return false ;
|
||||
}
|
||||
|
||||
if ( element1.hasAttributes() != element2.hasAttributes() )
|
||||
{
|
||||
qDebug( "Different hasAttributes: %s, %s", tag1.toAscii().data(), tag2.toAscii().data() );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( element1.hasAttributes() )
|
||||
{
|
||||
QDomNamedNodeMap attrs1 = element1.attributes();
|
||||
QDomNamedNodeMap attrs2 = element2.attributes();
|
||||
|
||||
if ( attrs1.size() != attrs2.size() )
|
||||
{
|
||||
qDebug( "Different attributes size: %s, %s", tag1.toAscii().data(), tag2.toAscii().data() );
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( int i = 0 ; i < attrs1.size() ; ++i )
|
||||
{
|
||||
QDomNode node1 = attrs1.item( i );
|
||||
QDomAttr attr1 = node1.toAttr();
|
||||
|
||||
if ( !element2.hasAttribute( attr1.name() ) )
|
||||
{
|
||||
qDebug( "Element2 has not attribute: %s, %s, %s", tag1.toAscii().data(), tag2.toAscii().data(), attr1.name().toAscii().data() );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( element2.attribute( attr1.name() ) != attr1.value() )
|
||||
{
|
||||
qDebug( "Element2 attribute has not the same value: %s, %s, %s", tag1.toAscii().data(), tag2.toAscii().data(), attr1.name().toAscii().data() );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( element1.hasChildNodes() != element2.hasChildNodes() )
|
||||
{
|
||||
qDebug( "Different childNodes: %s, %s", tag1.toAscii().data(), tag2.toAscii().data() );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( element1.hasChildNodes() )
|
||||
{
|
||||
QDomNodeList nodes1 = element1.childNodes();
|
||||
QDomNodeList nodes2 = element2.childNodes();
|
||||
|
||||
if ( nodes1.size() != nodes2.size() )
|
||||
{
|
||||
qDebug( "Different childNodes size: %s, %s", tag1.toAscii().data(), tag2.toAscii().data() );
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( int i = 0 ; i < nodes1.size() ; ++i )
|
||||
{
|
||||
QDomNode node1 = nodes1.at( i );
|
||||
QDomNode node2 = nodes2.at( i );
|
||||
if ( node1.isElement() && node2.isElement() )
|
||||
{
|
||||
QDomElement elt1 = node1.toElement();
|
||||
QDomElement elt2 = node2.toElement();
|
||||
|
||||
if ( !compareElements( elt1, elt2 ) )
|
||||
return false;
|
||||
}
|
||||
else if ( node1.isText() && node2.isText() )
|
||||
{
|
||||
QDomText txt1 = node1.toText();
|
||||
QDomText txt2 = node2.toText();
|
||||
|
||||
if ( txt1.data() != txt2.data() )
|
||||
{
|
||||
qDebug( "Different text data: %s %s", tag1.toAscii().data(), txt1.data().toAscii().data() );
|
||||
qDebug( "Different text data: %s %s", tag2.toAscii().data(), txt2.data().toAscii().data() );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( element1.text() != element2.text() )
|
||||
{
|
||||
qDebug( "Different text: %s %s", tag1.toAscii().data(), element1.text().toAscii().data() );
|
||||
qDebug( "Different text: %s %s", tag2.toAscii().data(), element2.text().toAscii().data() );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
static QDomElement comparableElement( const QString& xmlText )
|
||||
{
|
||||
QDomDocument doc;
|
||||
if ( !doc.setContent( xmlText ) )
|
||||
return QDomElement();
|
||||
return doc.documentElement();
|
||||
}
|
||||
|
||||
|
||||
void TestQgsOgcUtils::testGeometryToGML()
|
||||
{
|
||||
QDomDocument doc;
|
||||
QgsGeometry geomPoint( QgsGeometry::fromPoint( QgsPoint( 111, 222 ) ) );
|
||||
QgsGeometry geomLine( QgsGeometry::fromWkt( "LINESTRING(111 222, 222 222)" ) );
|
||||
|
||||
// Elements to compare
|
||||
QDomElement xmlElem;
|
||||
QDomElement ogcElem;
|
||||
|
||||
// Test GML2
|
||||
QDomElement elemInvalid = QgsOgcUtils::geometryToGML( 0, doc );
|
||||
QVERIFY( elemInvalid.isNull() );
|
||||
@ -107,14 +221,18 @@ void TestQgsOgcUtils::testGeometryToGML()
|
||||
QVERIFY( !elemPoint.isNull() );
|
||||
|
||||
doc.appendChild( elemPoint );
|
||||
QCOMPARE( doc.toString( -1 ), QString( "<gml:Point><gml:coordinates ts=\" \" cs=\",\">111,222</gml:coordinates></gml:Point>" ) );
|
||||
xmlElem = comparableElement( QString( "<gml:Point><gml:coordinates ts=\" \" cs=\",\">111,222</gml:coordinates></gml:Point>" ) );
|
||||
ogcElem = comparableElement( doc.toString( -1 ) );
|
||||
QVERIFY( compareElements( xmlElem, ogcElem ) );
|
||||
doc.removeChild( elemPoint );
|
||||
|
||||
QDomElement elemLine = QgsOgcUtils::geometryToGML( &geomLine, doc );
|
||||
QVERIFY( !elemLine.isNull() );
|
||||
|
||||
doc.appendChild( elemLine );
|
||||
QCOMPARE( doc.toString( -1 ), QString( "<gml:LineString><gml:coordinates ts=\" \" cs=\",\">111,222 222,222</gml:coordinates></gml:LineString>" ) );
|
||||
xmlElem = comparableElement( QString( "<gml:LineString><gml:coordinates ts=\" \" cs=\",\">111,222 222,222</gml:coordinates></gml:LineString>" ) );
|
||||
ogcElem = comparableElement( doc.toString( -1 ) );
|
||||
QVERIFY( compareElements( xmlElem, ogcElem ) );
|
||||
doc.removeChild( elemLine );
|
||||
|
||||
// Test GML3
|
||||
@ -125,14 +243,18 @@ void TestQgsOgcUtils::testGeometryToGML()
|
||||
QVERIFY( !elemPoint.isNull() );
|
||||
|
||||
doc.appendChild( elemPoint );
|
||||
QCOMPARE( doc.toString( -1 ), QString( "<gml:Point><gml:pos srsDimension=\"2\">111 222</gml:pos></gml:Point>" ) );
|
||||
xmlElem = comparableElement( QString( "<gml:Point><gml:pos srsDimension=\"2\">111 222</gml:pos></gml:Point>" ) );
|
||||
ogcElem = comparableElement( doc.toString( -1 ) );
|
||||
QVERIFY( compareElements( xmlElem, ogcElem ) );
|
||||
doc.removeChild( elemPoint );
|
||||
|
||||
elemLine = QgsOgcUtils::geometryToGML( &geomLine, doc, "GML3" );
|
||||
QVERIFY( !elemLine.isNull() );
|
||||
|
||||
doc.appendChild( elemLine );
|
||||
QCOMPARE( doc.toString( -1 ), QString( "<gml:LineString><gml:posList srsDimension=\"2\">111 222 222 222</gml:posList></gml:LineString>" ) );
|
||||
xmlElem = comparableElement( QString( "<gml:LineString><gml:posList srsDimension=\"2\">111 222 222 222</gml:posList></gml:LineString>" ) );
|
||||
ogcElem = comparableElement( doc.toString( -1 ) );
|
||||
QVERIFY( compareElements( xmlElem, ogcElem ) );
|
||||
doc.removeChild( elemLine );
|
||||
}
|
||||
|
||||
@ -287,7 +409,10 @@ void TestQgsOgcUtils::testExpressionToOgcFilter()
|
||||
qDebug( "EXPR: %s", exp.expression().toAscii().data() );
|
||||
qDebug( "OGC : %s", doc.toString( -1 ).toAscii().data() );
|
||||
|
||||
QCOMPARE( xmlText, doc.toString( -1 ) );
|
||||
|
||||
QDomElement xmlElem = comparableElement( xmlText );
|
||||
QDomElement ogcElem = comparableElement( doc.toString( -1 ) );
|
||||
QVERIFY( compareElements( xmlElem, ogcElem ) );
|
||||
}
|
||||
|
||||
void TestQgsOgcUtils::testExpressionToOgcFilter_data()
|
||||
@ -449,7 +574,10 @@ void TestQgsOgcUtils::testExpressionToOgcFilterWFS11()
|
||||
qDebug( "SRSNAME: %s", srsName.toAscii().data() );
|
||||
qDebug( "OGC : %s", doc.toString( -1 ).toAscii().data() );
|
||||
|
||||
QCOMPARE( xmlText, doc.toString( -1 ) );
|
||||
|
||||
QDomElement xmlElem = comparableElement( xmlText );
|
||||
QDomElement ogcElem = comparableElement( doc.toString( -1 ) );
|
||||
QVERIFY( compareElements( xmlElem, ogcElem ) );
|
||||
}
|
||||
|
||||
void TestQgsOgcUtils::testExpressionToOgcFilterWFS11_data()
|
||||
@ -473,14 +601,6 @@ void TestQgsOgcUtils::testExpressionToOgcFilterWFS11_data()
|
||||
"</ogc:Filter>" );
|
||||
}
|
||||
|
||||
static QString normalizeXML( const QString& xmlText )
|
||||
{
|
||||
QDomDocument doc;
|
||||
if ( !doc.setContent( xmlText, true ) )
|
||||
return QString();
|
||||
return doc.toString( -1 );
|
||||
}
|
||||
|
||||
void TestQgsOgcUtils::testExpressionToOgcFilterWFS20()
|
||||
{
|
||||
QFETCH( QString, exprText );
|
||||
@ -506,15 +626,9 @@ void TestQgsOgcUtils::testExpressionToOgcFilterWFS20()
|
||||
qDebug( "SRSNAME: %s", srsName.toAscii().data() );
|
||||
qDebug( "OGC : %s", doc.toString( -1 ).toAscii().data() );
|
||||
|
||||
QString normalizedExpected( normalizeXML( xmlText ) );
|
||||
QString normalizedGot( normalizeXML( doc.toString( -1 ) ) );
|
||||
|
||||
if ( normalizedExpected != normalizedGot )
|
||||
{
|
||||
qDebug( "Normalized expected: %s", normalizedExpected.toAscii().data() );
|
||||
qDebug( "Normalized got: %s", normalizedGot.toAscii().data() );
|
||||
}
|
||||
QCOMPARE( normalizedExpected, normalizedGot );
|
||||
QDomElement xmlElem = comparableElement( xmlText );
|
||||
QDomElement ogcElem = comparableElement( doc.toString( -1 ) );
|
||||
QVERIFY( compareElements( xmlElem, ogcElem ) );
|
||||
}
|
||||
|
||||
void TestQgsOgcUtils::testExpressionToOgcFilterWFS20_data()
|
||||
@ -614,15 +728,9 @@ void TestQgsOgcUtils::testSQLStatementToOgcFilter()
|
||||
filterVersion == QgsOgcUtils::FILTER_FES_2_0 ? "FES 2.0" : "unknown" );
|
||||
qDebug( "OGC : %s", doc.toString( -1 ).toAscii().data() );
|
||||
|
||||
QString normalizedExpected( normalizeXML( xmlText ) );
|
||||
QString normalizedGot( normalizeXML( doc.toString( -1 ) ) );
|
||||
|
||||
if ( normalizedExpected != normalizedGot )
|
||||
{
|
||||
qDebug( "Normalized expected: %s", normalizedExpected.toAscii().data() );
|
||||
qDebug( "Normalized got: %s", normalizedGot.toAscii().data() );
|
||||
}
|
||||
QCOMPARE( normalizedExpected, normalizedGot );
|
||||
QDomElement xmlElem = comparableElement( xmlText );
|
||||
QDomElement ogcElem = comparableElement( doc.toString( -1 ) );
|
||||
QVERIFY( compareElements( xmlElem, ogcElem ) );
|
||||
}
|
||||
|
||||
void TestQgsOgcUtils::testSQLStatementToOgcFilter_data()
|
||||
|
Loading…
x
Reference in New Issue
Block a user