~chasedouglas/+junk/client-lib

« back to all changes in this revision

Viewing changes to unit-tests/compositor/mock_buffer.h

  • Committer: Alan Griffiths
  • Date: 2012-07-06 16:48:49 UTC
  • mfrom: (28.4.63 add-bm-client)
  • Revision ID: alan@octopull.co.uk-20120706164849-4g2i72hplzgbvuwa
Refine interfaces surrounding the BufferBundle

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2012 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Thomas Voss <thomas.voss@canonical.com>
 
17
 */
 
18
 
 
19
#ifndef MIR_COMPOSITOR_MOCK_BUFFER_H_
 
20
#define MIR_COMPOSITOR_MOCK_BUFFER_H_
 
21
 
 
22
#include "mir/compositor/buffer.h"
 
23
#include "mir/geometry/dimensions.h"
 
24
 
 
25
#include <gmock/gmock.h>
 
26
#include <gtest/gtest.h>
 
27
 
 
28
namespace mir
 
29
{
 
30
namespace compositor
 
31
{
 
32
 
 
33
namespace geom = mir::geometry;
 
34
 
 
35
struct MockBuffer : public Buffer
 
36
{
 
37
 public:
 
38
    MockBuffer(geom::Width w,
 
39
               geom::Height h,
 
40
               geom::Stride s,
 
41
               PixelFormat pf)
 
42
        {
 
43
            using namespace testing;
 
44
            ON_CALL(*this, width())
 
45
                    .WillByDefault(Return(w));
 
46
            ON_CALL(*this, height())
 
47
                    .WillByDefault(Return(h));
 
48
            ON_CALL(*this, stride())
 
49
                    .WillByDefault(Return(s));
 
50
            ON_CALL(*this, pixel_format())
 
51
                    .WillByDefault(Return(pf));
 
52
        }
 
53
 
 
54
    MOCK_CONST_METHOD0(width, geom::Width());
 
55
    MOCK_CONST_METHOD0(height, geom::Height());
 
56
    MOCK_CONST_METHOD0(stride, geom::Stride());
 
57
    MOCK_CONST_METHOD0(pixel_format, PixelFormat());
 
58
 
 
59
    MOCK_METHOD0(lock, void());
 
60
    MOCK_METHOD0(unlock, void());
 
61
    MOCK_METHOD0(bind_to_texture, graphics::Texture*());
 
62
 
 
63
};
 
64
 
 
65
}
 
66
}
 
67
 
 
68
#endif // MIR_COMPOSITOR_MOCK_BUFFER_H_