Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / common / gpu / gpu_channel_test_common.h
blobbe4109bd0dfd97a3afb69765de5d9844dd160d50
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 "base/memory/scoped_ptr.h"
6 #include "content/common/gpu/gpu_channel.h"
7 #include "content/common/gpu/gpu_channel_manager.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace base {
11 class TestSimpleTaskRunner;
12 } // namespace base
14 namespace IPC {
15 class TestSink;
16 } // namespace IPC
18 namespace content {
20 class SyncPointManager;
22 class TestGpuChannelManager : public GpuChannelManager {
23 public:
24 TestGpuChannelManager(IPC::TestSink* sink,
25 base::SingleThreadTaskRunner* task_runner,
26 base::SingleThreadTaskRunner* io_task_runner,
27 gpu::SyncPointManager* sync_point_manager,
28 GpuMemoryBufferFactory* gpu_memory_buffer_factory);
29 ~TestGpuChannelManager() override;
31 // IPC::Sender implementation.
32 bool Send(IPC::Message* msg) override;
34 protected:
35 scoped_ptr<GpuChannel> CreateGpuChannel(
36 gfx::GLShareGroup* share_group,
37 gpu::gles2::MailboxManager* mailbox_manager,
38 int client_id,
39 uint64_t client_tracing_id,
40 bool allow_future_sync_points,
41 bool allow_real_time_streams) override;
43 private:
44 IPC::TestSink* const sink_;
47 class TestGpuChannel : public GpuChannel {
48 public:
49 TestGpuChannel(IPC::TestSink* sink,
50 GpuChannelManager* gpu_channel_manager,
51 gfx::GLShareGroup* share_group,
52 gpu::gles2::MailboxManager* mailbox_manager,
53 base::SingleThreadTaskRunner* task_runner,
54 base::SingleThreadTaskRunner* io_task_runner,
55 int client_id,
56 uint64_t client_tracing_id,
57 bool allow_future_sync_points,
58 bool allow_real_time_streams);
59 ~TestGpuChannel() override;
61 base::ProcessId GetClientPID() const override;
63 IPC::ChannelHandle Init(base::WaitableEvent* shutdown_event) override;
65 // IPC::Sender implementation.
66 bool Send(IPC::Message* msg) override;
68 private:
69 IPC::TestSink* const sink_;
72 class GpuChannelTestCommon : public testing::Test {
73 public:
74 GpuChannelTestCommon();
75 ~GpuChannelTestCommon() override;
77 protected:
78 IPC::TestSink* sink() { return sink_.get(); }
79 GpuChannelManager* channel_manager() { return channel_manager_.get(); }
80 base::TestSimpleTaskRunner* task_runner() { return task_runner_.get(); }
82 private:
83 scoped_ptr<IPC::TestSink> sink_;
84 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
85 scoped_refptr<base::TestSimpleTaskRunner> io_task_runner_;
86 scoped_ptr<gpu::SyncPointManager> sync_point_manager_;
87 scoped_ptr<GpuChannelManager> channel_manager_;
90 } // namespace content