File: test_dgroups.py

package info (click to toggle)
qtile 0.34.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,004 kB
  • sloc: python: 49,959; ansic: 4,371; xml: 324; sh: 260; makefile: 218
file content (85 lines) | stat: -rw-r--r-- 2,054 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import time

import pytest

import libqtile
from test.helpers import Retry


class DGroupsConfig(libqtile.confreader.Config):
    auto_fullscreen = True
    groups = [libqtile.config.Group("a"), libqtile.config.Group("b")]
    layouts = [libqtile.layout.MonadTall()]
    floating_layout = libqtile.resources.default_config.floating_layout
    keys = []
    mouse = []
    screens = []


class DGroupsSpawnConfig(DGroupsConfig):
    groups = [
        libqtile.config.Group("a"),
        libqtile.config.Group("b", spawn=["xterm"]),
    ]


dgroups_config = pytest.mark.parametrize("manager", [DGroupsConfig], indirect=True)
dgroups_spawn_config = pytest.mark.parametrize("manager", [DGroupsSpawnConfig], indirect=True)


@dgroups_config
def test_dgroup_persist(manager):
    # create dgroup
    gname = "c"
    manager.c.addgroup(gname, persist=True)

    # switch to dgroup
    manager.c.group[gname].toscreen()

    # start window
    one = manager.test_window("test1")

    # close window
    manager.kill_window(one)

    # wait for window to close and group to NOT be destroyed
    time.sleep(2)

    # check if dgroup still exists
    assert len(manager.c.get_groups()) == 3


@dgroups_config
def test_dgroup_nonpersist(manager):
    # create dgroup
    gname = "c"
    manager.c.addgroup(gname)

    # switch to dgroup
    manager.c.group[gname].toscreen()

    # start window
    one = manager.test_window("test1")

    # close window
    manager.kill_window(one)

    # wait for window to close and group to be destroyed
    time.sleep(2)

    # check if dgroup does not exist anymore
    assert len(manager.c.get_groups()) == 2


@dgroups_spawn_config
def test_dgroup_spawn_in_group(manager, backend_name):
    if backend_name == "wayland":
        pytest.skip("TODO: X11 only for now.")

    @Retry(ignore_exceptions=(AssertionError,), tmax=10)
    def wait_for_window():
        assert len(manager.c.windows()) > 0

    wait_for_window()
    assert not manager.c.group["a"].info()["windows"]
    assert manager.c.group["b"].info()["windows"]