Merge lp:~jamesh/storage-framework/provider-testing-api into lp:storage-framework/devel
- provider-testing-api
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Michi Henning |
Approved revision: | 50 |
Merged at revision: | 49 |
Proposed branch: | lp:~jamesh/storage-framework/provider-testing-api |
Merge into: | lp:storage-framework/devel |
Diff against target: |
814 lines (+467/-128) 17 files modified
include/unity/storage/internal/dbusmarshal.h (+44/-0) include/unity/storage/provider/CMakeLists.txt (+2/-0) include/unity/storage/provider/internal/TestServerImpl.h (+64/-0) include/unity/storage/provider/testing/CMakeLists.txt (+5/-0) include/unity/storage/provider/testing/TestServer.h (+68/-0) include/unity/storage/qt/client/internal/remote_client/dbusmarshal.h (+1/-20) src/internal/CMakeLists.txt (+4/-0) src/internal/dbusmarshal.cpp (+113/-0) src/provider/CMakeLists.txt (+2/-0) src/provider/internal/TestServerImpl.cpp (+82/-0) src/provider/testing/TestServer.cpp (+61/-0) src/qt/client/CMakeLists.txt (+2/-1) src/qt/client/internal/remote_client/RuntimeImpl.cpp (+2/-1) src/qt/client/internal/remote_client/dbusmarshal.cpp (+0/-83) tests/provider-ProviderInterface/CMakeLists.txt (+3/-5) tests/provider-ProviderInterface/ProviderInterface_test.cpp (+8/-17) tests/provider-ProviderInterface/TestProvider.h (+6/-1) |
To merge this branch: | bzr merge lp:~jamesh/storage-framework/provider-testing-api |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
unity-api-1-bot | continuous-integration | Approve | |
Michi Henning (community) | Approve | ||
Review via email: mp+302627@code.launchpad.net |
Commit message
Add unity::
Description of the change
Add a unity::
It takes a ProviderBase instance, OnlineAccounts:
Using this code let me remove the use of internal symbols in the ProviderInterface test.
While the rest of storage-
I had thought about moving creation of the second QDBusConnection inside TestServer (so we'd take the session bus address as an argument instead), but we've still got the OnlineAccounts instance to deal with. Since this is in the testing namespace, perhaps that is okay.
unity-api-1-bot (unity-api-1-bot) wrote : | # |
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:48
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
- 49. By James Henstridge
-
Merge from devel, fixing conflict.
- 50. By James Henstridge
-
Move QDBusArgument marshalling code for ItemMetadata to
storage-framework- common- internal library: while local-client doesn't
explicitly need it, it was already linking to QtDBus, so it doesn't
really matter.
Michi Henning (michihenning) wrote : | # |
Looks good, thank you!
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:50
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | === added file 'include/unity/storage/internal/dbusmarshal.h' |
2 | --- include/unity/storage/internal/dbusmarshal.h 1970-01-01 00:00:00 +0000 |
3 | +++ include/unity/storage/internal/dbusmarshal.h 2016-08-11 06:54:57 +0000 |
4 | @@ -0,0 +1,44 @@ |
5 | +/* |
6 | + * Copyright (C) 2016 Canonical Ltd |
7 | + * |
8 | + * This program is free software: you can redistribute it and/or modify |
9 | + * it under the terms of the GNU Lesser General Public License version 3 as |
10 | + * published by the Free Software Foundation. |
11 | + * |
12 | + * This program is distributed in the hope that it will be useful, |
13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | + * GNU Lesser General Public License for more details. |
16 | + * |
17 | + * You should have received a copy of the GNU Lesser General Public License |
18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | + * |
20 | + * Authors: Michi Henning <michi.henning@canonical.com> |
21 | + */ |
22 | + |
23 | +#pragma once |
24 | + |
25 | +#include <unity/storage/internal/ItemMetadata.h> |
26 | + |
27 | +#include <QDBusArgument> |
28 | +#include <QMetaType> |
29 | + |
30 | +namespace unity |
31 | +{ |
32 | +namespace storage |
33 | +{ |
34 | +namespace internal |
35 | +{ |
36 | + |
37 | +QDBusArgument& operator<<(QDBusArgument& argument, ItemMetadata const& metadata); |
38 | +QDBusArgument const& operator>>(QDBusArgument const& argument, ItemMetadata& metadata); |
39 | + |
40 | +QDBusArgument& operator<<(QDBusArgument& argument, QList<ItemMetadata> const& md_list); |
41 | +QDBusArgument const& operator>>(QDBusArgument const& argument, QList<ItemMetadata>& md_list); |
42 | + |
43 | +} // namespace internal |
44 | +} // storage |
45 | +} // unity |
46 | + |
47 | +Q_DECLARE_METATYPE(unity::storage::internal::ItemMetadata) |
48 | +Q_DECLARE_METATYPE(QList<unity::storage::internal::ItemMetadata>) |
49 | |
50 | === modified file 'include/unity/storage/provider/CMakeLists.txt' |
51 | --- include/unity/storage/provider/CMakeLists.txt 2016-07-11 03:28:40 +0000 |
52 | +++ include/unity/storage/provider/CMakeLists.txt 2016-08-11 06:54:57 +0000 |
53 | @@ -3,3 +3,5 @@ |
54 | |
55 | install(FILES ${provider_headers} |
56 | DESTINATION ${provider_base_includedir}/${includeprefix}) |
57 | + |
58 | +add_subdirectory(testing) |
59 | |
60 | === added file 'include/unity/storage/provider/internal/TestServerImpl.h' |
61 | --- include/unity/storage/provider/internal/TestServerImpl.h 1970-01-01 00:00:00 +0000 |
62 | +++ include/unity/storage/provider/internal/TestServerImpl.h 2016-08-11 06:54:57 +0000 |
63 | @@ -0,0 +1,64 @@ |
64 | +/* |
65 | + * Copyright (C) 2016 Canonical Ltd |
66 | + * |
67 | + * This program is free software: you can redistribute it and/or modify |
68 | + * it under the terms of the GNU Lesser General Public License version 3 as |
69 | + * published by the Free Software Foundation. |
70 | + * |
71 | + * This program is distributed in the hope that it will be useful, |
72 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
73 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
74 | + * GNU Lesser General Public License for more details. |
75 | + * |
76 | + * You should have received a copy of the GNU Lesser General Public License |
77 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
78 | + * |
79 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
80 | + */ |
81 | + |
82 | +#pragma once |
83 | + |
84 | +#include <unity/storage/provider/testing/TestServer.h> |
85 | + |
86 | +#pragma GCC diagnostic push |
87 | +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
88 | +#include <QDBusConnection> |
89 | +#pragma GCC diagnostic pop |
90 | + |
91 | +#include <memory> |
92 | +#include <string> |
93 | + |
94 | +namespace unity |
95 | +{ |
96 | +namespace storage |
97 | +{ |
98 | +namespace provider |
99 | +{ |
100 | +namespace internal |
101 | +{ |
102 | + |
103 | +class ProviderInterface; |
104 | + |
105 | +class TestServerImpl |
106 | +{ |
107 | +public: |
108 | + TestServerImpl(std::unique_ptr<ProviderBase>&& provider, |
109 | + OnlineAccounts::Account* account, |
110 | + QDBusConnection const& connection, |
111 | + std::string const& object_path); |
112 | + ~TestServerImpl(); |
113 | + |
114 | + QDBusConnection const& connection() const; |
115 | + std::string const& object_path() const; |
116 | + |
117 | +private: |
118 | + QDBusConnection connection_; |
119 | + std::string const object_path_; |
120 | + |
121 | + std::unique_ptr<ProviderInterface> interface_; |
122 | +}; |
123 | + |
124 | +} |
125 | +} |
126 | +} |
127 | +} |
128 | |
129 | === added directory 'include/unity/storage/provider/testing' |
130 | === added file 'include/unity/storage/provider/testing/CMakeLists.txt' |
131 | --- include/unity/storage/provider/testing/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
132 | +++ include/unity/storage/provider/testing/CMakeLists.txt 2016-08-11 06:54:57 +0000 |
133 | @@ -0,0 +1,5 @@ |
134 | +set(includeprefix unity/storage/provider/testing) |
135 | +file(GLOB provider_headers *.h) |
136 | + |
137 | +install(FILES ${provider_headers} |
138 | + DESTINATION ${provider_base_includedir}/${includeprefix}) |
139 | |
140 | === added file 'include/unity/storage/provider/testing/TestServer.h' |
141 | --- include/unity/storage/provider/testing/TestServer.h 1970-01-01 00:00:00 +0000 |
142 | +++ include/unity/storage/provider/testing/TestServer.h 2016-08-11 06:54:57 +0000 |
143 | @@ -0,0 +1,68 @@ |
144 | +/* |
145 | + * Copyright (C) 2016 Canonical Ltd |
146 | + * |
147 | + * This program is free software: you can redistribute it and/or modify |
148 | + * it under the terms of the GNU Lesser General Public License version 3 as |
149 | + * published by the Free Software Foundation. |
150 | + * |
151 | + * This program is distributed in the hope that it will be useful, |
152 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
153 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
154 | + * GNU Lesser General Public License for more details. |
155 | + * |
156 | + * You should have received a copy of the GNU Lesser General Public License |
157 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
158 | + * |
159 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
160 | + */ |
161 | + |
162 | +#pragma once |
163 | + |
164 | +#include <unity/storage/visibility.h> |
165 | + |
166 | +#include <memory> |
167 | +#include <string> |
168 | + |
169 | +namespace OnlineAccounts |
170 | +{ |
171 | +class Account; |
172 | +} |
173 | +class QDBusConnection; |
174 | + |
175 | +namespace unity |
176 | +{ |
177 | +namespace storage |
178 | +{ |
179 | +namespace provider |
180 | +{ |
181 | + |
182 | +class ProviderBase; |
183 | + |
184 | +namespace internal |
185 | +{ |
186 | +class TestServerImpl; |
187 | +} |
188 | + |
189 | +namespace testing |
190 | +{ |
191 | + |
192 | +class UNITY_STORAGE_EXPORT TestServer |
193 | +{ |
194 | +public: |
195 | + TestServer(std::unique_ptr<ProviderBase>&& provider, |
196 | + OnlineAccounts::Account* account, |
197 | + QDBusConnection const& connection, |
198 | + std::string const& object_path); |
199 | + ~TestServer(); |
200 | + |
201 | + QDBusConnection const& connection() const; |
202 | + std::string const& object_path() const; |
203 | + |
204 | +private: |
205 | + std::unique_ptr<internal::TestServerImpl> p_; |
206 | +}; |
207 | + |
208 | +} |
209 | +} |
210 | +} |
211 | +} |
212 | |
213 | === modified file 'include/unity/storage/qt/client/internal/remote_client/dbusmarshal.h' |
214 | --- include/unity/storage/qt/client/internal/remote_client/dbusmarshal.h 2016-08-05 05:37:23 +0000 |
215 | +++ include/unity/storage/qt/client/internal/remote_client/dbusmarshal.h 2016-08-11 06:54:57 +0000 |
216 | @@ -18,11 +18,7 @@ |
217 | |
218 | #pragma once |
219 | |
220 | -#include <unity/storage/internal/ItemMetadata.h> |
221 | - |
222 | -#include <QDBusArgument> |
223 | -#include <QMetaType> |
224 | -#include <QVariant> |
225 | +#include <exception> |
226 | |
227 | class QDBusPendingCallWatcher; |
228 | |
229 | @@ -30,18 +26,6 @@ |
230 | { |
231 | namespace storage |
232 | { |
233 | -namespace internal |
234 | -{ |
235 | - |
236 | -struct ItemMetadata; |
237 | -QDBusArgument& operator<<(QDBusArgument& argument, storage::internal::ItemMetadata const& metadata); |
238 | -QDBusArgument const& operator>>(QDBusArgument const& argument, storage::internal::ItemMetadata& metadata); |
239 | - |
240 | -QDBusArgument& operator<<(QDBusArgument& argument, QList<storage::internal::ItemMetadata> const& md_list); |
241 | -QDBusArgument const& operator>>(QDBusArgument const& argument, QList<storage::internal::ItemMetadata>& md_list); |
242 | - |
243 | -} // namespace internal |
244 | - |
245 | namespace qt |
246 | { |
247 | namespace client |
248 | @@ -59,6 +43,3 @@ |
249 | } // qt |
250 | } // storage |
251 | } // unity |
252 | - |
253 | -Q_DECLARE_METATYPE(unity::storage::internal::ItemMetadata) |
254 | -Q_DECLARE_METATYPE(QList<unity::storage::internal::ItemMetadata>) |
255 | |
256 | === modified file 'src/internal/CMakeLists.txt' |
257 | --- src/internal/CMakeLists.txt 2016-07-06 00:59:42 +0000 |
258 | +++ src/internal/CMakeLists.txt 2016-08-11 06:54:57 +0000 |
259 | @@ -1,5 +1,9 @@ |
260 | set(src |
261 | + dbusmarshal.cpp |
262 | safe_strerror.cpp |
263 | ) |
264 | |
265 | add_library(storage-framework-common-internal STATIC ${src}) |
266 | +target_link_libraries(storage-framework-common-internal |
267 | + Qt5::DBus |
268 | +) |
269 | |
270 | === added file 'src/internal/dbusmarshal.cpp' |
271 | --- src/internal/dbusmarshal.cpp 1970-01-01 00:00:00 +0000 |
272 | +++ src/internal/dbusmarshal.cpp 2016-08-11 06:54:57 +0000 |
273 | @@ -0,0 +1,113 @@ |
274 | +/* |
275 | + * Copyright (C) 2016 Canonical Ltd |
276 | + * |
277 | + * This program is free software: you can redistribute it and/or modify |
278 | + * it under the terms of the GNU Lesser General Public License version 3 as |
279 | + * published by the Free Software Foundation. |
280 | + * |
281 | + * This program is distributed in the hope that it will be useful, |
282 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
283 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
284 | + * GNU Lesser General Public License for more details. |
285 | + * |
286 | + * You should have received a copy of the GNU Lesser General Public License |
287 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
288 | + * |
289 | + * Authors: Michi Henning <michi.henning@canonical.com> |
290 | + */ |
291 | + |
292 | +#include <unity/storage/internal/dbusmarshal.h> |
293 | + |
294 | +#include <QDebug> |
295 | + |
296 | +using namespace unity::storage::internal; |
297 | +using namespace std; |
298 | + |
299 | +namespace unity |
300 | +{ |
301 | +namespace storage |
302 | +{ |
303 | +namespace internal |
304 | +{ |
305 | + |
306 | +QDBusArgument& operator<<(QDBusArgument& argument, storage::internal::ItemMetadata const& metadata) |
307 | +{ |
308 | + argument.beginStructure(); |
309 | + argument << metadata.item_id; |
310 | + argument << metadata.parent_id; |
311 | + argument << metadata.name; |
312 | + argument << metadata.etag; |
313 | + argument << static_cast<int32_t>(metadata.type); |
314 | + argument.beginMap(QVariant::String, qMetaTypeId<QDBusVariant>()); |
315 | + decltype(ItemMetadata::metadata)::const_iterator i = metadata.metadata.constBegin(); |
316 | + while (i != metadata.metadata.constEnd()) |
317 | + { |
318 | + argument.beginMapEntry(); |
319 | + argument << i.key() << QDBusVariant(i.value()); |
320 | + argument.endMapEntry(); |
321 | + ++i; |
322 | + } |
323 | + argument.endMap(); |
324 | + argument.endStructure(); |
325 | + return argument; |
326 | +} |
327 | + |
328 | +QDBusArgument const& operator>>(QDBusArgument const& argument, storage::internal::ItemMetadata& metadata) |
329 | +{ |
330 | + argument.beginStructure(); |
331 | + argument >> metadata.item_id; |
332 | + argument >> metadata.parent_id; |
333 | + argument >> metadata.name; |
334 | + argument >> metadata.etag; |
335 | + int32_t enum_val; |
336 | + argument >> enum_val; |
337 | + if (enum_val < 0 || enum_val >= int(ItemType::LAST_ENTRY__)) |
338 | + { |
339 | + qCritical() << "unmarshaling error: impossible ItemType value: " + QString::number(enum_val); |
340 | + return argument; // Forces error |
341 | + } |
342 | + metadata.type = static_cast<ItemType>(enum_val); |
343 | + metadata.metadata.clear(); |
344 | + argument.beginMap(); |
345 | + while (!argument.atEnd()) |
346 | + { |
347 | + QString key; |
348 | + QVariant value; |
349 | + argument.beginMapEntry(); |
350 | + argument >> key >> value; |
351 | + argument.endMapEntry(); |
352 | + metadata.metadata.insert(key, value); |
353 | + } |
354 | + argument.endMap(); |
355 | + argument.endStructure(); |
356 | + return argument; |
357 | +} |
358 | + |
359 | +QDBusArgument& operator<<(QDBusArgument& argument, QList<storage::internal::ItemMetadata> const& md_list) |
360 | +{ |
361 | + argument.beginArray(qMetaTypeId<storage::internal::ItemMetadata>()); |
362 | + for (auto const& md : md_list) |
363 | + { |
364 | + argument << md; |
365 | + } |
366 | + argument.endArray(); |
367 | + return argument; |
368 | +} |
369 | + |
370 | +QDBusArgument const& operator>>(QDBusArgument const& argument, QList<storage::internal::ItemMetadata>& md_list) |
371 | +{ |
372 | + md_list.clear(); |
373 | + argument.beginArray(); |
374 | + while (!argument.atEnd()) |
375 | + { |
376 | + ItemMetadata imd; |
377 | + argument >> imd; |
378 | + md_list.append(imd); |
379 | + } |
380 | + argument.endArray(); |
381 | + return argument; |
382 | +} |
383 | + |
384 | +} // namespace internal |
385 | +} // namespace storage |
386 | +} // namespace unity |
387 | |
388 | === modified file 'src/provider/CMakeLists.txt' |
389 | --- src/provider/CMakeLists.txt 2016-08-11 03:49:32 +0000 |
390 | +++ src/provider/CMakeLists.txt 2016-08-11 06:54:57 +0000 |
391 | @@ -19,6 +19,7 @@ |
392 | Server.cpp |
393 | TempfileUploadJob.cpp |
394 | UploadJob.cpp |
395 | + testing/TestServer.cpp |
396 | internal/AccountData.cpp |
397 | internal/DBusPeerCache.cpp |
398 | internal/DownloadJobImpl.cpp |
399 | @@ -28,6 +29,7 @@ |
400 | internal/ProviderInterface.cpp |
401 | internal/ServerImpl.cpp |
402 | internal/TempfileUploadJobImpl.cpp |
403 | + internal/TestServerImpl.cpp |
404 | internal/UploadJobImpl.cpp |
405 | internal/dbusmarshal.cpp |
406 | ${CMAKE_SOURCE_DIR}/include/unity/storage/provider/internal/AccountData.h |
407 | |
408 | === added file 'src/provider/internal/TestServerImpl.cpp' |
409 | --- src/provider/internal/TestServerImpl.cpp 1970-01-01 00:00:00 +0000 |
410 | +++ src/provider/internal/TestServerImpl.cpp 2016-08-11 06:54:57 +0000 |
411 | @@ -0,0 +1,82 @@ |
412 | +/* |
413 | + * Copyright (C) 2016 Canonical Ltd |
414 | + * |
415 | + * This program is free software: you can redistribute it and/or modify |
416 | + * it under the terms of the GNU Lesser General Public License version 3 as |
417 | + * published by the Free Software Foundation. |
418 | + * |
419 | + * This program is distributed in the hope that it will be useful, |
420 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
421 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
422 | + * GNU Lesser General Public License for more details. |
423 | + * |
424 | + * You should have received a copy of the GNU Lesser General Public License |
425 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
426 | + * |
427 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
428 | + */ |
429 | + |
430 | +#include <unity/storage/provider/internal/TestServerImpl.h> |
431 | +#include <unity/storage/provider/ProviderBase.h> |
432 | +#include <unity/storage/provider/internal/AccountData.h> |
433 | +#include <unity/storage/provider/internal/DBusPeerCache.h> |
434 | +#include <unity/storage/provider/internal/ProviderInterface.h> |
435 | +#include <unity/storage/provider/internal/dbusmarshal.h> |
436 | +#include "provideradaptor.h" |
437 | + |
438 | +#include <OnlineAccounts/Account> |
439 | + |
440 | +#include <stdexcept> |
441 | + |
442 | +using namespace std; |
443 | + |
444 | +namespace unity |
445 | +{ |
446 | +namespace storage |
447 | +{ |
448 | +namespace provider |
449 | +{ |
450 | +namespace internal |
451 | +{ |
452 | + |
453 | +TestServerImpl::TestServerImpl(unique_ptr<ProviderBase>&& provider, |
454 | + OnlineAccounts::Account* account, |
455 | + QDBusConnection const& connection, |
456 | + string const& object_path) |
457 | + : connection_(connection), object_path_(object_path) |
458 | +{ |
459 | + qDBusRegisterMetaType<Item>(); |
460 | + qDBusRegisterMetaType<std::vector<Item>>(); |
461 | + |
462 | + auto peer_cache = make_shared<DBusPeerCache>(connection_); |
463 | + auto account_data = make_shared<AccountData>( |
464 | + move(provider), peer_cache, connection_, account); |
465 | + interface_.reset(new ProviderInterface(account_data)); |
466 | + new ProviderAdaptor(interface_.get()); |
467 | + |
468 | + if (!connection_.registerObject(QString::fromStdString(object_path_), |
469 | + interface_.get())) |
470 | + { |
471 | + throw runtime_error("Could not register provider on connection"); |
472 | + } |
473 | +} |
474 | + |
475 | +TestServerImpl::~TestServerImpl() |
476 | +{ |
477 | + connection_.unregisterObject(QString::fromStdString(object_path_)); |
478 | +} |
479 | + |
480 | +QDBusConnection const& TestServerImpl::connection() const |
481 | +{ |
482 | + return connection_; |
483 | +} |
484 | + |
485 | +string const& TestServerImpl::object_path() const |
486 | +{ |
487 | + return object_path_; |
488 | +} |
489 | + |
490 | +} |
491 | +} |
492 | +} |
493 | +} |
494 | |
495 | === added directory 'src/provider/testing' |
496 | === added file 'src/provider/testing/TestServer.cpp' |
497 | --- src/provider/testing/TestServer.cpp 1970-01-01 00:00:00 +0000 |
498 | +++ src/provider/testing/TestServer.cpp 2016-08-11 06:54:57 +0000 |
499 | @@ -0,0 +1,61 @@ |
500 | +/* |
501 | + * Copyright (C) 2016 Canonical Ltd |
502 | + * |
503 | + * This program is free software: you can redistribute it and/or modify |
504 | + * it under the terms of the GNU Lesser General Public License version 3 as |
505 | + * published by the Free Software Foundation. |
506 | + * |
507 | + * This program is distributed in the hope that it will be useful, |
508 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
509 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
510 | + * GNU Lesser General Public License for more details. |
511 | + * |
512 | + * You should have received a copy of the GNU Lesser General Public License |
513 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
514 | + * |
515 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
516 | + */ |
517 | + |
518 | +#include <unity/storage/provider/testing/TestServer.h> |
519 | +#include <unity/storage/provider/internal/TestServerImpl.h> |
520 | +#include <unity/storage/provider/ProviderBase.h> |
521 | + |
522 | +#include <OnlineAccounts/Account> |
523 | + |
524 | + |
525 | +using namespace std; |
526 | + |
527 | +namespace unity |
528 | +{ |
529 | +namespace storage |
530 | +{ |
531 | +namespace provider |
532 | +{ |
533 | +namespace testing |
534 | +{ |
535 | + |
536 | +TestServer::TestServer(unique_ptr<ProviderBase>&& provider, |
537 | + OnlineAccounts::Account* account, |
538 | + QDBusConnection const& connection, |
539 | + string const& object_path) |
540 | + : p_(new internal::TestServerImpl(move(provider), account, |
541 | + connection, object_path)) |
542 | +{ |
543 | +} |
544 | + |
545 | +TestServer::~TestServer() = default; |
546 | + |
547 | +QDBusConnection const& TestServer::connection() const |
548 | +{ |
549 | + return p_->connection(); |
550 | +} |
551 | + |
552 | +string const& TestServer::object_path() const |
553 | +{ |
554 | + return p_->object_path(); |
555 | +} |
556 | + |
557 | +} |
558 | +} |
559 | +} |
560 | +} |
561 | |
562 | === modified file 'src/qt/client/CMakeLists.txt' |
563 | --- src/qt/client/CMakeLists.txt 2016-07-27 02:19:17 +0000 |
564 | +++ src/qt/client/CMakeLists.txt 2016-08-11 06:54:57 +0000 |
565 | @@ -80,7 +80,7 @@ |
566 | # Build the remote client library |
567 | set_source_files_properties(${CMAKE_SOURCE_DIR}/data/provider.xml PROPERTIES |
568 | CLASSNAME ProviderInterface |
569 | - INCLUDE unity/storage/qt/client/internal/remote_client/dbusmarshal.h |
570 | + INCLUDE unity/storage/internal/dbusmarshal.h |
571 | ) |
572 | |
573 | qt5_add_dbus_interface(generated_files |
574 | @@ -109,6 +109,7 @@ |
575 | VERSION ${SF_CLIENT_LIBVERSION} |
576 | ) |
577 | target_link_libraries(storage-framework-qt-client |
578 | + storage-framework-common-internal |
579 | Qt5::Concurrent |
580 | Qt5::Core |
581 | Qt5::DBus |
582 | |
583 | === modified file 'src/qt/client/internal/remote_client/RuntimeImpl.cpp' |
584 | --- src/qt/client/internal/remote_client/RuntimeImpl.cpp 2016-08-03 06:29:48 +0000 |
585 | +++ src/qt/client/internal/remote_client/RuntimeImpl.cpp 2016-08-11 06:54:57 +0000 |
586 | @@ -18,11 +18,12 @@ |
587 | |
588 | #include <unity/storage/qt/client/internal/remote_client/RuntimeImpl.h> |
589 | |
590 | +#include <unity/storage/internal/dbusmarshal.h> |
591 | #include <unity/storage/qt/client/Account.h> |
592 | #include <unity/storage/qt/client/Exceptions.h> |
593 | #include <unity/storage/qt/client/internal/make_future.h> |
594 | #include <unity/storage/qt/client/internal/remote_client/AccountImpl.h> |
595 | -#include <unity/storage/qt/client/internal/remote_client/dbusmarshal.h> |
596 | +#include <unity/storage/internal/dbusmarshal.h> |
597 | |
598 | #include <QDBusMetaType> |
599 | |
600 | |
601 | === modified file 'src/qt/client/internal/remote_client/dbusmarshal.cpp' |
602 | --- src/qt/client/internal/remote_client/dbusmarshal.cpp 2016-08-11 01:39:44 +0000 |
603 | +++ src/qt/client/internal/remote_client/dbusmarshal.cpp 2016-08-11 06:54:57 +0000 |
604 | @@ -37,89 +37,6 @@ |
605 | { |
606 | namespace storage |
607 | { |
608 | -namespace internal |
609 | -{ |
610 | - |
611 | -QDBusArgument& operator<<(QDBusArgument& argument, storage::internal::ItemMetadata const& metadata) |
612 | -{ |
613 | - argument.beginStructure(); |
614 | - argument << metadata.item_id; |
615 | - argument << metadata.parent_id; |
616 | - argument << metadata.name; |
617 | - argument << metadata.etag; |
618 | - argument << static_cast<int32_t>(metadata.type); |
619 | - argument.beginMap(QVariant::String, qMetaTypeId<QDBusVariant>()); |
620 | - decltype(ItemMetadata::metadata)::const_iterator i = metadata.metadata.constBegin(); |
621 | - while (i != metadata.metadata.constEnd()) |
622 | - { |
623 | - argument.beginMapEntry(); |
624 | - argument << i.key() << QDBusVariant(i.value()); |
625 | - argument.endMapEntry(); |
626 | - ++i; |
627 | - } |
628 | - argument.endMap(); |
629 | - argument.endStructure(); |
630 | - return argument; |
631 | -} |
632 | - |
633 | -QDBusArgument const& operator>>(QDBusArgument const& argument, storage::internal::ItemMetadata& metadata) |
634 | -{ |
635 | - argument.beginStructure(); |
636 | - argument >> metadata.item_id; |
637 | - argument >> metadata.parent_id; |
638 | - argument >> metadata.name; |
639 | - argument >> metadata.etag; |
640 | - int32_t enum_val; |
641 | - argument >> enum_val; |
642 | - if (enum_val < 0 || enum_val >= int(ItemType::LAST_ENTRY__)) |
643 | - { |
644 | - qCritical() << "unmarshaling error: impossible ItemType value: " + QString::number(enum_val); |
645 | - return argument; // Forces error |
646 | - } |
647 | - metadata.type = static_cast<ItemType>(enum_val); |
648 | - metadata.metadata.clear(); |
649 | - argument.beginMap(); |
650 | - while (!argument.atEnd()) |
651 | - { |
652 | - QString key; |
653 | - QVariant value; |
654 | - argument.beginMapEntry(); |
655 | - argument >> key >> value; |
656 | - argument.endMapEntry(); |
657 | - metadata.metadata.insert(key, value); |
658 | - } |
659 | - argument.endMap(); |
660 | - argument.endStructure(); |
661 | - return argument; |
662 | -} |
663 | - |
664 | -QDBusArgument& operator<<(QDBusArgument& argument, QList<storage::internal::ItemMetadata> const& md_list) |
665 | -{ |
666 | - argument.beginArray(qMetaTypeId<storage::internal::ItemMetadata>()); |
667 | - for (auto const& md : md_list) |
668 | - { |
669 | - argument << md; |
670 | - } |
671 | - argument.endArray(); |
672 | - return argument; |
673 | -} |
674 | - |
675 | -QDBusArgument const& operator>>(QDBusArgument const& argument, QList<storage::internal::ItemMetadata>& md_list) |
676 | -{ |
677 | - md_list.clear(); |
678 | - argument.beginArray(); |
679 | - while (!argument.atEnd()) |
680 | - { |
681 | - ItemMetadata imd; |
682 | - argument >> imd; |
683 | - md_list.append(imd); |
684 | - } |
685 | - argument.endArray(); |
686 | - return argument; |
687 | -} |
688 | - |
689 | -} // namespace internal |
690 | - |
691 | namespace qt |
692 | { |
693 | namespace client |
694 | |
695 | === modified file 'tests/provider-ProviderInterface/CMakeLists.txt' |
696 | --- tests/provider-ProviderInterface/CMakeLists.txt 2016-08-11 03:49:32 +0000 |
697 | +++ tests/provider-ProviderInterface/CMakeLists.txt 2016-08-11 06:54:57 +0000 |
698 | @@ -2,7 +2,7 @@ |
699 | |
700 | set_source_files_properties(${CMAKE_SOURCE_DIR}/data/provider.xml PROPERTIES |
701 | CLASSNAME ProviderClient |
702 | - INCLUDE unity/storage/qt/client/internal/remote_client/dbusmarshal.h |
703 | + INCLUDE unity/storage/internal/dbusmarshal.h |
704 | ) |
705 | qt5_add_dbus_interface(generated_files |
706 | ${CMAKE_SOURCE_DIR}/data/provider.xml |
707 | @@ -15,16 +15,14 @@ |
708 | add_executable(provider-ProviderInterface_test |
709 | ProviderInterface_test.cpp |
710 | TestProvider.cpp |
711 | - ../../src/qt/client/internal/remote_client/dbusmarshal.cpp |
712 | ${generated_files} |
713 | ) |
714 | -add_dependencies(provider-ProviderInterface_test storage-framework-provider) |
715 | set_target_properties(provider-ProviderInterface_test PROPERTIES |
716 | AUTOMOC TRUE |
717 | ) |
718 | target_link_libraries(provider-ProviderInterface_test |
719 | - storage-framework-provider-static |
720 | - storage-framework-qt-client |
721 | + storage-framework-common-internal |
722 | + storage-framework-provider |
723 | Qt5::Test |
724 | testutils |
725 | gtest |
726 | |
727 | === modified file 'tests/provider-ProviderInterface/ProviderInterface_test.cpp' |
728 | --- tests/provider-ProviderInterface/ProviderInterface_test.cpp 2016-08-11 02:49:25 +0000 |
729 | +++ tests/provider-ProviderInterface/ProviderInterface_test.cpp 2016-08-11 06:54:57 +0000 |
730 | @@ -18,12 +18,7 @@ |
731 | |
732 | #include <unity/storage/internal/dbus_error.h> |
733 | #include <unity/storage/provider/ProviderBase.h> |
734 | -#include <unity/storage/provider/internal/DBusPeerCache.h> |
735 | -#include <unity/storage/provider/internal/AccountData.h> |
736 | -#include <unity/storage/provider/internal/ProviderInterface.h> |
737 | -#include <unity/storage/provider/internal/dbusmarshal.h> |
738 | -// generated DBus service adaptor |
739 | -#include "../../src/provider/provideradaptor.h" |
740 | +#include <unity/storage/provider/testing/TestServer.h> |
741 | |
742 | #include "TestProvider.h" |
743 | #include "ProviderClient.h" |
744 | @@ -48,7 +43,8 @@ |
745 | |
746 | using namespace std; |
747 | using unity::storage::ItemType; |
748 | -using namespace unity::storage::provider; |
749 | +using unity::storage::provider::ProviderBase; |
750 | +using unity::storage::provider::testing::TestServer; |
751 | |
752 | namespace { |
753 | |
754 | @@ -75,12 +71,9 @@ |
755 | 2, "oauth2-service"); |
756 | ASSERT_NE(nullptr, account); |
757 | |
758 | - auto peer_cache = make_shared<internal::DBusPeerCache>(*service_connection_); |
759 | - auto account_data = make_shared<internal::AccountData>( |
760 | - move(provider), peer_cache, *service_connection_, account); |
761 | - provider_interface_.reset(new internal::ProviderInterface(account_data)); |
762 | - new ProviderAdaptor(provider_interface_.get()); |
763 | - service_connection_->registerObject(BUS_PATH, provider_interface_.get()); |
764 | + test_server_.reset( |
765 | + new TestServer(move(provider), account, |
766 | + *service_connection_, BUS_PATH.toStdString())); |
767 | |
768 | client_.reset(new ProviderClient(service_connection_->baseService(), |
769 | BUS_PATH, |
770 | @@ -108,7 +101,7 @@ |
771 | void TearDown() override |
772 | { |
773 | client_.reset(); |
774 | - provider_interface_.reset(); |
775 | + test_server_.reset(); |
776 | service_connection_.reset(); |
777 | QDBusConnection::disconnectFromBus(SERVICE_CONNECTION_NAME); |
778 | dbus_.reset(); |
779 | @@ -117,7 +110,7 @@ |
780 | unique_ptr<DBusEnvironment> dbus_; |
781 | unique_ptr<QDBusConnection> service_connection_; |
782 | unique_ptr<OnlineAccounts::Manager> account_manager_; |
783 | - unique_ptr<internal::ProviderInterface> provider_interface_; |
784 | + unique_ptr<TestServer> test_server_; |
785 | unique_ptr<ProviderClient> client_; |
786 | }; |
787 | |
788 | @@ -525,8 +518,6 @@ |
789 | QCoreApplication app(argc, argv); |
790 | qDBusRegisterMetaType<unity::storage::internal::ItemMetadata>(); |
791 | qDBusRegisterMetaType<QList<unity::storage::internal::ItemMetadata>>(); |
792 | - qDBusRegisterMetaType<unity::storage::provider::Item>(); |
793 | - qDBusRegisterMetaType<std::vector<unity::storage::provider::Item>>(); |
794 | ::testing::InitGoogleTest(&argc, argv); |
795 | return RUN_ALL_TESTS(); |
796 | } |
797 | |
798 | === modified file 'tests/provider-ProviderInterface/TestProvider.h' |
799 | --- tests/provider-ProviderInterface/TestProvider.h 2016-08-04 10:12:01 +0000 |
800 | +++ tests/provider-ProviderInterface/TestProvider.h 2016-08-11 06:54:57 +0000 |
801 | @@ -21,7 +21,12 @@ |
802 | #include <unity/storage/provider/ProviderBase.h> |
803 | |
804 | using namespace std; |
805 | -using namespace unity::storage::provider; |
806 | +using unity::storage::provider::Context; |
807 | +using unity::storage::provider::DownloadJob; |
808 | +using unity::storage::provider::ProviderBase; |
809 | +using unity::storage::provider::Item; |
810 | +using unity::storage::provider::ItemList; |
811 | +using unity::storage::provider::UploadJob; |
812 | |
813 | class TestProvider : public ProviderBase { |
814 | public: |
FAILED: Continuous integration, rev:48 /code.launchpad .net/~jamesh/ storage- framework/ provider- testing- api/+merge/ 302627/ +edit-commit- message
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
https:/ /jenkins. canonical. com/unity- api-1/job/ lp-storage- framework- ci/68/ /jenkins. canonical. com/unity- api-1/job/ build/355/ console /jenkins. canonical. com/unity- api-1/job/ build-0- fetch/361/ console
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/unity- api-1/job/ lp-storage- framework- ci/68/rebuild
https:/