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()) {}
~MockFramebufferImpl()24     virtual ~MockFramebufferImpl() { destructor(); }
25 
26     MOCK_METHOD3(discard, gl::Error(const gl::Context *, size_t, const GLenum *));
27     MOCK_METHOD3(invalidate, gl::Error(const gl::Context *, size_t, const GLenum *));
28     MOCK_METHOD4(invalidateSub,
29                  gl::Error(const gl::Context *, size_t, const GLenum *, const gl::Rectangle &));
30 
31     MOCK_METHOD2(clear, gl::Error(const gl::Context *, GLbitfield));
32     MOCK_METHOD4(clearBufferfv, gl::Error(const gl::Context *, GLenum, GLint, const GLfloat *));
33     MOCK_METHOD4(clearBufferuiv, gl::Error(const gl::Context *, GLenum, GLint, const GLuint *));
34     MOCK_METHOD4(clearBufferiv, gl::Error(const gl::Context *, GLenum, GLint, const GLint *));
35     MOCK_METHOD5(clearBufferfi, gl::Error(const gl::Context *, GLenum, GLint, GLfloat, GLint));
36 
37     MOCK_CONST_METHOD1(getImplementationColorReadFormat, GLenum(const gl::Context *));
38     MOCK_CONST_METHOD1(getImplementationColorReadType, GLenum(const gl::Context *));
39     MOCK_METHOD5(readPixels,
40                  gl::Error(const gl::Context *, const gl::Rectangle &, GLenum, GLenum, void *));
41 
42     MOCK_CONST_METHOD2(getSamplePosition, gl::Error(size_t, GLfloat *));
43 
44     MOCK_METHOD5(blit,
45                  gl::Error(const gl::Context *,
46                            const gl::Rectangle &,
47                            const gl::Rectangle &,
48                            GLbitfield,
49                            GLenum));
50 
51     MOCK_CONST_METHOD1(checkStatus, bool(const gl::Context *));
52 
53     MOCK_METHOD2(syncState, void(const gl::Context *, const gl::Framebuffer::DirtyBits &));
54 
55     MOCK_METHOD0(destructor, void());
56 };
57 
MakeFramebufferMock()58 inline ::testing::NiceMock<MockFramebufferImpl> *MakeFramebufferMock()
59 {
60     ::testing::NiceMock<MockFramebufferImpl> *framebufferImpl =
61         new ::testing::NiceMock<MockFramebufferImpl>();
62     // TODO(jmadill): add ON_CALLS for other returning methods
63     ON_CALL(*framebufferImpl, checkStatus(testing::_)).WillByDefault(::testing::Return(true));
64 
65     // We must mock the destructor since NiceMock doesn't work for destructors.
66     EXPECT_CALL(*framebufferImpl, destructor()).Times(1).RetiresOnSaturation();
67 
68     return framebufferImpl;
69 }
70 
71 }  // namespace rx
72 
73 #endif  // LIBANGLE_RENDERER_FRAMEBUFFERIMPLMOCK_H_
74