Flutter Engine
 
Loading...
Searching...
No Matches
mock_gles.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter 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.
4
5#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_TEST_MOCK_GLES_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_TEST_MOCK_GLES_H_
7
8#include <memory>
9#include <optional>
10
11#include "gmock/gmock.h"
13
14namespace impeller {
15namespace testing {
16
18
20 public:
21 virtual ~IMockGLESImpl() = default;
22 virtual void DeleteTextures(GLsizei size, const GLuint* queries) {}
23 virtual void GenTextures(GLsizei n, GLuint* textures) {}
24 virtual void BindTexture(GLenum target, GLuint texture) {}
25 virtual void TexImage2D(GLenum target,
26 GLint level,
27 GLint internalformat,
28 GLsizei width,
29 GLsizei height,
30 GLint border,
31 GLenum format,
32 GLenum type,
33 const void* pixels) {}
34 virtual void GenFramebuffers(GLsizei n, GLuint* framebuffers) {}
35 virtual void BindFramebuffer(GLenum target, GLuint framebuffer) {}
36 virtual void FramebufferTexture2D(GLenum target,
37 GLenum attachment,
38 GLenum textarget,
39 GLuint texture,
40 GLint level) {}
41 virtual GLenum CheckFramebufferStatus(GLenum target) {
42 return GL_FRAMEBUFFER_COMPLETE;
43 }
44 virtual void ReadPixels(GLint x,
45 GLint y,
46 GLsizei width,
47 GLsizei height,
48 GLenum format,
49 GLenum type,
50 void* pixels) {}
51 virtual void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) {}
52 virtual void ObjectLabelKHR(GLenum identifier,
53 GLuint name,
54 GLsizei length,
55 const GLchar* label) {}
56 virtual void Uniform1fv(GLint location, GLsizei count, const GLfloat* value) {
57 }
58 virtual void GenQueriesEXT(GLsizei n, GLuint* ids) {}
59 virtual void BeginQueryEXT(GLenum target, GLuint id) {}
60 virtual void EndQueryEXT(GLuint id) {}
61 virtual void GetQueryObjectuivEXT(GLuint id, GLenum target, GLuint* result) {}
62 virtual void GetQueryObjectui64vEXT(GLuint id,
63 GLenum target,
64 GLuint64* result) {}
65 virtual void DeleteQueriesEXT(GLsizei size, const GLuint* queries) {}
66 virtual void GenBuffers(GLsizei n, GLuint* buffers) {}
67 virtual void DeleteBuffers(GLsizei n, const GLuint* buffers) {}
68 virtual GLboolean IsTexture(GLuint texture) { return true; }
69 virtual void DiscardFramebufferEXT(GLenum target,
70 GLsizei numAttachments,
71 const GLenum* attachments) {};
72 virtual void GetIntegerv(GLenum name, GLint* attachments) {};
73};
74
76 public:
79 (GLsizei size, const GLuint* queries),
80 (override));
81 MOCK_METHOD(void, GenTextures, (GLsizei n, GLuint* textures), (override));
82 MOCK_METHOD(void, BindTexture, (GLenum target, GLuint texture), (override));
85 (GLenum target,
86 GLint level,
87 GLint internalformat,
88 GLsizei width,
89 GLsizei height,
90 GLint border,
91 GLenum format,
92 GLenum type,
93 const void* pixels),
94 (override));
97 (GLsizei n, GLuint* framebuffers),
98 (override));
101 (GLenum target, GLuint framebuffer),
102 (override));
105 (GLenum target,
106 GLenum attachment,
107 GLenum textarget,
108 GLuint texture,
109 GLint level),
110 (override));
111 MOCK_METHOD(GLenum, CheckFramebufferStatus, (GLenum target), (override));
114 (GLint x,
115 GLint y,
116 GLsizei width,
117 GLsizei height,
118 GLenum format,
119 GLenum type,
120 void* pixels),
121 (override));
124 (GLsizei n, const GLuint* framebuffers),
125 (override));
127 void,
129 (GLenum identifier, GLuint name, GLsizei length, const GLchar* label),
130 (override));
133 (GLint location, GLsizei count, const GLfloat* value),
134 (override));
135 MOCK_METHOD(void, GenQueriesEXT, (GLsizei n, GLuint* ids), (override));
136 MOCK_METHOD(void, BeginQueryEXT, (GLenum target, GLuint id), (override));
137 MOCK_METHOD(void, EndQueryEXT, (GLuint id), (override));
140 (GLuint id, GLenum target, GLuint* result),
141 (override));
144 (GLuint id, GLenum target, GLuint64* result),
145 (override));
148 (GLsizei size, const GLuint* queries),
149 (override));
150 MOCK_METHOD(void, GenBuffers, (GLsizei n, GLuint* buffers), (override));
153 (GLsizei n, const GLuint* buffers),
154 (override));
155 MOCK_METHOD(GLboolean, IsTexture, (GLuint texture), (override));
158 (GLenum target,
159 GLsizei numAttachments,
160 const GLenum* attachments),
161 (override));
162 MOCK_METHOD(void, GetIntegerv, (GLenum name, GLint* value), (override));
163};
164
165/// @brief Provides a mocked version of the |ProcTableGLES| class.
166///
167/// Typically, Open GLES at runtime will be provided the host's GLES bindings
168/// (as function pointers). This class maintains a set of function pointers that
169/// appear to be GLES functions, but are actually just stubs that record
170/// invocations.
171///
172/// See `README.md` for more information.
173class MockGLES final {
174 public:
175 static std::shared_ptr<MockGLES> Init(
176 std::unique_ptr<MockGLESImpl> impl,
177 const std::optional<std::vector<const char*>>& extensions = std::nullopt);
178
179 /// @brief Returns an initialized |MockGLES| instance.
180 ///
181 /// This method overwrites mocked global GLES function pointers to record
182 /// invocations on this instance of |MockGLES|. As such, it should only be
183 /// called once per test.
184 static std::shared_ptr<MockGLES> Init(
185 const std::optional<std::vector<const char*>>& extensions = std::nullopt,
186 const char* version_string = "OpenGL ES 3.0",
188
189 /// @brief Returns a configured |ProcTableGLES| instance.
190 const ProcTableGLES& GetProcTable() const { return proc_table_; }
191
192 ~MockGLES();
193
194 IMockGLESImpl* GetImpl() { return impl_.get(); }
195
196 private:
197 friend void RecordGLCall(const char* name);
198 friend void mockGenTextures(GLsizei n, GLuint* textures);
199
201
202 ProcTableGLES proc_table_;
203 std::unique_ptr<IMockGLESImpl> impl_;
204
205 MockGLES(const MockGLES&) = delete;
206
207 MockGLES& operator=(const MockGLES&) = delete;
208};
209
210} // namespace testing
211} // namespace impeller
212
213#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_TEST_MOCK_GLES_H_
GLenum type
std::function< void *(const char *function_name)> Resolver
virtual void GenFramebuffers(GLsizei n, GLuint *framebuffers)
Definition mock_gles.h:34
virtual void GenBuffers(GLsizei n, GLuint *buffers)
Definition mock_gles.h:66
virtual void GetQueryObjectui64vEXT(GLuint id, GLenum target, GLuint64 *result)
Definition mock_gles.h:62
virtual void GetQueryObjectuivEXT(GLuint id, GLenum target, GLuint *result)
Definition mock_gles.h:61
virtual void DeleteQueriesEXT(GLsizei size, const GLuint *queries)
Definition mock_gles.h:65
virtual void DeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
Definition mock_gles.h:51
virtual void ObjectLabelKHR(GLenum identifier, GLuint name, GLsizei length, const GLchar *label)
Definition mock_gles.h:52
virtual void BindTexture(GLenum target, GLuint texture)
Definition mock_gles.h:24
virtual void EndQueryEXT(GLuint id)
Definition mock_gles.h:60
virtual ~IMockGLESImpl()=default
virtual void DiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum *attachments)
Definition mock_gles.h:69
virtual void DeleteTextures(GLsizei size, const GLuint *queries)
Definition mock_gles.h:22
virtual void GenQueriesEXT(GLsizei n, GLuint *ids)
Definition mock_gles.h:58
virtual void BeginQueryEXT(GLenum target, GLuint id)
Definition mock_gles.h:59
virtual void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
Definition mock_gles.h:36
virtual void BindFramebuffer(GLenum target, GLuint framebuffer)
Definition mock_gles.h:35
virtual void GetIntegerv(GLenum name, GLint *attachments)
Definition mock_gles.h:72
virtual void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels)
Definition mock_gles.h:25
virtual GLboolean IsTexture(GLuint texture)
Definition mock_gles.h:68
virtual void DeleteBuffers(GLsizei n, const GLuint *buffers)
Definition mock_gles.h:67
virtual void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels)
Definition mock_gles.h:44
virtual void Uniform1fv(GLint location, GLsizei count, const GLfloat *value)
Definition mock_gles.h:56
virtual void GenTextures(GLsizei n, GLuint *textures)
Definition mock_gles.h:23
virtual GLenum CheckFramebufferStatus(GLenum target)
Definition mock_gles.h:41
Provides a mocked version of the |ProcTableGLES| class.
Definition mock_gles.h:173
friend void RecordGLCall(const char *name)
friend void mockGenTextures(GLsizei n, GLuint *textures)
Definition mock_gles.cc:186
static std::shared_ptr< MockGLES > Init(std::unique_ptr< MockGLESImpl > impl, const std::optional< std::vector< const char * > > &extensions=std::nullopt)
Definition mock_gles.cc:260
const ProcTableGLES & GetProcTable() const
Returns a configured |ProcTableGLES| instance.
Definition mock_gles.h:190
IMockGLESImpl * GetImpl()
Definition mock_gles.h:194
MOCK_METHOD(void, TexImage2D,(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels),(override))
MOCK_METHOD(void, GetQueryObjectuivEXT,(GLuint id, GLenum target, GLuint *result),(override))
MOCK_METHOD(void, GenTextures,(GLsizei n, GLuint *textures),(override))
MOCK_METHOD(void, BeginQueryEXT,(GLenum target, GLuint id),(override))
MOCK_METHOD(void, DeleteBuffers,(GLsizei n, const GLuint *buffers),(override))
MOCK_METHOD(GLboolean, IsTexture,(GLuint texture),(override))
MOCK_METHOD(void, BindTexture,(GLenum target, GLuint texture),(override))
MOCK_METHOD(void, BindFramebuffer,(GLenum target, GLuint framebuffer),(override))
MOCK_METHOD(void, ReadPixels,(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels),(override))
MOCK_METHOD(void, GenFramebuffers,(GLsizei n, GLuint *framebuffers),(override))
MOCK_METHOD(void, EndQueryEXT,(GLuint id),(override))
MOCK_METHOD(GLenum, CheckFramebufferStatus,(GLenum target),(override))
MOCK_METHOD(void, GenBuffers,(GLsizei n, GLuint *buffers),(override))
MOCK_METHOD(void, FramebufferTexture2D,(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level),(override))
MOCK_METHOD(void, GetIntegerv,(GLenum name, GLint *value),(override))
MOCK_METHOD(void, Uniform1fv,(GLint location, GLsizei count, const GLfloat *value),(override))
MOCK_METHOD(void, DiscardFramebufferEXT,(GLenum target, GLsizei numAttachments, const GLenum *attachments),(override))
MOCK_METHOD(void, DeleteTextures,(GLsizei size, const GLuint *queries),(override))
MOCK_METHOD(void, DeleteQueriesEXT,(GLsizei size, const GLuint *queries),(override))
MOCK_METHOD(void, GenQueriesEXT,(GLsizei n, GLuint *ids),(override))
MOCK_METHOD(void, ObjectLabelKHR,(GLenum identifier, GLuint name, GLsizei length, const GLchar *label),(override))
MOCK_METHOD(void, DeleteFramebuffers,(GLsizei n, const GLuint *framebuffers),(override))
MOCK_METHOD(void, GetQueryObjectui64vEXT,(GLuint id, GLenum target, GLuint64 *result),(override))
int32_t x
uint32_t * target
size_t length
FlTexture * texture
double y
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
Definition switch_defs.h:27
const ProcTableGLES::Resolver kMockResolverGLES
Definition mock_gles.cc:287
int32_t height
int32_t width