OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
11 #include "gpu/command_buffer/common/id_allocator.h" | |
12 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h" | 11 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h" |
13 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" | 12 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" |
14 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h" | 13 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h" |
15 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 14 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
16 #include "gpu/command_buffer/service/context_group.h" | 15 #include "gpu/command_buffer/service/context_group.h" |
17 #include "gpu/command_buffer/service/context_state.h" | 16 #include "gpu/command_buffer/service/context_state.h" |
18 #include "gpu/command_buffer/service/gl_surface_mock.h" | 17 #include "gpu/command_buffer/service/gl_surface_mock.h" |
19 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 18 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
20 #include "gpu/command_buffer/service/gpu_switches.h" | 19 #include "gpu/command_buffer/service/gpu_switches.h" |
21 #include "gpu/command_buffer/service/image_manager.h" | 20 #include "gpu/command_buffer/service/image_manager.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 201 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
203 cmd.Init(client_element_buffer_id_, | 202 cmd.Init(client_element_buffer_id_, |
204 kValidIndexRangeCount + 1, | 203 kValidIndexRangeCount + 1, |
205 GL_UNSIGNED_SHORT, | 204 GL_UNSIGNED_SHORT, |
206 kValidIndexRangeStart * 2, | 205 kValidIndexRangeStart * 2, |
207 kSharedMemoryId, | 206 kSharedMemoryId, |
208 kInvalidSharedMemoryOffset); | 207 kInvalidSharedMemoryOffset); |
209 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 208 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
210 } | 209 } |
211 | 210 |
212 TEST_P(GLES2DecoderTest, SharedIds) { | |
213 GenSharedIdsCHROMIUM gen_cmd; | |
214 RegisterSharedIdsCHROMIUM reg_cmd; | |
215 DeleteSharedIdsCHROMIUM del_cmd; | |
216 | |
217 const GLuint kNamespaceId = id_namespaces::kTextures; | |
218 const GLuint kExpectedId1 = 1; | |
219 const GLuint kExpectedId2 = 2; | |
220 const GLuint kExpectedId3 = 4; | |
221 const GLuint kRegisterId = 3; | |
222 GLuint* ids = GetSharedMemoryAs<GLuint*>(); | |
223 gen_cmd.Init(kNamespaceId, 0, 2, kSharedMemoryId, kSharedMemoryOffset); | |
224 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); | |
225 IdAllocatorInterface* id_allocator = GetIdAllocator(kNamespaceId); | |
226 ASSERT_TRUE(id_allocator != NULL); | |
227 // This check is implementation dependant but it's kind of hard to check | |
228 // otherwise. | |
229 EXPECT_EQ(kExpectedId1, ids[0]); | |
230 EXPECT_EQ(kExpectedId2, ids[1]); | |
231 EXPECT_TRUE(id_allocator->InUse(kExpectedId1)); | |
232 EXPECT_TRUE(id_allocator->InUse(kExpectedId2)); | |
233 EXPECT_FALSE(id_allocator->InUse(kRegisterId)); | |
234 EXPECT_FALSE(id_allocator->InUse(kExpectedId3)); | |
235 | |
236 ClearSharedMemory(); | |
237 ids[0] = kRegisterId; | |
238 reg_cmd.Init(kNamespaceId, 1, kSharedMemoryId, kSharedMemoryOffset); | |
239 EXPECT_EQ(error::kNoError, ExecuteCmd(reg_cmd)); | |
240 EXPECT_TRUE(id_allocator->InUse(kExpectedId1)); | |
241 EXPECT_TRUE(id_allocator->InUse(kExpectedId2)); | |
242 EXPECT_TRUE(id_allocator->InUse(kRegisterId)); | |
243 EXPECT_FALSE(id_allocator->InUse(kExpectedId3)); | |
244 | |
245 ClearSharedMemory(); | |
246 gen_cmd.Init(kNamespaceId, 0, 1, kSharedMemoryId, kSharedMemoryOffset); | |
247 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); | |
248 EXPECT_EQ(kExpectedId3, ids[0]); | |
249 EXPECT_TRUE(id_allocator->InUse(kExpectedId1)); | |
250 EXPECT_TRUE(id_allocator->InUse(kExpectedId2)); | |
251 EXPECT_TRUE(id_allocator->InUse(kRegisterId)); | |
252 EXPECT_TRUE(id_allocator->InUse(kExpectedId3)); | |
253 | |
254 ClearSharedMemory(); | |
255 ids[0] = kExpectedId1; | |
256 ids[1] = kRegisterId; | |
257 del_cmd.Init(kNamespaceId, 2, kSharedMemoryId, kSharedMemoryOffset); | |
258 EXPECT_EQ(error::kNoError, ExecuteCmd(del_cmd)); | |
259 EXPECT_FALSE(id_allocator->InUse(kExpectedId1)); | |
260 EXPECT_TRUE(id_allocator->InUse(kExpectedId2)); | |
261 EXPECT_FALSE(id_allocator->InUse(kRegisterId)); | |
262 EXPECT_TRUE(id_allocator->InUse(kExpectedId3)); | |
263 | |
264 ClearSharedMemory(); | |
265 ids[0] = kExpectedId3; | |
266 ids[1] = kExpectedId2; | |
267 del_cmd.Init(kNamespaceId, 2, kSharedMemoryId, kSharedMemoryOffset); | |
268 EXPECT_EQ(error::kNoError, ExecuteCmd(del_cmd)); | |
269 EXPECT_FALSE(id_allocator->InUse(kExpectedId1)); | |
270 EXPECT_FALSE(id_allocator->InUse(kExpectedId2)); | |
271 EXPECT_FALSE(id_allocator->InUse(kRegisterId)); | |
272 EXPECT_FALSE(id_allocator->InUse(kExpectedId3)); | |
273 | |
274 // Check passing in an id_offset. | |
275 ClearSharedMemory(); | |
276 const GLuint kOffset = 0xABCDEF; | |
277 gen_cmd.Init(kNamespaceId, kOffset, 2, kSharedMemoryId, kSharedMemoryOffset); | |
278 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); | |
279 EXPECT_EQ(kOffset, ids[0]); | |
280 EXPECT_EQ(kOffset + 1, ids[1]); | |
281 } | |
282 | |
283 TEST_P(GLES2DecoderTest, GenSharedIdsCHROMIUMBadArgs) { | |
284 const GLuint kNamespaceId = id_namespaces::kTextures; | |
285 GenSharedIdsCHROMIUM cmd; | |
286 cmd.Init(kNamespaceId, 0, -1, kSharedMemoryId, kSharedMemoryOffset); | |
287 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
288 cmd.Init(kNamespaceId, 0, 1, kInvalidSharedMemoryId, kSharedMemoryOffset); | |
289 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
290 cmd.Init(kNamespaceId, 0, 1, kSharedMemoryId, kInvalidSharedMemoryOffset); | |
291 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
292 } | |
293 | |
294 TEST_P(GLES2DecoderTest, RegisterSharedIdsCHROMIUMBadArgs) { | |
295 const GLuint kNamespaceId = id_namespaces::kTextures; | |
296 RegisterSharedIdsCHROMIUM cmd; | |
297 cmd.Init(kNamespaceId, -1, kSharedMemoryId, kSharedMemoryOffset); | |
298 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
299 cmd.Init(kNamespaceId, 1, kInvalidSharedMemoryId, kSharedMemoryOffset); | |
300 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
301 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kInvalidSharedMemoryOffset); | |
302 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
303 } | |
304 | |
305 TEST_P(GLES2DecoderTest, RegisterSharedIdsCHROMIUMDuplicateIds) { | |
306 const GLuint kNamespaceId = id_namespaces::kTextures; | |
307 const GLuint kRegisterId = 3; | |
308 RegisterSharedIdsCHROMIUM cmd; | |
309 GLuint* ids = GetSharedMemoryAs<GLuint*>(); | |
310 ids[0] = kRegisterId; | |
311 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kSharedMemoryOffset); | |
312 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
313 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kSharedMemoryOffset); | |
314 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
315 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
316 } | |
317 | |
318 TEST_P(GLES2DecoderTest, DeleteSharedIdsCHROMIUMBadArgs) { | |
319 const GLuint kNamespaceId = id_namespaces::kTextures; | |
320 DeleteSharedIdsCHROMIUM cmd; | |
321 cmd.Init(kNamespaceId, -1, kSharedMemoryId, kSharedMemoryOffset); | |
322 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
323 cmd.Init(kNamespaceId, 1, kInvalidSharedMemoryId, kSharedMemoryOffset); | |
324 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
325 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kInvalidSharedMemoryOffset); | |
326 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
327 } | |
328 | |
329 TEST_P(GLES2DecoderTest, IsBuffer) { | 211 TEST_P(GLES2DecoderTest, IsBuffer) { |
330 EXPECT_FALSE(DoIsBuffer(client_buffer_id_)); | 212 EXPECT_FALSE(DoIsBuffer(client_buffer_id_)); |
331 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); | 213 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); |
332 EXPECT_TRUE(DoIsBuffer(client_buffer_id_)); | 214 EXPECT_TRUE(DoIsBuffer(client_buffer_id_)); |
333 DoDeleteBuffer(client_buffer_id_, kServiceBufferId); | 215 DoDeleteBuffer(client_buffer_id_, kServiceBufferId); |
334 EXPECT_FALSE(DoIsBuffer(client_buffer_id_)); | 216 EXPECT_FALSE(DoIsBuffer(client_buffer_id_)); |
335 } | 217 } |
336 | 218 |
337 TEST_P(GLES2DecoderTest, IsFramebuffer) { | 219 TEST_P(GLES2DecoderTest, IsFramebuffer) { |
338 EXPECT_FALSE(DoIsFramebuffer(client_framebuffer_id_)); | 220 EXPECT_FALSE(DoIsFramebuffer(client_framebuffer_id_)); |
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); | 1308 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); |
1427 | 1309 |
1428 INSTANTIATE_TEST_CASE_P(Service, | 1310 INSTANTIATE_TEST_CASE_P(Service, |
1429 GLES2DecoderRGBBackbufferTest, | 1311 GLES2DecoderRGBBackbufferTest, |
1430 ::testing::Bool()); | 1312 ::testing::Bool()); |
1431 | 1313 |
1432 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); | 1314 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); |
1433 | 1315 |
1434 } // namespace gles2 | 1316 } // namespace gles2 |
1435 } // namespace gpu | 1317 } // namespace gpu |
OLD | NEW |