Bug 1790097 - Vendor libwebrtc from 83830f316e

Upstream commit: https://webrtc.googlesource.com/src/+/83830f316e264537af77289fc695187a5e7b5cee
    Delete TestListener and top-level thread wrapping.

    Instead use rtc::AutoThread in tests that need that.

    Bug: webrtc:9714
    Change-Id: I1f33b1b2d321770d062504dd9ef86d66a345dd42
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254681
    Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
    Commit-Queue: Niels Moller <nisse@webrtc.org>
    Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#36950}
This commit is contained in:
Michael Froman 2022-09-21 17:36:35 -05:00
Родитель fb4870adee
Коммит 31f89c14e6
69 изменённых файлов: 143 добавлений и 98 удалений

3
third_party/libwebrtc/README.moz-ff-commit поставляемый
Просмотреть файл

@ -14388,3 +14388,6 @@ c0a9f35248
# MOZ_LIBWEBRTC_SRC=/home/mfroman/git-checkouts/moz-libwebrtc MOZ_LIBWEBRTC_COMMIT=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
be2fb41b32
# MOZ_LIBWEBRTC_SRC=/home/mfroman/git-checkouts/moz-libwebrtc MOZ_LIBWEBRTC_COMMIT=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
83830f316e

2
third_party/libwebrtc/README.mozilla поставляемый
Просмотреть файл

@ -9612,3 +9612,5 @@ libwebrtc updated from /home/mfroman/git-checkouts/moz-libwebrtc commit mozpatch
libwebrtc updated from /home/mfroman/git-checkouts/moz-libwebrtc commit mozpatches on 2022-09-21T21:54:09.478891.
# python3 vendor-libwebrtc.py --from-local /home/mfroman/git-checkouts/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /home/mfroman/git-checkouts/moz-libwebrtc commit mozpatches on 2022-09-21T21:55:20.479979.
# python3 vendor-libwebrtc.py --from-local /home/mfroman/git-checkouts/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /home/mfroman/git-checkouts/moz-libwebrtc commit mozpatches on 2022-09-21T22:36:30.204061.

Просмотреть файл

@ -68,6 +68,7 @@ TEST(ChannelReceiveFrameTransformerDelegateTest,
// transformer, it passes it to the channel using the ReceiveFrameCallback.
TEST(ChannelReceiveFrameTransformerDelegateTest,
TransformRunsChannelReceiveCallback) {
rtc::AutoThread main_thread;
rtc::scoped_refptr<MockFrameTransformer> mock_frame_transformer =
rtc::make_ref_counted<NiceMock<MockFrameTransformer>>();
MockChannelReceive mock_channel;
@ -99,6 +100,7 @@ TEST(ChannelReceiveFrameTransformerDelegateTest,
// after resetting the delegate.
TEST(ChannelReceiveFrameTransformerDelegateTest,
OnTransformedDoesNotRunChannelReceiveCallbackAfterReset) {
rtc::AutoThread main_thread;
rtc::scoped_refptr<MockFrameTransformer> mock_frame_transformer =
rtc::make_ref_counted<testing::NiceMock<MockFrameTransformer>>();
MockChannelReceive mock_channel;

Просмотреть файл

@ -33,6 +33,7 @@ if (rtc_include_tests) {
"../../../modules/utility:mock_process_thread",
"../../../test:audio_codec_mocks",
"../../../test:mock_transport",
"../../../test:run_loop",
"../../../test:test_support",
]
}
@ -74,6 +75,7 @@ if (rtc_include_tests) {
"../../../rtc_base:logging",
"../../../rtc_base:rtc_event",
"../../../test:mock_transport",
"../../../test:run_loop",
"../../../test:test_support",
]
}
@ -92,6 +94,7 @@ if (rtc_include_tests) {
"../../../rtc_base:logging",
"../../../rtc_base:rtc_event",
"../../../test:mock_transport",
"../../../test:run_loop",
"../../../test:test_support",
]
}

Просмотреть файл

@ -9,6 +9,7 @@
*/
#include "audio/voip/audio_egress.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/call/transport.h"
#include "api/task_queue/default_task_queue_factory.h"
@ -20,6 +21,7 @@
#include "test/gmock.h"
#include "test/gtest.h"
#include "test/mock_transport.h"
#include "test/run_loop.h"
namespace webrtc {
namespace {
@ -98,6 +100,7 @@ class AudioEgressTest : public ::testing::Test {
return frame;
}
test::RunLoop run_loop_;
// SimulatedClock doesn't directly affect this testcase as the the
// AudioFrame's timestamp is driven by GetAudioFrame.
SimulatedClock fake_clock_;

Просмотреть файл

@ -9,6 +9,7 @@
*/
#include "audio/voip/audio_ingress.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/call/transport.h"
@ -21,6 +22,7 @@
#include "test/gmock.h"
#include "test/gtest.h"
#include "test/mock_transport.h"
#include "test/run_loop.h"
namespace webrtc {
namespace {
@ -91,6 +93,7 @@ class AudioIngressTest : public ::testing::Test {
return frame;
}
test::RunLoop run_loop_;
SimulatedClock fake_clock_;
SineWaveGenerator wave_generator_;
NiceMock<MockTransport> transport_;

Просмотреть файл

@ -9,6 +9,7 @@
*/
#include "audio/voip/voip_core.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/task_queue/default_task_queue_factory.h"
@ -16,6 +17,7 @@
#include "modules/audio_processing/include/mock_audio_processing.h"
#include "test/gtest.h"
#include "test/mock_transport.h"
#include "test/run_loop.h"
namespace webrtc {
namespace {
@ -46,6 +48,7 @@ class VoipCoreTest : public ::testing::Test {
std::move(audio_processing));
}
test::RunLoop run_loop_;
std::unique_ptr<VoipCore> voip_core_;
NiceMock<MockTransport> transport_;
rtc::scoped_refptr<test::MockAudioDeviceModule> audio_device_;

1
third_party/libwebrtc/call/BUILD.gn поставляемый
Просмотреть файл

@ -505,6 +505,7 @@ if (rtc_include_tests) {
"../rtc_base:rtc_event",
"../rtc_base:safe_conversions",
"../rtc_base:task_queue_for_test",
"../rtc_base:threading",
"../rtc_base:timeutils",
"../rtc_base/synchronization:mutex",
"../system_wrappers",

Просмотреть файл

@ -135,6 +135,7 @@ class ResourceAdaptationProcessorTest : public ::testing::Test {
}
protected:
rtc::AutoThread main_thread_;
webrtc::test::ScopedKeyValueConfig field_trials_;
FakeFrameRateProvider frame_rate_provider_;
VideoStreamInputStateProvider input_state_provider_;

Просмотреть файл

@ -26,6 +26,7 @@
#include "modules/rtp_rtcp/source/byte_io.h"
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
#include "rtc_base/thread.h"
#include "test/gmock.h"
#include "test/gtest.h"
#include "test/mock_transport.h"
@ -96,6 +97,7 @@ class FlexfecReceiveStreamTest : public ::testing::Test {
receive_stream_->UnregisterFromTransport();
}
rtc::AutoThread main_thread_;
MockTransport rtcp_send_transport_;
FlexfecReceiveStream::Config config_;
MockRecoveredPacketReceiver recovered_packet_receiver_;

Просмотреть файл

@ -1263,6 +1263,7 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) {
// Test behavior when decoder factory fails to create a decoder (returns null).
TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, NullDecoder) {
rtc::AutoThread main_thread_;
// `engine` take ownership of the factories.
webrtc::MockVideoEncoderFactory* encoder_factory =
new webrtc::MockVideoEncoderFactory();
@ -1439,6 +1440,7 @@ class WebRtcVideoChannelEncodedFrameCallbackTest : public ::testing::Test {
}
static const std::vector<webrtc::SdpVideoFormat> kSdpVideoFormats;
rtc::AutoThread main_thread_;
webrtc::test::ScopedKeyValueConfig field_trials_;
webrtc::RtcEventLogNull event_log_;
std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory_;
@ -1723,6 +1725,7 @@ class WebRtcVideoChannelBaseTest : public ::testing::Test {
return cricket::StreamParams::CreateLegacy(kSsrc);
}
rtc::AutoThread main_thread_;
webrtc::RtcEventLogNull event_log_;
webrtc::test::ScopedKeyValueConfig field_trials_;
std::unique_ptr<webrtc::test::ScopedKeyValueConfig> override_field_trials_;

Просмотреть файл

@ -783,6 +783,7 @@ class WebRtcVoiceEngineTestFake : public ::testing::TestWithParam<bool> {
}
protected:
rtc::AutoThread main_thread_;
const bool use_null_apm_;
webrtc::test::ScopedKeyValueConfig field_trials_;
std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory_;
@ -3600,6 +3601,7 @@ TEST_P(WebRtcVoiceEngineTestFake, GetSourcesWithNonExistingSsrc) {
// Tests that the library initializes and shuts down properly.
TEST(WebRtcVoiceEngineTest, StartupShutdown) {
rtc::AutoThread main_thread;
for (bool use_null_apm : {false, true}) {
// If the VoiceEngine wants to gather available codecs early, that's fine
// but we never want it to create a decoder at this stage.
@ -3631,6 +3633,7 @@ TEST(WebRtcVoiceEngineTest, StartupShutdown) {
// Tests that reference counting on the external ADM is correct.
TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) {
rtc::AutoThread main_thread;
for (bool use_null_apm : {false, true}) {
std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory =
webrtc::CreateDefaultTaskQueueFactory();
@ -3720,6 +3723,7 @@ TEST(WebRtcVoiceEngineTest, HasCorrectPayloadTypeMapping) {
// Tests that VoE supports at least 32 channels
TEST(WebRtcVoiceEngineTest, Has32Channels) {
rtc::AutoThread main_thread;
for (bool use_null_apm : {false, true}) {
std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory =
webrtc::CreateDefaultTaskQueueFactory();
@ -3762,6 +3766,7 @@ TEST(WebRtcVoiceEngineTest, Has32Channels) {
// Test that we set our preferred codecs properly.
TEST(WebRtcVoiceEngineTest, SetRecvCodecs) {
rtc::AutoThread main_thread;
for (bool use_null_apm : {false, true}) {
std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory =
webrtc::CreateDefaultTaskQueueFactory();

Просмотреть файл

@ -78,6 +78,7 @@ class Peer {
} // namespace
TEST(DcSctpTransportTest, OpenSequence) {
rtc::AutoThread main_thread;
Peer peer_a;
peer_a.fake_packet_transport_.SetWritable(true);
@ -94,6 +95,7 @@ TEST(DcSctpTransportTest, OpenSequence) {
// Tests that the close sequence invoked from one end results in the stream to
// be reset from both ends and all the proper signals are sent.
TEST(DcSctpTransportTest, CloseSequence) {
rtc::AutoThread main_thread;
Peer peer_a;
Peer peer_b;
peer_a.fake_packet_transport_.SetDestination(&peer_b.fake_packet_transport_,
@ -135,6 +137,7 @@ TEST(DcSctpTransportTest, CloseSequence) {
// terminates properly. Both peers will think they initiated it, so no
// OnSignalClosingProcedureStartedRemotely should be called.
TEST(DcSctpTransportTest, CloseSequenceSimultaneous) {
rtc::AutoThread main_thread;
Peer peer_a;
Peer peer_b;
peer_a.fake_packet_transport_.SetDestination(&peer_b.fake_packet_transport_,

Просмотреть файл

@ -650,6 +650,7 @@ if (rtc_include_tests) {
"../../rtc_base:rtc_numerics",
"../../rtc_base:stringutils",
"../../rtc_base:task_queue_for_test",
"../../rtc_base:threading",
"../../rtc_base:timeutils",
"../../rtc_base/task_utils:to_queued_task",
"../../system_wrappers",

Просмотреть файл

@ -24,6 +24,7 @@
#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h"
#include "modules/rtp_rtcp/source/rtp_sender_video.h"
#include "rtc_base/rate_limiter.h"
#include "rtc_base/thread.h"
#include "test/gtest.h"
namespace webrtc {
@ -224,6 +225,7 @@ class RtpRtcpRtxNackTest : public ::testing::Test {
media_stream_.sequence_numbers_.sort();
}
rtc::AutoThread main_thread_;
std::unique_ptr<ReceiveStatistics> receive_statistics_;
std::unique_ptr<ModuleRtpRtcpImpl2> rtp_rtcp_module_;
std::unique_ptr<RTPSenderVideo> rtp_sender_video_;

Просмотреть файл

@ -21,6 +21,7 @@
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h"
#include "rtc_base/rate_limiter.h"
#include "rtc_base/thread.h"
#include "test/gmock.h"
#include "test/gtest.h"
#include "test/mock_transport.h"
@ -131,6 +132,7 @@ class RtcpSenderTest : public ::testing::Test {
return rtp_rtcp_impl_->GetFeedbackState();
}
rtc::AutoThread main_thread_;
SimulatedClock clock_;
TestTransport test_transport_;
std::unique_ptr<ReceiveStatistics> receive_statistics_;

Просмотреть файл

@ -19,6 +19,7 @@
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h"
#include "rtc_base/thread.h"
#include "test/field_trial.h"
#include "test/gmock.h"
#include "test/gtest.h"
@ -82,6 +83,7 @@ class RtpSenderAudioTest : public ::testing::Test {
rtp_module_->SetSequenceNumber(kSeqNum);
}
rtc::AutoThread main_thread_;
SimulatedClock fake_clock_;
LoopbackTransportTest transport_;
std::unique_ptr<ModuleRtpRtcpImpl2> rtp_module_;

Просмотреть файл

@ -38,6 +38,7 @@
#include "rtc_base/arraysize.h"
#include "rtc_base/rate_limiter.h"
#include "rtc_base/task_queue_for_test.h"
#include "rtc_base/thread.h"
#include "test/gmock.h"
#include "test/gtest.h"
#include "test/mock_frame_transformer.h"
@ -197,6 +198,7 @@ class RtpSenderVideoTest : public ::testing::TestWithParam<bool> {
int version);
protected:
rtc::AutoThread main_thread_;
const RtpRtcpInterface::Configuration config_;
FieldTrials field_trials_;
SimulatedClock fake_clock_;
@ -1416,6 +1418,7 @@ class RtpSenderVideoWithFrameTransformerTest : public ::testing::Test {
}
protected:
rtc::AutoThread main_thread_;
FieldTrialBasedConfig field_trials_;
SimulatedClock fake_clock_;
LoopbackTransportTest transport_;

Просмотреть файл

@ -92,6 +92,7 @@ class TestNackRequester : public ::testing::TestWithParam<bool>,
}
static constexpr int64_t kDefaultRttMs = 20;
rtc::AutoThread main_thread_;
test::RunLoop loop_;
std::unique_ptr<SimulatedClock> clock_;
test::ScopedKeyValueConfig field_trial_;
@ -400,6 +401,7 @@ class TestNackRequesterWithFieldTrial : public ::testing::Test,
void RequestKeyFrame() override { ++keyframes_requested_; }
test::ScopedKeyValueConfig nack_delay_field_trial_;
rtc::AutoThread main_thread_;
std::unique_ptr<SimulatedClock> clock_;
NackPeriodicProcessor nack_periodic_processor_;
NackRequester nack_module_;

Просмотреть файл

@ -49,10 +49,12 @@ class BasicAsyncResolverFactoryTest : public ::testing::Test,
// This test is primarily intended to let tools check that the created resolver
// doesn't leak.
TEST_F(BasicAsyncResolverFactoryTest, TestCreate) {
rtc::AutoThread main_thread;
TestCreate();
}
TEST(WrappingAsyncDnsResolverFactoryTest, TestCreateAndResolve) {
rtc::AutoThread main_thread;
WrappingAsyncDnsResolverFactory factory(
std::make_unique<BasicAsyncResolverFactory>());
@ -67,6 +69,7 @@ TEST(WrappingAsyncDnsResolverFactoryTest, TestCreateAndResolve) {
}
TEST(WrappingAsyncDnsResolverFactoryTest, WrapOtherResolver) {
rtc::AutoThread main_thread;
BasicAsyncResolverFactory non_owned_factory;
WrappingAsyncDnsResolverFactory factory(&non_owned_factory);
std::unique_ptr<AsyncDnsResolverInterface> resolver(factory.Create());
@ -92,11 +95,7 @@ void CallResolver(WrappingAsyncDnsResolverFactory& factory) {
}
TEST(WrappingAsyncDnsResolverFactoryDeathTest, DestroyResolverInCallback) {
// This test requires the main thread to be wrapped. So we defeat the
// workaround in test/test_main_lib.cc by explicitly wrapping the main
// thread here.
auto thread = rtc::Thread::CreateWithSocketServer();
thread->WrapCurrent();
rtc::AutoThread main_thread;
// TODO(bugs.webrtc.org/12652): Rewrite as death test in loop style when it
// works.
WrappingAsyncDnsResolverFactory factory(
@ -106,11 +105,6 @@ TEST(WrappingAsyncDnsResolverFactoryDeathTest, DestroyResolverInCallback) {
// we wrap the whole creation section in EXPECT_DEATH.
RTC_EXPECT_DEATH(CallResolver(factory),
"Check failed: !within_resolve_result_");
// If we get here, we have to unwrap the thread.
thread->Quit();
thread->Run();
thread->UnwrapCurrent();
thread = nullptr;
}
#endif

Просмотреть файл

@ -380,6 +380,7 @@ class DtlsTransportTestBase {
}
protected:
rtc::AutoThread main_thread_;
rtc::ScopedFakeClock fake_clock_;
DtlsTestClient client1_;
DtlsTestClient client2_;

Просмотреть файл

@ -37,7 +37,9 @@ class FakeIceTransport : public IceTransportInternal {
: name_(name),
component_(component),
network_thread_(network_thread ? network_thread
: rtc::Thread::Current()) {}
: rtc::Thread::Current()) {
RTC_DCHECK(network_thread_);
}
// Must be called either on the network thread, or after the network thread
// has been shut down.
~FakeIceTransport() override {

Просмотреть файл

@ -5150,6 +5150,7 @@ TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest, TestTcpTurn) {
// if the channel is not destroyed.
TEST(P2PTransportChannelResolverTest, HostnameCandidateIsResolved) {
ResolverFactoryFixture resolver_fixture;
rtc::AutoThread main_thread;
FakePortAllocator allocator(rtc::Thread::Current(), nullptr);
webrtc::IceTransportInit init;
init.set_port_allocator(&allocator);
@ -6082,6 +6083,7 @@ TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampeningBoth) {
}
TEST(P2PTransportChannel, InjectIceController) {
rtc::AutoThread main_thread_;
MockIceControllerFactory factory;
FakePortAllocator pa(rtc::Thread::Current(), nullptr);
EXPECT_CALL(factory, RecordIceControllerCreated()).Times(1);

Просмотреть файл

@ -218,6 +218,7 @@ class PseudoTcpTestBase : public ::testing::Test,
delete message->pdata;
}
rtc::AutoThread main_thread_;
PseudoTcpForTest local_;
PseudoTcpForTest remote_;
rtc::MemoryStream send_stream_;

Просмотреть файл

@ -18,6 +18,7 @@ BasicRegatheringController::BasicRegatheringController(
cricket::IceTransportInternal* ice_transport,
rtc::Thread* thread)
: config_(config), ice_transport_(ice_transport), thread_(thread) {
RTC_DCHECK(thread_);
RTC_DCHECK_RUN_ON(thread_);
RTC_DCHECK(ice_transport_);
ice_transport_->SignalStateChanged.connect(

Просмотреть файл

@ -67,6 +67,7 @@ class StunRequestTest : public ::testing::Test {
void OnTimeout() { timeout_ = true; }
protected:
rtc::AutoThread main_thread_;
StunRequestManager manager_;
int request_count_;
StunMessage* response_;

Просмотреть файл

@ -64,6 +64,7 @@ class StunServerTest : public ::testing::Test {
}
private:
rtc::AutoThread main_thread;
std::unique_ptr<rtc::VirtualSocketServer> ss_;
rtc::Thread network_;
std::unique_ptr<StunServer> server_;

Просмотреть файл

@ -50,6 +50,7 @@ class AudioRtpReceiverTest : public ::testing::Test {
receiver_->SetMediaChannel(nullptr);
}
rtc::AutoThread main_thread_;
rtc::Thread* worker_;
rtc::scoped_refptr<AudioRtpReceiver> receiver_;
cricket::MockVoiceMediaChannel media_channel_;

Просмотреть файл

@ -87,6 +87,7 @@ class ChannelManagerTest : public ::testing::Test {
// go out of scope.
}
rtc::AutoThread main_thread_;
std::unique_ptr<rtc::Thread> network_;
rtc::Thread* const worker_;
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>

Просмотреть файл

@ -1412,6 +1412,7 @@ class ChannelTest : public ::testing::Test, public sigslot::has_slots<> {
return static_cast<typename T::MediaChannel*>(channel2_->media_channel());
}
rtc::AutoThread main_thread_;
// TODO(pbos): Remove playout from all media channels and let renderers mute
// themselves.
const bool verify_playout_;

Просмотреть файл

@ -33,6 +33,7 @@ class DataChannelControllerTest : public ::testing::Test {
.WillByDefault(Return(rtc::Thread::Current()));
}
rtc::AutoThread main_thread_;
rtc::scoped_refptr<NiceMock<MockPeerConnectionInternal>> pc_;
};

Просмотреть файл

@ -100,6 +100,7 @@ class SctpDataChannelTest : public ::testing::Test {
webrtc_data_channel_->RegisterObserver(observer_.get());
}
rtc::AutoThread main_thread_;
webrtc::InternalDataChannelInit init_;
std::unique_ptr<FakeDataChannelController> controller_;
std::unique_ptr<FakeDataChannelObserver> observer_;

Просмотреть файл

@ -251,6 +251,7 @@ class DtlsSrtpTransportTest : public ::testing::Test,
SendRecvRtcpPackets();
}
rtc::AutoThread main_thread_;
std::unique_ptr<DtlsSrtpTransport> dtls_srtp_transport1_;
std::unique_ptr<DtlsSrtpTransport> dtls_srtp_transport2_;
webrtc::TransportObserver transport_observer1_;

Просмотреть файл

@ -85,6 +85,7 @@ class DtlsTransportTest : public ::testing::Test {
fake_dtls1->SetDestination(fake_dtls2.get());
}
rtc::AutoThread main_thread_;
rtc::scoped_refptr<DtlsTransport> transport_;
TestDtlsTransportObserver observer_;
};

Просмотреть файл

@ -214,6 +214,7 @@ class DtmfSenderTest : public ::testing::Test {
}
}
rtc::AutoThread main_thread_;
std::unique_ptr<FakeDtmfObserver> observer_;
std::unique_ptr<FakeDtmfProvider> provider_;
rtc::scoped_refptr<DtmfSender> dtmf_;

Просмотреть файл

@ -22,7 +22,10 @@
namespace webrtc {
class IceTransportTest : public ::testing::Test {};
class IceTransportTest : public ::testing::Test {
private:
rtc::AutoThread main_thread_;
};
TEST_F(IceTransportTest, CreateNonSelfDeletingTransport) {
auto cricket_transport =

Просмотреть файл

@ -346,6 +346,7 @@ class JsepTransportControllerTest : public JsepTransportController::Observer,
return true;
}
rtc::AutoThread main_thread_;
// Information received from signals from transport controller.
cricket::IceConnectionState connection_state_ =
cricket::kIceConnectionConnecting;

Просмотреть файл

@ -188,6 +188,7 @@ class JsepTransport2Test : public ::testing::Test, public sigslot::has_slots<> {
void OnRtcpMuxActive() { signal_rtcp_mux_active_received_ = true; }
rtc::AutoThread main_thread_;
std::unique_ptr<JsepTransport> jsep_transport_;
bool signal_rtcp_mux_active_received_ = false;
// The SrtpTransport is owned by `jsep_transport_`. Keep a raw pointer here

Просмотреть файл

@ -80,6 +80,7 @@ class MediaStreamTest : public ::testing::Test {
EXPECT_FALSE(track->enabled());
}
rtc::AutoThread main_thread_;
scoped_refptr<MediaStreamInterface> stream_;
scoped_refptr<AudioTrackInterface> audio_track_;
scoped_refptr<VideoTrackInterface> video_track_;

Просмотреть файл

@ -220,6 +220,7 @@ class PeerConnectionEndToEndBaseTest : public sigslot::has_slots<>,
}
protected:
rtc::AutoThread main_thread_;
rtc::PhysicalSocketServer pss_;
std::unique_ptr<rtc::Thread> network_thread_;
std::unique_ptr<rtc::Thread> worker_thread_;

Просмотреть файл

@ -154,6 +154,7 @@ class PeerConnectionFactoryTest : public ::testing::Test {
EXPECT_GT(codec.clock_rate, 0);
}
rtc::AutoThread main_thread_;
rtc::scoped_refptr<PeerConnectionFactoryInterface> factory_;
NullPeerConnectionObserver observer_;
std::unique_ptr<cricket::FakePortAllocator> port_allocator_;

Просмотреть файл

@ -111,6 +111,7 @@ class PeerConnectionHeaderExtensionTest
pc_factory, result.MoveValue(), std::move(observer));
}
rtc::AutoThread main_thread_;
std::vector<RtpHeaderExtensionCapability> extensions_;
};

Просмотреть файл

@ -1425,6 +1425,7 @@ class PeerConnectionIceConfigTest : public ::testing::Test {
pc_ = result.MoveValue();
}
rtc::AutoThread main_thread_;
rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_ = nullptr;
rtc::scoped_refptr<PeerConnectionInterface> pc_ = nullptr;
cricket::FakePortAllocator* port_allocator_ = nullptr;

Просмотреть файл

@ -142,6 +142,8 @@ class PeerConnectionRtpBaseTest : public ::testing::Test {
return std::make_unique<PeerConnectionWrapper>(
pc_factory_, result.MoveValue(), std::move(observer));
}
rtc::AutoThread main_thread_;
};
class PeerConnectionRtpTest

Просмотреть файл

@ -62,7 +62,6 @@ RemoteAudioSource::RemoteAudioSource(
}
RemoteAudioSource::~RemoteAudioSource() {
RTC_DCHECK_RUN_ON(main_thread_);
RTC_DCHECK(audio_observers_.empty());
if (!sinks_.empty()) {
RTC_LOG(LS_WARNING)

Просмотреть файл

@ -917,6 +917,7 @@ class RTCStatsCollectorTest : public ::testing::Test {
protected:
rtc::ScopedFakeClock fake_clock_;
rtc::AutoThread main_thread_;
rtc::scoped_refptr<FakePeerConnectionForStats> pc_;
std::unique_ptr<RTCStatsCollectorWrapper> stats_;
};
@ -3529,6 +3530,7 @@ class FakeRTCStatsCollector : public RTCStatsCollector,
};
TEST(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) {
rtc::AutoThread main_thread_;
auto pc = rtc::make_ref_counted<FakePeerConnectionForStats>();
rtc::scoped_refptr<FakeRTCStatsCollector> stats_collector(
FakeRTCStatsCollector::Create(pc.get(),

Просмотреть файл

@ -53,6 +53,7 @@ class RtpTransceiverTest : public testing::Test {
cricket::ChannelManager* channel_manager() { return channel_manager_.get(); }
private:
rtc::AutoThread main_thread_;
cricket::FakeMediaEngine fake_media_engine_;
rtc::UniqueRandomIdGenerator ssrc_generator_;
std::unique_ptr<cricket::ChannelManager> channel_manager_;
@ -151,6 +152,7 @@ class RtpTransceiverUnifiedPlanTest : public RtpTransceiverTest {
return sender;
}
rtc::AutoThread main_thread_;
rtc::scoped_refptr<MockRtpReceiverInternal> receiver_ = MockReceiver();
rtc::scoped_refptr<MockRtpSenderInternal> sender_ = MockSender();
rtc::scoped_refptr<RtpTransceiver> transceiver_;
@ -222,6 +224,7 @@ class RtpTransceiverTestForHeaderExtensions : public RtpTransceiverTest {
transceiver_->ClearChannel();
}
rtc::AutoThread main_thread_;
rtc::scoped_refptr<MockRtpReceiverInternal> receiver_ = MockReceiver();
rtc::scoped_refptr<MockRtpSenderInternal> sender_ = MockSender();

Просмотреть файл

@ -147,12 +147,14 @@ class SctpTransportTest : public ::testing::Test {
return static_cast<FakeCricketSctpTransport*>(transport_->internal());
}
rtc::AutoThread main_thread_;
rtc::scoped_refptr<SctpTransport> transport_;
rtc::scoped_refptr<DtlsTransport> dtls_transport_;
TestSctpTransportObserver observer_;
};
TEST(SctpTransportSimpleTest, CreateClearDelete) {
rtc::AutoThread main_thread;
std::unique_ptr<cricket::SctpTransportInternal> fake_cricket_sctp_transport =
absl::WrapUnique(new FakeCricketSctpTransport());
rtc::scoped_refptr<SctpTransport> sctp_transport =

Просмотреть файл

@ -95,6 +95,7 @@ class SdpOfferAnswerTest : public ::testing::Test {
rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_;
private:
rtc::AutoThread main_thread_;
};
TEST_F(SdpOfferAnswerTest, OnTrackReturnsProxiedObject) {

Просмотреть файл

@ -731,6 +731,9 @@ class StatsCollectorTest : public ::testing::Test {
EXPECT_EQ(rtc::SrtpCryptoSuiteToName(rtc::kSrtpAes128CmSha1_80),
srtp_crypto_suite);
}
private:
rtc::AutoThread main_thread_;
};
static rtc::scoped_refptr<MockRtpSenderInternal> CreateMockSender(

Просмотреть файл

@ -115,6 +115,8 @@ class FakeAdmTest : public ::testing::Test, public webrtc::AudioTransport {
return min_buffer_size;
}
rtc::AutoThread main_thread_;
mutable webrtc::Mutex mutex_;
int push_iterations_;

Просмотреть файл

@ -1896,6 +1896,7 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
SdpSemantics sdp_semantics_;
private:
rtc::AutoThread main_thread_; // Used as the signal thread by most tests.
// `ss_` is used by `network_thread_` so it must be destroyed later.
std::unique_ptr<rtc::VirtualSocketServer> ss_;
std::unique_ptr<rtc::FirewallSocketServer> fss_;

Просмотреть файл

@ -191,6 +191,7 @@ class TrackMediaInfoMapTest : public ::testing::Test {
}
protected:
rtc::AutoThread main_thread_;
cricket::VoiceMediaInfo* voice_media_info_;
cricket::VideoMediaInfo* video_media_info_;
std::vector<rtc::scoped_refptr<RtpSenderInternal>> rtp_senders_;

Просмотреть файл

@ -86,6 +86,7 @@ class VideoRtpReceiverTest : public testing::Test {
return receiver_->streams()[0]->FindVideoTrack("receiver")->GetSource();
}
rtc::AutoThread main_thread_;
std::unique_ptr<rtc::Thread> worker_thread_;
NiceMock<MockVideoMediaChannel> channel_;
rtc::scoped_refptr<VideoRtpReceiver> receiver_;

Просмотреть файл

@ -39,6 +39,7 @@ class VideoTrackTest : public ::testing::Test {
}
protected:
rtc::AutoThread main_thread_;
rtc::scoped_refptr<FakeVideoTrackSource> video_track_source_;
rtc::scoped_refptr<VideoTrack> video_track_;
cricket::FakeFrameSource frame_source_;

Просмотреть файл

@ -17,6 +17,7 @@
namespace rtc {
TEST(FifoBufferTest, TestAll) {
rtc::AutoThread main_thread;
const size_t kSize = 16;
const char in[kSize * 2 + 1] = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
char out[kSize * 2];
@ -213,6 +214,7 @@ TEST(FifoBufferTest, TestAll) {
}
TEST(FifoBufferTest, FullBufferCheck) {
rtc::AutoThread main_thread;
FifoBuffer buff(10);
buff.ConsumeWriteBuffer(10);

Просмотреть файл

@ -221,6 +221,7 @@ bool TestConnectivity(const SocketAddress& src, const IPAddress& dst) {
void TestPhysicalInternal(const SocketAddress& int_addr) {
webrtc::test::ScopedKeyValueConfig field_trials;
rtc::AutoThread main_thread;
PhysicalSocketServer socket_server;
BasicNetworkManager network_manager(nullptr, &socket_server, &field_trials);
network_manager.StartUpdating();
@ -292,6 +293,7 @@ class TestVirtualSocketServer : public VirtualSocketServer {
} // namespace
void TestVirtualInternal(int family) {
rtc::AutoThread main_thread;
std::unique_ptr<TestVirtualSocketServer> int_vss(
new TestVirtualSocketServer());
std::unique_ptr<TestVirtualSocketServer> ext_vss(

Просмотреть файл

@ -319,6 +319,7 @@ class NetworkTest : public ::testing::Test, public sigslot::has_slots<> {
protected:
webrtc::test::ScopedKeyValueConfig field_trials_;
rtc::AutoThread main_thread_;
bool callback_called_;
};

Просмотреть файл

@ -84,6 +84,7 @@ TEST(OpenSSLAdapterTest, TestTransformAlpnProtocols) {
// Verifies that SSLStart works when OpenSSLAdapter is started in standalone
// mode.
TEST(OpenSSLAdapterTest, TestBeginSSLBeforeConnection) {
rtc::AutoThread main_thread;
Socket* async_socket = new MockAsyncSocket();
OpenSSLAdapter adapter(async_socket);
EXPECT_EQ(adapter.StartSSL("webrtc.org"), 0);
@ -91,6 +92,7 @@ TEST(OpenSSLAdapterTest, TestBeginSSLBeforeConnection) {
// Verifies that the adapter factory can create new adapters.
TEST(OpenSSLAdapterFactoryTest, CreateSingleOpenSSLAdapter) {
rtc::AutoThread main_thread;
OpenSSLAdapterFactory adapter_factory;
Socket* async_socket = new MockAsyncSocket();
auto simple_adapter = std::unique_ptr<OpenSSLAdapter>(
@ -101,6 +103,7 @@ TEST(OpenSSLAdapterFactoryTest, CreateSingleOpenSSLAdapter) {
// Verifies that setting a custom verifier still allows for adapters to be
// created.
TEST(OpenSSLAdapterFactoryTest, CreateWorksWithCustomVerifier) {
rtc::AutoThread main_thread;
MockCertVerifier* mock_verifier = new MockCertVerifier();
EXPECT_CALL(*mock_verifier, Verify(_)).WillRepeatedly(Return(true));
auto cert_verifier = std::unique_ptr<SSLCertificateVerifier>(mock_verifier);

Просмотреть файл

@ -392,6 +392,7 @@ TEST(OperationsChainTest, IsEmpty) {
}
TEST(OperationsChainTest, OnChainEmptyCallback) {
rtc::AutoThread main_thread;
OperationTrackerProxy operation_tracker_proxy;
operation_tracker_proxy.Initialize()->Wait(Event::kForever);

Просмотреть файл

@ -75,6 +75,7 @@ class RTCCertificateGeneratorTest : public ::testing::Test {
protected:
static constexpr int kGenerationTimeoutMs = 10000;
rtc::AutoThread main_thread_;
scoped_refptr<RTCCertificateGeneratorFixture> fixture_;
};

Просмотреть файл

@ -762,6 +762,7 @@ class SSLStreamAdapterTestBase : public ::testing::Test,
return server_ssl_->GetIdentityForTesting();
}
rtc::AutoThread main_thread_;
std::string client_cert_pem_;
std::string client_private_key_pem_;
rtc::KeyParams client_key_type_;

Просмотреть файл

@ -17,8 +17,8 @@
#include "rtc_base/async_udp_socket.h"
#include "rtc_base/logging.h"
#include "rtc_base/net_helpers.h"
#include "rtc_base/physical_socket_server.h"
#include "rtc_base/socket.h"
#include "rtc_base/socket_server.h"
#include "rtc_base/test_echo_server.h"
#include "rtc_base/thread.h"
#include "test/gtest.h"
@ -39,9 +39,9 @@ namespace {
}
void TestUdpInternal(const SocketAddress& loopback) {
Thread* main = Thread::Current();
Socket* socket =
main->socketserver()->CreateSocket(loopback.family(), SOCK_DGRAM);
rtc::PhysicalSocketServer socket_server;
rtc::AutoSocketServerThread main_thread(&socket_server);
Socket* socket = socket_server.CreateSocket(loopback.family(), SOCK_DGRAM);
socket->Bind(loopback);
TestClient client(std::make_unique<AsyncUDPSocket>(socket));
@ -53,11 +53,11 @@ void TestUdpInternal(const SocketAddress& loopback) {
}
void TestTcpInternal(const SocketAddress& loopback) {
Thread* main = Thread::Current();
TestEchoServer server(main, loopback);
rtc::PhysicalSocketServer socket_server;
rtc::AutoSocketServerThread main_thread(&socket_server);
TestEchoServer server(&main_thread, loopback);
Socket* socket =
main->socketserver()->CreateSocket(loopback.family(), SOCK_STREAM);
Socket* socket = socket_server.CreateSocket(loopback.family(), SOCK_STREAM);
std::unique_ptr<AsyncTCPSocket> tcp_socket = absl::WrapUnique(
AsyncTCPSocket::Create(socket, loopback, server.address()));
ASSERT_TRUE(tcp_socket != nullptr);

Просмотреть файл

@ -260,12 +260,12 @@ TEST(ThreadTest, DISABLED_Main) {
}
TEST(ThreadTest, CountBlockingCalls) {
rtc::AutoThread current;
// When the test runs, this will print out:
// (thread_unittest.cc:262): Blocking TestBody: total=2 (actual=1, could=1)
RTC_LOG_THREAD_BLOCK_COUNT();
#if RTC_DCHECK_IS_ON
rtc::Thread* current = rtc::Thread::Current();
ASSERT_TRUE(current);
rtc::Thread::ScopedCountBlockingCalls blocked_calls(
[&](uint32_t actual_block, uint32_t could_block) {
EXPECT_EQ(1u, actual_block);
@ -280,7 +280,7 @@ TEST(ThreadTest, CountBlockingCalls) {
// invoke, but should still count as an invoke that could block since we
// that the call to Invoke serves a purpose in some configurations (and should
// not be used a general way to call methods on the same thread).
current->Invoke<void>(RTC_FROM_HERE, []() {});
current.Invoke<void>(RTC_FROM_HERE, []() {});
EXPECT_EQ(0u, blocked_calls.GetBlockingCallCount());
EXPECT_EQ(1u, blocked_calls.GetCouldBeBlockingCallCount());
EXPECT_EQ(1u, blocked_calls.GetTotalBlockedCallCount());
@ -302,22 +302,20 @@ TEST(ThreadTest, CountBlockingCalls) {
#if RTC_DCHECK_IS_ON
TEST(ThreadTest, CountBlockingCallsOneCallback) {
rtc::Thread* current = rtc::Thread::Current();
ASSERT_TRUE(current);
rtc::AutoThread current;
bool was_called_back = false;
{
rtc::Thread::ScopedCountBlockingCalls blocked_calls(
[&](uint32_t actual_block, uint32_t could_block) {
was_called_back = true;
});
current->Invoke<void>(RTC_FROM_HERE, []() {});
current.Invoke<void>(RTC_FROM_HERE, []() {});
}
EXPECT_TRUE(was_called_back);
}
TEST(ThreadTest, CountBlockingCallsSkipCallback) {
rtc::Thread* current = rtc::Thread::Current();
ASSERT_TRUE(current);
rtc::AutoThread current;
bool was_called_back = false;
{
rtc::Thread::ScopedCountBlockingCalls blocked_calls(
@ -327,7 +325,7 @@ TEST(ThreadTest, CountBlockingCallsSkipCallback) {
// Changed `blocked_calls` to not issue the callback if there are 1 or
// fewer blocking calls (i.e. we set the minimum required number to 2).
blocked_calls.set_minimum_call_count_for_callback(2);
current->Invoke<void>(RTC_FROM_HERE, []() {});
current.Invoke<void>(RTC_FROM_HERE, []() {});
}
// We should not have gotten a call back.
EXPECT_FALSE(was_called_back);
@ -371,17 +369,18 @@ TEST(ThreadTest, Wrap) {
#if (!defined(NDEBUG) || RTC_DCHECK_IS_ON)
TEST(ThreadTest, InvokeToThreadAllowedReturnsTrueWithoutPolicies) {
rtc::AutoThread main_thread;
// Create and start the thread.
auto thread1 = Thread::CreateWithSocketServer();
auto thread2 = Thread::CreateWithSocketServer();
thread1->PostTask(ToQueuedTask(
[&]() { EXPECT_TRUE(thread1->IsInvokeToThreadAllowed(thread2.get())); }));
Thread* th_main = Thread::Current();
th_main->ProcessMessages(100);
main_thread.ProcessMessages(100);
}
TEST(ThreadTest, InvokeAllowedWhenThreadsAdded) {
rtc::AutoThread main_thread;
// Create and start the thread.
auto thread1 = Thread::CreateWithSocketServer();
auto thread2 = Thread::CreateWithSocketServer();
@ -396,11 +395,11 @@ TEST(ThreadTest, InvokeAllowedWhenThreadsAdded) {
EXPECT_TRUE(thread1->IsInvokeToThreadAllowed(thread3.get()));
EXPECT_FALSE(thread1->IsInvokeToThreadAllowed(thread4.get()));
}));
Thread* th_main = Thread::Current();
th_main->ProcessMessages(100);
main_thread.ProcessMessages(100);
}
TEST(ThreadTest, InvokesDisallowedWhenDisallowAllInvokes) {
rtc::AutoThread main_thread;
// Create and start the thread.
auto thread1 = Thread::CreateWithSocketServer();
auto thread2 = Thread::CreateWithSocketServer();
@ -410,20 +409,19 @@ TEST(ThreadTest, InvokesDisallowedWhenDisallowAllInvokes) {
thread1->PostTask(ToQueuedTask([&]() {
EXPECT_FALSE(thread1->IsInvokeToThreadAllowed(thread2.get()));
}));
Thread* th_main = Thread::Current();
th_main->ProcessMessages(100);
main_thread.ProcessMessages(100);
}
#endif // (!defined(NDEBUG) || RTC_DCHECK_IS_ON)
TEST(ThreadTest, InvokesAllowedByDefault) {
rtc::AutoThread main_thread;
// Create and start the thread.
auto thread1 = Thread::CreateWithSocketServer();
auto thread2 = Thread::CreateWithSocketServer();
thread1->PostTask(ToQueuedTask(
[&]() { EXPECT_TRUE(thread1->IsInvokeToThreadAllowed(thread2.get())); }));
Thread* th_main = Thread::Current();
th_main->ProcessMessages(100);
main_thread.ProcessMessages(100);
}
TEST(ThreadTest, Invoke) {
@ -653,6 +651,7 @@ TEST_F(ThreadQueueTest, DiposeHandlerWithPostedMessagePending) {
// all messages (both delayed and non delayed) up until the current time, on
// all registered message queues.
TEST(ThreadManager, ProcessAllMessageQueues) {
rtc::AutoThread main_thread;
Event entered_process_all_message_queues(true, false);
auto a = Thread::CreateWithSocketServer();
auto b = Thread::CreateWithSocketServer();
@ -678,7 +677,7 @@ TEST(ThreadManager, ProcessAllMessageQueues) {
b->PostTask(ToQueuedTask(incrementer));
a->PostDelayedTask(ToQueuedTask(incrementer), 0);
b->PostDelayedTask(ToQueuedTask(incrementer), 0);
rtc::Thread::Current()->PostTask(ToQueuedTask(event_signaler));
main_thread.PostTask(ToQueuedTask(event_signaler));
ThreadManager::ProcessAllMessageQueuesForTesting();
EXPECT_EQ(4, AtomicOps::AcquireLoad(&messages_processed));
@ -695,6 +694,7 @@ TEST(ThreadManager, ProcessAllMessageQueuesWithQuittingThread) {
// Test that ProcessAllMessageQueues doesn't hang if a queue clears its
// messages.
TEST(ThreadManager, ProcessAllMessageQueuesWithClearedQueue) {
rtc::AutoThread main_thread;
Event entered_process_all_message_queues(true, false);
auto t = Thread::CreateWithSocketServer();
t->Start();
@ -713,7 +713,7 @@ TEST(ThreadManager, ProcessAllMessageQueuesWithClearedQueue) {
// Post messages (both delayed and non delayed) to both threads.
t->PostTask(clearer);
rtc::Thread::Current()->PostTask(event_signaler);
main_thread.PostTask(event_signaler);
ThreadManager::ProcessAllMessageQueuesForTesting();
}
@ -759,6 +759,7 @@ class DEPRECATED_AsyncInvokeTest : public ::testing::Test {
enum { kWaitTimeout = 1000 };
DEPRECATED_AsyncInvokeTest() : int_value_(0), expected_thread_(nullptr) {}
rtc::AutoThread main_thread_;
int int_value_;
Thread* expected_thread_;
};

Просмотреть файл

@ -12,6 +12,7 @@
#include "rtc_base/ip_address.h"
#include "rtc_base/logging.h"
#include "rtc_base/thread.h"
#include "sdk/android/native_unittests/application_context_provider.h"
#include "sdk/android/src/jni/jni_helpers.h"
#include "test/gtest.h"
@ -67,6 +68,7 @@ class AndroidNetworkMonitorTest : public ::testing::Test {
protected:
test::ScopedKeyValueConfig field_trials_;
rtc::AutoThread main_thread_;
std::unique_ptr<jni::AndroidNetworkMonitor> network_monitor_;
};

58
third_party/libwebrtc/test/test_main_lib.cc поставляемый
Просмотреть файл

@ -102,62 +102,6 @@ namespace {
class TestMainImpl : public TestMain {
public:
// In order to set up a fresh rtc::Thread state for each test and avoid
// accidentally carrying over pending tasks that might be sent from one test
// and executed while another test is running, we inject a TestListener
// that sets up a new rtc::Thread instance for the main thread, per test.
class TestListener : public ::testing::EmptyTestEventListener {
public:
TestListener() = default;
private:
bool IsDeathTest(const char* test_case_name, const char* test_name) {
// Workaround to avoid wrapping the main thread when we run death tests.
// The approach we take for detecting death tests is essentially the same
// as gtest does internally. Gtest does this:
//
// static const char kDeathTestCaseFilter[] = "*DeathTest:*DeathTest/*";
// ::testing::internal::UnitTestOptions::MatchesFilter(
// test_case_name, kDeathTestCaseFilter);
//
// Our approach is a little more straight forward.
if (absl::EndsWith(test_case_name, "DeathTest"))
return true;
return absl::EndsWith(test_name, "DeathTest");
}
void OnTestStart(const ::testing::TestInfo& test_info) override {
if (!IsDeathTest(test_info.test_suite_name(), test_info.name())) {
// Ensure that main thread gets wrapped as an rtc::Thread.
// TODO(bugs.webrtc.org/9714): It might be better to avoid wrapping the
// main thread, or leave it to individual tests that need it. But as
// long as we have automatic thread wrapping, we need this to avoid that
// some other random thread (which one depending on which tests are run)
// gets automatically wrapped.
thread_ = rtc::Thread::CreateWithSocketServer();
thread_->WrapCurrent();
RTC_DCHECK_EQ(rtc::Thread::Current(), thread_.get());
} else {
RTC_LOG(LS_INFO) << "No thread auto wrap for death test.";
}
}
void OnTestEnd(const ::testing::TestInfo& test_info) override {
// Terminate the message loop. Note that if the test failed to clean
// up pending messages, this may execute part of the test. Ideally we
// should print a warning message here, or even fail the test if it leaks.
if (thread_) {
thread_->Quit(); // Signal quit.
thread_->Run(); // Flush + process Quit signal.
thread_->UnwrapCurrent();
thread_ = nullptr;
}
}
std::unique_ptr<rtc::Thread> thread_;
};
int Init(int* argc, char* argv[]) override { return Init(); }
int Init() override {
@ -191,8 +135,6 @@ class TestMainImpl : public TestMain {
rtc::InitializeSSL();
rtc::SSLStreamAdapter::EnableTimeCallbackForTesting();
::testing::UnitTest::GetInstance()->listeners().Append(new TestListener());
return 0;
}

Просмотреть файл

@ -110,6 +110,7 @@ if (rtc_include_tests) {
"../../rtc_base:rtc_numerics",
"../../rtc_base:rtc_task_queue",
"../../rtc_base:task_queue_for_test",
"../../rtc_base:threading",
"../../rtc_base/task_utils:to_queued_task",
"../../test:field_trial",
"../../test:rtc_expect_death",

Просмотреть файл

@ -16,6 +16,7 @@
#include "api/task_queue/task_queue_base.h"
#include "api/video_codecs/video_encoder.h"
#include "call/adaptation/test/mock_resource_listener.h"
#include "rtc_base/thread.h"
#include "test/gmock.h"
#include "test/gtest.h"
@ -52,6 +53,7 @@ class QualityScalerResourceTest : public ::testing::Test {
}
protected:
rtc::AutoThread main_thread_;
StrictMock<MockResourceListener> fake_resource_listener_;
FakeDegradationPreferenceProvider degradation_preference_provider_;
rtc::scoped_refptr<QualityScalerResource> quality_scaler_resource_;

Просмотреть файл

@ -97,6 +97,7 @@ TEST(RtpVideoStreamReceiverFrameTransformerDelegateTest, TransformFrame) {
TEST(RtpVideoStreamReceiverFrameTransformerDelegateTest,
ManageFrameOnTransformedFrame) {
rtc::AutoThread main_thread_;
TestRtpVideoFrameReceiver receiver;
auto mock_frame_transformer(
rtc::make_ref_counted<NiceMock<MockFrameTransformer>>());