Refactor CallStats2Test to not use ProcessThread.

Bug: None
Change-Id: I93bed50d03c2b15c03f57b6db6dd34a038e1ba58
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242369
Auto-Submit: Niels Moller <nisse@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35571}
This commit is contained in:
Niels Möller
2021-12-22 15:44:54 +01:00
committed by WebRTC LUCI CQ
parent db0df4d8fd
commit 8d6cd55b60
2 changed files with 8 additions and 13 deletions

View File

@ -726,7 +726,6 @@ if (rtc_include_tests) {
"../modules/rtp_rtcp", "../modules/rtp_rtcp",
"../modules/rtp_rtcp:mock_rtp_rtcp", "../modules/rtp_rtcp:mock_rtp_rtcp",
"../modules/rtp_rtcp:rtp_rtcp_format", "../modules/rtp_rtcp:rtp_rtcp_format",
"../modules/utility",
"../modules/video_coding", "../modules/video_coding",
"../modules/video_coding:codec_globals_headers", "../modules/video_coding:codec_globals_headers",
"../modules/video_coding:encoded_frame", "../modules/video_coding:encoded_frame",

View File

@ -12,8 +12,8 @@
#include <memory> #include <memory>
#include "api/task_queue/default_task_queue_factory.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/utility/include/process_thread.h"
#include "rtc_base/task_utils/to_queued_task.h" #include "rtc_base/task_utils/to_queued_task.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
#include "system_wrappers/include/metrics.h" #include "system_wrappers/include/metrics.h"
@ -38,31 +38,27 @@ class MockStatsObserver : public CallStatsObserver {
class CallStats2Test : public ::testing::Test { class CallStats2Test : public ::testing::Test {
public: public:
CallStats2Test() { CallStats2Test() { call_stats_.EnsureStarted(); }
call_stats_.EnsureStarted();
process_thread_->Start();
}
~CallStats2Test() override { process_thread_->Stop(); }
// Queues an rtt update call on the process thread. // Queues an rtt update call on the process thread.
void AsyncSimulateRttUpdate(int64_t rtt) { void AsyncSimulateRttUpdate(int64_t rtt) {
RtcpRttStats* rtcp_rtt_stats = call_stats_.AsRtcpRttStats(); RtcpRttStats* rtcp_rtt_stats = call_stats_.AsRtcpRttStats();
process_thread_->PostTask(ToQueuedTask( task_queue_.PostTask(ToQueuedTask(
[rtcp_rtt_stats, rtt] { rtcp_rtt_stats->OnRttUpdate(rtt); })); [rtcp_rtt_stats, rtt] { rtcp_rtt_stats->OnRttUpdate(rtt); }));
} }
protected: protected:
void FlushProcessAndWorker() { void FlushProcessAndWorker() {
process_thread_->PostTask( task_queue_.PostTask(
ToQueuedTask([this] { loop_.PostTask([this]() { loop_.Quit(); }); })); ToQueuedTask([this] { loop_.PostTask([this]() { loop_.Quit(); }); }));
loop_.Run(); loop_.Run();
} }
test::RunLoop loop_; test::RunLoop loop_;
// TODO(nisse): Don't use process thread. rtc::TaskQueue task_queue_{CreateDefaultTaskQueueFactory()->CreateTaskQueue(
std::unique_ptr<ProcessThread> process_thread_{ "CallStats",
ProcessThread::Create("CallStats")}; TaskQueueFactory::Priority::NORMAL)};
// Note: Since rtc::Thread doesn't support injecting a Clock, we're going // Note: Since rtc::Thread doesn't support injecting a Clock, we're going
// to be using a mix of the fake clock (used by CallStats) as well as the // to be using a mix of the fake clock (used by CallStats) as well as the
// system clock (used by rtc::Thread). This isn't ideal and will result in // system clock (used by rtc::Thread). This isn't ideal and will result in