Telemetry: adding memory tests & solving problems on the go.
[chromium-blink-merge.git] / gpu / command_buffer / common / gl_mock.h
blob3d2e2b5157ee425b1b53981e6f4b33337832b901
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 // This file implements mock GL Interface for unit testing. It has to mock
6 // Desktop GL, not GLES2 as it is used to test the service side code.
8 #ifndef GPU_COMMAND_BUFFER_COMMON_GL_MOCK_H_
9 #define GPU_COMMAND_BUFFER_COMMON_GL_MOCK_H_
11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "ui/gl/gl_interface.h"
14 namespace gfx {
16 class MockGLInterface : public GLInterface {
17 public:
18 MockGLInterface();
19 virtual ~MockGLInterface();
21 MOCK_METHOD1(ActiveTexture, void(GLenum texture));
23 MOCK_METHOD2(AttachShader, void(GLuint program, GLuint shader));
25 MOCK_METHOD2(BeginQuery, void(GLenum target, GLuint id));
27 MOCK_METHOD3(BindAttribLocation, void(
28 GLuint program, GLuint index, const char* name));
30 MOCK_METHOD2(BindBuffer, void(GLenum target, GLuint buffer));
32 MOCK_METHOD3(BindFragDataLocation, void(GLuint program, GLuint colorNumber,
33 const char* name));
35 MOCK_METHOD4(BindFragDataLocationIndexed, void(GLuint program,
36 GLuint colorNumber, GLuint index, const char* name));
38 MOCK_METHOD2(BindFramebufferEXT, void(GLenum target, GLuint framebuffer));
40 MOCK_METHOD2(BindRenderbufferEXT, void(GLenum target, GLuint renderbuffer));
42 MOCK_METHOD2(BindTexture, void(GLenum target, GLuint texture));
44 MOCK_METHOD4(BlendColor, void(
45 GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha));
47 MOCK_METHOD1(BlendEquation, void(GLenum mode));
49 MOCK_METHOD2(BlendEquationSeparate, void(GLenum modeRGB, GLenum modeAlpha));
51 MOCK_METHOD2(BlendFunc, void(GLenum sfactor, GLenum dfactor));
53 MOCK_METHOD4(BlendFuncSeparate, void(
54 GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha));
56 MOCK_METHOD10(BlitFramebufferANGLE, void(
57 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
58 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
59 GLbitfield mask, GLenum filter));
61 MOCK_METHOD10(BlitFramebufferEXT, void(
62 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
63 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
64 GLbitfield mask, GLenum filter));
66 MOCK_METHOD4(BufferData, void(
67 GLenum target, GLsizeiptr size, const void* data, GLenum usage));
69 MOCK_METHOD4(BufferSubData, void(
70 GLenum target, GLintptr offset, GLsizeiptr size, const void* data));
72 MOCK_METHOD1(CheckFramebufferStatusEXT, GLenum(GLenum target));
74 MOCK_METHOD1(Clear, void(GLbitfield mask));
76 MOCK_METHOD4(ClearColor, void(
77 GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha));
79 MOCK_METHOD1(ClearDepth, void(GLclampd depth));
81 MOCK_METHOD1(ClearDepthf, void(GLclampf depth));
83 MOCK_METHOD1(ClearStencil, void(GLint s));
85 MOCK_METHOD4(ColorMask, void(
86 GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha));
88 MOCK_METHOD1(CompileShader, void(GLuint shader));
90 MOCK_METHOD8(CompressedTexImage2D, void(
91 GLenum target, GLint level, GLenum internalformat, GLsizei width,
92 GLsizei height, GLint border, GLsizei imageSize, const void* data));
94 MOCK_METHOD9(CompressedTexSubImage2D, void(
95 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
96 GLsizei height, GLenum format, GLsizei imageSize, const void* data));
98 MOCK_METHOD8(CopyTexImage2D, void(
99 GLenum target, GLint level, GLenum internalformat, GLint x, GLint y,
100 GLsizei width, GLsizei height, GLint border));
102 MOCK_METHOD8(CopyTexSubImage2D, void(
103 GLenum target, GLint level, GLint xoffset, GLint yoffset,
104 GLint x, GLint y, GLsizei width, GLsizei height));
106 MOCK_METHOD0(CreateProgram, GLuint());
108 MOCK_METHOD1(CreateShader, GLuint(GLenum type));
110 MOCK_METHOD1(CullFace, void(GLenum mode));
112 MOCK_METHOD2(DeleteBuffersARB, void(GLsizei n, const GLuint* buffers));
114 MOCK_METHOD2(DeleteFramebuffersEXT,
115 void(GLsizei n, const GLuint* framebuffers));
117 MOCK_METHOD1(DeleteProgram, void(GLuint program));
119 MOCK_METHOD2(DeleteQueries, void(GLsizei n, const GLuint* ids));
121 MOCK_METHOD2(DeleteRenderbuffersEXT, void(
122 GLsizei n, const GLuint* renderbuffers));
124 MOCK_METHOD1(DeleteShader, void(GLuint shader));
126 MOCK_METHOD2(DeleteTextures, void(GLsizei n, const GLuint* textures));
128 MOCK_METHOD1(DepthFunc, void(GLenum func));
130 MOCK_METHOD1(DepthMask, void(GLboolean flag));
132 MOCK_METHOD2(DepthRange, void(GLclampd zNear, GLclampd zFar));
134 MOCK_METHOD2(DepthRangef, void(GLclampf zNear, GLclampf zFar));
136 MOCK_METHOD2(DetachShader, void(GLuint program, GLuint shader));
138 MOCK_METHOD1(Disable, void(GLenum cap));
140 MOCK_METHOD1(DisableVertexAttribArray, void(GLuint index));
142 MOCK_METHOD3(DrawArrays, void(GLenum mode, GLint first, GLsizei count));
144 MOCK_METHOD1(DrawBuffer, void(GLenum mode));
146 MOCK_METHOD2(DrawBuffersARB, void(GLsizei n, const GLenum* bufs));
148 MOCK_METHOD4(DrawElements, void(
149 GLenum mode, GLsizei count, GLenum type, const void* indices));
151 MOCK_METHOD2(EGLImageTargetTexture2DOES, void(
152 GLenum target, GLeglImageOES image));
154 MOCK_METHOD2(EGLImageTargetRenderbufferStorageOES, void(
155 GLenum target, GLeglImageOES image));
157 MOCK_METHOD1(Enable, void(GLenum cap));
159 MOCK_METHOD1(EnableVertexAttribArray, void(GLuint index));
161 MOCK_METHOD1(EndQuery, void(GLenum target));
163 MOCK_METHOD0(Finish, void());
165 MOCK_METHOD0(Flush, void());
167 MOCK_METHOD4(FramebufferRenderbufferEXT, void(
168 GLenum target, GLenum attachment, GLenum renderbuffertarget,
169 GLuint renderbuffer));
171 MOCK_METHOD5(FramebufferTexture2DEXT, void(
172 GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
173 GLint level));
175 MOCK_METHOD1(FrontFace, void(GLenum mode));
177 MOCK_METHOD2(GenBuffersARB, void(GLsizei n, GLuint* buffers));
179 MOCK_METHOD1(GenerateMipmapEXT, void(GLenum target));
181 MOCK_METHOD2(GenFramebuffersEXT, void(GLsizei n, GLuint* framebuffers));
183 MOCK_METHOD2(GenQueries, void(GLsizei n, GLuint* ids));
185 MOCK_METHOD2(GenRenderbuffersEXT, void(GLsizei n, GLuint* renderbuffers));
187 MOCK_METHOD2(GenTextures, void(GLsizei n, GLuint* textures));
189 MOCK_METHOD7(GetActiveAttrib, void(
190 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length,
191 GLint* size, GLenum* type, char* name));
193 MOCK_METHOD7(GetActiveUniform, void(
194 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length,
195 GLint* size, GLenum* type, char* name));
197 MOCK_METHOD4(GetAttachedShaders, void(
198 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders));
200 MOCK_METHOD2(GetAttribLocation, GLint(GLuint program, const char* name));
202 MOCK_METHOD2(GetBooleanv, void(GLenum pname, GLboolean* params));
204 MOCK_METHOD3(GetBufferParameteriv, void(
205 GLenum target, GLenum pname, GLint* params));
207 MOCK_METHOD0(GetError, GLenum());
209 MOCK_METHOD2(GetFloatv, void(GLenum pname, GLfloat* params));
211 MOCK_METHOD4(GetFramebufferAttachmentParameterivEXT, void(
212 GLenum target, GLenum attachment, GLenum pname, GLint* params));
214 MOCK_METHOD2(GetIntegerv, void(GLenum pname, GLint* params));
216 MOCK_METHOD5(GetProgramBinary, void(
217 GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat,
218 GLvoid* binary));
220 MOCK_METHOD3(GetProgramiv, void(GLuint program, GLenum pname, GLint* params));
222 MOCK_METHOD4(GetProgramInfoLog, void(
223 GLuint program, GLsizei bufsize, GLsizei* length, char* infolog));
225 MOCK_METHOD3(GetQueryiv, void(GLenum target, GLenum pname, GLint* params));
227 MOCK_METHOD3(GetQueryObjecti64v, void(
228 GLuint id, GLenum pname, GLint64* params));
230 MOCK_METHOD3(GetQueryObjectiv, void(GLuint id, GLenum pname, GLint* params));
232 MOCK_METHOD3(GetQueryObjectui64v, void(
233 GLuint id, GLenum pname, GLuint64* params));
235 MOCK_METHOD3(GetQueryObjectuiv, void(
236 GLuint id, GLenum pname, GLuint* params));
238 MOCK_METHOD3(GetRenderbufferParameterivEXT, void(
239 GLenum target, GLenum pname, GLint* params));
241 MOCK_METHOD3(GetShaderiv, void(GLuint shader, GLenum pname, GLint* params));
243 MOCK_METHOD4(GetShaderInfoLog, void(
244 GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog));
246 MOCK_METHOD4(GetShaderPrecisionFormat, void(
247 GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision));
249 MOCK_METHOD4(GetShaderSource, void(
250 GLuint shader, GLsizei bufsize, GLsizei* length, char* source));
252 MOCK_METHOD1(GetString, const GLubyte*(GLenum name));
254 MOCK_METHOD4(GetTexLevelParameterfv, void(
255 GLenum target, GLint level, GLenum pname, GLfloat* params));
257 MOCK_METHOD4(GetTexLevelParameteriv, void(
258 GLenum target, GLint level, GLenum pname, GLint* params));
260 MOCK_METHOD3(GetTexParameterfv, void(
261 GLenum target, GLenum pname, GLfloat* params));
263 MOCK_METHOD3(GetTexParameteriv, void(
264 GLenum target, GLenum pname, GLint* params));
266 MOCK_METHOD4(GetTranslatedShaderSourceANGLE, void(
267 GLuint shader, GLsizei bufsize, GLsizei* length, char* source));
269 MOCK_METHOD3(GetUniformfv,
270 void(GLuint program, GLint location, GLfloat* params));
272 MOCK_METHOD3(GetUniformiv,
273 void(GLuint program, GLint location, GLint* params));
275 MOCK_METHOD2(GetUniformLocation, GLint(GLuint program, const char* name));
277 MOCK_METHOD3(GetVertexAttribfv, void(
278 GLuint index, GLenum pname, GLfloat* params));
280 MOCK_METHOD3(GetVertexAttribiv,
281 void(GLuint index, GLenum pname, GLint* params));
283 MOCK_METHOD3(GetVertexAttribPointerv, void(
284 GLuint index, GLenum pname, void** pointer));
286 MOCK_METHOD2(Hint, void(GLenum target, GLenum mode));
288 MOCK_METHOD1(IsBuffer, GLboolean(GLuint buffer));
290 MOCK_METHOD1(IsEnabled, GLboolean(GLenum cap));
292 MOCK_METHOD1(IsFramebufferEXT, GLboolean(GLuint framebuffer));
294 MOCK_METHOD1(IsProgram, GLboolean(GLuint program));
296 MOCK_METHOD1(IsRenderbufferEXT, GLboolean(GLuint renderbuffer));
298 MOCK_METHOD1(IsShader, GLboolean(GLuint shader));
300 MOCK_METHOD1(IsTexture, GLboolean(GLuint texture));
302 MOCK_METHOD1(LineWidth, void(GLfloat width));
304 MOCK_METHOD1(LinkProgram, void(GLuint program));
306 MOCK_METHOD2(MapBuffer, void*(GLenum target, GLenum access));
308 MOCK_METHOD2(PixelStorei, void(GLenum pname, GLint param));
310 MOCK_METHOD2(PointParameteri, void(GLenum pname, GLint param));
312 MOCK_METHOD2(PolygonOffset, void(GLfloat factor, GLfloat units));
314 MOCK_METHOD4(ProgramBinary, void(
315 GLuint program, GLenum binaryFormat, const GLvoid* binary,
316 GLsizei length));
318 MOCK_METHOD3(ProgramParameteri, void(
319 GLuint program, GLenum pname, GLint value));
321 MOCK_METHOD2(QueryCounter, void(GLuint id, GLenum target));
323 MOCK_METHOD1(ReadBuffer, void(GLenum src));
325 MOCK_METHOD7(ReadPixels, void(
326 GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
327 GLenum type, void* pixels));
329 MOCK_METHOD0(ReleaseShaderCompiler, void());
331 MOCK_METHOD4(RenderbufferStorageEXT, void(
332 GLenum target, GLenum internalformat, GLsizei width, GLsizei height));
334 MOCK_METHOD5(RenderbufferStorageMultisampleANGLE, void(
335 GLenum target, GLsizei samples, GLenum internalformat,
336 GLsizei width, GLsizei height));
338 MOCK_METHOD5(RenderbufferStorageMultisampleEXT, void(
339 GLenum target, GLsizei samples, GLenum internalformat,
340 GLsizei width, GLsizei height));
342 MOCK_METHOD2(SampleCoverage, void(GLclampf value, GLboolean invert));
344 MOCK_METHOD4(Scissor, void(GLint x, GLint y, GLsizei width, GLsizei height));
346 MOCK_METHOD5(ShaderBinary, void(
347 GLsizei n, const GLuint* shaders, GLenum binaryformat,
348 const void* binary, GLsizei length));
350 MOCK_METHOD4(ShaderSource, void(
351 GLuint shader, GLsizei count, const char** str, const GLint* length));
353 MOCK_METHOD3(StencilFunc, void(GLenum func, GLint ref, GLuint mask));
355 MOCK_METHOD4(StencilFuncSeparate, void(
356 GLenum face, GLenum func, GLint ref, GLuint mask));
358 MOCK_METHOD1(StencilMask, void(GLuint mask));
360 MOCK_METHOD2(StencilMaskSeparate, void(GLenum face, GLuint mask));
362 MOCK_METHOD3(StencilOp, void(GLenum fail, GLenum zfail, GLenum zpass));
364 MOCK_METHOD4(StencilOpSeparate, void(
365 GLenum face, GLenum fail, GLenum zfail, GLenum zpass));
367 MOCK_METHOD9(TexImage2D, void(
368 GLenum target, GLint level, GLint internalformat, GLsizei width,
369 GLsizei height, GLint border, GLenum format, GLenum type,
370 const void* pixels));
372 MOCK_METHOD3(TexParameterf, void(GLenum target, GLenum pname, GLfloat param));
374 MOCK_METHOD3(TexParameterfv, void(
375 GLenum target, GLenum pname, const GLfloat* params));
377 MOCK_METHOD3(TexParameteri, void(GLenum target, GLenum pname, GLint param));
379 MOCK_METHOD3(TexParameteriv, void(
380 GLenum target, GLenum pname, const GLint* params));
382 MOCK_METHOD5(TexStorage2DEXT, void(
383 GLenum target, GLsizei levels, GLenum internalformat,
384 GLsizei width, GLsizei height));
386 MOCK_METHOD9(TexSubImage2D, void(
387 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
388 GLsizei height, GLenum format, GLenum type, const void* pixels));
390 MOCK_METHOD2(Uniform1f, void(GLint location, GLfloat x));
392 MOCK_METHOD3(Uniform1fv,
393 void(GLint location, GLsizei count, const GLfloat* v));
395 MOCK_METHOD2(Uniform1i, void(GLint location, GLint x));
397 MOCK_METHOD3(Uniform1iv, void(GLint location, GLsizei count, const GLint* v));
399 MOCK_METHOD3(Uniform2f, void(GLint location, GLfloat x, GLfloat y));
401 MOCK_METHOD3(Uniform2fv,
402 void(GLint location, GLsizei count, const GLfloat* v));
404 MOCK_METHOD3(Uniform2i, void(GLint location, GLint x, GLint y));
406 MOCK_METHOD3(Uniform2iv, void(GLint location, GLsizei count, const GLint* v));
408 MOCK_METHOD4(Uniform3f,
409 void(GLint location, GLfloat x, GLfloat y, GLfloat z));
411 MOCK_METHOD3(Uniform3fv,
412 void(GLint location, GLsizei count, const GLfloat* v));
414 MOCK_METHOD4(Uniform3i, void(GLint location, GLint x, GLint y, GLint z));
416 MOCK_METHOD3(Uniform3iv, void(GLint location, GLsizei count, const GLint* v));
418 MOCK_METHOD5(Uniform4f, void(
419 GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w));
421 MOCK_METHOD3(Uniform4fv,
422 void(GLint location, GLsizei count, const GLfloat* v));
424 MOCK_METHOD5(Uniform4i,
425 void(GLint location, GLint x, GLint y, GLint z, GLint w));
427 MOCK_METHOD3(Uniform4iv, void(GLint location, GLsizei count, const GLint* v));
429 MOCK_METHOD4(UniformMatrix2fv, void(
430 GLint location, GLsizei count, GLboolean transpose,
431 const GLfloat* value));
433 MOCK_METHOD4(UniformMatrix3fv, void(
434 GLint location, GLsizei count, GLboolean transpose,
435 const GLfloat* value));
437 MOCK_METHOD4(UniformMatrix4fv, void(
438 GLint location, GLsizei count, GLboolean transpose,
439 const GLfloat* value));
441 MOCK_METHOD1(UnmapBuffer, GLboolean(GLenum target));
443 MOCK_METHOD1(UseProgram, void(GLuint program));
445 MOCK_METHOD1(ValidateProgram, void(GLuint program));
447 MOCK_METHOD2(VertexAttrib1f, void(GLuint indx, GLfloat x));
449 MOCK_METHOD2(VertexAttrib1fv, void(GLuint indx, const GLfloat* values));
451 MOCK_METHOD3(VertexAttrib2f, void(GLuint indx, GLfloat x, GLfloat y));
453 MOCK_METHOD2(VertexAttrib2fv, void(GLuint indx, const GLfloat* values));
455 MOCK_METHOD4(VertexAttrib3f,
456 void(GLuint indx, GLfloat x, GLfloat y, GLfloat z));
458 MOCK_METHOD2(VertexAttrib3fv, void(GLuint indx, const GLfloat* values));
460 MOCK_METHOD5(VertexAttrib4f, void(
461 GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w));
463 MOCK_METHOD2(VertexAttrib4fv, void(GLuint indx, const GLfloat* values));
465 MOCK_METHOD6(VertexAttribPointer, void(
466 GLuint indx, GLint size, GLenum type, GLboolean normalized,
467 GLsizei stride, const void* ptr));
469 MOCK_METHOD4(Viewport, void(GLint x, GLint y, GLsizei width, GLsizei height));
471 MOCK_METHOD0(SwapBuffers, void());
473 MOCK_METHOD4(GetMaxValueInBufferCHROMIUM, GLuint(
474 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset));
476 MOCK_METHOD2(GenFencesNV, void(GLsizei n, GLuint *fences));
478 MOCK_METHOD2(DeleteFencesNV, void(GLsizei n, const GLuint *fences));
480 MOCK_METHOD2(SetFenceNV, void(GLuint fence, GLenum condition));
482 MOCK_METHOD1(TestFenceNV, GLboolean(GLuint fence));
484 MOCK_METHOD1(FinishFenceNV, void(GLuint fence));
486 MOCK_METHOD1(IsFenceNV, GLboolean(GLuint fence));
488 MOCK_METHOD3(GetFenceivNV, void(GLuint fence, GLenum pname, GLint *params));
490 MOCK_METHOD2(FenceSync, GLsync(GLenum condition, GLbitfield flags));
492 MOCK_METHOD1(DeleteSync, void(GLsync sync));
494 MOCK_METHOD5(GetSynciv, void(
495 GLsync sync, GLenum pname, GLsizei bufSize,
496 GLsizei* length, GLint* values));
498 MOCK_METHOD2(GenQueriesARB, void(GLsizei n, GLuint* ids));
500 MOCK_METHOD2(DeleteQueriesARB, void(GLsizei n, const GLuint* ids));
502 MOCK_METHOD1(IsQueryARB, GLboolean(GLuint id));
504 MOCK_METHOD2(BeginQueryARB, void(GLenum target, GLuint id));
506 MOCK_METHOD1(EndQueryARB, void(GLenum target));
508 MOCK_METHOD3(GetQueryivARB, void(GLenum target, GLenum pname, GLint* params));
510 MOCK_METHOD3(GetQueryObjectuivARB, void(
511 GLuint id, GLenum pname, GLuint* params));
513 MOCK_METHOD1(SetSurfaceCHROMIUM, void(GLuint));
515 MOCK_METHOD0(GetGraphicsResetStatusARB, GLenum());
517 MOCK_METHOD4(DrawArraysInstancedANGLE, void(
518 GLenum mode, GLint first, GLsizei count, GLsizei primcount));
520 MOCK_METHOD5(DrawElementsInstancedANGLE, void(
521 GLenum mode, GLsizei count, GLenum type, const void* indices,
522 GLsizei primcount));
524 MOCK_METHOD2(VertexAttribDivisorANGLE, void(GLuint index, GLuint divisor));
526 MOCK_METHOD2(GenVertexArraysOES, void(GLsizei n, GLuint* ids));
528 MOCK_METHOD2(DeleteVertexArraysOES, void(GLsizei n, const GLuint* ids));
530 MOCK_METHOD1(IsVertexArrayOES, GLboolean(GLuint id));
532 MOCK_METHOD1(BindVertexArrayOES, void(GLuint id));
535 } // namespace gfx
537 #endif // GPU_COMMAND_BUFFER_COMMON_GL_MOCK_H_