Merge pull request #1043 from jotomo/issue-646

[Bugfix] On bolus cancel request, cancel all boluses. Partially addresses #646.
This commit is contained in:
Milos Kozak 2018-05-15 10:55:04 +02:00 committed by GitHub
commit e58149379a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 1 deletions

View file

@ -112,7 +112,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
stopPressed = true;
stopPressedView.setVisibility(View.VISIBLE);
stopButton.setVisibility(View.INVISIBLE);
ConfigBuilderPlugin.getActivePump().stopBolusDelivering();
ConfigBuilderPlugin.getCommandQueue().cancelAllBoluses();
break;
}
}

View file

@ -213,6 +213,12 @@ public class CommandQueue {
return true;
}
public synchronized void cancelAllBoluses() {
removeAll(Command.CommandType.BOLUS);
removeAll(Command.CommandType.SMB_BOLUS);
ConfigBuilderPlugin.getActivePump().stopBolusDelivering();
}
// returns true if command is queued
public boolean tempBasalAbsolute(double absoluteRate, int durationInMinutes, boolean enforceNew, Profile profile, Callback callback) {
if (!enforceNew && isRunning(Command.CommandType.TEMPBASAL)) {

View file

@ -156,4 +156,24 @@ public class CommandQueueTest extends CommandQueue {
public boolean isThisProfileSet(Profile profile) {
return false;
}
@Test
public void callingCancelAllBolusesClearsQueue() throws Exception {
prepareMock(0d, 0);
// add normal and SMB-bolus to queue
Assert.assertEquals(0, size());
bolus(new DetailedBolusInfo(), null);
DetailedBolusInfo smb = new DetailedBolusInfo();
smb.isSMB = true;
bolus(smb, null);
Assert.assertEquals(2, size());
// cancelling all boluses clear all boluses from the queue
cancelAllBoluses();
Assert.assertEquals(0, size());
}
}