Fix tests to handle omni-presence of Style sheets
This commit is contained in:
parent
fc97d43cf7
commit
e440e5315d
@ -306,8 +306,8 @@ class AssociationConnectorTestCase(TestCase):
|
||||
self.connect(asc, asc.tail, c2)
|
||||
assert asc.subject is not None
|
||||
|
||||
# Diagram, Class *2, Property *2, Association
|
||||
self.assertEqual(6, len(list(self.element_factory.select())))
|
||||
# Diagram, Class *2, Property *2, Association, StyleSheet
|
||||
self.assertEqual(7, len(list(self.element_factory.select())))
|
||||
assert asc.head_end.subject is not None
|
||||
assert asc.tail_end.subject is not None
|
||||
|
||||
|
@ -65,7 +65,7 @@ def test_diagram_stylesheet(element_factory):
|
||||
assert diagram.styleSheet is styleSheet
|
||||
|
||||
|
||||
def test_diagram_stylesheet_is_absent(element_factory):
|
||||
def test_diagram_stylesheet_is_always_there(element_factory):
|
||||
diagram = element_factory.create(Diagram)
|
||||
|
||||
assert diagram.styleSheet is None
|
||||
assert diagram.styleSheet is not None
|
||||
|
@ -112,7 +112,7 @@ def test_copy_item_when_subject_has_been_removed(diagram, element_factory):
|
||||
cls.unlink() # normally handled by the sanitizer service
|
||||
|
||||
assert len(diagram.canvas.get_all_items()) == 0
|
||||
assert len(element_factory.lselect()) == 2
|
||||
assert len(element_factory.lselect()) == 3
|
||||
assert not element_factory.lookup(orig_cls_id)
|
||||
|
||||
print(buffer)
|
||||
|
@ -10,6 +10,7 @@ from gaphas.view import Context, View
|
||||
|
||||
from gaphor.abc import ActionProvider, Service
|
||||
from gaphor.core import action, gettext
|
||||
from gaphor.core.modeling.diagram import StyledDiagram
|
||||
from gaphor.diagram.painter import ItemPainter
|
||||
from gaphor.ui.filedialog import FileDialog
|
||||
from gaphor.ui.questiondialog import QuestionDialog
|
||||
@ -64,7 +65,7 @@ class DiagramExport(Service, ActionProvider):
|
||||
return filename
|
||||
|
||||
def update_painters(self, view, diagram):
|
||||
style = diagram.style(diagram)
|
||||
style = diagram.style(StyledDiagram(diagram))
|
||||
|
||||
sloppiness = style.get("line-style", 0.0)
|
||||
|
||||
|
@ -184,7 +184,7 @@ def load_elements_generator(elements, factory, modeling_language, gaphor_version
|
||||
)
|
||||
yield from _load_attributes_and_references(elements, update_status_queue)
|
||||
|
||||
for d in factory.select(Diagram):
|
||||
for d in factory.lselect(Diagram):
|
||||
canvas = d.canvas
|
||||
# update_now() is implicitly called when lock is released
|
||||
canvas.block_updates = False
|
||||
|
@ -110,7 +110,7 @@ class StorageTestCase(TestCase):
|
||||
data = self.save()
|
||||
self.load(data)
|
||||
|
||||
assert len(self.element_factory.lselect()) == 5
|
||||
assert len(self.element_factory.lselect()) == 6
|
||||
assert len(self.element_factory.lselect(UML.Package)) == 1
|
||||
assert len(self.element_factory.lselect(UML.Diagram)) == 1
|
||||
d = self.element_factory.lselect(UML.Diagram)[0]
|
||||
@ -173,7 +173,7 @@ class StorageTestCase(TestCase):
|
||||
data = self.save()
|
||||
self.load(data)
|
||||
|
||||
assert len(self.element_factory.lselect()) == 4
|
||||
assert len(self.element_factory.lselect()) == 5
|
||||
assert len(self.element_factory.lselect(UML.Package)) == 1
|
||||
assert len(self.element_factory.lselect(UML.Diagram)) == 1
|
||||
d = self.element_factory.lselect(UML.Diagram)[0]
|
||||
|
@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
from gaphas.examples import Box
|
||||
|
||||
from gaphor.core.modeling import Comment
|
||||
from gaphor.core.modeling import Comment, Diagram, StyleSheet
|
||||
from gaphor.diagram.general import Box
|
||||
from gaphor.diagram.general.comment import CommentItem
|
||||
from gaphor.ui.mainwindow import DiagramPage
|
||||
from gaphor.UML.modelinglanguage import UMLModelingLanguage
|
||||
@ -20,14 +20,14 @@ def page(diagram, event_manager, element_factory, properties):
|
||||
|
||||
|
||||
def test_creation(page, element_factory):
|
||||
assert len(element_factory.lselect()) == 1
|
||||
assert len(element_factory.lselect()) == 2
|
||||
assert len(element_factory.lselect(Diagram)) == 1
|
||||
assert len(element_factory.lselect(StyleSheet)) == 1
|
||||
|
||||
|
||||
def test_placement(diagram, page, element_factory):
|
||||
box = Box()
|
||||
diagram.canvas.add(box)
|
||||
diagram.canvas.update_now()
|
||||
box = diagram.create(Box)
|
||||
page.view.request_update([box])
|
||||
|
||||
diagram.create(CommentItem, subject=element_factory.create(Comment))
|
||||
assert len(element_factory.lselect()) == 2
|
||||
assert len(element_factory.lselect()) == 3
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<gaphor xmlns="http://gaphor.sourceforge.net/model" version="3.0" gaphor-version="0.17.2">
|
||||
<gaphor xmlns="http://gaphor.sourceforge.net/model" version="3.0" gaphor-version="1.3.0">
|
||||
<Package id="DCE:658E43CC-3A1D-11DC-8B61-000D93868322">
|
||||
<name>
|
||||
<val>New model</val>
|
||||
@ -56,4 +56,24 @@
|
||||
</item>
|
||||
</canvas>
|
||||
</Diagram>
|
||||
<StyleSheet id="d8c43f36-c545-11ea-9af2-f5ca580d221e">
|
||||
<styleSheet>
|
||||
<val>diagram {
|
||||
background-color: white;
|
||||
line-style: normal;
|
||||
/* line-style: sloppy 0.3; */
|
||||
}
|
||||
|
||||
diagram * {
|
||||
background-color: transparent;
|
||||
color: black;
|
||||
font-family: sans;
|
||||
font-size: 14;
|
||||
highlight-color: rgba(0, 0, 255, 0.4);
|
||||
line-width: 2;
|
||||
padding: 0;
|
||||
}
|
||||
</val>
|
||||
</styleSheet>
|
||||
</StyleSheet>
|
||||
</gaphor>
|
@ -66,8 +66,8 @@ def test_class_association_undo_redo(element_factory, undo_manager):
|
||||
connect(a, a.head, ci1)
|
||||
connect(a, a.tail, ci2)
|
||||
|
||||
# Diagram, Association, 2x Class, Property, LiteralSpecification
|
||||
assert 6 == len(element_factory.lselect())
|
||||
# Diagram, Association, 2x Class, Property, LiteralSpecification, StyleSheet
|
||||
assert 7 == len(element_factory.lselect())
|
||||
assert 14 == len(diagram.canvas.solver.constraints)
|
||||
|
||||
@transactional
|
||||
|
Loading…
Reference in New Issue
Block a user