Merge lp:~robertcarr/mir/ease-shell-configuration into lp:~mir-team/mir/trunk
- ease-shell-configuration
- Merge into trunk
Status: | Rejected |
---|---|
Rejected by: | Robert Carr |
Proposed branch: | lp:~robertcarr/mir/ease-shell-configuration |
Merge into: | lp:~mir-team/mir/trunk |
Diff against target: |
813 lines (+393/-110) 12 files modified
include/server/mir/default_server_configuration.h (+3/-0) include/server/mir/shell/default_shell_configuration.h (+71/-0) include/server/mir/shell/session_manager.h (+2/-4) include/server/mir/shell/shell_configuration.h (+52/-0) src/server/default_server_configuration.cpp (+14/-14) src/server/shell/CMakeLists.txt (+1/-0) src/server/shell/default_shell_configuration.cpp (+82/-0) src/server/shell/session_manager.cpp (+8/-11) tests/acceptance-tests/test_focus_selection.cpp (+33/-12) tests/death-tests/test_application_manager_death.cpp (+25/-5) tests/integration-tests/shell/test_session_manager.cpp (+47/-31) tests/unit-tests/shell/test_session_manager.cpp (+55/-33) |
To merge this branch: | bzr merge lp:~robertcarr/mir/ease-shell-configuration |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alan Griffiths | Needs Fixing | ||
Daniel van Vugt | Abstain | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Alexandros Frantzis (community) | Needs Fixing | ||
Review via email: mp+157965@code.launchpad.net |
Commit message
Encapsulate SessionManager dependencies in a ShellConfiguration object (using the idiom established by input)
Description of the change
I want to write a small demo shell which among other things (largely input filtering), replaces the placement strategy. It's a little cumbersome to do so from the shells perspective though! Also the large number of arguments to SessionManager constructor make refactoring a little painful.
This branch refactors it to use the idiom established by the server configuration and input configuration
PS Jenkins bot (ps-jenkins) wrote : | # |
Daniel van Vugt (vanvugt) wrote : | # |
I like the intention. Though I don't claim to fully understand the context of all the changes.
This is a common mistake throughout the Mir code. We should probably stop copying and pasting it...
15 + * GNU General Public License for more details.
115 + * GNU General Public License for more details.
220 + * GNU General Public License for more details.
Need "Lesser" as in LGPL.
Alexandros Frantzis (afrantzis) wrote : | # |
187 + auto configuration = std::make_
188 + the_surface_
I think it would make sense to have DefaultServerCo
140 + virtual ~ShellConfigura
For new base classes/interfaces it is recommended to use "= default()" for the destructor, too, so that we get the noexcept guarantee. The price for this is that we need to explicitly mark destructors of derived classes as noexcept(true).
Some nits:
242 + : view_area(
243 + input_focus_
244 + underlying_
':' should be indented 4 spaces (we don't use 2 space indentations in any case).
318 + : surface_
Likewise.
370 + : DefaultShellCon
Likewise.
498 + : sequence(
Likewise
648 + : session_
Likewise.
Alan Griffiths (alan-griffiths) wrote : | # |
On 11/04/13 15:59, Alexandros Frantzis wrote:
> For new base classes/interfaces it is recommended to use "= default()" for the destructor, too, so that we get the noexcept guarantee. The price for this is that we need to explicitly mark destructors of derived classes as noexcept(true).
Only true for *some* derived classes: Ones with an explicit destructor
definition, or those where there are members with throwing destructors.
--
Alan Griffiths +44 (0)798 9938 758
Octopull Ltd http://
Robert Carr (robertcarr) wrote : | # |
Thanks both!
Copyright headers fixed (r581)
Add the_shell_
Use = default for ~ShellConfiguration (r583)
Fix whitespace (r584)
Daniel van Vugt (vanvugt) wrote : | # |
server/*: Need to s/GNU Lesser General/GNU General/g
Stylistically I disagree with a lot of this. Though the sources of all my concerns originate before this proposal and are not really new.
From a high-level perspective, I totally agree that writing a simple dumb shell would be very useful. I was thinking the same. Although I am concerned about the number and complexity of classes we're exposing to shell developers. It feels like too much, but I don't understand them well enough to comment further.
Just need to fix up the licenses for now.
Alexandros Frantzis (afrantzis) wrote : | # |
> Thanks both!
>
> Copyright headers fixed (r581)
> Add the_shell_
> Use = default for ~ShellConfiguration (r583)
> Fix whitespace (r584)
It seems you didn't push the commits :)
- 580. By Robert Carr
-
Merge trunk
- 581. By Robert Carr
-
Fix copyright headers
- 582. By Robert Carr
-
Add the_shell_
configuration( ) to default server configuration - 583. By Robert Carr
-
~ShellConfiguration is noexcept
- 584. By Robert Carr
-
Whitespace
Robert Carr (robertcarr) wrote : | # |
I know how to use bzr!
- 585. By Robert Carr
-
Merge trunk
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:585
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Robert Carr (robertcarr) wrote : | # |
>> From a high-level perspective, I totally agree that writing a simple dumb shell would be very useful. I was >> thinking the same. Although I am concerned about the number
>> and complexity of classes we're exposing to shell
>> developers. It feels like too much, but I don't understand them well enough to comment further.
I feel this concern! This is part of the idea with getting a little dumb shell going (and some of the other examples), to give us explicit targets to try and improve.
- 586. By Robert Carr
-
Trim whitespace
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:586
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Daniel van Vugt (vanvugt) wrote : | # |
Still need to remove "Lesser" in src/server/* as in:
37 + * under the terms of the GNU Lesser General Public License version 3,
Robert Carr (robertcarr) wrote : | # |
Fix headers for real!
- 587. By Robert Carr
-
Merge trunk
- 588. By Robert Carr
-
Fix headers
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:588
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alan Griffiths (alan-griffiths) wrote : | # |
While I think we need to add structure to our configuration process, I'm not convinced that this is is right way forward. (C.f. https:/
Lets have a discussion of the pros & cons of different approaches before going too far along any path.
Daniel van Vugt (vanvugt) wrote : | # |
OK, licenses are fixed. Though based on Alan's comment I won't do another review just yet.
Alan Griffiths (alan-griffiths) wrote : | # |
From the email list:
On 16/04/13 22:45, Robert Carr wrote:
> In the case of the shell configuration, the intent was to allow overriding of the session store dependencies constructed in the_session_manager without overriding the entire construction. I felt strange adding many more methods to the already polluted default_
I can see this approach - the master config having some member config objects with reduced scope. But for this approach to be followed consistently the ShellConfiguration should be held in the DefaultServerCo
Unmerged revisions
- 588. By Robert Carr
-
Fix headers
- 587. By Robert Carr
-
Merge trunk
- 586. By Robert Carr
-
Trim whitespace
- 585. By Robert Carr
-
Merge trunk
- 584. By Robert Carr
-
Whitespace
- 583. By Robert Carr
-
~ShellConfiguration is noexcept
- 582. By Robert Carr
-
Add the_shell_
configuration( ) to default server configuration - 581. By Robert Carr
-
Fix copyright headers
- 580. By Robert Carr
-
Merge trunk
- 579. By Robert Carr
-
Factor placement strategy out to a default shell configuration method
Preview Diff
1 | === modified file 'include/server/mir/default_server_configuration.h' | |||
2 | --- include/server/mir/default_server_configuration.h 2013-04-12 04:55:11 +0000 | |||
3 | +++ include/server/mir/default_server_configuration.h 2013-04-15 14:20:37 +0000 | |||
4 | @@ -48,6 +48,7 @@ | |||
5 | 48 | 48 | ||
6 | 49 | namespace shell | 49 | namespace shell |
7 | 50 | { | 50 | { |
8 | 51 | class ShellConfiguration; | ||
9 | 51 | class SessionManager; | 52 | class SessionManager; |
10 | 52 | class SurfaceFactory; | 53 | class SurfaceFactory; |
11 | 53 | class SurfaceSource; | 54 | class SurfaceSource; |
12 | @@ -108,6 +109,7 @@ | |||
13 | 108 | virtual std::shared_ptr<frontend::SessionMediatorReport> the_session_mediator_report(); | 109 | virtual std::shared_ptr<frontend::SessionMediatorReport> the_session_mediator_report(); |
14 | 109 | virtual std::shared_ptr<frontend::MessageProcessorReport> the_message_processor_report(); | 110 | virtual std::shared_ptr<frontend::MessageProcessorReport> the_message_processor_report(); |
15 | 110 | 111 | ||
16 | 112 | virtual std::shared_ptr<shell::ShellConfiguration> the_shell_configuration(); | ||
17 | 111 | virtual std::shared_ptr<frontend::Shell> the_frontend_shell(); | 113 | virtual std::shared_ptr<frontend::Shell> the_frontend_shell(); |
18 | 112 | virtual std::shared_ptr<shell::SurfaceFactory> the_surface_factory(); | 114 | virtual std::shared_ptr<shell::SurfaceFactory> the_surface_factory(); |
19 | 113 | 115 | ||
20 | @@ -130,6 +132,7 @@ | |||
21 | 130 | virtual std::shared_ptr<input::InputChannelFactory> the_input_channel_factory(); | 132 | virtual std::shared_ptr<input::InputChannelFactory> the_input_channel_factory(); |
22 | 131 | 133 | ||
23 | 132 | CachedPtr<frontend::Communicator> communicator; | 134 | CachedPtr<frontend::Communicator> communicator; |
24 | 135 | CachedPtr<shell::ShellConfiguration> shell_configuration; | ||
25 | 133 | CachedPtr<frontend::Shell> session_manager; | 136 | CachedPtr<frontend::Shell> session_manager; |
26 | 134 | CachedPtr<input::InputManager> input_manager; | 137 | CachedPtr<input::InputManager> input_manager; |
27 | 135 | CachedPtr<graphics::Platform> graphics_platform; | 138 | CachedPtr<graphics::Platform> graphics_platform; |
28 | 136 | 139 | ||
29 | === added file 'include/server/mir/shell/default_shell_configuration.h' | |||
30 | --- include/server/mir/shell/default_shell_configuration.h 1970-01-01 00:00:00 +0000 | |||
31 | +++ include/server/mir/shell/default_shell_configuration.h 2013-04-15 14:20:37 +0000 | |||
32 | @@ -0,0 +1,71 @@ | |||
33 | 1 | /* | ||
34 | 2 | * Copyright © 2013 Canonical Ltd. | ||
35 | 3 | * | ||
36 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
37 | 5 | * under the terms of the GNU General Public License version 3, | ||
38 | 6 | * as published by the Free Software Foundation. | ||
39 | 7 | * | ||
40 | 8 | * This program is distributed in the hope that it will be useful, | ||
41 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
42 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
43 | 11 | * GNU General Public License for more details. | ||
44 | 12 | * | ||
45 | 13 | * You should have received a copy of the GNU General Public License | ||
46 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
47 | 15 | * | ||
48 | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> | ||
49 | 17 | */ | ||
50 | 18 | |||
51 | 19 | #ifndef MIR_SHELL_DEFAULT_SHELL_CONFIGURATION_H_ | ||
52 | 20 | #define MIR_SHELL_DEFAULT_SHELL_CONFIGURATION_H_ | ||
53 | 21 | |||
54 | 22 | #include "mir/shell/shell_configuration.h" | ||
55 | 23 | #include "mir/cached_ptr.h" | ||
56 | 24 | |||
57 | 25 | namespace mir | ||
58 | 26 | { | ||
59 | 27 | namespace graphics | ||
60 | 28 | { | ||
61 | 29 | class ViewableArea; | ||
62 | 30 | } | ||
63 | 31 | namespace shell | ||
64 | 32 | { | ||
65 | 33 | class InputFocusSelector; | ||
66 | 34 | class SurfaceFactory; | ||
67 | 35 | class PlacementStrategy; | ||
68 | 36 | |||
69 | 37 | class DefaultShellConfiguration : public ShellConfiguration | ||
70 | 38 | { | ||
71 | 39 | public: | ||
72 | 40 | DefaultShellConfiguration(std::shared_ptr<graphics::ViewableArea> const& view_area, | ||
73 | 41 | std::shared_ptr<InputFocusSelector> const& focus_selector, | ||
74 | 42 | std::shared_ptr<SurfaceFactory> const& surface_factory); | ||
75 | 43 | virtual ~DefaultShellConfiguration() noexcept(true) = default; | ||
76 | 44 | |||
77 | 45 | std::shared_ptr<SurfaceFactory> the_surface_factory(); | ||
78 | 46 | std::shared_ptr<SessionContainer> the_session_container(); | ||
79 | 47 | std::shared_ptr<FocusSequence> the_focus_sequence(); | ||
80 | 48 | std::shared_ptr<FocusSetter> the_focus_setter(); | ||
81 | 49 | |||
82 | 50 | std::shared_ptr<PlacementStrategy> the_placement_strategy(); | ||
83 | 51 | |||
84 | 52 | protected: | ||
85 | 53 | DefaultShellConfiguration(DefaultShellConfiguration const&) = delete; | ||
86 | 54 | DefaultShellConfiguration& operator=(DefaultShellConfiguration const&) = delete; | ||
87 | 55 | |||
88 | 56 | private: | ||
89 | 57 | std::shared_ptr<graphics::ViewableArea> const view_area; | ||
90 | 58 | std::shared_ptr<InputFocusSelector> const input_focus_selector; | ||
91 | 59 | std::shared_ptr<SurfaceFactory> const underlying_surface_factory; | ||
92 | 60 | |||
93 | 61 | CachedPtr<SurfaceFactory> surface_factory; | ||
94 | 62 | CachedPtr<SessionContainer> session_container; | ||
95 | 63 | CachedPtr<FocusSequence> focus_sequence; | ||
96 | 64 | CachedPtr<FocusSetter> focus_setter; | ||
97 | 65 | CachedPtr<PlacementStrategy> placement_strategy; | ||
98 | 66 | }; | ||
99 | 67 | |||
100 | 68 | } | ||
101 | 69 | } // namespace mir | ||
102 | 70 | |||
103 | 71 | #endif // MIR_SHELL_DEFAULT_SHELL_CONFIGURATION_H_ | ||
104 | 0 | 72 | ||
105 | === modified file 'include/server/mir/shell/session_manager.h' | |||
106 | --- include/server/mir/shell/session_manager.h 2013-04-12 04:55:11 +0000 | |||
107 | +++ include/server/mir/shell/session_manager.h 2013-04-15 14:20:37 +0000 | |||
108 | @@ -36,6 +36,7 @@ | |||
109 | 36 | /// Management of sessions and surfaces | 36 | /// Management of sessions and surfaces |
110 | 37 | namespace shell | 37 | namespace shell |
111 | 38 | { | 38 | { |
112 | 39 | class ShellConfiguration; | ||
113 | 39 | class SurfaceFactory; | 40 | class SurfaceFactory; |
114 | 40 | class SessionContainer; | 41 | class SessionContainer; |
115 | 41 | class FocusSequence; | 42 | class FocusSequence; |
116 | @@ -44,10 +45,7 @@ | |||
117 | 44 | class SessionManager : public frontend::Shell | 45 | class SessionManager : public frontend::Shell |
118 | 45 | { | 46 | { |
119 | 46 | public: | 47 | public: |
124 | 47 | explicit SessionManager(std::shared_ptr<SurfaceFactory> const& surface_factory, | 48 | explicit SessionManager(std::shared_ptr<ShellConfiguration> const& configuration); |
121 | 48 | std::shared_ptr<SessionContainer> const& session_container, | ||
122 | 49 | std::shared_ptr<FocusSequence> const& focus_sequence, | ||
123 | 50 | std::shared_ptr<FocusSetter> const& focus_setter); | ||
125 | 51 | virtual ~SessionManager(); | 49 | virtual ~SessionManager(); |
126 | 52 | 50 | ||
127 | 53 | virtual std::shared_ptr<frontend::Session> open_session(std::string const& name); | 51 | virtual std::shared_ptr<frontend::Session> open_session(std::string const& name); |
128 | 54 | 52 | ||
129 | === added file 'include/server/mir/shell/shell_configuration.h' | |||
130 | --- include/server/mir/shell/shell_configuration.h 1970-01-01 00:00:00 +0000 | |||
131 | +++ include/server/mir/shell/shell_configuration.h 2013-04-15 14:20:37 +0000 | |||
132 | @@ -0,0 +1,52 @@ | |||
133 | 1 | /* | ||
134 | 2 | * Copyright © 2013 Canonical Ltd. | ||
135 | 3 | * | ||
136 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
137 | 5 | * under the terms of the GNU General Public License version 3, | ||
138 | 6 | * as published by the Free Software Foundation. | ||
139 | 7 | * | ||
140 | 8 | * This program is distributed in the hope that it will be useful, | ||
141 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
142 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
143 | 11 | * GNU General Public License for more details. | ||
144 | 12 | * | ||
145 | 13 | * You should have received a copy of the GNU General Public License | ||
146 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
147 | 15 | * | ||
148 | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> | ||
149 | 17 | */ | ||
150 | 18 | |||
151 | 19 | #ifndef MIR_SHELL_SHELL_CONFIGURATION_H_ | ||
152 | 20 | #define MIR_SHELL_SHELL_CONFIGURATION_H_ | ||
153 | 21 | |||
154 | 22 | #include <memory> | ||
155 | 23 | |||
156 | 24 | namespace mir | ||
157 | 25 | { | ||
158 | 26 | namespace shell | ||
159 | 27 | { | ||
160 | 28 | class SurfaceFactory; | ||
161 | 29 | class SessionContainer; | ||
162 | 30 | class FocusSequence; | ||
163 | 31 | class FocusSetter; | ||
164 | 32 | |||
165 | 33 | class ShellConfiguration | ||
166 | 34 | { | ||
167 | 35 | public: | ||
168 | 36 | virtual ~ShellConfiguration() = default; | ||
169 | 37 | |||
170 | 38 | virtual std::shared_ptr<SurfaceFactory> the_surface_factory() = 0; | ||
171 | 39 | virtual std::shared_ptr<SessionContainer> the_session_container() = 0; | ||
172 | 40 | virtual std::shared_ptr<FocusSequence> the_focus_sequence() = 0; | ||
173 | 41 | virtual std::shared_ptr<FocusSetter> the_focus_setter() = 0; | ||
174 | 42 | |||
175 | 43 | protected: | ||
176 | 44 | ShellConfiguration() = default; | ||
177 | 45 | ShellConfiguration(ShellConfiguration const&) = delete; | ||
178 | 46 | ShellConfiguration& operator=(ShellConfiguration const&) = delete; | ||
179 | 47 | }; | ||
180 | 48 | |||
181 | 49 | } | ||
182 | 50 | } // namespace mir | ||
183 | 51 | |||
184 | 52 | #endif // MIR_SHELL_SHELL_CONFIGURATION_H_ | ||
185 | 0 | 53 | ||
186 | === modified file 'src/server/default_server_configuration.cpp' | |||
187 | --- src/server/default_server_configuration.cpp 2013-04-12 04:55:11 +0000 | |||
188 | +++ src/server/default_server_configuration.cpp 2013-04-15 14:20:37 +0000 | |||
189 | @@ -32,12 +32,8 @@ | |||
190 | 32 | #include "mir/frontend/null_message_processor_report.h" | 32 | #include "mir/frontend/null_message_processor_report.h" |
191 | 33 | #include "mir/frontend/session_mediator.h" | 33 | #include "mir/frontend/session_mediator.h" |
192 | 34 | #include "mir/frontend/resource_cache.h" | 34 | #include "mir/frontend/resource_cache.h" |
193 | 35 | #include "mir/shell/default_shell_configuration.h" | ||
194 | 35 | #include "mir/shell/session_manager.h" | 36 | #include "mir/shell/session_manager.h" |
195 | 36 | #include "mir/shell/registration_order_focus_sequence.h" | ||
196 | 37 | #include "mir/shell/single_visibility_focus_mechanism.h" | ||
197 | 38 | #include "mir/shell/session_container.h" | ||
198 | 39 | #include "mir/shell/consuming_placement_strategy.h" | ||
199 | 40 | #include "mir/shell/organising_surface_factory.h" | ||
200 | 41 | #include "mir/graphics/display.h" | 37 | #include "mir/graphics/display.h" |
201 | 42 | #include "mir/graphics/gl_renderer.h" | 38 | #include "mir/graphics/gl_renderer.h" |
202 | 43 | #include "mir/graphics/renderer.h" | 39 | #include "mir/graphics/renderer.h" |
203 | @@ -292,20 +288,24 @@ | |||
204 | 292 | }); | 288 | }); |
205 | 293 | } | 289 | } |
206 | 294 | 290 | ||
207 | 291 | std::shared_ptr<msh::ShellConfiguration> | ||
208 | 292 | mir::DefaultServerConfiguration::the_shell_configuration() | ||
209 | 293 | { | ||
210 | 294 | return shell_configuration( | ||
211 | 295 | [this]() | ||
212 | 296 | { | ||
213 | 297 | return std::make_shared<msh::DefaultShellConfiguration>(the_display(), the_input_focus_selector(), | ||
214 | 298 | the_surface_factory()); | ||
215 | 299 | }); | ||
216 | 300 | } | ||
217 | 301 | |||
218 | 295 | std::shared_ptr<mf::Shell> | 302 | std::shared_ptr<mf::Shell> |
219 | 296 | mir::DefaultServerConfiguration::the_frontend_shell() | 303 | mir::DefaultServerConfiguration::the_frontend_shell() |
220 | 297 | { | 304 | { |
221 | 298 | return session_manager( | 305 | return session_manager( |
223 | 299 | [this]() -> std::shared_ptr<msh::SessionManager> | 306 | [this]() |
224 | 300 | { | 307 | { |
233 | 301 | auto session_container = std::make_shared<msh::SessionContainer>(); | 308 | return std::make_shared<msh::SessionManager>(the_shell_configuration()); |
226 | 302 | auto focus_mechanism = std::make_shared<msh::SingleVisibilityFocusMechanism>(session_container, the_input_focus_selector()); | ||
227 | 303 | auto focus_selection_strategy = std::make_shared<msh::RegistrationOrderFocusSequence>(session_container); | ||
228 | 304 | |||
229 | 305 | auto placement_strategy = std::make_shared<msh::ConsumingPlacementStrategy>(the_display()); | ||
230 | 306 | auto organising_factory = std::make_shared<msh::OrganisingSurfaceFactory>(the_surface_factory(), placement_strategy); | ||
231 | 307 | |||
232 | 308 | return std::make_shared<msh::SessionManager>(organising_factory, session_container, focus_selection_strategy, focus_mechanism); | ||
234 | 309 | }); | 309 | }); |
235 | 310 | } | 310 | } |
236 | 311 | 311 | ||
237 | 312 | 312 | ||
238 | === modified file 'src/server/shell/CMakeLists.txt' | |||
239 | --- src/server/shell/CMakeLists.txt 2013-03-21 03:32:59 +0000 | |||
240 | +++ src/server/shell/CMakeLists.txt 2013-04-15 14:20:37 +0000 | |||
241 | @@ -1,6 +1,7 @@ | |||
242 | 1 | set( | 1 | set( |
243 | 2 | SHELL_SOURCES | 2 | SHELL_SOURCES |
244 | 3 | 3 | ||
245 | 4 | default_shell_configuration.cpp | ||
246 | 4 | application_session.cpp | 5 | application_session.cpp |
247 | 5 | session_container.cpp | 6 | session_container.cpp |
248 | 6 | session_manager.cpp | 7 | session_manager.cpp |
249 | 7 | 8 | ||
250 | === added file 'src/server/shell/default_shell_configuration.cpp' | |||
251 | --- src/server/shell/default_shell_configuration.cpp 1970-01-01 00:00:00 +0000 | |||
252 | +++ src/server/shell/default_shell_configuration.cpp 2013-04-15 14:20:37 +0000 | |||
253 | @@ -0,0 +1,82 @@ | |||
254 | 1 | /* | ||
255 | 2 | * Copyright © 2013 Canonical Ltd. | ||
256 | 3 | * | ||
257 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
258 | 5 | * under the terms of the GNU General Public License version 3, | ||
259 | 6 | * as published by the Free Software Foundation. | ||
260 | 7 | * | ||
261 | 8 | * This program is distributed in the hope that it will be useful, | ||
262 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
263 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
264 | 11 | * GNU General Public License for more details. | ||
265 | 12 | * | ||
266 | 13 | * You should have received a copy of the GNU General Public License | ||
267 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
268 | 15 | * | ||
269 | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> | ||
270 | 17 | */ | ||
271 | 18 | |||
272 | 19 | #include "mir/shell/default_shell_configuration.h" | ||
273 | 20 | |||
274 | 21 | #include "mir/shell/organising_surface_factory.h" | ||
275 | 22 | #include "mir/shell/consuming_placement_strategy.h" | ||
276 | 23 | #include "mir/shell/session_container.h" | ||
277 | 24 | #include "mir/shell/registration_order_focus_sequence.h" | ||
278 | 25 | #include "mir/shell/single_visibility_focus_mechanism.h" | ||
279 | 26 | |||
280 | 27 | namespace msh = mir::shell; | ||
281 | 28 | namespace mg = mir::graphics; | ||
282 | 29 | |||
283 | 30 | msh::DefaultShellConfiguration::DefaultShellConfiguration(std::shared_ptr<mg::ViewableArea> const& view_area, | ||
284 | 31 | std::shared_ptr<msh::InputFocusSelector> const& focus_selector, | ||
285 | 32 | std::shared_ptr<msh::SurfaceFactory> const& surface_factory) : | ||
286 | 33 | view_area(view_area), | ||
287 | 34 | input_focus_selector(focus_selector), | ||
288 | 35 | underlying_surface_factory(surface_factory) | ||
289 | 36 | { | ||
290 | 37 | } | ||
291 | 38 | |||
292 | 39 | std::shared_ptr<msh::SurfaceFactory> msh::DefaultShellConfiguration::the_surface_factory() | ||
293 | 40 | { | ||
294 | 41 | return surface_factory( | ||
295 | 42 | [this]() -> std::shared_ptr<msh::SurfaceFactory> | ||
296 | 43 | { | ||
297 | 44 | return std::make_shared<msh::OrganisingSurfaceFactory>(underlying_surface_factory, the_placement_strategy()); | ||
298 | 45 | }); | ||
299 | 46 | } | ||
300 | 47 | |||
301 | 48 | std::shared_ptr<msh::SessionContainer> msh::DefaultShellConfiguration::the_session_container() | ||
302 | 49 | { | ||
303 | 50 | return session_container( | ||
304 | 51 | [this]() | ||
305 | 52 | { | ||
306 | 53 | return std::make_shared<msh::SessionContainer>(); | ||
307 | 54 | }); | ||
308 | 55 | } | ||
309 | 56 | |||
310 | 57 | std::shared_ptr<msh::FocusSequence> msh::DefaultShellConfiguration::the_focus_sequence() | ||
311 | 58 | { | ||
312 | 59 | return focus_sequence( | ||
313 | 60 | [this]() | ||
314 | 61 | { | ||
315 | 62 | return std::make_shared<msh::RegistrationOrderFocusSequence>(the_session_container()); | ||
316 | 63 | }); | ||
317 | 64 | } | ||
318 | 65 | |||
319 | 66 | std::shared_ptr<msh::FocusSetter> msh::DefaultShellConfiguration::the_focus_setter() | ||
320 | 67 | { | ||
321 | 68 | return focus_setter( | ||
322 | 69 | [this]() | ||
323 | 70 | { | ||
324 | 71 | return std::make_shared<msh::SingleVisibilityFocusMechanism>(the_session_container(), input_focus_selector); | ||
325 | 72 | }); | ||
326 | 73 | } | ||
327 | 74 | |||
328 | 75 | std::shared_ptr<msh::PlacementStrategy> msh::DefaultShellConfiguration::the_placement_strategy() | ||
329 | 76 | { | ||
330 | 77 | return placement_strategy( | ||
331 | 78 | [this]() | ||
332 | 79 | { | ||
333 | 80 | return std::make_shared<msh::ConsumingPlacementStrategy>(view_area); | ||
334 | 81 | }); | ||
335 | 82 | } | ||
336 | 0 | 83 | ||
337 | === modified file 'src/server/shell/session_manager.cpp' | |||
338 | --- src/server/shell/session_manager.cpp 2013-04-12 04:55:11 +0000 | |||
339 | +++ src/server/shell/session_manager.cpp 2013-04-15 14:20:37 +0000 | |||
340 | @@ -17,6 +17,7 @@ | |||
341 | 17 | */ | 17 | */ |
342 | 18 | 18 | ||
343 | 19 | #include "mir/shell/session_manager.h" | 19 | #include "mir/shell/session_manager.h" |
344 | 20 | #include "mir/shell/shell_configuration.h" | ||
345 | 20 | #include "mir/shell/application_session.h" | 21 | #include "mir/shell/application_session.h" |
346 | 21 | #include "mir/shell/session_container.h" | 22 | #include "mir/shell/session_container.h" |
347 | 22 | #include "mir/shell/surface_factory.h" | 23 | #include "mir/shell/surface_factory.h" |
348 | @@ -31,19 +32,15 @@ | |||
349 | 31 | namespace mf = mir::frontend; | 32 | namespace mf = mir::frontend; |
350 | 32 | namespace msh = mir::shell; | 33 | namespace msh = mir::shell; |
351 | 33 | 34 | ||
361 | 34 | msh::SessionManager::SessionManager( | 35 | msh::SessionManager::SessionManager(std::shared_ptr<msh::ShellConfiguration> const& config) : |
362 | 35 | std::shared_ptr<msh::SurfaceFactory> const& surface_factory, | 36 | surface_factory(config->the_surface_factory()), |
363 | 36 | std::shared_ptr<msh::SessionContainer> const& container, | 37 | app_container(config->the_session_container()), |
364 | 37 | std::shared_ptr<msh::FocusSequence> const& sequence, | 38 | focus_sequence(config->the_focus_sequence()), |
365 | 38 | std::shared_ptr<msh::FocusSetter> const& focus_setter) : | 39 | focus_setter(config->the_focus_setter()) |
357 | 39 | surface_factory(surface_factory), | ||
358 | 40 | app_container(container), | ||
359 | 41 | focus_sequence(sequence), | ||
360 | 42 | focus_setter(focus_setter) | ||
366 | 43 | { | 40 | { |
367 | 44 | assert(surface_factory); | 41 | assert(surface_factory); |
370 | 45 | assert(sequence); | 42 | assert(focus_sequence); |
371 | 46 | assert(container); | 43 | assert(app_container); |
372 | 47 | assert(focus_setter); | 44 | assert(focus_setter); |
373 | 48 | } | 45 | } |
374 | 49 | 46 | ||
375 | 50 | 47 | ||
376 | === modified file 'tests/acceptance-tests/test_focus_selection.cpp' | |||
377 | --- tests/acceptance-tests/test_focus_selection.cpp 2013-04-08 04:03:40 +0000 | |||
378 | +++ tests/acceptance-tests/test_focus_selection.cpp 2013-04-15 14:20:37 +0000 | |||
379 | @@ -23,12 +23,14 @@ | |||
380 | 23 | #include "mir/shell/consuming_placement_strategy.h" | 23 | #include "mir/shell/consuming_placement_strategy.h" |
381 | 24 | #include "mir/shell/organising_surface_factory.h" | 24 | #include "mir/shell/organising_surface_factory.h" |
382 | 25 | #include "mir/shell/session_manager.h" | 25 | #include "mir/shell/session_manager.h" |
383 | 26 | #include "mir/shell/default_shell_configuration.h" | ||
384 | 26 | #include "mir/graphics/display.h" | 27 | #include "mir/graphics/display.h" |
385 | 27 | #include "mir/shell/input_focus_selector.h" | 28 | #include "mir/shell/input_focus_selector.h" |
386 | 28 | 29 | ||
387 | 29 | #include "mir_test_framework/display_server_test_fixture.h" | 30 | #include "mir_test_framework/display_server_test_fixture.h" |
388 | 30 | #include "mir_test_doubles/mock_focus_setter.h" | 31 | #include "mir_test_doubles/mock_focus_setter.h" |
389 | 31 | #include "mir_test_doubles/mock_input_focus_selector.h" | 32 | #include "mir_test_doubles/mock_input_focus_selector.h" |
390 | 33 | #include "mir_test/fake_shared.h" | ||
391 | 32 | 34 | ||
392 | 33 | #include <gtest/gtest.h> | 35 | #include <gtest/gtest.h> |
393 | 34 | #include <gmock/gmock.h> | 36 | #include <gmock/gmock.h> |
394 | @@ -36,7 +38,9 @@ | |||
395 | 36 | namespace mf = mir::frontend; | 38 | namespace mf = mir::frontend; |
396 | 37 | namespace msh = mir::shell; | 39 | namespace msh = mir::shell; |
397 | 38 | namespace mi = mir::input; | 40 | namespace mi = mir::input; |
399 | 39 | namespace mtd = mir::test::doubles; | 41 | namespace mg = mir::graphics; |
400 | 42 | namespace mt = mir::test; | ||
401 | 43 | namespace mtd = mt::doubles; | ||
402 | 40 | namespace mtf = mir_test_framework; | 44 | namespace mtf = mir_test_framework; |
403 | 41 | 45 | ||
404 | 42 | namespace | 46 | namespace |
405 | @@ -46,6 +50,25 @@ | |||
406 | 46 | 50 | ||
407 | 47 | namespace | 51 | namespace |
408 | 48 | { | 52 | { |
409 | 53 | struct MockFocusShellConfiguration : public msh::DefaultShellConfiguration | ||
410 | 54 | { | ||
411 | 55 | MockFocusShellConfiguration(std::shared_ptr<mg::ViewableArea> const& view_area, | ||
412 | 56 | std::shared_ptr<msh::InputFocusSelector> const& input_selector, | ||
413 | 57 | std::shared_ptr<msh::SurfaceFactory> const& surface_factory) : | ||
414 | 58 | DefaultShellConfiguration(view_area, input_selector, surface_factory) | ||
415 | 59 | { | ||
416 | 60 | } | ||
417 | 61 | |||
418 | 62 | ~MockFocusShellConfiguration() noexcept(true) {} | ||
419 | 63 | |||
420 | 64 | std::shared_ptr<msh::FocusSetter> the_focus_setter() override | ||
421 | 65 | { | ||
422 | 66 | return mt::fake_shared(mock_focus_setter); | ||
423 | 67 | } | ||
424 | 68 | |||
425 | 69 | mtd::MockFocusSetter mock_focus_setter; | ||
426 | 70 | }; | ||
427 | 71 | |||
428 | 49 | struct ClientConfigCommon : TestingClientConfiguration | 72 | struct ClientConfigCommon : TestingClientConfiguration |
429 | 50 | { | 73 | { |
430 | 51 | ClientConfigCommon() : | 74 | ClientConfigCommon() : |
431 | @@ -139,31 +162,29 @@ | |||
432 | 139 | { | 162 | { |
433 | 140 | struct ServerConfig : TestingServerConfiguration | 163 | struct ServerConfig : TestingServerConfiguration |
434 | 141 | { | 164 | { |
435 | 165 | std::shared_ptr<MockFocusShellConfiguration> shell_config; | ||
436 | 166 | |||
437 | 142 | std::shared_ptr<mf::Shell> | 167 | std::shared_ptr<mf::Shell> |
438 | 143 | the_frontend_shell() | 168 | the_frontend_shell() |
439 | 144 | { | 169 | { |
440 | 170 | if (!shell_config) | ||
441 | 171 | shell_config = std::make_shared<MockFocusShellConfiguration>(the_display(), | ||
442 | 172 | the_input_focus_selector(), | ||
443 | 173 | the_surface_factory()); | ||
444 | 145 | return session_manager( | 174 | return session_manager( |
445 | 146 | [this]() -> std::shared_ptr<msh::SessionManager> | 175 | [this]() -> std::shared_ptr<msh::SessionManager> |
446 | 147 | { | 176 | { |
447 | 148 | using namespace ::testing; | 177 | using namespace ::testing; |
448 | 149 | |||
449 | 150 | auto session_container = std::make_shared<msh::SessionContainer>(); | ||
450 | 151 | auto focus_setter = std::make_shared<mtd::MockFocusSetter>(); | ||
451 | 152 | auto focus_selection_strategy = std::make_shared<msh::RegistrationOrderFocusSequence>(session_container); | ||
452 | 153 | |||
453 | 154 | auto placement_strategy = std::make_shared<msh::ConsumingPlacementStrategy>(the_display()); | ||
454 | 155 | auto organising_factory = std::make_shared<msh::OrganisingSurfaceFactory>(the_surface_factory(), placement_strategy); | ||
455 | 156 | |||
456 | 157 | { | 178 | { |
457 | 158 | InSequence seq; | 179 | InSequence seq; |
458 | 159 | // Once on application registration and once on surface creation | 180 | // Once on application registration and once on surface creation |
460 | 160 | EXPECT_CALL(*focus_setter, set_focus_to(NonNullSession())).Times(2); | 181 | EXPECT_CALL(shell_config->mock_focus_setter, set_focus_to(NonNullSession())).Times(2); |
461 | 161 | // Focus is cleared when the session is closed | 182 | // Focus is cleared when the session is closed |
463 | 162 | EXPECT_CALL(*focus_setter, set_focus_to(_)).Times(1); | 183 | EXPECT_CALL(shell_config->mock_focus_setter, set_focus_to(_)).Times(1); |
464 | 163 | } | 184 | } |
465 | 164 | // TODO: Counterexample ~racarr | 185 | // TODO: Counterexample ~racarr |
466 | 165 | 186 | ||
468 | 166 | return std::make_shared<msh::SessionManager>(organising_factory, session_container, focus_selection_strategy, focus_setter); | 187 | return std::make_shared<msh::SessionManager>(shell_config); |
469 | 167 | }); | 188 | }); |
470 | 168 | } | 189 | } |
471 | 169 | } server_config; | 190 | } server_config; |
472 | 170 | 191 | ||
473 | === modified file 'tests/death-tests/test_application_manager_death.cpp' | |||
474 | --- tests/death-tests/test_application_manager_death.cpp 2013-03-21 03:32:59 +0000 | |||
475 | +++ tests/death-tests/test_application_manager_death.cpp 2013-04-15 14:20:37 +0000 | |||
476 | @@ -17,11 +17,35 @@ | |||
477 | 17 | */ | 17 | */ |
478 | 18 | 18 | ||
479 | 19 | #include "mir/shell/session_manager.h" | 19 | #include "mir/shell/session_manager.h" |
480 | 20 | #include "mir/shell/shell_configuration.h" | ||
481 | 20 | #include <gmock/gmock.h> | 21 | #include <gmock/gmock.h> |
482 | 21 | #include <gtest/gtest.h> | 22 | #include <gtest/gtest.h> |
483 | 22 | 23 | ||
484 | 23 | namespace msh = mir::shell; | 24 | namespace msh = mir::shell; |
485 | 24 | 25 | ||
486 | 26 | namespace | ||
487 | 27 | { | ||
488 | 28 | struct NullShellConfiguration : public msh::ShellConfiguration | ||
489 | 29 | { | ||
490 | 30 | std::shared_ptr<msh::SurfaceFactory> the_surface_factory() | ||
491 | 31 | { | ||
492 | 32 | return std::shared_ptr<msh::SurfaceFactory>(); | ||
493 | 33 | } | ||
494 | 34 | std::shared_ptr<msh::SessionContainer> the_session_container() | ||
495 | 35 | { | ||
496 | 36 | return std::shared_ptr<msh::SessionContainer>(); | ||
497 | 37 | } | ||
498 | 38 | std::shared_ptr<msh::FocusSequence> the_focus_sequence() | ||
499 | 39 | { | ||
500 | 40 | return std::shared_ptr<msh::FocusSequence>(); | ||
501 | 41 | } | ||
502 | 42 | std::shared_ptr<msh::FocusSetter> the_focus_setter() | ||
503 | 43 | { | ||
504 | 44 | return std::shared_ptr<msh::FocusSetter>(); | ||
505 | 45 | } | ||
506 | 46 | }; | ||
507 | 47 | } | ||
508 | 48 | |||
509 | 25 | TEST(SessionManagerDeathTest, DISABLED_class_invariants_not_satisfied_triggers_assertion) | 49 | TEST(SessionManagerDeathTest, DISABLED_class_invariants_not_satisfied_triggers_assertion) |
510 | 26 | { | 50 | { |
511 | 27 | // Trying to avoid "[WARNING] /usr/src/gtest/src/gtest-death-test.cc:789:: | 51 | // Trying to avoid "[WARNING] /usr/src/gtest/src/gtest-death-test.cc:789:: |
512 | @@ -30,11 +54,7 @@ | |||
513 | 30 | // ::testing::FLAGS_gtest_death_test_style = "threadsafe"; | 54 | // ::testing::FLAGS_gtest_death_test_style = "threadsafe"; |
514 | 31 | // leads to the test failing under valgrind | 55 | // leads to the test failing under valgrind |
515 | 32 | EXPECT_EXIT( | 56 | EXPECT_EXIT( |
521 | 33 | std::shared_ptr<msh::SurfaceFactory> factory; | 57 | mir::shell::SessionManager app(std::make_shared<NullShellConfiguration>()), |
517 | 34 | mir::shell::SessionManager app(factory, | ||
518 | 35 | std::shared_ptr<msh::SessionContainer>(), | ||
519 | 36 | std::shared_ptr<msh::FocusSequence>(), | ||
520 | 37 | std::shared_ptr<msh::FocusSetter>()), | ||
522 | 38 | ::testing::KilledBySignal(SIGABRT), | 58 | ::testing::KilledBySignal(SIGABRT), |
523 | 39 | ".*"); | 59 | ".*"); |
524 | 40 | } | 60 | } |
525 | 41 | 61 | ||
526 | === modified file 'tests/integration-tests/shell/test_session_manager.cpp' | |||
527 | --- tests/integration-tests/shell/test_session_manager.cpp 2013-03-22 16:41:59 +0000 | |||
528 | +++ tests/integration-tests/shell/test_session_manager.cpp 2013-04-15 14:20:37 +0000 | |||
529 | @@ -17,6 +17,7 @@ | |||
530 | 17 | */ | 17 | */ |
531 | 18 | 18 | ||
532 | 19 | #include "mir/shell/session_manager.h" | 19 | #include "mir/shell/session_manager.h" |
533 | 20 | #include "mir/shell/shell_configuration.h" | ||
534 | 20 | #include "mir/shell/session.h" | 21 | #include "mir/shell/session.h" |
535 | 21 | #include "mir/shell/focus_sequence.h" | 22 | #include "mir/shell/focus_sequence.h" |
536 | 22 | #include "mir/shell/focus_setter.h" | 23 | #include "mir/shell/focus_setter.h" |
537 | @@ -41,22 +42,45 @@ | |||
538 | 41 | namespace mt = mir::test; | 42 | namespace mt = mir::test; |
539 | 42 | namespace mtd = mir::test::doubles; | 43 | namespace mtd = mir::test::doubles; |
540 | 43 | 44 | ||
541 | 45 | struct TestingShellConfiguration : public msh::ShellConfiguration | ||
542 | 46 | { | ||
543 | 47 | TestingShellConfiguration() : | ||
544 | 48 | sequence(mt::fake_shared(container)) | ||
545 | 49 | { | ||
546 | 50 | } | ||
547 | 51 | ~TestingShellConfiguration() noexcept(true) {} | ||
548 | 52 | |||
549 | 53 | std::shared_ptr<msh::SurfaceFactory> the_surface_factory() | ||
550 | 54 | { | ||
551 | 55 | return mt::fake_shared(surface_factory); | ||
552 | 56 | } | ||
553 | 57 | std::shared_ptr<msh::SessionContainer> the_session_container() | ||
554 | 58 | { | ||
555 | 59 | return mt::fake_shared(container); | ||
556 | 60 | } | ||
557 | 61 | std::shared_ptr<msh::FocusSequence> the_focus_sequence() | ||
558 | 62 | { | ||
559 | 63 | return mt::fake_shared(sequence); | ||
560 | 64 | } | ||
561 | 65 | std::shared_ptr<msh::FocusSetter> the_focus_setter() | ||
562 | 66 | { | ||
563 | 67 | return mt::fake_shared(focus_setter); | ||
564 | 68 | } | ||
565 | 69 | |||
566 | 70 | mtd::MockSurfaceFactory surface_factory; | ||
567 | 71 | msh::SessionContainer container; | ||
568 | 72 | msh::RegistrationOrderFocusSequence sequence; | ||
569 | 73 | mtd::MockFocusSetter focus_setter; | ||
570 | 74 | }; | ||
571 | 75 | |||
572 | 44 | TEST(TestSessionManagerAndFocusSelectionStrategy, cycle_focus) | 76 | TEST(TestSessionManagerAndFocusSelectionStrategy, cycle_focus) |
573 | 45 | { | 77 | { |
574 | 46 | using namespace ::testing; | 78 | using namespace ::testing; |
588 | 47 | mtd::MockSurfaceFactory surface_factory; | 79 | |
589 | 48 | std::shared_ptr<msh::SessionContainer> container(new msh::SessionContainer()); | 80 | TestingShellConfiguration config; |
590 | 49 | msh::RegistrationOrderFocusSequence sequence(container); | 81 | msh::SessionManager session_manager(mt::fake_shared(config)); |
591 | 50 | mtd::MockFocusSetter focus_changer; | 82 | |
592 | 51 | std::shared_ptr<mf::Session> new_session; | 83 | EXPECT_CALL(config.focus_setter, set_focus_to(_)).Times(3); |
580 | 52 | |||
581 | 53 | msh::SessionManager session_manager( | ||
582 | 54 | mt::fake_shared(surface_factory), | ||
583 | 55 | container, | ||
584 | 56 | mt::fake_shared(sequence), | ||
585 | 57 | mt::fake_shared(focus_changer)); | ||
586 | 58 | |||
587 | 59 | EXPECT_CALL(focus_changer, set_focus_to(_)).Times(3); | ||
593 | 60 | 84 | ||
594 | 61 | auto session1 = session_manager.open_session("Visual Basic Studio"); | 85 | auto session1 = session_manager.open_session("Visual Basic Studio"); |
595 | 62 | auto session2 = session_manager.open_session("Microsoft Access"); | 86 | auto session2 = session_manager.open_session("Microsoft Access"); |
596 | @@ -64,9 +88,9 @@ | |||
597 | 64 | 88 | ||
598 | 65 | { | 89 | { |
599 | 66 | InSequence seq; | 90 | InSequence seq; |
603 | 67 | EXPECT_CALL(focus_changer, set_focus_to(Eq(session1))).Times(1); | 91 | EXPECT_CALL(config.focus_setter, set_focus_to(Eq(session1))).Times(1); |
604 | 68 | EXPECT_CALL(focus_changer, set_focus_to(Eq(session2))).Times(1); | 92 | EXPECT_CALL(config.focus_setter, set_focus_to(Eq(session2))).Times(1); |
605 | 69 | EXPECT_CALL(focus_changer, set_focus_to(Eq(session3))).Times(1); | 93 | EXPECT_CALL(config.focus_setter, set_focus_to(Eq(session3))).Times(1); |
606 | 70 | } | 94 | } |
607 | 71 | 95 | ||
608 | 72 | session_manager.focus_next(); | 96 | session_manager.focus_next(); |
609 | @@ -77,19 +101,11 @@ | |||
610 | 77 | TEST(TestSessionManagerAndFocusSelectionStrategy, closing_applications_transfers_focus) | 101 | TEST(TestSessionManagerAndFocusSelectionStrategy, closing_applications_transfers_focus) |
611 | 78 | { | 102 | { |
612 | 79 | using namespace ::testing; | 103 | using namespace ::testing; |
626 | 80 | mtd::MockSurfaceFactory surface_factory; | 104 | |
627 | 81 | std::shared_ptr<msh::SessionContainer> model(new msh::SessionContainer()); | 105 | TestingShellConfiguration config; |
628 | 82 | msh::RegistrationOrderFocusSequence sequence(model); | 106 | msh::SessionManager session_manager(mt::fake_shared(config)); |
629 | 83 | mtd::MockFocusSetter focus_changer; | 107 | |
630 | 84 | std::shared_ptr<mf::Session> new_session; | 108 | EXPECT_CALL(config.focus_setter, set_focus_to(_)).Times(3); |
618 | 85 | |||
619 | 86 | msh::SessionManager session_manager( | ||
620 | 87 | mt::fake_shared(surface_factory), | ||
621 | 88 | model, | ||
622 | 89 | mt::fake_shared(sequence), | ||
623 | 90 | mt::fake_shared(focus_changer)); | ||
624 | 91 | |||
625 | 92 | EXPECT_CALL(focus_changer, set_focus_to(_)).Times(3); | ||
631 | 93 | 109 | ||
632 | 94 | auto session1 = session_manager.open_session("Visual Basic Studio"); | 110 | auto session1 = session_manager.open_session("Visual Basic Studio"); |
633 | 95 | auto session2 = session_manager.open_session("Microsoft Access"); | 111 | auto session2 = session_manager.open_session("Microsoft Access"); |
634 | @@ -97,8 +113,8 @@ | |||
635 | 97 | 113 | ||
636 | 98 | { | 114 | { |
637 | 99 | InSequence seq; | 115 | InSequence seq; |
640 | 100 | EXPECT_CALL(focus_changer, set_focus_to(Eq(session2))).Times(1); | 116 | EXPECT_CALL(config.focus_setter, set_focus_to(Eq(session2))).Times(1); |
641 | 101 | EXPECT_CALL(focus_changer, set_focus_to(Eq(session1))).Times(1); | 117 | EXPECT_CALL(config.focus_setter, set_focus_to(Eq(session1))).Times(1); |
642 | 102 | } | 118 | } |
643 | 103 | 119 | ||
644 | 104 | session_manager.close_session(session3); | 120 | session_manager.close_session(session3); |
645 | 105 | 121 | ||
646 | === modified file 'tests/unit-tests/shell/test_session_manager.cpp' | |||
647 | --- tests/unit-tests/shell/test_session_manager.cpp 2013-04-01 16:11:03 +0000 | |||
648 | +++ tests/unit-tests/shell/test_session_manager.cpp 2013-04-15 14:20:37 +0000 | |||
649 | @@ -21,6 +21,7 @@ | |||
650 | 21 | #include "mir/shell/session_manager.h" | 21 | #include "mir/shell/session_manager.h" |
651 | 22 | #include "mir/shell/session_container.h" | 22 | #include "mir/shell/session_container.h" |
652 | 23 | #include "mir/shell/session.h" | 23 | #include "mir/shell/session.h" |
653 | 24 | #include "mir/shell/shell_configuration.h" | ||
654 | 24 | #include "mir/frontend/session.h" | 25 | #include "mir/frontend/session.h" |
655 | 25 | #include "mir/frontend/surface_creation_parameters.h" | 26 | #include "mir/frontend/surface_creation_parameters.h" |
656 | 26 | #include "mir/surfaces/surface.h" | 27 | #include "mir/surfaces/surface.h" |
657 | @@ -63,22 +64,43 @@ | |||
658 | 63 | MOCK_CONST_METHOD0(default_focus, std::shared_ptr<mf::Session>()); | 64 | MOCK_CONST_METHOD0(default_focus, std::shared_ptr<mf::Session>()); |
659 | 64 | }; | 65 | }; |
660 | 65 | 66 | ||
661 | 67 | struct TestingShellConfiguration : public msh::ShellConfiguration | ||
662 | 68 | { | ||
663 | 69 | TestingShellConfiguration() {} | ||
664 | 70 | ~TestingShellConfiguration() noexcept(true) {} | ||
665 | 71 | |||
666 | 72 | std::shared_ptr<msh::SurfaceFactory> the_surface_factory() | ||
667 | 73 | { | ||
668 | 74 | return mt::fake_shared(surface_factory); | ||
669 | 75 | } | ||
670 | 76 | std::shared_ptr<msh::SessionContainer> the_session_container() | ||
671 | 77 | { | ||
672 | 78 | return mt::fake_shared(container); | ||
673 | 79 | } | ||
674 | 80 | std::shared_ptr<msh::FocusSequence> the_focus_sequence() | ||
675 | 81 | { | ||
676 | 82 | return mt::fake_shared(focus_sequence); | ||
677 | 83 | } | ||
678 | 84 | std::shared_ptr<msh::FocusSetter> the_focus_setter() | ||
679 | 85 | { | ||
680 | 86 | return mt::fake_shared(focus_setter); | ||
681 | 87 | } | ||
682 | 88 | |||
683 | 89 | mtd::MockSurfaceFactory surface_factory; | ||
684 | 90 | MockSessionContainer container; | ||
685 | 91 | MockFocusSequence focus_sequence; | ||
686 | 92 | ::testing::NiceMock<mtd::MockFocusSetter> focus_setter; | ||
687 | 93 | }; | ||
688 | 94 | |||
689 | 66 | struct SessionManagerSetup : public testing::Test | 95 | struct SessionManagerSetup : public testing::Test |
690 | 67 | { | 96 | { |
696 | 68 | SessionManagerSetup() | 97 | SessionManagerSetup() : |
697 | 69 | : session_manager(mt::fake_shared(surface_factory), | 98 | session_manager(mt::fake_shared(config)) |
693 | 70 | mt::fake_shared(container), | ||
694 | 71 | mt::fake_shared(sequence), | ||
695 | 72 | mt::fake_shared(focus_setter)) | ||
698 | 73 | { | 99 | { |
699 | 74 | } | 100 | } |
700 | 75 | 101 | ||
701 | 76 | mtd::StubSurfaceBuilder surface_builder; | 102 | mtd::StubSurfaceBuilder surface_builder; |
707 | 77 | mtd::MockSurfaceFactory surface_factory; | 103 | TestingShellConfiguration config; |
703 | 78 | testing::NiceMock<MockSessionContainer> container; // Inelegant but some tests need a stub | ||
704 | 79 | MockFocusSequence sequence; | ||
705 | 80 | testing::NiceMock<mtd::MockFocusSetter> focus_setter; // Inelegant but some tests need a stub | ||
706 | 81 | |||
708 | 82 | msh::SessionManager session_manager; | 104 | msh::SessionManager session_manager; |
709 | 83 | }; | 105 | }; |
710 | 84 | 106 | ||
711 | @@ -88,12 +110,12 @@ | |||
712 | 88 | { | 110 | { |
713 | 89 | using namespace ::testing; | 111 | using namespace ::testing; |
714 | 90 | 112 | ||
719 | 91 | EXPECT_CALL(container, insert_session(_)).Times(1); | 113 | EXPECT_CALL(config.container, insert_session(_)).Times(1); |
720 | 92 | EXPECT_CALL(container, remove_session(_)).Times(1); | 114 | EXPECT_CALL(config.container, remove_session(_)).Times(1); |
721 | 93 | EXPECT_CALL(focus_setter, set_focus_to(_)); | 115 | EXPECT_CALL(config.focus_setter, set_focus_to(_)); |
722 | 94 | EXPECT_CALL(focus_setter, set_focus_to(std::shared_ptr<msh::Session>())).Times(1); | 116 | EXPECT_CALL(config.focus_setter, set_focus_to(std::shared_ptr<msh::Session>())).Times(1); |
723 | 95 | 117 | ||
725 | 96 | EXPECT_CALL(sequence, default_focus()).WillOnce(Return((std::shared_ptr<mf::Session>()))); | 118 | EXPECT_CALL(config.focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<mf::Session>()))); |
726 | 97 | 119 | ||
727 | 98 | auto session = session_manager.open_session("Visual Basic Studio"); | 120 | auto session = session_manager.open_session("Visual Basic Studio"); |
728 | 99 | session_manager.close_session(session); | 121 | session_manager.close_session(session); |
729 | @@ -103,22 +125,22 @@ | |||
730 | 103 | { | 125 | { |
731 | 104 | using namespace ::testing; | 126 | using namespace ::testing; |
732 | 105 | 127 | ||
734 | 106 | EXPECT_CALL(surface_factory, create_surface(_)).Times(1); | 128 | EXPECT_CALL(config.surface_factory, create_surface(_)).Times(1); |
735 | 107 | 129 | ||
736 | 108 | std::shared_ptr<mi::InputChannel> null_input_channel; | 130 | std::shared_ptr<mi::InputChannel> null_input_channel; |
738 | 109 | ON_CALL(surface_factory, create_surface(_)).WillByDefault( | 131 | ON_CALL(config.surface_factory, create_surface(_)).WillByDefault( |
739 | 110 | Return(std::make_shared<msh::Surface>( | 132 | Return(std::make_shared<msh::Surface>( |
740 | 111 | mt::fake_shared(surface_builder), | 133 | mt::fake_shared(surface_builder), |
741 | 112 | mf::a_surface(), | 134 | mf::a_surface(), |
742 | 113 | null_input_channel))); | 135 | null_input_channel))); |
743 | 114 | 136 | ||
751 | 115 | EXPECT_CALL(container, insert_session(_)).Times(1); | 137 | EXPECT_CALL(config.container, insert_session(_)).Times(1); |
752 | 116 | EXPECT_CALL(container, remove_session(_)).Times(1); | 138 | EXPECT_CALL(config.container, remove_session(_)).Times(1); |
753 | 117 | 139 | ||
754 | 118 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); | 140 | EXPECT_CALL(config.focus_setter, set_focus_to(_)).Times(1); |
755 | 119 | EXPECT_CALL(focus_setter, set_focus_to(std::shared_ptr<msh::Session>())).Times(1); | 141 | EXPECT_CALL(config.focus_setter, set_focus_to(std::shared_ptr<msh::Session>())).Times(1); |
756 | 120 | 142 | ||
757 | 121 | EXPECT_CALL(sequence, default_focus()).WillOnce(Return((std::shared_ptr<mf::Session>()))); | 143 | EXPECT_CALL(config.focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<mf::Session>()))); |
758 | 122 | 144 | ||
759 | 123 | auto session = session_manager.open_session("Visual Basic Studio"); | 145 | auto session = session_manager.open_session("Visual Basic Studio"); |
760 | 124 | session->create_surface(mf::a_surface().of_size(geom::Size{geom::Width{1024}, geom::Height{768}})); | 146 | session->create_surface(mf::a_surface().of_size(geom::Size{geom::Width{1024}, geom::Height{768}})); |
761 | @@ -131,8 +153,8 @@ | |||
762 | 131 | using namespace ::testing; | 153 | using namespace ::testing; |
763 | 132 | std::shared_ptr<mf::Session> new_session; | 154 | std::shared_ptr<mf::Session> new_session; |
764 | 133 | 155 | ||
767 | 134 | EXPECT_CALL(container, insert_session(_)).Times(1); | 156 | EXPECT_CALL(config.container, insert_session(_)).Times(1); |
768 | 135 | EXPECT_CALL(focus_setter, set_focus_to(_)).WillOnce(SaveArg<0>(&new_session)); | 157 | EXPECT_CALL(config.focus_setter, set_focus_to(_)).WillOnce(SaveArg<0>(&new_session)); |
769 | 136 | 158 | ||
770 | 137 | auto session = session_manager.open_session("Visual Basic Studio"); | 159 | auto session = session_manager.open_session("Visual Basic Studio"); |
771 | 138 | EXPECT_EQ(session, new_session); | 160 | EXPECT_EQ(session, new_session); |
772 | @@ -147,7 +169,7 @@ | |||
773 | 147 | 169 | ||
774 | 148 | session_manager.tag_session_with_lightdm_id(session1, 1); | 170 | session_manager.tag_session_with_lightdm_id(session1, 1); |
775 | 149 | 171 | ||
777 | 150 | EXPECT_CALL(focus_setter, set_focus_to(Eq(session1))); | 172 | EXPECT_CALL(config.focus_setter, set_focus_to(Eq(session1))); |
778 | 151 | session_manager.focus_session_with_lightdm_id(1); | 173 | session_manager.focus_session_with_lightdm_id(1); |
779 | 152 | } | 174 | } |
780 | 153 | 175 | ||
781 | @@ -161,8 +183,8 @@ | |||
782 | 161 | session_manager.tag_session_with_lightdm_id(session1, 1); | 183 | session_manager.tag_session_with_lightdm_id(session1, 1); |
783 | 162 | session_manager.focus_session_with_lightdm_id(1); | 184 | session_manager.focus_session_with_lightdm_id(1); |
784 | 163 | 185 | ||
787 | 164 | EXPECT_CALL(sequence, default_focus()).WillOnce(Return(session2)); | 186 | EXPECT_CALL(config.focus_sequence, default_focus()).WillOnce(Return(session2)); |
788 | 165 | EXPECT_CALL(focus_setter, set_focus_to(Eq(session2))); | 187 | EXPECT_CALL(config.focus_setter, set_focus_to(Eq(session2))); |
789 | 166 | 188 | ||
790 | 167 | session_manager.close_session(session1); | 189 | session_manager.close_session(session1); |
791 | 168 | } | 190 | } |
792 | @@ -171,7 +193,7 @@ | |||
793 | 171 | { | 193 | { |
794 | 172 | using namespace ::testing; | 194 | using namespace ::testing; |
795 | 173 | std::shared_ptr<mi::InputChannel> null_input_channel; | 195 | std::shared_ptr<mi::InputChannel> null_input_channel; |
797 | 174 | ON_CALL(surface_factory, create_surface(_)).WillByDefault( | 196 | ON_CALL(config.surface_factory, create_surface(_)).WillByDefault( |
798 | 175 | Return(std::make_shared<msh::Surface>( | 197 | Return(std::make_shared<msh::Surface>( |
799 | 176 | mt::fake_shared(surface_builder), | 198 | mt::fake_shared(surface_builder), |
800 | 177 | mf::a_surface(), | 199 | mf::a_surface(), |
801 | @@ -181,9 +203,9 @@ | |||
802 | 181 | { | 203 | { |
803 | 182 | InSequence seq; | 204 | InSequence seq; |
804 | 183 | 205 | ||
808 | 184 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Session creation | 206 | EXPECT_CALL(config.focus_setter, set_focus_to(_)).Times(1); // Session creation |
809 | 185 | EXPECT_CALL(surface_factory, create_surface(_)).Times(1); | 207 | EXPECT_CALL(config.surface_factory, create_surface(_)).Times(1); |
810 | 186 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Post Surface creation | 208 | EXPECT_CALL(config.focus_setter, set_focus_to(_)).Times(1); // Post Surface creation |
811 | 187 | } | 209 | } |
812 | 188 | 210 | ||
813 | 189 | auto session1 = session_manager.open_session("Weather Report"); | 211 | auto session1 = session_manager.open_session("Weather Report"); |
PASSED: Continuous integration, rev:579 jenkins. qa.ubuntu. com/job/ mir-ci/ 343/ jenkins. qa.ubuntu. com/job/ mir-android- raring- i386-build/ 327 jenkins. qa.ubuntu. com/job/ mir-clang- raring- amd64-build/ 210 jenkins. qa.ubuntu. com/job/ mir-quantal- amd64-ci/ 348 jenkins. qa.ubuntu. com/job/ mir-quantal- amd64-ci/ 348/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-vm- ci-build/ ./distribution= precise, flavor= amd64/148
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ mir-ci/ 343/rebuild
http://