| 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" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 using ::testing::AtLeast; | 37 using ::testing::AtLeast; |
| 38 using ::testing::DoAll; | 38 using ::testing::DoAll; |
| 39 using ::testing::InSequence; | 39 using ::testing::InSequence; |
| 40 using ::testing::Invoke; | 40 using ::testing::Invoke; |
| 41 using ::testing::MatcherCast; | 41 using ::testing::MatcherCast; |
| 42 using ::testing::Mock; | 42 using ::testing::Mock; |
| 43 using ::testing::Pointee; | 43 using ::testing::Pointee; |
| 44 using ::testing::Return; | 44 using ::testing::Return; |
| 45 using ::testing::SaveArg; | 45 using ::testing::SaveArg; |
| 46 using ::testing::SetArrayArgument; | 46 using ::testing::SetArrayArgument; |
| 47 using ::testing::SetArgumentPointee; | |
| 48 using ::testing::SetArgPointee; | 47 using ::testing::SetArgPointee; |
| 49 using ::testing::StrEq; | 48 using ::testing::StrEq; |
| 50 using ::testing::StrictMock; | 49 using ::testing::StrictMock; |
| 51 | 50 |
| 52 namespace gpu { | 51 namespace gpu { |
| 53 namespace gles2 { | 52 namespace gles2 { |
| 54 | 53 |
| 55 using namespace cmds; | 54 using namespace cmds; |
| 56 | 55 |
| 57 void GLES2DecoderRGBBackbufferTest::SetUp() { | 56 void GLES2DecoderRGBBackbufferTest::SetUp() { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 } | 274 } |
| 276 | 275 |
| 277 TEST_P(GLES2DecoderTest, IsTexture) { | 276 TEST_P(GLES2DecoderTest, IsTexture) { |
| 278 EXPECT_FALSE(DoIsTexture(client_texture_id_)); | 277 EXPECT_FALSE(DoIsTexture(client_texture_id_)); |
| 279 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 278 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 280 EXPECT_TRUE(DoIsTexture(client_texture_id_)); | 279 EXPECT_TRUE(DoIsTexture(client_texture_id_)); |
| 281 DoDeleteTexture(client_texture_id_, kServiceTextureId); | 280 DoDeleteTexture(client_texture_id_, kServiceTextureId); |
| 282 EXPECT_FALSE(DoIsTexture(client_texture_id_)); | 281 EXPECT_FALSE(DoIsTexture(client_texture_id_)); |
| 283 } | 282 } |
| 284 | 283 |
| 284 TEST_P(GLES2DecoderTest, GetInternalformativValidArgs) { |
| 285 const GLint kNumSampleCounts = 8; |
| 286 EXPECT_CALL(*gl_, GetError()) |
| 287 .WillOnce(Return(GL_NO_ERROR)) |
| 288 .WillOnce(Return(GL_NO_ERROR)) |
| 289 .WillOnce(Return(GL_NO_ERROR)) |
| 290 .WillOnce(Return(GL_NO_ERROR)) |
| 291 .RetiresOnSaturation(); |
| 292 typedef cmds::GetInternalformativ::Result Result; |
| 293 Result* result = static_cast<Result*>(shared_memory_address_); |
| 294 EXPECT_CALL(*gl_, GetInternalformativ(GL_RENDERBUFFER, GL_RGBA4, |
| 295 GL_NUM_SAMPLE_COUNTS, 1, _)) |
| 296 .WillOnce(SetArgPointee<4>(kNumSampleCounts)) |
| 297 .RetiresOnSaturation(); |
| 298 EXPECT_CALL(*gl_, GetInternalformativ(GL_RENDERBUFFER, GL_RGBA4, |
| 299 GL_SAMPLES, kNumSampleCounts, |
| 300 result->GetData())) |
| 301 .Times(1) |
| 302 .RetiresOnSaturation(); |
| 303 result->size = 0; |
| 304 cmds::GetInternalformativ cmd; |
| 305 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, GL_SAMPLES, kNumSampleCounts, |
| 306 shared_memory_id_, shared_memory_offset_); |
| 307 decoder_->set_unsafe_es3_apis_enabled(true); |
| 308 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 309 EXPECT_EQ(kNumSampleCounts, result->GetNumResults()); |
| 310 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 311 decoder_->set_unsafe_es3_apis_enabled(false); |
| 312 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); |
| 313 } |
| 314 |
| 315 TEST_P(GLES2DecoderTest, GetInternalformativValidArgsBufSizeTooSmall) { |
| 316 const GLint kNumSampleCounts = 8; |
| 317 const GLint kBufSize = kNumSampleCounts - 2; |
| 318 EXPECT_CALL(*gl_, GetError()) |
| 319 .WillOnce(Return(GL_NO_ERROR)) |
| 320 .WillOnce(Return(GL_NO_ERROR)) |
| 321 .WillOnce(Return(GL_NO_ERROR)) |
| 322 .WillOnce(Return(GL_NO_ERROR)) |
| 323 .RetiresOnSaturation(); |
| 324 typedef cmds::GetInternalformativ::Result Result; |
| 325 Result* result = static_cast<Result*>(shared_memory_address_); |
| 326 EXPECT_CALL(*gl_, GetInternalformativ(GL_RENDERBUFFER, GL_RGBA4, |
| 327 GL_NUM_SAMPLE_COUNTS, 1, _)) |
| 328 .WillOnce(SetArgPointee<4>(kNumSampleCounts)) |
| 329 .RetiresOnSaturation(); |
| 330 EXPECT_CALL(*gl_, GetInternalformativ(GL_RENDERBUFFER, GL_RGBA4, |
| 331 GL_SAMPLES, kBufSize, |
| 332 result->GetData())) |
| 333 .Times(1) |
| 334 .RetiresOnSaturation(); |
| 335 result->size = 0; |
| 336 cmds::GetInternalformativ cmd; |
| 337 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, GL_SAMPLES, kBufSize, |
| 338 shared_memory_id_, shared_memory_offset_); |
| 339 decoder_->set_unsafe_es3_apis_enabled(true); |
| 340 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 341 EXPECT_EQ(kBufSize, result->GetNumResults()); |
| 342 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 343 decoder_->set_unsafe_es3_apis_enabled(false); |
| 344 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); |
| 345 } |
| 346 |
| 347 TEST_P(GLES2DecoderTest, GetInternalformativValidArgsBufSizeTooBig) { |
| 348 const GLint kNumSampleCounts = 8; |
| 349 const GLint kBufSize = kNumSampleCounts + 2; |
| 350 EXPECT_CALL(*gl_, GetError()) |
| 351 .WillOnce(Return(GL_NO_ERROR)) |
| 352 .WillOnce(Return(GL_NO_ERROR)) |
| 353 .WillOnce(Return(GL_NO_ERROR)) |
| 354 .WillOnce(Return(GL_NO_ERROR)) |
| 355 .RetiresOnSaturation(); |
| 356 typedef cmds::GetInternalformativ::Result Result; |
| 357 Result* result = static_cast<Result*>(shared_memory_address_); |
| 358 EXPECT_CALL(*gl_, GetInternalformativ(GL_RENDERBUFFER, GL_RGBA4, |
| 359 GL_NUM_SAMPLE_COUNTS, 1, _)) |
| 360 .WillOnce(SetArgPointee<4>(kNumSampleCounts)) |
| 361 .RetiresOnSaturation(); |
| 362 EXPECT_CALL(*gl_, GetInternalformativ(GL_RENDERBUFFER, GL_RGBA4, |
| 363 GL_SAMPLES, kNumSampleCounts, |
| 364 result->GetData())) |
| 365 .Times(1) |
| 366 .RetiresOnSaturation(); |
| 367 result->size = 0; |
| 368 cmds::GetInternalformativ cmd; |
| 369 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, GL_SAMPLES, kBufSize, |
| 370 shared_memory_id_, shared_memory_offset_); |
| 371 decoder_->set_unsafe_es3_apis_enabled(true); |
| 372 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 373 EXPECT_EQ(kNumSampleCounts, result->GetNumResults()); |
| 374 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 375 decoder_->set_unsafe_es3_apis_enabled(false); |
| 376 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); |
| 377 } |
| 378 |
| 285 TEST_P(GLES2DecoderTest, ClientWaitSyncValid) { | 379 TEST_P(GLES2DecoderTest, ClientWaitSyncValid) { |
| 286 typedef cmds::ClientWaitSync::Result Result; | 380 typedef cmds::ClientWaitSync::Result Result; |
| 287 Result* result = static_cast<Result*>(shared_memory_address_); | 381 Result* result = static_cast<Result*>(shared_memory_address_); |
| 288 cmds::ClientWaitSync cmd; | 382 cmds::ClientWaitSync cmd; |
| 289 uint32_t v32_0 = 0, v32_1 = 0; | 383 uint32_t v32_0 = 0, v32_1 = 0; |
| 290 GLES2Util::MapUint64ToTwoUint32(0, &v32_0, &v32_1); | 384 GLES2Util::MapUint64ToTwoUint32(0, &v32_0, &v32_1); |
| 291 cmd.Init(client_sync_id_, GL_SYNC_FLUSH_COMMANDS_BIT, v32_0, v32_1, | 385 cmd.Init(client_sync_id_, GL_SYNC_FLUSH_COMMANDS_BIT, v32_0, v32_1, |
| 292 shared_memory_id_, shared_memory_offset_); | 386 shared_memory_id_, shared_memory_offset_); |
| 293 EXPECT_CALL(*gl_, | 387 EXPECT_CALL(*gl_, |
| 294 ClientWaitSync(reinterpret_cast<GLsync>(kServiceSyncId), | 388 ClientWaitSync(reinterpret_cast<GLsync>(kServiceSyncId), |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 // Test id = 0 fails. | 548 // Test id = 0 fails. |
| 455 begin_cmd.Init( | 549 begin_cmd.Init( |
| 456 GL_ANY_SAMPLES_PASSED_EXT, 0, kSharedMemoryId, kSharedMemoryOffset); | 550 GL_ANY_SAMPLES_PASSED_EXT, 0, kSharedMemoryId, kSharedMemoryOffset); |
| 457 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); | 551 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); |
| 458 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 552 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 459 | 553 |
| 460 GenHelper<GenQueriesEXTImmediate>(kNewClientId); | 554 GenHelper<GenQueriesEXTImmediate>(kNewClientId); |
| 461 | 555 |
| 462 // Test valid parameters work. | 556 // Test valid parameters work. |
| 463 EXPECT_CALL(*gl_, GenQueries(1, _)) | 557 EXPECT_CALL(*gl_, GenQueries(1, _)) |
| 464 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) | 558 .WillOnce(SetArgPointee<1>(kNewServiceId)) |
| 465 .RetiresOnSaturation(); | 559 .RetiresOnSaturation(); |
| 466 EXPECT_CALL(*gl_, BeginQuery(GL_ANY_SAMPLES_PASSED_EXT, kNewServiceId)) | 560 EXPECT_CALL(*gl_, BeginQuery(GL_ANY_SAMPLES_PASSED_EXT, kNewServiceId)) |
| 467 .Times(1) | 561 .Times(1) |
| 468 .RetiresOnSaturation(); | 562 .RetiresOnSaturation(); |
| 469 | 563 |
| 470 // Query object should not be created untill BeginQueriesEXT. | 564 // Query object should not be created untill BeginQueriesEXT. |
| 471 QueryManager* query_manager = decoder_->GetQueryManager(); | 565 QueryManager* query_manager = decoder_->GetQueryManager(); |
| 472 ASSERT_TRUE(query_manager != NULL); | 566 ASSERT_TRUE(query_manager != NULL); |
| 473 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); | 567 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); |
| 474 EXPECT_TRUE(query == NULL); | 568 EXPECT_TRUE(query == NULL); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 init.bind_generates_resource = true; | 639 init.bind_generates_resource = true; |
| 546 test->InitDecoder(init); | 640 test->InitDecoder(init); |
| 547 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); | 641 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); |
| 548 | 642 |
| 549 BeginQueryEXT begin_cmd; | 643 BeginQueryEXT begin_cmd; |
| 550 | 644 |
| 551 test->GenHelper<GenQueriesEXTImmediate>(client_id); | 645 test->GenHelper<GenQueriesEXTImmediate>(client_id); |
| 552 | 646 |
| 553 if (query_type.is_gl) { | 647 if (query_type.is_gl) { |
| 554 EXPECT_CALL(*gl, GenQueries(1, _)) | 648 EXPECT_CALL(*gl, GenQueries(1, _)) |
| 555 .WillOnce(SetArgumentPointee<1>(service_id)) | 649 .WillOnce(SetArgPointee<1>(service_id)) |
| 556 .RetiresOnSaturation(); | 650 .RetiresOnSaturation(); |
| 557 EXPECT_CALL(*gl, BeginQuery(query_type.type, service_id)) | 651 EXPECT_CALL(*gl, BeginQuery(query_type.type, service_id)) |
| 558 .Times(1) | 652 .Times(1) |
| 559 .RetiresOnSaturation(); | 653 .RetiresOnSaturation(); |
| 560 } | 654 } |
| 561 | 655 |
| 562 // Test bad shared memory fails | 656 // Test bad shared memory fails |
| 563 begin_cmd.Init(query_type.type, client_id, shm_id, shm_offset); | 657 begin_cmd.Init(query_type.type, client_id, shm_id, shm_offset); |
| 564 error::Error error1 = test->ExecuteCmd(begin_cmd); | 658 error::Error error1 = test->ExecuteCmd(begin_cmd); |
| 565 | 659 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 586 #endif | 680 #endif |
| 587 } | 681 } |
| 588 | 682 |
| 589 EndQueryEXT end_cmd; | 683 EndQueryEXT end_cmd; |
| 590 end_cmd.Init(query_type.type, 1); | 684 end_cmd.Init(query_type.type, 1); |
| 591 error::Error error2 = test->ExecuteCmd(end_cmd); | 685 error::Error error2 = test->ExecuteCmd(end_cmd); |
| 592 | 686 |
| 593 if (query_type.is_gl) { | 687 if (query_type.is_gl) { |
| 594 EXPECT_CALL( | 688 EXPECT_CALL( |
| 595 *gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 689 *gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
| 596 .WillOnce(SetArgumentPointee<2>(1)) | 690 .WillOnce(SetArgPointee<2>(1)) |
| 597 .RetiresOnSaturation(); | 691 .RetiresOnSaturation(); |
| 598 EXPECT_CALL(*gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_EXT, _)) | 692 EXPECT_CALL(*gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_EXT, _)) |
| 599 .WillOnce(SetArgumentPointee<2>(1)) | 693 .WillOnce(SetArgPointee<2>(1)) |
| 600 .RetiresOnSaturation(); | 694 .RetiresOnSaturation(); |
| 601 } | 695 } |
| 602 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { | 696 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { |
| 603 #if DCHECK_IS_ON() | 697 #if DCHECK_IS_ON() |
| 604 EXPECT_CALL(*gl, IsSync(kGlSync)) | 698 EXPECT_CALL(*gl, IsSync(kGlSync)) |
| 605 .WillOnce(Return(GL_TRUE)) | 699 .WillOnce(Return(GL_TRUE)) |
| 606 .RetiresOnSaturation(); | 700 .RetiresOnSaturation(); |
| 607 #endif | 701 #endif |
| 608 EXPECT_CALL(*gl, ClientWaitSync(kGlSync, _, _)) | 702 EXPECT_CALL(*gl, ClientWaitSync(kGlSync, _, _)) |
| 609 .WillOnce(Return(GL_ALREADY_SIGNALED)) | 703 .WillOnce(Return(GL_ALREADY_SIGNALED)) |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 INSTANTIATE_TEST_CASE_P(Service, | 1383 INSTANTIATE_TEST_CASE_P(Service, |
| 1290 GLES2DecoderRGBBackbufferTest, | 1384 GLES2DecoderRGBBackbufferTest, |
| 1291 ::testing::Bool()); | 1385 ::testing::Bool()); |
| 1292 | 1386 |
| 1293 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); | 1387 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); |
| 1294 | 1388 |
| 1295 INSTANTIATE_TEST_CASE_P(Service, GLES3DecoderTest, ::testing::Bool()); | 1389 INSTANTIATE_TEST_CASE_P(Service, GLES3DecoderTest, ::testing::Bool()); |
| 1296 | 1390 |
| 1297 } // namespace gles2 | 1391 } // namespace gles2 |
| 1298 } // namespace gpu | 1392 } // namespace gpu |
| OLD | NEW |