using ::testing::_; using ::testing::AnyNumber; using ::testing::InSequence; using ::testing::Mock; using ::testing::NiceMock; using ::testing::SaveArg; using ::testing::StrictMock;
namespace webrtc {
namespace {
class VideoRtpReceiverTest : public testing::Test { protected: class MockVideoMediaSendChannel : public FakeVideoMediaSendChannel { public:
MockVideoMediaSendChannel(const VideoOptions& options,
TaskQueueBase* network_thread = Thread::Current())
: FakeVideoMediaSendChannel(options, network_thread) {}
MOCK_METHOD(void,
GenerateSendKeyFrame,
(uint32_t, const std::vector<std::string>&),
(override));
};
~VideoRtpReceiverTest() override { // Clear expectations that tests may have set up before calling // SetMediaChannel(nullptr).
Mock::VerifyAndClearExpectations(&channel_);
receiver_->Stop();
SetMediaChannel(nullptr);
}
TEST_F(VideoRtpReceiverTest,
GenerateKeyFrameOnChannelSwitchUnlessGenerateKeyframeCalled) { // A channel switch without previous call to GenerateKeyFrame shouldn't // cause a call to happen on the new channel.
MockVideoMediaReceiveChannel channel2{VideoOptions()};
EXPECT_CALL(channel_, RequestRecvKeyFrame).Times(0);
EXPECT_CALL(channel2, RequestRecvKeyFrame).Times(0);
SetMediaChannel(&channel2);
Mock::VerifyAndClearExpectations(&channel2);
// Generate a key frame. When we switch channel next time, we will have to // re-generate it as we don't know if it was eventually received
EXPECT_CALL(channel2, RequestRecvKeyFrame).Times(1);
Source()->GenerateKeyFrame();
MockVideoMediaReceiveChannel channel3{VideoOptions()};
EXPECT_CALL(channel3, RequestRecvKeyFrame);
SetMediaChannel(&channel3);
// Switching to a new channel should now not cause calls to GenerateKeyFrame.
StrictMock<MockVideoMediaReceiveChannel> channel4{VideoOptions()};
SetMediaChannel(&channel4);
// We must call SetMediaChannel(nullptr) here since the mock media channels // live on the stack and `receiver_` still has a pointer to those objects.
SetMediaChannel(nullptr);
}
// When clearing encoded frame buffer function, we need channel switches // to NOT set the callback again.
EXPECT_CALL(channel2, ClearRecordableEncodedFrameCallback);
Source()->RemoveEncodedSink(&sink);
StrictMock<MockVideoMediaReceiveChannel> channel3{VideoOptions()};
SetMediaChannel(&channel3);
// We must call SetMediaChannel(nullptr) here since the mock media channels // live on the stack and `receiver_` still has a pointer to those objects.
SetMediaChannel(nullptr);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.