Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: content/common/gpu/gpu_channel_unittest.cc

Issue 1365563002: Make channel preemption not require view contexts for hookup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wakeup_gpu
Patch Set: rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/test/test_simple_task_runner.h" 5 #include "base/test/test_simple_task_runner.h"
6 #include "content/common/gpu/gpu_channel.h" 6 #include "content/common/gpu/gpu_channel.h"
7 #include "content/common/gpu/gpu_channel_manager.h" 7 #include "content/common/gpu/gpu_channel_manager.h"
8 #include "content/common/gpu/gpu_channel_test_common.h" 8 #include "content/common/gpu/gpu_channel_test_common.h"
9 #include "content/common/gpu/gpu_messages.h" 9 #include "content/common/gpu/gpu_messages.h"
10 #include "ipc/ipc_test_sink.h" 10 #include "ipc/ipc_test_sink.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 class GpuChannelTest : public GpuChannelTestCommon { 14 class GpuChannelTest : public GpuChannelTestCommon {
15 public: 15 public:
16 GpuChannelTest() : GpuChannelTestCommon() {} 16 GpuChannelTest() : GpuChannelTestCommon() {}
17 ~GpuChannelTest() override {} 17 ~GpuChannelTest() override {}
18
19 GpuChannel* CreateChannel(int32 client_id, bool allow_real_time_streams) {
20 DCHECK(channel_manager());
21 uint64 kClientTracingId = 1;
22 GpuMsg_EstablishChannel_Params params;
23 params.client_id = client_id;
24 params.client_tracing_id = kClientTracingId;
25 params.preempts = false;
26 params.preempted = false;
27 params.allow_future_sync_points = false;
28 params.allow_real_time_streams = allow_real_time_streams;
29 EXPECT_TRUE(
30 channel_manager()->OnMessageReceived(GpuMsg_EstablishChannel(params)));
31 return channel_manager()->LookupChannel(client_id);
32 }
18 }; 33 };
19 34
20 TEST_F(GpuChannelTest, CreateViewCommandBuffer) { 35 TEST_F(GpuChannelTest, CreateViewCommandBuffer) {
21 int32 kClientId = 1; 36 int32 kClientId = 1;
22 uint64 kClientTracingId = 1; 37 GpuChannel* channel = CreateChannel(kClientId, false);
23
24 ASSERT_TRUE(channel_manager());
25
26 EXPECT_TRUE(channel_manager()->OnMessageReceived(GpuMsg_EstablishChannel(
27 kClientId, kClientTracingId, false, false, false)));
28 GpuChannel* channel = channel_manager()->LookupChannel(kClientId);
29 ASSERT_TRUE(channel); 38 ASSERT_TRUE(channel);
30 39
31 gfx::GLSurfaceHandle surface_handle; 40 gfx::GLSurfaceHandle surface_handle;
32 int32 kSurfaceId = 1;
33 int32 kRouteId = 1; 41 int32 kRouteId = 1;
34 GPUCreateCommandBufferConfig init_params; 42 GPUCreateCommandBufferConfig init_params;
35 init_params.share_group_id = MSG_ROUTING_NONE; 43 init_params.share_group_id = MSG_ROUTING_NONE;
36 init_params.stream_id = 0; 44 init_params.stream_id = 0;
37 init_params.stream_priority = GpuStreamPriority::NORMAL; 45 init_params.stream_priority = GpuStreamPriority::NORMAL;
38 init_params.attribs = std::vector<int>(); 46 init_params.attribs = std::vector<int>();
39 init_params.active_url = GURL(); 47 init_params.active_url = GURL();
40 init_params.gpu_preference = gfx::PreferIntegratedGpu; 48 init_params.gpu_preference = gfx::PreferIntegratedGpu;
41 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer( 49 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer(
42 surface_handle, kSurfaceId, kClientId, init_params, kRouteId)); 50 surface_handle, kClientId, init_params, kRouteId));
43 51
44 const IPC::Message* msg = 52 const IPC::Message* msg =
45 sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID); 53 sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID);
46 ASSERT_TRUE(msg); 54 ASSERT_TRUE(msg);
47 55
48 base::Tuple<CreateCommandBufferResult> result; 56 base::Tuple<CreateCommandBufferResult> result;
49 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result)); 57 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result));
50 58
51 EXPECT_EQ(CREATE_COMMAND_BUFFER_SUCCEEDED, base::get<0>(result)); 59 EXPECT_EQ(CREATE_COMMAND_BUFFER_SUCCEEDED, base::get<0>(result));
52 60
53 sink()->ClearMessages(); 61 sink()->ClearMessages();
54 62
55 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); 63 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId);
56 ASSERT_TRUE(stub); 64 ASSERT_TRUE(stub);
57 } 65 }
58 66
59 TEST_F(GpuChannelTest, IncompatibleStreamIds) { 67 TEST_F(GpuChannelTest, IncompatibleStreamIds) {
60 int32 kClientId = 1; 68 int32 kClientId = 1;
61 uint64 kClientTracingId = 1; 69 GpuChannel* channel = CreateChannel(kClientId, false);
62
63 ASSERT_TRUE(channel_manager());
64
65 EXPECT_TRUE(channel_manager()->OnMessageReceived(GpuMsg_EstablishChannel(
66 kClientId, kClientTracingId, false, false, false)));
67 GpuChannel* channel = channel_manager()->LookupChannel(kClientId);
68 ASSERT_TRUE(channel); 70 ASSERT_TRUE(channel);
69 71
70 // Create first context. 72 // Create first context.
71 int32 kSurfaceId1 = 1;
72 int32 kRouteId1 = 1; 73 int32 kRouteId1 = 1;
73 int32 kStreamId1 = 1; 74 int32 kStreamId1 = 1;
74 GPUCreateCommandBufferConfig init_params; 75 GPUCreateCommandBufferConfig init_params;
75 init_params.share_group_id = MSG_ROUTING_NONE; 76 init_params.share_group_id = MSG_ROUTING_NONE;
76 init_params.stream_id = kStreamId1; 77 init_params.stream_id = kStreamId1;
77 init_params.stream_priority = GpuStreamPriority::NORMAL; 78 init_params.stream_priority = GpuStreamPriority::NORMAL;
78 init_params.attribs = std::vector<int>(); 79 init_params.attribs = std::vector<int>();
79 init_params.active_url = GURL(); 80 init_params.active_url = GURL();
80 init_params.gpu_preference = gfx::PreferIntegratedGpu; 81 init_params.gpu_preference = gfx::PreferIntegratedGpu;
81 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer( 82 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer(
82 gfx::GLSurfaceHandle(), kSurfaceId1, kClientId, init_params, kRouteId1)); 83 gfx::GLSurfaceHandle(), kClientId, init_params, kRouteId1));
83 84
84 const IPC::Message* msg = 85 const IPC::Message* msg =
85 sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID); 86 sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID);
86 ASSERT_TRUE(msg); 87 ASSERT_TRUE(msg);
87 88
88 base::Tuple<CreateCommandBufferResult> result; 89 base::Tuple<CreateCommandBufferResult> result;
89 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result)); 90 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result));
90 91
91 EXPECT_EQ(CREATE_COMMAND_BUFFER_SUCCEEDED, base::get<0>(result)); 92 EXPECT_EQ(CREATE_COMMAND_BUFFER_SUCCEEDED, base::get<0>(result));
92 93
93 sink()->ClearMessages(); 94 sink()->ClearMessages();
94 95
95 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId1); 96 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId1);
96 ASSERT_TRUE(stub); 97 ASSERT_TRUE(stub);
97 98
98 // Create second context in same share group but different stream. 99 // Create second context in same share group but different stream.
99 int32 kSurfaceId2 = 2;
100 int32 kRouteId2 = 2; 100 int32 kRouteId2 = 2;
101 int32 kStreamId2 = 2; 101 int32 kStreamId2 = 2;
102 102
103 init_params.share_group_id = kRouteId1; 103 init_params.share_group_id = kRouteId1;
104 init_params.stream_id = kStreamId2; 104 init_params.stream_id = kStreamId2;
105 init_params.stream_priority = GpuStreamPriority::NORMAL; 105 init_params.stream_priority = GpuStreamPriority::NORMAL;
106 init_params.attribs = std::vector<int>(); 106 init_params.attribs = std::vector<int>();
107 init_params.active_url = GURL(); 107 init_params.active_url = GURL();
108 init_params.gpu_preference = gfx::PreferIntegratedGpu; 108 init_params.gpu_preference = gfx::PreferIntegratedGpu;
109 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer( 109 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer(
110 gfx::GLSurfaceHandle(), kSurfaceId2, kClientId, init_params, kRouteId2)); 110 gfx::GLSurfaceHandle(), kClientId, init_params, kRouteId2));
111 111
112 msg = sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID); 112 msg = sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID);
113 ASSERT_TRUE(msg); 113 ASSERT_TRUE(msg);
114 114
115 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result)); 115 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result));
116 116
117 EXPECT_EQ(CREATE_COMMAND_BUFFER_FAILED, base::get<0>(result)); 117 EXPECT_EQ(CREATE_COMMAND_BUFFER_FAILED, base::get<0>(result));
118 118
119 sink()->ClearMessages(); 119 sink()->ClearMessages();
120 120
121 stub = channel->LookupCommandBuffer(kRouteId2); 121 stub = channel->LookupCommandBuffer(kRouteId2);
122 ASSERT_FALSE(stub); 122 ASSERT_FALSE(stub);
123 } 123 }
124 124
125 TEST_F(GpuChannelTest, IncompatibleStreamPriorities) { 125 TEST_F(GpuChannelTest, IncompatibleStreamPriorities) {
126 int32 kClientId = 1; 126 int32 kClientId = 1;
127 uint64 kClientTracingId = 1; 127 GpuChannel* channel = CreateChannel(kClientId, false);
128
129 ASSERT_TRUE(channel_manager());
130
131 EXPECT_TRUE(channel_manager()->OnMessageReceived(GpuMsg_EstablishChannel(
132 kClientId, kClientTracingId, false, false, false)));
133 GpuChannel* channel = channel_manager()->LookupChannel(kClientId);
134 ASSERT_TRUE(channel); 128 ASSERT_TRUE(channel);
135 129
136 // Create first context. 130 // Create first context.
137 int32 kSurfaceId1 = 1;
138 int32 kRouteId1 = 1; 131 int32 kRouteId1 = 1;
139 int32 kStreamId1 = 1; 132 int32 kStreamId1 = 1;
140 GpuStreamPriority kStreamPriority1 = GpuStreamPriority::NORMAL; 133 GpuStreamPriority kStreamPriority1 = GpuStreamPriority::NORMAL;
141 GPUCreateCommandBufferConfig init_params; 134 GPUCreateCommandBufferConfig init_params;
142 init_params.share_group_id = MSG_ROUTING_NONE; 135 init_params.share_group_id = MSG_ROUTING_NONE;
143 init_params.stream_id = kStreamId1; 136 init_params.stream_id = kStreamId1;
144 init_params.stream_priority = kStreamPriority1; 137 init_params.stream_priority = kStreamPriority1;
145 init_params.attribs = std::vector<int>(); 138 init_params.attribs = std::vector<int>();
146 init_params.active_url = GURL(); 139 init_params.active_url = GURL();
147 init_params.gpu_preference = gfx::PreferIntegratedGpu; 140 init_params.gpu_preference = gfx::PreferIntegratedGpu;
148 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer( 141 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer(
149 gfx::GLSurfaceHandle(), kSurfaceId1, kClientId, init_params, kRouteId1)); 142 gfx::GLSurfaceHandle(), kClientId, init_params, kRouteId1));
150 143
151 const IPC::Message* msg = 144 const IPC::Message* msg =
152 sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID); 145 sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID);
153 ASSERT_TRUE(msg); 146 ASSERT_TRUE(msg);
154 147
155 base::Tuple<CreateCommandBufferResult> result; 148 base::Tuple<CreateCommandBufferResult> result;
156 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result)); 149 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result));
157 150
158 EXPECT_EQ(CREATE_COMMAND_BUFFER_SUCCEEDED, base::get<0>(result)); 151 EXPECT_EQ(CREATE_COMMAND_BUFFER_SUCCEEDED, base::get<0>(result));
159 152
160 sink()->ClearMessages(); 153 sink()->ClearMessages();
161 154
162 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId1); 155 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId1);
163 ASSERT_TRUE(stub); 156 ASSERT_TRUE(stub);
164 157
165 // Create second context in same share group but different stream. 158 // Create second context in same share group but different stream.
166 int32 kSurfaceId2 = 2;
167 int32 kRouteId2 = 2; 159 int32 kRouteId2 = 2;
168 int32 kStreamId2 = kStreamId1; 160 int32 kStreamId2 = kStreamId1;
169 GpuStreamPriority kStreamPriority2 = GpuStreamPriority::LOW; 161 GpuStreamPriority kStreamPriority2 = GpuStreamPriority::LOW;
170 162
171 init_params.share_group_id = MSG_ROUTING_NONE; 163 init_params.share_group_id = MSG_ROUTING_NONE;
172 init_params.stream_id = kStreamId2; 164 init_params.stream_id = kStreamId2;
173 init_params.stream_priority = kStreamPriority2; 165 init_params.stream_priority = kStreamPriority2;
174 init_params.attribs = std::vector<int>(); 166 init_params.attribs = std::vector<int>();
175 init_params.active_url = GURL(); 167 init_params.active_url = GURL();
176 init_params.gpu_preference = gfx::PreferIntegratedGpu; 168 init_params.gpu_preference = gfx::PreferIntegratedGpu;
177 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer( 169 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer(
178 gfx::GLSurfaceHandle(), kSurfaceId2, kClientId, init_params, kRouteId2)); 170 gfx::GLSurfaceHandle(), kClientId, init_params, kRouteId2));
179 171
180 msg = sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID); 172 msg = sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID);
181 ASSERT_TRUE(msg); 173 ASSERT_TRUE(msg);
182 174
183 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result)); 175 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result));
184 176
185 EXPECT_EQ(CREATE_COMMAND_BUFFER_FAILED, base::get<0>(result)); 177 EXPECT_EQ(CREATE_COMMAND_BUFFER_FAILED, base::get<0>(result));
186 178
187 sink()->ClearMessages(); 179 sink()->ClearMessages();
188 180
189 stub = channel->LookupCommandBuffer(kRouteId2); 181 stub = channel->LookupCommandBuffer(kRouteId2);
190 ASSERT_FALSE(stub); 182 ASSERT_FALSE(stub);
191 } 183 }
192 184
193 TEST_F(GpuChannelTest, StreamLifetime) { 185 TEST_F(GpuChannelTest, StreamLifetime) {
194 int32 kClientId = 1; 186 int32 kClientId = 1;
195 uint64 kClientTracingId = 1; 187 GpuChannel* channel = CreateChannel(kClientId, false);
196
197 ASSERT_TRUE(channel_manager());
198
199 EXPECT_TRUE(channel_manager()->OnMessageReceived(GpuMsg_EstablishChannel(
200 kClientId, kClientTracingId, false, false, false)));
201 GpuChannel* channel = channel_manager()->LookupChannel(kClientId);
202 ASSERT_TRUE(channel); 188 ASSERT_TRUE(channel);
203 189
204 // Create first context. 190 // Create first context.
205 int32 kSurfaceId1 = 1;
206 int32 kRouteId1 = 1; 191 int32 kRouteId1 = 1;
207 int32 kStreamId1 = 1; 192 int32 kStreamId1 = 1;
208 GpuStreamPriority kStreamPriority1 = GpuStreamPriority::NORMAL; 193 GpuStreamPriority kStreamPriority1 = GpuStreamPriority::NORMAL;
209 GPUCreateCommandBufferConfig init_params; 194 GPUCreateCommandBufferConfig init_params;
210 init_params.share_group_id = MSG_ROUTING_NONE; 195 init_params.share_group_id = MSG_ROUTING_NONE;
211 init_params.stream_id = kStreamId1; 196 init_params.stream_id = kStreamId1;
212 init_params.stream_priority = kStreamPriority1; 197 init_params.stream_priority = kStreamPriority1;
213 init_params.attribs = std::vector<int>(); 198 init_params.attribs = std::vector<int>();
214 init_params.active_url = GURL(); 199 init_params.active_url = GURL();
215 init_params.gpu_preference = gfx::PreferIntegratedGpu; 200 init_params.gpu_preference = gfx::PreferIntegratedGpu;
216 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer( 201 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer(
217 gfx::GLSurfaceHandle(), kSurfaceId1, kClientId, init_params, kRouteId1)); 202 gfx::GLSurfaceHandle(), kClientId, init_params, kRouteId1));
218 203
219 const IPC::Message* msg = 204 const IPC::Message* msg =
220 sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID); 205 sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID);
221 ASSERT_TRUE(msg); 206 ASSERT_TRUE(msg);
222 207
223 base::Tuple<CreateCommandBufferResult> result; 208 base::Tuple<CreateCommandBufferResult> result;
224 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result)); 209 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result));
225 210
226 EXPECT_EQ(CREATE_COMMAND_BUFFER_SUCCEEDED, base::get<0>(result)); 211 EXPECT_EQ(CREATE_COMMAND_BUFFER_SUCCEEDED, base::get<0>(result));
227 212
228 sink()->ClearMessages(); 213 sink()->ClearMessages();
229 214
230 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId1); 215 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId1);
231 ASSERT_TRUE(stub); 216 ASSERT_TRUE(stub);
232 217
233 { 218 {
234 // GpuChannelHost always calls set_unblock(false) on messages sent to the 219 // GpuChannelHost always calls set_unblock(false) on messages sent to the
235 // GPU process. 220 // GPU process.
236 IPC::Message m = GpuChannelMsg_DestroyCommandBuffer(kRouteId1); 221 IPC::Message m = GpuChannelMsg_DestroyCommandBuffer(kRouteId1);
237 m.set_unblock(false); 222 m.set_unblock(false);
238 EXPECT_TRUE(channel->filter()->OnMessageReceived(m)); 223 EXPECT_TRUE(channel->filter()->OnMessageReceived(m));
239 task_runner()->RunPendingTasks(); 224 task_runner()->RunPendingTasks();
240 } 225 }
241 226
242 stub = channel->LookupCommandBuffer(kRouteId1); 227 stub = channel->LookupCommandBuffer(kRouteId1);
243 ASSERT_FALSE(stub); 228 ASSERT_FALSE(stub);
244 229
245 // Create second context in same share group but different stream. 230 // Create second context in same share group but different stream.
246 int32 kSurfaceId2 = 2;
247 int32 kRouteId2 = 2; 231 int32 kRouteId2 = 2;
248 int32 kStreamId2 = 2; 232 int32 kStreamId2 = 2;
249 GpuStreamPriority kStreamPriority2 = GpuStreamPriority::LOW; 233 GpuStreamPriority kStreamPriority2 = GpuStreamPriority::LOW;
250 234
251 init_params.share_group_id = MSG_ROUTING_NONE; 235 init_params.share_group_id = MSG_ROUTING_NONE;
252 init_params.stream_id = kStreamId2; 236 init_params.stream_id = kStreamId2;
253 init_params.stream_priority = kStreamPriority2; 237 init_params.stream_priority = kStreamPriority2;
254 init_params.attribs = std::vector<int>(); 238 init_params.attribs = std::vector<int>();
255 init_params.active_url = GURL(); 239 init_params.active_url = GURL();
256 init_params.gpu_preference = gfx::PreferIntegratedGpu; 240 init_params.gpu_preference = gfx::PreferIntegratedGpu;
257 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer( 241 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer(
258 gfx::GLSurfaceHandle(), kSurfaceId2, kClientId, init_params, kRouteId2)); 242 gfx::GLSurfaceHandle(), kClientId, init_params, kRouteId2));
259 243
260 msg = sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID); 244 msg = sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID);
261 ASSERT_TRUE(msg); 245 ASSERT_TRUE(msg);
262 246
263 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result)); 247 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result));
264 248
265 EXPECT_EQ(CREATE_COMMAND_BUFFER_SUCCEEDED, base::get<0>(result)); 249 EXPECT_EQ(CREATE_COMMAND_BUFFER_SUCCEEDED, base::get<0>(result));
266 250
267 sink()->ClearMessages(); 251 sink()->ClearMessages();
268 252
269 stub = channel->LookupCommandBuffer(kRouteId2); 253 stub = channel->LookupCommandBuffer(kRouteId2);
270 ASSERT_TRUE(stub); 254 ASSERT_TRUE(stub);
271 } 255 }
272 256
273 TEST_F(GpuChannelTest, RealTimeStreamsDisallowed) { 257 TEST_F(GpuChannelTest, RealTimeStreamsDisallowed) {
274 int32 kClientId = 1; 258 int32 kClientId = 1;
275 uint64 kClientTracingId = 1;
276 bool allow_real_time_streams = false; 259 bool allow_real_time_streams = false;
277 260 GpuChannel* channel = CreateChannel(kClientId, allow_real_time_streams);
278 ASSERT_TRUE(channel_manager());
279
280 EXPECT_TRUE(channel_manager()->OnMessageReceived(GpuMsg_EstablishChannel(
281 kClientId, kClientTracingId, false, false, allow_real_time_streams)));
282 GpuChannel* channel = channel_manager()->LookupChannel(kClientId);
283 ASSERT_TRUE(channel); 261 ASSERT_TRUE(channel);
284 262
285 // Create first context. 263 // Create first context.
286 int32 kSurfaceId = 1;
287 int32 kRouteId = 1; 264 int32 kRouteId = 1;
288 int32 kStreamId = 1; 265 int32 kStreamId = 1;
289 GpuStreamPriority kStreamPriority = GpuStreamPriority::REAL_TIME; 266 GpuStreamPriority kStreamPriority = GpuStreamPriority::REAL_TIME;
290 GPUCreateCommandBufferConfig init_params; 267 GPUCreateCommandBufferConfig init_params;
291 init_params.share_group_id = MSG_ROUTING_NONE; 268 init_params.share_group_id = MSG_ROUTING_NONE;
292 init_params.stream_id = kStreamId; 269 init_params.stream_id = kStreamId;
293 init_params.stream_priority = kStreamPriority; 270 init_params.stream_priority = kStreamPriority;
294 init_params.attribs = std::vector<int>(); 271 init_params.attribs = std::vector<int>();
295 init_params.active_url = GURL(); 272 init_params.active_url = GURL();
296 init_params.gpu_preference = gfx::PreferIntegratedGpu; 273 init_params.gpu_preference = gfx::PreferIntegratedGpu;
297 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer( 274 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer(
298 gfx::GLSurfaceHandle(), kSurfaceId, kClientId, init_params, kRouteId)); 275 gfx::GLSurfaceHandle(), kClientId, init_params, kRouteId));
299 276
300 const IPC::Message* msg = 277 const IPC::Message* msg =
301 sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID); 278 sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID);
302 ASSERT_TRUE(msg); 279 ASSERT_TRUE(msg);
303 280
304 base::Tuple<CreateCommandBufferResult> result; 281 base::Tuple<CreateCommandBufferResult> result;
305 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result)); 282 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result));
306 283
307 EXPECT_EQ(CREATE_COMMAND_BUFFER_FAILED, base::get<0>(result)); 284 EXPECT_EQ(CREATE_COMMAND_BUFFER_FAILED, base::get<0>(result));
308 285
309 sink()->ClearMessages(); 286 sink()->ClearMessages();
310 287
311 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); 288 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId);
312 ASSERT_FALSE(stub); 289 ASSERT_FALSE(stub);
313 } 290 }
314 291
315 TEST_F(GpuChannelTest, RealTimeStreamsAllowed) { 292 TEST_F(GpuChannelTest, RealTimeStreamsAllowed) {
316 int32 kClientId = 1; 293 int32 kClientId = 1;
317 uint64 kClientTracingId = 1;
318
319 ASSERT_TRUE(channel_manager());
320
321 bool allow_real_time_streams = true; 294 bool allow_real_time_streams = true;
322 EXPECT_TRUE(channel_manager()->OnMessageReceived(GpuMsg_EstablishChannel( 295 GpuChannel* channel = CreateChannel(kClientId, allow_real_time_streams);
323 kClientId, kClientTracingId, false, false, allow_real_time_streams)));
324 GpuChannel* channel = channel_manager()->LookupChannel(kClientId);
325 ASSERT_TRUE(channel); 296 ASSERT_TRUE(channel);
326 297
327 // Create first context. 298 // Create first context.
328 int32 kSurfaceId = 1;
329 int32 kRouteId = 1; 299 int32 kRouteId = 1;
330 int32 kStreamId = 1; 300 int32 kStreamId = 1;
331 GpuStreamPriority kStreamPriority = GpuStreamPriority::REAL_TIME; 301 GpuStreamPriority kStreamPriority = GpuStreamPriority::REAL_TIME;
332 GPUCreateCommandBufferConfig init_params; 302 GPUCreateCommandBufferConfig init_params;
333 init_params.share_group_id = MSG_ROUTING_NONE; 303 init_params.share_group_id = MSG_ROUTING_NONE;
334 init_params.stream_id = kStreamId; 304 init_params.stream_id = kStreamId;
335 init_params.stream_priority = kStreamPriority; 305 init_params.stream_priority = kStreamPriority;
336 init_params.attribs = std::vector<int>(); 306 init_params.attribs = std::vector<int>();
337 init_params.active_url = GURL(); 307 init_params.active_url = GURL();
338 init_params.gpu_preference = gfx::PreferIntegratedGpu; 308 init_params.gpu_preference = gfx::PreferIntegratedGpu;
339 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer( 309 channel_manager()->OnMessageReceived(GpuMsg_CreateViewCommandBuffer(
340 gfx::GLSurfaceHandle(), kSurfaceId, kClientId, init_params, kRouteId)); 310 gfx::GLSurfaceHandle(), kClientId, init_params, kRouteId));
341 311
342 const IPC::Message* msg = 312 const IPC::Message* msg =
343 sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID); 313 sink()->GetUniqueMessageMatching(GpuHostMsg_CommandBufferCreated::ID);
344 ASSERT_TRUE(msg); 314 ASSERT_TRUE(msg);
345 315
346 base::Tuple<CreateCommandBufferResult> result; 316 base::Tuple<CreateCommandBufferResult> result;
347 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result)); 317 ASSERT_TRUE(GpuHostMsg_CommandBufferCreated::Read(msg, &result));
348 318
349 EXPECT_EQ(CREATE_COMMAND_BUFFER_SUCCEEDED, base::get<0>(result)); 319 EXPECT_EQ(CREATE_COMMAND_BUFFER_SUCCEEDED, base::get<0>(result));
350 320
351 sink()->ClearMessages(); 321 sink()->ClearMessages();
352 322
353 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); 323 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId);
354 ASSERT_TRUE(stub); 324 ASSERT_TRUE(stub);
355 } 325 }
356 326
357 } // namespace content 327 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel_test_common.cc ('k') | content/common/gpu/gpu_command_buffer_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698