RuffyScripter.verifyMenuIsDisplayed: wait a bit longer if needed.
Sometimes the pump seems to take a bit longer.
This commit is contained in:
parent
76578872d1
commit
d35d93ed44
1 changed files with 24 additions and 17 deletions
|
@ -209,12 +209,14 @@ public class RuffyScripter {
|
||||||
pressKey(Key.MENU);
|
pressKey(Key.MENU);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Wait until the menu update is in */
|
/**
|
||||||
|
* Wait until the menu update is in
|
||||||
|
*/
|
||||||
public void waitForMenuUpdate() {
|
public void waitForMenuUpdate() {
|
||||||
long timeoutExpired = System.currentTimeMillis() + 90 * 1000;
|
long timeoutExpired = System.currentTimeMillis() + 90 * 1000;
|
||||||
long initialUpdateTime = menuLastUpdated;
|
long initialUpdateTime = menuLastUpdated;
|
||||||
while (initialUpdateTime == menuLastUpdated) {
|
while (initialUpdateTime == menuLastUpdated) {
|
||||||
if(System.currentTimeMillis() > timeoutExpired) {
|
if (System.currentTimeMillis() > timeoutExpired) {
|
||||||
throw new CommandException().message("Timeout waiting for menu update");
|
throw new CommandException().message("Timeout waiting for menu update");
|
||||||
}
|
}
|
||||||
SystemClock.sleep(50);
|
SystemClock.sleep(50);
|
||||||
|
@ -232,7 +234,6 @@ public class RuffyScripter {
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
ruffyService.rtSendKey(Key.NO_KEY, true);
|
ruffyService.rtSendKey(Key.NO_KEY, true);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
private void pressKey(final byte key) {
|
private void pressKey(final byte key) {
|
||||||
try {
|
try {
|
||||||
ruffyService.rtSendKey(key, true);
|
ruffyService.rtSendKey(key, true);
|
||||||
|
@ -269,16 +270,22 @@ public class RuffyScripter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void verifyMenuIsDisplayed(MenuType menu) {
|
public void verifyMenuIsDisplayed(MenuType expectedMenu) {
|
||||||
String message = "Invalid pump state, expected to be in menu "
|
String failureMessage = "Invalid pump state, expected to be in menu "
|
||||||
+ menu + ", but current menu is " + currentMenu.getType();
|
+ expectedMenu + ", but current menu is " + currentMenu.getType();
|
||||||
verifyMenuIsDisplayed(menu, message);
|
verifyMenuIsDisplayed(expectedMenu, failureMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void verifyMenuIsDisplayed(MenuType menu, String message) {
|
public void verifyMenuIsDisplayed(MenuType expectedMenu, String failureMessage) {
|
||||||
waitForMenuUpdate();
|
waitForMenuUpdate();
|
||||||
if (currentMenu.getType() != menu) {
|
int retries = 5;
|
||||||
throw new CommandException().message(message);
|
while (currentMenu.getType() != expectedMenu) {
|
||||||
|
if (retries > 0) {
|
||||||
|
SystemClock.sleep(200);
|
||||||
|
retries = retries - 1;
|
||||||
|
} else {
|
||||||
|
throw new CommandException().message(failureMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue