/[gzz]/gzz/lava/test/gzz/loom/SimpleView.test
ViewVC logotype

Diff of /gzz/lava/test/gzz/loom/SimpleView.test

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by benja, Sun Feb 23 16:50:27 2003 UTC revision 1.14 by benja, Sun Feb 23 20:19:10 2003 UTC
# Line 31  s = model.createResource() Line 31  s = model.createResource()
31  t = model.createResource()  t = model.createResource()
32  u = model.createResource()  u = model.createResource()
33  v = model.createResource()  v = model.createResource()
34    w = model.createResource()
35    
36  nodes = {}  nodes = {}
37    
# Line 40  class NodeView(gzz.loom.NodeView): Line 41  class NodeView(gzz.loom.NodeView):
41    
42  class Cmp(java.util.Comparator):  class Cmp(java.util.Comparator):
43      def compare(self, r1, r2):      def compare(self, r1, r2):
44          return [t,r,s,v,u].index(r1) - [t,r,s,v,u].index(r2)          return [t,r,s,v,u,w].index(r1) - [t,r,s,v,u,w].index(r2)
45    
46  view = gzz.loom.SimpleView(NodeView())  view = gzz.loom.SimpleView(NodeView())
47    
# Line 70  def testSimple(): Line 71  def testSimple():
71      r.addProperty(p, u)      r.addProperty(p, u)
72      r.addProperty(p, v)      r.addProperty(p, v)
73    
74        w.addProperty(p, r)
75    
76      vs = getvs()      vs = getvs()
77      cursor = gzz.loom.Cursor(Cmp(), r, s)      cursor = gzz.loom.Cursor(Cmp(), r, s)
78      view.render(vs, 0, cursor)      view.render(vs, 0, cursor)
79    
80      cs_r, cs_s, cs_t, cs_u, cs_v = [vs.matcher.getCS(0, x)      cs_r, cs_s, cs_t, cs_u, cs_v, cs_w = \
81                                      for x in (r,s,t,u,v)]          [vs.matcher.getCS(0, x) for x in (r,s,t,u,v,w)]
82    
83      pr, ps, pt, pu, pv = [vs.coords.transformPoint(cs, 0, 0, None)      pr, ps, pt, pu, pv, pw = \
84                            for cs in [cs_r, cs_s, cs_t, cs_u, cs_v]]          [vs.coords.transformPoint(cs, 0, 0, None)
85             for cs in [cs_r, cs_s, cs_t, cs_u, cs_v, cs_w]]
86    
87      arr = jarray.zeros(2, 'f')      arr = jarray.zeros(2, 'f')
88      vs.coords.getSqSize(cs_r, arr)      vs.coords.getSqSize(cs_r, arr)
# Line 90  def testSimple(): Line 94  def testSimple():
94      assert abs(pr.y+h_r/2-middle_y) < 3      assert abs(pr.y+h_r/2-middle_y) < 3
95    
96      # s,t,u,v should be same size and on a single vertical line      # s,t,u,v should be same size and on a single vertical line
97      assert ps.x == pt.x == pu.x == pv.x > pr.x      assert ps.x == pt.x == pu.x == pv.x > pr.x > pw.x
98    
99      # s should be approx. the same height as r,      # s and w should be approx. the same height as r,
100      # while t is above and v,u are below      # while t is above and v,u are below
101      assert pt.y < ps.y < pv.y < pu.y      assert pt.y == pw.y < pr.y == ps.y < pv.y < pu.y
102      assert abs(ps.y-pr.y) < 5  
103        # distances on both sides should be equal
104        # this works only if all nodes are same size... XXX
105        assert (ps.x - pr.x) == (pr.x - pw.x)
106    
107      assert nodes[r] == cs_r      assert nodes[r] == cs_r
108      assert nodes[s] == cs_s      assert nodes[s] == cs_s
109      assert nodes[t] == cs_t      assert nodes[t] == cs_t
110      assert nodes[u] == cs_u      assert nodes[u] == cs_u
111      assert nodes[v] == cs_v      assert nodes[v] == cs_v
112        assert nodes[w] == cs_w

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26