예제 #1
0
 def setUp(self):
     TestCase.setUp(self)
     diagram = self.diagram
     tab = DiagramTab(WindowOwner())
     tab.diagram = diagram
     tab.construct()
     self.tab = tab
예제 #2
0
 def setUp(self):
     TestCase.setUp(self)
     diagram = self.diagram
     tab = DiagramTab(WindowOwner())
     tab.diagram = diagram
     tab.construct()
     self.tab = tab
예제 #3
0
    def show_diagram(self, diagram):
        """
        Show a Diagram element in a new tab.
        If a tab is already open, show that one instead.
        """
        # Try to find an existing window/tab and let it get focus:
        for tab in self.get_tabs():
            if tab.get_diagram() is diagram:
                self.set_current_page(tab)
                return tab

        tab = DiagramTab(diagram)
        dock_item = tab.construct()
        dock_item.set_name('diagram-tab')
        dock_item.diagram_tab = tab
        assert dock_item.get_name() == 'diagram-tab'
        tab.set_drawing_style(self.properties('diagram.sloppiness', 0))

        self.add_tab(dock_item)

        return tab
예제 #4
0
class DiagramTabTestCase(unittest.TestCase):

    def setUp(self):
        Application.init(services=['element_factory', 'main_window', 'action_manager', 'properties', 'element_dispatcher'])
        main_window = Application.get_service('main_window')
        element_factory = Application.get_service('element_factory')
        self.element_factory = element_factory
        self.diagram = element_factory.create(UML.Diagram)
        self.tab = DiagramTab(main_window)
        self.tab.set_diagram(self.diagram)
        self.assertEquals(self.tab.diagram, self.diagram)
        widget = self.tab.construct()
        main_window.add_tab(self.tab, widget, 'title')
        self.assertEquals(self.tab.view.canvas, self.diagram.canvas)
        self.assertEquals(len(element_factory.lselect()), 1)

    def tearDown(self):
        self.tab.close()
        del self.tab
        self.diagram.unlink()
        del self.diagram
        Application.shutdown()
        #assert len(self.element_factory.lselect()) == 0

    def test_creation(self):
        pass

    def test_placement(self):
        tab = self.tab
        diagram = self.diagram
        from gaphas import Element
        from gaphas.examples import Box
        box = Box()
        diagram.canvas.add(box)
        diagram.canvas.update_now()
        tab.view.request_update([box])
        
        from gaphor.diagram.comment import CommentItem
        comment = self.diagram.create(CommentItem, subject=self.element_factory.create(UML.Comment))
        self.assertEquals(len(self.element_factory.lselect()), 2)