forked from organicmaps/organicmaps
new mocked functions
This commit is contained in:
parent
1f52a45ef7
commit
b7b3163b92
3 changed files with 46 additions and 4 deletions
|
@ -7,6 +7,21 @@ using namespace emul;
|
|||
|
||||
#define MOCK_CALL(f) GLMockFunctions::Instance().f;
|
||||
|
||||
uint32_t GLFunctions::glGenVertexArray()
|
||||
{
|
||||
return MOCK_CALL(glGenVertexArray());
|
||||
}
|
||||
|
||||
void GLFunctions::glBindVertexArray(uint32_t vao)
|
||||
{
|
||||
MOCK_CALL(glBindVertexArray(vao));
|
||||
}
|
||||
|
||||
void GLFunctions::glDeleteVertexArray(uint32_t vao)
|
||||
{
|
||||
MOCK_CALL(glDeleteVertexArray(vao));
|
||||
}
|
||||
|
||||
uint32_t GLFunctions::glGenBuffer()
|
||||
{
|
||||
return MOCK_CALL(glGenBuffer());
|
||||
|
@ -84,7 +99,7 @@ void GLFunctions::glUseProgram(uint32_t programID)
|
|||
|
||||
int8_t GLFunctions::glGetAttribLocation(uint32_t programID, const string & name)
|
||||
{
|
||||
return 0;
|
||||
return MOCK_CALL(glGetAttribLocation(programID, name));
|
||||
}
|
||||
|
||||
void GLFunctions::glBindAttribLocation(uint32_t programID, uint8_t index, const string & name)
|
||||
|
@ -95,7 +110,7 @@ void GLFunctions::glBindAttribLocation(uint32_t programID, uint8_t index, const
|
|||
/// enable vertex attribute binding. To get attributeLocation need to call glGetAttributeLocation
|
||||
void GLFunctions::glEnableVertexAttribute(int32_t attributeLocation)
|
||||
{
|
||||
|
||||
MOCK_CALL(glEnableVertexAttribute(attributeLocation));
|
||||
}
|
||||
|
||||
void GLFunctions::glVertexAttributePointer(int32_t attrLocation,
|
||||
|
@ -105,7 +120,7 @@ void GLFunctions::glVertexAttributePointer(int32_t attrLocation,
|
|||
uint32_t stride,
|
||||
uint32_t offset)
|
||||
{
|
||||
|
||||
MOCK_CALL(glVertexAttributePointer(attrLocation, count, type, needNormalize, stride, offset));
|
||||
}
|
||||
|
||||
int8_t GLFunctions::glGetUniformLocation(uint32_t programID, const string & name)
|
||||
|
@ -158,9 +173,14 @@ void GLFunctions::glUniformMatrix4x4Value(int8_t location, float * values)
|
|||
MOCK_CALL(glUniformMatrix4x4Value(location, values));
|
||||
}
|
||||
|
||||
static uint32_t glGetCurrentProgram()
|
||||
uint32_t GLFunctions::glGetCurrentProgram()
|
||||
{
|
||||
return MOCK_CALL(glGetCurrentProgram());
|
||||
}
|
||||
|
||||
bool GLFunctions::glHasExtension(string const & extName)
|
||||
{
|
||||
return MOCK_CALL(glHasExtension(extName));
|
||||
}
|
||||
|
||||
void CheckGLError() {}
|
||||
|
|
|
@ -19,5 +19,10 @@ namespace emul
|
|||
return *m_mock;
|
||||
}
|
||||
|
||||
void GLMockFunctions::ValidateAndClear()
|
||||
{
|
||||
::testing::Mock::VerifyAndClear(m_mock);
|
||||
}
|
||||
|
||||
GLMockFunctions * GLMockFunctions::m_mock;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,14 @@ namespace emul
|
|||
static void Init(int * argc, char ** argv);
|
||||
static void Teardown();
|
||||
static GLMockFunctions & Instance();
|
||||
static void ValidateAndClear();
|
||||
|
||||
//VAO
|
||||
MOCK_METHOD0(glGenVertexArray, uint32_t());
|
||||
MOCK_METHOD1(glBindVertexArray, void(uint32_t vao));
|
||||
MOCK_METHOD1(glDeleteVertexArray, void(uint32_t vao));
|
||||
|
||||
// VBO
|
||||
MOCK_METHOD0(glGenBuffer, uint32_t());
|
||||
MOCK_METHOD2(glBindBuffer, void(uint32_t vbo, glConst target));
|
||||
MOCK_METHOD1(glDeleteBuffer, void(uint32_t vbo));
|
||||
|
@ -44,7 +51,17 @@ namespace emul
|
|||
MOCK_METHOD2(glLinkProgram, bool(uint32_t programID, string & errorLog));
|
||||
MOCK_METHOD1(glDeleteProgram, void(uint32_t programID));
|
||||
|
||||
MOCK_METHOD2(glGetAttribLocation, int32_t(uint32_t programID, const string & name));
|
||||
MOCK_METHOD1(glEnableVertexAttribute, void(int32_t attributeLocation));
|
||||
MOCK_METHOD6(glVertexAttributePointer, void(int32_t attrLocation,
|
||||
uint32_t count,
|
||||
glConst type,
|
||||
bool needNormalize,
|
||||
uint32_t stride,
|
||||
uint32_t offset));
|
||||
|
||||
MOCK_METHOD1(glUseProgram, void(uint32_t programID));
|
||||
MOCK_METHOD1(glHasExtension, bool(string const & extName));
|
||||
|
||||
private:
|
||||
static GLMockFunctions * m_mock;
|
||||
|
|
Loading…
Add table
Reference in a new issue