File: test-titlebar.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 (162 lines) | stat: -rw-r--r-- 3,763 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
local runner = require("_runner")
local titlebar = require("awful.titlebar")
local rules = require("awful.rules")
local spawn = require("awful.spawn")

local tiny_client_code_template = [[
local Gtk, class = require('lgi').require('Gtk'), 'client'
Gtk.init()
window = Gtk.Window {default_width=100, default_height=100, title='title'}
%s
window:set_wmclass(class, class)
local app = Gtk.Application {}
function app:on_activate()
    window.application = self
    window:show_all()
end
app:run {''}
]]
local tiny_client = {"lua", "-e", string.format(tiny_client_code_template, "")}
local tiny_client_undecorated = {"lua", "-e",
    string.format(tiny_client_code_template, [[
window.decorated = false
]])
}

-- Use the test client props
rules.rules = {}

-- Too bad there's no way to disconnect the rc.lua request::titlebars function

local steps = {
    function()
        assert(#client.get() == 0)
        spawn(tiny_client)
        return true
    end,
    function()
        if #client.get() ~= 1 then return end

        local c = client.get()[1]

        -- The rules don't set any borders nor enable the titlebar
        assert(not c._request_titlebars_called)
        assert(c.width == 100 and c.height == 100)

        -- Should create the top titlebar
        titlebar.toggle(c, "top")

        assert(c._request_titlebars_called)

        local h = c.height
        assert(h > 100)

        -- Should do nothing, there is no titlebar at the bottom by default
        titlebar.toggle(c, "bottom")
        assert(h == c.height)

        -- Should hide the titlebar
        titlebar.toggle(c, "top")
        assert(c.height == 100)

        c:kill()

        return true
    end,
    function()
        if #client.get() ~= 0 then return end

        spawn(tiny_client, {titlebars_enabled=true})

        return true
    end,
    function()
        if #client.get() ~= 1 then return end

        local c = client.get()[1]

        local h = c.height
        assert(c.width == 100 and h > 100)
        assert(c._request_titlebars_called)

        titlebar.hide(c, "top")

        assert(c.width == 100 and c.height == 100)

        titlebar.hide(c, "top")

        assert(c.width == 100 and c.height == 100)
        titlebar.show(c, "top")

        assert(c.width == 100 and c.height == h)

        c:kill()

        return true
    end,
    function()
        if #client.get() ~= 0 then return end

        spawn(tiny_client_undecorated, {titlebars_enabled=true})

        return true
    end,
    function()
        if #client.get() ~= 1 then return end

        local c = client.get()[1]

        assert(c.width == 100 and c.height > 100)
        assert(c._request_titlebars_called)

        c:kill()

        return true
    end,
    function()
        if #client.get() ~= 0 then return end

        spawn(tiny_client, {titlebars_enabled=function(c)
            return not c.requests_no_titlebar
        end})

        return true
    end,
    function()
        if #client.get() ~= 1 then return end

        local c = client.get()[1]

        assert(c.width == 100 and c.height > 100)
        assert(c._request_titlebars_called)

        c:kill()

        return true
    end,
    function()
        if #client.get() ~= 0 then return end

        spawn(tiny_client_undecorated, {titlebars_enabled=function(c)
            return not c.requests_no_titlebar
        end})

        return true
    end,
    function()
        if #client.get() ~= 1 then return end

        local c = client.get()[1]

        assert(not c._request_titlebars_called)
        assert(c.width == 100 and c.height == 100)

        c:kill()

        return true
    end,
}

runner.run_steps(steps)

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