Replace gunit.h macros with WaitUntil in audio/
Bug: webrtc:381524905 Change-Id: If153ae0f284873a35cfce7d72e3dcba41f768190 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/373741 Commit-Queue: Per Åhgren <peah@webrtc.org> Auto-Submit: Evan Shrubsole <eshr@webrtc.org> Reviewed-by: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43717}
This commit is contained in:
parent
f3dafd1d43
commit
815c5c0179
@ -177,9 +177,11 @@ if (rtc_include_tests) {
|
|||||||
"../api:mock_frame_encryptor",
|
"../api:mock_frame_encryptor",
|
||||||
"../api:mock_frame_transformer",
|
"../api:mock_frame_transformer",
|
||||||
"../api:mock_transformable_audio_frame",
|
"../api:mock_transformable_audio_frame",
|
||||||
|
"../api:rtc_error_matchers",
|
||||||
"../api:rtp_headers",
|
"../api:rtp_headers",
|
||||||
"../api:rtp_parameters",
|
"../api:rtp_parameters",
|
||||||
"../api:scoped_refptr",
|
"../api:scoped_refptr",
|
||||||
|
"../api:simulated_network_api",
|
||||||
"../api:transport_api",
|
"../api:transport_api",
|
||||||
"../api/audio:audio_frame_api",
|
"../api/audio:audio_frame_api",
|
||||||
"../api/audio:audio_mixer_api",
|
"../api/audio:audio_mixer_api",
|
||||||
@ -193,6 +195,7 @@ if (rtc_include_tests) {
|
|||||||
"../api/crypto:options",
|
"../api/crypto:options",
|
||||||
"../api/environment",
|
"../api/environment",
|
||||||
"../api/environment:environment_factory",
|
"../api/environment:environment_factory",
|
||||||
|
"../api/task_queue",
|
||||||
"../api/task_queue:default_task_queue_factory",
|
"../api/task_queue:default_task_queue_factory",
|
||||||
"../api/task_queue/test:mock_task_queue_base",
|
"../api/task_queue/test:mock_task_queue_base",
|
||||||
"../api/transport:bitrate_settings",
|
"../api/transport:bitrate_settings",
|
||||||
@ -240,8 +243,10 @@ if (rtc_include_tests) {
|
|||||||
"../test:test_common",
|
"../test:test_common",
|
||||||
"../test:test_support",
|
"../test:test_support",
|
||||||
"../test:video_test_constants",
|
"../test:video_test_constants",
|
||||||
|
"../test:wait_until",
|
||||||
"../test/time_controller:time_controller",
|
"../test/time_controller:time_controller",
|
||||||
"utility:utility_tests",
|
"utility:utility_tests",
|
||||||
|
"//testing/gmock",
|
||||||
"//testing/gtest",
|
"//testing/gtest",
|
||||||
"//third_party/abseil-cpp/absl/memory",
|
"//third_party/abseil-cpp/absl/memory",
|
||||||
"//third_party/abseil-cpp/absl/strings:string_view",
|
"//third_party/abseil-cpp/absl/strings:string_view",
|
||||||
|
|||||||
@ -34,6 +34,7 @@
|
|||||||
#include "api/scoped_refptr.h"
|
#include "api/scoped_refptr.h"
|
||||||
#include "api/test/mock_frame_transformer.h"
|
#include "api/test/mock_frame_transformer.h"
|
||||||
#include "api/test/mock_transformable_audio_frame.h"
|
#include "api/test/mock_transformable_audio_frame.h"
|
||||||
|
#include "api/test/rtc_error_matchers.h"
|
||||||
#include "api/transport/bitrate_settings.h"
|
#include "api/transport/bitrate_settings.h"
|
||||||
#include "api/units/data_rate.h"
|
#include "api/units/data_rate.h"
|
||||||
#include "api/units/time_delta.h"
|
#include "api/units/time_delta.h"
|
||||||
@ -42,18 +43,20 @@
|
|||||||
#include "call/rtp_transport_controller_send.h"
|
#include "call/rtp_transport_controller_send.h"
|
||||||
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||||
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
|
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
|
||||||
#include "rtc_base/gunit.h"
|
|
||||||
#include "test/gmock.h"
|
#include "test/gmock.h"
|
||||||
#include "test/gtest.h"
|
#include "test/gtest.h"
|
||||||
#include "test/mock_transport.h"
|
#include "test/mock_transport.h"
|
||||||
#include "test/scoped_key_value_config.h"
|
#include "test/scoped_key_value_config.h"
|
||||||
#include "test/time_controller/simulated_time_controller.h"
|
#include "test/time_controller/simulated_time_controller.h"
|
||||||
|
#include "test/wait_until.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace voe {
|
namespace voe {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using ::testing::Eq;
|
||||||
using ::testing::Invoke;
|
using ::testing::Invoke;
|
||||||
|
using ::testing::IsTrue;
|
||||||
using ::testing::NiceMock;
|
using ::testing::NiceMock;
|
||||||
using ::testing::Return;
|
using ::testing::Return;
|
||||||
using ::testing::SaveArg;
|
using ::testing::SaveArg;
|
||||||
@ -212,9 +215,11 @@ TEST_F(ChannelSendTest, FrameTransformerGetsCorrectTimestamp) {
|
|||||||
// Ensure the RTP timestamp on the frame passed to the transformer
|
// Ensure the RTP timestamp on the frame passed to the transformer
|
||||||
// includes the RTP offset and matches the actual RTP timestamp on the sent
|
// includes the RTP offset and matches the actual RTP timestamp on the sent
|
||||||
// packet.
|
// packet.
|
||||||
EXPECT_EQ_WAIT(transformable_frame_timestamp,
|
EXPECT_THAT(
|
||||||
0 + channel_->GetRtpRtcp()->StartTimestamp(), 1000);
|
WaitUntil([&] { return 0 + channel_->GetRtpRtcp()->StartTimestamp(); },
|
||||||
EXPECT_TRUE_WAIT(sent_timestamp, 1000);
|
Eq(transformable_frame_timestamp)),
|
||||||
|
IsRtcOk());
|
||||||
|
EXPECT_THAT(WaitUntil([&] { return sent_timestamp; }, IsTrue()), IsRtcOk());
|
||||||
EXPECT_EQ(*sent_timestamp, transformable_frame_timestamp);
|
EXPECT_EQ(*sent_timestamp, transformable_frame_timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +269,7 @@ TEST_F(ChannelSendTest, AudioLevelsAttachedToCorrectTransformedFrame) {
|
|||||||
ProcessNextFrame(CreateAudioFrame(/*data_init_value=*/3));
|
ProcessNextFrame(CreateAudioFrame(/*data_init_value=*/3));
|
||||||
|
|
||||||
// Wait for both packets to be encoded and sent to the transform.
|
// Wait for both packets to be encoded and sent to the transform.
|
||||||
EXPECT_EQ_WAIT(frames.size(), 2ul, 1000);
|
EXPECT_THAT(WaitUntil([&] { return frames.size(); }, Eq(2ul)), IsRtcOk());
|
||||||
// Complete the transforms on both frames at the same time
|
// Complete the transforms on both frames at the same time
|
||||||
callback->OnTransformedFrame(std::move(frames[0]));
|
callback->OnTransformedFrame(std::move(frames[0]));
|
||||||
callback->OnTransformedFrame(std::move(frames[1]));
|
callback->OnTransformedFrame(std::move(frames[1]));
|
||||||
@ -274,7 +279,8 @@ TEST_F(ChannelSendTest, AudioLevelsAttachedToCorrectTransformedFrame) {
|
|||||||
|
|
||||||
// Ensure the audio levels on both sent packets is present and
|
// Ensure the audio levels on both sent packets is present and
|
||||||
// matches their contents.
|
// matches their contents.
|
||||||
EXPECT_EQ_WAIT(sent_audio_levels.size(), 2ul, 1000);
|
EXPECT_THAT(WaitUntil([&] { return sent_audio_levels.size(); }, Eq(2ul)),
|
||||||
|
IsRtcOk());
|
||||||
// rms dbov of the packet with raw audio of 7s is 73.
|
// rms dbov of the packet with raw audio of 7s is 73.
|
||||||
EXPECT_EQ(sent_audio_levels[0], 73);
|
EXPECT_EQ(sent_audio_levels[0], 73);
|
||||||
// rms dbov of the second packet with raw audio of 3s is 81.
|
// rms dbov of the second packet with raw audio of 3s is 81.
|
||||||
@ -318,14 +324,14 @@ TEST_F(ChannelSendTest, AudioLevelsAttachedToInsertedTransformedFrame) {
|
|||||||
uint8_t payload[10];
|
uint8_t payload[10];
|
||||||
ON_CALL(*mock_frame, GetData())
|
ON_CALL(*mock_frame, GetData())
|
||||||
.WillByDefault(Return(rtc::ArrayView<uint8_t>(&payload[0], 10)));
|
.WillByDefault(Return(rtc::ArrayView<uint8_t>(&payload[0], 10)));
|
||||||
EXPECT_TRUE_WAIT(callback, 1000);
|
EXPECT_THAT(WaitUntil([&] { return callback; }, IsTrue()), IsRtcOk());
|
||||||
callback->OnTransformedFrame(std::move(mock_frame));
|
callback->OnTransformedFrame(std::move(mock_frame));
|
||||||
|
|
||||||
// Allow things posted back to the encoder queue to run.
|
// Allow things posted back to the encoder queue to run.
|
||||||
time_controller_.AdvanceTime(TimeDelta::Millis(10));
|
time_controller_.AdvanceTime(TimeDelta::Millis(10));
|
||||||
|
|
||||||
// Ensure the audio levels is set on the sent packet.
|
// Ensure the audio levels is set on the sent packet.
|
||||||
EXPECT_TRUE_WAIT(sent_audio_level, 1000);
|
EXPECT_THAT(WaitUntil([&] { return sent_audio_level; }, IsTrue()), IsRtcOk());
|
||||||
EXPECT_EQ(*sent_audio_level, audio_level);
|
EXPECT_EQ(*sent_audio_level, audio_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,15 +8,26 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "api/task_queue/task_queue_base.h"
|
||||||
|
#include "api/test/rtc_error_matchers.h"
|
||||||
|
#include "api/test/simulated_network.h"
|
||||||
|
#include "api/units/time_delta.h"
|
||||||
#include "audio/test/audio_end_to_end_test.h"
|
#include "audio/test/audio_end_to_end_test.h"
|
||||||
#include "rtc_base/gunit.h"
|
#include "call/audio_receive_stream.h"
|
||||||
|
#include "call/audio_send_stream.h"
|
||||||
#include "rtc_base/task_queue_for_test.h"
|
#include "rtc_base/task_queue_for_test.h"
|
||||||
#include "system_wrappers/include/sleep.h"
|
#include "test/call_test.h"
|
||||||
|
#include "test/gmock.h"
|
||||||
#include "test/gtest.h"
|
#include "test/gtest.h"
|
||||||
|
#include "test/wait_until.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
|
using ::testing::IsTrue;
|
||||||
using NonSenderRttTest = CallTest;
|
using NonSenderRttTest = CallTest;
|
||||||
|
|
||||||
TEST_F(NonSenderRttTest, NonSenderRttStats) {
|
TEST_F(NonSenderRttTest, NonSenderRttStats) {
|
||||||
@ -47,7 +58,10 @@ TEST_F(NonSenderRttTest, NonSenderRttStats) {
|
|||||||
// Wait until we have an RTT measurement, but no longer than
|
// Wait until we have an RTT measurement, but no longer than
|
||||||
// `kLongTimeoutMs`. This usually takes around 5 seconds, but in rare
|
// `kLongTimeoutMs`. This usually takes around 5 seconds, but in rare
|
||||||
// cases it can take more than 10 seconds.
|
// cases it can take more than 10 seconds.
|
||||||
EXPECT_TRUE_WAIT(HasRoundTripTimeMeasurement(), kLongTimeoutMs);
|
EXPECT_THAT(
|
||||||
|
WaitUntil([&] { return HasRoundTripTimeMeasurement(); }, IsTrue(),
|
||||||
|
{.timeout = webrtc::TimeDelta::Millis(kLongTimeoutMs)}),
|
||||||
|
IsRtcOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnStreamsStopped() override {
|
void OnStreamsStopped() override {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user