1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_MIRRORING_SERVICE_FAKE_VIDEO_CAPTURE_HOST_H_ 6 #define COMPONENTS_MIRRORING_SERVICE_FAKE_VIDEO_CAPTURE_HOST_H_ 7 8 #include <string> 9 10 #include "media/capture/mojom/video_capture.mojom.h" 11 #include "mojo/public/cpp/bindings/pending_receiver.h" 12 #include "mojo/public/cpp/bindings/receiver.h" 13 #include "mojo/public/cpp/bindings/remote.h" 14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gtest/include/gtest/gtest.h" 16 17 namespace mirroring { 18 19 class FakeVideoCaptureHost final : public media::mojom::VideoCaptureHost { 20 public: 21 explicit FakeVideoCaptureHost( 22 mojo::PendingReceiver<media::mojom::VideoCaptureHost> receiver); 23 ~FakeVideoCaptureHost() override; 24 25 // mojom::VideoCaptureHost implementations 26 MOCK_METHOD1(RequestRefreshFrame, void(const base::UnguessableToken&)); 27 MOCK_METHOD3(ReleaseBuffer, 28 void(const base::UnguessableToken&, 29 int32_t, 30 const media::VideoFrameFeedback&)); 31 MOCK_METHOD1(Pause, void(const base::UnguessableToken&)); 32 MOCK_METHOD3(Resume, 33 void(const base::UnguessableToken&, 34 const base::UnguessableToken&, 35 const media::VideoCaptureParams&)); 36 MOCK_METHOD0(OnStopped, void()); 37 MOCK_METHOD2(OnLog, void(const base::UnguessableToken&, const std::string&)); 38 MOCK_METHOD2(OnFrameDropped, 39 void(const base::UnguessableToken&, 40 media::VideoCaptureFrameDropReason)); 41 42 void Start(const base::UnguessableToken& device_id, 43 const base::UnguessableToken& session_id, 44 const media::VideoCaptureParams& params, 45 mojo::PendingRemote<media::mojom::VideoCaptureObserver> observer) 46 override; 47 void Stop(const base::UnguessableToken& device_id) override; 48 GetDeviceSupportedFormats(const base::UnguessableToken & device_id,const base::UnguessableToken & session_id,GetDeviceSupportedFormatsCallback callback)49 void GetDeviceSupportedFormats( 50 const base::UnguessableToken& device_id, 51 const base::UnguessableToken& session_id, 52 GetDeviceSupportedFormatsCallback callback) override {} GetDeviceFormatsInUse(const base::UnguessableToken & device_id,const base::UnguessableToken & session_id,GetDeviceFormatsInUseCallback callback)53 void GetDeviceFormatsInUse(const base::UnguessableToken& device_id, 54 const base::UnguessableToken& session_id, 55 GetDeviceFormatsInUseCallback callback) override {} 56 57 // Create one video frame and send it to |observer_|. 58 void SendOneFrame(const gfx::Size& size, base::TimeTicks capture_time); 59 60 private: 61 mojo::Receiver<media::mojom::VideoCaptureHost> receiver_; 62 mojo::Remote<media::mojom::VideoCaptureObserver> observer_; 63 64 DISALLOW_COPY_AND_ASSIGN(FakeVideoCaptureHost); 65 }; 66 67 } // namespace mirroring 68 69 #endif // COMPONENTS_MIRRORING_SERVICE_FAKE_VIDEO_CAPTURE_HOST_H_ 70