def test_element_factory_undo(self): from gaphor.UML.element import Element event_manager = EventManager() undo_manager = UndoManager(event_manager) element_factory = ElementFactory(event_manager) undo_manager.begin_transaction() p = element_factory.create(Element) assert undo_manager._current_transaction assert undo_manager._current_transaction._actions assert undo_manager.can_undo() undo_manager.commit_transaction() assert undo_manager.can_undo() assert element_factory.size() == 1 undo_manager.undo_transaction() assert not undo_manager.can_undo() assert undo_manager.can_redo() assert element_factory.size() == 0 undo_manager.redo_transaction() assert undo_manager.can_undo() assert not undo_manager.can_redo() assert element_factory.size() == 1 assert element_factory.lselect()[0] is p undo_manager.shutdown()
def test_element_factory_undo(self): from gaphor.UML.elementfactory import ElementFactory from gaphor.UML.element import Element undo_manager = UndoManager() undo_manager.init(Application) undo_manager.begin_transaction() ef = ElementFactory() ef.init(Application) p = ef.create(Element) assert undo_manager._current_transaction assert undo_manager._current_transaction._actions assert undo_manager.can_undo() undo_manager.commit_transaction() assert undo_manager.can_undo() assert ef.size() == 1 undo_manager.undo_transaction() assert not undo_manager.can_undo() assert undo_manager.can_redo() assert ef.size() == 0 undo_manager.redo_transaction() assert undo_manager.can_undo() assert not undo_manager.can_redo() assert ef.size() == 1 assert ef.lselect()[0] is p undo_manager.shutdown()
def test_redo_stack(self): from gaphor.UML.element import Element event_manager = EventManager() undo_manager = UndoManager(event_manager) element_factory = ElementFactory(event_manager) undo_manager.begin_transaction() p = element_factory.create(Element) assert undo_manager._current_transaction assert undo_manager._current_transaction._actions assert undo_manager.can_undo() undo_manager.commit_transaction() assert undo_manager.can_undo() assert element_factory.size() == 1, element_factory.size() with Transaction(event_manager): element_factory.create(Element) assert undo_manager.can_undo() assert not undo_manager.can_redo() assert element_factory.size() == 2 undo_manager.undo_transaction() assert undo_manager.can_undo() assert 1 == len(undo_manager._undo_stack) assert 1 == len(undo_manager._redo_stack) assert undo_manager.can_redo() assert element_factory.size() == 1 undo_manager.undo_transaction() assert not undo_manager.can_undo() assert undo_manager.can_redo() assert 0 == len(undo_manager._undo_stack) assert 2 == len(undo_manager._redo_stack) # assert element_factory.size() == 0 undo_manager.redo_transaction() assert 1 == len(undo_manager._undo_stack) assert 1 == len(undo_manager._redo_stack) assert undo_manager.can_undo() assert undo_manager.can_redo() assert element_factory.size() == 1 undo_manager.redo_transaction() assert undo_manager.can_undo() assert not undo_manager.can_redo() assert element_factory.size() == 2 assert p in element_factory.lselect() undo_manager.shutdown()
def test_redo_stack(self): from gaphor.UML.elementfactory import ElementFactory from gaphor.UML.element import Element undo_manager = UndoManager() undo_manager.init(Application) undo_manager.begin_transaction() ef = ElementFactory() ef.init(Application) p = ef.create(Element) assert undo_manager._current_transaction assert undo_manager._current_transaction._actions assert undo_manager.can_undo() undo_manager.commit_transaction() assert undo_manager.can_undo() assert ef.size() == 1 with Transaction(): q = ef.create(Element) assert undo_manager.can_undo() assert not undo_manager.can_redo() assert ef.size() == 2 undo_manager.undo_transaction() assert undo_manager.can_undo() self.assertEquals(1, len(undo_manager._undo_stack)) self.assertEquals(1, len(undo_manager._redo_stack)) assert undo_manager.can_redo() assert ef.size() == 1 undo_manager.undo_transaction() assert not undo_manager.can_undo() assert undo_manager.can_redo() self.assertEquals(0, len(undo_manager._undo_stack)) self.assertEquals(2, len(undo_manager._redo_stack)) assert ef.size() == 0 undo_manager.redo_transaction() self.assertEquals(1, len(undo_manager._undo_stack)) self.assertEquals(1, len(undo_manager._redo_stack)) assert undo_manager.can_undo() assert undo_manager.can_redo() assert ef.size() == 1 undo_manager.redo_transaction() assert undo_manager.can_undo() assert not undo_manager.can_redo() assert ef.size() == 2 assert p in ef.lselect() undo_manager.shutdown()