OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "gpu/command_buffer/service/test_helper.h" |
| 6 #include "app/gfx/gl/gl_mock.h" |
| 7 #include "gpu/command_buffer/common/types.h" |
| 8 #include "gpu/GLES2/gles2_command_buffer.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 |
| 11 using ::testing::_; |
| 12 using ::testing::DoAll; |
| 13 using ::testing::InSequence; |
| 14 using ::testing::MatcherCast; |
| 15 using ::testing::Pointee; |
| 16 using ::testing::Return; |
| 17 using ::testing::SetArrayArgument; |
| 18 using ::testing::SetArgumentPointee; |
| 19 using ::testing::StrEq; |
| 20 using ::testing::StrictMock; |
| 21 |
| 22 namespace gpu { |
| 23 namespace gles2 { |
| 24 |
| 25 // GCC requires these declarations, but MSVC requires they not be present |
| 26 #ifndef COMPILER_MSVC |
| 27 const GLuint TestHelper::kServiceBlackTexture2dId; |
| 28 const GLuint TestHelper::kServiceBlackTextureCubemapId; |
| 29 const GLuint TestHelper::kServiceDefaultTexture2dId; |
| 30 const GLuint TestHelper::kServiceDefaultTextureCubemapId; |
| 31 |
| 32 const GLint TestHelper::kMaxTextureSize; |
| 33 const GLint TestHelper::kMaxCubeMapTextureSize; |
| 34 const GLint TestHelper::kNumVertexAttribs; |
| 35 const GLint TestHelper::kNumTextureUnits; |
| 36 const GLint TestHelper::kMaxTextureImageUnits; |
| 37 const GLint TestHelper::kMaxVertexTextureImageUnits; |
| 38 const GLint TestHelper::kMaxFragmentUniformVectors; |
| 39 const GLint TestHelper::kMaxVaryingVectors; |
| 40 const GLint TestHelper::kMaxVertexUniformVectors; |
| 41 #endif |
| 42 |
| 43 void TestHelper::SetupTextureManagerInitExpectations( |
| 44 ::gfx::MockGLInterface* gl) { |
| 45 static GLuint texture_ids[] = { |
| 46 kServiceBlackTexture2dId, |
| 47 kServiceDefaultTexture2dId, |
| 48 kServiceBlackTextureCubemapId, |
| 49 kServiceDefaultTextureCubemapId, |
| 50 }; |
| 51 EXPECT_CALL(*gl, GenTextures(arraysize(texture_ids), _)) |
| 52 .WillOnce(SetArrayArgument<1>(texture_ids, |
| 53 texture_ids + arraysize(texture_ids))) |
| 54 .RetiresOnSaturation(); |
| 55 for (int ii = 0; ii < 2; ++ii) { |
| 56 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_2D, texture_ids[ii])) |
| 57 .Times(1) |
| 58 .RetiresOnSaturation(); |
| 59 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, |
| 60 GL_UNSIGNED_BYTE, _)) |
| 61 .Times(1) |
| 62 .RetiresOnSaturation(); |
| 63 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_CUBE_MAP, texture_ids[2 + ii])) |
| 64 .Times(1) |
| 65 .RetiresOnSaturation(); |
| 66 static GLenum faces[] = { |
| 67 GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
| 68 GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
| 69 GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
| 70 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, |
| 71 GL_TEXTURE_CUBE_MAP_POSITIVE_Z, |
| 72 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, |
| 73 }; |
| 74 for (size_t ii = 0; ii < arraysize(faces); ++ii) { |
| 75 EXPECT_CALL(*gl, TexImage2D(faces[ii], 0, GL_RGBA, 1, 1, 0, GL_RGBA, |
| 76 GL_UNSIGNED_BYTE, _)) |
| 77 .Times(1) |
| 78 .RetiresOnSaturation(); |
| 79 } |
| 80 } |
| 81 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_2D, 0)) |
| 82 .Times(1) |
| 83 .RetiresOnSaturation(); |
| 84 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_CUBE_MAP, 0)) |
| 85 .Times(1) |
| 86 .RetiresOnSaturation(); |
| 87 } |
| 88 |
| 89 void TestHelper::SetupContextGroupInitExpectations( |
| 90 ::gfx::MockGLInterface* gl, const char* extensions) { |
| 91 InSequence sequence; |
| 92 |
| 93 EXPECT_CALL(*gl, GetString(GL_EXTENSIONS)) |
| 94 .WillOnce(Return(reinterpret_cast<const uint8*>(extensions))) |
| 95 .RetiresOnSaturation(); |
| 96 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VERTEX_ATTRIBS, _)) |
| 97 .WillOnce(SetArgumentPointee<1>(kNumVertexAttribs)) |
| 98 .RetiresOnSaturation(); |
| 99 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, _)) |
| 100 .WillOnce(SetArgumentPointee<1>(kNumTextureUnits)) |
| 101 .RetiresOnSaturation(); |
| 102 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_TEXTURE_SIZE, _)) |
| 103 .WillOnce(SetArgumentPointee<1>(kMaxTextureSize)) |
| 104 .RetiresOnSaturation(); |
| 105 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, _)) |
| 106 .WillOnce(SetArgumentPointee<1>(kMaxCubeMapTextureSize)) |
| 107 .RetiresOnSaturation(); |
| 108 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, _)) |
| 109 .WillOnce(SetArgumentPointee<1>(kMaxTextureImageUnits)) |
| 110 .RetiresOnSaturation(); |
| 111 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, _)) |
| 112 .WillOnce(SetArgumentPointee<1>(kMaxVertexTextureImageUnits)) |
| 113 .RetiresOnSaturation(); |
| 114 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, _)) |
| 115 .WillOnce(SetArgumentPointee<1>(kMaxFragmentUniformVectors)) |
| 116 .RetiresOnSaturation(); |
| 117 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VARYING_FLOATS, _)) |
| 118 .WillOnce(SetArgumentPointee<1>(kMaxVaryingVectors)) |
| 119 .RetiresOnSaturation(); |
| 120 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, _)) |
| 121 .WillOnce(SetArgumentPointee<1>(kMaxVertexUniformVectors)) |
| 122 .RetiresOnSaturation(); |
| 123 |
| 124 SetupTextureManagerInitExpectations(gl); |
| 125 } |
| 126 |
| 127 } // namespace gles2 |
| 128 } // namespace gpu |
| 129 |
OLD | NEW |