Mir

Merge lp:~andreas-pokorny/mir/fake-event-hub-to-fake-input-server-configuration into lp:mir

Proposed by Andreas Pokorny
Status: Work in progress
Proposed branch: lp:~andreas-pokorny/mir/fake-event-hub-to-fake-input-server-configuration
Merge into: lp:mir
Prerequisite: lp:~andreas-pokorny/mir/stub-legacy-input-dispatchable
Diff against target: 677 lines (+161/-117)
10 files modified
benchmarks/frame-uniformity/touch_producing_server.cpp (+12/-10)
benchmarks/frame-uniformity/touch_producing_server.h (+5/-2)
src/server/input/default_input_manager.cpp (+35/-23)
src/server/input/default_input_manager.h (+5/-2)
tests/acceptance-tests/throwback/test_client_cursor_api.cpp (+15/-15)
tests/include/mir_test_framework/fake_input_server_configuration.h (+12/-22)
tests/integration-tests/input/test_cursor_listener.cpp (+2/-3)
tests/integration-tests/test_server_shutdown.cpp (+59/-12)
tests/mir_test_framework/CMakeLists.txt (+1/-1)
tests/mir_test_framework/fake_input_server_configuration.cpp (+15/-27)
To merge this branch: bzr merge lp:~andreas-pokorny/mir/fake-event-hub-to-fake-input-server-configuration
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Needs Fixing
Robert Carr (community) Approve
Kevin DuBois (community) Needs Fixing
Review via email: mp+258845@code.launchpad.net

Commit message

Switch all tests to FakeInputServerConfiguration, and ensure that DefaultInputManagers dispatchables are unlinked from the MutliplexingDispatchable in all shutdown paths.

Description of the change

Change FakeEventHubServerConfiguration into FakeInputServerConfiguration - a server configuration that ensures that an input platform is loaded that can be used with fake input devices.

There were a few copies of FakeEventHubServerConfigration in the code, those were changed to. Hence the shutdown case: exception during user input processing was converted to. That required a cleanup of the DefaultInputManager 'stop' paths.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
2369. By Andreas Pokorny

merge clang fix

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
2370. By Andreas Pokorny

include not needed

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

183+ for (auto const platform : platforms)
const&?

123+ if (!state.compare_exchange_strong(expected, State::running))
Close to my EOD (and my brain's somewhat cooked), but the existing code doesn't look threadsafe, and this could still have an interleaving of stop() and start(). I'd guess the start and stop need to be exclusive (maybe a 'start', 'stop' and 'transitioning' state could work). If its also not threadsafe now, could we leave it as is?

review: Needs Fixing
2371. By Andreas Pokorny

merge prereq

2372. By Andreas Pokorny

merge prereq

2373. By Andreas Pokorny

fixing missing ref

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

> 123+ if (!state.compare_exchange_strong(expected, State::running))
> Close to my EOD (and my brain's somewhat cooked), but the existing code
> doesn't look threadsafe, and this could still have an interleaving of stop()
> and start(). I'd guess the start and stop need to be exclusive (maybe a
> 'start', 'stop' and 'transitioning' state could work). If its also not
> threadsafe now, could we leave it as is?

Yes it is not safe against interleaving start/stop calls. This change only helps against parallel stop calls.. Looking at the code again, it also lacks exception safety. I think I should bring it on par with the start/stop behavior of MultithreadedCompositor

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote :

LGTM Besides the mentioned exception safety in start/stop.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

The only blocking issue I see is the exception safety.

~~~~

One nit:

89 + std::unique_ptr<mir_test_framework::FakeInputDevice> touch_screen;

const?

~~~~

One (pre-existing) wish:

359 std::shared_ptr<mir::input::InputManager> the_input_manager() override;
360 std::shared_ptr<mir::input::InputDispatcher> the_input_dispatcher() override;
...
362 std::shared_ptr<mir::input::InputSender> the_input_sender() override;

A shame these are needed but are not customization points in mir::Server (as that would go a long way to getting rid of these "throwback" tests).

review: Needs Fixing
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

Uh, I nearly forgot about that branch.

> One (pre-existing) wish:
>
> 359 std::shared_ptr<mir::input::InputManager> the_input_manager()
> override;
> 360 std::shared_ptr<mir::input::InputDispatcher>
> the_input_dispatcher() override;
> ...
> 362 std::shared_ptr<mir::input::InputSender> the_input_sender()
> override;
>
> A shame these are needed but are not customization points in mir::Server (as
> that would go a long way to getting rid of these "throwback" tests).

I believe none of those three are touched in throwback. I think throwback could be cleaned if we add a customization point to track the scene contents (cursor + touch vizsualiation) and the used cursor buffers. Hmm the other remaining would be focus tracking.. We might get away by testing for focus events on the client?

2374. By Andreas Pokorny

merge lp:mir

2375. By Andreas Pokorny

merge lp:mir

2376. By Andreas Pokorny

nits fixed additional tear down on stop

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

hm maybe my last change was unnecessary as unique_ptr should cover that case nicely..

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
2377. By Andreas Pokorny

revert additional stack unwinding code

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> > One (pre-existing) wish:
> >
> > 359 std::shared_ptr<mir::input::InputManager> the_input_manager()
> > override;
> > 360 std::shared_ptr<mir::input::InputDispatcher>
> > the_input_dispatcher() override;
> > ...
> > 362 std::shared_ptr<mir::input::InputSender> the_input_sender()
> > override;
>
> I believe none of those three are touched in throwback. I think throwback
> could be cleaned if we add a customization point to track the scene contents
> (cursor + touch vizsualiation) and the used cursor buffers. Hmm the other
> remaining would be focus tracking.. We might get away by testing for focus
> events on the client?

You say they are "not touched" but the tests use this configuration and this configuration implements these overrides. So touched or not they are used.

Revision history for this message
Kevin DuBois (kdub) wrote :

Especially given that start/stop isn't on a critical path, guarding against interleaving start/stop calls seems like something thats easy to do with a mutex... but if that's not the goal, it seems okay to guard against many stop() or start() calls this way. So I guess still needs fixing on the exception safety.

Revision history for this message
Alberto Aguirre (albaguirre) wrote :

So..is this work in progress? Or still needs review?

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> So..is this work in progress? Or still needs review?

"Needs fixing" on the exception safety.

2378. By Andreas Pokorny

merged lp:mir

2379. By Andreas Pokorny

Mutually exclude multiple start and stop executions

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Am I missing something?

AFAICS this has been blocked for four weeks over on the same issue (exception safety) and the latest revision does not address this.

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

> Am I missing something?
>
> AFAICS this has been blocked for four weeks over on the same issue (exception
> safety) and the latest revision does not address this.

No you are not. I returned to the branch today.. and I am still on it.

Unmerged revisions

2379. By Andreas Pokorny

Mutually exclude multiple start and stop executions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'benchmarks/frame-uniformity/touch_producing_server.cpp'
2--- benchmarks/frame-uniformity/touch_producing_server.cpp 2015-04-28 07:54:10 +0000
3+++ benchmarks/frame-uniformity/touch_producing_server.cpp 2015-06-22 19:27:32 +0000
4@@ -18,9 +18,10 @@
5
6 #include "touch_producing_server.h"
7 #include "vsync_simulating_graphics_platform.h"
8+#include "mir/input/input_device_info.h"
9
10 #include "mir_test/event_factory.h"
11-#include "mir_test/fake_event_hub.h"
12+#include "mir_test_framework/stub_server_platform_factory.h"
13 #include "mir/geometry/displacement.h"
14
15 #include <functional>
16@@ -37,15 +38,17 @@
17 TouchProducingServer::TouchProducingServer(geom::Rectangle screen_dimensions, geom::Point touch_start,
18 geom::Point touch_end, std::chrono::high_resolution_clock::duration touch_duration,
19 mt::Barrier &client_ready)
20- : FakeEventHubServerConfiguration({screen_dimensions}),
21+ : FakeInputServerConfiguration({screen_dimensions}),
22 screen_dimensions(screen_dimensions),
23 touch_start(touch_start),
24 touch_end(touch_end),
25 touch_duration(touch_duration),
26- client_ready(client_ready)
27+ client_ready(client_ready),
28+ touch_screen(mtf::add_fake_input_device(mi::InputDeviceInfo{
29+ 0, "touch screen", "touch-screen-uid", mi::DeviceCapability::touchscreen | mi::DeviceCapability::multitouch}))
30 {
31 input_injection_thread = std::thread(std::mem_fn(&TouchProducingServer::thread_function), this);
32-}
33+}
34
35 TouchProducingServer::~TouchProducingServer()
36 {
37@@ -66,18 +69,17 @@
38
39 void TouchProducingServer::synthesize_event_at(geom::Point const& point)
40 {
41- auto const minimum_touch = mia::FakeEventHub::TouchScreenMinAxisValue;
42- auto const maximum_touch = mia::FakeEventHub::TouchScreenMaxAxisValue;
43+ auto const minimum_touch = mtf::FakeInputDevice::minimum_touch_axis_value;
44+ auto const maximum_touch = mtf::FakeInputDevice::maximum_touch_axis_value;
45 auto const display_width = screen_dimensions.size.width.as_int();
46 auto const display_height = screen_dimensions.size.height.as_int();
47-
48+
49 auto px_frac = point.x.as_int() / static_cast<double>(display_width);
50 auto py_frac = point.y.as_int() / static_cast<double>(display_height);
51 auto const abs_touch_x = minimum_touch + (maximum_touch-minimum_touch) * px_frac;
52 auto const abs_touch_y = minimum_touch + (maximum_touch-minimum_touch) * py_frac;
53-
54- fake_event_hub->synthesize_event(
55- mis::a_touch_event().at_position({abs_touch_x, abs_touch_y}));
56+
57+ touch_screen->emit_event(mis::a_touch_event().at_position({abs_touch_x, abs_touch_y}));
58 }
59
60 void TouchProducingServer::thread_function()
61
62=== modified file 'benchmarks/frame-uniformity/touch_producing_server.h'
63--- benchmarks/frame-uniformity/touch_producing_server.h 2014-10-22 19:27:20 +0000
64+++ benchmarks/frame-uniformity/touch_producing_server.h 2015-06-22 19:27:32 +0000
65@@ -19,7 +19,8 @@
66 #ifndef TOUCH_PRODUCING_SERVER_H_
67 #define TOUCH_PRODUCING_SERVER_H_
68
69-#include "mir_test_framework/fake_event_hub_server_configuration.h"
70+#include "mir_test_framework/fake_input_server_configuration.h"
71+#include "mir_test_framework/fake_input_device.h"
72 #include "mir_test/barrier.h"
73
74 #include "mir/geometry/rectangle.h"
75@@ -27,7 +28,7 @@
76
77 #include <thread>
78
79-class TouchProducingServer : public mir_test_framework::FakeEventHubServerConfiguration
80+class TouchProducingServer : public mir_test_framework::FakeInputServerConfiguration
81 {
82 public:
83 TouchProducingServer(mir::geometry::Rectangle screen_dimensions, mir::geometry::Point touch_start, mir::geometry::Point touch_end, std::chrono::high_resolution_clock::duration touch_duration, mir::test::Barrier& client_ready);
84@@ -59,6 +60,8 @@
85
86 void synthesize_event_at(mir::geometry::Point const& point);
87 void thread_function();
88+
89+ std::unique_ptr<mir_test_framework::FakeInputDevice> const touch_screen;
90 };
91
92 #endif
93
94=== modified file 'src/server/input/default_input_manager.cpp'
95--- src/server/input/default_input_manager.cpp 2015-06-17 05:20:42 +0000
96+++ src/server/input/default_input_manager.cpp 2015-06-22 19:27:32 +0000
97@@ -29,16 +29,14 @@
98 #include "mir/thread_name.h"
99 #include "mir/terminate_with_current_exception.h"
100
101-#include <condition_variable>
102-#include <mutex>
103 #include <future>
104
105 namespace mi = mir::input;
106-namespace mia = mi::android;
107
108 mi::DefaultInputManager::DefaultInputManager(std::shared_ptr<dispatch::MultiplexingDispatchable> const& multiplexer,
109- std::shared_ptr<LegacyInputDispatchable> const& legacy_dispatchable)
110- : multiplexer{multiplexer}, legacy_dispatchable{legacy_dispatchable}, queue{std::make_shared<mir::dispatch::ActionQueue>()}, state{State::stopped}
111+ std::shared_ptr<LegacyInputDispatchable> const& legacy_dispatchable)
112+ : multiplexer{multiplexer}, legacy_dispatchable{legacy_dispatchable},
113+ queue{std::make_shared<mir::dispatch::ActionQueue>()}, state{State::stopped}
114 {
115 }
116
117@@ -70,6 +68,8 @@
118
119 void mi::DefaultInputManager::start()
120 {
121+ std::unique_lock<std::mutex> start_guard(start_stop_exclusion);
122+
123 if (state == State::running)
124 return;
125
126@@ -103,6 +103,9 @@
127 multiplexer,
128 [this,weak_started_promise]()
129 {
130+ unregister_dispatchables();
131+ stop_platforms();
132+
133 state = State::stopped;
134 if (auto started_promise = weak_started_promise.lock())
135 started_promise->set_exception(std::current_exception());
136@@ -114,30 +117,39 @@
137
138 void mi::DefaultInputManager::stop()
139 {
140+ std::unique_lock<std::mutex> start_guard(start_stop_exclusion);
141+
142 if (state == State::stopped)
143 return;
144- std::mutex m;
145- std::unique_lock<std::mutex> lock(m);
146- std::condition_variable cv;
147- bool done = false;
148-
149- queue->enqueue([&]()
150- {
151- for (auto const platform : platforms)
152- {
153- multiplexer->remove_watch(platform->dispatchable());
154- platform->stop();
155- }
156-
157- std::unique_lock<std::mutex> lock(m);
158- done = true;
159- cv.notify_one();
160- });
161- cv.wait(lock, [&]{return done;});
162+
163 state = State::stopped;
164
165+ auto const stop_promise = std::make_shared<std::promise<void>>();
166+
167+ queue->enqueue([stop_promise,this]()
168+ {
169+ stop_platforms();
170+
171+ stop_promise->set_value();
172+ });
173+
174+ stop_promise->get_future().wait();
175 input_thread.reset();
176
177+ unregister_dispatchables();
178+}
179+
180+void mi::DefaultInputManager::stop_platforms()
181+{
182+ for (auto const& platform : platforms)
183+ {
184+ multiplexer->remove_watch(platform->dispatchable());
185+ platform->stop();
186+ }
187+}
188+
189+void mi::DefaultInputManager::unregister_dispatchables()
190+{
191 multiplexer->remove_watch(legacy_dispatchable);
192 multiplexer->remove_watch(queue);
193 }
194
195=== modified file 'src/server/input/default_input_manager.h'
196--- src/server/input/default_input_manager.h 2015-06-17 05:20:42 +0000
197+++ src/server/input/default_input_manager.h 2015-06-22 19:27:32 +0000
198@@ -23,7 +23,7 @@
199
200 #include <vector>
201 #include <thread>
202-#include <atomic>
203+#include <mutex>
204
205 namespace mir
206 {
207@@ -50,6 +50,8 @@
208 void start() override;
209 void stop() override;
210 private:
211+ void stop_platforms();
212+ void unregister_dispatchables();
213 std::vector<std::shared_ptr<Platform>> platforms;
214 std::shared_ptr<dispatch::MultiplexingDispatchable> const multiplexer;
215 std::shared_ptr<input::LegacyInputDispatchable> const legacy_dispatchable;
216@@ -60,7 +62,8 @@
217 {
218 running, stopped
219 };
220- std::atomic<State> state;
221+ State state;
222+ std::mutex start_stop_exclusion;
223 };
224
225 }
226
227=== modified file 'tests/acceptance-tests/throwback/test_client_cursor_api.cpp'
228--- tests/acceptance-tests/throwback/test_client_cursor_api.cpp 2015-06-17 15:19:52 +0000
229+++ tests/acceptance-tests/throwback/test_client_cursor_api.cpp 2015-06-22 19:27:32 +0000
230@@ -20,12 +20,14 @@
231 #include "mir/graphics/cursor.h"
232 #include "mir/graphics/cursor_image.h"
233 #include "mir/input/cursor_images.h"
234+#include "mir/input/input_device_info.h"
235 #include "mir/shell/canonical_window_manager.h"
236 #include "mir/scene/placement_strategy.h"
237
238-
239 #include "mir_test_framework/in_process_server.h"
240-#include "mir_test_framework/fake_event_hub_server_configuration.h"
241+#include "mir_test_framework/fake_input_device.h"
242+#include "mir_test_framework/stub_server_platform_factory.h"
243+#include "mir_test_framework/fake_input_server_configuration.h"
244 #include "mir_test_framework/declarative_placement_strategy.h"
245 #include "mir_test_framework/using_stub_client_platform.h"
246 #include "mir_test_framework/headless_nested_server_runner.h"
247@@ -34,7 +36,6 @@
248 #include "mir_test/fake_shared.h"
249 #include "mir_test/spin_wait.h"
250 #include "mir_test/wait_condition.h"
251-#include "mir_test/fake_event_hub.h"
252
253 #include "mir_toolkit/mir_client_library.h"
254
255@@ -239,7 +240,7 @@
256 std::shared_ptr<ms::PlacementStrategy> const placement_strategy;
257 };
258
259-struct TestServerConfiguration : mtf::FakeEventHubServerConfiguration
260+struct TestServerConfiguration : mtf::FakeInputServerConfiguration
261 {
262 std::shared_ptr<mir::scene::PlacementStrategy> the_placement_strategy()
263 {
264@@ -292,11 +293,6 @@
265 return server_configuration_;
266 }
267
268- std::shared_ptr<mir::input::android::FakeEventHub> fake_event_hub()
269- {
270- return server_configuration_.fake_event_hub;
271- }
272-
273 void expect_client_shutdown()
274 {
275 using namespace testing;
276@@ -316,6 +312,10 @@
277 mir::test::WaitCondition expectations_satisfied;
278 mtf::UsingStubClientPlatform using_stub_client_platform;
279
280+ std::unique_ptr<mtf::FakeInputDevice> fake_mouse{
281+ mtf::add_fake_input_device(mi::InputDeviceInfo{ 0, "mouse", "mouse-uid" , mi::DeviceCapability::pointer})
282+ };
283+
284 ::testing::NiceMock<mtd::MockEGL> mock_egl;
285 };
286
287@@ -337,7 +337,7 @@
288 EXPECT_CALL(test_server_config().cursor, hide())
289 .WillOnce(mt::WakeUp(&expectations_satisfied));
290
291- fake_event_hub()->synthesize_event(mis::a_pointer_event().with_movement(1, 0));
292+ fake_mouse->emit_event(mis::a_pointer_event().with_movement(1, 0));
293
294 expectations_satisfied.wait_for_at_most_seconds(5);
295
296@@ -359,8 +359,8 @@
297 EXPECT_CALL(test_server_config().cursor, show(DefaultCursorImage()))
298 .WillOnce(mt::WakeUp(&expectations_satisfied));
299
300- fake_event_hub()->synthesize_event(mis::a_pointer_event().with_movement(1, 0));
301- fake_event_hub()->synthesize_event(mis::a_pointer_event().with_movement(2, 0));
302+ fake_mouse->emit_event(mis::a_pointer_event().with_movement(1, 0));
303+ fake_mouse->emit_event(mis::a_pointer_event().with_movement(2, 0));
304
305 expectations_satisfied.wait_for_at_most_seconds(5);
306
307@@ -386,8 +386,8 @@
308 EXPECT_CALL(test_server_config().cursor, show(CursorNamed(client_cursor_2)))
309 .WillOnce(mt::WakeUp(&expectations_satisfied));
310
311- fake_event_hub()->synthesize_event(mis::a_pointer_event().with_movement(1, 0));
312- fake_event_hub()->synthesize_event(mis::a_pointer_event().with_movement(1, 0));
313+ fake_mouse->emit_event(mis::a_pointer_event().with_movement(1, 0));
314+ fake_mouse->emit_event(mis::a_pointer_event().with_movement(1, 0));
315
316 expectations_satisfied.wait_for_at_most_seconds(5);
317
318@@ -411,7 +411,7 @@
319 EXPECT_CALL(test_server_config().cursor, show(CursorNamed(client_cursor_2)))
320 .WillOnce(mt::WakeUp(&expectations_satisfied));
321
322- fake_event_hub()->synthesize_event(mis::a_pointer_event().with_movement(1, 0));
323+ fake_mouse->emit_event(mis::a_pointer_event().with_movement(1, 0));
324
325 expectations_satisfied.wait_for_at_most_seconds(5);
326
327
328=== renamed file 'tests/include/mir_test_framework/fake_event_hub_server_configuration.h' => 'tests/include/mir_test_framework/fake_input_server_configuration.h'
329--- tests/include/mir_test_framework/fake_event_hub_server_configuration.h 2015-06-17 15:19:52 +0000
330+++ tests/include/mir_test_framework/fake_input_server_configuration.h 2015-06-22 19:27:32 +0000
331@@ -1,5 +1,5 @@
332 /*
333- * Copyright © 2013-2014 Canonical Ltd.
334+ * Copyright © 2013-2015 Canonical Ltd.
335 *
336 * This program is free software: you can redistribute it and/or modify it
337 * under the terms of the GNU General Public License version 3,
338@@ -17,41 +17,31 @@
339 * Alexandros Frantzis <alexandros.frantzis@canonical.com>
340 */
341
342-#ifndef MIR_TEST_FAKE_EVENT_HUB_SERVER_CONFIGURATION_H_
343-#define MIR_TEST_FAKE_EVENT_HUB_SERVER_CONFIGURATION_H_
344+#ifndef MIR_TEST_FAKE_INPUT_SERVER_CONFIGURATION_H_
345+#define MIR_TEST_FAKE_INPUT_SERVER_CONFIGURATION_H_
346
347 #include "mir_test_framework/testing_server_configuration.h"
348-
349-namespace mir
350-{
351-namespace input
352-{
353-namespace android
354-{
355-class FakeEventHub;
356-}
357-}
358-}
359+#include "mir_test_framework/temporary_environment_value.h"
360+#include "mir_test_framework/executable_path.h"
361
362 namespace mir_test_framework
363 {
364
365-class FakeEventHubServerConfiguration : public TestingServerConfiguration
366+class FakeInputServerConfiguration : public TestingServerConfiguration
367 {
368 public:
369- using TestingServerConfiguration::TestingServerConfiguration;
370+ FakeInputServerConfiguration();
371+ FakeInputServerConfiguration(std::vector<mir::geometry::Rectangle> const& display_rects);
372
373- std::shared_ptr<droidinput::EventHubInterface> the_event_hub() override;
374 std::shared_ptr<mir::input::InputManager> the_input_manager() override;
375 std::shared_ptr<mir::input::InputDispatcher> the_input_dispatcher() override;
376+ std::shared_ptr<mir::input::LegacyInputDispatchable> the_legacy_input_dispatchable() override;
377 std::shared_ptr<mir::shell::InputTargeter> the_input_targeter() override;
378 std::shared_ptr<mir::input::InputSender> the_input_sender() override;
379- std::shared_ptr<mir::input::LegacyInputDispatchable> the_legacy_input_dispatchable() override;
380- std::shared_ptr<mir::input::android::FakeEventHub> the_fake_event_hub();
381-
382- std::shared_ptr<mir::input::android::FakeEventHub> fake_event_hub;
383+private:
384+ TemporaryEnvironmentValue input_lib{"MIR_SERVER_PLATFORM_INPUT_LIB", server_platform("input-stub.so").c_str()};
385 };
386
387 }
388
389-#endif /* MIR_TEST_FAKE_EVENT_HUB_SERVER_CONFIGURATION_H_ */
390+#endif /* MIR_TEST_FAKE_INPUT_SERVER_CONFIGURATION_H_ */
391
392=== modified file 'tests/integration-tests/input/test_cursor_listener.cpp'
393--- tests/integration-tests/input/test_cursor_listener.cpp 2015-06-17 05:20:42 +0000
394+++ tests/integration-tests/input/test_cursor_listener.cpp 2015-06-22 19:27:32 +0000
395@@ -21,7 +21,7 @@
396
397 #include "mir_test/fake_shared.h"
398 #include "mir_test_framework/fake_input_device.h"
399-#include "mir_test_framework/stubbed_server_configuration.h"
400+#include "mir_test_framework/fake_input_server_configuration.h"
401 #include "mir_test_framework/stub_server_platform_factory.h"
402 #include "mir_test_framework/temporary_environment_value.h"
403 #include "mir_test_doubles/stub_input_enumerator.h"
404@@ -57,13 +57,12 @@
405 ~MockCursorListener() noexcept {}
406 };
407
408-struct CursorListenerIntegrationTest : testing::Test, mtf::StubbedServerConfiguration
409+struct CursorListenerIntegrationTest : testing::Test, mtf::FakeInputServerConfiguration
410 {
411 mtf::TemporaryEnvironmentValue input_lib{"MIR_SERVER_PLATFORM_INPUT_LIB", mtf::server_platform("input-stub.so").c_str()};
412 mtf::TemporaryEnvironmentValue real_input{"MIR_SERVER_TESTS_USE_REAL_INPUT", "1"};
413 mtf::TemporaryEnvironmentValue no_key_repeat{"MIR_SERVER_ENABLE_KEY_REPEAT", "0"};
414
415-
416 std::shared_ptr<mi::CursorListener> the_cursor_listener() override
417 {
418 return mt::fake_shared(cursor_listener);
419
420=== modified file 'tests/integration-tests/test_server_shutdown.cpp'
421--- tests/integration-tests/test_server_shutdown.cpp 2015-06-17 05:20:42 +0000
422+++ tests/integration-tests/test_server_shutdown.cpp 2015-06-22 19:27:32 +0000
423@@ -21,9 +21,11 @@
424 #include "mir/run_mir.h"
425 #include "mir/main_loop.h"
426
427+#include "mir_toolkit/mir_client_library.h"
428+
429+#include "mir_test_framework/fake_input_server_configuration.h"
430 #include "mir_test_framework/any_surface.h"
431-#include "mir_test_framework/fake_event_hub_server_configuration.h"
432-#include "mir_test_framework/fake_event_hub_server_configuration.h"
433+#include "mir_test_framework/fake_input_server_configuration.h"
434 #include "mir_test_framework/server_runner.h"
435 #include "mir_test_framework/testing_server_configuration.h"
436 #include "mir_test_framework/using_stub_client_platform.h"
437@@ -31,8 +33,14 @@
438 #include "mir_test_doubles/null_display_buffer_compositor_factory.h"
439 #include "mir_test_doubles/stub_frame_dropping_policy_factory.h"
440
441+#include "mir_test_doubles/stub_renderer.h"
442 #include "mir_test/fake_event_hub.h"
443
444+#include "mir/dispatch/action_queue.h"
445+#include "mir/input/input_device.h"
446+#include "mir/input/input_device_info.h"
447+#include "mir/input/input_device_registry.h"
448+
449 #include "mir_toolkit/mir_client_library.h"
450
451 #include <gtest/gtest.h>
452@@ -41,6 +49,7 @@
453 namespace mtd = mir::test::doubles;
454 namespace mc = mir::compositor;
455 namespace mg = mir::graphics;
456+namespace mi = mir::input;
457
458 namespace
459 {
460@@ -159,7 +168,7 @@
461 std::weak_ptr<mir::graphics::Display> display = server_configuration->the_display();
462 std::weak_ptr<mir::compositor::Compositor> compositor = server_configuration->the_compositor();
463 std::weak_ptr<mir::frontend::Connector> connector = server_configuration->the_connector();
464- std::weak_ptr<mir::input::InputManager> input_manager = server_configuration->the_input_manager();
465+ std::weak_ptr<mi::InputManager> input_manager = server_configuration->the_input_manager();
466
467 server_configuration.reset();
468
469@@ -191,6 +200,35 @@
470 }
471 };
472
473+struct ThrowingInputDevice : mi::InputDevice
474+{
475+ ThrowingInputDevice()
476+ : queue{std::make_shared<mir::dispatch::ActionQueue>()}
477+ {
478+ }
479+
480+ std::shared_ptr<mir::dispatch::Dispatchable> dispatchable() override
481+ {
482+ return queue;
483+ }
484+ void start(mi::InputSink*) override
485+ {
486+ queue->enqueue([](){throw std::runtime_error("InputDevice dispatch exception");});
487+ }
488+ void stop() override
489+ {
490+ }
491+
492+ mi::InputDeviceInfo get_device_info() override
493+ {
494+ return info;
495+ }
496+
497+
498+ mi::InputDeviceInfo info{0, "keyboard", "keyboard-uid", mi::DeviceCapability::keyboard};
499+ std::shared_ptr<mir::dispatch::ActionQueue> queue;
500+};
501+
502 }
503
504 TEST(ServerShutdownWithThreadException,
505@@ -224,7 +262,8 @@
506 std::weak_ptr<mir::graphics::Display> display = server_config->the_display();
507 std::weak_ptr<mir::compositor::Compositor> compositor = server_config->the_compositor();
508 std::weak_ptr<mir::frontend::Connector> connector = server_config->the_connector();
509- std::weak_ptr<mir::input::InputManager> input_manager = server_config->the_input_manager();
510+ std::weak_ptr<mi::InputManager> input_manager = server_config->the_input_manager();
511+ std::weak_ptr<mi::InputDeviceHub> hub = server_config->the_input_device_hub();
512
513 server_config.reset();
514
515@@ -232,13 +271,16 @@
516 EXPECT_EQ(0, compositor.use_count());
517 EXPECT_EQ(0, connector.use_count());
518 EXPECT_EQ(0, input_manager.use_count());
519+ EXPECT_EQ(0, hub.use_count());
520 }
521
522 TEST(ServerShutdownWithThreadException,
523 server_releases_resources_on_abnormal_input_thread_termination)
524 {
525- auto server_config = std::make_shared<mtf::FakeEventHubServerConfiguration>();
526- auto fake_event_hub = server_config->the_fake_event_hub();
527+ auto server_config = std::make_shared<mtf::FakeInputServerConfiguration>();
528+ auto dev = std::make_shared<ThrowingInputDevice>();
529+ std::weak_ptr<ThrowingInputDevice> weak_dev = dev;
530+ auto device_registry = server_config->the_input_device_registry();
531
532 std::thread server{
533 [&server_config]
534@@ -248,13 +290,16 @@
535 std::runtime_error);
536 }};
537
538- fake_event_hub->throw_exception_in_next_get_events();
539+ device_registry->add_device(dev);
540 server.join();
541+ dev.reset();
542+ device_registry.reset();
543
544 std::weak_ptr<mir::graphics::Display> display = server_config->the_display();
545 std::weak_ptr<mir::compositor::Compositor> compositor = server_config->the_compositor();
546 std::weak_ptr<mir::frontend::Connector> connector = server_config->the_connector();
547- std::weak_ptr<mir::input::InputManager> input_manager = server_config->the_input_manager();
548+ std::weak_ptr<mi::InputManager> input_manager = server_config->the_input_manager();
549+ std::weak_ptr<mi::InputDeviceHub> hub = server_config->the_input_device_hub();
550
551 server_config.reset();
552
553@@ -262,15 +307,15 @@
554 EXPECT_EQ(0, compositor.use_count());
555 EXPECT_EQ(0, connector.use_count());
556 EXPECT_EQ(0, input_manager.use_count());
557+ EXPECT_EQ(0, hub.use_count());
558 }
559
560 // This also acts as a regression test for LP: #1378740
561 TEST(ServerShutdownWithThreadException,
562 server_releases_resources_on_abnormal_main_thread_termination)
563 {
564- // Use the FakeEventHubServerConfiguration to get the production input components
565- // (with the exception of EventHub, of course).
566- auto server_config = std::make_shared<mtf::FakeEventHubServerConfiguration>();
567+ // Use the FakeInputServerConfiguration to get the production input components
568+ auto server_config = std::make_shared<mtf::FakeInputServerConfiguration>();
569
570 std::thread server{
571 [&]
572@@ -291,7 +336,8 @@
573 std::weak_ptr<mir::graphics::Display> display = server_config->the_display();
574 std::weak_ptr<mir::compositor::Compositor> compositor = server_config->the_compositor();
575 std::weak_ptr<mir::frontend::Connector> connector = server_config->the_connector();
576- std::weak_ptr<mir::input::InputManager> input_manager = server_config->the_input_manager();
577+ std::weak_ptr<mi::InputManager> input_manager = server_config->the_input_manager();
578+ std::weak_ptr<mi::InputDeviceHub> hub = server_config->the_input_device_hub();
579
580 server_config.reset();
581
582@@ -299,4 +345,5 @@
583 EXPECT_EQ(0, compositor.use_count());
584 EXPECT_EQ(0, connector.use_count());
585 EXPECT_EQ(0, input_manager.use_count());
586+ EXPECT_EQ(0, hub.use_count());
587 }
588
589=== modified file 'tests/mir_test_framework/CMakeLists.txt'
590--- tests/mir_test_framework/CMakeLists.txt 2015-06-17 05:20:42 +0000
591+++ tests/mir_test_framework/CMakeLists.txt 2015-06-22 19:27:32 +0000
592@@ -42,7 +42,7 @@
593 stub_server_platform_factory.cpp
594 udev_environment.cpp
595 declarative_placement_strategy.cpp
596- fake_event_hub_server_configuration.cpp
597+ fake_input_server_configuration.cpp
598 any_surface.cpp
599 headless_nested_server_runner.cpp
600 placement_applying_shell.cpp
601
602=== renamed file 'tests/mir_test_framework/fake_event_hub_server_configuration.cpp' => 'tests/mir_test_framework/fake_input_server_configuration.cpp'
603--- tests/mir_test_framework/fake_event_hub_server_configuration.cpp 2015-06-17 15:19:52 +0000
604+++ tests/mir_test_framework/fake_input_server_configuration.cpp 2015-06-22 19:27:32 +0000
605@@ -17,9 +17,7 @@
606 * Alexandros Frantzis <alexandros.frantzis@canonical.com>
607 */
608
609-#include "mir_test_framework/fake_event_hub_server_configuration.h"
610-
611-#include "mir_test/fake_event_hub.h"
612+#include "mir_test_framework/fake_input_server_configuration.h"
613
614 namespace mtf = mir_test_framework;
615 namespace mi = mir::input;
616@@ -27,47 +25,37 @@
617 namespace msh = mir::shell;
618 namespace mia = mir::input::android;
619
620-std::shared_ptr<mi::InputManager> mtf::FakeEventHubServerConfiguration::the_input_manager()
621+mtf::FakeInputServerConfiguration::FakeInputServerConfiguration()
622+{
623+}
624+
625+mtf::FakeInputServerConfiguration::FakeInputServerConfiguration(std::vector<mir::geometry::Rectangle> const& display_rects)
626+ : TestingServerConfiguration(display_rects)
627+{
628+}
629+
630+std::shared_ptr<mi::InputManager> mtf::FakeInputServerConfiguration::the_input_manager()
631 {
632 return DefaultServerConfiguration::the_input_manager();
633 }
634
635-std::shared_ptr<msh::InputTargeter> mtf::FakeEventHubServerConfiguration::the_input_targeter()
636+std::shared_ptr<msh::InputTargeter> mtf::FakeInputServerConfiguration::the_input_targeter()
637 {
638 return DefaultServerConfiguration::the_input_targeter();
639 }
640
641-std::shared_ptr<mi::InputDispatcher> mtf::FakeEventHubServerConfiguration::the_input_dispatcher()
642+std::shared_ptr<mi::InputDispatcher> mtf::FakeInputServerConfiguration::the_input_dispatcher()
643 {
644 return DefaultServerConfiguration::the_input_dispatcher();
645 }
646
647-std::shared_ptr<mi::InputSender> mtf::FakeEventHubServerConfiguration::the_input_sender()
648+std::shared_ptr<mi::InputSender> mtf::FakeInputServerConfiguration::the_input_sender()
649 {
650 return DefaultServerConfiguration::the_input_sender();
651 }
652
653-std::shared_ptr<mi::LegacyInputDispatchable> mtf::FakeEventHubServerConfiguration::the_legacy_input_dispatchable()
654+std::shared_ptr<mi::LegacyInputDispatchable> mtf::FakeInputServerConfiguration::the_legacy_input_dispatchable()
655 {
656 return DefaultServerConfiguration::the_legacy_input_dispatchable();
657 }
658
659-std::shared_ptr<droidinput::EventHubInterface> mtf::FakeEventHubServerConfiguration::the_event_hub()
660-{
661- return the_fake_event_hub();
662-}
663-
664-std::shared_ptr<mia::FakeEventHub> mtf::FakeEventHubServerConfiguration::the_fake_event_hub()
665-{
666- if (!fake_event_hub)
667- {
668- fake_event_hub = std::make_shared<mia::FakeEventHub>();
669-
670- fake_event_hub->synthesize_builtin_keyboard_added();
671- fake_event_hub->synthesize_builtin_cursor_added();
672- fake_event_hub->synthesize_usb_touchscreen_added();
673- fake_event_hub->synthesize_device_scan_complete();
674- }
675-
676- return fake_event_hub;
677-}

Subscribers

People subscribed via source and target branches