diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.java index b1520407c9..d942e6c78f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.java @@ -83,8 +83,8 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface { } value.set(false, resourceHelper.gs(R.string.closed_loop_disabled_on_dev_branch), this); } - - if (TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress()) { + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); + if (pump != null && !pump.isFakingTempsByExtendedBoluses() && TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress()) { value.set(false, MainApp.gs(R.string.closed_loop_disabled_with_eb), this); } return value; diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java index 75da631c5f..82d7035f9c 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java @@ -30,6 +30,8 @@ import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin; import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin; import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin; import info.nightscout.androidaps.plugins.source.GlimpPlugin; +import info.nightscout.androidaps.plugins.treatments.TreatmentService; +import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.SP; @@ -39,7 +41,7 @@ import static org.mockito.Mockito.when; * Created by mike on 18.03.2018. */ @RunWith(PowerMockRunner.class) -@PrepareForTest({MainApp.class, ConfigBuilderPlugin.class, FabricPrivacy.class, SP.class, Context.class, OpenAPSMAPlugin.class, OpenAPSAMAPlugin.class, OpenAPSSMBPlugin.class}) +@PrepareForTest({MainApp.class, ConfigBuilderPlugin.class, FabricPrivacy.class, SP.class, Context.class, OpenAPSMAPlugin.class, OpenAPSAMAPlugin.class, OpenAPSSMBPlugin.class, TreatmentsPlugin.class, TreatmentService.class}) public class ConstraintsCheckerTest { VirtualPumpPlugin pump = new VirtualPumpPlugin(); @@ -278,6 +280,8 @@ public class ConstraintsCheckerTest { AAPSMocker.mockStrings(); AAPSMocker.mockSP(); AAPSMocker.mockCommandQueue(); + AAPSMocker.mockTreatmentService(); + AAPSMocker.mockTreatmentPlugin(); when(mainApp.getPackageName()).thenReturn("info.nightscout.androidaps"); diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPluginTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPluginTest.java index e18a3bc758..b6bfda8cb1 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPluginTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPluginTest.java @@ -21,6 +21,8 @@ import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin; import info.nightscout.androidaps.plugins.source.GlimpPlugin; +import info.nightscout.androidaps.plugins.treatments.TreatmentService; +import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.utils.SP; import static org.mockito.Mockito.when; @@ -30,7 +32,7 @@ import static org.mockito.Mockito.when; */ @RunWith(PowerMockRunner.class) -@PrepareForTest({MainApp.class, ConfigBuilderPlugin.class, SP.class, Context.class}) +@PrepareForTest({MainApp.class, ConfigBuilderPlugin.class, SP.class, Context.class, TreatmentsPlugin.class, TreatmentService.class}) public class SafetyPluginTest { private VirtualPumpPlugin pump = new VirtualPumpPlugin(); @@ -230,6 +232,8 @@ public class SafetyPluginTest { AAPSMocker.mockConstraintsChecker(); AAPSMocker.mockSP(); AAPSMocker.mockStrings(); + AAPSMocker.mockTreatmentService(); + AAPSMocker.mockTreatmentPlugin(); when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump); diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.java index a243464cb1..1a6c87b232 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.java @@ -652,7 +652,7 @@ public class SmsCommunicatorPluginTest { passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode(); smsCommunicatorPlugin.processSms(new Sms("1234", passCode)); Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText()); - Assert.assertEquals("Extended bolus 1.00U for 20 min started successfully\nVirtual Pump", smsCommunicatorPlugin.getMessages().get(3).getText()); + Assert.assertEquals("Extended bolus 1.00U for 20 min started successfully\nnull\nVirtual Pump", smsCommunicatorPlugin.getMessages().get(3).getText()); } @Test