Elements tests
This commit is contained in:
parent
d7ed61de0c
commit
6f2ba7c135
|
@ -14,7 +14,7 @@ class InputBg(injector: HasAndroidInjector) : Element(injector) {
|
|||
|
||||
var units = Constants.MGDL
|
||||
var value = 0.0
|
||||
private var minValue = 0.0
|
||||
var minValue = 0.0
|
||||
private var maxValue = 0.0
|
||||
private var step = 0.0
|
||||
private var decimalFormat: DecimalFormat? = null
|
||||
|
@ -35,6 +35,11 @@ class InputBg(injector: HasAndroidInjector) : Element(injector) {
|
|||
root.addView(numberPicker)
|
||||
}
|
||||
|
||||
fun setValue(value: Double) : InputBg {
|
||||
this.value = value
|
||||
return this
|
||||
}
|
||||
|
||||
fun setUnits(units: String): InputBg {
|
||||
if (units == Constants.MMOL) {
|
||||
minValue = MMOL_MIN
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class})
|
||||
public class ComparatorExistsTest {
|
||||
|
||||
@Test
|
||||
public void labelsTest() {
|
||||
Assert.assertEquals(2, ComparatorExists.Compare.labels().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSetValueTest() {
|
||||
ComparatorExists c = new ComparatorExists().setValue(ComparatorExists.Compare.NOT_EXISTS);
|
||||
Assert.assertEquals(ComparatorExists.Compare.NOT_EXISTS, c.getValue());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void prepare() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockStrings();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class ComparatorExistsTest : TriggerTestBase() {
|
||||
|
||||
@Test fun labelsTest() {
|
||||
Assert.assertEquals(2, ComparatorExists.Compare.labels(resourceHelper).size)
|
||||
}
|
||||
|
||||
@Test fun setValueTest() {
|
||||
val c = ComparatorExists(injector)
|
||||
c.value = ComparatorExists.Compare.NOT_EXISTS
|
||||
Assert.assertEquals(ComparatorExists.Compare.NOT_EXISTS, c.value)
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class})
|
||||
public class ComparatorTest {
|
||||
|
||||
@Test
|
||||
public void checkTest() {
|
||||
Assert.assertTrue(Comparator.Compare.IS_EQUAL.check(1, 1));
|
||||
Assert.assertTrue(Comparator.Compare.IS_LESSER.check(1, 2));
|
||||
Assert.assertTrue(Comparator.Compare.IS_EQUAL_OR_LESSER.check(1, 2));
|
||||
Assert.assertTrue(Comparator.Compare.IS_EQUAL_OR_LESSER.check(2, 2));
|
||||
Assert.assertTrue(Comparator.Compare.IS_GREATER.check(2, 1));
|
||||
Assert.assertTrue(Comparator.Compare.IS_EQUAL_OR_GREATER.check(2, 1));
|
||||
Assert.assertTrue(Comparator.Compare.IS_EQUAL_OR_GREATER.check(2, 2));
|
||||
|
||||
Assert.assertFalse(Comparator.Compare.IS_LESSER.check(2, 1));
|
||||
Assert.assertFalse(Comparator.Compare.IS_EQUAL_OR_LESSER.check(2, 1));
|
||||
Assert.assertFalse(Comparator.Compare.IS_GREATER.check(1, 2));
|
||||
Assert.assertFalse(Comparator.Compare.IS_EQUAL_OR_GREATER.check(1, 2));
|
||||
|
||||
Assert.assertTrue(Comparator.Compare.IS_NOT_AVAILABLE.check(1, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void labelsTest() {
|
||||
Assert.assertEquals(6, Comparator.Compare.labels().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSetValueTest() {
|
||||
Comparator c = new Comparator().setValue(Comparator.Compare.IS_EQUAL_OR_GREATER);
|
||||
Assert.assertEquals(Comparator.Compare.IS_EQUAL_OR_GREATER, c.getValue());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void prepare() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockStrings();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class ComparatorTest : TriggerTestBase() {
|
||||
|
||||
@Test
|
||||
fun checkTest() {
|
||||
Assert.assertTrue(Comparator.Compare.IS_EQUAL.check(1, 1))
|
||||
Assert.assertTrue(Comparator.Compare.IS_LESSER.check(1, 2))
|
||||
Assert.assertTrue(Comparator.Compare.IS_EQUAL_OR_LESSER.check(1, 2))
|
||||
Assert.assertTrue(Comparator.Compare.IS_EQUAL_OR_LESSER.check(2, 2))
|
||||
Assert.assertTrue(Comparator.Compare.IS_GREATER.check(2, 1))
|
||||
Assert.assertTrue(Comparator.Compare.IS_EQUAL_OR_GREATER.check(2, 1))
|
||||
Assert.assertTrue(Comparator.Compare.IS_EQUAL_OR_GREATER.check(2, 2))
|
||||
Assert.assertFalse(Comparator.Compare.IS_LESSER.check(2, 1))
|
||||
Assert.assertFalse(Comparator.Compare.IS_EQUAL_OR_LESSER.check(2, 1))
|
||||
Assert.assertFalse(Comparator.Compare.IS_GREATER.check(1, 2))
|
||||
Assert.assertFalse(Comparator.Compare.IS_EQUAL_OR_GREATER.check(1, 2))
|
||||
// Assert.assertTrue(Comparator.Compare.IS_NOT_AVAILABLE.check<Int?>(1, null))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun labelsTest() {
|
||||
Assert.assertEquals(6, Comparator.Compare.labels(resourceHelper).size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun setValueTest() {
|
||||
val c: Comparator = Comparator(injector).setValue(Comparator.Compare.IS_EQUAL_OR_GREATER)
|
||||
Assert.assertEquals(Comparator.Compare.IS_EQUAL_OR_GREATER, c.value)
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, ProfileFunctions.class})
|
||||
public class InputBgTest {
|
||||
|
||||
@Test
|
||||
public void getSetValueTest() {
|
||||
InputBg i = new InputBg().setUnits(Constants.MMOL).setValue(5d);
|
||||
Assert.assertEquals(5d, i.getValue(), 0.01d);
|
||||
Assert.assertEquals(InputBg.MMOL_MIN, i.minValue, 0.01d);
|
||||
i = new InputBg().setValue(100d).setUnits(Constants.MGDL);
|
||||
Assert.assertEquals(100d, i.getValue(), 0.01d);
|
||||
Assert.assertEquals(InputBg.MGDL_MIN, i.minValue, 0.01d);
|
||||
Assert.assertEquals(Constants.MGDL, i.getUnits());
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void prepare() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockStrings();
|
||||
AAPSMocker.mockProfileFunctions();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(ProfileFunctions::class)
|
||||
class InputBgTest : TriggerTestBase() {
|
||||
|
||||
@Test
|
||||
fun setValueTest() {
|
||||
var i: InputBg = InputBg(injector).setUnits(Constants.MMOL).setValue(5.0)
|
||||
Assert.assertEquals(5.0, i.value, 0.01)
|
||||
Assert.assertEquals(InputBg.MMOL_MIN, i.minValue, 0.01)
|
||||
i = InputBg(injector).setValue(100.0).setUnits(Constants.MGDL)
|
||||
Assert.assertEquals(100.0, i.value, 0.01)
|
||||
Assert.assertEquals(InputBg.MGDL_MIN, i.minValue, 0.01)
|
||||
Assert.assertEquals(Constants.MGDL, i.units)
|
||||
}
|
||||
|
||||
@Before
|
||||
fun prepare() {
|
||||
`when`(profileFunction.getUnits()).thenReturn(Constants.MGDL)
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class})
|
||||
public class InputDurationTest {
|
||||
|
||||
@Test
|
||||
public void getSetValueTest() {
|
||||
InputDuration i = new InputDuration(5, InputDuration.TimeUnit.MINUTES);
|
||||
Assert.assertEquals(5, i.getValue(), 0.01d);
|
||||
Assert.assertEquals(InputDuration.TimeUnit.MINUTES, i.getUnit());
|
||||
i = i = new InputDuration(5, InputDuration.TimeUnit.HOURS);
|
||||
Assert.assertEquals(5d, i.getValue(), 0.01d);
|
||||
Assert.assertEquals(InputDuration.TimeUnit.HOURS, i.getUnit());
|
||||
Assert.assertEquals(5 * 60, i.getMinutes());
|
||||
i.setMinutes(60);
|
||||
Assert.assertEquals(1, i.getValue(), 0.01d);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class InputDurationTest : TriggerTestBase() {
|
||||
|
||||
@Test fun setValueTest() {
|
||||
var i = InputDuration(injector, 5, InputDuration.TimeUnit.MINUTES)
|
||||
Assert.assertEquals(5, i.value)
|
||||
Assert.assertEquals(InputDuration.TimeUnit.MINUTES, i.unit)
|
||||
i = InputDuration(injector, 5, InputDuration.TimeUnit.HOURS)
|
||||
Assert.assertEquals(5, i.value)
|
||||
Assert.assertEquals(InputDuration.TimeUnit.HOURS, i.unit)
|
||||
Assert.assertEquals(5 * 60, i.getMinutes())
|
||||
i.setMinutes(60)
|
||||
Assert.assertEquals(1, i.value)
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class})
|
||||
public class InputInsulinTest {
|
||||
|
||||
@Test
|
||||
public void textWatcherTest() {
|
||||
InputInsulin t = new InputInsulin().setValue(30d);
|
||||
t.textWatcher.beforeTextChanged(null, 0, 0, 0);
|
||||
t.textWatcher.onTextChanged(null, 0, 0, 0);
|
||||
t.textWatcher.afterTextChanged(null);
|
||||
Assert.assertEquals(20d, t.getValue(), 0.01d);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSetValueTest() {
|
||||
InputInsulin i = new InputInsulin().setValue(5d);
|
||||
Assert.assertEquals(5d, i.getValue(), 0.01d);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class InputInsulinTest : TriggerTestBase() {
|
||||
|
||||
@Test fun setValueTest() {
|
||||
val i = InputInsulin(injector)
|
||||
i.value = 5.0
|
||||
Assert.assertEquals(5.0, i.value, 0.01)
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class})
|
||||
public class InputPercentTest {
|
||||
|
||||
@Test
|
||||
public void textWatcherTest() {
|
||||
InputPercent t = new InputPercent().setValue(530d);
|
||||
t.textWatcher.beforeTextChanged(null, 0, 0, 0);
|
||||
t.textWatcher.onTextChanged(null, 0, 0, 0);
|
||||
t.textWatcher.afterTextChanged(null);
|
||||
Assert.assertEquals(130d, t.getValue(), 0.01d);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSetValueTest() {
|
||||
InputPercent i = new InputPercent().setValue(10d);
|
||||
Assert.assertEquals(10d, i.getValue(), 0.01d);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class InputPercentTest : TriggerTestBase() {
|
||||
|
||||
@Test fun setValueTest() {
|
||||
val i = InputPercent(injector)
|
||||
i.value = 10.0
|
||||
Assert.assertEquals(10.0, i.value, 0.01)
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, TreatmentsPlugin.class, ProfileFunctions.class})
|
||||
public class InputProfileNameTest {
|
||||
String profileName = "Test";
|
||||
InputProfileName inputProfileName = new InputProfileName(profileName);
|
||||
|
||||
@Test
|
||||
public void getSetValue() {
|
||||
inputProfileName = new InputProfileName("Test");
|
||||
Assert.assertEquals("Test", inputProfileName.getValue());
|
||||
inputProfileName.setValue("Test2");
|
||||
Assert.assertEquals("Test2", inputProfileName.getValue());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.utils.SP
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class InputProfileNameTest : TriggerTestBase() {
|
||||
|
||||
@Test fun setValue() {
|
||||
val inputProfileName = InputProfileName(injector, "Test")
|
||||
Assert.assertEquals("Test", inputProfileName.value)
|
||||
inputProfileName.value = "Test2"
|
||||
Assert.assertEquals("Test2", inputProfileName.value)
|
||||
}
|
||||
}
|
|
@ -1,155 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements;
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class})
|
||||
public class InputStringTest {
|
||||
|
||||
@Test
|
||||
public void textWatcherTest() {
|
||||
InputString t = new InputString().setValue("asd");
|
||||
t.textWatcher.beforeTextChanged(null, 0, 0, 0);
|
||||
t.textWatcher.onTextChanged(null, 0, 0, 0);
|
||||
t.textWatcher.afterTextChanged(new Editable() {
|
||||
@Override
|
||||
public Editable replace(int st, int en, CharSequence source, int start, int end) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editable replace(int st, int en, CharSequence text) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editable insert(int where, CharSequence text, int start, int end) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editable insert(int where, CharSequence text) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editable delete(int st, int en) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editable append(CharSequence text) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editable append(CharSequence text, int start, int end) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editable append(char text) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearSpans() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilters(InputFilter[] filters) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputFilter[] getFilters() {
|
||||
return new InputFilter[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getChars(int start, int end, char[] dest, int destoff) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpan(Object what, int start, int end, int flags) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSpan(Object what) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] getSpans(int start, int end, Class<T> type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpanStart(Object tag) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpanEnd(Object tag) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpanFlags(Object tag) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextSpanTransition(int start, int limit, Class type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char charAt(int index) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence subSequence(int start, int end) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "qwerty";
|
||||
}
|
||||
});
|
||||
Assert.assertEquals("qwerty", t.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSetValueTest() {
|
||||
InputString i = new InputString().setValue("asd");
|
||||
Assert.assertEquals("asd", i.getValue());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class InputStringTest : TriggerTestBase() {
|
||||
|
||||
@Test fun setValueTest() {
|
||||
val i = InputString(injector)
|
||||
i.value = "asd"
|
||||
Assert.assertEquals("asd", i.value)
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, ProfileFunctions.class})
|
||||
public class InputTempTargetTest {
|
||||
|
||||
@Test
|
||||
public void getSetValueTest() {
|
||||
InputTempTarget i = new InputTempTarget().setUnits(Constants.MMOL).setValue(5d);
|
||||
Assert.assertEquals(5d, i.getValue(), 0.01d);
|
||||
Assert.assertEquals(Constants.MIN_TT_MMOL, i.minValue, 0.01d);
|
||||
i = new InputTempTarget().setValue(100d).setUnits(Constants.MGDL);
|
||||
Assert.assertEquals(100d, i.getValue(), 0.01d);
|
||||
Assert.assertEquals(Constants.MIN_TT_MGDL, i.minValue, 0.01d);
|
||||
Assert.assertEquals(Constants.MGDL, i.getUnits());
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void prepare() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockStrings();
|
||||
AAPSMocker.mockProfileFunctions();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class InputTempTargetTest : TriggerTestBase() {
|
||||
|
||||
@Test fun setValueTest() {
|
||||
val i = InputTempTarget(injector)
|
||||
i.units = Constants.MMOL
|
||||
i.value = 5.0
|
||||
Assert.assertEquals(5.0, i.value, 0.01)
|
||||
i.units = Constants.MGDL
|
||||
i.value = 100.0
|
||||
Assert.assertEquals(100.0, i.value, 0.01)
|
||||
Assert.assertEquals(Constants.MGDL, i.units)
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
public class LabelWithElementTest {
|
||||
|
||||
@Test
|
||||
public void constructorTest() {
|
||||
LabelWithElement l = new LabelWithElement("A", "B", new InputInsulin());
|
||||
Assert.assertEquals("A", l.textPre);
|
||||
Assert.assertEquals("B", l.textPost);
|
||||
Assert.assertEquals(InputInsulin.class, l.element.getClass());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class LabelWithElementTest : TriggerTestBase() {
|
||||
|
||||
@Test
|
||||
fun constructorTest() {
|
||||
val l = LabelWithElement(injector, "A", "B", InputInsulin(injector))
|
||||
Assert.assertEquals("A", l.textPre)
|
||||
Assert.assertEquals("B", l.textPost)
|
||||
Assert.assertEquals(InputInsulin::class.java, l.element!!.javaClass)
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class})
|
||||
public class StaticLabelTest {
|
||||
|
||||
@Test
|
||||
public void constructor() {
|
||||
StaticLabel sl = new StaticLabel("any");
|
||||
Assert.assertEquals("any", sl.label);
|
||||
|
||||
sl = new StaticLabel(R.string.pumplimit);
|
||||
Assert.assertEquals(MainApp.gs(R.string.pumplimit), sl.label);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void prepareTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockStrings();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerDummy
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class StaticLabelTest : TriggerTestBase() {
|
||||
|
||||
@Test fun constructor() {
|
||||
var sl = StaticLabel(injector, "any", TriggerDummy(injector))
|
||||
Assert.assertEquals("any", sl.label)
|
||||
`when`(resourceHelper.gs(R.string.pumplimit)).thenReturn("pump limit")
|
||||
sl = StaticLabel(injector, R.string.pumplimit, TriggerDummy(injector))
|
||||
Assert.assertEquals("pump limit", sl.label)
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import info.nightscout.androidaps.logging.AAPSLogger
|
|||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputBg
|
||||
import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
|
@ -52,6 +53,9 @@ open class TriggerTestBase : TestBase() {
|
|||
it.aapsLogger = aapsLogger
|
||||
it.iobCobCalculatorPlugin = iobCobCalculatorPlugin
|
||||
}
|
||||
if (it is StaticLabel) {
|
||||
it.resourceHelper = resourceHelper
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue