def test_widget_render_with_window(root): widget = Widget(None) widget.window = root.window widget.content = 'Hello World' widget.pin(1, 2).render() window_text = widget.window.instr(0, 0, 11) assert isinstance(widget, Widget) assert widget.window is not None assert window_text == b'Hello World'
def test_widget_render_resize_error(root): root.window.resize(1, 1) widget = Widget(root) result = widget.pin(height=2, width=2).render() assert result is widget assert widget.window is None
def test_widget_render_fixed_children(root): parent = Widget(root) child_a = Widget(parent) child_b = Widget(parent, position='fixed') child_c = Widget(parent) parent.render() curses.doupdate() assert parent.window is not None assert child_a.window is not None assert child_b.window is None assert child_c.window is not None child_b.pin(5, 5, 10, 10).render() parent.render() curses.doupdate() assert child_b.window is not None
def test_widget_render_fixed(root): sibling = Widget(root).grid(0, 0) parent = Widget(root).grid(0, 1) root.render() assert sibling.window.getbegyx() == (0, 0) assert parent.window.getbegyx() == (0, 45) fixed_widget = Widget(parent, position='fixed') fixed_widget.pin(5, 5, 5, 30).render() assert fixed_widget.window is not None assert fixed_widget.parent is parent coordinates = fixed_widget.window.getbegyx() dimensions = fixed_widget.window.getmaxyx() assert fixed_widget in parent.children assert fixed_widget.window is not None assert coordinates == (5, 50) assert dimensions == (5, 30)