| 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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 }; | 566 }; |
| 567 | 567 |
| 568 const QueryType kQueryTypes[] = { | 568 const QueryType kQueryTypes[] = { |
| 569 {GL_COMMANDS_ISSUED_CHROMIUM, false}, | 569 {GL_COMMANDS_ISSUED_CHROMIUM, false}, |
| 570 {GL_LATENCY_QUERY_CHROMIUM, false}, | 570 {GL_LATENCY_QUERY_CHROMIUM, false}, |
| 571 {GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM, false}, | 571 {GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM, false}, |
| 572 {GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, false}, | 572 {GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, false}, |
| 573 {GL_GET_ERROR_QUERY_CHROMIUM, false}, | 573 {GL_GET_ERROR_QUERY_CHROMIUM, false}, |
| 574 {GL_COMMANDS_COMPLETED_CHROMIUM, false}, | 574 {GL_COMMANDS_COMPLETED_CHROMIUM, false}, |
| 575 {GL_ANY_SAMPLES_PASSED_EXT, true}, | 575 {GL_ANY_SAMPLES_PASSED_EXT, true}, |
| 576 {GL_TIME_ELAPSED, true}, | |
| 577 }; | 576 }; |
| 578 | 577 |
| 579 static void CheckBeginEndQueryBadMemoryFails(GLES2DecoderTestBase* test, | 578 static void CheckBeginEndQueryBadMemoryFails(GLES2DecoderTestBase* test, |
| 580 GLuint client_id, | 579 GLuint client_id, |
| 581 GLuint service_id, | 580 GLuint service_id, |
| 582 const QueryType& query_type, | 581 const QueryType& query_type, |
| 583 int32 shm_id, | 582 int32 shm_id, |
| 584 uint32 shm_offset) { | 583 uint32 shm_offset) { |
| 585 // We need to reset the decoder on each iteration, because we lose the | 584 // We need to reset the decoder on each iteration, because we lose the |
| 586 // context every time. | 585 // context every time. |
| 587 GLES2DecoderTestBase::InitState init; | 586 GLES2DecoderTestBase::InitState init; |
| 588 init.extensions = "GL_EXT_occlusion_query_boolean" | 587 init.extensions = "GL_EXT_occlusion_query_boolean GL_ARB_sync"; |
| 589 " GL_ARB_sync" | |
| 590 " GL_ARB_timer_query"; | |
| 591 init.gl_version = "opengl es 2.0"; | 588 init.gl_version = "opengl es 2.0"; |
| 592 init.has_alpha = true; | 589 init.has_alpha = true; |
| 593 init.request_alpha = true; | 590 init.request_alpha = true; |
| 594 init.bind_generates_resource = true; | 591 init.bind_generates_resource = true; |
| 595 test->InitDecoder(init); | 592 test->InitDecoder(init); |
| 596 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); | 593 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); |
| 597 | 594 |
| 598 BeginQueryEXT begin_cmd; | 595 BeginQueryEXT begin_cmd; |
| 599 | 596 |
| 600 test->GenHelper<GenQueriesEXTImmediate>(client_id); | 597 test->GenHelper<GenQueriesEXTImmediate>(client_id); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 | 634 |
| 638 EndQueryEXT end_cmd; | 635 EndQueryEXT end_cmd; |
| 639 end_cmd.Init(query_type.type, 1); | 636 end_cmd.Init(query_type.type, 1); |
| 640 error::Error error2 = test->ExecuteCmd(end_cmd); | 637 error::Error error2 = test->ExecuteCmd(end_cmd); |
| 641 | 638 |
| 642 if (query_type.is_gl) { | 639 if (query_type.is_gl) { |
| 643 EXPECT_CALL( | 640 EXPECT_CALL( |
| 644 *gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 641 *gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
| 645 .WillOnce(SetArgPointee<2>(1)) | 642 .WillOnce(SetArgPointee<2>(1)) |
| 646 .RetiresOnSaturation(); | 643 .RetiresOnSaturation(); |
| 647 if (query_type.type == GL_TIME_ELAPSED) { | 644 EXPECT_CALL(*gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_EXT, _)) |
| 648 EXPECT_CALL(*gl, GetQueryObjectui64v(service_id, GL_QUERY_RESULT_EXT, _)) | 645 .WillOnce(SetArgPointee<2>(1)) |
| 649 .WillOnce(SetArgPointee<2>(1)) | 646 .RetiresOnSaturation(); |
| 650 .RetiresOnSaturation(); | |
| 651 } else { | |
| 652 EXPECT_CALL(*gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_EXT, _)) | |
| 653 .WillOnce(SetArgPointee<2>(1)) | |
| 654 .RetiresOnSaturation(); | |
| 655 } | |
| 656 EXPECT_CALL(*gl, DeleteQueries(1, _)).Times(1).RetiresOnSaturation(); | |
| 657 } | 647 } |
| 658 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { | 648 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { |
| 659 #if DCHECK_IS_ON() | 649 #if DCHECK_IS_ON() |
| 660 EXPECT_CALL(*gl, IsSync(kGlSync)) | 650 EXPECT_CALL(*gl, IsSync(kGlSync)) |
| 661 .WillOnce(Return(GL_TRUE)) | 651 .WillOnce(Return(GL_TRUE)) |
| 662 .RetiresOnSaturation(); | 652 .RetiresOnSaturation(); |
| 663 #endif | 653 #endif |
| 664 EXPECT_CALL(*gl, ClientWaitSync(kGlSync, _, _)) | 654 EXPECT_CALL(*gl, ClientWaitSync(kGlSync, _, _)) |
| 665 .WillOnce(Return(GL_ALREADY_SIGNALED)) | 655 .WillOnce(Return(GL_ALREADY_SIGNALED)) |
| 666 .RetiresOnSaturation(); | 656 .RetiresOnSaturation(); |
| 657 } |
| 658 |
| 659 QueryManager* query_manager = test->GetDecoder()->GetQueryManager(); |
| 660 ASSERT_TRUE(query_manager != NULL); |
| 661 bool process_success = query_manager->ProcessPendingQueries(false); |
| 662 |
| 663 EXPECT_TRUE(error1 != error::kNoError || error2 != error::kNoError || |
| 664 !process_success); |
| 665 |
| 666 if (query_type.is_gl) { |
| 667 EXPECT_CALL(*gl, DeleteQueries(1, _)).Times(1).RetiresOnSaturation(); |
| 668 } |
| 669 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { |
| 667 #if DCHECK_IS_ON() | 670 #if DCHECK_IS_ON() |
| 668 EXPECT_CALL(*gl, IsSync(kGlSync)) | 671 EXPECT_CALL(*gl, IsSync(kGlSync)) |
| 669 .WillOnce(Return(GL_TRUE)) | 672 .WillOnce(Return(GL_TRUE)) |
| 670 .RetiresOnSaturation(); | 673 .RetiresOnSaturation(); |
| 671 #endif | 674 #endif |
| 672 EXPECT_CALL(*gl, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); | 675 EXPECT_CALL(*gl, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); |
| 673 } | 676 } |
| 674 | |
| 675 QueryManager* query_manager = test->GetDecoder()->GetQueryManager(); | |
| 676 ASSERT_TRUE(query_manager != NULL); | |
| 677 bool process_success = query_manager->ProcessPendingQueries(false); | |
| 678 | |
| 679 EXPECT_TRUE(error1 != error::kNoError || error2 != error::kNoError || | |
| 680 !process_success); | |
| 681 test->ResetDecoder(); | 677 test->ResetDecoder(); |
| 682 } | 678 } |
| 683 | 679 |
| 684 TEST_P(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) { | 680 TEST_P(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) { |
| 685 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { | 681 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { |
| 686 CheckBeginEndQueryBadMemoryFails(this, | 682 CheckBeginEndQueryBadMemoryFails(this, |
| 687 kNewClientId, | 683 kNewClientId, |
| 688 kNewServiceId, | 684 kNewServiceId, |
| 689 kQueryTypes[i], | 685 kQueryTypes[i], |
| 690 kInvalidSharedMemoryId, | 686 kInvalidSharedMemoryId, |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 INSTANTIATE_TEST_CASE_P(Service, | 1335 INSTANTIATE_TEST_CASE_P(Service, |
| 1340 GLES2DecoderRGBBackbufferTest, | 1336 GLES2DecoderRGBBackbufferTest, |
| 1341 ::testing::Bool()); | 1337 ::testing::Bool()); |
| 1342 | 1338 |
| 1343 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); | 1339 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); |
| 1344 | 1340 |
| 1345 INSTANTIATE_TEST_CASE_P(Service, GLES3DecoderTest, ::testing::Bool()); | 1341 INSTANTIATE_TEST_CASE_P(Service, GLES3DecoderTest, ::testing::Bool()); |
| 1346 | 1342 |
| 1347 } // namespace gles2 | 1343 } // namespace gles2 |
| 1348 } // namespace gpu | 1344 } // namespace gpu |
| OLD | NEW |