1 //
2 // Copyright 2015 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // FramebufferImpl_mock.h:
7 // Defines a mock of the FramebufferImpl class.
8 //
9
10 #ifndef LIBANGLE_RENDERER_FRAMEBUFFERIMPLMOCK_H_
11 #define LIBANGLE_RENDERER_FRAMEBUFFERIMPLMOCK_H_
12
13 #include "gmock/gmock.h"
14
15 #include "libANGLE/renderer/FramebufferImpl.h"
16
17 namespace rx
18 {
19
20 class MockFramebufferImpl : public rx::FramebufferImpl
21 {
22 public:
MockFramebufferImpl()23 MockFramebufferImpl() : rx::FramebufferImpl(gl::FramebufferState(1)) {}
~MockFramebufferImpl()24 virtual ~MockFramebufferImpl() { destructor(); }
25
26 MOCK_METHOD3(discard, angle::Result(const gl::Context *, size_t, const GLenum *));
27 MOCK_METHOD3(invalidate, angle::Result(const gl::Context *, size_t, const GLenum *));
28 MOCK_METHOD4(invalidateSub,
29 angle::Result(const gl::Context *, size_t, const GLenum *, const gl::Rectangle &));
30
31 MOCK_METHOD2(clear, angle::Result(const gl::Context *, GLbitfield));
32 MOCK_METHOD4(clearBufferfv, angle::Result(const gl::Context *, GLenum, GLint, const GLfloat *));
33 MOCK_METHOD4(clearBufferuiv, angle::Result(const gl::Context *, GLenum, GLint, const GLuint *));
34 MOCK_METHOD4(clearBufferiv, angle::Result(const gl::Context *, GLenum, GLint, const GLint *));
35 MOCK_METHOD5(clearBufferfi, angle::Result(const gl::Context *, GLenum, GLint, GLfloat, GLint));
36
37 MOCK_METHOD5(readPixels,
38 angle::Result(const gl::Context *, const gl::Rectangle &, GLenum, GLenum, void *));
39
40 MOCK_CONST_METHOD3(getSamplePosition, angle::Result(const gl::Context *, size_t, GLfloat *));
41
42 MOCK_METHOD5(blit,
43 angle::Result(const gl::Context *,
44 const gl::Rectangle &,
45 const gl::Rectangle &,
46 GLbitfield,
47 GLenum));
48
49 MOCK_CONST_METHOD1(checkStatus, bool(const gl::Context *));
50
51 MOCK_METHOD3(syncState,
52 angle::Result(const gl::Context *, GLenum, const gl::Framebuffer::DirtyBits &));
53
54 MOCK_METHOD0(destructor, void());
55 };
56
MakeFramebufferMock()57 inline ::testing::NiceMock<MockFramebufferImpl> *MakeFramebufferMock()
58 {
59 ::testing::NiceMock<MockFramebufferImpl> *framebufferImpl =
60 new ::testing::NiceMock<MockFramebufferImpl>();
61 // TODO(jmadill): add ON_CALLS for other returning methods
62 ON_CALL(*framebufferImpl, checkStatus(testing::_)).WillByDefault(::testing::Return(true));
63
64 // We must mock the destructor since NiceMock doesn't work for destructors.
65 EXPECT_CALL(*framebufferImpl, destructor()).Times(1).RetiresOnSaturation();
66
67 return framebufferImpl;
68 }
69
70 } // namespace rx
71
72 #endif // LIBANGLE_RENDERER_FRAMEBUFFERIMPLMOCK_H_
73