Ejemplo n.º 1
0
def _run_server():
    s = ServerDisplay()

    e = s.get_event_loop()
    source = e.add_timer(_kill_server, data=s)
    source.timer_update(500)

    s.add_socket()
    s.run()
    s.destroy()
Ejemplo n.º 2
0
def test_client_destroy_listener():
    global a, b
    s1, s2 = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM, 0)
    a = 0
    b = 0

    display = Display()
    client = Client(display, s1.fileno())

    destroy_listener_a = DestroyListener(destroy_notify_a)
    destroy_listener_b = DestroyListener(destroy_notify_b)

    client.add_destroy_listener(destroy_listener_a)
    client.add_destroy_listener(destroy_listener_b)

    destroy_listener_a.remove()

    client.destroy()

    assert a == 0
    assert b == 1

    display.destroy()
Ejemplo n.º 3
0
def test_display_socket():
    """Test that we can create a socket and have a client connect to it"""
    s = ServerDisplay()

    s.add_socket("wayland-0")

    with pytest.raises(Exception):
        s.add_socket("wayland-0")

    c = ClientDisplay()

    c.connect()

    assert c._ptr

    c.disconnect()
    s.destroy()
Ejemplo n.º 4
0
def test_client_destroy_listener():
    global a, b
    s1, s2 = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM, 0)
    a = 0
    b = 0

    display = Display()
    client = Client(display, s1.fileno())

    destroy_listener_a = Listener(destroy_notify_a)
    destroy_listener_b = Listener(destroy_notify_b)

    client.add_destroy_listener(destroy_listener_a)
    client.add_destroy_listener(destroy_listener_b)

    destroy_listener_a.remove()

    client.destroy()

    assert a == 0
    assert b == 1