Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
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.
 
std::vector< std::string > GetCapturedCalls ()
 Returns a vector of the names of all recorded calls.
 
 ~MockGLES ()
 

Static Public Member Functions

static std::shared_ptr< MockGLESInit (const std::optional< std::vector< const unsigned 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)
 

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 26 of file mock_gles.h.

Constructor & Destructor Documentation

◆ ~MockGLES()

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

Definition at line 213 of file mock_gles.cc.

213 {
214 g_test_lock.unlock();
215}
static std::mutex g_test_lock
Definition mock_gles.cc:18

Member Function Documentation

◆ GetCapturedCalls()

std::vector< std::string > impeller::testing::MockGLES::GetCapturedCalls ( )
inline

Returns a vector of the names of all recorded calls.

Calls are cleared after this method is called.

Definition at line 45 of file mock_gles.h.

45 {
46 std::vector<std::string> calls = captured_calls_;
47 captured_calls_.clear();
48 return calls;
49 }

◆ GetProcTable()

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

Returns a configured |ProcTableGLES| instance.

Definition at line 40 of file mock_gles.h.

40{ return proc_table_; }

◆ Init()

std::shared_ptr< MockGLES > impeller::testing::MockGLES::Init ( const std::optional< std::vector< const unsigned 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 166 of file mock_gles.cc.

169 {
170 // If we cannot obtain a lock, MockGLES is already being used elsewhere.
171 FML_CHECK(g_test_lock.try_lock())
172 << "MockGLES is already being used by another test.";
173 g_version = (unsigned char*)version_string;
175 auto mock_gles = std::shared_ptr<MockGLES>(new MockGLES(std::move(resolver)));
176 g_mock_gles = mock_gles;
177 return mock_gles;
178}
#define FML_CHECK(condition)
Definition logging.h:85
auto const kExtensions
Definition mock_gles.cc:46
static std::weak_ptr< MockGLES > g_mock_gles
Definition mock_gles.cc:20
static std::vector< const unsigned char * > g_extensions
Definition mock_gles.cc:24
static const unsigned char * g_version
Definition mock_gles.cc:26

Friends And Related Symbol Documentation

◆ RecordGLCall

void RecordGLCall ( const char *  name)
friend

Definition at line 29 of file mock_gles.cc.

29 {
30 if (auto mock_gles = g_mock_gles.lock()) {
31 mock_gles->RecordCall(name);
32 }
33}
const char * name
Definition fuchsia.cc:50

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