| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 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 | 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
| 8 #include "content/common/gpu/establish_channel_params.h" | |
| 9 #include "content/common/gpu/gpu_channel.h" | 8 #include "content/common/gpu/gpu_channel.h" |
| 10 #include "content/common/gpu/gpu_channel_manager.h" | 9 #include "content/common/gpu/gpu_channel_manager.h" |
| 11 #include "content/common/gpu/gpu_channel_test_common.h" | 10 #include "content/common/gpu/gpu_channel_test_common.h" |
| 12 #include "content/common/gpu/gpu_messages.h" | 11 #include "content/common/gpu/gpu_messages.h" |
| 13 #include "ipc/ipc_test_sink.h" | 12 #include "ipc/ipc_test_sink.h" |
| 14 | 13 |
| 15 namespace content { | 14 namespace content { |
| 16 | 15 |
| 17 class GpuChannelTest : public GpuChannelTestCommon { | 16 class GpuChannelTest : public GpuChannelTestCommon { |
| 18 public: | 17 public: |
| 19 GpuChannelTest() : GpuChannelTestCommon() {} | 18 GpuChannelTest() : GpuChannelTestCommon() {} |
| 20 ~GpuChannelTest() override {} | 19 ~GpuChannelTest() override {} |
| 21 | 20 |
| 22 GpuChannel* CreateChannel(int32_t client_id, | 21 GpuChannel* CreateChannel(int32_t client_id, |
| 23 bool allow_view_command_buffers, | 22 bool allow_view_command_buffers, |
| 24 bool allow_real_time_streams) { | 23 bool allow_real_time_streams) { |
| 25 DCHECK(channel_manager()); | 24 DCHECK(channel_manager()); |
| 26 uint64_t kClientTracingId = 1; | 25 uint64_t kClientTracingId = 1; |
| 27 EstablishChannelParams params; | 26 GpuMsg_EstablishChannel_Params params; |
| 28 params.client_id = client_id; | 27 params.client_id = client_id; |
| 29 params.client_tracing_id = kClientTracingId; | 28 params.client_tracing_id = kClientTracingId; |
| 30 params.preempts = false; | 29 params.preempts = false; |
| 31 params.allow_view_command_buffers = allow_view_command_buffers; | 30 params.allow_view_command_buffers = allow_view_command_buffers; |
| 32 params.allow_real_time_streams = allow_real_time_streams; | 31 params.allow_real_time_streams = allow_real_time_streams; |
| 33 channel_manager()->EstablishChannel(params); | 32 EXPECT_TRUE( |
| 33 channel_manager()->OnMessageReceived(GpuMsg_EstablishChannel(params))); |
| 34 sink()->ClearMessages(); |
| 34 return channel_manager()->LookupChannel(client_id); | 35 return channel_manager()->LookupChannel(client_id); |
| 35 } | 36 } |
| 36 | 37 |
| 37 void HandleMessage(GpuChannel* channel, IPC::Message* msg) { | 38 void HandleMessage(GpuChannel* channel, IPC::Message* msg) { |
| 38 TestGpuChannel* test_channel = static_cast<TestGpuChannel*>(channel); | 39 channel->HandleMessageForTesting(*msg); |
| 39 test_channel->HandleMessageForTesting(*msg); | |
| 40 | 40 |
| 41 if (msg->is_sync()) { | 41 if (msg->is_sync()) { |
| 42 const IPC::Message* reply_msg = test_channel->sink()->GetMessageAt(0); | 42 const IPC::Message* reply_msg = sink()->GetMessageAt(0); |
| 43 ASSERT_TRUE(reply_msg); | 43 ASSERT_TRUE(reply_msg); |
| 44 | 44 |
| 45 EXPECT_TRUE(IPC::SyncMessage::IsMessageReplyTo( | 45 EXPECT_TRUE(IPC::SyncMessage::IsMessageReplyTo( |
| 46 *reply_msg, IPC::SyncMessage::GetMessageId(*msg))); | 46 *reply_msg, IPC::SyncMessage::GetMessageId(*msg))); |
| 47 | 47 |
| 48 IPC::MessageReplyDeserializer* deserializer = | 48 IPC::MessageReplyDeserializer* deserializer = |
| 49 static_cast<IPC::SyncMessage*>(msg)->GetReplyDeserializer(); | 49 static_cast<IPC::SyncMessage*>(msg)->GetReplyDeserializer(); |
| 50 ASSERT_TRUE(deserializer); | 50 ASSERT_TRUE(deserializer); |
| 51 deserializer->SerializeOutputParameters(*reply_msg); | 51 deserializer->SerializeOutputParameters(*reply_msg); |
| 52 | 52 |
| 53 delete deserializer; | 53 delete deserializer; |
| 54 | 54 |
| 55 test_channel->sink()->ClearMessages(); | 55 sink()->ClearMessages(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 delete msg; | 58 delete msg; |
| 59 } | 59 } |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 TEST_F(GpuChannelTest, CreateViewCommandBufferAllowed) { | 62 TEST_F(GpuChannelTest, CreateViewCommandBufferAllowed) { |
| 63 int32_t kClientId = 1; | 63 int32_t kClientId = 1; |
| 64 bool allow_view_command_buffers = true; | 64 bool allow_view_command_buffers = true; |
| 65 GpuChannel* channel = | 65 GpuChannel* channel = |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 HandleMessage(channel, | 279 HandleMessage(channel, |
| 280 new GpuChannelMsg_CreateOffscreenCommandBuffer( | 280 new GpuChannelMsg_CreateOffscreenCommandBuffer( |
| 281 gfx::Size(1, 1), init_params, kRouteId, &succeeded)); | 281 gfx::Size(1, 1), init_params, kRouteId, &succeeded)); |
| 282 EXPECT_TRUE(succeeded); | 282 EXPECT_TRUE(succeeded); |
| 283 | 283 |
| 284 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); | 284 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); |
| 285 EXPECT_TRUE(stub); | 285 EXPECT_TRUE(stub); |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace content | 288 } // namespace content |
| OLD | NEW |