Mir

Merge lp:~alan-griffiths/mir/fix-1583536-for-0.23.1 into lp:mir

Proposed by Alan Griffiths on 2016-05-20
Status: Superseded
Proposed branch: lp:~alan-griffiths/mir/fix-1583536-for-0.23.1
Merge into: lp:mir
Diff against target: 587 lines (+232/-73) (has conflicts)
15 files modified
debian/changelog (+33/-7)
debian/control (+4/-4)
debian/libmircommon6.install (+1/-1)
debian/libmirserver40.install (+1/-1)
src/client/buffer_vault.cpp (+30/-19)
src/client/buffer_vault.h (+2/-0)
src/common/CMakeLists.txt (+1/-1)
src/server/CMakeLists.txt (+1/-1)
src/server/symbols.map (+1/-1)
tests/acceptance-tests/test_prompt_session_client_api.cpp (+2/-2)
tests/mir_test/CMakeLists.txt (+4/-0)
tests/mir_test_doubles/CMakeLists.txt (+5/-1)
tests/mir_test_framework/CMakeLists.txt (+4/-0)
tests/mirtest.pc.in (+1/-1)
tests/unit-tests/client/test_buffer_vault.cpp (+142/-34)
Text conflict in tests/unit-tests/client/test_buffer_vault.cpp
To merge this branch: bzr merge lp:~alan-griffiths/mir/fix-1583536-for-0.23.1
Reviewer Review Type Date Requested Status
Mir development team 2016-05-20 Pending
Review via email: mp+295290@code.launchpad.net

Commit message

Make the mirtest-dev package useful for downstream projects

Description of the change

Backport fix to mirtest-dev

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2016-05-03 04:36:33 +0000
3+++ debian/changelog 2016-05-20 09:11:49 +0000
4@@ -1,25 +1,51 @@
5-mir (0.23.0) UNRELEASED; urgency=medium
6+mir (0.23.0ubuntu1) UNRELEASED; urgency=medium
7
8+ [ Kevin DuBois ]
9 * New upstream release 0.23.0 (https://launchpad.net/mir/+milestone/0.23.0)
10 - ABI summary:
11 . mirclient ABI unchanged at 9
12- . mirserver ABI unchanged at 39
13- . mircommon ABI unchanged at 5
14+ . mirserver ABI bumped to 40
15+ . mircommon ABI bumped at 6
16 . mirplatform ABI unchanged at 11
17 . mirprotobuf ABI unchanged at 3
18 . mirplatformgraphics ABI unchanged at 9
19 . mirclientplatform ABI unchanged at 5
20 . mirinputplatform ABI unchanged at 5
21 - Enhancements:
22+ . Enable internal usage of more flexible graphics buffer submission,
23+ precursing client API additions.
24 - Bug fixes:
25+ . Potential NBS performance loss after resize (LP: #1579076)
26+ . Performance loss with NBS and overlays on (LP: #1578159)
27 . Mir crashes with useless backtrace when mg::Platform methods throw
28 (LP: #1553549)
29 . Virtual output is not removed when screencast client disappears
30 (LP: #1573572)
31- . Virtual display output configuration is set to LVDS Edit (LP: #1573782)
32- . Resizing can crash mir_demo_server (LP: #1575211)
33-
34- -- Alberto Aguirre <alberto.aguirre@canonical.com> Thu, 28 Apr 2016 09:24:21 -0500
35+ . Can't VT switch from mir_demo_server (any more) (LP: #1576260)
36+ . mir_demo_server(_minimal): Window movement/resizing stops responding
37+ when the cursor leaves the surface, and can lead to windows 1px wide
38+ and unrecoverable. (LP: #1447886)
39+ . Virtual display output configuration is set to LVDS (LP: #1573782)
40+ . Mir-on-X11 doesn't pass Alt+primary button drag to Mir (LP: #1575765)
41+ . Mir-on-X11 breaks mir_proving_server resize logic (LP: #1575192)
42+ . Resizing can crash mir_demo_server (LP: #1575211)
43+ . [regression] Cursor stops at phantom edge on M10 and N7 (LP: 1580774)
44+
45+ -- Kevin DuBois <kevin.dubois@canonical.com> Mon, 09 May 2016 11:59:42 -0400
46+
47+mir (0.22.1+16.04.20160516.2-0ubuntu1) xenial; urgency=medium
48+
49+ [ Andreas Pokorny ]
50+ * New upstream release 0.22.1 (https://launchpad.net/mir/+milestone/0.22.1)
51+ - ABI summary:
52+ . No ABI changes in any libraries. Bugfix release only.
53+ - Bugs fixed:
54+ . [regression] Cursor stops at phantom edge on M10 and N7 (LP: 1580774)
55+
56+ [ CI Train Bot ]
57+ * No-change rebuild.
58+
59+ -- MichaƂ Sawicz <michal.sawicz@canonical.com> Mon, 16 May 2016 15:36:50 +0000
60
61 mir (0.22.0+16.04.20160422.2-0ubuntu1) xenial; urgency=medium
62
63
64=== modified file 'debian/control'
65--- debian/control 2016-05-20 07:19:12 +0000
66+++ debian/control 2016-05-20 09:11:49 +0000
67@@ -68,7 +68,7 @@
68
69 #TODO: Packaging infrastructure for better dependency generation,
70 # ala pkg-xorg's xviddriver:Provides and ABI detection.
71-Package: libmirserver39
72+Package: libmirserver40
73 Section: libs
74 Architecture: linux-any
75 Multi-Arch: same
76@@ -100,7 +100,7 @@
77 Architecture: linux-any
78 Multi-Arch: same
79 Pre-Depends: ${misc:Pre-Depends}
80-Depends: libmircommon5 (= ${binary:Version}),
81+Depends: libmircommon6 (= ${binary:Version}),
82 libprotobuf-dev (>= 2.4.1),
83 libxkbcommon-dev,
84 ${misc:Depends},
85@@ -134,7 +134,7 @@
86 Architecture: linux-any
87 Multi-Arch: same
88 Pre-Depends: ${misc:Pre-Depends}
89-Depends: libmirserver39 (= ${binary:Version}),
90+Depends: libmirserver40 (= ${binary:Version}),
91 libmirplatform-dev (= ${binary:Version}),
92 libmircommon-dev (= ${binary:Version}),
93 libglm-dev,
94@@ -288,7 +288,7 @@
95 .
96 Contains a tool for checking the graphics components of android devices.
97
98-Package: libmircommon5
99+Package: libmircommon6
100 Section: libs
101 Architecture: linux-any
102 Multi-Arch: same
103
104=== renamed file 'debian/libmircommon5.install' => 'debian/libmircommon6.install'
105--- debian/libmircommon5.install 2015-06-17 05:20:42 +0000
106+++ debian/libmircommon6.install 2016-05-20 09:11:49 +0000
107@@ -1,1 +1,1 @@
108-usr/lib/*/libmircommon.so.5
109+usr/lib/*/libmircommon.so.6
110
111=== renamed file 'debian/libmirserver39.install' => 'debian/libmirserver40.install'
112--- debian/libmirserver39.install 2016-03-29 07:30:50 +0000
113+++ debian/libmirserver40.install 2016-05-20 09:11:49 +0000
114@@ -1,1 +1,1 @@
115-usr/lib/*/libmirserver.so.39
116+usr/lib/*/libmirserver.so.40
117
118=== modified file 'src/client/buffer_vault.cpp'
119--- src/client/buffer_vault.cpp 2016-05-09 14:27:58 +0000
120+++ src/client/buffer_vault.cpp 2016-05-20 09:11:49 +0000
121@@ -122,7 +122,7 @@
122
123 mcl::NoTLSFuture<std::shared_ptr<mcl::Buffer>> mcl::BufferVault::withdraw()
124 {
125- std::lock_guard<std::mutex> lk(mutex);
126+ std::unique_lock<std::mutex> lk(mutex);
127 if (disconnected_)
128 BOOST_THROW_EXCEPTION(std::logic_error("server_disconnected"));
129 mcl::NoTLSPromise<std::shared_ptr<mcl::Buffer>> promise;
130@@ -146,6 +146,15 @@
131 else
132 {
133 promises.emplace_back(std::move(promise));
134+
135+ auto s = size;
136+ bool allocate_buffer = (current_buffer_count < needed_buffer_count);
137+ if (allocate_buffer)
138+ current_buffer_count++;
139+ lk.unlock();
140+
141+ if (allocate_buffer)
142+ alloc_buffer(s, format, usage);
143 }
144 return future;
145 }
146@@ -198,12 +207,12 @@
147 {
148 auto id = it->first;
149 buffers.erase(it);
150- lk.unlock();
151-
152- free_buffer(id);
153 if (should_decrease_count)
154 current_buffer_count--;
155- else
156+ lk.unlock();
157+
158+ free_buffer(id);
159+ if (!should_decrease_count)
160 alloc_buffer(size, format, usage);
161 return;
162 }
163@@ -221,15 +230,6 @@
164 }
165 }
166
167-//TODO: the server will currently spam us with a lot of resize messages at once,
168-// and we want to delay the IPC transactions for resize. If we could rate-limit
169-// the incoming messages, we should should consolidate the scale and size functions
170-void mcl::BufferVault::set_size(geom::Size sz)
171-{
172- std::lock_guard<std::mutex> lk(mutex);
173- size = sz;
174-}
175-
176 void mcl::BufferVault::disconnected()
177 {
178 std::lock_guard<std::mutex> lk(mutex);
179@@ -239,17 +239,28 @@
180
181 void mcl::BufferVault::set_scale(float scale)
182 {
183+ std::unique_lock<std::mutex> lk(mutex);
184+ set_size(lk, size * scale);
185+}
186+
187+void mcl::BufferVault::set_size(geom::Size new_size)
188+{
189+ std::unique_lock<std::mutex> lk(mutex);
190+ set_size(lk, new_size);
191+}
192+
193+void mcl::BufferVault::set_size(std::unique_lock<std::mutex>& lk, geometry::Size new_size)
194+{
195+ if (new_size == size)
196+ return;
197 std::vector<int> free_ids;
198- std::unique_lock<std::mutex> lk(mutex);
199- auto new_size = size * scale;
200- if (new_size == size)
201- return;
202 size = new_size;
203 for (auto it = buffers.begin(); it != buffers.end();)
204 {
205 auto buffer = checked_buffer_from_map(it->first);
206 if ((it->second == Owner::Self) && (buffer->size() != size))
207 {
208+ current_buffer_count--;
209 free_ids.push_back(it->first);
210 it = buffers.erase(it);
211 }
212@@ -261,7 +272,7 @@
213 lk.unlock();
214
215 for(auto& id : free_ids)
216- realloc_buffer(id, new_size, format, usage);
217+ free_buffer(id);
218 }
219
220 void mcl::BufferVault::increase_buffer_count()
221
222=== modified file 'src/client/buffer_vault.h'
223--- src/client/buffer_vault.h 2016-05-09 14:27:58 +0000
224+++ src/client/buffer_vault.h 2016-05-20 09:11:49 +0000
225@@ -78,6 +78,8 @@
226 void alloc_buffer(geometry::Size size, MirPixelFormat format, int usage);
227 void free_buffer(int free_id);
228 void realloc_buffer(int free_id, geometry::Size size, MirPixelFormat format, int usage);
229+ void set_size(std::unique_lock<std::mutex>& lk, geometry::Size new_size);
230+
231 std::shared_ptr<Buffer> checked_buffer_from_map(int id);
232
233 std::shared_ptr<ClientBufferFactory> const platform_factory;
234
235=== modified file 'src/common/CMakeLists.txt'
236--- src/common/CMakeLists.txt 2016-03-30 08:59:35 +0000
237+++ src/common/CMakeLists.txt 2016-05-20 09:11:49 +0000
238@@ -36,7 +36,7 @@
239 PARENT_SCOPE)
240
241 # TODO we need a place to manage ABI and related versioning but use this as placeholder
242-set(MIRCOMMON_ABI 5)
243+set(MIRCOMMON_ABI 6)
244 set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols.map)
245
246 mir_add_library_with_symbols(mircommon SHARED
247
248=== modified file 'src/server/CMakeLists.txt'
249--- src/server/CMakeLists.txt 2016-05-12 07:35:07 +0000
250+++ src/server/CMakeLists.txt 2016-05-20 09:11:49 +0000
251@@ -125,7 +125,7 @@
252 ${CMAKE_SOURCE_DIR}/include/server/mir DESTINATION "include/mirserver"
253 )
254
255-set(MIRSERVER_ABI 39) # Be sure to increment MIR_VERSION_MINOR at the same time
256+set(MIRSERVER_ABI 40) # Be sure to increment MIR_VERSION_MINOR at the same time
257 set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols.map)
258
259 set_target_properties(
260
261=== modified file 'src/server/symbols.map'
262--- src/server/symbols.map 2016-05-03 04:36:33 +0000
263+++ src/server/symbols.map 2016-05-20 09:11:49 +0000
264@@ -1,4 +1,4 @@
265-MIR_SERVER_0.22 {
266+MIR_SERVER_0.23 {
267 global:
268 extern "C++" {
269 # Symbols not yet picked up by script
270
271=== modified file 'tests/acceptance-tests/test_prompt_session_client_api.cpp'
272--- tests/acceptance-tests/test_prompt_session_client_api.cpp 2016-03-29 07:30:50 +0000
273+++ tests/acceptance-tests/test_prompt_session_client_api.cpp 2016-05-20 09:11:49 +0000
274@@ -383,7 +383,7 @@
275 mir_prompt_session_release_sync(prompt_session);
276 }
277
278-TEST_F(PromptSessionClientAPI, client_pid_is_associated_with_session)
279+TEST_F(PromptSessionClientAPI, DISABLED_client_pid_is_associated_with_session)
280 {
281 connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
282
283@@ -624,7 +624,7 @@
284 #ifndef TEST
285 int main()
286 #else
287-TEST(LP, 1540731)
288+TEST(LP, DISABLED_1540731)
289 #endif
290 {
291 enum { server, client, size };
292
293=== modified file 'tests/integration-tests/test_buffer_scheduling.cpp'
294=== modified file 'tests/mir_test/CMakeLists.txt'
295--- tests/mir_test/CMakeLists.txt 2015-06-23 16:08:35 +0000
296+++ tests/mir_test/CMakeLists.txt 2016-05-20 09:11:49 +0000
297@@ -1,3 +1,7 @@
298+# We don't want LTO objects in a published archive (libmir-test-assist.a)
299+string (REPLACE " -flto " " " CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
300+string (REPLACE " -flto " " " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
301+
302 add_library(mir-public-test OBJECT
303 cross_process_action.cpp
304 cross_process_sync.cpp
305
306=== modified file 'tests/mir_test_doubles/CMakeLists.txt'
307--- tests/mir_test_doubles/CMakeLists.txt 2016-05-04 09:06:26 +0000
308+++ tests/mir_test_doubles/CMakeLists.txt 2016-05-20 09:11:49 +0000
309@@ -16,7 +16,6 @@
310 mock_input_device.cpp
311 mock_frame_dropping_policy_factory.cpp
312 mock_timer.cpp
313- stub_buffer.cpp
314 test_protobuf_client.cpp
315 test_protobuf_socket_server.cpp
316 triggered_main_loop.cpp
317@@ -71,11 +70,16 @@
318 )
319 endif()
320
321+# We don't want LTO objects in a published archive (libmir-test-assist.a)
322+string (REPLACE " -flto " " " CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
323+string (REPLACE " -flto " " " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
324+
325 add_library(mir-public-test-doubles OBJECT
326 nested_mock_egl.cpp
327 null_logger.cpp
328 stub_display_configuration.cpp ${CMAKE_SOURCE_DIR}/include/test/mir/test/doubles/stub_display_configuration.h
329 fake_display.cpp ${CMAKE_SOURCE_DIR}/include/test/mir/test/doubles/fake_display.h
330+ stub_buffer.cpp
331 )
332
333 add_library(mir-test-doubles-static STATIC
334
335=== modified file 'tests/mir_test_framework/CMakeLists.txt'
336--- tests/mir_test_framework/CMakeLists.txt 2016-03-29 07:30:50 +0000
337+++ tests/mir_test_framework/CMakeLists.txt 2016-05-20 09:11:49 +0000
338@@ -21,6 +21,10 @@
339 -DMIR_BUILD_PREFIX="${CMAKE_BINARY_DIR}"
340 )
341
342+# We don't want LTO objects in a published archive (libmir-test-assist.a)
343+string (REPLACE " -flto " " " CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
344+string (REPLACE " -flto " " " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
345+
346 add_library(mir-public-test-framework OBJECT
347 any_surface.cpp
348 async_server_runner.cpp
349
350=== modified file 'tests/mirtest.pc.in'
351--- tests/mirtest.pc.in 2015-06-25 16:47:02 +0000
352+++ tests/mirtest.pc.in 2016-05-20 09:11:49 +0000
353@@ -6,5 +6,5 @@
354 Description: Mir test assist library
355 Version: @MIR_VERSION@
356 Requires: mirserver mirplatform mirclient
357-Libs: -L@LIBDIR@ -lmir-test-assist
358+Libs: -L@LIBDIR@ -lmir-test-assist -ldl
359 Cflags: -I@INCLUDEDIR@
360
361=== modified file 'tests/unit-tests/client/test_buffer_vault.cpp'
362--- tests/unit-tests/client/test_buffer_vault.cpp 2016-05-09 14:27:58 +0000
363+++ tests/unit-tests/client/test_buffer_vault.cpp 2016-05-20 09:11:49 +0000
364@@ -326,6 +326,8 @@
365
366 TEST_F(StartedBufferVault, reallocates_incoming_buffers_of_incorrect_size_with_immediate_response)
367 {
368+ vault.set_size(new_size);
369+
370 EXPECT_CALL(mock_requests, free_buffer(package.buffer_id()));
371 EXPECT_CALL(mock_requests, allocate_buffer(new_size,_,_))
372 .WillOnce(Invoke(
373@@ -334,17 +336,17 @@
374 vault.wire_transfer_inbound(package4.buffer_id());
375 }));
376
377- vault.set_size(new_size);
378 vault.wire_transfer_inbound(package.buffer_id());
379 Mock::VerifyAndClearExpectations(&mock_requests);
380 }
381
382 TEST_F(StartedBufferVault, reallocates_incoming_buffers_of_incorrect_size_with_delayed_response)
383 {
384+ vault.set_size(new_size);
385+
386 EXPECT_CALL(mock_requests, free_buffer(package.buffer_id()));
387 EXPECT_CALL(mock_requests, allocate_buffer(new_size,_,_));
388
389- vault.set_size(new_size);
390 vault.wire_transfer_inbound(package.buffer_id());
391 vault.wire_transfer_inbound(package4.buffer_id());
392 EXPECT_THAT(vault.withdraw().get()->size(), Eq(new_size));
393@@ -361,9 +363,9 @@
394 Mock::VerifyAndClearExpectations(&mock_requests);
395 }
396
397-TEST_F(StartedBufferVault, simply_setting_size_triggers_no_server_interations)
398+TEST_F(StartedBufferVault, setting_size_frees_unneeded_buffers_right_away)
399 {
400- EXPECT_CALL(mock_requests, free_buffer(_)).Times(0);
401+ EXPECT_CALL(mock_requests, free_buffer(_)).Times(3);
402 EXPECT_CALL(mock_requests, allocate_buffer(_,_,_)).Times(0);
403 auto const cycles = 30u;
404 geom::Size new_size(80, 100);
405@@ -450,21 +452,14 @@
406 EXPECT_CALL(mock_requests, free_buffer(_))
407 .Times(initial_nbuffers);
408
409- auto buffer = vault.withdraw().get();
410 vault.set_scale(scale);
411- vault.deposit(buffer);
412- vault.wire_transfer_outbound(buffer);
413- vault.wire_transfer_inbound(package.buffer_id());
414
415- for(auto i = 0; i < 100; i++)
416+ for(auto i = 0u; i < initial_nbuffers; i++)
417 {
418 auto b = vault.withdraw().get();
419- EXPECT_THAT(b->size(), Eq(new_size));
420 vault.deposit(b);
421- b->received();
422- vault.wire_transfer_outbound(b);
423- vault.wire_transfer_inbound(buffers[(i+1)%3].buffer_id());
424 }
425+
426 Mock::VerifyAndClearExpectations(&mock_requests);
427 }
428
429@@ -554,24 +549,137 @@
430 vault.wire_transfer_inbound(package2.buffer_id());
431 Mock::VerifyAndClearExpectations(&mock_requests);
432 }
433-
434-//LP: #1578159
435-TEST_F(StartedBufferVault, prefers_buffers_returned_further_in_the_past)
436-{
437- auto buffer = vault.withdraw().get();
438- vault.deposit(buffer);
439- vault.wire_transfer_outbound(buffer);
440- auto first_id = buffer->rpc_id();
441-
442- buffer = vault.withdraw().get();
443- vault.deposit(buffer);
444- vault.wire_transfer_outbound(buffer);
445- auto second_id = buffer->rpc_id();
446-
447- vault.wire_transfer_inbound(second_id);
448- vault.wire_transfer_inbound(first_id);
449-
450- EXPECT_THAT(vault.withdraw().get()->rpc_id(), Ne(first_id));
451-
452-
453-}
454+<<<<<<< TREE
455+
456+//LP: #1578159
457+TEST_F(StartedBufferVault, prefers_buffers_returned_further_in_the_past)
458+{
459+ auto buffer = vault.withdraw().get();
460+ vault.deposit(buffer);
461+ vault.wire_transfer_outbound(buffer);
462+ auto first_id = buffer->rpc_id();
463+
464+ buffer = vault.withdraw().get();
465+ vault.deposit(buffer);
466+ vault.wire_transfer_outbound(buffer);
467+ auto second_id = buffer->rpc_id();
468+
469+ vault.wire_transfer_inbound(second_id);
470+ vault.wire_transfer_inbound(first_id);
471+
472+ EXPECT_THAT(vault.withdraw().get()->rpc_id(), Ne(first_id));
473+
474+
475+}
476+=======
477+
478+//LP: #1578159
479+TEST_F(StartedBufferVault, prefers_buffers_returned_further_in_the_past)
480+{
481+ auto buffer = vault.withdraw().get();
482+ vault.deposit(buffer);
483+ vault.wire_transfer_outbound(buffer);
484+ auto first_id = buffer->rpc_id();
485+
486+ buffer = vault.withdraw().get();
487+ vault.deposit(buffer);
488+ vault.wire_transfer_outbound(buffer);
489+ auto second_id = buffer->rpc_id();
490+
491+ vault.wire_transfer_inbound(second_id);
492+ vault.wire_transfer_inbound(first_id);
493+
494+ EXPECT_THAT(vault.withdraw().get()->rpc_id(), Ne(first_id));
495+}
496+
497+//LP: #1579076
498+TEST_F(StartedBufferVault, doesnt_let_buffers_stagnate_after_resize)
499+{
500+ EXPECT_CALL(mock_requests, free_buffer(_))
501+ .Times(3);
502+ vault.set_size(new_size);
503+
504+ EXPECT_CALL(mock_requests, allocate_buffer(new_size,_,_))
505+ .Times(1);
506+ auto buffer_future = vault.withdraw();
507+ vault.wire_transfer_inbound(package4.buffer_id());
508+ EXPECT_THAT(buffer_future.get()->size(), Eq(new_size));
509+ Mock::VerifyAndClearExpectations(&mock_requests);
510+}
511+
512+TEST_F(StartedBufferVault, doesnt_free_buffers_in_the_driver_after_resize)
513+{
514+ EXPECT_CALL(mock_requests, free_buffer(_))
515+ .Times(2);
516+ auto buffer = vault.withdraw().get();
517+ vault.set_size(new_size);
518+ Mock::VerifyAndClearExpectations(&mock_requests);
519+
520+ vault.deposit(buffer);
521+ vault.wire_transfer_outbound(buffer);
522+
523+ EXPECT_CALL(mock_requests, free_buffer(_))
524+ .Times(1);
525+ vault.wire_transfer_inbound(buffer->rpc_id());
526+ Mock::VerifyAndClearExpectations(&mock_requests);
527+}
528+
529+TEST_F(StartedBufferVault, doesnt_free_buffers_with_content_after_resize)
530+{
531+ EXPECT_CALL(mock_requests, free_buffer(_))
532+ .Times(2);
533+ auto buffer = vault.withdraw().get();
534+ vault.deposit(buffer);
535+ vault.set_size(new_size);
536+ Mock::VerifyAndClearExpectations(&mock_requests);
537+
538+ vault.wire_transfer_outbound(buffer);
539+ EXPECT_CALL(mock_requests, free_buffer(_))
540+ .Times(1);
541+ vault.wire_transfer_inbound(buffer->rpc_id());
542+ Mock::VerifyAndClearExpectations(&mock_requests);
543+}
544+
545+TEST_F(StartedBufferVault, doesnt_free_buffers_if_size_is_the_same)
546+{
547+ EXPECT_CALL(mock_requests, free_buffer(_))
548+ .Times(0);
549+ vault.set_size(size);
550+ Mock::VerifyAndClearExpectations(&mock_requests);
551+}
552+
553+TEST_F(StartedBufferVault, delays_allocation_if_not_needed)
554+{
555+ vault.set_size(new_size);
556+
557+ EXPECT_CALL(mock_requests, allocate_buffer(new_size,_,_))
558+ .Times(1)
559+ .WillOnce(Invoke(
560+ [&, this](geom::Size, MirPixelFormat, int)
561+ {
562+ vault.wire_transfer_inbound(package4.buffer_id());
563+ }));
564+
565+ for(auto i = 0u; i < 10u; i++)
566+ {
567+ auto buffer = vault.withdraw().get();
568+ vault.deposit(buffer);
569+ buffer->received();
570+ vault.wire_transfer_outbound(buffer);
571+ vault.wire_transfer_inbound(buffer->rpc_id());
572+ }
573+}
574+
575+TEST_F(StartedBufferVault, can_increase_count_after_resize)
576+{
577+ auto num_allocations = 4u;
578+ EXPECT_CALL(mock_requests, allocate_buffer(_,_,_))
579+ .Times(num_allocations);
580+
581+ vault.increase_buffer_count();
582+ vault.set_size(new_size);
583+
584+ for(auto i = 0u; i < num_allocations + 1; i++)
585+ vault.withdraw();
586+}
587+>>>>>>> MERGE-SOURCE

Subscribers

People subscribed via source and target branches