1 // Copyright 2013 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.
5 #ifndef MEDIA_RENDERERS_MOCK_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
6 #define MEDIA_RENDERERS_MOCK_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/single_thread_task_runner.h"
10 #include "media/renderers/gpu_video_accelerator_factories.h"
11 #include "media/video/video_decode_accelerator.h"
12 #include "media/video/video_encode_accelerator.h"
13 #include "testing/gmock/include/gmock/gmock.h"
24 class MockGpuVideoAcceleratorFactories
: public GpuVideoAcceleratorFactories
{
26 MockGpuVideoAcceleratorFactories();
28 bool IsGpuVideoAcceleratorEnabled() override
;
29 // CreateVideo{Decode,Encode}Accelerator returns scoped_ptr, which the mocking
30 // framework does not want. Trampoline them.
31 MOCK_METHOD0(DoCreateVideoDecodeAccelerator
, VideoDecodeAccelerator
*());
32 MOCK_METHOD0(DoCreateVideoEncodeAccelerator
, VideoEncodeAccelerator
*());
34 MOCK_METHOD5(CreateTextures
,
36 const gfx::Size
& size
,
37 std::vector
<uint32
>* texture_ids
,
38 std::vector
<gpu::Mailbox
>* texture_mailboxes
,
39 uint32 texture_target
));
40 MOCK_METHOD1(DeleteTexture
, void(uint32 texture_id
));
41 MOCK_METHOD1(WaitSyncPoint
, void(uint32 sync_point
));
42 MOCK_METHOD0(GetTaskRunner
, scoped_refptr
<base::SingleThreadTaskRunner
>());
43 MOCK_METHOD0(GetVideoDecodeAcceleratorSupportedProfiles
,
44 VideoDecodeAccelerator::SupportedProfiles());
45 MOCK_METHOD0(GetVideoEncodeAcceleratorSupportedProfiles
,
46 VideoEncodeAccelerator::SupportedProfiles());
48 scoped_ptr
<gfx::GpuMemoryBuffer
> AllocateGpuMemoryBuffer(
49 const gfx::Size
& size
,
50 gfx::BufferFormat format
,
51 gfx::BufferUsage usage
) override
;
53 bool ShouldUseGpuMemoryBuffersForVideoFrames() const override
;
54 unsigned ImageTextureTarget() override
;
55 VideoPixelFormat
VideoFrameOutputFormat() override
{
56 return video_frame_output_format_
;
59 void SetVideoFrameOutputFormat(
60 const VideoPixelFormat video_frame_output_format
) {
61 video_frame_output_format_
= video_frame_output_format
;
64 void SetFailToAllocateGpuMemoryBufferForTesting(bool fail
) {
65 fail_to_allocate_gpu_memory_buffer_
= fail
;
68 MOCK_METHOD0(GetGLES2Interface
, gpu::gles2::GLES2Interface
*());
70 scoped_ptr
<base::SharedMemory
> CreateSharedMemory(size_t size
) override
;
72 scoped_ptr
<VideoDecodeAccelerator
> CreateVideoDecodeAccelerator() override
;
74 scoped_ptr
<VideoEncodeAccelerator
> CreateVideoEncodeAccelerator() override
;
77 ~MockGpuVideoAcceleratorFactories() override
;
79 DISALLOW_COPY_AND_ASSIGN(MockGpuVideoAcceleratorFactories
);
81 VideoPixelFormat video_frame_output_format_
= PIXEL_FORMAT_I420
;
83 bool fail_to_allocate_gpu_memory_buffer_
= false;
88 #endif // MEDIA_RENDERERS_MOCK_GPU_VIDEO_ACCELERATOR_FACTORIES_H_