@@ -26,10 +26,10 @@ std::function<void(const uvc_host_stream_event_data_t *, void *)> stream_callbac
2626// code for each transfer type (bulk or isochronous). Instead, we can dynamically set the appropriate
2727// frame-sending function, allowing `run_streaming_frame_reconstruction_scenario` to run identical tests
2828// with either transfer method.
29- std::function<void (size_t , void *, std::span<const uint8_t >, uint8_t , bool , bool )> send_frame_function;
30- inline void send_function_wrapper (size_t transfer_size, void *transfer_context, std::span<const uint8_t > data, uint8_t frame_id = 0 , bool error_in_sof = false , bool error_in_eof = false )
29+ std::function<void (size_t , void *, std::span<const uint8_t >, uint8_t , bool , bool , bool )> send_frame_function;
30+ inline void send_function_wrapper (size_t transfer_size, void *transfer_context, std::span<const uint8_t > data, uint8_t frame_id = 0 , bool error_in_sof = false , bool error_in_eof = false , bool eof_in_sof = false )
3131{
32- send_frame_function (transfer_size, transfer_context, data, frame_id, error_in_sof, error_in_eof);
32+ send_frame_function (transfer_size, transfer_context, data, frame_id, error_in_sof, error_in_eof, eof_in_sof );
3333}
3434
3535void run_streaming_frame_reconstruction_scenario (void )
@@ -236,15 +236,48 @@ void run_streaming_frame_reconstruction_scenario(void)
236236
237237SCENARIO (" Bulk stream frame reconstruction" , " [streaming][bulk]" )
238238{
239+ /* Tests that are same for ISOC and BULK */
239240 send_frame_function = test_streaming_bulk_send_frame;
240241 run_streaming_frame_reconstruction_scenario ();
242+
243+ /* BULK specific tests */
244+ int frame_callback_called = 0 ;
245+ uvc_stream_t stream = {}; // Define mock stream
246+ stream.constant .cb_arg = (void *)&frame_callback_called;
247+ stream.constant .frame_cb = [](const uvc_host_frame_t *frame, void *user_ctx) -> bool {
248+ int *fb_called = static_cast <int *>(user_ctx);
249+ (*fb_called)++;
250+ return true ;
251+ };
252+
253+ GIVEN (" Streaming enabled and frame allocated" ) {
254+ REQUIRE (uvc_host_stream_unpause (&stream) == ESP_OK);
255+ const uvc_host_stream_format_t format = {
256+ .h_res = 46 ,
257+ .v_res = 46 ,
258+ .fps = 15 ,
259+ .format = UVC_VS_FORMAT_MJPEG,
260+ };
261+
262+ REQUIRE (uvc_frame_allocate (&stream, 1 , 100 * 1024 , 0 ) == ESP_OK);
263+ uvc_frame_format_update (&stream, &format);
264+
265+ WHEN (" Expected SoF but got EoF" ) {
266+ test_streaming_bulk_send_frame (512 , &stream, std::span (logo_jpg), 0 , false , false , true );
267+ THEN (" The frame callback is called" ) {
268+ REQUIRE (frame_callback_called == 1 );
269+ }
270+ }
271+ }
241272}
242273
243274SCENARIO (" Isochronous stream frame reconstruction" , " [streaming][isoc]" )
244275{
276+ /* Tests that are same for ISOC and BULK */
245277 send_frame_function = test_streaming_isoc_send_frame;
246278 run_streaming_frame_reconstruction_scenario ();
247279
280+ /* ISOC specific tests */
248281 /*
249282 @todo ISOC test
250283 - Missed SoF
0 commit comments