- 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>
80 lines
3.1 KiB
MoonBit
80 lines
3.1 KiB
MoonBit
///| App icons in the Applications menu and on the Icon Desktop: the shell publishes the .desktop
|
|
/// icon of every app they show (compositor/shell/icons.mbt `icon_app_ids`), and both draw it.
|
|
/// Needs the modules built: scripts/build-modules.sh.
|
|
|
|
///| A 48x48 PNG of one colour at `path`.
|
|
fn write_icon_png(path : String, r : Int, g : Int, b : Int) -> Unit {
|
|
let p = @renderer.Pixmap::new(48, 48)
|
|
for i = 0; i < 48 * 48; i = i + 1 {
|
|
p.data[i * 4] = r.to_byte()
|
|
p.data[i * 4 + 1] = g.to_byte()
|
|
p.data[i * 4 + 2] = b.to_byte()
|
|
p.data[i * 4 + 3] = b'\xff'
|
|
}
|
|
ignore(@sys.write_file_bytes(path, @renderer.encode_png(p)))
|
|
}
|
|
|
|
///| The (r, g, b) of the frame at (x, y).
|
|
fn frame_rgb(f : @renderer.Pixmap, x : Int, y : Int) -> (Int, Int, Int) {
|
|
let i = (y * f.width + x) * 4
|
|
(f.data[i].to_int(), f.data[i + 1].to_int(), f.data[i + 2].to_int())
|
|
}
|
|
|
|
///| A compositor with the six fake apps of `desk_comp`, where app0's .desktop file says
|
|
/// Icon=<an absolute path to a red PNG without an extension, as AppImage managers write it>.
|
|
fn icon_comp(tag : String) -> @host.ChandraCompositor {
|
|
let comp = desk_comp(tag)
|
|
let png = "/tmp/chandra-icon-" + tag + "-" + @sys.getpid().to_string()
|
|
write_icon_png(png, 230, 20, 20)
|
|
comp.shell.exec.set("app0", "app0")
|
|
comp.shell.icon_names.set("app0", png)
|
|
// The first frame already looked app0 up (the dock pins it): forget that.
|
|
comp.shell.icon_handles.remove("app0")
|
|
comp
|
|
}
|
|
|
|
///|
|
|
test "the Icon Desktop gets every catalog app's icon, drawn from an absolute Icon= path" {
|
|
let comp = icon_comp("idesk")
|
|
let before = comp.shell.icon_app_ids()
|
|
assert_false(before.contains("app5"))
|
|
assert_true(comp.shell.set_desktop("icon-desktop"))
|
|
ignore(comp.compose_frame())
|
|
let ids = comp.shell.icon_app_ids()
|
|
for i = 0; i < 6; i = i + 1 {
|
|
assert_true(ids.contains("app" + i.to_string()))
|
|
}
|
|
assert_true(comp.shell.window_icon("app0") != 0U)
|
|
// app0's icon sits in the first cell (see desktop_test): its middle is the PNG's red.
|
|
let f = comp.compose_frame()
|
|
assert_eq(frame_rgb(f, 68, 50), (230, 20, 20))
|
|
ignore(@sys.write_file_bytes("_build/desktop_icons_real.png", @renderer.encode_png(f)))
|
|
comp.shell.shutdown()
|
|
}
|
|
|
|
///|
|
|
test "the open Applications menu gets its rows' icons and draws them" {
|
|
let comp = icon_comp("lmenu")
|
|
assert_false(comp.shell.icon_app_ids().contains("app5"))
|
|
comp.shell.toggle_launcher()
|
|
for _ in 0..<10 {
|
|
@sys.sleep_ms(30) // the popup slides in
|
|
ignore(comp.compose_frame())
|
|
}
|
|
let pr = comp.shell.slot_popup_rect(comp.shell.slot_of("launcher"))
|
|
assert_true(pr.w > 0)
|
|
let ids = comp.shell.icon_app_ids()
|
|
for i = 0; i < 6; i = i + 1 {
|
|
assert_true(ids.contains("app" + i.to_string()))
|
|
}
|
|
let f = comp.compose_frame()
|
|
// Row 0 is app0 ("Files"): its icon is centred 30 px in, half a row (46 px) below the header.
|
|
assert_eq(frame_rgb(f, pr.x + 30, pr.y + 52 + 22), (230, 20, 20))
|
|
ignore(@sys.write_file_bytes("_build/launcher_icons.png", @renderer.encode_png(f)))
|
|
// Closed again: the menu's apps drop out of the table.
|
|
comp.shell.toggle_launcher()
|
|
ignore(comp.compose_frame())
|
|
assert_false(comp.shell.icon_app_ids().contains("app5"))
|
|
comp.shell.shutdown()
|
|
}
|