def testPartCount(self): # Create rulebased style sym1 = QgsFillSymbol.createSimple({'color': '#fdbf6f', 'outline_color': 'black'}) renderer = QgsSingleSymbolRenderer(sym1) renderer.symbols(QgsRenderContext())[0].symbolLayers()[0].setDataDefinedProperty(QgsSymbolLayer.PropertyFillColor, QgsProperty.fromExpression('color_rgb( (@geometry_part_count - 1) * 200, 0, 0 )')) self.layer.setRenderer(renderer) # Setup rendering check renderchecker = QgsMultiRenderChecker() renderchecker.setMapSettings(self.mapsettings) renderchecker.setControlName('expected_geometry_part_count') result = renderchecker.runTest('part_geometry_part_count') self.assertTrue(result)
def testSymbolColor(self): # Create rulebased style sym1 = QgsFillSymbol.createSimple({'color': '#ff0000', 'outline_color': 'black'}) renderer = QgsSingleSymbolRenderer(sym1) renderer.symbols(QgsRenderContext())[0].symbolLayers()[0].setDataDefinedProperty(QgsSymbolLayer.PropertyFillColor, QgsProperty.fromExpression('set_color_part( @symbol_color, \'value\', "Value" * 4)')) self.layer.setRenderer(renderer) # Setup rendering check renderchecker = QgsMultiRenderChecker() renderchecker.setMapSettings(self.mapsettings) renderchecker.setControlName('expected_symbol_color_variable') result = renderchecker.runTest('symbol_color_variable', 50) self.assertTrue(result)
def testPartCount(self): # Create rulebased style sym1 = QgsFillSymbol.createSimple({"color": "#fdbf6f"}) renderer = QgsSingleSymbolRenderer(sym1) renderer.symbols()[0].symbolLayers()[0].setDataDefinedProperty( "color", "color_rgb( (@geometry_part_count - 1) * 200, 0, 0 )" ) self.layer.setRenderer(renderer) # Setup rendering check renderchecker = QgsMultiRenderChecker() renderchecker.setMapSettings(self.mapsettings) renderchecker.setControlName("expected_geometry_part_count") result = renderchecker.runTest("part_geometry_part_count") self.assertTrue(result)
def testSymbolColor(self): # Create rulebased style sym1 = QgsFillSymbol.createSimple({"color": "#ff0000"}) renderer = QgsSingleSymbolRenderer(sym1) renderer.symbols()[0].symbolLayers()[0].setDataDefinedProperty( "color", "set_color_part( @symbol_color, 'value', \"Value\" * 4)" ) self.layer.setRenderer(renderer) # Setup rendering check renderchecker = QgsMultiRenderChecker() renderchecker.setMapSettings(self.mapsettings) renderchecker.setControlName("expected_symbol_color_variable") result = renderchecker.runTest("symbol_color_variable", 50) self.assertTrue(result)
def testPartCount(self): # Create rulebased style sym1 = QgsFillSymbol.createSimple({ 'color': '#fdbf6f', 'outline_color': 'black' }) renderer = QgsSingleSymbolRenderer(sym1) renderer.symbols( QgsRenderContext())[0].symbolLayers()[0].setDataDefinedProperty( QgsSymbolLayer.PropertyFillColor, QgsProperty.fromExpression( 'color_rgb( (@geometry_part_count - 1) * 200, 0, 0 )')) self.layer.setRenderer(renderer) # Setup rendering check renderchecker = QgsMultiRenderChecker() renderchecker.setMapSettings(self.mapsettings) renderchecker.setControlName('expected_geometry_part_count') result = renderchecker.runTest('part_geometry_part_count') self.assertTrue(result)
def testSymbolColor(self): # Create rulebased style sym1 = QgsFillSymbol.createSimple({ 'color': '#ff0000', 'outline_color': 'black' }) renderer = QgsSingleSymbolRenderer(sym1) renderer.symbols( QgsRenderContext())[0].symbolLayers()[0].setDataDefinedProperty( QgsSymbolLayer.PropertyFillColor, QgsProperty.fromExpression( 'set_color_part( @symbol_color, \'value\', "Value" * 4)')) self.layer.setRenderer(renderer) # Setup rendering check renderchecker = QgsMultiRenderChecker() renderchecker.setMapSettings(self.mapsettings) renderchecker.setControlName('expected_symbol_color_variable') result = renderchecker.runTest('symbol_color_variable', 50) self.assertTrue(result)