android - Simplify test step running

master
Martin Boonk 2023-01-28 10:03:06 +01:00
parent e2f57cfb20
commit 9b8ecf8f8c
1 changed files with 40 additions and 26 deletions

View File

@ -29,7 +29,9 @@ let sec = {
NRF.getSecurityStatus = () => sec; NRF.getSecurityStatus = () => sec;
setTimeout(() => { let teststeps = [];
teststeps.push(()=>{
// add an empty starting point to make the asserts work // add an empty starting point to make the asserts work
Bangle._PWR={}; Bangle._PWR={};
@ -90,9 +92,9 @@ setTimeout(() => {
NRF.emit("disconnect", {}); NRF.emit("disconnect", {});
print("disconnect"); print("disconnect");
sec.connected = false; sec.connected = false;
});
setTimeout(() => { teststeps.push(()=>{
assertNotEmpty(Bangle._PWR.GPS, "GPS"); assertNotEmpty(Bangle._PWR.GPS, "GPS");
assertTrue(Bangle.isGPSOn(), "isGPSOn"); assertTrue(Bangle.isGPSOn(), "isGPSOn");
assertTrue(internalOn(), "Internal GPS on"); assertTrue(internalOn(), "Internal GPS on");
@ -100,8 +102,9 @@ setTimeout(() => {
print("connect"); print("connect");
sec.connected = true; sec.connected = true;
NRF.emit("connect", {}); NRF.emit("connect", {});
});
setTimeout(() => { teststeps.push(()=>{
assertNotEmpty(Bangle._PWR.GPS, "GPS"); assertNotEmpty(Bangle._PWR.GPS, "GPS");
assertTrue(Bangle.isGPSOn(), "isGPSOn"); assertTrue(Bangle.isGPSOn(), "isGPSOn");
assertFalse(internalOn(), "Internal GPS off"); assertFalse(internalOn(), "Internal GPS off");
@ -111,8 +114,9 @@ setTimeout(() => {
assertUndefinedOrEmpty(Bangle._PWR.GPS, "No GPS"); assertUndefinedOrEmpty(Bangle._PWR.GPS, "No GPS");
assertFalse(Bangle.isGPSOn(), "isGPSOn"); assertFalse(Bangle.isGPSOn(), "isGPSOn");
assertFalse(internalOn(), "Internal GPS off"); assertFalse(internalOn(), "Internal GPS off");
});
setTimeout(() => { setTimeout(()=>{
print("Test disconnect without gps on"); print("Test disconnect without gps on");
assertUndefinedOrEmpty(Bangle._PWR.GPS, "No GPS"); assertUndefinedOrEmpty(Bangle._PWR.GPS, "No GPS");
@ -120,7 +124,17 @@ setTimeout(() => {
assertFalse(internalOn(), "Internal GPS off"); assertFalse(internalOn(), "Internal GPS off");
print("Result Overall is " + (result ? "OK" : "FAIL")); print("Result Overall is " + (result ? "OK" : "FAIL"));
}, 0); });
}, 0);
}, 0); let wrap = (functions) => {
if (functions.length > 0) {
setTimeout(()=>{
functions.shift()();
wrap(functions);
},0);
}
};
setTimeout(()=>{
wrap(teststeps);
}, 5000); }, 5000);