add sandbox-test app content and test functions

- Add main_content.rml for sandbox-test app with test cards for Timer, JSON, Crypto, Storage
- Add sandbox test functions to shell.lua (testSandboxTimer, testSandboxJSON, etc.)
- Register sandbox-test in builtin_ids and shellNavigateTo paths
- Add sandbox-test styles to shell.rml

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-20 11:28:12 +01:00
parent 2134a53921
commit a52b58c176
4 changed files with 248 additions and 2 deletions

View File

@@ -103,7 +103,8 @@ function shellNavigateTo(app_id)
browser = "apps/browser/browser_content.rml",
store = "apps/store/store_content.rml",
camera = "apps/camera/camera_content.rml",
music = "apps/music/music_content.rml"
music = "apps/music/music_content.rml",
["sandbox-test"] = "apps/sandbox-test/main_content.rml"
}
local path = app_paths[app_id]
@@ -488,7 +489,8 @@ function launchDiscoveredApp(package_id)
local app_id = package_id:gsub("com.mosis.", "")
local builtin_ids = {
browser = true, camera = true, contacts = true, dialer = true,
messages = true, music = true, settings = true, store = true
messages = true, music = true, settings = true, store = true,
["sandbox-test"] = true
}
if builtin_ids[app_id] then
@@ -532,6 +534,97 @@ function launchDiscoveredApp(package_id)
return false
end
-- ===== SANDBOX TEST FUNCTIONS =====
function testSandboxTimer()
local status = shell_document:GetElementById("timer-status")
local results = shell_document:GetElementById("sandbox-results")
if not mosis or not mosis.timer then
if status then status.inner_rml = "Timer API not available" end
return
end
if status then status.inner_rml = "Timer started..." end
mosis.timer.setTimeout(function()
if status then status.inner_rml = "Timer completed!" end
if results then results.inner_rml = results.inner_rml .. "\nTimer: PASSED (1 second delay)" end
showToast("Timer test passed!", "success")
end, 1000)
end
function testSandboxJSON()
local status = shell_document:GetElementById("json-status")
local results = shell_document:GetElementById("sandbox-results")
if not mosis or not mosis.json then
if status then status.inner_rml = "JSON API not available" end
return
end
local test_data = {name = "test", value = 42, nested = {a = 1, b = 2}}
local encoded = mosis.json.encode(test_data)
local decoded = mosis.json.decode(encoded)
if decoded and decoded.name == "test" and decoded.value == 42 then
if status then status.inner_rml = "JSON encode/decode: PASSED" end
if results then results.inner_rml = results.inner_rml .. "\nJSON: PASSED" end
showToast("JSON test passed!", "success")
else
if status then status.inner_rml = "JSON test: FAILED" end
showToast("JSON test failed!", "error")
end
end
function testSandboxCrypto()
local status = shell_document:GetElementById("crypto-status")
local results = shell_document:GetElementById("sandbox-results")
if not mosis or not mosis.crypto then
if status then status.inner_rml = "Crypto API not available" end
return
end
local hash = mosis.crypto.sha256("test")
if hash and #hash > 0 then
if status then status.inner_rml = "SHA256: " .. hash:sub(1, 16) .. "..." end
if results then results.inner_rml = results.inner_rml .. "\nCrypto: PASSED" end
showToast("Crypto test passed!", "success")
else
if status then status.inner_rml = "Crypto test: FAILED" end
showToast("Crypto test failed!", "error")
end
end
function testSandboxStorage()
local status = shell_document:GetElementById("storage-status")
local results = shell_document:GetElementById("sandbox-results")
if not mosis or not mosis.fs then
if status then status.inner_rml = "Storage API not available" end
return
end
local test_content = "Hello from sandbox test!"
local write_ok = mosis.fs.writeFile("test.txt", test_content)
if write_ok then
local read_content = mosis.fs.readFile("test.txt")
if read_content == test_content then
if status then status.inner_rml = "Storage read/write: PASSED" end
if results then results.inner_rml = results.inner_rml .. "\nStorage: PASSED" end
showToast("Storage test passed!", "success")
else
if status then status.inner_rml = "Storage read: FAILED" end
showToast("Storage read failed!", "error")
end
else
if status then status.inner_rml = "Storage write: FAILED" end
showToast("Storage write failed!", "error")
end
end
-- Make shell functions globally available for apps
_G.showToast = showToast
_G.showDialog = showDialog
@@ -540,5 +633,9 @@ _G.shellNavigateTo = shellNavigateTo
_G.shellLaunchApp = shellLaunchApp
_G.launchDiscoveredApp = launchDiscoveredApp
_G.populateHomeApps = populateHomeApps
_G.testSandboxTimer = testSandboxTimer
_G.testSandboxJSON = testSandboxJSON
_G.testSandboxCrypto = testSandboxCrypto
_G.testSandboxStorage = testSandboxStorage
print("[Shell] Shell script loaded")