1 // Copyright (c) 2012 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.
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEST_HELPER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_TEST_HELPER_H_
8 #include "gpu/command_buffer/service/shader_translator.h"
9 #include "ui/gl/gl_implementation.h"
10 #include "ui/gl/gl_mock.h"
15 struct DisallowedFeatures
;
25 static const GLuint kServiceBlackTexture2dId
= 701;
26 static const GLuint kServiceDefaultTexture2dId
= 702;
27 static const GLuint kServiceBlackTextureCubemapId
= 703;
28 static const GLuint kServiceDefaultTextureCubemapId
= 704;
29 static const GLuint kServiceBlackExternalTextureId
= 705;
30 static const GLuint kServiceDefaultExternalTextureId
= 706;
31 static const GLuint kServiceBlackRectangleTextureId
= 707;
32 static const GLuint kServiceDefaultRectangleTextureId
= 708;
34 static const GLint kMaxSamples
= 4;
35 static const GLint kMaxRenderbufferSize
= 1024;
36 static const GLint kMaxTextureSize
= 2048;
37 static const GLint kMaxCubeMapTextureSize
= 256;
38 static const GLint kNumVertexAttribs
= 16;
39 static const GLint kNumTextureUnits
= 8;
40 static const GLint kMaxTextureImageUnits
= 8;
41 static const GLint kMaxVertexTextureImageUnits
= 2;
42 static const GLint kMaxFragmentUniformVectors
= 16;
43 static const GLint kMaxFragmentUniformComponents
=
44 kMaxFragmentUniformVectors
* 4;
45 static const GLint kMaxVaryingVectors
= 8;
46 static const GLint kMaxVaryingFloats
= kMaxVaryingVectors
* 4;
47 static const GLint kMaxVertexUniformVectors
= 128;
48 static const GLint kMaxVertexUniformComponents
= kMaxVertexUniformVectors
* 4;
63 GLint desired_location
;
64 const char* good_name
;
67 static void SetupContextGroupInitExpectations(
68 ::gfx::MockGLInterface
* gl
,
69 const DisallowedFeatures
& disallowed_features
,
70 const char* extensions
,
71 const char* gl_version
,
72 bool bind_generates_resource
);
73 static void SetupFeatureInfoInitExpectations(
74 ::gfx::MockGLInterface
* gl
, const char* extensions
);
75 static void SetupFeatureInfoInitExpectationsWithGLVersion(
76 ::gfx::MockGLInterface
* gl
,
77 const char* extensions
,
78 const char* gl_renderer
,
79 const char* gl_version
);
80 static void SetupTextureManagerInitExpectations(::gfx::MockGLInterface
* gl
,
81 const char* extensions
,
82 bool use_default_textures
);
83 static void SetupTextureManagerDestructionExpectations(
84 ::gfx::MockGLInterface
* gl
,
85 const char* extensions
,
86 bool use_default_textures
);
88 static void SetupExpectationsForClearingUniforms(
89 ::gfx::MockGLInterface
* gl
, UniformInfo
* uniforms
, size_t num_uniforms
);
91 static void SetupShader(
92 ::gfx::MockGLInterface
* gl
,
93 AttribInfo
* attribs
, size_t num_attribs
,
94 UniformInfo
* uniforms
, size_t num_uniforms
,
97 static void SetupProgramSuccessExpectations(::gfx::MockGLInterface
* gl
,
98 AttribInfo
* attribs
, size_t num_attribs
,
99 UniformInfo
* uniforms
, size_t num_uniforms
,
102 static void DoBufferData(
103 ::gfx::MockGLInterface
* gl
, MockErrorState
* error_state
,
104 BufferManager
* manager
, Buffer
* buffer
, GLsizeiptr size
, GLenum usage
,
105 const GLvoid
* data
, GLenum error
);
107 static void SetTexParameteriWithExpectations(
108 ::gfx::MockGLInterface
* gl
, MockErrorState
* error_state
,
109 TextureManager
* manager
, TextureRef
* texture_ref
,
110 GLenum pname
, GLint value
, GLenum error
);
112 static void SetShaderStates(
113 ::gfx::MockGLInterface
* gl
, Shader
* shader
,
115 const std::string
* const expected_log_info
,
116 const std::string
* const expected_translated_source
,
117 const ShaderTranslatorInterface::VariableMap
* const expected_attrib_map
,
118 const ShaderTranslatorInterface::VariableMap
* const expected_uniform_map
,
119 const ShaderTranslatorInterface::VariableMap
* const expected_varying_map
,
120 const ShaderTranslatorInterface::NameMap
* const expected_name_map
);
122 static void SetShaderStates(
123 ::gfx::MockGLInterface
* gl
, Shader
* shader
, bool valid
);
126 static void SetupTextureInitializationExpectations(::gfx::MockGLInterface
* gl
,
128 bool use_default_textures
);
129 static void SetupTextureDestructionExpectations(::gfx::MockGLInterface
* gl
,
131 bool use_default_textures
);
134 // This object temporaritly Sets what gfx::GetGLImplementation returns. During
135 // testing the GLImplementation is set to kGLImplemenationMockGL but lots of
136 // code branches based on what gfx::GetGLImplementation returns.
137 class ScopedGLImplementationSetter
{
139 explicit ScopedGLImplementationSetter(gfx::GLImplementation implementation
);
140 ~ScopedGLImplementationSetter();
143 gfx::GLImplementation old_implementation_
;
149 #endif // GPU_COMMAND_BUFFER_SERVICE_TEST_HELPER_H_