예제 #1
0
def test_exclude(mocker):
    xrandr_cli = mock_xrandr(mocker, HDMI_CONNECTED_ACTIVE)
    module = Module(Config(["-p", "xrandr.exclude=eDP"]), theme=None)
    module.update()
    xrandr_cli.assert_called_once_with("xrandr -q")

    assert_widgets(module, ("HDMI-1-1", "on", 1920))

    assert_trigger(xrandr_cli, module, 0, LEFT_MOUSE,
                   "xrandr --output HDMI-1-1 --off")
    assert_trigger(xrandr_cli, module, 0, RIGHT_MOUSE,
                   "xrandr --output HDMI-1-1 --off")
예제 #2
0
def test_exclude_off(mocker):
    xrandr_cli = mock_xrandr(mocker, HDMI_CONNECTED_INACTIVE)
    module = Module(Config(["-p", "xrandr.exclude=eDP"]), theme=None)
    module.update()
    xrandr_cli.assert_called_once_with("xrandr -q")

    assert_widgets(module, ("HDMI-1-1", "off", sys.maxsize))

    assert_trigger(xrandr_cli, module, 0, LEFT_MOUSE,
                   "xrandr --output HDMI-1-1 --auto --left-of eDP-1-1")
    assert_trigger(xrandr_cli, module, 0, RIGHT_MOUSE,
                   "xrandr --output HDMI-1-1 --auto --right-of eDP-1-1")
예제 #3
0
def test_no_autoupdate(mocker):
    xrandr_cli = mock_xrandr(mocker, HDMI_CONNECTED_ACTIVE)
    module = Module(Config(["-p", "xrandr.autoupdate=false"]), theme=None)
    module.update()
    xrandr_cli.assert_called_once_with("xrandr -q")

    assert_widgets(module, ("eDP-1-1", "on", 0), ("HDMI-1-1", "on", 1920),
                   (None, "refresh", None))

    assert_trigger(xrandr_cli, module, 0, LEFT_MOUSE,
                   "xrandr --output eDP-1-1 --off")
    assert_trigger(xrandr_cli, module, 0, RIGHT_MOUSE,
                   "xrandr --output eDP-1-1 --off")
    assert_trigger(xrandr_cli, module, 1, LEFT_MOUSE,
                   "xrandr --output HDMI-1-1 --off")
    assert_trigger(xrandr_cli, module, 1, RIGHT_MOUSE,
                   "xrandr --output HDMI-1-1 --off")
예제 #4
0
def test_autotoggle_active_connected(mocker):
    xrandr_cli = mock_xrandr(mocker, HDMI_DISCONNECTED_ACTIVE)
    module = Module(Config(["-p", "xrandr.autotoggle=true"]), theme=None)
    module.update()
    xrandr_cli.assert_called_once_with("xrandr -q")

    assert_widgets(module, ("eDP-1-1", "on", 0))

    xrandr_cli.return_value = HDMI_CONNECTED_ACTIVE
    xrandr_cli.reset_mock()

    module.update()
    xrandr_cli.assert_called_once_with("xrandr -q")
예제 #5
0
def test_autotoggle_inactive_connected(mocker):
    xrandr_cli = mock_xrandr(mocker, HDMI_DISCONNECTED_INACTIVE)
    module = Module(Config(["-p", "xrandr.autotoggle=true"]), theme=None)
    module.update()
    xrandr_cli.assert_called_once_with("xrandr -q")

    assert_widgets(module, ("eDP-1-1", "on", 0))

    xrandr_cli.return_value = HDMI_CONNECTED_INACTIVE
    xrandr_cli.reset_mock()

    module.update()
    assert xrandr_cli.call_count == 2
    xrandr_cli.assert_any_call("xrandr -q")
    xrandr_cli.assert_called_with(
        "xrandr --output HDMI-1-1 --auto --right-of eDP-1-1")