Mir

Merge lp:~alan-griffiths/mir/fix-1335741 into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 1735
Proposed branch: lp:~alan-griffiths/mir/fix-1335741
Merge into: lp:mir
Diff against target: 71 lines (+17/-4)
1 file modified
tests/acceptance-tests/test_client_surface_events.cpp (+17/-4)
To merge this branch: bzr merge lp:~alan-griffiths/mir/fix-1335741
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alberto Aguirre (community) Approve
Alexandros Frantzis (community) Approve
Review via email: mp+224982@code.launchpad.net

Commit message

tests: add an event filter to ClientSurfaceEvents so that interesting events are not overwritten

Description of the change

tests: add an event filter to ClientSurfaceEvents so that interesting events are not overwritten

To post a comment you must log in.
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

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

Yep

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

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_surface_events.cpp'
2--- tests/acceptance-tests/test_client_surface_events.cpp 2014-06-19 16:15:42 +0000
3+++ tests/acceptance-tests/test_client_surface_events.cpp 2014-06-30 11:17:53 +0000
4@@ -100,6 +100,7 @@
5 MirSurface* other_surface;
6
7 std::mutex last_event_mutex;
8+ MirEventType event_filter{mir_event_type_surface};
9 std::condition_variable last_event_cv;
10 MirEvent last_event{};
11 MirSurface* last_event_surface = nullptr;
12@@ -111,16 +112,24 @@
13 {
14 ClientSurfaceEvents* self = static_cast<ClientSurfaceEvents*>(ctx);
15 std::lock_guard<decltype(self->last_event_mutex)> last_event_lock{self->last_event_mutex};
16+ // Don't overwrite an interesting event with an uninteresting one!
17+ if (event->type != self->event_filter) return;
18 self->last_event = *event;
19 self->last_event_surface = surface;
20 self->last_event_cv.notify_one();
21 }
22
23- bool wait_for_event(MirEventType type, std::chrono::milliseconds delay)
24+ bool wait_for_event(std::chrono::milliseconds delay)
25 {
26 std::unique_lock<decltype(last_event_mutex)> last_event_lock{last_event_mutex};
27 return last_event_cv.wait_for(last_event_lock, delay,
28- [&] { return !!last_event_surface && last_event.type == type; });
29+ [&] { return last_event_surface == surface && last_event.type == event_filter; });
30+ }
31+
32+ void set_event_filter(MirEventType type)
33+ {
34+ std::lock_guard<decltype(last_event_mutex)> last_event_lock{last_event_mutex};
35+ event_filter = type;
36 }
37
38 void reset_last_event()
39@@ -218,11 +227,13 @@
40
41 TEST_P(OrientationEvents, surface_receives_orientation_events)
42 {
43+ set_event_filter(mir_event_type_orientation);
44+
45 auto const direction = GetParam();
46
47 scene_surface->set_orientation(direction);
48
49- EXPECT_TRUE(wait_for_event(mir_event_type_orientation, std::chrono::seconds(1)));
50+ EXPECT_TRUE(wait_for_event(std::chrono::seconds(1)));
51
52 std::lock_guard<decltype(last_event_mutex)> last_event_lock{last_event_mutex};
53
54@@ -237,6 +248,8 @@
55
56 TEST_F(ClientSurfaceEvents, client_can_query_current_orientation)
57 {
58+ set_event_filter(mir_event_type_orientation);
59+
60 for (auto const direction:
61 {mir_orientation_normal, mir_orientation_left, mir_orientation_inverted,
62 mir_orientation_right, mir_orientation_normal, mir_orientation_inverted,
63@@ -246,7 +259,7 @@
64
65 scene_surface->set_orientation(direction);
66
67- EXPECT_TRUE(wait_for_event(mir_event_type_orientation, std::chrono::seconds(1)));
68+ EXPECT_TRUE(wait_for_event(std::chrono::seconds(1)));
69
70 EXPECT_THAT(mir_surface_get_orientation(surface), Eq(direction));
71 }

Subscribers

People subscribed via source and target branches