Merge lp:~jamesh/storage-framework/provider-testing-api into lp:storage-framework/devel

Proposed by James Henstridge
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
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::storage::provider::testing::TestServer class.

Description of the change

Add a unity::storage::provider::testing::TestServer class for use in testing providers.

It takes a ProviderBase instance, OnlineAccounts::Account, a dbus connection, and object path, and it publishes that provider on the dbus connection. When the TestServer instance is destroyed the server is unpublished.

Using this code let me remove the use of internal symbols in the ProviderInterface test.

While the rest of storage-framework-provider is Qt free, I couldn't think of a good way to do this one without referencing QDBusConnection.

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.

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

FAILED: Continuous integration, rev:48
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://code.launchpad.net/~jamesh/storage-framework/provider-testing-api/+merge/302627/+edit-commit-message

https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/68/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/355/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/361/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/68/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
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.

Revision history for this message
Michi Henning (michihenning) wrote :

Looks good, thank you!

review: Approve
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:50
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/71/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/362
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/368
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/286
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/286
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/286
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/216
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/216/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/216
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/216/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/216
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/216/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/216
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/216/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/216
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/216/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/216
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/216/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/216
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/216/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/216
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/216/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/216
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/216/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/71/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'include/unity/storage/internal/dbusmarshal.h'
--- include/unity/storage/internal/dbusmarshal.h 1970-01-01 00:00:00 +0000
+++ include/unity/storage/internal/dbusmarshal.h 2016-08-11 06:54:57 +0000
@@ -0,0 +1,44 @@
1/*
2 * Copyright (C) 2016 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: Michi Henning <michi.henning@canonical.com>
17 */
18
19#pragma once
20
21#include <unity/storage/internal/ItemMetadata.h>
22
23#include <QDBusArgument>
24#include <QMetaType>
25
26namespace unity
27{
28namespace storage
29{
30namespace internal
31{
32
33QDBusArgument& operator<<(QDBusArgument& argument, ItemMetadata const& metadata);
34QDBusArgument const& operator>>(QDBusArgument const& argument, ItemMetadata& metadata);
35
36QDBusArgument& operator<<(QDBusArgument& argument, QList<ItemMetadata> const& md_list);
37QDBusArgument const& operator>>(QDBusArgument const& argument, QList<ItemMetadata>& md_list);
38
39} // namespace internal
40} // storage
41} // unity
42
43Q_DECLARE_METATYPE(unity::storage::internal::ItemMetadata)
44Q_DECLARE_METATYPE(QList<unity::storage::internal::ItemMetadata>)
045
=== modified file 'include/unity/storage/provider/CMakeLists.txt'
--- include/unity/storage/provider/CMakeLists.txt 2016-07-11 03:28:40 +0000
+++ include/unity/storage/provider/CMakeLists.txt 2016-08-11 06:54:57 +0000
@@ -3,3 +3,5 @@
33
4install(FILES ${provider_headers}4install(FILES ${provider_headers}
5 DESTINATION ${provider_base_includedir}/${includeprefix})5 DESTINATION ${provider_base_includedir}/${includeprefix})
6
7add_subdirectory(testing)
68
=== added file 'include/unity/storage/provider/internal/TestServerImpl.h'
--- include/unity/storage/provider/internal/TestServerImpl.h 1970-01-01 00:00:00 +0000
+++ include/unity/storage/provider/internal/TestServerImpl.h 2016-08-11 06:54:57 +0000
@@ -0,0 +1,64 @@
1/*
2 * Copyright (C) 2016 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: James Henstridge <james.henstridge@canonical.com>
17 */
18
19#pragma once
20
21#include <unity/storage/provider/testing/TestServer.h>
22
23#pragma GCC diagnostic push
24#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
25#include <QDBusConnection>
26#pragma GCC diagnostic pop
27
28#include <memory>
29#include <string>
30
31namespace unity
32{
33namespace storage
34{
35namespace provider
36{
37namespace internal
38{
39
40class ProviderInterface;
41
42class TestServerImpl
43{
44public:
45 TestServerImpl(std::unique_ptr<ProviderBase>&& provider,
46 OnlineAccounts::Account* account,
47 QDBusConnection const& connection,
48 std::string const& object_path);
49 ~TestServerImpl();
50
51 QDBusConnection const& connection() const;
52 std::string const& object_path() const;
53
54private:
55 QDBusConnection connection_;
56 std::string const object_path_;
57
58 std::unique_ptr<ProviderInterface> interface_;
59};
60
61}
62}
63}
64}
065
=== added directory 'include/unity/storage/provider/testing'
=== added file 'include/unity/storage/provider/testing/CMakeLists.txt'
--- include/unity/storage/provider/testing/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ include/unity/storage/provider/testing/CMakeLists.txt 2016-08-11 06:54:57 +0000
@@ -0,0 +1,5 @@
1set(includeprefix unity/storage/provider/testing)
2file(GLOB provider_headers *.h)
3
4install(FILES ${provider_headers}
5 DESTINATION ${provider_base_includedir}/${includeprefix})
06
=== added file 'include/unity/storage/provider/testing/TestServer.h'
--- include/unity/storage/provider/testing/TestServer.h 1970-01-01 00:00:00 +0000
+++ include/unity/storage/provider/testing/TestServer.h 2016-08-11 06:54:57 +0000
@@ -0,0 +1,68 @@
1/*
2 * Copyright (C) 2016 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: James Henstridge <james.henstridge@canonical.com>
17 */
18
19#pragma once
20
21#include <unity/storage/visibility.h>
22
23#include <memory>
24#include <string>
25
26namespace OnlineAccounts
27{
28class Account;
29}
30class QDBusConnection;
31
32namespace unity
33{
34namespace storage
35{
36namespace provider
37{
38
39class ProviderBase;
40
41namespace internal
42{
43class TestServerImpl;
44}
45
46namespace testing
47{
48
49class UNITY_STORAGE_EXPORT TestServer
50{
51public:
52 TestServer(std::unique_ptr<ProviderBase>&& provider,
53 OnlineAccounts::Account* account,
54 QDBusConnection const& connection,
55 std::string const& object_path);
56 ~TestServer();
57
58 QDBusConnection const& connection() const;
59 std::string const& object_path() const;
60
61private:
62 std::unique_ptr<internal::TestServerImpl> p_;
63};
64
65}
66}
67}
68}
069
=== modified file 'include/unity/storage/qt/client/internal/remote_client/dbusmarshal.h'
--- include/unity/storage/qt/client/internal/remote_client/dbusmarshal.h 2016-08-05 05:37:23 +0000
+++ include/unity/storage/qt/client/internal/remote_client/dbusmarshal.h 2016-08-11 06:54:57 +0000
@@ -18,11 +18,7 @@
1818
19#pragma once19#pragma once
2020
21#include <unity/storage/internal/ItemMetadata.h>21#include <exception>
22
23#include <QDBusArgument>
24#include <QMetaType>
25#include <QVariant>
2622
27class QDBusPendingCallWatcher;23class QDBusPendingCallWatcher;
2824
@@ -30,18 +26,6 @@
30{26{
31namespace storage27namespace storage
32{28{
33namespace internal
34{
35
36struct ItemMetadata;
37QDBusArgument& operator<<(QDBusArgument& argument, storage::internal::ItemMetadata const& metadata);
38QDBusArgument const& operator>>(QDBusArgument const& argument, storage::internal::ItemMetadata& metadata);
39
40QDBusArgument& operator<<(QDBusArgument& argument, QList<storage::internal::ItemMetadata> const& md_list);
41QDBusArgument const& operator>>(QDBusArgument const& argument, QList<storage::internal::ItemMetadata>& md_list);
42
43} // namespace internal
44
45namespace qt29namespace qt
46{30{
47namespace client31namespace client
@@ -59,6 +43,3 @@
59} // qt43} // qt
60} // storage44} // storage
61} // unity45} // unity
62
63Q_DECLARE_METATYPE(unity::storage::internal::ItemMetadata)
64Q_DECLARE_METATYPE(QList<unity::storage::internal::ItemMetadata>)
6546
=== modified file 'src/internal/CMakeLists.txt'
--- src/internal/CMakeLists.txt 2016-07-06 00:59:42 +0000
+++ src/internal/CMakeLists.txt 2016-08-11 06:54:57 +0000
@@ -1,5 +1,9 @@
1set(src1set(src
2 dbusmarshal.cpp
2 safe_strerror.cpp3 safe_strerror.cpp
3)4)
45
5add_library(storage-framework-common-internal STATIC ${src})6add_library(storage-framework-common-internal STATIC ${src})
7target_link_libraries(storage-framework-common-internal
8 Qt5::DBus
9)
610
=== added file 'src/internal/dbusmarshal.cpp'
--- src/internal/dbusmarshal.cpp 1970-01-01 00:00:00 +0000
+++ src/internal/dbusmarshal.cpp 2016-08-11 06:54:57 +0000
@@ -0,0 +1,113 @@
1/*
2 * Copyright (C) 2016 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: Michi Henning <michi.henning@canonical.com>
17 */
18
19#include <unity/storage/internal/dbusmarshal.h>
20
21#include <QDebug>
22
23using namespace unity::storage::internal;
24using namespace std;
25
26namespace unity
27{
28namespace storage
29{
30namespace internal
31{
32
33QDBusArgument& operator<<(QDBusArgument& argument, storage::internal::ItemMetadata const& metadata)
34{
35 argument.beginStructure();
36 argument << metadata.item_id;
37 argument << metadata.parent_id;
38 argument << metadata.name;
39 argument << metadata.etag;
40 argument << static_cast<int32_t>(metadata.type);
41 argument.beginMap(QVariant::String, qMetaTypeId<QDBusVariant>());
42 decltype(ItemMetadata::metadata)::const_iterator i = metadata.metadata.constBegin();
43 while (i != metadata.metadata.constEnd())
44 {
45 argument.beginMapEntry();
46 argument << i.key() << QDBusVariant(i.value());
47 argument.endMapEntry();
48 ++i;
49 }
50 argument.endMap();
51 argument.endStructure();
52 return argument;
53}
54
55QDBusArgument const& operator>>(QDBusArgument const& argument, storage::internal::ItemMetadata& metadata)
56{
57 argument.beginStructure();
58 argument >> metadata.item_id;
59 argument >> metadata.parent_id;
60 argument >> metadata.name;
61 argument >> metadata.etag;
62 int32_t enum_val;
63 argument >> enum_val;
64 if (enum_val < 0 || enum_val >= int(ItemType::LAST_ENTRY__))
65 {
66 qCritical() << "unmarshaling error: impossible ItemType value: " + QString::number(enum_val);
67 return argument; // Forces error
68 }
69 metadata.type = static_cast<ItemType>(enum_val);
70 metadata.metadata.clear();
71 argument.beginMap();
72 while (!argument.atEnd())
73 {
74 QString key;
75 QVariant value;
76 argument.beginMapEntry();
77 argument >> key >> value;
78 argument.endMapEntry();
79 metadata.metadata.insert(key, value);
80 }
81 argument.endMap();
82 argument.endStructure();
83 return argument;
84}
85
86QDBusArgument& operator<<(QDBusArgument& argument, QList<storage::internal::ItemMetadata> const& md_list)
87{
88 argument.beginArray(qMetaTypeId<storage::internal::ItemMetadata>());
89 for (auto const& md : md_list)
90 {
91 argument << md;
92 }
93 argument.endArray();
94 return argument;
95}
96
97QDBusArgument const& operator>>(QDBusArgument const& argument, QList<storage::internal::ItemMetadata>& md_list)
98{
99 md_list.clear();
100 argument.beginArray();
101 while (!argument.atEnd())
102 {
103 ItemMetadata imd;
104 argument >> imd;
105 md_list.append(imd);
106 }
107 argument.endArray();
108 return argument;
109}
110
111} // namespace internal
112} // namespace storage
113} // namespace unity
0114
=== modified file 'src/provider/CMakeLists.txt'
--- src/provider/CMakeLists.txt 2016-08-11 03:49:32 +0000
+++ src/provider/CMakeLists.txt 2016-08-11 06:54:57 +0000
@@ -19,6 +19,7 @@
19 Server.cpp19 Server.cpp
20 TempfileUploadJob.cpp20 TempfileUploadJob.cpp
21 UploadJob.cpp21 UploadJob.cpp
22 testing/TestServer.cpp
22 internal/AccountData.cpp23 internal/AccountData.cpp
23 internal/DBusPeerCache.cpp24 internal/DBusPeerCache.cpp
24 internal/DownloadJobImpl.cpp25 internal/DownloadJobImpl.cpp
@@ -28,6 +29,7 @@
28 internal/ProviderInterface.cpp29 internal/ProviderInterface.cpp
29 internal/ServerImpl.cpp30 internal/ServerImpl.cpp
30 internal/TempfileUploadJobImpl.cpp31 internal/TempfileUploadJobImpl.cpp
32 internal/TestServerImpl.cpp
31 internal/UploadJobImpl.cpp33 internal/UploadJobImpl.cpp
32 internal/dbusmarshal.cpp34 internal/dbusmarshal.cpp
33 ${CMAKE_SOURCE_DIR}/include/unity/storage/provider/internal/AccountData.h35 ${CMAKE_SOURCE_DIR}/include/unity/storage/provider/internal/AccountData.h
3436
=== added file 'src/provider/internal/TestServerImpl.cpp'
--- src/provider/internal/TestServerImpl.cpp 1970-01-01 00:00:00 +0000
+++ src/provider/internal/TestServerImpl.cpp 2016-08-11 06:54:57 +0000
@@ -0,0 +1,82 @@
1/*
2 * Copyright (C) 2016 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: James Henstridge <james.henstridge@canonical.com>
17 */
18
19#include <unity/storage/provider/internal/TestServerImpl.h>
20#include <unity/storage/provider/ProviderBase.h>
21#include <unity/storage/provider/internal/AccountData.h>
22#include <unity/storage/provider/internal/DBusPeerCache.h>
23#include <unity/storage/provider/internal/ProviderInterface.h>
24#include <unity/storage/provider/internal/dbusmarshal.h>
25#include "provideradaptor.h"
26
27#include <OnlineAccounts/Account>
28
29#include <stdexcept>
30
31using namespace std;
32
33namespace unity
34{
35namespace storage
36{
37namespace provider
38{
39namespace internal
40{
41
42TestServerImpl::TestServerImpl(unique_ptr<ProviderBase>&& provider,
43 OnlineAccounts::Account* account,
44 QDBusConnection const& connection,
45 string const& object_path)
46 : connection_(connection), object_path_(object_path)
47{
48 qDBusRegisterMetaType<Item>();
49 qDBusRegisterMetaType<std::vector<Item>>();
50
51 auto peer_cache = make_shared<DBusPeerCache>(connection_);
52 auto account_data = make_shared<AccountData>(
53 move(provider), peer_cache, connection_, account);
54 interface_.reset(new ProviderInterface(account_data));
55 new ProviderAdaptor(interface_.get());
56
57 if (!connection_.registerObject(QString::fromStdString(object_path_),
58 interface_.get()))
59 {
60 throw runtime_error("Could not register provider on connection");
61 }
62}
63
64TestServerImpl::~TestServerImpl()
65{
66 connection_.unregisterObject(QString::fromStdString(object_path_));
67}
68
69QDBusConnection const& TestServerImpl::connection() const
70{
71 return connection_;
72}
73
74string const& TestServerImpl::object_path() const
75{
76 return object_path_;
77}
78
79}
80}
81}
82}
083
=== added directory 'src/provider/testing'
=== added file 'src/provider/testing/TestServer.cpp'
--- src/provider/testing/TestServer.cpp 1970-01-01 00:00:00 +0000
+++ src/provider/testing/TestServer.cpp 2016-08-11 06:54:57 +0000
@@ -0,0 +1,61 @@
1/*
2 * Copyright (C) 2016 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: James Henstridge <james.henstridge@canonical.com>
17 */
18
19#include <unity/storage/provider/testing/TestServer.h>
20#include <unity/storage/provider/internal/TestServerImpl.h>
21#include <unity/storage/provider/ProviderBase.h>
22
23#include <OnlineAccounts/Account>
24
25
26using namespace std;
27
28namespace unity
29{
30namespace storage
31{
32namespace provider
33{
34namespace testing
35{
36
37TestServer::TestServer(unique_ptr<ProviderBase>&& provider,
38 OnlineAccounts::Account* account,
39 QDBusConnection const& connection,
40 string const& object_path)
41 : p_(new internal::TestServerImpl(move(provider), account,
42 connection, object_path))
43{
44}
45
46TestServer::~TestServer() = default;
47
48QDBusConnection const& TestServer::connection() const
49{
50 return p_->connection();
51}
52
53string const& TestServer::object_path() const
54{
55 return p_->object_path();
56}
57
58}
59}
60}
61}
062
=== modified file 'src/qt/client/CMakeLists.txt'
--- src/qt/client/CMakeLists.txt 2016-07-27 02:19:17 +0000
+++ src/qt/client/CMakeLists.txt 2016-08-11 06:54:57 +0000
@@ -80,7 +80,7 @@
80# Build the remote client library80# Build the remote client library
81set_source_files_properties(${CMAKE_SOURCE_DIR}/data/provider.xml PROPERTIES81set_source_files_properties(${CMAKE_SOURCE_DIR}/data/provider.xml PROPERTIES
82 CLASSNAME ProviderInterface82 CLASSNAME ProviderInterface
83 INCLUDE unity/storage/qt/client/internal/remote_client/dbusmarshal.h83 INCLUDE unity/storage/internal/dbusmarshal.h
84)84)
8585
86qt5_add_dbus_interface(generated_files86qt5_add_dbus_interface(generated_files
@@ -109,6 +109,7 @@
109 VERSION ${SF_CLIENT_LIBVERSION}109 VERSION ${SF_CLIENT_LIBVERSION}
110)110)
111target_link_libraries(storage-framework-qt-client111target_link_libraries(storage-framework-qt-client
112 storage-framework-common-internal
112 Qt5::Concurrent113 Qt5::Concurrent
113 Qt5::Core114 Qt5::Core
114 Qt5::DBus115 Qt5::DBus
115116
=== modified file 'src/qt/client/internal/remote_client/RuntimeImpl.cpp'
--- src/qt/client/internal/remote_client/RuntimeImpl.cpp 2016-08-03 06:29:48 +0000
+++ src/qt/client/internal/remote_client/RuntimeImpl.cpp 2016-08-11 06:54:57 +0000
@@ -18,11 +18,12 @@
1818
19#include <unity/storage/qt/client/internal/remote_client/RuntimeImpl.h>19#include <unity/storage/qt/client/internal/remote_client/RuntimeImpl.h>
2020
21#include <unity/storage/internal/dbusmarshal.h>
21#include <unity/storage/qt/client/Account.h>22#include <unity/storage/qt/client/Account.h>
22#include <unity/storage/qt/client/Exceptions.h>23#include <unity/storage/qt/client/Exceptions.h>
23#include <unity/storage/qt/client/internal/make_future.h>24#include <unity/storage/qt/client/internal/make_future.h>
24#include <unity/storage/qt/client/internal/remote_client/AccountImpl.h>25#include <unity/storage/qt/client/internal/remote_client/AccountImpl.h>
25#include <unity/storage/qt/client/internal/remote_client/dbusmarshal.h>26#include <unity/storage/internal/dbusmarshal.h>
2627
27#include <QDBusMetaType>28#include <QDBusMetaType>
2829
2930
=== modified file 'src/qt/client/internal/remote_client/dbusmarshal.cpp'
--- src/qt/client/internal/remote_client/dbusmarshal.cpp 2016-08-11 01:39:44 +0000
+++ src/qt/client/internal/remote_client/dbusmarshal.cpp 2016-08-11 06:54:57 +0000
@@ -37,89 +37,6 @@
37{37{
38namespace storage38namespace storage
39{39{
40namespace internal
41{
42
43QDBusArgument& operator<<(QDBusArgument& argument, storage::internal::ItemMetadata const& metadata)
44{
45 argument.beginStructure();
46 argument << metadata.item_id;
47 argument << metadata.parent_id;
48 argument << metadata.name;
49 argument << metadata.etag;
50 argument << static_cast<int32_t>(metadata.type);
51 argument.beginMap(QVariant::String, qMetaTypeId<QDBusVariant>());
52 decltype(ItemMetadata::metadata)::const_iterator i = metadata.metadata.constBegin();
53 while (i != metadata.metadata.constEnd())
54 {
55 argument.beginMapEntry();
56 argument << i.key() << QDBusVariant(i.value());
57 argument.endMapEntry();
58 ++i;
59 }
60 argument.endMap();
61 argument.endStructure();
62 return argument;
63}
64
65QDBusArgument const& operator>>(QDBusArgument const& argument, storage::internal::ItemMetadata& metadata)
66{
67 argument.beginStructure();
68 argument >> metadata.item_id;
69 argument >> metadata.parent_id;
70 argument >> metadata.name;
71 argument >> metadata.etag;
72 int32_t enum_val;
73 argument >> enum_val;
74 if (enum_val < 0 || enum_val >= int(ItemType::LAST_ENTRY__))
75 {
76 qCritical() << "unmarshaling error: impossible ItemType value: " + QString::number(enum_val);
77 return argument; // Forces error
78 }
79 metadata.type = static_cast<ItemType>(enum_val);
80 metadata.metadata.clear();
81 argument.beginMap();
82 while (!argument.atEnd())
83 {
84 QString key;
85 QVariant value;
86 argument.beginMapEntry();
87 argument >> key >> value;
88 argument.endMapEntry();
89 metadata.metadata.insert(key, value);
90 }
91 argument.endMap();
92 argument.endStructure();
93 return argument;
94}
95
96QDBusArgument& operator<<(QDBusArgument& argument, QList<storage::internal::ItemMetadata> const& md_list)
97{
98 argument.beginArray(qMetaTypeId<storage::internal::ItemMetadata>());
99 for (auto const& md : md_list)
100 {
101 argument << md;
102 }
103 argument.endArray();
104 return argument;
105}
106
107QDBusArgument const& operator>>(QDBusArgument const& argument, QList<storage::internal::ItemMetadata>& md_list)
108{
109 md_list.clear();
110 argument.beginArray();
111 while (!argument.atEnd())
112 {
113 ItemMetadata imd;
114 argument >> imd;
115 md_list.append(imd);
116 }
117 argument.endArray();
118 return argument;
119}
120
121} // namespace internal
122
123namespace qt40namespace qt
124{41{
125namespace client42namespace client
12643
=== modified file 'tests/provider-ProviderInterface/CMakeLists.txt'
--- tests/provider-ProviderInterface/CMakeLists.txt 2016-08-11 03:49:32 +0000
+++ tests/provider-ProviderInterface/CMakeLists.txt 2016-08-11 06:54:57 +0000
@@ -2,7 +2,7 @@
22
3set_source_files_properties(${CMAKE_SOURCE_DIR}/data/provider.xml PROPERTIES3set_source_files_properties(${CMAKE_SOURCE_DIR}/data/provider.xml PROPERTIES
4 CLASSNAME ProviderClient4 CLASSNAME ProviderClient
5 INCLUDE unity/storage/qt/client/internal/remote_client/dbusmarshal.h5 INCLUDE unity/storage/internal/dbusmarshal.h
6)6)
7qt5_add_dbus_interface(generated_files7qt5_add_dbus_interface(generated_files
8 ${CMAKE_SOURCE_DIR}/data/provider.xml8 ${CMAKE_SOURCE_DIR}/data/provider.xml
@@ -15,16 +15,14 @@
15add_executable(provider-ProviderInterface_test15add_executable(provider-ProviderInterface_test
16 ProviderInterface_test.cpp16 ProviderInterface_test.cpp
17 TestProvider.cpp17 TestProvider.cpp
18 ../../src/qt/client/internal/remote_client/dbusmarshal.cpp
19 ${generated_files}18 ${generated_files}
20)19)
21add_dependencies(provider-ProviderInterface_test storage-framework-provider)
22set_target_properties(provider-ProviderInterface_test PROPERTIES20set_target_properties(provider-ProviderInterface_test PROPERTIES
23 AUTOMOC TRUE21 AUTOMOC TRUE
24)22)
25target_link_libraries(provider-ProviderInterface_test23target_link_libraries(provider-ProviderInterface_test
26 storage-framework-provider-static24 storage-framework-common-internal
27 storage-framework-qt-client25 storage-framework-provider
28 Qt5::Test26 Qt5::Test
29 testutils27 testutils
30 gtest28 gtest
3129
=== modified file 'tests/provider-ProviderInterface/ProviderInterface_test.cpp'
--- tests/provider-ProviderInterface/ProviderInterface_test.cpp 2016-08-11 02:49:25 +0000
+++ tests/provider-ProviderInterface/ProviderInterface_test.cpp 2016-08-11 06:54:57 +0000
@@ -18,12 +18,7 @@
1818
19#include <unity/storage/internal/dbus_error.h>19#include <unity/storage/internal/dbus_error.h>
20#include <unity/storage/provider/ProviderBase.h>20#include <unity/storage/provider/ProviderBase.h>
21#include <unity/storage/provider/internal/DBusPeerCache.h>21#include <unity/storage/provider/testing/TestServer.h>
22#include <unity/storage/provider/internal/AccountData.h>
23#include <unity/storage/provider/internal/ProviderInterface.h>
24#include <unity/storage/provider/internal/dbusmarshal.h>
25// generated DBus service adaptor
26#include "../../src/provider/provideradaptor.h"
2722
28#include "TestProvider.h"23#include "TestProvider.h"
29#include "ProviderClient.h"24#include "ProviderClient.h"
@@ -48,7 +43,8 @@
4843
49using namespace std;44using namespace std;
50using unity::storage::ItemType;45using unity::storage::ItemType;
51using namespace unity::storage::provider;46using unity::storage::provider::ProviderBase;
47using unity::storage::provider::testing::TestServer;
5248
53namespace {49namespace {
5450
@@ -75,12 +71,9 @@
75 2, "oauth2-service");71 2, "oauth2-service");
76 ASSERT_NE(nullptr, account);72 ASSERT_NE(nullptr, account);
7773
78 auto peer_cache = make_shared<internal::DBusPeerCache>(*service_connection_);74 test_server_.reset(
79 auto account_data = make_shared<internal::AccountData>(75 new TestServer(move(provider), account,
80 move(provider), peer_cache, *service_connection_, account);76 *service_connection_, BUS_PATH.toStdString()));
81 provider_interface_.reset(new internal::ProviderInterface(account_data));
82 new ProviderAdaptor(provider_interface_.get());
83 service_connection_->registerObject(BUS_PATH, provider_interface_.get());
8477
85 client_.reset(new ProviderClient(service_connection_->baseService(),78 client_.reset(new ProviderClient(service_connection_->baseService(),
86 BUS_PATH,79 BUS_PATH,
@@ -108,7 +101,7 @@
108 void TearDown() override101 void TearDown() override
109 {102 {
110 client_.reset();103 client_.reset();
111 provider_interface_.reset();104 test_server_.reset();
112 service_connection_.reset();105 service_connection_.reset();
113 QDBusConnection::disconnectFromBus(SERVICE_CONNECTION_NAME);106 QDBusConnection::disconnectFromBus(SERVICE_CONNECTION_NAME);
114 dbus_.reset();107 dbus_.reset();
@@ -117,7 +110,7 @@
117 unique_ptr<DBusEnvironment> dbus_;110 unique_ptr<DBusEnvironment> dbus_;
118 unique_ptr<QDBusConnection> service_connection_;111 unique_ptr<QDBusConnection> service_connection_;
119 unique_ptr<OnlineAccounts::Manager> account_manager_;112 unique_ptr<OnlineAccounts::Manager> account_manager_;
120 unique_ptr<internal::ProviderInterface> provider_interface_;113 unique_ptr<TestServer> test_server_;
121 unique_ptr<ProviderClient> client_;114 unique_ptr<ProviderClient> client_;
122};115};
123116
@@ -525,8 +518,6 @@
525 QCoreApplication app(argc, argv);518 QCoreApplication app(argc, argv);
526 qDBusRegisterMetaType<unity::storage::internal::ItemMetadata>();519 qDBusRegisterMetaType<unity::storage::internal::ItemMetadata>();
527 qDBusRegisterMetaType<QList<unity::storage::internal::ItemMetadata>>();520 qDBusRegisterMetaType<QList<unity::storage::internal::ItemMetadata>>();
528 qDBusRegisterMetaType<unity::storage::provider::Item>();
529 qDBusRegisterMetaType<std::vector<unity::storage::provider::Item>>();
530 ::testing::InitGoogleTest(&argc, argv);521 ::testing::InitGoogleTest(&argc, argv);
531 return RUN_ALL_TESTS();522 return RUN_ALL_TESTS();
532}523}
533524
=== modified file 'tests/provider-ProviderInterface/TestProvider.h'
--- tests/provider-ProviderInterface/TestProvider.h 2016-08-04 10:12:01 +0000
+++ tests/provider-ProviderInterface/TestProvider.h 2016-08-11 06:54:57 +0000
@@ -21,7 +21,12 @@
21#include <unity/storage/provider/ProviderBase.h>21#include <unity/storage/provider/ProviderBase.h>
2222
23using namespace std;23using namespace std;
24using namespace unity::storage::provider;24using unity::storage::provider::Context;
25using unity::storage::provider::DownloadJob;
26using unity::storage::provider::ProviderBase;
27using unity::storage::provider::Item;
28using unity::storage::provider::ItemList;
29using unity::storage::provider::UploadJob;
2530
26class TestProvider : public ProviderBase {31class TestProvider : public ProviderBase {
27public:32public:

Subscribers

People subscribed via source and target branches