| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/run_loop.h" | 5 #include "base/run_loop.h" |
| 6 #include "base/synchronization/waitable_event.h" | 6 #include "base/synchronization/waitable_event.h" |
| 7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
| 8 #include "content/common/gpu/gpu_channel.h" | 8 #include "content/common/gpu/gpu_channel.h" |
| 9 #include "content/common/gpu/gpu_channel_manager.h" | 9 #include "content/common/gpu/gpu_channel_manager.h" |
| 10 #include "content/common/gpu/gpu_messages.h" | 10 #include "content/common/gpu/gpu_messages.h" |
| 11 #include "content/common/message_router.h" | 11 #include "content/common/message_router.h" |
| 12 #include "gpu/command_buffer/common/value_state.h" | 12 #include "gpu/command_buffer/common/value_state.h" |
| 13 #include "gpu/command_buffer/service/gl_utils.h" | 13 #include "gpu/command_buffer/service/gl_utils.h" |
| 14 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 14 #include "gpu/command_buffer/service/valuebuffer_manager.h" | 15 #include "gpu/command_buffer/service/valuebuffer_manager.h" |
| 15 #include "ipc/ipc_sync_channel.h" | 16 #include "ipc/ipc_sync_channel.h" |
| 16 | 17 |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 using base::WaitableEvent; | 20 using base::WaitableEvent; |
| 20 using gpu::gles2::ValuebufferManager; | 21 using gpu::gles2::ValuebufferManager; |
| 21 using gpu::ValueState; | 22 using gpu::ValueState; |
| 22 | 23 |
| 23 namespace IPC { | 24 namespace IPC { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 104 |
| 104 class SimpleGpuClient : public IPC::SimpleWorker { | 105 class SimpleGpuClient : public IPC::SimpleWorker { |
| 105 public: | 106 public: |
| 106 SimpleGpuClient() | 107 SimpleGpuClient() |
| 107 : IPC::SimpleWorker(IPC::Channel::MODE_CLIENT, "simple_client"), | 108 : IPC::SimpleWorker(IPC::Channel::MODE_CLIENT, "simple_client"), |
| 108 router_(this) { | 109 router_(this) { |
| 109 } | 110 } |
| 110 | 111 |
| 111 void Start() override { | 112 void Start() override { |
| 112 IPC::SimpleWorker::Start(); | 113 IPC::SimpleWorker::Start(); |
| 113 gpu_channel_manager_.reset( | 114 sync_point_manager_.reset(new gpu::SyncPointManager(false)); |
| 114 new GpuChannelManager(&router_, NULL, ipc_thread().task_runner().get(), | 115 gpu_channel_manager_.reset(new GpuChannelManager( |
| 115 shutdown_event(), channel(), nullptr, nullptr)); | 116 &router_, NULL, ipc_thread().task_runner().get(), shutdown_event(), |
| 117 channel(), nullptr, sync_point_manager_.get(), nullptr)); |
| 116 } | 118 } |
| 117 | 119 |
| 118 void Shutdown() override { | 120 void Shutdown() override { |
| 119 gpu_channel_manager_.reset(); | 121 gpu_channel_manager_.reset(); |
| 120 IPC::SimpleWorker::Shutdown(); | 122 IPC::SimpleWorker::Shutdown(); |
| 121 } | 123 } |
| 122 | 124 |
| 123 GpuChannelManager* gpu_channel_manager() { | 125 GpuChannelManager* gpu_channel_manager() { |
| 124 return gpu_channel_manager_.get(); | 126 return gpu_channel_manager_.get(); |
| 125 } | 127 } |
| 126 | 128 |
| 127 private: | 129 private: |
| 128 class SimpleMessageRouter : public MessageRouter { | 130 class SimpleMessageRouter : public MessageRouter { |
| 129 public: | 131 public: |
| 130 explicit SimpleMessageRouter(IPC::Sender* sender) | 132 explicit SimpleMessageRouter(IPC::Sender* sender) |
| 131 : sender_(sender) { | 133 : sender_(sender) { |
| 132 } | 134 } |
| 133 | 135 |
| 134 bool Send(IPC::Message* msg) override { return sender_->Send(msg); } | 136 bool Send(IPC::Message* msg) override { return sender_->Send(msg); } |
| 135 | 137 |
| 136 private: | 138 private: |
| 137 IPC::Sender* const sender_; | 139 IPC::Sender* const sender_; |
| 138 }; | 140 }; |
| 139 | 141 |
| 140 SimpleMessageRouter router_; | 142 SimpleMessageRouter router_; |
| 141 | 143 |
| 144 scoped_ptr<gpu::SyncPointManager> sync_point_manager_; |
| 142 scoped_ptr<GpuChannelManager> gpu_channel_manager_; | 145 scoped_ptr<GpuChannelManager> gpu_channel_manager_; |
| 143 }; | 146 }; |
| 144 | 147 |
| 145 class GpuChannelManagerTest : public testing::Test { | 148 class GpuChannelManagerTest : public testing::Test { |
| 146 public: | 149 public: |
| 147 GpuChannelManagerTest() {} | 150 GpuChannelManagerTest() {} |
| 148 | 151 |
| 149 void SetUp() override { | 152 void SetUp() override { |
| 150 simple_client_.reset(new SimpleGpuClient()); | 153 simple_client_.reset(new SimpleGpuClient()); |
| 151 simple_server_.reset(new IPC::SimpleServer()); | 154 simple_server_.reset(new IPC::SimpleServer()); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 const ValueState* state2 = | 217 const ValueState* state2 = |
| 215 pending_value_buffer_state2->GetState(GL_MOUSE_POSITION_CHROMIUM); | 218 pending_value_buffer_state2->GetState(GL_MOUSE_POSITION_CHROMIUM); |
| 216 ASSERT_NE(state1, state2); | 219 ASSERT_NE(state1, state2); |
| 217 | 220 |
| 218 ASSERT_EQ(state1->int_value[0], value_state1.int_value[0]); | 221 ASSERT_EQ(state1->int_value[0], value_state1.int_value[0]); |
| 219 ASSERT_EQ(state2->int_value[0], value_state2.int_value[0]); | 222 ASSERT_EQ(state2->int_value[0], value_state2.int_value[0]); |
| 220 ASSERT_NE(state1->int_value[0], state2->int_value[0]); | 223 ASSERT_NE(state1->int_value[0], state2->int_value[0]); |
| 221 } | 224 } |
| 222 | 225 |
| 223 } // namespace content | 226 } // namespace content |
| OLD | NEW |