Merge lp:~robertcarr/mir/enable-pointer-touch-input into lp:~mir-team/mir/trunk
- enable-pointer-touch-input
- Merge into trunk
Proposed by
Robert Carr
Status: | Superseded |
---|---|
Proposed branch: | lp:~robertcarr/mir/enable-pointer-touch-input |
Merge into: | lp:~mir-team/mir/trunk |
Diff against target: |
2645 lines (+1013/-387) 49 files modified
include/server/mir/default_server_configuration.h (+3/-3) include/server/mir/input/input_manager.h (+0/-1) include/server/mir/input/null_input_manager.h (+0/-5) include/server/mir/input/null_input_target_listener.h (+26/-11) include/server/mir/input/surface_target.h (+2/-0) include/server/mir/shell/application_session.h (+4/-1) include/server/mir/shell/input_focus_selector.h (+0/-52) include/server/mir/shell/input_target_listener.h (+59/-0) include/server/mir/shell/session_manager.h (+5/-2) include/server/mir/shell/single_visibility_focus_mechanism.h (+1/-4) include/server/mir/shell/surface.h (+1/-0) include/test/mir_test/event_matchers.h (+64/-0) include/test/mir_test/fake_event_hub_input_configuration.h (+2/-0) include/test/mir_test_doubles/mock_event_filter.h (+0/-32) include/test/mir_test_doubles/mock_input_focus_selector.h (+0/-40) include/test/mir_test_doubles/mock_input_target_listener.h (+49/-0) include/test/mir_test_doubles/stub_input_target_listener.h (+59/-0) include/test/mir_test_doubles/stub_surface_target.h (+4/-0) include/test/mir_test_framework/testing_server_configuration.h (+1/-1) src/server/default_server_configuration.cpp (+8/-8) src/server/display_server.cpp (+1/-1) src/server/input/android/android_dispatcher_controller.cpp (+73/-23) src/server/input/android/android_dispatcher_controller.h (+19/-6) src/server/input/android/android_input_window_handle.cpp (+8/-2) src/server/input/android/default_android_input_configuration.cpp (+6/-1) src/server/input/android/default_android_input_configuration.h (+2/-0) src/server/input/android/event_filter_dispatcher_policy.cpp (+6/-5) src/server/input/android/event_filter_dispatcher_policy.h (+2/-1) src/server/shell/application_session.cpp (+6/-2) src/server/shell/session_manager.cpp (+27/-10) src/server/shell/single_visibility_focus_mechanism.cpp (+2/-7) src/server/shell/surface.cpp (+12/-0) tests/acceptance-tests/test_client_input.cpp (+145/-35) tests/acceptance-tests/test_focus_selection.cpp (+21/-21) tests/death-tests/test_application_manager_death.cpp (+4/-3) tests/integration-tests/input/android/test_android_input_manager.cpp (+71/-12) tests/integration-tests/input/android/test_fake_event_hub_to_event_filter.cpp (+2/-1) tests/integration-tests/shell/test_session_manager.cpp (+24/-17) tests/mir_test_doubles/fake_event_hub.cpp (+2/-2) tests/mir_test_framework/testing_server_options.cpp (+3/-11) tests/unit-tests/input/android/test_android_dispatcher_controller.cpp (+138/-13) tests/unit-tests/input/android/test_android_input_window_handle.cpp (+11/-0) tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp (+15/-2) tests/unit-tests/shell/test_application_session.cpp (+11/-5) tests/unit-tests/shell/test_registration_order_focus_sequence.cpp (+16/-11) tests/unit-tests/shell/test_session_manager.cpp (+72/-8) tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp (+1/-24) tests/unit-tests/shell/test_surface.cpp (+18/-0) tests/unit-tests/shell/test_the_session_container_implementation.cpp (+7/-4) |
To merge this branch: | bzr merge lp:~robertcarr/mir/enable-pointer-touch-input |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir development team | Pending | ||
Review via email: mp+160151@code.launchpad.net |
This proposal has been superseded by a proposal from 2013-04-22.
Commit message
Enable motion events! (Pointer and touch input)
Description of the change
Enable motion events in the DispatcherPolicy and Window Handle. This branch is largely new acceptance tests! (small changes to event_filter_
To post a comment you must log in.
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-04-19 15:59:41 +0000 | |||
3 | +++ include/server/mir/default_server_configuration.h 2013-04-22 16:32:37 +0000 | |||
4 | @@ -50,7 +50,7 @@ | |||
5 | 50 | { | 50 | { |
6 | 51 | class SurfaceFactory; | 51 | class SurfaceFactory; |
7 | 52 | class SurfaceBuilder; | 52 | class SurfaceBuilder; |
9 | 53 | class InputFocusSelector; | 53 | class InputTargetListener; |
10 | 54 | class SessionContainer; | 54 | class SessionContainer; |
11 | 55 | class FocusSetter; | 55 | class FocusSetter; |
12 | 56 | class FocusSequence; | 56 | class FocusSequence; |
13 | @@ -156,7 +156,6 @@ | |||
14 | 156 | /** @name shell configuration - dependencies | 156 | /** @name shell configuration - dependencies |
15 | 157 | * dependencies of shell on the rest of the Mir | 157 | * dependencies of shell on the rest of the Mir |
16 | 158 | * @{ */ | 158 | * @{ */ |
17 | 159 | virtual std::shared_ptr<shell::InputFocusSelector> the_input_focus_selector(); | ||
18 | 160 | virtual std::shared_ptr<shell::SurfaceBuilder> the_surface_builder(); | 159 | virtual std::shared_ptr<shell::SurfaceBuilder> the_surface_builder(); |
19 | 161 | /** @} */ | 160 | /** @} */ |
20 | 162 | 161 | ||
21 | @@ -178,6 +177,7 @@ | |||
22 | 178 | * @{ */ | 177 | * @{ */ |
23 | 179 | virtual std::shared_ptr<input::android::InputConfiguration> the_input_configuration(); | 178 | virtual std::shared_ptr<input::android::InputConfiguration> the_input_configuration(); |
24 | 180 | virtual std::initializer_list<std::shared_ptr<input::EventFilter> const> the_event_filters(); | 179 | virtual std::initializer_list<std::shared_ptr<input::EventFilter> const> the_event_filters(); |
25 | 180 | virtual std::shared_ptr<shell::InputTargetListener> the_input_target_listener(); | ||
26 | 181 | /** @} */ | 181 | /** @} */ |
27 | 182 | 182 | ||
28 | 183 | /** @name logging configuration - customization | 183 | /** @name logging configuration - customization |
29 | @@ -197,7 +197,7 @@ | |||
30 | 197 | CachedPtr<frontend::Shell> session_manager; | 197 | CachedPtr<frontend::Shell> session_manager; |
31 | 198 | std::shared_ptr<input::android::InputConfiguration> input_configuration; | 198 | std::shared_ptr<input::android::InputConfiguration> input_configuration; |
32 | 199 | CachedPtr<input::InputManager> input_manager; | 199 | CachedPtr<input::InputManager> input_manager; |
34 | 200 | CachedPtr<shell::InputFocusSelector> input_focus_selector; | 200 | CachedPtr<shell::InputTargetListener> input_target_listener; |
35 | 201 | CachedPtr<graphics::Platform> graphics_platform; | 201 | CachedPtr<graphics::Platform> graphics_platform; |
36 | 202 | CachedPtr<graphics::BufferInitializer> buffer_initializer; | 202 | CachedPtr<graphics::BufferInitializer> buffer_initializer; |
37 | 203 | CachedPtr<compositor::GraphicBufferAllocator> buffer_allocator; | 203 | CachedPtr<compositor::GraphicBufferAllocator> buffer_allocator; |
38 | 204 | 204 | ||
39 | === modified file 'include/server/mir/input/input_manager.h' | |||
40 | --- include/server/mir/input/input_manager.h 2013-04-16 09:08:29 +0000 | |||
41 | +++ include/server/mir/input/input_manager.h 2013-04-22 16:32:37 +0000 | |||
42 | @@ -21,7 +21,6 @@ | |||
43 | 21 | #define MIR_INPUT_INPUT_MANAGER_H_ | 21 | #define MIR_INPUT_INPUT_MANAGER_H_ |
44 | 22 | 22 | ||
45 | 23 | #include "mir/input/input_channel_factory.h" | 23 | #include "mir/input/input_channel_factory.h" |
46 | 24 | #include "mir/shell/input_focus_selector.h" | ||
47 | 25 | 24 | ||
48 | 26 | #include <memory> | 25 | #include <memory> |
49 | 27 | 26 | ||
50 | 28 | 27 | ||
51 | === modified file 'include/server/mir/input/null_input_manager.h' | |||
52 | --- include/server/mir/input/null_input_manager.h 2013-04-16 09:08:29 +0000 | |||
53 | +++ include/server/mir/input/null_input_manager.h 2013-04-22 16:32:37 +0000 | |||
54 | @@ -40,11 +40,6 @@ | |||
55 | 40 | return std::shared_ptr<InputChannel>(); | 40 | return std::shared_ptr<InputChannel>(); |
56 | 41 | } | 41 | } |
57 | 42 | 42 | ||
58 | 43 | virtual void set_input_focus_to(std::shared_ptr<input::SessionTarget> const& /* session */, | ||
59 | 44 | std::shared_ptr<input::SurfaceTarget> const& /* surface */) | ||
60 | 45 | { | ||
61 | 46 | } | ||
62 | 47 | |||
63 | 48 | protected: | 43 | protected: |
64 | 49 | NullInputManager(const NullInputManager&) = delete; | 44 | NullInputManager(const NullInputManager&) = delete; |
65 | 50 | NullInputManager& operator=(const NullInputManager&) = delete; | 45 | NullInputManager& operator=(const NullInputManager&) = delete; |
66 | 51 | 46 | ||
67 | === renamed file 'include/server/mir/input/null_input_focus_selector.h' => 'include/server/mir/input/null_input_target_listener.h' | |||
68 | --- include/server/mir/input/null_input_focus_selector.h 2013-04-17 02:04:35 +0000 | |||
69 | +++ include/server/mir/input/null_input_target_listener.h 2013-04-22 16:32:37 +0000 | |||
70 | @@ -16,33 +16,48 @@ | |||
71 | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> |
72 | 17 | */ | 17 | */ |
73 | 18 | 18 | ||
76 | 19 | #ifndef MIR_INPUT_NULL_INPUT_FOCUS_SELECTOR_H_ | 19 | #ifndef MIR_INPUT_NULL_INPUT_TARGET_LISTENER_H_ |
77 | 20 | #define MIR_INPUT_NULL_INPUT_FOCUS_SELECTOR_H_ | 20 | #define MIR_INPUT_NULL_INPUT_TARGET_LISTENER_H_ |
78 | 21 | 21 | ||
80 | 22 | #include "mir/shell/input_focus_selector.h" | 22 | #include "mir/shell/input_target_listener.h" |
81 | 23 | 23 | ||
82 | 24 | namespace mir | 24 | namespace mir |
83 | 25 | { | 25 | { |
84 | 26 | namespace input | 26 | namespace input |
85 | 27 | { | 27 | { |
86 | 28 | 28 | ||
88 | 29 | class NullInputFocusSelector : public shell::InputFocusSelector | 29 | class NullInputTargetListener : public shell::InputTargetListener |
89 | 30 | { | 30 | { |
90 | 31 | public: | 31 | public: |
93 | 32 | NullInputFocusSelector() {}; | 32 | NullInputTargetListener() {}; |
94 | 33 | virtual ~NullInputFocusSelector() {} | 33 | virtual ~NullInputTargetListener() noexcept(true) {} |
95 | 34 | 34 | ||
98 | 35 | virtual void set_input_focus_to(std::shared_ptr<input::SessionTarget> const&, | 35 | virtual void input_application_opened(std::shared_ptr<input::SessionTarget> const&) |
99 | 36 | std::shared_ptr<input::SurfaceTarget> const&) | 36 | { |
100 | 37 | } | ||
101 | 38 | virtual void input_application_closed(std::shared_ptr<input::SessionTarget> const&) | ||
102 | 39 | { | ||
103 | 40 | } | ||
104 | 41 | virtual void input_surface_opened(std::shared_ptr<input::SessionTarget> const&, | ||
105 | 42 | std::shared_ptr<input::SurfaceTarget> const&) | ||
106 | 43 | { | ||
107 | 44 | } | ||
108 | 45 | virtual void input_surface_closed(std::shared_ptr<input::SurfaceTarget> const&) | ||
109 | 46 | { | ||
110 | 47 | } | ||
111 | 48 | virtual void focus_changed(std::shared_ptr<input::SurfaceTarget> const&) | ||
112 | 49 | { | ||
113 | 50 | } | ||
114 | 51 | virtual void focus_cleared() | ||
115 | 37 | { | 52 | { |
116 | 38 | } | 53 | } |
117 | 39 | 54 | ||
118 | 40 | protected: | 55 | protected: |
121 | 41 | NullInputFocusSelector(const NullInputFocusSelector&) = delete; | 56 | NullInputTargetListener(const NullInputTargetListener&) = delete; |
122 | 42 | NullInputFocusSelector& operator=(const NullInputFocusSelector&) = delete; | 57 | NullInputTargetListener& operator=(const NullInputTargetListener&) = delete; |
123 | 43 | }; | 58 | }; |
124 | 44 | 59 | ||
125 | 45 | } | 60 | } |
126 | 46 | } | 61 | } |
127 | 47 | 62 | ||
129 | 48 | #endif // MIR_INPUT_NULL_INPUT_FOCUS_SELECTOR_H_ | 63 | #endif // MIR_INPUT_NULL_INPUT_TARGET_LISTENER_H_ |
130 | 49 | 64 | ||
131 | === modified file 'include/server/mir/input/surface_target.h' | |||
132 | --- include/server/mir/input/surface_target.h 2013-04-16 09:08:29 +0000 | |||
133 | +++ include/server/mir/input/surface_target.h 2013-04-22 16:32:37 +0000 | |||
134 | @@ -20,6 +20,7 @@ | |||
135 | 20 | #define MIR_INPUT_SURFACE_TARGET_H_ | 20 | #define MIR_INPUT_SURFACE_TARGET_H_ |
136 | 21 | 21 | ||
137 | 22 | #include "mir/geometry/size.h" | 22 | #include "mir/geometry/size.h" |
138 | 23 | #include "mir/geometry/point.h" | ||
139 | 23 | 24 | ||
140 | 24 | #include <string> | 25 | #include <string> |
141 | 25 | 26 | ||
142 | @@ -33,6 +34,7 @@ | |||
143 | 33 | public: | 34 | public: |
144 | 34 | virtual ~SurfaceTarget() {} | 35 | virtual ~SurfaceTarget() {} |
145 | 35 | 36 | ||
146 | 37 | virtual geometry::Point top_left() const = 0; | ||
147 | 36 | virtual geometry::Size size() const = 0; | 38 | virtual geometry::Size size() const = 0; |
148 | 37 | virtual std::string name() const = 0; | 39 | virtual std::string name() const = 0; |
149 | 38 | 40 | ||
150 | 39 | 41 | ||
151 | === modified file 'include/server/mir/shell/application_session.h' | |||
152 | --- include/server/mir/shell/application_session.h 2013-04-16 17:42:26 +0000 | |||
153 | +++ include/server/mir/shell/application_session.h 2013-04-22 16:32:37 +0000 | |||
154 | @@ -30,11 +30,13 @@ | |||
155 | 30 | { | 30 | { |
156 | 31 | class SurfaceFactory; | 31 | class SurfaceFactory; |
157 | 32 | class Surface; | 32 | class Surface; |
158 | 33 | class InputTargetListener; | ||
159 | 33 | 34 | ||
160 | 34 | class ApplicationSession : public Session | 35 | class ApplicationSession : public Session |
161 | 35 | { | 36 | { |
162 | 36 | public: | 37 | public: |
164 | 37 | explicit ApplicationSession(std::shared_ptr<SurfaceFactory> const& surface_factory, std::string const& session_name); | 38 | explicit ApplicationSession(std::shared_ptr<SurfaceFactory> const& surface_factory, |
165 | 39 | std::shared_ptr<InputTargetListener> const& input_target_listener, std::string const& session_name); | ||
166 | 38 | ~ApplicationSession(); | 40 | ~ApplicationSession(); |
167 | 39 | 41 | ||
168 | 40 | frontend::SurfaceId create_surface(frontend::SurfaceCreationParameters const& params); | 42 | frontend::SurfaceId create_surface(frontend::SurfaceCreationParameters const& params); |
169 | @@ -58,6 +60,7 @@ | |||
170 | 58 | 60 | ||
171 | 59 | private: | 61 | private: |
172 | 60 | std::shared_ptr<SurfaceFactory> const surface_factory; | 62 | std::shared_ptr<SurfaceFactory> const surface_factory; |
173 | 63 | std::shared_ptr<InputTargetListener> const input_target_listener; | ||
174 | 61 | std::string const session_name; | 64 | std::string const session_name; |
175 | 62 | 65 | ||
176 | 63 | frontend::SurfaceId next_id(); | 66 | frontend::SurfaceId next_id(); |
177 | 64 | 67 | ||
178 | === removed file 'include/server/mir/shell/input_focus_selector.h' | |||
179 | --- include/server/mir/shell/input_focus_selector.h 2013-04-16 09:08:29 +0000 | |||
180 | +++ include/server/mir/shell/input_focus_selector.h 1970-01-01 00:00:00 +0000 | |||
181 | @@ -1,52 +0,0 @@ | |||
182 | 1 | /* | ||
183 | 2 | * Copyright © 2013 Canonical Ltd. | ||
184 | 3 | * | ||
185 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
186 | 5 | * under the terms of the GNU General Public License version 3, | ||
187 | 6 | * as published by the Free Software Foundation. | ||
188 | 7 | * | ||
189 | 8 | * This program is distributed in the hope that it will be useful, | ||
190 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
191 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
192 | 11 | * GNU General Public License for more details. | ||
193 | 12 | * | ||
194 | 13 | * You should have received a copy of the GNU General Public License | ||
195 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
196 | 15 | * | ||
197 | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> | ||
198 | 17 | */ | ||
199 | 18 | |||
200 | 19 | #ifndef MIR_SHELL_INPUT_FOCUS_SELECTOR_H_ | ||
201 | 20 | #define MIR_SHELL_INPUT_FOCUS_SELECTOR_H_ | ||
202 | 21 | |||
203 | 22 | #include <memory> | ||
204 | 23 | |||
205 | 24 | namespace mir | ||
206 | 25 | { | ||
207 | 26 | namespace input | ||
208 | 27 | { | ||
209 | 28 | class SessionTarget; | ||
210 | 29 | class SurfaceTarget; | ||
211 | 30 | } | ||
212 | 31 | |||
213 | 32 | namespace shell | ||
214 | 33 | { | ||
215 | 34 | |||
216 | 35 | class InputFocusSelector | ||
217 | 36 | { | ||
218 | 37 | public: | ||
219 | 38 | virtual ~InputFocusSelector() {} | ||
220 | 39 | |||
221 | 40 | virtual void set_input_focus_to(std::shared_ptr<input::SessionTarget> const& focus_application, | ||
222 | 41 | std::shared_ptr<input::SurfaceTarget> const& focus_surface) = 0; | ||
223 | 42 | |||
224 | 43 | protected: | ||
225 | 44 | InputFocusSelector() = default; | ||
226 | 45 | InputFocusSelector(InputFocusSelector const&) = delete; | ||
227 | 46 | InputFocusSelector& operator=(InputFocusSelector const&) = delete; | ||
228 | 47 | }; | ||
229 | 48 | |||
230 | 49 | } | ||
231 | 50 | } // namespace mir | ||
232 | 51 | |||
233 | 52 | #endif // MIR_SHELL_INPUT_FOCUS_SELECTOR_H_ | ||
234 | 53 | 0 | ||
235 | === added file 'include/server/mir/shell/input_target_listener.h' | |||
236 | --- include/server/mir/shell/input_target_listener.h 1970-01-01 00:00:00 +0000 | |||
237 | +++ include/server/mir/shell/input_target_listener.h 2013-04-22 16:32:37 +0000 | |||
238 | @@ -0,0 +1,59 @@ | |||
239 | 1 | /* | ||
240 | 2 | * Copyright © 2013 Canonical Ltd. | ||
241 | 3 | * | ||
242 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
243 | 5 | * under the terms of the GNU General Public License version 3, | ||
244 | 6 | * as published by the Free Software Foundation. | ||
245 | 7 | * | ||
246 | 8 | * This program is distributed in the hope that it will be useful, | ||
247 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
248 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
249 | 11 | * GNU General Public License for more details. | ||
250 | 12 | * | ||
251 | 13 | * You should have received a copy of the GNU General Public License | ||
252 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
253 | 15 | * | ||
254 | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> | ||
255 | 17 | */ | ||
256 | 18 | |||
257 | 19 | #ifndef MIR_SHELL_INPUT_TARGET_LISTENER_H_ | ||
258 | 20 | #define MIR_SHELL_INPUT_TARGET_LISTENER_H_ | ||
259 | 21 | |||
260 | 22 | #include <memory> | ||
261 | 23 | |||
262 | 24 | namespace mir | ||
263 | 25 | { | ||
264 | 26 | namespace input | ||
265 | 27 | { | ||
266 | 28 | class SessionTarget; | ||
267 | 29 | class SurfaceTarget; | ||
268 | 30 | } | ||
269 | 31 | |||
270 | 32 | namespace shell | ||
271 | 33 | { | ||
272 | 34 | |||
273 | 35 | class InputTargetListener | ||
274 | 36 | { | ||
275 | 37 | public: | ||
276 | 38 | virtual ~InputTargetListener() = default; | ||
277 | 39 | |||
278 | 40 | virtual void input_application_opened(std::shared_ptr<input::SessionTarget> const& application) = 0; | ||
279 | 41 | virtual void input_application_closed(std::shared_ptr<input::SessionTarget> const& application) = 0; | ||
280 | 42 | |||
281 | 43 | virtual void input_surface_opened(std::shared_ptr<input::SessionTarget> const& application, | ||
282 | 44 | std::shared_ptr<input::SurfaceTarget> const& opened_surface) = 0; | ||
283 | 45 | virtual void input_surface_closed(std::shared_ptr<input::SurfaceTarget> const& closed_surface) = 0; | ||
284 | 46 | |||
285 | 47 | virtual void focus_changed(std::shared_ptr<input::SurfaceTarget> const& focus_surface) = 0; | ||
286 | 48 | virtual void focus_cleared() = 0; | ||
287 | 49 | |||
288 | 50 | protected: | ||
289 | 51 | InputTargetListener() = default; | ||
290 | 52 | InputTargetListener(InputTargetListener const&) = delete; | ||
291 | 53 | InputTargetListener& operator=(InputTargetListener const&) = delete; | ||
292 | 54 | }; | ||
293 | 55 | |||
294 | 56 | } | ||
295 | 57 | } // namespace mir | ||
296 | 58 | |||
297 | 59 | #endif // MIR_SHELL_INPUT_TARGET_LISTENER_H_ | ||
298 | 0 | 60 | ||
299 | === modified file 'include/server/mir/shell/session_manager.h' | |||
300 | --- include/server/mir/shell/session_manager.h 2013-04-19 09:15:31 +0000 | |||
301 | +++ include/server/mir/shell/session_manager.h 2013-04-22 16:32:37 +0000 | |||
302 | @@ -40,15 +40,17 @@ | |||
303 | 40 | class SessionContainer; | 40 | class SessionContainer; |
304 | 41 | class FocusSequence; | 41 | class FocusSequence; |
305 | 42 | class FocusSetter; | 42 | class FocusSetter; |
306 | 43 | class InputTargetListener; | ||
307 | 43 | class Session; | 44 | class Session; |
308 | 44 | 45 | ||
309 | 45 | class SessionManager : public frontend::Shell | 46 | class SessionManager : public frontend::Shell |
310 | 46 | { | 47 | { |
311 | 47 | public: | 48 | public: |
312 | 48 | explicit SessionManager(std::shared_ptr<SurfaceFactory> const& surface_factory, | 49 | explicit SessionManager(std::shared_ptr<SurfaceFactory> const& surface_factory, |
314 | 49 | std::shared_ptr<SessionContainer> const& session_container, | 50 | std::shared_ptr<SessionContainer> const& app_container, |
315 | 50 | std::shared_ptr<FocusSequence> const& focus_sequence, | 51 | std::shared_ptr<FocusSequence> const& focus_sequence, |
317 | 51 | std::shared_ptr<FocusSetter> const& focus_setter); | 52 | std::shared_ptr<FocusSetter> const& focus_setter, |
318 | 53 | std::shared_ptr<InputTargetListener> const& input_target_listener); | ||
319 | 52 | virtual ~SessionManager(); | 54 | virtual ~SessionManager(); |
320 | 53 | 55 | ||
321 | 54 | virtual std::shared_ptr<frontend::Session> open_session(std::string const& name); | 56 | virtual std::shared_ptr<frontend::Session> open_session(std::string const& name); |
322 | @@ -71,6 +73,7 @@ | |||
323 | 71 | std::shared_ptr<SessionContainer> const app_container; | 73 | std::shared_ptr<SessionContainer> const app_container; |
324 | 72 | std::shared_ptr<FocusSequence> const focus_sequence; | 74 | std::shared_ptr<FocusSequence> const focus_sequence; |
325 | 73 | std::shared_ptr<FocusSetter> const focus_setter; | 75 | std::shared_ptr<FocusSetter> const focus_setter; |
326 | 76 | std::shared_ptr<InputTargetListener> const input_target_listener; | ||
327 | 74 | 77 | ||
328 | 75 | std::mutex mutex; | 78 | std::mutex mutex; |
329 | 76 | std::weak_ptr<Session> focus_application; | 79 | std::weak_ptr<Session> focus_application; |
330 | 77 | 80 | ||
331 | === modified file 'include/server/mir/shell/single_visibility_focus_mechanism.h' | |||
332 | --- include/server/mir/shell/single_visibility_focus_mechanism.h 2013-04-16 09:08:29 +0000 | |||
333 | +++ include/server/mir/shell/single_visibility_focus_mechanism.h 2013-04-22 16:32:37 +0000 | |||
334 | @@ -28,13 +28,11 @@ | |||
335 | 28 | namespace shell | 28 | namespace shell |
336 | 29 | { | 29 | { |
337 | 30 | class SessionContainer; | 30 | class SessionContainer; |
338 | 31 | class InputFocusSelector; | ||
339 | 32 | 31 | ||
340 | 33 | class SingleVisibilityFocusMechanism : public FocusSetter | 32 | class SingleVisibilityFocusMechanism : public FocusSetter |
341 | 34 | { | 33 | { |
342 | 35 | public: | 34 | public: |
345 | 36 | explicit SingleVisibilityFocusMechanism(std::shared_ptr<SessionContainer> const& app_container, | 35 | explicit SingleVisibilityFocusMechanism(std::shared_ptr<SessionContainer> const& app_container); |
344 | 37 | std::shared_ptr<shell::InputFocusSelector> const& input_selector); | ||
346 | 38 | virtual ~SingleVisibilityFocusMechanism() {} | 36 | virtual ~SingleVisibilityFocusMechanism() {} |
347 | 39 | 37 | ||
348 | 40 | void set_focus_to(std::shared_ptr<shell::Session> const& new_focus); | 38 | void set_focus_to(std::shared_ptr<shell::Session> const& new_focus); |
349 | @@ -44,7 +42,6 @@ | |||
350 | 44 | SingleVisibilityFocusMechanism& operator=(const SingleVisibilityFocusMechanism&) = delete; | 42 | SingleVisibilityFocusMechanism& operator=(const SingleVisibilityFocusMechanism&) = delete; |
351 | 45 | private: | 43 | private: |
352 | 46 | std::shared_ptr<SessionContainer> const app_container; | 44 | std::shared_ptr<SessionContainer> const app_container; |
353 | 47 | std::shared_ptr<shell::InputFocusSelector> const input_selector; | ||
354 | 48 | }; | 45 | }; |
355 | 49 | 46 | ||
356 | 50 | } | 47 | } |
357 | 51 | 48 | ||
358 | === modified file 'include/server/mir/shell/surface.h' | |||
359 | --- include/server/mir/shell/surface.h 2013-04-16 17:42:26 +0000 | |||
360 | +++ include/server/mir/shell/surface.h 2013-04-22 16:32:37 +0000 | |||
361 | @@ -63,6 +63,7 @@ | |||
362 | 63 | virtual std::string name() const; | 63 | virtual std::string name() const; |
363 | 64 | 64 | ||
364 | 65 | virtual geometry::Size size() const; | 65 | virtual geometry::Size size() const; |
365 | 66 | virtual geometry::Point top_left() const; | ||
366 | 66 | 67 | ||
367 | 67 | virtual geometry::PixelFormat pixel_format() const; | 68 | virtual geometry::PixelFormat pixel_format() const; |
368 | 68 | 69 | ||
369 | 69 | 70 | ||
370 | === added file 'include/test/mir_test/event_matchers.h' | |||
371 | --- include/test/mir_test/event_matchers.h 1970-01-01 00:00:00 +0000 | |||
372 | +++ include/test/mir_test/event_matchers.h 2013-04-22 16:32:37 +0000 | |||
373 | @@ -0,0 +1,64 @@ | |||
374 | 1 | /* | ||
375 | 2 | * Copyright © 2013 Canonical Ltd. | ||
376 | 3 | * | ||
377 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
378 | 5 | * under the terms of the GNU General Public License version 3, | ||
379 | 6 | * as published by the Free Software Foundation. | ||
380 | 7 | * | ||
381 | 8 | * This program is distributed in the hope that it will be useful, | ||
382 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
383 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
384 | 11 | * GNU General Public License for more details. | ||
385 | 12 | * | ||
386 | 13 | * You should have received a copy of the GNU General Public License | ||
387 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
388 | 15 | * | ||
389 | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> | ||
390 | 17 | */ | ||
391 | 18 | |||
392 | 19 | #ifndef MIR_TEST_EVENT_MATCHERS_H_ | ||
393 | 20 | #define MIR_TEST_EVENT_MATCHERS_H_ | ||
394 | 21 | |||
395 | 22 | #include <androidfw/Input.h> | ||
396 | 23 | |||
397 | 24 | #include <gmock/gmock.h> | ||
398 | 25 | |||
399 | 26 | namespace mir | ||
400 | 27 | { | ||
401 | 28 | namespace test | ||
402 | 29 | { | ||
403 | 30 | |||
404 | 31 | MATCHER_P(IsKeyEventWithKey, key, "") | ||
405 | 32 | { | ||
406 | 33 | if (arg.type != mir_event_type_key) | ||
407 | 34 | return false; | ||
408 | 35 | |||
409 | 36 | return arg.key.key_code == key; | ||
410 | 37 | } | ||
411 | 38 | MATCHER(KeyDownEvent, "") | ||
412 | 39 | { | ||
413 | 40 | if (arg.type != mir_event_type_key) | ||
414 | 41 | return false; | ||
415 | 42 | |||
416 | 43 | return arg.key.action == AKEY_EVENT_ACTION_DOWN; | ||
417 | 44 | } | ||
418 | 45 | MATCHER(ButtonDownEvent, "") | ||
419 | 46 | { | ||
420 | 47 | if (arg.type != mir_event_type_motion) | ||
421 | 48 | return false; | ||
422 | 49 | if (arg.motion.button_state == 0) | ||
423 | 50 | return false; | ||
424 | 51 | return arg.motion.action == AMOTION_EVENT_ACTION_DOWN; | ||
425 | 52 | } | ||
426 | 53 | MATCHER_P2(MotionEvent, dx, dy, "") | ||
427 | 54 | { | ||
428 | 55 | if (arg.type != mir_event_type_motion) | ||
429 | 56 | return false; | ||
430 | 57 | auto coords = &arg.motion.pointer_coordinates[0]; | ||
431 | 58 | return (coords->x == dx) && (coords->y == dy); | ||
432 | 59 | } | ||
433 | 60 | |||
434 | 61 | } | ||
435 | 62 | } // namespace mir | ||
436 | 63 | |||
437 | 64 | #endif // MIR_TEST_EVENT_MATCHERS_H_ | ||
438 | 0 | 65 | ||
439 | === modified file 'include/test/mir_test/fake_event_hub_input_configuration.h' | |||
440 | --- include/test/mir_test/fake_event_hub_input_configuration.h 2013-04-16 09:08:29 +0000 | |||
441 | +++ include/test/mir_test/fake_event_hub_input_configuration.h 2013-04-22 16:32:37 +0000 | |||
442 | @@ -63,6 +63,8 @@ | |||
443 | 63 | 63 | ||
444 | 64 | droidinput::sp<droidinput::EventHubInterface> the_event_hub(); | 64 | droidinput::sp<droidinput::EventHubInterface> the_event_hub(); |
445 | 65 | input::android::FakeEventHub* the_fake_event_hub(); | 65 | input::android::FakeEventHub* the_fake_event_hub(); |
446 | 66 | |||
447 | 67 | bool is_key_repeat_enabled() override { return false; } | ||
448 | 66 | 68 | ||
449 | 67 | 69 | ||
450 | 68 | protected: | 70 | protected: |
451 | 69 | 71 | ||
452 | === modified file 'include/test/mir_test_doubles/mock_event_filter.h' | |||
453 | --- include/test/mir_test_doubles/mock_event_filter.h 2013-04-16 09:08:29 +0000 | |||
454 | +++ include/test/mir_test_doubles/mock_event_filter.h 2013-04-22 16:32:37 +0000 | |||
455 | @@ -21,8 +21,6 @@ | |||
456 | 21 | 21 | ||
457 | 22 | #include "mir/input/event_filter.h" | 22 | #include "mir/input/event_filter.h" |
458 | 23 | 23 | ||
459 | 24 | #include <androidfw/Input.h> | ||
460 | 25 | |||
461 | 26 | #include <gmock/gmock.h> | 24 | #include <gmock/gmock.h> |
462 | 27 | 25 | ||
463 | 28 | namespace mir | 26 | namespace mir |
464 | @@ -36,36 +34,6 @@ | |||
465 | 36 | MOCK_METHOD1(handles, bool(const MirEvent&)); | 34 | MOCK_METHOD1(handles, bool(const MirEvent&)); |
466 | 37 | }; | 35 | }; |
467 | 38 | } | 36 | } |
468 | 39 | |||
469 | 40 | MATCHER_P(IsKeyEventWithKey, key, "") | ||
470 | 41 | { | ||
471 | 42 | if (arg.type != mir_event_type_key) | ||
472 | 43 | return false; | ||
473 | 44 | |||
474 | 45 | return arg.key.key_code == key; | ||
475 | 46 | } | ||
476 | 47 | MATCHER(KeyDownEvent, "") | ||
477 | 48 | { | ||
478 | 49 | if (arg.type != mir_event_type_key) | ||
479 | 50 | return false; | ||
480 | 51 | |||
481 | 52 | return arg.key.action == AKEY_EVENT_ACTION_DOWN; | ||
482 | 53 | } | ||
483 | 54 | MATCHER(ButtonDownEvent, "") | ||
484 | 55 | { | ||
485 | 56 | if (arg.type != mir_event_type_motion) | ||
486 | 57 | return false; | ||
487 | 58 | if (arg.motion.button_state == 0) | ||
488 | 59 | return false; | ||
489 | 60 | return arg.motion.action == AKEY_EVENT_ACTION_DOWN; | ||
490 | 61 | } | ||
491 | 62 | MATCHER_P2(MotionEvent, dx, dy, "") | ||
492 | 63 | { | ||
493 | 64 | if (arg.type != mir_event_type_motion) | ||
494 | 65 | return false; | ||
495 | 66 | auto coords = &arg.motion.pointer_coordinates[0]; | ||
496 | 67 | return (coords->x == dx) && (coords->y == dy); | ||
497 | 68 | } | ||
498 | 69 | } | 37 | } |
499 | 70 | } | 38 | } |
500 | 71 | 39 | ||
501 | 72 | 40 | ||
502 | === removed file 'include/test/mir_test_doubles/mock_input_focus_selector.h' | |||
503 | --- include/test/mir_test_doubles/mock_input_focus_selector.h 2013-04-16 09:08:29 +0000 | |||
504 | +++ include/test/mir_test_doubles/mock_input_focus_selector.h 1970-01-01 00:00:00 +0000 | |||
505 | @@ -1,40 +0,0 @@ | |||
506 | 1 | /* | ||
507 | 2 | * Copyright © 2013 Canonical Ltd. | ||
508 | 3 | * | ||
509 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
510 | 5 | * under the terms of the GNU General Public License version 3, | ||
511 | 6 | * as published by the Free Software Foundation. | ||
512 | 7 | * | ||
513 | 8 | * This program is distributed in the hope that it will be useful, | ||
514 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
515 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
516 | 11 | * GNU General Public License for more details. | ||
517 | 12 | * | ||
518 | 13 | * You should have received a copy of the GNU General Public License | ||
519 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
520 | 15 | * | ||
521 | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> | ||
522 | 17 | */ | ||
523 | 18 | |||
524 | 19 | #ifndef MIR_TEST_DOUBLES_MOCK_INPUT_FOCUS_SELECTOR_H_ | ||
525 | 20 | #define MIR_TEST_DOUBLES_MOCK_INPUT_FOCUS_SELECTOR_H_ | ||
526 | 21 | |||
527 | 22 | #include "mir/shell/input_focus_selector.h" | ||
528 | 23 | |||
529 | 24 | namespace mir | ||
530 | 25 | { | ||
531 | 26 | namespace test | ||
532 | 27 | { | ||
533 | 28 | namespace doubles | ||
534 | 29 | { | ||
535 | 30 | |||
536 | 31 | struct MockInputFocusSelector : public shell::InputFocusSelector | ||
537 | 32 | { | ||
538 | 33 | MOCK_METHOD2(set_input_focus_to, void(std::shared_ptr<input::SessionTarget> const&, std::shared_ptr<input::SurfaceTarget> const&)); | ||
539 | 34 | }; | ||
540 | 35 | |||
541 | 36 | } | ||
542 | 37 | } | ||
543 | 38 | } // namespace mir | ||
544 | 39 | |||
545 | 40 | #endif // MIR_TEST_DOUBLES_MOCK_INPUT_FOCUS_SELECTOR_H_ | ||
546 | 41 | 0 | ||
547 | === added file 'include/test/mir_test_doubles/mock_input_target_listener.h' | |||
548 | --- include/test/mir_test_doubles/mock_input_target_listener.h 1970-01-01 00:00:00 +0000 | |||
549 | +++ include/test/mir_test_doubles/mock_input_target_listener.h 2013-04-22 16:32:37 +0000 | |||
550 | @@ -0,0 +1,49 @@ | |||
551 | 1 | /* | ||
552 | 2 | * Copyright © 2013 Canonical Ltd. | ||
553 | 3 | * | ||
554 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
555 | 5 | * under the terms of the GNU General Public License version 3, | ||
556 | 6 | * as published by the Free Software Foundation. | ||
557 | 7 | * | ||
558 | 8 | * This program is distributed in the hope that it will be useful, | ||
559 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
560 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
561 | 11 | * GNU General Public License for more details. | ||
562 | 12 | * | ||
563 | 13 | * You should have received a copy of the GNU General Public License | ||
564 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
565 | 15 | * | ||
566 | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> | ||
567 | 17 | */ | ||
568 | 18 | |||
569 | 19 | #ifndef MIR_TEST_DOUBLES_MOCK_INPUT_TARGET_LISTENER_H_ | ||
570 | 20 | #define MIR_TEST_DOUBLES_MOCK_INPUT_TARGET_LISTENER_H_ | ||
571 | 21 | |||
572 | 22 | #include "mir/shell/input_target_listener.h" | ||
573 | 23 | |||
574 | 24 | #include <gmock/gmock.h> | ||
575 | 25 | |||
576 | 26 | namespace mir | ||
577 | 27 | { | ||
578 | 28 | namespace test | ||
579 | 29 | { | ||
580 | 30 | namespace doubles | ||
581 | 31 | { | ||
582 | 32 | |||
583 | 33 | struct MockInputTargetListener : public shell::InputTargetListener | ||
584 | 34 | { | ||
585 | 35 | virtual ~MockInputTargetListener() noexcept(true) {} | ||
586 | 36 | MOCK_METHOD1(input_application_opened, void(std::shared_ptr<input::SessionTarget> const& application)); | ||
587 | 37 | MOCK_METHOD1(input_application_closed, void(std::shared_ptr<input::SessionTarget> const& application)); | ||
588 | 38 | MOCK_METHOD2(input_surface_opened, void(std::shared_ptr<input::SessionTarget> const& application, | ||
589 | 39 | std::shared_ptr<input::SurfaceTarget> const& opened_surface)); | ||
590 | 40 | MOCK_METHOD1(input_surface_closed, void(std::shared_ptr<input::SurfaceTarget> const& closed_surface)); | ||
591 | 41 | MOCK_METHOD1(focus_changed, void(std::shared_ptr<input::SurfaceTarget> const& focus_surface)); | ||
592 | 42 | MOCK_METHOD0(focus_cleared, void()); | ||
593 | 43 | }; | ||
594 | 44 | |||
595 | 45 | } | ||
596 | 46 | } | ||
597 | 47 | } // namespace mir | ||
598 | 48 | |||
599 | 49 | #endif // MIR_TEST_DOUBLES_MOCK_INPUT_TARGET_LISTENER_H_ | ||
600 | 0 | 50 | ||
601 | === added file 'include/test/mir_test_doubles/stub_input_target_listener.h' | |||
602 | --- include/test/mir_test_doubles/stub_input_target_listener.h 1970-01-01 00:00:00 +0000 | |||
603 | +++ include/test/mir_test_doubles/stub_input_target_listener.h 2013-04-22 16:32:37 +0000 | |||
604 | @@ -0,0 +1,59 @@ | |||
605 | 1 | /* | ||
606 | 2 | * Copyright © 2013 Canonical Ltd. | ||
607 | 3 | * | ||
608 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
609 | 5 | * under the terms of the GNU General Public License version 3, | ||
610 | 6 | * as published by the Free Software Foundation. | ||
611 | 7 | * | ||
612 | 8 | * This program is distributed in the hope that it will be useful, | ||
613 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
614 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
615 | 11 | * GNU General Public License for more details. | ||
616 | 12 | * | ||
617 | 13 | * You should have received a copy of the GNU General Public License | ||
618 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
619 | 15 | * | ||
620 | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> | ||
621 | 17 | */ | ||
622 | 18 | |||
623 | 19 | #ifndef MIR_TEST_DOUBLES_STUB_INPUT_LISTENER_H_ | ||
624 | 20 | #define MIR_TEST_DOUBLES_STUB_INPUT_LISTENER_H_ | ||
625 | 21 | |||
626 | 22 | #include "mir/shell/input_target_listener.h" | ||
627 | 23 | |||
628 | 24 | namespace mir | ||
629 | 25 | { | ||
630 | 26 | namespace test | ||
631 | 27 | { | ||
632 | 28 | namespace doubles | ||
633 | 29 | { | ||
634 | 30 | |||
635 | 31 | struct StubInputTargetListener : public shell::InputTargetListener | ||
636 | 32 | { | ||
637 | 33 | void input_application_opened(std::shared_ptr<input::SessionTarget> const&) | ||
638 | 34 | { | ||
639 | 35 | } | ||
640 | 36 | void input_application_closed(std::shared_ptr<input::SessionTarget> const&) | ||
641 | 37 | { | ||
642 | 38 | } | ||
643 | 39 | void input_surface_opened(std::shared_ptr<input::SessionTarget> const&, | ||
644 | 40 | std::shared_ptr<input::SurfaceTarget> const&) | ||
645 | 41 | { | ||
646 | 42 | } | ||
647 | 43 | void input_surface_closed(std::shared_ptr<input::SurfaceTarget> const&) | ||
648 | 44 | { | ||
649 | 45 | } | ||
650 | 46 | void focus_changed(std::shared_ptr<input::SurfaceTarget> const&) | ||
651 | 47 | { | ||
652 | 48 | } | ||
653 | 49 | |||
654 | 50 | void focus_cleared() | ||
655 | 51 | { | ||
656 | 52 | } | ||
657 | 53 | }; | ||
658 | 54 | |||
659 | 55 | } | ||
660 | 56 | } | ||
661 | 57 | } // namespace mir | ||
662 | 58 | |||
663 | 59 | #endif // MIR_TEST_DOUBLES_STUB_INPUT_LISTENER_H_ | ||
664 | 0 | 60 | ||
665 | === modified file 'include/test/mir_test_doubles/stub_surface_target.h' | |||
666 | --- include/test/mir_test_doubles/stub_surface_target.h 2013-04-16 09:08:29 +0000 | |||
667 | +++ include/test/mir_test_doubles/stub_surface_target.h 2013-04-22 16:32:37 +0000 | |||
668 | @@ -43,6 +43,10 @@ | |||
669 | 43 | { | 43 | { |
670 | 44 | return geometry::Size(); | 44 | return geometry::Size(); |
671 | 45 | } | 45 | } |
672 | 46 | geometry::Point top_left() const override | ||
673 | 47 | { | ||
674 | 48 | return geometry::Point(); | ||
675 | 49 | } | ||
676 | 46 | std::string name() const override | 50 | std::string name() const override |
677 | 47 | { | 51 | { |
678 | 48 | return std::string(); | 52 | return std::string(); |
679 | 49 | 53 | ||
680 | === modified file 'include/test/mir_test_framework/testing_server_configuration.h' | |||
681 | --- include/test/mir_test_framework/testing_server_configuration.h 2013-04-16 09:08:29 +0000 | |||
682 | +++ include/test/mir_test_framework/testing_server_configuration.h 2013-04-22 16:32:37 +0000 | |||
683 | @@ -49,7 +49,7 @@ | |||
684 | 49 | // to avoid starting and stopping the full android input stack for tests | 49 | // to avoid starting and stopping the full android input stack for tests |
685 | 50 | // which do not leverage input. | 50 | // which do not leverage input. |
686 | 51 | std::shared_ptr<input::InputManager> the_input_manager(); | 51 | std::shared_ptr<input::InputManager> the_input_manager(); |
688 | 52 | std::shared_ptr<shell::InputFocusSelector> the_input_focus_selector(); | 52 | std::shared_ptr<shell::InputTargetListener> the_input_target_listener(); |
689 | 53 | 53 | ||
690 | 54 | virtual std::string the_socket_file() const; | 54 | virtual std::string the_socket_file() const; |
691 | 55 | using DefaultServerConfiguration::the_options; | 55 | using DefaultServerConfiguration::the_options; |
692 | 56 | 56 | ||
693 | === modified file 'src/server/default_server_configuration.cpp' | |||
694 | --- src/server/default_server_configuration.cpp 2013-04-19 12:49:42 +0000 | |||
695 | +++ src/server/default_server_configuration.cpp 2013-04-22 16:32:37 +0000 | |||
696 | @@ -45,7 +45,7 @@ | |||
697 | 45 | #include "mir/graphics/buffer_initializer.h" | 45 | #include "mir/graphics/buffer_initializer.h" |
698 | 46 | #include "mir/graphics/null_display_report.h" | 46 | #include "mir/graphics/null_display_report.h" |
699 | 47 | #include "mir/input/null_input_manager.h" | 47 | #include "mir/input/null_input_manager.h" |
701 | 48 | #include "mir/input/null_input_focus_selector.h" | 48 | #include "mir/input/null_input_target_listener.h" |
702 | 49 | #include "input/android/default_android_input_configuration.h" | 49 | #include "input/android/default_android_input_configuration.h" |
703 | 50 | #include "input/android/android_input_manager.h" | 50 | #include "input/android/android_input_manager.h" |
704 | 51 | #include "input/android/android_dispatcher_controller.h" | 51 | #include "input/android/android_dispatcher_controller.h" |
705 | @@ -310,8 +310,7 @@ | |||
706 | 310 | [this] | 310 | [this] |
707 | 311 | { | 311 | { |
708 | 312 | return std::make_shared<msh::SingleVisibilityFocusMechanism>( | 312 | return std::make_shared<msh::SingleVisibilityFocusMechanism>( |
711 | 313 | the_shell_session_container(), | 313 | the_shell_session_container()); |
710 | 314 | the_input_focus_selector()); | ||
712 | 315 | }); | 314 | }); |
713 | 316 | } | 315 | } |
714 | 317 | 316 | ||
715 | @@ -347,7 +346,8 @@ | |||
716 | 347 | the_shell_surface_factory(), | 346 | the_shell_surface_factory(), |
717 | 348 | the_shell_session_container(), | 347 | the_shell_session_container(), |
718 | 349 | the_shell_focus_sequence(), | 348 | the_shell_focus_sequence(), |
720 | 350 | the_shell_focus_setter()); | 349 | the_shell_focus_setter(), |
721 | 350 | the_input_target_listener()); | ||
722 | 351 | }); | 351 | }); |
723 | 352 | } | 352 | } |
724 | 353 | 353 | ||
725 | @@ -562,15 +562,15 @@ | |||
726 | 562 | return the_input_manager(); | 562 | return the_input_manager(); |
727 | 563 | } | 563 | } |
728 | 564 | 564 | ||
730 | 565 | std::shared_ptr<msh::InputFocusSelector> mir::DefaultServerConfiguration::the_input_focus_selector() | 565 | std::shared_ptr<msh::InputTargetListener> mir::DefaultServerConfiguration::the_input_target_listener() |
731 | 566 | { | 566 | { |
734 | 567 | return input_focus_selector( | 567 | return input_target_listener( |
735 | 568 | [&]() -> std::shared_ptr<msh::InputFocusSelector> | 568 | [&]() -> std::shared_ptr<msh::InputTargetListener> |
736 | 569 | { | 569 | { |
737 | 570 | if (the_options()->get("enable-input", false)) | 570 | if (the_options()->get("enable-input", false)) |
738 | 571 | return std::make_shared<mia::DispatcherController>(the_input_configuration()); | 571 | return std::make_shared<mia::DispatcherController>(the_input_configuration()); |
739 | 572 | else | 572 | else |
741 | 573 | return std::make_shared<mi::NullInputFocusSelector>(); | 573 | return std::make_shared<mi::NullInputTargetListener>(); |
742 | 574 | }); | 574 | }); |
743 | 575 | } | 575 | } |
744 | 576 | 576 | ||
745 | 577 | 577 | ||
746 | === modified file 'src/server/display_server.cpp' | |||
747 | --- src/server/display_server.cpp 2013-04-19 14:52:23 +0000 | |||
748 | +++ src/server/display_server.cpp 2013-04-22 16:32:37 +0000 | |||
749 | @@ -31,9 +31,9 @@ | |||
750 | 31 | 31 | ||
751 | 32 | namespace mc = mir::compositor; | 32 | namespace mc = mir::compositor; |
752 | 33 | namespace mf = mir::frontend; | 33 | namespace mf = mir::frontend; |
753 | 34 | namespace msh = mir::shell; | ||
754 | 35 | namespace mg = mir::graphics; | 34 | namespace mg = mir::graphics; |
755 | 36 | namespace mi = mir::input; | 35 | namespace mi = mir::input; |
756 | 36 | namespace msh = mir::shell; | ||
757 | 37 | 37 | ||
758 | 38 | namespace | 38 | namespace |
759 | 39 | { | 39 | { |
760 | 40 | 40 | ||
761 | === modified file 'src/server/input/android/android_dispatcher_controller.cpp' | |||
762 | --- src/server/input/android/android_dispatcher_controller.cpp 2013-04-11 23:06:12 +0000 | |||
763 | +++ src/server/input/android/android_dispatcher_controller.cpp 2013-04-22 16:32:37 +0000 | |||
764 | @@ -25,35 +25,85 @@ | |||
765 | 25 | 25 | ||
766 | 26 | #include <InputDispatcher.h> | 26 | #include <InputDispatcher.h> |
767 | 27 | 27 | ||
768 | 28 | #include <boost/throw_exception.hpp> | ||
769 | 29 | |||
770 | 30 | #include <stdexcept> | ||
771 | 31 | #include <mutex> | ||
772 | 32 | |||
773 | 28 | namespace mi = mir::input; | 33 | namespace mi = mir::input; |
774 | 29 | namespace mia = mi::android; | 34 | namespace mia = mi::android; |
775 | 30 | 35 | ||
776 | 31 | mia::DispatcherController::DispatcherController(std::shared_ptr<mia::InputConfiguration> const& config) : | 36 | mia::DispatcherController::DispatcherController(std::shared_ptr<mia::InputConfiguration> const& config) : |
792 | 32 | input_dispatcher(config->the_dispatcher()), | 37 | input_dispatcher(config->the_dispatcher()) |
793 | 33 | focused_window_handle(0), | 38 | { |
794 | 34 | focused_application_handle(0) | 39 | } |
795 | 35 | { | 40 | |
796 | 36 | } | 41 | void mia::DispatcherController::input_application_opened(std::shared_ptr<mi::SessionTarget> const& session) |
797 | 37 | 42 | { | |
798 | 38 | void mia::DispatcherController::set_input_focus_to(std::shared_ptr<mi::SessionTarget> const& session, | 43 | std::unique_lock<std::mutex> lock(handles_mutex); |
799 | 39 | std::shared_ptr<mi::SurfaceTarget> const& surface) | 44 | if (application_handles.find(session) != application_handles.end()) |
800 | 40 | { | 45 | BOOST_THROW_EXCEPTION(std::logic_error("An application was opened twice")); |
801 | 41 | if (focused_window_handle.get()) | 46 | application_handles[session] = new mia::InputApplicationHandle(session); |
802 | 42 | { | 47 | } |
803 | 43 | input_dispatcher->unregisterInputChannel(focused_window_handle->getInfo()->inputChannel); | 48 | |
804 | 44 | focused_window_handle.clear(); | 49 | void mia::DispatcherController::input_application_closed(std::shared_ptr<mi::SessionTarget> const& session) |
805 | 45 | focused_application_handle.clear(); | 50 | { |
806 | 46 | } | 51 | std::unique_lock<std::mutex> lock(handles_mutex); |
807 | 52 | if (application_handles.find(session) == application_handles.end()) | ||
808 | 53 | BOOST_THROW_EXCEPTION(std::logic_error("An application was closed twice")); | ||
809 | 54 | application_handles.erase(session); | ||
810 | 55 | } | ||
811 | 56 | |||
812 | 57 | void mia::DispatcherController::input_surface_opened(std::shared_ptr<mi::SessionTarget> const& session, | ||
813 | 58 | std::shared_ptr<input::SurfaceTarget> const& opened_surface) | ||
814 | 59 | { | ||
815 | 60 | std::unique_lock<std::mutex> lock(handles_mutex); | ||
816 | 61 | auto application_handle = application_handles.find(session); | ||
817 | 62 | if (application_handle == application_handles.end()) | ||
818 | 63 | BOOST_THROW_EXCEPTION(std::logic_error("A surface was opened for an unopened application")); | ||
819 | 64 | if (window_handles.find(opened_surface) != window_handles.end()) | ||
820 | 65 | BOOST_THROW_EXCEPTION(std::logic_error("A surface was opened twice")); | ||
821 | 66 | |||
822 | 67 | droidinput::sp<droidinput::InputWindowHandle> window_handle = new mia::InputWindowHandle(application_handle->second, opened_surface); | ||
823 | 68 | input_dispatcher->registerInputChannel(window_handle->getInfo()->inputChannel, window_handle, false); | ||
824 | 69 | |||
825 | 70 | window_handles[opened_surface] = window_handle; | ||
826 | 71 | } | ||
827 | 72 | |||
828 | 73 | void mia::DispatcherController::input_surface_closed(std::shared_ptr<input::SurfaceTarget> const& closed_surface) | ||
829 | 74 | { | ||
830 | 75 | std::unique_lock<std::mutex> lock(handles_mutex); | ||
831 | 76 | auto it = window_handles.find(closed_surface); | ||
832 | 77 | if (it == window_handles.end()) | ||
833 | 78 | BOOST_THROW_EXCEPTION(std::logic_error("A surface was closed twice")); | ||
834 | 79 | |||
835 | 80 | input_dispatcher->unregisterInputChannel(it->second->getInfo()->inputChannel); | ||
836 | 81 | window_handles.erase(it); | ||
837 | 82 | } | ||
838 | 83 | |||
839 | 84 | void mia::DispatcherController::focus_cleared() | ||
840 | 85 | { | ||
841 | 86 | droidinput::Vector<droidinput::sp<droidinput::InputWindowHandle>> empty_windows; | ||
842 | 87 | droidinput::sp<droidinput::InputApplicationHandle> null_application = nullptr; | ||
843 | 88 | |||
844 | 89 | input_dispatcher->setFocusedApplication(null_application); | ||
845 | 90 | input_dispatcher->setInputWindows(empty_windows); | ||
846 | 91 | } | ||
847 | 92 | |||
848 | 93 | void mia::DispatcherController::focus_changed(std::shared_ptr<mi::SurfaceTarget> const& surface) | ||
849 | 94 | { | ||
850 | 95 | std::unique_lock<std::mutex> lock(handles_mutex); | ||
851 | 96 | |||
852 | 97 | auto window_handle = window_handles[surface]; | ||
853 | 98 | |||
854 | 99 | if (!window_handle.get()) | ||
855 | 100 | BOOST_THROW_EXCEPTION(std::logic_error("Focus changed to an unopened surface")); | ||
856 | 101 | auto application_handle = window_handle->inputApplicationHandle; | ||
857 | 102 | |||
858 | 103 | input_dispatcher->setFocusedApplication(application_handle); | ||
859 | 47 | 104 | ||
860 | 48 | droidinput::Vector<droidinput::sp<droidinput::InputWindowHandle>> windows; | 105 | droidinput::Vector<droidinput::sp<droidinput::InputWindowHandle>> windows; |
866 | 49 | if (surface) | 106 | windows.push_back(window_handle); |
862 | 50 | { | ||
863 | 51 | focused_application_handle = new mia::InputApplicationHandle(session); | ||
864 | 52 | focused_window_handle = new mia::InputWindowHandle(focused_application_handle, surface); | ||
865 | 53 | input_dispatcher->setFocusedApplication(focused_application_handle); | ||
867 | 54 | 107 | ||
868 | 55 | input_dispatcher->registerInputChannel(focused_window_handle->getInfo()->inputChannel, focused_window_handle, false); | ||
869 | 56 | windows.push_back(focused_window_handle); | ||
870 | 57 | } | ||
871 | 58 | input_dispatcher->setInputWindows(windows); | 108 | input_dispatcher->setInputWindows(windows); |
872 | 59 | } | 109 | } |
873 | 60 | 110 | ||
874 | === modified file 'src/server/input/android/android_dispatcher_controller.h' | |||
875 | --- src/server/input/android/android_dispatcher_controller.h 2013-04-11 23:06:12 +0000 | |||
876 | +++ src/server/input/android/android_dispatcher_controller.h 2013-04-22 16:32:37 +0000 | |||
877 | @@ -19,10 +19,13 @@ | |||
878 | 19 | #ifndef MIR_INPUT_ANDROID_DISPATCHER_CONTROLLER_H_ | 19 | #ifndef MIR_INPUT_ANDROID_DISPATCHER_CONTROLLER_H_ |
879 | 20 | #define MIR_INPUT_ANDROID_DISPATCHER_CONTROLLER_H_ | 20 | #define MIR_INPUT_ANDROID_DISPATCHER_CONTROLLER_H_ |
880 | 21 | 21 | ||
882 | 22 | #include "mir/shell/input_focus_selector.h" | 22 | #include "mir/shell/input_target_listener.h" |
883 | 23 | 23 | ||
884 | 24 | #include <utils/StrongPointer.h> | 24 | #include <utils/StrongPointer.h> |
885 | 25 | 25 | ||
886 | 26 | #include <map> | ||
887 | 27 | #include <mutex> | ||
888 | 28 | |||
889 | 26 | namespace android | 29 | namespace android |
890 | 27 | { | 30 | { |
891 | 28 | class InputDispatcherInterface; | 31 | class InputDispatcherInterface; |
892 | @@ -40,13 +43,21 @@ | |||
893 | 40 | { | 43 | { |
894 | 41 | class InputConfiguration; | 44 | class InputConfiguration; |
895 | 42 | 45 | ||
897 | 43 | class DispatcherController : public shell::InputFocusSelector | 46 | class DispatcherController : public shell::InputTargetListener |
898 | 44 | { | 47 | { |
899 | 45 | public: | 48 | public: |
900 | 46 | explicit DispatcherController(std::shared_ptr<InputConfiguration> const& input_configuration); | 49 | explicit DispatcherController(std::shared_ptr<InputConfiguration> const& input_configuration); |
902 | 47 | virtual ~DispatcherController() = default; | 50 | virtual ~DispatcherController() noexcept(true) {} |
903 | 48 | 51 | ||
905 | 49 | void set_input_focus_to(std::shared_ptr<input::SessionTarget> const& session, std::shared_ptr<input::SurfaceTarget> const& surface); | 52 | void input_application_opened(std::shared_ptr<input::SessionTarget> const& application); |
906 | 53 | void input_application_closed(std::shared_ptr<input::SessionTarget> const& application); | ||
907 | 54 | |||
908 | 55 | void input_surface_opened(std::shared_ptr<input::SessionTarget> const& application, | ||
909 | 56 | std::shared_ptr<input::SurfaceTarget> const& opened_surface); | ||
910 | 57 | void input_surface_closed(std::shared_ptr<input::SurfaceTarget> const& closed_surface); | ||
911 | 58 | |||
912 | 59 | void focus_changed(std::shared_ptr<input::SurfaceTarget> const& focus_surface); | ||
913 | 60 | void focus_cleared(); | ||
914 | 50 | 61 | ||
915 | 51 | protected: | 62 | protected: |
916 | 52 | DispatcherController(const DispatcherController&) = delete; | 63 | DispatcherController(const DispatcherController&) = delete; |
917 | @@ -55,8 +66,10 @@ | |||
918 | 55 | private: | 66 | private: |
919 | 56 | droidinput::sp<droidinput::InputDispatcherInterface> input_dispatcher; | 67 | droidinput::sp<droidinput::InputDispatcherInterface> input_dispatcher; |
920 | 57 | 68 | ||
923 | 58 | droidinput::sp<droidinput::InputWindowHandle> focused_window_handle; | 69 | std::map<std::shared_ptr<input::SessionTarget>, droidinput::sp<droidinput::InputApplicationHandle>> application_handles; |
924 | 59 | droidinput::sp<droidinput::InputApplicationHandle> focused_application_handle; | 70 | std::map<std::shared_ptr<input::SurfaceTarget>, droidinput::sp<droidinput::InputWindowHandle>> window_handles; |
925 | 71 | |||
926 | 72 | std::mutex handles_mutex; | ||
927 | 60 | }; | 73 | }; |
928 | 61 | 74 | ||
929 | 62 | } | 75 | } |
930 | 63 | 76 | ||
931 | === modified file 'src/server/input/android/android_input_window_handle.cpp' | |||
932 | --- src/server/input/android/android_input_window_handle.cpp 2013-03-29 16:51:35 +0000 | |||
933 | +++ src/server/input/android/android_input_window_handle.cpp 2013-04-22 16:32:37 +0000 | |||
934 | @@ -48,11 +48,17 @@ | |||
935 | 48 | surface->server_input_fd()); | 48 | surface->server_input_fd()); |
936 | 49 | } | 49 | } |
937 | 50 | 50 | ||
940 | 51 | mInfo->frameLeft = 0; | 51 | auto surface_position = surface->top_left(); |
941 | 52 | mInfo->frameTop = 0; | 52 | mInfo->frameLeft = surface_position.x.as_uint32_t(); |
942 | 53 | mInfo->frameTop = surface_position.y.as_uint32_t(); | ||
943 | 53 | auto surface_size = surface->size(); | 54 | auto surface_size = surface->size(); |
944 | 54 | mInfo->frameRight = mInfo->frameLeft + surface_size.width.as_uint32_t(); | 55 | mInfo->frameRight = mInfo->frameLeft + surface_size.width.as_uint32_t(); |
945 | 55 | mInfo->frameBottom = mInfo->frameTop + surface_size.height.as_uint32_t(); | 56 | mInfo->frameBottom = mInfo->frameTop + surface_size.height.as_uint32_t(); |
946 | 57 | |||
947 | 58 | mInfo->touchableRegionLeft = mInfo->frameLeft; | ||
948 | 59 | mInfo->touchableRegionTop = mInfo->frameTop; | ||
949 | 60 | mInfo->touchableRegionRight = mInfo->frameRight; | ||
950 | 61 | mInfo->touchableRegionBottom = mInfo->frameBottom; | ||
951 | 56 | 62 | ||
952 | 57 | mInfo->name = droidinput::String8(surface->name().c_str()); | 63 | mInfo->name = droidinput::String8(surface->name().c_str()); |
953 | 58 | mInfo->layoutParamsFlags = droidinput::InputWindowInfo::FLAG_NOT_TOUCH_MODAL; | 64 | mInfo->layoutParamsFlags = droidinput::InputWindowInfo::FLAG_NOT_TOUCH_MODAL; |
954 | 59 | 65 | ||
955 | === modified file 'src/server/input/android/default_android_input_configuration.cpp' | |||
956 | --- src/server/input/android/default_android_input_configuration.cpp 2013-04-16 09:08:29 +0000 | |||
957 | +++ src/server/input/android/default_android_input_configuration.cpp 2013-04-22 16:32:37 +0000 | |||
958 | @@ -98,7 +98,7 @@ | |||
959 | 98 | return dispatcher_policy( | 98 | return dispatcher_policy( |
960 | 99 | [this]() | 99 | [this]() |
961 | 100 | { | 100 | { |
963 | 101 | return new mia::EventFilterDispatcherPolicy(filter_chain); | 101 | return new mia::EventFilterDispatcherPolicy(filter_chain, is_key_repeat_enabled()); |
964 | 102 | }); | 102 | }); |
965 | 103 | } | 103 | } |
966 | 104 | 104 | ||
967 | @@ -149,3 +149,8 @@ | |||
968 | 149 | new droidinput::InputReaderThread(the_reader())); | 149 | new droidinput::InputReaderThread(the_reader())); |
969 | 150 | }); | 150 | }); |
970 | 151 | } | 151 | } |
971 | 152 | |||
972 | 153 | bool mia::DefaultInputConfiguration::is_key_repeat_enabled() | ||
973 | 154 | { | ||
974 | 155 | return true; | ||
975 | 156 | } | ||
976 | 152 | 157 | ||
977 | === modified file 'src/server/input/android/default_android_input_configuration.h' | |||
978 | --- src/server/input/android/default_android_input_configuration.h 2013-04-16 09:08:29 +0000 | |||
979 | +++ src/server/input/android/default_android_input_configuration.h 2013-04-22 16:32:37 +0000 | |||
980 | @@ -69,6 +69,8 @@ | |||
981 | 69 | 69 | ||
982 | 70 | virtual droidinput::sp<droidinput::InputDispatcherPolicyInterface> the_dispatcher_policy(); | 70 | virtual droidinput::sp<droidinput::InputDispatcherPolicyInterface> the_dispatcher_policy(); |
983 | 71 | virtual droidinput::sp<droidinput::InputReaderPolicyInterface> the_reader_policy(); | 71 | virtual droidinput::sp<droidinput::InputReaderPolicyInterface> the_reader_policy(); |
984 | 72 | |||
985 | 73 | virtual bool is_key_repeat_enabled(); | ||
986 | 72 | 74 | ||
987 | 73 | protected: | 75 | protected: |
988 | 74 | DefaultInputConfiguration(DefaultInputConfiguration const&) = delete; | 76 | DefaultInputConfiguration(DefaultInputConfiguration const&) = delete; |
989 | 75 | 77 | ||
990 | === modified file 'src/server/input/android/event_filter_dispatcher_policy.cpp' | |||
991 | --- src/server/input/android/event_filter_dispatcher_policy.cpp 2013-04-16 09:27:00 +0000 | |||
992 | +++ src/server/input/android/event_filter_dispatcher_policy.cpp 2013-04-22 16:32:37 +0000 | |||
993 | @@ -21,8 +21,9 @@ | |||
994 | 21 | namespace mi = mir::input; | 21 | namespace mi = mir::input; |
995 | 22 | namespace mia = mi::android; | 22 | namespace mia = mi::android; |
996 | 23 | 23 | ||
999 | 24 | mia::EventFilterDispatcherPolicy::EventFilterDispatcherPolicy(std::shared_ptr<mi::EventFilter> const& event_filter) : | 24 | mia::EventFilterDispatcherPolicy::EventFilterDispatcherPolicy(std::shared_ptr<mi::EventFilter> const& event_filter, bool key_repeat_enabled) : |
1000 | 25 | event_filter(event_filter) | 25 | event_filter(event_filter), |
1001 | 26 | key_repeat_enabled(key_repeat_enabled) | ||
1002 | 26 | { | 27 | { |
1003 | 27 | } | 28 | } |
1004 | 28 | 29 | ||
1005 | @@ -46,7 +47,7 @@ | |||
1006 | 46 | 47 | ||
1007 | 47 | bool mia::EventFilterDispatcherPolicy::isKeyRepeatEnabled() | 48 | bool mia::EventFilterDispatcherPolicy::isKeyRepeatEnabled() |
1008 | 48 | { | 49 | { |
1010 | 49 | return true; | 50 | return key_repeat_enabled; |
1011 | 50 | } | 51 | } |
1012 | 51 | 52 | ||
1013 | 52 | bool mia::EventFilterDispatcherPolicy::filterInputEvent(const droidinput::InputEvent* input_event, uint32_t /*policy_flags*/) | 53 | bool mia::EventFilterDispatcherPolicy::filterInputEvent(const droidinput::InputEvent* input_event, uint32_t /*policy_flags*/) |
1014 | @@ -67,9 +68,9 @@ | |||
1015 | 67 | policy_flags |= droidinput::POLICY_FLAG_PASS_TO_USER; | 68 | policy_flags |= droidinput::POLICY_FLAG_PASS_TO_USER; |
1016 | 68 | } | 69 | } |
1017 | 69 | 70 | ||
1019 | 70 | void mia::EventFilterDispatcherPolicy::interceptMotionBeforeQueueing(nsecs_t /* when */, uint32_t& /* policyFlags */) | 71 | void mia::EventFilterDispatcherPolicy::interceptMotionBeforeQueueing(nsecs_t /* when */, uint32_t& policy_flags) |
1020 | 71 | { | 72 | { |
1022 | 72 | // TODO: Implement for motion events to client. | 73 | policy_flags |= droidinput::POLICY_FLAG_PASS_TO_USER; |
1023 | 73 | } | 74 | } |
1024 | 74 | 75 | ||
1025 | 75 | nsecs_t mia::EventFilterDispatcherPolicy::interceptKeyBeforeDispatching( | 76 | nsecs_t mia::EventFilterDispatcherPolicy::interceptKeyBeforeDispatching( |
1026 | 76 | 77 | ||
1027 | === modified file 'src/server/input/android/event_filter_dispatcher_policy.h' | |||
1028 | --- src/server/input/android/event_filter_dispatcher_policy.h 2013-04-16 09:08:29 +0000 | |||
1029 | +++ src/server/input/android/event_filter_dispatcher_policy.h 2013-04-22 16:32:37 +0000 | |||
1030 | @@ -40,7 +40,7 @@ | |||
1031 | 40 | class EventFilterDispatcherPolicy : public droidinput::InputDispatcherPolicyInterface | 40 | class EventFilterDispatcherPolicy : public droidinput::InputDispatcherPolicyInterface |
1032 | 41 | { | 41 | { |
1033 | 42 | public: | 42 | public: |
1035 | 43 | EventFilterDispatcherPolicy(std::shared_ptr<EventFilter> const& event_filter); | 43 | EventFilterDispatcherPolicy(std::shared_ptr<EventFilter> const& event_filter, bool key_repeat_enabled); |
1036 | 44 | virtual ~EventFilterDispatcherPolicy() {} | 44 | virtual ~EventFilterDispatcherPolicy() {} |
1037 | 45 | 45 | ||
1038 | 46 | void notifyConfigurationChanged(nsecs_t when); | 46 | void notifyConfigurationChanged(nsecs_t when); |
1039 | @@ -71,6 +71,7 @@ | |||
1040 | 71 | EventFilterDispatcherPolicy& operator=(const EventFilterDispatcherPolicy&) = delete; | 71 | EventFilterDispatcherPolicy& operator=(const EventFilterDispatcherPolicy&) = delete; |
1041 | 72 | private: | 72 | private: |
1042 | 73 | std::shared_ptr<EventFilter> event_filter; | 73 | std::shared_ptr<EventFilter> event_filter; |
1043 | 74 | bool key_repeat_enabled; | ||
1044 | 74 | }; | 75 | }; |
1045 | 75 | 76 | ||
1046 | 76 | } | 77 | } |
1047 | 77 | 78 | ||
1048 | === modified file 'src/server/shell/application_session.cpp' | |||
1049 | --- src/server/shell/application_session.cpp 2013-04-16 17:42:26 +0000 | |||
1050 | +++ src/server/shell/application_session.cpp 2013-04-22 16:32:37 +0000 | |||
1051 | @@ -18,8 +18,8 @@ | |||
1052 | 18 | 18 | ||
1053 | 19 | #include "mir/shell/application_session.h" | 19 | #include "mir/shell/application_session.h" |
1054 | 20 | #include "mir/shell/surface.h" | 20 | #include "mir/shell/surface.h" |
1055 | 21 | |||
1056 | 22 | #include "mir/shell/surface_factory.h" | 21 | #include "mir/shell/surface_factory.h" |
1057 | 22 | #include "mir/shell/input_target_listener.h" | ||
1058 | 23 | 23 | ||
1059 | 24 | #include <boost/throw_exception.hpp> | 24 | #include <boost/throw_exception.hpp> |
1060 | 25 | 25 | ||
1061 | @@ -32,9 +32,11 @@ | |||
1062 | 32 | namespace msh = mir::shell; | 32 | namespace msh = mir::shell; |
1063 | 33 | 33 | ||
1064 | 34 | msh::ApplicationSession::ApplicationSession( | 34 | msh::ApplicationSession::ApplicationSession( |
1066 | 35 | std::shared_ptr<SurfaceFactory> const& surface_factory, | 35 | std::shared_ptr<msh::SurfaceFactory> const& surface_factory, |
1067 | 36 | std::shared_ptr<msh::InputTargetListener> const& input_target_listener, | ||
1068 | 36 | std::string const& session_name) : | 37 | std::string const& session_name) : |
1069 | 37 | surface_factory(surface_factory), | 38 | surface_factory(surface_factory), |
1070 | 39 | input_target_listener(input_target_listener), | ||
1071 | 38 | session_name(session_name), | 40 | session_name(session_name), |
1072 | 39 | next_surface_id(0) | 41 | next_surface_id(0) |
1073 | 40 | { | 42 | { |
1074 | @@ -46,6 +48,7 @@ | |||
1075 | 46 | std::unique_lock<std::mutex> lock(surfaces_mutex); | 48 | std::unique_lock<std::mutex> lock(surfaces_mutex); |
1076 | 47 | for (auto const& pair_id_surface : surfaces) | 49 | for (auto const& pair_id_surface : surfaces) |
1077 | 48 | { | 50 | { |
1078 | 51 | input_target_listener->input_surface_closed(pair_id_surface.second); | ||
1079 | 49 | pair_id_surface.second->destroy(); | 52 | pair_id_surface.second->destroy(); |
1080 | 50 | } | 53 | } |
1081 | 51 | } | 54 | } |
1082 | @@ -95,6 +98,7 @@ | |||
1083 | 95 | std::unique_lock<std::mutex> lock(surfaces_mutex); | 98 | std::unique_lock<std::mutex> lock(surfaces_mutex); |
1084 | 96 | auto p = checked_find(id); | 99 | auto p = checked_find(id); |
1085 | 97 | 100 | ||
1086 | 101 | input_target_listener->input_surface_closed(p->second); | ||
1087 | 98 | p->second->destroy(); | 102 | p->second->destroy(); |
1088 | 99 | surfaces.erase(p); | 103 | surfaces.erase(p); |
1089 | 100 | } | 104 | } |
1090 | 101 | 105 | ||
1091 | === modified file 'src/server/shell/session_manager.cpp' | |||
1092 | --- src/server/shell/session_manager.cpp 2013-04-19 09:15:31 +0000 | |||
1093 | +++ src/server/shell/session_manager.cpp 2013-04-22 16:32:37 +0000 | |||
1094 | @@ -23,6 +23,8 @@ | |||
1095 | 23 | #include "mir/shell/focus_sequence.h" | 23 | #include "mir/shell/focus_sequence.h" |
1096 | 24 | #include "mir/shell/focus_setter.h" | 24 | #include "mir/shell/focus_setter.h" |
1097 | 25 | #include "mir/shell/session.h" | 25 | #include "mir/shell/session.h" |
1098 | 26 | #include "mir/shell/surface.h" | ||
1099 | 27 | #include "mir/shell/input_target_listener.h" | ||
1100 | 26 | 28 | ||
1101 | 27 | #include <memory> | 29 | #include <memory> |
1102 | 28 | #include <cassert> | 30 | #include <cassert> |
1103 | @@ -31,20 +33,22 @@ | |||
1104 | 31 | namespace mf = mir::frontend; | 33 | namespace mf = mir::frontend; |
1105 | 32 | namespace msh = mir::shell; | 34 | namespace msh = mir::shell; |
1106 | 33 | 35 | ||
1109 | 34 | msh::SessionManager::SessionManager( | 36 | msh::SessionManager::SessionManager(std::shared_ptr<msh::SurfaceFactory> const& surface_factory, |
1108 | 35 | std::shared_ptr<msh::SurfaceFactory> const& surface_factory, | ||
1110 | 36 | std::shared_ptr<msh::SessionContainer> const& container, | 37 | std::shared_ptr<msh::SessionContainer> const& container, |
1111 | 37 | std::shared_ptr<msh::FocusSequence> const& sequence, | 38 | std::shared_ptr<msh::FocusSequence> const& sequence, |
1113 | 38 | std::shared_ptr<msh::FocusSetter> const& focus_setter) : | 39 | std::shared_ptr<msh::FocusSetter> const& focus_setter, |
1114 | 40 | std::shared_ptr<msh::InputTargetListener> const& input_target_listener) : | ||
1115 | 39 | surface_factory(surface_factory), | 41 | surface_factory(surface_factory), |
1116 | 40 | app_container(container), | 42 | app_container(container), |
1117 | 41 | focus_sequence(sequence), | 43 | focus_sequence(sequence), |
1119 | 42 | focus_setter(focus_setter) | 44 | focus_setter(focus_setter), |
1120 | 45 | input_target_listener(input_target_listener) | ||
1121 | 43 | { | 46 | { |
1122 | 44 | assert(surface_factory); | 47 | assert(surface_factory); |
1123 | 45 | assert(sequence); | 48 | assert(sequence); |
1124 | 46 | assert(container); | 49 | assert(container); |
1125 | 47 | assert(focus_setter); | 50 | assert(focus_setter); |
1126 | 51 | assert(input_target_listener); | ||
1127 | 48 | } | 52 | } |
1128 | 49 | 53 | ||
1129 | 50 | msh::SessionManager::~SessionManager() | 54 | msh::SessionManager::~SessionManager() |
1130 | @@ -53,25 +57,36 @@ | |||
1131 | 53 | 57 | ||
1132 | 54 | std::shared_ptr<mf::Session> msh::SessionManager::open_session(std::string const& name) | 58 | std::shared_ptr<mf::Session> msh::SessionManager::open_session(std::string const& name) |
1133 | 55 | { | 59 | { |
1135 | 56 | auto new_session = std::make_shared<msh::ApplicationSession>(surface_factory, name); | 60 | auto new_session = std::make_shared<msh::ApplicationSession>(surface_factory, input_target_listener, name); |
1136 | 57 | 61 | ||
1137 | 58 | app_container->insert_session(new_session); | 62 | app_container->insert_session(new_session); |
1138 | 63 | |||
1139 | 64 | input_target_listener->input_application_opened(new_session); | ||
1140 | 59 | 65 | ||
1141 | 60 | set_focus_to_locked(std::unique_lock<std::mutex>(mutex), new_session); | 66 | set_focus_to_locked(std::unique_lock<std::mutex>(mutex), new_session); |
1142 | 61 | 67 | ||
1143 | 62 | return new_session; | 68 | return new_session; |
1144 | 63 | } | 69 | } |
1145 | 64 | 70 | ||
1147 | 65 | inline void msh::SessionManager::set_focus_to_locked(std::unique_lock<std::mutex> const&, std::shared_ptr<Session> const& next_focus) | 71 | inline void msh::SessionManager::set_focus_to_locked(std::unique_lock<std::mutex> const&, std::shared_ptr<Session> const& shell_session) |
1148 | 66 | { | 72 | { |
1151 | 67 | focus_application = next_focus; | 73 | auto old_focus = focus_application.lock(); |
1152 | 68 | focus_setter->set_focus_to(next_focus); | 74 | |
1153 | 75 | focus_application = shell_session; | ||
1154 | 76 | focus_setter->set_focus_to(shell_session); | ||
1155 | 77 | |||
1156 | 78 | if (shell_session && shell_session->default_surface()) | ||
1157 | 79 | input_target_listener->focus_changed(shell_session->default_surface()); | ||
1158 | 80 | else if (shell_session == old_focus || !shell_session) | ||
1159 | 81 | input_target_listener->focus_cleared(); | ||
1160 | 69 | } | 82 | } |
1161 | 70 | 83 | ||
1162 | 71 | void msh::SessionManager::close_session(std::shared_ptr<mf::Session> const& session) | 84 | void msh::SessionManager::close_session(std::shared_ptr<mf::Session> const& session) |
1163 | 72 | { | 85 | { |
1164 | 73 | auto shell_session = std::dynamic_pointer_cast<Session>(session); | 86 | auto shell_session = std::dynamic_pointer_cast<Session>(session); |
1165 | 74 | 87 | ||
1166 | 88 | input_target_listener->input_application_closed(shell_session); | ||
1167 | 89 | |||
1168 | 75 | app_container->remove_session(shell_session); | 90 | app_container->remove_session(shell_session); |
1169 | 76 | 91 | ||
1170 | 77 | std::unique_lock<std::mutex> lock(mutex); | 92 | std::unique_lock<std::mutex> lock(mutex); |
1171 | @@ -133,9 +148,11 @@ | |||
1172 | 133 | mf::SurfaceCreationParameters const& params) | 148 | mf::SurfaceCreationParameters const& params) |
1173 | 134 | { | 149 | { |
1174 | 135 | auto shell_session = std::dynamic_pointer_cast<Session>(session); | 150 | auto shell_session = std::dynamic_pointer_cast<Session>(session); |
1176 | 136 | auto id = session->create_surface(params); | 151 | auto id = shell_session->create_surface(params); |
1177 | 152 | |||
1178 | 153 | input_target_listener->input_surface_opened(shell_session, | ||
1179 | 154 | std::dynamic_pointer_cast<msh::Surface>(shell_session->get_surface(id))); | ||
1180 | 137 | set_focus_to_locked(std::unique_lock<std::mutex>(mutex), shell_session); | 155 | set_focus_to_locked(std::unique_lock<std::mutex>(mutex), shell_session); |
1181 | 138 | 156 | ||
1182 | 139 | return id; | 157 | return id; |
1183 | 140 | } | 158 | } |
1184 | 141 | |||
1185 | 142 | 159 | ||
1186 | === modified file 'src/server/shell/single_visibility_focus_mechanism.cpp' | |||
1187 | --- src/server/shell/single_visibility_focus_mechanism.cpp 2013-04-18 22:57:01 +0000 | |||
1188 | +++ src/server/shell/single_visibility_focus_mechanism.cpp 2013-04-22 16:32:37 +0000 | |||
1189 | @@ -19,7 +19,6 @@ | |||
1190 | 19 | #include "mir/shell/session_container.h" | 19 | #include "mir/shell/session_container.h" |
1191 | 20 | #include "mir/frontend/session.h" | 20 | #include "mir/frontend/session.h" |
1192 | 21 | #include "mir/shell/single_visibility_focus_mechanism.h" | 21 | #include "mir/shell/single_visibility_focus_mechanism.h" |
1193 | 22 | #include "mir/shell/input_focus_selector.h" | ||
1194 | 23 | 22 | ||
1195 | 24 | #include "mir/shell/session.h" | 23 | #include "mir/shell/session.h" |
1196 | 25 | #include "mir/shell/surface.h" | 24 | #include "mir/shell/surface.h" |
1197 | @@ -27,10 +26,8 @@ | |||
1198 | 27 | namespace mf = mir::frontend; | 26 | namespace mf = mir::frontend; |
1199 | 28 | namespace msh = mir::shell; | 27 | namespace msh = mir::shell; |
1200 | 29 | 28 | ||
1205 | 30 | msh::SingleVisibilityFocusMechanism::SingleVisibilityFocusMechanism(std::shared_ptr<msh::SessionContainer> const& app_container, | 29 | msh::SingleVisibilityFocusMechanism::SingleVisibilityFocusMechanism(std::shared_ptr<msh::SessionContainer> const& app_container) |
1206 | 31 | std::shared_ptr<msh::InputFocusSelector> const& input_selector) | 30 | : app_container(app_container) |
1203 | 32 | : app_container(app_container), | ||
1204 | 33 | input_selector(input_selector) | ||
1207 | 34 | { | 31 | { |
1208 | 35 | } | 32 | } |
1209 | 36 | 33 | ||
1210 | @@ -41,8 +38,6 @@ | |||
1211 | 41 | if (session == focus_session) | 38 | if (session == focus_session) |
1212 | 42 | { | 39 | { |
1213 | 43 | session->show(); | 40 | session->show(); |
1214 | 44 | |||
1215 | 45 | input_selector->set_input_focus_to(focus_session, focus_session->default_surface()); | ||
1216 | 46 | } | 41 | } |
1217 | 47 | else | 42 | else |
1218 | 48 | { | 43 | { |
1219 | 49 | 44 | ||
1220 | === modified file 'src/server/shell/surface.cpp' | |||
1221 | --- src/server/shell/surface.cpp 2013-04-16 17:42:26 +0000 | |||
1222 | +++ src/server/shell/surface.cpp 2013-04-22 16:32:37 +0000 | |||
1223 | @@ -88,6 +88,18 @@ | |||
1224 | 88 | } | 88 | } |
1225 | 89 | } | 89 | } |
1226 | 90 | 90 | ||
1227 | 91 | mir::geometry::Point msh::Surface::top_left() const | ||
1228 | 92 | { | ||
1229 | 93 | if (auto const& s = surface.lock()) | ||
1230 | 94 | { | ||
1231 | 95 | return s->top_left(); | ||
1232 | 96 | } | ||
1233 | 97 | else | ||
1234 | 98 | { | ||
1235 | 99 | BOOST_THROW_EXCEPTION(std::runtime_error("Invalid surface")); | ||
1236 | 100 | } | ||
1237 | 101 | } | ||
1238 | 102 | |||
1239 | 91 | std::string msh::Surface::name() const | 103 | std::string msh::Surface::name() const |
1240 | 92 | { | 104 | { |
1241 | 93 | if (auto const& s = surface.lock()) | 105 | if (auto const& s = surface.lock()) |
1242 | 94 | 106 | ||
1243 | === modified file 'tests/acceptance-tests/test_client_input.cpp' | |||
1244 | --- tests/acceptance-tests/test_client_input.cpp 2013-04-17 07:31:40 +0000 | |||
1245 | +++ tests/acceptance-tests/test_client_input.cpp 2013-04-22 16:32:37 +0000 | |||
1246 | @@ -65,10 +65,9 @@ | |||
1247 | 65 | 65 | ||
1248 | 66 | } | 66 | } |
1249 | 67 | 67 | ||
1252 | 68 | void set_input_focus_to( | 68 | void focus_changed(std::shared_ptr<mi::SurfaceTarget> const& surface) override |
1251 | 69 | std::shared_ptr<mi::SessionTarget> const& session, std::shared_ptr<mi::SurfaceTarget> const& surface) override | ||
1253 | 70 | { | 69 | { |
1255 | 71 | DispatcherController::set_input_focus_to(session, surface); | 70 | DispatcherController::focus_changed(surface); |
1256 | 72 | 71 | ||
1257 | 73 | // We need a synchronization primitive inorder to halt test event injection | 72 | // We need a synchronization primitive inorder to halt test event injection |
1258 | 74 | // until after a surface has taken focus (lest the events be discarded). | 73 | // until after a surface has taken focus (lest the events be discarded). |
1259 | @@ -96,6 +95,7 @@ | |||
1260 | 96 | { | 95 | { |
1261 | 97 | on_focus_set.wait_for_at_most_seconds(10); | 96 | on_focus_set.wait_for_at_most_seconds(10); |
1262 | 98 | fake_event_hub->synthesize_builtin_keyboard_added(); | 97 | fake_event_hub->synthesize_builtin_keyboard_added(); |
1263 | 98 | fake_event_hub->synthesize_builtin_cursor_added(); | ||
1264 | 99 | fake_event_hub->synthesize_device_scan_complete(); | 99 | fake_event_hub->synthesize_device_scan_complete(); |
1265 | 100 | inject_input(); | 100 | inject_input(); |
1266 | 101 | }); | 101 | }); |
1267 | @@ -122,10 +122,10 @@ | |||
1268 | 122 | }); | 122 | }); |
1269 | 123 | } | 123 | } |
1270 | 124 | 124 | ||
1273 | 125 | std::shared_ptr<msh::InputFocusSelector> | 125 | std::shared_ptr<msh::InputTargetListener> |
1274 | 126 | the_input_focus_selector() override | 126 | the_input_target_listener() override |
1275 | 127 | { | 127 | { |
1277 | 128 | return input_focus_selector( | 128 | return input_target_listener( |
1278 | 129 | [this]() | 129 | [this]() |
1279 | 130 | { | 130 | { |
1280 | 131 | return std::make_shared<FocusNotifyingDispatcherController>(mt::fake_shared(input_config), on_focus_set); | 131 | return std::make_shared<FocusNotifyingDispatcherController>(mt::fake_shared(input_config), on_focus_set); |
1281 | @@ -186,7 +186,7 @@ | |||
1282 | 186 | 186 | ||
1283 | 187 | struct MockInputHandler | 187 | struct MockInputHandler |
1284 | 188 | { | 188 | { |
1286 | 189 | MOCK_METHOD1(handle_key_down, void(MirEvent const*)); | 189 | MOCK_METHOD1(handle_input, bool(MirEvent const*)); |
1287 | 190 | }; | 190 | }; |
1288 | 191 | 191 | ||
1289 | 192 | struct InputReceivingClient : ClientConfigCommon | 192 | struct InputReceivingClient : ClientConfigCommon |
1290 | @@ -201,9 +201,9 @@ | |||
1291 | 201 | static void handle_input(MirSurface* /* surface */, MirEvent const* ev, void* context) | 201 | static void handle_input(MirSurface* /* surface */, MirEvent const* ev, void* context) |
1292 | 202 | { | 202 | { |
1293 | 203 | auto client = static_cast<InputReceivingClient *>(context); | 203 | auto client = static_cast<InputReceivingClient *>(context); |
1295 | 204 | if (ev->key.action == 0) | 204 | |
1296 | 205 | if(client->handler->handle_input(ev)) | ||
1297 | 205 | { | 206 | { |
1298 | 206 | client->handler->handle_key_down(ev); | ||
1299 | 207 | client->event_received[client->events_received].wake_up_everyone(); | 207 | client->event_received[client->events_received].wake_up_everyone(); |
1300 | 208 | client->events_received++; | 208 | client->events_received++; |
1301 | 209 | } | 209 | } |
1302 | @@ -227,7 +227,7 @@ | |||
1303 | 227 | MirSurfaceParameters const request_params = | 227 | MirSurfaceParameters const request_params = |
1304 | 228 | { | 228 | { |
1305 | 229 | __PRETTY_FUNCTION__, | 229 | __PRETTY_FUNCTION__, |
1307 | 230 | 640, 480, | 230 | surface_width, surface_height, |
1308 | 231 | mir_pixel_format_abgr_8888, | 231 | mir_pixel_format_abgr_8888, |
1309 | 232 | mir_buffer_usage_hardware | 232 | mir_buffer_usage_hardware |
1310 | 233 | }; | 233 | }; |
1311 | @@ -259,9 +259,66 @@ | |||
1312 | 259 | 259 | ||
1313 | 260 | int events_to_receive; | 260 | int events_to_receive; |
1314 | 261 | int events_received; | 261 | int events_received; |
1315 | 262 | |||
1316 | 263 | static int const surface_width = 100; | ||
1317 | 264 | static int const surface_height = 100; | ||
1318 | 262 | }; | 265 | }; |
1319 | 263 | 266 | ||
1321 | 264 | } | 267 | MATCHER(KeyDownEvent, "") |
1322 | 268 | { | ||
1323 | 269 | if (arg->type != mir_event_type_key) | ||
1324 | 270 | return false; | ||
1325 | 271 | if (arg->key.action != 0) // Key down | ||
1326 | 272 | return false; | ||
1327 | 273 | |||
1328 | 274 | return true; | ||
1329 | 275 | } | ||
1330 | 276 | MATCHER_P(KeyOfSymbol, keysym, "") | ||
1331 | 277 | { | ||
1332 | 278 | if (static_cast<xkb_keysym_t>(arg->key.key_code) == (uint)keysym) | ||
1333 | 279 | return true; | ||
1334 | 280 | return false; | ||
1335 | 281 | } | ||
1336 | 282 | |||
1337 | 283 | MATCHER(HoverEnterEvent, "") | ||
1338 | 284 | { | ||
1339 | 285 | if (arg->type != mir_event_type_motion) | ||
1340 | 286 | return false; | ||
1341 | 287 | if (arg->motion.action != AMOTION_EVENT_ACTION_HOVER_ENTER) | ||
1342 | 288 | return false; | ||
1343 | 289 | |||
1344 | 290 | return true; | ||
1345 | 291 | } | ||
1346 | 292 | |||
1347 | 293 | MATCHER_P2(ButtonDownEvent, x, y, "") | ||
1348 | 294 | { | ||
1349 | 295 | if (arg->type != mir_event_type_motion) | ||
1350 | 296 | return false; | ||
1351 | 297 | if (arg->motion.action != AMOTION_EVENT_ACTION_DOWN) | ||
1352 | 298 | return false; | ||
1353 | 299 | printf("action: %d \n", arg->motion.action); | ||
1354 | 300 | if (arg->motion.button_state == 0) | ||
1355 | 301 | return false; | ||
1356 | 302 | if (arg->motion.pointer_coordinates[0].x != x) | ||
1357 | 303 | return false; | ||
1358 | 304 | if (arg->motion.pointer_coordinates[0].y != y) | ||
1359 | 305 | return false; | ||
1360 | 306 | return true; | ||
1361 | 307 | } | ||
1362 | 308 | |||
1363 | 309 | MATCHER_P2(MotionEventWithPosition, x, y, "") | ||
1364 | 310 | { | ||
1365 | 311 | if (arg->type != mir_event_type_motion) | ||
1366 | 312 | return false; | ||
1367 | 313 | if (arg->motion.pointer_coordinates[0].x != x) | ||
1368 | 314 | return false; | ||
1369 | 315 | if (arg->motion.pointer_coordinates[0].y != y) | ||
1370 | 316 | return false; | ||
1371 | 317 | return true; | ||
1372 | 318 | } | ||
1373 | 319 | |||
1374 | 320 | } | ||
1375 | 321 | |||
1376 | 265 | 322 | ||
1377 | 266 | using TestClientInput = BespokeDisplayServerTestFixture; | 323 | using TestClientInput = BespokeDisplayServerTestFixture; |
1378 | 267 | 324 | ||
1379 | @@ -290,22 +347,13 @@ | |||
1380 | 290 | void expect_input() | 347 | void expect_input() |
1381 | 291 | { | 348 | { |
1382 | 292 | using namespace ::testing; | 349 | using namespace ::testing; |
1384 | 293 | EXPECT_CALL(*handler, handle_key_down(_)).Times(num_events_produced); | 350 | EXPECT_CALL(*handler, handle_input(KeyDownEvent())).Times(num_events_produced) |
1385 | 351 | .WillRepeatedly(Return(true)); | ||
1386 | 294 | } | 352 | } |
1387 | 295 | } client_config; | 353 | } client_config; |
1388 | 296 | launch_client_process(client_config); | 354 | launch_client_process(client_config); |
1389 | 297 | } | 355 | } |
1390 | 298 | 356 | ||
1391 | 299 | namespace | ||
1392 | 300 | { | ||
1393 | 301 | MATCHER_P(KeyOfSymbol, keysym, "") | ||
1394 | 302 | { | ||
1395 | 303 | if (static_cast<xkb_keysym_t>(arg->key.key_code) == (uint)keysym) | ||
1396 | 304 | return true; | ||
1397 | 305 | return false; | ||
1398 | 306 | } | ||
1399 | 307 | } | ||
1400 | 308 | |||
1401 | 309 | TEST_F(TestClientInput, clients_receive_us_english_mapped_keys) | 357 | TEST_F(TestClientInput, clients_receive_us_english_mapped_keys) |
1402 | 310 | { | 358 | { |
1403 | 311 | using namespace ::testing; | 359 | using namespace ::testing; |
1404 | @@ -319,12 +367,6 @@ | |||
1405 | 319 | fake_event_hub->synthesize_event(mis::a_key_down_event() | 367 | fake_event_hub->synthesize_event(mis::a_key_down_event() |
1406 | 320 | .of_scancode(KEY_4)); | 368 | .of_scancode(KEY_4)); |
1407 | 321 | 369 | ||
1408 | 322 | // Release the keys so we don't get repeat events. | ||
1409 | 323 | fake_event_hub->synthesize_event(mis::a_key_up_event() | ||
1410 | 324 | .of_scancode(KEY_4)); | ||
1411 | 325 | fake_event_hub->synthesize_event(mis::a_key_up_event() | ||
1412 | 326 | .of_scancode(KEY_LEFTSHIFT)); | ||
1413 | 327 | |||
1414 | 328 | } | 370 | } |
1415 | 329 | } server_config; | 371 | } server_config; |
1416 | 330 | launch_server_process(server_config); | 372 | launch_server_process(server_config); |
1417 | @@ -338,10 +380,78 @@ | |||
1418 | 338 | using namespace ::testing; | 380 | using namespace ::testing; |
1419 | 339 | 381 | ||
1420 | 340 | InSequence seq; | 382 | InSequence seq; |
1428 | 341 | EXPECT_CALL(*handler, handle_key_down(KeyOfSymbol(XKB_KEY_Shift_L))).Times(1); | 383 | EXPECT_CALL(*handler, handle_input(AllOf(KeyDownEvent(), KeyOfSymbol(XKB_KEY_Shift_L)))).Times(1) |
1429 | 342 | EXPECT_CALL(*handler, handle_key_down(KeyOfSymbol(XKB_KEY_dollar))).Times(1); | 384 | .WillOnce(Return(true)); |
1430 | 343 | } | 385 | EXPECT_CALL(*handler, handle_input(AllOf(KeyDownEvent(), KeyOfSymbol(XKB_KEY_dollar)))).Times(1) |
1431 | 344 | } client_config; | 386 | .WillOnce(Return(true)); |
1432 | 345 | launch_client_process(client_config); | 387 | } |
1433 | 346 | } | 388 | } client_config; |
1434 | 347 | 389 | launch_client_process(client_config); | |
1435 | 390 | } | ||
1436 | 391 | |||
1437 | 392 | // TODO: This assumes that clients are placed by shell at 0,0. Which probably isn't quite safe! | ||
1438 | 393 | TEST_F(TestClientInput, clients_receive_motion_inside_window) | ||
1439 | 394 | { | ||
1440 | 395 | using namespace ::testing; | ||
1441 | 396 | |||
1442 | 397 | struct InputProducingServerConfiguration : FakeInputServerConfiguration | ||
1443 | 398 | { | ||
1444 | 399 | void inject_input() | ||
1445 | 400 | { | ||
1446 | 401 | fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(InputReceivingClient::surface_width, | ||
1447 | 402 | InputReceivingClient::surface_height)); | ||
1448 | 403 | fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(2,2)); | ||
1449 | 404 | } | ||
1450 | 405 | } server_config; | ||
1451 | 406 | launch_server_process(server_config); | ||
1452 | 407 | |||
1453 | 408 | struct MotionReceivingClient : InputReceivingClient | ||
1454 | 409 | { | ||
1455 | 410 | MotionReceivingClient() : InputReceivingClient(2) {} | ||
1456 | 411 | |||
1457 | 412 | void expect_input() | ||
1458 | 413 | { | ||
1459 | 414 | using namespace ::testing; | ||
1460 | 415 | |||
1461 | 416 | InSequence seq; | ||
1462 | 417 | |||
1463 | 418 | // We should see the cursor enter | ||
1464 | 419 | EXPECT_CALL(*handler, handle_input(HoverEnterEvent())).Times(1).WillOnce(Return(true)); | ||
1465 | 420 | EXPECT_CALL(*handler, handle_input( | ||
1466 | 421 | MotionEventWithPosition(InputReceivingClient::surface_width, | ||
1467 | 422 | InputReceivingClient::surface_height))).Times(1).WillOnce(Return(true)); | ||
1468 | 423 | // But we should not receive an event for the second movement outside of our surface! | ||
1469 | 424 | } | ||
1470 | 425 | } client_config; | ||
1471 | 426 | launch_client_process(client_config); | ||
1472 | 427 | } | ||
1473 | 428 | |||
1474 | 429 | TEST_F(TestClientInput, clients_receive_button_events_inside_window) | ||
1475 | 430 | { | ||
1476 | 431 | using namespace ::testing; | ||
1477 | 432 | |||
1478 | 433 | struct InputProducingServerConfiguration : FakeInputServerConfiguration | ||
1479 | 434 | { | ||
1480 | 435 | void inject_input() | ||
1481 | 436 | { | ||
1482 | 437 | fake_event_hub->synthesize_event(mis::a_button_down_event().of_button(BTN_LEFT).with_action(mis::EventAction::Down)); | ||
1483 | 438 | } | ||
1484 | 439 | } server_config; | ||
1485 | 440 | launch_server_process(server_config); | ||
1486 | 441 | |||
1487 | 442 | struct ButtonReceivingClient : InputReceivingClient | ||
1488 | 443 | { | ||
1489 | 444 | ButtonReceivingClient() : InputReceivingClient(1) {} | ||
1490 | 445 | |||
1491 | 446 | void expect_input() | ||
1492 | 447 | { | ||
1493 | 448 | using namespace ::testing; | ||
1494 | 449 | |||
1495 | 450 | InSequence seq; | ||
1496 | 451 | |||
1497 | 452 | // The cursor starts at (0, 0). | ||
1498 | 453 | EXPECT_CALL(*handler, handle_input(ButtonDownEvent(0, 0))).Times(1).WillOnce(Return(true)); | ||
1499 | 454 | } | ||
1500 | 455 | } client_config; | ||
1501 | 456 | launch_client_process(client_config); | ||
1502 | 457 | } | ||
1503 | 348 | 458 | ||
1504 | === modified file 'tests/acceptance-tests/test_focus_selection.cpp' | |||
1505 | --- tests/acceptance-tests/test_focus_selection.cpp 2013-04-18 02:52:30 +0000 | |||
1506 | +++ tests/acceptance-tests/test_focus_selection.cpp 2013-04-22 16:32:37 +0000 | |||
1507 | @@ -24,11 +24,11 @@ | |||
1508 | 24 | #include "mir/shell/organising_surface_factory.h" | 24 | #include "mir/shell/organising_surface_factory.h" |
1509 | 25 | #include "mir/shell/session_manager.h" | 25 | #include "mir/shell/session_manager.h" |
1510 | 26 | #include "mir/graphics/display.h" | 26 | #include "mir/graphics/display.h" |
1512 | 27 | #include "mir/shell/input_focus_selector.h" | 27 | #include "mir/shell/input_target_listener.h" |
1513 | 28 | 28 | ||
1514 | 29 | #include "mir_test_framework/display_server_test_fixture.h" | 29 | #include "mir_test_framework/display_server_test_fixture.h" |
1515 | 30 | #include "mir_test_doubles/mock_focus_setter.h" | 30 | #include "mir_test_doubles/mock_focus_setter.h" |
1517 | 31 | #include "mir_test_doubles/mock_input_focus_selector.h" | 31 | #include "mir_test_doubles/mock_input_target_listener.h" |
1518 | 32 | 32 | ||
1519 | 33 | #include <gtest/gtest.h> | 33 | #include <gtest/gtest.h> |
1520 | 34 | #include <gmock/gmock.h> | 34 | #include <gmock/gmock.h> |
1521 | @@ -36,7 +36,8 @@ | |||
1522 | 36 | namespace mf = mir::frontend; | 36 | namespace mf = mir::frontend; |
1523 | 37 | namespace msh = mir::shell; | 37 | namespace msh = mir::shell; |
1524 | 38 | namespace mi = mir::input; | 38 | namespace mi = mir::input; |
1526 | 39 | namespace mtd = mir::test::doubles; | 39 | namespace mt = mir::test; |
1527 | 40 | namespace mtd = mt::doubles; | ||
1528 | 40 | namespace mtf = mir_test_framework; | 41 | namespace mtf = mir_test_framework; |
1529 | 41 | 42 | ||
1530 | 42 | namespace | 43 | namespace |
1531 | @@ -46,6 +47,7 @@ | |||
1532 | 46 | 47 | ||
1533 | 47 | namespace | 48 | namespace |
1534 | 48 | { | 49 | { |
1535 | 50 | |||
1536 | 49 | struct ClientConfigCommon : TestingClientConfiguration | 51 | struct ClientConfigCommon : TestingClientConfiguration |
1537 | 50 | { | 52 | { |
1538 | 51 | ClientConfigCommon() : | 53 | ClientConfigCommon() : |
1539 | @@ -121,18 +123,10 @@ | |||
1540 | 121 | { | 123 | { |
1541 | 122 | return arg != std::shared_ptr<msh::Session>(); | 124 | return arg != std::shared_ptr<msh::Session>(); |
1542 | 123 | } | 125 | } |
1543 | 124 | MATCHER(NonNullSessionTarget, "") | ||
1544 | 125 | { | ||
1545 | 126 | return arg != std::shared_ptr<mi::SessionTarget>(); | ||
1546 | 127 | } | ||
1547 | 128 | MATCHER(NonNullSurfaceTarget, "") | 126 | MATCHER(NonNullSurfaceTarget, "") |
1548 | 129 | { | 127 | { |
1549 | 130 | return arg != std::shared_ptr<mi::SurfaceTarget>(); | 128 | return arg != std::shared_ptr<mi::SurfaceTarget>(); |
1550 | 131 | } | 129 | } |
1551 | 132 | MATCHER(NullSurfaceTarget, "") | ||
1552 | 133 | { | ||
1553 | 134 | return arg == std::shared_ptr<mi::SurfaceTarget>(); | ||
1554 | 135 | } | ||
1555 | 136 | } | 130 | } |
1556 | 137 | 131 | ||
1557 | 138 | TEST_F(BespokeDisplayServerTestFixture, sessions_creating_surface_receive_focus) | 132 | TEST_F(BespokeDisplayServerTestFixture, sessions_creating_surface_receive_focus) |
1558 | @@ -148,7 +142,6 @@ | |||
1559 | 148 | using namespace ::testing; | 142 | using namespace ::testing; |
1560 | 149 | 143 | ||
1561 | 150 | auto focus_setter = std::make_shared<mtd::MockFocusSetter>(); | 144 | auto focus_setter = std::make_shared<mtd::MockFocusSetter>(); |
1562 | 151 | |||
1563 | 152 | { | 145 | { |
1564 | 153 | InSequence seq; | 146 | InSequence seq; |
1565 | 154 | // Once on application registration and once on surface creation | 147 | // Once on application registration and once on surface creation |
1566 | @@ -174,30 +167,37 @@ | |||
1567 | 174 | { | 167 | { |
1568 | 175 | struct ServerConfig : TestingServerConfiguration | 168 | struct ServerConfig : TestingServerConfiguration |
1569 | 176 | { | 169 | { |
1571 | 177 | std::shared_ptr<mtd::MockInputFocusSelector> focus_selector; | 170 | std::shared_ptr<mtd::MockInputTargetListener> target_listener; |
1572 | 178 | bool expected; | 171 | bool expected; |
1573 | 179 | 172 | ||
1574 | 180 | ServerConfig() | 173 | ServerConfig() |
1576 | 181 | : focus_selector(std::make_shared<mtd::MockInputFocusSelector>()), | 174 | : target_listener(std::make_shared<mtd::MockInputTargetListener>()), |
1577 | 182 | expected(false) | 175 | expected(false) |
1578 | 183 | { | 176 | { |
1579 | 184 | } | 177 | } |
1580 | 185 | 178 | ||
1583 | 186 | std::shared_ptr<msh::InputFocusSelector> | 179 | std::shared_ptr<msh::InputTargetListener> |
1584 | 187 | the_input_focus_selector() override | 180 | the_input_target_listener() override |
1585 | 188 | { | 181 | { |
1586 | 189 | using namespace ::testing; | 182 | using namespace ::testing; |
1587 | 190 | 183 | ||
1588 | 191 | if (!expected) | 184 | if (!expected) |
1589 | 192 | { | 185 | { |
1591 | 193 | InSequence seq; | 186 | |
1592 | 187 | EXPECT_CALL(*target_listener, input_application_opened(_)).Times(AtLeast(0)); | ||
1593 | 188 | EXPECT_CALL(*target_listener, input_application_closed(_)).Times(AtLeast(0)); | ||
1594 | 189 | EXPECT_CALL(*target_listener, input_surface_opened(_,_)).Times(AtLeast(0)); | ||
1595 | 190 | EXPECT_CALL(*target_listener, input_surface_closed(_)).Times(AtLeast(0)); | ||
1596 | 191 | EXPECT_CALL(*target_listener, focus_cleared()).Times(AtLeast(0)); | ||
1597 | 194 | 192 | ||
1601 | 195 | EXPECT_CALL(*focus_selector, set_input_focus_to(NonNullSessionTarget(), NullSurfaceTarget())).Times(1); | 193 | { |
1602 | 196 | EXPECT_CALL(*focus_selector, set_input_focus_to(NonNullSessionTarget(), NonNullSurfaceTarget())).Times(1); | 194 | InSequence seq; |
1603 | 197 | expected = true; | 195 | EXPECT_CALL(*target_listener, focus_changed(NonNullSurfaceTarget())).Times(1); |
1604 | 196 | expected = true; | ||
1605 | 197 | } | ||
1606 | 198 | } | 198 | } |
1607 | 199 | 199 | ||
1609 | 200 | return focus_selector; | 200 | return target_listener; |
1610 | 201 | } | 201 | } |
1611 | 202 | } server_config; | 202 | } server_config; |
1612 | 203 | 203 | ||
1613 | 204 | 204 | ||
1614 | === modified file 'tests/death-tests/test_application_manager_death.cpp' | |||
1615 | --- tests/death-tests/test_application_manager_death.cpp 2013-03-21 03:32:59 +0000 | |||
1616 | +++ tests/death-tests/test_application_manager_death.cpp 2013-04-22 16:32:37 +0000 | |||
1617 | @@ -30,11 +30,12 @@ | |||
1618 | 30 | // ::testing::FLAGS_gtest_death_test_style = "threadsafe"; | 30 | // ::testing::FLAGS_gtest_death_test_style = "threadsafe"; |
1619 | 31 | // leads to the test failing under valgrind | 31 | // leads to the test failing under valgrind |
1620 | 32 | EXPECT_EXIT( | 32 | EXPECT_EXIT( |
1623 | 33 | std::shared_ptr<msh::SurfaceFactory> factory; | 33 | std::shared_ptr<msh::SurfaceFactory> surface_factory; |
1624 | 34 | mir::shell::SessionManager app(factory, | 34 | mir::shell::SessionManager app(surface_factory, |
1625 | 35 | std::shared_ptr<msh::SessionContainer>(), | 35 | std::shared_ptr<msh::SessionContainer>(), |
1626 | 36 | std::shared_ptr<msh::FocusSequence>(), | 36 | std::shared_ptr<msh::FocusSequence>(), |
1628 | 37 | std::shared_ptr<msh::FocusSetter>()), | 37 | std::shared_ptr<msh::FocusSetter>(), |
1629 | 38 | std::shared_ptr<msh::InputTargetListener>()), | ||
1630 | 38 | ::testing::KilledBySignal(SIGABRT), | 39 | ::testing::KilledBySignal(SIGABRT), |
1631 | 39 | ".*"); | 40 | ".*"); |
1632 | 40 | } | 41 | } |
1633 | 41 | 42 | ||
1634 | === modified file 'tests/integration-tests/input/android/test_android_input_manager.cpp' | |||
1635 | --- tests/integration-tests/input/android/test_android_input_manager.cpp 2013-04-10 23:48:23 +0000 | |||
1636 | +++ tests/integration-tests/input/android/test_android_input_manager.cpp 2013-04-22 16:32:37 +0000 | |||
1637 | @@ -35,6 +35,7 @@ | |||
1638 | 35 | #include "mir_test_doubles/stub_surface_target.h" | 35 | #include "mir_test_doubles/stub_surface_target.h" |
1639 | 36 | #include "mir_test/wait_condition.h" | 36 | #include "mir_test/wait_condition.h" |
1640 | 37 | #include "mir_test/event_factory.h" | 37 | #include "mir_test/event_factory.h" |
1641 | 38 | #include "mir_test/event_matchers.h" | ||
1642 | 38 | 39 | ||
1643 | 39 | #include <EventHub.h> | 40 | #include <EventHub.h> |
1644 | 40 | #include <InputDispatcher.h> | 41 | #include <InputDispatcher.h> |
1645 | @@ -171,7 +172,7 @@ | |||
1646 | 171 | struct MockDispatcherPolicy : public mia::EventFilterDispatcherPolicy | 172 | struct MockDispatcherPolicy : public mia::EventFilterDispatcherPolicy |
1647 | 172 | { | 173 | { |
1648 | 173 | MockDispatcherPolicy(std::shared_ptr<mi::EventFilter> const& filter) | 174 | MockDispatcherPolicy(std::shared_ptr<mi::EventFilter> const& filter) |
1650 | 174 | : EventFilterDispatcherPolicy(filter) | 175 | : EventFilterDispatcherPolicy(filter, false) |
1651 | 175 | { | 176 | { |
1652 | 176 | } | 177 | } |
1653 | 177 | MOCK_METHOD3(interceptKeyBeforeDispatching, nsecs_t(droidinput::sp<droidinput::InputWindowHandle> const&, | 178 | MOCK_METHOD3(interceptKeyBeforeDispatching, nsecs_t(droidinput::sp<droidinput::InputWindowHandle> const&, |
1654 | @@ -211,24 +212,31 @@ | |||
1655 | 211 | ON_CALL(viewable_area, view_area()) | 212 | ON_CALL(viewable_area, view_area()) |
1656 | 212 | .WillByDefault(Return(default_view_area)); | 213 | .WillByDefault(Return(default_view_area)); |
1657 | 213 | input_manager = std::make_shared<mia::InputManager>(configuration); | 214 | input_manager = std::make_shared<mia::InputManager>(configuration); |
1659 | 214 | input_focus_selector = std::make_shared<mia::DispatcherController>(configuration); | 215 | input_target_listener = std::make_shared<mia::DispatcherController>(configuration); |
1660 | 215 | 216 | ||
1661 | 216 | dispatcher_policy = configuration->the_mock_dispatcher_policy(); | 217 | dispatcher_policy = configuration->the_mock_dispatcher_policy(); |
1662 | 217 | 218 | ||
1663 | 218 | } | 219 | } |
1664 | 219 | 220 | ||
1665 | 221 | ~AndroidInputManagerDispatcherInterceptSetup() | ||
1666 | 222 | { | ||
1667 | 223 | input_manager->stop(); | ||
1668 | 224 | } | ||
1669 | 225 | |||
1670 | 220 | // TODO: It would be nice if it were possible to mock the interface between | 226 | // TODO: It would be nice if it were possible to mock the interface between |
1671 | 221 | // droidinput::InputChannel and droidinput::InputDispatcher rather than use | 227 | // droidinput::InputChannel and droidinput::InputDispatcher rather than use |
1672 | 222 | // valid fds to allow non-throwing construction of a real input channel. | 228 | // valid fds to allow non-throwing construction of a real input channel. |
1673 | 223 | void SetUp() | 229 | void SetUp() |
1674 | 224 | { | 230 | { |
1675 | 225 | test_input_fd = socket(AF_UNIX, SOCK_SEQPACKET, 0); | ||
1676 | 226 | input_manager->start(); | 231 | input_manager->start(); |
1677 | 227 | } | 232 | } |
1679 | 228 | void TearDown() | 233 | |
1680 | 234 | int test_fd() | ||
1681 | 229 | { | 235 | { |
1684 | 230 | input_manager->stop(); | 236 | int fds[2]; |
1685 | 231 | close(test_input_fd); | 237 | // Closed by droidinput InputChannel on shutdown |
1686 | 238 | socketpair(AF_UNIX, SOCK_SEQPACKET, 0, fds); | ||
1687 | 239 | return fds[0]; | ||
1688 | 232 | } | 240 | } |
1689 | 233 | 241 | ||
1690 | 234 | MockEventFilter event_filter; | 242 | MockEventFilter event_filter; |
1691 | @@ -238,9 +246,7 @@ | |||
1692 | 238 | droidinput::sp<MockDispatcherPolicy> dispatcher_policy; | 246 | droidinput::sp<MockDispatcherPolicy> dispatcher_policy; |
1693 | 239 | 247 | ||
1694 | 240 | std::shared_ptr<mia::InputManager> input_manager; | 248 | std::shared_ptr<mia::InputManager> input_manager; |
1698 | 241 | std::shared_ptr<msh::InputFocusSelector> input_focus_selector; | 249 | std::shared_ptr<msh::InputTargetListener> input_target_listener; |
1696 | 242 | |||
1697 | 243 | int test_input_fd; | ||
1699 | 244 | }; | 250 | }; |
1700 | 245 | 251 | ||
1701 | 246 | MATCHER_P(WindowHandleWithInputFd, input_fd, "") | 252 | MATCHER_P(WindowHandleWithInputFd, input_fd, "") |
1702 | @@ -259,14 +265,18 @@ | |||
1703 | 259 | mt::WaitCondition wait_condition; | 265 | mt::WaitCondition wait_condition; |
1704 | 260 | 266 | ||
1705 | 261 | mtd::StubSessionTarget session; | 267 | mtd::StubSessionTarget session; |
1707 | 262 | mtd::StubSurfaceTarget surface(test_input_fd); | 268 | |
1708 | 269 | auto input_fd = test_fd(); | ||
1709 | 270 | mtd::StubSurfaceTarget surface(input_fd); | ||
1710 | 263 | 271 | ||
1711 | 264 | EXPECT_CALL(event_filter, handles(_)).Times(1).WillOnce(Return(false)); | 272 | EXPECT_CALL(event_filter, handles(_)).Times(1).WillOnce(Return(false)); |
1712 | 265 | // We return -1 here to skip publishing of the event (to an unconnected test socket!). | 273 | // We return -1 here to skip publishing of the event (to an unconnected test socket!). |
1714 | 266 | EXPECT_CALL(*dispatcher_policy, interceptKeyBeforeDispatching(WindowHandleWithInputFd(test_input_fd), _, _)) | 274 | EXPECT_CALL(*dispatcher_policy, interceptKeyBeforeDispatching(WindowHandleWithInputFd(input_fd), _, _)) |
1715 | 267 | .Times(1).WillOnce(DoAll(mt::WakeUp(&wait_condition), Return(-1))); | 275 | .Times(1).WillOnce(DoAll(mt::WakeUp(&wait_condition), Return(-1))); |
1716 | 268 | 276 | ||
1718 | 269 | input_focus_selector->set_input_focus_to(mt::fake_shared(session), mt::fake_shared(surface)); | 277 | input_target_listener->input_application_opened(mt::fake_shared(session)); |
1719 | 278 | input_target_listener->input_surface_opened(mt::fake_shared(session), mt::fake_shared(surface)); | ||
1720 | 279 | input_target_listener->focus_changed(mt::fake_shared(surface)); | ||
1721 | 270 | 280 | ||
1722 | 271 | fake_event_hub->synthesize_builtin_keyboard_added(); | 281 | fake_event_hub->synthesize_builtin_keyboard_added(); |
1723 | 272 | fake_event_hub->synthesize_device_scan_complete(); | 282 | fake_event_hub->synthesize_device_scan_complete(); |
1724 | @@ -275,3 +285,52 @@ | |||
1725 | 275 | 285 | ||
1726 | 276 | wait_condition.wait_for_at_most_seconds(1); | 286 | wait_condition.wait_for_at_most_seconds(1); |
1727 | 277 | } | 287 | } |
1728 | 288 | |||
1729 | 289 | TEST_F(AndroidInputManagerDispatcherInterceptSetup, changing_focus_changes_event_recipient) | ||
1730 | 290 | { | ||
1731 | 291 | using namespace ::testing; | ||
1732 | 292 | |||
1733 | 293 | mt::WaitCondition wait1, wait2, wait3; | ||
1734 | 294 | |||
1735 | 295 | mtd::StubSessionTarget session; | ||
1736 | 296 | |||
1737 | 297 | auto input_fd_1 = test_fd(); | ||
1738 | 298 | mtd::StubSurfaceTarget surface1(input_fd_1); | ||
1739 | 299 | auto input_fd_2 = test_fd(); | ||
1740 | 300 | mtd::StubSurfaceTarget surface2(input_fd_2); | ||
1741 | 301 | |||
1742 | 302 | input_target_listener->input_application_opened(mt::fake_shared(session)); | ||
1743 | 303 | input_target_listener->input_surface_opened(mt::fake_shared(session), mt::fake_shared(surface1)); | ||
1744 | 304 | input_target_listener->input_surface_opened(mt::fake_shared(session), mt::fake_shared(surface2)); | ||
1745 | 305 | |||
1746 | 306 | EXPECT_CALL(event_filter, handles(_)).Times(3).WillRepeatedly(Return(false)); | ||
1747 | 307 | |||
1748 | 308 | { | ||
1749 | 309 | InSequence seq; | ||
1750 | 310 | |||
1751 | 311 | EXPECT_CALL(*dispatcher_policy, interceptKeyBeforeDispatching(WindowHandleWithInputFd(input_fd_1), _, _)) | ||
1752 | 312 | .Times(1).WillOnce(DoAll(mt::WakeUp(&wait1), Return(-1))); | ||
1753 | 313 | EXPECT_CALL(*dispatcher_policy, interceptKeyBeforeDispatching(WindowHandleWithInputFd(input_fd_2), _, _)) | ||
1754 | 314 | .Times(1).WillOnce(DoAll(mt::WakeUp(&wait2), Return(-1))); | ||
1755 | 315 | EXPECT_CALL(*dispatcher_policy, interceptKeyBeforeDispatching(WindowHandleWithInputFd(input_fd_1), _, _)) | ||
1756 | 316 | .Times(1).WillOnce(DoAll(mt::WakeUp(&wait3), Return(-1))); | ||
1757 | 317 | } | ||
1758 | 318 | |||
1759 | 319 | fake_event_hub->synthesize_builtin_keyboard_added(); | ||
1760 | 320 | fake_event_hub->synthesize_device_scan_complete(); | ||
1761 | 321 | |||
1762 | 322 | input_target_listener->focus_changed(mt::fake_shared(surface1)); | ||
1763 | 323 | fake_event_hub->synthesize_event(mis::a_key_down_event() | ||
1764 | 324 | .of_scancode(KEY_1)); | ||
1765 | 325 | wait1.wait_for_at_most_seconds(1); | ||
1766 | 326 | |||
1767 | 327 | input_target_listener->focus_changed(mt::fake_shared(surface2)); | ||
1768 | 328 | fake_event_hub->synthesize_event(mis::a_key_down_event() | ||
1769 | 329 | .of_scancode(KEY_2)); | ||
1770 | 330 | wait2.wait_for_at_most_seconds(1); | ||
1771 | 331 | |||
1772 | 332 | input_target_listener->focus_changed(mt::fake_shared(surface1)); | ||
1773 | 333 | fake_event_hub->synthesize_event(mis::a_key_down_event() | ||
1774 | 334 | .of_scancode(KEY_3)); | ||
1775 | 335 | wait3.wait_for_at_most_seconds(5); | ||
1776 | 336 | } | ||
1777 | 278 | 337 | ||
1778 | === modified file 'tests/integration-tests/input/android/test_fake_event_hub_to_event_filter.cpp' | |||
1779 | --- tests/integration-tests/input/android/test_fake_event_hub_to_event_filter.cpp 2013-04-02 18:26:40 +0000 | |||
1780 | +++ tests/integration-tests/input/android/test_fake_event_hub_to_event_filter.cpp 2013-04-22 16:32:37 +0000 | |||
1781 | @@ -26,6 +26,7 @@ | |||
1782 | 26 | #include "mir_test_doubles/mock_event_filter.h" | 26 | #include "mir_test_doubles/mock_event_filter.h" |
1783 | 27 | #include "mir_test/wait_condition.h" | 27 | #include "mir_test/wait_condition.h" |
1784 | 28 | #include "mir_test/event_factory.h" | 28 | #include "mir_test/event_factory.h" |
1785 | 29 | #include "mir_test/event_matchers.h" | ||
1786 | 29 | 30 | ||
1787 | 30 | #include <InputDispatcher.h> | 31 | #include <InputDispatcher.h> |
1788 | 31 | #include <InputReader.h> | 32 | #include <InputReader.h> |
1789 | @@ -56,7 +57,7 @@ | |||
1790 | 56 | void SetUp() | 57 | void SetUp() |
1791 | 57 | { | 58 | { |
1792 | 58 | event_hub = new mia::FakeEventHub(); | 59 | event_hub = new mia::FakeEventHub(); |
1794 | 59 | dispatcher_policy = new mia::EventFilterDispatcherPolicy(mt::fake_shared(event_filter)); | 60 | dispatcher_policy = new mia::EventFilterDispatcherPolicy(mt::fake_shared(event_filter), false); |
1795 | 60 | reader_policy = new mia::RudimentaryInputReaderPolicy(); | 61 | reader_policy = new mia::RudimentaryInputReaderPolicy(); |
1796 | 61 | dispatcher = new droidinput::InputDispatcher(dispatcher_policy); | 62 | dispatcher = new droidinput::InputDispatcher(dispatcher_policy); |
1797 | 62 | reader = new droidinput::InputReader(event_hub, reader_policy, dispatcher); | 63 | reader = new droidinput::InputReader(event_hub, reader_policy, dispatcher); |
1798 | 63 | 64 | ||
1799 | === modified file 'tests/integration-tests/shell/test_session_manager.cpp' | |||
1800 | --- tests/integration-tests/shell/test_session_manager.cpp 2013-04-18 00:00:55 +0000 | |||
1801 | +++ tests/integration-tests/shell/test_session_manager.cpp 2013-04-22 16:32:37 +0000 | |||
1802 | @@ -33,6 +33,7 @@ | |||
1803 | 33 | #include "mir_test/fake_shared.h" | 33 | #include "mir_test/fake_shared.h" |
1804 | 34 | #include "mir_test_doubles/mock_surface_factory.h" | 34 | #include "mir_test_doubles/mock_surface_factory.h" |
1805 | 35 | #include "mir_test_doubles/mock_focus_setter.h" | 35 | #include "mir_test_doubles/mock_focus_setter.h" |
1806 | 36 | #include "mir_test_doubles/stub_input_target_listener.h" | ||
1807 | 36 | 37 | ||
1808 | 37 | namespace mc = mir::compositor; | 38 | namespace mc = mir::compositor; |
1809 | 38 | namespace mf = mir::frontend; | 39 | namespace mf = mir::frontend; |
1810 | @@ -44,19 +45,22 @@ | |||
1811 | 44 | TEST(TestSessionManagerAndFocusSelectionStrategy, cycle_focus) | 45 | TEST(TestSessionManagerAndFocusSelectionStrategy, cycle_focus) |
1812 | 45 | { | 46 | { |
1813 | 46 | using namespace ::testing; | 47 | using namespace ::testing; |
1814 | 48 | |||
1815 | 47 | mtd::MockSurfaceFactory surface_factory; | 49 | mtd::MockSurfaceFactory surface_factory; |
1816 | 48 | std::shared_ptr<msh::DefaultSessionContainer> container(new msh::DefaultSessionContainer()); | 50 | std::shared_ptr<msh::DefaultSessionContainer> container(new msh::DefaultSessionContainer()); |
1817 | 49 | msh::RegistrationOrderFocusSequence sequence(container); | 51 | msh::RegistrationOrderFocusSequence sequence(container); |
1819 | 50 | mtd::MockFocusSetter focus_changer; | 52 | mtd::MockFocusSetter focus_setter; |
1820 | 51 | std::shared_ptr<mf::Session> new_session; | 53 | std::shared_ptr<mf::Session> new_session; |
1821 | 54 | mtd::StubInputTargetListener input_target_listener; | ||
1822 | 52 | 55 | ||
1823 | 53 | msh::SessionManager session_manager( | 56 | msh::SessionManager session_manager( |
1824 | 54 | mt::fake_shared(surface_factory), | 57 | mt::fake_shared(surface_factory), |
1825 | 55 | container, | 58 | container, |
1826 | 56 | mt::fake_shared(sequence), | 59 | mt::fake_shared(sequence), |
1830 | 57 | mt::fake_shared(focus_changer)); | 60 | mt::fake_shared(focus_setter), |
1831 | 58 | 61 | mt::fake_shared(input_target_listener)); | |
1832 | 59 | EXPECT_CALL(focus_changer, set_focus_to(_)).Times(3); | 62 | |
1833 | 63 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3); | ||
1834 | 60 | 64 | ||
1835 | 61 | auto session1 = session_manager.open_session("Visual Basic Studio"); | 65 | auto session1 = session_manager.open_session("Visual Basic Studio"); |
1836 | 62 | auto session2 = session_manager.open_session("Microsoft Access"); | 66 | auto session2 = session_manager.open_session("Microsoft Access"); |
1837 | @@ -64,9 +68,9 @@ | |||
1838 | 64 | 68 | ||
1839 | 65 | { | 69 | { |
1840 | 66 | InSequence seq; | 70 | InSequence seq; |
1844 | 67 | EXPECT_CALL(focus_changer, set_focus_to(Eq(session1))).Times(1); | 71 | EXPECT_CALL(focus_setter, set_focus_to(Eq(session1))).Times(1); |
1845 | 68 | EXPECT_CALL(focus_changer, set_focus_to(Eq(session2))).Times(1); | 72 | EXPECT_CALL(focus_setter, set_focus_to(Eq(session2))).Times(1); |
1846 | 69 | EXPECT_CALL(focus_changer, set_focus_to(Eq(session3))).Times(1); | 73 | EXPECT_CALL(focus_setter, set_focus_to(Eq(session3))).Times(1); |
1847 | 70 | } | 74 | } |
1848 | 71 | 75 | ||
1849 | 72 | session_manager.focus_next(); | 76 | session_manager.focus_next(); |
1850 | @@ -77,19 +81,22 @@ | |||
1851 | 77 | TEST(TestSessionManagerAndFocusSelectionStrategy, closing_applications_transfers_focus) | 81 | TEST(TestSessionManagerAndFocusSelectionStrategy, closing_applications_transfers_focus) |
1852 | 78 | { | 82 | { |
1853 | 79 | using namespace ::testing; | 83 | using namespace ::testing; |
1854 | 84 | |||
1855 | 80 | mtd::MockSurfaceFactory surface_factory; | 85 | mtd::MockSurfaceFactory surface_factory; |
1859 | 81 | std::shared_ptr<msh::DefaultSessionContainer> model(new msh::DefaultSessionContainer()); | 86 | std::shared_ptr<msh::DefaultSessionContainer> container(new msh::DefaultSessionContainer()); |
1860 | 82 | msh::RegistrationOrderFocusSequence sequence(model); | 87 | msh::RegistrationOrderFocusSequence sequence(container); |
1861 | 83 | mtd::MockFocusSetter focus_changer; | 88 | mtd::MockFocusSetter focus_setter; |
1862 | 84 | std::shared_ptr<mf::Session> new_session; | 89 | std::shared_ptr<mf::Session> new_session; |
1863 | 90 | mtd::StubInputTargetListener input_target_listener; | ||
1864 | 85 | 91 | ||
1865 | 86 | msh::SessionManager session_manager( | 92 | msh::SessionManager session_manager( |
1870 | 87 | mt::fake_shared(surface_factory), | 93 | mt::fake_shared(surface_factory), |
1871 | 88 | model, | 94 | container, |
1872 | 89 | mt::fake_shared(sequence), | 95 | mt::fake_shared(sequence), |
1873 | 90 | mt::fake_shared(focus_changer)); | 96 | mt::fake_shared(focus_setter), |
1874 | 97 | mt::fake_shared(input_target_listener)); | ||
1875 | 91 | 98 | ||
1877 | 92 | EXPECT_CALL(focus_changer, set_focus_to(_)).Times(3); | 99 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3); |
1878 | 93 | 100 | ||
1879 | 94 | auto session1 = session_manager.open_session("Visual Basic Studio"); | 101 | auto session1 = session_manager.open_session("Visual Basic Studio"); |
1880 | 95 | auto session2 = session_manager.open_session("Microsoft Access"); | 102 | auto session2 = session_manager.open_session("Microsoft Access"); |
1881 | @@ -97,8 +104,8 @@ | |||
1882 | 97 | 104 | ||
1883 | 98 | { | 105 | { |
1884 | 99 | InSequence seq; | 106 | InSequence seq; |
1887 | 100 | EXPECT_CALL(focus_changer, set_focus_to(Eq(session2))).Times(1); | 107 | EXPECT_CALL(focus_setter, set_focus_to(Eq(session2))).Times(1); |
1888 | 101 | EXPECT_CALL(focus_changer, set_focus_to(Eq(session1))).Times(1); | 108 | EXPECT_CALL(focus_setter, set_focus_to(Eq(session1))).Times(1); |
1889 | 102 | } | 109 | } |
1890 | 103 | 110 | ||
1891 | 104 | session_manager.close_session(session3); | 111 | session_manager.close_session(session3); |
1892 | 105 | 112 | ||
1893 | === modified file 'tests/mir_test_doubles/fake_event_hub.cpp' | |||
1894 | --- tests/mir_test_doubles/fake_event_hub.cpp 2013-03-29 16:51:35 +0000 | |||
1895 | +++ tests/mir_test_doubles/fake_event_hub.cpp 2013-04-22 16:32:37 +0000 | |||
1896 | @@ -322,7 +322,7 @@ | |||
1897 | 322 | void mia::FakeEventHub::synthesize_event(const mis::ButtonParameters ¶meters) | 322 | void mia::FakeEventHub::synthesize_event(const mis::ButtonParameters ¶meters) |
1898 | 323 | { | 323 | { |
1899 | 324 | RawEvent event; | 324 | RawEvent event; |
1901 | 325 | event.when = 0; // TODO: This may need a timestamp to go over the wire ~racarr | 325 | event.when = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch()).count(); |
1902 | 326 | event.type = EV_KEY; | 326 | event.type = EV_KEY; |
1903 | 327 | event.code = parameters.button; | 327 | event.code = parameters.button; |
1904 | 328 | 328 | ||
1905 | @@ -348,7 +348,7 @@ | |||
1906 | 348 | void mia::FakeEventHub::synthesize_event(const mis::MotionParameters ¶meters) | 348 | void mia::FakeEventHub::synthesize_event(const mis::MotionParameters ¶meters) |
1907 | 349 | { | 349 | { |
1908 | 350 | RawEvent event; | 350 | RawEvent event; |
1910 | 351 | event.when = 0; | 351 | event.when = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch()).count(); |
1911 | 352 | event.type = EV_REL; | 352 | event.type = EV_REL; |
1912 | 353 | if (parameters.device_id) | 353 | if (parameters.device_id) |
1913 | 354 | event.deviceId = parameters.device_id; | 354 | event.deviceId = parameters.device_id; |
1914 | 355 | 355 | ||
1915 | === modified file 'tests/mir_test_framework/testing_server_options.cpp' | |||
1916 | --- tests/mir_test_framework/testing_server_options.cpp 2013-04-18 15:20:45 +0000 | |||
1917 | +++ tests/mir_test_framework/testing_server_options.cpp 2013-04-22 16:32:37 +0000 | |||
1918 | @@ -29,7 +29,7 @@ | |||
1919 | 29 | #include "mir/compositor/graphic_buffer_allocator.h" | 29 | #include "mir/compositor/graphic_buffer_allocator.h" |
1920 | 30 | #include "mir/input/input_channel.h" | 30 | #include "mir/input/input_channel.h" |
1921 | 31 | #include "mir/input/input_manager.h" | 31 | #include "mir/input/input_manager.h" |
1923 | 32 | #include "mir/shell/input_focus_selector.h" | 32 | #include "mir/input/null_input_target_listener.h" |
1924 | 33 | #include "src/server/input/android/android_input_manager.h" | 33 | #include "src/server/input/android/android_input_manager.h" |
1925 | 34 | #include "src/server/input/android/android_dispatcher_controller.h" | 34 | #include "src/server/input/android/android_dispatcher_controller.h" |
1926 | 35 | 35 | ||
1927 | @@ -159,14 +159,6 @@ | |||
1928 | 159 | } | 159 | } |
1929 | 160 | }; | 160 | }; |
1930 | 161 | 161 | ||
1931 | 162 | class StubInputFocusSelector : public msh::InputFocusSelector | ||
1932 | 163 | { | ||
1933 | 164 | public: | ||
1934 | 165 | void set_input_focus_to(std::shared_ptr<mi::SessionTarget> const& /* session */, std::shared_ptr<mi::SurfaceTarget> const& /* surface */) | ||
1935 | 166 | { | ||
1936 | 167 | } | ||
1937 | 168 | }; | ||
1938 | 169 | |||
1939 | 170 | } | 162 | } |
1940 | 171 | 163 | ||
1941 | 172 | mtf::TestingServerConfiguration::TestingServerConfiguration() : | 164 | mtf::TestingServerConfiguration::TestingServerConfiguration() : |
1942 | @@ -184,14 +176,14 @@ | |||
1943 | 184 | return std::make_shared<StubInputManager>(); | 176 | return std::make_shared<StubInputManager>(); |
1944 | 185 | } | 177 | } |
1945 | 186 | 178 | ||
1947 | 187 | std::shared_ptr<msh::InputFocusSelector> mtf::TestingServerConfiguration::the_input_focus_selector() | 179 | std::shared_ptr<msh::InputTargetListener> mtf::TestingServerConfiguration::the_input_target_listener() |
1948 | 188 | { | 180 | { |
1949 | 189 | auto options = the_options(); | 181 | auto options = the_options(); |
1950 | 190 | 182 | ||
1951 | 191 | if (options->get("tests-use-real-input", false)) | 183 | if (options->get("tests-use-real-input", false)) |
1952 | 192 | return std::make_shared<mia::DispatcherController>(the_input_configuration()); | 184 | return std::make_shared<mia::DispatcherController>(the_input_configuration()); |
1953 | 193 | else | 185 | else |
1955 | 194 | return std::make_shared<StubInputFocusSelector>(); | 186 | return std::make_shared<mi::NullInputTargetListener>(); |
1956 | 195 | } | 187 | } |
1957 | 196 | 188 | ||
1958 | 197 | std::shared_ptr<mg::Platform> mtf::TestingServerConfiguration::the_graphics_platform() | 189 | std::shared_ptr<mg::Platform> mtf::TestingServerConfiguration::the_graphics_platform() |
1959 | 198 | 190 | ||
1960 | === modified file 'tests/unit-tests/input/android/test_android_dispatcher_controller.cpp' | |||
1961 | --- tests/unit-tests/input/android/test_android_dispatcher_controller.cpp 2013-04-15 14:39:18 +0000 | |||
1962 | +++ tests/unit-tests/input/android/test_android_dispatcher_controller.cpp 2013-04-22 16:32:37 +0000 | |||
1963 | @@ -31,6 +31,8 @@ | |||
1964 | 31 | #include <sys/types.h> | 31 | #include <sys/types.h> |
1965 | 32 | #include <sys/socket.h> | 32 | #include <sys/socket.h> |
1966 | 33 | 33 | ||
1967 | 34 | #include <stdexcept> | ||
1968 | 35 | |||
1969 | 34 | namespace mi = mir::input; | 36 | namespace mi = mir::input; |
1970 | 35 | namespace mia = mi::android; | 37 | namespace mia = mi::android; |
1971 | 36 | namespace mt = mir::test; | 38 | namespace mt = mir::test; |
1972 | @@ -47,12 +49,16 @@ | |||
1973 | 47 | void SetUp() override | 49 | void SetUp() override |
1974 | 48 | { | 50 | { |
1975 | 49 | test_input_fd = socket(AF_UNIX, SOCK_SEQPACKET, 0); | 51 | test_input_fd = socket(AF_UNIX, SOCK_SEQPACKET, 0); |
1976 | 52 | |||
1977 | 53 | dispatcher = new mtd::MockInputDispatcher(); | ||
1978 | 50 | } | 54 | } |
1979 | 51 | void TearDown() override | 55 | void TearDown() override |
1980 | 52 | { | 56 | { |
1981 | 53 | close(test_input_fd); | 57 | close(test_input_fd); |
1982 | 54 | } | 58 | } |
1983 | 55 | int test_input_fd; | 59 | int test_input_fd; |
1984 | 60 | droidinput::sp<mtd::MockInputDispatcher> dispatcher; | ||
1985 | 61 | mtd::MockInputConfiguration config; | ||
1986 | 56 | }; | 62 | }; |
1987 | 57 | 63 | ||
1988 | 58 | static bool | 64 | static bool |
1989 | @@ -104,12 +110,116 @@ | |||
1990 | 104 | 110 | ||
1991 | 105 | } | 111 | } |
1992 | 106 | 112 | ||
1999 | 107 | TEST_F(AndroidDispatcherControllerFdSetup, set_input_focus) | 113 | TEST_F(AndroidDispatcherControllerFdSetup, input_application_opened_behavior) |
2000 | 108 | { | 114 | { |
2001 | 109 | using namespace ::testing; | 115 | using namespace ::testing; |
2002 | 110 | 116 | ||
2003 | 111 | auto dispatcher = new mtd::MockInputDispatcher(); // We need droidinput::sp | 117 | EXPECT_CALL(config, the_dispatcher()).Times(1) |
2004 | 112 | mtd::MockInputConfiguration config; | 118 | .WillOnce(Return(dispatcher)); |
2005 | 119 | mia::DispatcherController controller(mt::fake_shared(config)); | ||
2006 | 120 | |||
2007 | 121 | auto session = std::make_shared<mtd::StubSessionTarget>(); | ||
2008 | 122 | controller.input_application_opened(session); | ||
2009 | 123 | EXPECT_THROW({ | ||
2010 | 124 | // An application can not be opened twice! | ||
2011 | 125 | controller.input_application_opened(session); | ||
2012 | 126 | }, std::logic_error); | ||
2013 | 127 | } | ||
2014 | 128 | |||
2015 | 129 | TEST_F(AndroidDispatcherControllerFdSetup, input_application_closed_behavior) | ||
2016 | 130 | { | ||
2017 | 131 | using namespace ::testing; | ||
2018 | 132 | |||
2019 | 133 | EXPECT_CALL(config, the_dispatcher()).Times(1) | ||
2020 | 134 | .WillOnce(Return(dispatcher)); | ||
2021 | 135 | mia::DispatcherController controller(mt::fake_shared(config)); | ||
2022 | 136 | |||
2023 | 137 | auto session = std::make_shared<mtd::StubSessionTarget>(); | ||
2024 | 138 | EXPECT_THROW({ | ||
2025 | 139 | // We can't close an application which is not open | ||
2026 | 140 | controller.input_application_closed(session); | ||
2027 | 141 | }, std::logic_error); | ||
2028 | 142 | controller.input_application_opened(session); | ||
2029 | 143 | controller.input_application_closed(session); | ||
2030 | 144 | EXPECT_THROW({ | ||
2031 | 145 | // Nor can we close an application twice | ||
2032 | 146 | controller.input_application_closed(session); | ||
2033 | 147 | }, std::logic_error); | ||
2034 | 148 | } | ||
2035 | 149 | |||
2036 | 150 | TEST_F(AndroidDispatcherControllerFdSetup, input_surface_opened_behavior) | ||
2037 | 151 | { | ||
2038 | 152 | using namespace ::testing; | ||
2039 | 153 | |||
2040 | 154 | auto session = std::make_shared<mtd::StubSessionTarget>(); | ||
2041 | 155 | auto surface = std::make_shared<mtd::StubSurfaceTarget>(test_input_fd); | ||
2042 | 156 | |||
2043 | 157 | EXPECT_CALL(config, the_dispatcher()).Times(1) | ||
2044 | 158 | .WillOnce(Return(dispatcher)); | ||
2045 | 159 | EXPECT_CALL(*dispatcher, registerInputChannel(_, WindowHandleFor(session, surface), false)).Times(1) | ||
2046 | 160 | .WillOnce(Return(droidinput::OK)); | ||
2047 | 161 | |||
2048 | 162 | mia::DispatcherController controller(mt::fake_shared(config)); | ||
2049 | 163 | |||
2050 | 164 | EXPECT_THROW({ | ||
2051 | 165 | // We can't open a surface with an unopened session! | ||
2052 | 166 | controller.input_surface_opened(session, surface); | ||
2053 | 167 | }, std::logic_error); | ||
2054 | 168 | controller.input_application_opened(session); | ||
2055 | 169 | controller.input_surface_opened(session, surface); | ||
2056 | 170 | EXPECT_THROW({ | ||
2057 | 171 | // We can't open a surface twice | ||
2058 | 172 | controller.input_surface_opened(session, surface); | ||
2059 | 173 | }, std::logic_error); | ||
2060 | 174 | } | ||
2061 | 175 | |||
2062 | 176 | TEST_F(AndroidDispatcherControllerFdSetup, input_surface_closed_behavior) | ||
2063 | 177 | { | ||
2064 | 178 | using namespace ::testing; | ||
2065 | 179 | |||
2066 | 180 | auto session = std::make_shared<mtd::StubSessionTarget>(); | ||
2067 | 181 | auto surface = std::make_shared<mtd::StubSurfaceTarget>(test_input_fd); | ||
2068 | 182 | |||
2069 | 183 | EXPECT_CALL(config, the_dispatcher()).Times(1) | ||
2070 | 184 | .WillOnce(Return(dispatcher)); | ||
2071 | 185 | EXPECT_CALL(*dispatcher, registerInputChannel(_, WindowHandleFor(session, surface), false)).Times(1) | ||
2072 | 186 | .WillOnce(Return(droidinput::OK)); | ||
2073 | 187 | EXPECT_CALL(*dispatcher, unregisterInputChannel(_)).Times(1); | ||
2074 | 188 | mia::DispatcherController controller(mt::fake_shared(config)); | ||
2075 | 189 | |||
2076 | 190 | controller.input_application_opened(session); | ||
2077 | 191 | |||
2078 | 192 | EXPECT_THROW({ | ||
2079 | 193 | // We can't close a surface which hasn't been opened | ||
2080 | 194 | controller.input_surface_closed(surface); | ||
2081 | 195 | }, std::logic_error); | ||
2082 | 196 | controller.input_surface_opened(session, surface); | ||
2083 | 197 | controller.input_surface_closed(surface); | ||
2084 | 198 | EXPECT_THROW({ | ||
2085 | 199 | // Nor can we close a surface twice | ||
2086 | 200 | controller.input_surface_closed(surface); | ||
2087 | 201 | }, std::logic_error); | ||
2088 | 202 | } | ||
2089 | 203 | |||
2090 | 204 | TEST_F(AndroidDispatcherControllerFdSetup, on_focus_cleared) | ||
2091 | 205 | { | ||
2092 | 206 | using namespace ::testing; | ||
2093 | 207 | |||
2094 | 208 | EXPECT_CALL(config, the_dispatcher()).Times(1) | ||
2095 | 209 | .WillOnce(Return(dispatcher)); | ||
2096 | 210 | |||
2097 | 211 | EXPECT_CALL(*dispatcher, setFocusedApplication(droidinput::sp<droidinput::InputApplicationHandle>(0))).Times(1); | ||
2098 | 212 | EXPECT_CALL(*dispatcher, setInputWindows(EmptyVector())).Times(1); | ||
2099 | 213 | |||
2100 | 214 | mia::DispatcherController controller(mt::fake_shared(config)); | ||
2101 | 215 | |||
2102 | 216 | controller.focus_cleared(); | ||
2103 | 217 | } | ||
2104 | 218 | |||
2105 | 219 | TEST_F(AndroidDispatcherControllerFdSetup, on_focus_changed) | ||
2106 | 220 | { | ||
2107 | 221 | using namespace ::testing; | ||
2108 | 222 | |||
2109 | 113 | EXPECT_CALL(config, the_dispatcher()).Times(1) | 223 | EXPECT_CALL(config, the_dispatcher()).Times(1) |
2110 | 114 | .WillOnce(Return(dispatcher)); | 224 | .WillOnce(Return(dispatcher)); |
2111 | 115 | 225 | ||
2112 | @@ -119,15 +229,30 @@ | |||
2113 | 119 | { | 229 | { |
2114 | 120 | InSequence seq; | 230 | InSequence seq; |
2115 | 121 | EXPECT_CALL(*dispatcher, setFocusedApplication(ApplicationHandleFor(session))).Times(1); | 231 | EXPECT_CALL(*dispatcher, setFocusedApplication(ApplicationHandleFor(session))).Times(1); |
2116 | 122 | EXPECT_CALL(*dispatcher, registerInputChannel(_, WindowHandleFor(session, surface), false)).Times(1) | ||
2117 | 123 | .WillOnce(Return(droidinput::OK)); | ||
2118 | 124 | EXPECT_CALL(*dispatcher, setInputWindows(VectorContainingWindowHandleFor(session, surface))).Times(1); | 232 | EXPECT_CALL(*dispatcher, setInputWindows(VectorContainingWindowHandleFor(session, surface))).Times(1); |
2119 | 125 | EXPECT_CALL(*dispatcher, unregisterInputChannel(_)).Times(1); | ||
2120 | 126 | EXPECT_CALL(*dispatcher, setInputWindows(EmptyVector())).Times(1); | ||
2121 | 127 | } | 233 | } |
2122 | 128 | 234 | ||
2123 | 129 | mia::DispatcherController controller(mt::fake_shared(config)); | 235 | mia::DispatcherController controller(mt::fake_shared(config)); |
2127 | 130 | 236 | ||
2128 | 131 | controller.set_input_focus_to(session, surface); | 237 | controller.input_application_opened(session); |
2129 | 132 | controller.set_input_focus_to(session, std::shared_ptr<mi::SurfaceTarget>()); | 238 | controller.input_surface_opened(session, surface); |
2130 | 239 | |||
2131 | 240 | controller.focus_changed(surface); | ||
2132 | 241 | } | ||
2133 | 242 | |||
2134 | 243 | TEST_F(AndroidDispatcherControllerFdSetup, on_focus_changed_throw_behavior) | ||
2135 | 244 | { | ||
2136 | 245 | using namespace ::testing; | ||
2137 | 246 | |||
2138 | 247 | EXPECT_CALL(config, the_dispatcher()).Times(1) | ||
2139 | 248 | .WillOnce(Return(dispatcher)); | ||
2140 | 249 | |||
2141 | 250 | auto surface = std::make_shared<mtd::StubSurfaceTarget>(test_input_fd); | ||
2142 | 251 | |||
2143 | 252 | mia::DispatcherController controller(mt::fake_shared(config)); | ||
2144 | 253 | |||
2145 | 254 | EXPECT_THROW({ | ||
2146 | 255 | // We can't focus surfaces which never opened | ||
2147 | 256 | controller.focus_changed(surface); | ||
2148 | 257 | }, std::logic_error); | ||
2149 | 133 | } | 258 | } |
2150 | 134 | 259 | ||
2151 | === modified file 'tests/unit-tests/input/android/test_android_input_window_handle.cpp' | |||
2152 | --- tests/unit-tests/input/android/test_android_input_window_handle.cpp 2013-04-04 11:26:58 +0000 | |||
2153 | +++ tests/unit-tests/input/android/test_android_input_window_handle.cpp 2013-04-22 16:32:37 +0000 | |||
2154 | @@ -52,6 +52,7 @@ | |||
2155 | 52 | struct MockSurfaceTarget : public mi::SurfaceTarget | 52 | struct MockSurfaceTarget : public mi::SurfaceTarget |
2156 | 53 | { | 53 | { |
2157 | 54 | MOCK_CONST_METHOD0(server_input_fd, int()); | 54 | MOCK_CONST_METHOD0(server_input_fd, int()); |
2158 | 55 | MOCK_CONST_METHOD0(top_left, geom::Point()); | ||
2159 | 55 | MOCK_CONST_METHOD0(size, geom::Size()); | 56 | MOCK_CONST_METHOD0(size, geom::Size()); |
2160 | 56 | MOCK_CONST_METHOD0(name, std::string()); | 57 | MOCK_CONST_METHOD0(name, std::string()); |
2161 | 57 | }; | 58 | }; |
2162 | @@ -64,6 +65,7 @@ | |||
2163 | 64 | 65 | ||
2164 | 65 | geom::Size const default_surface_size = geom::Size{geom::Width{256}, | 66 | geom::Size const default_surface_size = geom::Size{geom::Width{256}, |
2165 | 66 | geom::Height{256}}; | 67 | geom::Height{256}}; |
2166 | 68 | geom::Point const default_surface_top_left = geom::Point{geom::X{10}, geom::Y{10}}; | ||
2167 | 67 | std::string const testing_surface_name = "Test"; | 69 | std::string const testing_surface_name = "Test"; |
2168 | 68 | 70 | ||
2169 | 69 | // We need a real open fd, as InputWindowHandle's constructor will fcntl() it, and | 71 | // We need a real open fd, as InputWindowHandle's constructor will fcntl() it, and |
2170 | @@ -81,6 +83,8 @@ | |||
2171 | 81 | // for touch/pointer events we will need a position | 83 | // for touch/pointer events we will need a position |
2172 | 82 | EXPECT_CALL(surface, size()).Times(1) | 84 | EXPECT_CALL(surface, size()).Times(1) |
2173 | 83 | .WillOnce(Return(default_surface_size)); | 85 | .WillOnce(Return(default_surface_size)); |
2174 | 86 | EXPECT_CALL(surface, top_left()).Times(1) | ||
2175 | 87 | .WillOnce(Return(default_surface_top_left)); | ||
2176 | 84 | EXPECT_CALL(surface, name()).Times(1) | 88 | EXPECT_CALL(surface, name()).Times(1) |
2177 | 85 | .WillOnce(Return(testing_surface_name)); | 89 | .WillOnce(Return(testing_surface_name)); |
2178 | 86 | 90 | ||
2179 | @@ -93,8 +97,15 @@ | |||
2180 | 93 | 97 | ||
2181 | 94 | EXPECT_EQ(testing_server_fd, info->inputChannel->getFd()); | 98 | EXPECT_EQ(testing_server_fd, info->inputChannel->getFd()); |
2182 | 95 | 99 | ||
2183 | 100 | EXPECT_EQ(default_surface_top_left.x.as_uint32_t(), (uint32_t)(info->frameLeft)); | ||
2184 | 101 | EXPECT_EQ(default_surface_top_left.y.as_uint32_t(), (uint32_t)(info->frameTop)); | ||
2185 | 96 | EXPECT_EQ(default_surface_size.height.as_uint32_t(), (uint32_t)(info->frameRight - info->frameLeft)); | 102 | EXPECT_EQ(default_surface_size.height.as_uint32_t(), (uint32_t)(info->frameRight - info->frameLeft)); |
2186 | 97 | EXPECT_EQ(default_surface_size.height.as_uint32_t(), (uint32_t)(info->frameBottom - info->frameTop)); | 103 | EXPECT_EQ(default_surface_size.height.as_uint32_t(), (uint32_t)(info->frameBottom - info->frameTop)); |
2187 | 98 | 104 | ||
2188 | 105 | EXPECT_EQ(info->frameLeft, info->touchableRegionLeft); | ||
2189 | 106 | EXPECT_EQ(info->frameTop, info->touchableRegionTop); | ||
2190 | 107 | EXPECT_EQ(info->frameRight, info->touchableRegionRight); | ||
2191 | 108 | EXPECT_EQ(info->frameBottom, info->touchableRegionBottom); | ||
2192 | 109 | |||
2193 | 99 | free(filename); | 110 | free(filename); |
2194 | 100 | } | 111 | } |
2195 | 101 | 112 | ||
2196 | === modified file 'tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp' | |||
2197 | --- tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp 2013-03-22 16:41:59 +0000 | |||
2198 | +++ tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp 2013-04-22 16:32:37 +0000 | |||
2199 | @@ -32,12 +32,12 @@ | |||
2200 | 32 | namespace mt = mir::test; | 32 | namespace mt = mir::test; |
2201 | 33 | namespace mtd = mir::test::doubles; | 33 | namespace mtd = mir::test::doubles; |
2202 | 34 | 34 | ||
2204 | 35 | TEST(EventFilterDispatcherPolicy, offers_events_to_filter) | 35 | TEST(EventFilterDispatcherPolicy, offers_key_events_to_filter) |
2205 | 36 | { | 36 | { |
2206 | 37 | using namespace ::testing; | 37 | using namespace ::testing; |
2207 | 38 | droidinput::KeyEvent ev; | 38 | droidinput::KeyEvent ev; |
2208 | 39 | mtd::MockEventFilter filter; | 39 | mtd::MockEventFilter filter; |
2210 | 40 | mia::EventFilterDispatcherPolicy policy(mt::fake_shared(filter)); | 40 | mia::EventFilterDispatcherPolicy policy(mt::fake_shared(filter), true); |
2211 | 41 | uint32_t policy_flags; | 41 | uint32_t policy_flags; |
2212 | 42 | 42 | ||
2213 | 43 | EXPECT_CALL(filter, handles(_)).Times(1).WillOnce(Return(false)); | 43 | EXPECT_CALL(filter, handles(_)).Times(1).WillOnce(Return(false)); |
2214 | @@ -53,3 +53,16 @@ | |||
2215 | 53 | EXPECT_TRUE(policy.filterInputEvent(&ev, 0)); | 53 | EXPECT_TRUE(policy.filterInputEvent(&ev, 0)); |
2216 | 54 | } | 54 | } |
2217 | 55 | 55 | ||
2218 | 56 | TEST(EventFilterDispatcherPolicy, motion_events_are_allowed_to_pass_to_clients) | ||
2219 | 57 | { | ||
2220 | 58 | using namespace ::testing; | ||
2221 | 59 | |||
2222 | 60 | mtd::MockEventFilter filter; | ||
2223 | 61 | mia::EventFilterDispatcherPolicy policy(mt::fake_shared(filter), true); | ||
2224 | 62 | |||
2225 | 63 | uint32_t policy_flags; | ||
2226 | 64 | policy.interceptMotionBeforeQueueing(0, policy_flags); | ||
2227 | 65 | |||
2228 | 66 | // All motion events are allowed. Of course they could later be removed by the input filter. | ||
2229 | 67 | EXPECT_TRUE(policy_flags & droidinput::POLICY_FLAG_PASS_TO_USER); | ||
2230 | 68 | } | ||
2231 | 56 | 69 | ||
2232 | === modified file 'tests/unit-tests/shell/test_application_session.cpp' | |||
2233 | --- tests/unit-tests/shell/test_application_session.cpp 2013-04-17 18:18:31 +0000 | |||
2234 | +++ tests/unit-tests/shell/test_application_session.cpp 2013-04-22 16:32:37 +0000 | |||
2235 | @@ -22,6 +22,7 @@ | |||
2236 | 22 | #include "mir_test/fake_shared.h" | 22 | #include "mir_test/fake_shared.h" |
2237 | 23 | #include "mir_test_doubles/mock_surface_factory.h" | 23 | #include "mir_test_doubles/mock_surface_factory.h" |
2238 | 24 | #include "mir_test_doubles/mock_surface.h" | 24 | #include "mir_test_doubles/mock_surface.h" |
2239 | 25 | #include "mir_test_doubles/stub_input_target_listener.h" | ||
2240 | 25 | #include "mir_test_doubles/stub_surface_builder.h" | 26 | #include "mir_test_doubles/stub_surface_builder.h" |
2241 | 26 | #include "mir_test_doubles/stub_surface.h" | 27 | #include "mir_test_doubles/stub_surface.h" |
2242 | 27 | 28 | ||
2243 | @@ -51,7 +52,8 @@ | |||
2244 | 51 | EXPECT_CALL(surface_factory, create_surface(_)); | 52 | EXPECT_CALL(surface_factory, create_surface(_)); |
2245 | 52 | EXPECT_CALL(*mock_surface, destroy()); | 53 | EXPECT_CALL(*mock_surface, destroy()); |
2246 | 53 | 54 | ||
2248 | 54 | msh::ApplicationSession session(mt::fake_shared(surface_factory), "Foo"); | 55 | mtd::StubInputTargetListener input_listener; |
2249 | 56 | msh::ApplicationSession session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo"); | ||
2250 | 55 | 57 | ||
2251 | 56 | mf::SurfaceCreationParameters params; | 58 | mf::SurfaceCreationParameters params; |
2252 | 57 | auto surf = session.create_surface(params); | 59 | auto surf = session.create_surface(params); |
2253 | @@ -75,7 +77,8 @@ | |||
2254 | 75 | .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder)))); | 77 | .WillOnce(Return(std::make_shared<NiceMock<mtd::MockSurface>>(mt::fake_shared(surface_builder)))); |
2255 | 76 | } | 78 | } |
2256 | 77 | 79 | ||
2258 | 78 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo"); | 80 | mtd::StubInputTargetListener input_listener; |
2259 | 81 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo"); | ||
2260 | 79 | 82 | ||
2261 | 80 | mf::SurfaceCreationParameters params; | 83 | mf::SurfaceCreationParameters params; |
2262 | 81 | auto id1 = app_session.create_surface(params); | 84 | auto id1 = app_session.create_surface(params); |
2263 | @@ -105,7 +108,8 @@ | |||
2264 | 105 | mtd::MockSurfaceFactory surface_factory; | 108 | mtd::MockSurfaceFactory surface_factory; |
2265 | 106 | ON_CALL(surface_factory, create_surface(_)).WillByDefault(Return(mock_surface)); | 109 | ON_CALL(surface_factory, create_surface(_)).WillByDefault(Return(mock_surface)); |
2266 | 107 | 110 | ||
2268 | 108 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo"); | 111 | mtd::StubInputTargetListener input_listener; |
2269 | 112 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo"); | ||
2270 | 109 | 113 | ||
2271 | 110 | EXPECT_CALL(surface_factory, create_surface(_)); | 114 | EXPECT_CALL(surface_factory, create_surface(_)); |
2272 | 111 | 115 | ||
2273 | @@ -130,7 +134,8 @@ | |||
2274 | 130 | using namespace ::testing; | 134 | using namespace ::testing; |
2275 | 131 | 135 | ||
2276 | 132 | mtd::MockSurfaceFactory surface_factory; | 136 | mtd::MockSurfaceFactory surface_factory; |
2278 | 133 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo"); | 137 | mtd::StubInputTargetListener input_listener; |
2279 | 138 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo"); | ||
2280 | 134 | mf::SurfaceId invalid_surface_id(1); | 139 | mf::SurfaceId invalid_surface_id(1); |
2281 | 135 | 140 | ||
2282 | 136 | EXPECT_THROW({ | 141 | EXPECT_THROW({ |
2283 | @@ -143,7 +148,8 @@ | |||
2284 | 143 | using namespace ::testing; | 148 | using namespace ::testing; |
2285 | 144 | 149 | ||
2286 | 145 | mtd::MockSurfaceFactory surface_factory; | 150 | mtd::MockSurfaceFactory surface_factory; |
2288 | 146 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo"); | 151 | mtd::StubInputTargetListener input_listener; |
2289 | 152 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), mt::fake_shared(input_listener), "Foo"); | ||
2290 | 147 | mf::SurfaceId invalid_surface_id(1); | 153 | mf::SurfaceId invalid_surface_id(1); |
2291 | 148 | 154 | ||
2292 | 149 | EXPECT_THROW({ | 155 | EXPECT_THROW({ |
2293 | 150 | 156 | ||
2294 | === modified file 'tests/unit-tests/shell/test_registration_order_focus_sequence.cpp' | |||
2295 | --- tests/unit-tests/shell/test_registration_order_focus_sequence.cpp 2013-04-18 00:00:55 +0000 | |||
2296 | +++ tests/unit-tests/shell/test_registration_order_focus_sequence.cpp 2013-04-22 16:32:37 +0000 | |||
2297 | @@ -22,8 +22,11 @@ | |||
2298 | 22 | #include "mir/shell/registration_order_focus_sequence.h" | 22 | #include "mir/shell/registration_order_focus_sequence.h" |
2299 | 23 | #include "mir/frontend/surface_creation_parameters.h" | 23 | #include "mir/frontend/surface_creation_parameters.h" |
2300 | 24 | #include "mir/surfaces/surface.h" | 24 | #include "mir/surfaces/surface.h" |
2301 | 25 | |||
2302 | 25 | #include "mir_test_doubles/mock_buffer_bundle.h" | 26 | #include "mir_test_doubles/mock_buffer_bundle.h" |
2303 | 26 | #include "mir_test_doubles/mock_surface_factory.h" | 27 | #include "mir_test_doubles/mock_surface_factory.h" |
2304 | 28 | #include "mir_test_doubles/stub_input_target_listener.h" | ||
2305 | 29 | #include "mir_test/fake_shared.h" | ||
2306 | 27 | 30 | ||
2307 | 28 | #include <gmock/gmock.h> | 31 | #include <gmock/gmock.h> |
2308 | 29 | #include <gtest/gtest.h> | 32 | #include <gtest/gtest.h> |
2309 | @@ -32,7 +35,8 @@ | |||
2310 | 32 | namespace mc = mir::compositor; | 35 | namespace mc = mir::compositor; |
2311 | 33 | namespace msh = mir::shell; | 36 | namespace msh = mir::shell; |
2312 | 34 | namespace ms = mir::surfaces; | 37 | namespace ms = mir::surfaces; |
2314 | 35 | namespace mtd = mir::test::doubles; | 38 | namespace mt = mir::test; |
2315 | 39 | namespace mtd = mt::doubles; | ||
2316 | 36 | 40 | ||
2317 | 37 | namespace | 41 | namespace |
2318 | 38 | { | 42 | { |
2319 | @@ -45,6 +49,7 @@ | |||
2320 | 45 | } | 49 | } |
2321 | 46 | std::shared_ptr<mtd::MockSurfaceFactory> factory; | 50 | std::shared_ptr<mtd::MockSurfaceFactory> factory; |
2322 | 47 | std::shared_ptr<msh::DefaultSessionContainer> container; | 51 | std::shared_ptr<msh::DefaultSessionContainer> container; |
2323 | 52 | mtd::StubInputTargetListener input_listener; | ||
2324 | 48 | 53 | ||
2325 | 49 | static std::string const testing_app_name1; | 54 | static std::string const testing_app_name1; |
2326 | 50 | static std::string const testing_app_name2; | 55 | static std::string const testing_app_name2; |
2327 | @@ -60,9 +65,9 @@ | |||
2328 | 60 | { | 65 | { |
2329 | 61 | using namespace ::testing; | 66 | using namespace ::testing; |
2330 | 62 | 67 | ||
2334 | 63 | auto app1 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name1); | 68 | auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1); |
2335 | 64 | auto app2 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name2); | 69 | auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2); |
2336 | 65 | auto app3 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name3); | 70 | auto app3 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name3); |
2337 | 66 | 71 | ||
2338 | 67 | container->insert_session(app1); | 72 | container->insert_session(app1); |
2339 | 68 | container->insert_session(app2); | 73 | container->insert_session(app2); |
2340 | @@ -78,9 +83,9 @@ | |||
2341 | 78 | { | 83 | { |
2342 | 79 | using namespace ::testing; | 84 | using namespace ::testing; |
2343 | 80 | 85 | ||
2347 | 81 | auto app1 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name1); | 86 | auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1); |
2348 | 82 | auto app2 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name2); | 87 | auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2); |
2349 | 83 | auto app3 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name3); | 88 | auto app3 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name3); |
2350 | 84 | container->insert_session(app1); | 89 | container->insert_session(app1); |
2351 | 85 | container->insert_session(app2); | 90 | container->insert_session(app2); |
2352 | 86 | container->insert_session(app3); | 91 | container->insert_session(app3); |
2353 | @@ -95,7 +100,7 @@ | |||
2354 | 95 | { | 100 | { |
2355 | 96 | using namespace ::testing; | 101 | using namespace ::testing; |
2356 | 97 | 102 | ||
2358 | 98 | auto app1 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name1); | 103 | auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1); |
2359 | 99 | container->insert_session(app1); | 104 | container->insert_session(app1); |
2360 | 100 | 105 | ||
2361 | 101 | msh::RegistrationOrderFocusSequence focus_sequence(container); | 106 | msh::RegistrationOrderFocusSequence focus_sequence(container); |
2362 | @@ -107,8 +112,8 @@ | |||
2363 | 107 | { | 112 | { |
2364 | 108 | using namespace ::testing; | 113 | using namespace ::testing; |
2365 | 109 | 114 | ||
2368 | 110 | auto app1 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name1); | 115 | auto app1 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1); |
2369 | 111 | auto app2 = std::make_shared<msh::ApplicationSession>(factory, testing_app_name2); | 116 | auto app2 = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name2); |
2370 | 112 | auto null_session = std::shared_ptr<msh::ApplicationSession>(); | 117 | auto null_session = std::shared_ptr<msh::ApplicationSession>(); |
2371 | 113 | 118 | ||
2372 | 114 | msh::RegistrationOrderFocusSequence focus_sequence(container); | 119 | msh::RegistrationOrderFocusSequence focus_sequence(container); |
2373 | @@ -124,7 +129,7 @@ | |||
2374 | 124 | { | 129 | { |
2375 | 125 | using namespace ::testing; | 130 | using namespace ::testing; |
2376 | 126 | 131 | ||
2378 | 127 | auto invalid_session = std::make_shared<msh::ApplicationSession>(factory, testing_app_name1); | 132 | auto invalid_session = std::make_shared<msh::ApplicationSession>(factory, mt::fake_shared(input_listener), testing_app_name1); |
2379 | 128 | auto null_session = std::shared_ptr<msh::ApplicationSession>(); | 133 | auto null_session = std::shared_ptr<msh::ApplicationSession>(); |
2380 | 129 | 134 | ||
2381 | 130 | msh::RegistrationOrderFocusSequence focus_sequence(container); | 135 | msh::RegistrationOrderFocusSequence focus_sequence(container); |
2382 | 131 | 136 | ||
2383 | === modified file 'tests/unit-tests/shell/test_session_manager.cpp' | |||
2384 | --- tests/unit-tests/shell/test_session_manager.cpp 2013-04-18 22:29:24 +0000 | |||
2385 | +++ tests/unit-tests/shell/test_session_manager.cpp 2013-04-22 16:32:37 +0000 | |||
2386 | @@ -21,15 +21,19 @@ | |||
2387 | 21 | #include "mir/shell/session_manager.h" | 21 | #include "mir/shell/session_manager.h" |
2388 | 22 | #include "mir/shell/default_session_container.h" | 22 | #include "mir/shell/default_session_container.h" |
2389 | 23 | #include "mir/shell/session.h" | 23 | #include "mir/shell/session.h" |
2390 | 24 | #include "mir/shell/input_target_listener.h" | ||
2391 | 24 | #include "mir/frontend/surface_creation_parameters.h" | 25 | #include "mir/frontend/surface_creation_parameters.h" |
2392 | 25 | #include "mir/surfaces/surface.h" | 26 | #include "mir/surfaces/surface.h" |
2393 | 26 | #include "mir/input/input_channel.h" | 27 | #include "mir/input/input_channel.h" |
2394 | 28 | |||
2395 | 29 | #include "mir_test/fake_shared.h" | ||
2396 | 27 | #include "mir_test_doubles/mock_buffer_bundle.h" | 30 | #include "mir_test_doubles/mock_buffer_bundle.h" |
2397 | 28 | #include "mir_test/fake_shared.h" | ||
2398 | 29 | #include "mir_test_doubles/mock_surface_factory.h" | 31 | #include "mir_test_doubles/mock_surface_factory.h" |
2399 | 30 | #include "mir_test_doubles/mock_focus_setter.h" | 32 | #include "mir_test_doubles/mock_focus_setter.h" |
2400 | 31 | #include "mir_test_doubles/null_buffer_bundle.h" | 33 | #include "mir_test_doubles/null_buffer_bundle.h" |
2401 | 32 | #include "mir_test_doubles/stub_surface_builder.h" | 34 | #include "mir_test_doubles/stub_surface_builder.h" |
2402 | 35 | #include "mir_test_doubles/stub_input_target_listener.h" | ||
2403 | 36 | #include "mir_test_doubles/mock_input_target_listener.h" | ||
2404 | 33 | 37 | ||
2405 | 34 | #include "mir/shell/surface.h" | 38 | #include "mir/shell/surface.h" |
2406 | 35 | 39 | ||
2407 | @@ -56,7 +60,7 @@ | |||
2408 | 56 | ~MockSessionContainer() noexcept {} | 60 | ~MockSessionContainer() noexcept {} |
2409 | 57 | }; | 61 | }; |
2410 | 58 | 62 | ||
2412 | 59 | struct MockFocusSequence: public msh::FocusSequence | 63 | struct MockFocusSequence : public msh::FocusSequence |
2413 | 60 | { | 64 | { |
2414 | 61 | MOCK_CONST_METHOD1(successor_of, std::shared_ptr<msh::Session>(std::shared_ptr<msh::Session> const&)); | 65 | MOCK_CONST_METHOD1(successor_of, std::shared_ptr<msh::Session>(std::shared_ptr<msh::Session> const&)); |
2415 | 62 | MOCK_CONST_METHOD1(predecessor_of, std::shared_ptr<msh::Session>(std::shared_ptr<msh::Session> const&)); | 66 | MOCK_CONST_METHOD1(predecessor_of, std::shared_ptr<msh::Session>(std::shared_ptr<msh::Session> const&)); |
2416 | @@ -68,16 +72,18 @@ | |||
2417 | 68 | SessionManagerSetup() | 72 | SessionManagerSetup() |
2418 | 69 | : session_manager(mt::fake_shared(surface_factory), | 73 | : session_manager(mt::fake_shared(surface_factory), |
2419 | 70 | mt::fake_shared(container), | 74 | mt::fake_shared(container), |
2422 | 71 | mt::fake_shared(sequence), | 75 | mt::fake_shared(focus_sequence), |
2423 | 72 | mt::fake_shared(focus_setter)) | 76 | mt::fake_shared(focus_setter), |
2424 | 77 | mt::fake_shared(input_target_listener)) | ||
2425 | 73 | { | 78 | { |
2426 | 74 | } | 79 | } |
2427 | 75 | 80 | ||
2428 | 76 | mtd::StubSurfaceBuilder surface_builder; | 81 | mtd::StubSurfaceBuilder surface_builder; |
2429 | 77 | mtd::MockSurfaceFactory surface_factory; | 82 | mtd::MockSurfaceFactory surface_factory; |
2430 | 78 | testing::NiceMock<MockSessionContainer> container; // Inelegant but some tests need a stub | 83 | testing::NiceMock<MockSessionContainer> container; // Inelegant but some tests need a stub |
2432 | 79 | MockFocusSequence sequence; | 84 | MockFocusSequence focus_sequence; |
2433 | 80 | testing::NiceMock<mtd::MockFocusSetter> focus_setter; // Inelegant but some tests need a stub | 85 | testing::NiceMock<mtd::MockFocusSetter> focus_setter; // Inelegant but some tests need a stub |
2434 | 86 | mtd::StubInputTargetListener input_target_listener; | ||
2435 | 81 | 87 | ||
2436 | 82 | msh::SessionManager session_manager; | 88 | msh::SessionManager session_manager; |
2437 | 83 | }; | 89 | }; |
2438 | @@ -93,7 +99,7 @@ | |||
2439 | 93 | EXPECT_CALL(focus_setter, set_focus_to(_)); | 99 | EXPECT_CALL(focus_setter, set_focus_to(_)); |
2440 | 94 | EXPECT_CALL(focus_setter, set_focus_to(std::shared_ptr<msh::Session>())).Times(1); | 100 | EXPECT_CALL(focus_setter, set_focus_to(std::shared_ptr<msh::Session>())).Times(1); |
2441 | 95 | 101 | ||
2443 | 96 | EXPECT_CALL(sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); | 102 | EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); |
2444 | 97 | 103 | ||
2445 | 98 | auto session = session_manager.open_session("Visual Basic Studio"); | 104 | auto session = session_manager.open_session("Visual Basic Studio"); |
2446 | 99 | session_manager.close_session(session); | 105 | session_manager.close_session(session); |
2447 | @@ -118,7 +124,7 @@ | |||
2448 | 118 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); | 124 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); |
2449 | 119 | EXPECT_CALL(focus_setter, set_focus_to(std::shared_ptr<msh::Session>())).Times(1); | 125 | EXPECT_CALL(focus_setter, set_focus_to(std::shared_ptr<msh::Session>())).Times(1); |
2450 | 120 | 126 | ||
2452 | 121 | EXPECT_CALL(sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); | 127 | EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); |
2453 | 122 | 128 | ||
2454 | 123 | auto session = session_manager.open_session("Visual Basic Studio"); | 129 | auto session = session_manager.open_session("Visual Basic Studio"); |
2455 | 124 | session->create_surface(mf::a_surface().of_size(geom::Size{geom::Width{1024}, geom::Height{768}})); | 130 | session->create_surface(mf::a_surface().of_size(geom::Size{geom::Width{1024}, geom::Height{768}})); |
2456 | @@ -164,7 +170,7 @@ | |||
2457 | 164 | session_manager.tag_session_with_lightdm_id(session1, 1); | 170 | session_manager.tag_session_with_lightdm_id(session1, 1); |
2458 | 165 | session_manager.focus_session_with_lightdm_id(1); | 171 | session_manager.focus_session_with_lightdm_id(1); |
2459 | 166 | 172 | ||
2461 | 167 | EXPECT_CALL(sequence, default_focus()).WillOnce(Return(shell_session2)); | 173 | EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return(shell_session2)); |
2462 | 168 | EXPECT_CALL(focus_setter, set_focus_to(Eq(shell_session2))); | 174 | EXPECT_CALL(focus_setter, set_focus_to(Eq(shell_session2))); |
2463 | 169 | 175 | ||
2464 | 170 | session_manager.close_session(session1); | 176 | session_manager.close_session(session1); |
2465 | @@ -193,3 +199,61 @@ | |||
2466 | 193 | session_manager.create_surface_for(session1, mf::a_surface()); | 199 | session_manager.create_surface_for(session1, mf::a_surface()); |
2467 | 194 | } | 200 | } |
2468 | 195 | 201 | ||
2469 | 202 | namespace | ||
2470 | 203 | { | ||
2471 | 204 | |||
2472 | 205 | struct SessionManagerInputTargetListenerSetup : public testing::Test | ||
2473 | 206 | { | ||
2474 | 207 | SessionManagerInputTargetListenerSetup() | ||
2475 | 208 | : session_manager(mt::fake_shared(surface_factory), | ||
2476 | 209 | mt::fake_shared(container), | ||
2477 | 210 | mt::fake_shared(focus_sequence), | ||
2478 | 211 | mt::fake_shared(focus_setter), | ||
2479 | 212 | mt::fake_shared(input_target_listener)) | ||
2480 | 213 | { | ||
2481 | 214 | } | ||
2482 | 215 | |||
2483 | 216 | mtd::StubSurfaceBuilder surface_builder; | ||
2484 | 217 | mtd::MockSurfaceFactory surface_factory; | ||
2485 | 218 | testing::NiceMock<MockSessionContainer> container; // Inelegant but some tests need a stub | ||
2486 | 219 | testing::NiceMock<MockFocusSequence> focus_sequence; | ||
2487 | 220 | testing::NiceMock<mtd::MockFocusSetter> focus_setter; // Inelegant but some tests need a stub | ||
2488 | 221 | mtd::MockInputTargetListener input_target_listener; | ||
2489 | 222 | |||
2490 | 223 | msh::SessionManager session_manager; | ||
2491 | 224 | }; | ||
2492 | 225 | |||
2493 | 226 | } | ||
2494 | 227 | |||
2495 | 228 | TEST_F(SessionManagerInputTargetListenerSetup, listener_is_notified_of_session_and_surfacelifecycle) | ||
2496 | 229 | { | ||
2497 | 230 | using namespace ::testing; | ||
2498 | 231 | |||
2499 | 232 | std::shared_ptr<mi::InputChannel> null_input_channel; | ||
2500 | 233 | ON_CALL(surface_factory, create_surface(_)).WillByDefault( | ||
2501 | 234 | Return(std::make_shared<msh::Surface>( | ||
2502 | 235 | mt::fake_shared(surface_builder), | ||
2503 | 236 | mf::a_surface(), | ||
2504 | 237 | null_input_channel))); | ||
2505 | 238 | |||
2506 | 239 | EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); | ||
2507 | 240 | { | ||
2508 | 241 | InSequence seq; | ||
2509 | 242 | |||
2510 | 243 | EXPECT_CALL(input_target_listener, input_application_opened(_)) | ||
2511 | 244 | .Times(1); | ||
2512 | 245 | EXPECT_CALL(input_target_listener, input_surface_opened(_, _)).Times(1); | ||
2513 | 246 | EXPECT_CALL(input_target_listener, focus_changed(_)).Times(1); | ||
2514 | 247 | EXPECT_CALL(input_target_listener, input_surface_closed(_)).Times(1); | ||
2515 | 248 | EXPECT_CALL(input_target_listener, input_application_closed(_)) | ||
2516 | 249 | .Times(1); | ||
2517 | 250 | EXPECT_CALL(input_target_listener, focus_cleared()).Times(1); | ||
2518 | 251 | } | ||
2519 | 252 | |||
2520 | 253 | { | ||
2521 | 254 | auto session = session_manager.open_session("test"); | ||
2522 | 255 | auto surf = session_manager.create_surface_for(session, mf::a_surface()); | ||
2523 | 256 | session->destroy_surface(surf); | ||
2524 | 257 | session_manager.close_session(session); | ||
2525 | 258 | } | ||
2526 | 259 | } | ||
2527 | 196 | 260 | ||
2528 | === modified file 'tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp' | |||
2529 | --- tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp 2013-04-19 15:33:04 +0000 | |||
2530 | +++ tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp 2013-04-22 16:32:37 +0000 | |||
2531 | @@ -27,7 +27,6 @@ | |||
2532 | 27 | #include "mir_test_doubles/mock_buffer_bundle.h" | 27 | #include "mir_test_doubles/mock_buffer_bundle.h" |
2533 | 28 | #include "mir_test/fake_shared.h" | 28 | #include "mir_test/fake_shared.h" |
2534 | 29 | #include "mir_test_doubles/mock_surface_factory.h" | 29 | #include "mir_test_doubles/mock_surface_factory.h" |
2535 | 30 | #include "mir_test_doubles/mock_input_focus_selector.h" | ||
2536 | 31 | #include "mir_test_doubles/stub_surface.h" | 30 | #include "mir_test_doubles/stub_surface.h" |
2537 | 32 | #include "mir_test_doubles/mock_surface.h" | 31 | #include "mir_test_doubles/mock_surface.h" |
2538 | 33 | #include "mir_test_doubles/stub_surface_builder.h" | 32 | #include "mir_test_doubles/stub_surface_builder.h" |
2539 | @@ -64,8 +63,6 @@ | |||
2540 | 64 | { | 63 | { |
2541 | 65 | using namespace ::testing; | 64 | using namespace ::testing; |
2542 | 66 | 65 | ||
2543 | 67 | NiceMock<mtd::MockInputFocusSelector> input_focus_selector; | ||
2544 | 68 | |||
2545 | 69 | NiceMock<MockShellSession> app1, app2, app3; | 66 | NiceMock<MockShellSession> app1, app2, app3; |
2546 | 70 | msh::DefaultSessionContainer model; | 67 | msh::DefaultSessionContainer model; |
2547 | 71 | 68 | ||
2548 | @@ -73,7 +70,7 @@ | |||
2549 | 73 | ON_CALL(app2, default_surface()).WillByDefault(Return(std::shared_ptr<msh::Surface>())); | 70 | ON_CALL(app2, default_surface()).WillByDefault(Return(std::shared_ptr<msh::Surface>())); |
2550 | 74 | ON_CALL(app3, default_surface()).WillByDefault(Return(std::shared_ptr<msh::Surface>())); | 71 | ON_CALL(app3, default_surface()).WillByDefault(Return(std::shared_ptr<msh::Surface>())); |
2551 | 75 | 72 | ||
2553 | 76 | msh::SingleVisibilityFocusMechanism focus_mechanism(mt::fake_shared(model), mt::fake_shared(input_focus_selector)); | 73 | msh::SingleVisibilityFocusMechanism focus_mechanism(mt::fake_shared(model)); |
2554 | 77 | 74 | ||
2555 | 78 | EXPECT_CALL(app1, show()).Times(1); | 75 | EXPECT_CALL(app1, show()).Times(1); |
2556 | 79 | EXPECT_CALL(app2, hide()).Times(1); | 76 | EXPECT_CALL(app2, hide()).Times(1); |
2557 | @@ -89,23 +86,3 @@ | |||
2558 | 89 | 86 | ||
2559 | 90 | focus_mechanism.set_focus_to(mt::fake_shared(app1)); | 87 | focus_mechanism.set_focus_to(mt::fake_shared(app1)); |
2560 | 91 | } | 88 | } |
2561 | 92 | |||
2562 | 93 | TEST(SingleVisibilityFocusMechanism, mechanism_sets_input_focus_from_default_surface) | ||
2563 | 94 | { | ||
2564 | 95 | using namespace ::testing; | ||
2565 | 96 | |||
2566 | 97 | mtd::MockInputFocusSelector input_focus_selector; | ||
2567 | 98 | msh::DefaultSessionContainer model; | ||
2568 | 99 | auto session = std::make_shared<NiceMock<MockShellSession>>(); | ||
2569 | 100 | auto surface = std::make_shared<mtd::MockSurface>(std::make_shared<mtd::StubSurfaceBuilder>()); | ||
2570 | 101 | |||
2571 | 102 | msh::SingleVisibilityFocusMechanism focus_mechanism(mt::fake_shared(model), mt::fake_shared(input_focus_selector)); | ||
2572 | 103 | |||
2573 | 104 | EXPECT_CALL(*session, default_surface()).Times(1).WillOnce(Return(surface)); | ||
2574 | 105 | |||
2575 | 106 | EXPECT_CALL(input_focus_selector, set_input_focus_to(Eq(session), Eq(surface))).Times(1); | ||
2576 | 107 | |||
2577 | 108 | model.insert_session(session); | ||
2578 | 109 | focus_mechanism.set_focus_to(session); | ||
2579 | 110 | } | ||
2580 | 111 | |||
2581 | 112 | 89 | ||
2582 | === modified file 'tests/unit-tests/shell/test_surface.cpp' | |||
2583 | --- tests/unit-tests/shell/test_surface.cpp 2013-04-16 17:42:26 +0000 | |||
2584 | +++ tests/unit-tests/shell/test_surface.cpp 2013-04-22 16:32:37 +0000 | |||
2585 | @@ -220,6 +220,24 @@ | |||
2586 | 220 | }, std::runtime_error); | 220 | }, std::runtime_error); |
2587 | 221 | } | 221 | } |
2588 | 222 | 222 | ||
2589 | 223 | TEST_F(ShellSurface, top_left_throw_behavior) | ||
2590 | 224 | { | ||
2591 | 225 | msh::Surface test( | ||
2592 | 226 | mt::fake_shared(surface_builder), | ||
2593 | 227 | mf::a_surface(), | ||
2594 | 228 | null_input_channel); | ||
2595 | 229 | |||
2596 | 230 | EXPECT_NO_THROW({ | ||
2597 | 231 | test.top_left(); | ||
2598 | 232 | }); | ||
2599 | 233 | |||
2600 | 234 | surface_builder.reset_surface(); | ||
2601 | 235 | |||
2602 | 236 | EXPECT_THROW({ | ||
2603 | 237 | test.top_left(); | ||
2604 | 238 | }, std::runtime_error); | ||
2605 | 239 | } | ||
2606 | 240 | |||
2607 | 223 | TEST_F(ShellSurface, name_throw_behavior) | 241 | TEST_F(ShellSurface, name_throw_behavior) |
2608 | 224 | { | 242 | { |
2609 | 225 | msh::Surface test( | 243 | msh::Surface test( |
2610 | 226 | 244 | ||
2611 | === modified file 'tests/unit-tests/shell/test_the_session_container_implementation.cpp' | |||
2612 | --- tests/unit-tests/shell/test_the_session_container_implementation.cpp 2013-04-18 00:00:55 +0000 | |||
2613 | +++ tests/unit-tests/shell/test_the_session_container_implementation.cpp 2013-04-22 16:32:37 +0000 | |||
2614 | @@ -22,6 +22,7 @@ | |||
2615 | 22 | #include "mir/frontend/surface_creation_parameters.h" | 22 | #include "mir/frontend/surface_creation_parameters.h" |
2616 | 23 | #include "mir/surfaces/surface.h" | 23 | #include "mir/surfaces/surface.h" |
2617 | 24 | #include "mir_test_doubles/mock_buffer_bundle.h" | 24 | #include "mir_test_doubles/mock_buffer_bundle.h" |
2618 | 25 | #include "mir_test_doubles/stub_input_target_listener.h" | ||
2619 | 25 | #include "mir_test_doubles/mock_surface_factory.h" | 26 | #include "mir_test_doubles/mock_surface_factory.h" |
2620 | 26 | 27 | ||
2621 | 27 | #include <gmock/gmock.h> | 28 | #include <gmock/gmock.h> |
2622 | @@ -38,8 +39,10 @@ | |||
2623 | 38 | auto factory = std::make_shared<mtd::MockSurfaceFactory>(); | 39 | auto factory = std::make_shared<mtd::MockSurfaceFactory>(); |
2624 | 39 | msh::DefaultSessionContainer container; | 40 | msh::DefaultSessionContainer container; |
2625 | 40 | 41 | ||
2628 | 41 | container.insert_session(std::make_shared<msh::ApplicationSession>(factory, "Visual Studio 7")); | 42 | container.insert_session(std::make_shared<msh::ApplicationSession>(factory, std::make_shared<mtd::StubInputTargetListener>(), |
2629 | 42 | container.insert_session(std::make_shared<msh::ApplicationSession>(factory, "Visual Studio 8")); | 43 | "Visual Studio 7")); |
2630 | 44 | container.insert_session(std::make_shared<msh::ApplicationSession>(factory, std::make_shared<mtd::StubInputTargetListener>(), | ||
2631 | 45 | "Visual Studio 8")); | ||
2632 | 43 | 46 | ||
2633 | 44 | struct local | 47 | struct local |
2634 | 45 | { | 48 | { |
2635 | @@ -64,8 +67,8 @@ | |||
2636 | 64 | auto factory = std::make_shared<mtd::MockSurfaceFactory>(); | 67 | auto factory = std::make_shared<mtd::MockSurfaceFactory>(); |
2637 | 65 | msh::DefaultSessionContainer container; | 68 | msh::DefaultSessionContainer container; |
2638 | 66 | 69 | ||
2641 | 67 | auto session = std::make_shared<msh::ApplicationSession>(factory, | 70 | auto session = std::make_shared<msh::ApplicationSession>(factory, std::make_shared<mtd::StubInputTargetListener>(), |
2642 | 68 | "Visual Studio 7"); | 71 | "Visual Studio 7"); |
2643 | 69 | EXPECT_THROW({ | 72 | EXPECT_THROW({ |
2644 | 70 | container.remove_session(session); | 73 | container.remove_session(session); |
2645 | 71 | }, std::logic_error); | 74 | }, std::logic_error); |