Skip to content

Commit

Permalink
test(w.w.slider): Fix integration test
Browse files Browse the repository at this point in the history
In CI, the wibox doesn't always seem to be in the same location.
So before the actual test steps, we need to find it first.
  • Loading branch information
sclu1034 authored and Elv13 committed Dec 31, 2023
1 parent fc9c3a5 commit 4d9ea87
Showing 1 changed file with 36 additions and 17 deletions.
53 changes: 36 additions & 17 deletions tests/test-wibox-widget-slider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ local function step(_, func)
table.insert(steps, func)
end

-- Apparently in CI the wibox won't always be at the coordinates we specify.
-- So we'll have to click around blindly until we find our widget,
-- then use those coordinates as offset for the actual test.
local offset_x = nil
local offset_y = nil

local w
local slider

Expand All @@ -34,7 +40,18 @@ step("create slider widget", function()
handle_border_width = 1,
}

slider:connect_signal("button::press", function(...) on_mouse_press = true end)
slider:connect_signal("button::press", function(...)
on_mouse_press = true

if offset_x ~= nil then
return
end

local coords = mouse.coords()
offset_x = coords.x
offset_y = coords.y
print(coords.x, coords.y)
end)
slider:connect_signal("drag_start", function(...) on_drag_start = true end)
slider:connect_signal("drag", function(...) on_drag = true end)
slider:connect_signal("drag_end", function(...) on_drag_end = true end)
Expand All @@ -53,26 +70,28 @@ step("create slider widget", function()
return true
end)

step("start dragging", function()
-- Coordinates to hit the slider's handle
mouse.coords({ x = 1, y = 24 })
for x = 0, 2000, 5 do
for y = 0, 2000, 5 do
step("find widget", function()
if offset_x ~= nil then
return true
end

root.fake_input("button_press", 1)
awesome.sync()

return on_drag_start
end)
mouse.coords({ x = x, y = y })
root.fake_input("button_press", 1)
root.fake_input("button_release", 1)

step("drag handle", function()
mouse.coords({ x = 50, y = 24 })
return true
end)
return true
end)
end
end

step("stop dragging", function()
step("test dragging", function()
mouse.coords({ x = offset_x, y = offset_y })
root.fake_input("button_press", 1)
mouse.coords({ x = offset_x + 100, offset_y })
root.fake_input("button_release", 1)
awesome.sync()

return on_drag_end
return true
end)

step("check signals", function()
Expand Down

0 comments on commit 4d9ea87

Please sign in to comment.