local win before_each -> win = Window! win\realize!
win\add_view Gtk.Label! assert.equals 1, #win.views
label = Gtk.Label! assert.same { x: 1, y: 1, width: 1, height: 1, view: label }, win\add_view label
entry = Gtk.Entry! win\add_view entry entry\grab_focus! label = Gtk.Label! assert.same { x: 2, y: 1, width: 1, height: 1, view: label }, win\add_view label
local view, entry before_each -> entry = Gtk.Entry! win\add_view entry entry\grab_focus! view = Gtk.Entry!
assert.same { x: 2, y: 1, width: 1, height: 1, :view }, win\add_view view, 'right_of'
assert.same { x: 1, y: 1, width: 1, height: 1, :view }, win\add_view view, 'left_of'
assert.same { x: 1, y: 1, width: 1, height: 1, :view }, win\add_view view, 'above' assert.same { x: 1, y: 2, width: 1, height: 1, view: entry }, win\get_view entry
assert.same { x: 1, y: 2, width: 1, height: 1, :view }, win\add_view view, 'below'
win\add_view view, 'below' next_view = Gtk.Label! assert.same { x: 1, y: 2, width: 1, height: 1, view: next_view }, win\add_view next_view, 'left_of', view
win\add_view view, 'right_of' next_view = Gtk.Label! assert.same { x: 2, y: 1, width: 1, height: 1, view: next_view }, win\add_view next_view, 'left_of', view assert.same { 1, 2, 3 }, [v.x for v in *win.views]
label = Gtk.Label! win\add_view label win\remove_view label assert.equals 0, #win.views
entry = Gtk.Entry! win\add_view entry entry\grab_focus! win\remove_view! assert.equals 0, #win.views
label = Gtk.Label! win\add_view label assert.raises 'remove', -> win\remove_view!
left = Gtk.Entry! middle = Gtk.Entry! right = Gtk.Entry! win\add_view left win\add_view middle win\add_view right middle\grab_focus! win\remove_view middle assert.is_true right.is_focus
left = Gtk.Entry! middle = Gtk.Entry! right = Gtk.Entry! win\add_view left win\add_view middle win\add_view right right\grab_focus! win\remove_view right assert.is_true middle.is_focus
label = Gtk.Label! win\add_view label assert.same { { x: 1, y: 1, width: 1, height: 1, view: label } }, win.views
entry = Gtk.Entry! win\add_view entry entry\grab_focus! l1 = Gtk.Label! l2 = Gtk.Label! win\add_view l1, 'left_of' win\add_view l2, 'below' assert.same { l1, entry, l2 }, [v.view for v in *win.views]
assert.is_nil, win.current_view
e1 = Gtk.Entry! e2 = Gtk.Entry! win\add_view e1 win\add_view e2 e1\grab_focus! assert.same { x: 1, y: 1, width: 1, height: 1, view: e1 }, win.current_view e2\grab_focus! assert.same { x: 2, y: 1, width: 1, height: 1, view: e2 }, win.current_view
v1 = Gtk.Entry! win\add_view v1 assert.same {}, win\siblings v1
v1 = Gtk.Entry! win\add_view v1 v1\grab_focus! assert.same {}, win\siblings!
assert.same {}, win\siblings!
left = Gtk.Entry! right = Gtk.Entry! bottom = Gtk.Entry! win\add_view left win\add_view right, 'right_of', left win\add_view bottom, 'below', left assert.same { right: right, down: bottom }, win\siblings left, false assert.same { left: left, down: bottom }, win\siblings right, false assert.same { up: left }, win\siblings bottom, false
left = Gtk.Entry! right = Gtk.Entry! bottom = Gtk.Entry! win\add_view left win\add_view right, 'right_of', left win\add_view bottom, 'below', left assert.same { left: bottom, right: right, up: bottom, down: bottom }, win\siblings left, true assert.same { left: left, right: bottom, up: bottom, down: bottom }, win\siblings right, true assert.same { left: right, right: left, up: left, down: left }, win\siblings bottom, true
local left, right, bottom before_each -> left = Gtk.Entry! right = Gtk.Entry! bottom = Gtk.Entry! win\add_view left win\add_view right right\grab_focus! win\add_view bottom, 'below'
assert.same { x: 1, y: 2, width: 2, height: 1, view: bottom }, win\get_view bottom
win\remove_view left assert.same { x: 1, y: 1, width: 1, height: 1, view: right }, win\get_view right
win\remove_view right assert.same { x: 1, y: 1, width: 1, height: 1, view: left }, win\get_view left
middle = Gtk.Entry! win\add_view middle, 'right_of', left win\remove_view middle assert.same { x: 1, y: 1, width: 1, height: 1, view: left }, win\get_view left assert.same { x: 2, y: 1, width: 1, height: 1, view: right }, win\get_view right