Merge lp:~alan-griffiths/mir/refactor-shell-cleaner-Surface-class into lp:~mir-team/mir/trunk
- refactor-shell-cleaner-Surface-class
- Merge into trunk
Proposed by
Alan Griffiths
Status: | Merged |
---|---|
Approved by: | Robert Ancell |
Approved revision: | no longer in the source branch. |
Merged at revision: | 510 |
Proposed branch: | lp:~alan-griffiths/mir/refactor-shell-cleaner-Surface-class |
Merge into: | lp:~mir-team/mir/trunk |
Diff against target: |
1067 lines (+343/-205) 19 files modified
include/server/mir/default_server_configuration.h (+7/-2) include/server/mir/shell/surface_builder.h (+48/-0) include/server/mir/shell/surface_factory.h (+1/-2) include/server/mir/shell/surface_source.h (+11/-16) include/server/mir/surfaces/surface_controller.h (+48/-0) include/server/mir/surfaces/surface_stack.h (+3/-1) src/server/default_server_configuration.cpp (+13/-2) src/server/shell/CMakeLists.txt (+1/-1) src/server/shell/application_session.cpp (+2/-3) src/server/shell/surface.cpp (+11/-17) src/server/shell/surface.h (+7/-14) src/server/shell/surface_source.cpp (+11/-10) src/server/surfaces/CMakeLists.txt (+1/-0) src/server/surfaces/surface_controller.cpp (+37/-0) tests/integration-tests/frontend/test_session_manager.cpp (+0/-2) tests/unit-tests/shell/test_session_manager.cpp (+33/-15) tests/unit-tests/shell/test_surface.cpp (+97/-89) tests/unit-tests/surfaces/CMakeLists.txt (+1/-0) tests/unit-tests/surfaces/test_surface_controller.cpp (+11/-31) |
To merge this branch: | bzr merge lp:~alan-griffiths/mir/refactor-shell-cleaner-Surface-class |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Ancell | Approve | ||
Robert Carr (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+153851@code.launchpad.net |
Commit message
shell: clean up the dodgy Surface class that resulted from ProxySurface
Description of the change
shell: clean up the dodgy Surface class that resulted from ProxySurface
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Needs Fixing
(continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:513
http://
Executed test runs:
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
review:
Approve
(continuous-integration)
Revision history for this message
Robert Ancell (robert-ancell) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'include/server/mir/default_server_configuration.h' |
2 | --- include/server/mir/default_server_configuration.h 2013-03-15 22:34:53 +0000 |
3 | +++ include/server/mir/default_server_configuration.h 2013-03-18 15:53:36 +0000 |
4 | @@ -48,13 +48,15 @@ |
5 | { |
6 | class SessionManager; |
7 | class SurfaceFactory; |
8 | -class SurfaceController; |
9 | +class SurfaceSource; |
10 | +class SurfaceBuilder; |
11 | } |
12 | namespace surfaces |
13 | { |
14 | class BufferBundleFactory; |
15 | class SurfaceStackModel; |
16 | class SurfaceStack; |
17 | +class SurfaceController; |
18 | } |
19 | namespace graphics |
20 | { |
21 | @@ -108,6 +110,8 @@ |
22 | virtual std::initializer_list<std::shared_ptr<input::EventFilter> const> the_event_filters(); |
23 | virtual std::shared_ptr<input::InputManager> the_input_manager(); |
24 | |
25 | + virtual std::shared_ptr<shell::SurfaceBuilder> the_surface_builder(); |
26 | + |
27 | protected: |
28 | virtual std::shared_ptr<options::Option> the_options() const; |
29 | virtual std::shared_ptr<input::InputChannelFactory> the_input_channel_factory(); |
30 | @@ -126,10 +130,11 @@ |
31 | CachedPtr<graphics::Renderer> renderer; |
32 | CachedPtr<compositor::BufferBundleManager> buffer_bundle_manager; |
33 | CachedPtr<surfaces::SurfaceStack> surface_stack; |
34 | - CachedPtr<shell::SurfaceController> surface_controller; |
35 | + CachedPtr<shell::SurfaceSource> surface_source; |
36 | CachedPtr<compositor::Compositor> compositor; |
37 | CachedPtr<logging::Logger> logger; |
38 | CachedPtr<graphics::DisplayReport> display_report; |
39 | + CachedPtr<surfaces::SurfaceController> surface_controller; |
40 | |
41 | private: |
42 | std::shared_ptr<options::Option> options; |
43 | |
44 | === added file 'include/server/mir/shell/surface_builder.h' |
45 | --- include/server/mir/shell/surface_builder.h 1970-01-01 00:00:00 +0000 |
46 | +++ include/server/mir/shell/surface_builder.h 2013-03-18 15:53:36 +0000 |
47 | @@ -0,0 +1,48 @@ |
48 | +/* |
49 | + * Copyright © 2013 Canonical Ltd. |
50 | + * |
51 | + * This program is free software: you can redistribute it and/or modify it |
52 | + * under the terms of the GNU Lesser General Public License version 3, |
53 | + * as published by the Free Software Foundation. |
54 | + * |
55 | + * This program is distributed in the hope that it will be useful, |
56 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
57 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
58 | + * GNU General Public License for more details. |
59 | + * |
60 | + * You should have received a copy of the GNU Lesser General Public License |
61 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
62 | + * |
63 | + * Authored by: Alan Griffiths <alan@octopull.co.uk> |
64 | + */ |
65 | + |
66 | + |
67 | +#ifndef MIR_SHELL_SURFACE_BUILDER_H_ |
68 | +#define MIR_SHELL_SURFACE_BUILDER_H_ |
69 | + |
70 | +#include <memory> |
71 | + |
72 | +namespace mir |
73 | +{ |
74 | +namespace frontend { class SurfaceCreationParameters; } |
75 | +namespace surfaces { class Surface; } |
76 | + |
77 | +namespace shell |
78 | +{ |
79 | +class SurfaceBuilder |
80 | +{ |
81 | +public: |
82 | + virtual std::weak_ptr<surfaces::Surface> create_surface(frontend::SurfaceCreationParameters const& params) = 0; |
83 | + |
84 | + virtual void destroy_surface(std::weak_ptr<surfaces::Surface> const& surface) = 0; |
85 | +protected: |
86 | + SurfaceBuilder() = default; |
87 | + virtual ~SurfaceBuilder() {} // should be "= default;" but that causes "noexcept" spread |
88 | + SurfaceBuilder(SurfaceBuilder const&) = delete; |
89 | + SurfaceBuilder& operator=(SurfaceBuilder const&) = delete; |
90 | +}; |
91 | +} |
92 | +} |
93 | + |
94 | + |
95 | +#endif /* MIR_SHELL_SURFACE_BUILDER_H_ */ |
96 | |
97 | === modified file 'include/server/mir/shell/surface_factory.h' |
98 | --- include/server/mir/shell/surface_factory.h 2013-03-14 12:48:20 +0000 |
99 | +++ include/server/mir/shell/surface_factory.h 2013-03-18 15:53:36 +0000 |
100 | @@ -34,11 +34,10 @@ |
101 | class SurfaceFactory |
102 | { |
103 | public: |
104 | - virtual ~SurfaceFactory() {} |
105 | - |
106 | virtual std::shared_ptr<frontend::Surface> create_surface(const frontend::SurfaceCreationParameters& params) = 0; |
107 | |
108 | protected: |
109 | + virtual ~SurfaceFactory() {} |
110 | SurfaceFactory() = default; |
111 | SurfaceFactory(const SurfaceFactory&) = delete; |
112 | SurfaceFactory& operator=(const SurfaceFactory&) = delete; |
113 | |
114 | === renamed file 'include/server/mir/shell/surface_controller.h' => 'include/server/mir/shell/surface_source.h' |
115 | --- include/server/mir/shell/surface_controller.h 2013-03-15 22:34:53 +0000 |
116 | +++ include/server/mir/shell/surface_source.h 2013-03-18 15:53:36 +0000 |
117 | @@ -16,8 +16,8 @@ |
118 | * Authored by: Thomas Voss <thomas.voss@canonical.com> |
119 | */ |
120 | |
121 | -#ifndef MIR_SHELL_SURFACE_CONTROLLER_H_ |
122 | -#define MIR_SHELL_SURFACE_CONTROLLER_H_ |
123 | +#ifndef MIR_SHELL_SURFACE_SOURCE_H_ |
124 | +#define MIR_SHELL_SURFACE_SOURCE_H_ |
125 | |
126 | #include "mir/shell/surface_factory.h" |
127 | |
128 | @@ -30,33 +30,28 @@ |
129 | class InputChannelFactory; |
130 | } |
131 | |
132 | -/// Management of Surface objects. Includes the model (SurfaceStack and Surface |
133 | -/// classes) and controller (SurfaceController) elements of an MVC design. |
134 | -namespace surfaces |
135 | -{ |
136 | -class SurfaceStackModel; |
137 | -} |
138 | - |
139 | namespace shell |
140 | { |
141 | -class SurfaceController : public SurfaceFactory |
142 | +class SurfaceBuilder; |
143 | + |
144 | +class SurfaceSource : public SurfaceFactory |
145 | { |
146 | public: |
147 | - explicit SurfaceController(std::shared_ptr<surfaces::SurfaceStackModel> const& surface_stack, std::shared_ptr<input::InputChannelFactory> const& input_factory); |
148 | - virtual ~SurfaceController() {} |
149 | + explicit SurfaceSource(std::shared_ptr<SurfaceBuilder> const& surface_builder, std::shared_ptr<input::InputChannelFactory> const& input_factory); |
150 | + virtual ~SurfaceSource() {} |
151 | |
152 | std::shared_ptr<frontend::Surface> create_surface(const frontend::SurfaceCreationParameters& params); |
153 | |
154 | protected: |
155 | - SurfaceController(const SurfaceController&) = delete; |
156 | - SurfaceController& operator=(const SurfaceController&) = delete; |
157 | + SurfaceSource(const SurfaceSource&) = delete; |
158 | + SurfaceSource& operator=(const SurfaceSource&) = delete; |
159 | |
160 | private: |
161 | - std::shared_ptr<surfaces::SurfaceStackModel> const surface_stack; |
162 | + std::shared_ptr<SurfaceBuilder> const surface_builder; |
163 | std::shared_ptr<input::InputChannelFactory> const input_factory; |
164 | }; |
165 | |
166 | } |
167 | } |
168 | |
169 | -#endif // MIR_SHELL_SURFACE_CONTROLLER_H_ |
170 | +#endif // MIR_SHELL_SURFACE_SOURCE_H_ |
171 | |
172 | === added file 'include/server/mir/surfaces/surface_controller.h' |
173 | --- include/server/mir/surfaces/surface_controller.h 1970-01-01 00:00:00 +0000 |
174 | +++ include/server/mir/surfaces/surface_controller.h 2013-03-18 15:53:36 +0000 |
175 | @@ -0,0 +1,48 @@ |
176 | +/* |
177 | + * Copyright © 2013 Canonical Ltd. |
178 | + * |
179 | + * This program is free software: you can redistribute it and/or modify it |
180 | + * under the terms of the GNU Lesser General Public License version 3, |
181 | + * as published by the Free Software Foundation. |
182 | + * |
183 | + * This program is distributed in the hope that it will be useful, |
184 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
185 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
186 | + * GNU General Public License for more details. |
187 | + * |
188 | + * You should have received a copy of the GNU Lesser General Public License |
189 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
190 | + * |
191 | + * Authored by: Alan Griffiths <alan@octopull.co.uk> |
192 | + */ |
193 | + |
194 | + |
195 | +#ifndef MIR_SURFACES_SURFACE_CONTROLLER_H_ |
196 | +#define MIR_SURFACES_SURFACE_CONTROLLER_H_ |
197 | + |
198 | +#include "mir/shell/surface_builder.h" |
199 | + |
200 | +namespace mir |
201 | +{ |
202 | +namespace surfaces |
203 | +{ |
204 | +class SurfaceStackModel; |
205 | + |
206 | +/// Will grow up to provide synchronization of model updates |
207 | +class SurfaceController : public shell::SurfaceBuilder |
208 | +{ |
209 | +public: |
210 | + explicit SurfaceController(std::shared_ptr<SurfaceStackModel> const& surface_stack); |
211 | + |
212 | + virtual std::weak_ptr<Surface> create_surface(frontend::SurfaceCreationParameters const& params); |
213 | + |
214 | + virtual void destroy_surface(std::weak_ptr<Surface> const& surface); |
215 | +protected: |
216 | + std::shared_ptr<SurfaceStackModel> const surface_stack; |
217 | +}; |
218 | + |
219 | +} |
220 | +} |
221 | + |
222 | + |
223 | +#endif /* MIR_SURFACES_SURFACE_CONTROLLER_H_ */ |
224 | |
225 | === modified file 'include/server/mir/surfaces/surface_stack.h' |
226 | --- include/server/mir/surfaces/surface_stack.h 2013-03-14 12:48:20 +0000 |
227 | +++ include/server/mir/surfaces/surface_stack.h 2013-03-18 15:53:36 +0000 |
228 | @@ -40,6 +40,8 @@ |
229 | class SurfaceCreationParameters; |
230 | } |
231 | |
232 | +/// Management of Surface objects. Includes the model (SurfaceStack and Surface |
233 | +/// classes) and controller (SurfaceController) elements of an MVC design. |
234 | namespace surfaces |
235 | { |
236 | class BufferBundleFactory; |
237 | @@ -49,7 +51,7 @@ |
238 | { |
239 | public: |
240 | explicit SurfaceStack(std::shared_ptr<BufferBundleFactory> const& bb_factory); |
241 | - virtual ~SurfaceStack() {} |
242 | + virtual ~SurfaceStack() = default; |
243 | |
244 | // From RenderView |
245 | virtual void for_each_if(compositor::FilterForRenderables &filter, compositor::OperatorForRenderables &renderable_operator); |
246 | |
247 | === modified file 'src/server/default_server_configuration.cpp' |
248 | --- src/server/default_server_configuration.cpp 2013-03-15 22:34:53 +0000 |
249 | +++ src/server/default_server_configuration.cpp 2013-03-18 15:53:36 +0000 |
250 | @@ -45,8 +45,9 @@ |
251 | #include "mir/logging/dumb_console_logger.h" |
252 | #include "mir/logging/session_mediator_report.h" |
253 | #include "mir/logging/display_report.h" |
254 | -#include "mir/shell/surface_controller.h" |
255 | +#include "mir/shell/surface_source.h" |
256 | #include "mir/surfaces/surface_stack.h" |
257 | +#include "mir/surfaces/surface_controller.h" |
258 | |
259 | namespace mc = mir::compositor; |
260 | namespace geom = mir::geometry; |
261 | @@ -326,10 +327,20 @@ |
262 | std::shared_ptr<msh::SurfaceFactory> |
263 | mir::DefaultServerConfiguration::the_surface_factory() |
264 | { |
265 | + return surface_source( |
266 | + [this]() |
267 | + { |
268 | + return std::make_shared<msh::SurfaceSource>(the_surface_builder(), the_input_channel_factory()); |
269 | + }); |
270 | +} |
271 | + |
272 | +std::shared_ptr<msh::SurfaceBuilder> |
273 | +mir::DefaultServerConfiguration::the_surface_builder() |
274 | +{ |
275 | return surface_controller( |
276 | [this]() |
277 | { |
278 | - return std::make_shared<msh::SurfaceController>(the_surface_stack_model(), the_input_channel_factory()); |
279 | + return std::make_shared<ms::SurfaceController>(the_surface_stack_model()); |
280 | }); |
281 | } |
282 | |
283 | |
284 | === modified file 'src/server/shell/CMakeLists.txt' |
285 | --- src/server/shell/CMakeLists.txt 2013-03-14 18:09:51 +0000 |
286 | +++ src/server/shell/CMakeLists.txt 2013-03-18 15:53:36 +0000 |
287 | @@ -8,7 +8,7 @@ |
288 | single_visibility_focus_mechanism.cpp |
289 | consuming_placement_strategy.cpp |
290 | organising_surface_factory.cpp |
291 | - surface_controller.cpp |
292 | + surface_source.cpp |
293 | surface.cpp |
294 | ) |
295 | |
296 | |
297 | === modified file 'src/server/shell/application_session.cpp' |
298 | --- src/server/shell/application_session.cpp 2013-03-14 17:45:38 +0000 |
299 | +++ src/server/shell/application_session.cpp 2013-03-18 15:53:36 +0000 |
300 | @@ -19,7 +19,7 @@ |
301 | #include "mir/shell/application_session.h" |
302 | #include "mir/frontend/surface.h" |
303 | |
304 | -#include "mir/shell/surface_controller.h" |
305 | +#include "mir/shell/surface_factory.h" |
306 | |
307 | #include <boost/throw_exception.hpp> |
308 | |
309 | @@ -30,10 +30,9 @@ |
310 | |
311 | namespace mf = mir::frontend; |
312 | namespace msh = mir::shell; |
313 | -namespace ms = mir::surfaces; |
314 | |
315 | msh::ApplicationSession::ApplicationSession( |
316 | - std::shared_ptr<msh::SurfaceFactory> const& surface_factory, |
317 | + std::shared_ptr<SurfaceFactory> const& surface_factory, |
318 | std::string const& session_name) : |
319 | surface_factory(surface_factory), |
320 | session_name(session_name), |
321 | |
322 | === modified file 'src/server/shell/surface.cpp' |
323 | --- src/server/shell/surface.cpp 2013-03-15 22:34:53 +0000 |
324 | +++ src/server/shell/surface.cpp 2013-03-18 15:53:36 +0000 |
325 | @@ -18,7 +18,7 @@ |
326 | |
327 | #include "surface.h" |
328 | |
329 | -#include "mir/surfaces/surface_stack_model.h" |
330 | +#include "mir/shell/surface_builder.h" |
331 | #include "mir/input/input_channel.h" |
332 | |
333 | #include <boost/throw_exception.hpp> |
334 | @@ -29,28 +29,22 @@ |
335 | namespace mc = mir::compositor; |
336 | namespace mi = mir::input; |
337 | |
338 | -msh::Surface::Surface(std::weak_ptr<mir::surfaces::Surface> const& surface, |
339 | - std::shared_ptr<input::InputChannel> const& input_channel) |
340 | - : surface(surface), |
341 | - input_channel(input_channel), |
342 | - deleter([](std::weak_ptr<mir::surfaces::Surface> const&){}) |
343 | -{ |
344 | -} |
345 | - |
346 | msh::Surface::Surface( |
347 | - std::weak_ptr<mir::surfaces::Surface> const& surface, |
348 | - std::shared_ptr<input::InputChannel> const& input_channel, |
349 | - std::function<void(std::weak_ptr<mir::surfaces::Surface> const&)> const& deleter) |
350 | -: |
351 | - surface(surface), |
352 | + std::shared_ptr<SurfaceBuilder> const& builder, |
353 | + frontend::SurfaceCreationParameters const& params, |
354 | + std::shared_ptr<input::InputChannel> const& input_channel) |
355 | + : builder(builder), |
356 | input_channel(input_channel), |
357 | - deleter(deleter) |
358 | + surface(builder->create_surface(params)) |
359 | { |
360 | } |
361 | |
362 | msh::Surface::~Surface() |
363 | { |
364 | - destroy(); |
365 | + if (surface.lock()) |
366 | + { |
367 | + destroy(); |
368 | + } |
369 | } |
370 | |
371 | void msh::Surface::hide() |
372 | @@ -71,7 +65,7 @@ |
373 | |
374 | void msh::Surface::destroy() |
375 | { |
376 | - deleter(surface); |
377 | + builder->destroy_surface(surface); |
378 | } |
379 | |
380 | void msh::Surface::shutdown() |
381 | |
382 | === modified file 'src/server/shell/surface.h' |
383 | --- src/server/shell/surface.h 2013-03-15 22:34:53 +0000 |
384 | +++ src/server/shell/surface.h 2013-03-18 15:53:36 +0000 |
385 | @@ -23,8 +23,6 @@ |
386 | #include "mir/frontend/surface.h" |
387 | #include "mir/surfaces/surface.h" |
388 | |
389 | -#include <functional> |
390 | - |
391 | namespace mir |
392 | { |
393 | namespace frontend |
394 | @@ -36,21 +34,17 @@ |
395 | class InputChannel; |
396 | } |
397 | |
398 | -namespace surfaces |
399 | -{ |
400 | -class SurfaceStackModel; |
401 | -} |
402 | - |
403 | namespace shell |
404 | { |
405 | +class SurfaceBuilder; |
406 | |
407 | class Surface : public frontend::Surface |
408 | { |
409 | public: |
410 | - explicit Surface(std::weak_ptr<mir::surfaces::Surface> const& surface, std::shared_ptr<input::InputChannel> const& input_channel); |
411 | - Surface(std::weak_ptr<mir::surfaces::Surface> const& surface, |
412 | - std::shared_ptr<input::InputChannel> const& input_channel, |
413 | - std::function<void(std::weak_ptr<mir::surfaces::Surface> const&)> const& deleter); |
414 | + Surface( |
415 | + std::shared_ptr<SurfaceBuilder> const& builder, |
416 | + frontend::SurfaceCreationParameters const& params, |
417 | + std::shared_ptr<input::InputChannel> const& input_channel); |
418 | ~Surface(); |
419 | |
420 | void hide(); |
421 | @@ -73,11 +67,10 @@ |
422 | int client_input_fd() const; |
423 | |
424 | private: |
425 | + std::shared_ptr<SurfaceBuilder> const builder; |
426 | + std::shared_ptr<mir::input::InputChannel> const input_channel; |
427 | std::weak_ptr<mir::surfaces::Surface> const surface; |
428 | - std::shared_ptr<mir::input::InputChannel> const input_channel; |
429 | - std::function<void(std::weak_ptr<mir::surfaces::Surface> const&)> const deleter; |
430 | }; |
431 | - |
432 | } |
433 | } |
434 | |
435 | |
436 | === renamed file 'src/server/shell/surface_controller.cpp' => 'src/server/shell/surface_source.cpp' |
437 | --- src/server/shell/surface_controller.cpp 2013-03-15 22:34:53 +0000 |
438 | +++ src/server/shell/surface_source.cpp 2013-03-18 15:53:36 +0000 |
439 | @@ -16,8 +16,8 @@ |
440 | * Authored by: Thomas Voss <thomas.voss@canonical.com> |
441 | */ |
442 | |
443 | -#include "mir/shell/surface_controller.h" |
444 | -#include "mir/surfaces/surface_stack_model.h" |
445 | +#include "mir/shell/surface_source.h" |
446 | +#include "mir/shell/surface_builder.h" |
447 | #include "mir/frontend/surface.h" |
448 | #include "mir/input/input_channel_factory.h" |
449 | |
450 | @@ -31,19 +31,20 @@ |
451 | namespace mf = mir::frontend; |
452 | |
453 | |
454 | -msh::SurfaceController::SurfaceController(std::shared_ptr<ms::SurfaceStackModel> const& surface_stack, |
455 | - std::shared_ptr<mi::InputChannelFactory> const& input_factory) |
456 | - : surface_stack(surface_stack), |
457 | +msh::SurfaceSource::SurfaceSource( |
458 | + std::shared_ptr<SurfaceBuilder> const& surface_builder, |
459 | + std::shared_ptr<mi::InputChannelFactory> const& input_factory) : |
460 | + surface_builder(surface_builder), |
461 | input_factory(input_factory) |
462 | { |
463 | - assert(surface_stack); |
464 | + assert(surface_builder); |
465 | } |
466 | |
467 | -std::shared_ptr<mf::Surface> msh::SurfaceController::create_surface(const mf::SurfaceCreationParameters& params) |
468 | +std::shared_ptr<mf::Surface> msh::SurfaceSource::create_surface(const mf::SurfaceCreationParameters& params) |
469 | { |
470 | return std::make_shared<Surface>( |
471 | - surface_stack->create_surface(params), |
472 | - input_factory->make_input_channel(), |
473 | - [=] (std::weak_ptr<mir::surfaces::Surface> const& surface) { surface_stack->destroy_surface(surface); }); |
474 | + surface_builder, |
475 | + params, |
476 | + input_factory->make_input_channel()); |
477 | } |
478 | |
479 | |
480 | === modified file 'src/server/surfaces/CMakeLists.txt' |
481 | --- src/server/surfaces/CMakeLists.txt 2013-03-14 17:49:25 +0000 |
482 | +++ src/server/surfaces/CMakeLists.txt 2013-03-18 15:53:36 +0000 |
483 | @@ -3,4 +3,5 @@ |
484 | |
485 | surface.cpp |
486 | surface_stack.cpp |
487 | + surface_controller.cpp |
488 | ) |
489 | |
490 | === added file 'src/server/surfaces/surface_controller.cpp' |
491 | --- src/server/surfaces/surface_controller.cpp 1970-01-01 00:00:00 +0000 |
492 | +++ src/server/surfaces/surface_controller.cpp 2013-03-18 15:53:36 +0000 |
493 | @@ -0,0 +1,37 @@ |
494 | +/* |
495 | + * Copyright © 2013 Canonical Ltd. |
496 | + * |
497 | + * This program is free software: you can redistribute it and/or modify it |
498 | + * under the terms of the GNU Lesser General Public License version 3, |
499 | + * as published by the Free Software Foundation. |
500 | + * |
501 | + * This program is distributed in the hope that it will be useful, |
502 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
503 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
504 | + * GNU General Public License for more details. |
505 | + * |
506 | + * You should have received a copy of the GNU Lesser General Public License |
507 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
508 | + * |
509 | + * Authored by: Alan Griffiths <alan@octopull.co.uk> |
510 | + */ |
511 | + |
512 | +#include "mir/surfaces/surface_controller.h" |
513 | +#include "mir/surfaces/surface_stack_model.h" |
514 | + |
515 | +namespace ms = mir::surfaces; |
516 | + |
517 | +ms::SurfaceController::SurfaceController(std::shared_ptr<SurfaceStackModel> const& surface_stack) : |
518 | + surface_stack(surface_stack) |
519 | +{ |
520 | +} |
521 | + |
522 | +std::weak_ptr<ms::Surface> ms::SurfaceController::create_surface(frontend::SurfaceCreationParameters const& params) |
523 | +{ |
524 | + return surface_stack->create_surface(params); |
525 | +} |
526 | + |
527 | +void ms::SurfaceController::destroy_surface(std::weak_ptr<Surface> const& surface) |
528 | +{ |
529 | + surface_stack->destroy_surface(surface); |
530 | +} |
531 | |
532 | === modified file 'tests/integration-tests/frontend/test_session_manager.cpp' |
533 | --- tests/integration-tests/frontend/test_session_manager.cpp 2013-03-14 17:45:38 +0000 |
534 | +++ tests/integration-tests/frontend/test_session_manager.cpp 2013-03-18 15:53:36 +0000 |
535 | @@ -18,8 +18,6 @@ |
536 | |
537 | #include "mir/shell/session_manager.h" |
538 | #include "mir/surfaces/buffer_bundle.h" |
539 | -#include "mir/shell/surface_controller.h" |
540 | -#include "mir/surfaces/surface_stack.h" |
541 | #include "mir/surfaces/surface.h" |
542 | #include "mir/compositor/buffer_swapper.h" |
543 | #include "mir/shell/focus_sequence.h" |
544 | |
545 | === modified file 'tests/unit-tests/shell/test_session_manager.cpp' |
546 | --- tests/unit-tests/shell/test_session_manager.cpp 2013-03-18 03:33:22 +0000 |
547 | +++ tests/unit-tests/shell/test_session_manager.cpp 2013-03-18 15:53:36 +0000 |
548 | @@ -29,6 +29,7 @@ |
549 | #include "mir_test_doubles/mock_surface_factory.h" |
550 | #include "mir_test_doubles/mock_focus_setter.h" |
551 | #include "mir_test_doubles/null_buffer_bundle.h" |
552 | +#include "mir/shell/surface_builder.h" |
553 | |
554 | #include "src/server/shell/surface.h" |
555 | |
556 | @@ -46,6 +47,27 @@ |
557 | |
558 | namespace |
559 | { |
560 | +class StubSurfaceBuilder : public msh::SurfaceBuilder |
561 | +{ |
562 | +public: |
563 | + StubSurfaceBuilder() : |
564 | + buffer_bundle(new mtd::NullBufferBundle()), |
565 | + dummy_surface(std::make_shared<ms::Surface>(mf::a_surface().name, buffer_bundle)) |
566 | + { |
567 | + } |
568 | + |
569 | + std::weak_ptr<ms::Surface> create_surface(mf::SurfaceCreationParameters const& ) |
570 | + { |
571 | + return dummy_surface; |
572 | + } |
573 | + |
574 | + void destroy_surface(std::weak_ptr<ms::Surface> const& ) |
575 | + { |
576 | + } |
577 | +private: |
578 | + std::shared_ptr<ms::BufferBundle> const buffer_bundle; |
579 | + std::shared_ptr<ms::Surface> dummy_surface; |
580 | +}; |
581 | |
582 | struct MockSessionContainer : public msh::SessionContainer |
583 | { |
584 | @@ -72,6 +94,7 @@ |
585 | { |
586 | } |
587 | |
588 | + StubSurfaceBuilder surface_builder; |
589 | mtd::MockSurfaceFactory surface_factory; |
590 | MockSessionContainer container; |
591 | MockFocusSequence sequence; |
592 | @@ -102,14 +125,13 @@ |
593 | using namespace ::testing; |
594 | |
595 | EXPECT_CALL(surface_factory, create_surface(_)).Times(1); |
596 | - std::shared_ptr<ms::BufferBundle> buffer_bundle(new mtd::NullBufferBundle()); |
597 | - std::shared_ptr<ms::Surface> dummy_surface( |
598 | - std::make_shared<ms::Surface>( |
599 | - mf::a_surface().name, |
600 | - buffer_bundle)); |
601 | + |
602 | std::shared_ptr<mi::InputChannel> null_input_channel; |
603 | ON_CALL(surface_factory, create_surface(_)).WillByDefault( |
604 | - Return(std::make_shared<msh::Surface>(dummy_surface, null_input_channel))); |
605 | + Return(std::make_shared<msh::Surface>( |
606 | + mt::fake_shared(surface_builder), |
607 | + mf::a_surface(), |
608 | + null_input_channel))); |
609 | |
610 | EXPECT_CALL(container, insert_session(_)).Times(1); |
611 | EXPECT_CALL(container, remove_session(_)).Times(1); |
612 | @@ -168,18 +190,14 @@ |
613 | |
614 | TEST_F(SessionManagerSetup, create_surface_for_session_forwards_and_then_focuses_session) |
615 | { |
616 | - using namespace ::testing; |
617 | - |
618 | - std::shared_ptr<ms::BufferBundle> buffer_bundle(new mtd::NullBufferBundle()); |
619 | - std::shared_ptr<ms::Surface> dummy_surface( |
620 | - std::make_shared<ms::Surface>( |
621 | - mf::a_surface().name, |
622 | - buffer_bundle)); |
623 | + using namespace ::testing; |
624 | std::shared_ptr<mi::InputChannel> null_input_channel; |
625 | ON_CALL(surface_factory, create_surface(_)).WillByDefault( |
626 | - Return(std::make_shared<msh::Surface>(dummy_surface, null_input_channel))); |
627 | + Return(std::make_shared<msh::Surface>( |
628 | + mt::fake_shared(surface_builder), |
629 | + mf::a_surface(), |
630 | + null_input_channel))); |
631 | |
632 | - |
633 | // Once for session creation and once for surface creation |
634 | { |
635 | InSequence seq; |
636 | |
637 | === modified file 'tests/unit-tests/shell/test_surface.cpp' |
638 | --- tests/unit-tests/shell/test_surface.cpp 2013-03-15 22:34:53 +0000 |
639 | +++ tests/unit-tests/shell/test_surface.cpp 2013-03-18 15:53:36 +0000 |
640 | @@ -21,7 +21,9 @@ |
641 | #include "mir/shell/surface_creation_parameters.h" |
642 | #include "mir/surfaces/surface_stack_model.h" |
643 | #include "mir/input/input_channel.h" |
644 | +#include "mir/shell/surface_builder.h" |
645 | |
646 | +#include "mir_test_doubles/null_buffer_bundle.h" |
647 | #include "mir_test_doubles/mock_buffer_bundle.h" |
648 | #include "mir_test_doubles/mock_buffer.h" |
649 | #include "mir_test_doubles/stub_buffer.h" |
650 | @@ -42,43 +44,48 @@ |
651 | |
652 | namespace |
653 | { |
654 | -typedef testing::NiceMock<mtd::MockBufferBundle> StubBufferBundle; |
655 | - |
656 | -class MockSurfaceStackModel : public ms::SurfaceStackModel |
657 | +class MockSurfaceBuilder : public msh::SurfaceBuilder |
658 | { |
659 | public: |
660 | - MockSurfaceStackModel() |
661 | + MockSurfaceBuilder() : |
662 | + buffer_bundle(new mtd::NullBufferBundle()), |
663 | + dummy_surface() |
664 | { |
665 | using namespace testing; |
666 | - |
667 | ON_CALL(*this, create_surface(_)). |
668 | - WillByDefault(Invoke(this, &MockSurfaceStackModel::do_create_surface)); |
669 | + WillByDefault(Invoke(this, &MockSurfaceBuilder::do_create_surface)); |
670 | |
671 | ON_CALL(*this, destroy_surface(_)). |
672 | - WillByDefault(Invoke(this, &MockSurfaceStackModel::do_destroy_surface)); |
673 | + WillByDefault(Invoke(this, &MockSurfaceBuilder::do_destroy_surface)); |
674 | } |
675 | |
676 | MOCK_METHOD1(create_surface, std::weak_ptr<ms::Surface> (const mf::SurfaceCreationParameters&)); |
677 | |
678 | MOCK_METHOD1(destroy_surface, void (std::weak_ptr<ms::Surface> const&)); |
679 | |
680 | + std::weak_ptr<ms::Surface> do_create_surface(mf::SurfaceCreationParameters const& ) |
681 | + { |
682 | + dummy_surface = std::make_shared<ms::Surface>(mf::a_surface().name, buffer_bundle); |
683 | + return dummy_surface; |
684 | + } |
685 | + |
686 | + void do_destroy_surface(std::weak_ptr<ms::Surface> const& ) |
687 | + { |
688 | + reset_surface(); |
689 | + } |
690 | + |
691 | + void reset_surface() |
692 | + { |
693 | + dummy_surface.reset(); |
694 | + } |
695 | + |
696 | private: |
697 | - std::weak_ptr<ms::Surface> do_create_surface(const mf::SurfaceCreationParameters& params) |
698 | - { |
699 | - surface = std::make_shared<ms::Surface>( |
700 | - params.name, |
701 | - std::make_shared<StubBufferBundle>()); |
702 | - return surface; |
703 | - } |
704 | - |
705 | - void do_destroy_surface(std::weak_ptr<ms::Surface> const&) |
706 | - { |
707 | - surface.reset(); |
708 | - } |
709 | - |
710 | - std::shared_ptr<ms::Surface> surface; |
711 | + std::shared_ptr<ms::BufferBundle> const buffer_bundle; |
712 | + std::shared_ptr<ms::Surface> dummy_surface; |
713 | }; |
714 | |
715 | +typedef testing::NiceMock<mtd::MockBufferBundle> StubBufferBundle; |
716 | + |
717 | |
718 | struct MockInputChannel : public mi::InputChannel |
719 | { |
720 | @@ -90,6 +97,7 @@ |
721 | { |
722 | std::shared_ptr<StubBufferBundle> buffer_bundle; |
723 | std::shared_ptr<mi::InputChannel> null_input_channel; |
724 | + MockSurfaceBuilder surface_builder; |
725 | |
726 | ShellSurface() : |
727 | buffer_bundle(std::make_shared<StubBufferBundle>()), |
728 | @@ -108,171 +116,173 @@ |
729 | { |
730 | using namespace testing; |
731 | |
732 | - MockSurfaceStackModel surface_stack; |
733 | mf::SurfaceCreationParameters params; |
734 | |
735 | InSequence sequence; |
736 | - EXPECT_CALL(surface_stack, create_surface(_)).Times(1); |
737 | - EXPECT_CALL(surface_stack, destroy_surface(_)).Times(1); |
738 | + EXPECT_CALL(surface_builder, create_surface(_)).Times(1); |
739 | + EXPECT_CALL(surface_builder, destroy_surface(_)).Times(1); |
740 | |
741 | msh::Surface test( |
742 | - surface_stack.create_surface(params), |
743 | - null_input_channel, |
744 | - [&](std::weak_ptr<mir::surfaces::Surface> const& s) {surface_stack.destroy_surface(s);}); |
745 | + mt::fake_shared(surface_builder), |
746 | + params, |
747 | + null_input_channel); |
748 | } |
749 | |
750 | TEST_F(ShellSurface, destroy) |
751 | { |
752 | using namespace testing; |
753 | |
754 | - NiceMock<MockSurfaceStackModel> surface_stack; |
755 | - mf::SurfaceCreationParameters params; |
756 | - |
757 | msh::Surface test( |
758 | - surface_stack.create_surface(params), |
759 | - null_input_channel, |
760 | - [&](std::weak_ptr<mir::surfaces::Surface> const& s) {surface_stack.destroy_surface(s);}); |
761 | + mt::fake_shared(surface_builder), |
762 | + mf::a_surface(), |
763 | + null_input_channel); |
764 | |
765 | - EXPECT_CALL(surface_stack, destroy_surface(_)).Times(1); |
766 | + EXPECT_CALL(surface_builder, destroy_surface(_)).Times(1); |
767 | |
768 | test.destroy(); |
769 | - |
770 | - Mock::VerifyAndClearExpectations(&surface_stack); |
771 | } |
772 | |
773 | TEST_F(ShellSurface, client_buffer_throw_behavior) |
774 | { |
775 | - auto surface = std::make_shared<ms::Surface>(__PRETTY_FUNCTION__, buffer_bundle); |
776 | - |
777 | - msh::Surface proxy_surface(surface, null_input_channel); |
778 | + msh::Surface test( |
779 | + mt::fake_shared(surface_builder), |
780 | + mf::a_surface(), |
781 | + null_input_channel); |
782 | |
783 | EXPECT_NO_THROW({ |
784 | - proxy_surface.client_buffer(); |
785 | + test.client_buffer(); |
786 | }); |
787 | |
788 | - surface.reset(); |
789 | + surface_builder.reset_surface(); |
790 | |
791 | EXPECT_THROW({ |
792 | - proxy_surface.client_buffer(); |
793 | + test.client_buffer(); |
794 | }, std::runtime_error); |
795 | } |
796 | |
797 | TEST_F(ShellSurface, size_throw_behavior) |
798 | { |
799 | - auto surface = std::make_shared<ms::Surface>(__PRETTY_FUNCTION__, buffer_bundle); |
800 | - |
801 | - msh::Surface proxy_surface(surface, null_input_channel); |
802 | + msh::Surface test( |
803 | + mt::fake_shared(surface_builder), |
804 | + mf::a_surface(), |
805 | + null_input_channel); |
806 | |
807 | EXPECT_NO_THROW({ |
808 | - proxy_surface.size(); |
809 | + test.size(); |
810 | }); |
811 | |
812 | - surface.reset(); |
813 | + surface_builder.reset_surface(); |
814 | |
815 | EXPECT_THROW({ |
816 | - proxy_surface.size(); |
817 | + test.size(); |
818 | }, std::runtime_error); |
819 | } |
820 | |
821 | TEST_F(ShellSurface, pixel_format_throw_behavior) |
822 | { |
823 | - auto surface = std::make_shared<ms::Surface>(__PRETTY_FUNCTION__, buffer_bundle); |
824 | - |
825 | - msh::Surface proxy_surface(surface, null_input_channel); |
826 | + msh::Surface test( |
827 | + mt::fake_shared(surface_builder), |
828 | + mf::a_surface(), |
829 | + null_input_channel); |
830 | |
831 | EXPECT_NO_THROW({ |
832 | - proxy_surface.pixel_format(); |
833 | + test.pixel_format(); |
834 | }); |
835 | |
836 | - surface.reset(); |
837 | + surface_builder.reset_surface(); |
838 | |
839 | EXPECT_THROW({ |
840 | - proxy_surface.pixel_format(); |
841 | + test.pixel_format(); |
842 | }, std::runtime_error); |
843 | } |
844 | |
845 | TEST_F(ShellSurface, hide_throw_behavior) |
846 | { |
847 | - auto surface = std::make_shared<ms::Surface>(__PRETTY_FUNCTION__, buffer_bundle); |
848 | - |
849 | - msh::Surface proxy_surface(surface, null_input_channel); |
850 | + msh::Surface test( |
851 | + mt::fake_shared(surface_builder), |
852 | + mf::a_surface(), |
853 | + null_input_channel); |
854 | |
855 | EXPECT_NO_THROW({ |
856 | - proxy_surface.hide(); |
857 | + test.hide(); |
858 | }); |
859 | |
860 | - surface.reset(); |
861 | + surface_builder.reset_surface(); |
862 | |
863 | EXPECT_NO_THROW({ |
864 | - proxy_surface.hide(); |
865 | + test.hide(); |
866 | }); |
867 | } |
868 | |
869 | TEST_F(ShellSurface, show_throw_behavior) |
870 | { |
871 | - auto surface = std::make_shared<ms::Surface>(__PRETTY_FUNCTION__, buffer_bundle); |
872 | - |
873 | - msh::Surface proxy_surface(surface, null_input_channel); |
874 | + msh::Surface test( |
875 | + mt::fake_shared(surface_builder), |
876 | + mf::a_surface(), |
877 | + null_input_channel); |
878 | |
879 | EXPECT_NO_THROW({ |
880 | - proxy_surface.show(); |
881 | + test.show(); |
882 | }); |
883 | |
884 | - surface.reset(); |
885 | + surface_builder.reset_surface(); |
886 | |
887 | EXPECT_NO_THROW({ |
888 | - proxy_surface.show(); |
889 | + test.show(); |
890 | }); |
891 | } |
892 | |
893 | TEST_F(ShellSurface, destroy_throw_behavior) |
894 | { |
895 | - auto surface = std::make_shared<ms::Surface>(__PRETTY_FUNCTION__, buffer_bundle); |
896 | - |
897 | - msh::Surface proxy_surface(surface, null_input_channel); |
898 | + msh::Surface test( |
899 | + mt::fake_shared(surface_builder), |
900 | + mf::a_surface(), |
901 | + null_input_channel); |
902 | |
903 | EXPECT_NO_THROW({ |
904 | - proxy_surface.destroy(); |
905 | + test.destroy(); |
906 | }); |
907 | |
908 | - surface.reset(); |
909 | + surface_builder.reset_surface(); |
910 | |
911 | EXPECT_NO_THROW({ |
912 | - proxy_surface.destroy(); |
913 | + test.destroy(); |
914 | }); |
915 | } |
916 | |
917 | TEST_F(ShellSurface, shutdown_throw_behavior) |
918 | { |
919 | - auto surface = std::make_shared<ms::Surface>(__PRETTY_FUNCTION__, buffer_bundle); |
920 | - |
921 | - msh::Surface proxy_surface(surface, null_input_channel); |
922 | + msh::Surface test( |
923 | + mt::fake_shared(surface_builder), |
924 | + mf::a_surface(), |
925 | + null_input_channel); |
926 | |
927 | EXPECT_NO_THROW({ |
928 | - proxy_surface.shutdown(); |
929 | + test.shutdown(); |
930 | }); |
931 | |
932 | - surface.reset(); |
933 | + surface_builder.reset_surface(); |
934 | |
935 | EXPECT_NO_THROW({ |
936 | - proxy_surface.shutdown(); |
937 | + test.shutdown(); |
938 | }); |
939 | } |
940 | |
941 | TEST_F(ShellSurface, advance_client_buffer_throw_behavior) |
942 | { |
943 | - auto surface = std::make_shared<ms::Surface>(__PRETTY_FUNCTION__, buffer_bundle); |
944 | - |
945 | - msh::Surface proxy_surface(surface, null_input_channel); |
946 | + msh::Surface test( |
947 | + mt::fake_shared(surface_builder), |
948 | + mf::a_surface(), |
949 | + null_input_channel); |
950 | |
951 | EXPECT_NO_THROW({ |
952 | - proxy_surface.advance_client_buffer(); |
953 | + test.advance_client_buffer(); |
954 | }); |
955 | |
956 | - surface.reset(); |
957 | + surface_builder.reset_surface(); |
958 | |
959 | EXPECT_NO_THROW({ |
960 | - proxy_surface.advance_client_buffer(); |
961 | + test.advance_client_buffer(); |
962 | }); |
963 | } |
964 | |
965 | @@ -282,13 +292,11 @@ |
966 | const int testing_client_fd = 17; |
967 | |
968 | MockInputChannel mock_package; |
969 | - auto surface = std::make_shared<ms::Surface>(__PRETTY_FUNCTION__, buffer_bundle); |
970 | - auto input_surface = std::make_shared<ms::Surface>(__PRETTY_FUNCTION__, buffer_bundle); |
971 | - msh::Surface proxy_surface(surface, null_input_channel); |
972 | - msh::Surface input_proxy_surface(surface, mt::fake_shared(mock_package)); |
973 | + msh::Surface proxy_surface(mt::fake_shared(surface_builder), mf::a_surface(), null_input_channel); |
974 | + msh::Surface input_proxy_surface(mt::fake_shared(surface_builder), mf::a_surface(), mt::fake_shared(mock_package)); |
975 | |
976 | EXPECT_CALL(mock_package, client_fd()).Times(1).WillOnce(Return(testing_client_fd)); |
977 | - |
978 | + |
979 | EXPECT_TRUE(input_proxy_surface.supports_input()); |
980 | EXPECT_FALSE(proxy_surface.supports_input()); |
981 | |
982 | |
983 | === modified file 'tests/unit-tests/surfaces/CMakeLists.txt' |
984 | --- tests/unit-tests/surfaces/CMakeLists.txt 2013-03-15 22:34:53 +0000 |
985 | +++ tests/unit-tests/surfaces/CMakeLists.txt 2013-03-18 15:53:36 +0000 |
986 | @@ -2,6 +2,7 @@ |
987 | APPEND UNIT_TEST_SOURCES |
988 | ${CMAKE_CURRENT_SOURCE_DIR}/test_surface.cpp |
989 | ${CMAKE_CURRENT_SOURCE_DIR}/test_surface_stack.cpp |
990 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_surface_controller.cpp |
991 | ) |
992 | |
993 | set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE) |
994 | |
995 | === modified file 'tests/unit-tests/surfaces/test_surface_controller.cpp' |
996 | --- tests/unit-tests/surfaces/test_surface_controller.cpp 2013-03-11 19:26:34 +0000 |
997 | +++ tests/unit-tests/surfaces/test_surface_controller.cpp 2013-03-18 15:53:36 +0000 |
998 | @@ -19,58 +19,38 @@ |
999 | #include "mir/surfaces/surface_controller.h" |
1000 | #include "mir/surfaces/surface_stack_model.h" |
1001 | #include "mir/shell/surface_creation_parameters.h" |
1002 | -#include "mir/input/input_channel.h" |
1003 | -#include "mir/input/input_channel_factory.h" |
1004 | |
1005 | #include "mir_test/fake_shared.h" |
1006 | |
1007 | #include <gtest/gtest.h> |
1008 | #include <gmock/gmock.h> |
1009 | |
1010 | +namespace mf = mir::frontend; |
1011 | namespace ms = mir::surfaces; |
1012 | -namespace msh = mir::shell; |
1013 | -namespace mi = mir::input; |
1014 | namespace mt = mir::test; |
1015 | |
1016 | namespace |
1017 | { |
1018 | - |
1019 | struct MockSurfaceStackModel : public ms::SurfaceStackModel |
1020 | { |
1021 | - MOCK_METHOD1(create_surface, std::weak_ptr<ms::Surface>(msh::SurfaceCreationParameters const&)); |
1022 | + MOCK_METHOD1(create_surface, std::weak_ptr<ms::Surface>(mf::SurfaceCreationParameters const&)); |
1023 | MOCK_METHOD1(destroy_surface, void(std::weak_ptr<ms::Surface> const&)); |
1024 | }; |
1025 | - |
1026 | -struct MockInputChannel : public mi::InputChannel |
1027 | -{ |
1028 | - MOCK_CONST_METHOD0(client_fd, int()); |
1029 | - MOCK_CONST_METHOD0(server_fd, int()); |
1030 | -}; |
1031 | - |
1032 | -struct MockInputChannelFactory : public mi::InputChannelFactory |
1033 | -{ |
1034 | - MOCK_METHOD0(make_input_channel, std::shared_ptr<mi::InputChannel>()); |
1035 | -}; |
1036 | - |
1037 | } |
1038 | |
1039 | -TEST(SurfaceStack, create_surface) |
1040 | +TEST(SurfaceController, create_and_destroy_surface) |
1041 | { |
1042 | using namespace ::testing; |
1043 | |
1044 | std::weak_ptr<ms::Surface> null_surface; |
1045 | MockSurfaceStackModel model; |
1046 | - MockInputChannelFactory input_factory; |
1047 | - MockInputChannel package; |
1048 | - |
1049 | - EXPECT_CALL(model, create_surface(_)).Times(1) |
1050 | - .WillOnce(Return(null_surface)); |
1051 | - EXPECT_CALL(input_factory, make_input_channel()).Times(1) |
1052 | - .WillOnce(Return(mt::fake_shared(package))); |
1053 | + |
1054 | + ms::SurfaceController controller(mt::fake_shared(model)); |
1055 | + |
1056 | + InSequence seq; |
1057 | + EXPECT_CALL(model, create_surface(_)).Times(1).WillOnce(Return(null_surface)); |
1058 | EXPECT_CALL(model, destroy_surface(_)).Times(1); |
1059 | - |
1060 | - ms::SurfaceController controller(mt::fake_shared(model), mt::fake_shared(input_factory)); |
1061 | - { |
1062 | - auto surface = controller.create_surface(msh::a_surface()); |
1063 | - } |
1064 | + |
1065 | + auto surface = controller.create_surface(mf::a_surface()); |
1066 | + controller.destroy_surface(surface); |
1067 | } |
FAILED: Continuous integration, rev:513 jenkins. qa.ubuntu. com/job/ mir-ci/ 114/
http://
Executed test runs:
Click here to trigger a rebuild: jenkins. qa.ubuntu. com/job/ mir-ci/ 114/rebuild
http://