|
26 | 26 | __revision__ = '$Format:%H$' |
27 | 27 |
|
28 | 28 | from qgis.testing import start_app, unittest |
29 | | -from qgis.core import QgsApplication |
| 29 | +from qgis.core import (QgsApplication, |
| 30 | + QgsCoordinateReferenceSystem, |
| 31 | + QgsProcessingParameterMatrix, |
| 32 | + QgsVectorLayer) |
30 | 33 | from qgis.analysis import QgsNativeAlgorithms |
31 | 34 |
|
32 | 35 | from processing.gui.AlgorithmDialog import AlgorithmDialog |
@@ -115,12 +118,34 @@ def testField(self): |
115 | 118 | def testSource(self): |
116 | 119 | self.checkConstructWrapper(QgsProcessingParameterFeatureSource('test'), FeatureSourceWidgetWrapper) |
117 | 120 |
|
118 | | - def testSource(self): |
119 | | - self.checkConstructWrapper(QgsProcessingParameterBand('test'), BandWidgetWrapper) |
120 | | - |
121 | 121 | def testMapLayer(self): |
122 | 122 | self.checkConstructWrapper(QgsProcessingParameterMapLayer('test'), MapLayerWidgetWrapper) |
123 | 123 |
|
| 124 | + def testMatrix(self): |
| 125 | + self.checkConstructWrapper(QgsProcessingParameterMatrix('test'), FixedTableWidgetWrapper) |
| 126 | + |
| 127 | + alg = QgsApplication.processingRegistry().algorithmById('native:centroids') |
| 128 | + dlg = AlgorithmDialog(alg) |
| 129 | + param = QgsProcessingParameterMatrix('test', 'test', 2, True, ['x', 'y'], [['a', 'b'], ['c', 'd']]) |
| 130 | + wrapper = FixedTableWidgetWrapper(param, dlg) |
| 131 | + widget = wrapper.createWidget() |
| 132 | + |
| 133 | + # check that default value is initially set |
| 134 | + self.assertEqual(wrapper.value(), [['a', 'b'], ['c', 'd']]) |
| 135 | + |
| 136 | + # test widget |
| 137 | + widget.show() |
| 138 | + wrapper.setValue([[1, 2], [3, 4]]) |
| 139 | + self.assertEqual(wrapper.value(), [[1, 2], [3, 4]]) |
| 140 | + |
| 141 | + widget.deleteLater() |
| 142 | + |
| 143 | + def testNumber(self): |
| 144 | + self.checkConstructWrapper(QgsProcessingParameterNumber('test'), NumberWidgetWrapper) |
| 145 | + |
| 146 | + def testBand(self): |
| 147 | + self.checkConstructWrapper(QgsProcessingParameterBand('test'), BandWidgetWrapper) |
| 148 | + |
124 | 149 |
|
125 | 150 | if __name__ == '__main__': |
126 | 151 | unittest.main() |
0 commit comments