@@ -605,76 +605,5 @@ TEST_F(TrackingWorkerTest, Tracking_Confidence_PreservedThroughTracker) {
605605 }
606606}
607607
608- // Test that first_seen is set on the first observation of a track and remains stable
609- // across subsequent observations (same RobotVision ID → same UUID → same first_seen).
610- TEST_F (TrackingWorkerTest, Tracking_FirstSeen_SetOnFirstObservationAndStable) {
611- std::vector<Track> all_published_tracks;
612- std::mutex mtx;
613- std::condition_variable cv;
614- int callback_count = 0 ;
615- const int kChunksToSend = 3 ;
616-
617- PublishCallback callback = [&](const std::string&, const std::string&, const std::string&,
618- const std::string&, const std::vector<Track>& tracks,
619- const std::unordered_map<std::string, double >&) {
620- std::lock_guard lock (mtx);
621- all_published_tracks.insert (all_published_tracks.end (), tracks.begin (), tracks.end ());
622- callback_count++;
623- cv.notify_one ();
624- };
625-
626- TrackingConfig config = make_test_tracking_config ();
627- config.max_unreliable_time_s = 0.0 ;
628-
629- TrackingScope scope{" scene-1" , " person" };
630- TrackingWorker worker (scope, " Test Scene" , 10 , callback, config, cameras_);
631-
632- for (int i = 0 ; i < kChunksToSend ; ++i) {
633- Chunk chunk;
634- chunk.scene_id = " scene-1" ;
635- chunk.category = " person" ;
636- chunk.chunk_time = std::chrono::steady_clock::now ();
637-
638- DetectionBatch batch;
639- batch.camera_id = " cam-1" ;
640- batch.timestamp_iso = std::format (" 2026-01-27T12:00:{:02d}.000Z" , i);
641- batch.timestamp = std::chrono::system_clock::now ();
642-
643- Detection det;
644- det.id = 1 ;
645- det.bounding_box_px = cv::Rect2f (100 .0f , 200 .0f , 50 .0f , 100 .0f );
646- batch.detections .push_back (std::move (det));
647-
648- chunk.camera_batches .push_back (std::move (batch));
649- worker.try_enqueue (std::move (chunk));
650- }
651-
652- {
653- std::unique_lock lock (mtx);
654- ASSERT_TRUE (cv.wait_for (lock, std::chrono::seconds (2 ),
655- [&] { return callback_count >= kChunksToSend ; }))
656- << " Timed out waiting for " << kChunksToSend << " publish callbacks" ;
657- }
658-
659- ASSERT_GT (all_published_tracks.size (), 0u )
660- << " No reliable tracks published" ;
661-
662- // All tracks should have a non-empty first_seen
663- for (const auto & track : all_published_tracks) {
664- EXPECT_FALSE (track.first_seen_iso .empty ())
665- << " Track " << track.id << " is missing first_seen" ;
666- }
667-
668- // Tracks with the same ID must have the same first_seen (stable across frames)
669- std::unordered_map<std::string, std::string> id_to_first_seen;
670- for (const auto & track : all_published_tracks) {
671- auto [it, inserted] = id_to_first_seen.emplace (track.id , track.first_seen_iso );
672- if (!inserted) {
673- EXPECT_EQ (it->second , track.first_seen_iso )
674- << " Track " << track.id << " has inconsistent first_seen across frames" ;
675- }
676- }
677- }
678-
679608} // namespace
680609} // namespace tracker
0 commit comments