File: test-current-desktop.lua

package info (click to toggle)
awesome 4.3-8.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,468 kB
  • sloc: ansic: 14,508; sh: 526; makefile: 46
file content (99 lines) | stat: -rw-r--r-- 2,322 bytes parent folder | download | duplicates (4)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
--- Tests for _NET_CURRENT_DESKTOP

local runner = require("_runner")
local test_client = require("_client")
local awful = require("awful")
local gtable = require("gears.table")

local c
local s = screen[1]
local tags = s.tags

local function wait_for_current_desktop(tag)
    -- The X property has 0-based indicies
    local idx = gtable.hasitem(tags, tag) - 1
    return function()
        local file = io.popen("xprop -notype -root _NET_CURRENT_DESKTOP")
        local result = file:read("*all")
        file:close()

        -- Extract the value
        local value = string.sub(result, 24, -2)

        if tostring(idx) == value then
            return true
        end
        print(string.format("Got _NET_CURRENT_DESKTOP = '%s', expected %d", value, idx))
        return false
    end
end

local steps = {

    -- Set up the state we want
    function(count)
        if count == 1 then
            test_client()
            awful.tag.viewmore({ tags[3], tags[4], tags[5] }, s)
        end

        c = awful.client.visible()[1]

        if c then
            c:move_to_tag(tags[4])
            client.focus = c
            return true
        end
    end,
    wait_for_current_desktop(tags[4]),

    -- Move the client around
    function()
        c:move_to_tag(tags[5])
        return true
    end,
    wait_for_current_desktop(tags[5]),

    -- Move the client to a non-selected tag
    function()
        c:move_to_tag(tags[6])
        assert(client.focus == nil)
        return true
    end,
    wait_for_current_desktop(tags[3]),

    -- Move the client back
    function(count)
        if count == 1 then
            c:move_to_tag(tags[4])
            return
        end
        client.focus = c
        return true
    end,
    wait_for_current_desktop(tags[4]),

    -- Killing the client means the first selected tag counts
    function(count)
        if count == 1 then
            assert(client.focus == c)
            c:kill()
            c = nil
            return
        end
        return true
    end,
    wait_for_current_desktop(tags[3]),

    -- Change tag selection
    function()
        tags[3].selected = false
        return true
    end,
    wait_for_current_desktop(tags[4]),

}

runner.run_steps(steps)

-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80