Merge lp:~kdub/mir/platform-operations into lp:mir
- platform-operations
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Kevin DuBois |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2060 |
Proposed branch: | lp:~kdub/mir/platform-operations |
Merge into: | lp:mir |
Diff against target: |
1122 lines (+248/-334) 26 files modified
benchmarks/frame-uniformity/vsync_simulating_graphics_platform.cpp (+5/-0) include/platform/mir/graphics/platform_ipc_operations.h (+10/-1) include/platform/mir/graphics/platform_ipc_package.h (+0/-1) platform-ABI-sha1sums (+2/-2) server-ABI-sha1sums (+2/-2) src/platform/graphics/android/ipc_operations.cpp (+8/-0) src/platform/graphics/android/ipc_operations.h (+2/-0) src/platform/graphics/mesa/ipc_operations.cpp (+12/-0) src/platform/graphics/mesa/ipc_operations.h (+3/-0) src/server/frontend/default_configuration.cpp (+2/-1) src/server/frontend/default_ipc_factory.cpp (+5/-5) src/server/frontend/default_ipc_factory.h (+4/-4) src/server/frontend/session_mediator.cpp (+15/-17) src/server/frontend/session_mediator.h (+1/-4) src/server/graphics/nested/nested_platform.cpp (+7/-0) tests/include/mir_test_doubles/null_platform_ipc_operations.h (+5/-0) tests/integration-tests/test_drm_auth_magic.cpp (+35/-9) tests/integration-tests/test_exchange_buffer.cpp (+6/-0) tests/mir_test_framework/stubbed_graphics_platform.cpp (+6/-0) tests/unit-tests/frontend/CMakeLists.txt (+0/-10) tests/unit-tests/frontend/test_session_mediator.cpp (+57/-38) tests/unit-tests/frontend/test_session_mediator_android.cpp (+0/-95) tests/unit-tests/frontend/test_session_mediator_mesa.cpp (+0/-141) tests/unit-tests/graphics/android/CMakeLists.txt (+1/-0) tests/unit-tests/graphics/android/test_ipc_operations.cpp (+50/-0) tests/unit-tests/graphics/mesa/test_platform.cpp (+10/-4) |
To merge this branch: | bzr merge lp:~kdub/mir/platform-operations |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alan Griffiths | Approve | ||
Alexandros Frantzis (community) | Approve | ||
Cemil Azizoglu (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Chris Halse Rogers | Approve | ||
Review via email: mp+241563@code.launchpad.net |
Commit message
platform: Allow for use of platform operations in the platform interfaces. This currently abstracts the drm auth magic request for the mesa platform. (the protocol still needs the drm magic stuff weeded out)
Description of the change
platform: Allow for use of platform operations in the platform interfaces. This currently abstracts the drm auth magic request for the mesa platform. (the protocol still needs the drm magic stuff weeded out)
This is a branch that sprung from the discussion started here:
https:/
I opted to put an opcode in the signature (Alan suggested on the chain that an opcode/type of operation is not necessary, it could just be part of the "DataAndFds"), mostly because all platform requests will need an opcode to distinguish what is to be done.
This benefits SessionMediator in that we don't have to cast to figure out whether we're dealing with the mesa platform or not. We also no longer need mg::Platform in SessionMediator, just mg::PlatformIpc
note: This branch has been rattling around my computer for a bit, now that I'm attempting to clean up the platform a bit and split out the nested/offscreen into actual platforms, seemed like a good time to propose.
note2: There's another cleanup coming that should also have a negative diff... but I figured ~1100 was a good review size.
PS Jenkins bot (ps-jenkins) wrote : | # |
Kevin DuBois (kdub) wrote : | # |
doesnt look related retriggered.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2026
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Chris Halse Rogers (raof) wrote : | # |
Looks sensible to me. A bunch of spurious frontend:: → mf:: diff, but that's managable :)
Alan Griffiths (alan-griffiths) wrote : | # |
> doesnt look related retriggered.
filed as lp:1392256
Alan Griffiths (alan-griffiths) wrote : | # |
Nit I suspect that this:
170 + the_graphics_
should be:
170 + the_ipc_
With the_ipc_
LGTM
Alexandros Frantzis (afrantzis) wrote : | # |
> virtual void platform_operation(
> PlatformIPCPackage& response, unsigned int const opcode, PlatformIPCPackage const& package) = 0;
The other option is:
virtual PlatformIPCPackage platform_
PlatformIPCPackage is movable so even if (N)RVO doesn't kick in, returning the package should be cheap.
Weak "Needs Fixing", I prefer it with the return value, but I am not fussed.
Kevin DuBois (kdub) wrote : | # |
I think my [weak] reason for having an out parameter was that I could forward-declare the PlatformIPCPackage type in the platform_ipc.h header... but I do like returning the response package a bit better.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2028
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Cemil Azizoglu (cemil-azizoglu) wrote : | # |
This makes the arch a whole lot cleaner. Looking forward to the IPC part of the cleanup.
Alexandros Frantzis (afrantzis) wrote : | # |
> I think my [weak] reason for having an out parameter was that I could forward-declare the PlatformIPCPackage type in the platform_ipc.h header...
It's allowed to declare functions that return (or accept) incomplete types, so we can still forward-declare PlatformIPCPackage in this case if we want.
Alan Griffiths (alan-griffiths) wrote : | # |
24 +#include "platform_
...
32 -struct PlatformIPCPackage;
Not needed - the declaration was enough.
Preview Diff
1 | === modified file 'benchmarks/frame-uniformity/vsync_simulating_graphics_platform.cpp' |
2 | --- benchmarks/frame-uniformity/vsync_simulating_graphics_platform.cpp 2014-10-26 00:41:36 +0000 |
3 | +++ benchmarks/frame-uniformity/vsync_simulating_graphics_platform.cpp 2014-11-13 16:42:20 +0000 |
4 | @@ -61,6 +61,11 @@ |
5 | { |
6 | return std::make_shared<mg::PlatformIPCPackage>(); |
7 | } |
8 | + |
9 | + mg::PlatformIPCPackage platform_operation(unsigned int const, mg::PlatformIPCPackage const&) override |
10 | + { |
11 | + return mg::PlatformIPCPackage(); |
12 | + } |
13 | }; |
14 | |
15 | struct StubDisplayBuffer : mtd::StubDisplayBuffer |
16 | |
17 | === modified file 'include/platform/mir/graphics/platform_ipc_operations.h' |
18 | --- include/platform/mir/graphics/platform_ipc_operations.h 2014-10-06 03:02:44 +0000 |
19 | +++ include/platform/mir/graphics/platform_ipc_operations.h 2014-11-13 16:42:20 +0000 |
20 | @@ -19,6 +19,7 @@ |
21 | #ifndef MIR_GRAPHICS_PLATFORM_IPC_OPERATIONS_H_ |
22 | #define MIR_GRAPHICS_PLATFORM_IPC_OPERATIONS_H_ |
23 | |
24 | +#include "platform_ipc_package.h" |
25 | #include <memory> |
26 | |
27 | namespace mir |
28 | @@ -32,7 +33,6 @@ |
29 | }; |
30 | class Buffer; |
31 | class BufferIpcMessage; |
32 | -struct PlatformIPCPackage; |
33 | |
34 | class PlatformIpcOperations |
35 | { |
36 | @@ -68,6 +68,15 @@ |
37 | */ |
38 | virtual std::shared_ptr<PlatformIPCPackage> connection_ipc_package() = 0; |
39 | |
40 | + |
41 | + /** |
42 | + * Arranges a platform specific operation triggered by an IPC call |
43 | + * \returns the response that will be sent to the client |
44 | + * \param [in] opcode the opcode that indicates the action to be performed |
45 | + * \param [in] request the message that was sent to the server |
46 | + */ |
47 | + virtual PlatformIPCPackage platform_operation(unsigned int const opcode, PlatformIPCPackage const& package) = 0; |
48 | + |
49 | protected: |
50 | PlatformIpcOperations() = default; |
51 | PlatformIpcOperations(PlatformIpcOperations const&) = delete; |
52 | |
53 | === modified file 'include/platform/mir/graphics/platform_ipc_package.h' |
54 | --- include/platform/mir/graphics/platform_ipc_package.h 2014-10-21 16:21:14 +0000 |
55 | +++ include/platform/mir/graphics/platform_ipc_package.h 2014-11-13 16:42:20 +0000 |
56 | @@ -32,7 +32,6 @@ |
57 | */ |
58 | struct PlatformIPCPackage |
59 | { |
60 | - virtual ~PlatformIPCPackage() {} |
61 | std::vector<int32_t> ipc_data; |
62 | std::vector<int32_t> ipc_fds; |
63 | }; |
64 | |
65 | === modified file 'platform-ABI-sha1sums' |
66 | --- platform-ABI-sha1sums 2014-11-11 07:34:31 +0000 |
67 | +++ platform-ABI-sha1sums 2014-11-13 16:42:20 +0000 |
68 | @@ -37,8 +37,8 @@ |
69 | c9730cac4a3a101f9706ec6f444958abe047fd88 include/platform/mir/graphics/internal_surface.h |
70 | d4ab0ef9544345fcc85740f6ed6d8118728a5c59 include/platform/mir/graphics/native_platform.h |
71 | 109d2c82d245a512e7c1790a3b853c9c275ebd4d include/platform/mir/graphics/platform.h |
72 | -1fbe488b4581486fd01e2f03e504f31b72c09040 include/platform/mir/graphics/platform_ipc_operations.h |
73 | -9c7712af84b6fde1970ff802ad2ea78f892c7b7e include/platform/mir/graphics/platform_ipc_package.h |
74 | +3b3463d2513f4c3985f2400496dab333518f9a13 include/platform/mir/graphics/platform_ipc_operations.h |
75 | +1b77fb3290af00dc7d1c11dcc5388972dacb9ec3 include/platform/mir/graphics/platform_ipc_package.h |
76 | 84c063346b3bd51b4624d9f940008d4c3f8be066 include/platform/mir/graphics/renderable.h |
77 | b19329d35a55f640edd72c0a953908995211d97e include/platform/mir/options/configuration.h |
78 | 47007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h |
79 | |
80 | === modified file 'server-ABI-sha1sums' |
81 | --- server-ABI-sha1sums 2014-11-13 15:24:33 +0000 |
82 | +++ server-ABI-sha1sums 2014-11-13 16:42:20 +0000 |
83 | @@ -37,8 +37,8 @@ |
84 | c9730cac4a3a101f9706ec6f444958abe047fd88 include/platform/mir/graphics/internal_surface.h |
85 | d4ab0ef9544345fcc85740f6ed6d8118728a5c59 include/platform/mir/graphics/native_platform.h |
86 | 109d2c82d245a512e7c1790a3b853c9c275ebd4d include/platform/mir/graphics/platform.h |
87 | -1fbe488b4581486fd01e2f03e504f31b72c09040 include/platform/mir/graphics/platform_ipc_operations.h |
88 | -9c7712af84b6fde1970ff802ad2ea78f892c7b7e include/platform/mir/graphics/platform_ipc_package.h |
89 | +3b3463d2513f4c3985f2400496dab333518f9a13 include/platform/mir/graphics/platform_ipc_operations.h |
90 | +1b77fb3290af00dc7d1c11dcc5388972dacb9ec3 include/platform/mir/graphics/platform_ipc_package.h |
91 | 84c063346b3bd51b4624d9f940008d4c3f8be066 include/platform/mir/graphics/renderable.h |
92 | b19329d35a55f640edd72c0a953908995211d97e include/platform/mir/options/configuration.h |
93 | 47007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h |
94 | |
95 | === modified file 'src/platform/graphics/android/ipc_operations.cpp' |
96 | --- src/platform/graphics/android/ipc_operations.cpp 2014-10-16 19:07:47 +0000 |
97 | +++ src/platform/graphics/android/ipc_operations.cpp 2014-11-13 16:42:20 +0000 |
98 | @@ -21,6 +21,8 @@ |
99 | #include "mir/graphics/buffer_ipc_message.h" |
100 | #include "mir/graphics/android/android_native_buffer.h" |
101 | #include "ipc_operations.h" |
102 | +#include <stdexcept> |
103 | +#include <boost/throw_exception.hpp> |
104 | |
105 | namespace mg = mir::graphics; |
106 | namespace mga = mir::graphics::android; |
107 | @@ -67,3 +69,9 @@ |
108 | { |
109 | return std::make_shared<mg::PlatformIPCPackage>(); |
110 | } |
111 | + |
112 | +mg::PlatformIPCPackage mga::IpcOperations::platform_operation( |
113 | + unsigned int const, mg::PlatformIPCPackage const&) |
114 | +{ |
115 | + BOOST_THROW_EXCEPTION(std::invalid_argument("android platform does not support any platform operations")); |
116 | +} |
117 | |
118 | === modified file 'src/platform/graphics/android/ipc_operations.h' |
119 | --- src/platform/graphics/android/ipc_operations.h 2014-09-03 12:24:33 +0000 |
120 | +++ src/platform/graphics/android/ipc_operations.h 2014-11-13 16:42:20 +0000 |
121 | @@ -33,6 +33,8 @@ |
122 | void pack_buffer(BufferIpcMessage&, Buffer const&, BufferIpcMsgType) const override; |
123 | void unpack_buffer(BufferIpcMessage&, Buffer const&) const override; |
124 | std::shared_ptr<PlatformIPCPackage> connection_ipc_package() override; |
125 | + PlatformIPCPackage platform_operation( |
126 | + unsigned int const opcode, PlatformIPCPackage const& package) override; |
127 | }; |
128 | } |
129 | } |
130 | |
131 | === modified file 'src/platform/graphics/mesa/ipc_operations.cpp' |
132 | --- src/platform/graphics/mesa/ipc_operations.cpp 2014-09-03 12:24:33 +0000 |
133 | +++ src/platform/graphics/mesa/ipc_operations.cpp 2014-11-13 16:42:20 +0000 |
134 | @@ -77,3 +77,15 @@ |
135 | void mgm::IpcOperations::unpack_buffer(BufferIpcMessage&, Buffer const&) const |
136 | { |
137 | } |
138 | + |
139 | +mg::PlatformIPCPackage mgm::IpcOperations::platform_operation( |
140 | + unsigned int const, mg::PlatformIPCPackage const& request) |
141 | +{ |
142 | + int magic{0}; |
143 | + if (request.ipc_data.size() > 0) |
144 | + magic = request.ipc_data[0]; |
145 | + |
146 | + drm->auth_magic(magic); |
147 | + |
148 | + return mg::PlatformIPCPackage{{0},{}}; |
149 | +} |
150 | |
151 | === modified file 'src/platform/graphics/mesa/ipc_operations.h' |
152 | --- src/platform/graphics/mesa/ipc_operations.h 2014-09-03 12:24:33 +0000 |
153 | +++ src/platform/graphics/mesa/ipc_operations.h 2014-11-13 16:42:20 +0000 |
154 | @@ -37,6 +37,9 @@ |
155 | void pack_buffer(BufferIpcMessage& message, Buffer const& buffer, BufferIpcMsgType msg_type) const override; |
156 | void unpack_buffer(BufferIpcMessage& message, Buffer const& buffer) const override; |
157 | std::shared_ptr<PlatformIPCPackage> connection_ipc_package() override; |
158 | + PlatformIPCPackage platform_operation( |
159 | + unsigned int const opcode, |
160 | + PlatformIPCPackage const& package) override; |
161 | private: |
162 | std::shared_ptr<helpers::DRMHelper> const drm; |
163 | }; |
164 | |
165 | === modified file 'src/server/frontend/default_configuration.cpp' |
166 | --- src/server/frontend/default_configuration.cpp 2014-10-27 22:31:16 +0000 |
167 | +++ src/server/frontend/default_configuration.cpp 2014-11-13 16:42:20 +0000 |
168 | @@ -24,6 +24,7 @@ |
169 | |
170 | #include "unsupported_coordinate_translator.h" |
171 | |
172 | +#include "mir/graphics/platform.h" |
173 | #include "mir/frontend/protobuf_connection_creator.h" |
174 | #include "mir/frontend/session_authorizer.h" |
175 | #include "mir/options/configuration.h" |
176 | @@ -152,7 +153,7 @@ |
177 | return std::make_shared<mf::DefaultIpcFactory>( |
178 | the_frontend_shell(), |
179 | the_session_mediator_report(), |
180 | - the_graphics_platform(), |
181 | + the_graphics_platform()->make_ipc_operations(), |
182 | the_frontend_display_changer(), |
183 | the_buffer_allocator(), |
184 | the_screencast(), |
185 | |
186 | === modified file 'src/server/frontend/default_ipc_factory.cpp' |
187 | --- src/server/frontend/default_ipc_factory.cpp 2014-10-27 22:31:16 +0000 |
188 | +++ src/server/frontend/default_ipc_factory.cpp 2014-11-13 16:42:20 +0000 |
189 | @@ -33,7 +33,7 @@ |
190 | mf::DefaultIpcFactory::DefaultIpcFactory( |
191 | std::shared_ptr<Shell> const& shell, |
192 | std::shared_ptr<SessionMediatorReport> const& sm_report, |
193 | - std::shared_ptr<mg::Platform> const& graphics_platform, |
194 | + std::shared_ptr<mg::PlatformIpcOperations> const& platform_ipc_operations, |
195 | std::shared_ptr<DisplayChanger> const& display_changer, |
196 | std::shared_ptr<mg::GraphicBufferAllocator> const& buffer_allocator, |
197 | std::shared_ptr<Screencast> const& screencast, |
198 | @@ -44,7 +44,7 @@ |
199 | no_prompt_shell(std::make_shared<NoPromptShell>(shell)), |
200 | sm_report(sm_report), |
201 | cache(std::make_shared<ResourceCache>()), |
202 | - graphics_platform(graphics_platform), |
203 | + platform_ipc_operations(platform_ipc_operations), |
204 | display_changer(display_changer), |
205 | buffer_allocator(buffer_allocator), |
206 | screencast(screencast), |
207 | @@ -87,7 +87,7 @@ |
208 | |
209 | return make_mediator( |
210 | effective_shell, |
211 | - graphics_platform, |
212 | + platform_ipc_operations, |
213 | changer, |
214 | buffer_allocator, |
215 | sm_report, |
216 | @@ -103,7 +103,7 @@ |
217 | |
218 | std::shared_ptr<mf::detail::DisplayServer> mf::DefaultIpcFactory::make_mediator( |
219 | std::shared_ptr<Shell> const& shell, |
220 | - std::shared_ptr<mg::Platform> const& graphics_platform, |
221 | + std::shared_ptr<mg::PlatformIpcOperations> const& platform_ipc_operations, |
222 | std::shared_ptr<DisplayChanger> const& changer, |
223 | std::shared_ptr<mg::GraphicBufferAllocator> const& buffer_allocator, |
224 | std::shared_ptr<SessionMediatorReport> const& sm_report, |
225 | @@ -114,7 +114,7 @@ |
226 | { |
227 | return std::make_shared<SessionMediator>( |
228 | shell, |
229 | - graphics_platform, |
230 | + platform_ipc_operations, |
231 | changer, |
232 | buffer_allocator->supported_pixel_formats(), |
233 | sm_report, |
234 | |
235 | === modified file 'src/server/frontend/default_ipc_factory.h' |
236 | --- src/server/frontend/default_ipc_factory.h 2014-10-27 22:31:16 +0000 |
237 | +++ src/server/frontend/default_ipc_factory.h 2014-11-13 16:42:20 +0000 |
238 | @@ -25,7 +25,7 @@ |
239 | { |
240 | namespace graphics |
241 | { |
242 | -class Platform; |
243 | +class PlatformIpcOperations; |
244 | class GraphicBufferAllocator; |
245 | } |
246 | namespace input |
247 | @@ -52,7 +52,7 @@ |
248 | explicit DefaultIpcFactory( |
249 | std::shared_ptr<Shell> const& shell, |
250 | std::shared_ptr<SessionMediatorReport> const& sm_report, |
251 | - std::shared_ptr<graphics::Platform> const& graphics_platform, |
252 | + std::shared_ptr<graphics::PlatformIpcOperations> const& platform_ipc_operations, |
253 | std::shared_ptr<DisplayChanger> const& display_changer, |
254 | std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator, |
255 | std::shared_ptr<Screencast> const& screencast, |
256 | @@ -69,7 +69,7 @@ |
257 | |
258 | virtual std::shared_ptr<detail::DisplayServer> make_mediator( |
259 | std::shared_ptr<Shell> const& shell, |
260 | - std::shared_ptr<graphics::Platform> const& graphics_platform, |
261 | + std::shared_ptr<graphics::PlatformIpcOperations> const& platform_ipc_operations, |
262 | std::shared_ptr<DisplayChanger> const& changer, |
263 | std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator, |
264 | std::shared_ptr<SessionMediatorReport> const& sm_report, |
265 | @@ -83,7 +83,7 @@ |
266 | std::shared_ptr<Shell> const no_prompt_shell; |
267 | std::shared_ptr<SessionMediatorReport> const sm_report; |
268 | std::shared_ptr<ResourceCache> const cache; |
269 | - std::shared_ptr<graphics::Platform> const graphics_platform; |
270 | + std::shared_ptr<graphics::PlatformIpcOperations> const platform_ipc_operations; |
271 | std::shared_ptr<DisplayChanger> const display_changer; |
272 | std::shared_ptr<graphics::GraphicBufferAllocator> const buffer_allocator; |
273 | std::shared_ptr<Screencast> const screencast; |
274 | |
275 | === modified file 'src/server/frontend/session_mediator.cpp' |
276 | --- src/server/frontend/session_mediator.cpp 2014-10-30 18:37:11 +0000 |
277 | +++ src/server/frontend/session_mediator.cpp 2014-11-13 16:42:20 +0000 |
278 | @@ -35,6 +35,7 @@ |
279 | #include "mir/frontend/display_changer.h" |
280 | #include "mir/graphics/display_configuration.h" |
281 | #include "mir/graphics/pixel_format_utils.h" |
282 | +#include "mir/graphics/platform_ipc_operations.h" |
283 | #include "mir/graphics/platform_ipc_package.h" |
284 | #include "mir/graphics/drm_authenticator.h" |
285 | #include "mir/frontend/client_constants.h" |
286 | @@ -64,8 +65,8 @@ |
287 | namespace geom = mir::geometry; |
288 | |
289 | mf::SessionMediator::SessionMediator( |
290 | - std::shared_ptr<frontend::Shell> const& shell, |
291 | - std::shared_ptr<graphics::Platform> const & graphics_platform, |
292 | + std::shared_ptr<mf::Shell> const& shell, |
293 | + std::shared_ptr<mg::PlatformIpcOperations> const& ipc_operations, |
294 | std::shared_ptr<mf::DisplayChanger> const& display_changer, |
295 | std::vector<MirPixelFormat> const& surface_pixel_formats, |
296 | std::shared_ptr<SessionMediatorReport> const& report, |
297 | @@ -77,8 +78,7 @@ |
298 | std::shared_ptr<scene::CoordinateTranslator> const& translator) : |
299 | client_pid_(0), |
300 | shell(shell), |
301 | - graphics_platform(graphics_platform), |
302 | - ipc_operations(graphics_platform->make_ipc_operations()), |
303 | + ipc_operations(ipc_operations), |
304 | surface_pixel_formats(surface_pixel_formats), |
305 | display_changer(display_changer), |
306 | report(report), |
307 | @@ -357,7 +357,7 @@ |
308 | |
309 | report->session_configure_surface_called(session->name()); |
310 | |
311 | - auto const id = frontend::SurfaceId(request->surfaceid().value()); |
312 | + auto const id = mf::SurfaceId(request->surfaceid().value()); |
313 | int value = request->ivalue(); |
314 | auto const surface = session->get_surface(id); |
315 | int newvalue = surface->configure(attrib, value); |
316 | @@ -474,7 +474,7 @@ |
317 | |
318 | std::function<void(std::shared_ptr<mf::Session> const&)> mf::SessionMediator::prompt_session_connect_handler() const |
319 | { |
320 | - return [this](std::shared_ptr<frontend::Session> const& session) |
321 | + return [this](std::shared_ptr<mf::Session> const& session) |
322 | { |
323 | auto prompt_session = weak_prompt_session.lock(); |
324 | if (prompt_session.get() == nullptr) |
325 | @@ -500,7 +500,7 @@ |
326 | |
327 | report->session_configure_surface_cursor_called(session->name()); |
328 | |
329 | - auto const id = frontend::SurfaceId(cursor_request->surfaceid().value()); |
330 | + auto const id = mf::SurfaceId(cursor_request->surfaceid().value()); |
331 | auto const surface = session->get_surface(id); |
332 | |
333 | if (cursor_request->has_name()) |
334 | @@ -548,7 +548,7 @@ |
335 | done->Run(); |
336 | } |
337 | |
338 | -void mir::frontend::SessionMediator::translate_surface_to_screen( |
339 | +void mf::SessionMediator::translate_surface_to_screen( |
340 | ::google::protobuf::RpcController* , |
341 | ::mir::protobuf::CoordinateTranslationRequest const* request, |
342 | ::mir::protobuf::CoordinateTranslationResponse* response, |
343 | @@ -562,7 +562,7 @@ |
344 | if (session.get() == nullptr) |
345 | BOOST_THROW_EXCEPTION(std::logic_error("Invalid application session")); |
346 | |
347 | - auto const id = frontend::SurfaceId(request->surfaceid().value()); |
348 | + auto const id = mf::SurfaceId(request->surfaceid().value()); |
349 | |
350 | auto const coords = translator->surface_to_screen(session->get_surface(id), |
351 | request->x(), |
352 | @@ -590,16 +590,14 @@ |
353 | report->session_drm_auth_magic_called(session->name()); |
354 | } |
355 | |
356 | - auto const magic = static_cast<unsigned int>(request->magic()); |
357 | - //FIXME: don't dynamic cast like this drm_auth_magic should be a part of PlatformIpcOperations |
358 | - auto authenticator = std::dynamic_pointer_cast<mg::DRMAuthenticator>(graphics_platform); |
359 | - if (!authenticator) |
360 | - BOOST_THROW_EXCEPTION(std::logic_error("drm_auth_magic request not supported by the active platform")); |
361 | - |
362 | + //TODO: the opcode should be provided as part of the request, and should be opaque to the server code. |
363 | + unsigned int const made_up_opcode{0}; |
364 | + mg::PlatformIPCPackage platform_request{{static_cast<int32_t>(request->magic())},{}}; |
365 | try |
366 | { |
367 | - authenticator->drm_auth_magic(magic); |
368 | - response->set_status_code(0); |
369 | + auto platform_response = ipc_operations->platform_operation(made_up_opcode, platform_request); |
370 | + if (platform_response.ipc_data.size() > 0) |
371 | + response->set_status_code(platform_response.ipc_data[0]); |
372 | } |
373 | catch (std::exception const& e) |
374 | { |
375 | |
376 | === modified file 'src/server/frontend/session_mediator.h' |
377 | --- src/server/frontend/session_mediator.h 2014-11-03 06:51:26 +0000 |
378 | +++ src/server/frontend/session_mediator.h 2014-11-13 16:42:20 +0000 |
379 | @@ -22,7 +22,6 @@ |
380 | #include "display_server.h" |
381 | #include "mir/frontend/connection_context.h" |
382 | #include "mir/frontend/surface_id.h" |
383 | -#include "mir/graphics/platform.h" |
384 | #include "mir/graphics/platform_ipc_operations.h" |
385 | #include "mir_toolkit/common.h" |
386 | #include "surface_tracker.h" |
387 | @@ -37,7 +36,6 @@ |
388 | namespace graphics |
389 | { |
390 | class Buffer; |
391 | -class Platform; |
392 | class Display; |
393 | class GraphicBufferAllocator; |
394 | } |
395 | @@ -73,7 +71,7 @@ |
396 | |
397 | SessionMediator( |
398 | std::shared_ptr<Shell> const& shell, |
399 | - std::shared_ptr<graphics::Platform> const& graphics_platform, |
400 | + std::shared_ptr<graphics::PlatformIpcOperations> const& ipc_operations, |
401 | std::shared_ptr<frontend::DisplayChanger> const& display_changer, |
402 | std::vector<MirPixelFormat> const& surface_pixel_formats, |
403 | std::shared_ptr<SessionMediatorReport> const& report, |
404 | @@ -194,7 +192,6 @@ |
405 | |
406 | pid_t client_pid_; |
407 | std::shared_ptr<Shell> const shell; |
408 | - std::shared_ptr<graphics::Platform> const graphics_platform; |
409 | std::shared_ptr<graphics::PlatformIpcOperations> const ipc_operations; |
410 | |
411 | std::vector<MirPixelFormat> const surface_pixel_formats; |
412 | |
413 | === modified file 'src/server/graphics/nested/nested_platform.cpp' |
414 | --- src/server/graphics/nested/nested_platform.cpp 2014-10-27 13:06:48 +0000 |
415 | +++ src/server/graphics/nested/nested_platform.cpp 2014-11-13 16:42:20 +0000 |
416 | @@ -111,12 +111,19 @@ |
417 | { |
418 | native_platform->fill_buffer_package(&message, &buffer, msg_type); |
419 | } |
420 | + |
421 | void unpack_buffer(mg::BufferIpcMessage&, mg::Buffer const&) const {} |
422 | |
423 | std::shared_ptr<mg::PlatformIPCPackage> connection_ipc_package() |
424 | { |
425 | return native_platform->connection_ipc_package(); |
426 | } |
427 | + |
428 | + mg::PlatformIPCPackage platform_operation(unsigned int const, mg::PlatformIPCPackage const&) override |
429 | + { |
430 | + return mg::PlatformIPCPackage(); |
431 | + } |
432 | + |
433 | private: |
434 | std::shared_ptr<mg::NativePlatform> const native_platform; |
435 | }; |
436 | |
437 | === modified file 'tests/include/mir_test_doubles/null_platform_ipc_operations.h' |
438 | --- tests/include/mir_test_doubles/null_platform_ipc_operations.h 2014-09-03 12:24:33 +0000 |
439 | +++ tests/include/mir_test_doubles/null_platform_ipc_operations.h 2014-11-13 16:42:20 +0000 |
440 | @@ -40,6 +40,11 @@ |
441 | { |
442 | return std::make_shared<graphics::PlatformIPCPackage>(); |
443 | } |
444 | + graphics::PlatformIPCPackage platform_operation( |
445 | + unsigned int const, graphics::PlatformIPCPackage const&) override |
446 | + { |
447 | + return graphics::PlatformIPCPackage(); |
448 | + } |
449 | }; |
450 | } |
451 | } |
452 | |
453 | === modified file 'tests/integration-tests/test_drm_auth_magic.cpp' |
454 | --- tests/integration-tests/test_drm_auth_magic.cpp 2014-10-16 11:53:01 +0000 |
455 | +++ tests/integration-tests/test_drm_auth_magic.cpp 2014-11-13 16:42:20 +0000 |
456 | @@ -19,6 +19,7 @@ |
457 | #include "mir/graphics/display.h" |
458 | #include "mir/graphics/drm_authenticator.h" |
459 | #include "mir/graphics/platform_ipc_package.h" |
460 | +#include "mir/graphics/buffer_ipc_message.h" |
461 | #include "mir/graphics/buffer_basic.h" |
462 | |
463 | #include <boost/exception/errinfo_errno.hpp> |
464 | @@ -44,15 +45,34 @@ |
465 | |
466 | char const* const mir_test_socket = mtf::test_socket_file().c_str(); |
467 | |
468 | -class MockAuthenticatingPlatform : public mtd::NullPlatform, public mg::DRMAuthenticator |
469 | +struct MockAuthenticatingIpcOps : public mg::PlatformIpcOperations |
470 | +{ |
471 | + MOCK_CONST_METHOD3(pack_buffer, void(mg::BufferIpcMessage&, mg::Buffer const&, mg::BufferIpcMsgType)); |
472 | + MOCK_CONST_METHOD2(unpack_buffer, void(mg::BufferIpcMessage&, mg::Buffer const&)); |
473 | + MOCK_METHOD0(connection_ipc_package, std::shared_ptr<mg::PlatformIPCPackage>()); |
474 | + MOCK_METHOD2(platform_operation, mg::PlatformIPCPackage( |
475 | + unsigned int const, mg::PlatformIPCPackage const&)); |
476 | +}; |
477 | + |
478 | +class StubAuthenticatingPlatform : public mtd::NullPlatform |
479 | { |
480 | public: |
481 | + StubAuthenticatingPlatform(std::shared_ptr<mg::PlatformIpcOperations> const& ops) : |
482 | + ops{ops} |
483 | + { |
484 | + } |
485 | + |
486 | std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator() override |
487 | { |
488 | return std::make_shared<mtd::StubBufferAllocator>(); |
489 | } |
490 | + std::shared_ptr<mg::PlatformIpcOperations> make_ipc_operations() const override |
491 | + { |
492 | + return ops; |
493 | + } |
494 | |
495 | - MOCK_METHOD1(drm_auth_magic, void(unsigned int)); |
496 | +private: |
497 | + std::shared_ptr<mg::PlatformIpcOperations> const ops; |
498 | }; |
499 | |
500 | void connection_callback(MirConnection* connection, void* context) |
501 | @@ -80,15 +100,20 @@ |
502 | using namespace testing; |
503 | if (!platform) |
504 | { |
505 | - platform = std::make_shared<MockAuthenticatingPlatform>(); |
506 | - EXPECT_CALL(*platform, drm_auth_magic(magic)) |
507 | - .Times(1); |
508 | + mg::PlatformIPCPackage pkg{{0},{}}; |
509 | + auto ipc_ops = std::make_shared<NiceMock<MockAuthenticatingIpcOps>>(); |
510 | + EXPECT_CALL(*ipc_ops, platform_operation(_,_)) |
511 | + .Times(1) |
512 | + .WillRepeatedly(Return(pkg)); |
513 | + ON_CALL(*ipc_ops, connection_ipc_package()) |
514 | + .WillByDefault(Return(std::make_shared<mg::PlatformIPCPackage>())); |
515 | + platform = std::make_shared<StubAuthenticatingPlatform>(ipc_ops); |
516 | } |
517 | |
518 | return platform; |
519 | } |
520 | |
521 | - std::shared_ptr<MockAuthenticatingPlatform> platform; |
522 | + std::shared_ptr<StubAuthenticatingPlatform> platform; |
523 | } server_config; |
524 | |
525 | launch_server_process(server_config); |
526 | @@ -130,16 +155,17 @@ |
527 | using namespace testing; |
528 | if (!platform) |
529 | { |
530 | - platform = std::make_shared<MockAuthenticatingPlatform>(); |
531 | - EXPECT_CALL(*platform, drm_auth_magic(magic)) |
532 | + auto ipc_ops = std::make_shared<NiceMock<MockAuthenticatingIpcOps>>(); |
533 | + EXPECT_CALL(*ipc_ops, platform_operation(_,_)) |
534 | .WillOnce(Throw(::boost::enable_error_info(std::exception()) |
535 | << boost::errinfo_errno(auth_magic_error))); |
536 | + platform = std::make_shared<StubAuthenticatingPlatform>(ipc_ops); |
537 | } |
538 | |
539 | return platform; |
540 | } |
541 | |
542 | - std::shared_ptr<MockAuthenticatingPlatform> platform; |
543 | + std::shared_ptr<StubAuthenticatingPlatform> platform; |
544 | } server_config; |
545 | |
546 | launch_server_process(server_config); |
547 | |
548 | === modified file 'tests/integration-tests/test_exchange_buffer.cpp' |
549 | --- tests/integration-tests/test_exchange_buffer.cpp 2014-10-27 20:15:54 +0000 |
550 | +++ tests/integration-tests/test_exchange_buffer.cpp 2014-11-13 16:42:20 +0000 |
551 | @@ -130,6 +130,12 @@ |
552 | { |
553 | return last_fd; |
554 | } |
555 | + |
556 | + mg::PlatformIPCPackage platform_operation( |
557 | + unsigned int const, mg::PlatformIPCPackage const&) override |
558 | + { |
559 | + return mg::PlatformIPCPackage(); |
560 | + } |
561 | private: |
562 | mir::Fd mutable last_fd; |
563 | }; |
564 | |
565 | === modified file 'tests/mir_test_framework/stubbed_graphics_platform.cpp' |
566 | --- tests/mir_test_framework/stubbed_graphics_platform.cpp 2014-10-22 12:46:08 +0000 |
567 | +++ tests/mir_test_framework/stubbed_graphics_platform.cpp 2014-11-13 16:42:20 +0000 |
568 | @@ -147,6 +147,12 @@ |
569 | { |
570 | return std::make_shared<mg::PlatformIPCPackage>(); |
571 | } |
572 | + |
573 | + mg::PlatformIPCPackage platform_operation( |
574 | + unsigned int const, mg::PlatformIPCPackage const&) override |
575 | + { |
576 | + return mg::PlatformIPCPackage(); |
577 | + } |
578 | }; |
579 | } |
580 | |
581 | |
582 | === modified file 'tests/unit-tests/frontend/CMakeLists.txt' |
583 | --- tests/unit-tests/frontend/CMakeLists.txt 2014-10-27 22:31:16 +0000 |
584 | +++ tests/unit-tests/frontend/CMakeLists.txt 2014-11-13 16:42:20 +0000 |
585 | @@ -14,16 +14,6 @@ |
586 | ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_message_processor.cpp |
587 | ) |
588 | |
589 | -if (MIR_TEST_PLATFORM STREQUAL "android") |
590 | - list(APPEND UNIT_TEST_SOURCES |
591 | - ${CMAKE_CURRENT_SOURCE_DIR}/test_session_mediator_android.cpp |
592 | - ) |
593 | -elseif (MIR_TEST_PLATFORM STREQUAL "mesa") |
594 | - list(APPEND UNIT_TEST_SOURCES |
595 | - ${CMAKE_CURRENT_SOURCE_DIR}/test_session_mediator_mesa.cpp |
596 | - ) |
597 | -endif() |
598 | - |
599 | set( |
600 | UNIT_TEST_SOURCES |
601 | ${UNIT_TEST_SOURCES} |
602 | |
603 | === modified file 'tests/unit-tests/frontend/test_session_mediator.cpp' |
604 | --- tests/unit-tests/frontend/test_session_mediator.cpp 2014-10-30 18:37:11 +0000 |
605 | +++ tests/unit-tests/frontend/test_session_mediator.cpp 2014-11-13 16:42:20 +0000 |
606 | @@ -50,6 +50,8 @@ |
607 | #include "mir/frontend/event_sink.h" |
608 | |
609 | #include "gmock_set_arg.h" |
610 | +#include <boost/exception/errinfo_errno.hpp> |
611 | +#include <boost/throw_exception.hpp> |
612 | #include <gtest/gtest.h> |
613 | #include <gmock/gmock.h> |
614 | |
615 | @@ -124,6 +126,7 @@ |
616 | MOCK_CONST_METHOD2(unpack_buffer, |
617 | void(mg::BufferIpcMessage&, mg::Buffer const&)); |
618 | MOCK_METHOD0(connection_ipc_package, std::shared_ptr<mg::PlatformIPCPackage>()); |
619 | + MOCK_METHOD2(platform_operation, mg::PlatformIPCPackage(unsigned int const, mg::PlatformIPCPackage const&)); |
620 | }; |
621 | |
622 | class StubbedSession : public mtd::StubSession |
623 | @@ -202,36 +205,6 @@ |
624 | MOCK_METHOD0(supported_pixel_formats, std::vector<MirPixelFormat>()); |
625 | }; |
626 | |
627 | - |
628 | -class MockPlatform : public mg::Platform |
629 | -{ |
630 | - public: |
631 | - MockPlatform(std::shared_ptr<mg::PlatformIpcOperations> const& ipc_ops) |
632 | - { |
633 | - using namespace testing; |
634 | - ON_CALL(*this, create_buffer_allocator()) |
635 | - .WillByDefault(Return(std::shared_ptr<mg::GraphicBufferAllocator>())); |
636 | - ON_CALL(*this, create_display(_,_,_)) |
637 | - .WillByDefault(Return(std::make_shared<mtd::NullDisplay>())); |
638 | - ON_CALL(*this, connection_ipc_package()) |
639 | - .WillByDefault(Return(std::make_shared<mg::PlatformIPCPackage>())); |
640 | - ON_CALL(*this, make_ipc_operations()) |
641 | - .WillByDefault(Return(ipc_ops)); |
642 | - } |
643 | - |
644 | - MOCK_METHOD0(create_buffer_allocator, std::shared_ptr<mg::GraphicBufferAllocator>()); |
645 | - MOCK_METHOD3(create_display, |
646 | - std::shared_ptr<mg::Display>( |
647 | - std::shared_ptr<mg::DisplayConfigurationPolicy> const&, |
648 | - std::shared_ptr<mg::GLProgramFactory> const&, |
649 | - std::shared_ptr<mg::GLConfig> const&)); |
650 | - MOCK_METHOD0(connection_ipc_package, std::shared_ptr<mg::PlatformIPCPackage>()); |
651 | - MOCK_METHOD0(create_internal_client, std::shared_ptr<mg::InternalClient>()); |
652 | - MOCK_CONST_METHOD0(make_ipc_operations, std::shared_ptr<mg::PlatformIpcOperations>()); |
653 | - MOCK_CONST_METHOD0(egl_native_display, EGLNativeDisplayType()); |
654 | - MOCK_METHOD0(make_buffer_writer, std::shared_ptr<mg::BufferWriter>()); |
655 | -}; |
656 | - |
657 | struct StubScreencast : mtd::NullScreencast |
658 | { |
659 | std::shared_ptr<mg::Buffer> capture(mf::ScreencastSessionId) |
660 | @@ -246,8 +219,6 @@ |
661 | { |
662 | SessionMediator() |
663 | : shell{std::make_shared<testing::NiceMock<mtd::MockShell>>()}, |
664 | - graphics_platform{ |
665 | - std::make_shared<testing::NiceMock<MockPlatform>>(mt::fake_shared(mock_ipc_operations))}, |
666 | graphics_changer{std::make_shared<mtd::NullDisplayChanger>()}, |
667 | surface_pixel_formats{mir_pixel_format_argb_8888, mir_pixel_format_xrgb_8888}, |
668 | report{mr::null_session_mediator_report()}, |
669 | @@ -256,7 +227,7 @@ |
670 | stubbed_session{std::make_shared<StubbedSession>()}, |
671 | null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}, |
672 | mediator{ |
673 | - shell, graphics_platform, graphics_changer, |
674 | + shell, mt::fake_shared(mock_ipc_operations), graphics_changer, |
675 | surface_pixel_formats, report, |
676 | std::make_shared<mtd::NullEventSink>(), |
677 | resource_cache, stub_screencast, &connector, nullptr, nullptr} |
678 | @@ -269,7 +240,6 @@ |
679 | MockConnector connector; |
680 | testing::NiceMock<MockBufferPacker> mock_ipc_operations; |
681 | std::shared_ptr<testing::NiceMock<mtd::MockShell>> const shell; |
682 | - std::shared_ptr<MockPlatform> const graphics_platform; |
683 | std::shared_ptr<mf::DisplayChanger> const graphics_changer; |
684 | std::vector<MirPixelFormat> const surface_pixel_formats; |
685 | std::shared_ptr<mf::SessionMediatorReport> const report; |
686 | @@ -313,7 +283,7 @@ |
687 | }; |
688 | |
689 | mf::SessionMediator mediator{ |
690 | - shell, graphics_platform, graphics_changer, |
691 | + shell, mt::fake_shared(mock_ipc_operations), graphics_changer, |
692 | surface_pixel_formats, report, |
693 | std::make_shared<mtd::NullEventSink>(), |
694 | resource_cache, stub_screencast, context, nullptr, nullptr}; |
695 | @@ -417,7 +387,7 @@ |
696 | .WillByDefault(Return(mt::fake_shared(config))); |
697 | |
698 | mf::SessionMediator mediator( |
699 | - shell, graphics_platform, mock_display, |
700 | + shell, mt::fake_shared(mock_ipc_operations), mock_display, |
701 | surface_pixel_formats, report, |
702 | std::make_shared<mtd::NullEventSink>(), |
703 | resource_cache, std::make_shared<mtd::NullScreencast>(), |
704 | @@ -619,7 +589,7 @@ |
705 | .WillOnce(Return(mt::fake_shared(stub_display_config))); |
706 | |
707 | mf::SessionMediator mediator{ |
708 | - shell, graphics_platform, mock_display_selector, |
709 | + shell, mt::fake_shared(mock_ipc_operations), mock_display_selector, |
710 | surface_pixel_formats, report, |
711 | std::make_shared<mtd::NullEventSink>(), resource_cache, |
712 | std::make_shared<mtd::NullScreencast>(), |
713 | @@ -873,7 +843,7 @@ |
714 | EXPECT_CALL(mock_cache, save_fd(_,fake_fd2)); |
715 | |
716 | mf::SessionMediator mediator{ |
717 | - shell, graphics_platform, graphics_changer, |
718 | + shell, mt::fake_shared(mock_ipc_operations), graphics_changer, |
719 | surface_pixel_formats, report, |
720 | std::make_shared<mtd::NullEventSink>(), |
721 | mt::fake_shared(mock_cache), stub_screencast, &connector, nullptr, nullptr}; |
722 | @@ -891,3 +861,52 @@ |
723 | buffer_request.mutable_buffer()->set_buffer_id(exchanged_buffer.buffer_id()); |
724 | buffer_request.mutable_buffer()->clear_fd(); |
725 | } |
726 | + |
727 | +//FIXME: we have an platform specific request in the protocol! |
728 | +TEST_F(SessionMediator, drm_auth_magic_calls_platform_operation_abstraction) |
729 | +{ |
730 | + using namespace testing; |
731 | + |
732 | + int magic{0x3248}; |
733 | + int test_response{4}; |
734 | + mg::PlatformIPCPackage response{{test_response}, {}}; |
735 | + mg::PlatformIPCPackage request; |
736 | + drm_request.set_magic(magic); |
737 | + |
738 | + EXPECT_CALL(mock_ipc_operations, platform_operation(_, _)) |
739 | + .Times(1) |
740 | + .WillOnce(DoAll(SaveArg<1>(&request), Return(response))); |
741 | + |
742 | + mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get()); |
743 | + mediator.drm_auth_magic(nullptr, &drm_request, &drm_response, null_callback.get()); |
744 | + mediator.disconnect(nullptr, nullptr, nullptr, null_callback.get()); |
745 | + |
746 | + ASSERT_THAT(request.ipc_data.size(), Eq(1)); |
747 | + EXPECT_THAT(request.ipc_data[0], Eq(magic)); |
748 | + EXPECT_THAT(drm_response.status_code(), Eq(test_response)); |
749 | +} |
750 | + |
751 | +TEST_F(SessionMediator, drm_auth_magic_sets_status_code_on_error) |
752 | +{ |
753 | + using namespace testing; |
754 | + |
755 | + mp::ConnectParameters connect_parameters; |
756 | + mp::Connection connection; |
757 | + |
758 | + unsigned int const drm_magic{0x10111213}; |
759 | + int const error_number{667}; |
760 | + |
761 | + EXPECT_CALL(mock_ipc_operations, platform_operation(_, _)) |
762 | + .WillOnce(Throw(::boost::enable_error_info(std::exception()) |
763 | + << boost::errinfo_errno(error_number))); |
764 | + |
765 | + mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get()); |
766 | + |
767 | + mp::DRMMagic magic; |
768 | + mp::DRMAuthMagicStatus status; |
769 | + magic.set_magic(drm_magic); |
770 | + |
771 | + mediator.drm_auth_magic(nullptr, &magic, &status, null_callback.get()); |
772 | + |
773 | + EXPECT_EQ(error_number, status.status_code()); |
774 | +} |
775 | |
776 | === removed file 'tests/unit-tests/frontend/test_session_mediator_android.cpp' |
777 | --- tests/unit-tests/frontend/test_session_mediator_android.cpp 2014-10-27 22:31:16 +0000 |
778 | +++ tests/unit-tests/frontend/test_session_mediator_android.cpp 1970-01-01 00:00:00 +0000 |
779 | @@ -1,95 +0,0 @@ |
780 | -/* |
781 | - * Copyright © 2012 Canonical Ltd. |
782 | - * |
783 | - * This program is free software: you can redistribute it and/or modify |
784 | - * it under the terms of the GNU General Public License version 3 as |
785 | - * published by the Free Software Foundation. |
786 | - * |
787 | - * This program is distributed in the hope that it will be useful, |
788 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
789 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
790 | - * GNU General Public License for more details. |
791 | - * |
792 | - * You should have received a copy of the GNU General Public License |
793 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
794 | - * |
795 | - * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
796 | - */ |
797 | - |
798 | -#include "mir/frontend/session_mediator_report.h" |
799 | -#include "src/server/frontend/session_mediator.h" |
800 | -#include "src/server/frontend/resource_cache.h" |
801 | -#include "src/server/scene/application_session.h" |
802 | -#include "src/server/report/null_report_factory.h" |
803 | -#include "mir/frontend/shell.h" |
804 | -#include "mir/scene/surface_creation_parameters.h" |
805 | -#include "mir/graphics/display.h" |
806 | -#include "mir/graphics/platform.h" |
807 | -#include "mir/graphics/platform_ipc_package.h" |
808 | - |
809 | -#include "mir_test_doubles/null_display_changer.h" |
810 | -#include "mir_test_doubles/mock_session.h" |
811 | -#include "mir_test_doubles/stub_shell.h" |
812 | -#include "mir_test_doubles/null_platform.h" |
813 | -#include "mir_test_doubles/null_event_sink.h" |
814 | -#include "mir_test_doubles/stub_buffer_allocator.h" |
815 | -#include "mir_test_doubles/null_screencast.h" |
816 | - |
817 | -#include <gtest/gtest.h> |
818 | - |
819 | -#include <stdexcept> |
820 | - |
821 | -namespace mf = mir::frontend; |
822 | -namespace mg = mir::graphics; |
823 | -namespace geom = mir::geometry; |
824 | -namespace mp = mir::protobuf; |
825 | -namespace mtd = mir::test::doubles; |
826 | -namespace mr = mir::report; |
827 | - |
828 | -namespace |
829 | -{ |
830 | - |
831 | -struct SessionMediatorAndroidTest : public ::testing::Test |
832 | -{ |
833 | - SessionMediatorAndroidTest() |
834 | - : shell{std::make_shared<mtd::StubShell>()}, |
835 | - graphics_platform{std::make_shared<mtd::NullPlatform>()}, |
836 | - display_changer{std::make_shared<mtd::NullDisplayChanger>()}, |
837 | - surface_pixel_formats{mir_pixel_format_argb_8888, mir_pixel_format_xrgb_8888}, |
838 | - report{mr::null_session_mediator_report()}, |
839 | - resource_cache{std::make_shared<mf::ResourceCache>()}, |
840 | - mediator{shell, graphics_platform, display_changer, |
841 | - surface_pixel_formats, report, |
842 | - std::make_shared<mtd::NullEventSink>(), |
843 | - resource_cache, std::make_shared<mtd::NullScreencast>(), nullptr, nullptr, nullptr}, |
844 | - null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)} |
845 | - { |
846 | - } |
847 | - |
848 | - std::shared_ptr<mtd::StubShell> const shell; |
849 | - std::shared_ptr<mtd::NullPlatform> const graphics_platform; |
850 | - std::shared_ptr<mf::DisplayChanger> const display_changer; |
851 | - std::vector<MirPixelFormat> const surface_pixel_formats; |
852 | - std::shared_ptr<mf::SessionMediatorReport> const report; |
853 | - std::shared_ptr<mf::ResourceCache> const resource_cache; |
854 | - mf::SessionMediator mediator; |
855 | - |
856 | - std::unique_ptr<google::protobuf::Closure> null_callback; |
857 | -}; |
858 | - |
859 | -} |
860 | - |
861 | -TEST_F(SessionMediatorAndroidTest, drm_auth_magic_throws) |
862 | -{ |
863 | - mp::ConnectParameters connect_parameters; |
864 | - mp::Connection connection; |
865 | - |
866 | - mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get()); |
867 | - |
868 | - mp::DRMMagic magic; |
869 | - magic.set_magic(0x10111213); |
870 | - |
871 | - EXPECT_THROW({ |
872 | - mediator.drm_auth_magic(nullptr, &magic, nullptr, null_callback.get()); |
873 | - }, std::logic_error); |
874 | -} |
875 | |
876 | === removed file 'tests/unit-tests/frontend/test_session_mediator_mesa.cpp' |
877 | --- tests/unit-tests/frontend/test_session_mediator_mesa.cpp 2014-10-27 22:31:16 +0000 |
878 | +++ tests/unit-tests/frontend/test_session_mediator_mesa.cpp 1970-01-01 00:00:00 +0000 |
879 | @@ -1,141 +0,0 @@ |
880 | -/* |
881 | - * Copyright © 2012-2014 Canonical Ltd. |
882 | - * |
883 | - * This program is free software: you can redistribute it and/or modify |
884 | - * it under the terms of the GNU General Public License version 3 as |
885 | - * published by the Free Software Foundation. |
886 | - * |
887 | - * This program is distributed in the hope that it will be useful, |
888 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
889 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
890 | - * GNU General Public License for more details. |
891 | - * |
892 | - * You should have received a copy of the GNU General Public License |
893 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
894 | - * |
895 | - * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
896 | - */ |
897 | - |
898 | -#include "mir/frontend/session_mediator_report.h" |
899 | -#include "src/server/frontend/session_mediator.h" |
900 | -#include "src/server/frontend/resource_cache.h" |
901 | -#include "src/server/scene/application_session.h" |
902 | -#include "src/server/frontend/session_mediator.h" |
903 | -#include "src/server/report/null_report_factory.h" |
904 | -#include "mir/frontend/shell.h" |
905 | -#include "mir/graphics/display.h" |
906 | -#include "mir/graphics/drm_authenticator.h" |
907 | -#include "mir/frontend/event_sink.h" |
908 | - |
909 | -#include <boost/exception/errinfo_errno.hpp> |
910 | -#include <boost/throw_exception.hpp> |
911 | - |
912 | -#include "mir_test_doubles/null_display.h" |
913 | -#include "mir_test_doubles/null_event_sink.h" |
914 | -#include "mir_test_doubles/null_display_changer.h" |
915 | -#include "mir_test_doubles/null_platform.h" |
916 | -#include "mir_test_doubles/mock_session.h" |
917 | -#include "mir_test_doubles/stub_shell.h" |
918 | -#include "mir_test_doubles/null_screencast.h" |
919 | - |
920 | -#include <gtest/gtest.h> |
921 | -#include <gmock/gmock.h> |
922 | - |
923 | -namespace mf = mir::frontend; |
924 | -namespace mg = mir::graphics; |
925 | -namespace geom = mir::geometry; |
926 | -namespace mp = mir::protobuf; |
927 | -namespace mtd = mir::test::doubles; |
928 | -namespace mr = mir::report; |
929 | - |
930 | -namespace |
931 | -{ |
932 | - |
933 | -class MockAuthenticatingPlatform : public mtd::NullPlatform, public mg::DRMAuthenticator |
934 | -{ |
935 | - public: |
936 | - std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator() override |
937 | - { |
938 | - return std::shared_ptr<mg::GraphicBufferAllocator>(); |
939 | - } |
940 | - |
941 | - MOCK_METHOD1(drm_auth_magic, void(unsigned int)); |
942 | -}; |
943 | - |
944 | -struct SessionMediatorMesaTest : public ::testing::Test |
945 | -{ |
946 | - SessionMediatorMesaTest() |
947 | - : shell{std::make_shared<mtd::StubShell>()}, |
948 | - mock_platform{std::make_shared<MockAuthenticatingPlatform>()}, |
949 | - display_changer{std::make_shared<mtd::NullDisplayChanger>()}, |
950 | - surface_pixel_formats{mir_pixel_format_argb_8888, mir_pixel_format_xrgb_8888}, |
951 | - report{mr::null_session_mediator_report()}, |
952 | - resource_cache{std::make_shared<mf::ResourceCache>()}, |
953 | - mediator{shell, mock_platform, display_changer, |
954 | - surface_pixel_formats, report, |
955 | - std::make_shared<mtd::NullEventSink>(), |
956 | - resource_cache, std::make_shared<mtd::NullScreencast>(), nullptr, nullptr, |
957 | - nullptr}, |
958 | - null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)} |
959 | - { |
960 | - } |
961 | - |
962 | - std::shared_ptr<mtd::StubShell> const shell; |
963 | - std::shared_ptr<MockAuthenticatingPlatform> const mock_platform; |
964 | - std::shared_ptr<mf::DisplayChanger> const display_changer; |
965 | - std::vector<MirPixelFormat> const surface_pixel_formats; |
966 | - std::shared_ptr<mf::SessionMediatorReport> const report; |
967 | - std::shared_ptr<mf::ResourceCache> const resource_cache; |
968 | - mf::SessionMediator mediator; |
969 | - |
970 | - std::unique_ptr<google::protobuf::Closure> null_callback; |
971 | -}; |
972 | - |
973 | -} |
974 | - |
975 | -TEST_F(SessionMediatorMesaTest, drm_auth_magic_uses_drm_authenticator) |
976 | -{ |
977 | - mp::ConnectParameters connect_parameters; |
978 | - mp::Connection connection; |
979 | - |
980 | - unsigned int const drm_magic{0x10111213}; |
981 | - int const no_error{0}; |
982 | - |
983 | - EXPECT_CALL(*mock_platform, drm_auth_magic(drm_magic)) |
984 | - .Times(1); |
985 | - |
986 | - mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get()); |
987 | - |
988 | - mp::DRMMagic magic; |
989 | - mp::DRMAuthMagicStatus status; |
990 | - magic.set_magic(drm_magic); |
991 | - |
992 | - mediator.drm_auth_magic(nullptr, &magic, &status, null_callback.get()); |
993 | - |
994 | - EXPECT_EQ(no_error, status.status_code()); |
995 | -} |
996 | - |
997 | -TEST_F(SessionMediatorMesaTest, drm_auth_magic_sets_status_code_on_error) |
998 | -{ |
999 | - using namespace testing; |
1000 | - |
1001 | - mp::ConnectParameters connect_parameters; |
1002 | - mp::Connection connection; |
1003 | - |
1004 | - unsigned int const drm_magic{0x10111213}; |
1005 | - int const error_number{667}; |
1006 | - |
1007 | - EXPECT_CALL(*mock_platform, drm_auth_magic(drm_magic)) |
1008 | - .WillOnce(Throw(::boost::enable_error_info(std::exception()) |
1009 | - << boost::errinfo_errno(error_number))); |
1010 | - |
1011 | - mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get()); |
1012 | - |
1013 | - mp::DRMMagic magic; |
1014 | - mp::DRMAuthMagicStatus status; |
1015 | - magic.set_magic(drm_magic); |
1016 | - |
1017 | - mediator.drm_auth_magic(nullptr, &magic, &status, null_callback.get()); |
1018 | - |
1019 | - EXPECT_EQ(error_number, status.status_code()); |
1020 | -} |
1021 | |
1022 | === modified file 'tests/unit-tests/graphics/android/CMakeLists.txt' |
1023 | --- tests/unit-tests/graphics/android/CMakeLists.txt 2014-10-01 06:25:56 +0000 |
1024 | +++ tests/unit-tests/graphics/android/CMakeLists.txt 2014-11-13 16:42:20 +0000 |
1025 | @@ -13,6 +13,7 @@ |
1026 | ${CMAKE_CURRENT_SOURCE_DIR}/test_display_buffer.cpp |
1027 | ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_client_interpreter.cpp |
1028 | ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_client.cpp |
1029 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_ipc_operations.cpp |
1030 | ${CMAKE_CURRENT_SOURCE_DIR}/test_resource_factory.cpp |
1031 | ${CMAKE_CURRENT_SOURCE_DIR}/test_fb_simple_swapper.cpp |
1032 | ${CMAKE_CURRENT_SOURCE_DIR}/test_fb_device.cpp |
1033 | |
1034 | === added file 'tests/unit-tests/graphics/android/test_ipc_operations.cpp' |
1035 | --- tests/unit-tests/graphics/android/test_ipc_operations.cpp 1970-01-01 00:00:00 +0000 |
1036 | +++ tests/unit-tests/graphics/android/test_ipc_operations.cpp 2014-11-13 16:42:20 +0000 |
1037 | @@ -0,0 +1,50 @@ |
1038 | +/* |
1039 | + * Copyright © 2014 Canonical Ltd. |
1040 | + * |
1041 | + * This program is free software: you can redistribute it and/or modify |
1042 | + * it under the terms of the GNU General Public License version 3 as |
1043 | + * published by the Free Software Foundation. |
1044 | + * |
1045 | + * This program is distributed in the hope that it will be useful, |
1046 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1047 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1048 | + * GNU General Public License for more details. |
1049 | + * |
1050 | + * You should have received a copy of the GNU General Public License |
1051 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1052 | + * |
1053 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
1054 | + */ |
1055 | + |
1056 | +#include "src/platform/graphics/android/ipc_operations.h" |
1057 | +#include "mir/graphics/platform_ipc_package.h" |
1058 | +#include <gtest/gtest.h> |
1059 | + |
1060 | +namespace mg = mir::graphics; |
1061 | +namespace mga = mir::graphics::android; |
1062 | + |
1063 | +struct IpcOperations : public ::testing::Test |
1064 | +{ |
1065 | + mga::IpcOperations ipc_operations; |
1066 | +}; |
1067 | + |
1068 | +/* ipc packaging tests */ |
1069 | +TEST_F(IpcOperations, test_ipc_data_packed_correctly_for_full_ipc) |
1070 | +{ |
1071 | + //android has no valid operations platform specific operations yet, expect throw |
1072 | + mg::PlatformIPCPackage package{ |
1073 | + std::vector<int32_t>{2,4,8,16,32}, |
1074 | + std::vector<int32_t>{fileno(tmpfile()), fileno(tmpfile())} |
1075 | + }; |
1076 | + |
1077 | + EXPECT_THROW({ |
1078 | + ipc_operations.platform_operation(0u, package); |
1079 | + }, std::invalid_argument); |
1080 | + |
1081 | + EXPECT_THROW({ |
1082 | + ipc_operations.platform_operation(1u, package); |
1083 | + }, std::invalid_argument); |
1084 | + |
1085 | + for (auto fd : package.ipc_fds) |
1086 | + close(fd); |
1087 | +} |
1088 | |
1089 | === modified file 'tests/unit-tests/graphics/mesa/test_platform.cpp' |
1090 | --- tests/unit-tests/graphics/mesa/test_platform.cpp 2014-10-27 13:06:48 +0000 |
1091 | +++ tests/unit-tests/graphics/mesa/test_platform.cpp 2014-11-13 16:42:20 +0000 |
1092 | @@ -200,9 +200,13 @@ |
1093 | EXPECT_CALL(mock_drm, drmAuthMagic(mock_drm.fake_drm.fd(),magic)) |
1094 | .WillOnce(Return(0)); |
1095 | |
1096 | + mg::PlatformIPCPackage magic_pkg{{magic}, {}}; |
1097 | + int drm_opcode{44}; |
1098 | auto platform = create_platform(); |
1099 | - auto authenticator = std::dynamic_pointer_cast<mg::DRMAuthenticator>(platform); |
1100 | - authenticator->drm_auth_magic(magic); |
1101 | + auto ipc_ops = platform->make_ipc_operations(); |
1102 | + auto response_pkg = ipc_ops->platform_operation(drm_opcode, magic_pkg); |
1103 | + ASSERT_THAT(response_pkg.ipc_data.size(), Eq(1)); |
1104 | + EXPECT_THAT(response_pkg.ipc_data[0], Eq(0)); |
1105 | } |
1106 | |
1107 | TEST_F(MesaGraphicsPlatform, drm_auth_magic_throws_if_drm_function_fails) |
1108 | @@ -214,11 +218,13 @@ |
1109 | EXPECT_CALL(mock_drm, drmAuthMagic(mock_drm.fake_drm.fd(),magic)) |
1110 | .WillOnce(Return(-1)); |
1111 | |
1112 | + int drm_opcode{44}; |
1113 | auto platform = create_platform(); |
1114 | - auto authenticator = std::dynamic_pointer_cast<mg::DRMAuthenticator>(platform); |
1115 | + auto ipc_ops = platform->make_ipc_operations(); |
1116 | + mg::PlatformIPCPackage magic_pkg{{magic}, {}}; |
1117 | |
1118 | EXPECT_THROW({ |
1119 | - authenticator->drm_auth_magic(magic); |
1120 | + ipc_ops->platform_operation(drm_opcode, magic_pkg); |
1121 | }, std::runtime_error); |
1122 | } |
1123 |
FAILED: Continuous integration, rev:2026 jenkins. qa.ubuntu. com/job/ mir-ci/ 2084/ jenkins. qa.ubuntu. com/job/ mir-android- vivid-i386- build/95 jenkins. qa.ubuntu. com/job/ mir-clang- vivid-amd64- build/95/ console jenkins. qa.ubuntu. com/job/ mir-mediumtests -vivid- touch/75 jenkins. qa.ubuntu. com/job/ mir-vivid- amd64-ci/ 73 jenkins. qa.ubuntu. com/job/ mir-vivid- amd64-ci/ 73/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 75 jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 75/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -runner- mako/3367 s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 15771
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/mir- ci/2084/ rebuild
http://