Merge lp:~michihenning/storage-framework/provider-map into lp:storage-framework/devel

Proposed by Michi Henning
Status: Merged
Approved by: James Henstridge
Approved revision: 56
Merged at revision: 56
Proposed branch: lp:~michihenning/storage-framework/provider-map
Merge into: lp:storage-framework/devel
Diff against target: 85 lines (+25/-11)
2 files modified
src/qt/client/internal/remote_client/RuntimeImpl.cpp (+21/-7)
tests/remote-client/remote-client_test.cpp (+4/-4)
To merge this branch: bzr merge lp:~michihenning/storage-framework/provider-map
Reviewer Review Type Date Requested Status
unity-api-1-bot continuous-integration Approve
James Henstridge Approve
Review via email: mp+303360@code.launchpad.net

Commit message

Got rid of hard-wired bus name in RuntimeImpl.

Description of the change

Replaced hard-wired bus name in remote client with a map, so we can use it with both the demo provider and the real mcloud provider. If a provider isn't present, we ignore it and print a trace message. This is still dirty, but will have to do until we have a proper registry.

To post a comment you must log in.
Revision history for this message
James Henstridge (jamesh) wrote :

Looks good!

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

PASSED: Continuous integration, rev:56
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/80/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/419
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/425
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/332
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/332
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/332
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/262
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/262/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/262
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/262/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/262
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/262/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/262
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/262/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/262
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/262/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/262
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/262/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/262
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/262/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/262
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/262/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/262
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/262/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/qt/client/internal/remote_client/RuntimeImpl.cpp'
2--- src/qt/client/internal/remote_client/RuntimeImpl.cpp 2016-08-17 02:55:12 +0000
3+++ src/qt/client/internal/remote_client/RuntimeImpl.cpp 2016-08-19 03:21:01 +0000
4@@ -44,8 +44,14 @@
5
6 namespace
7 {
8-constexpr char BUS_NAME[] = "com.canonical.StorageFramework.Provider.ProviderTest";
9-}
10+
11+static const map<QString, QString> BUS_NAMES =
12+{
13+ { "google-drive-scope", "com.canonical.StorageFramework.Provider.ProviderTest" },
14+ { "com.canonical.scopes.mcloud_mcloud_mcloud", "com.canonical.StorageFramework.Provider.McloudProvider" }
15+};
16+
17+} // namespace
18
19 namespace unity
20 {
21@@ -130,18 +136,26 @@
22
23 timer_.stop();
24
25- static QString const service_ids[] = { "com.canonical.scopes.mcloud_mcloud_mcloud", "google-drive-scope" };
26-
27 try
28 {
29 QVector<Account::SPtr> accounts;
30- for (auto const service_id : service_ids)
31+ for (auto const map_entry : BUS_NAMES)
32 {
33+ auto service_id = map_entry.first;
34 for (auto const& a : manager_->availableAccounts(service_id))
35 {
36 auto object_path = QStringLiteral("/provider/%1").arg(a->id());
37- accounts.append(make_account(BUS_NAME, object_path,
38- "", a->serviceId(), a->displayName()));
39+ try
40+ {
41+ auto bus_name = map_entry.second;
42+ accounts.append(make_account(bus_name, object_path,
43+ "", a->serviceId(), a->displayName()));
44+
45+ }
46+ catch (LocalCommsException const& e)
47+ {
48+ qDebug() << "RuntimeImpl: ignoring non-existent provider" << a->serviceId();
49+ }
50 }
51 }
52 accounts_ = accounts;
53
54=== modified file 'tests/remote-client/remote-client_test.cpp'
55--- tests/remote-client/remote-client_test.cpp 2016-08-18 09:25:51 +0000
56+++ tests/remote-client/remote-client_test.cpp 2016-08-19 03:21:01 +0000
57@@ -52,7 +52,7 @@
58 void SetUp() override
59 {
60 dbus_.reset(new DBusEnvironment);
61- dbus_->add_demo_provider("com.canonical.scopes.mcloud_mcloud_mcloud");
62+ dbus_->add_demo_provider("google-drive-scope");
63 dbus_->start_services();
64 }
65
66@@ -121,7 +121,7 @@
67 {
68 auto acc = get_account(runtime);
69 auto roots = call(acc->roots());
70- assert(roots.size() >= 1);
71+ assert(roots.size() == 1);
72 return roots[0];
73 }
74
75@@ -157,8 +157,8 @@
76 auto acc = get_account(runtime);
77 EXPECT_EQ(runtime, acc->runtime());
78 EXPECT_EQ("", acc->owner());
79- EXPECT_EQ("com.canonical.scopes.mcloud_mcloud_mcloud", acc->owner_id());
80- EXPECT_EQ("Fake mcloud account", acc->description());
81+ EXPECT_EQ("google-drive-scope", acc->owner_id());
82+ EXPECT_EQ("Fake google account", acc->description());
83 }
84
85 TEST_F(RuntimeTest, roots)

Subscribers

People subscribed via source and target branches

to all changes: