Merge remote-tracking branch 'origin/dev' into watchfaces

This commit is contained in:
Andrew Warrington 2018-01-11 19:42:50 +01:00
commit 3495ef129a
24 changed files with 280 additions and 42 deletions

View file

@ -15,4 +15,7 @@ android:
script: script:
# Unit Test # Unit Test
- ./gradlew test - ./gradlew test jacocoTestReport
after_success:
- bash <(curl -s https://codecov.io/bash)

View file

@ -5,3 +5,5 @@
[![Gitter](https://badges.gitter.im/MilosKozak/AndroidAPS.svg)](https://gitter.im/MilosKozak/AndroidAPS?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Gitter](https://badges.gitter.im/MilosKozak/AndroidAPS.svg)](https://gitter.im/MilosKozak/AndroidAPS?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build status](https://travis-ci.org/MilosKozak/AndroidAPS.svg?branch=master)](https://travis-ci.org/MilosKozak/AndroidAPS) [![Build status](https://travis-ci.org/MilosKozak/AndroidAPS.svg?branch=master)](https://travis-ci.org/MilosKozak/AndroidAPS)
[![codecov](https://codecov.io/gh/MilosKozak/AndroidAPS/branch/master/graph/badge.svg)](https://codecov.io/gh/MilosKozak/AndroidAPS)
dev: [![codecov](https://codecov.io/gh/MilosKozak/AndroidAPS/branch/dev/graph/badge.svg)](https://codecov.io/gh/MilosKozak/AndroidAPS)

View file

@ -1,14 +1,17 @@
buildscript { buildscript {
repositories { repositories {
maven { url 'https://maven.fabric.io/public' } maven { url 'https://maven.fabric.io/public' }
jcenter()
} }
dependencies { dependencies {
classpath 'io.fabric.tools:gradle:1.+' classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.2'
} }
} }
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'io.fabric' apply plugin: 'io.fabric'
apply plugin: 'jacoco-android'
repositories { repositories {
maven { url 'https://maven.fabric.io/public' } maven { url 'https://maven.fabric.io/public' }
@ -55,12 +58,16 @@ android {
} }
lintOptions { lintOptions {
disable 'MissingTranslation' disable 'MissingTranslation'
disable 'ExtraTranslation'
} }
buildTypes { buildTypes {
release { release {
minifyEnabled false minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
debug {
testCoverageEnabled true
}
} }
productFlavors { productFlavors {
flavorDimensions "standard" flavorDimensions "standard"
@ -174,6 +181,10 @@ dependencies {
compile 'junit:junit:4.12' compile 'junit:junit:4.12'
testCompile 'org.json:json:20140107' testCompile 'org.json:json:20140107'
testCompile 'org.mockito:mockito-core:2.7.22' testCompile 'org.mockito:mockito-core:2.7.22'
testCompile 'org.powermock:powermock-api-mockito2:1.7.3'
testCompile 'org.powermock:powermock-module-junit4-rule-agent:1.7.3'
testCompile 'org.powermock:powermock-module-junit4-rule:1.7.3'
testCompile 'org.powermock:powermock-module-junit4:1.7.3'
androidTestCompile 'org.mockito:mockito-core:2.7.22' androidTestCompile 'org.mockito:mockito-core:2.7.22'
androidTestCompile 'com.google.dexmaker:dexmaker:1.2' androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2' androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'

View file

@ -174,10 +174,6 @@ public class Profile {
} }
double value = o.getDouble("value") * multiplier; double value = o.getDouble("value") * multiplier;
sparse.put(tas, value); sparse.put(tas, value);
if (tas % 3600 != 0) {
Notification notification = new Notification(Notification.BASAL_PROFILE_NOT_ALIGNED_TO_HOURS, MainApp.sResources.getString(R.string.basalprofilenotaligned), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
}
if (value == 0) { if (value == 0) {
Notification notification = new Notification(Notification.ZERO_VALUE_IN_PROFILE, MainApp.sResources.getString(R.string.zerovalueinprofile), Notification.URGENT); Notification notification = new Notification(Notification.ZERO_VALUE_IN_PROFILE, MainApp.sResources.getString(R.string.zerovalueinprofile), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
@ -345,6 +341,14 @@ public class Profile {
public Double getBasal(Integer timeAsSeconds) { public Double getBasal(Integer timeAsSeconds) {
if (basal_v == null) { if (basal_v == null) {
basal_v = convertToSparseArray(basal); basal_v = convertToSparseArray(basal);
for (int index = 0; index < basal_v.size(); index++) {
long secondsFromMidnight = basal_v.keyAt(index);
if (secondsFromMidnight % 3600 != 0) {
Notification notification = new Notification(Notification.BASAL_PROFILE_NOT_ALIGNED_TO_HOURS, MainApp.sResources.getString(R.string.basalprofilenotaligned), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
}
}
// Check for minimal basal value // Check for minimal basal value
PumpInterface pump = ConfigBuilderPlugin.getActivePump(); PumpInterface pump = ConfigBuilderPlugin.getActivePump();
if (pump != null) { if (pump != null) {

View file

@ -30,7 +30,9 @@ import java.util.concurrent.TimeUnit;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.events.EventCareportalEventChange; import info.nightscout.androidaps.events.EventCareportalEventChange;
import info.nightscout.androidaps.events.EventExtendedBolusChange; import info.nightscout.androidaps.events.EventExtendedBolusChange;
import info.nightscout.androidaps.events.EventFoodDatabaseChanged; import info.nightscout.androidaps.events.EventFoodDatabaseChanged;
@ -43,7 +45,10 @@ import info.nightscout.androidaps.events.EventReloadTreatmentData;
import info.nightscout.androidaps.events.EventTempBasalChange; import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.events.EventTempTargetChange; import info.nightscout.androidaps.events.EventTempTargetChange;
import info.nightscout.androidaps.events.EventTreatmentChange; import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync; import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin; import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.utils.PercentageSplitter; import info.nightscout.utils.PercentageSplitter;
@ -1674,6 +1679,19 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
profileSwitch.percentage = trJson.getInt("percentage"); profileSwitch.percentage = trJson.getInt("percentage");
if (trJson.has("profileJson")) if (trJson.has("profileJson"))
profileSwitch.profileJson = trJson.getString("profileJson"); profileSwitch.profileJson = trJson.getString("profileJson");
else {
ProfileStore store = ConfigBuilderPlugin.getActiveProfileInterface().getProfile();
Profile profile = store.getSpecificProfile(profileSwitch.profileName);
if (profile != null) {
profileSwitch.profileJson = profile.getData().toString();
log.debug("Profile switch prefilled with JSON from local store");
} else {
Notification notification = new Notification(Notification.NO_LOCALE_PROFILE_FOUND, MainApp.sResources.getString(R.string.nolocaleprofilefound), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
log.debug("JSON for profile switch doesn't exist. Ignoring ...");
return;
}
}
if (trJson.has("profilePlugin")) if (trJson.has("profilePlugin"))
profileSwitch.profilePlugin = trJson.getString("profilePlugin"); profileSwitch.profilePlugin = trJson.getString("profilePlugin");
createOrUpdate(profileSwitch); createOrUpdate(profileSwitch);

View file

@ -101,7 +101,8 @@ public class FillDialog extends DialogFragment implements OnClickListener {
divider.setVisibility(View.GONE); divider.setVisibility(View.GONE);
} }
setCancelable(false); setCancelable(true);
getDialog().setCanceledOnTouchOutside(false);
return view; return view;
} }

View file

@ -55,7 +55,8 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
view.findViewById(R.id.ok).setOnClickListener(this); view.findViewById(R.id.ok).setOnClickListener(this);
view.findViewById(R.id.cancel).setOnClickListener(this); view.findViewById(R.id.cancel).setOnClickListener(this);
setCancelable(false); setCancelable(true);
getDialog().setCanceledOnTouchOutside(false);
return view; return view;
} }

View file

@ -103,7 +103,8 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
view.findViewById(R.id.cancel).setOnClickListener(this); view.findViewById(R.id.cancel).setOnClickListener(this);
basalTypeRadioGroup.setOnCheckedChangeListener(this); basalTypeRadioGroup.setOnCheckedChangeListener(this);
setCancelable(false); setCancelable(true);
getDialog().setCanceledOnTouchOutside(false);
return view; return view;
} }

View file

@ -360,7 +360,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_reuse_layout), options.profile && ps != null && ps.isCPP); showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_reuse_layout), options.profile && ps != null && ps.isCPP);
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_temptarget_layout), options.tempTarget); showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_temptarget_layout), options.tempTarget);
setCancelable(false); setCancelable(true);
getDialog().setCanceledOnTouchOutside(false);
return view; return view;
} }

View file

@ -14,6 +14,7 @@ import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.interfaces.APSInterface; import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.ConstraintsInterface; import info.nightscout.androidaps.interfaces.ConstraintsInterface;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
@ -160,19 +161,21 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
boolean isVirtualPump = VirtualPumpPlugin.getPlugin().isEnabled(PluginBase.PUMP); boolean isVirtualPump = VirtualPumpPlugin.getPlugin().isEnabled(PluginBase.PUMP);
boolean vpUploadEnabled = SP.getBoolean("virtualpump_uploadstatus", false); boolean vpUploadEnabled = SP.getBoolean("virtualpump_uploadstatus", false);
boolean vpUploadNeeded = !isVirtualPump || vpUploadEnabled; boolean vpUploadNeeded = !isVirtualPump || vpUploadEnabled;
boolean hasBGData = DatabaseHelper.lastBg()!=null;
boolean apsEnabled = false; boolean apsEnabled = false;
APSInterface usedAPS = ConfigBuilderPlugin.getActiveAPS(); APSInterface usedAPS = ConfigBuilderPlugin.getActiveAPS();
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS)) if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS))
apsEnabled = true; apsEnabled = true;
return new RequirementResult(bgIsAvailableInNS && pumpStatusIsAvailableInNS && NSClientInternalPlugin.getPlugin().hasWritePermission() && LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP) && apsEnabled && vpUploadNeeded, return new RequirementResult(hasBGData&&bgIsAvailableInNS && pumpStatusIsAvailableInNS && NSClientInternalPlugin.getPlugin().hasWritePermission() && LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP) && apsEnabled && vpUploadNeeded,
MainApp.sResources.getString(R.string.objectives_bgavailableinns) + ": " + yesOrNo(bgIsAvailableInNS) MainApp.sResources.getString(R.string.objectives_bgavailableinns) + ": " + yesOrNo(bgIsAvailableInNS)
+ " " + MainApp.sResources.getString(R.string.nsclienthaswritepermission) + ": " + yesOrNo(NSClientInternalPlugin.getPlugin().hasWritePermission()) + "\n" + MainApp.sResources.getString(R.string.nsclienthaswritepermission) + ": " + yesOrNo(NSClientInternalPlugin.getPlugin().hasWritePermission())
+ (isVirtualPump ? " " + MainApp.sResources.getString(R.string.virtualpump_uploadstatus_title) + ": " + yesOrNo(vpUploadEnabled) : "") + (isVirtualPump ? "\n" + MainApp.sResources.getString(R.string.virtualpump_uploadstatus_title) + ": " + yesOrNo(vpUploadEnabled) : "")
+ " " + MainApp.sResources.getString(R.string.objectives_pumpstatusavailableinns) + ": " + yesOrNo(pumpStatusIsAvailableInNS) + "\n" + MainApp.sResources.getString(R.string.objectives_pumpstatusavailableinns) + ": " + yesOrNo(pumpStatusIsAvailableInNS)
+ " " + MainApp.sResources.getString(R.string.loopenabled) + ": " + yesOrNo(LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP)) + "\n" + MainApp.sResources.getString(R.string.hasbgdata) + ": " + yesOrNo(hasBGData)
+ " " + MainApp.sResources.getString(R.string.apsselected) + ": " + yesOrNo(apsEnabled) + "\n" + MainApp.sResources.getString(R.string.loopenabled) + ": " + yesOrNo(LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP))
+ "\n" + MainApp.sResources.getString(R.string.apsselected) + ": " + yesOrNo(apsEnabled)
); );
case 1: case 1:
return new RequirementResult(manualEnacts >= manualEnactsNeeded, return new RequirementResult(manualEnacts >= manualEnactsNeeded,

View file

@ -114,6 +114,18 @@ public class NSClientService extends Service {
initialize(); initialize();
} }
@Override
public void onCreate() {
super.onCreate();
mWakeLock.acquire();
}
@Override
public void onDestroy() {
super.onDestroy();
mWakeLock.release();
}
public class LocalBinder extends Binder { public class LocalBinder extends Binder {
public NSClientService getServiceInstance() { public NSClientService getServiceInstance() {
return NSClientService.this; return NSClientService.this;
@ -182,8 +194,6 @@ public class NSClientService extends Service {
public void initialize() { public void initialize() {
dataCounter = 0; dataCounter = 0;
NSClientService.mWakeLock.acquire();
readPreferences(); readPreferences();
if (!nsAPISecret.equals("")) if (!nsAPISecret.equals(""))
@ -221,7 +231,6 @@ public class NSClientService extends Service {
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "No NS URL specified")); MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "No NS URL specified"));
MainApp.bus().post(new EventNSClientStatus("Not configured")); MainApp.bus().post(new EventNSClientStatus("Not configured"));
} }
NSClientService.mWakeLock.release();
} }
private Emitter.Listener onConnect = new Emitter.Listener() { private Emitter.Listener onConnect = new Emitter.Listener() {
@ -242,6 +251,15 @@ public class NSClientService extends Service {
public void destroy() { public void destroy() {
if (mSocket != null) { if (mSocket != null) {
mSocket.off(Socket.EVENT_CONNECT);
mSocket.off(Socket.EVENT_DISCONNECT);
mSocket.off(Socket.EVENT_PING);
mSocket.off("dataUpdate");
mSocket.off("announcement");
mSocket.off("alarm");
mSocket.off("urgent_alarm");
mSocket.off("clear_alarm");
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "destroy")); MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "destroy"));
isConnected = false; isConnected = false;
hasWriteAuth = false; hasWriteAuth = false;

View file

@ -248,9 +248,11 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
determineBasalResultAMA.changeRequested = false; determineBasalResultAMA.changeRequested = false;
// limit requests on openloop mode // limit requests on openloop mode
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) { if (!MainApp.getConfigBuilder().isClosedModeEnabled()) {
if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultAMA.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory()) < 0.1) if (MainApp.getConfigBuilder().isTempBasalInProgress() && determineBasalResultAMA.rate == 0 && determineBasalResultAMA.duration == 0) {
// going to cancel
} else if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultAMA.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory()) < 0.1) {
determineBasalResultAMA.changeRequested = false; determineBasalResultAMA.changeRequested = false;
if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultAMA.rate - ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) < 0.1) } else if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultAMA.rate - ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) < 0.1)
determineBasalResultAMA.changeRequested = false; determineBasalResultAMA.changeRequested = false;
} }

View file

@ -232,9 +232,11 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
determineBasalResultMA.changeRequested = false; determineBasalResultMA.changeRequested = false;
// limit requests on openloop mode // limit requests on openloop mode
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) { if (!MainApp.getConfigBuilder().isClosedModeEnabled()) {
if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory()) < 0.1) if (MainApp.getConfigBuilder().isTempBasalInProgress() && determineBasalResultMA.rate == 0 && determineBasalResultMA.duration == 0) {
// going to cancel
} else if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory()) < 0.1) {
determineBasalResultMA.changeRequested = false; determineBasalResultMA.changeRequested = false;
if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) < 0.1) } else if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) < 0.1)
determineBasalResultMA.changeRequested = false; determineBasalResultMA.changeRequested = false;
} }

View file

@ -76,7 +76,8 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis
unitsView = (TextView) view.findViewById(R.id.overview_calibration_units); unitsView = (TextView) view.findViewById(R.id.overview_calibration_units);
unitsView.setText(units); unitsView.setText(units);
setCancelable(false); setCancelable(true);
getDialog().setCanceledOnTouchOutside(false);
return view; return view;
} }

View file

@ -102,7 +102,8 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher); editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false, textWatcher); editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false, textWatcher);
setCancelable(false); setCancelable(true);
getDialog().setCanceledOnTouchOutside(false);
return view; return view;
} }

View file

@ -233,7 +233,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false); editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
initDialog(); initDialog();
setCancelable(false); setCancelable(true);
getDialog().setCanceledOnTouchOutside(false);
return view; return view;
} }

View file

@ -59,6 +59,7 @@ public class Notification {
public static final int MINIMAL_BASAL_VALUE_REPLACED = 29; public static final int MINIMAL_BASAL_VALUE_REPLACED = 29;
public static final int BASAL_PROFILE_NOT_ALIGNED_TO_HOURS = 30; public static final int BASAL_PROFILE_NOT_ALIGNED_TO_HOURS = 30;
public static final int ZERO_VALUE_IN_PROFILE = 31; public static final int ZERO_VALUE_IN_PROFILE = 31;
public static final int NO_LOCALE_PROFILE_FOUND = 32;
public int id; public int id;
public Date date; public Date date;

View file

@ -405,6 +405,8 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
} else { } else {
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE)); MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(notification));
result.success = true; result.success = true;
result.enacted = true; result.enacted = true;
result.comment = "OK"; result.comment = "OK";

View file

@ -257,6 +257,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
} else { } else {
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE)); MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(notification));
result.success = true; result.success = true;
result.enacted = true; result.enacted = true;
result.comment = "OK"; result.comment = "OK";

View file

@ -23,7 +23,9 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui; import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.NSUpload; import info.nightscout.utils.NSUpload;
@ -218,12 +220,14 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
// Do nothing here. we are using MainApp.getConfigBuilder().getActiveProfile().getProfile(); // Do nothing here. we are using MainApp.getConfigBuilder().getActiveProfile().getProfile();
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
result.success = true; result.success = true;
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60);
MainApp.bus().post(new EventNewNotification(notification));
return result; return result;
} }
@Override @Override
public boolean isThisProfileSet(Profile profile) { public boolean isThisProfileSet(Profile profile) {
return false; return true;
} }
@Override @Override

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">AndroidAPS</string>
<string name="Glimp">Glimp</string> <string name="Glimp">Glimp</string>
<string name="MM640g">MM640g</string> <string name="MM640g">MM640g</string>
<string name="absolute">Absoluut</string> <string name="absolute">Absoluut</string>
@ -13,7 +12,7 @@
<string name="adult">Volwassene</string> <string name="adult">Volwassene</string>
<string name="advancedsettings_title">Uitgebreide instellingen</string> <string name="advancedsettings_title">Uitgebreide instellingen</string>
<string name="alert_dialog_storage_permission_text">Herstart je telefoon of herstart AndroidAPS vanuit de systeem instellingen a.u.b. anders zal AndroidAPS geen logboek hebben (Belangrijk om te controleren of de algoritmes correct werken)!</string> <string name="alert_dialog_storage_permission_text">Herstart je telefoon of herstart AndroidAPS vanuit de systeem instellingen a.u.b. anders zal AndroidAPS geen logboek hebben (Belangrijk om te controleren of de algoritmes correct werken)!</string>
<string name="always_use_shortavg_summary">Nuttig wanneer gevens van niet gefilterde bronnes zoals Xdrip wispelturig zijn</string> <string name="always_use_shortavg_summary">Nuttig wanneer gegevens van niet gedempte bronnen zoals Xdrip wispelturig zijn</string>
<string name="androidaps_start">AndroidAPS gestart</string> <string name="androidaps_start">AndroidAPS gestart</string>
<string name="approachingdailylimit">Insuline daglimiet bereikt</string> <string name="approachingdailylimit">Insuline daglimiet bereikt</string>
<string name="apsmode_title">APS Mode</string> <string name="apsmode_title">APS Mode</string>
@ -40,17 +39,17 @@
<string name="vitualpump_label">VIRTUELE POMP</string> <string name="vitualpump_label">VIRTUELE POMP</string>
<string name="visible">Toon</string> <string name="visible">Toon</string>
<string name="virtualpump_uploadstatus_title">Upload status naar NS</string> <string name="virtualpump_uploadstatus_title">Upload status naar NS</string>
<string name="virtualpump_tempbasal_label">Tijdelijk basaal</string> <string name="pump_tempbasal_label">Tijdelijk basaal</string>
<string name="virtualpump_sqlerror">SQL Storing</string> <string name="virtualpump_sqlerror">SQL Storing</string>
<string name="virtualpump_shortname">VP</string> <string name="virtualpump_shortname">VP</string>
<string name="virtualpump_settings">Virtuele pomp instellingen</string> <string name="virtualpump_settings">Virtuele pomp instellingen</string>
<string name="virtualpump_resultok">OK</string> <string name="virtualpump_resultok">OK</string>
<string name="virtualpump_reservoir_label">Reservoir</string> <string name="pump_reservoir_label">Reservoir</string>
<string name="virtualpump_lastconnection_label">Laatste verbinding</string> <string name="pump_lastconnection_label">Laatste verbinding</string>
<string name="virtualpump_firmware_label">Firmware</string> <string name="virtualpump_firmware_label">Firmware</string>
<string name="virtualpump_extendedbolus_label_short">EXT</string> <string name="virtualpump_extendedbolus_label_short">EXT</string>
<string name="virtualpump_extendedbolus_label">Vertraagde bolus</string> <string name="virtualpump_extendedbolus_label">Vertraagde bolus</string>
<string name="virtualpump_battery_label">Batterij</string> <string name="pump_battery_label">Batterij</string>
<string name="virtualpump">Virtuele Pomp</string> <string name="virtualpump">Virtuele Pomp</string>
<string name="uploading">Uploaden</string> <string name="uploading">Uploaden</string>
<string name="uploader_short">UPLD</string> <string name="uploader_short">UPLD</string>
@ -92,7 +91,7 @@
<string name="careportal_cgm_label">CGM &amp; OPENAPS</string> <string name="careportal_cgm_label">CGM &amp; OPENAPS</string>
<string name="careportal_cgmsensorinsert">CGM Sens. ingebracht</string> <string name="careportal_cgmsensorinsert">CGM Sens. ingebracht</string>
<string name="careportal_cgmsensorstart">CGM Sens. Start</string> <string name="careportal_cgmsensorstart">CGM Sens. Start</string>
<string name="careportal_combobolus">Multiwave bolus</string> <string name="careportal_bolus">Multiwave bolus</string>
<string name="careportal_correctionbolus">Correctie bolus</string> <string name="careportal_correctionbolus">Correctie bolus</string>
<string name="careportal_exercise">Sport</string> <string name="careportal_exercise">Sport</string>
<string name="careportal_insulinage_label">Ouderdom insuline</string> <string name="careportal_insulinage_label">Ouderdom insuline</string>
@ -175,7 +174,7 @@
<string name="danar_enableextendedbolus">Activeer vertraagde bolussen op de pomp</string> <string name="danar_enableextendedbolus">Activeer vertraagde bolussen op de pomp</string>
<string name="danar_error">Storing</string> <string name="danar_error">Storing</string>
<string name="danar_glucose">glucose</string> <string name="danar_glucose">glucose</string>
<string name="danar_history">Geschiedenis</string> <string name="danar_history">Historiek</string>
<string name="danar_history_alarm">Alarm</string> <string name="danar_history_alarm">Alarm</string>
<string name="restart">Herstart</string> <string name="restart">Herstart</string>
<string name="result">Resultaat</string> <string name="result">Resultaat</string>
@ -275,7 +274,7 @@
<string name="openaps">OpenAPS</string> <string name="openaps">OpenAPS</string>
<string name="openaps_short">OAPS</string> <string name="openaps_short">OAPS</string>
<string name="openapsama">OpenAPS AMA</string> <string name="openapsama">OpenAPS AMA</string>
<string name="danar_lastbolus">Laatste bolus</string> <string name="pump_lastbolus_label">Laatste bolus</string>
<string name="danar_password_title">Pomp wachtwoord</string> <string name="danar_password_title">Pomp wachtwoord</string>
<string name="danar_pump_settings">DanaR pomp instellingen</string> <string name="danar_pump_settings">DanaR pomp instellingen</string>
<string name="danar_refill">Hervullen</string> <string name="danar_refill">Hervullen</string>
@ -454,7 +453,7 @@
<string name="openapsma_maxiob_title">Maximaal basaal IOB OpenAPS kan toedienen [E]</string> <string name="openapsma_maxiob_title">Maximaal basaal IOB OpenAPS kan toedienen [E]</string>
<string name="openapsma_profile_label">Profiel</string> <string name="openapsma_profile_label">Profiel</string>
<string name="openapsma_valueoutofrange">Waarde %s is buiten de toegestane limieten</string> <string name="openapsma_valueoutofrange">Waarde %s is buiten de toegestane limieten</string>
<string name="virtualpump_basebasalrate_label">Basis basale dosis</string> <string name="pump_basebasalrate_label">Basis basale dosis</string>
<string name="openapsma_lastrun_label">Laatse berekening</string> <string name="openapsma_lastrun_label">Laatse berekening</string>
<string name="openapsma_lastenact_label">Laatste uitvoering</string> <string name="openapsma_lastenact_label">Laatste uitvoering</string>
<string name="openapsma_glucosestatus_label">Glucose gegevens</string> <string name="openapsma_glucosestatus_label">Glucose gegevens</string>
@ -462,7 +461,6 @@
<string name="openapsma_inputparameters_label">Berekende gegevens</string> <string name="openapsma_inputparameters_label">Berekende gegevens</string>
<string name="openapsma_iobdata_label">IOB gegevens</string> <string name="openapsma_iobdata_label">IOB gegevens</string>
<string name="openapsma_maxbasal_summary">DIt is de maximale waarde waarop het basaal door OpenAPS ingesteld kan worden</string> <string name="openapsma_maxbasal_summary">DIt is de maximale waarde waarop het basaal door OpenAPS ingesteld kan worden</string>
<string name="profileswitch">Profiel wissel</string>
<string name="profileviewer">NS Profiel</string> <string name="profileviewer">NS Profiel</string>
<string name="profileviewer_shortname">NSPROFIEL</string> <string name="profileviewer_shortname">NSPROFIEL</string>
<string name="pump">Pomp</string> <string name="pump">Pomp</string>
@ -510,9 +508,9 @@
<string name="overview_quickwizard_item_remove_button">Verwijder</string> <string name="overview_quickwizard_item_remove_button">Verwijder</string>
<string name="overview_quickwizard_item_edit_button">Wijzig</string> <string name="overview_quickwizard_item_edit_button">Wijzig</string>
<string name="overview_shortname">Home</string> <string name="overview_shortname">Home</string>
<string name="overview_editquickwizard_valid">Geldigheid:</string> <string name="overview_editquickwizard_valid">Beschikbaarheid:</string>
<string name="overview_editquickwizard_carbs">Koolhydraten:</string> <string name="overview_editquickwizard_carbs">Koolhydraten:</string>
<string name="overview_editquickwizard_buttontext">Knop tekst:</string> <string name="overview_editquickwizard_buttontext">Naam:</string>
<string name="overview_calibration_bg_label">Kalibratie</string> <string name="overview_calibration_bg_label">Kalibratie</string>
<string name="overview_calculator_label">Bolus wizard</string> <string name="overview_calculator_label">Bolus wizard</string>
<string name="danar_ebolus">E bolus</string> <string name="danar_ebolus">E bolus</string>
@ -566,7 +564,7 @@
<string name="objectives_shortname">DOEL</string> <string name="objectives_shortname">DOEL</string>
<string name="occlusion">Afsluiting</string> <string name="occlusion">Afsluiting</string>
<string name="ongoingnotificaction">Lopende berichten</string> <string name="ongoingnotificaction">Lopende berichten</string>
<string name="open_settings_on_wear">Opene instellingen op Wear</string> <string name="open_settings_on_wear">Open instellingen op Wear</string>
<string name="openapsma_maxbasal_title">Maximale E/u dat OpenAPS kan toedienen</string> <string name="openapsma_maxbasal_title">Maximale E/u dat OpenAPS kan toedienen</string>
<string name="prefs_delta_title">Verschil instellingen</string> <string name="prefs_delta_title">Verschil instellingen</string>
<string name="prefs_range_title">Bereik voor visualisatie</string> <string name="prefs_range_title">Bereik voor visualisatie</string>
@ -592,8 +590,8 @@
<string name="pumpshutdown">Pomp uitschakelen</string> <string name="pumpshutdown">Pomp uitschakelen</string>
<string name="pumpsuspended">Pomp onderbreken</string> <string name="pumpsuspended">Pomp onderbreken</string>
<string name="pumpsuspendedclicktorefresh">Pomp onderbroken. Klik om de status te vernieuwen</string> <string name="pumpsuspendedclicktorefresh">Pomp onderbroken. Klik om de status te vernieuwen</string>
<string name="quickwizard">Instelassisten</string> <string name="quickwizard">Vaste maaltijd</string>
<string name="quickwizardsettings">Instelassistent instellingen</string> <string name="quickwizardsettings">Vaste maaltijd instellingen</string>
<string name="ratio_short">SEN</string> <string name="ratio_short">SEN</string>
<string name="removerecord">Verwijder gegeven:</string> <string name="removerecord">Verwijder gegeven:</string>
<string name="resend_all_data">Verzend alle gegevens opnieuw</string> <string name="resend_all_data">Verzend alle gegevens opnieuw</string>
@ -679,4 +677,75 @@
<string name="wearcontrol_title">Bedieningen via horloge</string> <string name="wearcontrol_title">Bedieningen via horloge</string>
<string name="emptyreservoir">Ampull leeg</string> <string name="emptyreservoir">Ampull leeg</string>
<string name="waitingforpairing">Wachten op koppelen van de pomp</string> <string name="waitingforpairing">Wachten op koppelen van de pomp</string>
<string name="pump_errors_history">Storingen</string>
<string name="profileswitch">Wijzigingen van profiel</string>
<string name="bluetooth">Bluetooth</string>
<string name="food">Voeding</string>
<string name="enable_pump_unreachable_alert">Waarschuwing bij niet bereikbare pomp</string>
<string name="bolus_frequency_exceeded">Een bolus met dezelfde hoeveelheid was gevraagd binnen de minuut. Om accidentiële of door bugs veroorzaakte dubbele bolussen te vermijden is deze bolus geannuleerd</string>
<string name="bolusstopping">estopt Bolus toediening wordt</string>
<string name="shortfat">Vet</string>
<string name="bolusstopped">Bolus toediening gestopt</string>
<string name="raise_urgent_alarms_as_android_notification">Gebruik systeem notificaties voor waarschuwingen</string>
<string name="wear_detailed_delta_title">Toon gedetaillieerde delta</string>
<string name="unsupportedfirmware">Niet ondersteune pomp firmware</string>
<string name="DexcomG5">DexcomG5 App (aangepast)</string>
<string name="shortgramm">g</string>
<string name="shortkilojoul">kJ</string>
<string name="shortenergy">En</string>
<string name="shortprotein">Prot</string>
<string name="info">INFO</string>
<string name="btwatchdog_title">BT Watchdog</string>
<string name="btwatchdog_summary">Desactiveert de bluetooth functie van de telefoon gedurende een ogenblik. Dit kan op sommige gsm\'s een vastgelopen bluetooth service verhelpen.</string>
<string name="missed_bg_readings">Geen BG metingen</string>
<string name="processinghistory">Uitvoeren van gebeurtenis</string>
<string name="pump_unreachable">Pomp niet beschikbaar</string>
<string name="pump_unreachable_threshold">Pomp niet beschikbaar sinds [min]</string>
<string name="pumpdrivercorrected">Pomp service gecorrigeerd</string>
<string name="localalertsettings_title">Lokaal gegenereerde waarschuwingen</string>
<string name="startingbolus">Bolus toediening gestart</string>
<string name="wear_detailed_delta_summary">Toon delta met eenextra decimaal punt</string>
<string name="waitingforestimatedbolusend">Wacht op complete bolus toediening Resterend %d sec.</string>
<string name="urgent_alarm">Dringend alarm</string>
<string name="treatments_wizard_tt_label">TT</string>
<string name="raise_notifications_as_android_notifications">Gebruik systeem notficaties voor waarchuwingen en notificaties</string>
<string name="executingrightnow">Opdracht is nu uitgevoerd</string>
<string name="enable_missed_bg_readings_alert">Alarm als er geen BG gegevens ontvangen zijn</string>
<string name="customapp">Aangepaste APK downloaden</string>
<string name="dexcomg5_nsupload_title">Upload BG gegevens naar NS</string>
<string name="dexcomg5_upload">G5 Upload instellingen</string>
<string name="loopenabled">Loop Actief</string>
<string name="yes">Ja</string>
<string name="no">Nee</string>
<string name="dexcomg5_xdripupload_summary">In xDrip+ kies 640g/Eversense data bron</string>
<string name="nsclientbg">NSClient BG</string>
<string name="overview_editquickwizard_usebasaliob">Basaal IOB meerekenen</string>
<string name="apsselected">APS geslecteerd</string>
<string name="dexcomg5_xdripupload_title">Stuur BG data naar xDrip+</string>
<string name="minimalbasalvaluereplaced">Basale waarde vervangen door minimaal ondersteunde waarde</string>
<string name="overview_editquickwizard_usetemptarget">Tijdelijk doel berekenen</string>
<string name="overview_editquickwizard_usesuperbolus">Superbolus berekening</string>
<string name="nsclienthaswritepermission">NSClient heeft schrijf rechten</string>
<string name="objectives_7_objective">Activeren van extra functies tijdes de dag zoals SMB</string>
<string name="overview_editquickwizard_usebg">BG meerekenen</string>
<string name="overview_editquickwizard_usebolusiob">Bolus IOB meerekenen</string>
<string name="closedmodeenabled">Closed modus actief</string>
<string name="overview_editquickwizard_usecob">COB berekening</string>
<string name="active"><![CDATA[<Huidig>]]></string>
<string name="none"><![CDATA[<geen>]]></string>
<string name="app_name">AndroidAPS</string>
<string name="zerovalueinprofile">Nul waarde in basaal profiel</string>
<string name="hasbgdata">BG beschikbaar op gekozen bron</string>
<string name="positiveonly">Enkel positief</string>
<string name="negativeonly">Enkel negatief</string>
<string name="maxiobset">Maximum IOB juist ingesteld</string>
<string name="virtualpump_basebasalrate_label">Basis basaal patroon</string>
<string name="virtualpump_tempbasal_label">Tijdelijk basaal</string>
<string name="virtualpump_battery_label">Batterij</string>
<string name="virtualpump_reservoir_label">Reservoir</string>
<string name="careportal_combobolus">Multiwave bolus</string>
<string name="danar_lastbolus">Laatste bolus:</string>
<string name="virtualpump_lastconnection_label">Laatste verbinding</string>
<string name="overview_editquickwizard_usetrend">Trend berekening</string>
<string name="nolocaleprofilefound">Profiel wiissel ontvangen via NS maar dit profiel bestaat niet op gsm</string>
</resources> </resources>

View file

@ -806,7 +806,9 @@
<string name="nsclienthaswritepermission">NSClient has write permission</string> <string name="nsclienthaswritepermission">NSClient has write permission</string>
<string name="closedmodeenabled">Closed mode enabled</string> <string name="closedmodeenabled">Closed mode enabled</string>
<string name="maxiobset">Maximal IOB set properly</string> <string name="maxiobset">Maximal IOB set properly</string>
<string name="hasbgdata">BG available from selected source</string>
<string name="basalprofilenotaligned">Basal values not aligned to hours</string> <string name="basalprofilenotaligned">Basal values not aligned to hours</string>
<string name="zerovalueinprofile">Zero value in profile</string> <string name="zerovalueinprofile">Zero value in profile</string>
<string name="nolocaleprofilefound">Received profile switch from NS but profile doesn\'t exist localy</string>
</resources> </resources>

View file

@ -0,0 +1,85 @@
package info.nightscout.utils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.data.GlucoseStatus;
import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.PumpMDI.MDIPlugin;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
* Created by kuchjir on 12/12/2017.
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest( { MainApp.class, GlucoseStatus.class, ConfigBuilderPlugin.class })
public class BolusWizardTest {
private static final double PUMP_BOLUS_STEP = 0.1;
@Test
/** Should calculate the same bolus when different blood glucose but both in target range */
public void shuldCalculateTheSameBolusWhenBGsInRange() throws Exception {
BolusWizard bw = new BolusWizard();
Profile profile = setupProfile(4d, 8d, 20d, 12d);
Double bolusForBg42 = bw.doCalc(profile, null, 20, 0.0,4.2, 0d, 100d, true, true, false, false);
Double bolusForBg54 = bw.doCalc(profile, null, 20, 0.0,5.4, 0d, 100d, true, true, false, false);
Assert.assertEquals(bolusForBg42, bolusForBg54);
}
@Test
public void shuldCalculateHigherBolusWhenHighBG() throws Exception {
BolusWizard bw = new BolusWizard();
Profile profile = setupProfile(4d, 8d, 20d, 12d);
Double bolusForHighBg = bw.doCalc(profile, null, 20, 0d,9.8, 0d, 100d, true, true, false, false);
Double bolusForBgInRange = bw.doCalc(profile, null, 20, 0.0,5.4, 0d, 100d, true, true, false, false);
Assert.assertTrue(bolusForHighBg > bolusForBgInRange);
}
@Test
public void shuldCalculateLowerBolusWhenLowBG() throws Exception {
BolusWizard bw = new BolusWizard();
Profile profile = setupProfile(4d, 8d, 20d, 12d);
Double bolusForLowBg = bw.doCalc(profile, null, 20, 0d,3.6, 0d, 100d, true, true, false, false);
Double bolusForBgInRange = bw.doCalc(profile, null, 20, 0.0,5.4, 0d, 100d, true, true, false, false);
Assert.assertTrue(bolusForLowBg < bolusForBgInRange);
}
private Profile setupProfile(Double targetLow, Double targetHigh, Double insulinSensitivityFactor, Double insulinToCarbRatio) {
Profile profile = mock(Profile.class);
when(profile.getTargetLow()).thenReturn(targetLow);
when(profile.getTargetHigh()).thenReturn(targetHigh);
when(profile.getIsf()).thenReturn(insulinSensitivityFactor);
when(profile.getIc()).thenReturn(insulinToCarbRatio);
PowerMockito.mockStatic(GlucoseStatus.class);
when(GlucoseStatus.getGlucoseStatusData()).thenReturn(null);
ConfigBuilderPlugin treatment = mock(ConfigBuilderPlugin.class);
IobTotal iobTotalZero = new IobTotal(System.currentTimeMillis());
when(treatment.getLastCalculationTreatments()).thenReturn(iobTotalZero);
when(treatment.getLastCalculationTempBasals()).thenReturn(iobTotalZero);
PowerMockito.mockStatic(MainApp.class);
when(MainApp.getConfigBuilder()).thenReturn(treatment);
PowerMockito.mockStatic(ConfigBuilderPlugin.class);
PumpInterface pump = MDIPlugin.getPlugin();
pump.getPumpDescription().bolusStep = PUMP_BOLUS_STEP;
when(ConfigBuilderPlugin.getActivePump()).thenReturn(pump);
return profile;
}
}

View file

@ -14,18 +14,21 @@ public class RoundTest {
public void roundToTest() throws Exception { public void roundToTest() throws Exception {
assertEquals( 0.55d, Round.roundTo(0.54d, 0.05d), 0.00000001d ); assertEquals( 0.55d, Round.roundTo(0.54d, 0.05d), 0.00000001d );
assertEquals( 1d, Round.roundTo(1.49d, 1d), 0.00000001d ); assertEquals( 1d, Round.roundTo(1.49d, 1d), 0.00000001d );
assertEquals( 0d, Round.roundTo(0d, 1d), 0.00000001d );
} }
@Test @Test
public void floorToTest() throws Exception { public void floorToTest() throws Exception {
assertEquals( 0.5d, Round.floorTo(0.54d, 0.05d), 0.00000001d ); assertEquals( 0.5d, Round.floorTo(0.54d, 0.05d), 0.00000001d );
assertEquals( 1d, Round.floorTo(1.59d, 1d), 0.00000001d ); assertEquals( 1d, Round.floorTo(1.59d, 1d), 0.00000001d );
assertEquals( 0d, Round.floorTo(0d, 1d), 0.00000001d );
} }
@Test @Test
public void ceilToTest() throws Exception { public void ceilToTest() throws Exception {
assertEquals( 0.6d, Round.ceilTo(0.54d, 0.1d), 0.00000001d ); assertEquals( 0.6d, Round.ceilTo(0.54d, 0.1d), 0.00000001d );
assertEquals( 2d, Round.ceilTo(1.49999d, 1d), 0.00000001d ); assertEquals( 2d, Round.ceilTo(1.49999d, 1d), 0.00000001d );
assertEquals( 0d, Round.ceilTo(0d, 1d), 0.00000001d );
} }
} }