Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / gpu / command_buffer / service / gles2_cmd_decoder_unittest_base.cc
index 097d8cd..0b35b39 100644 (file)
@@ -22,6 +22,7 @@
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gl/gl_implementation.h"
 #include "ui/gl/gl_mock.h"
+#include "ui/gl/gl_surface.h"
 
 using ::gfx::MockGLInterface;
 using ::testing::_;
@@ -115,9 +116,8 @@ void GLES2DecoderTestBase::InitDecoderWithCommandLine(
     const CommandLine* command_line) {
   Framebuffer::ClearFramebufferCompleteComboMap();
 
-  gfx::ClearGLBindings();
   gfx::SetGLGetProcAddressProc(gfx::MockGLInterface::GetGLProcAddress);
-  gfx::InitializeStaticGLBindings(gfx::kGLImplementationMockGL);
+  gfx::GLSurface::InitializeOneOffWithMockBindingsForTests();
 
   gl_.reset(new StrictMock<MockGLInterface>());
   ::gfx::MockGLInterface::SetGLInterface(gl_.get());
@@ -141,8 +141,21 @@ void GLES2DecoderTestBase::InitDecoderWithCommandLine(
 
   InSequence sequence;
 
+  surface_ = new gfx::GLSurfaceStub;
+  surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight));
+
+  // Context needs to be created before initializing ContextGroup, which will
+  // in turn initialize FeatureInfo, which needs a context to determine
+  // extension support.
+  context_ = new gfx::GLContextStubWithExtensions;
+  context_->AddExtensionsString(extensions);
+  context_->SetGLVersionString(gl_version);
+
+  context_->MakeCurrent(surface_.get());
+  gfx::GLSurface::InitializeDynamicMockBindingsForTests(context_);
+
   TestHelper::SetupContextGroupInitExpectations(gl_.get(),
-      DisallowedFeatures(), extensions);
+      DisallowedFeatures(), extensions, gl_version);
 
   // We initialize the ContextGroup with a MockGLES2Decoder so that
   // we can use the ContextGroup to figure out how the real GLES2Decoder
@@ -281,16 +294,6 @@ void GLES2DecoderTestBase::InitDecoderWithCommandLine(
   shared_memory_id_ = kSharedMemoryId;
   shared_memory_base_ = buffer.ptr;
 
-  surface_ = new gfx::GLSurfaceStub;
-  surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight));
-
-  context_ = new gfx::GLContextStubWithExtensions;
-  context_->AddExtensionsString(extensions);
-  context_->SetGLVersionString(gl_version);
-
-  context_->MakeCurrent(surface_.get());
-  gfx::InitializeDynamicGLBindings(gfx::kGLImplementationMockGL, context_);
-
   int32 attributes[] = {
     EGL_ALPHA_SIZE, request_alpha ? 8 : 0,
     EGL_DEPTH_SIZE, request_depth ? 24 : 0,
@@ -834,6 +837,28 @@ void GLES2DecoderTestBase::DoTexImage2D(
   EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
 }
 
+void GLES2DecoderTestBase::DoTexImage2DConvertInternalFormat(
+    GLenum target, GLint level, GLenum requested_internal_format,
+    GLsizei width, GLsizei height, GLint border,
+    GLenum format, GLenum type,
+    uint32 shared_memory_id, uint32 shared_memory_offset,
+    GLenum expected_internal_format) {
+  EXPECT_CALL(*gl_, GetError())
+      .WillOnce(Return(GL_NO_ERROR))
+      .RetiresOnSaturation();
+  EXPECT_CALL(*gl_, TexImage2D(target, level, expected_internal_format,
+                               width, height, border, format, type, _))
+      .Times(1)
+      .RetiresOnSaturation();
+  EXPECT_CALL(*gl_, GetError())
+      .WillOnce(Return(GL_NO_ERROR))
+      .RetiresOnSaturation();
+  cmds::TexImage2D cmd;
+  cmd.Init(target, level, requested_internal_format, width, height, border,
+           format, type, shared_memory_id, shared_memory_offset);
+  EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
 void GLES2DecoderTestBase::DoCompressedTexImage2D(
     GLenum target, GLint level, GLenum format,
     GLsizei width, GLsizei height, GLint border,
@@ -1263,9 +1288,6 @@ void GLES2DecoderTestBase::SetupShader(
   link_cmd.Init(program_client_id);
 
   EXPECT_EQ(error::kNoError, ExecuteCmd(link_cmd));
-
-  // Assume the next command will be UseProgram.
-  SetupExpectationsForClearingUniforms(uniforms, num_uniforms);
 }
 
 void GLES2DecoderTestBase::DoEnableVertexAttribArray(GLint index) {