Exemplo n.º 1
0
def test_link_focus_no_loopback():
    focusables = [FocusButton() for _ in range(10)]
    link_focus(focusables)
    for i, widget in enumerate(focusables):
        if i > 0:
            assert widget.focus_previous is focusables[i - 1]
        if i < len(focusables) - 1:
            assert widget.focus_next is focusables[i + 1]

    assert focusables[0].focus_previous is None
    assert focusables[-1].focus_next is None
Exemplo n.º 2
0
def test_link_one_loopback():
    btn = FocusButton()
    focusables = [btn]
    link_focus(focusables, loopback=True)
    assert btn.focus_previous is None
    assert btn.focus_next is None
Exemplo n.º 3
0
def test_link_one():
    btn = FocusButton()
    focusables = [btn]
    link_focus(focusables)
    assert btn.focus_previous is None
    assert btn.focus_next is None
Exemplo n.º 4
0
def test_link_empty():
    focusables = []
    link_focus(focusables)
    assert focusables == []
Exemplo n.º 5
0
def test_link_focus_loopback():
    focusables = [FocusButton() for _ in range(10)]
    link_focus(focusables, loopback=True)
    for i, widget in enumerate(focusables):
        assert widget.focus_previous is focusables[(i - 1) % len(focusables)]
        assert widget.focus_next is focusables[(i + 1) % len(focusables)]