parent
e7f1cb0be6
commit
c2dc844286
1 changed files with 15 additions and 15 deletions
|
@ -2,6 +2,7 @@ package info.nightscout.plugins.aps.loop
|
||||||
|
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
|
@ -25,7 +26,6 @@ import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import info.nightscout.shared.utils.DateUtil
|
import info.nightscout.shared.utils.DateUtil
|
||||||
import info.nightscout.sharedtests.TestBase
|
import info.nightscout.sharedtests.TestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -74,28 +74,28 @@ class LoopPluginTest : TestBase() {
|
||||||
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
|
`when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.name)).thenReturn(ApsMode.CLOSED.name)
|
||||||
val pumpDescription = PumpDescription()
|
val pumpDescription = PumpDescription()
|
||||||
`when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription)
|
`when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription)
|
||||||
Assertions.assertEquals(LoopFragment::class.java.name, loopPlugin.pluginDescription.fragmentClass)
|
assertThat(loopPlugin.pluginDescription.fragmentClass).isEqualTo(LoopFragment::class.java.name)
|
||||||
Assertions.assertEquals(PluginType.LOOP, loopPlugin.getType())
|
assertThat(loopPlugin.getType()).isEqualTo(PluginType.LOOP)
|
||||||
Assertions.assertEquals("Loop", loopPlugin.name)
|
assertThat(loopPlugin.name).isEqualTo("Loop")
|
||||||
Assertions.assertEquals("LOOP", loopPlugin.nameShort)
|
assertThat(loopPlugin.nameShort).isEqualTo("LOOP")
|
||||||
Assertions.assertEquals(true, loopPlugin.hasFragment())
|
assertThat(loopPlugin.hasFragment()).isTrue()
|
||||||
Assertions.assertEquals(true, loopPlugin.showInList(PluginType.LOOP))
|
assertThat(loopPlugin.showInList(PluginType.LOOP)).isTrue()
|
||||||
Assertions.assertEquals(info.nightscout.plugins.aps.R.xml.pref_loop.toLong(), loopPlugin.preferencesId.toLong())
|
assertThat(loopPlugin.preferencesId.toLong()).isEqualTo(info.nightscout.plugins.aps.R.xml.pref_loop.toLong())
|
||||||
|
|
||||||
// Plugin is disabled by default
|
// Plugin is disabled by default
|
||||||
Assertions.assertEquals(false, loopPlugin.isEnabled())
|
assertThat(loopPlugin.isEnabled()).isFalse()
|
||||||
loopPlugin.setPluginEnabled(PluginType.LOOP, true)
|
loopPlugin.setPluginEnabled(PluginType.LOOP, true)
|
||||||
Assertions.assertEquals(true, loopPlugin.isEnabled())
|
assertThat(loopPlugin.isEnabled()).isTrue()
|
||||||
|
|
||||||
// No temp basal capable pump should disable plugin
|
// No temp basal capable pump should disable plugin
|
||||||
virtualPumpPlugin.pumpDescription.isTempBasalCapable = false
|
virtualPumpPlugin.pumpDescription.isTempBasalCapable = false
|
||||||
Assertions.assertEquals(false, loopPlugin.isEnabled())
|
assertThat(loopPlugin.isEnabled()).isFalse()
|
||||||
virtualPumpPlugin.pumpDescription.isTempBasalCapable = true
|
virtualPumpPlugin.pumpDescription.isTempBasalCapable = true
|
||||||
|
|
||||||
// Fragment is hidden by default
|
// Fragment is hidden by default
|
||||||
Assertions.assertEquals(false, loopPlugin.isFragmentVisible())
|
assertThat(loopPlugin.isFragmentVisible()).isFalse()
|
||||||
loopPlugin.setFragmentVisible(PluginType.LOOP, true)
|
loopPlugin.setFragmentVisible(PluginType.LOOP, true)
|
||||||
Assertions.assertEquals(true, loopPlugin.isFragmentVisible())
|
assertThat(loopPlugin.isFragmentVisible()).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *********** not working
|
/* *********** not working
|
||||||
|
@ -118,7 +118,7 @@ class LoopPluginTest : TestBase() {
|
||||||
MockedLoopPlugin mockedLoopPlugin = new MockedLoopPlugin();
|
MockedLoopPlugin mockedLoopPlugin = new MockedLoopPlugin();
|
||||||
Treatment t = new Treatment();
|
Treatment t = new Treatment();
|
||||||
bus.post(new EventTreatmentChange(t));
|
bus.post(new EventTreatmentChange(t));
|
||||||
Assertions.assertEquals(true, mockedLoopPlugin.invokeCalled);
|
assertThat(mockedLoopPlugin.invokeCalled).isTrue();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue