| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_base.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" |
| 6 #include "app/gfx/gl/gl_mock.h" |
| 6 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 7 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
| 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 9 #include "gpu/command_buffer/service/gl_mock.h" | |
| 10 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 10 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
| 11 #include "gpu/command_buffer/service/context_group.h" | 11 #include "gpu/command_buffer/service/context_group.h" |
| 12 #include "gpu/command_buffer/service/program_manager.h" | 12 #include "gpu/command_buffer/service/program_manager.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 using ::gles2::MockGLInterface; | 15 using ::gfx::MockGLInterface; |
| 16 using ::testing::_; | 16 using ::testing::_; |
| 17 using ::testing::DoAll; | 17 using ::testing::DoAll; |
| 18 using ::testing::InSequence; | 18 using ::testing::InSequence; |
| 19 using ::testing::MatcherCast; | 19 using ::testing::MatcherCast; |
| 20 using ::testing::Pointee; | 20 using ::testing::Pointee; |
| 21 using ::testing::Return; | 21 using ::testing::Return; |
| 22 using ::testing::SetArrayArgument; | 22 using ::testing::SetArrayArgument; |
| 23 using ::testing::SetArgumentPointee; | 23 using ::testing::SetArgumentPointee; |
| 24 using ::testing::StrEq; | 24 using ::testing::StrEq; |
| 25 using ::testing::StrictMock; | 25 using ::testing::StrictMock; |
| 26 | 26 |
| 27 namespace gpu { | 27 namespace gpu { |
| 28 namespace gles2 { | 28 namespace gles2 { |
| 29 | 29 |
| 30 void GLES2DecoderTestBase::SetUp() { | 30 void GLES2DecoderTestBase::SetUp() { |
| 31 gl_.reset(new StrictMock<MockGLInterface>()); | 31 gl_.reset(new StrictMock<MockGLInterface>()); |
| 32 ::gles2::GLInterface::SetGLInterface(gl_.get()); | 32 ::gfx::GLInterface::SetGLInterface(gl_.get()); |
| 33 | 33 |
| 34 InSequence sequence; | 34 InSequence sequence; |
| 35 | 35 |
| 36 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_ATTRIBS, _)) | 36 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_ATTRIBS, _)) |
| 37 .WillOnce(SetArgumentPointee<1>(kNumVertexAttribs)) | 37 .WillOnce(SetArgumentPointee<1>(kNumVertexAttribs)) |
| 38 .RetiresOnSaturation(); | 38 .RetiresOnSaturation(); |
| 39 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, _)) | 39 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, _)) |
| 40 .WillOnce(SetArgumentPointee<1>(kNumTextureUnits)) | 40 .WillOnce(SetArgumentPointee<1>(kNumTextureUnits)) |
| 41 .RetiresOnSaturation(); | 41 .RetiresOnSaturation(); |
| 42 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_TEXTURE_SIZE, _)) | 42 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_TEXTURE_SIZE, _)) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 .Times(1) | 141 .Times(1) |
| 142 .RetiresOnSaturation(); | 142 .RetiresOnSaturation(); |
| 143 | 143 |
| 144 engine_.reset(new StrictMock<MockCommandBufferEngine>()); | 144 engine_.reset(new StrictMock<MockCommandBufferEngine>()); |
| 145 Buffer buffer = engine_->GetSharedMemoryBuffer(kSharedMemoryId); | 145 Buffer buffer = engine_->GetSharedMemoryBuffer(kSharedMemoryId); |
| 146 shared_memory_offset_ = kSharedMemoryOffset; | 146 shared_memory_offset_ = kSharedMemoryOffset; |
| 147 shared_memory_address_ = reinterpret_cast<int8*>(buffer.ptr) + | 147 shared_memory_address_ = reinterpret_cast<int8*>(buffer.ptr) + |
| 148 shared_memory_offset_; | 148 shared_memory_offset_; |
| 149 shared_memory_id_ = kSharedMemoryId; | 149 shared_memory_id_ = kSharedMemoryId; |
| 150 | 150 |
| 151 context_.reset(gfx::GLContext::CreateOffscreenGLContext(NULL)); | 151 context_.reset(new gfx::StubGLContext); |
| 152 | 152 |
| 153 decoder_.reset(GLES2Decoder::Create(&group_)); | 153 decoder_.reset(GLES2Decoder::Create(&group_)); |
| 154 decoder_->Initialize(context_.get(), gfx::Size(), NULL, 0); | 154 decoder_->Initialize(context_.get(), gfx::Size(), NULL, 0); |
| 155 decoder_->set_engine(engine_.get()); | 155 decoder_->set_engine(engine_.get()); |
| 156 | 156 |
| 157 EXPECT_CALL(*gl_, GenBuffersARB(_, _)) | 157 EXPECT_CALL(*gl_, GenBuffersARB(_, _)) |
| 158 .WillOnce(SetArgumentPointee<1>(kServiceBufferId)) | 158 .WillOnce(SetArgumentPointee<1>(kServiceBufferId)) |
| 159 .RetiresOnSaturation(); | 159 .RetiresOnSaturation(); |
| 160 GenHelper<GenBuffersImmediate>(client_buffer_id_); | 160 GenHelper<GenBuffersImmediate>(client_buffer_id_); |
| 161 EXPECT_CALL(*gl_, GenFramebuffersEXT(_, _)) | 161 EXPECT_CALL(*gl_, GenFramebuffersEXT(_, _)) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 195 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 196 EXPECT_CALL(*gl_, DeleteTextures(1, _)) | 196 EXPECT_CALL(*gl_, DeleteTextures(1, _)) |
| 197 .Times(2) | 197 .Times(2) |
| 198 .RetiresOnSaturation(); | 198 .RetiresOnSaturation(); |
| 199 EXPECT_CALL(*gl_, DeleteBuffersARB(1, _)) | 199 EXPECT_CALL(*gl_, DeleteBuffersARB(1, _)) |
| 200 .Times(1) | 200 .Times(1) |
| 201 .RetiresOnSaturation(); | 201 .RetiresOnSaturation(); |
| 202 decoder_->Destroy(); | 202 decoder_->Destroy(); |
| 203 decoder_.reset(); | 203 decoder_.reset(); |
| 204 engine_.reset(); | 204 engine_.reset(); |
| 205 ::gles2::GLInterface::SetGLInterface(NULL); | 205 ::gfx::GLInterface::SetGLInterface(NULL); |
| 206 gl_.reset(); | 206 gl_.reset(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 GLint GLES2DecoderTestBase::GetGLError() { | 209 GLint GLES2DecoderTestBase::GetGLError() { |
| 210 EXPECT_CALL(*gl_, GetError()) | 210 EXPECT_CALL(*gl_, GetError()) |
| 211 .WillOnce(Return(GL_NO_ERROR)) | 211 .WillOnce(Return(GL_NO_ERROR)) |
| 212 .RetiresOnSaturation(); | 212 .RetiresOnSaturation(); |
| 213 GetError cmd; | 213 GetError cmd; |
| 214 cmd.Init(shared_memory_id_, shared_memory_offset_); | 214 cmd.Init(shared_memory_id_, shared_memory_offset_); |
| 215 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 215 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 const char* GLES2DecoderWithShaderTestBase::kAttrib2Name = "attrib2"; | 655 const char* GLES2DecoderWithShaderTestBase::kAttrib2Name = "attrib2"; |
| 656 const char* GLES2DecoderWithShaderTestBase::kAttrib3Name = "attrib3"; | 656 const char* GLES2DecoderWithShaderTestBase::kAttrib3Name = "attrib3"; |
| 657 const char* GLES2DecoderWithShaderTestBase::kUniform1Name = "uniform1"; | 657 const char* GLES2DecoderWithShaderTestBase::kUniform1Name = "uniform1"; |
| 658 const char* GLES2DecoderWithShaderTestBase::kUniform2Name = "uniform2[0]"; | 658 const char* GLES2DecoderWithShaderTestBase::kUniform2Name = "uniform2[0]"; |
| 659 const char* GLES2DecoderWithShaderTestBase::kUniform3Name = "uniform3[0]"; | 659 const char* GLES2DecoderWithShaderTestBase::kUniform3Name = "uniform3[0]"; |
| 660 | 660 |
| 661 } // namespace gles2 | 661 } // namespace gles2 |
| 662 } // namespace gpu | 662 } // namespace gpu |
| 663 | 663 |
| 664 | 664 |
| OLD | NEW |