// 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 #include #include "base/memory/scoped_refptr.h" #include "base/no_destructor.h" #include "media/mojo/mojom/media_types.mojom.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 receiver); void SendAudioFrame(uint32_t frame_count, scoped_refptr buffer); void SendVideoFrame(uint32_t frame_count, scoped_refptr buffer); // mojom::Remotee implementation void OnRemotingSinkReady( mojo::PendingRemote remoting_sink) override; void SendMessageToSource(const std::vector& message) override; void StartDataStreams( mojo::PendingRemote audio_stream, mojo::PendingRemote 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 BindNewPipeAndPassRemote() { return receiver_.BindNewPipeAndPassRemote(); } mojo::Remote audio_stream_; mojo::Remote video_stream_; private: gfx::Size changed_size_; uint32_t flush_audio_count_{0}; uint32_t flush_video_count_{0}; std::unique_ptr audio_buffer_writer_; std::unique_ptr video_buffer_writer_; mojo::Remote remoting_sink_; mojo::Receiver receiver_{this}; }; class MockReceiverController : public ReceiverController { public: static MockReceiverController* GetInstance(); MockRemotee* mock_remotee() { return mock_remotee_.get(); } private: friend base::NoDestructor; friend testing::StrictMock; friend testing::NiceMock; MockReceiverController(); ~MockReceiverController() override; void OnSendRpc(std::vector message); std::unique_ptr mock_remotee_; }; } // namespace remoting } // namespace media #endif // MEDIA_REMOTING_MOCK_RECEIVER_CONTROLLER_H_