fix tests

This commit is contained in:
Milos Kozak 2019-07-16 22:35:46 +02:00
parent 58da7fc854
commit 1c8aae9757
5 changed files with 20 additions and 17 deletions

View file

@ -219,14 +219,16 @@ public class AutomationPlugin extends PluginBase {
storeToSP(); // save last run time
}
public static final List<Action> actionDummyObjects = new ArrayList<Action>() {{
//add(new ActionLoopDisable());
//add(new ActionLoopEnable());
//add(new ActionLoopResume());
//add(new ActionLoopSuspend());
add(new ActionStartTempTarget());
add(new ActionStopTempTarget());
add(new ActionNotification());
add(new ActionProfileSwitchPercent());
}};
public final List<Action> getActionDummyObjects() {
return new ArrayList<Action>() {{
//add(new ActionLoopDisable());
//add(new ActionLoopEnable());
//add(new ActionLoopResume());
//add(new ActionLoopSuspend());
add(new ActionStartTempTarget());
add(new ActionStopTempTarget());
add(new ActionNotification());
add(new ActionProfileSwitchPercent());
}};
}
}

View file

@ -37,7 +37,7 @@ public class ChooseActionDialog extends DialogFragment {
View view = inflater.inflate(R.layout.automation_dialog_choose_action, container, false);
mUnbinder = ButterKnife.bind(this, view);
for (Action a : AutomationPlugin.actionDummyObjects) {
for (Action a : AutomationPlugin.getPlugin().getActionDummyObjects()) {
RadioButton radioButton = new RadioButton(getContext());
radioButton.setText(a.friendlyName());
radioButton.setTag(a);

View file

@ -161,7 +161,7 @@ public class TriggerListAdapter {
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) {
// split connector
int pos = connector.pos(trigger) - 1;

View file

@ -7,6 +7,7 @@ import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
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.Trigger;
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerConnector;
@ -44,7 +45,7 @@ public class ComposeTriggerTest {
// initialize scenario
TriggerConnector root = new TriggerConnector(TriggerConnector.Type.AND);
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();
root.add(t[i]);
}
@ -52,7 +53,7 @@ public class ComposeTriggerTest {
// change connector of t1,t2 from "and" to "or"
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(t[0], root.get(0));
@ -66,9 +67,9 @@ public class ComposeTriggerTest {
// undo
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());
for(int i = 0; i < 4; ++i) {
for (int i = 0; i < 4; ++i) {
Assert.assertEquals(t[i], root.get(i));
}
}

View file

@ -18,7 +18,7 @@ public class InputPercentTest {
t.textWatcher.beforeTextChanged(null, 0, 0, 0);
t.textWatcher.onTextChanged(null, 0, 0, 0);
t.textWatcher.afterTextChanged(null);
Assert.assertEquals(500d, t.getValue(), 0.01d);
Assert.assertEquals(130d, t.getValue(), 0.01d);
}
@Test