Skip to content

Commit

Permalink
Try to fix crash on travis
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 15, 2019
1 parent fbd243b commit b25fa7a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/plugins/processing/tests/GuiTest.py
Expand Up @@ -73,6 +73,9 @@ def checkConstructWrapper(self, param, expected_wrapper_class):
self.assertIsInstance(wrapper, expected_wrapper_class)
self.assertEqual(wrapper.dialog, dlg)
self.assertIsNotNone(wrapper.widget)
wrapper.widget.deleteLater()
del wrapper.widget
del wrapper

alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
# batch dialog
Expand All @@ -94,6 +97,9 @@ def checkConstructWrapper(self, param, expected_wrapper_class):
self.assertEqual(wrapper.dialog, dlg)
self.assertIsNotNone(wrapper.widget)

wrapper.widget.deleteLater()
del wrapper.widget

def testBoolean(self):
self.checkConstructWrapper(QgsProcessingParameterBoolean('test'), BooleanWidgetWrapper)

Expand Down Expand Up @@ -170,6 +176,9 @@ def testSource(self):
value = wrapper.value()
self.assertEqual(value, '/home/my_layer.shp')

widget.deleteLater()
del widget

def testRange(self):
# minimal test to check if wrapper generate GUI for each processign context
self.checkConstructWrapper(QgsProcessingParameterRange('test'), RangeWidgetWrapper)
Expand Down
42 changes: 42 additions & 0 deletions tests/src/gui/testprocessinggui.cpp
Expand Up @@ -3133,6 +3133,8 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( combo->value().value< QgsProcessingFeatureSourceDefinition >().selectedFeaturesOnly );
QVERIFY( combo->currentText().startsWith( vl->name() ) );
QCOMPARE( spy.count(), 13 );
combo.reset();
param.reset();

// setup a project with a range of layer types
QgsProject::instance()->removeAllMapLayers();
Expand Down Expand Up @@ -3166,6 +3168,8 @@ void TestProcessingGui::mapLayerComboBox()
QCOMPARE( combo->currentLayer(), mesh );
combo->setLayer( raster );
QCOMPARE( combo->currentLayer(), raster );
combo.reset();
param.reset();

// raster layer param, only raster types are acceptable
param = qgis::make_unique< QgsProcessingParameterRasterLayer> ( QStringLiteral( "param" ), QString() );
Expand All @@ -3182,6 +3186,8 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo->setLayer( raster );
QCOMPARE( combo->currentLayer(), raster );
combo.reset();
param.reset();

// mesh layer parm, only mesh types are acceptable
param = qgis::make_unique< QgsProcessingParameterMeshLayer> ( QStringLiteral( "param" ), QString() );
Expand All @@ -3198,6 +3204,8 @@ void TestProcessingGui::mapLayerComboBox()
QCOMPARE( combo->currentLayer(), mesh );
combo->setLayer( raster );
QVERIFY( !combo->currentLayer() );
combo.reset();
param.reset();

// feature source and vector layer params
// if not specified, the default is any vector layer with geometry
Expand Down Expand Up @@ -3229,6 +3237,10 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo2->setLayer( raster );
QVERIFY( !combo2->currentLayer() );
combo2.reset();
param2.reset();
combo.reset();
param.reset();

// point layer
param = qgis::make_unique< QgsProcessingParameterVectorLayer> ( QStringLiteral( "param" ), QString(), QList< int>() << QgsProcessing::TypeVectorPoint );
Expand Down Expand Up @@ -3259,6 +3271,10 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo2->setLayer( raster );
QVERIFY( !combo2->currentLayer() );
combo2.reset();
param2.reset();
combo.reset();
param.reset();

// line layer
param = qgis::make_unique< QgsProcessingParameterVectorLayer> ( QStringLiteral( "param" ), QString(), QList< int>() << QgsProcessing::TypeVectorLine );
Expand Down Expand Up @@ -3289,6 +3305,10 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo2->setLayer( raster );
QVERIFY( !combo2->currentLayer() );
combo2.reset();
param2.reset();
combo.reset();
param.reset();

// polygon
param = qgis::make_unique< QgsProcessingParameterVectorLayer> ( QStringLiteral( "param" ), QString(), QList< int>() << QgsProcessing::TypeVectorPolygon );
Expand Down Expand Up @@ -3319,6 +3339,10 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo2->setLayer( raster );
QVERIFY( !combo2->currentLayer() );
combo2.reset();
param2.reset();
combo.reset();
param.reset();

// no geom
param = qgis::make_unique< QgsProcessingParameterVectorLayer> ( QStringLiteral( "param" ), QString(), QList< int>() << QgsProcessing::TypeVector );
Expand Down Expand Up @@ -3349,6 +3373,10 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo2->setLayer( raster );
QVERIFY( !combo2->currentLayer() );
combo2.reset();
param2.reset();
combo.reset();
param.reset();

// any geom
param = qgis::make_unique< QgsProcessingParameterVectorLayer> ( QStringLiteral( "param" ), QString(), QList< int>() << QgsProcessing::TypeVectorAnyGeometry );
Expand Down Expand Up @@ -3379,6 +3407,10 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo2->setLayer( raster );
QVERIFY( !combo2->currentLayer() );
combo2.reset();
param2.reset();
combo.reset();
param.reset();

// combination point and line only
param = qgis::make_unique< QgsProcessingParameterVectorLayer> ( QStringLiteral( "param" ), QString(), QList< int>() << QgsProcessing::TypeVectorPoint << QgsProcessing::TypeVectorLine );
Expand Down Expand Up @@ -3409,6 +3441,10 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo2->setLayer( raster );
QVERIFY( !combo2->currentLayer() );
combo2.reset();
param2.reset();
combo.reset();
param.reset();

// optional
param = qgis::make_unique< QgsProcessingParameterVectorLayer> ( QStringLiteral( "param" ), QString(), QList< int>(), QVariant(), true );
Expand All @@ -3423,6 +3459,12 @@ void TestProcessingGui::mapLayerComboBox()
combo->setValue( QVariant(), context );
QVERIFY( !combo->currentLayer() );
QVERIFY( !combo->value().isValid() );

combo2.reset();
param2.reset();
combo.reset();
param.reset();
QgsProject::instance()->removeAllMapLayers();
}

void TestProcessingGui::cleanupTempDir()
Expand Down

0 comments on commit b25fa7a

Please sign in to comment.