From ebe14fb0cfb52f57db3b27f0dec4fbf114b7f60e Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Tue, 18 Jul 2017 01:51:52 +0200 Subject: [PATCH] BolusCommand: deal with blinking values. How did this not trigger with all the boluses I've issued so far? --- .../jotomo/ruffyscripter/commands/BolusCommand.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java index f97573bfdf..255f5cda71 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java @@ -110,14 +110,23 @@ public class BolusCommand implements Command { } private void verifyDisplayedBolusAmount(RuffyScripter scripter) { - scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER); - double displayedBolus = (double) scripter.currentMenu.getAttribute(MenuAttribute.BOLUS); + double displayedBolus = readDisplayedBolusAmount(scripter); log.debug("Final bolus: " + displayedBolus); if (Math.abs(displayedBolus - bolus) > 0.05) { throw new CommandException().message("Failed to set correct bolus. Expected: " + bolus + ", actual: " + displayedBolus); } } + private double readDisplayedBolusAmount(RuffyScripter scripter) { + scripter.verifyMenuIsDisplayed(MenuType.BOLUS_ENTER); + Object amountObj = scripter.currentMenu.getAttribute(MenuAttribute.BOLUS); + while (!(amountObj instanceof Double)) { + scripter.waitForMenuUpdate(); + amountObj = scripter.currentMenu.getAttribute(MenuAttribute.BOLUS); + } + return (double) amountObj; + } + @Override public String toString() { return "BolusCommand{" +