Merge lp:~afrantzis/mir/platform-operation-set-gbm-device into lp:mir
- platform-operation-set-gbm-device
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Alexandros Frantzis |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2286 |
Proposed branch: | lp:~afrantzis/mir/platform-operation-set-gbm-device |
Merge into: | lp:mir |
Prerequisite: | lp:~afrantzis/mir/client-platform-populate-package |
Diff against target: |
763 lines (+306/-143) 17 files modified
src/client/mir_connection.cpp (+8/-20) src/client/mir_connection.h (+0/-4) src/client/mir_connection_api.cpp (+36/-11) src/include/client/mir/client_platform.h (+11/-0) src/platforms/android/client/android_client_platform.cpp (+6/-0) src/platforms/android/client/android_client_platform.h (+1/-1) src/platforms/mesa/client/client_platform.cpp (+46/-1) src/platforms/mesa/client/client_platform.h (+4/-0) src/platforms/mesa/include/mir_toolkit/mesa/platform_operation.h (+19/-2) tests/acceptance-tests/CMakeLists.txt (+0/-1) tests/acceptance-tests/test_client_library_drm.cpp (+0/-46) tests/acceptance-tests/test_client_library_errors.cpp (+5/-0) tests/include/mir_test_framework/client_platform_factory.h (+3/-9) tests/mir_test_framework/stub_client_platform_factory.cpp (+5/-0) tests/unit-tests/client/mesa/test_client_platform.cpp (+77/-6) tests/unit-tests/client/test_client_mir_surface.cpp (+6/-0) tests/unit-tests/client/test_mir_connection.cpp (+79/-42) |
To merge this branch: | bzr merge lp:~afrantzis/mir/platform-operation-set-gbm-device |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Robert Carr (community) | Approve | ||
Alan Griffiths | Approve | ||
Review via email: mp+248125@code.launchpad.net |
This proposal supersedes a proposal from 2015-01-30.
Commit message
client: Add set_gbm_device platform operation
Description of the change
client: Add set_gbm_device platform operation
Implement the set_gbm_device functionality as a platform operation. The mir_connection_
This changes also allows us to remove the final platform specific piece from the nested server, which will happen in an upcoming MP.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2281
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://
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'src/client/mir_connection.cpp' | |||
2 | --- src/client/mir_connection.cpp 2015-01-30 14:38:25 +0000 | |||
3 | +++ src/client/mir_connection.cpp 2015-01-30 14:38:25 +0000 | |||
4 | @@ -361,6 +361,14 @@ | |||
5 | 361 | MirPlatformMessage const* request, | 361 | MirPlatformMessage const* request, |
6 | 362 | mir_platform_operation_callback callback, void* context) | 362 | mir_platform_operation_callback callback, void* context) |
7 | 363 | { | 363 | { |
8 | 364 | auto const client_response = platform->platform_operation(request); | ||
9 | 365 | if (client_response) | ||
10 | 366 | { | ||
11 | 367 | set_error_message(""); | ||
12 | 368 | callback(this, client_response, context); | ||
13 | 369 | return nullptr; | ||
14 | 370 | } | ||
15 | 371 | |||
16 | 364 | mir::protobuf::PlatformOperationMessage protobuf_request; | 372 | mir::protobuf::PlatformOperationMessage protobuf_request; |
17 | 365 | 373 | ||
18 | 366 | protobuf_request.set_opcode(opcode); | 374 | protobuf_request.set_opcode(opcode); |
19 | @@ -420,11 +428,6 @@ | |||
20 | 420 | platform_package.fd_items = platform.fd_size(); | 428 | platform_package.fd_items = platform.fd_size(); |
21 | 421 | for (int i = 0; i != platform.fd_size(); ++i) | 429 | for (int i = 0; i != platform.fd_size(); ++i) |
22 | 422 | platform_package.fd[i] = platform.fd(i); | 430 | platform_package.fd[i] = platform.fd(i); |
23 | 423 | |||
24 | 424 | // TODO: Replace the extra platform data mechanism with a | ||
25 | 425 | // client side, platform specific operation | ||
26 | 426 | for (auto d : extra_platform_data) | ||
27 | 427 | platform_package.data[platform_package.data_items++] = d; | ||
28 | 428 | } | 431 | } |
29 | 429 | else | 432 | else |
30 | 430 | { | 433 | { |
31 | @@ -567,21 +570,6 @@ | |||
32 | 567 | return &configure_display_wait_handle; | 570 | return &configure_display_wait_handle; |
33 | 568 | } | 571 | } |
34 | 569 | 572 | ||
35 | 570 | bool MirConnection::set_extra_platform_data( | ||
36 | 571 | std::vector<int> const& extra_platform_data_arg) | ||
37 | 572 | { | ||
38 | 573 | std::lock_guard<decltype(mutex)> lock(mutex); | ||
39 | 574 | |||
40 | 575 | auto const total_data_size = | ||
41 | 576 | connect_result.platform().data_size() + extra_platform_data_arg.size(); | ||
42 | 577 | |||
43 | 578 | if (total_data_size > mir_platform_package_max) | ||
44 | 579 | return false; | ||
45 | 580 | |||
46 | 581 | extra_platform_data = extra_platform_data_arg; | ||
47 | 582 | return true; | ||
48 | 583 | } | ||
49 | 584 | |||
50 | 585 | mir::protobuf::DisplayServer& MirConnection::display_server() | 573 | mir::protobuf::DisplayServer& MirConnection::display_server() |
51 | 586 | { | 574 | { |
52 | 587 | return server; | 575 | return server; |
53 | 588 | 576 | ||
54 | === modified file 'src/client/mir_connection.h' | |||
55 | --- src/client/mir_connection.h 2015-01-30 14:38:25 +0000 | |||
56 | +++ src/client/mir_connection.h 2015-01-30 14:38:25 +0000 | |||
57 | @@ -137,8 +137,6 @@ | |||
58 | 137 | MirWaitHandle* configure_display(MirDisplayConfiguration* configuration); | 137 | MirWaitHandle* configure_display(MirDisplayConfiguration* configuration); |
59 | 138 | void done_display_configure(); | 138 | void done_display_configure(); |
60 | 139 | 139 | ||
61 | 140 | bool set_extra_platform_data(std::vector<int> const& extra_platform_data); | ||
62 | 141 | |||
63 | 142 | std::shared_ptr<google::protobuf::RpcChannel> rpc_channel() const | 140 | std::shared_ptr<google::protobuf::RpcChannel> rpc_channel() const |
64 | 143 | { | 141 | { |
65 | 144 | return channel; | 142 | return channel; |
66 | @@ -197,8 +195,6 @@ | |||
67 | 197 | std::shared_ptr<mir::client::EventHandlerRegister> const event_handler_register; | 195 | std::shared_ptr<mir::client::EventHandlerRegister> const event_handler_register; |
68 | 198 | 196 | ||
69 | 199 | std::unique_ptr<mir::dispatch::SimpleDispatchThread> const eventloop; | 197 | std::unique_ptr<mir::dispatch::SimpleDispatchThread> const eventloop; |
70 | 200 | |||
71 | 201 | std::vector<int> extra_platform_data; | ||
72 | 202 | 198 | ||
73 | 203 | std::shared_ptr<mir::client::ClientBufferStreamFactory> buffer_stream_factory; | 199 | std::shared_ptr<mir::client::ClientBufferStreamFactory> buffer_stream_factory; |
74 | 204 | 200 | ||
75 | 205 | 201 | ||
76 | === modified file 'src/client/mir_connection_api.cpp' | |||
77 | --- src/client/mir_connection_api.cpp 2015-01-26 15:53:18 +0000 | |||
78 | +++ src/client/mir_connection_api.cpp 2015-01-30 14:38:25 +0000 | |||
79 | @@ -51,11 +51,6 @@ | |||
80 | 51 | *context = result; | 51 | *context = result; |
81 | 52 | } | 52 | } |
82 | 53 | 53 | ||
83 | 54 | size_t division_ceiling(size_t a, size_t b) | ||
84 | 55 | { | ||
85 | 56 | return ((a - 1) / b) + 1; | ||
86 | 57 | } | ||
87 | 58 | |||
88 | 59 | class DefaultMirConnectionAPI : public mcl::MirConnectionAPI | 54 | class DefaultMirConnectionAPI : public mcl::MirConnectionAPI |
89 | 60 | { | 55 | { |
90 | 61 | public: | 56 | public: |
91 | @@ -356,6 +351,21 @@ | |||
92 | 356 | auth_magic_context->callback(auth_response->status, auth_magic_context->context); | 351 | auth_magic_context->callback(auth_response->status, auth_magic_context->context); |
93 | 357 | } | 352 | } |
94 | 358 | 353 | ||
95 | 354 | void assign_set_gbm_device_status( | ||
96 | 355 | MirConnection*, MirPlatformMessage* response, void* context) | ||
97 | 356 | { | ||
98 | 357 | auto const response_msg = mir::raii::deleter_for( | ||
99 | 358 | response, | ||
100 | 359 | &mir_platform_message_release); | ||
101 | 360 | |||
102 | 361 | auto const response_data = mir_platform_message_get_data(response_msg.get()); | ||
103 | 362 | auto const set_gbm_device_response_ptr = | ||
104 | 363 | reinterpret_cast<MirMesaSetGBMDeviceResponse const*>(response_data.data); | ||
105 | 364 | |||
106 | 365 | auto status_ptr = static_cast<int*>(context); | ||
107 | 366 | *status_ptr = set_gbm_device_response_ptr->status; | ||
108 | 367 | } | ||
109 | 368 | |||
110 | 359 | } | 369 | } |
111 | 360 | 370 | ||
112 | 361 | MirWaitHandle* mir_connection_drm_auth_magic(MirConnection* connection, | 371 | MirWaitHandle* mir_connection_drm_auth_magic(MirConnection* connection, |
113 | @@ -386,10 +396,25 @@ | |||
114 | 386 | int mir_connection_drm_set_gbm_device(MirConnection* connection, | 396 | int mir_connection_drm_set_gbm_device(MirConnection* connection, |
115 | 387 | struct gbm_device* gbm_dev) | 397 | struct gbm_device* gbm_dev) |
116 | 388 | { | 398 | { |
123 | 389 | size_t const pointer_size_in_ints = division_ceiling(sizeof(gbm_dev), sizeof(int)); | 399 | MirMesaSetGBMDeviceRequest const request{gbm_dev}; |
124 | 390 | std::vector<int> extra_data(pointer_size_in_ints); | 400 | |
125 | 391 | 401 | auto const msg = mir::raii::deleter_for( | |
126 | 392 | memcpy(extra_data.data(), &gbm_dev, sizeof(gbm_dev)); | 402 | mir_platform_message_create(MirMesaPlatformOperation::set_gbm_device), |
127 | 393 | 403 | &mir_platform_message_release); | |
128 | 394 | return connection->set_extra_platform_data(extra_data); | 404 | |
129 | 405 | mir_platform_message_set_data(msg.get(), &request, sizeof(request)); | ||
130 | 406 | |||
131 | 407 | static int const success{0}; | ||
132 | 408 | int status{-1}; | ||
133 | 409 | |||
134 | 410 | auto wh = mir_connection_platform_operation( | ||
135 | 411 | connection, | ||
136 | 412 | MirMesaPlatformOperation::set_gbm_device, | ||
137 | 413 | msg.get(), | ||
138 | 414 | assign_set_gbm_device_status, | ||
139 | 415 | &status); | ||
140 | 416 | |||
141 | 417 | mir_wait_for(wh); | ||
142 | 418 | |||
143 | 419 | return status == success; | ||
144 | 395 | } | 420 | } |
145 | 396 | 421 | ||
146 | === modified file 'src/include/client/mir/client_platform.h' | |||
147 | --- src/include/client/mir/client_platform.h 2015-01-30 14:38:25 +0000 | |||
148 | +++ src/include/client/mir/client_platform.h 2015-01-30 14:38:25 +0000 | |||
149 | @@ -49,6 +49,17 @@ | |||
150 | 49 | 49 | ||
151 | 50 | virtual MirPlatformType platform_type() const = 0; | 50 | virtual MirPlatformType platform_type() const = 0; |
152 | 51 | virtual void populate(MirPlatformPackage& package) const = 0; | 51 | virtual void populate(MirPlatformPackage& package) const = 0; |
153 | 52 | /** | ||
154 | 53 | * Perform a platform operation. | ||
155 | 54 | * | ||
156 | 55 | * The returned platform message is owned by the caller and should be | ||
157 | 56 | * released with mir_platform_message_release(). | ||
158 | 57 | * | ||
159 | 58 | * \param [in] request The platform operation request | ||
160 | 59 | * \return The platform operation reply, or a nullptr if the | ||
161 | 60 | * requested operation is not supported | ||
162 | 61 | */ | ||
163 | 62 | virtual MirPlatformMessage* platform_operation(MirPlatformMessage const* request) = 0; | ||
164 | 52 | virtual std::shared_ptr<ClientBufferFactory> create_buffer_factory() = 0; | 63 | virtual std::shared_ptr<ClientBufferFactory> create_buffer_factory() = 0; |
165 | 53 | virtual std::shared_ptr<EGLNativeWindowType> create_egl_native_window(EGLNativeSurface *surface) = 0; | 64 | virtual std::shared_ptr<EGLNativeWindowType> create_egl_native_window(EGLNativeSurface *surface) = 0; |
166 | 54 | virtual std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() = 0; | 65 | virtual std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() = 0; |
167 | 55 | 66 | ||
168 | === modified file 'src/platforms/android/client/android_client_platform.cpp' | |||
169 | --- src/platforms/android/client/android_client_platform.cpp 2015-01-30 14:38:25 +0000 | |||
170 | +++ src/platforms/android/client/android_client_platform.cpp 2015-01-30 14:38:25 +0000 | |||
171 | @@ -112,6 +112,12 @@ | |||
172 | 112 | context->populate_server_package(package); | 112 | context->populate_server_package(package); |
173 | 113 | } | 113 | } |
174 | 114 | 114 | ||
175 | 115 | MirPlatformMessage* mcla::AndroidClientPlatform::platform_operation( | ||
176 | 116 | MirPlatformMessage const*) | ||
177 | 117 | { | ||
178 | 118 | return nullptr; | ||
179 | 119 | } | ||
180 | 120 | |||
181 | 115 | MirNativeBuffer* mcla::AndroidClientPlatform::convert_native_buffer(graphics::NativeBuffer* buf) const | 121 | MirNativeBuffer* mcla::AndroidClientPlatform::convert_native_buffer(graphics::NativeBuffer* buf) const |
182 | 116 | { | 122 | { |
183 | 117 | return buf->anwb(); | 123 | return buf->anwb(); |
184 | 118 | 124 | ||
185 | === modified file 'src/platforms/android/client/android_client_platform.h' | |||
186 | --- src/platforms/android/client/android_client_platform.h 2015-01-30 14:38:25 +0000 | |||
187 | +++ src/platforms/android/client/android_client_platform.h 2015-01-30 14:38:25 +0000 | |||
188 | @@ -35,6 +35,7 @@ | |||
189 | 35 | AndroidClientPlatform(ClientContext* const context); | 35 | AndroidClientPlatform(ClientContext* const context); |
190 | 36 | MirPlatformType platform_type() const override; | 36 | MirPlatformType platform_type() const override; |
191 | 37 | void populate(MirPlatformPackage& package) const override; | 37 | void populate(MirPlatformPackage& package) const override; |
192 | 38 | MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override; | ||
193 | 38 | std::shared_ptr<ClientBufferFactory> create_buffer_factory() override; | 39 | std::shared_ptr<ClientBufferFactory> create_buffer_factory() override; |
194 | 39 | std::shared_ptr<EGLNativeWindowType> create_egl_native_window(EGLNativeSurface *surface) override; | 40 | std::shared_ptr<EGLNativeWindowType> create_egl_native_window(EGLNativeSurface *surface) override; |
195 | 40 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; | 41 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; |
196 | @@ -42,7 +43,6 @@ | |||
197 | 42 | 43 | ||
198 | 43 | private: | 44 | private: |
199 | 44 | ClientContext* const context; | 45 | ClientContext* const context; |
200 | 45 | |||
201 | 46 | }; | 46 | }; |
202 | 47 | 47 | ||
203 | 48 | } | 48 | } |
204 | 49 | 49 | ||
205 | === modified file 'src/platforms/mesa/client/client_platform.cpp' | |||
206 | --- src/platforms/mesa/client/client_platform.cpp 2015-01-30 14:38:25 +0000 | |||
207 | +++ src/platforms/mesa/client/client_platform.cpp 2015-01-30 14:38:25 +0000 | |||
208 | @@ -23,6 +23,9 @@ | |||
209 | 23 | #include "native_surface.h" | 23 | #include "native_surface.h" |
210 | 24 | #include "mir/client_buffer_factory.h" | 24 | #include "mir/client_buffer_factory.h" |
211 | 25 | #include "mir/client_context.h" | 25 | #include "mir/client_context.h" |
212 | 26 | #include "mir_toolkit/mesa/platform_operation.h" | ||
213 | 27 | |||
214 | 28 | #include <cstring> | ||
215 | 26 | 29 | ||
216 | 27 | namespace mcl=mir::client; | 30 | namespace mcl=mir::client; |
217 | 28 | namespace mclm=mir::client::mesa; | 31 | namespace mclm=mir::client::mesa; |
218 | @@ -47,6 +50,11 @@ | |||
219 | 47 | mcl::EGLNativeDisplayContainer& container; | 50 | mcl::EGLNativeDisplayContainer& container; |
220 | 48 | }; | 51 | }; |
221 | 49 | 52 | ||
222 | 53 | constexpr size_t division_ceiling(size_t a, size_t b) | ||
223 | 54 | { | ||
224 | 55 | return ((a - 1) / b) + 1; | ||
225 | 56 | } | ||
226 | 57 | |||
227 | 50 | } | 58 | } |
228 | 51 | 59 | ||
229 | 52 | mclm::ClientPlatform::ClientPlatform( | 60 | mclm::ClientPlatform::ClientPlatform( |
230 | @@ -55,7 +63,8 @@ | |||
231 | 55 | mcl::EGLNativeDisplayContainer& display_container) | 63 | mcl::EGLNativeDisplayContainer& display_container) |
232 | 56 | : context{context}, | 64 | : context{context}, |
233 | 57 | buffer_file_ops{buffer_file_ops}, | 65 | buffer_file_ops{buffer_file_ops}, |
235 | 58 | display_container(display_container) | 66 | display_container(display_container), |
236 | 67 | gbm_dev{nullptr} | ||
237 | 59 | { | 68 | { |
238 | 60 | } | 69 | } |
239 | 61 | 70 | ||
240 | @@ -108,7 +117,43 @@ | |||
241 | 108 | 117 | ||
242 | 109 | void mclm::ClientPlatform::populate(MirPlatformPackage& package) const | 118 | void mclm::ClientPlatform::populate(MirPlatformPackage& package) const |
243 | 110 | { | 119 | { |
244 | 120 | size_t constexpr pointer_size_in_ints = division_ceiling(sizeof(gbm_dev), sizeof(int)); | ||
245 | 121 | |||
246 | 111 | context->populate_server_package(package); | 122 | context->populate_server_package(package); |
247 | 123 | |||
248 | 124 | auto const total_data_size = package.data_items + pointer_size_in_ints; | ||
249 | 125 | if (gbm_dev && total_data_size <= mir_platform_package_max) | ||
250 | 126 | { | ||
251 | 127 | int gbm_ptr[pointer_size_in_ints]{}; | ||
252 | 128 | std::memcpy(&gbm_ptr, &gbm_dev, sizeof(gbm_dev)); | ||
253 | 129 | |||
254 | 130 | for (auto i : gbm_ptr) | ||
255 | 131 | package.data[package.data_items++] = i; | ||
256 | 132 | } | ||
257 | 133 | } | ||
258 | 134 | |||
259 | 135 | MirPlatformMessage* mclm::ClientPlatform::platform_operation( | ||
260 | 136 | MirPlatformMessage const* msg) | ||
261 | 137 | { | ||
262 | 138 | auto const op = mir_platform_message_get_opcode(msg); | ||
263 | 139 | |||
264 | 140 | if (op == MirMesaPlatformOperation::set_gbm_device) | ||
265 | 141 | { | ||
266 | 142 | auto const msg_data = mir_platform_message_get_data(msg); | ||
267 | 143 | auto const set_gbm_device_request_ptr = | ||
268 | 144 | reinterpret_cast<MirMesaSetGBMDeviceRequest const*>(msg_data.data); | ||
269 | 145 | |||
270 | 146 | gbm_dev = set_gbm_device_request_ptr->device; | ||
271 | 147 | |||
272 | 148 | static int const success{0}; | ||
273 | 149 | MirMesaSetGBMDeviceResponse const response{success}; | ||
274 | 150 | auto const response_msg = mir_platform_message_create(op); | ||
275 | 151 | mir_platform_message_set_data(response_msg, &response, sizeof(response)); | ||
276 | 152 | |||
277 | 153 | return response_msg; | ||
278 | 154 | } | ||
279 | 155 | |||
280 | 156 | return nullptr; | ||
281 | 112 | } | 157 | } |
282 | 113 | 158 | ||
283 | 114 | MirNativeBuffer* mclm::ClientPlatform::convert_native_buffer(graphics::NativeBuffer* buf) const | 159 | MirNativeBuffer* mclm::ClientPlatform::convert_native_buffer(graphics::NativeBuffer* buf) const |
284 | 115 | 160 | ||
285 | === modified file 'src/platforms/mesa/client/client_platform.h' | |||
286 | --- src/platforms/mesa/client/client_platform.h 2015-01-30 14:38:25 +0000 | |||
287 | +++ src/platforms/mesa/client/client_platform.h 2015-01-30 14:38:25 +0000 | |||
288 | @@ -20,6 +20,8 @@ | |||
289 | 20 | 20 | ||
290 | 21 | #include "mir/client_platform.h" | 21 | #include "mir/client_platform.h" |
291 | 22 | 22 | ||
292 | 23 | struct gbm_device; | ||
293 | 24 | |||
294 | 23 | namespace mir | 25 | namespace mir |
295 | 24 | { | 26 | { |
296 | 25 | namespace client | 27 | namespace client |
297 | @@ -41,6 +43,7 @@ | |||
298 | 41 | 43 | ||
299 | 42 | MirPlatformType platform_type() const override; | 44 | MirPlatformType platform_type() const override; |
300 | 43 | void populate(MirPlatformPackage& package) const override; | 45 | void populate(MirPlatformPackage& package) const override; |
301 | 46 | MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override; | ||
302 | 44 | std::shared_ptr<ClientBufferFactory> create_buffer_factory() override; | 47 | std::shared_ptr<ClientBufferFactory> create_buffer_factory() override; |
303 | 45 | std::shared_ptr<EGLNativeWindowType> create_egl_native_window(EGLNativeSurface *surface) override; | 48 | std::shared_ptr<EGLNativeWindowType> create_egl_native_window(EGLNativeSurface *surface) override; |
304 | 46 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; | 49 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; |
305 | @@ -50,6 +53,7 @@ | |||
306 | 50 | ClientContext* const context; | 53 | ClientContext* const context; |
307 | 51 | std::shared_ptr<BufferFileOps> const buffer_file_ops; | 54 | std::shared_ptr<BufferFileOps> const buffer_file_ops; |
308 | 52 | EGLNativeDisplayContainer& display_container; | 55 | EGLNativeDisplayContainer& display_container; |
309 | 56 | gbm_device* gbm_dev; | ||
310 | 53 | }; | 57 | }; |
311 | 54 | 58 | ||
312 | 55 | } | 59 | } |
313 | 56 | 60 | ||
314 | === modified file 'src/platforms/mesa/include/mir_toolkit/mesa/platform_operation.h' | |||
315 | --- src/platforms/mesa/include/mir_toolkit/mesa/platform_operation.h 2015-01-27 14:59:08 +0000 | |||
316 | +++ src/platforms/mesa/include/mir_toolkit/mesa/platform_operation.h 2015-01-30 14:38:25 +0000 | |||
317 | @@ -35,7 +35,8 @@ | |||
318 | 35 | enum MirMesaPlatformOperation | 35 | enum MirMesaPlatformOperation |
319 | 36 | { | 36 | { |
320 | 37 | auth_magic = 1, | 37 | auth_magic = 1, |
322 | 38 | auth_fd = 2 | 38 | auth_fd = 2, |
323 | 39 | set_gbm_device = 3 | ||
324 | 39 | }; | 40 | }; |
325 | 40 | 41 | ||
326 | 41 | /* | 42 | /* |
327 | @@ -49,7 +50,23 @@ | |||
328 | 49 | 50 | ||
329 | 50 | struct MirMesaAuthMagicResponse | 51 | struct MirMesaAuthMagicResponse |
330 | 51 | { | 52 | { |
332 | 52 | int status; | 53 | int status; /* 0 on success, a positive error number on failure */ |
333 | 54 | }; | ||
334 | 55 | |||
335 | 56 | /* | ||
336 | 57 | * MesaPlatformOperation::set_gbm_device related structures | ||
337 | 58 | */ | ||
338 | 59 | |||
339 | 60 | struct gbm_device; | ||
340 | 61 | |||
341 | 62 | struct MirMesaSetGBMDeviceRequest | ||
342 | 63 | { | ||
343 | 64 | struct gbm_device* device; | ||
344 | 65 | }; | ||
345 | 66 | |||
346 | 67 | struct MirMesaSetGBMDeviceResponse | ||
347 | 68 | { | ||
348 | 69 | int status; /* 0 on success, a positive error number on failure */ | ||
349 | 53 | }; | 70 | }; |
350 | 54 | 71 | ||
351 | 55 | #ifdef __cplusplus | 72 | #ifdef __cplusplus |
352 | 56 | 73 | ||
353 | === modified file 'tests/acceptance-tests/CMakeLists.txt' | |||
354 | --- tests/acceptance-tests/CMakeLists.txt 2015-01-19 06:55:41 +0000 | |||
355 | +++ tests/acceptance-tests/CMakeLists.txt 2015-01-30 14:38:25 +0000 | |||
356 | @@ -25,7 +25,6 @@ | |||
357 | 25 | test_display_configuration.cpp | 25 | test_display_configuration.cpp |
358 | 26 | test_surfaces_with_output_id.cpp | 26 | test_surfaces_with_output_id.cpp |
359 | 27 | test_server_disconnect.cpp | 27 | test_server_disconnect.cpp |
360 | 28 | test_client_library_drm.cpp | ||
361 | 29 | test_prompt_session_client_api.cpp | 28 | test_prompt_session_client_api.cpp |
362 | 30 | test_client_screencast.cpp | 29 | test_client_screencast.cpp |
363 | 31 | test_client_surface_visibility.cpp | 30 | test_client_surface_visibility.cpp |
364 | 32 | 31 | ||
365 | === removed file 'tests/acceptance-tests/test_client_library_drm.cpp' | |||
366 | --- tests/acceptance-tests/test_client_library_drm.cpp 2015-01-14 06:39:13 +0000 | |||
367 | +++ tests/acceptance-tests/test_client_library_drm.cpp 1970-01-01 00:00:00 +0000 | |||
368 | @@ -1,46 +0,0 @@ | |||
369 | 1 | /* | ||
370 | 2 | * Copyright © 2013-2014 Canonical Ltd. | ||
371 | 3 | * | ||
372 | 4 | * This program is free software: you can redistribute it and/or modify | ||
373 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
374 | 6 | * published by the Free Software Foundation. | ||
375 | 7 | * | ||
376 | 8 | * This program is distributed in the hope that it will be useful, | ||
377 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
378 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
379 | 11 | * GNU General Public License for more details. | ||
380 | 12 | * | ||
381 | 13 | * You should have received a copy of the GNU General Public License | ||
382 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
383 | 15 | * | ||
384 | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> | ||
385 | 17 | */ | ||
386 | 18 | |||
387 | 19 | #include "mir_toolkit/mir_client_library_drm.h" | ||
388 | 20 | |||
389 | 21 | #include "mir_test_framework/connected_client_headless_server.h" | ||
390 | 22 | |||
391 | 23 | #include <gtest/gtest.h> | ||
392 | 24 | #include <gmock/gmock.h> | ||
393 | 25 | |||
394 | 26 | namespace mtf = mir_test_framework; | ||
395 | 27 | using namespace testing; | ||
396 | 28 | |||
397 | 29 | using MirClientLibraryDrmTest = mtf::ConnectedClientHeadlessServer; | ||
398 | 30 | |||
399 | 31 | TEST_F(MirClientLibraryDrmTest, sets_gbm_device_in_platform_data) | ||
400 | 32 | { | ||
401 | 33 | struct gbm_device* dev = reinterpret_cast<struct gbm_device*>(connection); | ||
402 | 34 | |||
403 | 35 | MirPlatformPackage pkg; | ||
404 | 36 | |||
405 | 37 | mir_connection_get_platform(connection, &pkg); | ||
406 | 38 | int const previous_data_count{pkg.data_items}; | ||
407 | 39 | |||
408 | 40 | mir_connection_drm_set_gbm_device(connection, dev); | ||
409 | 41 | mir_connection_get_platform(connection, &pkg); | ||
410 | 42 | |||
411 | 43 | EXPECT_THAT(pkg.data_items, Eq(previous_data_count + (sizeof(dev) / sizeof(int)))); | ||
412 | 44 | EXPECT_THAT(reinterpret_cast<struct gbm_device*>(pkg.data[previous_data_count]), | ||
413 | 45 | Eq(dev)); | ||
414 | 46 | } | ||
415 | 47 | 0 | ||
416 | === modified file 'tests/acceptance-tests/test_client_library_errors.cpp' | |||
417 | --- tests/acceptance-tests/test_client_library_errors.cpp 2015-01-30 14:38:25 +0000 | |||
418 | +++ tests/acceptance-tests/test_client_library_errors.cpp 2015-01-30 14:38:25 +0000 | |||
419 | @@ -77,6 +77,11 @@ | |||
420 | 77 | { | 77 | { |
421 | 78 | } | 78 | } |
422 | 79 | 79 | ||
423 | 80 | MirPlatformMessage* platform_operation(MirPlatformMessage const*) override | ||
424 | 81 | { | ||
425 | 82 | return nullptr; | ||
426 | 83 | } | ||
427 | 84 | |||
428 | 80 | MirPlatformType platform_type() const | 85 | MirPlatformType platform_type() const |
429 | 81 | { | 86 | { |
430 | 82 | BOOST_THROW_EXCEPTION(std::runtime_error{exception_text}); | 87 | BOOST_THROW_EXCEPTION(std::runtime_error{exception_text}); |
431 | 83 | 88 | ||
432 | === modified file 'tests/include/mir_test_framework/client_platform_factory.h' | |||
433 | --- tests/include/mir_test_framework/client_platform_factory.h 2015-01-30 14:38:25 +0000 | |||
434 | +++ tests/include/mir_test_framework/client_platform_factory.h 2015-01-30 14:38:25 +0000 | |||
435 | @@ -42,19 +42,13 @@ | |||
436 | 42 | return platform_factory(&ctx); | 42 | return platform_factory(&ctx); |
437 | 43 | } | 43 | } |
438 | 44 | 44 | ||
440 | 45 | std::shared_ptr<mir::client::ClientPlatform> create_mesa_client_platform() | 45 | std::shared_ptr<mir::client::ClientPlatform> create_mesa_client_platform( |
441 | 46 | mir::client::ClientContext* client_context) | ||
442 | 46 | { | 47 | { |
443 | 47 | using namespace testing; | 48 | using namespace testing; |
444 | 48 | mtd::MockClientContext ctx; | ||
445 | 49 | ON_CALL(ctx, populate_server_package(_)) | ||
446 | 50 | .WillByDefault(Invoke([](MirPlatformPackage& package) | ||
447 | 51 | { | ||
448 | 52 | ::memset(&package, 0, sizeof(package)); | ||
449 | 53 | package.fd_items = 1; | ||
450 | 54 | })); | ||
451 | 55 | platform_library = std::make_shared<mir::SharedLibrary>(client_platform("mesa.so")); | 49 | platform_library = std::make_shared<mir::SharedLibrary>(client_platform("mesa.so")); |
452 | 56 | auto platform_factory = platform_library->load_function<mir::client::CreateClientPlatform>("create_client_platform"); | 50 | auto platform_factory = platform_library->load_function<mir::client::CreateClientPlatform>("create_client_platform"); |
454 | 57 | return platform_factory(&ctx); | 51 | return platform_factory(client_context); |
455 | 58 | } | 52 | } |
456 | 59 | 53 | ||
457 | 60 | std::shared_ptr<mir::SharedLibrary> | 54 | std::shared_ptr<mir::SharedLibrary> |
458 | 61 | 55 | ||
459 | === modified file 'tests/mir_test_framework/stub_client_platform_factory.cpp' | |||
460 | --- tests/mir_test_framework/stub_client_platform_factory.cpp 2015-01-30 14:38:25 +0000 | |||
461 | +++ tests/mir_test_framework/stub_client_platform_factory.cpp 2015-01-30 14:38:25 +0000 | |||
462 | @@ -50,6 +50,11 @@ | |||
463 | 50 | context->populate_server_package(package); | 50 | context->populate_server_package(package); |
464 | 51 | } | 51 | } |
465 | 52 | 52 | ||
466 | 53 | MirPlatformMessage* platform_operation(MirPlatformMessage const*) override | ||
467 | 54 | { | ||
468 | 55 | return nullptr; | ||
469 | 56 | } | ||
470 | 57 | |||
471 | 53 | std::shared_ptr<mcl::ClientBufferFactory> create_buffer_factory() | 58 | std::shared_ptr<mcl::ClientBufferFactory> create_buffer_factory() |
472 | 54 | { | 59 | { |
473 | 55 | return std::make_shared<mtd::StubClientBufferFactory>(); | 60 | return std::make_shared<mtd::StubClientBufferFactory>(); |
474 | 56 | 61 | ||
475 | === modified file 'tests/unit-tests/client/mesa/test_client_platform.cpp' | |||
476 | --- tests/unit-tests/client/mesa/test_client_platform.cpp 2015-01-22 21:42:26 +0000 | |||
477 | +++ tests/unit-tests/client/mesa/test_client_platform.cpp 2015-01-30 14:38:25 +0000 | |||
478 | @@ -18,23 +18,56 @@ | |||
479 | 18 | 18 | ||
480 | 19 | #include "mir/client_platform.h" | 19 | #include "mir/client_platform.h" |
481 | 20 | #include "mir/shared_library.h" | 20 | #include "mir/shared_library.h" |
482 | 21 | #include "mir/raii.h" | ||
483 | 21 | #include "src/platforms/mesa/client/mesa_native_display_container.h" | 22 | #include "src/platforms/mesa/client/mesa_native_display_container.h" |
484 | 22 | #include "mir_test_framework/client_platform_factory.h" | 23 | #include "mir_test_framework/client_platform_factory.h" |
485 | 23 | #include "mir_test_doubles/mock_egl_native_surface.h" | ||
486 | 24 | 24 | ||
487 | 25 | #include "mir_toolkit/mir_client_library.h" | ||
488 | 25 | #include "mir_toolkit/mesa/native_display.h" | 26 | #include "mir_toolkit/mesa/native_display.h" |
489 | 27 | #include "mir_toolkit/mesa/platform_operation.h" | ||
490 | 26 | 28 | ||
491 | 27 | #include <gtest/gtest.h> | 29 | #include <gtest/gtest.h> |
492 | 30 | #include <gmock/gmock.h> | ||
493 | 28 | 31 | ||
494 | 29 | namespace mcl = mir::client; | 32 | namespace mcl = mir::client; |
495 | 30 | namespace mclm = mir::client::mesa; | 33 | namespace mclm = mir::client::mesa; |
496 | 31 | namespace mt = mir::test; | ||
497 | 32 | namespace mtd = mir::test::doubles; | ||
498 | 33 | namespace mtf = mir_test_framework; | 34 | namespace mtf = mir_test_framework; |
499 | 34 | 35 | ||
503 | 35 | TEST(MesaClientPlatformTest, egl_native_display_is_valid_until_released) | 36 | namespace |
504 | 36 | { | 37 | { |
505 | 37 | auto platform = mtf::create_mesa_client_platform(); | 38 | |
506 | 39 | struct StubClientContext : mcl::ClientContext | ||
507 | 40 | { | ||
508 | 41 | void populate_server_package(MirPlatformPackage& platform_package) override | ||
509 | 42 | { | ||
510 | 43 | platform_package.data_items = 0; | ||
511 | 44 | platform_package.fd_items = 1; | ||
512 | 45 | } | ||
513 | 46 | |||
514 | 47 | }; | ||
515 | 48 | |||
516 | 49 | struct MesaClientPlatformTest : testing::Test | ||
517 | 50 | { | ||
518 | 51 | MirPlatformMessage* set_gbm_device(gbm_device* dev) | ||
519 | 52 | { | ||
520 | 53 | auto request_msg = mir::raii::deleter_for( | ||
521 | 54 | mir_platform_message_create(MirMesaPlatformOperation::set_gbm_device), | ||
522 | 55 | &mir_platform_message_release); | ||
523 | 56 | MirMesaSetGBMDeviceRequest const request{dev}; | ||
524 | 57 | mir_platform_message_set_data(request_msg.get(), &request, sizeof(request)); | ||
525 | 58 | |||
526 | 59 | return platform->platform_operation(request_msg.get()); | ||
527 | 60 | } | ||
528 | 61 | |||
529 | 62 | StubClientContext client_context; | ||
530 | 63 | std::shared_ptr<mir::client::ClientPlatform> platform = | ||
531 | 64 | mtf::create_mesa_client_platform(&client_context); | ||
532 | 65 | }; | ||
533 | 66 | |||
534 | 67 | } | ||
535 | 68 | |||
536 | 69 | TEST_F(MesaClientPlatformTest, egl_native_display_is_valid_until_released) | ||
537 | 70 | { | ||
538 | 38 | auto platform_lib = mtf::get_platform_library(); | 71 | auto platform_lib = mtf::get_platform_library(); |
539 | 39 | 72 | ||
540 | 40 | MirMesaEGLNativeDisplay* nd; | 73 | MirMesaEGLNativeDisplay* nd; |
541 | @@ -47,3 +80,41 @@ | |||
542 | 47 | } | 80 | } |
543 | 48 | EXPECT_EQ(MIR_MESA_FALSE, mclm::mir_client_mesa_egl_native_display_is_valid(nd)); | 81 | EXPECT_EQ(MIR_MESA_FALSE, mclm::mir_client_mesa_egl_native_display_is_valid(nd)); |
544 | 49 | } | 82 | } |
545 | 83 | |||
546 | 84 | TEST_F(MesaClientPlatformTest, handles_set_gbm_device_platform_operation) | ||
547 | 85 | { | ||
548 | 86 | using namespace testing; | ||
549 | 87 | |||
550 | 88 | int const success{0}; | ||
551 | 89 | auto const gbm_dev_dummy = reinterpret_cast<gbm_device*>(this); | ||
552 | 90 | |||
553 | 91 | auto response_msg = mir::raii::deleter_for( | ||
554 | 92 | set_gbm_device(gbm_dev_dummy), | ||
555 | 93 | &mir_platform_message_release); | ||
556 | 94 | |||
557 | 95 | ASSERT_THAT(response_msg, NotNull()); | ||
558 | 96 | auto const response_data = mir_platform_message_get_data(response_msg.get()); | ||
559 | 97 | ASSERT_THAT(response_data.size, Eq(sizeof(MirMesaSetGBMDeviceResponse))); | ||
560 | 98 | auto const response_ptr = | ||
561 | 99 | reinterpret_cast<MirMesaSetGBMDeviceResponse const*>(response_data.data); | ||
562 | 100 | EXPECT_THAT(response_ptr->status, Eq(success)); | ||
563 | 101 | } | ||
564 | 102 | |||
565 | 103 | TEST_F(MesaClientPlatformTest, appends_gbm_device_to_platform_package) | ||
566 | 104 | { | ||
567 | 105 | using namespace testing; | ||
568 | 106 | |||
569 | 107 | MirPlatformPackage pkg; | ||
570 | 108 | platform->populate(pkg); | ||
571 | 109 | int const previous_data_count{pkg.data_items}; | ||
572 | 110 | auto const gbm_dev_dummy = reinterpret_cast<gbm_device*>(this); | ||
573 | 111 | |||
574 | 112 | auto response_msg = mir::raii::deleter_for( | ||
575 | 113 | set_gbm_device(gbm_dev_dummy), | ||
576 | 114 | &mir_platform_message_release); | ||
577 | 115 | |||
578 | 116 | platform->populate(pkg); | ||
579 | 117 | EXPECT_THAT(pkg.data_items, Eq(previous_data_count + (sizeof(gbm_dev_dummy) / sizeof(int)))); | ||
580 | 118 | EXPECT_THAT(reinterpret_cast<struct gbm_device*>(pkg.data[previous_data_count]), | ||
581 | 119 | Eq(gbm_dev_dummy)); | ||
582 | 120 | } | ||
583 | 50 | 121 | ||
584 | === modified file 'tests/unit-tests/client/test_client_mir_surface.cpp' | |||
585 | --- tests/unit-tests/client/test_client_mir_surface.cpp 2015-01-30 14:38:25 +0000 | |||
586 | +++ tests/unit-tests/client/test_client_mir_surface.cpp 2015-01-30 14:38:25 +0000 | |||
587 | @@ -211,6 +211,12 @@ | |||
588 | 211 | { | 211 | { |
589 | 212 | } | 212 | } |
590 | 213 | 213 | ||
591 | 214 | MirPlatformMessage* platform_operation( | ||
592 | 215 | MirPlatformMessage const*) override | ||
593 | 216 | { | ||
594 | 217 | return nullptr; | ||
595 | 218 | } | ||
596 | 219 | |||
597 | 214 | std::shared_ptr<mcl::ClientBufferFactory> create_buffer_factory() | 220 | std::shared_ptr<mcl::ClientBufferFactory> create_buffer_factory() |
598 | 215 | { | 221 | { |
599 | 216 | return std::make_shared<mtd::StubClientBufferFactory>(); | 222 | return std::make_shared<mtd::StubClientBufferFactory>(); |
600 | 217 | 223 | ||
601 | === modified file 'tests/unit-tests/client/test_mir_connection.cpp' | |||
602 | --- tests/unit-tests/client/test_mir_connection.cpp 2015-01-30 14:38:25 +0000 | |||
603 | +++ tests/unit-tests/client/test_mir_connection.cpp 2015-01-30 14:38:25 +0000 | |||
604 | @@ -28,6 +28,7 @@ | |||
605 | 28 | #include "src/client/mir_surface.h" | 28 | #include "src/client/mir_surface.h" |
606 | 29 | #include "mir/client_buffer_factory.h" | 29 | #include "mir/client_buffer_factory.h" |
607 | 30 | #include "mir/dispatch/dispatchable.h" | 30 | #include "mir/dispatch/dispatchable.h" |
608 | 31 | #include "mir/raii.h" | ||
609 | 31 | 32 | ||
610 | 32 | #include "src/server/frontend/resource_cache.h" /* needed by test_server.h */ | 33 | #include "src/server/frontend/resource_cache.h" /* needed by test_server.h */ |
611 | 33 | #include "mir_test/test_protobuf_server.h" | 34 | #include "mir_test/test_protobuf_server.h" |
612 | @@ -74,12 +75,19 @@ | |||
613 | 74 | { | 75 | { |
614 | 75 | configure_display_sent(static_cast<mp::DisplayConfiguration const*>(parameters)); | 76 | configure_display_sent(static_cast<mp::DisplayConfiguration const*>(parameters)); |
615 | 76 | } | 77 | } |
616 | 78 | else if (method->name() == "platform_operation") | ||
617 | 79 | { | ||
618 | 80 | platform_operation(static_cast<mp::PlatformOperationMessage const*>(parameters), | ||
619 | 81 | static_cast<mp::PlatformOperationMessage*>(response)); | ||
620 | 82 | } | ||
621 | 77 | 83 | ||
622 | 78 | complete->Run(); | 84 | complete->Run(); |
623 | 79 | } | 85 | } |
624 | 80 | 86 | ||
625 | 81 | MOCK_METHOD2(connect, void(mp::ConnectParameters const*,mp::Connection*)); | 87 | MOCK_METHOD2(connect, void(mp::ConnectParameters const*,mp::Connection*)); |
626 | 82 | MOCK_METHOD1(configure_display_sent, void(mp::DisplayConfiguration const*)); | 88 | MOCK_METHOD1(configure_display_sent, void(mp::DisplayConfiguration const*)); |
627 | 89 | MOCK_METHOD2(platform_operation, | ||
628 | 90 | void(mp::PlatformOperationMessage const*, mp::PlatformOperationMessage*)); | ||
629 | 83 | 91 | ||
630 | 84 | MOCK_CONST_METHOD0(watch_fd, mir::Fd()); | 92 | MOCK_CONST_METHOD0(watch_fd, mir::Fd()); |
631 | 85 | MOCK_METHOD1(dispatch, bool(md::FdEvents)); | 93 | MOCK_METHOD1(dispatch, bool(md::FdEvents)); |
632 | @@ -101,6 +109,8 @@ | |||
633 | 101 | .WillByDefault(Return(std::make_shared<mtd::StubClientBufferFactory>())); | 109 | .WillByDefault(Return(std::make_shared<mtd::StubClientBufferFactory>())); |
634 | 102 | ON_CALL(*this, create_egl_native_window(_)) | 110 | ON_CALL(*this, create_egl_native_window(_)) |
635 | 103 | .WillByDefault(Return(std::shared_ptr<EGLNativeWindowType>())); | 111 | .WillByDefault(Return(std::shared_ptr<EGLNativeWindowType>())); |
636 | 112 | ON_CALL(*this, platform_operation(_)) | ||
637 | 113 | .WillByDefault(Return(nullptr)); | ||
638 | 104 | } | 114 | } |
639 | 105 | 115 | ||
640 | 106 | void set_client_context(mcl::ClientContext* ctx) | 116 | void set_client_context(mcl::ClientContext* ctx) |
641 | @@ -115,6 +125,7 @@ | |||
642 | 115 | 125 | ||
643 | 116 | MOCK_CONST_METHOD1(convert_native_buffer, MirNativeBuffer*(mir::graphics::NativeBuffer*)); | 126 | MOCK_CONST_METHOD1(convert_native_buffer, MirNativeBuffer*(mir::graphics::NativeBuffer*)); |
644 | 117 | MOCK_CONST_METHOD0(platform_type, MirPlatformType()); | 127 | MOCK_CONST_METHOD0(platform_type, MirPlatformType()); |
645 | 128 | MOCK_METHOD1(platform_operation, MirPlatformMessage*(MirPlatformMessage const*)); | ||
646 | 118 | MOCK_METHOD0(create_buffer_factory, std::shared_ptr<mcl::ClientBufferFactory>()); | 129 | MOCK_METHOD0(create_buffer_factory, std::shared_ptr<mcl::ClientBufferFactory>()); |
647 | 119 | MOCK_METHOD1(create_egl_native_window, std::shared_ptr<EGLNativeWindowType>(mcl::EGLNativeSurface*)); | 130 | MOCK_METHOD1(create_egl_native_window, std::shared_ptr<EGLNativeWindowType>(mcl::EGLNativeSurface*)); |
648 | 120 | MOCK_METHOD0(create_egl_native_display, std::shared_ptr<EGLNativeDisplayType>()); | 131 | MOCK_METHOD0(create_egl_native_display, std::shared_ptr<EGLNativeDisplayType>()); |
649 | @@ -568,46 +579,72 @@ | |||
650 | 568 | namespace | 579 | namespace |
651 | 569 | { | 580 | { |
652 | 570 | 581 | ||
695 | 571 | ACTION_P(FillPlatformDataWith, sample_data) | 582 | void assign_response(MirConnection*, MirPlatformMessage* response, void* context) |
696 | 572 | { | 583 | { |
697 | 573 | for (auto d : sample_data) | 584 | auto response_ptr = static_cast<MirPlatformMessage**>(context); |
698 | 574 | arg1->mutable_platform()->add_data(d); | 585 | *response_ptr = response; |
699 | 575 | } | 586 | } |
700 | 576 | 587 | ||
701 | 577 | } | 588 | ACTION(CopyRequestToResponse) |
702 | 578 | 589 | { | |
703 | 579 | TEST_F(MirConnectionTest, sets_extra_platform_data) | 590 | *arg1 = *arg0; |
704 | 580 | { | 591 | } |
705 | 581 | using namespace testing; | 592 | } |
706 | 582 | std::vector<int> const initial_data{0x66, 0x67, 0x68}; | 593 | |
707 | 583 | std::vector<int> const extra_data{0x11, 0x12, 0x13}; | 594 | TEST_F(MirConnectionTest, uses_client_platform_for_platform_operation) |
708 | 584 | 595 | { | |
709 | 585 | EXPECT_CALL(*mock_channel, connect(_,_)) | 596 | using namespace testing; |
710 | 586 | .WillOnce(FillPlatformDataWith(initial_data)); | 597 | |
711 | 587 | 598 | unsigned int const opcode{42}; | |
712 | 588 | MirWaitHandle *wait_handle = | 599 | auto const request = mir::raii::deleter_for( |
713 | 589 | connection->connect("MirClientSurfaceTest", &connected_callback, nullptr); | 600 | mir_platform_message_create(opcode), |
714 | 590 | wait_handle->wait_for_all(); | 601 | &mir_platform_message_release); |
715 | 591 | 602 | auto const response = mir::raii::deleter_for( | |
716 | 592 | MirPlatformPackage pkg; | 603 | mir_platform_message_create(opcode), |
717 | 593 | 604 | &mir_platform_message_release); | |
718 | 594 | /* Check initial data */ | 605 | |
719 | 595 | connection->populate(pkg); | 606 | EXPECT_CALL(*mock_platform, platform_operation(request.get())) |
720 | 596 | 607 | .WillOnce(Return(response.get())); | |
721 | 597 | EXPECT_EQ(initial_data.size(), static_cast<size_t>(pkg.data_items)); | 608 | EXPECT_CALL(*mock_channel, platform_operation(_,_)) |
722 | 598 | for (size_t i = 0; i < initial_data.size(); i++) | 609 | .Times(0); |
723 | 599 | EXPECT_EQ(initial_data[i], pkg.data[i]) << " i=" << i; | 610 | |
724 | 600 | 611 | auto connect_wh = | |
725 | 601 | /* Check initial data plus extra data*/ | 612 | connection->connect("MirClientSurfaceTest", &connected_callback, nullptr); |
726 | 602 | connection->set_extra_platform_data(extra_data); | 613 | mir_wait_for(connect_wh); |
727 | 603 | connection->populate(pkg); | 614 | |
728 | 604 | 615 | MirPlatformMessage* returned_response{nullptr}; | |
729 | 605 | EXPECT_EQ(initial_data.size() + extra_data.size(), | 616 | |
730 | 606 | static_cast<size_t>(pkg.data_items)); | 617 | auto op_wh = connection->platform_operation( |
731 | 607 | 618 | opcode, request.get(), assign_response, &returned_response); | |
732 | 608 | for (size_t i = 0; i < initial_data.size(); i++) | 619 | mir_wait_for(op_wh); |
733 | 609 | EXPECT_EQ(initial_data[i], pkg.data[i]) << " i=" << i; | 620 | |
734 | 610 | 621 | EXPECT_THAT(returned_response, Eq(response.get())); | |
735 | 611 | for (size_t i = 0; i < extra_data.size(); i++) | 622 | } |
736 | 612 | EXPECT_EQ(extra_data[i], pkg.data[i + initial_data.size()]) << " i=" << i; | 623 | |
737 | 624 | TEST_F(MirConnectionTest, contacts_server_if_client_platform_cannot_handle_platform_operation) | ||
738 | 625 | { | ||
739 | 626 | using namespace testing; | ||
740 | 627 | |||
741 | 628 | unsigned int const opcode{42}; | ||
742 | 629 | auto const request = mir::raii::deleter_for( | ||
743 | 630 | mir_platform_message_create(opcode), | ||
744 | 631 | &mir_platform_message_release); | ||
745 | 632 | |||
746 | 633 | EXPECT_CALL(*mock_platform, platform_operation(_)) | ||
747 | 634 | .WillOnce(Return(nullptr)); | ||
748 | 635 | EXPECT_CALL(*mock_channel, platform_operation(_,_)) | ||
749 | 636 | .WillOnce(CopyRequestToResponse()); | ||
750 | 637 | |||
751 | 638 | auto connect_wh = | ||
752 | 639 | connection->connect("MirClientSurfaceTest", &connected_callback, nullptr); | ||
753 | 640 | mir_wait_for(connect_wh); | ||
754 | 641 | |||
755 | 642 | MirPlatformMessage* returned_response{nullptr}; | ||
756 | 643 | |||
757 | 644 | auto op_wh = connection->platform_operation( | ||
758 | 645 | opcode, request.get(), assign_response, &returned_response); | ||
759 | 646 | mir_wait_for(op_wh); | ||
760 | 647 | |||
761 | 648 | EXPECT_THAT(mir_platform_message_get_opcode(returned_response), Eq(opcode)); | ||
762 | 649 | mir_platform_message_release(returned_response); | ||
763 | 613 | } | 650 | } |
FAILED: Continuous integration, rev:2280 jenkins. qa.ubuntu. com/job/ mir-ci/ 2863/ jenkins. qa.ubuntu. com/job/ mir-android- vivid-i386- build/1137 jenkins. qa.ubuntu. com/job/ mir-clang- vivid-amd64- build/1136/ console jenkins. qa.ubuntu. com/job/ mir-mediumtests -vivid- touch/1098 jenkins. qa.ubuntu. com/job/ mir-vivid- amd64-ci/ 860 jenkins. qa.ubuntu. com/job/ mir-vivid- amd64-ci/ 860/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 1098 jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 1098/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -runner- mako/4151 s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 17634
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/2863/ rebuild
http://