Esempio n. 1
0
def fixture_useful_screens(monkeypatch, mocker):
    def mock_get_randr_screens(*args, **kwargs):
        return {"DVI-I-0": (1920, 1080, 50, 60)}

    monkeypatch.setattr(barython.panel, "get_randr_screens",
                        mock_get_randr_screens)
    monkeypatch.setattr(barython.screen, "get_randr_screens",
                        mock_get_randr_screens)

    disable_spawn_bar(Panel)
    p = Panel(keep_unplugged_screens=False)
    disable_spawn_bar(Screen)
    s0, s1 = Screen("DVI-I-0"), Screen("DVI-I-1")

    for i in (p, s0, s1):
        mocker.spy(i, "start")
        mocker.spy(i, "init_bar")
        mocker.spy(i, "_write_in_bar")

    w = TextWidget(text="test")
    s0.add_widget("l", w)
    s1.add_widget("l", w)

    p.add_screen(s0, s1)
    return p, s0, s1
Esempio n. 2
0
def test_panel_gather_no_screen(fixture_useful_screens):
    p = Panel(instance_per_screen=False, keep_unplugged_screens=True)
    disable_spawn_bar(p)
    p.gather()
    try:
        threading.Thread(target=p.start).start()
        time.sleep(0.1)
        assert p.gather() == ""
    finally:
        p.stop()
Esempio n. 3
0
def test_base_lock_update(mocker):
    """
    Test that only one update is running at a time by widget
    """
    disable_spawn_bar(Panel)
    p = Panel(instance_per_screen=False, keep_unplugged_screens=True)
    w = SubprocessWidget(cmd="echo Test", refresh=0.2)
    for i in range(0, 4):
        s = Screen()
        s.add_widget("l", w)
        p.add_screen(s)
    mocker.spy(w, "continuous_update")

    try:
        threading.Thread(target=p.start).start()
        time.sleep(0.3)
        assert w.continuous_update.call_count == 1
    finally:
        p.stop()