Mir

Merge lp:~alan-griffiths/mir/workaround-1200236 into lp:~mir-team/mir/trunk

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 847
Proposed branch: lp:~alan-griffiths/mir/workaround-1200236
Merge into: lp:~mir-team/mir/trunk
Diff against target: 74 lines (+20/-15)
1 file modified
tests/acceptance-tests/test_client_input.cpp (+20/-15)
To merge this branch: bzr merge lp:~alan-griffiths/mir/workaround-1200236
Reviewer Review Type Date Requested Status
Thomas Voß (community) Approve
Kevin DuBois (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+174201@code.launchpad.net

Commit message

tests: rework test to prevent test input events being missed before handler is registered

Description of the change

tests: rework test to prevent test input events being missed before handler is registered

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

This is only a workaround for bug-1200236 as I think the issue fixed here should result in intermittent test failure, not in a hang.

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

looks ok, but it really is just a workaround for the test. We could use the 'pipe' mechanism in the swapinterval of first-frame-sync tests to synchronize at the right points.

Registering the handler in the callback should ensure that the handler is good to go before the server is notified that the surface has been created, so it will work, and it is better than having that bug :)

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

> This is only a workaround for bug-1200236 as I think the issue fixed here
> should result in intermittent test failure, not in a hang.

I think the failures I saw were time outs after 1 minute ( events_received.wait_for_at_most_seconds(60); ), so I suppose technically not a hang :)

Revision history for this message
Thomas Voß (thomas-voss) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/acceptance-tests/test_client_input.cpp'
2--- tests/acceptance-tests/test_client_input.cpp 2013-07-10 17:06:37 +0000
3+++ tests/acceptance-tests/test_client_input.cpp 2013-07-11 13:54:24 +0000
4@@ -125,6 +125,20 @@
5 {
6 }
7
8+ virtual void surface_created(MirSurface* new_surface) override
9+ {
10+ ClientConfig::surface_created(new_surface);
11+
12+ MirEventDelegate const event_delegate =
13+ {
14+ handle_input,
15+ this
16+ };
17+
18+ // Set this in the callback, not main thread to avoid missing test events
19+ mir_surface_set_event_handler(surface, &event_delegate);
20+ }
21+
22 static void handle_input(MirSurface* /* surface */, MirEvent const* ev, void* context)
23 {
24 auto client = static_cast<InputClient *>(context);
25@@ -132,10 +146,8 @@
26 client->handler->handle_input(ev);
27 }
28
29- virtual void expect_input(mt::WaitCondition&)
30- {
31- }
32-
33+ virtual void expect_input(mt::WaitCondition&) = 0;
34+
35 virtual MirSurfaceParameters parameters()
36 {
37 MirSurfaceParameters const request_params =
38@@ -161,32 +173,25 @@
39 this));
40 ASSERT_TRUE(connection != NULL);
41
42- MirEventDelegate const event_delegate =
43- {
44- handle_input,
45- this
46- };
47 auto request_params = parameters();
48 mir_wait_for(mir_connection_create_surface(connection, &request_params, create_surface_callback, this));
49
50- mir_surface_set_event_handler(surface, &event_delegate);
51-
52 events_received.wait_for_at_most_seconds(60);
53
54 mir_surface_release_sync(surface);
55-
56+
57 mir_connection_release(connection);
58
59 // ClientConfiguration d'tor is not called on client side so we need this
60 // in order to not leak the Mock object.
61 handler.reset();
62 }
63-
64+
65 std::shared_ptr<MockInputHandler> handler;
66 mt::WaitCondition events_received;
67-
68+
69 std::string const surface_name;
70-
71+
72 static int const surface_width = 100;
73 static int const surface_height = 100;
74 };

Subscribers

People subscribed via source and target branches