Try to make PipeWire test more reliable
It appears to be still failing occasionally so add one more event to verify streams connected successfully in order to verify whether we sent and received buffers properly in the next step. Bug: webrtc:14644 Change-Id: I08822b15452fc845d68cbff1b01ae6b6f7c1f486 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282842 Reviewed-by: Alexander Cooper <alcooper@chromium.org> Reviewed-by: Jeremy Leconte <jleconte@google.com> Commit-Queue: Jan Grulich <grulja@gmail.com> Cr-Commit-Position: refs/heads/main@{#38598}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
01e8a2ad7c
commit
7ca522dcec
@ -224,6 +224,10 @@ void SharedScreenCastStreamPrivate::OnStreamStateChanged(
|
|||||||
RTC_LOG(LS_ERROR) << "PipeWire stream state error: " << error_message;
|
RTC_LOG(LS_ERROR) << "PipeWire stream state error: " << error_message;
|
||||||
break;
|
break;
|
||||||
case PW_STREAM_STATE_PAUSED:
|
case PW_STREAM_STATE_PAUSED:
|
||||||
|
if (that->observer_ && old_state != PW_STREAM_STATE_STREAMING) {
|
||||||
|
that->observer_->OnStreamConfigured();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case PW_STREAM_STATE_STREAMING:
|
case PW_STREAM_STATE_STREAMING:
|
||||||
case PW_STREAM_STATE_UNCONNECTED:
|
case PW_STREAM_STATE_UNCONNECTED:
|
||||||
case PW_STREAM_STATE_CONNECTING:
|
case PW_STREAM_STATE_CONNECTING:
|
||||||
|
|||||||
@ -34,6 +34,7 @@ class RTC_EXPORT SharedScreenCastStream
|
|||||||
virtual void OnCursorShapeChanged() = 0;
|
virtual void OnCursorShapeChanged() = 0;
|
||||||
virtual void OnDesktopFrameChanged() = 0;
|
virtual void OnDesktopFrameChanged() = 0;
|
||||||
virtual void OnFailedToProcessBuffer() = 0;
|
virtual void OnFailedToProcessBuffer() = 0;
|
||||||
|
virtual void OnStreamConfigured() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Observer() = default;
|
Observer() = default;
|
||||||
|
|||||||
@ -23,6 +23,7 @@
|
|||||||
#include "test/gtest.h"
|
#include "test/gtest.h"
|
||||||
|
|
||||||
using ::testing::_;
|
using ::testing::_;
|
||||||
|
using ::testing::AtLeast;
|
||||||
using ::testing::Ge;
|
using ::testing::Ge;
|
||||||
using ::testing::Invoke;
|
using ::testing::Invoke;
|
||||||
|
|
||||||
@ -39,16 +40,8 @@ class PipeWireStreamTest : public ::testing::Test,
|
|||||||
public TestScreenCastStreamProvider::Observer,
|
public TestScreenCastStreamProvider::Observer,
|
||||||
public SharedScreenCastStream::Observer {
|
public SharedScreenCastStream::Observer {
|
||||||
public:
|
public:
|
||||||
PipeWireStreamTest()
|
PipeWireStreamTest() = default;
|
||||||
: test_screencast_stream_provider_(
|
~PipeWireStreamTest() = default;
|
||||||
std::make_unique<TestScreenCastStreamProvider>(this,
|
|
||||||
kWidth,
|
|
||||||
kHeight)) {
|
|
||||||
shared_screencast_stream_ = SharedScreenCastStream::CreateDefault();
|
|
||||||
shared_screencast_stream_->SetObserver(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
~PipeWireStreamTest() override {}
|
|
||||||
|
|
||||||
// FakeScreenCastPortal::Observer
|
// FakeScreenCastPortal::Observer
|
||||||
MOCK_METHOD(void, OnBufferAdded, (), (override));
|
MOCK_METHOD(void, OnBufferAdded, (), (override));
|
||||||
@ -62,6 +55,14 @@ class PipeWireStreamTest : public ::testing::Test,
|
|||||||
MOCK_METHOD(void, OnCursorShapeChanged, (), (override));
|
MOCK_METHOD(void, OnCursorShapeChanged, (), (override));
|
||||||
MOCK_METHOD(void, OnDesktopFrameChanged, (), (override));
|
MOCK_METHOD(void, OnDesktopFrameChanged, (), (override));
|
||||||
MOCK_METHOD(void, OnFailedToProcessBuffer, (), (override));
|
MOCK_METHOD(void, OnFailedToProcessBuffer, (), (override));
|
||||||
|
MOCK_METHOD(void, OnStreamConfigured, (), (override));
|
||||||
|
|
||||||
|
void SetUp() override {
|
||||||
|
shared_screencast_stream_ = SharedScreenCastStream::CreateDefault();
|
||||||
|
shared_screencast_stream_->SetObserver(this);
|
||||||
|
test_screencast_stream_provider_ =
|
||||||
|
std::make_unique<TestScreenCastStreamProvider>(this, kWidth, kHeight);
|
||||||
|
}
|
||||||
|
|
||||||
void StartScreenCastStream(uint32_t stream_node_id) {
|
void StartScreenCastStream(uint32_t stream_node_id) {
|
||||||
shared_screencast_stream_->StartScreenCastStream(stream_node_id);
|
shared_screencast_stream_->StartScreenCastStream(stream_node_id);
|
||||||
@ -78,23 +79,24 @@ class PipeWireStreamTest : public ::testing::Test,
|
|||||||
TEST_F(PipeWireStreamTest, TestPipeWire) {
|
TEST_F(PipeWireStreamTest, TestPipeWire) {
|
||||||
// Set expectations for PipeWire to successfully connect both streams
|
// Set expectations for PipeWire to successfully connect both streams
|
||||||
rtc::Event waitConnectEvent;
|
rtc::Event waitConnectEvent;
|
||||||
rtc::Event waitAddBufferEvent;
|
rtc::Event waitStartStreamingEvent;
|
||||||
|
|
||||||
EXPECT_CALL(*this, OnStreamReady(_))
|
EXPECT_CALL(*this, OnStreamReady(_))
|
||||||
.WillOnce(Invoke(this, &PipeWireStreamTest::StartScreenCastStream));
|
.WillOnce(Invoke(this, &PipeWireStreamTest::StartScreenCastStream));
|
||||||
EXPECT_CALL(*this, OnStartStreaming).WillOnce([&waitConnectEvent] {
|
EXPECT_CALL(*this, OnStreamConfigured).WillOnce([&waitConnectEvent] {
|
||||||
waitConnectEvent.Set();
|
waitConnectEvent.Set();
|
||||||
});
|
});
|
||||||
EXPECT_CALL(*this, OnBufferAdded).WillRepeatedly([&waitAddBufferEvent] {
|
EXPECT_CALL(*this, OnBufferAdded).Times(AtLeast(3));
|
||||||
waitAddBufferEvent.Set();
|
EXPECT_CALL(*this, OnStartStreaming).WillOnce([&waitStartStreamingEvent] {
|
||||||
|
waitStartStreamingEvent.Set();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Give it some time to connect, the order between these shouldn't matter, but
|
// Give it some time to connect, the order between these shouldn't matter, but
|
||||||
// we need to be sure we are connected before we proceed to work with frames.
|
// we need to be sure we are connected before we proceed to work with frames.
|
||||||
waitConnectEvent.Wait(kLongWait);
|
waitConnectEvent.Wait(kLongWait);
|
||||||
|
|
||||||
// Wait for an empty buffer to be added
|
// Wait until we start streaming
|
||||||
waitAddBufferEvent.Wait(kShortWait);
|
waitStartStreamingEvent.Wait(kShortWait);
|
||||||
|
|
||||||
rtc::Event frameRetrievedEvent;
|
rtc::Event frameRetrievedEvent;
|
||||||
EXPECT_CALL(*this, OnFrameRecorded).Times(3);
|
EXPECT_CALL(*this, OnFrameRecorded).Times(3);
|
||||||
|
|||||||
Reference in New Issue
Block a user