Files
slate32/test/settings_busy.lua
T
evan 1cb52997a9 feat(gui): render user-selectable TTF fonts
Embed a Latin-1 Meslo LG S default and use OpenFontRender for anti-aliased text with an explicit pixel size on each draw and measurement call. Apps may replace the one retained face with an SD-backed TTF and restore Meslo with nil. Refresh UI sizing, status telemetry, Settings typography, tests, documentation, and font license notices.
2026-08-02 14:54:49 -04:00

50 lines
1.7 KiB
Lua

-- Run: lua test/settings_busy.lua
-- The scan and keyboard screens announce themselves before work that blocks the loop for
-- seconds. on_tick runs before draw in the same pass, so anything left for draw() to paint
-- appears only after the blocking call returns -- on a panel ui.screen() has already
-- cleared. These assert the announcement is painted by the tap itself.
package.path = "sdcard/lib/?.lua;test/?.lua;" .. package.path
local device = require("fake_device").install()
dofile("sdcard/apps/Settings/main.lua")
local function tapRow(prefix)
device.painted = {}
draw()
for _, item in ipairs(device.painted) do
if item.label:sub(1, #prefix) == prefix then
device.painted = {}
on_touch_down(item.x + 2, item.y + 2)
on_touch_up(item.x + 2, item.y + 2)
return
end
end
error("no row labelled '" .. prefix .. "'")
end
local function paintedLabel(prefix)
for _, item in ipairs(device.painted) do
if item.label:sub(1, #prefix) == prefix then return item end
end
return nil
end
init()
tapRow("WiFi")
tapRow("scan networks")
-- Painted by the tap, with no draw() in between.
local busy = paintedLabel("scanning")
assert(busy, "the scan screen paints its notice before scanning")
local width = #busy.label * device.charWidth
local centerX = busy.x + width / 2
local centerY = busy.y + device.fontHeight / 2
local panelW, panelH = gui.getWidth(), gui.getHeight()
assert(math.abs(centerX - panelW / 2) <= 1, "centered horizontally, got x " .. busy.x)
-- The bar is above the app's frame, so the app's own height is what it centers in.
assert(math.abs(centerY - panelH / 2) <= 1, "centered vertically, got y " .. busy.y)
print("ok")