Rewrite AndroidSyncSettings to be significantly simpler.
[chromium-blink-merge.git] / gpu / command_buffer / service / test_helper.h
bloba536cceab6b3dc4f842ca6d69f08f1852f3cc0b5
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"
12 namespace gpu {
13 namespace gles2 {
15 struct DisallowedFeatures;
16 class Buffer;
17 class BufferManager;
18 class MockErrorState;
19 class Shader;
20 class TextureRef;
21 class TextureManager;
23 class TestHelper {
24 public:
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 kMaxRectangleTextureSize = 64;
39 static const GLint kNumVertexAttribs = 16;
40 static const GLint kNumTextureUnits = 8;
41 static const GLint kMaxTextureImageUnits = 8;
42 static const GLint kMaxVertexTextureImageUnits = 2;
43 static const GLint kMaxFragmentUniformVectors = 16;
44 static const GLint kMaxFragmentUniformComponents =
45 kMaxFragmentUniformVectors * 4;
46 static const GLint kMaxVaryingVectors = 8;
47 static const GLint kMaxVaryingFloats = kMaxVaryingVectors * 4;
48 static const GLint kMaxVertexUniformVectors = 128;
49 static const GLint kMaxVertexUniformComponents = kMaxVertexUniformVectors * 4;
51 struct AttribInfo {
52 const char* name;
53 GLint size;
54 GLenum type;
55 GLint location;
58 struct UniformInfo {
59 const char* name;
60 GLint size;
61 GLenum type;
62 GLint fake_location;
63 GLint real_location;
64 GLint desired_location;
65 const char* good_name;
68 static void SetupContextGroupInitExpectations(
69 ::gfx::MockGLInterface* gl,
70 const DisallowedFeatures& disallowed_features,
71 const char* extensions,
72 const char* gl_version,
73 bool bind_generates_resource);
74 static void SetupFeatureInfoInitExpectations(
75 ::gfx::MockGLInterface* gl, const char* extensions);
76 static void SetupFeatureInfoInitExpectationsWithGLVersion(
77 ::gfx::MockGLInterface* gl,
78 const char* extensions,
79 const char* gl_renderer,
80 const char* gl_version);
81 static void SetupTextureManagerInitExpectations(::gfx::MockGLInterface* gl,
82 const char* extensions,
83 bool use_default_textures);
84 static void SetupTextureManagerDestructionExpectations(
85 ::gfx::MockGLInterface* gl,
86 const char* extensions,
87 bool use_default_textures);
89 static void SetupExpectationsForClearingUniforms(
90 ::gfx::MockGLInterface* gl, UniformInfo* uniforms, size_t num_uniforms);
92 static void SetupShader(
93 ::gfx::MockGLInterface* gl,
94 AttribInfo* attribs, size_t num_attribs,
95 UniformInfo* uniforms, size_t num_uniforms,
96 GLuint service_id);
98 static void SetupProgramSuccessExpectations(::gfx::MockGLInterface* gl,
99 AttribInfo* attribs, size_t num_attribs,
100 UniformInfo* uniforms, size_t num_uniforms,
101 GLuint service_id);
103 static void DoBufferData(
104 ::gfx::MockGLInterface* gl, MockErrorState* error_state,
105 BufferManager* manager, Buffer* buffer, GLsizeiptr size, GLenum usage,
106 const GLvoid* data, GLenum error);
108 static void SetTexParameteriWithExpectations(
109 ::gfx::MockGLInterface* gl, MockErrorState* error_state,
110 TextureManager* manager, TextureRef* texture_ref,
111 GLenum pname, GLint value, GLenum error);
113 static void SetShaderStates(
114 ::gfx::MockGLInterface* gl, Shader* shader,
115 bool expected_valid,
116 const std::string* const expected_log_info,
117 const std::string* const expected_translated_source,
118 const AttributeMap* const expected_attrib_map,
119 const UniformMap* const expected_uniform_map,
120 const VaryingMap* const expected_varying_map,
121 const NameMap* const expected_name_map);
123 static void SetShaderStates(
124 ::gfx::MockGLInterface* gl, Shader* shader, bool valid);
126 static sh::Attribute ConstructAttribute(
127 GLenum type, GLint array_size, GLenum precision,
128 bool static_use, const std::string& name);
129 static sh::Uniform ConstructUniform(
130 GLenum type, GLint array_size, GLenum precision,
131 bool static_use, const std::string& name);
132 static sh::Varying ConstructVarying(
133 GLenum type, GLint array_size, GLenum precision,
134 bool static_use, const std::string& name);
136 private:
137 static void SetupTextureInitializationExpectations(::gfx::MockGLInterface* gl,
138 GLenum target,
139 bool use_default_textures);
140 static void SetupTextureDestructionExpectations(::gfx::MockGLInterface* gl,
141 GLenum target,
142 bool use_default_textures);
145 // This object temporaritly Sets what gfx::GetGLImplementation returns. During
146 // testing the GLImplementation is set to kGLImplemenationMockGL but lots of
147 // code branches based on what gfx::GetGLImplementation returns.
148 class ScopedGLImplementationSetter {
149 public:
150 explicit ScopedGLImplementationSetter(gfx::GLImplementation implementation);
151 ~ScopedGLImplementationSetter();
153 private:
154 gfx::GLImplementation old_implementation_;
157 } // namespace gles2
158 } // namespace gpu
160 #endif // GPU_COMMAND_BUFFER_SERVICE_TEST_HELPER_H_