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;
|
||||
|
||||
|
@ -25,24 +24,24 @@ public class RFToolsParametrizedUTest {
|
|||
@Parameterized.Parameters
|
||||
public static Collection<Object[]> data() {
|
||||
return Arrays
|
||||
.asList(new Object[][] { //
|
||||
{ ByteUtil.createByteArrayFromCompactString("00"), ByteUtil.createByteArrayFromCompactString("5555") },
|
||||
.asList(new Object[][]{ //
|
||||
{ByteUtil.createByteArrayFromCompactString("00"), ByteUtil.createByteArrayFromCompactString("5555")},
|
||||
//
|
||||
{
|
||||
ByteUtil.createByteArrayFromCompactString("0000"),
|
||||
ByteUtil.createByteArrayFromCompactString("555555") }, //
|
||||
ByteUtil.createByteArrayFromCompactString("555555")}, //
|
||||
{
|
||||
ByteUtil.createByteArrayFromCompactString("A71289865D00BE"),
|
||||
ByteUtil.createByteArrayFromCompactString("A96C726996A694D5552CE5") }, //
|
||||
ByteUtil.createByteArrayFromCompactString("A96C726996A694D5552CE5")}, //
|
||||
{
|
||||
ByteUtil.createByteArrayFromCompactString("A7128986060015"),
|
||||
ByteUtil.createByteArrayFromCompactString("A96C726996A6566555C655") }, //
|
||||
ByteUtil.createByteArrayFromCompactString("A96C726996A6566555C655")}, //
|
||||
{
|
||||
ByteUtil.createByteArrayFromCompactString("A7128986150956"),
|
||||
ByteUtil.createByteArrayFromCompactString("A96C726996A6C655599665") }, //
|
||||
ByteUtil.createByteArrayFromCompactString("A96C726996A6C655599665")}, //
|
||||
{
|
||||
ByteUtil.createByteArrayFromCompactString("A71289868D00B0"),
|
||||
ByteUtil.createByteArrayFromCompactString("A96C726996A668D5552D55") }, //
|
||||
ByteUtil.createByteArrayFromCompactString("A96C726996A668D5552D55")}, //
|
||||
{
|
||||
ByteUtil
|
||||
.createByteArrayFromCompactString("A71289868D090337323200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000039"),
|
||||
|
@ -55,13 +54,15 @@ public class RFToolsParametrizedUTest {
|
|||
|
||||
@Parameterized.Parameter
|
||||
// first data value (0) is default
|
||||
public/* NOT private */byte[] decoded;
|
||||
public/* NOT private */ byte[] decoded;
|
||||
|
||||
@Parameterized.Parameter(1)
|
||||
public/* NOT private */byte[] encoded;
|
||||
public/* NOT private */ byte[] encoded;
|
||||
|
||||
|
||||
// @Test
|
||||
/**
|
||||
* @noinspection JUnit3StyleTestMethodInJUnit4Class, unused
|
||||
*/ // @Test
|
||||
public void testEncodeGeoff() {
|
||||
|
||||
Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(null);
|
||||
|
@ -88,8 +89,8 @@ public class RFToolsParametrizedUTest {
|
|||
// LOG.error("test: compare failed.");
|
||||
// }
|
||||
// testCompose(new byte[] {(byte)0xa7, (byte)0xa7});
|
||||
byte[] bs = decoder.encode4b6b(new byte[] { (byte)0xa7 });
|
||||
byte[] out = new byte[] { (byte)(0xa9), 0x65 };
|
||||
byte[] bs = decoder.encode4b6b(new byte[]{(byte) 0xa7});
|
||||
byte[] out = new byte[]{(byte) (0xa9), 0x65};
|
||||
if (ByteUtil.compare(bs, out) != 0) {
|
||||
Log.e(
|
||||
TAG,
|
||||
|
@ -97,8 +98,8 @@ public class RFToolsParametrizedUTest {
|
|||
+ ByteUtil.shortHexString(bs));
|
||||
Assert.fail();
|
||||
}
|
||||
bs = decoder.encode4b6b(new byte[] { (byte)0xa7, 0x12 });
|
||||
out = new byte[] { (byte)(0xa9), 0x6c, 0x72 };
|
||||
bs = decoder.encode4b6b(new byte[]{(byte) 0xa7, 0x12});
|
||||
out = new byte[]{(byte) (0xa9), 0x6c, 0x72};
|
||||
if (ByteUtil.compare(bs, out) != 0) {
|
||||
Log.e(
|
||||
TAG,
|
||||
|
@ -106,8 +107,8 @@ public class RFToolsParametrizedUTest {
|
|||
+ ByteUtil.shortHexString(bs));
|
||||
Assert.fail();
|
||||
}
|
||||
bs = decoder.encode4b6b(new byte[] { (byte)0xa7, 0x12, (byte)0xa7 });
|
||||
out = new byte[] { (byte)(0xa9), 0x6c, 0x72, (byte)0xa9, 0x65 };
|
||||
bs = decoder.encode4b6b(new byte[]{(byte) 0xa7, 0x12, (byte) 0xa7});
|
||||
out = new byte[]{(byte) (0xa9), 0x6c, 0x72, (byte) 0xa9, 0x65};
|
||||
if (ByteUtil.compare(bs, out) != 0) {
|
||||
Log.e(
|
||||
TAG,
|
||||
|
@ -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