Paranoia: check we're in the expected menu before each and every button press.
This commit is contained in:
parent
d619796019
commit
52b9621e29
2 changed files with 19 additions and 2 deletions
|
@ -23,13 +23,13 @@ public class BolusCommand implements Command {
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(RuffyScripter scripter) {
|
public CommandResult execute(RuffyScripter scripter) {
|
||||||
try {
|
try {
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
|
|
||||||
enterBolusMenu(scripter);
|
enterBolusMenu(scripter);
|
||||||
inputBolusAmount(scripter);
|
inputBolusAmount(scripter);
|
||||||
SystemClock.sleep(500);
|
SystemClock.sleep(500);
|
||||||
verifyDisplayedBolusAmount(scripter);
|
verifyDisplayedBolusAmount(scripter);
|
||||||
|
|
||||||
// confirm bolus
|
// confirm bolus
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
|
||||||
scripter.pressCheckKey();
|
scripter.pressCheckKey();
|
||||||
|
|
||||||
// the pump displays the entered bolus and waits a bit to let user check and cancel
|
// the pump displays the entered bolus and waits a bit to let user check and cancel
|
||||||
|
@ -63,7 +63,9 @@ public class BolusCommand implements Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enterBolusMenu(RuffyScripter scripter) {
|
private void enterBolusMenu(RuffyScripter scripter) {
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
|
||||||
scripter.navigateToMenu(MenuType.BOLUS_MENU);
|
scripter.navigateToMenu(MenuType.BOLUS_MENU);
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_MENU);
|
||||||
scripter.pressCheckKey();
|
scripter.pressCheckKey();
|
||||||
scripter.waitForMenuUpdate();
|
scripter.waitForMenuUpdate();
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
|
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
|
||||||
|
@ -73,12 +75,14 @@ public class BolusCommand implements Command {
|
||||||
// press 'up' once for each 0.1 U increment
|
// press 'up' once for each 0.1 U increment
|
||||||
long steps = Math.round(bolus * 10);
|
long steps = Math.round(bolus * 10);
|
||||||
for (int i = 0; i < steps; i++) {
|
for (int i = 0; i < steps; i++) {
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
|
||||||
scripter.pressUpKey();
|
scripter.pressUpKey();
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyDisplayedBolusAmount(RuffyScripter scripter) {
|
private void verifyDisplayedBolusAmount(RuffyScripter scripter) {
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER);
|
||||||
double displayedBolus = (double) scripter.currentMenu.getAttribute(MenuAttribute.BOLUS);
|
double displayedBolus = (double) scripter.currentMenu.getAttribute(MenuAttribute.BOLUS);
|
||||||
log.debug("Final bolus: " + displayedBolus);
|
log.debug("Final bolus: " + displayedBolus);
|
||||||
if (Math.abs(displayedBolus - bolus) > 0.05) {
|
if (Math.abs(displayedBolus - bolus) > 0.05) {
|
||||||
|
|
|
@ -47,7 +47,6 @@ public class SetTbrCommand implements Command {
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(RuffyScripter scripter) {
|
public CommandResult execute(RuffyScripter scripter) {
|
||||||
try {
|
try {
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
|
|
||||||
enterTbrMenu(scripter);
|
enterTbrMenu(scripter);
|
||||||
inputTbrPercentage(scripter);
|
inputTbrPercentage(scripter);
|
||||||
SystemClock.sleep(500);
|
SystemClock.sleep(500);
|
||||||
|
@ -57,6 +56,7 @@ public class SetTbrCommand implements Command {
|
||||||
cancelTbrAndConfirmCancellationWarning(scripter);
|
cancelTbrAndConfirmCancellationWarning(scripter);
|
||||||
} else {
|
} else {
|
||||||
// switch to TBR_DURATION menu by pressing menu key
|
// switch to TBR_DURATION menu by pressing menu key
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
|
||||||
scripter.pressMenuKey();
|
scripter.pressMenuKey();
|
||||||
scripter.waitForMenuUpdate();
|
scripter.waitForMenuUpdate();
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
||||||
|
@ -90,13 +90,16 @@ public class SetTbrCommand implements Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enterTbrMenu(RuffyScripter scripter) {
|
private void enterTbrMenu(RuffyScripter scripter) {
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
|
||||||
scripter.navigateToMenu(MenuType.TBR_MENU);
|
scripter.navigateToMenu(MenuType.TBR_MENU);
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_MENU);
|
||||||
scripter.pressCheckKey();
|
scripter.pressCheckKey();
|
||||||
scripter.waitForMenuUpdate();
|
scripter.waitForMenuUpdate();
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void inputTbrPercentage(RuffyScripter scripter) {
|
private void inputTbrPercentage(RuffyScripter scripter) {
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
|
||||||
long currentPercent = readDisplayedTbrPercentage(scripter);
|
long currentPercent = readDisplayedTbrPercentage(scripter);
|
||||||
log.debug("Current TBR %: " + currentPercent);
|
log.debug("Current TBR %: " + currentPercent);
|
||||||
long percentageChange = percentage - currentPercent;
|
long percentageChange = percentage - currentPercent;
|
||||||
|
@ -108,6 +111,7 @@ public class SetTbrCommand implements Command {
|
||||||
}
|
}
|
||||||
log.debug("Pressing " + (increasePercentage ? "up" : "down") + " " + percentageSteps + " times");
|
log.debug("Pressing " + (increasePercentage ? "up" : "down") + " " + percentageSteps + " times");
|
||||||
for (int i = 0; i < percentageSteps; i++) {
|
for (int i = 0; i < percentageSteps; i++) {
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
|
||||||
if (increasePercentage) scripter.pressUpKey();
|
if (increasePercentage) scripter.pressUpKey();
|
||||||
else scripter.pressDownKey();
|
else scripter.pressDownKey();
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
|
@ -142,6 +146,7 @@ public class SetTbrCommand implements Command {
|
||||||
// Pressing up will go to the next higher 15 minute step.
|
// Pressing up will go to the next higher 15 minute step.
|
||||||
// Don't press down, from 0:13 it can't go down, so press up.
|
// Don't press down, from 0:13 it can't go down, so press up.
|
||||||
// Pressing up from 23:59 works to go to 24:00.
|
// Pressing up from 23:59 works to go to 24:00.
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
||||||
scripter.pressUpKey();
|
scripter.pressUpKey();
|
||||||
scripter.waitForMenuUpdate();
|
scripter.waitForMenuUpdate();
|
||||||
currentDuration = readDisplayedTbrDuration(scripter);
|
currentDuration = readDisplayedTbrDuration(scripter);
|
||||||
|
@ -156,6 +161,7 @@ public class SetTbrCommand implements Command {
|
||||||
}
|
}
|
||||||
log.debug("Pressing " + (increaseDuration ? "up" : "down") + " " + durationSteps + " times");
|
log.debug("Pressing " + (increaseDuration ? "up" : "down") + " " + durationSteps + " times");
|
||||||
for (int i = 0; i < durationSteps; i++) {
|
for (int i = 0; i < durationSteps; i++) {
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
||||||
if (increaseDuration) scripter.pressUpKey();
|
if (increaseDuration) scripter.pressUpKey();
|
||||||
else scripter.pressDownKey();
|
else scripter.pressDownKey();
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
|
@ -164,6 +170,7 @@ public class SetTbrCommand implements Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyDisplayedTbrDuration(RuffyScripter scripter) {
|
private void verifyDisplayedTbrDuration(RuffyScripter scripter) {
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
||||||
long displayedDuration = readDisplayedTbrDuration(scripter);
|
long displayedDuration = readDisplayedTbrDuration(scripter);
|
||||||
if (displayedDuration != duration) {
|
if (displayedDuration != duration) {
|
||||||
log.debug("Final displayed TBR duration: " + displayedDuration);
|
log.debug("Final displayed TBR duration: " + displayedDuration);
|
||||||
|
@ -172,6 +179,7 @@ public class SetTbrCommand implements Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
private long readDisplayedTbrDuration(RuffyScripter scripter) {
|
private long readDisplayedTbrDuration(RuffyScripter scripter) {
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_DURATION);
|
||||||
Object durationObj = scripter.currentMenu.getAttribute(MenuAttribute.RUNTIME);
|
Object durationObj = scripter.currentMenu.getAttribute(MenuAttribute.RUNTIME);
|
||||||
// this as a bit hacky, the display value is blinking, so we might catch that, so
|
// this as a bit hacky, the display value is blinking, so we might catch that, so
|
||||||
// keep trying till we get the Double we want
|
// keep trying till we get the Double we want
|
||||||
|
@ -185,6 +193,7 @@ public class SetTbrCommand implements Command {
|
||||||
|
|
||||||
private void cancelTbrAndConfirmCancellationWarning(RuffyScripter scripter) {
|
private void cancelTbrAndConfirmCancellationWarning(RuffyScripter scripter) {
|
||||||
// confirm entered TBR
|
// confirm entered TBR
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.TBR_SET);
|
||||||
scripter.pressCheckKey();
|
scripter.pressCheckKey();
|
||||||
|
|
||||||
// we could read remaining duration from MAIN_MENU, but but the time we're here,
|
// we could read remaining duration from MAIN_MENU, but but the time we're here,
|
||||||
|
@ -205,8 +214,10 @@ public class SetTbrCommand implements Command {
|
||||||
+ errorMsg + ". Please check the pump.");
|
+ errorMsg + ". Please check the pump.");
|
||||||
}
|
}
|
||||||
// confirm "TBR CANCELLED alert"
|
// confirm "TBR CANCELLED alert"
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.WARNING_OR_ERROR);
|
||||||
scripter.pressCheckKey();
|
scripter.pressCheckKey();
|
||||||
// dismiss "TBR CANCELLED alert"
|
// dismiss "TBR CANCELLED alert"
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.WARNING_OR_ERROR);
|
||||||
scripter.pressCheckKey();
|
scripter.pressCheckKey();
|
||||||
scripter.waitForMenuToBeLeft(MenuType.WARNING_OR_ERROR);
|
scripter.waitForMenuToBeLeft(MenuType.WARNING_OR_ERROR);
|
||||||
alertProcessed = true;
|
alertProcessed = true;
|
||||||
|
@ -216,6 +227,7 @@ public class SetTbrCommand implements Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyMainMenuShowsNoActiveTbr(RuffyScripter scripter) {
|
private void verifyMainMenuShowsNoActiveTbr(RuffyScripter scripter) {
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
|
||||||
Double tbrPercentage = (Double) scripter.currentMenu.getAttribute(MenuAttribute.TBR);
|
Double tbrPercentage = (Double) scripter.currentMenu.getAttribute(MenuAttribute.TBR);
|
||||||
boolean runtimeDisplayed = scripter.currentMenu.attributes().contains(MenuAttribute.RUNTIME);
|
boolean runtimeDisplayed = scripter.currentMenu.attributes().contains(MenuAttribute.RUNTIME);
|
||||||
if (tbrPercentage != 100 || runtimeDisplayed) {
|
if (tbrPercentage != 100 || runtimeDisplayed) {
|
||||||
|
@ -224,6 +236,7 @@ public class SetTbrCommand implements Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyMainMenuShowsExpectedTbrActive(RuffyScripter scripter) {
|
private void verifyMainMenuShowsExpectedTbrActive(RuffyScripter scripter) {
|
||||||
|
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
|
||||||
// new TBR set; percentage and duration must be displayed ...
|
// new TBR set; percentage and duration must be displayed ...
|
||||||
if (!scripter.currentMenu.attributes().contains(MenuAttribute.TBR) ||
|
if (!scripter.currentMenu.attributes().contains(MenuAttribute.TBR) ||
|
||||||
!scripter.currentMenu.attributes().contains(MenuAttribute.TBR)) {
|
!scripter.currentMenu.attributes().contains(MenuAttribute.TBR)) {
|
||||||
|
|
Loading…
Reference in a new issue