示例#1
0
 def create_diagram(self, main_window=None):
     if main_window is None:
         main_window = self.create_main_window()
     diagram = Diagram(main_window)
     diagram.language = "Test"
     diagram.zoom = 2
     diagram.code_template = self.create_code_template()
     return diagram
示例#2
0
    def create_full_diagram(self, main_window=None):
        if main_window is None:
            main_window = self.create_main_window()
        diagram = Diagram(main_window)
        self.assertEquals(diagram.last_id, 0)
        diagram.language = "Test"
        diagram.zoom = 2
        diagram_control = self.create_diagram_control(diagram)

        block0 = self.create_block(diagram_control)
        result = diagram_control.add_block(block0)

        block1 = self.create_block(diagram_control)
        result = diagram_control.add_block(block1)
        assert result

        block2 = self.create_block(diagram_control)
        result = diagram_control.add_block(block2)
        assert result

        connection = ConnectionModel(diagram, block1, block1.ports[0], block2,
                                     block2.ports[0])
        result = diagram_control.add_connection(connection)
        self.assertEquals(result[0], False)

        connection = ConnectionModel(diagram, block1, block1.ports[1], block2,
                                     block2.ports[0])
        result = diagram_control.add_connection(connection)
        self.assertEquals(result[1], "Success")

        connection = ConnectionModel(diagram, block2, block2.ports[1], block1,
                                     block1.ports[1])
        result = diagram_control.add_connection(connection)
        self.assertEquals(result[0], False)

        connection = ConnectionModel(diagram, block1, block1.ports[1], block1,
                                     block1.ports[0])
        result = diagram_control.add_connection(connection)
        self.assertEquals(result[0], False)

        connection = ConnectionModel(diagram, None, None, None, None)
        result = diagram_control.add_connection(connection)
        self.assertEquals(result[0], False)

        comment = self.create_comment(diagram)
        diagram_control.add_comment(comment)
        comment = self.create_comment(diagram)
        diagram_control.add_comment(comment)
        diagram.code_template = self.create_code_template()
        return diagram