- Tests that only wrote PNGs to look at are gone: desktop, overview (and its overview_shot helper), editor, emoji picker, launcher/Icon Desktop and dock screenshots. They were among the slowest in the suite; the behaviour they touched has its own tests. - moon-disc never had source in the tree, so every fresh panel said "Module 'moon-disc' not found". It is out of the default panel, and a saved panel drops it (migrate_panel). The settings module's sample rows and labels no longer mention it. - The settings module lists Show Desktop under "Apps and windows", with a description. - just test ran lib/taskbar, lib/layoutpick and lib/modmgr, which no longer exist, so the wasm lib tests failed to start; it now runs every package in lib/ (83 tests). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
97 lines
5.1 KiB
MoonBit
97 lines
5.1 KiB
MoonBit
///| The dock as the panel's task manager, driven through real frames.
|
|
|
|
///| Pick row `label` of the open right-click menu (rows: 26px title, then 28px each).
|
|
fn dock_pick(comp : @host.ChandraCompositor, label : String, t : UInt) -> Unit raise {
|
|
let i = comp.shell.menu_rows.map(r => r.label).search(label).unwrap()
|
|
let m = comp.shell.menu_rect
|
|
click_at(comp, m.x + m.w / 2, m.y + 26 + 28 * i + 14, t)
|
|
}
|
|
|
|
///| A key pressed and released with Super held (evdev codes).
|
|
fn super_key(comp : @host.ChandraCompositor, code : UInt, t : UInt) -> Unit {
|
|
comp.handle_input(@nested.InputEvent::Key(125U, true), t)
|
|
comp.handle_input(@nested.InputEvent::Key(code, true), t + 1U)
|
|
comp.handle_input(@nested.InputEvent::Key(code, false), t + 2U)
|
|
comp.handle_input(@nested.InputEvent::Key(125U, false), t + 3U)
|
|
ignore(comp.compose_frame())
|
|
}
|
|
|
|
///|
|
|
test "the dock is the panel's task manager: empty + opens Applications, pin from there, Super+number" {
|
|
let socket_path = "/tmp/wayland-moon-dockbar-" + @sys.getpid().to_string() + ".sock"
|
|
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
|
ignore(comp.compose_frame())
|
|
// A fresh panel has the dock where the task list was; the old id is an alias of it.
|
|
let slot = comp.shell.slot_of("dock")
|
|
assert_true(slot.length() > 0)
|
|
assert_eq(comp.shell.slot_of("tasks"), slot)
|
|
// It stretches: the clock still packs against the right edge.
|
|
let r = comp.shell.slot_rect(slot)
|
|
assert_true(r.w > 300)
|
|
let clock = comp.shell.slot_rect(comp.shell.slot_of("clock-digital"))
|
|
assert_true(clock.x > 900)
|
|
// Nothing pinned, nothing running: a "+" that opens the Applications menu.
|
|
comp.shell.set_module_setting(slot, "pinned", ";")
|
|
ignore(comp.compose_frame())
|
|
comp.handle_input(@nested.InputEvent::PointerMove((r.x + 14).to_double(), (r.y + r.h / 2).to_double()), 8U)
|
|
ignore(@sys.write_file_bytes("_build/dock_empty.png", @renderer.encode_png(comp.compose_frame())))
|
|
click_at(comp, r.x + 14, r.y + r.h / 2, 10U)
|
|
let launcher = comp.shell.slot_of("launcher")
|
|
let pr = comp.shell.slot_popup_rect(launcher)
|
|
assert_true(pr.w > 0)
|
|
// (The apps are right of the category column, when the machine has enough of them for one.)
|
|
// Right-click the first app there: Open, Pin to dock. Pinning keeps the menu open.
|
|
click_at(comp, pr.x + pr.w - 60, pr.y + 60, 20U, btn=273U)
|
|
assert_true(comp.shell.menu_open)
|
|
assert_eq(comp.shell.menu_rows.map(r => r.label), ["Open", "Pin to dock"])
|
|
let first = comp.shell.menu_title
|
|
ignore(@sys.write_file_bytes("_build/dock_pin_from_menu.png", @renderer.encode_png(comp.compose_frame())))
|
|
dock_pick(comp, "Pin to dock", 25U)
|
|
assert_true(comp.shell.slot_popup_rect(launcher).w > 0)
|
|
let pinned = comp.shell.module_setting("dock", "pinned").unwrap_or("")
|
|
assert_true(pinned.length() > 1 && pinned != ";")
|
|
// The same app's menu now offers Unpin.
|
|
click_at(comp, pr.x + pr.w - 60, pr.y + 60, 30U, btn=273U)
|
|
assert_eq(comp.shell.menu_title, first)
|
|
assert_true(comp.shell.menu_rows.map(r => r.label).contains("Unpin from dock"))
|
|
comp.handle_input(@nested.InputEvent::Key(1U, true), 35U) // Escape closes the menu
|
|
comp.handle_input(@nested.InputEvent::Key(1U, false), 36U)
|
|
comp.handle_input(@nested.InputEvent::Key(1U, true), 37U) // and the Applications menu
|
|
comp.handle_input(@nested.InputEvent::Key(1U, false), 38U)
|
|
// Two running apps pinned in front: Super+2 brings the second one's window forward.
|
|
comp.shell.set_module_setting(slot, "pinned", "libreoffice-writer;libreoffice-calc;vim")
|
|
let _a = open_and_configure_client(comp, socket_path, "Report.odt", "libreoffice-writer")
|
|
let _b = open_and_configure_client(comp, socket_path, "Budget.ods", "libreoffice-calc")
|
|
let _c = open_and_configure_client(comp, socket_path, "Notes.odt", "libreoffice-writer")
|
|
ignore(comp.compose_frame())
|
|
let focused = fn() {
|
|
let mut f = ""
|
|
for _, w in comp.windows {
|
|
if w.focused {
|
|
f = w.title
|
|
}
|
|
}
|
|
f
|
|
}
|
|
// Vim isn't running, so its icon comes first, then the tasks: Writer, Calc (pin order).
|
|
assert_eq(comp.shell.dock_item_ids(), ["vim", "libreoffice-writer", "libreoffice-calc"])
|
|
super_key(comp, 4U, 40U) // Super+3
|
|
assert_eq(focused(), "Budget.ods")
|
|
super_key(comp, 3U, 50U) // Super+2: Writer's newest window, then its other one
|
|
assert_eq(focused(), "Notes.odt")
|
|
super_key(comp, 3U, 60U)
|
|
assert_eq(focused(), "Report.odt")
|
|
// Writer's menu lists its two windows by title; picking one brings it forward.
|
|
let r = comp.shell.slot_rect(slot)
|
|
let writer_x = r.x + 6 + 24 + 6 + 11 + 20 // after Vim's icon and the divider
|
|
click_at(comp, writer_x, r.y + r.h / 2, 70U, btn=273U)
|
|
let labels = comp.shell.menu_rows.map(r => r.label)
|
|
assert_true(labels.contains("Report.odt") && labels.contains("Notes.odt"))
|
|
ignore(@sys.write_file_bytes("_build/dock_bar_menu.png", @renderer.encode_png(comp.compose_frame())))
|
|
dock_pick(comp, "Notes.odt", 80U)
|
|
ignore(comp.compose_frame())
|
|
assert_eq(focused(), "Notes.odt")
|
|
comp.handle_input(@nested.InputEvent::PointerMove((r.x + 6 + 12).to_double(), (r.y + r.h / 2).to_double()), 90U)
|
|
ignore(@sys.write_file_bytes("_build/dock_bar.png", @renderer.encode_png(comp.compose_frame())))
|
|
}
|