Merge lp:~alan-griffiths/mir/orientation into lp:mir
- orientation
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Alan Griffiths |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1711 |
Proposed branch: | lp:~alan-griffiths/mir/orientation |
Merge into: | lp:mir |
Diff against target: |
606 lines (+307/-87) 17 files modified
include/server/mir/scene/null_surface_observer.h (+1/-0) include/server/mir/scene/surface.h (+1/-0) include/server/mir/scene/surface_event_source.h (+1/-0) include/server/mir/scene/surface_observer.h (+1/-0) include/shared/mir_toolkit/common.h (+2/-1) include/shared/mir_toolkit/event.h (+11/-1) include/test/mir_test_doubles/stub_scene_surface.h (+1/-0) src/client/rpc/mir_socket_rpc_channel.cpp (+19/-18) src/server/scene/basic_surface.cpp (+12/-0) src/server/scene/basic_surface.h (+2/-0) src/server/scene/legacy_surface_change_notification.cpp (+5/-0) src/server/scene/legacy_surface_change_notification.h (+1/-0) src/server/scene/null_surface_observer.cpp (+1/-0) src/server/scene/surface_event_source.cpp (+12/-0) tests/acceptance-tests/CMakeLists.txt (+1/-0) tests/acceptance-tests/test_client_library.cpp (+0/-67) tests/acceptance-tests/test_client_surface_events.cpp (+236/-0) |
To merge this branch: | bzr merge lp:~alan-griffiths/mir/orientation |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexandros Frantzis (community) | Approve | ||
Kevin DuBois (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+223759@code.launchpad.net |
Commit message
orientation API: support for the first orientation use-case (The shell can inform a surface of its orientation).
A second use case follows as Daniel d'Andrada asked about a client API to query the orientation.
Description of the change
orientation API: support for the first orientation use-case (The shell can inform a surface of its orientation).
PS Jenkins bot (ps-jenkins) wrote : | # |
Kevin DuBois (kdub) wrote : | # |
224 +// An orientation change alone is not enough to trigger recomposition.
couldn't some orientation changes be immediately recomposited?
seems okay otherwise
Alexandros Frantzis (afrantzis) wrote : | # |
Looks good. I wonder if we could come up with a guideline for when to use the surface attribute mechanism vs dedicated events.
Alan Griffiths (alan-griffiths) wrote : | # |
> Looks good. I wonder if we could come up with a guideline for when to use the
> surface attribute mechanism vs dedicated events.
I wondered (and still wonder) about this. But couldn't find a good argument for using attributes rather than an explicit event. (And an explicit event is marginally easier to wait for in the tests.)
Preview Diff
1 | === modified file 'include/server/mir/scene/null_surface_observer.h' | |||
2 | --- include/server/mir/scene/null_surface_observer.h 2014-06-12 15:35:08 +0000 | |||
3 | +++ include/server/mir/scene/null_surface_observer.h 2014-06-19 14:21:51 +0000 | |||
4 | @@ -37,6 +37,7 @@ | |||
5 | 37 | void hidden_set_to(bool hide); | 37 | void hidden_set_to(bool hide); |
6 | 38 | void frame_posted(int frames_available); | 38 | void frame_posted(int frames_available); |
7 | 39 | void alpha_set_to(float alpha); | 39 | void alpha_set_to(float alpha); |
8 | 40 | void orientation_set_to(MirOrientation orientation) override; | ||
9 | 40 | void transformation_set_to(glm::mat4 const& t); | 41 | void transformation_set_to(glm::mat4 const& t); |
10 | 41 | void cursor_image_set_to(graphics::CursorImage const& image); | 42 | void cursor_image_set_to(graphics::CursorImage const& image); |
11 | 42 | void reception_mode_set_to(input::InputReceptionMode mode); | 43 | void reception_mode_set_to(input::InputReceptionMode mode); |
12 | 43 | 44 | ||
13 | === modified file 'include/server/mir/scene/surface.h' | |||
14 | --- include/server/mir/scene/surface.h 2014-06-05 14:38:50 +0000 | |||
15 | +++ include/server/mir/scene/surface.h 2014-06-19 14:21:51 +0000 | |||
16 | @@ -70,6 +70,7 @@ | |||
17 | 70 | virtual void resize(geometry::Size const& size) = 0; | 70 | virtual void resize(geometry::Size const& size) = 0; |
18 | 71 | virtual void set_transformation(glm::mat4 const& t) = 0; | 71 | virtual void set_transformation(glm::mat4 const& t) = 0; |
19 | 72 | virtual void set_alpha(float alpha) = 0; | 72 | virtual void set_alpha(float alpha) = 0; |
20 | 73 | virtual void set_orientation(MirOrientation orientation) = 0; | ||
21 | 73 | virtual void force_requests_to_complete() = 0; | 74 | virtual void force_requests_to_complete() = 0; |
22 | 74 | 75 | ||
23 | 75 | virtual void set_cursor_image(std::shared_ptr<graphics::CursorImage> const& image) = 0; | 76 | virtual void set_cursor_image(std::shared_ptr<graphics::CursorImage> const& image) = 0; |
24 | 76 | 77 | ||
25 | === modified file 'include/server/mir/scene/surface_event_source.h' | |||
26 | --- include/server/mir/scene/surface_event_source.h 2014-06-02 17:07:02 +0000 | |||
27 | +++ include/server/mir/scene/surface_event_source.h 2014-06-19 14:21:51 +0000 | |||
28 | @@ -38,6 +38,7 @@ | |||
29 | 38 | 38 | ||
30 | 39 | void attrib_changed(MirSurfaceAttrib attrib, int value) override; | 39 | void attrib_changed(MirSurfaceAttrib attrib, int value) override; |
31 | 40 | void resized_to(geometry::Size const& size) override; | 40 | void resized_to(geometry::Size const& size) override; |
32 | 41 | void orientation_set_to(MirOrientation orientation) override; | ||
33 | 41 | 42 | ||
34 | 42 | private: | 43 | private: |
35 | 43 | frontend::SurfaceId const id; | 44 | frontend::SurfaceId const id; |
36 | 44 | 45 | ||
37 | === modified file 'include/server/mir/scene/surface_observer.h' | |||
38 | --- include/server/mir/scene/surface_observer.h 2014-06-12 15:35:08 +0000 | |||
39 | +++ include/server/mir/scene/surface_observer.h 2014-06-19 14:21:51 +0000 | |||
40 | @@ -48,6 +48,7 @@ | |||
41 | 48 | virtual void hidden_set_to(bool hide) = 0; | 48 | virtual void hidden_set_to(bool hide) = 0; |
42 | 49 | virtual void frame_posted(int frames_available) = 0; | 49 | virtual void frame_posted(int frames_available) = 0; |
43 | 50 | virtual void alpha_set_to(float alpha) = 0; | 50 | virtual void alpha_set_to(float alpha) = 0; |
44 | 51 | virtual void orientation_set_to(MirOrientation orientation) = 0; | ||
45 | 51 | virtual void transformation_set_to(glm::mat4 const& t) = 0; | 52 | virtual void transformation_set_to(glm::mat4 const& t) = 0; |
46 | 52 | virtual void reception_mode_set_to(input::InputReceptionMode mode) = 0; | 53 | virtual void reception_mode_set_to(input::InputReceptionMode mode) = 0; |
47 | 53 | virtual void cursor_image_set_to(graphics::CursorImage const& image) = 0; | 54 | virtual void cursor_image_set_to(graphics::CursorImage const& image) = 0; |
48 | 54 | 55 | ||
49 | === modified file 'include/shared/mir_toolkit/common.h' | |||
50 | --- include/shared/mir_toolkit/common.h 2014-06-12 15:35:08 +0000 | |||
51 | +++ include/shared/mir_toolkit/common.h 2014-06-19 14:21:51 +0000 | |||
52 | @@ -1,7 +1,7 @@ | |||
53 | 1 | /* | 1 | /* |
54 | 2 | * Simple definitions common to client and server. | 2 | * Simple definitions common to client and server. |
55 | 3 | * | 3 | * |
57 | 4 | * Copyright © 2013 Canonical Ltd. | 4 | * Copyright © 2013-2014 Canonical Ltd. |
58 | 5 | * | 5 | * |
59 | 6 | * This program is free software: you can redistribute it and/or modify | 6 | * This program is free software: you can redistribute it and/or modify |
60 | 7 | * it under the terms of the GNU Lesser General Public License version 3 as | 7 | * it under the terms of the GNU Lesser General Public License version 3 as |
61 | @@ -117,6 +117,7 @@ | |||
62 | 117 | /* This could be improved... https://bugs.launchpad.net/mir/+bug/1236254 */ | 117 | /* This could be improved... https://bugs.launchpad.net/mir/+bug/1236254 */ |
63 | 118 | #define MIR_BYTES_PER_PIXEL(f) (((f) == mir_pixel_format_bgr_888) ? 3 : 4) | 118 | #define MIR_BYTES_PER_PIXEL(f) (((f) == mir_pixel_format_bgr_888) ? 3 : 4) |
64 | 119 | 119 | ||
65 | 120 | /** Direction relative to the "natural" orientation of the display */ | ||
66 | 120 | typedef enum MirOrientation | 121 | typedef enum MirOrientation |
67 | 121 | { | 122 | { |
68 | 122 | mir_orientation_normal = 0, | 123 | mir_orientation_normal = 0, |
69 | 123 | 124 | ||
70 | === modified file 'include/shared/mir_toolkit/event.h' | |||
71 | --- include/shared/mir_toolkit/event.h 2014-06-11 16:11:32 +0000 | |||
72 | +++ include/shared/mir_toolkit/event.h 2014-06-19 14:21:51 +0000 | |||
73 | @@ -41,7 +41,8 @@ | |||
74 | 41 | mir_event_type_motion, | 41 | mir_event_type_motion, |
75 | 42 | mir_event_type_surface, | 42 | mir_event_type_surface, |
76 | 43 | mir_event_type_resize, | 43 | mir_event_type_resize, |
78 | 44 | mir_event_type_prompt_session_state_change | 44 | mir_event_type_prompt_session_state_change, |
79 | 45 | mir_event_type_orientation | ||
80 | 45 | } MirEventType; | 46 | } MirEventType; |
81 | 46 | 47 | ||
82 | 47 | typedef enum { | 48 | typedef enum { |
83 | @@ -212,6 +213,14 @@ | |||
84 | 212 | MirPromptSessionState new_state; | 213 | MirPromptSessionState new_state; |
85 | 213 | } MirPromptSessionEvent; | 214 | } MirPromptSessionEvent; |
86 | 214 | 215 | ||
87 | 216 | typedef struct MirOrientationEvent | ||
88 | 217 | { | ||
89 | 218 | MirEventType type; | ||
90 | 219 | |||
91 | 220 | int surface_id; | ||
92 | 221 | MirOrientation direction; | ||
93 | 222 | } MirOrientationEvent; | ||
94 | 223 | |||
95 | 215 | typedef union | 224 | typedef union |
96 | 216 | { | 225 | { |
97 | 217 | MirEventType type; | 226 | MirEventType type; |
98 | @@ -220,6 +229,7 @@ | |||
99 | 220 | MirSurfaceEvent surface; | 229 | MirSurfaceEvent surface; |
100 | 221 | MirResizeEvent resize; | 230 | MirResizeEvent resize; |
101 | 222 | MirPromptSessionEvent prompt_session; | 231 | MirPromptSessionEvent prompt_session; |
102 | 232 | MirOrientationEvent orientation; | ||
103 | 223 | } MirEvent; | 233 | } MirEvent; |
104 | 224 | 234 | ||
105 | 225 | #ifdef __cplusplus | 235 | #ifdef __cplusplus |
106 | 226 | 236 | ||
107 | === modified file 'include/test/mir_test_doubles/stub_scene_surface.h' | |||
108 | --- include/test/mir_test_doubles/stub_scene_surface.h 2014-06-05 14:38:50 +0000 | |||
109 | +++ include/test/mir_test_doubles/stub_scene_surface.h 2014-06-19 14:21:51 +0000 | |||
110 | @@ -77,6 +77,7 @@ | |||
111 | 77 | void resize(geometry::Size const&) override {} | 77 | void resize(geometry::Size const&) override {} |
112 | 78 | void set_transformation(glm::mat4 const&) override {} | 78 | void set_transformation(glm::mat4 const&) override {} |
113 | 79 | void set_alpha(float) override {} | 79 | void set_alpha(float) override {} |
114 | 80 | void set_orientation(MirOrientation) {} | ||
115 | 80 | void force_requests_to_complete() override {} | 81 | void force_requests_to_complete() override {} |
116 | 81 | 82 | ||
117 | 82 | void add_observer(std::shared_ptr<scene::SurfaceObserver> const&) override {} | 83 | void add_observer(std::shared_ptr<scene::SurfaceObserver> const&) override {} |
118 | 83 | 84 | ||
119 | === modified file 'src/client/rpc/mir_socket_rpc_channel.cpp' | |||
120 | --- src/client/rpc/mir_socket_rpc_channel.cpp 2014-06-12 15:35:08 +0000 | |||
121 | +++ src/client/rpc/mir_socket_rpc_channel.cpp 2014-06-19 14:21:51 +0000 | |||
122 | @@ -418,24 +418,25 @@ | |||
123 | 418 | 418 | ||
124 | 419 | rpc_report->event_parsing_succeeded(e); | 419 | rpc_report->event_parsing_succeeded(e); |
125 | 420 | 420 | ||
144 | 421 | event_sink->handle_event(e); | 421 | auto const send_e = [&e](MirSurface* surface) |
145 | 422 | 422 | { surface->handle_event(e); }; | |
146 | 423 | // todo - surfaces should register with the event handler register. | 423 | |
147 | 424 | if (e.type == mir_event_type_surface) | 424 | switch (e.type) |
148 | 425 | { | 425 | { |
149 | 426 | surface_map->with_surface_do(e.surface.id, | 426 | case mir_event_type_surface: |
150 | 427 | [&e](MirSurface* surface) | 427 | surface_map->with_surface_do(e.surface.id, send_e); |
151 | 428 | { | 428 | break; |
152 | 429 | surface->handle_event(e); | 429 | |
153 | 430 | }); | 430 | case mir_event_type_resize: |
154 | 431 | } | 431 | surface_map->with_surface_do(e.resize.surface_id, send_e); |
155 | 432 | else if (e.type == mir_event_type_resize) | 432 | break; |
156 | 433 | { | 433 | |
157 | 434 | surface_map->with_surface_do(e.resize.surface_id, | 434 | case mir_event_type_orientation: |
158 | 435 | [&e](MirSurface* surface) | 435 | surface_map->with_surface_do(e.orientation.surface_id, send_e); |
159 | 436 | { | 436 | break; |
160 | 437 | surface->handle_event(e); | 437 | |
161 | 438 | }); | 438 | default: |
162 | 439 | event_sink->handle_event(e); | ||
163 | 439 | } | 440 | } |
164 | 440 | } | 441 | } |
165 | 441 | else | 442 | else |
166 | 442 | 443 | ||
167 | === modified file 'src/server/scene/basic_surface.cpp' | |||
168 | --- src/server/scene/basic_surface.cpp 2014-06-12 15:35:08 +0000 | |||
169 | +++ src/server/scene/basic_surface.cpp 2014-06-19 14:21:51 +0000 | |||
170 | @@ -88,6 +88,14 @@ | |||
171 | 88 | p->alpha_set_to(alpha); | 88 | p->alpha_set_to(alpha); |
172 | 89 | } | 89 | } |
173 | 90 | 90 | ||
174 | 91 | void ms::SurfaceObservers::orientation_set_to(MirOrientation orientation) | ||
175 | 92 | { | ||
176 | 93 | std::unique_lock<decltype(mutex)> lock(mutex); | ||
177 | 94 | // TBD Maybe we should copy observers so we can release the lock? | ||
178 | 95 | for (auto const& p : observers) | ||
179 | 96 | p->orientation_set_to(orientation); | ||
180 | 97 | } | ||
181 | 98 | |||
182 | 91 | void ms::SurfaceObservers::transformation_set_to(glm::mat4 const& t) | 99 | void ms::SurfaceObservers::transformation_set_to(glm::mat4 const& t) |
183 | 92 | { | 100 | { |
184 | 93 | std::unique_lock<decltype(mutex)> lock(mutex); | 101 | std::unique_lock<decltype(mutex)> lock(mutex); |
185 | @@ -340,6 +348,10 @@ | |||
186 | 340 | observers.alpha_set_to(alpha); | 348 | observers.alpha_set_to(alpha); |
187 | 341 | } | 349 | } |
188 | 342 | 350 | ||
189 | 351 | void ms::BasicSurface::set_orientation(MirOrientation orientation) | ||
190 | 352 | { | ||
191 | 353 | observers.orientation_set_to(orientation); | ||
192 | 354 | } | ||
193 | 343 | 355 | ||
194 | 344 | void ms::BasicSurface::set_transformation(glm::mat4 const& t) | 356 | void ms::BasicSurface::set_transformation(glm::mat4 const& t) |
195 | 345 | { | 357 | { |
196 | 346 | 358 | ||
197 | === modified file 'src/server/scene/basic_surface.h' | |||
198 | --- src/server/scene/basic_surface.h 2014-06-12 15:35:08 +0000 | |||
199 | +++ src/server/scene/basic_surface.h 2014-06-19 14:21:51 +0000 | |||
200 | @@ -64,6 +64,7 @@ | |||
201 | 64 | void hidden_set_to(bool hide) override; | 64 | void hidden_set_to(bool hide) override; |
202 | 65 | void frame_posted(int frames_available) override; | 65 | void frame_posted(int frames_available) override; |
203 | 66 | void alpha_set_to(float alpha) override; | 66 | void alpha_set_to(float alpha) override; |
204 | 67 | void orientation_set_to(MirOrientation orientation) override; | ||
205 | 67 | void transformation_set_to(glm::mat4 const& t) override; | 68 | void transformation_set_to(glm::mat4 const& t) override; |
206 | 68 | void reception_mode_set_to(input::InputReceptionMode mode) override; | 69 | void reception_mode_set_to(input::InputReceptionMode mode) override; |
207 | 69 | void cursor_image_set_to(graphics::CursorImage const& image) override; | 70 | void cursor_image_set_to(graphics::CursorImage const& image) override; |
208 | @@ -121,6 +122,7 @@ | |||
209 | 121 | geometry::Rectangle input_bounds() const override; | 122 | geometry::Rectangle input_bounds() const override; |
210 | 122 | bool input_area_contains(geometry::Point const& point) const override; | 123 | bool input_area_contains(geometry::Point const& point) const override; |
211 | 123 | void set_alpha(float alpha) override; | 124 | void set_alpha(float alpha) override; |
212 | 125 | void set_orientation(MirOrientation orientation) override; | ||
213 | 124 | void set_transformation(glm::mat4 const&) override; | 126 | void set_transformation(glm::mat4 const&) override; |
214 | 125 | 127 | ||
215 | 126 | bool visible() const; | 128 | bool visible() const; |
216 | 127 | 129 | ||
217 | === modified file 'src/server/scene/legacy_surface_change_notification.cpp' | |||
218 | --- src/server/scene/legacy_surface_change_notification.cpp 2014-06-12 15:35:08 +0000 | |||
219 | +++ src/server/scene/legacy_surface_change_notification.cpp 2014-06-19 14:21:51 +0000 | |||
220 | @@ -56,6 +56,11 @@ | |||
221 | 56 | notify_scene_change(); | 56 | notify_scene_change(); |
222 | 57 | } | 57 | } |
223 | 58 | 58 | ||
224 | 59 | // An orientation change alone is not enough to trigger recomposition. | ||
225 | 60 | void ms::LegacySurfaceChangeNotification::orientation_set_to(MirOrientation /*orientation*/) | ||
226 | 61 | { | ||
227 | 62 | } | ||
228 | 63 | |||
229 | 59 | void ms::LegacySurfaceChangeNotification::transformation_set_to(glm::mat4 const& /*t*/) | 64 | void ms::LegacySurfaceChangeNotification::transformation_set_to(glm::mat4 const& /*t*/) |
230 | 60 | { | 65 | { |
231 | 61 | notify_scene_change(); | 66 | notify_scene_change(); |
232 | 62 | 67 | ||
233 | === modified file 'src/server/scene/legacy_surface_change_notification.h' | |||
234 | --- src/server/scene/legacy_surface_change_notification.h 2014-06-12 15:35:08 +0000 | |||
235 | +++ src/server/scene/legacy_surface_change_notification.h 2014-06-19 14:21:51 +0000 | |||
236 | @@ -42,6 +42,7 @@ | |||
237 | 42 | void hidden_set_to(bool /*hide*/) override; | 42 | void hidden_set_to(bool /*hide*/) override; |
238 | 43 | void frame_posted(int frames_available) override; | 43 | void frame_posted(int frames_available) override; |
239 | 44 | void alpha_set_to(float /*alpha*/) override; | 44 | void alpha_set_to(float /*alpha*/) override; |
240 | 45 | void orientation_set_to(MirOrientation orientation) override; | ||
241 | 45 | void transformation_set_to(glm::mat4 const& /*t*/) override; | 46 | void transformation_set_to(glm::mat4 const& /*t*/) override; |
242 | 46 | void attrib_changed(MirSurfaceAttrib, int) override; | 47 | void attrib_changed(MirSurfaceAttrib, int) override; |
243 | 47 | void reception_mode_set_to(input::InputReceptionMode mode) override; | 48 | void reception_mode_set_to(input::InputReceptionMode mode) override; |
244 | 48 | 49 | ||
245 | === modified file 'src/server/scene/null_surface_observer.cpp' | |||
246 | --- src/server/scene/null_surface_observer.cpp 2014-06-12 15:35:08 +0000 | |||
247 | +++ src/server/scene/null_surface_observer.cpp 2014-06-19 14:21:51 +0000 | |||
248 | @@ -27,6 +27,7 @@ | |||
249 | 27 | void ms::NullSurfaceObserver::hidden_set_to(bool /*hide*/) {} | 27 | void ms::NullSurfaceObserver::hidden_set_to(bool /*hide*/) {} |
250 | 28 | void ms::NullSurfaceObserver::frame_posted(int /*frames_available*/) {} | 28 | void ms::NullSurfaceObserver::frame_posted(int /*frames_available*/) {} |
251 | 29 | void ms::NullSurfaceObserver::alpha_set_to(float /*alpha*/) {} | 29 | void ms::NullSurfaceObserver::alpha_set_to(float /*alpha*/) {} |
252 | 30 | void ms::NullSurfaceObserver::orientation_set_to(MirOrientation /*orientation*/) {} | ||
253 | 30 | void ms::NullSurfaceObserver::transformation_set_to(glm::mat4 const& /*t*/) {} | 31 | void ms::NullSurfaceObserver::transformation_set_to(glm::mat4 const& /*t*/) {} |
254 | 31 | void ms::NullSurfaceObserver::reception_mode_set_to(input::InputReceptionMode /*mode*/) {} | 32 | void ms::NullSurfaceObserver::reception_mode_set_to(input::InputReceptionMode /*mode*/) {} |
255 | 32 | void ms::NullSurfaceObserver::cursor_image_set_to(mg::CursorImage const& /*image*/) {} | 33 | void ms::NullSurfaceObserver::cursor_image_set_to(mg::CursorImage const& /*image*/) {} |
256 | 33 | 34 | ||
257 | === modified file 'src/server/scene/surface_event_source.cpp' | |||
258 | --- src/server/scene/surface_event_source.cpp 2014-04-15 05:31:19 +0000 | |||
259 | +++ src/server/scene/surface_event_source.cpp 2014-06-19 14:21:51 +0000 | |||
260 | @@ -62,3 +62,15 @@ | |||
261 | 62 | 62 | ||
262 | 63 | event_sink->handle_event(e); | 63 | event_sink->handle_event(e); |
263 | 64 | } | 64 | } |
264 | 65 | |||
265 | 66 | void ms::SurfaceEventSource::orientation_set_to(MirOrientation orientation) | ||
266 | 67 | { | ||
267 | 68 | MirEvent e; | ||
268 | 69 | memset(&e, 0, sizeof e); | ||
269 | 70 | |||
270 | 71 | e.type = mir_event_type_orientation; | ||
271 | 72 | e.orientation.surface_id = id.as_value(); | ||
272 | 73 | e.orientation.direction = orientation; | ||
273 | 74 | |||
274 | 75 | event_sink->handle_event(e); | ||
275 | 76 | } | ||
276 | 65 | 77 | ||
277 | === modified file 'tests/acceptance-tests/CMakeLists.txt' | |||
278 | --- tests/acceptance-tests/CMakeLists.txt 2014-06-14 19:52:52 +0000 | |||
279 | +++ tests/acceptance-tests/CMakeLists.txt 2014-06-19 14:21:51 +0000 | |||
280 | @@ -17,6 +17,7 @@ | |||
281 | 17 | clients.cpp | 17 | clients.cpp |
282 | 18 | test_client_library.cpp | 18 | test_client_library.cpp |
283 | 19 | test_client_library_old.cpp | 19 | test_client_library_old.cpp |
284 | 20 | test_client_surface_events.cpp | ||
285 | 20 | test_custom_input_dispatcher.cpp | 21 | test_custom_input_dispatcher.cpp |
286 | 21 | test_client_surfaces.cpp | 22 | test_client_surfaces.cpp |
287 | 22 | test_test_framework.cpp | 23 | test_test_framework.cpp |
288 | 23 | 24 | ||
289 | === modified file 'tests/acceptance-tests/test_client_library.cpp' | |||
290 | --- tests/acceptance-tests/test_client_library.cpp 2014-06-03 10:26:58 +0000 | |||
291 | +++ tests/acceptance-tests/test_client_library.cpp 2014-06-19 14:21:51 +0000 | |||
292 | @@ -313,73 +313,6 @@ | |||
293 | 313 | mir_connection_release(connection); | 313 | mir_connection_release(connection); |
294 | 314 | } | 314 | } |
295 | 315 | 315 | ||
296 | 316 | TEST_F(ClientLibrary, receives_surface_state_events) | ||
297 | 317 | { | ||
298 | 318 | connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__); | ||
299 | 319 | |||
300 | 320 | MirSurfaceParameters const request_params = | ||
301 | 321 | { | ||
302 | 322 | __PRETTY_FUNCTION__, | ||
303 | 323 | 640, 480, | ||
304 | 324 | mir_pixel_format_abgr_8888, | ||
305 | 325 | mir_buffer_usage_hardware, | ||
306 | 326 | mir_display_output_id_invalid | ||
307 | 327 | }; | ||
308 | 328 | |||
309 | 329 | MirEventDelegate delegate{&event_callback, this}; | ||
310 | 330 | MirSurface* other_surface = mir_connection_create_surface_sync(connection, &request_params); | ||
311 | 331 | ASSERT_TRUE(mir_surface_is_valid(other_surface)); | ||
312 | 332 | |||
313 | 333 | mir_surface_set_event_handler(other_surface, nullptr); | ||
314 | 334 | |||
315 | 335 | surface = mir_connection_create_surface_sync(connection, &request_params); | ||
316 | 336 | ASSERT_TRUE(mir_surface_is_valid(surface)); | ||
317 | 337 | |||
318 | 338 | mir_surface_set_event_handler(surface, &delegate); | ||
319 | 339 | |||
320 | 340 | int surface_id = mir_debug_surface_id(surface); | ||
321 | 341 | |||
322 | 342 | mir_wait_for(mir_surface_set_state(surface, mir_surface_state_fullscreen)); | ||
323 | 343 | mir_wait_for(mir_surface_set_state(other_surface, mir_surface_state_minimized)); | ||
324 | 344 | EXPECT_THAT(last_event_surface, Eq(surface)); | ||
325 | 345 | EXPECT_THAT(last_event.type, Eq(mir_event_type_surface)); | ||
326 | 346 | EXPECT_THAT(last_event.surface.id, Eq(surface_id)); | ||
327 | 347 | EXPECT_THAT(last_event.surface.attrib, Eq(mir_surface_attrib_state)); | ||
328 | 348 | EXPECT_THAT(last_event.surface.value, Eq(mir_surface_state_fullscreen)); | ||
329 | 349 | |||
330 | 350 | mir_wait_for(mir_surface_set_state(surface, static_cast<MirSurfaceState>(999))); | ||
331 | 351 | EXPECT_THAT(last_event_surface, Eq(surface)); | ||
332 | 352 | EXPECT_THAT(last_event.type, Eq(mir_event_type_surface)); | ||
333 | 353 | EXPECT_THAT(last_event.surface.id, Eq(surface_id)); | ||
334 | 354 | EXPECT_THAT(last_event.surface.attrib, Eq(mir_surface_attrib_state)); | ||
335 | 355 | EXPECT_THAT(last_event.surface.value, Eq(mir_surface_state_fullscreen)); | ||
336 | 356 | |||
337 | 357 | memset(&last_event, 0, sizeof last_event); | ||
338 | 358 | last_event_surface = nullptr; | ||
339 | 359 | |||
340 | 360 | mir_wait_for(mir_surface_set_state(surface, mir_surface_state_minimized)); | ||
341 | 361 | EXPECT_THAT(last_event_surface, Eq(surface)); | ||
342 | 362 | EXPECT_THAT(last_event.type, Eq(mir_event_type_surface)); | ||
343 | 363 | EXPECT_THAT(last_event.surface.id, Eq(surface_id)); | ||
344 | 364 | EXPECT_THAT(last_event.surface.attrib, Eq(mir_surface_attrib_state)); | ||
345 | 365 | EXPECT_THAT(last_event.surface.value, Eq(mir_surface_state_minimized)); | ||
346 | 366 | |||
347 | 367 | memset(&last_event, 0, sizeof last_event); | ||
348 | 368 | last_event_surface = nullptr; | ||
349 | 369 | |||
350 | 370 | mir_wait_for(mir_surface_set_state(surface, static_cast<MirSurfaceState>(777))); | ||
351 | 371 | mir_wait_for(mir_surface_set_state(other_surface, mir_surface_state_maximized)); | ||
352 | 372 | EXPECT_THAT(last_event_surface, IsNull()); | ||
353 | 373 | EXPECT_THAT(last_event.type, Eq(0)); | ||
354 | 374 | EXPECT_THAT(last_event.surface.id, Eq(0)); | ||
355 | 375 | EXPECT_THAT(last_event.surface.attrib, Eq(0)); | ||
356 | 376 | EXPECT_THAT(last_event.surface.value, Eq(0)); | ||
357 | 377 | |||
358 | 378 | mir_surface_release_sync(surface); | ||
359 | 379 | mir_surface_release_sync(other_surface); | ||
360 | 380 | mir_connection_release(connection); | ||
361 | 381 | } | ||
362 | 382 | |||
363 | 383 | TEST_F(ClientLibrary, receives_surface_dpi_value) | 316 | TEST_F(ClientLibrary, receives_surface_dpi_value) |
364 | 384 | { | 317 | { |
365 | 385 | connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__); | 318 | connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__); |
366 | 386 | 319 | ||
367 | === added file 'tests/acceptance-tests/test_client_surface_events.cpp' | |||
368 | --- tests/acceptance-tests/test_client_surface_events.cpp 1970-01-01 00:00:00 +0000 | |||
369 | +++ tests/acceptance-tests/test_client_surface_events.cpp 2014-06-19 14:21:51 +0000 | |||
370 | @@ -0,0 +1,236 @@ | |||
371 | 1 | /* | ||
372 | 2 | * Copyright © 2014 Canonical Ltd. | ||
373 | 3 | * | ||
374 | 4 | * This program is free software: you can redistribute it and/or modify | ||
375 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
376 | 6 | * published by the Free Software Foundation. | ||
377 | 7 | * | ||
378 | 8 | * This program is distributed in the hope that it will be useful, | ||
379 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
380 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
381 | 11 | * GNU General Public License for more details. | ||
382 | 12 | * | ||
383 | 13 | * You should have received a copy of the GNU General Public License | ||
384 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
385 | 15 | * | ||
386 | 16 | * Authored by: Nick Dedekind <nick.dedekind@canonical.com> | ||
387 | 17 | */ | ||
388 | 18 | |||
389 | 19 | #include "mir_toolkit/mir_client_library.h" | ||
390 | 20 | #include "mir_toolkit/mir_client_library_debug.h" | ||
391 | 21 | |||
392 | 22 | #include "mir/shell/surface_coordinator_wrapper.h" | ||
393 | 23 | |||
394 | 24 | #include "mir/scene/surface.h" | ||
395 | 25 | #include "mir/scene/surface_creation_parameters.h" | ||
396 | 26 | |||
397 | 27 | #include "mir_test_framework/stubbed_server_configuration.h" | ||
398 | 28 | #include "mir_test_framework/basic_client_server_fixture.h" | ||
399 | 29 | |||
400 | 30 | #include <gtest/gtest.h> | ||
401 | 31 | #include <gmock/gmock.h> | ||
402 | 32 | |||
403 | 33 | #include <condition_variable> | ||
404 | 34 | #include <chrono> | ||
405 | 35 | #include <mutex> | ||
406 | 36 | |||
407 | 37 | namespace mtf = mir_test_framework; | ||
408 | 38 | namespace ms = mir::scene; | ||
409 | 39 | namespace msh = mir::shell; | ||
410 | 40 | |||
411 | 41 | using namespace testing; | ||
412 | 42 | |||
413 | 43 | namespace | ||
414 | 44 | { | ||
415 | 45 | struct MockSurfaceCoordinator : msh::SurfaceCoordinatorWrapper | ||
416 | 46 | { | ||
417 | 47 | MockSurfaceCoordinator(std::shared_ptr<ms::SurfaceCoordinator> const& wrapped) : | ||
418 | 48 | msh::SurfaceCoordinatorWrapper(wrapped) | ||
419 | 49 | { | ||
420 | 50 | } | ||
421 | 51 | |||
422 | 52 | std::shared_ptr<ms::Surface> add_surface( | ||
423 | 53 | ms::SurfaceCreationParameters const& params, | ||
424 | 54 | ms::Session* session) override | ||
425 | 55 | { | ||
426 | 56 | latest_surface = wrapped->add_surface(params, session); | ||
427 | 57 | return latest_surface; | ||
428 | 58 | } | ||
429 | 59 | |||
430 | 60 | std::shared_ptr<ms::Surface> latest_surface; | ||
431 | 61 | }; | ||
432 | 62 | |||
433 | 63 | struct MyConfig : mtf::StubbedServerConfiguration | ||
434 | 64 | { | ||
435 | 65 | std::shared_ptr<ms::SurfaceCoordinator> wrap_surface_coordinator( | ||
436 | 66 | std::shared_ptr<ms::SurfaceCoordinator> const& wrapped) override | ||
437 | 67 | { | ||
438 | 68 | auto const msc = std::make_shared<MockSurfaceCoordinator>(wrapped); | ||
439 | 69 | mock_surface_coordinator = msc; | ||
440 | 70 | return msc; | ||
441 | 71 | } | ||
442 | 72 | |||
443 | 73 | std::shared_ptr<MockSurfaceCoordinator> the_mock_surface_coordinator() const | ||
444 | 74 | { | ||
445 | 75 | return mock_surface_coordinator.lock(); | ||
446 | 76 | } | ||
447 | 77 | |||
448 | 78 | std::shared_ptr<ms::Surface> the_latest_surface() const | ||
449 | 79 | { | ||
450 | 80 | return the_mock_surface_coordinator()->latest_surface; | ||
451 | 81 | } | ||
452 | 82 | |||
453 | 83 | std::weak_ptr<MockSurfaceCoordinator> mock_surface_coordinator; | ||
454 | 84 | }; | ||
455 | 85 | |||
456 | 86 | using BasicClientServerFixture = mtf::BasicClientServerFixture<MyConfig>; | ||
457 | 87 | |||
458 | 88 | struct ClientSurfaceEvents : BasicClientServerFixture | ||
459 | 89 | { | ||
460 | 90 | MirSurfaceParameters const request_params | ||
461 | 91 | { | ||
462 | 92 | __FILE__, | ||
463 | 93 | 640, 480, | ||
464 | 94 | mir_pixel_format_abgr_8888, | ||
465 | 95 | mir_buffer_usage_hardware, | ||
466 | 96 | mir_display_output_id_invalid | ||
467 | 97 | }; | ||
468 | 98 | |||
469 | 99 | MirSurface* surface{nullptr}; | ||
470 | 100 | MirSurface* other_surface; | ||
471 | 101 | |||
472 | 102 | std::mutex last_event_mutex; | ||
473 | 103 | std::condition_variable last_event_cv; | ||
474 | 104 | MirEvent last_event{}; | ||
475 | 105 | MirSurface* last_event_surface = nullptr; | ||
476 | 106 | MirEventDelegate delegate{&event_callback, this}; | ||
477 | 107 | |||
478 | 108 | std::shared_ptr<ms::Surface> scene_surface; | ||
479 | 109 | |||
480 | 110 | static void event_callback(MirSurface* surface, MirEvent const* event, void* ctx) | ||
481 | 111 | { | ||
482 | 112 | ClientSurfaceEvents* self = static_cast<ClientSurfaceEvents*>(ctx); | ||
483 | 113 | std::lock_guard<decltype(self->last_event_mutex)> last_event_lock{self->last_event_mutex}; | ||
484 | 114 | self->last_event = *event; | ||
485 | 115 | self->last_event_surface = surface; | ||
486 | 116 | self->last_event_cv.notify_one(); | ||
487 | 117 | } | ||
488 | 118 | |||
489 | 119 | bool wait_for_event(MirEventType type, std::chrono::milliseconds delay) | ||
490 | 120 | { | ||
491 | 121 | std::unique_lock<decltype(last_event_mutex)> last_event_lock{last_event_mutex}; | ||
492 | 122 | return last_event_cv.wait_for(last_event_lock, delay, | ||
493 | 123 | [&] { return !!last_event_surface && last_event.type == type; }); | ||
494 | 124 | } | ||
495 | 125 | |||
496 | 126 | void reset_last_event() | ||
497 | 127 | { | ||
498 | 128 | std::lock_guard<decltype(last_event_mutex)> last_event_lock{last_event_mutex}; | ||
499 | 129 | memset(&last_event, 0, sizeof last_event); | ||
500 | 130 | last_event_surface = nullptr; | ||
501 | 131 | } | ||
502 | 132 | |||
503 | 133 | void SetUp() override | ||
504 | 134 | { | ||
505 | 135 | BasicClientServerFixture::SetUp(); | ||
506 | 136 | |||
507 | 137 | surface = mir_connection_create_surface_sync(connection, &request_params); | ||
508 | 138 | mir_surface_set_event_handler(surface, &delegate); | ||
509 | 139 | |||
510 | 140 | scene_surface = server_configuration.the_latest_surface(); | ||
511 | 141 | |||
512 | 142 | other_surface = mir_connection_create_surface_sync(connection, &request_params); | ||
513 | 143 | mir_surface_set_event_handler(other_surface, nullptr); | ||
514 | 144 | |||
515 | 145 | reset_last_event(); | ||
516 | 146 | } | ||
517 | 147 | |||
518 | 148 | void TearDown() override | ||
519 | 149 | { | ||
520 | 150 | mir_surface_release_sync(other_surface); | ||
521 | 151 | mir_surface_release_sync(surface); | ||
522 | 152 | |||
523 | 153 | BasicClientServerFixture::TearDown(); | ||
524 | 154 | } | ||
525 | 155 | }; | ||
526 | 156 | } | ||
527 | 157 | |||
528 | 158 | TEST_F(ClientSurfaceEvents, surface_receives_state_events) | ||
529 | 159 | { | ||
530 | 160 | int surface_id = mir_debug_surface_id(surface); | ||
531 | 161 | |||
532 | 162 | { | ||
533 | 163 | mir_wait_for(mir_surface_set_state(surface, mir_surface_state_fullscreen)); | ||
534 | 164 | mir_wait_for(mir_surface_set_state(other_surface, mir_surface_state_minimized)); | ||
535 | 165 | |||
536 | 166 | std::lock_guard<decltype(last_event_mutex)> last_event_lock{last_event_mutex}; | ||
537 | 167 | |||
538 | 168 | EXPECT_THAT(last_event_surface, Eq(surface)); | ||
539 | 169 | EXPECT_THAT(last_event.type, Eq(mir_event_type_surface)); | ||
540 | 170 | EXPECT_THAT(last_event.surface.id, Eq(surface_id)); | ||
541 | 171 | EXPECT_THAT(last_event.surface.attrib, Eq(mir_surface_attrib_state)); | ||
542 | 172 | EXPECT_THAT(last_event.surface.value, Eq(mir_surface_state_fullscreen)); | ||
543 | 173 | } | ||
544 | 174 | |||
545 | 175 | { | ||
546 | 176 | mir_wait_for(mir_surface_set_state(surface, static_cast<MirSurfaceState>(999))); | ||
547 | 177 | |||
548 | 178 | std::lock_guard<decltype(last_event_mutex)> last_event_lock{last_event_mutex}; | ||
549 | 179 | |||
550 | 180 | EXPECT_THAT(last_event_surface, Eq(surface)); | ||
551 | 181 | EXPECT_THAT(last_event.type, Eq(mir_event_type_surface)); | ||
552 | 182 | EXPECT_THAT(last_event.surface.id, Eq(surface_id)); | ||
553 | 183 | EXPECT_THAT(last_event.surface.attrib, Eq(mir_surface_attrib_state)); | ||
554 | 184 | EXPECT_THAT(last_event.surface.value, Eq(mir_surface_state_fullscreen)); | ||
555 | 185 | } | ||
556 | 186 | |||
557 | 187 | reset_last_event(); | ||
558 | 188 | |||
559 | 189 | { | ||
560 | 190 | mir_wait_for(mir_surface_set_state(surface, mir_surface_state_minimized)); | ||
561 | 191 | |||
562 | 192 | std::lock_guard<decltype(last_event_mutex)> last_event_lock{last_event_mutex}; | ||
563 | 193 | |||
564 | 194 | EXPECT_THAT(last_event_surface, Eq(surface)); | ||
565 | 195 | EXPECT_THAT(last_event.type, Eq(mir_event_type_surface)); | ||
566 | 196 | EXPECT_THAT(last_event.surface.id, Eq(surface_id)); | ||
567 | 197 | EXPECT_THAT(last_event.surface.attrib, Eq(mir_surface_attrib_state)); | ||
568 | 198 | EXPECT_THAT(last_event.surface.value, Eq(mir_surface_state_minimized)); | ||
569 | 199 | } | ||
570 | 200 | |||
571 | 201 | reset_last_event(); | ||
572 | 202 | |||
573 | 203 | { | ||
574 | 204 | mir_wait_for(mir_surface_set_state(surface, static_cast<MirSurfaceState>(777))); | ||
575 | 205 | mir_wait_for(mir_surface_set_state(other_surface, mir_surface_state_maximized)); | ||
576 | 206 | |||
577 | 207 | std::lock_guard<decltype(last_event_mutex)> last_event_lock{last_event_mutex}; | ||
578 | 208 | |||
579 | 209 | EXPECT_THAT(last_event_surface, IsNull()); | ||
580 | 210 | EXPECT_THAT(last_event.type, Eq(0)); | ||
581 | 211 | EXPECT_THAT(last_event.surface.id, Eq(0)); | ||
582 | 212 | EXPECT_THAT(last_event.surface.attrib, Eq(0)); | ||
583 | 213 | EXPECT_THAT(last_event.surface.value, Eq(0)); | ||
584 | 214 | } | ||
585 | 215 | } | ||
586 | 216 | |||
587 | 217 | struct OrientationEvents : ClientSurfaceEvents, ::testing::WithParamInterface<MirOrientation> {}; | ||
588 | 218 | |||
589 | 219 | TEST_P(OrientationEvents, surface_receives_orientation_events) | ||
590 | 220 | { | ||
591 | 221 | auto const direction = GetParam(); | ||
592 | 222 | |||
593 | 223 | scene_surface->set_orientation(direction); | ||
594 | 224 | |||
595 | 225 | EXPECT_TRUE(wait_for_event(mir_event_type_orientation, std::chrono::seconds(1))); | ||
596 | 226 | |||
597 | 227 | std::lock_guard<decltype(last_event_mutex)> last_event_lock{last_event_mutex}; | ||
598 | 228 | |||
599 | 229 | EXPECT_THAT(last_event_surface, Eq(surface)); | ||
600 | 230 | EXPECT_THAT(last_event.type, Eq(mir_event_type_orientation)); | ||
601 | 231 | EXPECT_THAT(last_event.orientation.direction, Eq(direction)); | ||
602 | 232 | } | ||
603 | 233 | |||
604 | 234 | INSTANTIATE_TEST_CASE_P(ClientSurfaceEvents, | ||
605 | 235 | OrientationEvents, | ||
606 | 236 | Values(mir_orientation_normal, mir_orientation_left, mir_orientation_inverted, mir_orientation_right)); |
PASSED: Continuous integration, rev:1709 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- ci/1934/ jenkins. qa.ubuntu. com/job/ mir-android- utopic- i386-build/ 616 jenkins. qa.ubuntu. com/job/ mir-clang- utopic- amd64-build/ 622 jenkins. qa.ubuntu. com/job/ mir-mediumtests -utopic- touch/616 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- utopic- amd64-ci/ 455 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- utopic- amd64-ci/ 455/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- utopic- armhf-ci/ 452 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- utopic- armhf-ci/ 452/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- armhf/1829 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- armhf/1829/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -runner- mako/1809 s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 8640
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/mir- team-mir- development- branch- ci/1934/ rebuild
http://