def testDraw(self):
        canvas = Canvas(0, 1)
        canvas.effect = Effect()
        canvas.document = canvas.effect.parse(
            "TestFiles/unit_test_svg_abstractShape_transformado.svg")
        canvas.root = canvas.effect.document.getroot()
        canvas.node = self.returnsGnode(canvas.root, "rect")
        rect = Rect("rect", canvas.node, canvas, None)

        rect.draw()

        self.assertEqual(rect.canvasContext.code, [
            '\tctx.transform(1.000000, 0.000000, 0.380253, 0.924882, 0.000000, 0.000000);\n',
            "\tctx.lineJoin = 'miter';\n",
            "\tctx.strokeStyle = 'rgb(0, 0, 0)';\n",
            "\tctx.lineCap = 'butt';\n", '\tctx.lineWidth = 1.012632;\n',
            "\tctx.fillStyle = 'rgb(0, 0, 255)';\n", '\tctx.beginPath();\n',
            '\tctx.moveTo(-60.184902, 299.915122);\n',
            '\tctx.lineTo(-60.184902, 677.860048);\n',
            '\tctx.quadraticCurveTo(-60.184902, 683.719660, -60.184902, 683.719660);\n',
            '\tctx.lineTo(431.239998, 683.719660);\n',
            '\tctx.quadraticCurveTo(431.239998, 683.719660, 431.239998, 677.860048);\n',
            '\tctx.lineTo(431.239998, 299.915122);\n',
            '\tctx.quadraticCurveTo(431.239998, 294.055510, 431.239998, 294.055510);\n',
            '\tctx.lineTo(-60.184902, 294.055510);\n',
            '\tctx.quadraticCurveTo(-60.184902, 294.055510, -60.184902, 299.915122);\n',
            '\tctx.fill();\n', '\tctx.stroke();\n'
        ])
 def testDraw(self):
     canvas = Canvas(0,1)
     canvas.effect = Effect()
     canvas.document = canvas.effect.parse("TestFiles/unit_test_svg_abstractShape_transformado.svg")
     canvas.root = canvas.effect.document.getroot()
     canvas.node = self.returnsGnode(canvas.root,"rect")
     rect = Rect("rect",canvas.node,canvas, None)
     
     rect.draw()
     
     self.assertEqual(rect.canvasContext.code,['\tctx.transform(1.000000, 0.000000, 0.380253, 0.924882, 0.000000, 0.000000);\n', "\tctx.lineJoin = 'miter';\n", "\tctx.strokeStyle = 'rgb(0, 0, 0)';\n", "\tctx.lineCap = 'butt';\n", '\tctx.lineWidth = 1.012632;\n', "\tctx.fillStyle = 'rgb(0, 0, 255)';\n", '\tctx.beginPath();\n', '\tctx.moveTo(-60.184902, 299.915122);\n', '\tctx.lineTo(-60.184902, 677.860048);\n', '\tctx.quadraticCurveTo(-60.184902, 683.719660, -60.184902, 683.719660);\n', '\tctx.lineTo(431.239998, 683.719660);\n', '\tctx.quadraticCurveTo(431.239998, 683.719660, 431.239998, 677.860048);\n', '\tctx.lineTo(431.239998, 299.915122);\n', '\tctx.quadraticCurveTo(431.239998, 294.055510, 431.239998, 294.055510);\n', '\tctx.lineTo(-60.184902, 294.055510);\n', '\tctx.quadraticCurveTo(-60.184902, 294.055510, -60.184902, 299.915122);\n', '\tctx.fill();\n', '\tctx.stroke();\n'])
 def testExitWithRxRy(self):
     self.document = self.effect.parse("TestFiles/unit_test_svg_Rect_ComRxRy.svg")
     root = self.effect.document.getroot()
     self.rect = Rect(None, self.node, self.canvas, None)
     self.rect.node = self.findNodeInG(root, 'rect')
     x, y, w, h, rx, ry = self.rect.getData()
     self.assertEqual(x, 40.0)
     self.assertEqual(y, 30.0)
     self.assertEqual(w, 100.0)
     self.assertEqual(h, 150.0)
     self.assertEqual(rx, 5.0)
     self.assertEqual(ry, 10.0)
示例#4
0
class TestRect(unittest.TestCase):
    def setUp(self):
        self.effect = Effect()
        self.document = None
        self.effect.parse("TestFiles/unit_test_svg_Rect_WithRxRy.svg")
        self.node = None
        self.canvas = Canvas(0, 0)

    def findNodeInG(self, root, tag):
        for node in root:
            nodeTag = node.tag.split("}")[1]
            if (nodeTag == 'g'):
                root = node
                break
        for node in root:
            nodeTag = node.tag.split("}")[1]
            if (nodeTag == tag):
                return node

    def testExitWithoutRxRy(self):
        self.document = self.effect.parse(
            "TestFiles/unit_test_svg_Rect_WithoutRxRy.svg")
        root = self.effect.document.getroot()
        self.rect = Rect(None, self.node, self.canvas, None)
        self.rect.node = self.findNodeInG(root, 'rect')
        x, y, w, h, rx, ry = self.rect.getData()
        self.assertEqual(x, 40.0)
        self.assertEqual(y, 30.0)
        self.assertEqual(w, 100.0)
        self.assertEqual(h, 150.0)
        self.assertEqual(rx, 0)
        self.assertEqual(ry, 0)

    def testExitWithRxRy(self):
        self.document = self.effect.parse(
            "TestFiles/unit_test_svg_Rect_WithRxRy.svg")
        root = self.effect.document.getroot()
        self.rect = Rect(None, self.node, self.canvas, None)
        self.rect.node = self.findNodeInG(root, 'rect')
        x, y, w, h, rx, ry = self.rect.getData()
        self.assertEqual(x, 40.0)
        self.assertEqual(y, 30.0)
        self.assertEqual(w, 100.0)
        self.assertEqual(h, 150.0)
        self.assertEqual(rx, 5.0)
        self.assertEqual(ry, 10.0)
class TestRect(unittest.TestCase):
    def setUp(self):
        self.effect = Effect()
        self.document = None
        self.effect.parse("TestFiles/unit_test_svg_Rect_WithRxRy.svg")
        self.node = None
        self.canvas = Canvas(0, 0)
              
    def findNodeInG(self, root, tag):
        for node in root:
            nodeTag = node.tag.split("}")[1]
            if(nodeTag == 'g'):
                root = node
                break
        for node in root:
            nodeTag = node.tag.split("}")[1]
            if(nodeTag == tag):
                return node
        
    def testExitWithoutRxRy(self):
        self.document = self.effect.parse("TestFiles/unit_test_svg_Rect_WithoutRxRy.svg")
        root = self.effect.document.getroot()
        self.rect = Rect(None, self.node, self.canvas, None)
        self.rect.node = self.findNodeInG(root, 'rect')
        x, y, w, h, rx, ry = self.rect.getData()
        self.assertEqual(x, 40.0)
        self.assertEqual(y, 30.0)
        self.assertEqual(w, 100.0)
        self.assertEqual(h, 150.0)
        self.assertEqual(rx, 0)
        self.assertEqual(ry, 0)
        
    def testExitWithRxRy(self):
        self.document = self.effect.parse("TestFiles/unit_test_svg_Rect_WithRxRy.svg")
        root = self.effect.document.getroot()
        self.rect = Rect(None, self.node, self.canvas, None)
        self.rect.node = self.findNodeInG(root, 'rect')
        x, y, w, h, rx, ry = self.rect.getData()
        self.assertEqual(x, 40.0)
        self.assertEqual(y, 30.0)
        self.assertEqual(w, 100.0)
        self.assertEqual(h, 150.0)
        self.assertEqual(rx, 5.0)
        self.assertEqual(ry, 10.0)
 def testExitWithRxRy(self):
     self.document = self.effect.parse("TestFiles/unit_test_svg_Rect_WithRxRy.svg")
     root = self.effect.document.getroot()
     self.rect = Rect(None, self.node, self.canvas, None)
     self.rect.node = self.findNodeInG(root, 'rect')
     x, y, w, h, rx, ry = self.rect.getData()
     self.assertEqual(x, 40.0)
     self.assertEqual(y, 30.0)
     self.assertEqual(w, 100.0)
     self.assertEqual(h, 150.0)
     self.assertEqual(rx, 5.0)
     self.assertEqual(ry, 10.0)