diff options
Diffstat (limited to 'gpu/command_buffer/client/gles2_implementation_unittest.cc')
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation_unittest.cc | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc index 2d69fce..9643b55 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc @@ -1232,6 +1232,84 @@ TEST_F(GLES2ImplementationTest, GetProgramInfoCHROMIUMBadArgs) { EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); } +// Test that things are cached +TEST_F(GLES2ImplementationTest, GetIntegerCacheRead) { + struct PNameValue { + GLenum pname; + GLint expected; + }; + const PNameValue pairs[] = { + { GL_ACTIVE_TEXTURE, GL_TEXTURE0, }, + { GL_TEXTURE_BINDING_2D, 0, }, + { GL_TEXTURE_BINDING_CUBE_MAP, 0, }, + { GL_FRAMEBUFFER_BINDING, 0, }, + { GL_RENDERBUFFER_BINDING, 0, }, + { GL_ARRAY_BUFFER_BINDING, 0, }, + { GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, }, + { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, kMaxCombinedTextureImageUnits, }, + { GL_MAX_CUBE_MAP_TEXTURE_SIZE, kMaxCubeMapTextureSize, }, + { GL_MAX_FRAGMENT_UNIFORM_VECTORS, kMaxFragmentUniformVectors, }, + { GL_MAX_RENDERBUFFER_SIZE, kMaxRenderbufferSize, }, + { GL_MAX_TEXTURE_IMAGE_UNITS, kMaxTextureImageUnits, }, + { GL_MAX_TEXTURE_SIZE, kMaxTextureSize, }, + { GL_MAX_VARYING_VECTORS, kMaxVaryingVectors, }, + { GL_MAX_VERTEX_ATTRIBS, kMaxVertexAttribs, }, + { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, kMaxVertexTextureImageUnits, }, + { GL_MAX_VERTEX_UNIFORM_VECTORS, kMaxVertexUniformVectors, }, + { GL_NUM_COMPRESSED_TEXTURE_FORMATS, kNumCompressedTextureFormats, }, + { GL_NUM_SHADER_BINARY_FORMATS, kNumShaderBinaryFormats, }, + }; + size_t num_pairs = sizeof(pairs) / sizeof(pairs[0]); + for (size_t ii = 0; ii < num_pairs; ++ii) { + const PNameValue& pv = pairs[ii]; + GLint v = -1; + gl_->GetIntegerv(pv.pname, &v); + EXPECT_TRUE(NoCommandsWritten()); + EXPECT_EQ(pv.expected, v); + } + + EXPECT_CALL(*command_buffer_, OnFlush(_)) + .WillOnce(SetMemory(GLuint(GL_NO_ERROR))) + .RetiresOnSaturation(); + EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); +} + +TEST_F(GLES2ImplementationTest, GetIntegerCacheWrite) { + struct PNameValue { + GLenum pname; + GLint expected; + }; + gl_->ActiveTexture(GL_TEXTURE4); + gl_->BindBuffer(GL_ARRAY_BUFFER, 2); + gl_->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 3); + gl_->BindFramebuffer(GL_FRAMEBUFFER, 4); + gl_->BindRenderbuffer(GL_RENDERBUFFER, 5); + gl_->BindTexture(GL_TEXTURE_2D, 6); + gl_->BindTexture(GL_TEXTURE_CUBE_MAP, 7); + + const PNameValue pairs[] = { + { GL_ACTIVE_TEXTURE, GL_TEXTURE4, }, + { GL_ARRAY_BUFFER_BINDING, 2, }, + { GL_ELEMENT_ARRAY_BUFFER_BINDING, 3, }, + { GL_FRAMEBUFFER_BINDING, 4, }, + { GL_RENDERBUFFER_BINDING, 5, }, + { GL_TEXTURE_BINDING_2D, 6, }, + { GL_TEXTURE_BINDING_CUBE_MAP, 7, }, + }; + size_t num_pairs = sizeof(pairs) / sizeof(pairs[0]); + for (size_t ii = 0; ii < num_pairs; ++ii) { + const PNameValue& pv = pairs[ii]; + GLint v = -1; + gl_->GetIntegerv(pv.pname, &v); + EXPECT_EQ(pv.expected, v); + } + + EXPECT_CALL(*command_buffer_, OnFlush(_)) + .WillOnce(SetMemory(GLuint(GL_NO_ERROR))) + .RetiresOnSaturation(); + EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); +} + } // namespace gles2 } // namespace gpu |