| 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/test_helper.h" | 5 #include "gpu/command_buffer/service/test_helper.h" |
| 6 | 6 |
| 7 #include <string> | |
| 8 #include <algorithm> | |
| 9 | |
| 10 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 11 #include "base/string_tokenizer.h" | 8 #include "base/string_tokenizer.h" |
| 12 #include "gpu/command_buffer/common/gl_mock.h" | 9 #include "gpu/command_buffer/common/gl_mock.h" |
| 13 #include "gpu/command_buffer/common/types.h" | 10 #include "gpu/command_buffer/common/types.h" |
| 14 #include "gpu/command_buffer/service/gl_utils.h" | 11 #include "gpu/command_buffer/service/gl_utils.h" |
| 15 #include "gpu/command_buffer/service/program_manager.h" | 12 #include "gpu/command_buffer/service/program_manager.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 14 |
| 15 #include <string.h> |
| 16 |
| 18 using ::testing::_; | 17 using ::testing::_; |
| 19 using ::testing::DoAll; | 18 using ::testing::DoAll; |
| 20 using ::testing::InSequence; | 19 using ::testing::InSequence; |
| 21 using ::testing::MatcherCast; | 20 using ::testing::MatcherCast; |
| 22 using ::testing::Pointee; | 21 using ::testing::Pointee; |
| 23 using ::testing::Return; | 22 using ::testing::Return; |
| 24 using ::testing::SetArrayArgument; | 23 using ::testing::SetArrayArgument; |
| 25 using ::testing::SetArgumentPointee; | 24 using ::testing::SetArgumentPointee; |
| 26 using ::testing::StrEq; | 25 using ::testing::StrEq; |
| 27 using ::testing::StrictMock; | 26 using ::testing::StrictMock; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 .Times(1) | 361 .Times(1) |
| 363 .RetiresOnSaturation(); | 362 .RetiresOnSaturation(); |
| 364 break; | 363 break; |
| 365 default: | 364 default: |
| 366 NOTREACHED(); | 365 NOTREACHED(); |
| 367 break; | 366 break; |
| 368 } | 367 } |
| 369 } | 368 } |
| 370 } | 369 } |
| 371 | 370 |
| 372 void TestHelper::SetupProgramSuccessExpectations( | 371 void TestHelper::SetupShader( |
| 373 ::gfx::MockGLInterface* gl, | 372 ::gfx::MockGLInterface* gl, |
| 374 AttribInfo* attribs, size_t num_attribs, | 373 AttribInfo* attribs, size_t num_attribs, |
| 375 UniformInfo* uniforms, size_t num_uniforms, | 374 UniformInfo* uniforms, size_t num_uniforms, |
| 376 GLuint service_id) { | 375 GLuint service_id) { |
| 376 InSequence s; |
| 377 |
| 378 EXPECT_CALL(*gl, |
| 379 LinkProgram(service_id)) |
| 380 .Times(1) |
| 381 .RetiresOnSaturation(); |
| 377 EXPECT_CALL(*gl, | 382 EXPECT_CALL(*gl, |
| 378 GetProgramiv(service_id, GL_LINK_STATUS, _)) | 383 GetProgramiv(service_id, GL_LINK_STATUS, _)) |
| 379 .WillOnce(SetArgumentPointee<2>(1)) | 384 .WillOnce(SetArgumentPointee<2>(1)) |
| 380 .RetiresOnSaturation(); | 385 .RetiresOnSaturation(); |
| 381 EXPECT_CALL(*gl, | 386 EXPECT_CALL(*gl, |
| 382 GetProgramiv(service_id, GL_INFO_LOG_LENGTH, _)) | 387 GetProgramiv(service_id, GL_INFO_LOG_LENGTH, _)) |
| 383 .WillOnce(SetArgumentPointee<2>(0)) | 388 .WillOnce(SetArgumentPointee<2>(0)) |
| 384 .RetiresOnSaturation(); | 389 .RetiresOnSaturation(); |
| 385 EXPECT_CALL(*gl, | 390 EXPECT_CALL(*gl, |
| 386 GetProgramiv(service_id, GL_ACTIVE_ATTRIBUTES, _)) | 391 GetProgramiv(service_id, GL_ACTIVE_ATTRIBUTES, _)) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 service_id, StrEq(element_name))) | 473 service_id, StrEq(element_name))) |
| 469 .WillOnce(Return(info.real_location + jj * 2)) | 474 .WillOnce(Return(info.real_location + jj * 2)) |
| 470 .RetiresOnSaturation(); | 475 .RetiresOnSaturation(); |
| 471 } | 476 } |
| 472 } | 477 } |
| 473 } | 478 } |
| 474 } | 479 } |
| 475 } | 480 } |
| 476 } | 481 } |
| 477 | 482 |
| 478 void TestHelper::SetupShader( | |
| 479 ::gfx::MockGLInterface* gl, | |
| 480 AttribInfo* attribs, size_t num_attribs, | |
| 481 UniformInfo* uniforms, size_t num_uniforms, | |
| 482 GLuint service_id) { | |
| 483 InSequence s; | |
| 484 | |
| 485 EXPECT_CALL(*gl, | |
| 486 LinkProgram(service_id)) | |
| 487 .Times(1) | |
| 488 .RetiresOnSaturation(); | |
| 489 | |
| 490 SetupProgramSuccessExpectations( | |
| 491 gl, attribs, num_attribs, uniforms, num_uniforms, service_id); | |
| 492 } | |
| 493 | |
| 494 } // namespace gles2 | 483 } // namespace gles2 |
| 495 } // namespace gpu | 484 } // namespace gpu |
| 496 | 485 |
| OLD | NEW |