1 // Copyright (c) 2015 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 #include "content/common/gpu/gpu_channel_test_common.h"
7 #include "base/test/test_simple_task_runner.h"
8 #include "base/thread_task_runner_handle.h"
9 #include "gpu/command_buffer/service/sync_point_manager.h"
10 #include "ipc/ipc_test_sink.h"
14 TestGpuChannelManager::TestGpuChannelManager(
16 base::SingleThreadTaskRunner
* task_runner
,
17 base::SingleThreadTaskRunner
* io_task_runner
,
18 gpu::SyncPointManager
* sync_point_manager
,
19 GpuMemoryBufferFactory
* gpu_memory_buffer_factory
)
20 : GpuChannelManager(nullptr,
26 gpu_memory_buffer_factory
),
29 TestGpuChannelManager::~TestGpuChannelManager() {
30 // Clear gpu channels here so that any IPC messages sent are handled using the
31 // overridden Send method.
32 gpu_channels_
.clear();
35 bool TestGpuChannelManager::Send(IPC::Message
* msg
) {
36 return sink_
->Send(msg
);
39 scoped_ptr
<GpuChannel
> TestGpuChannelManager::CreateGpuChannel(
40 gfx::GLShareGroup
* share_group
,
41 gpu::gles2::MailboxManager
* mailbox_manager
,
43 uint64_t client_tracing_id
,
44 bool allow_future_sync_points
,
45 bool allow_real_time_streams
) {
46 return make_scoped_ptr(new TestGpuChannel(
47 sink_
, this, share_group
, mailbox_manager
, task_runner_
.get(),
48 io_task_runner_
.get(), client_id
, client_tracing_id
,
49 allow_future_sync_points
, allow_real_time_streams
));
52 TestGpuChannel::TestGpuChannel(IPC::TestSink
* sink
,
53 GpuChannelManager
* gpu_channel_manager
,
54 gfx::GLShareGroup
* share_group
,
55 gpu::gles2::MailboxManager
* mailbox_manager
,
56 base::SingleThreadTaskRunner
* task_runner
,
57 base::SingleThreadTaskRunner
* io_task_runner
,
59 uint64_t client_tracing_id
,
60 bool allow_future_sync_points
,
61 bool allow_real_time_streams
)
62 : GpuChannel(gpu_channel_manager
,
71 allow_future_sync_points
,
72 allow_real_time_streams
),
75 TestGpuChannel::~TestGpuChannel() {
76 // Call stubs here so that any IPC messages sent are handled using the
77 // overridden Send method.
81 base::ProcessId
TestGpuChannel::GetClientPID() const {
82 return base::kNullProcessId
;
85 IPC::ChannelHandle
TestGpuChannel::Init(base::WaitableEvent
* shutdown_event
) {
86 filter_
->OnFilterAdded(sink_
);
87 return IPC::ChannelHandle(channel_id());
90 bool TestGpuChannel::Send(IPC::Message
* msg
) {
91 DCHECK(!msg
->is_sync());
92 return sink_
->Send(msg
);
95 // TODO(sunnyps): Use a mock memory buffer factory when necessary.
96 GpuChannelTestCommon::GpuChannelTestCommon()
97 : sink_(new IPC::TestSink
),
98 task_runner_(new base::TestSimpleTaskRunner
),
99 io_task_runner_(new base::TestSimpleTaskRunner
),
100 sync_point_manager_(new gpu::SyncPointManager(false)),
101 channel_manager_(new TestGpuChannelManager(sink_
.get(),
103 io_task_runner_
.get(),
104 sync_point_manager_
.get(),
107 GpuChannelTestCommon::~GpuChannelTestCommon() {}
109 } // namespace content