diff --git a/selfdrive/ui/replay/tests/test_replay.cc b/selfdrive/ui/replay/tests/test_replay.cc index 4b776e7403..f2a2171c82 100644 --- a/selfdrive/ui/replay/tests/test_replay.cc +++ b/selfdrive/ui/replay/tests/test_replay.cc @@ -57,7 +57,7 @@ TEST_CASE("FileReader") { } TEST_CASE("Segment") { - auto flags = GENERATE(REPLAY_FLAG_NONE, REPLAY_FLAG_QCAMERA); + auto flags = GENERATE(REPLAY_FLAG_DCAM | REPLAY_FLAG_ECAM, REPLAY_FLAG_QCAMERA); Route demo_route(DEMO_ROUTE); REQUIRE(demo_route.load()); REQUIRE(demo_route.segments().size() == 11); @@ -68,21 +68,32 @@ TEST_CASE("Segment") { REQUIRE(segment.isLoaded() == true); REQUIRE(segment.log != nullptr); REQUIRE(segment.frames[RoadCam] != nullptr); - REQUIRE(segment.frames[DriverCam] == nullptr); - REQUIRE(segment.frames[WideRoadCam] == nullptr); + if (flags & REPLAY_FLAG_DCAM) { + REQUIRE(segment.frames[DriverCam] != nullptr); + } + if (flags & REPLAY_FLAG_ECAM) { + REQUIRE(segment.frames[WideRoadCam] != nullptr); + } - // LogReader & FrameReader + // test LogReader & FrameReader REQUIRE(segment.log->events.size() > 0); REQUIRE(std::is_sorted(segment.log->events.begin(), segment.log->events.end(), Event::lessThan())); - auto &fr = segment.frames[RoadCam]; - REQUIRE(fr->getFrameCount() == 1200); - std::unique_ptr rgb_buf = std::make_unique(fr->getRGBSize()); - std::unique_ptr yuv_buf = std::make_unique(fr->getYUVSize()); - // sequence get 50 frames - for (int i = 0; i < 50; ++i) { - REQUIRE(fr->get(i, rgb_buf.get(), yuv_buf.get())); + for (auto cam : ALL_CAMERAS) { + auto &fr = segment.frames[cam]; + if (!fr) continue; + + if (cam == RoadCam || cam == WideRoadCam) { + REQUIRE(fr->getFrameCount() == 1200); + } + std::unique_ptr rgb_buf = std::make_unique(fr->getRGBSize()); + std::unique_ptr yuv_buf = std::make_unique(fr->getYUVSize()); + // sequence get 50 frames + for (int i = 0; i < 50; ++i) { + REQUIRE(fr->get(i, rgb_buf.get(), yuv_buf.get())); + } } + loop.quit(); }); loop.exec(); @@ -134,7 +145,7 @@ void TestReplay::test_seek() { stream_thread_ = new QThread(this); QEventLoop loop; std::thread thread = std::thread([&]() { - for (int i = 0; i < 100; ++i) { + for (int i = 0; i < 50; ++i) { testSeekTo(random_int(0, 3 * 60)); } loop.quit();