Merge lp:~raof/mir/buffer-age-misc-cleanups into lp:~mir-team/mir/trunk
- buffer-age-misc-cleanups
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Alan Griffiths |
Approved revision: | no longer in the source branch. |
Merged at revision: | 536 |
Proposed branch: | lp:~raof/mir/buffer-age-misc-cleanups |
Merge into: | lp:~mir-team/mir/trunk |
Diff against target: |
549 lines (+156/-58) 14 files modified
src/client/android/android_client_buffer_factory.cpp (+2/-2) src/client/android/android_client_buffer_factory.h (+2/-2) src/client/client_buffer_depository.cpp (+2/-2) src/client/client_buffer_depository.h (+2/-2) src/client/client_buffer_factory.h (+7/-1) src/client/client_platform.h (+1/-1) src/client/gbm/gbm_client_buffer_factory.cpp (+1/-1) src/client/gbm/gbm_client_buffer_factory.h (+1/-1) src/client/gbm/gbm_client_platform.h (+1/-1) src/client/mir_connection.cpp (+1/-2) src/client/mir_surface.cpp (+4/-4) src/client/mir_surface.h (+3/-3) tests/unit-tests/client/test_client_buffer_depository.cpp (+22/-15) tests/unit-tests/client/test_client_mir_surface.cpp (+107/-21) |
To merge this branch: | bzr merge lp:~raof/mir/buffer-age-misc-cleanups |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexandros Frantzis (community) | Approve | ||
Alan Griffiths | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+155164@code.launchpad.net |
Commit message
Miscellaneous cleanups left over from non-blocking merge reviews of
lp:~raof/mir/client-side-buffer-age.
Description of the change
Miscellaneous cleanups left over from non-blocking merge reviews of
lp:~raof/mir/client-side-buffer-age.
PS Jenkins bot (ps-jenkins) wrote : | # |
Alan Griffiths (alan-griffiths) wrote : | # |
180 - buffer_
181 logger(logger)
182 {
183 + buffer_depository = std::make_
184 +
Use initializers where possible. Vis:
buffer_
~~~~
in test_client_
226 +#include <cstring>
227 +
Is anything from this header used?
~~~~
$ bin/unit-tests --gtest_
66
Robert Carr (robertcarr) wrote : | # |
Looks good to me besides Alan's comments.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:503
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Chris Halse Rogers (raof) wrote : | # |
> in test_client_
>
>226 +#include <cstring>
>227 +
>
>Is anything from this header used?
Yes - memcmp, for the BufferPackageMa
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:504
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Alexandros Frantzis (afrantzis) wrote : | # |
Looks good.
Preview Diff
1 | === modified file 'src/client/android/android_client_buffer_factory.cpp' |
2 | --- src/client/android/android_client_buffer_factory.cpp 2013-03-20 06:14:48 +0000 |
3 | +++ src/client/android/android_client_buffer_factory.cpp 2013-03-26 09:39:22 +0000 |
4 | @@ -24,12 +24,12 @@ |
5 | namespace mcla=mir::client::android; |
6 | namespace geom=mir::geometry; |
7 | |
8 | -mcla::AndroidClientBufferFactory::AndroidClientBufferFactory(std::shared_ptr<AndroidRegistrar> const &buffer_registrar) |
9 | +mcla::AndroidClientBufferFactory::AndroidClientBufferFactory(std::shared_ptr<AndroidRegistrar> const& buffer_registrar) |
10 | : registrar(buffer_registrar) |
11 | { |
12 | } |
13 | |
14 | -std::shared_ptr<mcl::ClientBuffer> mcla::AndroidClientBufferFactory::create_buffer(std::shared_ptr<mir_toolkit::MirBufferPackage> const & package, geom::Size size, geom::PixelFormat pf) |
15 | +std::shared_ptr<mcl::ClientBuffer> mcla::AndroidClientBufferFactory::create_buffer(std::shared_ptr<mir_toolkit::MirBufferPackage> const& package, geom::Size size, geom::PixelFormat pf) |
16 | { |
17 | return std::make_shared<mcla::AndroidClientBuffer>(registrar, package, size, pf); |
18 | } |
19 | |
20 | === modified file 'src/client/android/android_client_buffer_factory.h' |
21 | --- src/client/android/android_client_buffer_factory.h 2013-03-20 06:14:48 +0000 |
22 | +++ src/client/android/android_client_buffer_factory.h 2013-03-26 09:39:22 +0000 |
23 | @@ -41,9 +41,9 @@ |
24 | class AndroidClientBufferFactory : public ClientBufferFactory |
25 | { |
26 | public: |
27 | - explicit AndroidClientBufferFactory(std::shared_ptr<AndroidRegistrar> const &); |
28 | + explicit AndroidClientBufferFactory(std::shared_ptr<AndroidRegistrar> const&); |
29 | |
30 | - virtual std::shared_ptr<ClientBuffer> create_buffer(std::shared_ptr<mir_toolkit::MirBufferPackage> const & package, |
31 | + virtual std::shared_ptr<ClientBuffer> create_buffer(std::shared_ptr<mir_toolkit::MirBufferPackage> const& package, |
32 | geometry::Size size, geometry::PixelFormat pf); |
33 | private: |
34 | std::shared_ptr<AndroidRegistrar> registrar; |
35 | |
36 | === modified file 'src/client/client_buffer_depository.cpp' |
37 | --- src/client/client_buffer_depository.cpp 2013-03-18 05:58:51 +0000 |
38 | +++ src/client/client_buffer_depository.cpp 2013-03-26 09:39:22 +0000 |
39 | @@ -27,14 +27,14 @@ |
40 | |
41 | namespace mcl=mir::client; |
42 | |
43 | -mcl::ClientBufferDepository::ClientBufferDepository(std::shared_ptr<ClientBufferFactory> const &factory, int max_buffers) |
44 | +mcl::ClientBufferDepository::ClientBufferDepository(std::shared_ptr<ClientBufferFactory> const& factory, int max_buffers) |
45 | : factory(factory), |
46 | current_buffer_iter(buffers.end()), |
47 | max_age(max_buffers - 1) |
48 | { |
49 | } |
50 | |
51 | -void mcl::ClientBufferDepository::deposit_package(std::shared_ptr<mir_toolkit::MirBufferPackage> const & package, int id, geometry::Size size, geometry::PixelFormat pf) |
52 | +void mcl::ClientBufferDepository::deposit_package(std::shared_ptr<mir_toolkit::MirBufferPackage> const& package, int id, geometry::Size size, geometry::PixelFormat pf) |
53 | { |
54 | for (auto next = buffers.begin(); next != buffers.end();) |
55 | { |
56 | |
57 | === modified file 'src/client/client_buffer_depository.h' |
58 | --- src/client/client_buffer_depository.h 2013-03-24 23:33:49 +0000 |
59 | +++ src/client/client_buffer_depository.h 2013-03-26 09:39:22 +0000 |
60 | @@ -47,13 +47,13 @@ |
61 | class ClientBufferDepository |
62 | { |
63 | public: |
64 | - ClientBufferDepository(std::shared_ptr<ClientBufferFactory> const &factory, int max_buffers); |
65 | + ClientBufferDepository(std::shared_ptr<ClientBufferFactory> const& factory, int max_buffers); |
66 | |
67 | /// Construct a ClientBuffer from the IPC data, and use it as the current buffer. |
68 | |
69 | /// This also marks the previous current buffer (if any) as being submitted to the server. |
70 | /// \post current_buffer() will return a ClientBuffer constructed from this IPC data. |
71 | - void deposit_package(std::shared_ptr<mir_toolkit::MirBufferPackage> const &, int id, |
72 | + void deposit_package(std::shared_ptr<mir_toolkit::MirBufferPackage> const&, int id, |
73 | geometry::Size, geometry::PixelFormat); |
74 | std::shared_ptr<ClientBuffer> current_buffer(); |
75 | |
76 | |
77 | === modified file 'src/client/client_buffer_factory.h' |
78 | --- src/client/client_buffer_factory.h 2013-03-20 06:14:48 +0000 |
79 | +++ src/client/client_buffer_factory.h 2013-03-26 09:39:22 +0000 |
80 | @@ -35,8 +35,14 @@ |
81 | class ClientBufferFactory |
82 | { |
83 | public: |
84 | - virtual std::shared_ptr<ClientBuffer> create_buffer(std::shared_ptr<mir_toolkit::MirBufferPackage> const & package, |
85 | + virtual std::shared_ptr<ClientBuffer> create_buffer(std::shared_ptr<mir_toolkit::MirBufferPackage> const& package, |
86 | geometry::Size size, geometry::PixelFormat pf) = 0; |
87 | + |
88 | +protected: |
89 | + ClientBufferFactory() = default; |
90 | + ClientBufferFactory(ClientBufferFactory const &) = delete; |
91 | + ClientBufferFactory &operator=(ClientBufferFactory const &) = delete; |
92 | + virtual ~ClientBufferFactory() {} |
93 | }; |
94 | |
95 | } |
96 | |
97 | === modified file 'src/client/client_platform.h' |
98 | --- src/client/client_platform.h 2013-03-24 23:33:49 +0000 |
99 | +++ src/client/client_platform.h 2013-03-26 09:39:22 +0000 |
100 | @@ -36,7 +36,7 @@ |
101 | ClientPlatform(const ClientPlatform& p) = delete; |
102 | ClientPlatform& operator=(const ClientPlatform& p) = delete; |
103 | |
104 | - virtual std::shared_ptr<ClientBufferFactory> create_buffer_factory () = 0; |
105 | + virtual std::shared_ptr<ClientBufferFactory> create_buffer_factory() = 0; |
106 | virtual std::shared_ptr<EGLNativeWindowType> create_egl_native_window(ClientSurface *surface) = 0; |
107 | virtual std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() = 0; |
108 | }; |
109 | |
110 | === modified file 'src/client/gbm/gbm_client_buffer_factory.cpp' |
111 | --- src/client/gbm/gbm_client_buffer_factory.cpp 2013-03-20 23:50:00 +0000 |
112 | +++ src/client/gbm/gbm_client_buffer_factory.cpp 2013-03-26 09:39:22 +0000 |
113 | @@ -29,7 +29,7 @@ |
114 | { |
115 | } |
116 | |
117 | -std::shared_ptr<mcl::ClientBuffer> mclg::GBMClientBufferFactory::create_buffer(std::shared_ptr<mir_toolkit::MirBufferPackage> const & package, geometry::Size size, geometry::PixelFormat pf) |
118 | +std::shared_ptr<mcl::ClientBuffer> mclg::GBMClientBufferFactory::create_buffer(std::shared_ptr<mir_toolkit::MirBufferPackage> const& package, geometry::Size size, geometry::PixelFormat pf) |
119 | { |
120 | return std::make_shared<mclg::GBMClientBuffer>(drm_fd_handler, package, size, pf); |
121 | } |
122 | |
123 | === modified file 'src/client/gbm/gbm_client_buffer_factory.h' |
124 | --- src/client/gbm/gbm_client_buffer_factory.h 2013-03-20 23:50:00 +0000 |
125 | +++ src/client/gbm/gbm_client_buffer_factory.h 2013-03-26 09:39:22 +0000 |
126 | @@ -39,7 +39,7 @@ |
127 | public: |
128 | explicit GBMClientBufferFactory(std::shared_ptr<DRMFDHandler> const& drm_fd_handler); |
129 | |
130 | - std::shared_ptr<ClientBuffer> create_buffer(std::shared_ptr<mir_toolkit::MirBufferPackage> const & package, |
131 | + std::shared_ptr<ClientBuffer> create_buffer(std::shared_ptr<mir_toolkit::MirBufferPackage> const& package, |
132 | geometry::Size size, geometry::PixelFormat pf); |
133 | private: |
134 | std::shared_ptr<DRMFDHandler> drm_fd_handler; |
135 | |
136 | === modified file 'src/client/gbm/gbm_client_platform.h' |
137 | --- src/client/gbm/gbm_client_platform.h 2013-03-24 23:33:49 +0000 |
138 | +++ src/client/gbm/gbm_client_platform.h 2013-03-26 09:39:22 +0000 |
139 | @@ -39,7 +39,7 @@ |
140 | std::shared_ptr<DRMFDHandler> const& drm_fd_handler, |
141 | EGLNativeDisplayContainer& display_container); |
142 | |
143 | - std::shared_ptr<ClientBufferFactory> create_buffer_factory (); |
144 | + std::shared_ptr<ClientBufferFactory> create_buffer_factory(); |
145 | std::shared_ptr<EGLNativeWindowType> create_egl_native_window(ClientSurface *surface); |
146 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display(); |
147 | |
148 | |
149 | === modified file 'src/client/mir_connection.cpp' |
150 | --- src/client/mir_connection.cpp 2013-03-24 23:33:49 +0000 |
151 | +++ src/client/mir_connection.cpp 2013-03-26 09:39:22 +0000 |
152 | @@ -66,9 +66,8 @@ |
153 | mir_surface_lifecycle_callback callback, |
154 | void * context) |
155 | { |
156 | - auto depository = std::make_shared<mir::client::ClientBufferDepository>(platform->create_buffer_factory(), 3); |
157 | auto null_log = std::make_shared<mir::client::NullLogger>(); |
158 | - auto surface = new MirSurface(this, server, null_log, depository, params, callback, context); |
159 | + auto surface = new MirSurface(this, server, null_log, platform->create_buffer_factory(), params, callback, context); |
160 | return surface->get_create_wait_handle(); |
161 | } |
162 | |
163 | |
164 | === modified file 'src/client/mir_surface.cpp' |
165 | --- src/client/mir_surface.cpp 2013-03-24 23:33:49 +0000 |
166 | +++ src/client/mir_surface.cpp 2013-03-26 09:39:22 +0000 |
167 | @@ -32,13 +32,13 @@ |
168 | mir_toolkit::MirSurface::MirSurface( |
169 | MirConnection *allocating_connection, |
170 | mp::DisplayServer::Stub & server, |
171 | - const std::shared_ptr<mir::client::Logger>& logger, |
172 | - const std::shared_ptr<mcl::ClientBufferDepository>& depository, |
173 | - MirSurfaceParameters const & params, |
174 | + std::shared_ptr<mir::client::Logger> const& logger, |
175 | + std::shared_ptr<mcl::ClientBufferFactory> const& factory, |
176 | + MirSurfaceParameters const& params, |
177 | mir_surface_lifecycle_callback callback, void * context) |
178 | : server(server), |
179 | connection(allocating_connection), |
180 | - buffer_depository(depository), |
181 | + buffer_depository(std::make_shared<mcl::ClientBufferDepository>(factory, 3)), |
182 | logger(logger) |
183 | { |
184 | mir::protobuf::SurfaceParameters message; |
185 | |
186 | === modified file 'src/client/mir_surface.h' |
187 | --- src/client/mir_surface.h 2013-03-24 23:33:49 +0000 |
188 | +++ src/client/mir_surface.h 2013-03-26 09:39:22 +0000 |
189 | @@ -49,9 +49,9 @@ |
190 | MirSurface( |
191 | MirConnection *allocating_connection, |
192 | mir::protobuf::DisplayServer::Stub & server, |
193 | - const std::shared_ptr<mir::client::Logger>& logger, |
194 | - const std::shared_ptr<mir::client::ClientBufferDepository>& depository, |
195 | - MirSurfaceParameters const & params, |
196 | + std::shared_ptr<mir::client::Logger> const& logger, |
197 | + std::shared_ptr<mir::client::ClientBufferFactory> const& buffer_factory, |
198 | + MirSurfaceParameters const& params, |
199 | mir_surface_lifecycle_callback callback, void * context); |
200 | |
201 | ~MirSurface(); |
202 | |
203 | === modified file 'tests/unit-tests/client/test_client_buffer_depository.cpp' |
204 | --- tests/unit-tests/client/test_client_buffer_depository.cpp 2013-03-21 07:54:30 +0000 |
205 | +++ tests/unit-tests/client/test_client_buffer_depository.cpp 2013-03-26 09:39:22 +0000 |
206 | @@ -36,6 +36,9 @@ |
207 | using namespace testing; |
208 | ON_CALL(*this, mark_as_submitted()) |
209 | .WillByDefault(Invoke([this](){this->AgingBuffer::mark_as_submitted();})); |
210 | + |
211 | + // By default we expect all buffers to be destroyed. |
212 | + EXPECT_CALL(*this, Destroy()).Times(1); |
213 | } |
214 | |
215 | MOCK_METHOD0(Destroy, void()); |
216 | @@ -67,7 +70,7 @@ |
217 | } |
218 | |
219 | MOCK_METHOD3(create_buffer, |
220 | - std::shared_ptr<mcl::ClientBuffer>(std::shared_ptr<MirBufferPackage> const &, |
221 | + std::shared_ptr<mcl::ClientBuffer>(std::shared_ptr<MirBufferPackage> const&, |
222 | geom::Size, geom::PixelFormat)); |
223 | |
224 | std::shared_ptr<mcl::ClientBuffer> buffer; |
225 | @@ -265,19 +268,23 @@ |
226 | depository.deposit_package(packages[0], 1, size, pf); |
227 | // Raw pointer so we don't influence the buffer's life-cycle |
228 | MockBuffer *first_buffer = static_cast<MockBuffer *>(depository.current_buffer().get()); |
229 | + // We expect this to not be destroyed before we deposit the fourth buffer. |
230 | + bool buffer_destroyed = false; |
231 | + ON_CALL(*first_buffer, Destroy()).WillByDefault(Invoke([&buffer_destroyed] () {buffer_destroyed = true;})); |
232 | + |
233 | |
234 | depository.deposit_package(packages[1], 2, size, pf); |
235 | depository.deposit_package(packages[2], 3, size, pf); |
236 | |
237 | // We've deposited three different buffers now; the fourth should trigger the destruction |
238 | // of the first buffer. |
239 | - EXPECT_CALL(*first_buffer, Destroy()); |
240 | + ASSERT_FALSE(buffer_destroyed); |
241 | |
242 | depository.deposit_package(packages[3], 4, size, pf); |
243 | |
244 | // Explicitly verify that the buffer has been destroyed here, before the depository goes out of scope |
245 | // and its destructor cleans everything up. |
246 | - Mock::VerifyAndClearExpectations(first_buffer); |
247 | + EXPECT_TRUE(buffer_destroyed); |
248 | } |
249 | |
250 | TEST_F(MirBufferDepositoryTest, depositing_packages_implicitly_submits_current_buffer) |
251 | @@ -300,33 +307,33 @@ |
252 | using namespace testing; |
253 | std::shared_ptr<mcl::ClientBufferDepository> depository; |
254 | std::shared_ptr<MirBufferPackage> packages[10]; |
255 | - MockBuffer *buffers[10]; |
256 | + bool buffer_destroyed[10]; |
257 | |
258 | for (int num_buffers = 2; num_buffers < 10; ++num_buffers) |
259 | { |
260 | depository = std::make_shared<mcl::ClientBufferDepository>(mock_factory, num_buffers); |
261 | - |
262 | - depository->deposit_package(packages[0], 1, size, pf); |
263 | - // Raw pointer so we don't influence the buffer's life-cycle |
264 | - MockBuffer* first_buffer = static_cast<MockBuffer *>(depository->current_buffer().get()); |
265 | + |
266 | + // Reset destroyed tracking; resetting the depository will have destroyed all the buffers |
267 | + for (bool& destroyed_flag : buffer_destroyed) |
268 | + destroyed_flag = false; |
269 | |
270 | int i; |
271 | - for (i = 1; i < num_buffers ; ++i) |
272 | + for (i = 0; i < num_buffers ; ++i) |
273 | { |
274 | + MockBuffer *buffer; |
275 | depository->deposit_package(packages[i], i + 1, size, pf); |
276 | - buffers[i] = static_cast<MockBuffer *>(depository->current_buffer().get()); |
277 | - // None of these buffers should be destroyed |
278 | - EXPECT_CALL(*buffers[i], Destroy()).Times(0); |
279 | + buffer = static_cast<MockBuffer *>(depository->current_buffer().get()); |
280 | + ON_CALL(*buffer, Destroy()).WillByDefault(Invoke([&buffer_destroyed, i] () {buffer_destroyed[i] = true;})); |
281 | } |
282 | |
283 | // Next deposit should destroy first buffer |
284 | - EXPECT_CALL(*first_buffer, Destroy()).Times(1); |
285 | + ASSERT_FALSE(buffer_destroyed[0]); |
286 | depository->deposit_package(packages[i], i+1, size, pf); |
287 | - EXPECT_TRUE(Mock::VerifyAndClearExpectations(first_buffer)); |
288 | + EXPECT_TRUE(buffer_destroyed[0]); |
289 | |
290 | // Verify none of the other buffers have been destroyed |
291 | for (i = 1; i < num_buffers; ++i) |
292 | - EXPECT_TRUE(Mock::VerifyAndClearExpectations(buffers[i])); |
293 | + EXPECT_FALSE(buffer_destroyed[i]); |
294 | } |
295 | } |
296 | |
297 | |
298 | === modified file 'tests/unit-tests/client/test_client_mir_surface.cpp' |
299 | --- tests/unit-tests/client/test_client_mir_surface.cpp 2013-03-24 23:33:49 +0000 |
300 | +++ tests/unit-tests/client/test_client_mir_surface.cpp 2013-03-26 09:39:22 +0000 |
301 | @@ -33,6 +33,8 @@ |
302 | #include "mir_test/test_protobuf_client.h" |
303 | #include "mir_test/gmock_fixes.h" |
304 | |
305 | +#include <cstring> |
306 | + |
307 | #include <gtest/gtest.h> |
308 | #include <gmock/gmock.h> |
309 | |
310 | @@ -84,11 +86,11 @@ |
311 | int num_fd = 2, num_data = 8; |
312 | for (auto i=0; i<num_fd; i++) |
313 | { |
314 | - server_package.fd[i] = i*3; |
315 | + server_package.fd[i] = global_buffer_id * i; |
316 | } |
317 | for (auto i=0; i<num_data; i++) |
318 | { |
319 | - server_package.data[i] = i*2; |
320 | + server_package.data[i] = (global_buffer_id + i) * 2; |
321 | } |
322 | server_package.stride = 66; |
323 | } |
324 | @@ -134,9 +136,14 @@ |
325 | |
326 | struct MockBuffer : public mcl::ClientBuffer |
327 | { |
328 | - MockBuffer() |
329 | + explicit MockBuffer(std::shared_ptr<MirBufferPackage> const& contents) |
330 | { |
331 | + using namespace testing; |
332 | |
333 | + auto buffer_package = std::make_shared<MirBufferPackage>(); |
334 | + *buffer_package = *contents; |
335 | + ON_CALL(*this, get_buffer_package()) |
336 | + .WillByDefault(Return(buffer_package)); |
337 | } |
338 | |
339 | MOCK_METHOD0(secure_for_cpu_write, std::shared_ptr<mcl::MemoryRegion>()); |
340 | @@ -156,15 +163,20 @@ |
341 | { |
342 | using namespace testing; |
343 | |
344 | - emptybuffer=std::make_shared<NiceMock<MockBuffer>>(); |
345 | + emptybuffer=std::make_shared<NiceMock<MockBuffer>>(std::make_shared<MirBufferPackage>()); |
346 | + |
347 | ON_CALL(*this, create_buffer(_,_,_)) |
348 | - .WillByDefault(Return(emptybuffer)); |
349 | + .WillByDefault(DoAll(SaveArg<0>(¤t_package), |
350 | + InvokeWithoutArgs([this] () {this->current_buffer = std::make_shared<NiceMock<MockBuffer>>(current_package);}), |
351 | + ReturnPointee(¤t_buffer))); |
352 | } |
353 | |
354 | MOCK_METHOD3(create_buffer, |
355 | - std::shared_ptr<mcl::ClientBuffer>(std::shared_ptr<MirBufferPackage> const &, |
356 | + std::shared_ptr<mcl::ClientBuffer>(std::shared_ptr<MirBufferPackage> const&, |
357 | geom::Size, geom::PixelFormat)); |
358 | |
359 | + std::shared_ptr<MirBufferPackage> current_package; |
360 | + std::shared_ptr<mcl::ClientBuffer> current_buffer; |
361 | std::shared_ptr<mcl::ClientBuffer> emptybuffer; |
362 | }; |
363 | |
364 | @@ -219,7 +231,6 @@ |
365 | test_server->comm->start(); |
366 | |
367 | mock_buffer_factory = std::make_shared<mt::MockClientBufferFactory>(); |
368 | - depository = std::make_shared<mcl::ClientBufferDepository>(mock_buffer_factory, 3); |
369 | |
370 | params = MirSurfaceParameters{"test", 33, 45, mir_pixel_format_abgr_8888, |
371 | mir_buffer_usage_hardware}; |
372 | @@ -250,7 +261,6 @@ |
373 | |
374 | MirSurfaceParameters params; |
375 | std::shared_ptr<mt::MockClientBufferFactory> mock_buffer_factory; |
376 | - std::shared_ptr<mcl::ClientBufferDepository> depository; |
377 | |
378 | mir::protobuf::Connection response; |
379 | mir::protobuf::ConnectParameters connect_parameters; |
380 | @@ -272,7 +282,13 @@ |
381 | EXPECT_CALL(*mock_buffer_factory, create_buffer(_,_,_)) |
382 | .Times(1); |
383 | |
384 | - auto surface = std::make_shared<MirSurface> (connection.get(), *client_comm_channel, logger, depository, params, &empty_callback, (void*) NULL); |
385 | + auto surface = std::make_shared<MirSurface> (connection.get(), |
386 | + *client_comm_channel, |
387 | + logger, |
388 | + mock_buffer_factory, |
389 | + params, |
390 | + &empty_callback, |
391 | + nullptr); |
392 | |
393 | auto wait_handle = surface->get_create_wait_handle(); |
394 | wait_handle->wait_for_result(); |
395 | @@ -290,7 +306,13 @@ |
396 | EXPECT_CALL(*mock_buffer_factory, create_buffer(_,_,_)) |
397 | .Times(1); |
398 | |
399 | - auto surface = std::make_shared<MirSurface> (connection.get(), *client_comm_channel, logger, depository, params, &empty_callback, (void*) NULL); |
400 | + auto surface = std::make_shared<MirSurface> (connection.get(), |
401 | + *client_comm_channel, |
402 | + logger, |
403 | + mock_buffer_factory, |
404 | + params, |
405 | + &empty_callback, |
406 | + nullptr); |
407 | |
408 | auto wait_handle = surface->get_create_wait_handle(); |
409 | wait_handle->wait_for_result(); |
410 | @@ -301,6 +323,22 @@ |
411 | buffer_wait_handle->wait_for_result(); |
412 | } |
413 | |
414 | +MATCHER_P(BufferPackageMatches, package, "") |
415 | +{ |
416 | + // Can't simply use memcmp() on the whole struct because age is not sent over the wire |
417 | + if (package.data_items != arg.data_items) |
418 | + return false; |
419 | + if (package.fd_items != arg.fd_items) |
420 | + return false; |
421 | + if (memcmp(package.data, arg.data, sizeof(package.data[0]) * package.data_items)) |
422 | + return false; |
423 | + if (memcmp(package.fd, arg.fd, sizeof(package.fd[0]) * package.fd_items)) |
424 | + return false; |
425 | + if (package.stride != arg.stride) |
426 | + return false; |
427 | + return true; |
428 | +} |
429 | + |
430 | TEST_F(MirClientSurfaceTest, client_buffer_uses_ipc_message_from_server_on_create) |
431 | { |
432 | using namespace testing; |
433 | @@ -311,16 +349,18 @@ |
434 | .WillOnce(DoAll(SaveArg<0>(&submitted_package), |
435 | Return(mock_buffer_factory->emptybuffer))); |
436 | |
437 | - auto surface = std::make_shared<MirSurface> (connection.get(), *client_comm_channel, logger, depository, params, &empty_callback, (void*) NULL); |
438 | + auto surface = std::make_shared<MirSurface> (connection.get(), |
439 | + *client_comm_channel, |
440 | + logger, |
441 | + mock_buffer_factory, |
442 | + params, |
443 | + &empty_callback, |
444 | + nullptr); |
445 | auto wait_handle = surface->get_create_wait_handle(); |
446 | wait_handle->wait_for_result(); |
447 | |
448 | /* check for same contents */ |
449 | - ASSERT_EQ(submitted_package->data_items, mock_server_tool->server_package.data_items); |
450 | - ASSERT_EQ(submitted_package->fd_items, mock_server_tool->server_package.fd_items); |
451 | - ASSERT_EQ(submitted_package->stride, mock_server_tool->server_package.stride); |
452 | - for (auto i=0; i< submitted_package->data_items; i++) |
453 | - EXPECT_EQ(submitted_package->data[i], mock_server_tool->server_package.data[i]); |
454 | + EXPECT_THAT(*submitted_package, BufferPackageMatches(mock_server_tool->server_package)); |
455 | } |
456 | |
457 | TEST_F(MirClientSurfaceTest, message_width_used_in_buffer_creation ) |
458 | @@ -335,7 +375,13 @@ |
459 | .WillOnce(DoAll(SaveArg<1>(&sz), |
460 | Return(mock_buffer_factory->emptybuffer))); |
461 | |
462 | - auto surface = std::make_shared<MirSurface> (connection.get(), *client_comm_channel, logger, depository, params, &empty_callback, (void*) NULL); |
463 | + auto surface = std::make_shared<MirSurface> (connection.get(), |
464 | + *client_comm_channel, |
465 | + logger, |
466 | + mock_buffer_factory, |
467 | + params, |
468 | + &empty_callback, |
469 | + nullptr); |
470 | auto wait_handle = surface->get_create_wait_handle(); |
471 | wait_handle->wait_for_result(); |
472 | |
473 | @@ -354,7 +400,13 @@ |
474 | .WillOnce(DoAll(SaveArg<1>(&sz), |
475 | Return(mock_buffer_factory->emptybuffer))); |
476 | |
477 | - auto surface = std::make_shared<MirSurface> (connection.get(), *client_comm_channel, logger, depository, params, &empty_callback, (void*) NULL); |
478 | + auto surface = std::make_shared<MirSurface> (connection.get(), |
479 | + *client_comm_channel, |
480 | + logger, |
481 | + mock_buffer_factory, |
482 | + params, |
483 | + &empty_callback, |
484 | + nullptr); |
485 | auto wait_handle = surface->get_create_wait_handle(); |
486 | wait_handle->wait_for_result(); |
487 | |
488 | @@ -373,13 +425,47 @@ |
489 | .WillOnce(DoAll(SaveArg<2>(&pf), |
490 | Return(mock_buffer_factory->emptybuffer))); |
491 | |
492 | - auto surface = std::make_shared<MirSurface> (connection.get(), *client_comm_channel, logger, depository, params, &empty_callback, (void*) NULL); |
493 | + auto surface = std::make_shared<MirSurface> (connection.get(), |
494 | + *client_comm_channel, |
495 | + logger, |
496 | + mock_buffer_factory, |
497 | + params, |
498 | + &empty_callback, |
499 | + nullptr); |
500 | + |
501 | auto wait_handle = surface->get_create_wait_handle(); |
502 | wait_handle->wait_for_result(); |
503 | |
504 | EXPECT_EQ(pf, geom::PixelFormat::abgr_8888); |
505 | } |
506 | |
507 | +TEST_F(MirClientSurfaceTest, get_buffer_returns_last_received_buffer_package) |
508 | +{ |
509 | + using namespace testing; |
510 | + |
511 | + EXPECT_CALL(*mock_buffer_factory, create_buffer(_,_,_)) |
512 | + .Times(1); |
513 | + |
514 | + auto surface = std::make_shared<MirSurface> (connection.get(), |
515 | + *client_comm_channel, |
516 | + logger, |
517 | + mock_buffer_factory, |
518 | + params, |
519 | + &empty_callback, |
520 | + nullptr); |
521 | + auto wait_handle = surface->get_create_wait_handle(); |
522 | + wait_handle->wait_for_result(); |
523 | + |
524 | + EXPECT_THAT(*surface->get_current_buffer_package(), BufferPackageMatches(mock_server_tool->server_package)); |
525 | + |
526 | + EXPECT_CALL(*mock_buffer_factory, create_buffer(_,_,_)) |
527 | + .Times(1); |
528 | + auto buffer_wait_handle = surface->next_buffer(&empty_surface_callback, nullptr); |
529 | + buffer_wait_handle->wait_for_result(); |
530 | + |
531 | + EXPECT_THAT(*surface->get_current_buffer_package(), BufferPackageMatches(mock_server_tool->server_package)); |
532 | +} |
533 | + |
534 | TEST_F(MirClientSurfaceTest, default_surface_type) |
535 | { |
536 | using namespace testing; |
537 | @@ -391,10 +477,10 @@ |
538 | auto surface = std::make_shared<MirSurface> (connection.get(), |
539 | *client_comm_channel, |
540 | logger, |
541 | - depository, |
542 | + mock_buffer_factory, |
543 | params, |
544 | &empty_callback, |
545 | - (void*) NULL); |
546 | + nullptr); |
547 | surface->get_create_wait_handle()->wait_for_result(); |
548 | |
549 | EXPECT_EQ(mir_surface_type_normal, |
PASSED: Continuous integration, rev:501 jenkins. qa.ubuntu. com/job/ mir-ci/ 189/ jenkins. qa.ubuntu. com/job/ mir-android- raring- i386-build/ 119 jenkins. qa.ubuntu. com/job/ mir-quantal- amd64-ci/ 190 jenkins. qa.ubuntu. com/job/ mir-quantal- amd64-ci/ 190/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ mir-ci/ 189/rebuild
http://