* removed overridden subject declaration from !AssociationEnd
* don't call handlers from register_handler: causes unit tests to fail. git-svn-id: file:///Users/arjan/backup/gaphor/gaphor/trunk@2157 a8418922-720d-0410-834f-a69b97ada669
This commit is contained in:
parent
581e4f2d88
commit
6d8390daa5
@ -346,21 +346,6 @@ class AssociationEnd(UML.Presentation):
|
||||
self._name_bounds = Rectangle()
|
||||
self._mult_bounds = Rectangle()
|
||||
|
||||
self._subject = None
|
||||
|
||||
|
||||
def _set_subject(self, value):
|
||||
self._subject = value
|
||||
self.set_text()
|
||||
self.request_update()
|
||||
|
||||
def _del_subject(self):
|
||||
self._subject = None
|
||||
self.set_text()
|
||||
self.request_update()
|
||||
|
||||
subject = property(lambda s: s._subject, _set_subject, _del_subject)
|
||||
|
||||
|
||||
def request_update(self):
|
||||
self._owner.request_update()
|
||||
|
@ -263,8 +263,9 @@ class DiagramItem(UML.Presentation, StereotypeSupport, EditableTextSupport):
|
||||
def register_handlers(self):
|
||||
Application.register_handler(self.on_element_change)
|
||||
Application.register_handler(self.on_presentation_subject)
|
||||
if self.subject:
|
||||
self.on_presentation_subject(None)
|
||||
# FixMe: calls to request_update() cause tests to fail
|
||||
# if self.subject:
|
||||
# self.on_presentation_subject(None)
|
||||
|
||||
|
||||
def unregister_handlers(self):
|
||||
|
85
tests/test_association_undo.py
Normal file
85
tests/test_association_undo.py
Normal file
@ -0,0 +1,85 @@
|
||||
"""
|
||||
This test exhibits a bug (ticket 77) that occurs when an undo action is done
|
||||
after an association is disconnected from a class.
|
||||
|
||||
|
||||
See: http://gaphor.devjavu.com/ticket/77
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from zope import component
|
||||
from gaphor import UML
|
||||
from gaphor import transaction
|
||||
from gaphor.diagram import items
|
||||
from gaphor.diagram.interfaces import IConnect
|
||||
from gaphor.application import Application
|
||||
|
||||
class AssociationUndoTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
Application.init(services=['adapter_loader', 'element_factory', 'undo_manager'])
|
||||
|
||||
def tearDown(self):
|
||||
Application.shutdown()
|
||||
|
||||
def testAssociationUndo(self):
|
||||
factory = Application.get_service('element_factory')
|
||||
|
||||
diagram = factory.create(UML.Diagram)
|
||||
|
||||
class1 = factory.create(UML.Class)
|
||||
class1.name = 'class1'
|
||||
classItem1 = diagram.create(items.ClassItem, subject=class1)
|
||||
|
||||
class2 = factory.create(UML.Class)
|
||||
class2.name = 'class2'
|
||||
classItem2 = diagram.create(items.ClassItem, subject=class2)
|
||||
|
||||
assoc = diagram.create(items.AssociationItem)
|
||||
assert assoc.subject is None
|
||||
|
||||
adapter = component.queryMultiAdapter((classItem1, assoc), IConnect)
|
||||
assert adapter
|
||||
adapter.connect(assoc.handles()[0])
|
||||
|
||||
adapter = component.queryMultiAdapter((classItem2, assoc), IConnect)
|
||||
assert adapter
|
||||
adapter.connect(assoc.handles()[1])
|
||||
|
||||
assert assoc.subject
|
||||
assert assoc.head_end.subject
|
||||
assert assoc.tail_end.subject
|
||||
|
||||
former = (assoc.subject, assoc.head_end.subject, assoc.tail_end.subject)
|
||||
|
||||
tx = transaction.Transaction()
|
||||
|
||||
adapter = component.queryMultiAdapter((classItem2, assoc), IConnect)
|
||||
assert adapter
|
||||
adapter.disconnect(assoc.handles()[1])
|
||||
|
||||
tx.commit()
|
||||
|
||||
assert assoc.subject is None
|
||||
assert assoc.head_end.subject is None
|
||||
assert assoc.tail_end.subject is None
|
||||
|
||||
undo_manager = Application.get_service('undo_manager')
|
||||
|
||||
assert undo_manager.can_undo()
|
||||
|
||||
undo_manager.undo_transaction()
|
||||
|
||||
assert not undo_manager.can_undo()
|
||||
|
||||
assert assoc.subject is former[0]
|
||||
assert assoc.head_end.subject is former[1]
|
||||
assert assoc.tail_end.subject is former[2]
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# vim:sw=4:et:ai
|
Loading…
x
Reference in New Issue
Block a user