def testNull(self): shape = QgsLegendPatchShape() self.assertTrue(shape.isNull()) shape.setGeometry(QgsGeometry.fromWkt('Multipoint( 1 1, 2 2)')) self.assertFalse(shape.isNull()) shape.setGeometry(QgsGeometry()) self.assertTrue(shape.isNull())
def testBasic(self): shape = QgsLegendPatchShape(QgsSymbol.Line, QgsGeometry.fromWkt('LineString( 0 0, 1 1)'), False) self.assertFalse(shape.isNull()) self.assertEqual(shape.symbolType(), QgsSymbol.Line) self.assertEqual(shape.geometry().asWkt(), 'LineString (0 0, 1 1)') self.assertFalse(shape.preserveAspectRatio()) shape.setSymbolType(QgsSymbol.Marker) self.assertEqual(shape.symbolType(), QgsSymbol.Marker) shape.setGeometry(QgsGeometry.fromWkt('Multipoint( 1 1, 2 2)')) self.assertEqual(shape.geometry().asWkt(), 'MultiPoint ((1 1),(2 2))') shape.setPreserveAspectRatio(True) self.assertTrue(shape.preserveAspectRatio())