Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements more asserts and reading testcases from json files #3399

Merged
merged 33 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d29876c
runapptests - Initial implementation for additional asserts and runni…
halemmerich Apr 20, 2024
c66199c
runapptests - Allow running setup steps
halemmerich May 3, 2024
8b354ed
runapptests - Print results table
halemmerich May 3, 2024
a7f17f0
android - Initial tests for GPS overwriting
halemmerich May 3, 2024
98479df
antonclk - Test for memory leaks
halemmerich May 3, 2024
97b5bf5
android - Remove duplicated tests file
halemmerich May 3, 2024
5574a0e
runapptests - Wrap every step in a promise to allow waiting
halemmerich May 4, 2024
412a14c
runapptests - Allow uploading files
halemmerich May 4, 2024
e8dc8b9
runapptests - Set defaults for sending a GB event
halemmerich May 4, 2024
a84b6d1
runapptests - Implement generic event emitter command
halemmerich May 4, 2024
7289d3f
runapptests - Fix promise use for step running
halemmerich May 4, 2024
9b01f82
runapptests - Better logging of emit
halemmerich May 4, 2024
8420709
runapptests - Reset apploaders device installed apps list for each test
halemmerich May 4, 2024
9f340dd
runapptests - Better result handling and logging
halemmerich May 4, 2024
24a40c8
messagesoverlay - Adds initial tests
halemmerich May 4, 2024
b7babc4
android - Remove a bit of noise during the testrun (erros because of …
halemmerich May 4, 2024
8c74a23
messagesoverlay - Remove not needed test steps regarding widgets
halemmerich May 4, 2024
00f66f3
runapptests - Add option for filtering tests by app id
halemmerich May 5, 2024
5c5c898
runapptests - Return number of failed tests as exit code
halemmerich May 5, 2024
56f7dd1
anton - Add description to test
halemmerich May 5, 2024
4f258f8
runapptests - Unify log messages
halemmerich May 7, 2024
305694a
runapptests - Add verbose option
halemmerich May 7, 2024
162aa57
runapptests - Allow directly loading from upload step
halemmerich May 7, 2024
7d4489e
runapptests - Adds a step type for starting an interactive console
halemmerich May 7, 2024
42cd2bf
runapptests - Refine assertValue
halemmerich May 7, 2024
acd910a
runapptests - Add example test as documentation
halemmerich May 7, 2024
52c17df
runapptests - Fix demo app tests
halemmerich May 7, 2024
a597489
runapptests - Fix call assertions
halemmerich May 7, 2024
c51ffbe
runapptests - Allow filterung for demo app
halemmerich May 7, 2024
d8b28e5
runapptests - Fix things not working after a wrap command
halemmerich May 9, 2024
1b4af29
runapptests - Fix missing newline for loading after uploading
halemmerich May 9, 2024
816313e
runapptests - Tweak some of the logging
halemmerich May 9, 2024
b1e7c1b
Update bin/runapptests.js
gfwilliams May 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions apps/android/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"app" : "android",
"setup" : [{
"id": "default",
"steps" : [
{"t":"cmd", "js": "Bangle.setGPSPower=(isOn, appID)=>{if (!appID) appID='?';if (!Bangle._PWR) Bangle._PWR={};if (!Bangle._PWR.GPS) Bangle._PWR.GPS=[];if (isOn && !Bangle._PWR.GPS.includes(appID)) Bangle._PWR.GPS.push(appID);if (!isOn && Bangle._PWR.GPS.includes(appID)) Bangle._PWR.GPS.splice(Bangle._PWR.GPS.indexOf(appID),1);return Bangle._PWR.GPS.length>0;};", "text": "Fake the setGPSPower"},
{"t":"wrap", "fn": "Bangle.setGPSPower", "id": "gpspower"},
{"t":"cmd", "js": "NRF.getSecurityStatus = () => { return { connected: false };}", "text": "Control the security status"},
{"t":"cmd", "js": "Serial1.println = () => { }", "text": "Fake the serial port println"},
{"t":"cmd", "js": "Bluetooth.println = () => { }", "text": "Fake the Bluetooth println"},
{"t":"cmd", "js": "Bangle._PWR={}", "text": "Prepare an empty _PWR for following asserts"},
{"t":"cmd", "js": "require('Storage').writeJSON('android.settings.json', {overwriteGps: true})", "text": "Enable GPS overwrite"},
{"t":"cmd", "js": "eval(require('Storage').read('android.boot.js'))", "text": "Load the boot code"}
]
}],
"tests" : [{
"description": "Check setGPSPower is replaced",
"steps" : [
{"t":"cmd", "js": "Serial1.println = () => { }", "text": "Fake the serial port"},
{"t":"cmd", "js": "Bluetooth.println = () => { }", "text": "Fake the Bluetooth println"},
{"t":"cmd", "js": "require('Storage').writeJSON('android.settings.json', {overwriteGps: true})", "text": "Enable GPS overwrite"},
{"t":"cmd", "js": "eval(require('Storage').read('android.boot.js'))", "text": "Load the boot code"},
{"t":"assert", "js": "Bangle.setGPSPower.toString().includes('native')", "is":"false", "text": "setGPSPower has been replaced"}
]
},{
"description": "Test switching hardware GPS on and off",
"steps" : [
{"t":"setup", "id": "default"},
{"t":"assertArray", "js": "Bangle._PWR.GPS", "is":"undefinedOrEmpty", "text": "No GPS clients"},
{"t":"assert", "js": "Bangle.isGPSOn()", "is":"falsy", "text": "isGPSOn shows GPS as off"},
{"t":"assert", "js": "Bangle.setGPSPower(1, 'test')", "is":"truthy", "text": "setGPSPower returns truthy when switching on"},
{"t":"assertArray", "js": "Bangle._PWR.GPS", "is":"notEmpty", "text": "GPS clients"},
{"t":"assert", "js": "Bangle.isGPSOn()", "is":"truthy", "text": "isGPSOn shows GPS as on"},
{"t":"assertCall", "id": "gpspower", "count": 1, "argAsserts": [ { "t": "assert", "arg": "0", "is": "equal", "to": 1 } ] , "text": "internal GPS switched on"},
{"t":"assert", "js": "Bangle.setGPSPower(0, 'test')", "is":"falsy", "text": "setGPSPower returns falsy when switching off"},
{"t":"assertArray", "js": "Bangle._PWR.GPS", "is":"undefinedOrEmpty", "text": "No GPS clients"},
{"t":"assert", "js": "Bangle.isGPSOn()", "is":"falsy", "text": "isGPSOn shows GPS as off"},
{"t":"assertCall", "id": "gpspower", "count": 2, "argAsserts": [ { "t": "assert", "arg": "0", "is": "equal", "to": 0 } ] , "text": "internal GPS switched off"}
]
}]
}
15 changes: 15 additions & 0 deletions apps/antonclk/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"app" : "antonclk",
"tests" : [{
"description": "Check memory usage after setUI",
"steps" : [
{"t":"cmd", "js": "Bangle.loadWidgets()"},
{"t":"cmd", "js": "eval(require('Storage').read('antonclk.app.js'))"},
{"t":"cmd", "js": "Bangle.setUI()"},
{"t":"saveMemoryUsage"},
{"t":"cmd", "js": "eval(require('Storage').read('antonclk.app.js'))"},
{"t":"cmd", "js":"Bangle.setUI()"},
{"t":"checkMemoryUsage"}
]
}]
}
32 changes: 32 additions & 0 deletions apps/messagesoverlay/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"app" : "messagesoverlay",
"tests" : [{
"description": "Test handler backgrounding",
"steps" : [
{"t":"upload", "file": "modules/widget_utils.js", "as": "widget_utils"},
{"t":"cmd", "js": "Bangle.loadWidgets()", "text": "Load widgets"},
{"t":"assertArray", "js": "Bangle['#onswipe']", "is":"undefinedOrEmpty", "text": "No swipe handlers"},
{"t":"cmd", "js": "require('widget_utils').swipeOn(0)", "text": "Store widgets in overlay"},
{"t":"assert", "js": "Bangle['#onswipe']", "is":"function", "text": "One swipe handler for widgets"},
{"t":"emit", "event":"swipe", "paramsArray": [ 0, 1 ], "text": "Show widgets"},
{"t":"assert", "js": "Bangle['#onswipe']", "is":"function", "text": "One swipe handler for widgets"},
{"t":"cmd", "js": "require('messagesoverlay').message('text', {src:'Messenger',t:'add',type:'text',id:Date.now().toFixed(0),title:'title',body:'body'})", "text": "Show a message overlay"},
{"t":"assertArray", "js": "Bangle['#onswipe']", "is":"undefinedOrEmpty", "text": "No swipe handlers while message overlay is on screen"},
{"t":"emit", "event":"touch", "paramsArray": [ 1, { "x": 10, "y": 10, "type": 0 } ], "text": "Close message"},
{"t":"assert", "js": "Bangle['#onswipe']", "is":"function", "text": "One swipe handler restored"}
]
},{
"description": "Test handler backgrounding with fastloading (setUI)",
"steps" : [
{"t":"cmd", "js": "Bangle.on('swipe',print)", "text": "Create listener for swipes"},
{"t":"cmd", "js": "Bangle.setUI({mode: 'clock',remove: ()=>{}})", "text": "Init UI for clock"},
{"t":"cmd", "js": "require('messagesoverlay').message('text', {src:'Messenger',t:'add',type:'text',id:Date.now().toFixed(0),title:'title',body:'body'})", "text": "Show a message overlay"},
{"t":"assertArray", "js": "Bangle['#onswipe']", "is":"undefinedOrEmpty", "text": "No swipe handlers while message overlay is on screen"},
{"t":"cmd", "js": "Bangle.setUI()", "text": "Trigger removal of UI"},
{"t":"assertArray", "js": "Bangle['#onswipe']", "is":"undefinedOrEmpty", "text": "Still no swipe handlers"},
{"t":"cmd", "js": "Bangle.on('touch', print)"},
{"t":"emit", "event":"touch", "paramsArray": [ 1, { "x": 10, "y": 10, "type": 0 } ], "text": "Close message"},
{"t":"assert", "js": "Bangle['#onswipe']", "is":"function", "text": "One swipe handler restored"}
]
}]
}
Loading
Loading