diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/media/remoting/mock_receiver_controller.h | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/media/remoting/mock_receiver_controller.h')
-rw-r--r-- | chromium/media/remoting/mock_receiver_controller.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/chromium/media/remoting/mock_receiver_controller.h b/chromium/media/remoting/mock_receiver_controller.h new file mode 100644 index 00000000000..e4c6da6c37b --- /dev/null +++ b/chromium/media/remoting/mock_receiver_controller.h @@ -0,0 +1,96 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MEDIA_REMOTING_MOCK_RECEIVER_CONTROLLER_H_ +#define MEDIA_REMOTING_MOCK_RECEIVER_CONTROLLER_H_ + +#include <memory> +#include <vector> + +#include "base/memory/scoped_refptr.h" +#include "base/no_destructor.h" +#include "media/mojo/mojom/remoting.mojom.h" +#include "media/remoting/receiver_controller.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "ui/gfx/geometry/size.h" + +namespace media { + +class MojoDecoderBufferWriter; + +namespace remoting { + +class MockRemotee : public mojom::Remotee { + public: + MockRemotee(); + ~MockRemotee() override; + + void BindMojoReceiver(mojo::PendingReceiver<Remotee> receiver); + + void SendAudioFrame(uint32_t frame_count, + scoped_refptr<DecoderBuffer> buffer); + void SendVideoFrame(uint32_t frame_count, + scoped_refptr<DecoderBuffer> buffer); + + // mojom::Remotee implementation + void OnRemotingSinkReady( + mojo::PendingRemote<mojom::RemotingSink> remoting_sink) override; + void SendMessageToSource(const std::vector<uint8_t>& message) override; + void StartDataStreams( + mojo::PendingRemote<mojom::RemotingDataStreamReceiver> audio_stream, + mojo::PendingRemote<mojom::RemotingDataStreamReceiver> video_stream) + override; + void OnFlushUntil(uint32_t audio_count, uint32_t video_count) override; + void OnVideoNaturalSizeChange(const gfx::Size& size) override; + + void Reset(); + + gfx::Size changed_size() { return changed_size_; } + uint32_t flush_audio_count() { return flush_audio_count_; } + uint32_t flush_video_count() { return flush_video_count_; } + + mojo::PendingRemote<mojom::Remotee> BindNewPipeAndPassRemote() { + return receiver_.BindNewPipeAndPassRemote(); + } + + mojo::Remote<mojom::RemotingDataStreamReceiver> audio_stream_; + mojo::Remote<mojom::RemotingDataStreamReceiver> video_stream_; + + private: + gfx::Size changed_size_; + + uint32_t flush_audio_count_{0}; + uint32_t flush_video_count_{0}; + + std::unique_ptr<MojoDecoderBufferWriter> audio_buffer_writer_; + std::unique_ptr<MojoDecoderBufferWriter> video_buffer_writer_; + + mojo::Remote<mojom::RemotingSink> remoting_sink_; + mojo::Receiver<mojom::Remotee> receiver_{this}; +}; + +class MockReceiverController : public ReceiverController { + public: + static MockReceiverController* GetInstance(); + + MockRemotee* mock_remotee() { return mock_remotee_.get(); } + + private: + friend base::NoDestructor<MockReceiverController>; + friend testing::StrictMock<MockReceiverController>; + friend testing::NiceMock<MockReceiverController>; + + MockReceiverController(); + ~MockReceiverController() override; + + void OnSendRpc(std::unique_ptr<std::vector<uint8_t>> message); + + std::unique_ptr<MockRemotee> mock_remotee_; +}; + +} // namespace remoting +} // namespace media + +#endif // MEDIA_REMOTING_MOCK_RECEIVER_CONTROLLER_H_ |