01dfc4b458
The directory name is what the status bar and the launcher cards display, so Home, Hello and Settings read as titles without a lookup table. Updates the firmware's home path, the launcher's self-exclusion and the host tests that load the settings app. Also brings the bar's next repaint forward when an app renames itself or the frame rotates. The bar still decides what changed; this only stops the answer waiting most of a second for the next tick.
50 lines
1.7 KiB
Lua
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")
|