Merge lp:~kdub/mir/prepare-for-display-notifications into lp:~mir-team/mir/trunk
- prepare-for-display-notifications
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Kevin DuBois |
Approved revision: | no longer in the source branch. |
Merged at revision: | 906 |
Proposed branch: | lp:~kdub/mir/prepare-for-display-notifications |
Merge into: | lp:~mir-team/mir/trunk |
Diff against target: |
2661 lines (+727/-568) 62 files modified
examples/demo-inprocess-surface-client/inprocess_egl_client.cpp (+1/-1) include/server/mir/frontend/event_sink.h (+6/-7) include/server/mir/frontend/protobuf_ipc_factory.h (+2/-5) include/server/mir/frontend/session_mediator.h (+3/-7) include/server/mir/frontend/shell.h (+3/-5) include/server/mir/shell/application_session.h (+3/-9) include/server/mir/shell/organising_surface_factory.h (+1/-1) include/server/mir/shell/session_manager.h (+6/-1) include/server/mir/shell/surface.h (+3/-8) include/server/mir/shell/surface_factory.h (+2/-3) include/server/mir/shell/surface_source.h (+1/-1) include/test/mir_test_doubles/mock_frontend_surface.h (+55/-0) include/test/mir_test_doubles/mock_shell.h (+2/-1) include/test/mir_test_doubles/mock_surface.h (+2/-1) include/test/mir_test_doubles/mock_surface_factory.h (+1/-1) include/test/mir_test_doubles/null_event_sink.h (+36/-0) include/test/mir_test_doubles/stub_ipc_factory.h (+1/-1) include/test/mir_test_doubles/stub_session.h (+1/-1) include/test/mir_test_doubles/stub_shell.h (+1/-1) src/client/mir_connection.h (+0/-1) src/client/rpc/mir_basic_rpc_channel.h (+0/-4) src/client/rpc/mir_socket_rpc_channel.cpp (+0/-1) src/server/default_server_configuration.cpp (+1/-2) src/server/frontend/CMakeLists.txt (+2/-1) src/server/frontend/event_pipe.h (+0/-42) src/server/frontend/event_sender.cpp (+32/-13) src/server/frontend/event_sender.h (+46/-0) src/server/frontend/message_processor.h (+6/-25) src/server/frontend/message_receiver.h (+48/-0) src/server/frontend/message_sender.h (+46/-0) src/server/frontend/protobuf_message_processor.cpp (+1/-30) src/server/frontend/protobuf_message_processor.h (+6/-9) src/server/frontend/protobuf_socket_communicator.cpp (+20/-21) src/server/frontend/protobuf_socket_communicator.h (+3/-1) src/server/frontend/session_mediator.cpp (+2/-2) src/server/frontend/socket_messenger.cpp (+109/-0) src/server/frontend/socket_messenger.h (+51/-0) src/server/frontend/socket_session.cpp (+22/-90) src/server/frontend/socket_session.h (+9/-22) src/server/shell/application_session.cpp (+1/-11) src/server/shell/organising_surface_factory.cpp (+2/-2) src/server/shell/session_manager.cpp (+3/-4) src/server/shell/surface.cpp (+17/-31) src/server/shell/surface_source.cpp (+2/-6) tests/acceptance-tests/test_client_input.cpp (+1/-2) tests/integration-tests/graphics/android/test_internal_client.cpp (+1/-1) tests/integration-tests/shell/test_session.cpp (+5/-2) tests/integration-tests/shell/test_session_manager.cpp (+7/-7) tests/unit-tests/client/test_mir_connection.cpp (+0/-2) tests/unit-tests/frontend/CMakeLists.txt (+1/-1) tests/unit-tests/frontend/test_event_pipe.cpp (+0/-116) tests/unit-tests/frontend/test_session_mediator.cpp (+5/-5) tests/unit-tests/frontend/test_session_mediator_android.cpp (+2/-9) tests/unit-tests/frontend/test_session_mediator_gbm.cpp (+2/-2) tests/unit-tests/frontend/test_socket_session.cpp (+85/-0) tests/unit-tests/graphics/gbm/test_internal_native_surface.cpp (+1/-1) tests/unit-tests/shell/test_application_session.cpp (+14/-8) tests/unit-tests/shell/test_organising_surface_factory.cpp (+5/-5) tests/unit-tests/shell/test_registration_order_focus_sequence.cpp (+3/-2) tests/unit-tests/shell/test_session_manager.cpp (+8/-9) tests/unit-tests/shell/test_surface.cpp (+25/-22) tests/unit-tests/shell/test_the_session_container_implementation.cpp (+3/-2) |
To merge this branch: | bzr merge lp:~kdub/mir/prepare-for-display-notifications |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Alexandros Frantzis (community) | Approve | ||
Alan Griffiths | Approve | ||
Review via email: mp+177068@code.launchpad.net |
Commit message
prepare for global event sending (like display resizing) by separating the ability to send messages into distinct classes that is used in the client request service loops
clean up constructors that aren't used, functions that aren't needed as well.
Description of the change
From a high level, we have a server right now that is mostly oriented towards receiving a request from a client, then responding to the request. The exception to this is EventSink, where we send messages to the client based upon server events, not upon a client request. The area of the code that needs the EventSink interface at the moment is the shell, and it uses it to send out shell-related events to the client.
This branch essentially decouples the send/receive code so there's distinct interfaces that have to do with sending, that is used by the code that is involved in the send/receive code. This allows us to hand out objects implementing the 'sending' interfaces to the rest of the system (at this time, just to the shell for the MirEvents). So, we send out an EventSink interface to the client now that is just a sender object, not a ProtobufSocketC
clean up constructors that aren't used, functions that aren't needed as well. a lot of the churn is from EventSink moving namespaces.
I scraped this change off my bigger iteration to support display change notifications. (hopefully is easier to review that way) the plan for moving forward the Communicator to be able to hand out an object implementing a display notification interface. The object will own the same SocketSender interface that is used to respond to clients or to send Events. This new object will be collected on a global level so we can iterate over the senders to send out global events to all clients. The per-surface events coming from the shell system don't see any change to the way they currently work.
PS Jenkins bot (ps-jenkins) wrote : | # |
Alexandros Frantzis (afrantzis) wrote : | # |
1256 mfd::SocketSess
1257 - boost::
1258 + std::shared_
836 +class MessageSender
837 +{
841 + virtual boost::
SocketSession doesn't really need a MessageSender, just the socket to use. With this change we can move the get_socket() method (perhaps renamed to just socket()) to SocketSender, leaving MessageSender implementation agnostic. However, this creates problem with the ownership and lifetime of communication resources (e.g. the socket). How about something like:
class MessageSender; // sender interface
class MessageReceiver; // receiver interface
class SocketSenderRec
EventSender:
detail:
SocketSession:
Initialization in start_accept():
auto socket_send_receive = std::make_
auto event_sink = std::make_
auto msg_proc = std::make_
auto session = std::make_
We could even consider removing SocketSession and handling everything in ProtobufSocketC
Kevin DuBois (kdub) wrote : | # |
was working on this today, it is possible to remove the get_socket method with a bit of refactoring. should have it working tomorrow
Kevin DuBois (kdub) wrote : | # |
@alexandros, wrote a test (test_socket_
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:901
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:903
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Kevin DuBois (kdub) wrote : | # |
strange, http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:903
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:904
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Alan Griffiths (alan-griffiths) wrote : | # |
Nit:
726 + EventSender(
Ought to be explicit.
Alexandros Frantzis (afrantzis) wrote : | # |
Enough nits for a "Nits Fixing" (har har har) :)
19 - * Copyright © 2013 Canonical Ltd.
20 + * Copyright © 2012 Canonical Ltd.
?
232 + std::shared_
Incorrect alignment.
1066 + auto sender = std::make_
auto messenger = ...
1072 + auto session = std::make_
auto msg_processor = ...
1327 + std::shared_
1336 + : socket_
s/sender/receiver/
Alexandros Frantzis (afrantzis) wrote : | # |
Looks good.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:906
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:907
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Kevin DuBois (kdub) wrote : | # |
reproduced failure in lp:mir, filed bug about it https:/
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'examples/demo-inprocess-surface-client/inprocess_egl_client.cpp' |
2 | --- examples/demo-inprocess-surface-client/inprocess_egl_client.cpp 2013-07-30 15:37:33 +0000 |
3 | +++ examples/demo-inprocess-surface-client/inprocess_egl_client.cpp 2013-07-31 16:00:57 +0000 |
4 | @@ -97,7 +97,7 @@ |
5 | .of_buffer_usage(mc::BufferUsage::hardware) |
6 | .of_pixel_format(geom::PixelFormat::argb_8888); |
7 | auto session = session_manager->open_session("Inprocess client", |
8 | - std::shared_ptr<mir::events::EventSink>()); |
9 | + std::shared_ptr<mf::EventSink>()); |
10 | // TODO: Why do we get an ID? ~racarr |
11 | auto surface = session->get_surface(session_manager->create_surface_for(session, params)); |
12 | |
13 | |
14 | === renamed file 'include/shared/mir/events/event_sink.h' => 'include/server/mir/frontend/event_sink.h' |
15 | --- include/shared/mir/events/event_sink.h 2013-04-23 11:56:42 +0000 |
16 | +++ include/server/mir/frontend/event_sink.h 2013-07-31 16:00:57 +0000 |
17 | @@ -1,16 +1,16 @@ |
18 | /* |
19 | * Copyright © 2013 Canonical Ltd. |
20 | * |
21 | - * This program is free software: you can redistribute it and/or modify |
22 | - * it under the terms of the GNU Lesser General Public License version 3 as |
23 | - * published by the Free Software Foundation. |
24 | + * This program is free software: you can redistribute it and/or modify it |
25 | + * under the terms of the GNU General Public License version 3, |
26 | + * as published by the Free Software Foundation. |
27 | * |
28 | * This program is distributed in the hope that it will be useful, |
29 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
30 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31 | - * GNU Lesser General Public License for more details. |
32 | + * GNU General Public License for more details. |
33 | * |
34 | - * You should have received a copy of the GNU Lesser General Public License |
35 | + * You should have received a copy of the GNU General Public License |
36 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
37 | * |
38 | * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
39 | @@ -23,9 +23,8 @@ |
40 | |
41 | namespace mir |
42 | { |
43 | -namespace events |
44 | +namespace frontend |
45 | { |
46 | - |
47 | class EventSink |
48 | { |
49 | public: |
50 | |
51 | === modified file 'include/server/mir/frontend/protobuf_ipc_factory.h' |
52 | --- include/server/mir/frontend/protobuf_ipc_factory.h 2013-04-25 09:48:54 +0000 |
53 | +++ include/server/mir/frontend/protobuf_ipc_factory.h 2013-07-31 16:00:57 +0000 |
54 | @@ -23,16 +23,13 @@ |
55 | |
56 | namespace mir |
57 | { |
58 | -namespace events |
59 | -{ |
60 | -class EventSink; |
61 | -} |
62 | namespace protobuf |
63 | { |
64 | class DisplayServer; |
65 | } |
66 | namespace frontend |
67 | { |
68 | +class EventSink; |
69 | class ResourceCache; |
70 | class MessageProcessorReport; |
71 | |
72 | @@ -40,7 +37,7 @@ |
73 | { |
74 | public: |
75 | virtual std::shared_ptr<protobuf::DisplayServer> make_ipc_server( |
76 | - std::shared_ptr<events::EventSink> const& sink) = 0; |
77 | + std::shared_ptr<EventSink> const& sink) = 0; |
78 | virtual std::shared_ptr<ResourceCache> resource_cache() = 0; |
79 | virtual std::shared_ptr<MessageProcessorReport> report() = 0; |
80 | |
81 | |
82 | === modified file 'include/server/mir/frontend/session_mediator.h' |
83 | --- include/server/mir/frontend/session_mediator.h 2013-07-22 02:18:21 +0000 |
84 | +++ include/server/mir/frontend/session_mediator.h 2013-07-31 16:00:57 +0000 |
85 | @@ -28,10 +28,6 @@ |
86 | |
87 | namespace mir |
88 | { |
89 | -namespace events |
90 | -{ |
91 | -class EventSink; |
92 | -} |
93 | namespace graphics |
94 | { |
95 | class Buffer; |
96 | @@ -54,19 +50,19 @@ |
97 | class ResourceCache; |
98 | class SessionMediatorReport; |
99 | class ClientBufferTracker; |
100 | +class EventSink; |
101 | |
102 | // SessionMediator relays requests from the client process into the server. |
103 | class SessionMediator : public mir::protobuf::DisplayServer |
104 | { |
105 | public: |
106 | - |
107 | SessionMediator( |
108 | std::shared_ptr<Shell> const& shell, |
109 | std::shared_ptr<graphics::Platform> const& graphics_platform, |
110 | std::shared_ptr<graphics::Display> const& display, |
111 | std::shared_ptr<compositor::GraphicBufferAllocator> const& buffer_allocator, |
112 | std::shared_ptr<SessionMediatorReport> const& report, |
113 | - std::shared_ptr<events::EventSink> const& event_sink, |
114 | + std::shared_ptr<EventSink> const& event_sink, |
115 | std::shared_ptr<ResourceCache> const& resource_cache); |
116 | |
117 | ~SessionMediator() noexcept; |
118 | @@ -119,7 +115,7 @@ |
119 | std::shared_ptr<compositor::GraphicBufferAllocator> const buffer_allocator; |
120 | |
121 | std::shared_ptr<SessionMediatorReport> const report; |
122 | - std::shared_ptr<events::EventSink> const event_sink; |
123 | + std::shared_ptr<EventSink> const event_sink; |
124 | std::shared_ptr<ResourceCache> const resource_cache; |
125 | std::shared_ptr<ClientBufferTracker> const client_tracker; |
126 | |
127 | |
128 | === modified file 'include/server/mir/frontend/shell.h' |
129 | --- include/server/mir/frontend/shell.h 2013-05-21 17:16:43 +0000 |
130 | +++ include/server/mir/frontend/shell.h 2013-07-31 16:00:57 +0000 |
131 | @@ -24,16 +24,13 @@ |
132 | |
133 | namespace mir |
134 | { |
135 | -namespace events |
136 | -{ |
137 | -class EventSink; |
138 | -} |
139 | namespace shell |
140 | { |
141 | struct SurfaceCreationParameters; |
142 | } |
143 | namespace frontend |
144 | { |
145 | +class EventSink; |
146 | class Session; |
147 | |
148 | class Shell |
149 | @@ -41,7 +38,8 @@ |
150 | public: |
151 | virtual ~Shell() {} |
152 | |
153 | - virtual std::shared_ptr<Session> open_session(std::string const& name, std::shared_ptr<events::EventSink> const& sink) = 0; |
154 | + virtual std::shared_ptr<Session> open_session( |
155 | + std::string const& name, std::shared_ptr<EventSink> const& sink) = 0; |
156 | virtual void close_session(std::shared_ptr<Session> const& session) = 0; |
157 | |
158 | virtual SurfaceId create_surface_for(std::shared_ptr<Session> const& session, |
159 | |
160 | === modified file 'include/server/mir/shell/application_session.h' |
161 | --- include/server/mir/shell/application_session.h 2013-07-24 03:59:44 +0000 |
162 | +++ include/server/mir/shell/application_session.h 2013-07-31 16:00:57 +0000 |
163 | @@ -25,7 +25,7 @@ |
164 | |
165 | namespace mir |
166 | { |
167 | -namespace events |
168 | +namespace frontend |
169 | { |
170 | class EventSink; |
171 | } |
172 | @@ -43,14 +43,8 @@ |
173 | std::shared_ptr<SurfaceFactory> const& surface_factory, |
174 | std::string const& session_name, |
175 | std::shared_ptr<SnapshotStrategy> const& snapshot_strategy, |
176 | - std::shared_ptr<SessionListener> const& session_listener); |
177 | - |
178 | - ApplicationSession( |
179 | - std::shared_ptr<SurfaceFactory> const& surface_factory, |
180 | - std::string const& session_name, |
181 | - std::shared_ptr<SnapshotStrategy> const& snapshot_strategy, |
182 | std::shared_ptr<SessionListener> const& session_listener, |
183 | - std::shared_ptr<events::EventSink> const& sink); |
184 | + std::shared_ptr<frontend::EventSink> const& sink); |
185 | |
186 | ~ApplicationSession(); |
187 | |
188 | @@ -79,7 +73,7 @@ |
189 | std::string const session_name; |
190 | std::shared_ptr<SnapshotStrategy> const snapshot_strategy; |
191 | std::shared_ptr<SessionListener> const session_listener; |
192 | - std::shared_ptr<events::EventSink> const event_sink; |
193 | + std::shared_ptr<frontend::EventSink> const event_sink; |
194 | |
195 | frontend::SurfaceId next_id(); |
196 | |
197 | |
198 | === modified file 'include/server/mir/shell/organising_surface_factory.h' |
199 | --- include/server/mir/shell/organising_surface_factory.h 2013-05-21 17:16:43 +0000 |
200 | +++ include/server/mir/shell/organising_surface_factory.h 2013-07-31 16:00:57 +0000 |
201 | @@ -39,7 +39,7 @@ |
202 | std::shared_ptr<Surface> create_surface( |
203 | shell::SurfaceCreationParameters const& params, |
204 | frontend::SurfaceId id, |
205 | - std::shared_ptr<events::EventSink> const& sink) override; |
206 | + std::shared_ptr<frontend::EventSink> const& sink) override; |
207 | |
208 | protected: |
209 | OrganisingSurfaceFactory(OrganisingSurfaceFactory const&) = delete; |
210 | |
211 | === modified file 'include/server/mir/shell/session_manager.h' |
212 | --- include/server/mir/shell/session_manager.h 2013-07-04 04:53:57 +0000 |
213 | +++ include/server/mir/shell/session_manager.h 2013-07-31 16:00:57 +0000 |
214 | @@ -30,6 +30,10 @@ |
215 | namespace mir |
216 | { |
217 | |
218 | +namespace frontend |
219 | +{ |
220 | +class EventSink; |
221 | +} |
222 | /// Management of sessions and surfaces |
223 | namespace shell |
224 | { |
225 | @@ -54,7 +58,8 @@ |
226 | std::shared_ptr<SessionListener> const& session_listener); |
227 | virtual ~SessionManager(); |
228 | |
229 | - virtual std::shared_ptr<frontend::Session> open_session(std::string const& name, std::shared_ptr<events::EventSink> const& sink); |
230 | + virtual std::shared_ptr<frontend::Session> open_session( |
231 | + std::string const& name, std::shared_ptr<frontend::EventSink> const& sink); |
232 | virtual void close_session(std::shared_ptr<frontend::Session> const& session); |
233 | |
234 | frontend::SurfaceId create_surface_for(std::shared_ptr<frontend::Session> const& session, |
235 | |
236 | === modified file 'include/server/mir/shell/surface.h' |
237 | --- include/server/mir/shell/surface.h 2013-07-22 02:18:21 +0000 |
238 | +++ include/server/mir/shell/surface.h 2013-07-31 16:00:57 +0000 |
239 | @@ -31,11 +31,10 @@ |
240 | |
241 | namespace mir |
242 | { |
243 | -namespace events |
244 | +namespace frontend |
245 | { |
246 | class EventSink; |
247 | } |
248 | - |
249 | namespace shell |
250 | { |
251 | class InputTargeter; |
252 | @@ -47,13 +46,9 @@ |
253 | public: |
254 | Surface( |
255 | std::shared_ptr<SurfaceBuilder> const& builder, |
256 | - SurfaceCreationParameters const& params); |
257 | - |
258 | - Surface( |
259 | - std::shared_ptr<SurfaceBuilder> const& builder, |
260 | SurfaceCreationParameters const& params, |
261 | frontend::SurfaceId id, |
262 | - std::shared_ptr<events::EventSink> const& sink); |
263 | + std::shared_ptr<frontend::EventSink> const& event_sink); |
264 | |
265 | ~Surface() noexcept; |
266 | |
267 | @@ -97,7 +92,7 @@ |
268 | std::weak_ptr<mir::surfaces::Surface> const surface; |
269 | |
270 | frontend::SurfaceId const id; |
271 | - std::shared_ptr<events::EventSink> const event_sink; |
272 | + std::shared_ptr<frontend::EventSink> const event_sink; |
273 | |
274 | MirSurfaceType type_value; |
275 | MirSurfaceState state_value; |
276 | |
277 | === modified file 'include/server/mir/shell/surface_factory.h' |
278 | --- include/server/mir/shell/surface_factory.h 2013-05-21 17:16:43 +0000 |
279 | +++ include/server/mir/shell/surface_factory.h 2013-07-31 16:00:57 +0000 |
280 | @@ -24,11 +24,10 @@ |
281 | |
282 | namespace mir |
283 | { |
284 | -namespace events |
285 | +namespace frontend |
286 | { |
287 | class EventSink; |
288 | } |
289 | - |
290 | namespace shell |
291 | { |
292 | class Surface; |
293 | @@ -40,7 +39,7 @@ |
294 | virtual std::shared_ptr<Surface> create_surface( |
295 | SurfaceCreationParameters const& params, |
296 | frontend::SurfaceId id, |
297 | - std::shared_ptr<events::EventSink> const& sink) = 0; |
298 | + std::shared_ptr<frontend::EventSink> const& sink) = 0; |
299 | |
300 | protected: |
301 | virtual ~SurfaceFactory() {} |
302 | |
303 | === modified file 'include/server/mir/shell/surface_source.h' |
304 | --- include/server/mir/shell/surface_source.h 2013-05-21 22:03:29 +0000 |
305 | +++ include/server/mir/shell/surface_source.h 2013-07-31 16:00:57 +0000 |
306 | @@ -39,7 +39,7 @@ |
307 | std::shared_ptr<Surface> create_surface( |
308 | shell::SurfaceCreationParameters const& params, |
309 | frontend::SurfaceId id, |
310 | - std::shared_ptr<events::EventSink> const& sink); |
311 | + std::shared_ptr<frontend::EventSink> const& sink); |
312 | |
313 | protected: |
314 | SurfaceSource(const SurfaceSource&) = delete; |
315 | |
316 | === removed directory 'include/shared/mir/events' |
317 | === added file 'include/test/mir_test_doubles/mock_frontend_surface.h' |
318 | --- include/test/mir_test_doubles/mock_frontend_surface.h 1970-01-01 00:00:00 +0000 |
319 | +++ include/test/mir_test_doubles/mock_frontend_surface.h 2013-07-31 16:00:57 +0000 |
320 | @@ -0,0 +1,55 @@ |
321 | +/* |
322 | + * Copyright © 2013 Canonical Ltd. |
323 | + * |
324 | + * This program is free software: you can redistribute it and/or modify it |
325 | + * under the terms of the GNU General Public License version 3, |
326 | + * as published by the Free Software Foundation. |
327 | + * |
328 | + * This program is distributed in the hope that it will be useful, |
329 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
330 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
331 | + * GNU General Public License for more details. |
332 | + * |
333 | + * You should have received a copy of the GNU General Public License |
334 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
335 | + * |
336 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
337 | + */ |
338 | + |
339 | +#ifndef MIR_TEST_DOUBLES_MOCK_FRONTEND_SURFACE_H_ |
340 | +#define MIR_TEST_DOUBLES_MOCK_FRONTEND_SURFACE_H_ |
341 | + |
342 | +#include "mir/frontend/surface.h" |
343 | + |
344 | +#include <gmock/gmock.h> |
345 | + |
346 | +namespace mir |
347 | +{ |
348 | +namespace test |
349 | +{ |
350 | +namespace doubles |
351 | +{ |
352 | +struct MockFrontendSurface : public frontend::Surface |
353 | +{ |
354 | + MockFrontendSurface() |
355 | + { |
356 | + } |
357 | + |
358 | + ~MockFrontendSurface() noexcept {} |
359 | + |
360 | + MOCK_METHOD0(destroy, void()); |
361 | + MOCK_METHOD0(force_requests_to_complete, void()); |
362 | + MOCK_METHOD0(advance_client_buffer, std::shared_ptr<graphics::Buffer>()); |
363 | + |
364 | + MOCK_CONST_METHOD0(size, geometry::Size()); |
365 | + MOCK_CONST_METHOD0(pixel_format, geometry::PixelFormat()); |
366 | + |
367 | + MOCK_CONST_METHOD0(supports_input, bool()); |
368 | + MOCK_CONST_METHOD0(client_input_fd, int()); |
369 | + |
370 | + MOCK_METHOD2(configure, int(MirSurfaceAttrib, int)); |
371 | +}; |
372 | +} |
373 | +} |
374 | +} // namespace mir |
375 | +#endif // MIR_TEST_DOUBLES_MOCK_FRONTEND_SURFACE_H_ |
376 | |
377 | === modified file 'include/test/mir_test_doubles/mock_shell.h' |
378 | --- include/test/mir_test_doubles/mock_shell.h 2013-05-21 17:16:43 +0000 |
379 | +++ include/test/mir_test_doubles/mock_shell.h 2013-07-31 16:00:57 +0000 |
380 | @@ -34,7 +34,8 @@ |
381 | |
382 | struct MockShell : public frontend::Shell |
383 | { |
384 | - MOCK_METHOD2(open_session, std::shared_ptr<frontend::Session>(std::string const&, std::shared_ptr<events::EventSink> const&)); |
385 | + MOCK_METHOD2(open_session, std::shared_ptr<frontend::Session>( |
386 | + std::string const&, std::shared_ptr<frontend::EventSink> const&)); |
387 | MOCK_METHOD1(close_session, void(std::shared_ptr<frontend::Session> const&)); |
388 | |
389 | MOCK_METHOD2(create_surface_for, frontend::SurfaceId(std::shared_ptr<frontend::Session> const&, shell::SurfaceCreationParameters const&)); |
390 | |
391 | === modified file 'include/test/mir_test_doubles/mock_surface.h' |
392 | --- include/test/mir_test_doubles/mock_surface.h 2013-07-17 16:31:45 +0000 |
393 | +++ include/test/mir_test_doubles/mock_surface.h 2013-07-31 16:00:57 +0000 |
394 | @@ -22,6 +22,7 @@ |
395 | #include "mir/shell/surface.h" |
396 | |
397 | #include "mir/shell/surface_creation_parameters.h" |
398 | +#include "null_event_sink.h" |
399 | |
400 | #include <gmock/gmock.h> |
401 | |
402 | @@ -37,7 +38,7 @@ |
403 | struct MockSurface : public shell::Surface |
404 | { |
405 | MockSurface(std::shared_ptr<shell::SurfaceBuilder> const& builder) : |
406 | - shell::Surface(builder, shell::a_surface()) |
407 | + shell::Surface(builder, shell::a_surface(), frontend::SurfaceId{}, std::make_shared<NullEventSink>()) |
408 | { |
409 | } |
410 | |
411 | |
412 | === modified file 'include/test/mir_test_doubles/mock_surface_factory.h' |
413 | --- include/test/mir_test_doubles/mock_surface_factory.h 2013-05-21 17:16:43 +0000 |
414 | +++ include/test/mir_test_doubles/mock_surface_factory.h 2013-07-31 16:00:57 +0000 |
415 | @@ -36,7 +36,7 @@ |
416 | MOCK_METHOD3(create_surface, std::shared_ptr<shell::Surface>( |
417 | const shell::SurfaceCreationParameters&, |
418 | frontend::SurfaceId, |
419 | - std::shared_ptr<events::EventSink> const&)); |
420 | + std::shared_ptr<frontend::EventSink> const&)); |
421 | }; |
422 | |
423 | } |
424 | |
425 | === added file 'include/test/mir_test_doubles/null_event_sink.h' |
426 | --- include/test/mir_test_doubles/null_event_sink.h 1970-01-01 00:00:00 +0000 |
427 | +++ include/test/mir_test_doubles/null_event_sink.h 2013-07-31 16:00:57 +0000 |
428 | @@ -0,0 +1,36 @@ |
429 | +/* |
430 | + * Copyright © 2013 Canonical Ltd. |
431 | + * |
432 | + * This program is free software: you can redistribute it and/or modify |
433 | + * it under the terms of the GNU General Public License version 3 as |
434 | + * published by the Free Software Foundation. |
435 | + * |
436 | + * This program is distributed in the hope that it will be useful, |
437 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
438 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
439 | + * GNU General Public License for more details. |
440 | + * |
441 | + * You should have received a copy of the GNU General Public License |
442 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
443 | + * |
444 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
445 | + */ |
446 | + |
447 | +#ifndef MIR_TEST_DOUBLES_NULL_EVENT_SINK_H_ |
448 | +#define MIR_TEST_DOUBLES_NULL_EVENT_SINK_H_ |
449 | + |
450 | +#include "mir/frontend/event_sink.h" |
451 | +namespace mir |
452 | +{ |
453 | +namespace test |
454 | +{ |
455 | +namespace doubles |
456 | +{ |
457 | +struct NullEventSink : public frontend::EventSink |
458 | +{ |
459 | + void handle_event(MirEvent const&) {} |
460 | +}; |
461 | +} |
462 | +} |
463 | +} |
464 | +#endif /* MIR_TEST_DOUBLES_NULL_EVENT_SINK_H_*/ |
465 | |
466 | === modified file 'include/test/mir_test_doubles/stub_ipc_factory.h' |
467 | --- include/test/mir_test_doubles/stub_ipc_factory.h 2013-04-25 09:48:54 +0000 |
468 | +++ include/test/mir_test_doubles/stub_ipc_factory.h 2013-07-31 16:00:57 +0000 |
469 | @@ -42,7 +42,7 @@ |
470 | } |
471 | |
472 | std::shared_ptr<protobuf::DisplayServer> make_ipc_server( |
473 | - std::shared_ptr<events::EventSink> const&) |
474 | + std::shared_ptr<frontend::EventSink> const&) |
475 | { |
476 | return server; |
477 | } |
478 | |
479 | === modified file 'include/test/mir_test_doubles/stub_session.h' |
480 | --- include/test/mir_test_doubles/stub_session.h 2013-05-21 17:16:43 +0000 |
481 | +++ include/test/mir_test_doubles/stub_session.h 2013-07-31 16:00:57 +0000 |
482 | @@ -58,7 +58,7 @@ |
483 | { |
484 | return 0; |
485 | } |
486 | - void set_event_sink(std::shared_ptr<events::EventSink> const&) |
487 | + void set_event_sink(std::shared_ptr<frontend::EventSink> const&) |
488 | { |
489 | } |
490 | }; |
491 | |
492 | === modified file 'include/test/mir_test_doubles/stub_shell.h' |
493 | --- include/test/mir_test_doubles/stub_shell.h 2013-05-21 17:16:43 +0000 |
494 | +++ include/test/mir_test_doubles/stub_shell.h 2013-07-31 16:00:57 +0000 |
495 | @@ -31,7 +31,7 @@ |
496 | |
497 | class StubShell : public frontend::Shell |
498 | { |
499 | - std::shared_ptr<frontend::Session> open_session(std::string const& /* name */, std::shared_ptr<events::EventSink> const& /* sink */) override |
500 | + std::shared_ptr<frontend::Session> open_session(std::string const& /* name */, std::shared_ptr<frontend::EventSink> const& /* sink */) override |
501 | { |
502 | return std::make_shared<StubSession>(); |
503 | } |
504 | |
505 | === modified file 'src/client/mir_connection.h' |
506 | --- src/client/mir_connection.h 2013-07-26 05:12:14 +0000 |
507 | +++ src/client/mir_connection.h 2013-07-31 16:00:57 +0000 |
508 | @@ -34,7 +34,6 @@ |
509 | #include "client_context.h" |
510 | |
511 | #include "mir_wait_handle.h" |
512 | -#include "mir/events/event_sink.h" |
513 | |
514 | namespace mir |
515 | { |
516 | |
517 | === modified file 'src/client/rpc/mir_basic_rpc_channel.h' |
518 | --- src/client/rpc/mir_basic_rpc_channel.h 2013-07-26 05:12:14 +0000 |
519 | +++ src/client/rpc/mir_basic_rpc_channel.h 2013-07-31 16:00:57 +0000 |
520 | @@ -29,10 +29,6 @@ |
521 | |
522 | namespace mir |
523 | { |
524 | -namespace events |
525 | -{ |
526 | -class EventSink; |
527 | -} |
528 | namespace protobuf |
529 | { |
530 | namespace wire |
531 | |
532 | === modified file 'src/client/rpc/mir_socket_rpc_channel.cpp' |
533 | --- src/client/rpc/mir_socket_rpc_channel.cpp 2013-07-26 05:12:14 +0000 |
534 | +++ src/client/rpc/mir_socket_rpc_channel.cpp 2013-07-31 16:00:57 +0000 |
535 | @@ -41,7 +41,6 @@ |
536 | |
537 | namespace mcl = mir::client; |
538 | namespace mclr = mir::client::rpc; |
539 | -namespace me = mir::events; |
540 | |
541 | mclr::MirSocketRpcChannel::MirSocketRpcChannel( |
542 | std::string const& endpoint, |
543 | |
544 | === modified file 'src/server/default_server_configuration.cpp' |
545 | --- src/server/default_server_configuration.cpp 2013-07-30 12:21:46 +0000 |
546 | +++ src/server/default_server_configuration.cpp 2013-07-31 16:00:57 +0000 |
547 | @@ -83,7 +83,6 @@ |
548 | #include <map> |
549 | |
550 | namespace mc = mir::compositor; |
551 | -namespace me = mir::events; |
552 | namespace geom = mir::geometry; |
553 | namespace mf = mir::frontend; |
554 | namespace mg = mir::graphics; |
555 | @@ -131,7 +130,7 @@ |
556 | std::shared_ptr<mc::GraphicBufferAllocator> const buffer_allocator; |
557 | |
558 | virtual std::shared_ptr<mir::protobuf::DisplayServer> make_ipc_server( |
559 | - std::shared_ptr<me::EventSink> const& sink) |
560 | + std::shared_ptr<mf::EventSink> const& sink) |
561 | { |
562 | return std::make_shared<mf::SessionMediator>( |
563 | shell, |
564 | |
565 | === modified file 'src/server/frontend/CMakeLists.txt' |
566 | --- src/server/frontend/CMakeLists.txt 2013-05-30 19:24:29 +0000 |
567 | +++ src/server/frontend/CMakeLists.txt 2013-07-31 16:00:57 +0000 |
568 | @@ -8,9 +8,10 @@ |
569 | protobuf_message_processor.cpp |
570 | protobuf_buffer_packer.cpp |
571 | null_message_processor.cpp |
572 | - event_pipe.cpp |
573 | |
574 | resource_cache.cpp |
575 | + socket_messenger.cpp |
576 | + event_sender.cpp |
577 | ${PROTO_HDRS} |
578 | ) |
579 | |
580 | |
581 | === removed file 'src/server/frontend/event_pipe.h' |
582 | --- src/server/frontend/event_pipe.h 2013-04-23 11:56:42 +0000 |
583 | +++ src/server/frontend/event_pipe.h 1970-01-01 00:00:00 +0000 |
584 | @@ -1,42 +0,0 @@ |
585 | -/* |
586 | - * Copyright © 2013 Canonical Ltd. |
587 | - * |
588 | - * This program is free software: you can redistribute it and/or modify |
589 | - * it under the terms of the GNU General Public License version 3 as |
590 | - * published by the Free Software Foundation. |
591 | - * |
592 | - * This program is distributed in the hope that it will be useful, |
593 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
594 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
595 | - * GNU General Public License for more details. |
596 | - * |
597 | - * You should have received a copy of the GNU General Public License |
598 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
599 | - * |
600 | - * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
601 | - */ |
602 | - |
603 | -#ifndef MIR_FRONTEND_EVENT_PIPE_H_ |
604 | -#define MIR_FRONTEND_EVENT_PIPE_H_ |
605 | - |
606 | -#include "mir_toolkit/event.h" |
607 | -#include "mir/events/event_sink.h" |
608 | -#include <memory> |
609 | - |
610 | -namespace mir |
611 | -{ |
612 | -namespace frontend |
613 | -{ |
614 | -class EventPipe : public events::EventSink |
615 | -{ |
616 | -public: |
617 | - void set_target(std::weak_ptr<events::EventSink> const& s); |
618 | - void handle_event(MirEvent const& e) override; |
619 | - |
620 | -private: |
621 | - std::weak_ptr<events::EventSink> target; |
622 | -}; |
623 | -} |
624 | -} |
625 | - |
626 | -#endif // MIR_FRONTEND_EVENT_PIPE_H_ |
627 | |
628 | === renamed file 'src/server/frontend/event_pipe.cpp' => 'src/server/frontend/event_sender.cpp' |
629 | --- src/server/frontend/event_pipe.cpp 2013-04-24 08:51:31 +0000 |
630 | +++ src/server/frontend/event_sender.cpp 2013-07-31 16:00:57 +0000 |
631 | @@ -16,21 +16,40 @@ |
632 | * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
633 | */ |
634 | |
635 | -#include "event_pipe.h" |
636 | - |
637 | -namespace mf = mir::frontend; |
638 | - |
639 | -void mf::EventPipe::set_target(std::weak_ptr<EventSink> const& s) |
640 | +#include "mir/frontend/client_constants.h" |
641 | +#include "event_sender.h" |
642 | +#include "message_sender.h" |
643 | +#include "mir_protobuf_wire.pb.h" |
644 | +#include "mir_protobuf.pb.h" |
645 | + |
646 | +namespace mfd = mir::frontend::detail; |
647 | +namespace mp = mir::protobuf; |
648 | + |
649 | +mfd::EventSender::EventSender(std::shared_ptr<MessageSender> const& socket_sender) |
650 | + : sender(socket_sender) |
651 | { |
652 | - target = s; |
653 | } |
654 | |
655 | -void mf::EventPipe::handle_event(MirEvent const& e) |
656 | +void mfd::EventSender::handle_event(MirEvent const& e) |
657 | { |
658 | - // In future, we might put e on a queue and wait for some background |
659 | - // thread to push it through to target. But that's not required right now. |
660 | - |
661 | - std::shared_ptr<EventSink> p = target.lock(); |
662 | - if (p) |
663 | - p->handle_event(e); |
664 | + // Limit the types of events we wish to send over protobuf, for now. |
665 | + if (e.type == mir_event_type_surface) |
666 | + { |
667 | + // In future we might send multiple events, or insert them into messages |
668 | + // containing other responses, but for now we send them individually. |
669 | + mp::EventSequence seq; |
670 | + mp::Event *ev = seq.add_event(); |
671 | + ev->set_raw(&e, sizeof(MirEvent)); |
672 | + |
673 | + std::string buffer; |
674 | + buffer.reserve(serialization_buffer_size); |
675 | + seq.SerializeToString(&buffer); |
676 | + |
677 | + mir::protobuf::wire::Result result; |
678 | + result.add_events(buffer); |
679 | + |
680 | + result.SerializeToString(&buffer); |
681 | + |
682 | + sender->send(buffer); |
683 | + } |
684 | } |
685 | |
686 | === added file 'src/server/frontend/event_sender.h' |
687 | --- src/server/frontend/event_sender.h 1970-01-01 00:00:00 +0000 |
688 | +++ src/server/frontend/event_sender.h 2013-07-31 16:00:57 +0000 |
689 | @@ -0,0 +1,46 @@ |
690 | +/* |
691 | + * Copyright © 2013 Canonical Ltd. |
692 | + * |
693 | + * This program is free software: you can redistribute it and/or modify it |
694 | + * under the terms of the GNU General Public License version 3, |
695 | + * as published by the Free Software Foundation. |
696 | + * |
697 | + * This program is distributed in the hope that it will be useful, |
698 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
699 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
700 | + * GNU General Public License for more details. |
701 | + * |
702 | + * You should have received a copy of the GNU General Public License |
703 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
704 | + * |
705 | + * Authored by: |
706 | + * Kevin DuBois <kevin.dubois@canonical.com> |
707 | + */ |
708 | +#ifndef MIR_FRONTEND_EVENT_SENDER_H_ |
709 | +#define MIR_FRONTEND_EVENT_SENDER_H_ |
710 | + |
711 | +#include "mir/frontend/event_sink.h" |
712 | +#include <memory> |
713 | + |
714 | +namespace mir |
715 | +{ |
716 | +namespace frontend |
717 | +{ |
718 | +namespace detail |
719 | +{ |
720 | +class MessageSender; |
721 | + |
722 | +class EventSender : public mir::frontend::EventSink |
723 | +{ |
724 | +public: |
725 | + explicit EventSender(std::shared_ptr<MessageSender> const& socket_sender); |
726 | + void handle_event(MirEvent const& e); |
727 | + |
728 | +private: |
729 | + std::shared_ptr<MessageSender> const sender; |
730 | +}; |
731 | + |
732 | +} |
733 | +} |
734 | +} |
735 | +#endif /* MIR_FRONTEND_EVENT_SENDER_H_ */ |
736 | |
737 | === modified file 'src/server/frontend/message_processor.h' |
738 | --- src/server/frontend/message_processor.h 2013-06-27 18:58:31 +0000 |
739 | +++ src/server/frontend/message_processor.h 2013-07-31 16:00:57 +0000 |
740 | @@ -16,16 +16,10 @@ |
741 | * Authored by: Alan Griffiths <alan@octopull.co.uk> |
742 | */ |
743 | |
744 | - |
745 | #ifndef MIR_FRONTEND_MESSAGE_PROCESSOR_H_ |
746 | #define MIR_FRONTEND_MESSAGE_PROCESSOR_H_ |
747 | |
748 | -#include <vector> |
749 | -#include <memory> |
750 | #include <iosfwd> |
751 | -#include <cstdint> |
752 | - |
753 | -#include <sys/types.h> |
754 | |
755 | namespace mir |
756 | { |
757 | @@ -33,21 +27,10 @@ |
758 | { |
759 | namespace detail |
760 | { |
761 | -struct MessageSender |
762 | -{ |
763 | - virtual void send(std::string const& body) = 0; |
764 | - virtual void send_fds(std::vector<int32_t> const& fd) = 0; |
765 | - |
766 | - virtual pid_t client_pid() = 0; |
767 | -protected: |
768 | - MessageSender() = default; |
769 | - virtual ~MessageSender() { /* TODO: make nothrow */ } |
770 | - MessageSender(MessageSender const&) = delete; |
771 | - MessageSender& operator=(MessageSender const&) = delete; |
772 | -}; |
773 | - |
774 | -struct MessageProcessor |
775 | -{ |
776 | + |
777 | +class MessageProcessor |
778 | +{ |
779 | +public: |
780 | virtual bool process_message(std::istream& msg) = 0; |
781 | protected: |
782 | MessageProcessor() = default; |
783 | @@ -56,15 +39,13 @@ |
784 | MessageProcessor& operator=(MessageProcessor const&) = delete; |
785 | }; |
786 | |
787 | -struct NullMessageProcessor : MessageProcessor |
788 | +class NullMessageProcessor : MessageProcessor |
789 | { |
790 | +public: |
791 | bool process_message(std::istream&); |
792 | }; |
793 | |
794 | } |
795 | } |
796 | } |
797 | - |
798 | - |
799 | - |
800 | #endif /* PROTOBUF_MESSAGE_PROCESSOR_H_ */ |
801 | |
802 | === added file 'src/server/frontend/message_receiver.h' |
803 | --- src/server/frontend/message_receiver.h 1970-01-01 00:00:00 +0000 |
804 | +++ src/server/frontend/message_receiver.h 2013-07-31 16:00:57 +0000 |
805 | @@ -0,0 +1,48 @@ |
806 | +/* |
807 | + * Copyright © 2013 Canonical Ltd. |
808 | + * |
809 | + * This program is free software: you can redistribute it and/or modify it |
810 | + * under the terms of the GNU General Public License version 3, |
811 | + * as published by the Free Software Foundation. |
812 | + * |
813 | + * This program is distributed in the hope that it will be useful, |
814 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
815 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
816 | + * GNU General Public License for more details. |
817 | + * |
818 | + * You should have received a copy of the GNU General Public License |
819 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
820 | + * |
821 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
822 | + */ |
823 | +#ifndef MIR_FRONTEND_MESSAGE_RECEIVER_H_ |
824 | +#define MIR_FRONTEND_MESSAGE_RECEIVER_H_ |
825 | + |
826 | +#include <functional> |
827 | +#include <boost/asio.hpp> |
828 | + |
829 | +namespace mir |
830 | +{ |
831 | +namespace frontend |
832 | +{ |
833 | +namespace detail |
834 | +{ |
835 | +class MessageReceiver |
836 | +{ |
837 | +public: |
838 | + //receive message from the socket. 'handler' will be called when 'buffer' has been filled with exactly 'size' |
839 | + typedef std::function<void(boost::system::error_code const&, size_t)> MirReadHandler; |
840 | + virtual void async_receive_msg(MirReadHandler const& handler, boost::asio::streambuf& buffer, size_t size) = 0; |
841 | + virtual pid_t client_pid() = 0; |
842 | + |
843 | +protected: |
844 | + MessageReceiver() = default; |
845 | + virtual ~MessageReceiver() = default; |
846 | + MessageReceiver(MessageReceiver const&) = delete; |
847 | + MessageReceiver& operator=(MessageReceiver const&) = delete; |
848 | +}; |
849 | + |
850 | +} |
851 | +} |
852 | +} |
853 | +#endif /* MIR_FRONTEND_MESSAGE_RECEIVER_H_ */ |
854 | |
855 | === added file 'src/server/frontend/message_sender.h' |
856 | --- src/server/frontend/message_sender.h 1970-01-01 00:00:00 +0000 |
857 | +++ src/server/frontend/message_sender.h 2013-07-31 16:00:57 +0000 |
858 | @@ -0,0 +1,46 @@ |
859 | +/* |
860 | + * Copyright © 2012 Canonical Ltd. |
861 | + * |
862 | + * This program is free software: you can redistribute it and/or modify it |
863 | + * under the terms of the GNU General Public License version 3, |
864 | + * as published by the Free Software Foundation. |
865 | + * |
866 | + * This program is distributed in the hope that it will be useful, |
867 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
868 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
869 | + * GNU General Public License for more details. |
870 | + * |
871 | + * You should have received a copy of the GNU General Public License |
872 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
873 | + * |
874 | + * Authored by: Alan Griffiths <alan@octopull.co.uk> |
875 | + */ |
876 | +#ifndef MIR_FRONTEND_MESSAGE_SENDER_H_ |
877 | +#define MIR_FRONTEND_MESSAGE_SENDER_H_ |
878 | + |
879 | +#include <vector> |
880 | +#include <boost/asio.hpp> |
881 | + |
882 | +namespace mir |
883 | +{ |
884 | +namespace frontend |
885 | +{ |
886 | +namespace detail |
887 | +{ |
888 | +class MessageSender |
889 | +{ |
890 | +public: |
891 | + virtual void send(std::string const& body) = 0; |
892 | + virtual void send_fds(std::vector<int32_t> const& fd) = 0; |
893 | + |
894 | +protected: |
895 | + MessageSender() = default; |
896 | + virtual ~MessageSender() = default; |
897 | + MessageSender(MessageSender const&) = delete; |
898 | + MessageSender& operator=(MessageSender const&) = delete; |
899 | +}; |
900 | + |
901 | +} |
902 | +} |
903 | +} |
904 | +#endif /* MIR_FRONTEND_MESSAGE_SENDER_H_ */ |
905 | |
906 | === modified file 'src/server/frontend/protobuf_message_processor.cpp' |
907 | --- src/server/frontend/protobuf_message_processor.cpp 2013-07-15 09:29:14 +0000 |
908 | +++ src/server/frontend/protobuf_message_processor.cpp 2013-07-31 16:00:57 +0000 |
909 | @@ -29,7 +29,7 @@ |
910 | namespace mfd = mir::frontend::detail; |
911 | |
912 | mfd::ProtobufMessageProcessor::ProtobufMessageProcessor( |
913 | - MessageSender* sender, |
914 | + std::shared_ptr<MessageSender> const& sender, |
915 | std::shared_ptr<protobuf::DisplayServer> const& display_server, |
916 | std::shared_ptr<ResourceCache> const& resource_cache, |
917 | std::shared_ptr<MessageProcessorReport> const& report) : |
918 | @@ -136,35 +136,6 @@ |
919 | sender->send(send_response_buffer); |
920 | } |
921 | |
922 | -void mfd::ProtobufMessageProcessor::send_event(MirEvent const& e) |
923 | -{ |
924 | - // In future we might send multiple events, or insert them into messages |
925 | - // containing other responses, but for now we send them individually. |
926 | - mir::protobuf::EventSequence seq; |
927 | - mir::protobuf::Event *ev = seq.add_event(); |
928 | - ev->set_raw(&e, sizeof(MirEvent)); |
929 | - |
930 | - std::string buffer; |
931 | - buffer.reserve(serialization_buffer_size); |
932 | - seq.SerializeToString(&buffer); |
933 | - |
934 | - mir::protobuf::wire::Result result; |
935 | - result.add_events(buffer); |
936 | - |
937 | - result.SerializeToString(&buffer); |
938 | - |
939 | - sender->send(buffer); |
940 | -} |
941 | - |
942 | -void mfd::ProtobufMessageProcessor::handle_event(MirEvent const& e) |
943 | -{ |
944 | - // Limit the types of events we wish to send over protobuf, for now. |
945 | - if (e.type == mir_event_type_surface) |
946 | - { |
947 | - send_event(e); |
948 | - } |
949 | -} |
950 | - |
951 | bool mfd::ProtobufMessageProcessor::dispatch(mir::protobuf::wire::Invocation const& invocation) |
952 | { |
953 | report->received_invocation(display_server.get(), invocation.id(), invocation.method_name()); |
954 | |
955 | === modified file 'src/server/frontend/protobuf_message_processor.h' |
956 | --- src/server/frontend/protobuf_message_processor.h 2013-07-15 09:29:14 +0000 |
957 | +++ src/server/frontend/protobuf_message_processor.h 2013-07-31 16:00:57 +0000 |
958 | @@ -21,10 +21,11 @@ |
959 | #define MIR_FRONTEND_PROTOBUF_MESSAGE_PROCESSOR_H_ |
960 | |
961 | #include "message_processor.h" |
962 | +#include "message_sender.h" |
963 | |
964 | #include "mir_protobuf.pb.h" |
965 | #include "mir_protobuf_wire.pb.h" |
966 | -#include "mir/events/event_sink.h" |
967 | +#include "mir/frontend/event_sink.h" |
968 | |
969 | #include <vector> |
970 | #include <memory> |
971 | @@ -43,11 +44,11 @@ |
972 | namespace detail |
973 | { |
974 | |
975 | -struct ProtobufMessageProcessor : MessageProcessor, |
976 | - public events::EventSink |
977 | +class ProtobufMessageProcessor : public MessageProcessor |
978 | { |
979 | +public: |
980 | ProtobufMessageProcessor( |
981 | - MessageSender* sender, |
982 | + std::shared_ptr<MessageSender> const& sender, |
983 | std::shared_ptr<protobuf::DisplayServer> const& display_server, |
984 | std::shared_ptr<ResourceCache> const& resource_cache, |
985 | std::shared_ptr<MessageProcessorReport> const& report); |
986 | @@ -72,10 +73,6 @@ |
987 | // OTOH until we have a real requirement it is hard to see how best to generalise. |
988 | void send_response(::google::protobuf::uint32 id, mir::protobuf::Surface* response); |
989 | |
990 | - void send_event(MirEvent const& e); |
991 | - |
992 | - void handle_event(MirEvent const& e); |
993 | - |
994 | template<class Response> |
995 | std::vector<int32_t> extract_fds_from(Response* response); |
996 | |
997 | @@ -92,7 +89,7 @@ |
998 | ::google::protobuf::Closure* done), |
999 | mir::protobuf::wire::Invocation const& invocation); |
1000 | |
1001 | - MessageSender* const sender; |
1002 | + std::shared_ptr<MessageSender> const sender; |
1003 | std::shared_ptr<protobuf::DisplayServer> const display_server; |
1004 | std::shared_ptr<ResourceCache> const resource_cache; |
1005 | std::shared_ptr<MessageProcessorReport> const report; |
1006 | |
1007 | === modified file 'src/server/frontend/protobuf_socket_communicator.cpp' |
1008 | --- src/server/frontend/protobuf_socket_communicator.cpp 2013-07-17 21:42:30 +0000 |
1009 | +++ src/server/frontend/protobuf_socket_communicator.cpp 2013-07-31 16:00:57 +0000 |
1010 | @@ -23,8 +23,9 @@ |
1011 | #include "mir/frontend/communicator_report.h" |
1012 | #include "mir/frontend/protobuf_ipc_factory.h" |
1013 | #include "mir/frontend/session_authorizer.h" |
1014 | +#include "socket_messenger.h" |
1015 | +#include "event_sender.h" |
1016 | #include "mir/protobuf/google_protobuf_guard.h" |
1017 | -#include "event_pipe.h" |
1018 | |
1019 | #include <boost/signals2.hpp> |
1020 | |
1021 | @@ -54,28 +55,14 @@ |
1022 | |
1023 | void mf::ProtobufSocketCommunicator::start_accept() |
1024 | { |
1025 | - auto const& event_pipe = std::make_shared<EventPipe>(); |
1026 | - |
1027 | - auto const& socket_session = std::make_shared<mfd::SocketSession>( |
1028 | - io_service, |
1029 | - next_id(), |
1030 | - connected_sessions); |
1031 | - |
1032 | - auto session = std::make_shared<detail::ProtobufMessageProcessor>( |
1033 | - socket_session.get(), |
1034 | - ipc_factory->make_ipc_server(event_pipe), |
1035 | - ipc_factory->resource_cache(), |
1036 | - ipc_factory->report()); |
1037 | - |
1038 | - event_pipe->set_target(session); |
1039 | - socket_session->set_processor(session); |
1040 | + auto socket = std::make_shared<boost::asio::local::stream_protocol::socket>(io_service); |
1041 | |
1042 | acceptor.async_accept( |
1043 | - socket_session->get_socket(), |
1044 | + *socket, |
1045 | boost::bind( |
1046 | &ProtobufSocketCommunicator::on_new_connection, |
1047 | this, |
1048 | - socket_session, |
1049 | + socket, |
1050 | ba::placeholders::error)); |
1051 | } |
1052 | |
1053 | @@ -143,13 +130,25 @@ |
1054 | } |
1055 | |
1056 | void mf::ProtobufSocketCommunicator::on_new_connection( |
1057 | - std::shared_ptr<mfd::SocketSession> const& session, |
1058 | - const boost::system::error_code& ec) |
1059 | + std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket, |
1060 | + boost::system::error_code const& ec) |
1061 | { |
1062 | if (!ec) |
1063 | { |
1064 | - if (session_authorizer->connection_is_allowed(session->client_pid())) |
1065 | + auto messenger = std::make_shared<detail::SocketMessenger>(socket); |
1066 | + if (session_authorizer->connection_is_allowed(messenger->client_pid())) |
1067 | { |
1068 | + auto event_sink = std::make_shared<detail::EventSender>(messenger); |
1069 | + auto msg_processor = std::make_shared<detail::ProtobufMessageProcessor>( |
1070 | + messenger, |
1071 | + ipc_factory->make_ipc_server(event_sink), |
1072 | + ipc_factory->resource_cache(), |
1073 | + ipc_factory->report()); |
1074 | + auto const& session = std::make_shared<mfd::SocketSession>( |
1075 | + messenger, |
1076 | + next_id(), |
1077 | + connected_sessions, |
1078 | + msg_processor); |
1079 | connected_sessions->add(session); |
1080 | session->read_next_message(); |
1081 | } |
1082 | |
1083 | === modified file 'src/server/frontend/protobuf_socket_communicator.h' |
1084 | --- src/server/frontend/protobuf_socket_communicator.h 2013-07-09 18:56:51 +0000 |
1085 | +++ src/server/frontend/protobuf_socket_communicator.h 2013-07-31 16:00:57 +0000 |
1086 | @@ -50,6 +50,7 @@ |
1087 | namespace detail |
1088 | { |
1089 | struct SocketSession; |
1090 | +class MessageSender; |
1091 | } |
1092 | |
1093 | class CommunicatorReport; |
1094 | @@ -72,7 +73,8 @@ |
1095 | |
1096 | private: |
1097 | void start_accept(); |
1098 | - void on_new_connection(std::shared_ptr<detail::SocketSession> const& session, const boost::system::error_code& ec); |
1099 | + void on_new_connection(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket, |
1100 | + boost::system::error_code const& ec); |
1101 | int next_id(); |
1102 | |
1103 | const std::string socket_file; |
1104 | |
1105 | === modified file 'src/server/frontend/session_mediator.cpp' |
1106 | --- src/server/frontend/session_mediator.cpp 2013-07-24 03:59:44 +0000 |
1107 | +++ src/server/frontend/session_mediator.cpp 2013-07-31 16:00:57 +0000 |
1108 | @@ -52,14 +52,14 @@ |
1109 | std::shared_ptr<graphics::Display> const& display, |
1110 | std::shared_ptr<compositor::GraphicBufferAllocator> const& buffer_allocator, |
1111 | std::shared_ptr<SessionMediatorReport> const& report, |
1112 | - std::shared_ptr<events::EventSink> const& event_sink, |
1113 | + std::shared_ptr<EventSink> const& sender, |
1114 | std::shared_ptr<ResourceCache> const& resource_cache) : |
1115 | shell(shell), |
1116 | graphics_platform(graphics_platform), |
1117 | display(display), |
1118 | buffer_allocator(buffer_allocator), |
1119 | report(report), |
1120 | - event_sink(event_sink), |
1121 | + event_sink(sender), |
1122 | resource_cache(resource_cache), |
1123 | client_tracker(std::make_shared<ClientBufferTracker>(frontend::client_buffer_cache_size)) |
1124 | { |
1125 | |
1126 | === added file 'src/server/frontend/socket_messenger.cpp' |
1127 | --- src/server/frontend/socket_messenger.cpp 1970-01-01 00:00:00 +0000 |
1128 | +++ src/server/frontend/socket_messenger.cpp 2013-07-31 16:00:57 +0000 |
1129 | @@ -0,0 +1,109 @@ |
1130 | +/* |
1131 | + * Copyright © 2013 Canonical Ltd. |
1132 | + * |
1133 | + * This program is free software: you can redistribute it and/or modify |
1134 | + * it under the terms of the GNU General Public License version 3 as |
1135 | + * published by the Free Software Foundation. |
1136 | + * |
1137 | + * This program is distributed in the hope that it will be useful, |
1138 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1139 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1140 | + * GNU General Public License for more details. |
1141 | + * |
1142 | + * You should have received a copy of the GNU General Public License |
1143 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1144 | + * |
1145 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
1146 | + */ |
1147 | + |
1148 | +#include "socket_messenger.h" |
1149 | +#include "mir/frontend/client_constants.h" |
1150 | + |
1151 | +namespace mfd = mir::frontend::detail; |
1152 | +namespace bs = boost::system; |
1153 | +namespace ba = boost::asio; |
1154 | + |
1155 | +mfd::SocketMessenger::SocketMessenger(std::shared_ptr<ba::local::stream_protocol::socket> const& socket) |
1156 | + : socket(socket) |
1157 | +{ |
1158 | + whole_message.reserve(serialization_buffer_size); |
1159 | +} |
1160 | + |
1161 | +pid_t mfd::SocketMessenger::client_pid() |
1162 | +{ |
1163 | + struct ucred cr; |
1164 | + socklen_t cl = sizeof(cr); |
1165 | + |
1166 | + auto status = getsockopt(socket->native_handle(), SOL_SOCKET, SO_PEERCRED, &cr, &cl); |
1167 | + |
1168 | + if (status) |
1169 | + BOOST_THROW_EXCEPTION(std::runtime_error("Failed to query client socket credentials")); |
1170 | + return cr.pid; |
1171 | +} |
1172 | + |
1173 | +void mfd::SocketMessenger::send(std::string const& body) |
1174 | +{ |
1175 | + const size_t size = body.size(); |
1176 | + const unsigned char header_bytes[2] = |
1177 | + { |
1178 | + static_cast<unsigned char>((size >> 8) & 0xff), |
1179 | + static_cast<unsigned char>((size >> 0) & 0xff) |
1180 | + }; |
1181 | + |
1182 | + whole_message.resize(sizeof header_bytes + size); |
1183 | + std::copy(header_bytes, header_bytes + sizeof header_bytes, whole_message.begin()); |
1184 | + std::copy(body.begin(), body.end(), whole_message.begin() + sizeof header_bytes); |
1185 | + |
1186 | + // TODO: This should be asynchronous, but we are not making sure |
1187 | + // that a potential call to send_fds is executed _after_ this |
1188 | + // function has completed (if it would be executed asynchronously. |
1189 | + ba::write(*socket, ba::buffer(whole_message)); |
1190 | +} |
1191 | + |
1192 | +void mfd::SocketMessenger::send_fds(std::vector<int32_t> const& fds) |
1193 | +{ |
1194 | + auto n_fds = fds.size(); |
1195 | + if (n_fds > 0) |
1196 | + { |
1197 | + // We send dummy data |
1198 | + struct iovec iov; |
1199 | + char dummy_iov_data = 'M'; |
1200 | + iov.iov_base = &dummy_iov_data; |
1201 | + iov.iov_len = 1; |
1202 | + |
1203 | + // Allocate space for control message |
1204 | + std::vector<char> control(sizeof(struct cmsghdr) + sizeof(int) * n_fds); |
1205 | + |
1206 | + // Message to send |
1207 | + struct msghdr header; |
1208 | + header.msg_name = NULL; |
1209 | + header.msg_namelen = 0; |
1210 | + header.msg_iov = &iov; |
1211 | + header.msg_iovlen = 1; |
1212 | + header.msg_controllen = control.size(); |
1213 | + header.msg_control = control.data(); |
1214 | + header.msg_flags = 0; |
1215 | + |
1216 | + // Control message contains file descriptors |
1217 | + struct cmsghdr *message = CMSG_FIRSTHDR(&header); |
1218 | + message->cmsg_len = header.msg_controllen; |
1219 | + message->cmsg_level = SOL_SOCKET; |
1220 | + message->cmsg_type = SCM_RIGHTS; |
1221 | + int *data = (int *)CMSG_DATA(message); |
1222 | + int i = 0; |
1223 | + for (auto &fd: fds) |
1224 | + data[i++] = fd; |
1225 | + |
1226 | + sendmsg(socket->native_handle(), &header, 0); |
1227 | + } |
1228 | +} |
1229 | + |
1230 | +void mfd::SocketMessenger::async_receive_msg( |
1231 | + MirReadHandler const& handler, ba::streambuf& buffer, size_t size) |
1232 | +{ |
1233 | + boost::asio::async_read( |
1234 | + *socket, |
1235 | + buffer, |
1236 | + boost::asio::transfer_exactly(size), |
1237 | + handler); |
1238 | +} |
1239 | |
1240 | === added file 'src/server/frontend/socket_messenger.h' |
1241 | --- src/server/frontend/socket_messenger.h 1970-01-01 00:00:00 +0000 |
1242 | +++ src/server/frontend/socket_messenger.h 2013-07-31 16:00:57 +0000 |
1243 | @@ -0,0 +1,51 @@ |
1244 | +/* |
1245 | + * Copyright © 2013 Canonical Ltd. |
1246 | + * |
1247 | + * This program is free software: you can redistribute it and/or modify |
1248 | + * it under the terms of the GNU General Public License version 3 as |
1249 | + * published by the Free Software Foundation. |
1250 | + * |
1251 | + * This program is distributed in the hope that it will be useful, |
1252 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1253 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1254 | + * GNU General Public License for more details. |
1255 | + * |
1256 | + * You should have received a copy of the GNU General Public License |
1257 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1258 | + * |
1259 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
1260 | + */ |
1261 | + |
1262 | +#ifndef MIR_FRONTEND_SOCKET_MESSENGER_H_ |
1263 | +#define MIR_FRONTEND_SOCKET_MESSENGER_H_ |
1264 | +#include "message_sender.h" |
1265 | +#include "message_receiver.h" |
1266 | +#include <mutex> |
1267 | + |
1268 | +namespace mir |
1269 | +{ |
1270 | +namespace frontend |
1271 | +{ |
1272 | +namespace detail |
1273 | +{ |
1274 | +class SocketMessenger : public MessageSender, |
1275 | + public MessageReceiver |
1276 | +{ |
1277 | +public: |
1278 | + SocketMessenger(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket); |
1279 | + |
1280 | + void send(std::string const& body); |
1281 | + void send_fds(std::vector<int32_t> const& fds); |
1282 | + |
1283 | + void async_receive_msg(MirReadHandler const& handler, boost::asio::streambuf& buffer, size_t size); |
1284 | + pid_t client_pid(); |
1285 | + |
1286 | +private: |
1287 | + std::shared_ptr<boost::asio::local::stream_protocol::socket> socket; |
1288 | + std::vector<char> whole_message; |
1289 | +}; |
1290 | +} |
1291 | +} |
1292 | +} |
1293 | + |
1294 | +#endif /* MIR_FRONTEND_SOCKET_MESSENGER_H_ */ |
1295 | |
1296 | === modified file 'src/server/frontend/socket_session.cpp' |
1297 | --- src/server/frontend/socket_session.cpp 2013-07-15 09:29:14 +0000 |
1298 | +++ src/server/frontend/socket_session.cpp 2013-07-31 16:00:57 +0000 |
1299 | @@ -17,6 +17,9 @@ |
1300 | */ |
1301 | |
1302 | #include "socket_session.h" |
1303 | +#include "message_processor.h" |
1304 | +#include "message_sender.h" |
1305 | +#include "message_receiver.h" |
1306 | |
1307 | #include <boost/signals2.hpp> |
1308 | #include <boost/throw_exception.hpp> |
1309 | @@ -26,92 +29,34 @@ |
1310 | #include <sys/types.h> |
1311 | #include <sys/socket.h> |
1312 | |
1313 | -#include "mir/frontend/client_constants.h" |
1314 | - |
1315 | namespace ba = boost::asio; |
1316 | namespace bs = boost::system; |
1317 | |
1318 | namespace mfd = mir::frontend::detail; |
1319 | |
1320 | mfd::SocketSession::SocketSession( |
1321 | - boost::asio::io_service& io_service, |
1322 | + std::shared_ptr<mfd::MessageReceiver> const& receiver, |
1323 | int id_, |
1324 | - std::shared_ptr<ConnectedSessions<SocketSession>> const& connected_sessions) : |
1325 | - socket(io_service), |
1326 | - id_(id_), |
1327 | - connected_sessions(connected_sessions), |
1328 | - processor(std::make_shared<NullMessageProcessor>()) |
1329 | + std::shared_ptr<ConnectedSessions<SocketSession>> const& connected_sessions, |
1330 | + std::shared_ptr<MessageProcessor> const& processor) |
1331 | + : socket_receiver(receiver), |
1332 | + id_(id_), |
1333 | + connected_sessions(connected_sessions), |
1334 | + processor(processor) |
1335 | { |
1336 | - whole_message.reserve(serialization_buffer_size); |
1337 | } |
1338 | |
1339 | mfd::SocketSession::~SocketSession() noexcept |
1340 | { |
1341 | } |
1342 | |
1343 | -void mfd::SocketSession::send(std::string const& body) |
1344 | -{ |
1345 | - const size_t size = body.size(); |
1346 | - const unsigned char header_bytes[2] = |
1347 | - { |
1348 | - static_cast<unsigned char>((size >> 8) & 0xff), |
1349 | - static_cast<unsigned char>((size >> 0) & 0xff) |
1350 | - }; |
1351 | - |
1352 | - whole_message.resize(sizeof header_bytes + size); |
1353 | - std::copy(header_bytes, header_bytes + sizeof header_bytes, whole_message.begin()); |
1354 | - std::copy(body.begin(), body.end(), whole_message.begin() + sizeof header_bytes); |
1355 | - |
1356 | - // TODO: This should be asynchronous, but we are not making sure |
1357 | - // that a potential call to send_fds is executed _after_ this |
1358 | - // function has completed (if it would be executed asynchronously. |
1359 | - ba::write(socket, ba::buffer(whole_message)); |
1360 | -} |
1361 | - |
1362 | -void mfd::SocketSession::send_fds(std::vector<int32_t> const& fds) |
1363 | -{ |
1364 | - auto n_fds = fds.size(); |
1365 | - if (n_fds > 0) |
1366 | - { |
1367 | - // We send dummy data |
1368 | - struct iovec iov; |
1369 | - char dummy_iov_data = 'M'; |
1370 | - iov.iov_base = &dummy_iov_data; |
1371 | - iov.iov_len = 1; |
1372 | - |
1373 | - // Allocate space for control message |
1374 | - std::vector<char> control(sizeof(struct cmsghdr) + sizeof(int) * n_fds); |
1375 | - |
1376 | - // Message to send |
1377 | - struct msghdr header; |
1378 | - header.msg_name = NULL; |
1379 | - header.msg_namelen = 0; |
1380 | - header.msg_iov = &iov; |
1381 | - header.msg_iovlen = 1; |
1382 | - header.msg_controllen = control.size(); |
1383 | - header.msg_control = control.data(); |
1384 | - header.msg_flags = 0; |
1385 | - |
1386 | - // Control message contains file descriptors |
1387 | - struct cmsghdr *message = CMSG_FIRSTHDR(&header); |
1388 | - message->cmsg_len = header.msg_controllen; |
1389 | - message->cmsg_level = SOL_SOCKET; |
1390 | - message->cmsg_type = SCM_RIGHTS; |
1391 | - int *data = (int *)CMSG_DATA(message); |
1392 | - int i = 0; |
1393 | - for (auto &fd: fds) |
1394 | - data[i++] = fd; |
1395 | - |
1396 | - sendmsg(socket.native_handle(), &header, 0); |
1397 | - } |
1398 | -} |
1399 | |
1400 | void mfd::SocketSession::read_next_message() |
1401 | { |
1402 | - ba::async_read(socket, |
1403 | - ba::buffer(message_header_bytes), |
1404 | - boost::bind(&mfd::SocketSession::on_read_size, |
1405 | - this, ba::placeholders::error)); |
1406 | + size_t const header_size = 2; |
1407 | + auto callback = std::bind(&mfd::SocketSession::on_read_size, |
1408 | + this, std::placeholders::_1); |
1409 | + socket_receiver->async_receive_msg(callback, message, header_size); |
1410 | } |
1411 | |
1412 | void mfd::SocketSession::on_read_size(const boost::system::error_code& error) |
1413 | @@ -121,15 +66,14 @@ |
1414 | connected_sessions->remove(id()); |
1415 | BOOST_THROW_EXCEPTION(std::runtime_error(error.message())); |
1416 | } |
1417 | - |
1418 | - size_t const body_size = (message_header_bytes[0] << 8) + message_header_bytes[1]; |
1419 | - |
1420 | - ba::async_read( |
1421 | - socket, |
1422 | - message, |
1423 | - ba::transfer_exactly(body_size), |
1424 | - boost::bind(&mfd::SocketSession::on_new_message, |
1425 | - this, ba::placeholders::error)); |
1426 | + |
1427 | + unsigned char high_byte = message.sbumpc(); |
1428 | + unsigned char low_byte = message.sbumpc(); |
1429 | + size_t const body_size = (high_byte << 8) + low_byte; |
1430 | + |
1431 | + auto callback = std::bind(&mfd::SocketSession::on_new_message, |
1432 | + this, std::placeholders::_1); |
1433 | + socket_receiver->async_receive_msg(callback, message, body_size); |
1434 | } |
1435 | |
1436 | void mfd::SocketSession::on_new_message(const boost::system::error_code& error) |
1437 | @@ -160,15 +104,3 @@ |
1438 | BOOST_THROW_EXCEPTION(std::runtime_error(error.message())); |
1439 | } |
1440 | } |
1441 | - |
1442 | -pid_t mfd::SocketSession::client_pid() |
1443 | -{ |
1444 | - struct ucred cr; |
1445 | - socklen_t cl = sizeof(cr); |
1446 | - |
1447 | - auto status = getsockopt(socket.native_handle(), SOL_SOCKET, SO_PEERCRED, &cr, &cl); |
1448 | - |
1449 | - if (status) |
1450 | - BOOST_THROW_EXCEPTION(std::runtime_error("Failed to query client socket credentials")); |
1451 | - return cr.pid; |
1452 | -} |
1453 | |
1454 | === modified file 'src/server/frontend/socket_session.h' |
1455 | --- src/server/frontend/socket_session.h 2013-07-10 16:29:06 +0000 |
1456 | +++ src/server/frontend/socket_session.h 2013-07-31 16:00:57 +0000 |
1457 | @@ -34,12 +34,15 @@ |
1458 | namespace detail |
1459 | { |
1460 | |
1461 | -struct SocketSession : public MessageSender |
1462 | +class MessageReceiver; |
1463 | + |
1464 | +struct SocketSession |
1465 | { |
1466 | SocketSession( |
1467 | - boost::asio::io_service& io_service, |
1468 | + std::shared_ptr<MessageReceiver> const& socket_receiver, |
1469 | int id_, |
1470 | - std::shared_ptr<ConnectedSessions<SocketSession>> const& connected_sessions); |
1471 | + std::shared_ptr<ConnectedSessions<SocketSession>> const& connected_sessions, |
1472 | + std::shared_ptr<MessageProcessor> const& processor); |
1473 | |
1474 | ~SocketSession() noexcept; |
1475 | |
1476 | @@ -47,34 +50,18 @@ |
1477 | |
1478 | void read_next_message(); |
1479 | |
1480 | - void set_processor(std::shared_ptr<MessageProcessor> const& processor) |
1481 | - { |
1482 | - this->processor = processor; |
1483 | - } |
1484 | - |
1485 | - boost::asio::local::stream_protocol::socket& get_socket() |
1486 | - { |
1487 | - return socket; |
1488 | - } |
1489 | - |
1490 | - pid_t client_pid(); |
1491 | - |
1492 | private: |
1493 | - void send(std::string const& body); |
1494 | - void send_fds(std::vector<int32_t> const& fd); |
1495 | - |
1496 | void on_response_sent(boost::system::error_code const& error, std::size_t); |
1497 | void on_new_message(const boost::system::error_code& ec); |
1498 | void on_read_size(const boost::system::error_code& ec); |
1499 | |
1500 | - boost::asio::local::stream_protocol::socket socket; |
1501 | + std::shared_ptr<MessageReceiver> const socket_receiver; |
1502 | int const id_; |
1503 | std::shared_ptr<ConnectedSessions<SocketSession>> const connected_sessions; |
1504 | std::shared_ptr<MessageProcessor> processor; |
1505 | + |
1506 | + boost::asio::streambuf header; |
1507 | boost::asio::streambuf message; |
1508 | - static size_t const size_of_header = 2; |
1509 | - unsigned char message_header_bytes[size_of_header]; |
1510 | - std::vector<char> whole_message; |
1511 | }; |
1512 | |
1513 | } |
1514 | |
1515 | === modified file 'src/server/shell/application_session.cpp' |
1516 | --- src/server/shell/application_session.cpp 2013-07-24 03:59:44 +0000 |
1517 | +++ src/server/shell/application_session.cpp 2013-07-31 16:00:57 +0000 |
1518 | @@ -29,7 +29,6 @@ |
1519 | #include <cassert> |
1520 | #include <algorithm> |
1521 | |
1522 | -namespace me = mir::events; |
1523 | namespace mf = mir::frontend; |
1524 | namespace msh = mir::shell; |
1525 | |
1526 | @@ -38,7 +37,7 @@ |
1527 | std::string const& session_name, |
1528 | std::shared_ptr<SnapshotStrategy> const& snapshot_strategy, |
1529 | std::shared_ptr<msh::SessionListener> const& session_listener, |
1530 | - std::shared_ptr<me::EventSink> const& sink) : |
1531 | + std::shared_ptr<mf::EventSink> const& sink) : |
1532 | surface_factory(surface_factory), |
1533 | session_name(session_name), |
1534 | snapshot_strategy(snapshot_strategy), |
1535 | @@ -49,15 +48,6 @@ |
1536 | assert(surface_factory); |
1537 | } |
1538 | |
1539 | -msh::ApplicationSession::ApplicationSession( |
1540 | - std::shared_ptr<SurfaceFactory> const& surface_factory, |
1541 | - std::string const& session_name, |
1542 | - std::shared_ptr<SnapshotStrategy> const& snapshot_strategy, |
1543 | - std::shared_ptr<msh::SessionListener> const& session_listener) : |
1544 | - ApplicationSession(surface_factory, session_name, snapshot_strategy, session_listener, std::shared_ptr<me::EventSink>()) |
1545 | -{ |
1546 | -} |
1547 | - |
1548 | msh::ApplicationSession::~ApplicationSession() |
1549 | { |
1550 | std::unique_lock<std::mutex> lock(surfaces_mutex); |
1551 | |
1552 | === modified file 'src/server/shell/organising_surface_factory.cpp' |
1553 | --- src/server/shell/organising_surface_factory.cpp 2013-05-21 17:16:43 +0000 |
1554 | +++ src/server/shell/organising_surface_factory.cpp 2013-07-31 16:00:57 +0000 |
1555 | @@ -37,10 +37,10 @@ |
1556 | std::shared_ptr<msh::Surface> msh::OrganisingSurfaceFactory::create_surface( |
1557 | shell::SurfaceCreationParameters const& params, |
1558 | frontend::SurfaceId id, |
1559 | - std::shared_ptr<events::EventSink> const& sink) |
1560 | + std::shared_ptr<mf::EventSink> const& sender) |
1561 | { |
1562 | auto placed_params = placement_strategy->place(params); |
1563 | |
1564 | - return underlying_factory->create_surface(placed_params, id, sink); |
1565 | + return underlying_factory->create_surface(placed_params, id, sender); |
1566 | } |
1567 | |
1568 | |
1569 | === modified file 'src/server/shell/session_manager.cpp' |
1570 | --- src/server/shell/session_manager.cpp 2013-07-24 03:59:44 +0000 |
1571 | +++ src/server/shell/session_manager.cpp 2013-07-31 16:00:57 +0000 |
1572 | @@ -73,13 +73,12 @@ |
1573 | close_session(session); |
1574 | } |
1575 | |
1576 | -std::shared_ptr<mf::Session> msh::SessionManager::open_session( |
1577 | - std::string const& name, |
1578 | - std::shared_ptr<events::EventSink> const& sink) |
1579 | +std::shared_ptr<mf::Session> msh::SessionManager::open_session(std::string const& name, |
1580 | + std::shared_ptr<mf::EventSink> const& sender) |
1581 | { |
1582 | std::shared_ptr<msh::Session> new_session = |
1583 | std::make_shared<msh::ApplicationSession>( |
1584 | - surface_factory, name, snapshot_strategy, session_listener, sink); |
1585 | + surface_factory, name, snapshot_strategy, session_listener, sender); |
1586 | |
1587 | app_container->insert_session(new_session); |
1588 | |
1589 | |
1590 | === modified file 'src/server/shell/surface.cpp' |
1591 | --- src/server/shell/surface.cpp 2013-07-19 09:47:28 +0000 |
1592 | +++ src/server/shell/surface.cpp 2013-07-31 16:00:57 +0000 |
1593 | @@ -20,7 +20,7 @@ |
1594 | #include "mir/shell/surface_builder.h" |
1595 | #include "mir/shell/input_targeter.h" |
1596 | #include "mir/input/input_channel.h" |
1597 | -#include "mir/events/event_sink.h" |
1598 | +#include "mir/frontend/event_sink.h" |
1599 | |
1600 | #include "mir_toolkit/event.h" |
1601 | |
1602 | @@ -35,28 +35,17 @@ |
1603 | namespace mi = mir::input; |
1604 | namespace ms = mir::surfaces; |
1605 | namespace geom = mir::geometry; |
1606 | +namespace mf = mir::frontend; |
1607 | |
1608 | msh::Surface::Surface( |
1609 | std::shared_ptr<SurfaceBuilder> const& builder, |
1610 | shell::SurfaceCreationParameters const& params, |
1611 | frontend::SurfaceId id, |
1612 | - std::shared_ptr<events::EventSink> const& sink) |
1613 | + std::shared_ptr<mf::EventSink> const& event_sink) |
1614 | : builder(builder), |
1615 | surface(builder->create_surface(params)), |
1616 | id(id), |
1617 | - event_sink(sink), |
1618 | - type_value(mir_surface_type_normal), |
1619 | - state_value(mir_surface_state_restored) |
1620 | -{ |
1621 | -} |
1622 | - |
1623 | -msh::Surface::Surface( |
1624 | - std::shared_ptr<SurfaceBuilder> const& builder, |
1625 | - shell::SurfaceCreationParameters const& params) |
1626 | - : builder(builder), |
1627 | - surface(builder->create_surface(params)), |
1628 | - id(), |
1629 | - event_sink(), |
1630 | + event_sink(event_sink), |
1631 | type_value(mir_surface_type_normal), |
1632 | state_value(mir_surface_state_restored) |
1633 | { |
1634 | @@ -302,22 +291,19 @@ |
1635 | |
1636 | void msh::Surface::notify_change(MirSurfaceAttrib attrib, int value) |
1637 | { |
1638 | - if (event_sink) |
1639 | - { |
1640 | - MirEvent e; |
1641 | - |
1642 | - // This memset is not really required. However it does avoid some |
1643 | - // harmless uninitialized memory reads that valgrind will complain |
1644 | - // about, due to gaps in MirEvent. |
1645 | - memset(&e, 0, sizeof e); |
1646 | - |
1647 | - e.type = mir_event_type_surface; |
1648 | - e.surface.id = id.as_value(); |
1649 | - e.surface.attrib = attrib; |
1650 | - e.surface.value = value; |
1651 | - |
1652 | - event_sink->handle_event(e); |
1653 | - } |
1654 | + MirEvent e; |
1655 | + |
1656 | + // This memset is not really required. However it does avoid some |
1657 | + // harmless uninitialized memory reads that valgrind will complain |
1658 | + // about, due to gaps in MirEvent. |
1659 | + memset(&e, 0, sizeof e); |
1660 | + |
1661 | + e.type = mir_event_type_surface; |
1662 | + e.surface.id = id.as_value(); |
1663 | + e.surface.attrib = attrib; |
1664 | + e.surface.value = value; |
1665 | + |
1666 | + event_sink->handle_event(e); |
1667 | } |
1668 | |
1669 | void msh::Surface::take_input_focus(std::shared_ptr<msh::InputTargeter> const& targeter) |
1670 | |
1671 | === modified file 'src/server/shell/surface_source.cpp' |
1672 | --- src/server/shell/surface_source.cpp 2013-05-21 22:03:29 +0000 |
1673 | +++ src/server/shell/surface_source.cpp 2013-07-31 16:00:57 +0000 |
1674 | @@ -39,12 +39,8 @@ |
1675 | std::shared_ptr<msh::Surface> msh::SurfaceSource::create_surface( |
1676 | shell::SurfaceCreationParameters const& params, |
1677 | frontend::SurfaceId id, |
1678 | - std::shared_ptr<events::EventSink> const& sink) |
1679 | + std::shared_ptr<mf::EventSink> const& sender) |
1680 | { |
1681 | - return std::make_shared<Surface>( |
1682 | - surface_builder, |
1683 | - params, |
1684 | - id, |
1685 | - sink); |
1686 | + return std::make_shared<Surface>(surface_builder, params, id, sender); |
1687 | } |
1688 | |
1689 | |
1690 | === modified file 'tests/acceptance-tests/test_client_input.cpp' |
1691 | --- tests/acceptance-tests/test_client_input.cpp 2013-07-29 15:13:09 +0000 |
1692 | +++ tests/acceptance-tests/test_client_input.cpp 2013-07-31 16:00:57 +0000 |
1693 | @@ -54,7 +54,6 @@ |
1694 | namespace mis = mi::synthesis; |
1695 | namespace mf = mir::frontend; |
1696 | namespace msh = mir::shell; |
1697 | -namespace me = mir::events; |
1698 | namespace ms = mir::surfaces; |
1699 | namespace mg = mir::graphics; |
1700 | namespace geom = mir::geometry; |
1701 | @@ -621,7 +620,7 @@ |
1702 | |
1703 | std::shared_ptr<msh::Surface> create_surface(msh::SurfaceCreationParameters const& params, |
1704 | mf::SurfaceId id, |
1705 | - std::shared_ptr<me::EventSink> const& sink) |
1706 | + std::shared_ptr<mf::EventSink> const& sink) |
1707 | { |
1708 | auto surface = underlying_factory->create_surface(params, id, sink); |
1709 | |
1710 | |
1711 | === modified file 'tests/integration-tests/graphics/android/test_internal_client.cpp' |
1712 | --- tests/integration-tests/graphics/android/test_internal_client.cpp 2013-07-30 15:37:33 +0000 |
1713 | +++ tests/integration-tests/graphics/android/test_internal_client.cpp 2013-07-31 16:00:57 +0000 |
1714 | @@ -112,7 +112,7 @@ |
1715 | auto surface_controller = std::make_shared<ms::SurfaceController>(ss); |
1716 | auto surface_source = std::make_shared<msh::SurfaceSource>(surface_controller); |
1717 | auto mir_surface = std::make_shared<ForwardingInternalSurface>( |
1718 | - surface_source->create_surface(params, id, std::shared_ptr<mir::events::EventSink>())); |
1719 | + surface_source->create_surface(params, id, std::shared_ptr<mf::EventSink>())); |
1720 | |
1721 | auto options = std::shared_ptr<mo::ProgramOption>(); |
1722 | auto report = std::shared_ptr<mg::NullDisplayReport>(); |
1723 | |
1724 | === modified file 'tests/integration-tests/shell/test_session.cpp' |
1725 | --- tests/integration-tests/shell/test_session.cpp 2013-07-30 09:11:45 +0000 |
1726 | +++ tests/integration-tests/shell/test_session.cpp 2013-07-31 16:00:57 +0000 |
1727 | @@ -33,6 +33,7 @@ |
1728 | |
1729 | #include "mir_test_doubles/stub_buffer.h" |
1730 | #include "mir_test_doubles/null_display.h" |
1731 | +#include "mir_test_doubles/null_event_sink.h" |
1732 | #include "mir_test_doubles/stub_display_buffer.h" |
1733 | |
1734 | #include <gtest/gtest.h> |
1735 | @@ -175,8 +176,10 @@ |
1736 | conf.the_shell_surface_factory(), |
1737 | "stress", |
1738 | conf.the_shell_snapshot_strategy(), |
1739 | - std::make_shared<msh::NullSessionListener>()}; |
1740 | - session.create_surface(msh::a_surface().of_size({50,50})); |
1741 | + std::make_shared<msh::NullSessionListener>(), |
1742 | + std::make_shared<mtd::NullEventSink>() |
1743 | + }; |
1744 | + session.create_surface(msh::a_surface()); |
1745 | |
1746 | auto compositor = conf.the_compositor(); |
1747 | |
1748 | |
1749 | === modified file 'tests/integration-tests/shell/test_session_manager.cpp' |
1750 | --- tests/integration-tests/shell/test_session_manager.cpp 2013-06-25 13:19:15 +0000 |
1751 | +++ tests/integration-tests/shell/test_session_manager.cpp 2013-07-31 16:00:57 +0000 |
1752 | @@ -33,12 +33,12 @@ |
1753 | #include "mir_test_doubles/mock_surface_factory.h" |
1754 | #include "mir_test_doubles/mock_focus_setter.h" |
1755 | #include "mir_test_doubles/null_snapshot_strategy.h" |
1756 | +#include "mir_test_doubles/null_event_sink.h" |
1757 | |
1758 | #include <gmock/gmock.h> |
1759 | #include <gtest/gtest.h> |
1760 | |
1761 | namespace mc = mir::compositor; |
1762 | -namespace me = mir::events; |
1763 | namespace mf = mir::frontend; |
1764 | namespace msh = mir::shell; |
1765 | namespace ms = mir::surfaces; |
1766 | @@ -66,9 +66,9 @@ |
1767 | |
1768 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3); |
1769 | |
1770 | - auto session1 = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
1771 | - auto session2 = session_manager.open_session("Microsoft Access", std::shared_ptr<me::EventSink>()); |
1772 | - auto session3 = session_manager.open_session("WordPerfect", std::shared_ptr<me::EventSink>()); |
1773 | + auto session1 = session_manager.open_session("Visual Basic Studio", std::make_shared<mtd::NullEventSink>()); |
1774 | + auto session2 = session_manager.open_session("Microsoft Access", std::make_shared<mtd::NullEventSink>()); |
1775 | + auto session3 = session_manager.open_session("WordPerfect", std::make_shared<mtd::NullEventSink>()); |
1776 | |
1777 | Mock::VerifyAndClearExpectations(&focus_setter); |
1778 | |
1779 | @@ -110,9 +110,9 @@ |
1780 | |
1781 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3); |
1782 | |
1783 | - auto session1 = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
1784 | - auto session2 = session_manager.open_session("Microsoft Access", std::shared_ptr<me::EventSink>()); |
1785 | - auto session3 = session_manager.open_session("WordPerfect", std::shared_ptr<me::EventSink>()); |
1786 | + auto session1 = session_manager.open_session("Visual Basic Studio", std::make_shared<mtd::NullEventSink>()); |
1787 | + auto session2 = session_manager.open_session("Microsoft Access", std::make_shared<mtd::NullEventSink>()); |
1788 | + auto session3 = session_manager.open_session("WordPerfect", std::make_shared<mtd::NullEventSink>()); |
1789 | |
1790 | Mock::VerifyAndClearExpectations(&focus_setter); |
1791 | |
1792 | |
1793 | === modified file 'tests/unit-tests/client/test_mir_connection.cpp' |
1794 | --- tests/unit-tests/client/test_mir_connection.cpp 2013-07-26 05:12:14 +0000 |
1795 | +++ tests/unit-tests/client/test_mir_connection.cpp 2013-07-31 16:00:57 +0000 |
1796 | @@ -66,8 +66,6 @@ |
1797 | |
1798 | MOCK_METHOD1(drm_auth_magic, void(const mp::DRMMagic*)); |
1799 | MOCK_METHOD2(connect, void(mp::ConnectParameters const*,mp::Connection*)); |
1800 | - |
1801 | - void set_event_handler(mir::events::EventSink *) {} |
1802 | }; |
1803 | |
1804 | struct MockClientPlatform : public mcl::ClientPlatform |
1805 | |
1806 | === modified file 'tests/unit-tests/frontend/CMakeLists.txt' |
1807 | --- tests/unit-tests/frontend/CMakeLists.txt 2013-05-30 03:50:54 +0000 |
1808 | +++ tests/unit-tests/frontend/CMakeLists.txt 2013-07-31 16:00:57 +0000 |
1809 | @@ -7,7 +7,7 @@ |
1810 | ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_buffer_packer.cpp |
1811 | ${CMAKE_CURRENT_SOURCE_DIR}/test_resource_cache.cpp |
1812 | ${CMAKE_CURRENT_SOURCE_DIR}/test_session_mediator.cpp |
1813 | - ${CMAKE_CURRENT_SOURCE_DIR}/test_event_pipe.cpp |
1814 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_socket_session.cpp |
1815 | ) |
1816 | |
1817 | # TODO this test is a mess - something better is needed. |
1818 | |
1819 | === removed file 'tests/unit-tests/frontend/test_event_pipe.cpp' |
1820 | --- tests/unit-tests/frontend/test_event_pipe.cpp 2013-04-23 11:56:42 +0000 |
1821 | +++ tests/unit-tests/frontend/test_event_pipe.cpp 1970-01-01 00:00:00 +0000 |
1822 | @@ -1,116 +0,0 @@ |
1823 | -/* |
1824 | - * Copyright © 2013 Canonical Ltd. |
1825 | - * |
1826 | - * This program is free software: you can redistribute it and/or modify |
1827 | - * it under the terms of the GNU General Public License version 3 as |
1828 | - * published by the Free Software Foundation. |
1829 | - * |
1830 | - * This program is distributed in the hope that it will be useful, |
1831 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1832 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1833 | - * GNU General Public License for more details. |
1834 | - * |
1835 | - * You should have received a copy of the GNU General Public License |
1836 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1837 | - * |
1838 | - * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
1839 | - */ |
1840 | - |
1841 | -#include "src/server/frontend/event_pipe.h" |
1842 | -#include <cstring> |
1843 | - |
1844 | -#include <gtest/gtest.h> |
1845 | - |
1846 | -using mir::frontend::EventPipe; |
1847 | - |
1848 | - |
1849 | -TEST(EventPipe, no_sink) |
1850 | -{ |
1851 | - EventPipe q; |
1852 | - MirEvent e; |
1853 | - |
1854 | - e.type = mir_event_type_key; |
1855 | - q.handle_event(e); |
1856 | - |
1857 | - e.type = mir_event_type_motion; |
1858 | - q.handle_event(e); |
1859 | - |
1860 | - e.type = mir_event_type_surface; |
1861 | - q.handle_event(e); |
1862 | -} |
1863 | - |
1864 | -namespace |
1865 | -{ |
1866 | - class TestSink : public mir::events::EventSink |
1867 | - { |
1868 | - public: |
1869 | - TestSink() |
1870 | - { |
1871 | - memset(&last_event, 0, sizeof last_event); |
1872 | - } |
1873 | - |
1874 | - void handle_event(MirEvent const& e) |
1875 | - { |
1876 | - last_event = e; |
1877 | - } |
1878 | - |
1879 | - MirEvent const& last_event_handled() const |
1880 | - { |
1881 | - return last_event; |
1882 | - } |
1883 | - |
1884 | - private: |
1885 | - MirEvent last_event; |
1886 | - }; |
1887 | -} |
1888 | - |
1889 | -TEST(EventPipe, events_get_handled) |
1890 | -{ |
1891 | - EventPipe q; |
1892 | - std::shared_ptr<TestSink> s(new TestSink); |
1893 | - |
1894 | - q.set_target(s); |
1895 | - |
1896 | - MirEvent e; |
1897 | - memset(&e, 0, sizeof e); |
1898 | - |
1899 | - e.type = mir_event_type_key; |
1900 | - q.handle_event(e); |
1901 | - EXPECT_EQ(mir_event_type_key, s->last_event_handled().type); |
1902 | - |
1903 | - e.type = mir_event_type_motion; |
1904 | - q.handle_event(e); |
1905 | - EXPECT_EQ(mir_event_type_motion, s->last_event_handled().type); |
1906 | - |
1907 | - e.type = mir_event_type_surface; |
1908 | - q.handle_event(e); |
1909 | - EXPECT_EQ(mir_event_type_surface, s->last_event_handled().type); |
1910 | -} |
1911 | - |
1912 | -TEST(EventPipe, sink_is_changeable) |
1913 | -{ |
1914 | - EventPipe q; |
1915 | - std::shared_ptr<TestSink> a(new TestSink); |
1916 | - std::shared_ptr<TestSink> b(new TestSink); |
1917 | - |
1918 | - q.set_target(a); |
1919 | - |
1920 | - MirEvent e; |
1921 | - memset(&e, 0, sizeof e); |
1922 | - |
1923 | - e.type = mir_event_type_motion; |
1924 | - q.handle_event(e); |
1925 | - EXPECT_EQ(mir_event_type_motion, a->last_event_handled().type); |
1926 | - |
1927 | - q.set_target(b); |
1928 | - |
1929 | - e.type = mir_event_type_surface; |
1930 | - q.handle_event(e); |
1931 | - EXPECT_EQ(mir_event_type_surface, b->last_event_handled().type); |
1932 | - EXPECT_EQ(mir_event_type_motion, a->last_event_handled().type); |
1933 | - |
1934 | - e.type = mir_event_type_key; |
1935 | - q.handle_event(e); |
1936 | - EXPECT_EQ(mir_event_type_key, b->last_event_handled().type); |
1937 | - EXPECT_EQ(mir_event_type_motion, a->last_event_handled().type); |
1938 | -} |
1939 | |
1940 | === modified file 'tests/unit-tests/frontend/test_session_mediator.cpp' |
1941 | --- tests/unit-tests/frontend/test_session_mediator.cpp 2013-07-24 03:59:44 +0000 |
1942 | +++ tests/unit-tests/frontend/test_session_mediator.cpp 2013-07-31 16:00:57 +0000 |
1943 | @@ -28,12 +28,12 @@ |
1944 | #include "mir/surfaces/surface.h" |
1945 | #include "mir_test_doubles/null_display.h" |
1946 | #include "mir_test_doubles/mock_shell.h" |
1947 | -#include "mir_test_doubles/mock_surface.h" |
1948 | +#include "mir_test_doubles/mock_frontend_surface.h" |
1949 | #include "mir_test_doubles/mock_buffer.h" |
1950 | #include "mir_test_doubles/stub_session.h" |
1951 | #include "mir_test_doubles/stub_surface_builder.h" |
1952 | #include "mir_test/fake_shared.h" |
1953 | -#include "mir/events/event_sink.h" |
1954 | +#include "mir/frontend/event_sink.h" |
1955 | #include "mir/shell/surface.h" |
1956 | |
1957 | #include <gtest/gtest.h> |
1958 | @@ -61,7 +61,7 @@ |
1959 | { |
1960 | using namespace ::testing; |
1961 | |
1962 | - mock_surface = std::make_shared<mtd::MockSurface>(mt::fake_shared(surface_builder)); |
1963 | + mock_surface = std::make_shared<mtd::MockFrontendSurface>(); |
1964 | mock_buffer = std::make_shared<NiceMock<mtd::MockBuffer>>(geom::Size(), geom::Stride(), geom::PixelFormat()); |
1965 | |
1966 | EXPECT_CALL(*mock_surface, size()).Times(AnyNumber()).WillRepeatedly(Return(geom::Size())); |
1967 | @@ -78,7 +78,7 @@ |
1968 | } |
1969 | |
1970 | mtd::StubSurfaceBuilder surface_builder; |
1971 | - std::shared_ptr<mtd::MockSurface> mock_surface; |
1972 | + std::shared_ptr<mtd::MockFrontendSurface> mock_surface; |
1973 | std::shared_ptr<mtd::MockBuffer> mock_buffer; |
1974 | static int const testing_client_input_fd; |
1975 | }; |
1976 | @@ -127,7 +127,7 @@ |
1977 | std::shared_ptr<mg::Buffer> const&)); |
1978 | }; |
1979 | |
1980 | -class NullEventSink : public mir::events::EventSink |
1981 | +class NullEventSink : public mir::frontend::EventSink |
1982 | { |
1983 | public: |
1984 | void handle_event(MirEvent const& ) override {} |
1985 | |
1986 | === modified file 'tests/unit-tests/frontend/test_session_mediator_android.cpp' |
1987 | --- tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-07-17 16:31:45 +0000 |
1988 | +++ tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-07-31 16:00:57 +0000 |
1989 | @@ -31,8 +31,7 @@ |
1990 | #include "mir_test_doubles/mock_session.h" |
1991 | #include "mir_test_doubles/stub_shell.h" |
1992 | #include "mir_test_doubles/null_platform.h" |
1993 | - |
1994 | -#include "mir/events/event_sink.h" |
1995 | +#include "mir_test_doubles/null_event_sink.h" |
1996 | |
1997 | #include <gtest/gtest.h> |
1998 | |
1999 | @@ -63,12 +62,6 @@ |
2000 | } |
2001 | }; |
2002 | |
2003 | -class NullEventSink : public mir::events::EventSink |
2004 | -{ |
2005 | -public: |
2006 | - void handle_event(MirEvent const& ) override {} |
2007 | -}; |
2008 | - |
2009 | struct SessionMediatorAndroidTest : public ::testing::Test |
2010 | { |
2011 | SessionMediatorAndroidTest() |
2012 | @@ -80,7 +73,7 @@ |
2013 | resource_cache{std::make_shared<mf::ResourceCache>()}, |
2014 | mediator{shell, graphics_platform, graphics_display, |
2015 | buffer_allocator, report, |
2016 | - std::make_shared<NullEventSink>(), |
2017 | + std::make_shared<mtd::NullEventSink>(), |
2018 | resource_cache}, |
2019 | null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)} |
2020 | { |
2021 | |
2022 | === modified file 'tests/unit-tests/frontend/test_session_mediator_gbm.cpp' |
2023 | --- tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-07-17 16:31:45 +0000 |
2024 | +++ tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-07-31 16:00:57 +0000 |
2025 | @@ -24,7 +24,7 @@ |
2026 | #include "mir/frontend/shell.h" |
2027 | #include "mir/graphics/display.h" |
2028 | #include "mir/graphics/drm_authenticator.h" |
2029 | -#include "mir/events/event_sink.h" |
2030 | +#include "mir/frontend/event_sink.h" |
2031 | |
2032 | #include <boost/exception/errinfo_errno.hpp> |
2033 | #include <boost/throw_exception.hpp> |
2034 | @@ -74,7 +74,7 @@ |
2035 | MOCK_METHOD1(drm_auth_magic, void(drm_magic_t)); |
2036 | }; |
2037 | |
2038 | -class NullEventSink : public mir::events::EventSink |
2039 | +class NullEventSink : public mir::frontend::EventSink |
2040 | { |
2041 | public: |
2042 | void handle_event(MirEvent const& ) override {} |
2043 | |
2044 | === added file 'tests/unit-tests/frontend/test_socket_session.cpp' |
2045 | --- tests/unit-tests/frontend/test_socket_session.cpp 1970-01-01 00:00:00 +0000 |
2046 | +++ tests/unit-tests/frontend/test_socket_session.cpp 2013-07-31 16:00:57 +0000 |
2047 | @@ -0,0 +1,85 @@ |
2048 | +/* |
2049 | + * Copyright © 2013 Canonical Ltd. |
2050 | + * |
2051 | + * This program is free software: you can redistribute it and/or modify |
2052 | + * it under the terms of the GNU General Public License version 3 as |
2053 | + * published by the Free Software Foundation. |
2054 | + * |
2055 | + * This program is distributed in the hope that it will be useful, |
2056 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2057 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2058 | + * GNU General Public License for more details. |
2059 | + * |
2060 | + * You should have received a copy of the GNU General Public License |
2061 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2062 | + * |
2063 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
2064 | + */ |
2065 | + |
2066 | +#include "src/server/frontend/socket_session.h" |
2067 | +#include "src/server/frontend/message_receiver.h" |
2068 | +#include "src/server/frontend/message_processor.h" |
2069 | + |
2070 | +#include "mir_test/fake_shared.h" |
2071 | + |
2072 | +#include <gmock/gmock.h> |
2073 | +#include <gtest/gtest.h> |
2074 | + |
2075 | +namespace mfd = mir::frontend::detail; |
2076 | +namespace ba = boost::asio; |
2077 | +namespace mt = mir::test; |
2078 | + |
2079 | +namespace |
2080 | +{ |
2081 | +struct MockReceiver : public mfd::MessageReceiver |
2082 | +{ |
2083 | + MOCK_METHOD3(async_receive_msg, void(std::function<void(boost::system::error_code const&, size_t)> const&, |
2084 | + boost::asio::streambuf&, size_t)); |
2085 | + MOCK_METHOD0(client_pid, pid_t()); |
2086 | +}; |
2087 | + |
2088 | +struct MockProcessor : public mfd::MessageProcessor |
2089 | +{ |
2090 | + MOCK_METHOD1(process_message, bool(std::istream&)); |
2091 | +}; |
2092 | +} |
2093 | +struct SocketSessionTest : public ::testing::Test |
2094 | +{ |
2095 | + testing::NiceMock<MockProcessor> mock_processor; |
2096 | + testing::NiceMock<MockReceiver> mock_receiver; |
2097 | +}; |
2098 | + |
2099 | +TEST_F(SocketSessionTest, basic_msg) |
2100 | +{ |
2101 | + using namespace testing; |
2102 | + |
2103 | + std::shared_ptr<mfd::ConnectedSessions<mfd::SocketSession>> null_sessions; |
2104 | + std::function<void(boost::system::error_code const&, size_t)> header_read, body_read; |
2105 | + |
2106 | + size_t header_size = 2; |
2107 | + EXPECT_CALL(mock_receiver, async_receive_msg(_,_, header_size)) |
2108 | + .Times(1) |
2109 | + .WillOnce(SaveArg<0>(&header_read)); |
2110 | + |
2111 | + mfd::SocketSession session(mt::fake_shared(mock_receiver), 0, null_sessions, mt::fake_shared(mock_processor)); |
2112 | + |
2113 | + //trigger wait for header |
2114 | + session.read_next_message(); |
2115 | + testing::Mock::VerifyAndClearExpectations(&mock_receiver); |
2116 | + |
2117 | + //trigger body read |
2118 | + EXPECT_CALL(mock_receiver, async_receive_msg(_,_,_)) |
2119 | + .Times(1) |
2120 | + .WillOnce(SaveArg<0>(&body_read)); |
2121 | + |
2122 | + boost::system::error_code code; |
2123 | + header_read(code, 2); |
2124 | + |
2125 | + testing::Mock::VerifyAndClearExpectations(&mock_receiver); |
2126 | + |
2127 | + //trigger message process |
2128 | + EXPECT_CALL(mock_processor, process_message(_)) |
2129 | + .Times(1) |
2130 | + .WillOnce(Return(true)); |
2131 | + body_read(code, 9); |
2132 | +} |
2133 | |
2134 | === modified file 'tests/unit-tests/graphics/gbm/test_internal_native_surface.cpp' |
2135 | --- tests/unit-tests/graphics/gbm/test_internal_native_surface.cpp 2013-07-30 15:37:33 +0000 |
2136 | +++ tests/unit-tests/graphics/gbm/test_internal_native_surface.cpp 2013-07-31 16:00:57 +0000 |
2137 | @@ -25,7 +25,7 @@ |
2138 | |
2139 | #include "mir_test/fake_shared.h" |
2140 | #include "mir_test_doubles/stub_surface_builder.h" |
2141 | -#include "mir_test_doubles/mock_surface.h" |
2142 | +#include "mir_test_doubles/mock_frontend_surface.h" |
2143 | #include "mir_test_doubles/mock_buffer.h" |
2144 | |
2145 | #include <gtest/gtest.h> |
2146 | |
2147 | === modified file 'tests/unit-tests/shell/test_application_session.cpp' |
2148 | --- tests/unit-tests/shell/test_application_session.cpp 2013-07-24 03:59:44 +0000 |
2149 | +++ tests/unit-tests/shell/test_application_session.cpp 2013-07-31 16:00:57 +0000 |
2150 | @@ -27,6 +27,7 @@ |
2151 | #include "mir_test_doubles/stub_surface_builder.h" |
2152 | #include "mir_test_doubles/stub_surface.h" |
2153 | #include "mir_test_doubles/null_snapshot_strategy.h" |
2154 | +#include "mir_test_doubles/null_event_sink.h" |
2155 | |
2156 | #include "mir/shell/surface.h" |
2157 | |
2158 | @@ -34,7 +35,6 @@ |
2159 | #include <gtest/gtest.h> |
2160 | |
2161 | namespace mc = mir::compositor; |
2162 | -namespace me = mir::events; |
2163 | namespace mf = mir::frontend; |
2164 | namespace msh = mir::shell; |
2165 | namespace ms = mir::surfaces; |
2166 | @@ -46,11 +46,12 @@ |
2167 | { |
2168 | using namespace ::testing; |
2169 | |
2170 | + mtd::NullEventSink sender; |
2171 | mtd::StubSurfaceBuilder surface_builder; |
2172 | auto const mock_surface = std::make_shared<mtd::MockSurface>(mt::fake_shared(surface_builder)); |
2173 | |
2174 | mtd::MockSurfaceFactory surface_factory; |
2175 | - ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(Return(mock_surface)); |
2176 | + ON_CALL(surface_factory, create_surface(_,_,_)).WillByDefault(Return(mock_surface)); |
2177 | |
2178 | EXPECT_CALL(surface_factory, create_surface(_, _, _)); |
2179 | EXPECT_CALL(*mock_surface, destroy()); |
2180 | @@ -61,7 +62,7 @@ |
2181 | |
2182 | msh::ApplicationSession session(mt::fake_shared(surface_factory), "Foo", |
2183 | std::make_shared<mtd::NullSnapshotStrategy>(), |
2184 | - mt::fake_shared(listener)); |
2185 | + mt::fake_shared(listener), mt::fake_shared(sender)); |
2186 | |
2187 | msh::SurfaceCreationParameters params; |
2188 | auto surf = session.create_surface(params); |
2189 | @@ -73,6 +74,7 @@ |
2190 | { |
2191 | using namespace ::testing; |
2192 | |
2193 | + mtd::NullEventSink sender; |
2194 | mtd::MockSurfaceFactory surface_factory; |
2195 | mtd::StubSurfaceBuilder surface_builder; |
2196 | { |
2197 | @@ -87,7 +89,7 @@ |
2198 | |
2199 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo", |
2200 | std::make_shared<mtd::NullSnapshotStrategy>(), |
2201 | - std::make_shared<msh::NullSessionListener>()); |
2202 | + std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender)); |
2203 | |
2204 | |
2205 | msh::SurfaceCreationParameters params; |
2206 | @@ -112,6 +114,7 @@ |
2207 | { |
2208 | using namespace ::testing; |
2209 | |
2210 | + mtd::NullEventSink sender; |
2211 | mtd::StubSurfaceBuilder surface_builder; |
2212 | auto const mock_surface = std::make_shared<mtd::MockSurface>(mt::fake_shared(surface_builder)); |
2213 | |
2214 | @@ -120,7 +123,7 @@ |
2215 | |
2216 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo", |
2217 | std::make_shared<mtd::NullSnapshotStrategy>(), |
2218 | - std::make_shared<msh::NullSessionListener>()); |
2219 | + std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender)); |
2220 | |
2221 | EXPECT_CALL(surface_factory, create_surface(_, _, _)); |
2222 | |
2223 | @@ -144,10 +147,11 @@ |
2224 | { |
2225 | using namespace ::testing; |
2226 | |
2227 | + mtd::NullEventSink sender; |
2228 | mtd::MockSurfaceFactory surface_factory; |
2229 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo", |
2230 | std::make_shared<mtd::NullSnapshotStrategy>(), |
2231 | - std::make_shared<msh::NullSessionListener>()); |
2232 | + std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender)); |
2233 | mf::SurfaceId invalid_surface_id(1); |
2234 | |
2235 | EXPECT_THROW({ |
2236 | @@ -159,10 +163,11 @@ |
2237 | { |
2238 | using namespace ::testing; |
2239 | |
2240 | + mtd::NullEventSink sender; |
2241 | mtd::MockSurfaceFactory surface_factory; |
2242 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo", |
2243 | std::make_shared<mtd::NullSnapshotStrategy>(), |
2244 | - std::make_shared<msh::NullSessionListener>()); |
2245 | + std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender)); |
2246 | mf::SurfaceId invalid_surface_id(1); |
2247 | |
2248 | EXPECT_THROW({ |
2249 | @@ -186,10 +191,11 @@ |
2250 | }; |
2251 | |
2252 | auto snapshot_strategy = std::make_shared<MockSnapshotStrategy>(); |
2253 | + mtd::NullEventSink sender; |
2254 | mtd::MockSurfaceFactory surface_factory; |
2255 | msh::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo", |
2256 | snapshot_strategy, |
2257 | - std::make_shared<msh::NullSessionListener>()); |
2258 | + std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender)); |
2259 | |
2260 | EXPECT_CALL(*snapshot_strategy, take_snapshot_of(_,_)); |
2261 | |
2262 | |
2263 | === modified file 'tests/unit-tests/shell/test_organising_surface_factory.cpp' |
2264 | --- tests/unit-tests/shell/test_organising_surface_factory.cpp 2013-05-21 17:16:43 +0000 |
2265 | +++ tests/unit-tests/shell/test_organising_surface_factory.cpp 2013-07-31 16:00:57 +0000 |
2266 | @@ -17,6 +17,7 @@ |
2267 | */ |
2268 | |
2269 | #include <mir_test_doubles/mock_surface_factory.h> |
2270 | +#include <mir_test_doubles/null_event_sink.h> |
2271 | |
2272 | #include <mir/shell/organising_surface_factory.h> |
2273 | #include <mir/shell/placement_strategy.h> |
2274 | @@ -25,7 +26,6 @@ |
2275 | #include <gtest/gtest.h> |
2276 | #include <gmock/gmock.h> |
2277 | |
2278 | -namespace me = mir::events; |
2279 | namespace mf = mir::frontend; |
2280 | namespace msh = mir::shell; |
2281 | namespace geom = mir::geometry; |
2282 | @@ -69,7 +69,7 @@ |
2283 | EXPECT_CALL(*placement_strategy, place(Ref(params))).Times(1) |
2284 | .WillOnce(Return(msh::a_surface())); |
2285 | |
2286 | - factory.create_surface(params, mf::SurfaceId(), std::shared_ptr<me::EventSink>()); |
2287 | + factory.create_surface(params, mf::SurfaceId(), std::make_shared<mtd::NullEventSink>()); |
2288 | } |
2289 | |
2290 | TEST_F(OrganisingSurfaceFactorySetup, forwards_create_surface_parameters_from_placement_strategy_to_underlying_factory) |
2291 | @@ -78,14 +78,14 @@ |
2292 | |
2293 | msh::OrganisingSurfaceFactory factory(underlying_surface_factory, placement_strategy); |
2294 | |
2295 | + std::shared_ptr<mf::EventSink> sink = std::make_shared<mtd::NullEventSink>(); |
2296 | auto params = msh::a_surface(); |
2297 | auto placed_params = params; |
2298 | placed_params.size.width = geom::Width{100}; |
2299 | |
2300 | EXPECT_CALL(*placement_strategy, place(Ref(params))).Times(1) |
2301 | .WillOnce(Return(placed_params)); |
2302 | - EXPECT_CALL(*underlying_surface_factory, create_surface(placed_params, mf::SurfaceId(), std::shared_ptr<me::EventSink>())); |
2303 | + EXPECT_CALL(*underlying_surface_factory, create_surface(placed_params, mf::SurfaceId(), sink)); |
2304 | |
2305 | - factory.create_surface(params, mf::SurfaceId(), std::shared_ptr<me::EventSink>()); |
2306 | + factory.create_surface(params, mf::SurfaceId(), sink); |
2307 | } |
2308 | - |
2309 | |
2310 | === modified file 'tests/unit-tests/shell/test_registration_order_focus_sequence.cpp' |
2311 | --- tests/unit-tests/shell/test_registration_order_focus_sequence.cpp 2013-07-24 03:59:44 +0000 |
2312 | +++ tests/unit-tests/shell/test_registration_order_focus_sequence.cpp 2013-07-31 16:00:57 +0000 |
2313 | @@ -25,6 +25,7 @@ |
2314 | |
2315 | #include "mir_test_doubles/mock_buffer_stream.h" |
2316 | #include "mir_test_doubles/mock_surface_factory.h" |
2317 | +#include "mir_test_doubles/null_event_sink.h" |
2318 | #include "mir_test/fake_shared.h" |
2319 | |
2320 | #include <gmock/gmock.h> |
2321 | @@ -32,7 +33,6 @@ |
2322 | #include <string> |
2323 | |
2324 | namespace mc = mir::compositor; |
2325 | -namespace me = mir::events; |
2326 | namespace msh = mir::shell; |
2327 | namespace ms = mir::surfaces; |
2328 | namespace mt = mir::test; |
2329 | @@ -53,7 +53,8 @@ |
2330 | return std::make_shared<msh::ApplicationSession>( |
2331 | factory, name, |
2332 | std::shared_ptr<msh::SnapshotStrategy>(), |
2333 | - std::make_shared<msh::NullSessionListener>()); |
2334 | + std::make_shared<msh::NullSessionListener>(), |
2335 | + std::make_shared<mtd::NullEventSink>()); |
2336 | } |
2337 | |
2338 | std::shared_ptr<mtd::MockSurfaceFactory> const factory; |
2339 | |
2340 | === modified file 'tests/unit-tests/shell/test_session_manager.cpp' |
2341 | --- tests/unit-tests/shell/test_session_manager.cpp 2013-07-24 03:59:44 +0000 |
2342 | +++ tests/unit-tests/shell/test_session_manager.cpp 2013-07-31 16:00:57 +0000 |
2343 | @@ -39,7 +39,6 @@ |
2344 | #include <gtest/gtest.h> |
2345 | |
2346 | namespace mc = mir::compositor; |
2347 | -namespace me = mir::events; |
2348 | namespace mf = mir::frontend; |
2349 | namespace msh = mir::shell; |
2350 | namespace ms = mir::surfaces; |
2351 | @@ -100,7 +99,7 @@ |
2352 | |
2353 | EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); |
2354 | |
2355 | - auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
2356 | + auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<mf::EventSink>()); |
2357 | session_manager.close_session(session); |
2358 | } |
2359 | |
2360 | @@ -113,7 +112,7 @@ |
2361 | ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault( |
2362 | Return(std::make_shared<msh::Surface>( |
2363 | mt::fake_shared(surface_builder), |
2364 | - msh::a_surface()))); |
2365 | + msh::a_surface(),mf::SurfaceId{}, std::shared_ptr<mf::EventSink>()))); |
2366 | |
2367 | |
2368 | EXPECT_CALL(container, insert_session(_)).Times(1); |
2369 | @@ -124,7 +123,7 @@ |
2370 | |
2371 | EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); |
2372 | |
2373 | - auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
2374 | + auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<mf::EventSink>()); |
2375 | session->create_surface(msh::a_surface().of_size(geom::Size{geom::Width{1024}, geom::Height{768}})); |
2376 | |
2377 | session_manager.close_session(session); |
2378 | @@ -138,7 +137,7 @@ |
2379 | EXPECT_CALL(container, insert_session(_)).Times(1); |
2380 | EXPECT_CALL(focus_setter, set_focus_to(_)).WillOnce(SaveArg<0>(&new_session)); |
2381 | |
2382 | - auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<me::EventSink>()); |
2383 | + auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<mf::EventSink>()); |
2384 | EXPECT_EQ(session, new_session); |
2385 | } |
2386 | |
2387 | @@ -147,8 +146,8 @@ |
2388 | using namespace ::testing; |
2389 | ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault( |
2390 | Return(std::make_shared<msh::Surface>( |
2391 | - mt::fake_shared(surface_builder), |
2392 | - msh::a_surface()))); |
2393 | + mt::fake_shared(surface_builder), |
2394 | + msh::a_surface(),mf::SurfaceId{}, std::shared_ptr<mf::EventSink>()))); |
2395 | |
2396 | // Once for session creation and once for surface creation |
2397 | { |
2398 | @@ -159,7 +158,7 @@ |
2399 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Post Surface creation |
2400 | } |
2401 | |
2402 | - auto session1 = session_manager.open_session("Weather Report", std::shared_ptr<me::EventSink>()); |
2403 | + auto session1 = session_manager.open_session("Weather Report", std::shared_ptr<mf::EventSink>()); |
2404 | session_manager.create_surface_for(session1, msh::a_surface()); |
2405 | } |
2406 | |
2407 | @@ -200,6 +199,6 @@ |
2408 | |
2409 | EXPECT_CALL(focus_sequence, default_focus()).WillOnce(Return((std::shared_ptr<msh::Session>()))); |
2410 | |
2411 | - auto session = session_manager.open_session("XPlane", std::shared_ptr<me::EventSink>()); |
2412 | + auto session = session_manager.open_session("XPlane", std::shared_ptr<mf::EventSink>()); |
2413 | session_manager.close_session(session); |
2414 | } |
2415 | |
2416 | === modified file 'tests/unit-tests/shell/test_surface.cpp' |
2417 | --- tests/unit-tests/shell/test_surface.cpp 2013-07-17 16:31:45 +0000 |
2418 | +++ tests/unit-tests/shell/test_surface.cpp 2013-07-31 16:00:57 +0000 |
2419 | @@ -28,6 +28,7 @@ |
2420 | #include "mir_test_doubles/stub_buffer.h" |
2421 | #include "mir_test_doubles/mock_input_targeter.h" |
2422 | #include "mir_test_doubles/stub_input_targeter.h" |
2423 | +#include "mir_test_doubles/null_event_sink.h" |
2424 | #include "mir_test_doubles/mock_surface_state.h" |
2425 | #include "mir_test/fake_shared.h" |
2426 | |
2427 | @@ -35,7 +36,6 @@ |
2428 | #include <gmock/gmock.h> |
2429 | #include <gtest/gtest.h> |
2430 | |
2431 | -namespace me = mir::events; |
2432 | namespace ms = mir::surfaces; |
2433 | namespace msh = mir::shell; |
2434 | namespace mf = mir::frontend; |
2435 | @@ -114,7 +114,8 @@ |
2436 | StubSurfaceBuilder surface_builder; |
2437 | |
2438 | ShellSurface() : |
2439 | - buffer_stream(std::make_shared<StubBufferStream>()) |
2440 | + buffer_stream(std::make_shared<StubBufferStream>()), |
2441 | + stub_sender(std::make_shared<mtd::NullEventSink>()) |
2442 | { |
2443 | using namespace testing; |
2444 | |
2445 | @@ -122,6 +123,8 @@ |
2446 | ON_CALL(*buffer_stream, get_stream_pixel_format()).WillByDefault(Return(geom::PixelFormat::abgr_8888)); |
2447 | ON_CALL(*buffer_stream, secure_client_buffer()).WillByDefault(Return(std::shared_ptr<mtd::StubBuffer>())); |
2448 | } |
2449 | + mf::SurfaceId stub_id; |
2450 | + std::shared_ptr<mf::EventSink> stub_sender; |
2451 | }; |
2452 | } |
2453 | |
2454 | @@ -138,7 +141,7 @@ |
2455 | |
2456 | msh::Surface test( |
2457 | mt::fake_shared(surface_builder), |
2458 | - params); |
2459 | + params, stub_id, stub_sender); |
2460 | } |
2461 | |
2462 | TEST_F(ShellSurface, creation_throws_means_no_destroy) |
2463 | @@ -156,7 +159,7 @@ |
2464 | EXPECT_THROW({ |
2465 | msh::Surface test( |
2466 | mt::fake_shared(surface_builder), |
2467 | - params); |
2468 | + params, stub_id, stub_sender); |
2469 | }, std::runtime_error); |
2470 | } |
2471 | |
2472 | @@ -171,7 +174,7 @@ |
2473 | |
2474 | msh::Surface test( |
2475 | mt::fake_shared(surface_builder), |
2476 | - msh::a_surface()); |
2477 | + msh::a_surface(), stub_id, stub_sender); |
2478 | |
2479 | Mock::VerifyAndClearExpectations(&test); |
2480 | EXPECT_CALL(surface_builder, destroy_surface(_)).Times(1); |
2481 | @@ -187,7 +190,7 @@ |
2482 | { |
2483 | msh::Surface test( |
2484 | mt::fake_shared(surface_builder), |
2485 | - msh::a_surface()); |
2486 | + msh::a_surface(), stub_id, stub_sender); |
2487 | |
2488 | EXPECT_NO_THROW({ |
2489 | test.size(); |
2490 | @@ -204,7 +207,7 @@ |
2491 | { |
2492 | msh::Surface test( |
2493 | mt::fake_shared(surface_builder), |
2494 | - msh::a_surface()); |
2495 | + msh::a_surface(), stub_id, stub_sender); |
2496 | |
2497 | EXPECT_NO_THROW({ |
2498 | test.top_left(); |
2499 | @@ -221,7 +224,7 @@ |
2500 | { |
2501 | msh::Surface test( |
2502 | mt::fake_shared(surface_builder), |
2503 | - msh::a_surface()); |
2504 | + msh::a_surface(), stub_id, stub_sender); |
2505 | |
2506 | EXPECT_NO_THROW({ |
2507 | test.name(); |
2508 | @@ -238,7 +241,7 @@ |
2509 | { |
2510 | msh::Surface test( |
2511 | mt::fake_shared(surface_builder), |
2512 | - msh::a_surface()); |
2513 | + msh::a_surface(), stub_id, stub_sender); |
2514 | |
2515 | EXPECT_NO_THROW({ |
2516 | test.pixel_format(); |
2517 | @@ -255,7 +258,7 @@ |
2518 | { |
2519 | msh::Surface test( |
2520 | mt::fake_shared(surface_builder), |
2521 | - msh::a_surface()); |
2522 | + msh::a_surface(), stub_id, stub_sender); |
2523 | |
2524 | EXPECT_NO_THROW({ |
2525 | test.hide(); |
2526 | @@ -272,7 +275,7 @@ |
2527 | { |
2528 | msh::Surface test( |
2529 | mt::fake_shared(surface_builder), |
2530 | - msh::a_surface()); |
2531 | + msh::a_surface(), stub_id, stub_sender); |
2532 | |
2533 | EXPECT_NO_THROW({ |
2534 | test.show(); |
2535 | @@ -289,7 +292,7 @@ |
2536 | { |
2537 | msh::Surface test( |
2538 | mt::fake_shared(surface_builder), |
2539 | - msh::a_surface()); |
2540 | + msh::a_surface(), stub_id, stub_sender); |
2541 | |
2542 | EXPECT_NO_THROW({ |
2543 | test.destroy(); |
2544 | @@ -306,7 +309,7 @@ |
2545 | { |
2546 | msh::Surface test( |
2547 | mt::fake_shared(surface_builder), |
2548 | - msh::a_surface()); |
2549 | + msh::a_surface(), stub_id, stub_sender); |
2550 | |
2551 | EXPECT_NO_THROW({ |
2552 | test.force_requests_to_complete(); |
2553 | @@ -323,7 +326,7 @@ |
2554 | { |
2555 | msh::Surface test( |
2556 | mt::fake_shared(surface_builder), |
2557 | - msh::a_surface()); |
2558 | + msh::a_surface(), stub_id, stub_sender); |
2559 | |
2560 | EXPECT_NO_THROW({ |
2561 | test.advance_client_buffer(); |
2562 | @@ -340,7 +343,7 @@ |
2563 | { |
2564 | msh::Surface test( |
2565 | mt::fake_shared(surface_builder), |
2566 | - msh::a_surface()); |
2567 | + msh::a_surface(), stub_id, stub_sender); |
2568 | |
2569 | surface_builder.reset_surface(); |
2570 | |
2571 | @@ -355,7 +358,7 @@ |
2572 | |
2573 | msh::Surface surf( |
2574 | mt::fake_shared(surface_builder), |
2575 | - msh::a_surface()); |
2576 | + msh::a_surface(), stub_id, stub_sender); |
2577 | |
2578 | EXPECT_THROW({ |
2579 | surf.configure(static_cast<MirSurfaceAttrib>(111), 222); |
2580 | @@ -368,7 +371,7 @@ |
2581 | |
2582 | msh::Surface surf( |
2583 | mt::fake_shared(surface_builder), |
2584 | - msh::a_surface()); |
2585 | + msh::a_surface(), stub_id, stub_sender); |
2586 | |
2587 | EXPECT_EQ(mir_surface_type_normal, surf.type()); |
2588 | |
2589 | @@ -402,7 +405,7 @@ |
2590 | |
2591 | msh::Surface surf( |
2592 | mt::fake_shared(surface_builder), |
2593 | - msh::a_surface()); |
2594 | + msh::a_surface(), stub_id, stub_sender); |
2595 | |
2596 | EXPECT_EQ(mir_surface_state_restored, surf.state()); |
2597 | |
2598 | @@ -436,7 +439,7 @@ |
2599 | |
2600 | msh::Surface test( |
2601 | mt::fake_shared(surface_builder), |
2602 | - msh::a_surface()); |
2603 | + msh::a_surface(), stub_id, stub_sender); |
2604 | |
2605 | mtd::MockInputTargeter targeter; |
2606 | EXPECT_CALL(targeter, focus_changed(_)).Times(1); |
2607 | @@ -450,7 +453,7 @@ |
2608 | |
2609 | msh::Surface test( |
2610 | mt::fake_shared(surface_builder), |
2611 | - msh::a_surface()); |
2612 | + msh::a_surface(), stub_id, stub_sender); |
2613 | surface_builder.reset_surface(); |
2614 | |
2615 | mtd::StubInputTargeter targeter; |
2616 | @@ -466,7 +469,7 @@ |
2617 | |
2618 | msh::Surface test( |
2619 | mt::fake_shared(surface_builder), |
2620 | - msh::a_surface()); |
2621 | + msh::a_surface(), stub_id, stub_sender); |
2622 | |
2623 | EXPECT_NO_THROW({ |
2624 | test.set_input_region(std::vector<geom::Rectangle>{}); |
2625 | @@ -483,7 +486,7 @@ |
2626 | { |
2627 | msh::Surface test( |
2628 | mt::fake_shared(surface_builder), |
2629 | - msh::a_surface()); |
2630 | + msh::a_surface(), stub_id, stub_sender); |
2631 | |
2632 | mg::Buffer* buf_ptr{nullptr}; |
2633 | |
2634 | |
2635 | === modified file 'tests/unit-tests/shell/test_the_session_container_implementation.cpp' |
2636 | --- tests/unit-tests/shell/test_the_session_container_implementation.cpp 2013-07-24 03:59:44 +0000 |
2637 | +++ tests/unit-tests/shell/test_the_session_container_implementation.cpp 2013-07-31 16:00:57 +0000 |
2638 | @@ -24,12 +24,12 @@ |
2639 | #include "mir_test_doubles/mock_buffer_stream.h" |
2640 | #include "mir_test_doubles/mock_surface_factory.h" |
2641 | #include "mir_test_doubles/null_snapshot_strategy.h" |
2642 | +#include "mir_test_doubles/null_event_sink.h" |
2643 | |
2644 | #include <gmock/gmock.h> |
2645 | #include <gtest/gtest.h> |
2646 | #include <string> |
2647 | |
2648 | -namespace me = mir::events; |
2649 | namespace mf = mir::frontend; |
2650 | namespace msh = mir::shell; |
2651 | namespace mtd = mir::test::doubles; |
2652 | @@ -44,7 +44,8 @@ |
2653 | return std::make_shared<msh::ApplicationSession>( |
2654 | factory, session_name, |
2655 | std::make_shared<mtd::NullSnapshotStrategy>(), |
2656 | - std::make_shared<msh::NullSessionListener>()); |
2657 | + std::make_shared<msh::NullSessionListener>(), |
2658 | + std::make_shared<mtd::NullEventSink>()); |
2659 | } |
2660 | |
2661 | } |
PASSED: Continuous integration, rev:891 jenkins. qa.ubuntu. com/job/ mir-ci/ 1107/ jenkins. qa.ubuntu. com/job/ mir-android- saucy-i386- build/1451 jenkins. qa.ubuntu. com/job/ mir-clang- saucy-amd64- build/1336 jenkins. qa.ubuntu. com/job/ mir-saucy- amd64-ci/ 345 jenkins. qa.ubuntu. com/job/ mir-saucy- amd64-ci/ 345/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-vm- ci-build/ ./distribution= quantal, flavor= amd64/719
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ mir-ci/ 1107/rebuild
http://