shared-tests #14
This commit is contained in:
parent
22c1f8f166
commit
593af85b57
8 changed files with 96 additions and 170 deletions
|
@ -20,4 +20,6 @@ dependencies {
|
|||
implementation project(':core:ui')
|
||||
implementation project(':pump:pump-common')
|
||||
implementation project(':pump:pump-core')
|
||||
|
||||
testImplementation project(':app-wear-shared:shared-tests')
|
||||
}
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
package info.nightscout.androidaps
|
||||
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.TestAapsSchedulers
|
||||
import info.nightscout.rx.logging.AAPSLoggerTest
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.junit.jupiter.MockitoExtension
|
||||
import org.mockito.junit.jupiter.MockitoSettings
|
||||
import org.mockito.quality.Strictness
|
||||
import java.util.Locale
|
||||
|
||||
@ExtendWith(MockitoExtension::class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
open class TestBase {
|
||||
|
||||
val aapsLogger = AAPSLoggerTest()
|
||||
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
|
||||
|
||||
@BeforeEach
|
||||
fun setupLocale() {
|
||||
Locale.setDefault(Locale.ENGLISH)
|
||||
System.setProperty("disableFirebase", "true")
|
||||
}
|
||||
|
||||
// Workaround for Kotlin nullability.
|
||||
// https://medium.com/@elye.project/befriending-kotlin-and-mockito-1c2e7b0ef791
|
||||
// https://stackoverflow.com/questions/30305217/is-it-possible-to-use-mockito-in-kotlin
|
||||
fun <T> anyObject(): T {
|
||||
Mockito.any<T>()
|
||||
return uninitialized()
|
||||
}
|
||||
|
||||
@Suppress("Unchecked_Cast")
|
||||
fun <T> uninitialized(): T = null as T
|
||||
}
|
|
@ -1,98 +1,98 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble
|
||||
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkFirmwareVersion
|
||||
import org.junit.Assert
|
||||
import info.nightscout.sharedtests.TestBase
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class RFSpyTest : TestBase() {
|
||||
@Suppress("SpellCheckingInspection") class RFSpyTest : TestBase() {
|
||||
|
||||
@Test fun testGetFirmwareVersion() {
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_1_0,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.0")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_1_x,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.1")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_1_x,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.1.13")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_2_0,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.0")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_2_0,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.0.1")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_2_2,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_2_2,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2.16")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_2_2,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2.17")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_2_x,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_2_x,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3.0")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_2_x,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3.17")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_3_x,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.0")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_3_x,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.0.1")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_3_x,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.1")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_3_x,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.1.13")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_4_x,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.0")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_4_x,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.0.4")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_4_x,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.3")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.Version_4_x,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.5.7")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.UnknownVersion,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.0")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.UnknownVersion,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.0.0")
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
RileyLinkFirmwareVersion.UnknownVersion,
|
||||
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.5.5")
|
||||
)
|
||||
|
|
|
@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble;
|
|||
import android.util.Log;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
|
@ -61,7 +60,9 @@ public class RFToolsParametrizedUTest {
|
|||
public/* NOT private */ byte[] encoded;
|
||||
|
||||
|
||||
// @Test
|
||||
/**
|
||||
* @noinspection JUnit3StyleTestMethodInJUnit4Class, unused
|
||||
*/ // @Test
|
||||
public void testEncodeGeoff() {
|
||||
|
||||
Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(null);
|
||||
|
@ -119,8 +120,9 @@ public class RFToolsParametrizedUTest {
|
|||
}
|
||||
|
||||
|
||||
|
||||
// @Test
|
||||
/**
|
||||
* @noinspection JUnit3StyleTestMethodInJUnit4Class, unused
|
||||
*/ // @Test
|
||||
public void testParametrizedGeoffEncode() {
|
||||
|
||||
Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(null);
|
||||
|
@ -135,7 +137,9 @@ public class RFToolsParametrizedUTest {
|
|||
}
|
||||
|
||||
|
||||
// @Test
|
||||
/**
|
||||
* @noinspection unused
|
||||
*/ // @Test
|
||||
public void geoffDecode() throws Exception {
|
||||
Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(null);
|
||||
|
||||
|
@ -145,7 +149,9 @@ public class RFToolsParametrizedUTest {
|
|||
}
|
||||
|
||||
|
||||
// @Test
|
||||
/**
|
||||
* @noinspection unused
|
||||
*/ // @Test
|
||||
public void geoffEncode() {
|
||||
|
||||
Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(null);
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
|
||||
/**
|
||||
* Created by andy on 11/21/18.
|
||||
*/
|
||||
|
||||
public class RFToolsUTest {
|
||||
@Disabled
|
||||
class RFToolsUTest {
|
||||
|
||||
private static final String TAG = "RFToolsUTest";
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncodeGeoff() {
|
||||
//@Test
|
||||
void testEncodeGeoff() {
|
||||
// /*
|
||||
// * {0xa7} -> {0xa9, 0x60}
|
||||
// * {0xa7, 0x12} -> {0xa9, 0x6c, 0x72}
|
||||
|
@ -66,8 +64,8 @@ public class RFToolsUTest {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncodeGo() {
|
||||
//@Test
|
||||
void testEncodeGo() {
|
||||
// /*
|
||||
// * {0xa7} -> {0xa9, 0x60}
|
||||
// * {0xa7, 0x12} -> {0xa9, 0x6c, 0x72}
|
||||
|
@ -126,8 +124,8 @@ public class RFToolsUTest {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDecodeGo() {
|
||||
//@Test
|
||||
void testDecodeGo() {
|
||||
|
||||
// // testCompose(new byte[] {(byte)0xa7, (byte)0xa7});
|
||||
// byte[] bs = RFTools.encode4b6b(new byte[] { (byte)0xa7 });
|
||||
|
@ -187,12 +185,11 @@ public class RFToolsUTest {
|
|||
// Assert.fail();
|
||||
// }
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void ttt_decodeGo() {
|
||||
//@Test
|
||||
void ttt_decodeGo() {
|
||||
|
||||
// RFTools.DecodeResponseDto decodeResponseDto = RFTools
|
||||
// .decode4b6b_go(new byte[] {
|
||||
|
@ -208,11 +205,4 @@ public class RFToolsUTest {
|
|||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void goTest() {
|
||||
// System.out.println(RFTools.hi(4, (short)0xa7));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,4 +23,6 @@ dependencies {
|
|||
implementation project(':core:main')
|
||||
implementation project(':core:ui')
|
||||
implementation project(':core:utils')
|
||||
|
||||
testImplementation project(':app-wear-shared:shared-tests')
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package info.nightscout.androidaps
|
||||
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.TestAapsSchedulers
|
||||
import info.nightscout.rx.logging.AAPSLoggerTest
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.junit.jupiter.MockitoExtension
|
||||
import org.mockito.junit.jupiter.MockitoSettings
|
||||
import org.mockito.quality.Strictness
|
||||
import java.util.Locale
|
||||
|
||||
@ExtendWith(MockitoExtension::class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
open class TestBase {
|
||||
|
||||
val aapsLogger = AAPSLoggerTest()
|
||||
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
|
||||
|
||||
@BeforeEach
|
||||
fun setupLocale() {
|
||||
Locale.setDefault(Locale.ENGLISH)
|
||||
System.setProperty("disableFirebase", "true")
|
||||
}
|
||||
|
||||
// Workaround for Kotlin nullability.
|
||||
// https://medium.com/@elye.project/befriending-kotlin-and-mockito-1c2e7b0ef791
|
||||
// https://stackoverflow.com/questions/30305217/is-it-possible-to-use-mockito-in-kotlin
|
||||
fun <T> anyObject(): T {
|
||||
Mockito.any<T>()
|
||||
return uninitialized()
|
||||
}
|
||||
|
||||
@Suppress("Unchecked_Cast")
|
||||
fun <T> uninitialized(): T = null as T
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package info.nightscout.pump.virtual
|
||||
|
||||
import dagger.android.AndroidInjector
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||
|
@ -14,6 +13,7 @@ import info.nightscout.rx.bus.RxBus
|
|||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import info.nightscout.sharedtests.TestBase
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
|
|
Loading…
Reference in a new issue