2018-03-31 15:00:32 +02:00
|
|
|
package info.nightscout;
|
|
|
|
|
|
|
|
import org.junit.Assert;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
import org.robolectric.RobolectricTestRunner;
|
|
|
|
|
2018-03-31 21:41:14 +02:00
|
|
|
import info.nightscout.androidaps.Config;
|
2018-03-31 15:00:32 +02:00
|
|
|
import info.nightscout.androidaps.MainApp;
|
|
|
|
import info.nightscout.androidaps.R;
|
|
|
|
import info.nightscout.androidaps.interfaces.PluginType;
|
|
|
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
2018-09-17 19:56:56 +02:00
|
|
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
2018-08-02 15:19:13 +02:00
|
|
|
import info.nightscout.androidaps.plugins.Maintenance.LoggerUtils;
|
2018-08-07 21:07:43 +02:00
|
|
|
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
2018-03-31 15:00:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by mike on 28.03.2018.
|
|
|
|
*/
|
|
|
|
|
|
|
|
@RunWith(RobolectricTestRunner.class)
|
|
|
|
public class MainAppTest {
|
|
|
|
MainApp mainApp = new MainApp();
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void busTest() {
|
|
|
|
Assert.assertNotNull(mainApp.bus());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void gsTest() {
|
2018-03-31 21:41:14 +02:00
|
|
|
Assert.assertNotNull(mainApp.gs(R.string.app_name));
|
|
|
|
Assert.assertNotNull(mainApp.gs(R.string.app_name, ""));
|
2018-03-31 15:00:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void gcTest() {
|
|
|
|
Assert.assertEquals(-16711681, mainApp.gc(R.color.basal));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void instanceTest() {
|
|
|
|
Assert.assertNotNull(mainApp.instance());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getDbHelperTest() {
|
|
|
|
Assert.assertNotNull(mainApp.getDbHelper());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void closeDbHelperTest() {
|
|
|
|
mainApp.closeDbHelper();
|
|
|
|
Assert.assertNull(mainApp.getDbHelper());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getConstraintCheckerTest() {
|
|
|
|
Assert.assertNotNull(mainApp.getConstraintChecker());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getPluginsListTest() {
|
|
|
|
Assert.assertNotNull(mainApp.getPluginsList());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getSpecificPluginsListTest() {
|
|
|
|
// currently MDI, VP, R, Rv2, KoreanR, RS
|
2018-03-31 21:41:14 +02:00
|
|
|
int expected;
|
2018-08-07 21:45:35 +02:00
|
|
|
if (Config.NSCLIENT)
|
2018-03-31 21:41:14 +02:00
|
|
|
expected = 1; // VirtualPump only
|
|
|
|
else
|
2019-02-08 20:44:39 +01:00
|
|
|
expected = 7;
|
2018-03-31 21:41:14 +02:00
|
|
|
Assert.assertEquals(expected, mainApp.getSpecificPluginsList(PluginType.PUMP).size());
|
2018-03-31 15:00:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getSpecificPluginsVisibleInListTest() {
|
|
|
|
// currently MDI, VP, R, Rv2, KoreanR, RS
|
2018-03-31 21:41:14 +02:00
|
|
|
int expected;
|
2018-08-07 21:45:35 +02:00
|
|
|
if (Config.NSCLIENT)
|
2018-03-31 21:41:14 +02:00
|
|
|
expected = 1; // VirtualPump only
|
|
|
|
else
|
2019-02-08 20:44:39 +01:00
|
|
|
expected = 7;
|
2018-03-31 21:41:14 +02:00
|
|
|
Assert.assertEquals(expected, mainApp.getSpecificPluginsVisibleInList(PluginType.PUMP).size());
|
2018-03-31 15:00:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getSpecificPluginsListByInterfaceTest() {
|
|
|
|
// currently MDI, VP, R, Rv2, KoreanR, RS
|
2018-03-31 21:41:14 +02:00
|
|
|
int expected;
|
2018-08-07 21:45:35 +02:00
|
|
|
if (Config.NSCLIENT)
|
2018-03-31 21:41:14 +02:00
|
|
|
expected = 1; // VirtualPump only
|
|
|
|
else
|
2019-02-08 20:44:39 +01:00
|
|
|
expected = 7;
|
2018-03-31 21:41:14 +02:00
|
|
|
Assert.assertEquals(expected, mainApp.getSpecificPluginsListByInterface(PumpInterface.class).size());
|
2018-03-31 15:00:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getSpecificPluginsVisibleInListByInterfaceTest() {
|
|
|
|
// currently MDI, VP, R, Rv2, KoreanR, RS
|
2018-03-31 21:41:14 +02:00
|
|
|
int expected;
|
2018-08-07 21:45:35 +02:00
|
|
|
if (Config.NSCLIENT)
|
2018-03-31 21:41:14 +02:00
|
|
|
expected = 1; // VirtualPump only
|
|
|
|
else
|
2019-02-08 20:44:39 +01:00
|
|
|
expected = 7;
|
2018-03-31 21:41:14 +02:00
|
|
|
Assert.assertEquals(expected, mainApp.getSpecificPluginsVisibleInListByInterface(PumpInterface.class, PluginType.PUMP).size());
|
2018-03-31 15:00:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getSpecificPluginTest() {
|
|
|
|
// currently MDI, VP, R, Rv2, KoreanR, RS
|
|
|
|
Assert.assertEquals("Overview", mainApp.getSpecificPlugin(OverviewPlugin.class).getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void isEngineeringModeOrReleaseTest() {
|
2018-11-03 00:04:31 +01:00
|
|
|
mainApp.devBranch = true;
|
2018-08-07 21:07:43 +02:00
|
|
|
Assert.assertEquals(!Config.APS, mainApp.isEngineeringModeOrRelease());
|
2018-03-31 15:00:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getLogDirectoryTest() {
|
|
|
|
// logger not initialized in Roboelectric
|
2018-07-23 20:58:20 +02:00
|
|
|
Assert.assertNull(LoggerUtils.getLogDirectory());
|
2018-03-31 15:00:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|