Replace gunit.h macros with WaitUntil in modules/
Bug: webrtc:381524905 Change-Id: Ifde77639d720b404eda2e21275d0c3682ac933c6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/374222 Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org> Auto-Submit: Evan Shrubsole <eshr@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43770}
This commit is contained in:
parent
2a858e21f6
commit
f1b3e3e115
@ -178,10 +178,13 @@ if (!build_with_chromium || is_linux || is_chromeos) {
|
|||||||
deps = [
|
deps = [
|
||||||
":video_capture_internal_impl",
|
":video_capture_internal_impl",
|
||||||
":video_capture_module",
|
":video_capture_module",
|
||||||
|
"../../api:rtc_error_matchers",
|
||||||
"../../api:scoped_refptr",
|
"../../api:scoped_refptr",
|
||||||
|
"../../api/units:time_delta",
|
||||||
"../../api/video:video_frame",
|
"../../api/video:video_frame",
|
||||||
"../../api/video:video_rtp_headers",
|
"../../api/video:video_rtp_headers",
|
||||||
"../../common_video",
|
"../../common_video",
|
||||||
|
"../../rtc_base:checks",
|
||||||
"../../rtc_base:gunit_helpers",
|
"../../rtc_base:gunit_helpers",
|
||||||
"../../rtc_base:timeutils",
|
"../../rtc_base:timeutils",
|
||||||
"../../rtc_base/synchronization:mutex",
|
"../../rtc_base/synchronization:mutex",
|
||||||
@ -190,6 +193,7 @@ if (!build_with_chromium || is_linux || is_chromeos) {
|
|||||||
"../../test:test_main",
|
"../../test:test_main",
|
||||||
"../../test:test_support",
|
"../../test:test_support",
|
||||||
"../../test:video_test_common",
|
"../../test:video_test_common",
|
||||||
|
"../../test:wait_until",
|
||||||
"//testing/gtest",
|
"//testing/gtest",
|
||||||
"//third_party/abseil-cpp/absl/memory",
|
"//third_party/abseil-cpp/absl/memory",
|
||||||
]
|
]
|
||||||
|
|||||||
@ -12,22 +12,30 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/memory/memory.h"
|
|
||||||
#include "api/scoped_refptr.h"
|
#include "api/scoped_refptr.h"
|
||||||
#include "api/video/i420_buffer.h"
|
#include "api/test/rtc_error_matchers.h"
|
||||||
|
#include "api/units/time_delta.h"
|
||||||
#include "api/video/video_frame.h"
|
#include "api/video/video_frame.h"
|
||||||
#include "common_video/libyuv/include/webrtc_libyuv.h"
|
#include "api/video/video_rotation.h"
|
||||||
|
#include "api/video/video_sink_interface.h"
|
||||||
|
#include "modules/video_capture/video_capture_defines.h"
|
||||||
#include "modules/video_capture/video_capture_factory.h"
|
#include "modules/video_capture/video_capture_factory.h"
|
||||||
#include "rtc_base/gunit.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/synchronization/mutex.h"
|
#include "rtc_base/synchronization/mutex.h"
|
||||||
#include "rtc_base/time_utils.h"
|
#include "rtc_base/time_utils.h"
|
||||||
#include "test/frame_utils.h"
|
#include "test/frame_utils.h"
|
||||||
|
#include "test/gmock.h"
|
||||||
#include "test/gtest.h"
|
#include "test/gtest.h"
|
||||||
|
#include "test/wait_until.h"
|
||||||
|
|
||||||
|
using ::testing::Ge;
|
||||||
using webrtc::VideoCaptureCapability;
|
using webrtc::VideoCaptureCapability;
|
||||||
using webrtc::VideoCaptureFactory;
|
using webrtc::VideoCaptureFactory;
|
||||||
using webrtc::VideoCaptureModule;
|
using webrtc::VideoCaptureModule;
|
||||||
@ -203,7 +211,10 @@ TEST_F(VideoCaptureTest, MAYBE_CreateDelete) {
|
|||||||
EXPECT_LE(rtc::TimeMillis() - start_time, 4000);
|
EXPECT_LE(rtc::TimeMillis() - start_time, 4000);
|
||||||
|
|
||||||
// Make sure 5 frames are captured.
|
// Make sure 5 frames are captured.
|
||||||
EXPECT_TRUE_WAIT(capture_observer.incoming_frames() >= 5, kTimeOut);
|
EXPECT_THAT(webrtc::WaitUntil(
|
||||||
|
[&] { return capture_observer.incoming_frames(); }, Ge(5),
|
||||||
|
{.timeout = webrtc::TimeDelta::Millis(kTimeOut)}),
|
||||||
|
webrtc::IsRtcOk());
|
||||||
|
|
||||||
int64_t stop_time = rtc::TimeMillis();
|
int64_t stop_time = rtc::TimeMillis();
|
||||||
EXPECT_EQ(0, module->StopCapture());
|
EXPECT_EQ(0, module->StopCapture());
|
||||||
@ -254,7 +265,10 @@ TEST_F(VideoCaptureTest, MAYBE_Capabilities) {
|
|||||||
capture_observer.SetExpectedCapability(capability);
|
capture_observer.SetExpectedCapability(capability);
|
||||||
ASSERT_NO_FATAL_FAILURE(StartCapture(module.get(), capability));
|
ASSERT_NO_FATAL_FAILURE(StartCapture(module.get(), capability));
|
||||||
// Make sure at least one frame is captured.
|
// Make sure at least one frame is captured.
|
||||||
EXPECT_TRUE_WAIT(capture_observer.incoming_frames() >= 1, kTimeOut);
|
EXPECT_THAT(webrtc::WaitUntil(
|
||||||
|
[&] { return capture_observer.incoming_frames(); }, Ge(1),
|
||||||
|
{.timeout = webrtc::TimeDelta::Millis(kTimeOut)}),
|
||||||
|
webrtc::IsRtcOk());
|
||||||
|
|
||||||
EXPECT_EQ(0, module->StopCapture());
|
EXPECT_EQ(0, module->StopCapture());
|
||||||
}
|
}
|
||||||
@ -317,8 +331,14 @@ TEST_F(VideoCaptureTest, DISABLED_TestTwoCameras) {
|
|||||||
|
|
||||||
ASSERT_NO_FATAL_FAILURE(StartCapture(module1.get(), capability1));
|
ASSERT_NO_FATAL_FAILURE(StartCapture(module1.get(), capability1));
|
||||||
ASSERT_NO_FATAL_FAILURE(StartCapture(module2.get(), capability2));
|
ASSERT_NO_FATAL_FAILURE(StartCapture(module2.get(), capability2));
|
||||||
EXPECT_TRUE_WAIT(capture_observer1.incoming_frames() >= 5, kTimeOut);
|
EXPECT_THAT(webrtc::WaitUntil(
|
||||||
EXPECT_TRUE_WAIT(capture_observer2.incoming_frames() >= 5, kTimeOut);
|
[&] { return capture_observer1.incoming_frames(); }, Ge(5),
|
||||||
|
{.timeout = webrtc::TimeDelta::Millis(kTimeOut)}),
|
||||||
|
webrtc::IsRtcOk());
|
||||||
|
EXPECT_THAT(webrtc::WaitUntil(
|
||||||
|
[&] { return capture_observer2.incoming_frames(); }, Ge(5),
|
||||||
|
{.timeout = webrtc::TimeDelta::Millis(kTimeOut)}),
|
||||||
|
webrtc::IsRtcOk());
|
||||||
EXPECT_EQ(0, module2->StopCapture());
|
EXPECT_EQ(0, module2->StopCapture());
|
||||||
EXPECT_EQ(0, module1->StopCapture());
|
EXPECT_EQ(0, module1->StopCapture());
|
||||||
}
|
}
|
||||||
@ -346,12 +366,18 @@ TEST_F(VideoCaptureTest, MAYBE_ConcurrentAccess) {
|
|||||||
|
|
||||||
// Starting module1 should work.
|
// Starting module1 should work.
|
||||||
ASSERT_NO_FATAL_FAILURE(StartCapture(module1.get(), capability));
|
ASSERT_NO_FATAL_FAILURE(StartCapture(module1.get(), capability));
|
||||||
EXPECT_TRUE_WAIT(capture_observer1.incoming_frames() >= 5, kTimeOut);
|
EXPECT_THAT(webrtc::WaitUntil(
|
||||||
|
[&] { return capture_observer1.incoming_frames(); }, Ge(5),
|
||||||
|
{.timeout = webrtc::TimeDelta::Millis(kTimeOut)}),
|
||||||
|
webrtc::IsRtcOk());
|
||||||
|
|
||||||
// When module1 is stopped, starting module2 for the same device should work.
|
// When module1 is stopped, starting module2 for the same device should work.
|
||||||
EXPECT_EQ(0, module1->StopCapture());
|
EXPECT_EQ(0, module1->StopCapture());
|
||||||
ASSERT_NO_FATAL_FAILURE(StartCapture(module2.get(), capability));
|
ASSERT_NO_FATAL_FAILURE(StartCapture(module2.get(), capability));
|
||||||
EXPECT_TRUE_WAIT(capture_observer2.incoming_frames() >= 5, kTimeOut);
|
EXPECT_THAT(webrtc::WaitUntil(
|
||||||
|
[&] { return capture_observer2.incoming_frames(); }, Ge(5),
|
||||||
|
{.timeout = webrtc::TimeDelta::Millis(kTimeOut)}),
|
||||||
|
webrtc::IsRtcOk());
|
||||||
|
|
||||||
EXPECT_EQ(0, module2->StopCapture());
|
EXPECT_EQ(0, module2->StopCapture());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user