Synchronize capture queue before verifying mock expectations RTCCameraVideoCapturerTestsWithMockedCaptureSession tests startCaptureWithDevice and stopCapture, which dispatch asynchronously to RTCDispatcherTypeCaptureSession. OCMVerifyAllWithDelay does not reliably wait for these background tasks to complete. This change explicitly synchronizes the capture dispatch queue before verification to ensure deterministic test completion and prevent deallocation of unverified strict mock objects. Bug: none Change-Id: I94c64456291e970bcef962d4a78ae378c4e8f658 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/472500 Commit-Queue: Artem Titov <titovartem@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Auto-Submit: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#47713}
diff --git a/sdk/objc/unittests/RTCCameraVideoCapturerTests.mm b/sdk/objc/unittests/RTCCameraVideoCapturerTests.mm index d5b4da9..2d91532 100644 --- a/sdk/objc/unittests/RTCCameraVideoCapturerTests.mm +++ b/sdk/objc/unittests/RTCCameraVideoCapturerTests.mm
@@ -18,7 +18,7 @@ #import "base/RTCVideoFrame.h" #import "components/capturer/RTCCameraVideoCapturer.h" #import "helpers/AVCaptureSession+DevicePosition.h" -#import "helpers/RTCDispatcher.h" +#import "helpers/RTCDispatcher+Private.h" #import "helpers/scoped_cftyperef.h" #define WAIT(timeoutMs) \ @@ -476,6 +476,10 @@ [self.capturer stopCapture]; // Start capture code is dispatched async. + dispatch_sync([RTC_OBJC_TYPE(RTCDispatcher) + dispatchQueueForType:RTCDispatcherTypeCaptureSession], + ^{ + }); OCMVerifyAllWithDelay(_captureSessionMock, 15); } @@ -489,6 +493,10 @@ [self.capturer startCaptureWithDevice:self.deviceMock format:format fps:30]; // Start capture code is dispatched async. + dispatch_sync([RTC_OBJC_TYPE(RTCDispatcher) + dispatchQueueForType:RTCDispatcherTypeCaptureSession], + ^{ + }); OCMVerifyAllWithDelay(self.deviceMock, 15); }