Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
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, const char *version_string="OpenGL ES 3.0")
 
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 259 of file mock_gles.h.

Constructor & Destructor Documentation

◆ ~MockGLES()

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

Definition at line 479 of file mock_gles.cc.

479 {
480 g_test_lock.unlock();
481}
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 281 of file mock_gles.h.

281{ return impl_.get(); }

◆ GetProcTable()

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

Returns a configured |ProcTableGLES| instance.

Definition at line 277 of file mock_gles.h.

277{ 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 381 of file mock_gles.cc.

384 {
385 // If we cannot obtain a lock, MockGLES is already being used elsewhere.
386 FML_CHECK(g_test_lock.try_lock())
387 << "MockGLES is already being used by another test.";
388 g_extensions = extensions.value_or(kExtensions);
389 g_extensions_string.clear();
390 for (const auto& ext : g_extensions) {
391 if (!g_extensions_string.empty()) {
392 g_extensions_string += " ";
393 }
394 g_extensions_string += ext;
395 }
396 g_version = version_string;
397 auto mock_gles = std::shared_ptr<MockGLES>(new MockGLES(std::move(resolver)));
398 g_mock_gles = mock_gles;
399 return mock_gles;
400}
#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:38
static std::string g_extensions_string
Definition mock_gles.cc:25
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_extensions_string, 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,
const char *  version_string = "OpenGL ES 3.0" 
)
static

Definition at line 360 of file mock_gles.cc.

363 {
364 FML_CHECK(g_test_lock.try_lock())
365 << "MockGLES is already being used by another test.";
366 g_extensions = extensions.value_or(kExtensions);
367 g_extensions_string.clear();
368 for (const auto& ext : g_extensions) {
369 if (!g_extensions_string.empty()) {
370 g_extensions_string += " ";
371 }
372 g_extensions_string += ext;
373 }
374 g_version = version_string;
375 auto mock_gles = std::shared_ptr<MockGLES>(new MockGLES());
376 mock_gles->impl_ = std::move(impl);
377 g_mock_gles = mock_gles;
378 return mock_gles;
379}

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

Referenced by impeller::testing::RenderPassGLESViewportTest::CreateRenderPassGLESContext(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST_P(), and impeller::testing::TEST_P().

Friends And Related Symbol Documentation

◆ mockGenTextures

void mockGenTextures ( GLsizei  n,
GLuint *  textures 
)
friend

Definition at line 236 of file mock_gles.cc.

236 {
237 CallMockMethod(&IMockGLESImpl::GenTextures, n, textures);
238}
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: