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