add base-apps with manifests, layout system, and testing documentation

- Rename test-apps to base-apps with proper manifest.json for each app
- Add is_system_app flag to app discovery and Lua API
- Fix icon path resolution for /system/icons/ paths
- Add layout.lua and layout.rcss for reusable UI components
- Update home screen to dynamically load all apps from manifests
- Update all app RML files to use layout components
- Comprehensive testing framework documentation with JSON action format
- Add tests/ directory structure for automated UI testing
This commit is contained in:
2026-01-20 09:14:05 +01:00
parent 5de087e8e0
commit 1f91d7508e
101 changed files with 13103 additions and 966 deletions

View File

@@ -0,0 +1,223 @@
-- Sandbox Test App
-- Tests: timers, JSON, crypto, storage
local results = {}
local logCounter = 0
-- Helper to get document (use global set by C++)
local function getDocument()
-- The C++ code sets 'document' global after loading
return document
end
local function log(msg)
logCounter = logCounter + 1
table.insert(results, string.format("[%03d] %s", logCounter, msg))
local doc = getDocument()
if doc then
local el = doc:GetElementById("results")
if el then
el.inner_rml = table.concat(results, "\n")
end
end
end
-- Navigation helper
function goBack()
if navigation and navigation.back then
navigation.back()
else
log("Navigation not available")
end
end
local function setStatus(id, status, success)
local doc = getDocument()
if not doc then
print("[LUA] ERROR: document not available!")
return
end
local el = doc:GetElementById(id)
if el then
if success then
el.inner_rml = "✓ " .. status
else
el.inner_rml = "✗ " .. status
end
else
print("[LUA] ERROR: element not found: " .. id)
end
end
-- Timer test
function testTimer()
print("[LUA] testTimer called!")
setStatus("timer-status", "Running...", true)
log("Starting timer test...")
local count = 0
local timerId = nil
timerId = setInterval(function()
count = count + 1
log("Timer tick: " .. count)
if count >= 3 then
clearInterval(timerId)
setStatus("timer-status", "Passed (3 ticks)", true)
log("Timer test complete!")
end
end, 1000)
log("Timer started with ID: " .. tostring(timerId))
end
-- JSON test
function testJSON()
log("Starting JSON test...")
local success = true
local msg = ""
-- Test encode
local data = {
name = "test",
value = 42,
nested = { a = 1, b = 2 }
}
local encoded = json.encode(data)
if encoded then
log("Encoded: " .. encoded)
else
success = false
msg = "encode failed"
end
-- Test decode
if success then
local decoded = json.decode(encoded)
if decoded and decoded.name == "test" and decoded.value == 42 then
log("Decoded successfully, name=" .. decoded.name)
else
success = false
msg = "decode failed"
end
end
if success then
setStatus("json-status", "Passed", true)
log("JSON test complete!")
else
setStatus("json-status", "Failed: " .. msg, false)
end
end
-- Crypto test
function testCrypto()
log("Starting crypto test...")
local success = true
local msg = ""
-- Test random bytes
local bytes = crypto.randomBytes(16)
if bytes and #bytes == 16 then
log("Random bytes (hex): " .. bytes:gsub(".", function(c)
return string.format("%02x", c:byte())
end))
else
success = false
msg = "randomBytes failed"
end
-- Test SHA256
if success then
local hash = crypto.hash("sha256", "hello world")
if hash then
log("SHA256: " .. hash:sub(1, 32) .. "...")
else
success = false
msg = "sha256 failed"
end
end
-- Test HMAC
if success then
local hmac = crypto.hmac("sha256", "secret", "message")
if hmac then
log("HMAC: " .. hmac:sub(1, 32) .. "...")
else
success = false
msg = "hmac failed"
end
end
if success then
setStatus("crypto-status", "Passed", true)
log("Crypto test complete!")
else
setStatus("crypto-status", "Failed: " .. msg, false)
end
end
-- Storage test
function testStorage()
log("Starting storage test...")
local success = true
local msg = ""
-- Test write (VirtualFS requires /data/, /cache/, /temp/, or /shared/ prefix)
local writeOk = fs.write("/data/test.txt", "Hello from sandbox!")
if writeOk then
log("Write successful")
else
success = false
msg = "write failed"
end
-- Test read
if success then
local content = fs.read("/data/test.txt")
if content == "Hello from sandbox!" then
log("Read successful: " .. content)
else
success = false
msg = "read mismatch"
end
end
-- Test list
if success then
local files = fs.list("/data")
if files then
log("Files in /data: " .. #files)
for _, f in ipairs(files) do
log(" - " .. f)
end
end
end
-- Test delete
if success then
local deleteOk = fs.delete("/data/test.txt")
if deleteOk then
log("Delete successful")
else
success = false
msg = "delete failed"
end
end
if success then
setStatus("storage-status", "Passed", true)
log("Storage test complete!")
else
setStatus("storage-status", "Failed: " .. msg, false)
end
end
-- Initialize
log("Sandbox Test App loaded")
log("Lua version: " .. (_VERSION or "unknown"))

Binary file not shown.

View File

@@ -0,0 +1,46 @@
<rml>
<head>
<title>Sandbox Test</title>
<link type="text/rcss" href="styles.rcss"/>
<script src="app.lua"></script>
</head>
<body>
<div class="app-bar">
<div class="app-bar-nav btn-icon" onclick="goHome()">
<span class="icon">&lt;</span>
</div>
<div class="app-bar-title">Sandbox Test</div>
</div>
<div class="content">
<div class="card">
<div class="card-title">Timer Test</div>
<div id="timer-status">Not started</div>
<button onclick="testTimer()">Start Timer</button>
</div>
<div class="card">
<div class="card-title">JSON Test</div>
<div id="json-status">Not tested</div>
<button onclick="testJSON()">Test JSON</button>
</div>
<div class="card">
<div class="card-title">Crypto Test</div>
<div id="crypto-status">Not tested</div>
<button onclick="testCrypto()">Test Crypto</button>
</div>
<div class="card">
<div class="card-title">Storage Test</div>
<div id="storage-status">Not tested</div>
<button onclick="testStorage()">Test Storage</button>
</div>
<div class="card">
<div class="card-title">Results</div>
<div id="results">Click buttons above to run tests</div>
</div>
</div>
</body>
</rml>

View File

@@ -0,0 +1,18 @@
{
"id": "com.mosis.sandbox-test",
"name": "Sandbox Test",
"version": "1.0.0",
"version_code": 1,
"entry": "main.rml",
"icon": "icon.tga",
"description": "Tests sandbox APIs: timers, storage, JSON, crypto",
"developer": {
"name": "Mosis Team",
"email": "dev@mosis.dev"
},
"permissions": [
"storage",
"network"
],
"min_api_version": 1
}

View File

@@ -0,0 +1,97 @@
body {
font-family: LatoLatin;
font-size: 16dp;
background-color: #121212;
color: #ffffff;
width: 100%;
height: 100%;
}
.app-bar {
display: flex;
flex-direction: row;
align-items: center;
height: 56dp;
background-color: #1e1e1e;
padding: 0 8dp;
}
.app-bar-nav {
width: 40dp;
height: 40dp;
display: flex;
align-items: center;
justify-content: center;
border-radius: 20dp;
}
.app-bar-nav:hover {
background-color: #333333;
}
.icon {
font-size: 24dp;
}
.app-bar-title {
font-size: 20dp;
font-weight: bold;
margin-left: 16dp;
}
.content {
display: block;
padding: 16dp;
width: auto;
box-sizing: border-box;
}
.card {
display: block;
background-color: #1e1e1e;
border-radius: 12dp;
padding: 16dp;
margin-bottom: 12dp;
}
.card-title {
display: block;
font-size: 18dp;
font-weight: bold;
margin-bottom: 8dp;
color: #bb86fc;
}
.card div {
display: block;
}
button {
display: block;
background-color: #bb86fc;
color: #000000;
border-width: 0;
border-radius: 8dp;
padding: 12dp 24dp;
font-size: 14dp;
font-weight: bold;
margin-top: 8dp;
}
button:hover {
background-color: #cf9fff;
}
button:active {
background-color: #9a67ea;
}
#results {
font-family: LatoLatin;
font-size: 12dp;
background-color: #0d0d0d;
padding: 12dp;
border-radius: 8dp;
white-space: pre-wrap;
color: #00ff00;
}