Skip to content
Permalink
Browse files

Fix initial display of output widget set to temporary output

  • Loading branch information
nyalldawson committed Mar 17, 2020
1 parent a7f33be commit 813c9afa89b3d57f48f2fd7b0d31702e83c492a1
Showing with 25 additions and 6 deletions.
  1. +1 −1 src/gui/processing/qgsprocessingoutputdestinationwidget.cpp
  2. +24 −5 tests/src/gui/testprocessinggui.cpp
@@ -82,7 +82,7 @@ void QgsProcessingLayerOutputDestinationWidget::setValue( const QVariant &value
else if ( value.canConvert< QgsProcessingOutputLayerDefinition >() )
{
const QgsProcessingOutputLayerDefinition def = value.value< QgsProcessingOutputLayerDefinition >();
if ( def.sink.staticValue().toString() == QStringLiteral( "memory:" ) || def.sink.staticValue().toString().isEmpty() )
if ( def.sink.staticValue().toString() == QStringLiteral( "memory:" ) || def.sink.staticValue().toString() == QgsProcessing::TEMPORARY_OUTPUT || def.sink.staticValue().toString().isEmpty() )
{
saveToTemporary();
}
@@ -5237,10 +5237,21 @@ void TestProcessingGui::testOutputDefinitionWidget()
QCOMPARE( skipSpy.count(), 0 );
QCOMPARE( changedSpy.count(), 0 );

QgsProcessingOutputLayerDefinition def;
def.sink.setStaticValue( QgsProcessing::TEMPORARY_OUTPUT );
def.createOptions.insert( QStringLiteral( "fileEncoding" ), QStringLiteral( "utf8" ) );
panel.setValue( def );
QCOMPARE( skipSpy.count(), 0 );
QCOMPARE( changedSpy.count(), 0 );
v = panel.value();
QVERIFY( v.canConvert< QgsProcessingOutputLayerDefinition>() );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT );

panel.setValue( QStringLiteral( "memory:" ) );
v = panel.value();
QVERIFY( v.canConvert< QgsProcessingOutputLayerDefinition>() );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "System" ) );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT );
QVERIFY( !panel.outputIsSkipped() );
QCOMPARE( skipSpy.count(), 0 );
@@ -5249,13 +5260,21 @@ void TestProcessingGui::testOutputDefinitionWidget()
QCOMPARE( skipSpy.count(), 0 );
QCOMPARE( changedSpy.count(), 0 );

def.sink.setStaticValue( QStringLiteral( "memory:" ) );
panel.setValue( def );
QCOMPARE( skipSpy.count(), 0 );
QCOMPARE( changedSpy.count(), 0 );
v = panel.value();
QVERIFY( v.canConvert< QgsProcessingOutputLayerDefinition>() );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT );

panel.setValue( QStringLiteral( "ogr:dbname='/me/a.gpkg' table=\"d\" (geom) sql=''" ) );
QCOMPARE( skipSpy.count(), 0 );
QCOMPARE( changedSpy.count(), 1 );
v = panel.value();
QVERIFY( v.canConvert< QgsProcessingOutputLayerDefinition>() );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "System" ) );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QStringLiteral( "ogr:dbname='/me/a.gpkg' table=\"d\" (geom) sql=''" ) );
QVERIFY( !panel.outputIsSkipped() );
panel.setValue( QStringLiteral( "ogr:dbname='/me/a.gpkg' table=\"d\" (geom) sql=''" ) );
@@ -5265,7 +5284,7 @@ void TestProcessingGui::testOutputDefinitionWidget()
panel.setValue( QStringLiteral( "postgis:dbname='oraclesux' host=10.1.1.221 port=5432 user='qgis' password='qgis' table=\"stufff\".\"output\" (the_geom) sql=" ) );
v = panel.value();
QVERIFY( v.canConvert< QgsProcessingOutputLayerDefinition>() );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "System" ) );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QStringLiteral( "postgis:dbname='oraclesux' host=10.1.1.221 port=5432 user='qgis' password='qgis' table=\"stufff\".\"output\" (the_geom) sql=" ) );
QVERIFY( !panel.outputIsSkipped() );
QCOMPARE( skipSpy.count(), 0 );
@@ -5277,7 +5296,7 @@ void TestProcessingGui::testOutputDefinitionWidget()
panel.setValue( QStringLiteral( "/home/me/test.shp" ) );
v = panel.value();
QVERIFY( v.canConvert< QgsProcessingOutputLayerDefinition>() );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "System" ) );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QStringLiteral( "/home/me/test.shp" ) );
QVERIFY( !panel.outputIsSkipped() );
QCOMPARE( skipSpy.count(), 0 );
@@ -5294,7 +5313,7 @@ void TestProcessingGui::testOutputDefinitionWidget()
panel.setValue( QStringLiteral( "test.shp" ) );
v = panel.value();
QVERIFY( v.canConvert< QgsProcessingOutputLayerDefinition>() );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "System" ) );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) );
QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), TEST_DATA_DIR + QStringLiteral( "/test.shp" ) );

// optional, test skipping

0 comments on commit 813c9af

Please sign in to comment.
You can’t perform that action at this time.