2018-08-30 09:00:27 +03:00
|
|
|
extern crate abstutil;
|
|
|
|
extern crate control;
|
|
|
|
extern crate map_model;
|
|
|
|
extern crate sim;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn bus_reaches_stops() {
|
2018-10-03 00:36:04 +03:00
|
|
|
let (map, control_map, mut sim) = sim::load(
|
2018-10-03 02:16:25 +03:00
|
|
|
sim::SimFlags::for_test("bus_reaches_stops"),
|
2018-08-30 09:00:27 +03:00
|
|
|
Some(sim::Tick::from_seconds(30)),
|
|
|
|
);
|
|
|
|
|
2018-09-07 23:22:37 +03:00
|
|
|
let route = map.get_bus_route("48").unwrap();
|
|
|
|
let bus = sim.seed_bus_route(route, &map)[0];
|
|
|
|
let mut expectations: Vec<sim::Event> = Vec::new();
|
|
|
|
// TODO assert stuff about other buses as well, although the timing is a little unclear
|
|
|
|
for stop in route.stops.iter().skip(1) {
|
|
|
|
expectations.push(sim::Event::BusArrivedAtStop(bus, *stop));
|
|
|
|
expectations.push(sim::Event::BusDepartedFromStop(bus, *stop));
|
|
|
|
}
|
2018-08-30 09:00:27 +03:00
|
|
|
|
2018-09-01 01:03:15 +03:00
|
|
|
sim.run_until_expectations_met(
|
2018-08-30 09:00:27 +03:00
|
|
|
&map,
|
|
|
|
&control_map,
|
2018-09-07 23:22:37 +03:00
|
|
|
expectations,
|
2018-08-30 21:04:27 +03:00
|
|
|
sim::Tick::from_minutes(10),
|
2018-08-30 09:00:27 +03:00
|
|
|
);
|
2018-09-04 21:55:45 +03:00
|
|
|
sim.run_until_done(&map, &control_map, Box::new(|_sim| {}));
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO this test is strictly more complicated than bus_reaches_stops, should it subsume it?
|
|
|
|
#[test]
|
|
|
|
fn ped_uses_bus() {
|
2018-10-03 00:36:04 +03:00
|
|
|
let (map, control_map, mut sim) = sim::load(
|
2018-10-03 02:16:25 +03:00
|
|
|
sim::SimFlags::for_test("bus_reaches_stops"),
|
2018-09-04 21:55:45 +03:00
|
|
|
Some(sim::Tick::from_seconds(30)),
|
|
|
|
);
|
|
|
|
|
2018-09-07 23:22:37 +03:00
|
|
|
let route = map.get_bus_route("48").unwrap();
|
|
|
|
let bus = sim.seed_bus_route(route, &map)[0];
|
|
|
|
let ped_stop1 = route.stops[1];
|
|
|
|
let ped_stop2 = route.stops[2];
|
2018-10-17 23:33:38 +03:00
|
|
|
// TODO Need to fix this test after stabilizing a map
|
2018-09-04 21:55:45 +03:00
|
|
|
let ped = sim.make_ped_using_bus(
|
|
|
|
&map,
|
2018-10-17 23:33:38 +03:00
|
|
|
map_model::BuildingID(123),
|
|
|
|
map_model::BuildingID(456),
|
2018-09-04 21:55:45 +03:00
|
|
|
sim::RouteID(0),
|
2018-09-07 23:22:37 +03:00
|
|
|
ped_stop1,
|
|
|
|
ped_stop2,
|
2018-09-04 21:55:45 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
sim.run_until_expectations_met(
|
|
|
|
&map,
|
|
|
|
&control_map,
|
|
|
|
vec![
|
2018-09-07 23:22:37 +03:00
|
|
|
sim::Event::BusArrivedAtStop(bus, ped_stop1),
|
2018-09-04 21:55:45 +03:00
|
|
|
sim::Event::PedEntersBus(ped, bus),
|
2018-09-07 23:22:37 +03:00
|
|
|
sim::Event::BusDepartedFromStop(bus, ped_stop1),
|
|
|
|
sim::Event::BusArrivedAtStop(bus, ped_stop2),
|
2018-09-04 21:55:45 +03:00
|
|
|
sim::Event::PedLeavesBus(ped, bus),
|
2018-09-07 23:22:37 +03:00
|
|
|
sim::Event::BusDepartedFromStop(bus, ped_stop2),
|
|
|
|
sim::Event::BusArrivedAtStop(bus, route.stops[3]),
|
2018-09-04 21:55:45 +03:00
|
|
|
// TODO PedReachedBuilding, once the seeding specifies a building instead of picking
|
|
|
|
],
|
|
|
|
sim::Tick::from_minutes(10),
|
|
|
|
);
|
2018-08-30 09:00:27 +03:00
|
|
|
}
|