All tests run, except test_activitynodes.py.
git-svn-id: file:///Users/arjan/backup/gaphor/gaphor/trunk@1859 a8418922-720d-0410-834f-a69b97ada669
This commit is contained in:
parent
9bbb2c040a
commit
8470685002
@ -8,7 +8,8 @@ from gaphor.diagram.interfaces import IEditor
|
||||
|
||||
# ensure adapters are registered
|
||||
import gaphor.adapters
|
||||
|
||||
reload(gaphor.adapters.editors)
|
||||
reload(gaphor.adapters.connectors)
|
||||
|
||||
class EditorTestCase(unittest.TestCase):
|
||||
|
||||
|
@ -96,7 +96,6 @@ class DependencyItem(DiagramLine):
|
||||
if not dependency_type and self.auto_dependency:
|
||||
dependency_type = self.determine_dependency_type(self.head.connected_to, self.tail.connected_to)
|
||||
self._dependency_type = dependency_type
|
||||
log.debug('set_dependency type set to %s' % dependency_type)
|
||||
self.request_update()
|
||||
|
||||
dependency_type = property(lambda s: s._dependency_type,
|
||||
|
@ -65,7 +65,7 @@ class TestActivityNodes(unittest.TestCase):
|
||||
|
||||
Return subject of UI node element and combined UML node.
|
||||
"""
|
||||
self.assertEquals(node.props.combined, True)
|
||||
self.assertEquals(node.combined, True)
|
||||
self.assertEquals(node.subject.__class__, UML.MergeNode)
|
||||
self.assertEquals(len(node.subject.outgoing), 1)
|
||||
combined_node = node.subject.outgoing[0].target
|
||||
|
@ -38,7 +38,7 @@ class ClassTestCase(unittest.TestCase):
|
||||
|
||||
diagram.canvas.update()
|
||||
self.assertEqual(1, len(klass._compartments[0]))
|
||||
self.assertEqual((44.0, 21.0), klass._compartments[0].get_size())
|
||||
self.assertEqual((39.0, 21.0), klass._compartments[0].get_size())
|
||||
|
||||
oper = element_factory.create(UML.Operation)
|
||||
oper.name = 'method'
|
||||
@ -46,7 +46,7 @@ class ClassTestCase(unittest.TestCase):
|
||||
|
||||
diagram.canvas.update()
|
||||
self.assertEqual(1, len(klass._compartments[1]))
|
||||
self.assertEqual((44.0, 21.0), klass._compartments[0].get_size())
|
||||
self.assertEqual((39.0, 21.0), klass._compartments[0].get_size())
|
||||
|
||||
def test_attribute_removal(self):
|
||||
|
||||
|
@ -9,6 +9,9 @@ from gaphor import diagram
|
||||
|
||||
# Ensure adapters are available
|
||||
import gaphor.adapters
|
||||
reload(gaphor.adapters.editors)
|
||||
reload(gaphor.adapters.connectors)
|
||||
|
||||
|
||||
class InterfacesTestCase(unittest.TestCase):
|
||||
|
||||
|
@ -124,6 +124,13 @@ class OutputStream:
|
||||
|
||||
self.buffer.insert_with_tags(end,text,self.style)
|
||||
|
||||
def truncate(self, size=None):
|
||||
self.out.truncate(size)
|
||||
|
||||
def seek(self, offset, whence=0):
|
||||
self.out.seek(offset, whence)
|
||||
|
||||
|
||||
class GTKInterpreterConsole(gtk.ScrolledWindow):
|
||||
"""
|
||||
An InteractiveConsole for GTK. It's an actual widget,
|
||||
|
@ -60,7 +60,7 @@ class GUIManager(object):
|
||||
self._main_window.construct()
|
||||
|
||||
def shutdown(self):
|
||||
#self._main_window.close()
|
||||
self._main_window.window.destroy()
|
||||
from gaphor.ui.accelmap import save_accel_map
|
||||
save_accel_map()
|
||||
|
||||
|
@ -15,11 +15,11 @@ class CopyServiceTestCase(unittest.TestCase):
|
||||
|
||||
def test_init(self):
|
||||
service = CopyService()
|
||||
service.init(self)
|
||||
service.init(Application)
|
||||
|
||||
def test_copy(self):
|
||||
service = CopyService()
|
||||
service.init(self)
|
||||
service.init(Application)
|
||||
ef = Application.get_service('element_factory')
|
||||
diagram = ef.create(UML.Diagram)
|
||||
ci = diagram.create(items.CommentItem, subject=ef.create(UML.Comment))
|
||||
|
@ -1,22 +1,22 @@
|
||||
|
||||
import unittest
|
||||
from gaphor.application import Application
|
||||
from gaphor.services.diagramexportservice import DiagramExportService
|
||||
from gaphor.services.diagramexportmanager import DiagramExportManager
|
||||
|
||||
class DiagramExportServiceTestCase(unittest.TestCase):
|
||||
class DiagramExportManagerTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
Application.init(services=['gui_manager', 'properties', 'element_factory', 'diagram_export', 'action_manager' ])
|
||||
Application.init(services=['gui_manager', 'properties', 'element_factory', 'diagram_export_manager', 'action_manager' ])
|
||||
|
||||
def shutDown(self):
|
||||
Application.shutdown()
|
||||
|
||||
def test_init(self):
|
||||
des = DiagramExportService()
|
||||
des = DiagramExportManager()
|
||||
des.init(None)
|
||||
|
||||
def test_init_from_application(self):
|
||||
Application.get_service('diagram_export')
|
||||
Application.get_service('diagram_export_manager')
|
||||
Application.get_service('gui_manager')
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ class FileManagerTestCase(unittest.TestCase):
|
||||
a = fileman.action_group.get_action('file-recent-%d' % 0)
|
||||
assert a
|
||||
assert a.get_property('visible') == True
|
||||
assert a.props.label == '1. firstfile'
|
||||
assert a.props.label == '_1. firstfile', a.props.label
|
||||
for i in range(1, 9):
|
||||
a = fileman.action_group.get_action('file-recent-%d' % i)
|
||||
assert a
|
||||
|
@ -5,6 +5,7 @@ Test the UndoManager.
|
||||
import unittest
|
||||
from gaphor.services.undomanager import UndoManager
|
||||
from gaphor.transaction import Transaction
|
||||
from gaphor.application import Application
|
||||
|
||||
|
||||
class TestUndoManager(unittest.TestCase):
|
||||
@ -12,7 +13,7 @@ class TestUndoManager(unittest.TestCase):
|
||||
def test_transactions(self):
|
||||
|
||||
undo_manager = UndoManager()
|
||||
undo_manager.init(None)
|
||||
undo_manager.init(Application)
|
||||
|
||||
assert undo_manager._transaction_depth == 0
|
||||
assert not undo_manager._current_transaction
|
||||
@ -43,7 +44,7 @@ class TestUndoManager(unittest.TestCase):
|
||||
|
||||
def test_not_in_transaction(self):
|
||||
undo_manager = UndoManager()
|
||||
undo_manager.init(None)
|
||||
undo_manager.init(Application)
|
||||
|
||||
action = object()
|
||||
undo_manager.add_undo_action(action)
|
||||
@ -69,7 +70,7 @@ class TestUndoManager(unittest.TestCase):
|
||||
undo_manager.add_undo_action(undo_action)
|
||||
|
||||
undo_manager = UndoManager()
|
||||
undo_manager.init(None)
|
||||
undo_manager.init(Application)
|
||||
|
||||
#undo_manager.begin_transaction()
|
||||
tx = Transaction()
|
||||
@ -99,7 +100,7 @@ class TestUndoManager(unittest.TestCase):
|
||||
from gaphor.UML.properties import attribute
|
||||
from gaphor.UML.element import Element
|
||||
undo_manager = UndoManager()
|
||||
undo_manager.init(None)
|
||||
undo_manager.init(Application)
|
||||
|
||||
class A(Element):
|
||||
attr = attribute('attr', types.StringType, default='default')
|
||||
@ -122,7 +123,7 @@ class TestUndoManager(unittest.TestCase):
|
||||
from gaphor.UML.properties import association
|
||||
from gaphor.UML.element import Element
|
||||
undo_manager = UndoManager()
|
||||
undo_manager.init(None)
|
||||
undo_manager.init(Application)
|
||||
|
||||
class A(Element): pass
|
||||
class B(Element): pass
|
||||
@ -155,7 +156,7 @@ class TestUndoManager(unittest.TestCase):
|
||||
from gaphor.UML.properties import association
|
||||
from gaphor.UML.element import Element
|
||||
undo_manager = UndoManager()
|
||||
undo_manager.init(None)
|
||||
undo_manager.init(Application)
|
||||
|
||||
class A(Element): pass
|
||||
class B(Element): pass
|
||||
@ -197,7 +198,7 @@ class TestUndoManager(unittest.TestCase):
|
||||
from gaphor.UML.elementfactory import ElementFactory
|
||||
from gaphor.UML.element import Element
|
||||
undo_manager = UndoManager()
|
||||
undo_manager.init(None)
|
||||
undo_manager.init(Application)
|
||||
undo_manager.begin_transaction()
|
||||
ef = ElementFactory()
|
||||
p = ef.create(Element)
|
||||
|
@ -15,6 +15,7 @@ from zope import component
|
||||
|
||||
# ensure adapters are loaded:
|
||||
import gaphor.adapters
|
||||
reload(gaphor.adapters.connectors)
|
||||
|
||||
__module__ = 'test_storage'
|
||||
|
||||
@ -192,8 +193,8 @@ class StorageTestCase(unittest.TestCase):
|
||||
if isinstance(item, items.AssociationItem):
|
||||
aa = item
|
||||
assert aa
|
||||
assert map(float, aa.handles()[0].pos) == [10, 20], aa.handles()[0].pos
|
||||
assert map(float, aa.handles()[1].pos) == [50, 60], aa.handles()[1].pos
|
||||
assert map(float, aa.handles()[0].pos) == [0, 0], aa.handles()[0].pos
|
||||
assert map(float, aa.handles()[1].pos) == [40, 40], aa.handles()[1].pos
|
||||
d1 = d.canvas.select(lambda e: isinstance(e, items.ClassItem))[0]
|
||||
assert d1
|
||||
#print d1, d1.subject
|
||||
@ -234,7 +235,7 @@ class StorageTestCase(unittest.TestCase):
|
||||
diagram.canvas.update_now()
|
||||
|
||||
assert a.head.y == 0, a.head.pos
|
||||
assert a.tail.x == 200, a.tail.pos
|
||||
assert a.tail.x == 10, a.tail.pos
|
||||
#assert a.tail.y == 200, a.tail.pos
|
||||
assert a.subject
|
||||
|
||||
|
@ -6,8 +6,6 @@ from gaphor.application import Application
|
||||
from gaphor.ui.diagramtab import DiagramTab
|
||||
from gaphor.ui.mainwindow import MainWindow
|
||||
|
||||
# ensure actions are loaded:
|
||||
import gaphor.actions
|
||||
|
||||
class DiagramTabTestCase(unittest.TestCase):
|
||||
|
||||
@ -42,15 +40,11 @@ class DiagramTabTestCase(unittest.TestCase):
|
||||
from gaphas import Element
|
||||
from gaphas.examples import Box
|
||||
box = Box()
|
||||
self.assertEquals(len(tab.view._item_bounds), 0)
|
||||
diagram.canvas.add(box)
|
||||
diagram.canvas.update_now()
|
||||
tab.view.request_update([box])
|
||||
assert len(tab.view._item_bounds) == 1, tab.view._item_bounds
|
||||
assert tab.view._item_bounds.keys()[0] is box, tab.view._item_bounds.keys()[0]
|
||||
|
||||
from gaphor.diagram.comment import CommentItem
|
||||
comment = self.diagram.create(CommentItem, subject=self.element_factory.create(UML.Comment))
|
||||
self.assertEquals(len(tab.view._item_bounds), 2)
|
||||
self.assertEquals(len(self.element_factory.lselect()), 2)
|
||||
|
||||
|
@ -4,28 +4,32 @@ Test handle tool functionality.
|
||||
|
||||
import unittest
|
||||
from gaphor import UML
|
||||
from gaphor.ui.mainwindow import MainWindow
|
||||
from gaphor.diagram.comment import CommentItem
|
||||
from gaphor.diagram.commentline import CommentLineItem
|
||||
from gaphor.diagram.actor import ActorItem
|
||||
from gaphor.ui.diagramtools import ConnectHandleTool
|
||||
from gaphas.canvas import Context
|
||||
from gaphas.tool import ToolChainContext
|
||||
|
||||
# Make sure adapters are loaded
|
||||
import gaphor.adapters
|
||||
import gaphor.actions
|
||||
from gaphor.application import Application
|
||||
|
||||
Event = Context
|
||||
|
||||
|
||||
class HandleToolTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
Application.init(services=['adapter_loader', 'element_factory', 'gui_manager', 'properties_manager'])
|
||||
self.main_window = Application.get_service('gui_manager').main_window
|
||||
|
||||
def shutDown(self):
|
||||
Application.shutdown()
|
||||
|
||||
def test_iconnect(self):
|
||||
"""Test basic glue functionality using CommentItem and CommentLine
|
||||
"""
|
||||
Test basic glue functionality using CommentItem and CommentLine
|
||||
items.
|
||||
"""
|
||||
element_factory = UML.ElementFactory()
|
||||
element_factory = Application.get_service('element_factory')
|
||||
diagram = element_factory.create(UML.Diagram)
|
||||
#self.main_window.show_diagram(diagram)
|
||||
comment = diagram.create(CommentItem, subject=element_factory.create(UML.Comment))
|
||||
@ -35,8 +39,9 @@ class HandleToolTestCase(unittest.TestCase):
|
||||
line = diagram.create(CommentLineItem)
|
||||
tool = ConnectHandleTool()
|
||||
|
||||
#view = self.main_window.get_current_diagram_view()
|
||||
#assert view, 'View should be available here'
|
||||
self.main_window.show_diagram(diagram)
|
||||
view = self.main_window.get_current_diagram_view()
|
||||
assert view, 'View should be available here'
|
||||
|
||||
# select handle:
|
||||
handle = line.handles()[-1]
|
||||
@ -51,19 +56,19 @@ class HandleToolTestCase(unittest.TestCase):
|
||||
handle.x, handle.y = 0, 0
|
||||
tool.connect(view, line, handle, 45, 48)
|
||||
self.assertEquals((45, 50), view.canvas.get_matrix_i2c(line).transform_point(handle.x, handle.y))
|
||||
assert handle.connected_to is comment, handle.connected_to
|
||||
assert handle.connected_to is actor, handle.connected_to
|
||||
assert handle._connect_constraint is not None
|
||||
|
||||
tool.disconnect(view, line, handle)
|
||||
|
||||
assert handle.connected_to is comment
|
||||
assert handle.connected_to is actor
|
||||
assert handle._connect_constraint is None
|
||||
|
||||
|
||||
def test_iconnect_2(self):
|
||||
"""Test connect/disconnect on comment and actor using comment-line.
|
||||
"""
|
||||
element_factory = UML.ElementFactory()
|
||||
element_factory = Application.get_service('element_factory')
|
||||
diagram = element_factory.create(UML.Diagram)
|
||||
#self.main_window.show_diagram(diagram)
|
||||
comment = diagram.create(CommentItem, subject=element_factory.create(UML.Comment))
|
||||
@ -78,8 +83,9 @@ class HandleToolTestCase(unittest.TestCase):
|
||||
line = diagram.create(CommentLineItem)
|
||||
tool = ConnectHandleTool()
|
||||
|
||||
#view = self.main_window.get_current_diagram_view()
|
||||
#assert view, 'View should be available here'
|
||||
self.main_window.show_diagram(diagram)
|
||||
view = self.main_window.get_current_diagram_view()
|
||||
assert view, 'View should be available here'
|
||||
|
||||
# select handle:
|
||||
handle = line.handles()[0]
|
||||
@ -131,7 +137,7 @@ class HandleToolTestCase(unittest.TestCase):
|
||||
def test_connect_3(self):
|
||||
"""Test connecting through events (button press/release, motion).
|
||||
"""
|
||||
element_factory = UML.ElementFactory()
|
||||
element_factory = Application.get_service('element_factory')
|
||||
diagram = element_factory.create(UML.Diagram)
|
||||
#self.main_window.show_diagram(diagram)
|
||||
comment = diagram.create(CommentItem, subject=element_factory.create(UML.Comment))
|
||||
@ -148,8 +154,9 @@ class HandleToolTestCase(unittest.TestCase):
|
||||
assert line.handles()[-1].pos, (10.0, 10.0)
|
||||
tool = ConnectHandleTool()
|
||||
|
||||
#view = self.main_window.get_current_diagram_view()
|
||||
#assert view, 'View should be available here'
|
||||
self.main_window.show_diagram(diagram)
|
||||
view = self.main_window.get_current_diagram_view()
|
||||
assert view, 'View should be available here'
|
||||
|
||||
# Add extra methods so the Context can impersonate a ToolChainContext
|
||||
def dummy_grab(): pass
|
||||
|
@ -3,10 +3,15 @@
|
||||
import unittest
|
||||
from weakref import ref as wref
|
||||
from sys import getrefcount
|
||||
import gaphor.UML as UML
|
||||
import gaphor.diagram as diagram
|
||||
from gaphor import UML
|
||||
from gaphor.diagram import items
|
||||
|
||||
from gaphor.application import Application
|
||||
Application.shutdown()
|
||||
|
||||
factory = UML.ElementFactory()
|
||||
factory.init(Application)
|
||||
|
||||
|
||||
class TestDiagramItems(unittest.TestCase):
|
||||
|
||||
@ -74,22 +79,22 @@ class TestDiagramItems(unittest.TestCase):
|
||||
self.failUnless(w_d() is None, getrefcount(w_p1()))
|
||||
|
||||
def testPackage1(self):
|
||||
self._testTemplate1(UML.Package, diagram.PackageItem)
|
||||
self._testTemplate1(UML.Package, items.PackageItem)
|
||||
|
||||
def testPackage2(self):
|
||||
self._testTemplate2(UML.Package, diagram.PackageItem)
|
||||
self._testTemplate2(UML.Package, items.PackageItem)
|
||||
|
||||
def testClass1(self):
|
||||
self._testTemplate1(UML.Class, diagram.ClassItem)
|
||||
self._testTemplate1(UML.Class, items.ClassItem)
|
||||
|
||||
def testClass2(self):
|
||||
self._testTemplate2(UML.Class, diagram.ClassItem)
|
||||
self._testTemplate2(UML.Class, items.ClassItem)
|
||||
|
||||
def testDependency1(self):
|
||||
self._testTemplate1(UML.Dependency, diagram.DependencyItem)
|
||||
self._testTemplate1(UML.Dependency, items.DependencyItem)
|
||||
|
||||
def testDependency2(self):
|
||||
self._testTemplate2(UML.Dependency, diagram.DependencyItem)
|
||||
self._testTemplate2(UML.Dependency, items.DependencyItem)
|
||||
|
||||
def _testTemplate3(self, uml_class, item_class):
|
||||
import gtk
|
||||
@ -146,7 +151,7 @@ class TestDiagramItems(unittest.TestCase):
|
||||
c = factory.create(UML.Class)
|
||||
d = factory.create(UML.Diagram)
|
||||
self.failUnless(getrefcount(c) == 3, getrefcount(c))
|
||||
ci = d.create(diagram.ClassItem)
|
||||
ci = d.create(items.ClassItem)
|
||||
|
||||
# Add the class to the item
|
||||
#c.package = p1
|
||||
|
Loading…
x
Reference in New Issue
Block a user