summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
diff options
context:
space:
mode:
authorkkinnunen@nvidia.com <kkinnunen@nvidia.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-23 07:07:53 +0000
committerkkinnunen@nvidia.com <kkinnunen@nvidia.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-23 07:07:53 +0000
commitcedee3399d70b5067c8e2630da25ab4fc0f77e8d (patch)
tree998cd7adea8c371f5032f7bd27d55535ecfa1b65 /gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
parentbdae684928898ad2937176cbeda8722b2997757b (diff)
downloadchromium_src-cedee3399d70b5067c8e2630da25ab4fc0f77e8d.zip
chromium_src-cedee3399d70b5067c8e2630da25ab4fc0f77e8d.tar.gz
chromium_src-cedee3399d70b5067c8e2630da25ab4fc0f77e8d.tar.bz2
Return early after errors in glVertexAttribDivisor and glCopyTexImage2D implementations
Command buffer command decoder is missing few early returns. Add early returns after error handling in glVertexAttribDivisorANGLE if no extension is present and glCopyTexImage2D if texture is immutable. BUG=373159 Review URL: https://codereview.chromium.org/285703005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc')
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index 8c51b03..002e142 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -35,6 +35,7 @@
using ::gfx::MockGLInterface;
using ::testing::_;
+using ::testing::AtLeast;
using ::testing::DoAll;
using ::testing::InSequence;
using ::testing::Invoke;
@@ -1209,6 +1210,53 @@ TEST_P(GLES2DecoderManualInitTest, MemoryTrackerBufferData) {
EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged));
}
+TEST_P(GLES2DecoderManualInitTest, ImmutableCopyTexImage2D) {
+ const GLenum kTarget = GL_TEXTURE_2D;
+ const GLint kLevel = 0;
+ const GLenum kInternalFormat = GL_RGBA;
+ const GLenum kSizedInternalFormat = GL_RGBA8;
+ const GLsizei kWidth = 4;
+ const GLsizei kHeight = 8;
+ const GLint kBorder = 0;
+ InitState init;
+ init.extensions = "GL_EXT_texture_storage";
+ init.gl_version = "3.0";
+ init.has_alpha = true;
+ init.request_alpha = true;
+ init.bind_generates_resource = true;
+ InitDecoder(init);
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
+
+ // CopyTexImage2D will call arbitrary amount of GetErrors.
+ EXPECT_CALL(*gl_, GetError())
+ .Times(AtLeast(1));
+
+ EXPECT_CALL(*gl_,
+ CopyTexImage2D(
+ kTarget, kLevel, kInternalFormat, 0, 0, kWidth, kHeight,
+ kBorder))
+ .Times(1);
+
+ EXPECT_CALL(*gl_,
+ TexStorage2DEXT(
+ kTarget, kLevel, kSizedInternalFormat, kWidth, kHeight))
+ .Times(1);
+ CopyTexImage2D copy_cmd;
+ copy_cmd.Init(kTarget, kLevel, kInternalFormat, 0, 0, kWidth, kHeight);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(copy_cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+
+ TexStorage2DEXT storage_cmd;
+ storage_cmd.Init(kTarget, kLevel, kSizedInternalFormat, kWidth, kHeight);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(storage_cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+
+ // This should not invoke CopyTexImage2D.
+ copy_cmd.Init(kTarget, kLevel, kInternalFormat, 0, 0, kWidth, kHeight);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(copy_cmd));
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
+}
+
INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest, ::testing::Bool());
INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderWithShaderTest, ::testing::Bool());