Merge lp:~robertcarr/mir/refactor-input-acceptance-take-1 into lp:mir
- refactor-input-acceptance-take-1
- Merge into development-branch
Proposed by
Robert Carr
Status: | Superseded |
---|---|
Proposed branch: | lp:~robertcarr/mir/refactor-input-acceptance-take-1 |
Merge into: | lp:mir |
Diff against target: |
1600 lines (+720/-471) 17 files modified
doc/component_reports.md (+1/-0) include/shared/mir/input/input_platform.h (+3/-1) include/shared/mir/input/input_receiver_report.h (+48/-0) include/shared/mir/input/null_input_receiver_report.h (+46/-0) include/test/mir_test_framework/input_testing_server_configuration.h (+2/-1) src/client/CMakeLists.txt (+1/-0) src/client/default_connection_configuration.cpp (+20/-2) src/client/default_connection_configuration.h (+9/-0) src/client/logging/input_receiver_report.cpp (+125/-0) src/client/logging/input_receiver_report.h (+54/-0) src/shared/input/android/android_input_platform.cpp (+11/-3) src/shared/input/android/android_input_platform.h (+4/-1) src/shared/input/android/android_input_receiver.cpp (+9/-2) src/shared/input/android/android_input_receiver.h (+7/-2) tests/acceptance-tests/test_client_input.cpp (+367/-452) tests/unit-tests/client/input/test_android_input_receiver.cpp (+8/-5) tests/unit-tests/client/input/test_android_input_receiver_thread.cpp (+5/-2) |
To merge this branch: | bzr merge lp:~robertcarr/mir/refactor-input-acceptance-take-1 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir development team | Pending | ||
Review via email: mp+194264@code.launchpad.net |
This proposal has been superseded by a proposal from 2013-11-07.
Commit message
Simplify input acceptance tests with a better shared fixture.
Description of the change
First take at simplifying input acceptance tests with a better shared fixture.
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 'doc/component_reports.md' | |||
2 | --- doc/component_reports.md 2013-10-24 11:41:30 +0000 | |||
3 | +++ doc/component_reports.md 2013-11-07 00:22:14 +0000 | |||
4 | @@ -40,6 +40,7 @@ | |||
5 | 40 | Report | Handlers | 40 | Report | Handlers |
6 | 41 | ------------------- | -------- | 41 | ------------------- | -------- |
7 | 42 | rpc-report | log,lttng | 42 | rpc-report | log,lttng |
8 | 43 | input-receiver | log | ||
9 | 43 | 44 | ||
10 | 44 | For example, to enable the logging RPC report, one should set the | 45 | For example, to enable the logging RPC report, one should set the |
11 | 45 | `MIR_CLIENT_RPC_REPORT=log` environment variable. | 46 | `MIR_CLIENT_RPC_REPORT=log` environment variable. |
12 | 46 | 47 | ||
13 | === modified file 'include/shared/mir/input/input_platform.h' | |||
14 | --- include/shared/mir/input/input_platform.h 2013-05-13 23:20:52 +0000 | |||
15 | +++ include/shared/mir/input/input_platform.h 2013-11-07 00:22:14 +0000 | |||
16 | @@ -31,6 +31,7 @@ | |||
17 | 31 | namespace receiver | 31 | namespace receiver |
18 | 32 | { | 32 | { |
19 | 33 | class InputReceiverThread; | 33 | class InputReceiverThread; |
20 | 34 | class InputReceiverReport; | ||
21 | 34 | 35 | ||
22 | 35 | // Interface for MirSurface to construct input dispatcher threads. | 36 | // Interface for MirSurface to construct input dispatcher threads. |
23 | 36 | class InputPlatform | 37 | class InputPlatform |
24 | @@ -39,8 +40,9 @@ | |||
25 | 39 | virtual ~InputPlatform() {}; | 40 | virtual ~InputPlatform() {}; |
26 | 40 | 41 | ||
27 | 41 | virtual std::shared_ptr<InputReceiverThread> create_input_thread(int fd, std::function<void(MirEvent *)> const& callback) = 0; | 42 | virtual std::shared_ptr<InputReceiverThread> create_input_thread(int fd, std::function<void(MirEvent *)> const& callback) = 0; |
29 | 42 | 43 | ||
30 | 43 | static std::shared_ptr<InputPlatform> create(); | 44 | static std::shared_ptr<InputPlatform> create(); |
31 | 45 | static std::shared_ptr<InputPlatform> create(std::shared_ptr<InputReceiverReport> const& report); | ||
32 | 44 | 46 | ||
33 | 45 | protected: | 47 | protected: |
34 | 46 | InputPlatform() = default; | 48 | InputPlatform() = default; |
35 | 47 | 49 | ||
36 | === added file 'include/shared/mir/input/input_receiver_report.h' | |||
37 | --- include/shared/mir/input/input_receiver_report.h 1970-01-01 00:00:00 +0000 | |||
38 | +++ include/shared/mir/input/input_receiver_report.h 2013-11-07 00:22:14 +0000 | |||
39 | @@ -0,0 +1,48 @@ | |||
40 | 1 | /* | ||
41 | 2 | * Copyright © 2013 Canonical Ltd. | ||
42 | 3 | * | ||
43 | 4 | * This program is free software: you can redistribute it and/or modify | ||
44 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
45 | 6 | * published by the Free Software Foundation. | ||
46 | 7 | * | ||
47 | 8 | * This program is distributed in the hope that it will be useful, | ||
48 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
49 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
50 | 11 | * GNU Lesser General Public License for more details. | ||
51 | 12 | * | ||
52 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
53 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
54 | 15 | * | ||
55 | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> | ||
56 | 17 | */ | ||
57 | 18 | |||
58 | 19 | #ifndef MIR_CLIENT_INPUT_RECEIVER_REPORT_H_ | ||
59 | 20 | #define MIR_CLIENT_INPUT_RECEIVER_REPORT_H_ | ||
60 | 21 | |||
61 | 22 | #include <mir_toolkit/event.h> | ||
62 | 23 | |||
63 | 24 | namespace mir | ||
64 | 25 | { | ||
65 | 26 | namespace input | ||
66 | 27 | { | ||
67 | 28 | namespace receiver | ||
68 | 29 | { | ||
69 | 30 | |||
70 | 31 | class InputReceiverReport | ||
71 | 32 | { | ||
72 | 33 | public: | ||
73 | 34 | virtual ~InputReceiverReport() = default; | ||
74 | 35 | |||
75 | 36 | virtual void received_event(MirEvent const& event) = 0; | ||
76 | 37 | |||
77 | 38 | protected: | ||
78 | 39 | InputReceiverReport() = default; | ||
79 | 40 | InputReceiverReport(InputReceiverReport const&) = delete; | ||
80 | 41 | InputReceiverReport& operator=(InputReceiverReport const&) = delete; | ||
81 | 42 | }; | ||
82 | 43 | |||
83 | 44 | } | ||
84 | 45 | } | ||
85 | 46 | } | ||
86 | 47 | |||
87 | 48 | #endif /* MIR_CLIENT_INPUT_RECEIVER_REPORT_H_ */ | ||
88 | 0 | 49 | ||
89 | === added file 'include/shared/mir/input/null_input_receiver_report.h' | |||
90 | --- include/shared/mir/input/null_input_receiver_report.h 1970-01-01 00:00:00 +0000 | |||
91 | +++ include/shared/mir/input/null_input_receiver_report.h 2013-11-07 00:22:14 +0000 | |||
92 | @@ -0,0 +1,46 @@ | |||
93 | 1 | /* | ||
94 | 2 | * Copyright © 2013 Canonical Ltd. | ||
95 | 3 | * | ||
96 | 4 | * This program is free software: you can redistribute it and/or modify | ||
97 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
98 | 6 | * published by the Free Software Foundation. | ||
99 | 7 | * | ||
100 | 8 | * This program is distributed in the hope that it will be useful, | ||
101 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
102 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
103 | 11 | * GNU Lesser General Public License for more details. | ||
104 | 12 | * | ||
105 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
106 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
107 | 15 | * | ||
108 | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> | ||
109 | 17 | */ | ||
110 | 18 | |||
111 | 19 | #ifndef MIR_CLIENT_NULL_INPUT_RECEIVER_REPORT_H_ | ||
112 | 20 | #define MIR_CLIENT_NULL_INPUT_RECEIVER_REPORT_H_ | ||
113 | 21 | |||
114 | 22 | #include "mir/input/input_receiver_report.h" | ||
115 | 23 | |||
116 | 24 | #include <mir_toolkit/event.h> | ||
117 | 25 | |||
118 | 26 | namespace mir | ||
119 | 27 | { | ||
120 | 28 | namespace input | ||
121 | 29 | { | ||
122 | 30 | namespace receiver | ||
123 | 31 | { | ||
124 | 32 | |||
125 | 33 | class NullInputReceiverReport : public InputReceiverReport | ||
126 | 34 | { | ||
127 | 35 | public: | ||
128 | 36 | NullInputReceiverReport() = default; | ||
129 | 37 | virtual ~NullInputReceiverReport() = default; | ||
130 | 38 | |||
131 | 39 | void received_event(MirEvent const& /* event */) {} | ||
132 | 40 | }; | ||
133 | 41 | |||
134 | 42 | } | ||
135 | 43 | } | ||
136 | 44 | } | ||
137 | 45 | |||
138 | 46 | #endif /* MIR_CLIENT_NULL_INPUT_RECEIVER_REPORT_H_ */ | ||
139 | 0 | 47 | ||
140 | === modified file 'include/test/mir_test_framework/input_testing_server_configuration.h' | |||
141 | --- include/test/mir_test_framework/input_testing_server_configuration.h 2013-08-28 03:41:48 +0000 | |||
142 | +++ include/test/mir_test_framework/input_testing_server_configuration.h 2013-11-07 00:22:14 +0000 | |||
143 | @@ -65,9 +65,10 @@ | |||
144 | 65 | std::shared_ptr<mir::input::InputConfiguration> the_input_configuration() override; | 65 | std::shared_ptr<mir::input::InputConfiguration> the_input_configuration() override; |
145 | 66 | std::shared_ptr<mir::frontend::Shell> the_frontend_shell() override; | 66 | std::shared_ptr<mir::frontend::Shell> the_frontend_shell() override; |
146 | 67 | 67 | ||
147 | 68 | mir::input::android::FakeEventHub* fake_event_hub; | ||
148 | 69 | |||
149 | 68 | protected: | 70 | protected: |
150 | 69 | virtual void inject_input() = 0; | 71 | virtual void inject_input() = 0; |
151 | 70 | mir::input::android::FakeEventHub* fake_event_hub; | ||
152 | 71 | 72 | ||
153 | 72 | void wait_until_client_appears(std::string const& surface_name); | 73 | void wait_until_client_appears(std::string const& surface_name); |
154 | 73 | 74 | ||
155 | 74 | 75 | ||
156 | === modified file 'src/client/CMakeLists.txt' | |||
157 | --- src/client/CMakeLists.txt 2013-10-21 16:02:28 +0000 | |||
158 | +++ src/client/CMakeLists.txt 2013-11-07 00:22:14 +0000 | |||
159 | @@ -29,6 +29,7 @@ | |||
160 | 29 | mir_wait_handle.cpp | 29 | mir_wait_handle.cpp |
161 | 30 | mir_surface.cpp | 30 | mir_surface.cpp |
162 | 31 | logging/rpc_report.cpp | 31 | logging/rpc_report.cpp |
163 | 32 | logging/input_receiver_report.cpp | ||
164 | 32 | default_connection_configuration.cpp | 33 | default_connection_configuration.cpp |
165 | 33 | surface_map.cpp | 34 | surface_map.cpp |
166 | 34 | lifecycle_control.cpp | 35 | lifecycle_control.cpp |
167 | 35 | 36 | ||
168 | === modified file 'src/client/default_connection_configuration.cpp' | |||
169 | --- src/client/default_connection_configuration.cpp 2013-08-28 03:41:48 +0000 | |||
170 | +++ src/client/default_connection_configuration.cpp 2013-11-07 00:22:14 +0000 | |||
171 | @@ -24,7 +24,9 @@ | |||
172 | 24 | #include "mir/logging/dumb_console_logger.h" | 24 | #include "mir/logging/dumb_console_logger.h" |
173 | 25 | #include "native_client_platform_factory.h" | 25 | #include "native_client_platform_factory.h" |
174 | 26 | #include "mir/input/input_platform.h" | 26 | #include "mir/input/input_platform.h" |
175 | 27 | #include "mir/input/null_input_receiver_report.h" | ||
176 | 27 | #include "logging/rpc_report.h" | 28 | #include "logging/rpc_report.h" |
177 | 29 | #include "logging/input_receiver_report.h" | ||
178 | 28 | #include "lttng/rpc_report.h" | 30 | #include "lttng/rpc_report.h" |
179 | 29 | #include "connection_surface_map.h" | 31 | #include "connection_surface_map.h" |
180 | 30 | #include "lifecycle_control.h" | 32 | #include "lifecycle_control.h" |
181 | @@ -88,9 +90,9 @@ | |||
182 | 88 | mcl::DefaultConnectionConfiguration::the_input_platform() | 90 | mcl::DefaultConnectionConfiguration::the_input_platform() |
183 | 89 | { | 91 | { |
184 | 90 | return input_platform( | 92 | return input_platform( |
186 | 91 | [] | 93 | [this] |
187 | 92 | { | 94 | { |
189 | 93 | return mir::input::receiver::InputPlatform::create(); | 95 | return mir::input::receiver::InputPlatform::create(the_input_receiver_report()); |
190 | 94 | }); | 96 | }); |
191 | 95 | } | 97 | } |
192 | 96 | 98 | ||
193 | @@ -118,6 +120,22 @@ | |||
194 | 118 | }); | 120 | }); |
195 | 119 | } | 121 | } |
196 | 120 | 122 | ||
197 | 123 | std::shared_ptr<mir::input::receiver::InputReceiverReport> | ||
198 | 124 | mcl::DefaultConnectionConfiguration::the_input_receiver_report() | ||
199 | 125 | { | ||
200 | 126 | return input_receiver_report( | ||
201 | 127 | [this] () -> std::shared_ptr<mir::input::receiver::InputReceiverReport> | ||
202 | 128 | { | ||
203 | 129 | auto val_raw = getenv("MIR_CLIENT_INPUT_RECEIVER_REPORT"); | ||
204 | 130 | std::string const val{val_raw ? val_raw : off_opt_val}; | ||
205 | 131 | |||
206 | 132 | if (val == log_opt_val) | ||
207 | 133 | return std::make_shared<mcl::logging::InputReceiverReport>(the_logger()); | ||
208 | 134 | else | ||
209 | 135 | return std::make_shared<mir::input::receiver::NullInputReceiverReport>(); | ||
210 | 136 | }); | ||
211 | 137 | } | ||
212 | 138 | |||
213 | 121 | std::shared_ptr<mcl::DisplayConfiguration> mcl::DefaultConnectionConfiguration::the_display_configuration() | 139 | std::shared_ptr<mcl::DisplayConfiguration> mcl::DefaultConnectionConfiguration::the_display_configuration() |
214 | 122 | { | 140 | { |
215 | 123 | return display_configuration( | 141 | return display_configuration( |
216 | 124 | 142 | ||
217 | === modified file 'src/client/default_connection_configuration.h' | |||
218 | --- src/client/default_connection_configuration.h 2013-08-28 03:41:48 +0000 | |||
219 | +++ src/client/default_connection_configuration.h 2013-11-07 00:22:14 +0000 | |||
220 | @@ -27,6 +27,13 @@ | |||
221 | 27 | 27 | ||
222 | 28 | namespace mir | 28 | namespace mir |
223 | 29 | { | 29 | { |
224 | 30 | namespace input | ||
225 | 31 | { | ||
226 | 32 | namespace receiver | ||
227 | 33 | { | ||
228 | 34 | class InputReceiverReport; | ||
229 | 35 | } | ||
230 | 36 | } | ||
231 | 30 | namespace client | 37 | namespace client |
232 | 31 | { | 38 | { |
233 | 32 | 39 | ||
234 | @@ -50,6 +57,7 @@ | |||
235 | 50 | 57 | ||
236 | 51 | virtual std::string the_socket_file(); | 58 | virtual std::string the_socket_file(); |
237 | 52 | virtual std::shared_ptr<rpc::RpcReport> the_rpc_report(); | 59 | virtual std::shared_ptr<rpc::RpcReport> the_rpc_report(); |
238 | 60 | virtual std::shared_ptr<input::receiver::InputReceiverReport> the_input_receiver_report(); | ||
239 | 53 | 61 | ||
240 | 54 | protected: | 62 | protected: |
241 | 55 | CachedPtr<rpc::MirBasicRpcChannel> rpc_channel; | 63 | CachedPtr<rpc::MirBasicRpcChannel> rpc_channel; |
242 | @@ -61,6 +69,7 @@ | |||
243 | 61 | CachedPtr<LifecycleControl> lifecycle_control; | 69 | CachedPtr<LifecycleControl> lifecycle_control; |
244 | 62 | 70 | ||
245 | 63 | CachedPtr<rpc::RpcReport> rpc_report; | 71 | CachedPtr<rpc::RpcReport> rpc_report; |
246 | 72 | CachedPtr<input::receiver::InputReceiverReport> input_receiver_report; | ||
247 | 64 | 73 | ||
248 | 65 | private: | 74 | private: |
249 | 66 | std::string const socket_file; | 75 | std::string const socket_file; |
250 | 67 | 76 | ||
251 | === added file 'src/client/logging/input_receiver_report.cpp' | |||
252 | --- src/client/logging/input_receiver_report.cpp 1970-01-01 00:00:00 +0000 | |||
253 | +++ src/client/logging/input_receiver_report.cpp 2013-11-07 00:22:14 +0000 | |||
254 | @@ -0,0 +1,125 @@ | |||
255 | 1 | /* | ||
256 | 2 | * Copyright © 2013 Canonical Ltd. | ||
257 | 3 | * | ||
258 | 4 | * This program is free software: you can redistribute it and/or modify | ||
259 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
260 | 6 | * published by the Free Software Foundation. | ||
261 | 7 | * | ||
262 | 8 | * This program is distributed in the hope that it will be useful, | ||
263 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
264 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
265 | 11 | * GNU Lesser General Public License for more details. | ||
266 | 12 | * | ||
267 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
268 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
269 | 15 | * | ||
270 | 16 | * Authored by: Robert Carr <robert.carr@canonical.com> | ||
271 | 17 | */ | ||
272 | 18 | |||
273 | 19 | #include "input_receiver_report.h" | ||
274 | 20 | |||
275 | 21 | #include "mir/logging/logger.h" | ||
276 | 22 | |||
277 | 23 | #include <boost/throw_exception.hpp> | ||
278 | 24 | |||
279 | 25 | #include <sstream> | ||
280 | 26 | #include <stdexcept> | ||
281 | 27 | |||
282 | 28 | namespace ml = mir::logging; | ||
283 | 29 | namespace mcll = mir::client::logging; | ||
284 | 30 | |||
285 | 31 | namespace | ||
286 | 32 | { | ||
287 | 33 | std::string const component{"input-receiver"}; | ||
288 | 34 | } | ||
289 | 35 | |||
290 | 36 | mcll::InputReceiverReport::InputReceiverReport(std::shared_ptr<ml::Logger> const& logger) | ||
291 | 37 | : logger{logger} | ||
292 | 38 | { | ||
293 | 39 | } | ||
294 | 40 | |||
295 | 41 | namespace | ||
296 | 42 | { | ||
297 | 43 | |||
298 | 44 | static void format_key_event(std::stringstream &ss, MirKeyEvent const& ev) | ||
299 | 45 | { | ||
300 | 46 | ss << "MirKeyEvent {" << std::endl; | ||
301 | 47 | ss << " device_id: " << ev.device_id << std::endl; | ||
302 | 48 | ss << " source_id: " << ev.source_id << std::endl; | ||
303 | 49 | ss << " action: " << ev.action << std::endl; | ||
304 | 50 | ss << " flags: " << ev.flags << std::endl; | ||
305 | 51 | ss << " modifiers: " << ev.modifiers << std::endl; | ||
306 | 52 | ss << " key_code: " << ev.key_code << std::endl; | ||
307 | 53 | ss << " scan_code: " << ev.scan_code << std::endl; | ||
308 | 54 | ss << " repeat_count: " << ev.repeat_count << std::endl; | ||
309 | 55 | ss << " down_time: " << ev.down_time << std::endl; | ||
310 | 56 | ss << " event_time: " << ev.event_time << std::endl; | ||
311 | 57 | ss << " is_system_key: " << ev.is_system_key << std::endl; | ||
312 | 58 | ss << "}"; | ||
313 | 59 | } | ||
314 | 60 | static void format_motion_event(std::stringstream &ss, MirMotionEvent const& ev) | ||
315 | 61 | { | ||
316 | 62 | ss << "MirMotionEvent{" << std::endl; | ||
317 | 63 | ss << " type: motion" << std::endl; | ||
318 | 64 | ss << " device_id: " << ev.device_id << std::endl; | ||
319 | 65 | ss << " source_id: " << ev.source_id << std::endl; | ||
320 | 66 | ss << " action: " << ev.action << std::endl; | ||
321 | 67 | ss << " flags: " << ev.flags << std::endl; | ||
322 | 68 | ss << " modifiers: " << ev.modifiers << std::endl; | ||
323 | 69 | ss << " edge_flags: " << ev.edge_flags << std::endl; | ||
324 | 70 | ss << " button_state: " << ev.button_state << std::endl; | ||
325 | 71 | ss << " x_offset: " << ev.x_offset << std::endl; | ||
326 | 72 | ss << " y_offset: " << ev.y_offset << std::endl; | ||
327 | 73 | ss << " x_precision: " << ev.x_precision << std::endl; | ||
328 | 74 | ss << " y_precision: " << ev.y_precision << std::endl; | ||
329 | 75 | ss << " down_time: " << ev.down_time << std::endl; | ||
330 | 76 | ss << " event_time: " << ev.event_time << std::endl; | ||
331 | 77 | ss << " pointer_count: " << ev.pointer_count << std::endl; | ||
332 | 78 | for (unsigned int i = 0; i < ev.pointer_count; i++) | ||
333 | 79 | { | ||
334 | 80 | ss << " pointer[" << i << "]{" << std::endl; | ||
335 | 81 | ss << " id: " << ev.pointer_coordinates[i].id << std::endl; | ||
336 | 82 | ss << " x: " << ev.pointer_coordinates[i].x << std::endl; | ||
337 | 83 | ss << " raw_x: " << ev.pointer_coordinates[i].raw_x << std::endl; | ||
338 | 84 | ss << " y: " << ev.pointer_coordinates[i].y << std::endl; | ||
339 | 85 | ss << " raw_y: " << ev.pointer_coordinates[i].raw_y << std::endl; | ||
340 | 86 | ss << " touch_major: " << ev.pointer_coordinates[i].touch_major << std::endl; | ||
341 | 87 | ss << " touch_minor: " << ev.pointer_coordinates[i].touch_minor << std::endl; | ||
342 | 88 | ss << " size: " << ev.pointer_coordinates[i].size << std::endl; | ||
343 | 89 | ss << " pressure: " << ev.pointer_coordinates[i].pressure << std::endl; | ||
344 | 90 | ss << " orientation: " << ev.pointer_coordinates[i].orientation << std::endl; | ||
345 | 91 | ss << " vscroll: " << ev.pointer_coordinates[i].vscroll << std::endl; | ||
346 | 92 | ss << " hscroll: " << ev.pointer_coordinates[i].hscroll << std::endl; | ||
347 | 93 | ss << " }" << std::endl; | ||
348 | 94 | } | ||
349 | 95 | ss << "}"; | ||
350 | 96 | } | ||
351 | 97 | |||
352 | 98 | static void format_event(std::stringstream &ss, MirEvent const& ev) | ||
353 | 99 | { | ||
354 | 100 | switch (ev.type) | ||
355 | 101 | { | ||
356 | 102 | case mir_event_type_key: | ||
357 | 103 | format_key_event(ss, ev.key); | ||
358 | 104 | break; | ||
359 | 105 | case mir_event_type_motion: | ||
360 | 106 | format_motion_event(ss, ev.motion); | ||
361 | 107 | break; | ||
362 | 108 | default: | ||
363 | 109 | BOOST_THROW_EXCEPTION(std::runtime_error("Unexpected event type")); | ||
364 | 110 | } | ||
365 | 111 | } | ||
366 | 112 | |||
367 | 113 | } | ||
368 | 114 | |||
369 | 115 | void mcll::InputReceiverReport::received_event( | ||
370 | 116 | MirEvent const& event) | ||
371 | 117 | { | ||
372 | 118 | std::stringstream ss; | ||
373 | 119 | |||
374 | 120 | ss << "Received event:" << std::endl; | ||
375 | 121 | |||
376 | 122 | format_event(ss, event); | ||
377 | 123 | |||
378 | 124 | logger->log<ml::Logger::debug>(ss.str(), component); | ||
379 | 125 | } | ||
380 | 0 | 126 | ||
381 | === added file 'src/client/logging/input_receiver_report.h' | |||
382 | --- src/client/logging/input_receiver_report.h 1970-01-01 00:00:00 +0000 | |||
383 | +++ src/client/logging/input_receiver_report.h 2013-11-07 00:22:14 +0000 | |||
384 | @@ -0,0 +1,54 @@ | |||
385 | 1 | /* | ||
386 | 2 | * Copyright © 2013 Canonical Ltd. | ||
387 | 3 | * | ||
388 | 4 | * This program is free software: you can redistribute it and/or modify | ||
389 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
390 | 6 | * published by the Free Software Foundation. | ||
391 | 7 | * | ||
392 | 8 | * This program is distributed in the hope that it will be useful, | ||
393 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
394 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
395 | 11 | * GNU Lesser General Public License for more details. | ||
396 | 12 | * | ||
397 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
398 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
399 | 15 | * | ||
400 | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> | ||
401 | 17 | */ | ||
402 | 18 | |||
403 | 19 | #ifndef MIR_CLIENT_LOGGING_INPUT_RECEIVER_REPORT_H_ | ||
404 | 20 | #define MIR_CLIENT_LOGGING_INPUT_RECEIVER_REPORT_H_ | ||
405 | 21 | |||
406 | 22 | #include "mir/input/input_receiver_report.h" | ||
407 | 23 | |||
408 | 24 | #include <memory> | ||
409 | 25 | |||
410 | 26 | namespace mir | ||
411 | 27 | { | ||
412 | 28 | |||
413 | 29 | namespace logging | ||
414 | 30 | { | ||
415 | 31 | class Logger; | ||
416 | 32 | } | ||
417 | 33 | |||
418 | 34 | namespace client | ||
419 | 35 | { | ||
420 | 36 | namespace logging | ||
421 | 37 | { | ||
422 | 38 | |||
423 | 39 | class InputReceiverReport : public input::receiver::InputReceiverReport | ||
424 | 40 | { | ||
425 | 41 | public: | ||
426 | 42 | InputReceiverReport(std::shared_ptr<mir::logging::Logger> const& logger); | ||
427 | 43 | |||
428 | 44 | void received_event(MirEvent const& event) override; | ||
429 | 45 | |||
430 | 46 | private: | ||
431 | 47 | std::shared_ptr<mir::logging::Logger> const logger; | ||
432 | 48 | }; | ||
433 | 49 | |||
434 | 50 | } | ||
435 | 51 | } | ||
436 | 52 | } | ||
437 | 53 | |||
438 | 54 | #endif /* MIR_CLIENT_LOGGING_INPUT_RECEIVER_REPORT_H_ */ | ||
439 | 0 | 55 | ||
440 | === modified file 'src/shared/input/android/android_input_platform.cpp' | |||
441 | --- src/shared/input/android/android_input_platform.cpp 2013-05-13 23:20:52 +0000 | |||
442 | +++ src/shared/input/android/android_input_platform.cpp 2013-11-07 00:22:14 +0000 | |||
443 | @@ -20,10 +20,13 @@ | |||
444 | 20 | #include "android_input_receiver.h" | 20 | #include "android_input_receiver.h" |
445 | 21 | #include "android_input_receiver_thread.h" | 21 | #include "android_input_receiver_thread.h" |
446 | 22 | 22 | ||
447 | 23 | #include "mir/input/null_input_receiver_report.h" | ||
448 | 24 | |||
449 | 23 | namespace mircv = mir::input::receiver; | 25 | namespace mircv = mir::input::receiver; |
450 | 24 | namespace mircva = mircv::android; | 26 | namespace mircva = mircv::android; |
451 | 25 | 27 | ||
453 | 26 | mircva::AndroidInputPlatform::AndroidInputPlatform() | 28 | mircva::AndroidInputPlatform::AndroidInputPlatform(std::shared_ptr<mircv::InputReceiverReport> const& report) |
454 | 29 | : report(report) | ||
455 | 27 | { | 30 | { |
456 | 28 | } | 31 | } |
457 | 29 | 32 | ||
458 | @@ -34,11 +37,16 @@ | |||
459 | 34 | std::shared_ptr<mircv::InputReceiverThread> mircva::AndroidInputPlatform::create_input_thread( | 37 | std::shared_ptr<mircv::InputReceiverThread> mircva::AndroidInputPlatform::create_input_thread( |
460 | 35 | int fd, std::function<void(MirEvent*)> const& callback) | 38 | int fd, std::function<void(MirEvent*)> const& callback) |
461 | 36 | { | 39 | { |
463 | 37 | auto receiver = std::make_shared<mircva::InputReceiver>(fd); | 40 | auto receiver = std::make_shared<mircva::InputReceiver>(fd, report); |
464 | 38 | return std::make_shared<mircva::InputReceiverThread>(receiver, callback); | 41 | return std::make_shared<mircva::InputReceiverThread>(receiver, callback); |
465 | 39 | } | 42 | } |
466 | 40 | 43 | ||
467 | 41 | std::shared_ptr<mircv::InputPlatform> mircv::InputPlatform::create() | 44 | std::shared_ptr<mircv::InputPlatform> mircv::InputPlatform::create() |
468 | 42 | { | 45 | { |
470 | 43 | return std::make_shared<mircva::AndroidInputPlatform>(); | 46 | return create(std::make_shared<mircv::NullInputReceiverReport>()); |
471 | 47 | } | ||
472 | 48 | |||
473 | 49 | std::shared_ptr<mircv::InputPlatform> mircv::InputPlatform::create(std::shared_ptr<mircv::InputReceiverReport> const& report) | ||
474 | 50 | { | ||
475 | 51 | return std::make_shared<mircva::AndroidInputPlatform>(report); | ||
476 | 44 | } | 52 | } |
477 | 45 | 53 | ||
478 | === modified file 'src/shared/input/android/android_input_platform.h' | |||
479 | --- src/shared/input/android/android_input_platform.h 2013-05-13 23:20:52 +0000 | |||
480 | +++ src/shared/input/android/android_input_platform.h 2013-11-07 00:22:14 +0000 | |||
481 | @@ -34,7 +34,7 @@ | |||
482 | 34 | class AndroidInputPlatform : public InputPlatform | 34 | class AndroidInputPlatform : public InputPlatform |
483 | 35 | { | 35 | { |
484 | 36 | public: | 36 | public: |
486 | 37 | AndroidInputPlatform(); | 37 | AndroidInputPlatform(std::shared_ptr<InputReceiverReport> const& report); |
487 | 38 | virtual ~AndroidInputPlatform(); | 38 | virtual ~AndroidInputPlatform(); |
488 | 39 | 39 | ||
489 | 40 | std::shared_ptr<InputReceiverThread> create_input_thread(int fd, std::function<void(MirEvent *)> const& callback); | 40 | std::shared_ptr<InputReceiverThread> create_input_thread(int fd, std::function<void(MirEvent *)> const& callback); |
490 | @@ -42,6 +42,9 @@ | |||
491 | 42 | protected: | 42 | protected: |
492 | 43 | AndroidInputPlatform(const AndroidInputPlatform&) = delete; | 43 | AndroidInputPlatform(const AndroidInputPlatform&) = delete; |
493 | 44 | AndroidInputPlatform& operator=(const AndroidInputPlatform&) = delete; | 44 | AndroidInputPlatform& operator=(const AndroidInputPlatform&) = delete; |
494 | 45 | |||
495 | 46 | private: | ||
496 | 47 | std::shared_ptr<InputReceiverReport> const report; | ||
497 | 45 | }; | 48 | }; |
498 | 46 | 49 | ||
499 | 47 | } | 50 | } |
500 | 48 | 51 | ||
501 | === modified file 'src/shared/input/android/android_input_receiver.cpp' | |||
502 | --- src/shared/input/android/android_input_receiver.cpp 2013-05-24 18:20:37 +0000 | |||
503 | +++ src/shared/input/android/android_input_receiver.cpp 2013-11-07 00:22:14 +0000 | |||
504 | @@ -19,6 +19,7 @@ | |||
505 | 19 | #include "android_input_receiver.h" | 19 | #include "android_input_receiver.h" |
506 | 20 | 20 | ||
507 | 21 | #include "mir/input/xkb_mapper.h" | 21 | #include "mir/input/xkb_mapper.h" |
508 | 22 | #include "mir/input/input_receiver_report.h" | ||
509 | 22 | #include "mir/input/android/android_input_lexicon.h" | 23 | #include "mir/input/android/android_input_lexicon.h" |
510 | 23 | 24 | ||
511 | 24 | #include <androidfw/InputTransport.h> | 25 | #include <androidfw/InputTransport.h> |
512 | @@ -29,8 +30,10 @@ | |||
513 | 29 | 30 | ||
514 | 30 | namespace mia = mir::input::android; | 31 | namespace mia = mir::input::android; |
515 | 31 | 32 | ||
517 | 32 | mircva::InputReceiver::InputReceiver(droidinput::sp<droidinput::InputChannel> const& input_channel) | 33 | mircva::InputReceiver::InputReceiver(droidinput::sp<droidinput::InputChannel> const& input_channel, |
518 | 34 | std::shared_ptr<mircv::InputReceiverReport> const& report) | ||
519 | 33 | : input_channel(input_channel), | 35 | : input_channel(input_channel), |
520 | 36 | report(report), | ||
521 | 34 | input_consumer(std::make_shared<droidinput::InputConsumer>(input_channel)), | 37 | input_consumer(std::make_shared<droidinput::InputConsumer>(input_channel)), |
522 | 35 | looper(new droidinput::Looper(true)), | 38 | looper(new droidinput::Looper(true)), |
523 | 36 | fd_added(false), | 39 | fd_added(false), |
524 | @@ -38,8 +41,10 @@ | |||
525 | 38 | { | 41 | { |
526 | 39 | } | 42 | } |
527 | 40 | 43 | ||
529 | 41 | mircva::InputReceiver::InputReceiver(int fd) | 44 | mircva::InputReceiver::InputReceiver(int fd, |
530 | 45 | std::shared_ptr<mircv::InputReceiverReport> const& report) | ||
531 | 42 | : input_channel(new droidinput::InputChannel(droidinput::String8(""), fd)), | 46 | : input_channel(new droidinput::InputChannel(droidinput::String8(""), fd)), |
532 | 47 | report(report), | ||
533 | 43 | input_consumer(std::make_shared<droidinput::InputConsumer>(input_channel)), | 48 | input_consumer(std::make_shared<droidinput::InputConsumer>(input_channel)), |
534 | 44 | looper(new droidinput::Looper(true)), | 49 | looper(new droidinput::Looper(true)), |
535 | 45 | fd_added(false), | 50 | fd_added(false), |
536 | @@ -84,6 +89,8 @@ | |||
537 | 84 | map_key_event(xkb_mapper, ev); | 89 | map_key_event(xkb_mapper, ev); |
538 | 85 | 90 | ||
539 | 86 | input_consumer->sendFinishedSignal(event_sequence_id, true); | 91 | input_consumer->sendFinishedSignal(event_sequence_id, true); |
540 | 92 | |||
541 | 93 | report->received_event(ev); | ||
542 | 87 | 94 | ||
543 | 88 | return true; | 95 | return true; |
544 | 89 | } | 96 | } |
545 | 90 | 97 | ||
546 | === modified file 'src/shared/input/android/android_input_receiver.h' | |||
547 | --- src/shared/input/android/android_input_receiver.h 2013-05-24 18:20:37 +0000 | |||
548 | +++ src/shared/input/android/android_input_receiver.h 2013-11-07 00:22:14 +0000 | |||
549 | @@ -43,6 +43,7 @@ | |||
550 | 43 | namespace receiver | 43 | namespace receiver |
551 | 44 | { | 44 | { |
552 | 45 | class XKBMapper; | 45 | class XKBMapper; |
553 | 46 | class InputReceiverReport; | ||
554 | 46 | 47 | ||
555 | 47 | namespace android | 48 | namespace android |
556 | 48 | { | 49 | { |
557 | @@ -51,8 +52,10 @@ | |||
558 | 51 | class InputReceiver | 52 | class InputReceiver |
559 | 52 | { | 53 | { |
560 | 53 | public: | 54 | public: |
563 | 54 | InputReceiver(droidinput::sp<droidinput::InputChannel> const& input_channel); | 55 | InputReceiver(droidinput::sp<droidinput::InputChannel> const& input_channel, |
564 | 55 | InputReceiver(int fd); | 56 | std::shared_ptr<InputReceiverReport> const& report); |
565 | 57 | InputReceiver(int fd, | ||
566 | 58 | std::shared_ptr<InputReceiverReport> const& report); | ||
567 | 56 | 59 | ||
568 | 57 | virtual ~InputReceiver(); | 60 | virtual ~InputReceiver(); |
569 | 58 | int fd() const; | 61 | int fd() const; |
570 | @@ -71,6 +74,8 @@ | |||
571 | 71 | 74 | ||
572 | 72 | private: | 75 | private: |
573 | 73 | droidinput::sp<droidinput::InputChannel> input_channel; | 76 | droidinput::sp<droidinput::InputChannel> input_channel; |
574 | 77 | std::shared_ptr<InputReceiverReport> const report; | ||
575 | 78 | |||
576 | 74 | std::shared_ptr<droidinput::InputConsumer> input_consumer; | 79 | std::shared_ptr<droidinput::InputConsumer> input_consumer; |
577 | 75 | droidinput::PreallocatedInputEventFactory event_factory; | 80 | droidinput::PreallocatedInputEventFactory event_factory; |
578 | 76 | droidinput::sp<droidinput::Looper> looper; | 81 | droidinput::sp<droidinput::Looper> looper; |
579 | 77 | 82 | ||
580 | === modified file 'tests/acceptance-tests/test_client_input.cpp' | |||
581 | --- tests/acceptance-tests/test_client_input.cpp 2013-10-28 21:41:27 +0000 | |||
582 | +++ tests/acceptance-tests/test_client_input.cpp 2013-11-07 00:22:14 +0000 | |||
583 | @@ -248,6 +248,16 @@ | |||
584 | 248 | return true; | 248 | return true; |
585 | 249 | } | 249 | } |
586 | 250 | 250 | ||
587 | 251 | MATCHER(HoverMoveEvent, "") | ||
588 | 252 | { | ||
589 | 253 | if (arg->type != mir_event_type_motion) | ||
590 | 254 | return false; | ||
591 | 255 | if (arg->motion.action != mir_motion_action_hover_move) | ||
592 | 256 | return false; | ||
593 | 257 | |||
594 | 258 | return true; | ||
595 | 259 | } | ||
596 | 260 | |||
597 | 251 | MATCHER_P2(ButtonDownEvent, x, y, "") | 261 | MATCHER_P2(ButtonDownEvent, x, y, "") |
598 | 252 | { | 262 | { |
599 | 253 | if (arg->type != mir_event_type_motion) | 263 | if (arg->type != mir_event_type_motion) |
600 | @@ -302,194 +312,6 @@ | |||
601 | 302 | 312 | ||
602 | 303 | } | 313 | } |
603 | 304 | 314 | ||
604 | 305 | |||
605 | 306 | using TestClientInput = BespokeDisplayServerTestFixture; | ||
606 | 307 | |||
607 | 308 | TEST_F(TestClientInput, clients_receive_key_input) | ||
608 | 309 | { | ||
609 | 310 | using namespace ::testing; | ||
610 | 311 | |||
611 | 312 | int const num_events_produced = 3; | ||
612 | 313 | static std::string const test_client_name = "1"; | ||
613 | 314 | |||
614 | 315 | mtf::CrossProcessSync fence; | ||
615 | 316 | |||
616 | 317 | struct ServerConfiguration : mtf::InputTestingServerConfiguration | ||
617 | 318 | { | ||
618 | 319 | mtf::CrossProcessSync input_cb_setup_fence; | ||
619 | 320 | |||
620 | 321 | ServerConfiguration(const mtf::CrossProcessSync& input_cb_setup_fence) | ||
621 | 322 | : input_cb_setup_fence(input_cb_setup_fence) | ||
622 | 323 | { | ||
623 | 324 | } | ||
624 | 325 | |||
625 | 326 | void inject_input() | ||
626 | 327 | { | ||
627 | 328 | wait_until_client_appears(test_client_name); | ||
628 | 329 | input_cb_setup_fence.wait_for_signal_ready_for(); | ||
629 | 330 | |||
630 | 331 | for (int i = 0; i < num_events_produced; i++) | ||
631 | 332 | fake_event_hub->synthesize_event(mis::a_key_down_event() | ||
632 | 333 | .of_scancode(KEY_ENTER)); | ||
633 | 334 | } | ||
634 | 335 | } server_config(fence); | ||
635 | 336 | launch_server_process(server_config); | ||
636 | 337 | |||
637 | 338 | struct KeyReceivingClient : InputClient | ||
638 | 339 | { | ||
639 | 340 | KeyReceivingClient(const mtf::CrossProcessSync& fence) : InputClient(fence, test_client_name) {} | ||
640 | 341 | void expect_input(mt::WaitCondition& events_received) override | ||
641 | 342 | { | ||
642 | 343 | using namespace ::testing; | ||
643 | 344 | InSequence seq; | ||
644 | 345 | |||
645 | 346 | EXPECT_CALL(*handler, handle_input(KeyDownEvent())).Times(2); | ||
646 | 347 | EXPECT_CALL(*handler, handle_input(KeyDownEvent())).Times(1) | ||
647 | 348 | .WillOnce(mt::WakeUp(&events_received)); | ||
648 | 349 | } | ||
649 | 350 | } client_config(fence); | ||
650 | 351 | launch_client_process(client_config); | ||
651 | 352 | } | ||
652 | 353 | |||
653 | 354 | TEST_F(TestClientInput, clients_receive_us_english_mapped_keys) | ||
654 | 355 | { | ||
655 | 356 | using namespace ::testing; | ||
656 | 357 | static std::string const test_client_name = "1"; | ||
657 | 358 | mtf::CrossProcessSync fence; | ||
658 | 359 | |||
659 | 360 | struct ServerConfiguration : mtf::InputTestingServerConfiguration | ||
660 | 361 | { | ||
661 | 362 | mtf::CrossProcessSync input_cb_setup_fence; | ||
662 | 363 | |||
663 | 364 | ServerConfiguration(const mtf::CrossProcessSync& input_cb_setup_fence) | ||
664 | 365 | : input_cb_setup_fence(input_cb_setup_fence) | ||
665 | 366 | { | ||
666 | 367 | } | ||
667 | 368 | |||
668 | 369 | void inject_input() | ||
669 | 370 | { | ||
670 | 371 | wait_until_client_appears(test_client_name); | ||
671 | 372 | input_cb_setup_fence.wait_for_signal_ready_for(); | ||
672 | 373 | |||
673 | 374 | fake_event_hub->synthesize_event(mis::a_key_down_event() | ||
674 | 375 | .of_scancode(KEY_LEFTSHIFT)); | ||
675 | 376 | fake_event_hub->synthesize_event(mis::a_key_down_event() | ||
676 | 377 | .of_scancode(KEY_4)); | ||
677 | 378 | |||
678 | 379 | } | ||
679 | 380 | } server_config{fence}; | ||
680 | 381 | launch_server_process(server_config); | ||
681 | 382 | |||
682 | 383 | struct KeyReceivingClient : InputClient | ||
683 | 384 | { | ||
684 | 385 | KeyReceivingClient(const mtf::CrossProcessSync& fence) : InputClient(fence, test_client_name) {} | ||
685 | 386 | |||
686 | 387 | void expect_input(mt::WaitCondition& events_received) override | ||
687 | 388 | { | ||
688 | 389 | using namespace ::testing; | ||
689 | 390 | |||
690 | 391 | InSequence seq; | ||
691 | 392 | EXPECT_CALL(*handler, handle_input(AllOf(KeyDownEvent(), KeyOfSymbol(XKB_KEY_Shift_L)))).Times(1); | ||
692 | 393 | EXPECT_CALL(*handler, handle_input(AllOf(KeyDownEvent(), KeyOfSymbol(XKB_KEY_dollar)))).Times(1) | ||
693 | 394 | .WillOnce(mt::WakeUp(&events_received)); | ||
694 | 395 | } | ||
695 | 396 | } client_config{fence}; | ||
696 | 397 | launch_client_process(client_config); | ||
697 | 398 | } | ||
698 | 399 | |||
699 | 400 | TEST_F(TestClientInput, clients_receive_motion_inside_window) | ||
700 | 401 | { | ||
701 | 402 | using namespace ::testing; | ||
702 | 403 | static std::string const test_client_name = "1"; | ||
703 | 404 | mtf::CrossProcessSync fence; | ||
704 | 405 | |||
705 | 406 | struct ServerConfiguration : public mtf::InputTestingServerConfiguration | ||
706 | 407 | { | ||
707 | 408 | mtf::CrossProcessSync input_cb_setup_fence; | ||
708 | 409 | |||
709 | 410 | ServerConfiguration(const mtf::CrossProcessSync& input_cb_setup_fence) | ||
710 | 411 | : input_cb_setup_fence(input_cb_setup_fence) | ||
711 | 412 | { | ||
712 | 413 | } | ||
713 | 414 | |||
714 | 415 | void inject_input() | ||
715 | 416 | { | ||
716 | 417 | wait_until_client_appears(test_client_name); | ||
717 | 418 | input_cb_setup_fence.wait_for_signal_ready_for(); | ||
718 | 419 | |||
719 | 420 | fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(InputClient::surface_width - 1, | ||
720 | 421 | InputClient::surface_height - 1)); | ||
721 | 422 | fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(2,2)); | ||
722 | 423 | } | ||
723 | 424 | } server_config{fence}; | ||
724 | 425 | launch_server_process(server_config); | ||
725 | 426 | |||
726 | 427 | struct MotionReceivingClient : InputClient | ||
727 | 428 | { | ||
728 | 429 | MotionReceivingClient(const mtf::CrossProcessSync& fence) : InputClient(fence, test_client_name) {} | ||
729 | 430 | |||
730 | 431 | void expect_input(mt::WaitCondition& events_received) override | ||
731 | 432 | { | ||
732 | 433 | using namespace ::testing; | ||
733 | 434 | |||
734 | 435 | InSequence seq; | ||
735 | 436 | |||
736 | 437 | // We should see the cursor enter | ||
737 | 438 | EXPECT_CALL(*handler, handle_input(HoverEnterEvent())).Times(1); | ||
738 | 439 | EXPECT_CALL(*handler, handle_input( | ||
739 | 440 | MotionEventWithPosition(InputClient::surface_width - 1, | ||
740 | 441 | InputClient::surface_height - 1))).Times(1) | ||
741 | 442 | .WillOnce(mt::WakeUp(&events_received)); | ||
742 | 443 | // But we should not receive an event for the second movement outside of our surface! | ||
743 | 444 | } | ||
744 | 445 | } client_config{fence}; | ||
745 | 446 | launch_client_process(client_config); | ||
746 | 447 | } | ||
747 | 448 | |||
748 | 449 | TEST_F(TestClientInput, clients_receive_button_events_inside_window) | ||
749 | 450 | { | ||
750 | 451 | using namespace ::testing; | ||
751 | 452 | |||
752 | 453 | static std::string const test_client_name = "1"; | ||
753 | 454 | mtf::CrossProcessSync fence; | ||
754 | 455 | |||
755 | 456 | struct ServerConfiguration : public mtf::InputTestingServerConfiguration | ||
756 | 457 | { | ||
757 | 458 | mtf::CrossProcessSync input_cb_setup_fence; | ||
758 | 459 | |||
759 | 460 | ServerConfiguration(const mtf::CrossProcessSync& input_cb_setup_fence) | ||
760 | 461 | : input_cb_setup_fence(input_cb_setup_fence) | ||
761 | 462 | { | ||
762 | 463 | } | ||
763 | 464 | |||
764 | 465 | void inject_input() | ||
765 | 466 | { | ||
766 | 467 | wait_until_client_appears(test_client_name); | ||
767 | 468 | input_cb_setup_fence.wait_for_signal_ready_for(); | ||
768 | 469 | |||
769 | 470 | fake_event_hub->synthesize_event(mis::a_button_down_event().of_button(BTN_LEFT).with_action(mis::EventAction::Down)); | ||
770 | 471 | } | ||
771 | 472 | } server_config{fence}; | ||
772 | 473 | launch_server_process(server_config); | ||
773 | 474 | |||
774 | 475 | struct ButtonReceivingClient : InputClient | ||
775 | 476 | { | ||
776 | 477 | ButtonReceivingClient(const mtf::CrossProcessSync& fence) : InputClient(fence, test_client_name) {} | ||
777 | 478 | |||
778 | 479 | void expect_input(mt::WaitCondition& events_received) override | ||
779 | 480 | { | ||
780 | 481 | using namespace ::testing; | ||
781 | 482 | |||
782 | 483 | InSequence seq; | ||
783 | 484 | |||
784 | 485 | // The cursor starts at (0, 0). | ||
785 | 486 | EXPECT_CALL(*handler, handle_input(ButtonDownEvent(0, 0))).Times(1) | ||
786 | 487 | .WillOnce(mt::WakeUp(&events_received)); | ||
787 | 488 | } | ||
788 | 489 | } client_config{fence}; | ||
789 | 490 | launch_client_process(client_config); | ||
790 | 491 | } | ||
791 | 492 | |||
792 | 493 | namespace | 315 | namespace |
793 | 494 | { | 316 | { |
794 | 495 | typedef std::map<std::string, geom::Rectangle> GeometryMap; | 317 | typedef std::map<std::string, geom::Rectangle> GeometryMap; |
795 | @@ -497,34 +319,251 @@ | |||
796 | 497 | 319 | ||
797 | 498 | struct StaticPlacementStrategy : public msh::PlacementStrategy | 320 | struct StaticPlacementStrategy : public msh::PlacementStrategy |
798 | 499 | { | 321 | { |
800 | 500 | StaticPlacementStrategy(GeometryMap const& positions, | 322 | StaticPlacementStrategy(std::shared_ptr<msh::PlacementStrategy> const& underlying_strategy, |
801 | 323 | GeometryMap const& positions, | ||
802 | 501 | DepthMap const& depths) | 324 | DepthMap const& depths) |
804 | 502 | : surface_geometry_by_name(positions), | 325 | : underlying_strategy(underlying_strategy), |
805 | 326 | surface_geometry_by_name(positions), | ||
806 | 503 | surface_depths_by_name(depths) | 327 | surface_depths_by_name(depths) |
807 | 504 | { | 328 | { |
808 | 505 | } | 329 | } |
809 | 506 | 330 | ||
812 | 507 | StaticPlacementStrategy(GeometryMap const& positions) | 331 | StaticPlacementStrategy(std::shared_ptr<msh::PlacementStrategy> const& underlying_strategy, |
813 | 508 | : StaticPlacementStrategy(positions, DepthMap()) | 332 | GeometryMap const& positions) |
814 | 333 | : StaticPlacementStrategy(underlying_strategy, positions, DepthMap()) | ||
815 | 509 | { | 334 | { |
816 | 510 | } | 335 | } |
817 | 511 | 336 | ||
819 | 512 | msh::SurfaceCreationParameters place(msh::Session const&, msh::SurfaceCreationParameters const& request_parameters) | 337 | msh::SurfaceCreationParameters place(msh::Session const& session, msh::SurfaceCreationParameters const& request_parameters) |
820 | 513 | { | 338 | { |
821 | 514 | auto placed = request_parameters; | 339 | auto placed = request_parameters; |
822 | 515 | auto const& name = request_parameters.name; | 340 | auto const& name = request_parameters.name; |
827 | 516 | auto geometry = surface_geometry_by_name[name]; | 341 | |
828 | 517 | 342 | auto it = surface_geometry_by_name.find(name); | |
829 | 518 | placed.top_left = geometry.top_left; | 343 | if (it != surface_geometry_by_name.end()) |
830 | 519 | placed.size = geometry.size; | 344 | { |
831 | 345 | auto const& geometry = it->second; | ||
832 | 346 | placed.top_left = geometry.top_left; | ||
833 | 347 | placed.size = geometry.size; | ||
834 | 348 | } | ||
835 | 349 | else | ||
836 | 350 | { | ||
837 | 351 | placed = underlying_strategy->place(session, placed); | ||
838 | 352 | } | ||
839 | 520 | placed.depth = surface_depths_by_name[name]; | 353 | placed.depth = surface_depths_by_name[name]; |
840 | 521 | 354 | ||
841 | 522 | return placed; | 355 | return placed; |
842 | 523 | } | 356 | } |
843 | 357 | |||
844 | 358 | std::shared_ptr<msh::PlacementStrategy> const underlying_strategy; | ||
845 | 524 | GeometryMap surface_geometry_by_name; | 359 | GeometryMap surface_geometry_by_name; |
846 | 525 | DepthMap surface_depths_by_name; | 360 | DepthMap surface_depths_by_name; |
847 | 526 | }; | 361 | }; |
848 | 527 | 362 | ||
849 | 363 | std::shared_ptr<mtf::InputTestingServerConfiguration> | ||
850 | 364 | make_event_producing_server(mtf::CrossProcessSync const& client_ready_fence, | ||
851 | 365 | int number_of_clients, | ||
852 | 366 | std::function<void(mtf::InputTestingServerConfiguration& server)> const& produce_events, | ||
853 | 367 | GeometryMap const& client_geometry_map, DepthMap const& client_depth_map) | ||
854 | 368 | { | ||
855 | 369 | struct ServerConfiguration : mtf::InputTestingServerConfiguration | ||
856 | 370 | { | ||
857 | 371 | mtf::CrossProcessSync input_cb_setup_fence; | ||
858 | 372 | int const number_of_clients; | ||
859 | 373 | std::function<void(mtf::InputTestingServerConfiguration& server)> const produce_events; | ||
860 | 374 | GeometryMap const client_geometry; | ||
861 | 375 | DepthMap const client_depth; | ||
862 | 376 | |||
863 | 377 | ServerConfiguration(mtf::CrossProcessSync const& input_cb_setup_fence, int number_of_clients, | ||
864 | 378 | std::function<void(mtf::InputTestingServerConfiguration& server)> const& produce_events, | ||
865 | 379 | GeometryMap const& client_geometry, DepthMap const& client_depth) | ||
866 | 380 | : input_cb_setup_fence(input_cb_setup_fence), | ||
867 | 381 | number_of_clients(number_of_clients), | ||
868 | 382 | produce_events(produce_events), | ||
869 | 383 | client_geometry(client_geometry), | ||
870 | 384 | client_depth(client_depth) | ||
871 | 385 | { | ||
872 | 386 | } | ||
873 | 387 | |||
874 | 388 | std::shared_ptr<msh::PlacementStrategy> the_shell_placement_strategy() override | ||
875 | 389 | { | ||
876 | 390 | return std::make_shared<StaticPlacementStrategy>(InputTestingServerConfiguration::the_shell_placement_strategy(), | ||
877 | 391 | client_geometry, client_depth); | ||
878 | 392 | } | ||
879 | 393 | |||
880 | 394 | void inject_input() | ||
881 | 395 | { | ||
882 | 396 | for (int i = 1; i < number_of_clients + 1; i++) | ||
883 | 397 | EXPECT_EQ(i, input_cb_setup_fence.wait_for_signal_ready_for()); | ||
884 | 398 | produce_events(*this); | ||
885 | 399 | } | ||
886 | 400 | }; | ||
887 | 401 | return std::make_shared<ServerConfiguration>(client_ready_fence, number_of_clients, | ||
888 | 402 | produce_events, client_geometry_map, client_depth_map); | ||
889 | 403 | } | ||
890 | 404 | |||
891 | 405 | std::shared_ptr<mtf::InputTestingServerConfiguration> | ||
892 | 406 | make_event_producing_server(mtf::CrossProcessSync const& client_ready_fence, int number_of_clients, | ||
893 | 407 | std::function<void(mtf::InputTestingServerConfiguration& server)> const& produce_events) | ||
894 | 408 | { | ||
895 | 409 | return make_event_producing_server(client_ready_fence, number_of_clients, | ||
896 | 410 | produce_events, GeometryMap(), DepthMap()); | ||
897 | 411 | } | ||
898 | 412 | |||
899 | 413 | std::shared_ptr<InputClient> | ||
900 | 414 | make_event_expecting_client(std::string const& client_name, mtf::CrossProcessSync const& client_ready_fence, | ||
901 | 415 | std::function<void(MockInputHandler &, mt::WaitCondition&)> const& expect_input) | ||
902 | 416 | { | ||
903 | 417 | struct EventReceivingClient : InputClient | ||
904 | 418 | { | ||
905 | 419 | std::function<void(MockInputHandler&, mt::WaitCondition&)> const expect_cb; | ||
906 | 420 | |||
907 | 421 | EventReceivingClient(mtf::CrossProcessSync const& client_ready_fence, std::string const& client_name, | ||
908 | 422 | std::function<void(MockInputHandler&, mt::WaitCondition&)> const& expect_cb) | ||
909 | 423 | : InputClient(client_ready_fence, client_name), | ||
910 | 424 | expect_cb(expect_cb) | ||
911 | 425 | { | ||
912 | 426 | } | ||
913 | 427 | void expect_input(mt::WaitCondition& events_received) override | ||
914 | 428 | { | ||
915 | 429 | expect_cb(*handler, events_received); | ||
916 | 430 | } | ||
917 | 431 | }; | ||
918 | 432 | return std::make_shared<EventReceivingClient>(client_ready_fence, client_name, expect_input); | ||
919 | 433 | } | ||
920 | 434 | |||
921 | 435 | std::shared_ptr<InputClient> | ||
922 | 436 | make_event_expecting_client(mtf::CrossProcessSync const& client_ready_fence, | ||
923 | 437 | std::function<void(MockInputHandler &, mt::WaitCondition&)> const& expect_input) | ||
924 | 438 | { | ||
925 | 439 | return make_event_expecting_client("input-test-client", client_ready_fence, expect_input); | ||
926 | 440 | } | ||
927 | 441 | |||
928 | 442 | } | ||
929 | 443 | |||
930 | 444 | |||
931 | 445 | using TestClientInput = BespokeDisplayServerTestFixture; | ||
932 | 446 | |||
933 | 447 | TEST_F(TestClientInput, clients_receive_key_input) | ||
934 | 448 | { | ||
935 | 449 | using namespace ::testing; | ||
936 | 450 | |||
937 | 451 | static std::string const test_client_name = "1"; | ||
938 | 452 | |||
939 | 453 | mtf::CrossProcessSync fence; | ||
940 | 454 | |||
941 | 455 | auto server_config = make_event_producing_server(fence, 1, | ||
942 | 456 | [&](mtf::InputTestingServerConfiguration& server) | ||
943 | 457 | { | ||
944 | 458 | int const num_events_produced = 3; | ||
945 | 459 | |||
946 | 460 | for (int i = 0; i < num_events_produced; i++) | ||
947 | 461 | server.fake_event_hub->synthesize_event(mis::a_key_down_event() | ||
948 | 462 | .of_scancode(KEY_ENTER)); | ||
949 | 463 | }); | ||
950 | 464 | launch_server_process(*server_config); | ||
951 | 465 | |||
952 | 466 | auto client_config = make_event_expecting_client(fence, | ||
953 | 467 | [&](MockInputHandler& handler, mt::WaitCondition& events_received) | ||
954 | 468 | { | ||
955 | 469 | using namespace ::testing; | ||
956 | 470 | InSequence seq; | ||
957 | 471 | |||
958 | 472 | EXPECT_CALL(handler, handle_input(KeyDownEvent())).Times(2); | ||
959 | 473 | EXPECT_CALL(handler, handle_input(KeyDownEvent())).Times(1) | ||
960 | 474 | .WillOnce(mt::WakeUp(&events_received)); | ||
961 | 475 | |||
962 | 476 | }); | ||
963 | 477 | launch_client_process(*client_config); | ||
964 | 478 | } | ||
965 | 479 | |||
966 | 480 | TEST_F(TestClientInput, clients_receive_us_english_mapped_keys) | ||
967 | 481 | { | ||
968 | 482 | using namespace ::testing; | ||
969 | 483 | static std::string const test_client_name = "1"; | ||
970 | 484 | mtf::CrossProcessSync fence; | ||
971 | 485 | |||
972 | 486 | auto server_config = make_event_producing_server(fence, 1, | ||
973 | 487 | [&](mtf::InputTestingServerConfiguration& server) | ||
974 | 488 | { | ||
975 | 489 | server.fake_event_hub->synthesize_event(mis::a_key_down_event() | ||
976 | 490 | .of_scancode(KEY_LEFTSHIFT)); | ||
977 | 491 | server.fake_event_hub->synthesize_event(mis::a_key_down_event() | ||
978 | 492 | .of_scancode(KEY_4)); | ||
979 | 493 | }); | ||
980 | 494 | launch_server_process(*server_config); | ||
981 | 495 | |||
982 | 496 | auto client_config = make_event_expecting_client(fence, | ||
983 | 497 | [&](MockInputHandler& handler, mt::WaitCondition& events_received) | ||
984 | 498 | { | ||
985 | 499 | using namespace ::testing; | ||
986 | 500 | InSequence seq; | ||
987 | 501 | |||
988 | 502 | EXPECT_CALL(handler, handle_input(AllOf(KeyDownEvent(), KeyOfSymbol(XKB_KEY_Shift_L)))).Times(1); | ||
989 | 503 | EXPECT_CALL(handler, handle_input(AllOf(KeyDownEvent(), KeyOfSymbol(XKB_KEY_dollar)))).Times(1) | ||
990 | 504 | .WillOnce(mt::WakeUp(&events_received)); | ||
991 | 505 | }); | ||
992 | 506 | launch_client_process(*client_config); | ||
993 | 507 | } | ||
994 | 508 | |||
995 | 509 | TEST_F(TestClientInput, clients_receive_motion_inside_window) | ||
996 | 510 | { | ||
997 | 511 | using namespace ::testing; | ||
998 | 512 | static std::string const test_client_name = "1"; | ||
999 | 513 | mtf::CrossProcessSync fence; | ||
1000 | 514 | |||
1001 | 515 | auto server_config = make_event_producing_server(fence, 1, | ||
1002 | 516 | [&](mtf::InputTestingServerConfiguration& server) | ||
1003 | 517 | { | ||
1004 | 518 | server.fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(InputClient::surface_width - 1, | ||
1005 | 519 | InputClient::surface_height - 1)); | ||
1006 | 520 | server.fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(2,2)); | ||
1007 | 521 | }); | ||
1008 | 522 | launch_server_process(*server_config); | ||
1009 | 523 | |||
1010 | 524 | auto client_config = make_event_expecting_client(fence, | ||
1011 | 525 | [&](MockInputHandler& handler, mt::WaitCondition& events_received) | ||
1012 | 526 | { | ||
1013 | 527 | using namespace ::testing; | ||
1014 | 528 | InSequence seq; | ||
1015 | 529 | |||
1016 | 530 | // We should see the cursor enter | ||
1017 | 531 | EXPECT_CALL(handler, handle_input(HoverEnterEvent())).Times(1); | ||
1018 | 532 | EXPECT_CALL(handler, handle_input( | ||
1019 | 533 | MotionEventWithPosition(InputClient::surface_width - 1, | ||
1020 | 534 | InputClient::surface_height - 1))).Times(1) | ||
1021 | 535 | .WillOnce(mt::WakeUp(&events_received)); | ||
1022 | 536 | // But we should not receive an event for the second movement outside of our surface! | ||
1023 | 537 | }); | ||
1024 | 538 | launch_client_process(*client_config); | ||
1025 | 539 | } | ||
1026 | 540 | |||
1027 | 541 | TEST_F(TestClientInput, clients_receive_button_events_inside_window) | ||
1028 | 542 | { | ||
1029 | 543 | using namespace ::testing; | ||
1030 | 544 | |||
1031 | 545 | static std::string const test_client_name = "1"; | ||
1032 | 546 | mtf::CrossProcessSync fence; | ||
1033 | 547 | |||
1034 | 548 | auto server_config = make_event_producing_server(fence, 1, | ||
1035 | 549 | [&](mtf::InputTestingServerConfiguration& server) | ||
1036 | 550 | { | ||
1037 | 551 | server.fake_event_hub->synthesize_event(mis::a_button_down_event() | ||
1038 | 552 | .of_button(BTN_LEFT).with_action(mis::EventAction::Down)); | ||
1039 | 553 | }); | ||
1040 | 554 | launch_server_process(*server_config); | ||
1041 | 555 | |||
1042 | 556 | auto client_config = make_event_expecting_client(fence, | ||
1043 | 557 | [&](MockInputHandler& handler, mt::WaitCondition& events_received) | ||
1044 | 558 | { | ||
1045 | 559 | using namespace ::testing; | ||
1046 | 560 | InSequence seq; | ||
1047 | 561 | |||
1048 | 562 | // The cursor starts at (0, 0). | ||
1049 | 563 | EXPECT_CALL(handler, handle_input(ButtonDownEvent(0, 0))).Times(1) | ||
1050 | 564 | .WillOnce(mt::WakeUp(&events_received)); | ||
1051 | 565 | }); | ||
1052 | 566 | launch_client_process(*client_config); | ||
1053 | 528 | } | 567 | } |
1054 | 529 | 568 | ||
1055 | 530 | TEST_F(TestClientInput, multiple_clients_receive_motion_inside_windows) | 569 | TEST_F(TestClientInput, multiple_clients_receive_motion_inside_windows) |
1056 | @@ -539,77 +578,42 @@ | |||
1057 | 539 | static std::string const test_client_2 = "2"; | 578 | static std::string const test_client_2 = "2"; |
1058 | 540 | mtf::CrossProcessSync fence; | 579 | mtf::CrossProcessSync fence; |
1059 | 541 | 580 | ||
1087 | 542 | struct ServerConfiguration : mtf::InputTestingServerConfiguration | 581 | static GeometryMap positions; |
1088 | 543 | { | 582 | positions[test_client_1] = geom::Rectangle{geom::Point{0, 0}, |
1089 | 544 | mtf::CrossProcessSync input_cb_setup_fence; | 583 | geom::Size{client_width, client_height}}; |
1090 | 545 | 584 | positions[test_client_2] = geom::Rectangle{geom::Point{screen_width/2, screen_height/2}, | |
1091 | 546 | ServerConfiguration(const mtf::CrossProcessSync& input_cb_setup_fence) | 585 | geom::Size{client_width, client_height}}; |
1092 | 547 | : input_cb_setup_fence(input_cb_setup_fence) | 586 | |
1093 | 548 | { | 587 | auto server_config = make_event_producing_server(fence, 2, |
1094 | 549 | } | 588 | [&](mtf::InputTestingServerConfiguration& server) |
1095 | 550 | 589 | { | |
1069 | 551 | std::shared_ptr<msh::PlacementStrategy> the_shell_placement_strategy() override | ||
1070 | 552 | { | ||
1071 | 553 | static GeometryMap positions; | ||
1072 | 554 | positions[test_client_1] = geom::Rectangle{geom::Point{0, 0}, | ||
1073 | 555 | geom::Size{client_width, client_height}}; | ||
1074 | 556 | positions[test_client_2] = geom::Rectangle{geom::Point{screen_width/2, screen_height/2}, | ||
1075 | 557 | geom::Size{client_width, client_height}}; | ||
1076 | 558 | |||
1077 | 559 | return std::make_shared<StaticPlacementStrategy>(positions); | ||
1078 | 560 | } | ||
1079 | 561 | |||
1080 | 562 | void inject_input() override | ||
1081 | 563 | { | ||
1082 | 564 | wait_until_client_appears(test_client_1); | ||
1083 | 565 | EXPECT_EQ(1, input_cb_setup_fence.wait_for_signal_ready_for()); | ||
1084 | 566 | wait_until_client_appears(test_client_2); | ||
1085 | 567 | EXPECT_EQ(2, input_cb_setup_fence.wait_for_signal_ready_for()); | ||
1086 | 568 | |||
1096 | 569 | // In the bounds of the first surface | 590 | // In the bounds of the first surface |
1098 | 570 | fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(screen_width/2-1, screen_height/2-1)); | 591 | server.fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(screen_width/2-1, screen_height/2-1)); |
1099 | 571 | // In the bounds of the second surface | 592 | // In the bounds of the second surface |
1141 | 572 | fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(screen_width/2, screen_height/2)); | 593 | server.fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(screen_width/2, screen_height/2)); |
1142 | 573 | } | 594 | }, positions, DepthMap()); |
1143 | 574 | } server_config{fence}; | 595 | launch_server_process(*server_config); |
1144 | 575 | 596 | ||
1145 | 576 | launch_server_process(server_config); | 597 | auto client_1 = make_event_expecting_client(test_client_1, fence, |
1146 | 577 | 598 | [&](MockInputHandler& handler, mt::WaitCondition& events_received) | |
1147 | 578 | struct InputClientOne : InputClient | 599 | { |
1148 | 579 | { | 600 | InSequence seq; |
1149 | 580 | InputClientOne(const mtf::CrossProcessSync& fence) | 601 | EXPECT_CALL(handler, handle_input(HoverEnterEvent())).Times(1); |
1150 | 581 | : InputClient(fence, test_client_1) | 602 | EXPECT_CALL(handler, handle_input(MotionEventWithPosition(client_width - 1, client_height - 1))).Times(1); |
1151 | 582 | { | 603 | EXPECT_CALL(handler, handle_input(HoverExitEvent())).Times(1) |
1152 | 583 | } | 604 | .WillOnce(mt::WakeUp(&events_received)); |
1153 | 584 | 605 | }); | |
1154 | 585 | void expect_input(mt::WaitCondition& events_received) override | 606 | auto client_2 = make_event_expecting_client(test_client_2, fence, |
1155 | 586 | { | 607 | [&](MockInputHandler& handler, mt::WaitCondition& events_received) |
1156 | 587 | InSequence seq; | 608 | { |
1157 | 588 | EXPECT_CALL(*handler, handle_input(HoverEnterEvent())).Times(1); | 609 | InSequence seq; |
1158 | 589 | EXPECT_CALL(*handler, handle_input(MotionEventWithPosition(client_width - 1, client_height - 1))).Times(1); | 610 | EXPECT_CALL(handler, handle_input(HoverEnterEvent())).Times(1); |
1159 | 590 | EXPECT_CALL(*handler, handle_input(HoverExitEvent())).Times(1) | 611 | EXPECT_CALL(handler, handle_input(MotionEventWithPosition(client_width - 1, client_height - 1))).Times(1) |
1160 | 591 | .WillOnce(mt::WakeUp(&events_received)); | 612 | .WillOnce(mt::WakeUp(&events_received)); |
1161 | 592 | } | 613 | }); |
1162 | 593 | } client_1{fence}; | 614 | |
1163 | 594 | 615 | launch_client_process(*client_1); | |
1164 | 595 | struct InputClientTwo : InputClient | 616 | launch_client_process(*client_2); |
1124 | 596 | { | ||
1125 | 597 | InputClientTwo(const mtf::CrossProcessSync& fence) | ||
1126 | 598 | : InputClient(fence, test_client_2) | ||
1127 | 599 | { | ||
1128 | 600 | } | ||
1129 | 601 | |||
1130 | 602 | void expect_input(mt::WaitCondition& events_received) override | ||
1131 | 603 | { | ||
1132 | 604 | InSequence seq; | ||
1133 | 605 | EXPECT_CALL(*handler, handle_input(HoverEnterEvent())).Times(1); | ||
1134 | 606 | EXPECT_CALL(*handler, handle_input(MotionEventWithPosition(client_width - 1, client_height - 1))).Times(1) | ||
1135 | 607 | .WillOnce(mt::WakeUp(&events_received)); | ||
1136 | 608 | } | ||
1137 | 609 | } client_2{fence}; | ||
1138 | 610 | |||
1139 | 611 | launch_client_process(client_1); | ||
1140 | 612 | launch_client_process(client_2); | ||
1165 | 613 | } | 617 | } |
1166 | 614 | 618 | ||
1167 | 615 | namespace | 619 | namespace |
1168 | @@ -639,6 +643,7 @@ | |||
1169 | 639 | std::vector<geom::Rectangle> const input_rectangles; | 643 | std::vector<geom::Rectangle> const input_rectangles; |
1170 | 640 | }; | 644 | }; |
1171 | 641 | } | 645 | } |
1172 | 646 | |||
1173 | 642 | TEST_F(TestClientInput, clients_do_not_receive_motion_outside_input_region) | 647 | TEST_F(TestClientInput, clients_do_not_receive_motion_outside_input_region) |
1174 | 643 | { | 648 | { |
1175 | 644 | using namespace ::testing; | 649 | using namespace ::testing; |
1176 | @@ -670,7 +675,7 @@ | |||
1177 | 670 | static GeometryMap positions; | 675 | static GeometryMap positions; |
1178 | 671 | positions[test_client_name] = screen_geometry; | 676 | positions[test_client_name] = screen_geometry; |
1179 | 672 | 677 | ||
1181 | 673 | return std::make_shared<StaticPlacementStrategy>(positions); | 678 | return std::make_shared<StaticPlacementStrategy>(InputTestingServerConfiguration::the_shell_placement_strategy(), positions); |
1182 | 674 | } | 679 | } |
1183 | 675 | std::shared_ptr<msh::SurfaceFactory> the_shell_surface_factory() override | 680 | std::shared_ptr<msh::SurfaceFactory> the_shell_surface_factory() override |
1184 | 676 | { | 681 | { |
1185 | @@ -697,35 +702,26 @@ | |||
1186 | 697 | fake_event_hub->synthesize_event(mis::a_button_up_event().of_button(BTN_LEFT)); | 702 | fake_event_hub->synthesize_event(mis::a_button_up_event().of_button(BTN_LEFT)); |
1187 | 698 | } | 703 | } |
1188 | 699 | } server_config{fence}; | 704 | } server_config{fence}; |
1189 | 700 | |||
1190 | 701 | launch_server_process(server_config); | 705 | launch_server_process(server_config); |
1191 | 702 | 706 | ||
1205 | 703 | struct ClientConfig : InputClient | 707 | auto client_config = make_event_expecting_client(test_client_name, fence, |
1206 | 704 | { | 708 | [&](MockInputHandler& handler, mt::WaitCondition& events_received) |
1207 | 705 | ClientConfig(const mtf::CrossProcessSync& fence) | 709 | { |
1208 | 706 | : InputClient(fence, test_client_name) | 710 | EXPECT_CALL(handler, handle_input(HoverEnterEvent())).Times(AnyNumber()); |
1209 | 707 | { | 711 | EXPECT_CALL(handler, handle_input(HoverExitEvent())).Times(AnyNumber()); |
1210 | 708 | } | 712 | EXPECT_CALL(handler, handle_input(MovementEvent())).Times(AnyNumber()); |
1198 | 709 | |||
1199 | 710 | void expect_input(mt::WaitCondition& events_received) override | ||
1200 | 711 | { | ||
1201 | 712 | |||
1202 | 713 | EXPECT_CALL(*handler, handle_input(HoverEnterEvent())).Times(AnyNumber()); | ||
1203 | 714 | EXPECT_CALL(*handler, handle_input(HoverExitEvent())).Times(AnyNumber()); | ||
1204 | 715 | EXPECT_CALL(*handler, handle_input(MovementEvent())).Times(AnyNumber()); | ||
1211 | 716 | 713 | ||
1212 | 717 | { | 714 | { |
1213 | 718 | // We should see two of the three button pairs. | 715 | // We should see two of the three button pairs. |
1214 | 719 | InSequence seq; | 716 | InSequence seq; |
1219 | 720 | EXPECT_CALL(*handler, handle_input(ButtonDownEvent(1, 1))).Times(1); | 717 | EXPECT_CALL(handler, handle_input(ButtonDownEvent(1, 1))).Times(1); |
1220 | 721 | EXPECT_CALL(*handler, handle_input(ButtonUpEvent(1, 1))).Times(1); | 718 | EXPECT_CALL(handler, handle_input(ButtonUpEvent(1, 1))).Times(1); |
1221 | 722 | EXPECT_CALL(*handler, handle_input(ButtonDownEvent(99, 99))).Times(1); | 719 | EXPECT_CALL(handler, handle_input(ButtonDownEvent(99, 99))).Times(1); |
1222 | 723 | EXPECT_CALL(*handler, handle_input(ButtonUpEvent(99, 99))).Times(1) | 720 | EXPECT_CALL(handler, handle_input(ButtonUpEvent(99, 99))).Times(1) |
1223 | 724 | .WillOnce(mt::WakeUp(&events_received)); | 721 | .WillOnce(mt::WakeUp(&events_received)); |
1224 | 725 | } | 722 | } |
1228 | 726 | } | 723 | }); |
1229 | 727 | } client_config{fence}; | 724 | launch_client_process(*client_config); |
1227 | 728 | launch_client_process(client_config); | ||
1230 | 729 | } | 725 | } |
1231 | 730 | 726 | ||
1232 | 731 | TEST_F(TestClientInput, surfaces_obscure_motion_events_by_stacking) | 727 | TEST_F(TestClientInput, surfaces_obscure_motion_events_by_stacking) |
1233 | @@ -742,98 +738,62 @@ | |||
1234 | 742 | static geom::Rectangle const screen_geometry{geom::Point{0, 0}, | 738 | static geom::Rectangle const screen_geometry{geom::Point{0, 0}, |
1235 | 743 | geom::Size{screen_width, screen_height}}; | 739 | geom::Size{screen_width, screen_height}}; |
1236 | 744 | 740 | ||
1269 | 745 | struct ServerConfiguration : mtf::InputTestingServerConfiguration | 741 | static GeometryMap positions; |
1270 | 746 | { | 742 | positions[test_client_name_1] = screen_geometry; |
1271 | 747 | mtf::CrossProcessSync input_cb_setup_fence; | 743 | |
1272 | 748 | 744 | auto smaller_geometry = screen_geometry; | |
1273 | 749 | ServerConfiguration(const mtf::CrossProcessSync& input_cb_setup_fence) | 745 | smaller_geometry.size.width = geom::Width{screen_width/2}; |
1274 | 750 | : input_cb_setup_fence(input_cb_setup_fence) | 746 | positions[test_client_name_2] = smaller_geometry; |
1275 | 751 | { | 747 | |
1276 | 752 | } | 748 | static DepthMap depths; |
1277 | 753 | 749 | depths[test_client_name_1] = ms::DepthId{0}; | |
1278 | 754 | std::shared_ptr<msh::PlacementStrategy> the_shell_placement_strategy() override | 750 | depths[test_client_name_2] = ms::DepthId{1}; |
1279 | 755 | { | 751 | |
1280 | 756 | static GeometryMap positions; | 752 | auto server_config = make_event_producing_server(fence, 2, |
1281 | 757 | positions[test_client_name_1] = screen_geometry; | 753 | [&](mtf::InputTestingServerConfiguration& server) |
1282 | 758 | 754 | { | |
1251 | 759 | auto smaller_geometry = screen_geometry; | ||
1252 | 760 | smaller_geometry.size.width = geom::Width{screen_width/2}; | ||
1253 | 761 | positions[test_client_name_2] = smaller_geometry; | ||
1254 | 762 | |||
1255 | 763 | static DepthMap depths; | ||
1256 | 764 | depths[test_client_name_1] = ms::DepthId{0}; | ||
1257 | 765 | depths[test_client_name_2] = ms::DepthId{1}; | ||
1258 | 766 | |||
1259 | 767 | return std::make_shared<StaticPlacementStrategy>(positions, depths); | ||
1260 | 768 | } | ||
1261 | 769 | |||
1262 | 770 | void inject_input() override | ||
1263 | 771 | { | ||
1264 | 772 | wait_until_client_appears(test_client_name_1); | ||
1265 | 773 | input_cb_setup_fence.wait_for_signal_ready_for(); | ||
1266 | 774 | wait_until_client_appears(test_client_name_2); | ||
1267 | 775 | input_cb_setup_fence.wait_for_signal_ready_for(); | ||
1268 | 776 | |||
1283 | 777 | // First we will move the cursor in to the region where client 2 obscures client 1 | 755 | // First we will move the cursor in to the region where client 2 obscures client 1 |
1287 | 778 | fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(1, 1)); | 756 | server.fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(1, 1)); |
1288 | 779 | fake_event_hub->synthesize_event(mis::a_button_down_event().of_button(BTN_LEFT).with_action(mis::EventAction::Down)); | 757 | server.fake_event_hub->synthesize_event(mis::a_button_down_event().of_button(BTN_LEFT).with_action(mis::EventAction::Down)); |
1289 | 780 | fake_event_hub->synthesize_event(mis::a_button_up_event().of_button(BTN_LEFT)); | 758 | server.fake_event_hub->synthesize_event(mis::a_button_up_event().of_button(BTN_LEFT)); |
1290 | 781 | // Now we move to the unobscured region of client 1 | 759 | // Now we move to the unobscured region of client 1 |
1312 | 782 | fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(50, 0)); | 760 | server.fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(50, 0)); |
1313 | 783 | fake_event_hub->synthesize_event(mis::a_button_down_event().of_button(BTN_LEFT).with_action(mis::EventAction::Down)); | 761 | server.fake_event_hub->synthesize_event(mis::a_button_down_event().of_button(BTN_LEFT).with_action(mis::EventAction::Down)); |
1314 | 784 | fake_event_hub->synthesize_event(mis::a_button_up_event().of_button(BTN_LEFT)); | 762 | server.fake_event_hub->synthesize_event(mis::a_button_up_event().of_button(BTN_LEFT)); |
1315 | 785 | } | 763 | }, positions, depths); |
1316 | 786 | } server_config{fence}; | 764 | launch_server_process(*server_config); |
1317 | 787 | 765 | ||
1318 | 788 | launch_server_process(server_config); | 766 | auto client_config_1 = make_event_expecting_client(test_client_name_1, fence, |
1319 | 789 | 767 | [&](MockInputHandler& handler, mt::WaitCondition& events_received) | |
1320 | 790 | struct ClientConfigOne : InputClient | 768 | { |
1321 | 791 | { | 769 | EXPECT_CALL(handler, handle_input(HoverEnterEvent())).Times(AnyNumber()); |
1322 | 792 | ClientConfigOne(const mtf::CrossProcessSync& fence) | 770 | EXPECT_CALL(handler, handle_input(HoverExitEvent())).Times(AnyNumber()); |
1323 | 793 | : InputClient(fence, test_client_name_1) | 771 | EXPECT_CALL(handler, handle_input(MovementEvent())).Times(AnyNumber()); |
1303 | 794 | { | ||
1304 | 795 | } | ||
1305 | 796 | |||
1306 | 797 | void expect_input(mt::WaitCondition& events_received) override | ||
1307 | 798 | { | ||
1308 | 799 | EXPECT_CALL(*handler, handle_input(HoverEnterEvent())).Times(AnyNumber()); | ||
1309 | 800 | EXPECT_CALL(*handler, handle_input(HoverExitEvent())).Times(AnyNumber()); | ||
1310 | 801 | EXPECT_CALL(*handler, handle_input(MovementEvent())).Times(AnyNumber()); | ||
1311 | 802 | |||
1324 | 803 | { | 772 | { |
1325 | 804 | // We should only see one button event sequence. | 773 | // We should only see one button event sequence. |
1326 | 805 | InSequence seq; | 774 | InSequence seq; |
1329 | 806 | EXPECT_CALL(*handler, handle_input(ButtonDownEvent(51, 1))).Times(1); | 775 | EXPECT_CALL(handler, handle_input(ButtonDownEvent(51, 1))).Times(1); |
1330 | 807 | EXPECT_CALL(*handler, handle_input(ButtonUpEvent(51, 1))).Times(1) | 776 | EXPECT_CALL(handler, handle_input(ButtonUpEvent(51, 1))).Times(1) |
1331 | 808 | .WillOnce(mt::WakeUp(&events_received)); | 777 | .WillOnce(mt::WakeUp(&events_received)); |
1332 | 809 | } | 778 | } |
1350 | 810 | } | 779 | }); |
1351 | 811 | } client_config_1{fence}; | 780 | auto client_config_2 = make_event_expecting_client(test_client_name_2, fence, |
1352 | 812 | launch_client_process(client_config_1); | 781 | [&](MockInputHandler& handler, mt::WaitCondition& events_received) |
1353 | 813 | 782 | { | |
1354 | 814 | struct ClientConfigTwo : InputClient | 783 | EXPECT_CALL(handler, handle_input(HoverEnterEvent())).Times(AnyNumber()); |
1355 | 815 | { | 784 | EXPECT_CALL(handler, handle_input(HoverExitEvent())).Times(AnyNumber()); |
1356 | 816 | ClientConfigTwo(const mtf::CrossProcessSync& fence) | 785 | EXPECT_CALL(handler, handle_input(MovementEvent())).Times(AnyNumber()); |
1340 | 817 | : InputClient(fence, test_client_name_2) | ||
1341 | 818 | { | ||
1342 | 819 | } | ||
1343 | 820 | |||
1344 | 821 | void expect_input(mt::WaitCondition& events_received) override | ||
1345 | 822 | { | ||
1346 | 823 | EXPECT_CALL(*handler, handle_input(HoverEnterEvent())).Times(AnyNumber()); | ||
1347 | 824 | EXPECT_CALL(*handler, handle_input(HoverExitEvent())).Times(AnyNumber()); | ||
1348 | 825 | EXPECT_CALL(*handler, handle_input(MovementEvent())).Times(AnyNumber()); | ||
1349 | 826 | |||
1357 | 827 | { | 786 | { |
1358 | 828 | // Likewise we should only see one button sequence. | 787 | // Likewise we should only see one button sequence. |
1359 | 829 | InSequence seq; | 788 | InSequence seq; |
1362 | 830 | EXPECT_CALL(*handler, handle_input(ButtonDownEvent(1, 1))).Times(1); | 789 | EXPECT_CALL(handler, handle_input(ButtonDownEvent(1, 1))).Times(1); |
1363 | 831 | EXPECT_CALL(*handler, handle_input(ButtonUpEvent(1, 1))).Times(1) | 790 | EXPECT_CALL(handler, handle_input(ButtonUpEvent(1, 1))).Times(1) |
1364 | 832 | .WillOnce(mt::WakeUp(&events_received)); | 791 | .WillOnce(mt::WakeUp(&events_received)); |
1365 | 833 | } | 792 | } |
1369 | 834 | } | 793 | }); |
1370 | 835 | } client_config_2{fence}; | 794 | |
1371 | 836 | launch_client_process(client_config_2); | 795 | launch_client_process(*client_config_1); |
1372 | 796 | launch_client_process(*client_config_2); | ||
1373 | 837 | } | 797 | } |
1374 | 838 | 798 | ||
1375 | 839 | namespace | 799 | namespace |
1376 | @@ -853,93 +813,48 @@ | |||
1377 | 853 | static std::string const test_client_name = "1"; | 813 | static std::string const test_client_name = "1"; |
1378 | 854 | static std::string const test_client_2_name = "2"; | 814 | static std::string const test_client_2_name = "2"; |
1379 | 855 | mtf::CrossProcessSync fence, first_client_ready_fence, second_client_done_fence; | 815 | mtf::CrossProcessSync fence, first_client_ready_fence, second_client_done_fence; |
1408 | 856 | 816 | ||
1409 | 857 | struct ServerConfiguration : public mtf::InputTestingServerConfiguration | 817 | static DepthMap depths; |
1410 | 858 | { | 818 | depths[test_client_name] = ms::DepthId{0}; |
1411 | 859 | mtf::CrossProcessSync input_cb_setup_fence; | 819 | depths[test_client_2_name] = ms::DepthId{1}; |
1412 | 860 | mtf::CrossProcessSync second_client_done_fence; | 820 | |
1413 | 861 | 821 | auto server_config = make_event_producing_server(fence, 2, | |
1414 | 862 | ServerConfiguration(const mtf::CrossProcessSync& input_cb_setup_fence, | 822 | [&](mtf::InputTestingServerConfiguration& server) |
1415 | 863 | const mtf::CrossProcessSync& second_client_done_fence) | 823 | { |
1388 | 864 | : input_cb_setup_fence(input_cb_setup_fence), | ||
1389 | 865 | second_client_done_fence(second_client_done_fence) | ||
1390 | 866 | { | ||
1391 | 867 | } | ||
1392 | 868 | |||
1393 | 869 | void hide_session_by_name(std::string const& session_name) | ||
1394 | 870 | { | ||
1395 | 871 | the_shell_session_container()->for_each([&](std::shared_ptr<msh::Session> const& session) -> void | ||
1396 | 872 | { | ||
1397 | 873 | if (session->name() == session_name) | ||
1398 | 874 | session->hide(); | ||
1399 | 875 | }); | ||
1400 | 876 | } | ||
1401 | 877 | |||
1402 | 878 | void inject_input() | ||
1403 | 879 | { | ||
1404 | 880 | wait_until_client_appears(test_client_name); | ||
1405 | 881 | wait_until_client_appears(test_client_2_name); | ||
1406 | 882 | input_cb_setup_fence.wait_for_signal_ready_for(); | ||
1407 | 883 | |||
1416 | 884 | // We send one event and then hide the surface on top before sending the next. | 824 | // We send one event and then hide the surface on top before sending the next. |
1420 | 885 | // So we expect each of the two surfaces to receive one event pair. | 825 | // So we expect each of the two surfaces to receive one even |
1421 | 886 | fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(1,1)); | 826 | server.fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(1,1)); |
1419 | 887 | |||
1422 | 888 | // We use a fence to ensure we do not hide the client | 827 | // We use a fence to ensure we do not hide the client |
1423 | 889 | // before event dispatch occurs | 828 | // before event dispatch occurs |
1424 | 890 | second_client_done_fence.wait_for_signal_ready_for(); | 829 | second_client_done_fence.wait_for_signal_ready_for(); |
1444 | 891 | hide_session_by_name(test_client_2_name); | 830 | |
1445 | 892 | 831 | server.the_shell_session_container()->for_each([&](std::shared_ptr<msh::Session> const& session) -> void | |
1446 | 893 | fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(1,1)); | 832 | { |
1447 | 894 | } | 833 | if (session->name() == test_client_2_name) |
1448 | 895 | } server_config{fence, second_client_done_fence}; | 834 | session->hide(); |
1449 | 896 | launch_server_process(server_config); | 835 | }); |
1450 | 897 | 836 | ||
1451 | 898 | struct ButtonClientOne : InputClient | 837 | server.fake_event_hub->synthesize_event(mis::a_motion_event().with_movement(1,1)); |
1452 | 899 | { | 838 | }, GeometryMap(), depths); |
1453 | 900 | ButtonClientOne(const mtf::CrossProcessSync& fence) | 839 | launch_server_process(*server_config); |
1454 | 901 | : InputClient(fence, test_client_name) | 840 | |
1455 | 902 | { | 841 | auto client_config_1 = make_event_expecting_client(test_client_name, fence, |
1456 | 903 | } | 842 | [&](MockInputHandler& handler, mt::WaitCondition& events_received) |
1457 | 904 | 843 | { | |
1458 | 905 | void expect_input(mt::WaitCondition& events_received) override | 844 | EXPECT_CALL(handler, handle_input(HoverEnterEvent())).Times(AnyNumber()); |
1459 | 906 | { | 845 | EXPECT_CALL(handler, handle_input(HoverExitEvent())).Times(AnyNumber()); |
1460 | 907 | EXPECT_CALL(*handler, handle_input(HoverEnterEvent())).Times(AnyNumber()); | 846 | EXPECT_CALL(handler, handle_input(MotionEventWithPosition(2, 2))).Times(1) |
1442 | 908 | EXPECT_CALL(*handler, handle_input(HoverExitEvent())).Times(AnyNumber()); | ||
1443 | 909 | EXPECT_CALL(*handler, handle_input(MotionEventWithPosition(2, 2))).Times(1) | ||
1461 | 910 | .WillOnce(mt::WakeUp(&events_received)); | 847 | .WillOnce(mt::WakeUp(&events_received)); |
1496 | 911 | } | 848 | }); |
1497 | 912 | } client_1{first_client_ready_fence}; | 849 | auto client_config_2 = make_event_expecting_client(test_client_2_name, fence, |
1498 | 913 | struct ButtonClientTwo : InputClient | 850 | [&](MockInputHandler& handler, mt::WaitCondition& events_received) |
1499 | 914 | { | 851 | { |
1500 | 915 | mtf::CrossProcessSync first_client_ready; | 852 | EXPECT_CALL(handler, handle_input(HoverEnterEvent())).Times(AnyNumber()); |
1501 | 916 | mtf::CrossProcessSync done_fence; | 853 | EXPECT_CALL(handler, handle_input(HoverExitEvent())).Times(AnyNumber()); |
1502 | 917 | 854 | EXPECT_CALL(handler, handle_input(MotionEventWithPosition(1, 1))).Times(1) | |
1503 | 918 | ButtonClientTwo(mtf::CrossProcessSync const& fence, mtf::CrossProcessSync const& first_client_ready, | 855 | .WillOnce(DoAll(SignalFence(&second_client_done_fence), mt::WakeUp(&events_received))); |
1504 | 919 | mtf::CrossProcessSync const& done_fence) | 856 | }); |
1505 | 920 | : InputClient(fence, test_client_2_name), | 857 | |
1506 | 921 | first_client_ready(first_client_ready), | 858 | launch_client_process(*client_config_1); |
1507 | 922 | done_fence(done_fence) | 859 | launch_client_process(*client_config_2); |
1474 | 923 | { | ||
1475 | 924 | } | ||
1476 | 925 | void exec() | ||
1477 | 926 | { | ||
1478 | 927 | // Ensure we stack on top of the first client | ||
1479 | 928 | first_client_ready.wait_for_signal_ready_for(); | ||
1480 | 929 | InputClient::exec(); | ||
1481 | 930 | } | ||
1482 | 931 | |||
1483 | 932 | void expect_input(mt::WaitCondition& events_received) override | ||
1484 | 933 | { | ||
1485 | 934 | EXPECT_CALL(*handler, handle_input(HoverEnterEvent())).Times(AnyNumber()); | ||
1486 | 935 | EXPECT_CALL(*handler, handle_input(HoverExitEvent())).Times(AnyNumber()); | ||
1487 | 936 | EXPECT_CALL(*handler, handle_input(MotionEventWithPosition(1, 1))).Times(1) | ||
1488 | 937 | .WillOnce(DoAll(SignalFence(&done_fence), mt::WakeUp(&events_received))); | ||
1489 | 938 | } | ||
1490 | 939 | } client_2{fence, first_client_ready_fence, second_client_done_fence}; | ||
1491 | 940 | |||
1492 | 941 | // Client 2 is launched second so will be the first to receive input | ||
1493 | 942 | |||
1494 | 943 | launch_client_process(client_1); | ||
1495 | 944 | launch_client_process(client_2); | ||
1508 | 945 | } | 860 | } |
1509 | 946 | 861 | ||
1510 | === modified file 'tests/unit-tests/client/input/test_android_input_receiver.cpp' | |||
1511 | --- tests/unit-tests/client/input/test_android_input_receiver.cpp 2013-05-31 16:06:07 +0000 | |||
1512 | +++ tests/unit-tests/client/input/test_android_input_receiver.cpp 2013-11-07 00:22:14 +0000 | |||
1513 | @@ -17,8 +17,10 @@ | |||
1514 | 17 | */ | 17 | */ |
1515 | 18 | 18 | ||
1516 | 19 | #include "src/shared/input/android/android_input_receiver.h" | 19 | #include "src/shared/input/android/android_input_receiver.h" |
1517 | 20 | #include "mir/input/null_input_receiver_report.h" | ||
1518 | 20 | #include "mir_toolkit/event.h" | 21 | #include "mir_toolkit/event.h" |
1519 | 21 | 22 | ||
1520 | 23 | |||
1521 | 22 | #include <androidfw/InputTransport.h> | 24 | #include <androidfw/InputTransport.h> |
1522 | 23 | 25 | ||
1523 | 24 | #include <gmock/gmock.h> | 26 | #include <gmock/gmock.h> |
1524 | @@ -27,7 +29,8 @@ | |||
1525 | 27 | #include <unistd.h> | 29 | #include <unistd.h> |
1526 | 28 | #include <memory> | 30 | #include <memory> |
1527 | 29 | 31 | ||
1529 | 30 | namespace mircva = mir::input::receiver::android; | 32 | namespace mircv = mir::input::receiver; |
1530 | 33 | namespace mircva = mircv::android; | ||
1531 | 31 | 34 | ||
1532 | 32 | namespace droidinput = android; | 35 | namespace droidinput = android; |
1533 | 33 | 36 | ||
1534 | @@ -142,14 +145,14 @@ | |||
1535 | 142 | 145 | ||
1536 | 143 | TEST_F(AndroidInputReceiverSetup, receiever_takes_channel_fd) | 146 | TEST_F(AndroidInputReceiverSetup, receiever_takes_channel_fd) |
1537 | 144 | { | 147 | { |
1539 | 145 | mircva::InputReceiver receiver(client_fd); | 148 | mircva::InputReceiver receiver(client_fd, std::make_shared<mircv::NullInputReceiverReport>()); |
1540 | 146 | 149 | ||
1541 | 147 | EXPECT_EQ(client_fd, receiver.fd()); | 150 | EXPECT_EQ(client_fd, receiver.fd()); |
1542 | 148 | } | 151 | } |
1543 | 149 | 152 | ||
1544 | 150 | TEST_F(AndroidInputReceiverSetup, receiver_receives_key_events) | 153 | TEST_F(AndroidInputReceiverSetup, receiver_receives_key_events) |
1545 | 151 | { | 154 | { |
1547 | 152 | mircva::InputReceiver receiver(client_fd); | 155 | mircva::InputReceiver receiver(client_fd, std::make_shared<mircv::NullInputReceiverReport>()); |
1548 | 153 | TestingInputProducer producer(server_fd); | 156 | TestingInputProducer producer(server_fd); |
1549 | 154 | 157 | ||
1550 | 155 | producer.produce_a_key_event(); | 158 | producer.produce_a_key_event(); |
1551 | @@ -165,7 +168,7 @@ | |||
1552 | 165 | 168 | ||
1553 | 166 | TEST_F(AndroidInputReceiverSetup, receiver_handles_events) | 169 | TEST_F(AndroidInputReceiverSetup, receiver_handles_events) |
1554 | 167 | { | 170 | { |
1556 | 168 | mircva::InputReceiver receiver(client_fd); | 171 | mircva::InputReceiver receiver(client_fd, std::make_shared<mircv::NullInputReceiverReport>()); |
1557 | 169 | TestingInputProducer producer(server_fd); | 172 | TestingInputProducer producer(server_fd); |
1558 | 170 | 173 | ||
1559 | 171 | producer.produce_a_key_event(); | 174 | producer.produce_a_key_event(); |
1560 | @@ -181,7 +184,7 @@ | |||
1561 | 181 | 184 | ||
1562 | 182 | TEST_F(AndroidInputReceiverSetup, receiver_consumes_batched_motion_events) | 185 | TEST_F(AndroidInputReceiverSetup, receiver_consumes_batched_motion_events) |
1563 | 183 | { | 186 | { |
1565 | 184 | mircva::InputReceiver receiver(client_fd); | 187 | mircva::InputReceiver receiver(client_fd, std::make_shared<mircv::NullInputReceiverReport>()); |
1566 | 185 | TestingInputProducer producer(server_fd); | 188 | TestingInputProducer producer(server_fd); |
1567 | 186 | 189 | ||
1568 | 187 | // Produce 3 motion events before client handles any. | 190 | // Produce 3 motion events before client handles any. |
1569 | 188 | 191 | ||
1570 | === modified file 'tests/unit-tests/client/input/test_android_input_receiver_thread.cpp' | |||
1571 | --- tests/unit-tests/client/input/test_android_input_receiver_thread.cpp 2013-05-13 23:20:52 +0000 | |||
1572 | +++ tests/unit-tests/client/input/test_android_input_receiver_thread.cpp 2013-11-07 00:22:14 +0000 | |||
1573 | @@ -19,6 +19,8 @@ | |||
1574 | 19 | #include "src/shared/input/android/android_input_receiver_thread.h" | 19 | #include "src/shared/input/android/android_input_receiver_thread.h" |
1575 | 20 | #include "src/shared/input/android/android_input_receiver.h" | 20 | #include "src/shared/input/android/android_input_receiver.h" |
1576 | 21 | 21 | ||
1577 | 22 | #include "mir/input/null_input_receiver_report.h" | ||
1578 | 23 | |||
1579 | 22 | #include "mir_toolkit/mir_client_library.h" | 24 | #include "mir_toolkit/mir_client_library.h" |
1580 | 23 | 25 | ||
1581 | 24 | #include <gtest/gtest.h> | 26 | #include <gtest/gtest.h> |
1582 | @@ -30,7 +32,8 @@ | |||
1583 | 30 | 32 | ||
1584 | 31 | #include <fcntl.h> | 33 | #include <fcntl.h> |
1585 | 32 | 34 | ||
1587 | 33 | namespace mircva = mir::input::receiver::android; | 35 | namespace mircv = mir::input::receiver; |
1588 | 36 | namespace mircva = mircv::android; | ||
1589 | 34 | 37 | ||
1590 | 35 | namespace | 38 | namespace |
1591 | 36 | { | 39 | { |
1592 | @@ -43,7 +46,7 @@ | |||
1593 | 43 | struct MockInputReceiver : public mircva::InputReceiver | 46 | struct MockInputReceiver : public mircva::InputReceiver |
1594 | 44 | { | 47 | { |
1595 | 45 | MockInputReceiver(int fd) | 48 | MockInputReceiver(int fd) |
1597 | 46 | : InputReceiver(fd) | 49 | : InputReceiver(fd, std::make_shared<mircv::NullInputReceiverReport>()) |
1598 | 47 | { | 50 | { |
1599 | 48 | } | 51 | } |
1600 | 49 | MOCK_METHOD1(next_event, bool(MirEvent &)); | 52 | MOCK_METHOD1(next_event, bool(MirEvent &)); |