Ejemplo n.º 1
0
def test_that_nonvisible_windows_are_not_queued_by_display_handler(
    display_handler, monkeypatch, windows
):
    null_fake_event = MagicMock(spec=CreateNotifyEvent)
    null_fake_event.window = 0
    visible_fake_event = MagicMock(spec=CreateNotifyEvent)
    visible_fake_event.window = windows[0].id

    # Initialize a fake xpybutil connection which spits out a mapped window and a non-existant
    # window

    class Counter:
        def __init__(self):
            self.i = 0

    def wait_for_event(counter={"i": 0}):  # noqa: B006
        counter["i"] += 1
        if counter["i"] == 1:
            return visible_fake_event
        else:
            return null_fake_event

    monkeypatch.setattr("flashfocus.display_protocols.x11.conn.wait_for_event", wait_for_event)
    with producer_running(display_handler):
        pass
    queued = queue_to_list(display_handler.queue)
    # Check that only the mapped window caused the display_handler to queue an event
    assert queued == [WMEvent(window=windows[0], event_type=WMEventType.NEW_WINDOW)]
Ejemplo n.º 2
0
def test_display_handler_handles_focus_shifts(display_handler, windows):
    with producer_running(display_handler):
        change_focus(windows[1])
        change_focus(windows[0])
    queued = queue_to_list(display_handler.queue)
    assert queued == [
        WMEvent(window=windows[1], event_type=WMEventType.FOCUS_SHIFT),
        WMEvent(window=windows[0], event_type=WMEventType.FOCUS_SHIFT),
    ]
Ejemplo n.º 3
0
def test_client_monitor_handles_client_requests(client_monitor, windows):
    with producer_running(client_monitor):
        client_request_flash()
        client_request_flash()
    queued = queue_to_list(client_monitor.queue)
    assert queued == [
        WMEvent(window=windows[0], event_type=WMEventType.CLIENT_REQUEST),
        WMEvent(window=windows[0], event_type=WMEventType.CLIENT_REQUEST),
    ]
Ejemplo n.º 4
0
def test_client_monitor_handles_client_requests(client_monitor, windows):
    with producer_running(client_monitor):
        client_request_flash()
        client_request_flash()
    queued = queue_to_list(client_monitor.queue)
    assert queued == [
        (windows[0], "client_request"),
        (windows[0], "client_request"),
    ]
Ejemplo n.º 5
0
def test_that_nonvisible_windows_are_not_queued_by_xhandler(
        xhandler, monkeypatch, windows):
    null_fake_event = MagicMock(spec=CreateNotifyEvent)
    null_fake_event.window = 0
    visible_fake_event = MagicMock(spec=CreateNotifyEvent)
    visible_fake_event.window = windows[0]

    class FakeConnection:
        def __init__(self, windows):
            self.i = 0
            self.windows = windows

        def wait_for_event(self):
            self.i += 1
            if self.i == 2:
                return visible_fake_event
            else:
                return null_fake_event

    monkeypatch.setattr("xpybutil.conn", FakeConnection(windows))
    with producer_running(xhandler):
        pass
    queued = queue_to_list(xhandler.queue)
    assert queued == [(windows[0], "new_window")]
Ejemplo n.º 6
0
def test_xhandler_handles_focus_shifts(xhandler, windows):
    with producer_running(xhandler):
        change_focus(windows[1])
        change_focus(windows[0])
    queued = queue_to_list(xhandler.queue)
    assert queued == [(windows[1], "focus_shift"), (windows[0], "focus_shift")]