This commit is contained in:
Milos Kozak 2020-03-17 19:50:20 +01:00
parent 21f8a13098
commit 81eeacb02a
29 changed files with 54 additions and 70 deletions

View file

@ -62,7 +62,7 @@ import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.LocaleHelper;
import info.nightscout.androidaps.utils.OKDialog;
import info.nightscout.androidaps.utils.PasswordProtection;
import info.nightscout.androidaps.utils.build.BuildHelper;
import info.nightscout.androidaps.utils.buildHelper.BuildHelper;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
import io.reactivex.android.schedulers.AndroidSchedulers;

View file

@ -41,7 +41,7 @@ import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.DefaultValueHelper;
import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.T;
import info.nightscout.androidaps.utils.build.BuildHelper;
import info.nightscout.androidaps.utils.buildHelper.BuildHelper;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
import io.reactivex.android.schedulers.AndroidSchedulers;

View file

@ -31,7 +31,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.DecimalFormatter;
import info.nightscout.androidaps.utils.HardLimits;
import info.nightscout.androidaps.utils.Round;
import info.nightscout.androidaps.utils.build.BuildHelper;
import info.nightscout.androidaps.utils.buildHelper.BuildHelper;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;

View file

@ -27,7 +27,7 @@ import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.OKDialog
import info.nightscout.androidaps.utils.SingleClickButton
import info.nightscout.androidaps.utils.build.BuildHelper
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.extensions.plusAssign
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP

View file

@ -13,7 +13,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
import info.nightscout.androidaps.utils.build.BuildHelper
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import java.io.*

View file

@ -116,7 +116,7 @@ import info.nightscout.androidaps.utils.Profiler;
import info.nightscout.androidaps.utils.SingleClickButton;
import info.nightscout.androidaps.utils.T;
import info.nightscout.androidaps.utils.ToastUtils;
import info.nightscout.androidaps.utils.build.BuildHelper;
import info.nightscout.androidaps.utils.buildHelper.BuildHelper;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
import info.nightscout.androidaps.utils.wizard.BolusWizard;

View file

@ -41,7 +41,7 @@ import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.MidnightTime;
import info.nightscout.androidaps.utils.Profiler;
import info.nightscout.androidaps.utils.T;
import info.nightscout.androidaps.utils.build.BuildHelper;
import info.nightscout.androidaps.utils.buildHelper.BuildHelper;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;

View file

@ -39,7 +39,7 @@ import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.MidnightTime;
import info.nightscout.androidaps.utils.Profiler;
import info.nightscout.androidaps.utils.T;
import info.nightscout.androidaps.utils.build.BuildHelper;
import info.nightscout.androidaps.utils.buildHelper.BuildHelper;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;

View file

@ -15,7 +15,7 @@ import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.build.BuildHelper
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.extensions.isRunningTest
import info.nightscout.androidaps.utils.resources.ResourceHelper
import java.util.*

View file

@ -33,7 +33,7 @@ import info.nightscout.androidaps.queue.commands.*
import info.nightscout.androidaps.queue.commands.Command.CommandType
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.HtmlHelper
import info.nightscout.androidaps.utils.build.BuildHelper
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import io.reactivex.disposables.CompositeDisposable

View file

@ -0,0 +1,31 @@
package info.nightscout.androidaps.utils.buildHelper
import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.Config
import info.nightscout.androidaps.plugins.general.maintenance.LoggerUtils
import java.io.File
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class BuildHelper @Inject constructor() {
private var devBranch = false
private var engineeringMode = false
init {
val extFilesDir = LoggerUtils.getLogDirectory()
val engineeringModeSemaphore = File(extFilesDir, "engineering_mode")
engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile
devBranch = BuildConfig.VERSION.contains("-") || BuildConfig.VERSION.matches(Regex(".*[a-zA-Z]+.*"))
}
fun isEngineeringModeOrRelease(): Boolean =
if (!Config.APS) true else engineeringMode || !devBranch
fun isEngineeringMode(): Boolean =
if (!Config.APS) true else engineeringMode || !devBranch
fun isDev(): Boolean = devBranch
}

View file

@ -30,7 +30,7 @@ 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.HardLimits
import info.nightscout.androidaps.utils.build.BuildHelper
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.junit.Assert
@ -124,10 +124,10 @@ class ConstraintsCheckerTest : TestBase() {
danaRPump = DanaRPump(aapsLogger, sp, injector)
hardLimits = HardLimits(aapsLogger, sp, resourceHelper, context)
objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp)
comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue)
comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, resourceHelper, profileFunction, treatmentsPlugin, sp, commandQueue, context)
danaRPlugin = DanaRPlugin(injector, aapsLogger, rxBus, context, resourceHelper, constraintChecker, treatmentsPlugin, sp, commandQueue, danaRPump)
danaRSPlugin = DanaRSPlugin(injector, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue, danaRPump, detailedBolusInfoStorage)
insightPlugin = LocalInsightPlugin(injector, aapsLogger, rxBus, resourceHelper, constraintChecker, treatmentsPlugin, sp, commandQueue, profileFunction)
insightPlugin = LocalInsightPlugin(injector, aapsLogger, rxBus, resourceHelper, treatmentsPlugin, sp, commandQueue, profileFunction, context)
openAPSSMBPlugin = OpenAPSSMBPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, treatmentsPlugin, iobCobCalculatorPlugin, hardLimits)
openAPSAMAPlugin = OpenAPSAMAPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, treatmentsPlugin, iobCobCalculatorPlugin, hardLimits)
openAPSMAPlugin = OpenAPSMAPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, treatmentsPlugin, iobCobCalculatorPlugin, hardLimits)

View file

@ -41,6 +41,7 @@ class ComboPluginTest : TestBase() {
@Mock lateinit var commandQueue: CommandQueueProvider
@Mock lateinit var treatmentsPlugin: TreatmentsPlugin
@Mock lateinit var sp: SP
@Mock lateinit var context: Context
val injector = HasAndroidInjector {
AndroidInjector {
@ -52,7 +53,7 @@ class ComboPluginTest : TestBase() {
@Before
fun prepareMocks() {
`when`(resourceHelper.gs(R.string.novalidbasalrate)).thenReturn("No valid basal rate read from pump")
comboPlugin = ComboPlugin(injector, aapsLogger, RxBusWrapper(), resourceHelper, constraintChecker, profileFunction, treatmentsPlugin, sp, commandQueue)
comboPlugin = ComboPlugin(injector, aapsLogger, RxBusWrapper(), resourceHelper, profileFunction, treatmentsPlugin, sp, commandQueue, context)
}
@Test

View file

@ -12,8 +12,6 @@ class DanaRS_Packet_Bolus_Get_Calculation_InformationTest : DanaRSTestBase() {
@Test fun runTest() {
val packet = DanaRS_Packet_Bolus_Get_Calculation_Information(aapsLogger, danaRPump)
// test params
val testparams = packet.requestParams
Assert.assertEquals(null, packet.requestParams)
// test message decoding
packet.handleMessage(createArray(24, 0.toByte()))

View file

@ -12,8 +12,6 @@ class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_InformationTest : DanaRST
@Test fun runTest() {
val packet = DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(aapsLogger, danaRPump)
// test params
val testparams = packet.requestParams
Assert.assertEquals(null, packet.requestParams)
// test message decoding
packet.handleMessage(createArray(24, 0.toByte()))

View file

@ -12,8 +12,6 @@ class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_StateTest : DanaRSTestBase()
@Test fun runTest() {
val packet = DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(aapsLogger, danaRPump)
// test params
val testparams = packet.requestParams
Assert.assertEquals(null, packet.requestParams)
// test message decoding
packet.handleMessage(createArray(34, 0.toByte()))

View file

@ -12,15 +12,11 @@ class DanaRS_Packet_Bolus_Get_Initial_BolusTest : DanaRSTestBase() {
@Test fun runTest() {
val packet = DanaRS_Packet_Bolus_Get_Initial_Bolus(aapsLogger)
// test params
val testparams = packet.requestParams
Assert.assertEquals(null, packet.requestParams)
// test message decoding
packet.handleMessage(createArray(34, 0.toByte()))
// should fail only if all the initialbolusses are 0
// DanaRPump testPump = DanaRPump.getInstance();
Assert.assertEquals(false, !packet.failed)
// assertEquals(false, packet.failed);
packet.handleMessage(createArray(34, 1.toByte()))
Assert.assertEquals(true, !packet.failed)
Assert.assertEquals("BOLUS__GET_BOLUS_RATE", packet.friendlyName)

View file

@ -12,8 +12,6 @@ class DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest : DanaRSTestBase() {
@Test fun runTest() {
val packet = DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)
// test params
val testparams = packet.requestParams
Assert.assertEquals(null, packet.requestParams)
// test message decoding
packet.handleMessage(createArray(34, 0.toByte()))

View file

@ -12,16 +12,11 @@ class DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest : DanaRSTestBase() {
@Test fun runTest() {
val packet = DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(aapsLogger)
// test params
val testparams = packet.requestParams
Assert.assertEquals(null, packet.requestParams)
// test message decoding
packet.handleMessage(createArray(34, 0.toByte()))
// DanaRPump testPump = DanaRPump.getInstance();
Assert.assertEquals(false, packet.failed)
packet.handleMessage(createArray(34, 1.toByte()))
// int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
Assert.assertEquals(true, packet.failed)
Assert.assertEquals("BOLUS__SET_EXTENDED_BOLUS_CANCEL", packet.friendlyName)
}

View file

@ -12,8 +12,6 @@ class DanaRS_Packet_Etc_Keep_ConnectionTest : DanaRSTestBase() {
@Test fun runTest() {
val packet = DanaRS_Packet_Etc_Keep_Connection(aapsLogger)
// test params
val testparams = packet.requestParams
Assert.assertEquals(null, packet.requestParams)
// test message decoding
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))

View file

@ -12,11 +12,8 @@ class DanaRS_Packet_General_Delivery_StatusTest : DanaRSTestBase() {
@Test fun runTest() {
val packet = DanaRS_Packet_General_Delivery_Status(aapsLogger)
// test params
val testparams = packet.requestParams
Assert.assertEquals(null, packet.requestParams)
// test message decoding
// everything ok :)
packet.handleMessage(createArray(15, 0.toByte()))
Assert.assertEquals(false, packet.failed)
packet.handleMessage(createArray(15, 161.toByte()))

View file

@ -12,14 +12,11 @@ class DanaRS_Packet_General_Get_More_InformationTest : DanaRSTestBase() {
@Test fun runTest() {
var packet = DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump)
// test params
val testparams = packet.requestParams
Assert.assertEquals(null, packet.requestParams)
// test message decoding
// test for the length message
// test for the length message
packet.handleMessage(createArray(13, 0.toByte()))
Assert.assertEquals(true, packet.failed)
// everything ok :)
packet = DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump)
packet.handleMessage(createArray(15, 0.toByte()))
Assert.assertEquals(false, packet.failed)

View file

@ -12,19 +12,14 @@ class DanaRS_Packet_General_Get_PasswordTest : DanaRSTestBase() {
@Test fun runTest() {
var packet = DanaRS_Packet_General_Get_Password(aapsLogger, danaRPump)
// test params
val testparams = packet.requestParams
Assert.assertEquals(null, packet.requestParams)
// test message decoding
// test for the length message
// test for the length message
packet.handleMessage(createArray(1, 0.toByte()))
Assert.assertEquals(true, packet.failed)
// everything ok :)
packet = DanaRS_Packet_General_Get_Password(aapsLogger, danaRPump)
packet.handleMessage(createArray(15, 0.toByte()))
Assert.assertEquals(false, packet.failed)
// packet.handleMessage(createArray(15, (byte) 161));
// assertEquals(true, packet.failed);
Assert.assertEquals("REVIEW__GET_PASSWORD", packet.friendlyName)
}
}

View file

@ -18,19 +18,14 @@ class DanaRS_Packet_General_Get_Pump_CheckTest : DanaRSTestBase() {
@Test fun runTest() {
var packet = DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper)
// test params
val testparams = packet.requestParams
Assert.assertEquals(null, packet.requestParams)
// test message decoding
// test for the length message
// test for the length message
packet.handleMessage(createArray(1, 0.toByte()))
Assert.assertEquals(true, packet.failed)
// everything ok :)
packet = DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper)
packet.handleMessage(createArray(15, 0.toByte()))
Assert.assertEquals(false, packet.failed)
// packet.handleMessage(createArray(15, (byte) 161));
// assertEquals(true, packet.failed);
Assert.assertEquals("REVIEW__GET_PUMP_CHECK", packet.friendlyName)
}
}

View file

@ -10,19 +10,15 @@ class DanaRS_Packet_General_Get_Shipping_InformationTest : DanaRSTestBase() {
@Test fun runTest() {
var packet = DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump)
// test params
val testparams = packet.requestParams
Assert.assertEquals(null, packet.requestParams)
// test message decoding
// test for the length message
// test for the length message
packet.handleMessage(createArray(1, 0.toByte()))
Assert.assertEquals(true, packet.failed)
// everything ok :)
packet = DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump)
packet.handleMessage(createArray(18, 0.toByte()))
Assert.assertEquals(false, packet.failed)
// packet.handleMessage(createArray(15, (byte) 161));
// assertEquals(true, packet.failed);
Assert.assertEquals("REVIEW__GET_SHIPPING_INFORMATION", packet.friendlyName)
}
}

View file

@ -12,14 +12,11 @@ class DanaRS_Packet_General_Get_Today_Delivery_TotalTest : DanaRSTestBase() {
@Test fun runTest() {
var packet = DanaRS_Packet_General_Get_Today_Delivery_Total(aapsLogger, danaRPump)
// test params
val testparams = packet.requestParams
Assert.assertEquals(null, packet.requestParams)
// test message decoding
// test for the length message
// test for the length message
packet.handleMessage(createArray(1, 0.toByte()))
Assert.assertEquals(true, packet.failed)
// everything ok :)
packet = DanaRS_Packet_General_Get_Today_Delivery_Total(aapsLogger, danaRPump)
packet.handleMessage(createArray(18, 0.toByte()))
Assert.assertEquals(false, packet.failed)

View file

@ -12,14 +12,11 @@ class DanaRS_Packet_General_Get_User_Time_Change_FlagTest : DanaRSTestBase() {
@Test fun runTest() {
var packet = DanaRS_Packet_General_Get_User_Time_Change_Flag(aapsLogger)
// test params
val testparams = packet.requestParams
Assert.assertEquals(null, packet.requestParams)
// test message decoding
// test for the length message
// test for the length message
packet.handleMessage(createArray(1, 0.toByte()))
Assert.assertEquals(true, packet.failed)
// everything ok :)
packet = DanaRS_Packet_General_Get_User_Time_Change_Flag(aapsLogger)
packet.handleMessage(createArray(18, 0.toByte()))
Assert.assertEquals(false, packet.failed)

View file

@ -12,14 +12,11 @@ class DanaRS_Packet_General_Initial_Screen_InformationTest : DanaRSTestBase() {
@Test fun runTest() {
var packet = DanaRS_Packet_General_Initial_Screen_Information(aapsLogger, danaRPump)
// test params
val testparams = packet.requestParams
Assert.assertEquals(null, packet.requestParams)
// test message decoding
// test for the length message
// test for the length message
packet.handleMessage(createArray(1, 0.toByte()))
Assert.assertEquals(true, packet.failed)
// everything ok :)
packet = DanaRS_Packet_General_Initial_Screen_Information(aapsLogger, danaRPump)
packet.handleMessage(createArray(17, 1.toByte()))
Assert.assertEquals(false, packet.failed)

View file

@ -18,7 +18,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
import info.nightscout.androidaps.queue.commands.Command
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.build.BuildHelper
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.junit.Assert