Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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:
38  {
39  post = hook_post;
40  }
41 
42  MockFBHalDevice(unsigned int const width, unsigned int const height,
43  int const pf, int const numfbs)
44  : framebuffer_device_t({
46  0,
47  width,
48  height,
49  0,
50  pf,
51  0.0f,
52  0.0f,
53  0.0f,
54  0,
55  1,
56  numfbs,
57  {0,0,0,0,0,0,0},
58  nullptr, nullptr,nullptr,nullptr, nullptr,nullptr,
59  {0,0,0,0,0,0}
60  })
61  {
64  }
65 
66  static int hook_post(struct framebuffer_device_t* mock_fb, buffer_handle_t handle)
67  {
68  MockFBHalDevice* mocker = static_cast<MockFBHalDevice*>(mock_fb);
69  return mocker->post_interface(mock_fb, handle);
70  }
71 
72  static int hook_setSwapInterval(struct framebuffer_device_t* mock_fb, int interval)
73  {
74  MockFBHalDevice* mocker = static_cast<MockFBHalDevice*>(mock_fb);
75  return mocker->setSwapInterval_interface(mock_fb, interval);
76  }
77 
78  MOCK_METHOD2(post_interface, int(struct framebuffer_device_t*, buffer_handle_t));
79  MOCK_METHOD2(setSwapInterval_interface, int(struct framebuffer_device_t*, int));
80 
81  hw_device_t empty_module;
82 };
83 
84 }
85 }
86 }
87 #endif /* MIR_TEST_DOUBLES_MOCK_FB_HAL_DEVICE_H_ */

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Oct 15 00:23:28 UTC 2013