Flutter Engine
 
Loading...
Searching...
No Matches
impeller::testing::MockGLES Class Referencefinal

Provides a mocked version of the |ProcTableGLES| class. More...

#include <mock_gles.h>

Public Member Functions

const ProcTableGLESGetProcTable () const
 Returns a configured |ProcTableGLES| instance.
 
 ~MockGLES ()
 
IMockGLESImplGetImpl ()
 

Static Public Member Functions

static std::shared_ptr< MockGLESInit (std::unique_ptr< MockGLESImpl > impl, const std::optional< std::vector< const char * > > &extensions=std::nullopt)
 
static std::shared_ptr< MockGLESInit (const std::optional< std::vector< const char * > > &extensions=std::nullopt, const char *version_string="OpenGL ES 3.0", ProcTableGLES::Resolver resolver=kMockResolverGLES)
 Returns an initialized |MockGLES| instance.
 

Friends

void RecordGLCall (const char *name)
 
void mockGenTextures (GLsizei n, GLuint *textures)
 

Detailed Description

Provides a mocked version of the |ProcTableGLES| class.

Typically, Open GLES at runtime will be provided the host's GLES bindings (as function pointers). This class maintains a set of function pointers that appear to be GLES functions, but are actually just stubs that record invocations.

See README.md for more information.

Definition at line 173 of file mock_gles.h.

Constructor & Destructor Documentation

◆ ~MockGLES()

impeller::testing::MockGLES::~MockGLES ( )

Definition at line 342 of file mock_gles.cc.

342 {
343 g_test_lock.unlock();
344}
static std::mutex g_test_lock
Definition mock_gles.cc:18

References impeller::testing::g_test_lock.

Member Function Documentation

◆ GetImpl()

IMockGLESImpl * impeller::testing::MockGLES::GetImpl ( )
inline

Definition at line 194 of file mock_gles.h.

194{ return impl_.get(); }

◆ GetProcTable()

const ProcTableGLES & impeller::testing::MockGLES::GetProcTable ( ) const
inline

Returns a configured |ProcTableGLES| instance.

Definition at line 190 of file mock_gles.h.

190{ return proc_table_; }

◆ Init() [1/2]

std::shared_ptr< MockGLES > impeller::testing::MockGLES::Init ( const std::optional< std::vector< const char * > > &  extensions = std::nullopt,
const char *  version_string = "OpenGL ES 3.0",
ProcTableGLES::Resolver  resolver = kMockResolverGLES 
)
static

Returns an initialized |MockGLES| instance.

This method overwrites mocked global GLES function pointers to record invocations on this instance of |MockGLES|. As such, it should only be called once per test.

Definition at line 273 of file mock_gles.cc.

276 {
277 // If we cannot obtain a lock, MockGLES is already being used elsewhere.
278 FML_CHECK(g_test_lock.try_lock())
279 << "MockGLES is already being used by another test.";
280 g_extensions = extensions.value_or(kExtensions);
281 g_version = version_string;
282 auto mock_gles = std::shared_ptr<MockGLES>(new MockGLES(std::move(resolver)));
283 g_mock_gles = mock_gles;
284 return mock_gles;
285}
#define FML_CHECK(condition)
Definition logging.h:104
static std::vector< const char * > g_extensions
Definition mock_gles.cc:22
auto const kExtensions
Definition mock_gles.cc:37
static std::weak_ptr< MockGLES > g_mock_gles
Definition mock_gles.cc:20
static const char * g_version
Definition mock_gles.cc:24

References FML_CHECK, impeller::testing::g_extensions, impeller::testing::g_mock_gles, impeller::testing::g_test_lock, impeller::testing::g_version, and impeller::testing::kExtensions.

◆ Init() [2/2]

std::shared_ptr< MockGLES > impeller::testing::MockGLES::Init ( std::unique_ptr< MockGLESImpl impl,
const std::optional< std::vector< const char * > > &  extensions = std::nullopt 
)
static

Friends And Related Symbol Documentation

◆ mockGenTextures

void mockGenTextures ( GLsizei  n,
GLuint *  textures 
)
friend

Definition at line 186 of file mock_gles.cc.

186 {
187 CallMockMethod(&IMockGLESImpl::GenTextures, n, textures);
188}
virtual void GenTextures(GLsizei n, GLuint *textures)
Definition mock_gles.h:23

◆ RecordGLCall

void RecordGLCall ( const char *  name)
friend

The documentation for this class was generated from the following files: