Skip to content

Commit a6570c3

Browse files
authored
Add IsProgram mock method to MockGLESImpl, use it in BufferBindingsGLESTest (flutter#192196)
Previously, this method was not mocked and would return an undefined value when it was called in the `BufferBindingsGLESTest` unit tests. When the returned value happened to be false, this makes the tests fail. We've seen this failure pop up multiple times recently. Examples: https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20linux_unopt/47431/overview https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20linux_unopt/47434/overview https://ci.chromium.org/ui/p/flutter/builders/prod/Linux%20linux_unopt/19763/overview I can't consistently repro the failure at HEAD or at the PRs which produced the example failures. But I I tested that modifying this PR to return `GL_FALSE` instead of `GL_TRUE` does consistently reproduce the failure.
1 parent 0968ec9 commit a6570c3

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎engine/src/flutter/impeller/renderer/backend/gles/buffer_bindings_gles_unittests.cc‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ void TestBindUniformBufferRange(size_t buffer_view_length,
290290

291291
const GLuint kProgram = 1;
292292

293+
ON_CALL(*mock_gles_impl, IsProgram(kProgram))
294+
.WillByDefault(::testing::Return(GL_TRUE));
293295
ON_CALL(*mock_gles_impl,
294296
GetProgramiv(/*program=*/kProgram,
295297
/*pname=*/GL_ACTIVE_UNIFORM_BLOCKS, /*params=*/_))

‎engine/src/flutter/impeller/renderer/backend/gles/test/mock_gles.cc‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,13 @@ GLboolean mockIsTexture(GLuint texture) {
358358
static_assert(CheckSameSignature<decltype(mockIsTexture), //
359359
decltype(glIsTexture)>::value);
360360

361+
GLboolean mockIsProgram(GLuint program) {
362+
return CallMockMethod(&IMockGLESImpl::IsProgram, program);
363+
}
364+
365+
static_assert(CheckSameSignature<decltype(mockIsProgram), //
366+
decltype(glIsProgram)>::value);
367+
361368
GLenum mockCheckFramebufferStatus(GLenum target) {
362369
return CallMockMethod(&IMockGLESImpl::CheckFramebufferStatus, target);
363370
}
@@ -561,6 +568,8 @@ const ProcTableGLES::Resolver kMockResolverGLES = [](const char* name) {
561568
return reinterpret_cast<void*>(mockBufferSubData);
562569
} else if (strcmp(name, "glIsTexture") == 0) {
563570
return reinterpret_cast<void*>(mockIsTexture);
571+
} else if (strcmp(name, "glIsProgram") == 0) {
572+
return reinterpret_cast<void*>(mockIsProgram);
564573
} else if (strcmp(name, "glCheckFramebufferStatus") == 0) {
565574
return reinterpret_cast<void*>(mockCheckFramebufferStatus);
566575
} else if (strcmp(name, "glReadPixels") == 0) {

‎engine/src/flutter/impeller/renderer/backend/gles/test/mock_gles.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class IMockGLESImpl {
102102
GLsizeiptr size,
103103
const void* data) {}
104104
virtual GLboolean IsTexture(GLuint texture) { return true; }
105+
virtual GLboolean IsProgram(GLuint program) { return true; }
105106
virtual void DiscardFramebufferEXT(GLenum target,
106107
GLsizei numAttachments,
107108
const GLenum* attachments) {};
@@ -277,6 +278,7 @@ class MockGLESImpl : public IMockGLESImpl {
277278
(GLenum target, GLintptr offset, GLsizeiptr size, const void* data),
278279
(override));
279280
MOCK_METHOD(GLboolean, IsTexture, (GLuint texture), (override));
281+
MOCK_METHOD(GLboolean, IsProgram, (GLuint program), (override));
280282
MOCK_METHOD(void,
281283
DiscardFramebufferEXT,
282284
(GLenum target,

0 commit comments

Comments
 (0)