• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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(rx::Serial())) {}
~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_METHOD7(readPixels,
38                  angle::Result(const gl::Context *,
39                                const gl::Rectangle &,
40                                GLenum,
41                                GLenum,
42                                const gl::PixelPackState &,
43                                gl::Buffer *,
44                                void *));
45 
46     MOCK_CONST_METHOD3(getSamplePosition, angle::Result(const gl::Context *, size_t, GLfloat *));
47 
48     MOCK_METHOD5(blit,
49                  angle::Result(const gl::Context *,
50                                const gl::Rectangle &,
51                                const gl::Rectangle &,
52                                GLbitfield,
53                                GLenum));
54 
55     MOCK_CONST_METHOD1(checkStatus, gl::FramebufferStatus(const gl::Context *));
56 
57     MOCK_METHOD4(syncState,
58                  angle::Result(const gl::Context *,
59                                GLenum,
60                                const gl::Framebuffer::DirtyBits &,
61                                gl::Command command));
62 
63     MOCK_METHOD0(destructor, void());
64 };
65 
MakeFramebufferMock()66 inline ::testing::NiceMock<MockFramebufferImpl> *MakeFramebufferMock()
67 {
68     ::testing::NiceMock<MockFramebufferImpl> *framebufferImpl =
69         new ::testing::NiceMock<MockFramebufferImpl>();
70     // TODO(jmadill): add ON_CALLS for other returning methods
71     ON_CALL(*framebufferImpl, checkStatus(testing::_))
72         .WillByDefault(::testing::Return(gl::FramebufferStatus::Complete()));
73 
74     // We must mock the destructor since NiceMock doesn't work for destructors.
75     EXPECT_CALL(*framebufferImpl, destructor()).Times(1).RetiresOnSaturation();
76 
77     return framebufferImpl;
78 }
79 
80 }  // namespace rx
81 
82 #endif  // LIBANGLE_RENDERER_FRAMEBUFFERIMPLMOCK_H_
83