tests: fix indenting/style (#1303)

Basically:

> for f in **/*.lua; do vim '+set sw=4' '+norm gg=G' '+wq' "$f"; done
This commit is contained in:
Daniel Hahler 2016-12-27 21:39:08 +01:00 committed by GitHub
parent bdb7e90b74
commit 68de588f21
72 changed files with 1757 additions and 1770 deletions

View File

@ -355,16 +355,16 @@ local function clear_screen()
return return
end end
for s in screen do for s in screen do
local sur = surface.widget_to_surface( local sur = surface.widget_to_surface(
wibox.widget { wibox.widget {
bg = "#000000", bg = "#000000",
widget = wibox.container.background widget = wibox.container.background
}, },
s.geometry.width, s.geometry.width,
s.geometry.height s.geometry.height
) )
wallpaper.fit(sur, s, "#000000") wallpaper.fit(sur, s, "#000000")
end end
end end
-- Make it easier to debug the tests by showing the screen geometry when the -- Make it easier to debug the tests by showing the screen geometry when the
@ -419,97 +419,97 @@ local function add_steps(real_steps, new_steps)
end) end)
table.insert(real_steps, function() table.insert(real_steps, function()
clear_screen() clear_screen()
local keep = dispo.keep or false local keep = dispo.keep or false
local old = {} local old = {}
local geos = {} local geos = {}
check_tag_indexes()
if keep then
for _, sf in ipairs(dispo) do
local geo = sf and sf() or nil
-- If the function return nothing, assume the screen need to
-- be destroyed.
table.insert(geos, geo or false)
end
-- Removed screens need to be explicit.
assert(#geos >= screen.count())
-- Keep a cache to avoid working with invalid data
local old_screens = {}
for s in screen do
table.insert(old_screens, s)
end
for i, s in ipairs(old_screens) do
-- Remove the screen (if no new geometry is given
if not geos[i] then
s:fake_remove()
else
local cur_geo = s.geometry
for _, v in ipairs {"x", "y", "width", "height" } do
cur_geo[v] = geos[i][v] or cur_geo[v]
end
s:fake_resize(
cur_geo.x,
cur_geo.y,
cur_geo.width,
cur_geo.height
)
end
end
-- Add the remaining screens
for i=#old_screens + 1, #geos do
local geo = geos[i]
screen.fake_add(geo.x, geo.y, geo.width, geo.height)
end
check_tag_indexes() check_tag_indexes()
else
if keep then -- Move all existing screens out of the way (to avoid temporary overlapping)
for _, sf in ipairs(dispo) do for s in screen do
local geo = sf and sf() or nil s:fake_resize(canvas_w, canvas_h, 1, 1)
table.insert(old, s)
-- If the function return nothing, assume the screen need to
-- be destroyed.
table.insert(geos, geo or false)
end
-- Removed screens need to be explicit.
assert(#geos >= screen.count())
-- Keep a cache to avoid working with invalid data
local old_screens = {}
for s in screen do
table.insert(old_screens, s)
end
for i, s in ipairs(old_screens) do
-- Remove the screen (if no new geometry is given
if not geos[i] then
s:fake_remove()
else
local cur_geo = s.geometry
for _, v in ipairs {"x", "y", "width", "height" } do
cur_geo[v] = geos[i][v] or cur_geo[v]
end
s:fake_resize(
cur_geo.x,
cur_geo.y,
cur_geo.width,
cur_geo.height
)
end
end
-- Add the remaining screens
for i=#old_screens + 1, #geos do
local geo = geos[i]
screen.fake_add(geo.x, geo.y, geo.width, geo.height)
end
check_tag_indexes()
else
-- Move all existing screens out of the way (to avoid temporary overlapping)
for s in screen do
s:fake_resize(canvas_w, canvas_h, 1, 1)
table.insert(old, s)
end
-- Add the new screens
for _, sf in ipairs(dispo) do
local geo = sf()
screen.fake_add(geo.x, geo.y, geo.width, geo.height)
table.insert(geos, geo)
end
-- Remove old screens
for _, s in ipairs(old) do
s:fake_remove()
end
end end
show_screens() -- Add the new screens
for _, sf in ipairs(dispo) do
-- Check the result is correct local geo = sf()
local expected_count = 0 screen.fake_add(geo.x, geo.y, geo.width, geo.height)
for _,v in ipairs(geos) do table.insert(geos, geo)
expected_count = expected_count + (v and 1 or 0)
end end
assert(expected_count == screen.count()) -- Remove old screens
for k, geo in ipairs(geos) do for _, s in ipairs(old) do
if geo then s:fake_remove()
local sgeo = screen[k].geometry
assert(geo.x == sgeo.x)
assert(geo.y == sgeo.y)
assert(geo.width == sgeo.width )
assert(geo.height == sgeo.height)
end
end end
end
return true show_screens()
end)
-- Check the result is correct
local expected_count = 0
for _,v in ipairs(geos) do
expected_count = expected_count + (v and 1 or 0)
end
assert(expected_count == screen.count())
for k, geo in ipairs(geos) do
if geo then
local sgeo = screen[k].geometry
assert(geo.x == sgeo.x)
assert(geo.y == sgeo.y)
assert(geo.width == sgeo.width )
assert(geo.height == sgeo.height)
end
end
return true
end)
for _, step in ipairs(new_steps) do for _, step in ipairs(new_steps) do
table.insert(real_steps, step) table.insert(real_steps, step)
@ -518,5 +518,5 @@ local function add_steps(real_steps, new_steps)
end end
return setmetatable(module, { return setmetatable(module, {
__call = function(_,...) return add_steps(...) end __call = function(_,...) return add_steps(...) end
}) })

View File

@ -2,7 +2,7 @@ local timer = require("gears.timer")
local awful = require("awful") local awful = require("awful")
local runner = { local runner = {
quit_awesome_on_error = os.getenv('TEST_PAUSE_ON_ERRORS') ~= '1', quit_awesome_on_error = os.getenv('TEST_PAUSE_ON_ERRORS') ~= '1',
} }
-- Helpers. -- Helpers.
@ -10,8 +10,8 @@ local runner = {
--- Add some rules to awful.rules.rules, after the defaults. --- Add some rules to awful.rules.rules, after the defaults.
local default_rules = awful.util.table.clone(awful.rules.rules) local default_rules = awful.util.table.clone(awful.rules.rules)
runner.add_to_default_rules = function(r) runner.add_to_default_rules = function(r)
awful.rules.rules = awful.util.table.clone(default_rules) awful.rules.rules = awful.util.table.clone(default_rules)
table.insert(awful.rules.rules, r) table.insert(awful.rules.rules, r)
end end
-- Was the runner started already? -- Was the runner started already?
@ -30,72 +30,72 @@ timer.start_new(1, function()
end) end)
runner.run_steps = function(steps) runner.run_steps = function(steps)
-- Setup timer/timeout to limit waiting for signal and quitting awesome. -- Setup timer/timeout to limit waiting for signal and quitting awesome.
-- This would be common for all tests. -- This would be common for all tests.
local t = timer({timeout=0.1}) local t = timer({timeout=0.1})
local wait=20 local wait=20
local step=1 local step=1
local step_count=0 local step_count=0
assert(not running, "run_steps() was called twice") assert(not running, "run_steps() was called twice")
running = true running = true
t:connect_signal("timeout", function() timer.delayed_call(function() t:connect_signal("timeout", function() timer.delayed_call(function()
io.flush() -- for "tail -f". io.flush() -- for "tail -f".
step_count = step_count + 1 step_count = step_count + 1
local step_as_string = step..'/'..#steps..' (@'..step_count..')' local step_as_string = step..'/'..#steps..' (@'..step_count..')'
-- Call the current step's function. -- Call the current step's function.
local success, result = xpcall(function() local success, result = xpcall(function()
return steps[step](step_count) return steps[step](step_count)
end, debug.traceback) end, debug.traceback)
if not success then if not success then
io.stderr:write('Error: running function for step ' io.stderr:write('Error: running function for step '
..step_as_string..': '..tostring(result)..'!\n') ..step_as_string..': '..tostring(result)..'!\n')
t:stop() t:stop()
if not runner.quit_awesome_on_error then if not runner.quit_awesome_on_error then
io.stderr:write("Keeping awesome open...\n") io.stderr:write("Keeping awesome open...\n")
return -- keep awesome open on error. return -- keep awesome open on error.
end end
elseif result then elseif result then
-- true: test succeeded. -- true: test succeeded.
if step < #steps then if step < #steps then
-- Next step. -- Next step.
step = step+1 step = step+1
step_count = 0 step_count = 0
wait = 5 wait = 5
t:again() t:again()
return return
end end
elseif result == false then elseif result == false then
io.stderr:write("Step "..step_as_string.." failed (returned false).") io.stderr:write("Step "..step_as_string.." failed (returned false).")
if not runner.quit_awesome_on_error then if not runner.quit_awesome_on_error then
io.stderr:write("Keeping awesome open...\n") io.stderr:write("Keeping awesome open...\n")
return return
end end
else else
wait = wait-1 wait = wait-1
if wait > 0 then if wait > 0 then
t:again() t:again()
else else
io.stderr:write("Error: timeout waiting for signal in step " io.stderr:write("Error: timeout waiting for signal in step "
..step_as_string..".\n") ..step_as_string..".\n")
t:stop() t:stop()
end end
return return
end end
-- Remove any clients. -- Remove any clients.
for _,c in ipairs(client.get()) do for _,c in ipairs(client.get()) do
c:kill() c:kill()
end end
if success and result then if success and result then
io.stderr:write("Test finished successfully\n") io.stderr:write("Test finished successfully\n")
end end
awesome.quit() awesome.quit()
end) end) end) end)
t:start() t:start()
end end
return runner return runner

View File

@ -1,10 +1,10 @@
screen[1]._resize {x = 175, width = 128, height = 96} --DOC_HIDE screen[1]._resize {x = 175, width = 128, height = 96} --DOC_HIDE
mouse.coords {x=175+60,y=60} --DOC_HIDE mouse.coords {x=175+60,y=60} --DOC_HIDE
-- Get the position -- Get the position
print(mouse.coords().x) print(mouse.coords().x)
-- Change the position -- Change the position
mouse.coords { mouse.coords {
x = 185, x = 185,
y = 10 y = 10

View File

@ -2,13 +2,13 @@
local placement = require("awful.placement") local placement = require("awful.placement")
screen[1]._resize {x= 50} screen[1]._resize {x= 50}
for _, pos in ipairs{ for _, pos in ipairs{
"top_left", "top_right", "bottom_left", "bottom_right", "top_left", "top_right", "bottom_left", "bottom_right",
"left", "right", "top", "bottom", "centered", "left", "right", "top", "bottom", "centered",
} do } do
local c1 = client.gen_fake {x = 80, y = 55, width=75, height=50} local c1 = client.gen_fake {x = 80, y = 55, width=75, height=50}
c1:_hide() c1:_hide()
placement.align(client.focus, {position = pos, honor_workarea=true}) placement.align(client.focus, {position = pos, honor_workarea=true})
c1:set_label(pos) c1:set_label(pos)
end end
screen._add_screen {x = 70, y = 260 , width = 128, height = 96} screen._add_screen {x = 70, y = 260 , width = 128, height = 96}

View File

@ -12,5 +12,5 @@ local c = client.gen_fake {x = 45, y = 35, width=40, height=30} --DOC_HIDE
awful.placement.bottom(client.focus) awful.placement.bottom(client.focus)
assert(c.x == screen[1].geometry.width/2-40/2-c.border_width--DOC_HIDE assert(c.x == screen[1].geometry.width/2-40/2-c.border_width--DOC_HIDE
and c.y==screen[1].geometry.height-30-2*c.border_width--DOC_HIDE and c.y==screen[1].geometry.height-30-2*c.border_width--DOC_HIDE
and c.width==40 and c.height==30)--DOC_HIDE and c.width==40 and c.height==30)--DOC_HIDE

View File

@ -12,8 +12,8 @@ local c = client.gen_fake {x = 45, y = 35, width=40, height=30} --DOC_HIDE
awful.placement.bottom_left(client.focus) awful.placement.bottom_left(client.focus)
assert( --DOC_HIDE assert( --DOC_HIDE
c.x == 0 --DOC_HIDE c.x == 0 --DOC_HIDE
and c.y+2*c.border_width == screen[1].geometry.height-30 --DOC_HIDE and c.y+2*c.border_width == screen[1].geometry.height-30 --DOC_HIDE
and c.width == 40--DOC_HIDE and c.width == 40--DOC_HIDE
and c.height == 30--DOC_HIDE and c.height == 30--DOC_HIDE
) --DOC_HIDE ) --DOC_HIDE

View File

@ -5,7 +5,7 @@ local bw = c.border_width --DOC_HIDE
-- Left --DOC_HIDE -- Left --DOC_HIDE
mouse.coords {x=100,y=100} --DOC_HIDE mouse.coords {x=100,y=100} --DOC_HIDE
-- Move the mouse to the closest corner of the focused client -- Move the mouse to the closest corner of the focused client
awful.placement.closest_corner(mouse, {include_sides=true, parent=c}) awful.placement.closest_corner(mouse, {include_sides=true, parent=c})
mouse.push_history() --DOC_HIDE mouse.push_history() --DOC_HIDE
assert(mouse.coords().x == c.x) --DOC_HIDE assert(mouse.coords().x == c.x) --DOC_HIDE
@ -53,8 +53,8 @@ awful.placement.closest_corner(mouse, {include_sides=true, parent=c}) --DOC_HIDE
mouse.push_history() --DOC_HIDE mouse.push_history() --DOC_HIDE
assert(mouse.coords().x == c.x and mouse.coords().y == c.y+c.height+2*bw) --DOC_HIDE assert(mouse.coords().x == c.x and mouse.coords().y == c.y+c.height+2*bw) --DOC_HIDE
-- It is possible to emulate the mouse API to get the closest corner of -- It is possible to emulate the mouse API to get the closest corner of
-- random area -- random area
local _, corner = awful.placement.closest_corner( local _, corner = awful.placement.closest_corner(
{coords=function() return {x = 100, y=100} end}, {coords=function() return {x = 100, y=100} end},
{include_sides = true, bounding_rect = {x=0, y=0, width=200, height=200}} {include_sides = true, bounding_rect = {x=0, y=0, width=200, height=200}}

View File

@ -2,10 +2,10 @@ screen[1]._resize {x = 175, width = 128, height = 96} --DOC_NO_USAGE --DOC_HIDE
local awful = {placement = require("awful.placement")} --DOC_HIDE local awful = {placement = require("awful.placement")} --DOC_HIDE
local c = client.gen_fake {x = 220, y = 35, width=40, height=30} --DOC_HIDE local c = client.gen_fake {x = 220, y = 35, width=40, height=30} --DOC_HIDE
-- "right" will be replaced by "left" -- "right" will be replaced by "left"
local f = (awful.placement.right + awful.placement.left) local f = (awful.placement.right + awful.placement.left)
f(client.focus) f(client.focus)
local sg = screen[1].geometry--DOC_HIDE local sg = screen[1].geometry--DOC_HIDE
assert(c.x == sg.x and c.y==sg.height/2-30/2-c.border_width--DOC_HIDE assert(c.x == sg.x and c.y==sg.height/2-30/2-c.border_width--DOC_HIDE
and c.width==40 and c.height==30)--DOC_HIDE and c.width==40 and c.height==30)--DOC_HIDE

View File

@ -2,14 +2,14 @@ screen[1]._resize {x = 175, width = 128, height = 96} --DOC_NO_USAGE --DOC_HIDE
local awful = {placement = require("awful.placement")} --DOC_HIDE local awful = {placement = require("awful.placement")} --DOC_HIDE
local c = client.gen_fake {x = 220, y = 35, width=40, height=30} --DOC_HIDE local c = client.gen_fake {x = 220, y = 35, width=40, height=30} --DOC_HIDE
-- Simulate Windows 7 "edge snap" (also called aero snap) feature -- Simulate Windows 7 "edge snap" (also called aero snap) feature
local axis = "vertically" local axis = "vertically"
local f = awful.placement.scale local f = awful.placement.scale
+ awful.placement.left + awful.placement.left
+ (axis and awful.placement["maximize_"..axis] or nil) + (axis and awful.placement["maximize_"..axis] or nil)
local geo = f(client.focus, {honor_workarea=true, to_percent = 0.5}) local geo = f(client.focus, {honor_workarea=true, to_percent = 0.5})
local wa = screen[1].workarea--DOC_HIDE local wa = screen[1].workarea--DOC_HIDE
assert(c.x == wa.x and geo.x == wa.x)--DOC_HIDE assert(c.x == wa.x and geo.x == wa.x)--DOC_HIDE

View File

@ -12,4 +12,4 @@ local c = client.gen_fake {x = 45, y = 35, width=40, height=30} --DOC_HIDE
awful.placement.left(client.focus) awful.placement.left(client.focus)
assert(c.x == 0 and c.y==screen[1].geometry.height/2-30/2-c.border_width--DOC_HIDE assert(c.x == 0 and c.y==screen[1].geometry.height/2-30/2-c.border_width--DOC_HIDE
and c.width==40 and c.height==30)--DOC_HIDE and c.width==40 and c.height==30)--DOC_HIDE

View File

@ -4,15 +4,15 @@ screen._add_screen {x = 280, y = 0, width = 128, height = 96} --DOC_HIDE
local placement = require("awful.placement") --DOC_HIDE local placement = require("awful.placement") --DOC_HIDE
for k, pos in ipairs{ --DOC_HIDE for k, pos in ipairs{ --DOC_HIDE
"", "vertical", "horizontal" --DOC_HIDE "", "vertical", "horizontal" --DOC_HIDE
} do --DOC_HIDE } do --DOC_HIDE
local c1 = client.gen_fake {--DOC_HIDE local c1 = client.gen_fake {--DOC_HIDE
x = screen[k].geometry.x+40, --DOC_HIDE x = screen[k].geometry.x+40, --DOC_HIDE
y = screen[k].geometry.y+40, width=75, height=50, screen=screen[k]} --DOC_HIDE y = screen[k].geometry.y+40, width=75, height=50, screen=screen[k]} --DOC_HIDE
placement.maximize(c1, {axis = pos ~= "" and pos or nil}) --DOC_HIDE placement.maximize(c1, {axis = pos ~= "" and pos or nil}) --DOC_HIDE
if k == 1 then --DOC_HIDE if k == 1 then --DOC_HIDE
assert(c1.width+2*c1.border_width == screen[1].geometry.width and --DOC_HIDE assert(c1.width+2*c1.border_width == screen[1].geometry.width and --DOC_HIDE
c1.height+2*c1.border_width == screen[1].geometry.height) --DOC_HIDE c1.height+2*c1.border_width == screen[1].geometry.height) --DOC_HIDE
end --DOC_HIDE end --DOC_HIDE
end --DOC_HIDE end --DOC_HIDE

View File

@ -8,8 +8,8 @@ local function test_touch_mouse(c)
local coords = mouse.coords() local coords = mouse.coords()
return c:geometry().x == coords.x or c:geometry().y == coords.y return c:geometry().x == coords.x or c:geometry().y == coords.y
or c:geometry().x+c:geometry().width+2*c.border_width == coords.x or c:geometry().x+c:geometry().width+2*c.border_width == coords.x
or c:geometry().y+c:geometry().height+2*c.border_width == coords.y or c:geometry().y+c:geometry().height+2*c.border_width == coords.y
end end
for s=1, 8 do for s=1, 8 do

View File

@ -6,11 +6,11 @@ screen._add_screen {x = 140, y = 110, width = 128, height = 96}
local placement = require("awful.placement") local placement = require("awful.placement")
for k, pos in ipairs{ for k, pos in ipairs{
"up", "down", "left", "right" "up", "down", "left", "right"
} do } do
local c1 = client.gen_fake {--DOC_HIDE local c1 = client.gen_fake {--DOC_HIDE
x = screen[k].geometry.x+20, x = screen[k].geometry.x+20,
y = screen[k].geometry.y+20, width=75, height=50, screen=screen[k]} y = screen[k].geometry.y+20, width=75, height=50, screen=screen[k]}
placement.stretch(c1, {direction=pos}) placement.stretch(c1, {direction=pos})
end end

View File

@ -15,4 +15,4 @@ assert(c.x==45) --DOC_HIDE
assert(c.y==35) --DOC_HIDE assert(c.y==35) --DOC_HIDE
assert(c.width == 40) --DOC_HIDE assert(c.width == 40) --DOC_HIDE
assert(c.y+c.height+2*c.border_width == --DOC_HIDE assert(c.y+c.height+2*c.border_width == --DOC_HIDE
screen[1].geometry.y + screen[1].geometry.height) --DOC_HIDE screen[1].geometry.y + screen[1].geometry.height) --DOC_HIDE

View File

@ -12,4 +12,4 @@ local c = client.gen_fake {x = 45, y = 35, width=40, height=30} --DOC_HIDE
awful.placement.top_right(client.focus) awful.placement.top_right(client.focus)
assert(c.x == screen[1].geometry.width-40-2*c.border_width and c.y==0 --DOC_HIDE assert(c.x == screen[1].geometry.width-40-2*c.border_width and c.y==0 --DOC_HIDE
and c.width==40 and c.height==30)--DOC_HIDE and c.width==40 and c.height==30)--DOC_HIDE

View File

@ -4,9 +4,9 @@ shape.infobubble(cr, 70, 70)
show(cr) --DOC_HIDE show(cr) --DOC_HIDE
shape.transform(shape.infobubble) : translate(0, 20) shape.transform(shape.infobubble) : translate(0, 20)
: rotate_at(35,35,math.pi) (cr,70,20,10, 5, 35 - 5) : rotate_at(35,35,math.pi) (cr,70,20,10, 5, 35 - 5)
show(cr) --DOC_HIDE show(cr) --DOC_HIDE
shape.transform(shape.infobubble) shape.transform(shape.infobubble)
: rotate_at(35,35,3*math.pi/2) (cr,70,70, nil, nil, 40) : rotate_at(35,35,3*math.pi/2) (cr,70,70, nil, nil, 40)
show(cr) --DOC_HIDE show(cr) --DOC_HIDE

View File

@ -105,9 +105,9 @@ function client.gen_fake(args)
assert(not args.screen or (args.screen == ret.screen)) assert(not args.screen or (args.screen == ret.screen))
return setmetatable(ret, { return setmetatable(ret, {
__index = function(...) return meta.__index(...) end, __index = function(...) return meta.__index(...) end,
__newindex = function(...) return meta.__newindex(...) end __newindex = function(...) return meta.__newindex(...) end
}) })
end end
function client.get(s) function client.get(s)

View File

@ -11,14 +11,14 @@ local function new_drawin(_, args)
end end
return setmetatable(ret, { return setmetatable(ret, {
__index = function(...) return meta.__index(...) end, __index = function(...) return meta.__index(...) end,
__newindex = function(...) return meta.__newindex(...) end __newindex = function(...) return meta.__newindex(...) end
}) })
end end
return setmetatable(drawin, { return setmetatable(drawin, {
__call = new_drawin, __call = new_drawin,
}) })
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -26,26 +26,26 @@ local function create_screen(args)
local wa = args.workarea_sides or 10 local wa = args.workarea_sides or 10
return setmetatable(s,{ __index = function(_, key) return setmetatable(s,{ __index = function(_, key)
if key == "geometry" then if key == "geometry" then
return { return {
x = geo.x or 0, x = geo.x or 0,
y = geo.y or 0, y = geo.y or 0,
width = geo.width , width = geo.width ,
height = geo.height, height = geo.height,
} }
elseif key == "workarea" then elseif key == "workarea" then
return { return {
x = (geo.x or 0) + wa , x = (geo.x or 0) + wa ,
y = (geo.y or 0) + wa , y = (geo.y or 0) + wa ,
width = geo.width - 2*wa, width = geo.width - 2*wa,
height = geo.height - 2*wa, height = geo.height - 2*wa,
} }
else else
return meta.__index(_, key) return meta.__index(_, key)
end end
end, end,
__newindex = function(...) return meta.__newindex(...) end __newindex = function(...) return meta.__newindex(...) end
}) })
end end
local screens = {} local screens = {}

View File

@ -24,14 +24,14 @@ local function new_tag(_, args)
table.insert(root._tags, ret) table.insert(root._tags, ret)
return setmetatable(ret, { return setmetatable(ret, {
__index = function(...) return meta.__index(...) end, __index = function(...) return meta.__index(...) end,
__newindex = function(...) return meta.__newindex(...) end __newindex = function(...) return meta.__newindex(...) end
}) })
end end
return setmetatable(tag, { return setmetatable(tag, {
__call = new_tag, __call = new_tag,
}) })
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -1,8 +1,8 @@
local gears = require("gears") --DOC_HIDE local gears = require("gears") --DOC_HIDE
-- Create a class for this object. It will be used as a backup source for -- Create a class for this object. It will be used as a backup source for
-- methods and accessors. It is also possible to set them directly on the -- methods and accessors. It is also possible to set them directly on the
-- object. -- object.
local class = {} local class = {}
function class:get_foo() function class:get_foo()
@ -39,7 +39,7 @@ print(o.foo)
o:method(1, 2, 3) o:method(1, 2, 3)
-- Random properties can also be added, the signal will be emitted automatically. -- Random properties can also be added, the signal will be emitted automatically.
o:connect_signal("property::something", function(obj, value) o:connect_signal("property::something", function(obj, value)
assert(obj == o) assert(obj == o)

View File

@ -2,23 +2,23 @@ local gears = require("gears") --DOC_HIDE
local o = gears.object{} local o = gears.object{}
-- Function can be attached to signals -- Function can be attached to signals
local function slot(obj, a, b, c) local function slot(obj, a, b, c)
print("In slot", obj, a, b, c) print("In slot", obj, a, b, c)
end end
o:connect_signal("my_signal", slot) o:connect_signal("my_signal", slot)
-- Emitting can be done without arguments. In that case, the object will be -- Emitting can be done without arguments. In that case, the object will be
-- implicitly added as an argument. -- implicitly added as an argument.
o:emit_signal "my_signal" o:emit_signal "my_signal"
-- It is also possible to add as many random arguments are required. -- It is also possible to add as many random arguments are required.
o:emit_signal("my_signal", "foo", "bar", 42) o:emit_signal("my_signal", "foo", "bar", 42)
-- Finally, to allow the object to be garbage collected (the memory freed), it -- Finally, to allow the object to be garbage collected (the memory freed), it
-- is necessary to disconnect the signal or use `weak_connect_signal` -- is necessary to disconnect the signal or use `weak_connect_signal`
o:disconnect_signal("my_signal", slot) o:disconnect_signal("my_signal", slot)
-- This time, the `slot` wont be called as it is no longer connected. -- This time, the `slot` wont be called as it is no longer connected.
o:emit_signal "my_signal" o:emit_signal "my_signal"

View File

@ -9,30 +9,30 @@ parent:add(l)
for _, v in ipairs {"", "#00ff00", "#0000ff"} do for _, v in ipairs {"", "#00ff00", "#0000ff"} do
l:add(wibox.widget { l:add(wibox.widget {
{ {
text = v~="" and v or "nil", text = v~="" and v or "nil",
align = "center", align = "center",
valign = "center", valign = "center",
widget = wibox.widget.textbox, widget = wibox.widget.textbox,
}, },
colors = { colors = {
beautiful.bg_normal, beautiful.bg_normal,
beautiful.bg_highlight, beautiful.bg_highlight,
beautiful.border_color, beautiful.border_color,
}, },
values = { values = {
1, 1,
2, 2,
3, 3,
}, },
max_value = 10, max_value = 10,
min_value = 0, min_value = 0,
rounded_edge = false, rounded_edge = false,
bg = v~="" and v or nil, bg = v~="" and v or nil,
border_width = 0.5, border_width = 0.5,
border_color = "#000000", border_color = "#000000",
widget = wibox.container.arcchart widget = wibox.container.arcchart
}) })
end end
return nil, 60 return nil, 60

View File

@ -11,38 +11,38 @@ parent:add(l)
for _, v in ipairs {0,1,3,6.5} do for _, v in ipairs {0,1,3,6.5} do
l:add(wibox.widget { l:add(wibox.widget {
{ {
{ {
{ {
text = v, text = v,
align = "center", align = "center",
valign = "center", valign = "center",
widget = wibox.widget.textbox, widget = wibox.widget.textbox,
}, },
bg= "#ff000044", bg= "#ff000044",
widget = wibox.container.background, widget = wibox.container.background,
}, },
colors = { colors = {
beautiful.bg_normal, beautiful.bg_normal,
beautiful.bg_highlight, beautiful.bg_highlight,
beautiful.border_color, beautiful.border_color,
}, },
values = { values = {
1, 1,
2, 2,
3, 3,
}, },
max_value = 10, max_value = 10,
min_value = 0, min_value = 0,
rounded_edge = false, rounded_edge = false,
bg = "#00ff0033", bg = "#00ff0033",
border_width = v, border_width = v,
border_color = "#000000", border_color = "#000000",
widget = wibox.container.arcchart widget = wibox.container.arcchart
}, },
bg = cols[_], bg = cols[_],
widget = wibox.container.background widget = wibox.container.background
}) })
end end
return nil, 60 return nil, 60

View File

@ -9,71 +9,71 @@ parent:add(l)
for _, v in ipairs {0, 2, 4} do for _, v in ipairs {0, 2, 4} do
l:add(wibox.widget { l:add(wibox.widget {
{ {
{ {
text = v, text = v,
align = "center", align = "center",
valign = "center", valign = "center",
widget = wibox.widget.textbox, widget = wibox.widget.textbox,
}, },
bg= beautiful.bg_normal, bg= beautiful.bg_normal,
widget = wibox.container.background, widget = wibox.container.background,
}, },
colors = { colors = {
beautiful.bg_normal, beautiful.bg_normal,
beautiful.bg_highlight, beautiful.bg_highlight,
beautiful.border_color, beautiful.border_color,
}, },
values = { values = {
1, 1,
2, 2,
3, 3,
}, },
max_value = 10, max_value = 10,
min_value = 0, min_value = 0,
rounded_edge = false, rounded_edge = false,
bg = "#ff000033", bg = "#ff000033",
border_width = 0.5, border_width = 0.5,
border_color = "#000000", border_color = "#000000",
paddings = v, paddings = v,
widget = wibox.container.arcchart widget = wibox.container.arcchart
}) })
end end
l:add(wibox.widget { l:add(wibox.widget {
{ {
{ {
text = 6, text = 6,
align = "center", align = "center",
valign = "center", valign = "center",
widget = wibox.widget.textbox, widget = wibox.widget.textbox,
}, },
bg= beautiful.bg_normal, bg= beautiful.bg_normal,
widget = wibox.container.background, widget = wibox.container.background,
}, },
colors = { colors = {
beautiful.bg_normal, beautiful.bg_normal,
beautiful.bg_highlight, beautiful.bg_highlight,
beautiful.border_color, beautiful.border_color,
}, },
values = { values = {
1, 1,
2, 2,
3, 3,
}, },
max_value = 10, max_value = 10,
min_value = 0, min_value = 0,
rounded_edge = false, rounded_edge = false,
bg = "#ff000033", bg = "#ff000033",
border_width = 0.5, border_width = 0.5,
border_color = "#000000", border_color = "#000000",
paddings = { paddings = {
left = 6, left = 6,
right = 6, right = 6,
top = 6, top = 6,
bottom = 6, bottom = 6,
}, },
widget = wibox.container.arcchart widget = wibox.container.arcchart
}) })
return nil, 60 return nil, 60

View File

@ -4,78 +4,78 @@ local wibox = require( "wibox" )
local beautiful = require( "beautiful" ) local beautiful = require( "beautiful" )
parent:add(wibox.widget { parent:add(wibox.widget {
{ {
{ {
markup = "<b>rounded_edge</b> = <i>false</i>", markup = "<b>rounded_edge</b> = <i>false</i>",
widget = wibox.widget.textbox widget = wibox.widget.textbox
}, },
{ {
{ {
{ {
colors = { colors = {
beautiful.bg_normal, beautiful.bg_normal,
beautiful.bg_highlight, beautiful.bg_highlight,
beautiful.border_color, beautiful.border_color,
}, },
values = { values = {
1, 1,
2, 2,
3, 3,
}, },
max_value = 10, max_value = 10,
min_value = 0, min_value = 0,
rounded_edge = false, rounded_edge = false,
bg = "#ff000033", bg = "#ff000033",
border_width = 0.5, border_width = 0.5,
border_color = "#000000", border_color = "#000000",
widget = wibox.container.arcchart widget = wibox.container.arcchart
}, },
margins = 2, margins = 2,
colors = { colors = {
beautiful.bg_normal, beautiful.bg_normal,
beautiful.bg_highlight, beautiful.bg_highlight,
beautiful.border_color, beautiful.border_color,
}, },
layout = wibox.container.margin layout = wibox.container.margin
}, },
margins = 1, margins = 1,
color = beautiful.border_color, color = beautiful.border_color,
layout = wibox.container.margin, layout = wibox.container.margin,
}, },
layout = wibox.layout.fixed.vertical layout = wibox.layout.fixed.vertical
}, },
{ {
{ {
markup = "<b>rounded_edge</b> = <i>true</i>", markup = "<b>rounded_edge</b> = <i>true</i>",
widget = wibox.widget.textbox widget = wibox.widget.textbox
}, },
{ {
{ {
colors = { colors = {
beautiful.bg_normal, beautiful.bg_normal,
beautiful.bg_highlight, beautiful.bg_highlight,
beautiful.border_color, beautiful.border_color,
}, },
values = { values = {
1, 1,
2, 2,
3, 3,
}, },
max_value = 10, max_value = 10,
min_value = 0, min_value = 0,
rounded_edge = true, rounded_edge = true,
bg = "#ff000033", bg = "#ff000033",
border_width = 0.5, border_width = 0.5,
border_color = "#000000", border_color = "#000000",
widget = wibox.container.arcchart widget = wibox.container.arcchart
}, },
margins = 1, margins = 1,
color = beautiful.border_color, color = beautiful.border_color,
layout = wibox.container.margin, layout = wibox.container.margin,
}, },
layout = wibox.layout.fixed.vertical layout = wibox.layout.fixed.vertical
}, },
layout = wibox.layout.flex.horizontal layout = wibox.layout.flex.horizontal
}) })
return 500, 60 return 500, 60

View File

@ -9,27 +9,27 @@ parent:add(l)
for _, v in ipairs {0, math.pi/2, math.pi} do for _, v in ipairs {0, math.pi/2, math.pi} do
l:add(wibox.widget { l:add(wibox.widget {
{ {
text = v, text = v,
align = "center", align = "center",
valign = "center", valign = "center",
widget = wibox.widget.textbox, widget = wibox.widget.textbox,
}, },
colors = { colors = {
beautiful.bg_normal, beautiful.bg_normal,
beautiful.bg_highlight, beautiful.bg_highlight,
beautiful.border_color, beautiful.border_color,
}, },
value = 1, value = 1,
max_value = 10, max_value = 10,
min_value = 0, min_value = 0,
rounded_edge = false, rounded_edge = false,
bg = "#ff000033", bg = "#ff000033",
start_angle = v, start_angle = v,
border_width = 0.5, border_width = 0.5,
border_color = "#000000", border_color = "#000000",
widget = wibox.container.arcchart widget = wibox.container.arcchart
}) })
end end
return nil, 60 return nil, 60

View File

@ -9,31 +9,31 @@ parent:add(l)
for _, v in ipairs {1,3,7,10} do for _, v in ipairs {1,3,7,10} do
l:add(wibox.widget { l:add(wibox.widget {
{ {
text = v, text = v,
align = "center", align = "center",
valign = "center", valign = "center",
widget = wibox.widget.textbox, widget = wibox.widget.textbox,
}, },
colors = { colors = {
beautiful.bg_normal, beautiful.bg_normal,
beautiful.bg_highlight, beautiful.bg_highlight,
beautiful.border_color, beautiful.border_color,
}, },
values = { values = {
1, 1,
2, 2,
3, 3,
}, },
max_value = 10, max_value = 10,
min_value = 0, min_value = 0,
rounded_edge = false, rounded_edge = false,
thickness = v, thickness = v,
bg = "#ff000033", bg = "#ff000033",
border_width = 0.5, border_width = 0.5,
border_color = "#000000", border_color = "#000000",
widget = wibox.container.arcchart widget = wibox.container.arcchart
}) })
end end
return nil, 60 return nil, 60

View File

@ -9,20 +9,20 @@ parent:add(l)
for _, v in ipairs {0,1,7,99} do for _, v in ipairs {0,1,7,99} do
l:add(wibox.widget { l:add(wibox.widget {
colors = { colors = {
beautiful.bg_normal, beautiful.bg_normal,
beautiful.bg_highlight, beautiful.bg_highlight,
beautiful.border_color, beautiful.border_color,
}, },
value = v, value = v,
max_value = 10, max_value = 10,
min_value = 0, min_value = 0,
rounded_edge = false, rounded_edge = false,
bg = "#ff000033", bg = "#ff000033",
border_width = 0.5, border_width = 0.5,
border_color = "#000000", border_color = "#000000",
widget = wibox.container.arcchart widget = wibox.container.arcchart
}) })
end end
return nil, 60 return nil, 60

View File

@ -35,9 +35,9 @@ local container = wibox.widget {
shape_border_width = beautiful.border_width, shape_border_width = beautiful.border_width,
widget = wibox.container.background, widget = wibox.container.background,
shape = shape.transform(shape.arrow) shape = shape.transform(shape.arrow)
: rotate_at(15,15,math.pi/2) : rotate_at(15,15,math.pi/2)
: translate(0,-8) : translate(0,-8)
: scale(0.9, 0.9), : scale(0.9, 0.9),
}, },
strategy = 'exact', strategy = 'exact',
width = 42, width = 42,

View File

@ -4,12 +4,12 @@ local assets = require( "xresources.assets" ) --DOC_HIDE
parent:add( --DOC_HIDE parent:add( --DOC_HIDE
wibox.widget { wibox.widget {
fit = function() return 128, 128 end, fit = function() return 128, 128 end,
draw = function(_, _, cr) draw = function(_, _, cr)
assets.gen_logo(cr, 128, 128, nil, "#535d6c") assets.gen_logo(cr, 128, 128, nil, "#535d6c")
end, end,
widget = wibox.widget.base.make_widget widget = wibox.widget.base.make_widget
} }
) --DOC_HIDE ) --DOC_HIDE

View File

@ -4,14 +4,14 @@ local assets = require( "xresources.assets" ) --DOC_HIDE
parent:add( --DOC_HIDE parent:add( --DOC_HIDE
wibox.widget { wibox.widget {
fit = function() return 148, 128 end, fit = function() return 148, 128 end,
draw = function(_, _, cr) draw = function(_, _, cr)
assets.gen_logo(cr, 128, 128, nil, "#535d6c") assets.gen_logo(cr, 128, 128, nil, "#535d6c")
cr:translate(128 + 128/16, 0) cr:translate(128 + 128/16, 0)
assets.gen_awesome_name(cr, 158, nil, "#535d6c", nil) assets.gen_awesome_name(cr, 158, nil, "#535d6c", nil)
end, end,
widget = wibox.widget.base.make_widget widget = wibox.widget.base.make_widget
} }
) --DOC_HIDE ) --DOC_HIDE

View File

@ -3,18 +3,18 @@ local wibox = require( "wibox" ) --DOC_HIDE
local beautiful = require( "beautiful" ) --DOC_HIDE local beautiful = require( "beautiful" ) --DOC_HIDE
parent:add( --DOC_HIDE parent:add( --DOC_HIDE
wibox.widget { wibox.widget {
checked = true, checked = true,
color = beautiful.bg_normal, color = beautiful.bg_normal,
bg = "#ff00ff", bg = "#ff00ff",
border_width = 3, border_width = 3,
paddings = 4, paddings = 4,
border_color = "#0000ff", border_color = "#0000ff",
check_color = "#ff0000", check_color = "#ff0000",
forced_width = 20, --DOC_HIDE forced_width = 20, --DOC_HIDE
forced_height = 20, --DOC_HIDE forced_height = 20, --DOC_HIDE
check_border_color = "#ffff00", check_border_color = "#ffff00",
check_border_width = 1, check_border_width = 1,
widget = wibox.widget.checkbox widget = wibox.widget.checkbox
} }
) --DOC_HIDE ) --DOC_HIDE

View File

@ -10,17 +10,17 @@ local l = wibox.widget { --DOC_HIDE
for _, s in ipairs {"rectangle", "circle", "losange", "octogon"} do for _, s in ipairs {"rectangle", "circle", "losange", "octogon"} do
l:add( --DOC_HIDE l:add( --DOC_HIDE
wibox.widget { wibox.widget {
checked = true, checked = true,
color = beautiful.bg_normal, color = beautiful.bg_normal,
paddings = 2, paddings = 2,
forced_width = 20, --DOC_HIDE forced_width = 20, --DOC_HIDE
forced_height = 20, --DOC_HIDE forced_height = 20, --DOC_HIDE
check_shape = gears.shape[s], check_shape = gears.shape[s],
widget = wibox.widget.checkbox widget = wibox.widget.checkbox
} }
) --DOC_HIDE ) --DOC_HIDE
end end

View File

@ -3,31 +3,31 @@ local wibox = require( "wibox" ) --DOC_HIDE
local beautiful = require( "beautiful" ) --DOC_HIDE local beautiful = require( "beautiful" ) --DOC_HIDE
parent:add( --DOC_HIDE parent:add( --DOC_HIDE
wibox.widget { wibox.widget {
checked = true, checked = true,
color = beautiful.bg_normal, color = beautiful.bg_normal,
paddings = 2, paddings = 2,
forced_width = 20, --DOC_HIDE forced_width = 20, --DOC_HIDE
forced_height = 20, --DOC_HIDE forced_height = 20, --DOC_HIDE
check_shape = function(cr, width, height) check_shape = function(cr, width, height)
local rs = math.min(width, height) local rs = math.min(width, height)
cr:move_to( 0 , 0 ) cr:move_to( 0 , 0 )
cr:line_to( rs , 0 ) cr:line_to( rs , 0 )
cr:move_to( 0 , 0 ) cr:move_to( 0 , 0 )
cr:line_to( 0 , rs ) cr:line_to( 0 , rs )
cr:move_to( 0 , rs ) cr:move_to( 0 , rs )
cr:line_to( rs , rs ) cr:line_to( rs , rs )
cr:move_to( rs , 0 ) cr:move_to( rs , 0 )
cr:line_to( rs , rs ) cr:line_to( rs , rs )
cr:move_to( 0 , 0 ) cr:move_to( 0 , 0 )
cr:line_to( rs , rs ) cr:line_to( rs , rs )
cr:move_to( 0 , rs ) cr:move_to( 0 , rs )
cr:line_to( rs , 0 ) cr:line_to( rs , 0 )
end, end,
check_border_color = "#ff0000", check_border_color = "#ff0000",
check_color = "#00000000", check_color = "#00000000",
check_border_width = 1, check_border_width = 1,
widget = wibox.widget.checkbox widget = wibox.widget.checkbox
} }
) --DOC_HIDE ) --DOC_HIDE

View File

@ -10,17 +10,17 @@ local l = wibox.widget { --DOC_HIDE
for _, s in ipairs {"rectangle", "circle", "losange", "octogon"} do for _, s in ipairs {"rectangle", "circle", "losange", "octogon"} do
l:add( --DOC_HIDE l:add( --DOC_HIDE
wibox.widget { wibox.widget {
checked = true, checked = true,
color = beautiful.bg_normal, color = beautiful.bg_normal,
paddings = 2, paddings = 2,
forced_width = 20, --DOC_HIDE forced_width = 20, --DOC_HIDE
forced_height = 20, --DOC_HIDE forced_height = 20, --DOC_HIDE
shape = gears.shape[s], shape = gears.shape[s],
widget = wibox.widget.checkbox widget = wibox.widget.checkbox
} }
) --DOC_HIDE ) --DOC_HIDE
end end

View File

@ -4,28 +4,28 @@ local beautiful = require( "beautiful" ) --DOC_HIDE
local gears = {shape = require("gears.shape")} --DOC_HIDE local gears = {shape = require("gears.shape")} --DOC_HIDE
parent:add( --DOC_HIDE parent:add( --DOC_HIDE
wibox.widget { --DOC_HIDE wibox.widget { --DOC_HIDE
wibox.widget { wibox.widget {
checked = true, checked = true,
color = beautiful.bg_normal, color = beautiful.bg_normal,
paddings = 2, paddings = 2,
forced_width = 20, --DOC_HIDE forced_width = 20, --DOC_HIDE
forced_height = 20, --DOC_HIDE forced_height = 20, --DOC_HIDE
shape = gears.shape.circle, shape = gears.shape.circle,
widget = wibox.widget.checkbox widget = wibox.widget.checkbox
} }
, --DOC_HIDE , --DOC_HIDE
wibox.widget { --DOC_HIDE wibox.widget { --DOC_HIDE
checked = false, --DOC_HIDE checked = false, --DOC_HIDE
color = beautiful.bg_normal, --DOC_HIDE color = beautiful.bg_normal, --DOC_HIDE
paddings = 2, --DOC_HIDE paddings = 2, --DOC_HIDE
forced_width = 20, --DOC_HIDE forced_width = 20, --DOC_HIDE
forced_height = 20, --DOC_HIDE forced_height = 20, --DOC_HIDE
shape = gears.shape.circle, --DOC_HIDE shape = gears.shape.circle, --DOC_HIDE
widget = wibox.widget.checkbox --DOC_HIDE widget = wibox.widget.checkbox --DOC_HIDE
}, --DOC_HIDE }, --DOC_HIDE
spacing = 4, --DOC_HIDE spacing = 4, --DOC_HIDE
layout = wibox.layout.fixed.horizontal --DOC_HIDE layout = wibox.layout.fixed.horizontal --DOC_HIDE
} --DOC_HIDE } --DOC_HIDE
) --DOC_HIDE ) --DOC_HIDE

View File

@ -4,10 +4,10 @@ local beautiful = require( "beautiful" ) --DOC_HIDE
parent:add( --DOC_HIDE parent:add( --DOC_HIDE
wibox.widget { wibox.widget {
image = beautiful.awesome_icon, image = beautiful.awesome_icon,
resize = false, resize = false,
widget = wibox.widget.imagebox widget = wibox.widget.imagebox
} }
) --DOC_HIDE ) --DOC_HIDE

View File

@ -4,21 +4,21 @@ local beautiful = require( "beautiful" ) --DOC_HIDE
parent:add( --DOC_HIDE parent:add( --DOC_HIDE
wibox.widget { wibox.widget {
data_list = { data_list = {
{ 'L1', 100 }, { 'L1', 100 },
{ 'L2', 200 }, { 'L2', 200 },
{ 'L3', 300 }, { 'L3', 300 },
}, },
border_width = 1, border_width = 1,
forced_height = 50, --DOC_HIDE forced_height = 50, --DOC_HIDE
forced_width = 100, --DOC_HIDE forced_width = 100, --DOC_HIDE
colors = { colors = {
beautiful.bg_normal, beautiful.bg_normal,
beautiful.bg_highlight, beautiful.bg_highlight,
beautiful.border_color, beautiful.border_color,
}, },
widget = wibox.widget.piechart widget = wibox.widget.piechart
} }
) --DOC_HIDE ) --DOC_HIDE

View File

@ -5,15 +5,15 @@ local beautiful = require("beautiful") --DOC_HIDE
parent:add( --DOC_HIDE parent:add( --DOC_HIDE
wibox.widget { wibox.widget {
max_value = 1, max_value = 1,
value = 0.33, value = 0.33,
forced_height = 20, forced_height = 20,
forced_width = 100, forced_width = 100,
shape = gears.shape.rounded_bar, shape = gears.shape.rounded_bar,
border_width = 2, border_width = 2,
border_color = beautiful.border_color, border_color = beautiful.border_color,
widget = wibox.widget.progressbar, widget = wibox.widget.progressbar,
} }
) --DOC_HIDE ) --DOC_HIDE

View File

@ -5,18 +5,18 @@ local gears = {shape=require("gears.shape") } --DOC_HIDE
parent:add( --DOC_HIDE parent:add( --DOC_HIDE
wibox.widget { wibox.widget {
bar_shape = gears.shape.rounded_rect, bar_shape = gears.shape.rounded_rect,
bar_height = 3, bar_height = 3,
bar_color = beautiful.border_color, bar_color = beautiful.border_color,
handle_color = beautiful.bg_normal, handle_color = beautiful.bg_normal,
handle_shape = gears.shape.circle, handle_shape = gears.shape.circle,
handle_border_color = beautiful.border_color, handle_border_color = beautiful.border_color,
handle_border_width = 1, handle_border_width = 1,
value = 25, value = 25,
widget = wibox.widget.slider, widget = wibox.widget.slider,
forced_height = 50, --DOC_HIDE forced_height = 50, --DOC_HIDE
forced_width = 100, --DOC_HIDE forced_width = 100, --DOC_HIDE
} }
) --DOC_HIDE ) --DOC_HIDE

View File

@ -3,11 +3,11 @@ local wibox = require("wibox") --DOC_HIDE
parent:add( --DOC_HIDE parent:add( --DOC_HIDE
wibox.widget{ wibox.widget{
markup = "This <i>is</i> a <b>textbox</b>!!!", markup = "This <i>is</i> a <b>textbox</b>!!!",
align = "center", align = "center",
valign = "center", valign = "center",
widget = wibox.widget.textbox widget = wibox.widget.textbox
} }
) --DOC_HIDE ) --DOC_HIDE

View File

@ -8,20 +8,20 @@ parent:add(l)
for _, v in ipairs {"#ff0000", "#00ff00", "#0000ff"} do for _, v in ipairs {"#ff0000", "#00ff00", "#0000ff"} do
l:add(wibox.widget { l:add(wibox.widget {
data_list = { data_list = {
{ 'L1', 100 }, { 'L1', 100 },
{ 'L2', 200 }, { 'L2', 200 },
{ 'L3', 300 }, { 'L3', 300 },
}, },
border_width = 1, border_width = 1,
border_color = v, border_color = v,
forced_height = 50, forced_height = 50,
forced_width = 100, forced_width = 100,
colors = { colors = {
beautiful.bg_normal, beautiful.bg_normal,
beautiful.bg_highlight, beautiful.bg_highlight,
beautiful.border_color, beautiful.border_color,
}, },
widget = wibox.widget.piechart widget = wibox.widget.piechart
}) })
end end

View File

@ -8,19 +8,19 @@ parent:add(l)
for _, v in ipairs {0,1,3,5} do for _, v in ipairs {0,1,3,5} do
l:add(wibox.widget { l:add(wibox.widget {
data_list = { data_list = {
{ 'L1', 100 }, { 'L1', 100 },
{ 'L2', 200 }, { 'L2', 200 },
{ 'L3', 300 }, { 'L3', 300 },
}, },
border_width = v, border_width = v,
forced_height = 50, forced_height = 50,
forced_width = 100, forced_width = 100,
colors = { colors = {
beautiful.bg_normal, beautiful.bg_normal,
beautiful.bg_highlight, beautiful.bg_highlight,
beautiful.border_color, beautiful.border_color,
}, },
widget = wibox.widget.piechart widget = wibox.widget.piechart
}) })
end end

View File

@ -4,65 +4,65 @@ local wibox = require( "wibox" )
local beautiful = require( "beautiful" ) local beautiful = require( "beautiful" )
parent:add(wibox.widget { parent:add(wibox.widget {
{ {
{ {
markup = "<b>display_labels</b> = <i>false</i>", markup = "<b>display_labels</b> = <i>false</i>",
widget = wibox.widget.textbox widget = wibox.widget.textbox
}, },
{ {
{ {
data_list = { data_list = {
{ 'L1', 100 }, { 'L1', 100 },
{ 'L2', 200 }, { 'L2', 200 },
{ 'L3', 300 }, { 'L3', 300 },
}, },
border_width = 1, border_width = 1,
forced_height = 50, forced_height = 50,
forced_width = 100, forced_width = 100,
display_labels = false, display_labels = false,
colors = { colors = {
beautiful.bg_normal, beautiful.bg_normal,
beautiful.bg_highlight, beautiful.bg_highlight,
beautiful.border_color, beautiful.border_color,
}, },
widget = wibox.widget.piechart widget = wibox.widget.piechart
}, },
margins = 1, margins = 1,
color = beautiful.border_color, color = beautiful.border_color,
layout = wibox.container.margin, layout = wibox.container.margin,
}, },
layout = wibox.layout.fixed.vertical layout = wibox.layout.fixed.vertical
}, },
{ {
{ {
markup = "<b>display_labels</b> = <i>true</i>", markup = "<b>display_labels</b> = <i>true</i>",
widget = wibox.widget.textbox widget = wibox.widget.textbox
}, },
{ {
{ {
data_list = { data_list = {
{ 'L1', 100 }, { 'L1', 100 },
{ 'L2', 200 }, { 'L2', 200 },
{ 'L3', 300 }, { 'L3', 300 },
}, },
border_width = 1, border_width = 1,
forced_height = 50, forced_height = 50,
forced_width = 100, forced_width = 100,
display_labels = true, display_labels = true,
colors = { colors = {
beautiful.bg_normal, beautiful.bg_normal,
beautiful.bg_highlight, beautiful.bg_highlight,
beautiful.border_color, beautiful.border_color,
}, },
widget = wibox.widget.piechart widget = wibox.widget.piechart
}, },
margins = 1, margins = 1,
color = beautiful.border_color, color = beautiful.border_color,
layout = wibox.container.margin, layout = wibox.container.margin,
}, },
layout = wibox.layout.fixed.vertical layout = wibox.layout.fixed.vertical
}, },
layout = wibox.layout.flex.horizontal layout = wibox.layout.flex.horizontal
}) })
return 500, 60 return 500, 60

View File

@ -12,16 +12,16 @@ local l = wibox.layout { --DOC_HIDE
for _, shape in ipairs {"rounded_bar", "octogon", "hexagon", "powerline" } do for _, shape in ipairs {"rounded_bar", "octogon", "hexagon", "powerline" } do
l:add(wibox.widget { l:add(wibox.widget {
value = 0.33, value = 0.33,
bar_shape = gears.shape[shape], bar_shape = gears.shape[shape],
bar_border_color = beautiful.border_color, bar_border_color = beautiful.border_color,
bar_border_width = 1, bar_border_width = 1,
border_width = 2, border_width = 2,
border_color = beautiful.border_color, border_color = beautiful.border_color,
margins = 5, --DOC_HIDE margins = 5, --DOC_HIDE
paddings = 1, paddings = 1,
widget = wibox.widget.progressbar, widget = wibox.widget.progressbar,
}) })
end end
parent:add(l) --DOC_HIDE parent:add(l) --DOC_HIDE

View File

@ -5,23 +5,23 @@ local beautiful = require("beautiful") --DOC_HIDE
parent:add( --DOC_HIDE parent:add( --DOC_HIDE
wibox.widget { wibox.widget {
value = 75, value = 75,
max_value = 100, max_value = 100,
border_width = 2, border_width = 2,
border_color = beautiful.border_color, border_color = beautiful.border_color,
color = beautiful.border_color, color = beautiful.border_color,
shape = gears.shape.rounded_bar, shape = gears.shape.rounded_bar,
bar_shape = gears.shape.rounded_bar, bar_shape = gears.shape.rounded_bar,
clip = false, clip = false,
forced_height = 30, forced_height = 30,
forced_width = 100, forced_width = 100,
paddings = 5, paddings = 5,
margins = { margins = {
top = 12, top = 12,
bottom = 12, bottom = 12,
}, },
widget = wibox.widget.progressbar, widget = wibox.widget.progressbar,
} }
) --DOC_HIDE ) --DOC_HIDE

View File

@ -12,13 +12,13 @@ local l = wibox.layout { --DOC_HIDE
for _, shape in ipairs {"rounded_bar", "octogon", "hexagon", "powerline" } do for _, shape in ipairs {"rounded_bar", "octogon", "hexagon", "powerline" } do
l:add(wibox.widget { l:add(wibox.widget {
value = 0.33, value = 0.33,
shape = gears.shape[shape], shape = gears.shape[shape],
border_width = 2, border_width = 2,
border_color = beautiful.border_color, border_color = beautiful.border_color,
margins = 5, --DOC_HIDE margins = 5, --DOC_HIDE
widget = wibox.widget.progressbar, widget = wibox.widget.progressbar,
}) })
end end
parent:add(l) --DOC_HIDE parent:add(l) --DOC_HIDE

View File

@ -4,22 +4,22 @@ local beautiful = require("beautiful") --DOC_HIDE
parent:add( --DOC_HIDE parent:add( --DOC_HIDE
wibox.widget { wibox.widget {
{ {
max_value = 1, max_value = 1,
value = 0.5, value = 0.5,
forced_height = 20, forced_height = 20,
forced_width = 100, forced_width = 100,
paddings = 1, paddings = 1,
border_width = 1, border_width = 1,
border_color = beautiful.border_color, border_color = beautiful.border_color,
widget = wibox.widget.progressbar, widget = wibox.widget.progressbar,
}, },
{ {
text = "50%", text = "50%",
widget = wibox.widget.textbox, widget = wibox.widget.textbox,
}, },
layout = wibox.layout.stack layout = wibox.layout.stack
} }
) --DOC_HIDE ) --DOC_HIDE

View File

@ -3,16 +3,16 @@ local wibox = require("wibox") --DOC_HIDE
parent:add( --DOC_HIDE parent:add( --DOC_HIDE
wibox.widget { wibox.widget {
{ {
max_value = 1, max_value = 1,
value = 0.33, value = 0.33,
widget = wibox.widget.progressbar, widget = wibox.widget.progressbar,
}, },
forced_height = 100, forced_height = 100,
forced_width = 20, forced_width = 20,
direction = "east", direction = "east",
layout = wibox.container.rotate, layout = wibox.container.rotate,
} }
) --DOC_HIDE ) --DOC_HIDE

View File

@ -17,11 +17,11 @@ end
local l = wibox.layout { local l = wibox.layout {
gen(0), gen(3), gen(6), gen({ gen(0), gen(3), gen(6), gen({
top = 12, top = 12,
bottom = 12, bottom = 12,
left = 12, left = 12,
right = 12, right = 12,
}), }),
forced_height = 30, forced_height = 30,
forced_width = 400, forced_width = 400,
spacing = 5, spacing = 5,

View File

@ -17,11 +17,11 @@ end
local l = wibox.layout { local l = wibox.layout {
gen(0), gen(3), gen(6), gen({ gen(0), gen(3), gen(6), gen({
top = 12, top = 12,
bottom = 12, bottom = 12,
left = 12, left = 12,
right = 12, right = 12,
}), }),
forced_height = 30, forced_height = 30,
forced_width = 400, forced_width = 400,
spacing = 5, spacing = 5,

View File

@ -26,203 +26,203 @@ end
local steps = { local steps = {
function(count) function(count)
if count <= 5 then if count <= 5 then
awful.spawn("xterm") awful.spawn("xterm")
elseif #client.get() >= 5 then elseif #client.get() >= 5 then
local c, _ = get_c_and_t() local c, _ = get_c_and_t()
old_c = c old_c = c
return true
end
end,
-- Wait for the focus to change
function()
assert(old_c)
-- Test layout
-- local cb = get_callback({modkey}, " ")
-- assert(cb)
--TODO use the key once the bug is fixed
local l = old_c.screen.selected_tag.layout
assert(l)
-- cb()
awful.layout.inc(1)
assert(old_c.screen.selected_tag.layout ~= l)
-- Test ontop
assert(not old_c.ontop)
get_callback({modkey}, "t")()
return true
end,
-- Ok, no now ontop should be true
function()
local _, t = get_c_and_t()
-- Give awesome some time
if not old_c.ontop then return nil end
assert(old_c.ontop)
-- Now, test the master_width_factor
assert(t.master_width_factor == 0.5)
get_callback({modkey}, "l")()
return true
end,
-- The master width factor should now be bigger
function()
local _, t = get_c_and_t()
assert(t.master_width_factor == 0.55)
-- Now, test the master_count
assert(t.master_count == 1)
get_callback({modkey, "Shift"}, "h")()
return true
end,
-- The number of master client should now be 2
function()
local _, t = get_c_and_t()
assert(t.master_count == 2)
-- Now, test the column_count
assert(t.column_count == 1)
get_callback({modkey, "Control"}, "h")()
get_callback({modkey, "Shift" }, "l")()
return true
end,
-- The number of columns should now be 2
function()
local _, t = get_c_and_t()
assert(t.column_count == 2)
-- Now, test the switching tag
assert(t.index == 1)
get_callback({modkey, }, "Right")()
return true
end,
-- The tag index should now be 2
function()
local tags = mouse.screen.tags
-- local t = awful.screen.focused().selected_tag
-- assert(t.index == 2)--FIXME
assert(tags[1].index == 1)
tags[1]:view_only()
return true
end,
-- Before testing tags, lets make sure everything is still right
function()
local tags = mouse.screen.tags
assert(tags[1].selected)
local clients = mouse.screen.clients
-- Make sure the clients are all on the same screen, they should be
local c_scr = client.get()[1].screen
for _, c in ipairs(client.get()) do
assert(c_scr == c.screen)
end
-- Then this should be true
assert(#clients == #client.get())
assert(#mouse.screen.all_clients == #clients)
assert(#mouse.screen.all_clients - #mouse.screen.hidden_clients == #clients)
return true
end,
-- Now, test switching tags
function()
local tags = mouse.screen.tags
local clients = mouse.screen.all_clients
assert(#tags == 9)
assert(#clients == 5)
assert(mouse.screen.selected_tag == tags[1])
for i=1, 9 do
-- Check that assertion, because if it's false, the other assert()
-- wont make any sense.
assert(tags[i].index == i)
end
for i=1, 9 do
tags[i]:view_only()
assert(tags[i].selected)
assert(#mouse.screen.selected_tags == 1)
end
tags[1]:view_only()
return true
end,
-- Lets shift some clients around
function()
local tags = mouse.screen.tags
-- Given all tags have been selected, the selection should be back on
-- tags[1] and the client history should be kept
assert(client.focus == old_c)
--get_callback({modkey, "Shift" }, "#"..(9+i))() --FIXME
client.focus:move_to_tag(tags[2])
assert(not client.focus)
return true
end,
-- The client should be on tag 5
function()
-- Confirm the move did happen
local tags = mouse.screen.tags
assert(tags[1].selected)
assert(#old_c:tags() == 1)
assert(old_c:tags()[1] ~= tags[1])
assert(not old_c:tags()[1].selected)
-- The focus should have changed by now, as the tag isn't visible
assert(client.focus ~= old_c)
assert(old_c:tags()[1] == tags[2])
assert(#tags[2]:clients() == 1)
assert(#tags[1]:clients() == 4)
return true return true
end end
end,
-- Wait for the focus to change
function()
assert(old_c)
-- Test layout
-- local cb = get_callback({modkey}, " ")
-- assert(cb)
--TODO use the key once the bug is fixed
local l = old_c.screen.selected_tag.layout
assert(l)
-- cb()
awful.layout.inc(1)
assert(old_c.screen.selected_tag.layout ~= l)
-- Test ontop
assert(not old_c.ontop)
get_callback({modkey}, "t")()
return true
end,
-- Ok, no now ontop should be true
function()
local _, t = get_c_and_t()
-- Give awesome some time
if not old_c.ontop then return nil end
assert(old_c.ontop)
-- Now, test the master_width_factor
assert(t.master_width_factor == 0.5)
get_callback({modkey}, "l")()
return true
end,
-- The master width factor should now be bigger
function()
local _, t = get_c_and_t()
assert(t.master_width_factor == 0.55)
-- Now, test the master_count
assert(t.master_count == 1)
get_callback({modkey, "Shift"}, "h")()
return true
end,
-- The number of master client should now be 2
function()
local _, t = get_c_and_t()
assert(t.master_count == 2)
-- Now, test the column_count
assert(t.column_count == 1)
get_callback({modkey, "Control"}, "h")()
get_callback({modkey, "Shift" }, "l")()
return true
end,
-- The number of columns should now be 2
function()
local _, t = get_c_and_t()
assert(t.column_count == 2)
-- Now, test the switching tag
assert(t.index == 1)
get_callback({modkey, }, "Right")()
return true
end,
-- The tag index should now be 2
function()
local tags = mouse.screen.tags
-- local t = awful.screen.focused().selected_tag
-- assert(t.index == 2)--FIXME
assert(tags[1].index == 1)
tags[1]:view_only()
return true
end,
-- Before testing tags, lets make sure everything is still right
function()
local tags = mouse.screen.tags
assert(tags[1].selected)
local clients = mouse.screen.clients
-- Make sure the clients are all on the same screen, they should be
local c_scr = client.get()[1].screen
for _, c in ipairs(client.get()) do
assert(c_scr == c.screen)
end
-- Then this should be true
assert(#clients == #client.get())
assert(#mouse.screen.all_clients == #clients)
assert(#mouse.screen.all_clients - #mouse.screen.hidden_clients == #clients)
return true
end,
-- Now, test switching tags
function()
local tags = mouse.screen.tags
local clients = mouse.screen.all_clients
assert(#tags == 9)
assert(#clients == 5)
assert(mouse.screen.selected_tag == tags[1])
for i=1, 9 do
-- Check that assertion, because if it's false, the other assert()
-- wont make any sense.
assert(tags[i].index == i)
end
for i=1, 9 do
tags[i]:view_only()
assert(tags[i].selected)
assert(#mouse.screen.selected_tags == 1)
end
tags[1]:view_only()
return true
end,
-- Lets shift some clients around
function()
local tags = mouse.screen.tags
-- Given all tags have been selected, the selection should be back on
-- tags[1] and the client history should be kept
assert(client.focus == old_c)
--get_callback({modkey, "Shift" }, "#"..(9+i))() --FIXME
client.focus:move_to_tag(tags[2])
assert(not client.focus)
return true
end,
-- The client should be on tag 5
function()
-- Confirm the move did happen
local tags = mouse.screen.tags
assert(tags[1].selected)
assert(#old_c:tags() == 1)
assert(old_c:tags()[1] ~= tags[1])
assert(not old_c:tags()[1].selected)
-- The focus should have changed by now, as the tag isn't visible
assert(client.focus ~= old_c)
assert(old_c:tags()[1] == tags[2])
assert(#tags[2]:clients() == 1)
assert(#tags[1]:clients() == 4)
return true
end
} }
require("_runner").run_steps(steps) require("_runner").run_steps(steps)

View File

@ -6,75 +6,75 @@ awful.util.deprecate = function() end
local has_spawned = false local has_spawned = false
local steps = { local steps = {
function(count) function(count)
if count <= 1 and not has_spawned and #client.get() < 2 then if count <= 1 and not has_spawned and #client.get() < 2 then
awful.spawn("xterm") awful.spawn("xterm")
awful.spawn("xterm") awful.spawn("xterm")
has_spawned = true has_spawned = true
elseif #client.get() >= 2 then elseif #client.get() >= 2 then
-- Test properties -- Test properties
client.focus = client.get()[1] client.focus = client.get()[1]
local c = client.focus local c = client.focus
-- local c2 = client.get()[2] -- local c2 = client.get()[2]
c.foo = "bar" c.foo = "bar"
-- Check if the property system works -- Check if the property system works
assert(c.foo == "bar") assert(c.foo == "bar")
assert(c.foo == awful.client.property.get(c, "foo")) assert(c.foo == awful.client.property.get(c, "foo"))
-- Test jumpto -- Test jumpto
--FIXME doesn't work --FIXME doesn't work
-- c2:jump_to() -- c2:jump_to()
-- assert(client.focus == c2) -- assert(client.focus == c2)
-- awful.client.jumpto(c) -- awful.client.jumpto(c)
-- assert(client.focus == c) -- assert(client.focus == c)
-- Test moveresize -- Test moveresize
c.size_hints_honor = false c.size_hints_honor = false
c:geometry {x=0,y=0,width=50,height=50} c:geometry {x=0,y=0,width=50,height=50}
c:relative_move( 100, 100, 50, 50 ) c:relative_move( 100, 100, 50, 50 )
for _,v in pairs(c:geometry()) do for _,v in pairs(c:geometry()) do
assert(v == 100) assert(v == 100)
end end
awful.client.moveresize(-25, -25, -25, -25, c ) awful.client.moveresize(-25, -25, -25, -25, c )
for _,v in pairs(c:geometry()) do for _,v in pairs(c:geometry()) do
assert(v == 75) assert(v == 75)
end end
-- Test movetotag -- Test movetotag
local t = mouse.screen.tags[1] local t = mouse.screen.tags[1]
local t2 = mouse.screen.tags[2] local t2 = mouse.screen.tags[2]
c:tags{t} c:tags{t}
assert(c:tags()[1] == t) assert(c:tags()[1] == t)
c:move_to_tag(t2) c:move_to_tag(t2)
assert(c:tags()[1] == t2) assert(c:tags()[1] == t2)
awful.client.movetotag(t, c) awful.client.movetotag(t, c)
assert(c:tags()[1] == t) assert(c:tags()[1] == t)
-- Test toggletag -- Test toggletag
c:tags{t} c:tags{t}
c:toggle_tag(t2) c:toggle_tag(t2)
assert(c:tags()[1] == t2 or c:tags()[2] == t2) assert(c:tags()[1] == t2 or c:tags()[2] == t2)
awful.client.toggletag(t2, c) awful.client.toggletag(t2, c)
assert(c:tags()[1] == t and c:tags()[1] ~= t2 and c:tags()[2] == nil) assert(c:tags()[1] == t and c:tags()[1] ~= t2 and c:tags()[2] == nil)
-- Test floating -- Test floating
assert(c.floating ~= nil and type(c.floating) == "boolean") assert(c.floating ~= nil and type(c.floating) == "boolean")
c.floating = true c.floating = true
assert(awful.client.floating.get(c)) assert(awful.client.floating.get(c))
awful.client.floating.set(c, false) awful.client.floating.set(c, false)
assert(not c.floating) assert(not c.floating)
return true return true
end end
end end
} }
local original_count, c1, c2 = 0 local original_count, c1, c2 = 0
@ -108,21 +108,21 @@ table.insert(steps, function()
end) end)
table.insert(steps, function() table.insert(steps, function()
-- The request should have been denied -- The request should have been denied
assert(client.focus == c2) assert(client.focus == c2)
-- Test the remove function -- Test the remove function
awful.ewmh.remove_activate_filter(function() end) awful.ewmh.remove_activate_filter(function() end)
awful.ewmh.add_activate_filter(awful.ewmh.generic_activate_filters[1]) awful.ewmh.add_activate_filter(awful.ewmh.generic_activate_filters[1])
awful.ewmh.remove_activate_filter(awful.ewmh.generic_activate_filters[1]) awful.ewmh.remove_activate_filter(awful.ewmh.generic_activate_filters[1])
assert(original_count == #awful.ewmh.generic_activate_filters) assert(original_count == #awful.ewmh.generic_activate_filters)
c1:emit_signal("request::activate", "i_said_so") c1:emit_signal("request::activate", "i_said_so")
return client.focus == c1 return client.focus == c1
end) end)
local has_error local has_error
@ -154,8 +154,8 @@ table.insert(multi_screen_steps, function()
for i=1, screen.count() do for i=1, screen.count() do
local s = screen[i] local s = screen[i]
test_client("screen"..i, nil, { test_client("screen"..i, nil, {
screen = s, screen = s,
}) })
end end
return true return true
@ -218,92 +218,92 @@ table.insert(multi_screen_steps, function()
for i=1, screen.count() do for i=1, screen.count() do
local s = screen[i] local s = screen[i]
test_client("screen"..i, nil, { test_client("screen"..i, nil, {
new_tag = { new_tag = {
name = "NEW_AT_"..i, name = "NEW_AT_"..i,
screen = s, screen = s,
} }
})
end
return true
end)
table.insert(multi_screen_steps, function()
if #client.get() ~= screen.count() then return end
for _, c in ipairs(client.get()) do
assert(#c:tags() == 1)
assert(c.first_tag.name == "NEW_AT_"..c.screen.index)
end
-- Kill the client
for _, c in ipairs(client.get()) do
c:kill()
end
if screen.count() < 2 then return true end
-- Now, add client where the target tag and screen don't match
test_client("test_tag1", nil, {
tag = screen[2].tags[2],
screen = screen[1],
}) })
end
return true -- Add a client with multiple tags on the same screen, but not c.screen
end) test_client("test_tags1", nil, {
tags = { screen[1].tags[3], screen[1].tags[4] },
screen = screen[2],
})
table.insert(multi_screen_steps, function() -- Identical, but using the tag names
if #client.get() ~= screen.count() then return end test_client("test_tags2", nil, {
tags = { "3", "4" },
screen = screen[2],
})
for _, c in ipairs(client.get()) do -- Also test tags, but with an invalid screen array
assert(#c:tags() == 1) test_client("test_tags3", nil, {
assert(c.first_tag.name == "NEW_AT_"..c.screen.index) tags = { screen[2].tags[3], screen[1].tags[4] },
end screen = screen[1],
})
-- Kill the client -- Another test for tags, but with no matching names
for _, c in ipairs(client.get()) do test_client("test_tags4", nil, {
c:kill() tags = { "foobar", "bobcat" },
end screen = screen[1],
})
if screen.count() < 2 then return true end return true
-- Now, add client where the target tag and screen don't match
test_client("test_tag1", nil, {
tag = screen[2].tags[2],
screen = screen[1],
})
-- Add a client with multiple tags on the same screen, but not c.screen
test_client("test_tags1", nil, {
tags = { screen[1].tags[3], screen[1].tags[4] },
screen = screen[2],
})
-- Identical, but using the tag names
test_client("test_tags2", nil, {
tags = { "3", "4" },
screen = screen[2],
})
-- Also test tags, but with an invalid screen array
test_client("test_tags3", nil, {
tags = { screen[2].tags[3], screen[1].tags[4] },
screen = screen[1],
})
-- Another test for tags, but with no matching names
test_client("test_tags4", nil, {
tags = { "foobar", "bobcat" },
screen = screen[1],
})
return true
end) end)
table.insert(multi_screen_steps, function() table.insert(multi_screen_steps, function()
if screen.count() < 2 then return true end if screen.count() < 2 then return true end
if #client.get() ~= 5 then return end if #client.get() ~= 5 then return end
local c_by_class = {} local c_by_class = {}
for _, c in ipairs(client.get()) do for _, c in ipairs(client.get()) do
c_by_class[c.class] = c c_by_class[c.class] = c
end end
assert(c_by_class["test_tag1"].screen == screen[2]) assert(c_by_class["test_tag1"].screen == screen[2])
assert(#c_by_class["test_tag1"]:tags() == 1) assert(#c_by_class["test_tag1"]:tags() == 1)
assert(c_by_class["test_tags1"].screen == screen[1]) assert(c_by_class["test_tags1"].screen == screen[1])
assert(#c_by_class["test_tags1"]:tags() == 2) assert(#c_by_class["test_tags1"]:tags() == 2)
assert(c_by_class["test_tags2"].screen == screen[2]) assert(c_by_class["test_tags2"].screen == screen[2])
assert(#c_by_class["test_tags2"]:tags() == 2) assert(#c_by_class["test_tags2"]:tags() == 2)
assert(c_by_class["test_tags3"].screen == screen[2]) assert(c_by_class["test_tags3"].screen == screen[2])
assert(#c_by_class["test_tags3"]:tags() == 1) assert(#c_by_class["test_tags3"]:tags() == 1)
assert(c_by_class["test_tags4"].screen == screen[1]) assert(c_by_class["test_tags4"].screen == screen[1])
assert(#c_by_class["test_tags4"]:tags() == 1) assert(#c_by_class["test_tags4"]:tags() == 1)
assert(c_by_class["test_tags4"]:tags()[1] == screen[1].selected_tag) assert(c_by_class["test_tags4"]:tags()[1] == screen[1].selected_tag)
return true return true
end) end)
require("_multi_screen")(steps, multi_screen_steps) require("_multi_screen")(steps, multi_screen_steps)

View File

@ -11,20 +11,20 @@ local has_spawned = false
local steps = { local steps = {
-- Add enough clients -- Add enough clients
function(count) function(count)
if count <= 1 and not has_spawned then if count <= 1 and not has_spawned then
for _=1, 5 do awful.spawn("xterm") end for _=1, 5 do awful.spawn("xterm") end
has_spawned = true has_spawned = true
elseif #client.get() >= 5 then elseif #client.get() >= 5 then
first_layout = client.focus:tags()[1].layout first_layout = client.focus:tags()[1].layout
t = client.focus:tags()[1] t = client.focus:tags()[1]
return true return true
end end
end, end,
} }
@ -77,7 +77,7 @@ local common_steps = {
end, end,
function() function()
t.master_fill_policy = t.master_fill_policy == "master_width_factor" and t.master_fill_policy = t.master_fill_policy == "master_width_factor" and
"expand" or "master_width_factor" "expand" or "master_width_factor"
return true return true
end, end,

View File

@ -4,86 +4,73 @@ awful.util.deprecate = function() end
local has_spawned = false local has_spawned = false
local steps = { local steps = {
function(count)
if count <= 1 and not has_spawned and #client.get() < 2 then
awful.spawn("xterm")
awful.spawn("xterm")
has_spawned = true
function(count) elseif #client.get() >= 2 then
-- Test properties
client.focus = client.get()[1]
if count <= 1 and not has_spawned and #client.get() < 2 then local s = mouse.screen
awful.spawn("xterm") assert(s)
awful.spawn("xterm") assert(s == screen[s])
has_spawned = true
elseif #client.get() >= 2 then
-- Test properties -- Test padding
client.focus = client.get()[1] s.padding = 42
local counter = 0
for _, v in pairs(s.padding) do
assert(v == 42)
counter = counter + 1
end
assert(counter == 4)
local s = mouse.screen awful.screen.padding(s, {
left = 1337,
right = 1337,
top = 1337,
bottom = 1337,
})
counter = 0
for _, v in pairs(s.padding) do
assert(v == 1337)
counter = counter + 1
end
assert(counter == 4)
assert(s) counter = 0
for _, v in pairs(awful.screen.padding(s)) do
assert(v == 1337)
counter = counter + 1
end
assert(counter == 4)
assert(s == screen[s]) -- Test square distance
assert(s:get_square_distance(9999, 9999))
assert(s:get_square_distance(9999, 9999)
== awful.screen.getdistance_sq(s, 9999, 9999))
-- Test padding -- Test count
counter = 0
for _ in screen do
counter = counter + 1
end
s.padding = 42 assert(screen.count() == counter)
local counter = 0 counter = 0
for _, v in pairs(s.padding) do awful.screen.connect_for_each_screen(function()
assert(v == 42) counter = counter + 1
counter = counter + 1 end)
end assert(screen.count() == counter)
assert(counter == 4) return true
end
awful.screen.padding(s, { end
left = 1337,
right = 1337,
top = 1337,
bottom = 1337,
})
counter = 0
for _, v in pairs(s.padding) do
assert(v == 1337)
counter = counter + 1
end
assert(counter == 4)
counter = 0
for _, v in pairs(awful.screen.padding(s)) do
assert(v == 1337)
counter = counter + 1
end
assert(counter == 4)
-- Test square distance
assert(s:get_square_distance(9999, 9999))
assert(s:get_square_distance(9999, 9999)
== awful.screen.getdistance_sq(s, 9999, 9999))
-- Test count
counter = 0
for _ in screen do
counter = counter + 1
end
assert(screen.count() == counter)
counter = 0
awful.screen.connect_for_each_screen(function()
counter = counter + 1
end)
assert(screen.count() == counter)
return true
end
end
} }
require("_runner").run_steps(steps) require("_runner").run_steps(steps)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -14,118 +14,118 @@ end
local has_spawned = false local has_spawned = false
local steps = { local steps = {
function(count) function(count)
if count <= 1 and not has_spawned and #client.get() < 2 then if count <= 1 and not has_spawned and #client.get() < 2 then
awful.spawn("xterm") awful.spawn("xterm")
awful.spawn("xterm") awful.spawn("xterm")
has_spawned = true has_spawned = true
elseif #client.get() >= 2 then elseif #client.get() >= 2 then
-- Test move, swap and index -- Test move, swap and index
local tags = mouse.screen.tags local tags = mouse.screen.tags
assert(#mouse.screen.tags == 9) assert(#mouse.screen.tags == 9)
check_order() check_order()
tags[7].index = 9 tags[7].index = 9
assert(tags[7].index == 9) assert(tags[7].index == 9)
check_order() check_order()
tags[7].index = 4 tags[7].index = 4
assert(tags[7].index == 4) assert(tags[7].index == 4)
check_order() check_order()
awful.tag.move(5, tags[7]) awful.tag.move(5, tags[7])
assert(tags[7].index == 5) assert(tags[7].index == 5)
check_order() check_order()
tags[1]:swap(tags[3]) tags[1]:swap(tags[3])
check_order() check_order()
assert(tags[1].index == 3) assert(tags[1].index == 3)
assert(tags[3].index == 1) assert(tags[3].index == 1)
check_order() check_order()
awful.tag.swap(tags[1], tags[3]) awful.tag.swap(tags[1], tags[3])
assert(tags[3].index == 3) assert(tags[3].index == 3)
assert(tags[1].index == 1) assert(tags[1].index == 1)
check_order() check_order()
-- Test add, icon and delete -- Test add, icon and delete
client.focus = client.get()[1] client.focus = client.get()[1]
local c = client.focus local c = client.focus
assert(c and client.focus == c) assert(c and client.focus == c)
assert(beautiful.awesome_icon) assert(beautiful.awesome_icon)
local t = awful.tag.add("Test", {clients={c}, icon = beautiful.awesome_icon}) local t = awful.tag.add("Test", {clients={c}, icon = beautiful.awesome_icon})
check_order() check_order()
local found = false local found = false
tags = mouse.screen.tags tags = mouse.screen.tags
assert(#tags == 10) assert(#tags == 10)
for _, v in ipairs(tags) do for _, v in ipairs(tags) do
if t == v then if t == v then
found = true found = true
break break
end
end
assert(found)
assert(t:clients()[1] == c)
assert(c:tags()[2] == t)
assert(t.icon == beautiful.awesome_icon)
t:delete()
tags = mouse.screen.tags
assert(#tags == 9)
found = false
for _, v in ipairs(tags) do
if t == v then
found = true
break
end
end
assert(not found)
-- Test selected tags, view only and selected()
t = tags[2]
assert(not t.selected)
assert(t.screen.selected_tag == tags[1])
t:view_only()
assert(t.selected)
assert(not tags[1].selected)
assert(#t.screen.selected_tags == 1)
return true
end
end end
end
assert(found)
assert(t:clients()[1] == c)
assert(c:tags()[2] == t)
assert(t.icon == beautiful.awesome_icon)
t:delete()
tags = mouse.screen.tags
assert(#tags == 9)
found = false
for _, v in ipairs(tags) do
if t == v then
found = true
break
end
end
assert(not found)
-- Test selected tags, view only and selected()
t = tags[2]
assert(not t.selected)
assert(t.screen.selected_tag == tags[1])
t:view_only()
assert(t.selected)
assert(not tags[1].selected)
assert(#t.screen.selected_tags == 1)
return true
end
end
} }
local multi_screen_steps = {} local multi_screen_steps = {}

View File

@ -68,7 +68,7 @@ table.insert(steps, function()
awful.button({}, 1, nil, function () awful.button({}, 1, nil, function ()
button:emit_signal_recursive("test::recursive") button:emit_signal_recursive("test::recursive")
end) end)
)) ))
layout:connect_signal("test::recursive", function() layout:connect_signal("test::recursive", function()
got_called = true got_called = true
@ -87,9 +87,9 @@ table.insert(steps, function()
end) end)
table.insert(steps, function() table.insert(steps, function()
assert(button._private.image ~= img) assert(button._private.image ~= img)
return true return true
end) end)
-- Test a button release -- Test a button release
@ -111,29 +111,29 @@ table.insert(steps, function()
end) end)
table.insert(steps, function() table.insert(steps, function()
assert(button._private.image ~= img) assert(button._private.image ~= img)
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
-- just make sure the button is not released for nothing -- just make sure the button is not released for nothing
assert(button._private.image ~= img) assert(button._private.image ~= img)
-- test if the button is released when the mouse move out -- test if the button is released when the mouse move out
awful.placement.right(mouse--[[, {parent = w}]]) awful.placement.right(mouse--[[, {parent = w}]])
root.fake_input("button_release", 1) root.fake_input("button_release", 1)
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
assert(button._private.image == img) assert(button._private.image == img)
-- The button had plenty of clicks by now. Make sure everything worked -- The button had plenty of clicks by now. Make sure everything worked
assert(got_called) assert(got_called)
return true return true
end) end)
runner.run_steps(steps) runner.run_steps(steps)

View File

@ -35,7 +35,7 @@ do
time_per_iter, time_total = measure(f, iters) time_per_iter, time_total = measure(f, iters)
end end
print(string.format("%20s: %-10.6g sec/iter (%3d iters, %.4g sec for benchmark)", print(string.format("%20s: %-10.6g sec/iter (%3d iters, %.4g sec for benchmark)",
msg, time_per_iter, iters, timer_benchmark:elapsed())) msg, time_per_iter, iters, timer_benchmark:elapsed()))
end end
end end

View File

@ -4,30 +4,30 @@ local runner = require("_runner")
local test_client = require("_client") local test_client = require("_client")
runner.run_steps({ runner.run_steps({
-- Spawn two clients -- Spawn two clients
function(count) function(count)
if count == 1 then if count == 1 then
test_client() test_client()
test_client() test_client()
end end
if #client.get() >= 2 then if #client.get() >= 2 then
return true return true
end end
end, end,
-- Swap them -- Swap them
function() function()
assert(#client.get() == 2, #client.get()) assert(#client.get() == 2, #client.get())
local c1 = client.get()[1] local c1 = client.get()[1]
local c2 = client.get()[2] local c2 = client.get()[2]
c2:swap(c1) c2:swap(c1)
c1:swap(c2) c1:swap(c2)
c1:swap(c2) c1:swap(c2)
c1:swap(c2) c1:swap(c2)
c2:swap(c1) c2:swap(c1)
return true return true
end, end,
}) })
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -17,13 +17,13 @@ dbus.connect_signal("org.awesomewm.test", dbus_callback)
for _=1, 2 do for _=1, 2 do
awful.spawn({ awful.spawn({
"dbus-send", "dbus-send",
"--dest=org.awesomewm.test", "--dest=org.awesomewm.test",
"--type=method_call", "--type=method_call",
"/", "/",
"org.awesomewm.test.Ping", "org.awesomewm.test.Ping",
"string:foo" "string:foo"
}) })
end end
runner.run_steps({ function() runner.run_steps({ function()

View File

@ -25,32 +25,32 @@ local function callback(context, cr, width, height, arg)
end end
runner.run_steps({ runner.run_steps({
-- Set some bg image -- Set some bg image
function() function()
local img = assert(beautiful.titlebar_close_button_normal) local img = assert(beautiful.titlebar_close_button_normal)
w:set_bgimage(img) w:set_bgimage(img)
return true return true
end, end,
-- Do nothing for a while iteration to give the repaint some time to happen -- Do nothing for a while iteration to give the repaint some time to happen
function(arg) function(arg)
if arg == 3 then if arg == 3 then
return true return true
end end
end, end,
-- Set some bg image function -- Set some bg image function
function() function()
w:set_bgimage(callback, "argument: 42") w:set_bgimage(callback, "argument: 42")
return true return true
end, end,
-- Wait for the function to be done -- Wait for the function to be done
function() function()
if callback_called then if callback_called then
return true return true
end end
end, end,
}) })
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -9,40 +9,40 @@ beautiful.border_normal = "#0000ff"
beautiful.border_focus = "#00ff00" beautiful.border_focus = "#00ff00"
client.connect_signal("focus", function(c) client.connect_signal("focus", function(c)
c.border_color = "#ff0000" c.border_color = "#ff0000"
end) end)
local steps = { local steps = {
-- border_color should get applied via focus signal for first client on tag. -- border_color should get applied via focus signal for first client on tag.
function(count) function(count)
if count == 1 then if count == 1 then
awful.spawn("xterm") awful.spawn("xterm")
else else
local c = client.get()[1] local c = client.get()[1]
if c then if c then
assert(c.border_color == "#ff0000") assert(c.border_color == "#ff0000")
return true return true
end end
end
end,
-- border_color should get applied via focus signal for second client on tag.
function(count)
if count == 1 then
awful.spawn("xterm")
else
if #client.get() == 2 then
local c = client.get()[1]
assert(c == client.focus)
if c then
assert(c.border_color == "#ff0000")
return true
end end
end,
end -- border_color should get applied via focus signal for second client on tag.
function(count)
if count == 1 then
awful.spawn("xterm")
else
if #client.get() == 2 then
local c = client.get()[1]
assert(c == client.focus)
if c then
assert(c.border_color == "#ff0000")
return true
end
end
end
end end
end
} }
runner.run_steps(steps) runner.run_steps(steps)

View File

@ -11,14 +11,14 @@ local w1_draw, w2_draw
-- Disable automatic placement -- Disable automatic placement
awful.rules.rules = { awful.rules.rules = {
{ rule = { }, properties = { { rule = { }, properties = {
border_width = 0, border_width = 0,
size_hints_honor = false, size_hints_honor = false,
x = 0, x = 0,
y = 0, y = 0,
width = 100, width = 100,
height = 100, height = 100,
border_color = beautiful.border_normal border_color = beautiful.border_normal
} }
} }
} }
@ -55,22 +55,22 @@ local steps = {
awful.rules.rules = { awful.rules.rules = {
-- All clients will match this rule. -- All clients will match this rule.
{ rule = { },properties = { { rule = { },properties = {
titlebars_enabled = true, titlebars_enabled = true,
border_width = 10, border_width = 10,
border_color = "#00ff00", border_color = "#00ff00",
size_hints_honor = false, size_hints_honor = false,
x = 0, x = 0,
y = 0, y = 0,
width = 100, width = 100,
height = 100 height = 100
}
}
} }
return true }
}
return true
end, end,
function(count) function(count)
if count == 1 then if count == 1 then
awful.spawn("xterm") awful.spawn("xterm")
else else
local c = client.get()[1] local c = client.get()[1]
if c then if c then

View File

@ -6,17 +6,17 @@ local wibox = require("wibox")
-- "Enable" titlebars (so that the titlebar can prevent garbage collection) -- "Enable" titlebars (so that the titlebar can prevent garbage collection)
client.connect_signal("manage", function (c) client.connect_signal("manage", function (c)
local buttons = awful.util.table.join( local buttons = awful.util.table.join(
awful.button({ }, 1, function() awful.button({ }, 1, function()
client.focus = c client.focus = c
c:raise() c:raise()
awful.mouse.client.move(c) awful.mouse.client.move(c)
end), end),
awful.button({ }, 3, function() awful.button({ }, 3, function()
client.focus = c client.focus = c
c:raise() c:raise()
awful.mouse.client.resize(c) awful.mouse.client.resize(c)
end) end)
) )
-- Widgets that are aligned to the left -- Widgets that are aligned to the left
local left_layout = wibox.layout.fixed.horizontal(awful.titlebar.widget.iconwidget(c)) local left_layout = wibox.layout.fixed.horizontal(awful.titlebar.widget.iconwidget(c))
@ -37,7 +37,7 @@ client.connect_signal("manage", function (c)
awful.titlebar.widget.stickybutton(c), awful.titlebar.widget.stickybutton(c),
awful.titlebar.widget.ontopbutton(c), awful.titlebar.widget.ontopbutton(c),
awful.titlebar.widget.closebutton(c) awful.titlebar.widget.closebutton(c)
)), { position = "bottom"}) )), { position = "bottom"})
end) end)
-- We tell the garbage collector when to work, disable it -- We tell the garbage collector when to work, disable it

View File

@ -21,23 +21,23 @@ table.insert(steps, function(count)
end) end)
table.insert(steps, function() table.insert(steps, function()
-- The mousegrabber expect a button to be pressed. -- The mousegrabber expect a button to be pressed.
root.fake_input("button_press",1) root.fake_input("button_press",1)
local c = client.get()[1] local c = client.get()[1]
-- Just in case there is an accidental delayed geometry callback -- Just in case there is an accidental delayed geometry callback
assert(c:geometry().x == 200) assert(c:geometry().x == 200)
assert(c:geometry().y == 200) assert(c:geometry().y == 200)
assert(c:geometry().width == 300) assert(c:geometry().width == 300)
assert(c:geometry().height == 300) assert(c:geometry().height == 300)
mouse.coords {x = 500+2*c.border_width, y= 500+2*c.border_width} mouse.coords {x = 500+2*c.border_width, y= 500+2*c.border_width}
local corner = amouse.client.resize(c) local corner = amouse.client.resize(c)
assert(corner == "bottom_right") assert(corner == "bottom_right")
return true return true
end) end)
-- The geometry should remain the same, as the cursor is placed at the end of -- The geometry should remain the same, as the cursor is placed at the end of
@ -108,8 +108,8 @@ table.insert(steps, function()
assert(c:geometry().x == 100) assert(c:geometry().x == 100)
assert(c:geometry().y == 200) assert(c:geometry().y == 200)
-- assert(c:geometry().width == 200-2*c.border_width) --FIXME off by border width... -- assert(c:geometry().width == 200-2*c.border_width) --FIXME off by border width...
-- assert(c:geometry().height == 200-2*c.border_width) --FIXME off by border width... -- assert(c:geometry().height == 200-2*c.border_width) --FIXME off by border width...
mouse.coords {x = 300, y= 200} mouse.coords {x = 300, y= 200}
@ -120,9 +120,9 @@ end)
table.insert(steps, function() table.insert(steps, function()
root.fake_input("button_release",1) root.fake_input("button_release",1)
-- if not mousegrabber.isrunning then --FIXME it should work, but doesn't -- if not mousegrabber.isrunning then --FIXME it should work, but doesn't
-- return true -- return true
-- end -- end
mousegrabber.stop() mousegrabber.stop()
@ -143,7 +143,7 @@ table.insert(steps, function()
placement.bottom_right(c) placement.bottom_right(c)
mouse.coords {x = c.screen.geometry.width -150, mouse.coords {x = c.screen.geometry.width -150,
y = c.screen.geometry.height-150} y = c.screen.geometry.height-150}
return true return true

View File

@ -10,15 +10,15 @@ local function exit_callback(cause, signal)
done = true done = true
end end
local pid = awesome.spawn({"/bin/sh", "-c", "sleep 60"}, false, false, local pid = awesome.spawn({"/bin/sh", "-c", "sleep 60"}, false, false,
false, false, exit_callback) false, false, exit_callback)
awesome.kill(pid, awesome.unix_signal.SIGKILL) awesome.kill(pid, awesome.unix_signal.SIGKILL)
runner.run_steps({ runner.run_steps({
function() function()
if done then if done then
return true return true
end end
end end
}) })
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -6,10 +6,10 @@ local test_client = require("_client")
local manage_called, c_snid local manage_called, c_snid
client.connect_signal("manage", function(c) client.connect_signal("manage", function(c)
manage_called = true manage_called = true
c_snid = c.startup_id c_snid = c.startup_id
assert(c.machine == awesome.hostname, assert(c.machine == awesome.hostname,
tostring(c.machine) .. " ~= " .. tostring(awesome.hostname)) tostring(c.machine) .. " ~= " .. tostring(awesome.hostname))
end) end)
local snid local snid
@ -20,39 +20,39 @@ local function callback(c)
end end
local steps = { local steps = {
function(count) function(count)
if count == 1 then if count == 1 then
snid = test_client("foo", "bar", true) snid = test_client("foo", "bar", true)
elseif manage_called then elseif manage_called then
assert(snid) assert(snid)
assert(snid == c_snid) assert(snid == c_snid)
return true return true
end end
end, end,
-- Test that c.startup_id is nil for a client without startup notifications, -- Test that c.startup_id is nil for a client without startup notifications,
-- and especially not the one from the previous spawn. -- and especially not the one from the previous spawn.
function(count) function(count)
if count == 1 then if count == 1 then
manage_called = false manage_called = false
test_client("bar", "foo", false) test_client("bar", "foo", false)
elseif manage_called then elseif manage_called then
assert(c_snid == nil, "c.startup_snid should be nil!") assert(c_snid == nil, "c.startup_snid should be nil!")
return true return true
end end
end, end,
function(count) function(count)
if count == 1 then if count == 1 then
manage_called = false manage_called = false
snid = test_client("baz", "barz", false, callback) snid = test_client("baz", "barz", false, callback)
elseif manage_called then elseif manage_called then
assert(snid) assert(snid)
assert(snid == c_snid) assert(snid == c_snid)
assert(num_callbacks == 1, num_callbacks) assert(num_callbacks == 1, num_callbacks)
return true return true
end end
end, end,
} }
runner.run_steps(steps) runner.run_steps(steps)

View File

@ -10,89 +10,89 @@ local exit_yay, exit_snd = nil, nil
-- * spawn with startup notification is covered by test-spawn-snid.lua -- * spawn with startup notification is covered by test-spawn-snid.lua
local steps = { local steps = {
function() function()
-- Test various error conditions. There are quite a number of them... -- Test various error conditions. There are quite a number of them...
local error_message local error_message
error_message = spawn("this_does_not_exist_and_should_fail") error_message = spawn("this_does_not_exist_and_should_fail")
assert(string.find(error_message, 'No such file or directory'), error_message) assert(string.find(error_message, 'No such file or directory'), error_message)
error_message = spawn({"this_does_not_exist_and_should_fail"}) error_message = spawn({"this_does_not_exist_and_should_fail"})
assert(string.find(error_message, 'No such file or directory'), error_message) assert(string.find(error_message, 'No such file or directory'), error_message)
error_message = spawn("foo '") error_message = spawn("foo '")
assert(string.find(error_message, 'parse error: Text ended before matching quote was found'), error_message) assert(string.find(error_message, 'parse error: Text ended before matching quote was found'), error_message)
error_message = spawn() error_message = spawn()
assert(string.find(error_message, 'No command to execute'), error_message) assert(string.find(error_message, 'No command to execute'), error_message)
error_message = spawn(" ") error_message = spawn(" ")
assert(string.find(error_message, 'Text was empty'), error_message) assert(string.find(error_message, 'Text was empty'), error_message)
error_message = spawn("") error_message = spawn("")
assert(string.find(error_message, 'No command to execute'), error_message) assert(string.find(error_message, 'No command to execute'), error_message)
error_message = spawn{} error_message = spawn{}
assert(string.find(error_message, 'There is nothing to execute'), error_message) assert(string.find(error_message, 'There is nothing to execute'), error_message)
return true return true
end, end,
function(count) function(count)
if count == 1 then if count == 1 then
local steps_yay = 0 local steps_yay = 0
spawn.with_line_callback("echo yay", { spawn.with_line_callback("echo yay", {
stdout = function(line) stdout = function(line)
assert(line == "yay", "line == '" .. tostring(line) .. "'") assert(line == "yay", "line == '" .. tostring(line) .. "'")
assert(steps_yay == 0) assert(steps_yay == 0)
steps_yay = steps_yay + 1 steps_yay = steps_yay + 1
end, end,
output_done = function() output_done = function()
assert(steps_yay == 1) assert(steps_yay == 1)
steps_yay = steps_yay + 1 steps_yay = steps_yay + 1
spawns_done = spawns_done + 1 spawns_done = spawns_done + 1
end, end,
exit = function(reason, code) exit = function(reason, code)
assert(reason == "exit") assert(reason == "exit")
assert(exit_yay == nil) assert(exit_yay == nil)
assert(code == 0) assert(code == 0)
exit_yay = code exit_yay = code
end end
}) })
local steps_count = 0 local steps_count = 0
local err_count = 0 local err_count = 0
spawn.with_line_callback({ "sh", "-c", "printf line1\\\\nline2\\\\nline3 ; echo err >&2 ; exit 42" }, { spawn.with_line_callback({ "sh", "-c", "printf line1\\\\nline2\\\\nline3 ; echo err >&2 ; exit 42" }, {
stdout = function(line) stdout = function(line)
assert(steps_count < 3) assert(steps_count < 3)
steps_count = steps_count + 1 steps_count = steps_count + 1
assert(line == "line" .. steps_count, "line == '" .. tostring(line) .. "'") assert(line == "line" .. steps_count, "line == '" .. tostring(line) .. "'")
end, end,
stderr = function(line) stderr = function(line)
assert(err_count == 0) assert(err_count == 0)
err_count = err_count + 1 err_count = err_count + 1
assert(line == "err", "line == '" .. tostring(line) .. "'") assert(line == "err", "line == '" .. tostring(line) .. "'")
end, end,
output_done = function() output_done = function()
assert(steps_count == 3) assert(steps_count == 3)
assert(err_count == 1) assert(err_count == 1)
steps_count = steps_count + 1 steps_count = steps_count + 1
spawns_done = spawns_done + 1 spawns_done = spawns_done + 1
end, end,
exit = function(reason, code) exit = function(reason, code)
assert(reason == "exit") assert(reason == "exit")
assert(exit_snd == nil) assert(exit_snd == nil)
assert(code == 42) assert(code == 42)
exit_snd = code exit_snd = code
end end
}) })
end end
if spawns_done == 2 then if spawns_done == 2 then
assert(exit_yay == 0) assert(exit_yay == 0)
assert(exit_snd == 42) assert(exit_snd == 42)
return true return true
end end
end, end,
} }
runner.run_steps(steps) runner.run_steps(steps)

View File

@ -78,49 +78,49 @@ table.insert(steps, function()
end) end)
table.insert(steps, function() table.insert(steps, function()
assert(parent:geometry().width == 500) assert(parent:geometry().width == 500)
assert(parent:geometry().height == 500) assert(parent:geometry().height == 500)
assert(parent:geometry().y == small:geometry().y) assert(parent:geometry().y == small:geometry().y)
assert(parent:geometry().x == small:geometry().x) assert(parent:geometry().x == small:geometry().x)
assert(parent:geometry().width == small:geometry().width ) assert(parent:geometry().width == small:geometry().width )
assert(small:geometry().height == 24) assert(small:geometry().height == 24)
-- Now, move the parent and see of the attached one is correctly updated -- Now, move the parent and see of the attached one is correctly updated
placement.stretch_left(parent) placement.stretch_left(parent)
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
assert(parent:geometry().y == small:geometry().y) assert(parent:geometry().y == small:geometry().y)
assert(parent:geometry().x == small:geometry().x) assert(parent:geometry().x == small:geometry().x)
assert(parent:geometry().width == small:geometry().width ) assert(parent:geometry().width == small:geometry().width )
assert(small:geometry().height == 24) assert(small:geometry().height == 24)
-- Do the same, but with placement compositing -- Do the same, but with placement compositing
small = wibox { small = wibox {
bg = "#ff0000", bg = "#ff0000",
height = 50, height = 50,
width = 50, width = 50,
ontop = true, ontop = true,
visible = true, visible = true,
} }
local p = placement.bottom_right + placement.scale local p = placement.bottom_right + placement.scale
p(small, {parent=parent, attach=true, direction="left", to_percent=0.5}) p(small, {parent=parent, attach=true, direction="left", to_percent=0.5})
return true return true
end) end)
local function check_ratio() local function check_ratio()
assert( assert(
( (
parent:geometry().y parent:geometry().y
+ parent:geometry().height + parent:geometry().height
- small :geometry().height - small :geometry().height
) == small:geometry().y ) == small:geometry().y
) )
assert(math.abs(parent:geometry().x + math.ceil(parent:geometry().width/2) - small:geometry().x) <= 1) assert(math.abs(parent:geometry().x + math.ceil(parent:geometry().width/2) - small:geometry().x) <= 1)
@ -153,27 +153,27 @@ table.insert(steps, function()
end) end)
table.insert(steps, function() table.insert(steps, function()
local wa = screen.primary.workarea local wa = screen.primary.workarea
local sgeo = screen.primary.geometry local sgeo = screen.primary.geometry
local wgeo = twibar:geometry() local wgeo = twibar:geometry()
assert(wa.width == sgeo.width ) assert(wa.width == sgeo.width )
assert(wa.x == sgeo.x ) assert(wa.x == sgeo.x )
assert(wa.y == sgeo.y + wgeo.height ) assert(wa.y == sgeo.y + wgeo.height )
-- assert(wa.height == sgeo.height - wgeo.height) -- assert(wa.height == sgeo.height - wgeo.height)
-- assert(wgeo.height == sgeo.height - wa.height ) -- assert(wgeo.height == sgeo.height - wa.height )
assert(parent.y == wa.y ) assert(parent.y == wa.y )
assert(parent.x == wa.x ) assert(parent.x == wa.x )
assert(parent.width == wa.width ) assert(parent.width == wa.width )
assert(parent.height == wa.height ) assert(parent.height == wa.height )
-- Add more wibars -- Add more wibars
bwibar = wibar {position = "bottom", bg = "#00ff00"} bwibar = wibar {position = "bottom", bg = "#00ff00"}
lwibar = wibar {position = "left" , bg = "#0000ff"} lwibar = wibar {position = "left" , bg = "#0000ff"}
rwibar = wibar {position = "right" , bg = "#ff00ff"} rwibar = wibar {position = "right" , bg = "#ff00ff"}
return true return true
end) end)
-- Make sure the maximized client has the right size and position -- Make sure the maximized client has the right size and position
@ -217,7 +217,7 @@ table.insert(steps, function()
parent.border_color = "#ffff00" parent.border_color = "#ffff00"
parent.border_width = 10 parent.border_width = 10
parent.ontop = true parent.ontop = true
-- parent.visible = false -- parent.visible = false
local wa = screen.primary.workarea local wa = screen.primary.workarea
local sgeo = screen.primary.geometry local sgeo = screen.primary.geometry
@ -243,54 +243,54 @@ table.insert(steps, function()
end) end)
table.insert(steps, function() table.insert(steps, function()
check_maximize() check_maximize()
-- There should be a detach callback -- There should be a detach callback
assert(lwibar.detach_callback) assert(lwibar.detach_callback)
-- Begin to move wibars around -- Begin to move wibars around
lwibar.position = "top" lwibar.position = "top"
assert(lwibar.position == "top") assert(lwibar.position == "top")
assert(lwibar.y == twibar.height) assert(lwibar.y == twibar.height)
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
check_maximize() check_maximize()
bwibar.position = "right" bwibar.position = "right"
bwibar.ontop = true bwibar.ontop = true
rwibar.ontop = true rwibar.ontop = true
assert(bwibar.position == "right") assert(bwibar.position == "right")
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
check_maximize() check_maximize()
rwibar.position = "top" rwibar.position = "top"
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
check_maximize() check_maximize()
bwibar.position = "top" bwibar.position = "top"
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
check_maximize() check_maximize()
for _, w in ipairs {twibar, lwibar, rwibar, bwibar} do for _, w in ipairs {twibar, lwibar, rwibar, bwibar} do
w.position = "right" w.position = "right"
end end
return true return true
end) end)
-- Test visibility -- Test visibility
@ -304,17 +304,17 @@ table.insert(steps, function()
end) end)
table.insert(steps, function() table.insert(steps, function()
check_maximize() check_maximize()
twibar.visible = true twibar.visible = true
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
check_maximize() check_maximize()
return true return true
end) end)

View File

@ -11,100 +11,100 @@ assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == nil)
-- TODO: generalize and move to runner. -- TODO: generalize and move to runner.
local urgent_cb_done local urgent_cb_done
client.connect_signal("property::urgent", function (c) client.connect_signal("property::urgent", function (c)
urgent_cb_done = true urgent_cb_done = true
assert(c.class == "XTerm", "Client should be xterm!") assert(c.class == "XTerm", "Client should be xterm!")
end) end)
local manage_cb_done local manage_cb_done
client.connect_signal("manage", function (c) client.connect_signal("manage", function (c)
manage_cb_done = true manage_cb_done = true
assert(c.class == "XTerm", "Client should be xterm!") assert(c.class == "XTerm", "Client should be xterm!")
end) end)
-- Steps to do for this test. -- Steps to do for this test.
local steps = { local steps = {
-- Step 1: tag 2 should become urgent, when a client gets tagged via rules. -- Step 1: tag 2 should become urgent, when a client gets tagged via rules.
function(count) function(count)
if count == 1 then -- Setup. if count == 1 then -- Setup.
urgent_cb_done = false urgent_cb_done = false
-- Select first tag. -- Select first tag.
awful.screen.focused().tags[1]:view_only() awful.screen.focused().tags[1]:view_only()
runner.add_to_default_rules({ rule = { class = "XTerm" }, runner.add_to_default_rules({ rule = { class = "XTerm" },
properties = { tag = "2", focus = true } }) properties = { tag = "2", focus = true } })
awful.spawn("xterm") awful.spawn("xterm")
end end
if urgent_cb_done then if urgent_cb_done then
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == true) assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == true)
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent_count") == 1) assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent_count") == 1)
return true return true
end end
end, end,
-- Step 2: when switching to tag 2, it should not be urgent anymore. -- Step 2: when switching to tag 2, it should not be urgent anymore.
function(count) function(count)
if count == 1 then if count == 1 then
-- Setup: switch to tag. -- Setup: switch to tag.
root.fake_input("key_press", "Super_L") root.fake_input("key_press", "Super_L")
root.fake_input("key_press", "2") root.fake_input("key_press", "2")
root.fake_input("key_release", "2") root.fake_input("key_release", "2")
root.fake_input("key_release", "Super_L") root.fake_input("key_release", "Super_L")
elseif awful.screen.focused().selected_tags[1] == awful.screen.focused().tags[2] then elseif awful.screen.focused().selected_tags[1] == awful.screen.focused().tags[2] then
assert(#client.get() == 1) assert(#client.get() == 1)
local c = client.get()[1] local c = client.get()[1]
assert(not c.urgent, "Client is not urgent anymore.") assert(not c.urgent, "Client is not urgent anymore.")
assert(c == client.focus, "Client is focused.") assert(c == client.focus, "Client is focused.")
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == false) assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == false)
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent_count") == 0) assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent_count") == 0)
return true return true
end end
end, end,
-- Step 3: tag 2 should not be urgent, but switched to. -- Step 3: tag 2 should not be urgent, but switched to.
function(count) function(count)
if count == 1 then -- Setup. if count == 1 then -- Setup.
urgent_cb_done = false urgent_cb_done = false
-- Select first tag. -- Select first tag.
awful.screen.focused().tags[1]:view_only() awful.screen.focused().tags[1]:view_only()
runner.add_to_default_rules({ rule = { class = "XTerm" }, runner.add_to_default_rules({ rule = { class = "XTerm" },
properties = { tag = "2", focus = true, switchtotag = true }}) properties = { tag = "2", focus = true, switchtotag = true }})
awful.spawn("xterm") awful.spawn("xterm")
elseif awful.screen.focused().selected_tags[1] == awful.screen.focused().tags[2] then elseif awful.screen.focused().selected_tags[1] == awful.screen.focused().tags[2] then
assert(not urgent_cb_done) assert(not urgent_cb_done)
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == false) assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == false)
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent_count") == 0) assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent_count") == 0)
assert(awful.screen.focused().selected_tags[2] == nil) assert(awful.screen.focused().selected_tags[2] == nil)
return true return true
end end
end, end,
-- Step 4: tag 2 should not become urgent, when a client gets tagged via -- Step 4: tag 2 should not become urgent, when a client gets tagged via
-- rules with focus=false. -- rules with focus=false.
function(count) function(count)
if count == 1 then -- Setup. if count == 1 then -- Setup.
client.get()[1]:kill() client.get()[1]:kill()
manage_cb_done = false manage_cb_done = false
runner.add_to_default_rules({rule = { class = "XTerm" }, runner.add_to_default_rules({rule = { class = "XTerm" },
properties = { tag = "2", focus = false }}) properties = { tag = "2", focus = false }})
awful.spawn("xterm") awful.spawn("xterm")
end end
if manage_cb_done then if manage_cb_done then
assert(client.get()[1].urgent == false) assert(client.get()[1].urgent == false)
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == false) assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == false)
assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent_count") == 0) assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent_count") == 0)
return true return true
end end
end, end,
} }
runner.run_steps(steps) runner.run_steps(steps)

View File

@ -54,83 +54,83 @@ table.insert(steps, function()
end) end)
table.insert(steps, function() table.insert(steps, function()
wp.fit(img, screen[1], "#00ff00") wp.fit(img, screen[1], "#00ff00")
-- There is a delayed call for the last call, let it be processed before -- There is a delayed call for the last call, let it be processed before
-- adding more -- adding more
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
wp.centered(img, nil, nil) wp.centered(img, nil, nil)
wp.centered(img, screen[1], nil) wp.centered(img, screen[1], nil)
-- There is a delayed call for the last call, let it be processed before -- There is a delayed call for the last call, let it be processed before
-- adding more -- adding more
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
wp.centered(img, screen[1], "#00ff00") wp.centered(img, screen[1], "#00ff00")
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
wp.maximized(img, nil, nil, nil) wp.maximized(img, nil, nil, nil)
-- There is a delayed call for the last call, let it be processed before -- There is a delayed call for the last call, let it be processed before
-- adding more -- adding more
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
wp.maximized(img, screen[1], nil, nil) wp.maximized(img, screen[1], nil, nil)
-- There is a delayed call for the last call, let it be processed before -- There is a delayed call for the last call, let it be processed before
-- adding more -- adding more
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
wp.maximized(img, screen[1], false, nil) wp.maximized(img, screen[1], false, nil)
wp.maximized(img, screen[1], true, nil) wp.maximized(img, screen[1], true, nil)
-- There is a delayed call for the last call, let it be processed before -- There is a delayed call for the last call, let it be processed before
-- adding more -- adding more
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
wp.maximized(img, screen[1], false, {x=10, y= 10}) wp.maximized(img, screen[1], false, {x=10, y= 10})
wp.maximized(img, screen[1], true, {x=10, y= 10}) wp.maximized(img, screen[1], true, {x=10, y= 10})
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
wp.tiled(img, nil, nil) wp.tiled(img, nil, nil)
wp.tiled(img, screen[1], nil) wp.tiled(img, screen[1], nil)
-- There is a delayed call for the last call, let it be processed before -- There is a delayed call for the last call, let it be processed before
-- adding more -- adding more
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
wp.tiled(img, screen[1], {x=10, y= 10}) wp.tiled(img, screen[1], {x=10, y= 10})
return true return true
end) end)
table.insert(steps, function() table.insert(steps, function()
for _, c in ipairs(colors) do for _, c in ipairs(colors) do
wp.set(c) wp.set(c)
end end
return true return true
end) end)