Merge lp:~kdub/mir/resettable-buffer-cb into lp:mir
- resettable-buffer-cb
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Chris Halse Rogers |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3574 |
Proposed branch: | lp:~kdub/mir/resettable-buffer-cb |
Merge into: | lp:mir |
Diff against target: |
272 lines (+106/-7) 12 files modified
src/client/atomic_callback.h (+5/-0) src/client/buffer.cpp (+9/-4) src/client/buffer.h (+6/-3) src/client/error_buffer.cpp (+1/-0) src/client/error_buffer.h (+1/-0) src/client/mir_buffer.h (+1/-0) src/client/mir_buffer_api.cpp (+13/-0) src/client/symbols.map (+1/-0) src/include/client/mir_toolkit/mir_buffer.h (+12/-0) tests/acceptance-tests/throwback/test_presentation_chain.cpp (+38/-0) tests/include/mir/test/doubles/mock_mir_buffer.h (+1/-0) tests/unit-tests/client/test_mir_buffer.cpp (+18/-0) |
To merge this branch: | bzr merge lp:~kdub/mir/resettable-buffer-cb |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Halse Rogers | Approve | ||
Mir CI Bot | continuous-integration | Approve | |
Alan Griffiths | Approve | ||
Cemil Azizoglu (community) | Approve | ||
Review via email:
|
Commit message
client: add a function to the MirBuffer set of functions that allows a user to set the callback and context of a MirBuffer. Callback and context were provided in the construction; allow changing these via the new client api function.
Description of the change
client: add a function to the MirBuffer set of functions that allows a user to set the callback and context of a MirBuffer. Callback and context were provided in the construction; allow changing these via the new client api function.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3509
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
I'm not entirely convinced that a recursive lock allows useful behaviour, but OK.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Chris Halse Rogers (raof) wrote : | # |
This *seems* like the sort of thing mcl::AtomicCallback is for? It doesn't currently handle changing the callback from an active callback, but that'd be a simple matter of copy-then-unlock.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Kevin DuBois (kdub) wrote : | # |
Ah yes, that class would make the code better, will use it.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3512
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
https:/
Executed test runs:
FAILURE: https:/
None: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3513
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Kevin DuBois (kdub) wrote : | # |
krillin image 515 fails to come up, retriggering.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3513
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Chris Halse Rogers (raof) wrote : | # |
+ cb.set_callback([&, callback, context]{ (*callback)
The ‘&’ is rather strange there - you only really want to capture /this/ by value.
But that's a stylistic nit.
Preview Diff
1 | === modified file 'src/client/atomic_callback.h' | |||
2 | --- src/client/atomic_callback.h 2016-01-29 08:18:22 +0000 | |||
3 | +++ src/client/atomic_callback.h 2016-06-24 11:42:58 +0000 | |||
4 | @@ -35,6 +35,11 @@ | |||
5 | 35 | { | 35 | { |
6 | 36 | } | 36 | } |
7 | 37 | 37 | ||
8 | 38 | AtomicCallback(std::function<void(Args...)> const& fn) | ||
9 | 39 | : callback(fn) | ||
10 | 40 | { | ||
11 | 41 | } | ||
12 | 42 | |||
13 | 38 | ~AtomicCallback() = default; | 43 | ~AtomicCallback() = default; |
14 | 39 | 44 | ||
15 | 40 | void set_callback(std::function<void(Args...)> const& fn) | 45 | void set_callback(std::function<void(Args...)> const& fn) |
16 | 41 | 46 | ||
17 | === modified file 'src/client/buffer.cpp' | |||
18 | --- src/client/buffer.cpp 2016-06-06 11:51:31 +0000 | |||
19 | +++ src/client/buffer.cpp 2016-06-24 11:42:58 +0000 | |||
20 | @@ -28,10 +28,9 @@ | |||
21 | 28 | std::shared_ptr<ClientBuffer> const& buffer, | 28 | std::shared_ptr<ClientBuffer> const& buffer, |
22 | 29 | MirConnection* connection, | 29 | MirConnection* connection, |
23 | 30 | MirBufferUsage usage) : | 30 | MirBufferUsage usage) : |
24 | 31 | cb(cb), | ||
25 | 32 | cb_context(context), | ||
26 | 33 | buffer_id(buffer_id), | 31 | buffer_id(buffer_id), |
27 | 34 | buffer(buffer), | 32 | buffer(buffer), |
28 | 33 | cb([this, cb, context]{ (*cb)(reinterpret_cast<::MirBuffer*>(this), context); }), | ||
29 | 35 | owned(false), | 34 | owned(false), |
30 | 36 | connection(connection), | 35 | connection(connection), |
31 | 37 | usage(usage) | 36 | usage(usage) |
32 | @@ -60,8 +59,8 @@ | |||
33 | 60 | if (!owned) | 59 | if (!owned) |
34 | 61 | owned = true; | 60 | owned = true; |
35 | 62 | } | 61 | } |
36 | 63 | cb(reinterpret_cast<::MirBuffer*>(static_cast<mcl::MirBuffer*>(this)), cb_context); | ||
37 | 64 | 62 | ||
38 | 63 | cb(); | ||
39 | 65 | } | 64 | } |
40 | 66 | 65 | ||
41 | 67 | void mcl::Buffer::received(MirBufferPackage const& update_package) | 66 | void mcl::Buffer::received(MirBufferPackage const& update_package) |
42 | @@ -74,7 +73,8 @@ | |||
43 | 74 | buffer->update_from(update_package); | 73 | buffer->update_from(update_package); |
44 | 75 | } | 74 | } |
45 | 76 | } | 75 | } |
47 | 77 | cb(reinterpret_cast<::MirBuffer*>(static_cast<mcl::MirBuffer*>(this)), cb_context); | 76 | |
48 | 77 | cb(); | ||
49 | 78 | } | 78 | } |
50 | 79 | 79 | ||
51 | 80 | MirGraphicsRegion mcl::Buffer::map_region() | 80 | MirGraphicsRegion mcl::Buffer::map_region() |
52 | @@ -138,3 +138,8 @@ | |||
53 | 138 | { | 138 | { |
54 | 139 | buffer->increment_age(); | 139 | buffer->increment_age(); |
55 | 140 | } | 140 | } |
56 | 141 | |||
57 | 142 | void mcl::Buffer::set_callback(mir_buffer_callback callback, void* context) | ||
58 | 143 | { | ||
59 | 144 | cb.set_callback([&, callback, context]{ (*callback)(reinterpret_cast<::MirBuffer*>(this), context); }); | ||
60 | 145 | } | ||
61 | 141 | 146 | ||
62 | === modified file 'src/client/buffer.h' | |||
63 | --- src/client/buffer.h 2016-06-06 11:51:31 +0000 | |||
64 | +++ src/client/buffer.h 2016-06-24 11:42:58 +0000 | |||
65 | @@ -21,6 +21,7 @@ | |||
66 | 21 | 21 | ||
67 | 22 | #include "mir_toolkit/mir_buffer.h" | 22 | #include "mir_toolkit/mir_buffer.h" |
68 | 23 | #include "mir/geometry/size.h" | 23 | #include "mir/geometry/size.h" |
69 | 24 | #include "atomic_callback.h" | ||
70 | 24 | #include "mir_buffer.h" | 25 | #include "mir_buffer.h" |
71 | 25 | #include <memory> | 26 | #include <memory> |
72 | 26 | #include <chrono> | 27 | #include <chrono> |
73 | @@ -41,6 +42,7 @@ | |||
74 | 41 | std::shared_ptr<ClientBuffer> const& buffer, | 42 | std::shared_ptr<ClientBuffer> const& buffer, |
75 | 42 | MirConnection* connection, | 43 | MirConnection* connection, |
76 | 43 | MirBufferUsage usage); | 44 | MirBufferUsage usage); |
77 | 45 | |||
78 | 44 | int rpc_id() const override; | 46 | int rpc_id() const override; |
79 | 45 | 47 | ||
80 | 46 | void submitted() override; | 48 | void submitted() override; |
81 | @@ -62,11 +64,12 @@ | |||
82 | 62 | MirConnection* allocating_connection() const override; | 64 | MirConnection* allocating_connection() const override; |
83 | 63 | 65 | ||
84 | 64 | void increment_age() override; | 66 | void increment_age() override; |
85 | 67 | void set_callback(mir_buffer_callback callback, void* context) override; | ||
86 | 65 | private: | 68 | private: |
87 | 66 | mir_buffer_callback cb; | ||
88 | 67 | void* cb_context; | ||
89 | 68 | int const buffer_id; | 69 | int const buffer_id; |
91 | 69 | std::shared_ptr<ClientBuffer> buffer; | 70 | std::shared_ptr<ClientBuffer> const buffer; |
92 | 71 | |||
93 | 72 | AtomicCallback<> cb; | ||
94 | 70 | 73 | ||
95 | 71 | std::mutex mutex; | 74 | std::mutex mutex; |
96 | 72 | bool owned; | 75 | bool owned; |
97 | 73 | 76 | ||
98 | === modified file 'src/client/error_buffer.cpp' | |||
99 | --- src/client/error_buffer.cpp 2016-05-19 13:22:43 +0000 | |||
100 | +++ src/client/error_buffer.cpp 2016-06-24 11:42:58 +0000 | |||
101 | @@ -68,3 +68,4 @@ | |||
102 | 68 | geom::Size mcl::ErrorBuffer::size() const THROW_EXCEPTION | 68 | geom::Size mcl::ErrorBuffer::size() const THROW_EXCEPTION |
103 | 69 | MirConnection* mcl::ErrorBuffer::allocating_connection() const THROW_EXCEPTION | 69 | MirConnection* mcl::ErrorBuffer::allocating_connection() const THROW_EXCEPTION |
104 | 70 | void mcl::ErrorBuffer::increment_age() THROW_EXCEPTION | 70 | void mcl::ErrorBuffer::increment_age() THROW_EXCEPTION |
105 | 71 | void mcl::ErrorBuffer::set_callback(mir_buffer_callback, void*) THROW_EXCEPTION | ||
106 | 71 | 72 | ||
107 | === modified file 'src/client/error_buffer.h' | |||
108 | --- src/client/error_buffer.h 2016-05-19 13:22:43 +0000 | |||
109 | +++ src/client/error_buffer.h 2016-06-24 11:42:58 +0000 | |||
110 | @@ -47,6 +47,7 @@ | |||
111 | 47 | geometry::Size size() const override; | 47 | geometry::Size size() const override; |
112 | 48 | MirConnection* allocating_connection() const override; | 48 | MirConnection* allocating_connection() const override; |
113 | 49 | void increment_age() override; | 49 | void increment_age() override; |
114 | 50 | void set_callback(mir_buffer_callback callback, void* context) override; | ||
115 | 50 | 51 | ||
116 | 51 | bool valid() const; | 52 | bool valid() const; |
117 | 52 | char const* error_message() const; | 53 | char const* error_message() const; |
118 | 53 | 54 | ||
119 | === modified file 'src/client/mir_buffer.h' | |||
120 | --- src/client/mir_buffer.h 2016-05-16 14:45:02 +0000 | |||
121 | +++ src/client/mir_buffer.h 2016-06-24 11:42:58 +0000 | |||
122 | @@ -52,6 +52,7 @@ | |||
123 | 52 | virtual geometry::Size size() const = 0; | 52 | virtual geometry::Size size() const = 0; |
124 | 53 | virtual MirConnection* allocating_connection() const = 0; | 53 | virtual MirConnection* allocating_connection() const = 0; |
125 | 54 | virtual void increment_age() = 0; | 54 | virtual void increment_age() = 0; |
126 | 55 | virtual void set_callback(mir_buffer_callback callback, void* context) = 0; | ||
127 | 55 | protected: | 56 | protected: |
128 | 56 | MirBuffer() = default; | 57 | MirBuffer() = default; |
129 | 57 | MirBuffer(MirBuffer const&) = delete; | 58 | MirBuffer(MirBuffer const&) = delete; |
130 | 58 | 59 | ||
131 | === modified file 'src/client/mir_buffer_api.cpp' | |||
132 | --- src/client/mir_buffer_api.cpp 2016-06-06 11:51:31 +0000 | |||
133 | +++ src/client/mir_buffer_api.cpp 2016-06-24 11:42:58 +0000 | |||
134 | @@ -174,3 +174,16 @@ | |||
135 | 174 | MIR_LOG_UNCAUGHT_EXCEPTION(ex); | 174 | MIR_LOG_UNCAUGHT_EXCEPTION(ex); |
136 | 175 | return mir_buffer_usage_hardware; | 175 | return mir_buffer_usage_hardware; |
137 | 176 | } | 176 | } |
138 | 177 | |||
139 | 178 | void mir_buffer_set_callback( | ||
140 | 179 | MirBuffer* b, mir_buffer_callback available_callback, void* available_context) | ||
141 | 180 | try | ||
142 | 181 | { | ||
143 | 182 | mir::require(b); | ||
144 | 183 | auto buffer = reinterpret_cast<mcl::Buffer*>(b); | ||
145 | 184 | buffer->set_callback(available_callback, available_context); | ||
146 | 185 | } | ||
147 | 186 | catch (std::exception const& ex) | ||
148 | 187 | { | ||
149 | 188 | MIR_LOG_UNCAUGHT_EXCEPTION(ex); | ||
150 | 189 | } | ||
151 | 177 | 190 | ||
152 | === modified file 'src/client/symbols.map' | |||
153 | --- src/client/symbols.map 2016-06-09 17:42:21 +0000 | |||
154 | +++ src/client/symbols.map 2016-06-24 11:42:58 +0000 | |||
155 | @@ -366,6 +366,7 @@ | |||
156 | 366 | mir_buffer_wait_fence; | 366 | mir_buffer_wait_fence; |
157 | 367 | mir_buffer_get_native_buffer; | 367 | mir_buffer_get_native_buffer; |
158 | 368 | mir_buffer_get_graphics_region; | 368 | mir_buffer_get_graphics_region; |
159 | 369 | mir_buffer_set_callback; | ||
160 | 369 | mir_buffer_release; | 370 | mir_buffer_release; |
161 | 370 | mir_connection_create_presentation_chain_sync; | 371 | mir_connection_create_presentation_chain_sync; |
162 | 371 | mir_presentation_chain_is_valid; | 372 | mir_presentation_chain_is_valid; |
163 | 372 | 373 | ||
164 | === modified file 'src/include/client/mir_toolkit/mir_buffer.h' | |||
165 | --- src/include/client/mir_toolkit/mir_buffer.h 2016-06-06 11:51:31 +0000 | |||
166 | +++ src/include/client/mir_toolkit/mir_buffer.h 2016-06-24 11:42:58 +0000 | |||
167 | @@ -50,6 +50,18 @@ | |||
168 | 50 | MirBufferUsage buffer_usage, | 50 | MirBufferUsage buffer_usage, |
169 | 51 | mir_buffer_callback available_callback, void* available_context); | 51 | mir_buffer_callback available_callback, void* available_context); |
170 | 52 | 52 | ||
171 | 53 | /** Reassign the callback that the MirBuffer will call when the buffer is | ||
172 | 54 | * available for use again | ||
173 | 55 | * \param [in] buffer The buffer | ||
174 | 56 | * \param [in] available_callback The callback called when the buffer | ||
175 | 57 | * is available | ||
176 | 58 | * \param [in] available_context The context for the available_callback | ||
177 | 59 | **/ | ||
178 | 60 | |||
179 | 61 | void mir_buffer_set_callback( | ||
180 | 62 | MirBuffer* buffer, | ||
181 | 63 | mir_buffer_callback available_callback, void* available_context); | ||
182 | 64 | |||
183 | 53 | /** @name Fenced Buffer content access functions. | 65 | /** @name Fenced Buffer content access functions. |
184 | 54 | * | 66 | * |
185 | 55 | * These functions will wait until it is safe to access the buffer for the given purpose. | 67 | * These functions will wait until it is safe to access the buffer for the given purpose. |
186 | 56 | 68 | ||
187 | === modified file 'tests/acceptance-tests/throwback/test_presentation_chain.cpp' | |||
188 | --- tests/acceptance-tests/throwback/test_presentation_chain.cpp 2016-06-06 11:51:31 +0000 | |||
189 | +++ tests/acceptance-tests/throwback/test_presentation_chain.cpp 2016-06-24 11:42:58 +0000 | |||
190 | @@ -355,3 +355,41 @@ | |||
191 | 355 | EXPECT_THAT(mir_buffer_get_buffer_usage(buffer), Eq(usage)); | 355 | EXPECT_THAT(mir_buffer_get_buffer_usage(buffer), Eq(usage)); |
192 | 356 | EXPECT_THAT(mir_buffer_get_pixel_format(buffer), Eq(format)); | 356 | EXPECT_THAT(mir_buffer_get_pixel_format(buffer), Eq(format)); |
193 | 357 | } | 357 | } |
194 | 358 | |||
195 | 359 | namespace | ||
196 | 360 | { | ||
197 | 361 | void another_buffer_callback(MirBuffer* buffer, void* context) | ||
198 | 362 | { | ||
199 | 363 | buffer_callback(buffer, context); | ||
200 | 364 | } | ||
201 | 365 | } | ||
202 | 366 | TEST_F(PresentationChain, buffers_callback_can_be_reassigned) | ||
203 | 367 | { | ||
204 | 368 | SurfaceWithChainFromStart surface(connection, size, pf); | ||
205 | 369 | |||
206 | 370 | MirBufferSync second_buffer_context; | ||
207 | 371 | MirBufferSync context; | ||
208 | 372 | MirBufferSync another_context; | ||
209 | 373 | mir_connection_allocate_buffer( | ||
210 | 374 | connection, | ||
211 | 375 | size.width.as_int(), size.height.as_int(), pf, usage, | ||
212 | 376 | buffer_callback, &context); | ||
213 | 377 | mir_connection_allocate_buffer( | ||
214 | 378 | connection, | ||
215 | 379 | size.width.as_int(), size.height.as_int(), pf, usage, | ||
216 | 380 | buffer_callback, &second_buffer_context); | ||
217 | 381 | |||
218 | 382 | ASSERT_TRUE(context.wait_for_buffer(10s)); | ||
219 | 383 | ASSERT_THAT(context.buffer(), Ne(nullptr)); | ||
220 | 384 | ASSERT_TRUE(second_buffer_context.wait_for_buffer(10s)); | ||
221 | 385 | ASSERT_THAT(second_buffer_context.buffer(), Ne(nullptr)); | ||
222 | 386 | |||
223 | 387 | mir_buffer_set_callback(context.buffer(), another_buffer_callback, &another_context); | ||
224 | 388 | |||
225 | 389 | mir_presentation_chain_submit_buffer(surface.chain(), context.buffer()); | ||
226 | 390 | //flush the 1st buffer out | ||
227 | 391 | mir_presentation_chain_submit_buffer(surface.chain(), second_buffer_context.buffer()); | ||
228 | 392 | |||
229 | 393 | ASSERT_TRUE(another_context.wait_for_buffer(10s)); | ||
230 | 394 | ASSERT_THAT(another_context.buffer(), Ne(nullptr)); | ||
231 | 395 | } | ||
232 | 358 | 396 | ||
233 | === modified file 'tests/include/mir/test/doubles/mock_mir_buffer.h' | |||
234 | --- tests/include/mir/test/doubles/mock_mir_buffer.h 2016-05-13 18:55:24 +0000 | |||
235 | +++ tests/include/mir/test/doubles/mock_mir_buffer.h 2016-06-24 11:42:58 +0000 | |||
236 | @@ -55,6 +55,7 @@ | |||
237 | 55 | MOCK_CONST_METHOD0(size, geometry::Size()); | 55 | MOCK_CONST_METHOD0(size, geometry::Size()); |
238 | 56 | MOCK_CONST_METHOD0(allocating_connection, MirConnection*()); | 56 | MOCK_CONST_METHOD0(allocating_connection, MirConnection*()); |
239 | 57 | MOCK_METHOD0(increment_age, void()); | 57 | MOCK_METHOD0(increment_age, void()); |
240 | 58 | MOCK_METHOD2(set_callback, void(mir_buffer_callback callback, void* context)); | ||
241 | 58 | }; | 59 | }; |
242 | 59 | 60 | ||
243 | 60 | using StubMirBuffer = testing::NiceMock<MockMirBuffer>; | 61 | using StubMirBuffer = testing::NiceMock<MockMirBuffer>; |
244 | 61 | 62 | ||
245 | === modified file 'tests/unit-tests/client/test_mir_buffer.cpp' | |||
246 | --- tests/unit-tests/client/test_mir_buffer.cpp 2016-06-06 11:51:31 +0000 | |||
247 | +++ tests/unit-tests/client/test_mir_buffer.cpp 2016-06-24 11:42:58 +0000 | |||
248 | @@ -177,6 +177,24 @@ | |||
249 | 177 | EXPECT_THAT(call_count, Eq(1)); | 177 | EXPECT_THAT(call_count, Eq(1)); |
250 | 178 | } | 178 | } |
251 | 179 | 179 | ||
252 | 180 | TEST_F(MirBufferTest, callback_called_after_change_when_available_from_creation) | ||
253 | 181 | { | ||
254 | 182 | int call_count = 0; | ||
255 | 183 | mcl::Buffer buffer(cb, nullptr, buffer_id, mock_client_buffer, nullptr, usage); | ||
256 | 184 | buffer.set_callback(cb, &call_count); | ||
257 | 185 | buffer.received(); | ||
258 | 186 | EXPECT_THAT(call_count, Eq(1)); | ||
259 | 187 | } | ||
260 | 188 | |||
261 | 189 | TEST_F(MirBufferTest, callback_called_after_change_when_available_from_server_return) | ||
262 | 190 | { | ||
263 | 191 | int call_count = 0; | ||
264 | 192 | mcl::Buffer buffer(cb, nullptr, buffer_id, mock_client_buffer, nullptr, usage); | ||
265 | 193 | buffer.set_callback(cb, &call_count); | ||
266 | 194 | buffer.received(update_message); | ||
267 | 195 | EXPECT_THAT(call_count, Eq(1)); | ||
268 | 196 | } | ||
269 | 197 | |||
270 | 180 | TEST_F(MirBufferTest, updates_package_when_server_returns) | 198 | TEST_F(MirBufferTest, updates_package_when_server_returns) |
271 | 181 | { | 199 | { |
272 | 182 | EXPECT_CALL(*mock_client_buffer, update_from(Ref(update_message))); | 200 | EXPECT_CALL(*mock_client_buffer, update_from(Ref(update_message))); |
LGTM.
Nit : Line #110 (extraneous space) and line #116 (split at the comma) could use better formatting. set_callback(
+/** Reassign the callback that the MirBuffer will call when the buffer is
107 + * available for use again
108 + * \param [in] buffer The buffer
109 + * \param [in] available_callback The callback called when the buffer
110 + * is available
111 + * \param [in] available_context The context for the available_callback
112 + **/
113 +
114 +void mir_buffer_
115 + MirBuffer* buffer,
116 + mir_buffer_callback available_callback, void* available_context);