Merge fixes from branch 'xorn'
[geda-gaf.git] / xorn / tests / cpython / storage / normalize.py
blob1e34c44e7fe05feb7aeb6f4202b7dbf5a7735756
1 # Copyright (C) 2013-2020 Roland Lutz
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 import xorn.storage
19 def get_line(rev, ob):
20 line = rev.get_object_data(ob).line
21 return line.width, line.cap_style, line.dash_style, \
22 line.dash_length, line.dash_space
24 def get_fill(rev, ob):
25 fill = rev.get_object_data(ob).fill
26 return fill.type, fill.width, fill.angle0, fill.pitch0, \
27 fill.angle1, fill.pitch1
29 def check_line_attr(obtype):
30 rev = xorn.storage.Revision()
31 data = obtype()
32 ob = rev.add_object(data)
34 data.line.width = 70.
35 data.line.cap_style = 1
36 data.line.dash_length = 73.
37 data.line.dash_space = 74.
39 data.line.dash_style = 0
40 rev.set_object_data(ob, data)
41 assert get_line(rev, ob) == (70., 1, 0, 0., 0.)
43 data.line.dash_style = 1
44 rev.set_object_data(ob, data)
45 assert get_line(rev, ob) == (70., 1, 1, 0., 74.)
47 data.line.dash_style = 2
48 rev.set_object_data(ob, data)
49 assert get_line(rev, ob) == (70., 1, 2, 73., 74.)
51 data.line.dash_style = 3
52 rev.set_object_data(ob, data)
53 assert get_line(rev, ob) == (70., 1, 3, 73., 74.)
55 data.line.dash_style = 4
56 rev.set_object_data(ob, data)
57 assert get_line(rev, ob) == (70., 1, 4, 73., 74.)
59 def check_fill_attr(obtype):
60 rev = xorn.storage.Revision()
61 data = obtype()
62 ob = rev.add_object(data)
64 data.fill.width = 81.
65 data.fill.angle0 = 82
66 data.fill.pitch0 = 83.
67 data.fill.angle1 = 84
68 data.fill.pitch1 = 85.
70 data.fill.type = 0
71 rev.set_object_data(ob, data)
72 assert get_fill(rev, ob) == (0, 0., 0, 0., 0, 0.)
74 data.fill.type = 1
75 rev.set_object_data(ob, data)
76 assert get_fill(rev, ob) == (1, 0., 0, 0., 0, 0.)
78 data.fill.type = 2
79 rev.set_object_data(ob, data)
80 assert get_fill(rev, ob) == (2, 81., 82, 83., 84, 85.)
82 data.fill.type = 3
83 rev.set_object_data(ob, data)
84 assert get_fill(rev, ob) == (3, 81., 82, 83., 0, 0.)
86 data.fill.type = 4
87 rev.set_object_data(ob, data)
88 assert get_fill(rev, ob) == (4, 0., 0, 0., 0, 0.)
90 # arc
91 check_line_attr(xorn.storage.Arc)
93 # box
94 check_line_attr(xorn.storage.Box)
95 check_fill_attr(xorn.storage.Box)
97 # circle
98 check_line_attr(xorn.storage.Circle)
99 check_fill_attr(xorn.storage.Circle)
101 # component
102 pass
104 # line
105 check_line_attr(xorn.storage.Line)
107 # net
108 pass
110 # path
111 check_line_attr(xorn.storage.Path)
112 check_fill_attr(xorn.storage.Path)
114 # picture
115 pass
117 # text
118 pass