use of cl.smartcities.isci.transportinspector.backend.Bus in project androidApp by InspectorIncognito.
the class DetectionServiceTest method testManualGetOutOfBus.
@Test
public void testManualGetOutOfBus() throws TimeoutException {
DetectionService spyService = spy(service);
BusStop mockBusStop = mock(BusStop.class);
when(mockBusStop.getIncomingBuses()).thenReturn(new ArrayList<Bus>());
Bus bus = new Bus("506", "GGWP00", "");
spyService.setCurrentState(new VehicleState(new IdleState(spyService), bus, mock(StateLocationSender.class)));
spyService.onBusDetected(bus);
assertTrue(spyService.isRunningInForeground());
spyService.outOfBus();
assertFalse(spyService.isRunningInForeground());
}
use of cl.smartcities.isci.transportinspector.backend.Bus in project androidApp by InspectorIncognito.
the class DetectionServiceTest method testGetOutOfBus.
@Test
public void testGetOutOfBus() throws TimeoutException {
DetectionService spyService = spy(service);
BusStop mockBusStop = mock(BusStop.class);
when(mockBusStop.getIncomingBuses()).thenReturn(new ArrayList<Bus>());
Bus bus = new Bus("506", "GGWP00", "");
spyService.setCurrentState(new VehicleState(new IdleState(spyService), bus, mock(StateLocationSender.class)));
spyService.onBusDetected(bus);
assertTrue(spyService.isRunningInForeground());
spyService.onActivityChanged(new DetectedActivity(DetectedActivity.WALKING, 100));
spyService.onActivityChanged(new DetectedActivity(DetectedActivity.IN_VEHICLE, 100));
spyService.onActivityChanged(new DetectedActivity(DetectedActivity.WALKING, 100));
spyService.fakeOnTimePassed();
assertFalse(spyService.isRunningInForeground());
}
use of cl.smartcities.isci.transportinspector.backend.Bus in project androidApp by InspectorIncognito.
the class DetectionServiceTest method testBusDetectedNotificationIsSent.
@Test
public void testBusDetectedNotificationIsSent() throws TimeoutException {
DetectionService spyService = spy(service);
BusStop mockBusStop = mock(BusStop.class);
when(mockBusStop.getIncomingBuses()).thenReturn(new ArrayList<Bus>());
// IdleState is set
spyService.setCurrentState(new IdleState(spyService));
// BusStop is selected
spyService.busStopSelected(mockBusStop);
// New IN_VEHICLE Detected Activity
spyService.onActivityChanged(new DetectedActivity(DetectedActivity.IN_VEHICLE, 100));
// TODO(aantoine): REDO this test
// verify(spyService).sendNotification(anyInt(), any(NotificationCompat.Builder.class));
}
use of cl.smartcities.isci.transportinspector.backend.Bus in project androidApp by InspectorIncognito.
the class BusSelectionAdapterTest method setUp.
@Before
public void setUp() throws Exception {
listener = mock(BusSelectionAdapter.ListViewAdapterListener.class);
HashMap<String, ArrayList<Bus>> busHashMap = new HashMap<>();
ArrayList<Bus> array509 = new ArrayList<>();
array509.add(new Bus("509", "GGWP10", ""));
array509.add(new Bus("509", "GGWP11", ""));
busHashMap.put("509", array509);
ArrayList<Bus> array506 = new ArrayList<>();
array506.add(new Bus("506", "GGWP20", ""));
array506.add(new Bus("506", "GGWP21", ""));
busHashMap.put("506", array506);
ArrayList<Bus> array507 = new ArrayList<>();
b507first = new Bus("507", "GGWP00", "");
b507second = new Bus("507", "GGWP01", "");
array507.add(b507first);
array507.add(b507second);
busHashMap.put("507", array507);
ArrayList<Bus> array506v = new ArrayList<>();
b506first = new Bus("506v", "GGWP03", "");
array506v.add(b506first);
busHashMap.put("506v", array506v);
ArrayList<String> serviceList = new ArrayList<>();
serviceList.add("509");
serviceList.add("506");
serviceList.add("507");
serviceList.add("506v");
mAdapter = new BusSelectionAdapter(rule.getActivity(), serviceList, busHashMap, listener);
}
use of cl.smartcities.isci.transportinspector.backend.Bus in project androidApp by InspectorIncognito.
the class DetectionServiceTest method testRegisterUnregister.
@Test
public void testRegisterUnregister() throws TimeoutException {
Bus mockBus = mock(Bus.class);
DetectionService.ServiceListener mockListener = mock(DetectionService.ServiceListener.class);
service.register(mockListener);
service.onBusDetected(mockBus);
assertEquals(mockBus, service.getCurrentBus());
assertTrue(service.isRunningInForeground());
verify(mockListener, times(1)).nowOnForeground(mockBus);
service.outOfBus();
assertNull(service.getCurrentBus());
assertFalse(service.isRunningInForeground());
verify(mockListener, times(1)).nowOnForeground(mockBus);
service.unregister(mockListener);
service.onBusDetected(mockBus);
verify(mockListener, times(1)).nowOnForeground(mockBus);
}
Aggregations