MCPcopy Create free account
hub / github.com/KLayout/klayout / test_1

Method test_1

testdata/ruby/layLayoutView.rb:40–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38
39 # Basic view creation and MainWindow events
40 def test_1
41
42 if !RBA.constants.member?(:Application)
43 return
44 end
45
46 app = RBA::Application.instance
47 mw = app.main_window
48 mw.close_all
49
50 created = 0
51 created_proc = proc { created += 1 }
52 current_view_changed = 0
53 current_view_changed_proc = proc { current_view_changed += 1 }
54 closed = 0
55 closed_proc = proc { closed += 1 }
56 mw.on_view_created += created_proc
57 mw.on_current_view_changed += current_view_changed_proc
58 mw.on_view_closed += closed_proc
59
60 cv1 = mw.create_layout(1)
61 assert_equal(RBA::LayoutView::current.index, 0)
62 assert_equal(RBA::LayoutView::current.active_cellview_index, 0)
63 assert_equal(RBA::LayoutView::current.active_cellview.index, 0)
64 assert_equal(RBA::CellView::active.index, 0)
65 assert_equal(RBA::CellView::active.view.index, 0)
66 assert_equal(cv1.index, 0)
67 assert_equal(cv1.view.index, 0)
68
69 assert_equal(created, 1)
70 assert_equal(current_view_changed, 1)
71 assert_equal(closed, 0)
72
73 cv2 = mw.create_layout(2)
74 assert_equal(RBA::LayoutView::current.index, 0)
75 assert_equal(RBA::LayoutView::current.active_cellview_index, 1)
76 assert_equal(RBA::LayoutView::current.active_cellview.index, 1)
77 assert_equal(RBA::CellView::active.index, 1)
78 assert_equal(RBA::CellView::active.view.index, 0)
79 assert_equal(cv2.index, 1)
80 assert_equal(cv2.view.index, 0)
81
82 assert_equal(created, 1)
83 assert_equal(current_view_changed, 1)
84 assert_equal(closed, 0)
85
86 cv3 = mw.create_layout(1)
87 assert_equal(RBA::LayoutView::current.index, 1)
88 assert_equal(RBA::LayoutView::current.main_window.view(1).index, 1)
89 assert_equal(RBA::LayoutView::current.active_cellview_index, 0)
90 assert_equal(RBA::LayoutView::current.active_cellview.index, 0)
91 assert_equal(RBA::CellView::active.index, 0)
92 assert_equal(RBA::CellView::active.view.index, 1)
93 assert_equal(cv3.index, 0)
94 assert_equal(cv3.view.index, 1)
95
96 assert_equal(mw.current_view_index, 1)
97 assert_equal(created, 2)

Callers

nothing calls this directly

Calls 10

main_windowMethod · 0.80
current_view_indexMethod · 0.80
close_current_viewMethod · 0.80
instanceMethod · 0.45
close_allMethod · 0.45
create_layoutMethod · 0.45
indexMethod · 0.45
currentMethod · 0.45
active_cellview_indexMethod · 0.45
viewMethod · 0.45

Tested by

no test coverage detected