Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mock_fb_hal_device.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3,
6  * as 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: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 
19 #ifndef MIR_TEST_DOUBLES_MOCK_FB_HAL_DEVICE_H_
20 #define MIR_TEST_DOUBLES_MOCK_FB_HAL_DEVICE_H_
21 
22 #include <hardware/hwcomposer.h>
23 #include <hardware/gralloc.h>
24 #include <hardware/fb.h>
25 #include <gmock/gmock.h>
26 
27 namespace mir
28 {
29 namespace test
30 {
31 namespace doubles
32 {
33 
34 class MockFBHalDevice : public framebuffer_device_t
35 {
36 public:
37  MockFBHalDevice(unsigned int const width, unsigned int const height,
38  int const pf, int const numfbs)
39  : framebuffer_device_t({
40  hw_device_t(),
41  0,
42  width,
43  height,
44  0,
45  pf,
46  0.0f,
47  0.0f,
48  0.0f,
49  0,
50  1,
51  numfbs,
52  {0,0,0,0,0,0,0},
53  nullptr, nullptr,nullptr,nullptr, nullptr,nullptr,
54  {0,0,0,0,0,0}
55  })
56  {
57  post = hook_post;
60  }
61 
63  : MockFBHalDevice(1,1,1,1)
64  {
65  }
66 
67  static int hook_post(struct framebuffer_device_t* mock_fb, buffer_handle_t handle)
68  {
69  MockFBHalDevice* mocker = static_cast<MockFBHalDevice*>(mock_fb);
70  return mocker->post_interface(mock_fb, handle);
71  }
72 
73  static int hook_setSwapInterval(struct framebuffer_device_t* mock_fb, int interval)
74  {
75  MockFBHalDevice* mocker = static_cast<MockFBHalDevice*>(mock_fb);
76  return mocker->setSwapInterval_interface(mock_fb, interval);
77  }
78 
79  static int hook_enableScreen(struct framebuffer_device_t* mock_fb, int enable)
80  {
81  MockFBHalDevice* mocker = static_cast<MockFBHalDevice*>(mock_fb);
82  return mocker->enableScreen_interface(mock_fb, enable);
83  }
84 
85 
86  MOCK_METHOD2(enableScreen_interface, int(struct framebuffer_device_t*, int));
87  MOCK_METHOD2(post_interface, int(struct framebuffer_device_t*, buffer_handle_t));
88  MOCK_METHOD2(setSwapInterval_interface, int(struct framebuffer_device_t*, int));
89 };
90 
91 }
92 }
93 }
94 #endif /* MIR_TEST_DOUBLES_MOCK_FB_HAL_DEVICE_H_ */
setSwapInterval
Definition: mock_fb_hal_device.h:58
MOCK_METHOD2(enableScreen_interface, int(struct framebuffer_device_t *, int))
static int hook_enableScreen(struct framebuffer_device_t *mock_fb, int enable)
Definition: mock_fb_hal_device.h:79
unsigned int width
Definition: black_arrow.c:4
MockFBHalDevice()
Definition: mock_fb_hal_device.h:62
static int hook_post(struct framebuffer_device_t *mock_fb, buffer_handle_t handle)
Definition: mock_fb_hal_device.h:67
Definition: mock_fb_hal_device.h:34
unsigned int height
Definition: black_arrow.c:5
MockFBHalDevice(unsigned int const width, unsigned int const height, int const pf, int const numfbs)
Definition: mock_fb_hal_device.h:37
enableScreen
Definition: mock_fb_hal_device.h:59
static int hook_setSwapInterval(struct framebuffer_device_t *mock_fb, int interval)
Definition: mock_fb_hal_device.h:73

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Apr 11 21:14:53 UTC 2014