Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / gpu / command_buffer / service / test_helper.h
bloba7eaec2afe3bc2d5933ebb2e1984baa408adf9f7
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 <string>
9 #include <vector>
11 #include "gpu/command_buffer/service/shader_translator.h"
12 #include "ui/gl/gl_implementation.h"
13 #include "ui/gl/gl_mock.h"
15 namespace gpu {
16 namespace gles2 {
18 struct DisallowedFeatures;
19 class Buffer;
20 class BufferManager;
21 class MockErrorState;
22 class Shader;
23 class TextureRef;
24 class TextureManager;
26 class TestHelper {
27 public:
28 static const GLuint kServiceBlackTexture2dId = 701;
29 static const GLuint kServiceDefaultTexture2dId = 702;
30 static const GLuint kServiceBlackTextureCubemapId = 703;
31 static const GLuint kServiceDefaultTextureCubemapId = 704;
32 static const GLuint kServiceBlackExternalTextureId = 705;
33 static const GLuint kServiceDefaultExternalTextureId = 706;
34 static const GLuint kServiceBlackRectangleTextureId = 707;
35 static const GLuint kServiceDefaultRectangleTextureId = 708;
37 static const GLint kMaxSamples = 4;
38 static const GLint kMaxRenderbufferSize = 1024;
39 static const GLint kMaxTextureSize = 2048;
40 static const GLint kMaxCubeMapTextureSize = 256;
41 static const GLint kMax3DTextureSize = 256;
42 static const GLint kMaxRectangleTextureSize = 64;
43 static const GLint kNumVertexAttribs = 16;
44 static const GLint kNumTextureUnits = 8;
45 static const GLint kMaxTextureImageUnits = 8;
46 static const GLint kMaxVertexTextureImageUnits = 2;
47 static const GLint kMaxFragmentUniformVectors = 16;
48 static const GLint kMaxFragmentUniformComponents =
49 kMaxFragmentUniformVectors * 4;
50 static const GLint kMaxVaryingVectors = 8;
51 static const GLint kMaxVaryingFloats = kMaxVaryingVectors * 4;
52 static const GLint kMaxVertexUniformVectors = 128;
53 static const GLint kMaxVertexUniformComponents = kMaxVertexUniformVectors * 4;
55 struct AttribInfo {
56 const char* name;
57 GLint size;
58 GLenum type;
59 GLint location;
62 struct UniformInfo {
63 const char* name;
64 GLint size;
65 GLenum type;
66 GLint fake_location;
67 GLint real_location;
68 GLint desired_location;
69 const char* good_name;
72 static void SetupContextGroupInitExpectations(
73 ::gfx::MockGLInterface* gl,
74 const DisallowedFeatures& disallowed_features,
75 const char* extensions,
76 const char* gl_version,
77 bool bind_generates_resource);
78 static void SetupFeatureInfoInitExpectations(
79 ::gfx::MockGLInterface* gl, const char* extensions);
80 static void SetupFeatureInfoInitExpectationsWithGLVersion(
81 ::gfx::MockGLInterface* gl,
82 const char* extensions,
83 const char* gl_renderer,
84 const char* gl_version);
85 static void SetupTextureManagerInitExpectations(::gfx::MockGLInterface* gl,
86 const char* extensions,
87 bool use_default_textures);
88 static void SetupTextureManagerDestructionExpectations(
89 ::gfx::MockGLInterface* gl,
90 const char* extensions,
91 bool use_default_textures);
93 static void SetupExpectationsForClearingUniforms(
94 ::gfx::MockGLInterface* gl, UniformInfo* uniforms, size_t num_uniforms);
96 static void SetupShader(
97 ::gfx::MockGLInterface* gl,
98 AttribInfo* attribs, size_t num_attribs,
99 UniformInfo* uniforms, size_t num_uniforms,
100 GLuint service_id);
102 static void SetupProgramSuccessExpectations(::gfx::MockGLInterface* gl,
103 AttribInfo* attribs, size_t num_attribs,
104 UniformInfo* uniforms, size_t num_uniforms,
105 GLuint service_id);
107 static void DoBufferData(
108 ::gfx::MockGLInterface* gl, MockErrorState* error_state,
109 BufferManager* manager, Buffer* buffer, GLenum target, GLsizeiptr size,
110 GLenum usage, const GLvoid* data, GLenum error);
112 static void SetTexParameteriWithExpectations(
113 ::gfx::MockGLInterface* gl, MockErrorState* error_state,
114 TextureManager* manager, TextureRef* texture_ref,
115 GLenum pname, GLint value, GLenum error);
117 static void SetShaderStates(
118 ::gfx::MockGLInterface* gl, Shader* shader,
119 bool expected_valid,
120 const std::string* const expected_log_info,
121 const std::string* const expected_translated_source,
122 const int* const expected_shader_version,
123 const AttributeMap* const expected_attrib_map,
124 const UniformMap* const expected_uniform_map,
125 const VaryingMap* const expected_varying_map,
126 const NameMap* const expected_name_map);
128 static void SetShaderStates(
129 ::gfx::MockGLInterface* gl, Shader* shader, bool valid);
131 static sh::Attribute ConstructAttribute(
132 GLenum type, GLint array_size, GLenum precision,
133 bool static_use, const std::string& name);
134 static sh::Uniform ConstructUniform(
135 GLenum type, GLint array_size, GLenum precision,
136 bool static_use, const std::string& name);
137 static sh::Varying ConstructVarying(
138 GLenum type, GLint array_size, GLenum precision,
139 bool static_use, const std::string& name);
141 private:
142 static void SetupTextureInitializationExpectations(::gfx::MockGLInterface* gl,
143 GLenum target,
144 bool use_default_textures);
145 static void SetupTextureDestructionExpectations(::gfx::MockGLInterface* gl,
146 GLenum target,
147 bool use_default_textures);
149 static std::vector<std::string> split_extensions_;
152 // This object temporaritly Sets what gfx::GetGLImplementation returns. During
153 // testing the GLImplementation is set to kGLImplemenationMockGL but lots of
154 // code branches based on what gfx::GetGLImplementation returns.
155 class ScopedGLImplementationSetter {
156 public:
157 explicit ScopedGLImplementationSetter(gfx::GLImplementation implementation);
158 ~ScopedGLImplementationSetter();
160 private:
161 gfx::GLImplementation old_implementation_;
164 } // namespace gles2
165 } // namespace gpu
167 #endif // GPU_COMMAND_BUFFER_SERVICE_TEST_HELPER_H_