Ready-to-use Code ExampleRegionKVTestingAsset

Multi-Region Smoke Test

Verifies in a single pass that several critical regions of a UI (logo, button, counter) all render correctly. Writes results atomically with KV.setAll (no partial writes) and reports details on failure. Ideal for a CI-style sanity test flow.

Copyable Example Code

You can paste this into the code editor; still verify target image, region, color, text, and timing values in your own device flow.

-- Coklu bolge smoke testi / Multi-region smoke test
-- KV.setAll ile atomik sonuc yazma, basarisizlik raporu

local checks = {
  { name = "logo",       region = Region(50, 50, 200, 80),    asset = "ana_logo"   },
  { name = "baslat_btn", region = Region(400, 800, 280, 100), asset = "baslat_buton" },
  { name = "sayac",      region = Region(900, 100, 180, 60),  asset = "sayac_arka"  },
}

Snap.screenRefresh()
local results = {}
local failures = {}

for _, check in ipairs(checks) do
  local found = check.region:find(Asset.image(check.asset))
  if found then
    results[check.name] = "OK"
  else
    results[check.name] = "FAIL"
    table.insert(failures, check.name)
  end
end

-- Atomik yaz — eger setAll fail olursa hicbiri yazilmaz
results["smoke_test_ts"] = DateTime():format("YYYY-MM-DD HH:mm:ss")
results["smoke_test_pass"] = (#failures == 0) and "true" or "false"
KV.setAll(results)

if #failures == 0 then
  toast("Smoke test PASS — tum bolgeler OK")
  System.vibrate(50)
else
  local msg = "Smoke test FAIL: " .. table.concat(failures, ", ")
  toast(msg)
  System.noti("Smoke test basarisiz", msg)
end

Implementation and Adaptation Notes

  • Before running, replace sample values such as image names, text, colors, coordinates, and file paths with your own macro values.
  • For examples that use Region or coordinates, retest the target area on different resolutions and DPI values.
  • Tune mScore, timeout, and scan rate in a test macro first, then move the verified values into the production macro.
  • Avoid overly wide Region areas; a tighter area scans faster and reduces false matches.