27template <
typename T,
typename U>
30template <
typename Ret,
typename... Args>
45struct function_traits;
47template <
typename C,
typename Ret,
typename... Args>
48struct function_traits<Ret (C::*)(Args...)> {
49 using return_type = Ret;
52template <
typename Func,
typename... Args>
53auto CallMockMethod(Func func, Args&&...
args) {
55 if (mock_gles->GetImpl()) {
56 return (mock_gles->GetImpl()->*func)(std::forward<Args>(
args)...);
59 return typename function_traits<Func>::return_type();
66 return reinterpret_cast<const unsigned char*
>(
kMockVendor);
68 return reinterpret_cast<const unsigned char*
>(
g_version);
70 return reinterpret_cast<const unsigned char*
>(
72 case GL_SHADING_LANGUAGE_VERSION:
73 return reinterpret_cast<const unsigned char*
>(
76 return reinterpret_cast<const unsigned char*
>(
"");
81 decltype(glGetString)>::value);
86 return reinterpret_cast<const unsigned char*
>(
g_extensions[index]);
88 return reinterpret_cast<const unsigned char*
>(
"");
93 decltype(glGetStringi)>::value);
97 case GL_NUM_EXTENSIONS: {
100 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
103 case GL_MAX_LABEL_LENGTH_KHR:
106 case GL_MAX_TEXTURE_SIZE:
116 decltype(glGetIntegerv)>::value);
123 decltype(glGetError)>::value);
128 decltype(glPopDebugGroupKHR)>::value);
136 decltype(glPushDebugGroupKHR)>::value);
143 decltype(glGenQueriesEXT)>::value);
150 decltype(glBeginQueryEXT)>::value);
157 decltype(glEndQueryEXT)>::value);
164 decltype(glGetQueryObjectuivEXT)>::value);
171 decltype(glGetQueryObjectui64vEXT)>::value);
182 decltype(glDeleteQueriesEXT)>::value);
192 decltype(glUniform2fv)>::value);
198 decltype(glUniform3fv)>::value);
204 decltype(glUniform4fv)>::value);
209 const GLfloat* value) {
214 decltype(glUniformMatrix2fv)>::value);
219 const GLfloat* value) {
224 decltype(glUniformMatrix3fv)>::value);
229 const GLfloat* value) {
234 decltype(glUniformMatrix4fv)>::value);
241 decltype(glGenTextures)>::value);
255 decltype(glBufferSubData)>::value);
258 decltype(glGenTextures)>::value);
263 const GLchar* label) {
268 decltype(glObjectLabelKHR)>::value);
278 const void* pixels) {
283 decltype(glTexSubImage2D)>::value);
287 GLint internalformat,
293 const void* pixels) {
298 decltype(glTexImage2D)>::value);
304 decltype(glBindTexture)>::value);
311 decltype(glIsTexture)>::value);
318 decltype(glCheckFramebufferStatus)>::value);
325 decltype(glGenFramebuffers)>::value);
332 decltype(glBindFramebuffer)>::value);
346 GLsizei numAttachments,
347 const GLenum* attachments) {
349 numAttachments, attachments);
357 decltype(glDiscardFramebufferEXT)>::value);
360 GLsizei numAttachments,
361 const GLenum* attachments) {
363 numAttachments, attachments);
367 decltype(glInvalidateFramebuffer)>::value);
374 decltype(glDrawArrays)>::value);
379 const void* indices) {
384 decltype(glDrawElements)>::value);
389 GLsizei instancecount) {
395 decltype(glDrawArraysInstanced)>::value);
401 GLsizei instancecount) {
403 indices, instancecount);
407 decltype(glDrawElementsInstanced)>::value);
414 decltype(glVertexAttribDivisor)>::value);
418 std::unique_ptr<MockGLESImpl> impl,
419 const std::optional<std::vector<const char*>>& extensions,
420 const char* version_string) {
422 <<
"MockGLES is already being used by another test.";
432 auto mock_gles = std::shared_ptr<MockGLES>(
new MockGLES());
433 mock_gles->impl_ = std::move(impl);
439 const std::optional<std::vector<const char*>>& extensions,
440 const char* version_string,
444 <<
"MockGLES is already being used by another test.";
454 auto mock_gles = std::shared_ptr<MockGLES>(
new MockGLES(std::move(resolver)));
460 if (strcmp(
name,
"glPopDebugGroupKHR") == 0) {
462 }
else if (strcmp(
name,
"glPushDebugGroupKHR") == 0) {
464 }
else if (strcmp(
name,
"glGetString") == 0) {
466 }
else if (strcmp(
name,
"glGetStringi") == 0) {
468 }
else if (strcmp(
name,
"glGetIntegerv") == 0) {
470 }
else if (strcmp(
name,
"glGetError") == 0) {
472 }
else if (strcmp(
name,
"glGenQueriesEXT") == 0) {
474 }
else if (strcmp(
name,
"glBeginQueryEXT") == 0) {
476 }
else if (strcmp(
name,
"glEndQueryEXT") == 0) {
478 }
else if (strcmp(
name,
"glDeleteQueriesEXT") == 0) {
480 }
else if (strcmp(
name,
"glDeleteTextures") == 0) {
482 }
else if (strcmp(
name,
"glGetQueryObjectui64vEXT") == 0) {
484 }
else if (strcmp(
name,
"glGetQueryObjectuivEXT") == 0) {
486 }
else if (strcmp(
name,
"glUniform1fv") == 0) {
488 }
else if (strcmp(
name,
"glUniform2fv") == 0) {
490 }
else if (strcmp(
name,
"glUniform3fv") == 0) {
492 }
else if (strcmp(
name,
"glUniform4fv") == 0) {
494 }
else if (strcmp(
name,
"glUniformMatrix2fv") == 0) {
496 }
else if (strcmp(
name,
"glUniformMatrix3fv") == 0) {
498 }
else if (strcmp(
name,
"glUniformMatrix4fv") == 0) {
500 }
else if (strcmp(
name,
"glGenTextures") == 0) {
502 }
else if (strcmp(
name,
"glTexSubImage2D") == 0) {
504 }
else if (strcmp(
name,
"glTexImage2D") == 0) {
506 }
else if (strcmp(
name,
"glBindTexture") == 0) {
508 }
else if (strcmp(
name,
"glObjectLabelKHR") == 0) {
510 }
else if (strcmp(
name,
"glGenBuffers") == 0) {
512 }
else if (strcmp(
name,
"glBufferSubData") == 0) {
514 }
else if (strcmp(
name,
"glIsTexture") == 0) {
516 }
else if (strcmp(
name,
"glCheckFramebufferStatus") == 0) {
518 }
else if (strcmp(
name,
"glReadPixels") == 0) {
520 }
else if (strcmp(
name,
"glGenFramebuffers") == 0) {
522 }
else if (strcmp(
name,
"glBindFramebuffer") == 0) {
524 }
else if (strcmp(
name,
"glDiscardFramebufferEXT") == 0) {
526 }
else if (strcmp(
name,
"glInvalidateFramebuffer") == 0) {
528 }
else if (strcmp(
name,
"glViewport") == 0) {
530 }
else if (strcmp(
name,
"glDrawArrays") == 0) {
532 }
else if (strcmp(
name,
"glDrawElements") == 0) {
534 }
else if (strcmp(
name,
"glDrawArraysInstanced") == 0) {
536 }
else if (strcmp(
name,
"glDrawElementsInstanced") == 0) {
538 }
else if (strcmp(
name,
"glVertexAttribDivisor") == 0) {
541 return reinterpret_cast<void*
>(&
doNothing);
546 [](
const char*
name) ->
void* {
550 if (strcmp(
name,
"glDrawArraysInstancedEXT") == 0 ||
551 strcmp(
name,
"glDrawArraysInstanced") == 0 ||
552 strcmp(
name,
"glDrawElementsInstancedEXT") == 0 ||
553 strcmp(
name,
"glDrawElementsInstanced") == 0 ||
554 strcmp(
name,
"glVertexAttribDivisorEXT") == 0 ||
555 strcmp(
name,
"glVertexAttribDivisor") == 0) {
562 : proc_table_(
std::move(resolver)) {}
564MockGLES::~MockGLES() {
std::function< void *(const char *function_name)> Resolver
virtual void GenFramebuffers(GLsizei n, GLuint *framebuffers)
virtual void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels)
virtual void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments)
virtual void Uniform2fv(GLint location, GLsizei count, const GLfloat *value)
virtual void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void *data)
virtual void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
virtual void GenBuffers(GLsizei n, GLuint *buffers)
virtual void GetQueryObjectui64vEXT(GLuint id, GLenum target, GLuint64 *result)
virtual void GetQueryObjectuivEXT(GLuint id, GLenum target, GLuint *result)
virtual void DeleteQueriesEXT(GLsizei size, const GLuint *queries)
virtual void DrawArrays(GLenum mode, GLint first, GLsizei count)
virtual void ObjectLabelKHR(GLenum identifier, GLuint name, GLsizei length, const GLchar *label)
virtual void BindTexture(GLenum target, GLuint texture)
virtual void EndQueryEXT(GLuint id)
virtual void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
virtual void DiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum *attachments)
virtual void DeleteTextures(GLsizei size, const GLuint *queries)
virtual void GenQueriesEXT(GLsizei n, GLuint *ids)
virtual void VertexAttribDivisor(GLuint index, GLuint divisor)
virtual void DrawElements(GLenum mode, GLsizei count, GLenum type, const void *indices)
virtual void Uniform4fv(GLint location, GLsizei count, const GLfloat *value)
virtual void BeginQueryEXT(GLenum target, GLuint id)
virtual void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instancecount)
virtual void BindFramebuffer(GLenum target, GLuint framebuffer)
virtual void GetIntegerv(GLenum name, GLint *attachments)
virtual void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels)
virtual GLboolean IsTexture(GLuint texture)
virtual void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
virtual void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount)
virtual void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels)
virtual void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
virtual void Uniform1fv(GLint location, GLsizei count, const GLfloat *value)
virtual void Uniform3fv(GLint location, GLsizei count, const GLfloat *value)
virtual void GenTextures(GLsizei n, GLuint *textures)
virtual GLenum CheckFramebufferStatus(GLenum target)
Provides a mocked version of the |ProcTableGLES| class.
static std::shared_ptr< MockGLES > Init(std::unique_ptr< MockGLESImpl > impl, const std::optional< std::vector< const char * > > &extensions=std::nullopt, const char *version_string="OpenGL ES 3.0")
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
uint32_t uint32_t * format
#define FML_CHECK(condition)
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
DEF_SWITCHES_START aot vmservice shared library name
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
void mockDeleteQueriesEXT(GLsizei size, const GLuint *queries)
void mockGetQueryObjectuivEXT(GLuint id, GLenum target, GLuint *result)
static std::mutex g_test_lock
const ProcTableGLES::Resolver kMockResolverGLESWithoutInstancing
void mockDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum *attachments)
const auto kMockShadingLanguageVersion
void mockPopDebugGroupKHR()
const unsigned char * mockGetStringi(GLenum name, GLuint index)
void mockUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
void mockGetIntegerv(GLenum name, int *value)
static std::vector< const char * > g_extensions
void mockGetQueryObjectui64vEXT(GLuint id, GLenum target, GLuint64 *result)
GLboolean mockIsTexture(GLuint texture)
void mockDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instancecount)
static std::string g_extensions_string
void mockReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *data)
void mockUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
void mockTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels)
void mockDrawElements(GLenum mode, GLsizei count, GLenum type, const void *indices)
static std::weak_ptr< MockGLES > g_mock_gles
void mockUniform4fv(GLint location, GLsizei count, const GLfloat *value)
void mockTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels)
void mockDeleteTextures(GLsizei size, const GLuint *queries)
void mockUniform2fv(GLint location, GLsizei count, const GLfloat *value)
GLenum mockCheckFramebufferStatus(GLenum target)
void mockUniform1fv(GLint location, GLsizei count, const GLfloat *value)
void mockObjectLabelKHR(GLenum identifier, GLuint name, GLsizei length, const GLchar *label)
void mockBindTexture(GLenum target, GLuint texture)
static const char * g_version
void mockDrawArrays(GLenum mode, GLint first, GLsizei count)
const ProcTableGLES::Resolver kMockResolverGLES
void mockUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
void mockPushDebugGroupKHR(GLenum source, GLuint id, GLsizei length, const GLchar *message)
void mockUniform3fv(GLint location, GLsizei count, const GLfloat *value)
void mockBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void *data)
void mockBindFramebuffer(GLenum target, GLuint framebuffer)
void mockEndQueryEXT(GLuint id)
void mockDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount)
void mockGenBuffers(GLsizei n, GLuint *buffers)
void mockInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments)
void mockGenFramebuffers(GLsizei n, GLuint *ids)
void mockGenQueriesEXT(GLsizei n, GLuint *ids)
const unsigned char * mockGetString(GLenum name)
void mockBeginQueryEXT(GLenum target, GLuint id)
void mockViewport(GLint x, GLint y, GLsizei width, GLsizei height)
void mockGenTextures(GLsizei n, GLuint *textures)
void mockVertexAttribDivisor(GLuint index, GLuint divisor)
impeller::ShaderType type