This commit is contained in:
Andy Rozman 2020-04-24 12:11:16 +01:00
parent a3b0c8ce3b
commit f5b43454eb

View file

@ -6,30 +6,33 @@ import org.joda.time.DateTimeZone;
import org.joda.time.Duration; import org.joda.time.Duration;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; 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.AAPSMocker;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.FirmwareVersion; import info.nightscout.androidaps.plugins.pump.omnipod.defs.FirmwareVersion;
import info.nightscout.androidaps.testing.mockers.AAPSMocker;
import info.nightscout.androidaps.utils.SP; import info.nightscout.androidaps.utils.SP;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@Ignore("Not Dagger compliant")
@RunWith(PowerMockRunner.class) @RunWith(PowerMockRunner.class)
@PrepareForTest({MainApp.class, SP.class, L.class}) @PrepareForTest({MainApp.class, SP.class, L.class})
public class PodSessionStateTest { public class PodSessionStateTest {
@Before // @Before
public void setup() { // public void setup() {
AAPSMocker.mockMainApp(); //// AAPSMocker.mockMainApp();
AAPSMocker.mockApplicationContext(); //// AAPSMocker.mockApplicationContext();
AAPSMocker.mockSP(); //// AAPSMocker.mockSP();
} // }
@Test //@Test
public void times() { public void times() {
DateTimeZone timeZone = DateTimeZone.UTC; DateTimeZone timeZone = DateTimeZone.UTC;
DateTimeZone.setDefault(timeZone); DateTimeZone.setDefault(timeZone);
@ -48,7 +51,7 @@ public class PodSessionStateTest {
assertEquals(Duration.standardHours(1).plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))), podSessionState.getScheduleOffset()); assertEquals(Duration.standardHours(1).plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))), podSessionState.getScheduleOffset());
} }
@Test //@Test
public void changeSystemTimeZoneWithoutChangingPodTimeZone() { public void changeSystemTimeZoneWithoutChangingPodTimeZone() {
DateTimeZone timeZone = DateTimeZone.UTC; DateTimeZone timeZone = DateTimeZone.UTC;
DateTimeZone.setDefault(timeZone); DateTimeZone.setDefault(timeZone);
@ -72,7 +75,7 @@ public class PodSessionStateTest {
assertEquals(Duration.standardHours(1).plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))), podSessionState.getScheduleOffset()); assertEquals(Duration.standardHours(1).plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))), podSessionState.getScheduleOffset());
} }
@Test //@Test
public void changeSystemTimeZoneAndChangePodTimeZone() { public void changeSystemTimeZoneAndChangePodTimeZone() {
DateTimeZone timeZone = DateTimeZone.UTC; DateTimeZone timeZone = DateTimeZone.UTC;
DateTimeZone.setDefault(timeZone); DateTimeZone.setDefault(timeZone);
@ -97,8 +100,8 @@ public class PodSessionStateTest {
assertEquals(Duration.standardHours(3).plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))), podSessionState.getScheduleOffset()); assertEquals(Duration.standardHours(3).plus(Duration.standardMinutes(2).plus(Duration.standardSeconds(3))), podSessionState.getScheduleOffset());
} }
@After // @After
public void tearDown() { // public void tearDown() {
DateTimeUtils.setCurrentMillisSystem(); // DateTimeUtils.setCurrentMillisSystem();
} // }
} }