2016-04-08 06:59:20 +02:00
|
|
|
local awful = require("awful")
|
2018-10-14 04:42:28 +02:00
|
|
|
local gtable = require("gears.table")
|
2016-04-08 06:59:20 +02:00
|
|
|
local beautiful = require("beautiful")
|
|
|
|
|
2016-08-22 23:25:50 +02:00
|
|
|
local function check_order()
|
|
|
|
local tags = mouse.screen.tags
|
|
|
|
|
|
|
|
for k, v in ipairs(tags) do
|
|
|
|
assert(k == v.index)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-08 06:59:20 +02:00
|
|
|
local has_spawned = false
|
|
|
|
local steps = {
|
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
function(count)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
if count <= 1 and not has_spawned and #client.get() < 2 then
|
|
|
|
awful.spawn("xterm")
|
|
|
|
awful.spawn("xterm")
|
|
|
|
has_spawned = true
|
|
|
|
elseif #client.get() >= 2 then
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Test move, swap and index
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
local tags = mouse.screen.tags
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(#mouse.screen.tags == 9)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
check_order()
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
tags[7].index = 9
|
|
|
|
assert(tags[7].index == 9)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
check_order()
|
2016-08-22 23:25:50 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
tags[7].index = 4
|
|
|
|
assert(tags[7].index == 4)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
check_order()
|
2016-08-22 23:25:50 +02:00
|
|
|
|
2017-03-31 05:44:20 +02:00
|
|
|
tags[7].index = 5
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(tags[7].index == 5)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
check_order()
|
2016-08-22 23:25:50 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
tags[1]:swap(tags[3])
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
check_order()
|
2016-08-22 23:25:50 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(tags[1].index == 3)
|
|
|
|
assert(tags[3].index == 1)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
check_order()
|
2016-08-22 23:25:50 +02:00
|
|
|
|
2017-03-31 05:44:20 +02:00
|
|
|
tags[3]:swap(tags[1])
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(tags[3].index == 3)
|
|
|
|
assert(tags[1].index == 1)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
check_order()
|
2016-08-22 23:25:50 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Test add, icon and delete
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
client.focus = client.get()[1]
|
|
|
|
local c = client.focus
|
2019-11-11 00:39:26 +01:00
|
|
|
assert(c and c.active)
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(beautiful.awesome_icon)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
local t = awful.tag.add("Test", {clients={c}, icon = beautiful.awesome_icon})
|
2017-07-29 19:58:45 +02:00
|
|
|
assert(t.layout == awful.layout.suit.floating)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
check_order()
|
2016-08-22 23:25:50 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
local found = false
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
tags = mouse.screen.tags
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(#tags == 10)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
for _, v in ipairs(tags) do
|
|
|
|
if t == v then
|
|
|
|
found = true
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(found)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(t:clients()[1] == c)
|
|
|
|
assert(c:tags()[2] == t)
|
|
|
|
assert(t.icon == beautiful.awesome_icon)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
t:delete()
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
tags = mouse.screen.tags
|
|
|
|
assert(#tags == 9)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
found = false
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
for _, v in ipairs(tags) do
|
|
|
|
if t == v then
|
|
|
|
found = true
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(not found)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
-- Test selected tags, view only and selected()
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
t = tags[2]
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(not t.selected)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(t.screen.selected_tag == tags[1])
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
t:view_only()
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(t.selected)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(not tags[1].selected)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
assert(#t.screen.selected_tags == 1)
|
2016-04-08 06:59:20 +02:00
|
|
|
|
2016-12-27 21:39:08 +01:00
|
|
|
return true
|
|
|
|
end
|
2018-10-14 04:42:28 +02:00
|
|
|
end,
|
|
|
|
|
|
|
|
-- Test the custom layout list
|
|
|
|
function()
|
|
|
|
local t = mouse.screen.tags[9]
|
|
|
|
assert(t)
|
|
|
|
|
|
|
|
-- Test that the global_layouts is the default
|
|
|
|
local global_layouts = awful.layout.layouts
|
|
|
|
|
|
|
|
local t_layouts = t.layouts
|
|
|
|
local count = #t_layouts
|
|
|
|
local original = gtable.clone(t_layouts, false)
|
|
|
|
assert(t_layouts and global_layouts)
|
|
|
|
|
|
|
|
assert(#global_layouts == #t_layouts)
|
|
|
|
for idx, l in ipairs(global_layouts) do
|
|
|
|
assert(t_layouts[idx] == l)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Make sure the list isn't forked
|
|
|
|
t.layout = global_layouts[3]
|
|
|
|
assert(t_layouts == t.layouts)
|
|
|
|
|
|
|
|
-- Add a dummy layout
|
|
|
|
t.layout = {name = "fake1", arrange=function() end}
|
|
|
|
assert(#t.layouts == #global_layouts+1)
|
|
|
|
|
|
|
|
-- Make sure adding global layouts still work
|
|
|
|
table.insert(global_layouts, {name = "fake2", arrange=function() end})
|
|
|
|
assert(#t.layouts == count+2)
|
|
|
|
|
|
|
|
-- Test that the global list is forked when there is no other
|
|
|
|
-- options.
|
|
|
|
table.insert(global_layouts, function()
|
|
|
|
return {name = "fake2", arrange=function() end}
|
|
|
|
end)
|
|
|
|
assert(#t.layouts == count+3)
|
|
|
|
assert(#original == #global_layouts-2)
|
|
|
|
assert(not t._layouts)
|
|
|
|
|
|
|
|
t.layout = global_layouts[#global_layouts]
|
|
|
|
|
|
|
|
assert(t._layouts)
|
|
|
|
assert(#t._custom_layouts+#global_layouts == #t.layouts)
|
|
|
|
assert(#t.layouts == count+3, "Expected "..(count+3).." got "..#t.layouts)
|
|
|
|
|
|
|
|
-- Create a custom list of layouts
|
|
|
|
t.layouts = {
|
|
|
|
awful.layout.suit.fair,
|
|
|
|
awful.layout.suit.fair.horizontal,
|
|
|
|
}
|
|
|
|
|
|
|
|
-- 3 because the current layout was added
|
|
|
|
assert(#t.layouts == 3)
|
|
|
|
|
|
|
|
t.layout = {name = "fake3", arrange=function() end}
|
|
|
|
assert(#t.layouts == 4)
|
|
|
|
|
|
|
|
-- Test the layout template and stateful layouts
|
|
|
|
t.layouts = {
|
|
|
|
t.layout,
|
|
|
|
function() return {name = "fake4", arrange=function() end} end
|
|
|
|
}
|
|
|
|
assert(#t.layouts == 2)
|
|
|
|
|
|
|
|
t.layout = t.layouts[2]
|
|
|
|
assert(#t.layouts == 2)
|
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
2016-04-08 06:59:20 +02:00
|
|
|
}
|
|
|
|
|
2016-08-29 05:49:01 +02:00
|
|
|
local multi_screen_steps = {}
|
|
|
|
|
|
|
|
-- Clear the state (this step will be called once per disposition)
|
|
|
|
table.insert(multi_screen_steps, function()
|
|
|
|
if #client.get() == 0 then
|
|
|
|
-- Remove all existing tags created by the rc.lua callback
|
|
|
|
for s in screen do
|
|
|
|
while #s.tags > 0 do
|
|
|
|
local t = s.tags[1]
|
|
|
|
-- Test #1051 against regressions
|
|
|
|
assert(t.index == 1)
|
|
|
|
|
|
|
|
assert(t.screen == s)
|
|
|
|
|
|
|
|
t:delete()
|
|
|
|
assert(not t.activated)
|
|
|
|
assert(t.screen == nil)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
for _, c in ipairs(client.get()) do
|
|
|
|
c:kill()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Add a bunch of tags on each screens.
|
|
|
|
table.insert(multi_screen_steps, function()
|
|
|
|
for i=1, screen.count() do
|
|
|
|
local s = screen[i]
|
|
|
|
-- Add 5 tags per screen
|
|
|
|
for idx=1, 5 do
|
|
|
|
awful.tag.add("S"..i..":"..idx,{screen = s})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Check if everything adds up
|
|
|
|
for i=1, screen.count() do
|
|
|
|
local tags = screen[i].tags
|
|
|
|
assert(#tags == 5)
|
|
|
|
|
|
|
|
for k, t in ipairs(tags) do
|
|
|
|
assert(t.index == k)
|
|
|
|
assert(t.name == "S"..i..":"..k)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Select a tag on each screen
|
|
|
|
for i=1, screen.count() do
|
|
|
|
screen[i].tags[1].selected = true
|
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
|
|
|
end)
|
|
|
|
|
|
|
|
local function check_tag_indexes()
|
|
|
|
for s in screen do
|
|
|
|
for i, t in ipairs(s.tags) do
|
|
|
|
assert(t.index == i)
|
|
|
|
assert(t.screen == s)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Move tags across screens (without clients)
|
|
|
|
table.insert(multi_screen_steps, function()
|
|
|
|
-- This screen disposition cannot be used for this test, move on
|
|
|
|
if screen.count() < 2 then return true end
|
|
|
|
|
|
|
|
local s1, s2 = screen[1], screen[2]
|
|
|
|
|
|
|
|
local old_count1, old_count2 = #s1.tags, #s2.tags
|
|
|
|
|
|
|
|
local t = awful.tag.add("TEST", {screen=s1})
|
|
|
|
|
|
|
|
-- Check the current state
|
|
|
|
assert( t.index == old_count1+1 )
|
|
|
|
assert( t.screen == s1 )
|
|
|
|
assert( #s1.tags == old_count1+1 )
|
|
|
|
assert( s1.tags[old_count1+1] == t )
|
|
|
|
assert( #s2.tags == old_count2 )
|
|
|
|
|
|
|
|
-- Move to another index
|
|
|
|
local new_index = 3
|
|
|
|
t.index = new_index
|
|
|
|
assert(t.index == new_index)
|
|
|
|
check_tag_indexes()
|
|
|
|
|
|
|
|
-- Move the tag to screen 2
|
|
|
|
t.screen = s2
|
|
|
|
assert(t.screen == s2 )
|
|
|
|
assert(#s1.tags == old_count1 )
|
|
|
|
assert(#s2.tags == old_count2+1 )
|
|
|
|
assert( s2.tags[old_count2+1] == t )
|
|
|
|
assert( t.index == old_count2+1 )
|
|
|
|
check_tag_indexes()
|
|
|
|
|
|
|
|
-- Move to another index
|
|
|
|
t.index = new_index
|
|
|
|
assert(t.index == new_index)
|
|
|
|
check_tag_indexes()
|
|
|
|
|
|
|
|
-- Delete it
|
|
|
|
t:delete()
|
|
|
|
check_tag_indexes()
|
|
|
|
|
|
|
|
return true
|
|
|
|
end)
|
|
|
|
|
2017-01-10 06:11:43 +01:00
|
|
|
local ms = require("_multi_screen")
|
|
|
|
ms.disable_wibox()
|
|
|
|
ms(steps, multi_screen_steps)
|
2016-08-29 05:49:01 +02:00
|
|
|
|
2016-04-08 06:59:20 +02:00
|
|
|
require("_runner").run_steps(steps)
|
2016-12-31 14:05:51 +01:00
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|