Fix unit test, cleanup
This commit is contained in:
parent
41f51d26c0
commit
966939a9de
35 changed files with 36 additions and 37 deletions
|
@ -10,4 +10,4 @@ interface Medtrum {
|
||||||
fun clearAlarms(): PumpEnactResult // clear alarms
|
fun clearAlarms(): PumpEnactResult // clear alarms
|
||||||
fun deactivate(): PumpEnactResult // deactivate patch
|
fun deactivate(): PumpEnactResult // deactivate patch
|
||||||
fun updateTime(): PumpEnactResult // update time
|
fun updateTime(): PumpEnactResult // update time
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,7 +393,7 @@
|
||||||
<string name="carbs_g">CARBS %1$d g</string>
|
<string name="carbs_g">CARBS %1$d g</string>
|
||||||
<string name="extended_bolus_u_min">EXTENDED BOLUS %1$.2f U %2$d min</string>
|
<string name="extended_bolus_u_min">EXTENDED BOLUS %1$.2f U %2$d min</string>
|
||||||
<string name="load_events">LOAD EVENTS</string>
|
<string name="load_events">LOAD EVENTS</string>
|
||||||
<string name="clear_alarms">CLEAR_ALARMS</string>
|
<string name="clear_alarms">CLEAR ALARMS</string>
|
||||||
<string name="deactivate">DEACTIVATE</string>
|
<string name="deactivate">DEACTIVATE</string>
|
||||||
<string name="update_time">UPDATE TIME</string>
|
<string name="update_time">UPDATE TIME</string>
|
||||||
<string name="load_history">LOAD HISTORY %1$d</string>
|
<string name="load_history">LOAD HISTORY %1$d</string>
|
||||||
|
|
|
@ -14,4 +14,4 @@
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
@ -23,4 +23,4 @@ class OnSafeClickListener(
|
||||||
// Set duplicate click prevention time
|
// Set duplicate click prevention time
|
||||||
private const val MIN_CLICK_INTERVAL: Long = 1000
|
private const val MIN_CLICK_INTERVAL: Long = 1000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,4 +5,4 @@ enum class ConnectionState {
|
||||||
DISCONNECTED,
|
DISCONNECTED,
|
||||||
CONNECTING,
|
CONNECTING,
|
||||||
DISCONNECTING;
|
DISCONNECTING;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,4 +20,4 @@ enum class AlarmState {
|
||||||
BASE_FAULT, // Mapped from pump status 101
|
BASE_FAULT, // Mapped from pump status 101
|
||||||
BATTERY_OUT, // Mapped from pump status 102
|
BATTERY_OUT, // Mapped from pump status 102
|
||||||
NO_CALIBRATION // Mapped from pump status 103
|
NO_CALIBRATION // Mapped from pump status 103
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,7 +223,7 @@ class GetRecordPacket(injector: HasAndroidInjector, private val recordIndex: Int
|
||||||
var duration = (basalEndTime - basalStartTime)
|
var duration = (basalEndTime - basalStartTime)
|
||||||
// Work around for pumpSync not accepting 0 duration.
|
// Work around for pumpSync not accepting 0 duration.
|
||||||
// sometimes we get 0 duration for very short basal because the pump only reports time in seconds
|
// sometimes we get 0 duration for very short basal because the pump only reports time in seconds
|
||||||
if (duration < 250) duration = 250 // 250ms to make sure timestamp is unique
|
if (duration < 250) duration = 250 // 250ms to make sure AAPS accepts it
|
||||||
|
|
||||||
val newRecord = pumpSync.syncTemporaryBasalWithPumpId(
|
val newRecord = pumpSync.syncTemporaryBasalWithPumpId(
|
||||||
timestamp = basalStartTime,
|
timestamp = basalStartTime,
|
||||||
|
@ -306,4 +306,4 @@ class GetRecordPacket(injector: HasAndroidInjector, private val recordIndex: Int
|
||||||
|
|
||||||
return success
|
return success
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,4 +16,4 @@ private inline fun FragmentManager.transact(action: FragmentTransaction.() -> Un
|
||||||
beginTransaction().apply {
|
beginTransaction().apply {
|
||||||
action()
|
action()
|
||||||
}.commit()
|
}.commit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,7 +240,7 @@ class MedtrumService : DaggerService(), BLECommCallback {
|
||||||
|
|
||||||
fun loadEvents(): Boolean {
|
fun loadEvents(): Boolean {
|
||||||
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingpumpstatus)))
|
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingpumpstatus)))
|
||||||
// Sync records (based on the info we have from the sync)
|
// Sync records
|
||||||
val result = syncRecords()
|
val result = syncRecords()
|
||||||
if (result) {
|
if (result) {
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Events loaded")
|
aapsLogger.debug(LTag.PUMPCOMM, "Events loaded")
|
||||||
|
|
|
@ -54,4 +54,4 @@ abstract class MedtrumBaseActivity<B : ViewDataBinding> : DaggerAppCompatActivit
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,4 +63,4 @@ abstract class MedtrumBaseFragment<B : ViewDataBinding> : DaggerFragment(), Medt
|
||||||
override fun finish(finishAffinity: Boolean) {
|
override fun finish(finishAffinity: Boolean) {
|
||||||
baseActivity?.finish(finishAffinity)
|
baseActivity?.finish(finishAffinity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,4 +4,4 @@ interface MedtrumBaseNavigator {
|
||||||
fun back()
|
fun back()
|
||||||
|
|
||||||
fun finish(finishAffinity: Boolean = false)
|
fun finish(finishAffinity: Boolean = false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,4 +61,4 @@ class MedtrumOverviewFragment : MedtrumBaseFragment<FragmentMedtrumOverviewBindi
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,4 +26,4 @@ open class SingleLiveEvent<T> : MutableLiveData<T>() {
|
||||||
fun call() {
|
fun call() {
|
||||||
value = null
|
value = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,4 +187,3 @@ class MedtrumOverviewViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,7 @@ class MedtrumViewModel @Inject constructor(
|
||||||
when (newPatchStep) {
|
when (newPatchStep) {
|
||||||
PatchStep.CANCEL -> {
|
PatchStep.CANCEL -> {
|
||||||
if (oldPatchStep !in listOf(
|
if (oldPatchStep !in listOf(
|
||||||
|
PatchStep.PREPARE_PATCH,
|
||||||
PatchStep.START_DEACTIVATION,
|
PatchStep.START_DEACTIVATION,
|
||||||
PatchStep.DEACTIVATE,
|
PatchStep.DEACTIVATE,
|
||||||
PatchStep.FORCE_DEACTIVATION,
|
PatchStep.FORCE_DEACTIVATION,
|
||||||
|
@ -148,7 +149,6 @@ class MedtrumViewModel @Inject constructor(
|
||||||
) {
|
) {
|
||||||
medtrumService?.disconnect("Cancel")
|
medtrumService?.disconnect("Cancel")
|
||||||
}
|
}
|
||||||
medtrumService?.disconnect("Cancel")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PatchStep.COMPLETE -> {
|
PatchStep.COMPLETE -> {
|
||||||
|
|
|
@ -37,4 +37,4 @@ class ViewModelFactory @Inject constructor(private val creators: Map<Class<out V
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,4 +47,4 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -77,4 +77,4 @@
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -76,4 +76,4 @@
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -91,4 +91,4 @@
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -78,4 +78,4 @@
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -89,4 +89,4 @@
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -106,4 +106,4 @@
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -106,4 +106,4 @@
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -93,4 +93,4 @@
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -93,4 +93,4 @@
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -104,4 +104,4 @@
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -90,4 +90,4 @@
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -63,4 +63,4 @@
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -88,4 +88,4 @@
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -104,4 +104,4 @@ class ProfileStoreObject(val injector: HasAndroidInjector, override val data: JS
|
||||||
.map { profileName -> getSpecificProfile(profileName.toString()) }
|
.map { profileName -> getSpecificProfile(profileName.toString()) }
|
||||||
.map { pureProfile -> pureProfile?.let { ProfileSealed.Pure(pureProfile).isValid("allProfilesValid", activePlugin.activePump, config, rh, rxBus, hardLimits, false) } }
|
.map { pureProfile -> pureProfile?.let { ProfileSealed.Pure(pureProfile).isValid("allProfilesValid", activePlugin.activePump, config, rh, rxBus, hardLimits, false) } }
|
||||||
.all { it?.isValid == true }
|
.all { it?.isValid == true }
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,4 +59,4 @@ class GetRecordPacketTest : MedtrumTestBase() {
|
||||||
assertEquals(false, result)
|
assertEquals(false, result)
|
||||||
assertEquals(true, packet.failed)
|
assertEquals(true, packet.failed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,4 +88,4 @@ class NotificationPacketTest : MedtrumTestBase() {
|
||||||
assertEquals(1.65, medtrumPump.bolusingTreatment!!.insulin, 0.01)
|
assertEquals(1.65, medtrumPump.bolusingTreatment!!.insulin, 0.01)
|
||||||
assertEquals(161.95, medtrumPump.reservoir, 0.01)
|
assertEquals(161.95, medtrumPump.reservoir, 0.01)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,10 +93,10 @@ class SynchronizePacketTest : MedtrumTestBase() {
|
||||||
assertEquals(25, packet.medtrumPump.lastBasalSequence)
|
assertEquals(25, packet.medtrumPump.lastBasalSequence)
|
||||||
assertEquals(14, packet.medtrumPump.lastBasalPatchId)
|
assertEquals(14, packet.medtrumPump.lastBasalPatchId)
|
||||||
assertEquals(1685126612000, packet.medtrumPump.lastBasalStartTime)
|
assertEquals(1685126612000, packet.medtrumPump.lastBasalStartTime)
|
||||||
|
assertEquals(8123, packet.medtrumPump.patchAge)
|
||||||
assertEquals(186.80, packet.medtrumPump.reservoir, 0.01)
|
assertEquals(186.80, packet.medtrumPump.reservoir, 0.01)
|
||||||
assertEquals(296585720, packet.medtrumPump.patchAge)
|
assertEquals(1685120120000, packet.medtrumPump.patchStartTime)
|
||||||
assertEquals(5.96875, packet.medtrumPump.batteryVoltage_A, 0.01)
|
assertEquals(5.96875, packet.medtrumPump.batteryVoltage_A, 0.01)
|
||||||
assertEquals(2.8125, packet.medtrumPump.batteryVoltage_B, 0.01)
|
assertEquals(2.8125, packet.medtrumPump.batteryVoltage_B, 0.01)
|
||||||
assertEquals(1388542523000, packet.medtrumPump.patchStartTime)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue