diff --git a/apps/android/test.json b/apps/android/test.json index 1a1436ccd..429fd70fe 100644 --- a/apps/android/test.json +++ b/apps/android/test.json @@ -92,7 +92,7 @@ {"t":"assertCall", "id": "gpspower", "argAsserts": [ { "t": "assert", "arg": "0", "is": "equal", "to": 0 } ], "text": "internal GPS switched off"}, {"t":"resetCall", "id": "gpspower"}, - {"t":"advanceTime", "ms":"12000", "text": "wait for fallback"}, + {"t":"advanceTimers", "ms":"12000", "text": "wait for fallback"}, {"t":"assertCall", "id": "gpspower", "argAsserts": [ { "t": "assert", "arg": "0", "is": "equal", "to": 1 } ], "text": "internal GPS switched on caused by missing GB event"} ] }] diff --git a/bin/runapptests.js b/bin/runapptests.js index 6ac290fc2..dcbf13c58 100755 --- a/bin/runapptests.js +++ b/bin/runapptests.js @@ -61,11 +61,11 @@ const DEMOTEST = { {"t":"assertCall", "id": "testfunc", "count": 0 , "text": "Asserts if a wrapped function has been called the expected number of times"} ] }, { - "description": "Emulator time can advanced by a given amount. This currently works for timeouts,intervals and Date.now() calls", + "description": "Emulator timers and intervals can advanced by a given time", "steps": [ {"t":"cmd", "js":"setTimeout(()=>{global.waited = true},60000)", "text": "Set a timeout for 60 seconds"}, {"t":"assert", "js":"global.waited", "is": "falsy", "text": "Timeout has not yet fired"}, - {"t":"advanceTime", "ms":60000}, + {"t":"advanceTimers", "ms":60000, "text": "Advance timers by 60000 ms to get the timer to fire in the next idle period"}, {"t":"assert", "js":"global.waited", "is": "true", "text": "Timeout has fired"} ] }] @@ -323,18 +323,10 @@ function runStep(step, subtest, test, state){ } }); break; - case "advanceTime" : + case "advanceTimers" : p = p.then(()=>{ - console.log("> ADVANCE TIME BY", step.ms + "ms"); - if (!subtest.wrappedDateNow){ - emu.tx(`Date.now = (o)=>{return ()=>{ - return o() + global.APPTESTS.timeOffset; - };}(Date.now); - global.APPTESTS.timeOffset = 0;\n`); - subtest.wrappedDateNow = true; - } - emu.tx(`global.APPTESTS.timeOffset += ${step.ms}; - for(let c of global["\xff"].timers){ + console.log("> ADVANCE TIMERS BY", step.ms + "ms"); + emu.tx(`for(let c of global["\xff"].timers){ if(c) c.time -= ${step.ms * 1000}; }\n`); });