fix tests
This commit is contained in:
parent
58da7fc854
commit
1c8aae9757
5 changed files with 20 additions and 17 deletions
|
@ -219,14 +219,16 @@ public class AutomationPlugin extends PluginBase {
|
||||||
storeToSP(); // save last run time
|
storeToSP(); // save last run time
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final List<Action> actionDummyObjects = new ArrayList<Action>() {{
|
public final List<Action> getActionDummyObjects() {
|
||||||
//add(new ActionLoopDisable());
|
return new ArrayList<Action>() {{
|
||||||
//add(new ActionLoopEnable());
|
//add(new ActionLoopDisable());
|
||||||
//add(new ActionLoopResume());
|
//add(new ActionLoopEnable());
|
||||||
//add(new ActionLoopSuspend());
|
//add(new ActionLoopResume());
|
||||||
add(new ActionStartTempTarget());
|
//add(new ActionLoopSuspend());
|
||||||
add(new ActionStopTempTarget());
|
add(new ActionStartTempTarget());
|
||||||
add(new ActionNotification());
|
add(new ActionStopTempTarget());
|
||||||
add(new ActionProfileSwitchPercent());
|
add(new ActionNotification());
|
||||||
}};
|
add(new ActionProfileSwitchPercent());
|
||||||
|
}};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class ChooseActionDialog extends DialogFragment {
|
||||||
View view = inflater.inflate(R.layout.automation_dialog_choose_action, container, false);
|
View view = inflater.inflate(R.layout.automation_dialog_choose_action, container, false);
|
||||||
mUnbinder = ButterKnife.bind(this, view);
|
mUnbinder = ButterKnife.bind(this, view);
|
||||||
|
|
||||||
for (Action a : AutomationPlugin.actionDummyObjects) {
|
for (Action a : AutomationPlugin.getPlugin().getActionDummyObjects()) {
|
||||||
RadioButton radioButton = new RadioButton(getContext());
|
RadioButton radioButton = new RadioButton(getContext());
|
||||||
radioButton.setText(a.friendlyName());
|
radioButton.setText(a.friendlyName());
|
||||||
radioButton.setTag(a);
|
radioButton.setTag(a);
|
||||||
|
|
|
@ -161,7 +161,7 @@ public class TriggerListAdapter {
|
||||||
build(fragmentManager);
|
build(fragmentManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeConnector(final FragmentManager fragmentManager, final Trigger trigger, final TriggerConnector connector, final TriggerConnector.Type newConnectorType) {
|
public static void changeConnector(final FragmentManager fragmentManager, final Trigger trigger, final TriggerConnector connector, final TriggerConnector.Type newConnectorType) {
|
||||||
if (connector.size() > 2) {
|
if (connector.size() > 2) {
|
||||||
// split connector
|
// split connector
|
||||||
int pos = connector.pos(trigger) - 1;
|
int pos = connector.pos(trigger) - 1;
|
||||||
|
|
|
@ -7,6 +7,7 @@ import org.junit.runner.RunWith;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.dialogs.TriggerListAdapter;
|
||||||
import info.nightscout.androidaps.plugins.general.automation.triggers.DummyTrigger;
|
import info.nightscout.androidaps.plugins.general.automation.triggers.DummyTrigger;
|
||||||
import info.nightscout.androidaps.plugins.general.automation.triggers.Trigger;
|
import info.nightscout.androidaps.plugins.general.automation.triggers.Trigger;
|
||||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerConnector;
|
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerConnector;
|
||||||
|
@ -44,7 +45,7 @@ public class ComposeTriggerTest {
|
||||||
// initialize scenario
|
// initialize scenario
|
||||||
TriggerConnector root = new TriggerConnector(TriggerConnector.Type.AND);
|
TriggerConnector root = new TriggerConnector(TriggerConnector.Type.AND);
|
||||||
Trigger t[] = new Trigger[4];
|
Trigger t[] = new Trigger[4];
|
||||||
for(int i = 0; i < t.length; ++i) {
|
for (int i = 0; i < t.length; ++i) {
|
||||||
t[i] = new DummyTrigger();
|
t[i] = new DummyTrigger();
|
||||||
root.add(t[i]);
|
root.add(t[i]);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +53,7 @@ public class ComposeTriggerTest {
|
||||||
|
|
||||||
// change connector of t1,t2 from "and" to "or"
|
// change connector of t1,t2 from "and" to "or"
|
||||||
Assert.assertEquals(root, t[2].getConnector());
|
Assert.assertEquals(root, t[2].getConnector());
|
||||||
AutomationFragment.changeConnector(null, t[2], t[2].getConnector(), TriggerConnector.Type.OR);
|
TriggerListAdapter.changeConnector(null, t[2], t[2].getConnector(), TriggerConnector.Type.OR);
|
||||||
|
|
||||||
Assert.assertEquals(3, root.size());
|
Assert.assertEquals(3, root.size());
|
||||||
Assert.assertEquals(t[0], root.get(0));
|
Assert.assertEquals(t[0], root.get(0));
|
||||||
|
@ -66,9 +67,9 @@ public class ComposeTriggerTest {
|
||||||
|
|
||||||
// undo
|
// undo
|
||||||
Assert.assertEquals(newConnector, t[2].getConnector());
|
Assert.assertEquals(newConnector, t[2].getConnector());
|
||||||
AutomationFragment.changeConnector(null, t[2], t[2].getConnector(), TriggerConnector.Type.AND);
|
TriggerListAdapter.changeConnector(null, t[2], t[2].getConnector(), TriggerConnector.Type.AND);
|
||||||
Assert.assertEquals(4, root.size());
|
Assert.assertEquals(4, root.size());
|
||||||
for(int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
Assert.assertEquals(t[i], root.get(i));
|
Assert.assertEquals(t[i], root.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class InputPercentTest {
|
||||||
t.textWatcher.beforeTextChanged(null, 0, 0, 0);
|
t.textWatcher.beforeTextChanged(null, 0, 0, 0);
|
||||||
t.textWatcher.onTextChanged(null, 0, 0, 0);
|
t.textWatcher.onTextChanged(null, 0, 0, 0);
|
||||||
t.textWatcher.afterTextChanged(null);
|
t.textWatcher.afterTextChanged(null);
|
||||||
Assert.assertEquals(500d, t.getValue(), 0.01d);
|
Assert.assertEquals(130d, t.getValue(), 0.01d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in a new issue