| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/program_manager.h" | 5 #include "gpu/command_buffer/service/program_manager.h" |
| 6 #include "app/gfx/gl/gl_mock.h" |
| 6 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 7 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "gpu/command_buffer/service/gl_mock.h" | |
| 10 | 10 |
| 11 using ::gles2::MockGLInterface; | 11 using ::gfx::MockGLInterface; |
| 12 using ::testing::_; | 12 using ::testing::_; |
| 13 using ::testing::DoAll; | 13 using ::testing::DoAll; |
| 14 using ::testing::InSequence; | 14 using ::testing::InSequence; |
| 15 using ::testing::MatcherCast; | 15 using ::testing::MatcherCast; |
| 16 using ::testing::Pointee; | 16 using ::testing::Pointee; |
| 17 using ::testing::Return; | 17 using ::testing::Return; |
| 18 using ::testing::SetArrayArgument; | 18 using ::testing::SetArrayArgument; |
| 19 using ::testing::SetArgumentPointee; | 19 using ::testing::SetArgumentPointee; |
| 20 using ::testing::StrEq; | 20 using ::testing::StrEq; |
| 21 using ::testing::StrictMock; | 21 using ::testing::StrictMock; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 struct UniformInfo { | 115 struct UniformInfo { |
| 116 const char* name; | 116 const char* name; |
| 117 GLint size; | 117 GLint size; |
| 118 GLenum type; | 118 GLenum type; |
| 119 GLint location; | 119 GLint location; |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 virtual void SetUp() { | 122 virtual void SetUp() { |
| 123 gl_.reset(new StrictMock<MockGLInterface>()); | 123 gl_.reset(new StrictMock<gfx::MockGLInterface>()); |
| 124 ::gles2::GLInterface::SetGLInterface(gl_.get()); | 124 ::gfx::GLInterface::SetGLInterface(gl_.get()); |
| 125 | 125 |
| 126 SetupDefaultShaderExpectations(); | 126 SetupDefaultShaderExpectations(); |
| 127 | 127 |
| 128 manager_.CreateProgramInfo(kClientProgramId, kServiceProgramId); | 128 manager_.CreateProgramInfo(kClientProgramId, kServiceProgramId); |
| 129 program_info_ = manager_.GetProgramInfo(kClientProgramId); | 129 program_info_ = manager_.GetProgramInfo(kClientProgramId); |
| 130 program_info_->Update(); | 130 program_info_->Update(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void SetupShader(AttribInfo* attribs, size_t num_attribs, | 133 void SetupShader(AttribInfo* attribs, size_t num_attribs, |
| 134 UniformInfo* uniforms, size_t num_uniforms, | 134 UniformInfo* uniforms, size_t num_uniforms, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 | 212 |
| 213 | 213 |
| 214 void SetupDefaultShaderExpectations() { | 214 void SetupDefaultShaderExpectations() { |
| 215 SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms, | 215 SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms, |
| 216 kServiceProgramId); | 216 kServiceProgramId); |
| 217 } | 217 } |
| 218 | 218 |
| 219 virtual void TearDown() { | 219 virtual void TearDown() { |
| 220 ::gfx::GLInterface::SetGLInterface(NULL); |
| 220 } | 221 } |
| 221 | 222 |
| 222 static AttribInfo kAttribs[]; | 223 static AttribInfo kAttribs[]; |
| 223 static UniformInfo kUniforms[]; | 224 static UniformInfo kUniforms[]; |
| 224 | 225 |
| 225 scoped_ptr<StrictMock<MockGLInterface> > gl_; | 226 scoped_ptr<StrictMock<gfx::MockGLInterface> > gl_; |
| 226 | 227 |
| 227 ProgramManager manager_; | 228 ProgramManager manager_; |
| 228 | 229 |
| 229 ProgramManager::ProgramInfo* program_info_; | 230 ProgramManager::ProgramInfo* program_info_; |
| 230 }; | 231 }; |
| 231 | 232 |
| 232 ProgramManagerWithShaderTest::AttribInfo | 233 ProgramManagerWithShaderTest::AttribInfo |
| 233 ProgramManagerWithShaderTest::kAttribs[] = { | 234 ProgramManagerWithShaderTest::kAttribs[] = { |
| 234 { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, }, | 235 { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, }, |
| 235 { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, }, | 236 { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, }, |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 // as the "gl_" uniform we skipped. | 459 // as the "gl_" uniform we skipped. |
| 459 // +4u is to account for "gl_" and NULL terminator. | 460 // +4u is to account for "gl_" and NULL terminator. |
| 460 program_info->GetProgramiv(GL_ACTIVE_UNIFORM_MAX_LENGTH, &value); | 461 program_info->GetProgramiv(GL_ACTIVE_UNIFORM_MAX_LENGTH, &value); |
| 461 EXPECT_EQ(strlen(kUniform3Name) + 4u, static_cast<size_t>(value)); | 462 EXPECT_EQ(strlen(kUniform3Name) + 4u, static_cast<size_t>(value)); |
| 462 } | 463 } |
| 463 | 464 |
| 464 } // namespace gles2 | 465 } // namespace gles2 |
| 465 } // namespace gpu | 466 } // namespace gpu |
| 466 | 467 |
| 467 | 468 |
| OLD | NEW |