parent
55b90e57f2
commit
362a54b2c4
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.plugins.sync.nsclient
|
package info.nightscout.plugins.sync.nsclient
|
||||||
|
|
||||||
import app.aaps.shared.tests.TestBase
|
import app.aaps.shared.tests.TestBase
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.interfaces.receivers.ReceiverStatusStore
|
import info.nightscout.interfaces.receivers.ReceiverStatusStore
|
||||||
import info.nightscout.plugins.sync.R
|
import info.nightscout.plugins.sync.R
|
||||||
|
@ -8,7 +9,6 @@ import info.nightscout.rx.events.EventChargingState
|
||||||
import info.nightscout.rx.events.EventNetworkChange
|
import info.nightscout.rx.events.EventNetworkChange
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
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
|
||||||
|
@ -33,12 +33,12 @@ class ReceiverDelegateTest : TestBase() {
|
||||||
fun testCalculateStatusChargingState() {
|
fun testCalculateStatusChargingState() {
|
||||||
`when`(sp.getBoolean(R.string.key_ns_battery, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_battery, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_charging, true)).thenReturn(false)
|
`when`(sp.getBoolean(R.string.key_ns_charging, true)).thenReturn(false)
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventChargingState(false, 0)))
|
assertThat(sut.calculateStatus(EventChargingState(false, 0))).isTrue()
|
||||||
Assertions.assertFalse(sut.calculateStatus(EventChargingState(true, 0)))
|
assertThat(sut.calculateStatus(EventChargingState(true, 0))).isFalse()
|
||||||
`when`(sp.getBoolean(R.string.key_ns_battery, true)).thenReturn(false)
|
`when`(sp.getBoolean(R.string.key_ns_battery, true)).thenReturn(false)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_charging, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_charging, true)).thenReturn(true)
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventChargingState(true, 0)))
|
assertThat(sut.calculateStatus(EventChargingState(true, 0))).isTrue()
|
||||||
Assertions.assertFalse(sut.calculateStatus(EventChargingState(false, 0)))
|
assertThat(sut.calculateStatus(EventChargingState(false, 0))).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -47,41 +47,41 @@ class ReceiverDelegateTest : TestBase() {
|
||||||
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
||||||
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true))).isTrue()
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false))).isTrue()
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = true, wifiConnected = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = true, wifiConnected = true))).isTrue()
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = false, wifiConnected = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = false, wifiConnected = true))).isTrue()
|
||||||
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange()))
|
assertThat(sut.calculateStatus(EventNetworkChange())).isFalse()
|
||||||
|
|
||||||
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("test 1")
|
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("test 1")
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true))).isTrue()
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false))).isTrue()
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = true, wifiConnected = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = true, wifiConnected = true))).isTrue()
|
||||||
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = false, wifiConnected = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = false, wifiConnected = true))).isFalse()
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "test 1", mobileConnected = true, wifiConnected = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "test 1", mobileConnected = true, wifiConnected = true))).isTrue()
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "test 1", mobileConnected = false, wifiConnected = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "test 1", mobileConnected = false, wifiConnected = true))).isTrue()
|
||||||
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange()))
|
assertThat(sut.calculateStatus(EventNetworkChange())).isFalse()
|
||||||
|
|
||||||
`when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(false)
|
`when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(false)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(true)
|
||||||
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(wifiConnected = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(wifiConnected = true))).isTrue()
|
||||||
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange()))
|
assertThat(sut.calculateStatus(EventNetworkChange())).isFalse()
|
||||||
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange(mobileConnected = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true))).isFalse()
|
||||||
|
|
||||||
`when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(false)
|
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(false)
|
||||||
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false))).isTrue()
|
||||||
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true))).isFalse()
|
||||||
|
|
||||||
`when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(true)
|
||||||
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false))).isTrue()
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true))).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue