Merge lp:~mardy/ubuntu-system-settings-online-accounts/hide-unused-plugins into lp:ubuntu-system-settings-online-accounts

Proposed by Alberto Mardegan
Status: Merged
Approved by: David Barth
Approved revision: 297
Merged at revision: 315
Proposed branch: lp:~mardy/ubuntu-system-settings-online-accounts/hide-unused-plugins
Merge into: lp:ubuntu-system-settings-online-accounts
Diff against target: 422 lines (+265/-5)
14 files modified
debian/control (+0/-1)
debian/rules (+1/-1)
debian/ubuntu-system-settings-online-accounts-autopilot.install (+1/-0)
plugins/OnlineAccountsPlugin/application-manager.cpp (+15/-0)
plugins/OnlineAccountsPlugin/application-manager.h (+2/-0)
system-settings-plugin/ProvidersList.qml (+24/-1)
tests/autopilot/autopilot.pro (+18/-1)
tests/autopilot/data/ussoa-fake-oauth.provider (+27/-0)
tests/autopilot/data/ussoa-fake-service.service (+6/-0)
tests/autopilot/data/ussoa-integration-tests.application (+12/-0)
tests/autopilot/data/ussoa-test-login-photos.service (+6/-0)
tests/autopilot/data/ussoa-test-login.provider (+14/-0)
tests/plugin/tst_application_manager.cpp (+138/-1)
tests/plugin/tst_application_manager.pro (+1/-0)
To merge this branch: bzr merge lp:~mardy/ubuntu-system-settings-online-accounts/hide-unused-plugins
Reviewer Review Type Date Requested Status
David Barth (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+272345@code.launchpad.net

Commit message

Hide providers which no application can use

Filter the provider list to include only those providers which can be used by installed applications. If there are no applications which can use a certain account, hide the relative provider from the list of creatable accounts.

Description of the change

Hide providers which no application can use

Filter the provider list to include only those providers which can be used by installed applications. If there are no applications which can use a certain account, hide the relative provider from the list of creatable accounts.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
David Barth (dbarth) :
review: Approve
298. By Alberto Mardegan

Fix autopilot tests

Copy the files from the uoa-integration-tests package, which is no longer needed.

299. By Alberto Mardegan

Merge trunk

[ Alberto Mardegan ]
* Retry authentication on network errors (LP: #1504099, #1349975)
[ Alberto Mardegan ]
* Use version 1.3 of Ubuntu.Components (LP: #1508363, #1511055)
[ CI Train Bot ]
* Resync trunk.
[ Alberto Mardegan ]
* Regenerate hooks whenever file time changes (LP: #1510640)
[ CI Train Bot ]
* Resync trunk. added: po/hi.po
[ Alberto Mardegan ]
* Simplify hooks, load v2api library added: click-hooks/accounts.cpp
  click-hooks/accounts.hook.in click-hooks/acl-updater.cpp click-
  hooks/acl-updater.h click-hooks/click-hooks.pro click-hooks/online-
  accounts-hooks2.pro online-accounts-
  service/com.ubuntu.OnlineAccounts.Manager.service.in tests/click-
  hooks/click-hooks.pro tests/click-hooks/fake_signond.h tests/click-
  hooks/signond.py tests/click-hooks/tst_online_accounts_hooks2.cpp
  tests/click-hooks/tst_online_accounts_hooks2.pro renamed: click-
  hooks/click-hooks.pro => click-hooks/online-accounts-hooks.pro
  tests/click-hooks/click-hooks.pro => tests/click-
  hooks/tst_online_accounts_hooks.pro
[ CI Train Bot ]
* Resync trunk. added: po/mr.po po/th.po

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2015-11-02 07:28:44 +0000
3+++ debian/control 2015-11-26 16:02:38 +0000
4@@ -127,7 +127,6 @@
5 ${python3:Depends},
6 autopilot-qt5,
7 ubuntu-system-settings-online-accounts (>= ${binary:Version}),
8- uoa-integration-tests,
9 libqt5test5,
10 python3-autopilot,
11 Description: Online Accounts setup for Ubuntu Touch - tests
12
13=== modified file 'debian/rules'
14--- debian/rules 2014-10-06 08:44:37 +0000
15+++ debian/rules 2015-11-26 16:02:38 +0000
16@@ -15,7 +15,7 @@
17
18 override_dh_install:
19 rm -rf debian/*/usr/share/accounts/qml-plugins/example
20- rm -rf debian/*/usr/share/accounts/providers
21+ rm -rf debian/*/usr/share/accounts/providers/example.provider
22 rm -rf debian/*/usr/tests
23 dh_install --fail-missing
24
25
26=== modified file 'debian/ubuntu-system-settings-online-accounts-autopilot.install'
27--- debian/ubuntu-system-settings-online-accounts-autopilot.install 2013-09-25 11:38:44 +0000
28+++ debian/ubuntu-system-settings-online-accounts-autopilot.install 2015-11-26 16:02:38 +0000
29@@ -1,1 +1,2 @@
30 usr/lib/python*/dist-packages/online_accounts_ui/*
31+usr/share/accounts/
32
33=== modified file 'plugins/OnlineAccountsPlugin/application-manager.cpp'
34--- plugins/OnlineAccountsPlugin/application-manager.cpp 2014-11-07 08:34:05 +0000
35+++ plugins/OnlineAccountsPlugin/application-manager.cpp 2015-11-26 16:02:38 +0000
36@@ -205,6 +205,21 @@
37 return info;
38 }
39
40+QStringList ApplicationManager::usefulProviders() const
41+{
42+ AccountManager *manager = AccountManager::instance();
43+ Accounts::ServiceList allServices = manager->serviceList();
44+ QStringList providers;
45+ Q_FOREACH(const Accounts::Service &service, allServices) {
46+ if (providers.contains(service.provider())) continue;
47+
48+ if (!manager->applicationList(service).isEmpty()) {
49+ providers.append(service.provider());
50+ }
51+ }
52+ return providers;
53+}
54+
55 QStringList
56 ApplicationManager::addApplicationToAcl(const QStringList &acl,
57 const QString &applicationId) const
58
59=== modified file 'plugins/OnlineAccountsPlugin/application-manager.h'
60--- plugins/OnlineAccountsPlugin/application-manager.h 2014-10-03 14:56:11 +0000
61+++ plugins/OnlineAccountsPlugin/application-manager.h 2015-11-26 16:02:38 +0000
62@@ -44,6 +44,8 @@
63 const QString &profile);
64 QVariantMap providerInfo(const QString &providerId) const;
65
66+ Q_INVOKABLE QStringList usefulProviders() const;
67+
68 Q_INVOKABLE QStringList addApplicationToAcl(const QStringList &acl,
69 const QString &appId) const;
70 Q_INVOKABLE QStringList removeApplicationFromAcl(const QStringList &acl,
71
72=== modified file 'system-settings-plugin/ProvidersList.qml'
73--- system-settings-plugin/ProvidersList.qml 2015-10-29 13:43:52 +0000
74+++ system-settings-plugin/ProvidersList.qml 2015-11-26 16:02:38 +0000
75@@ -20,6 +20,7 @@
76 import Ubuntu.Components 1.3
77 import Ubuntu.Components.ListItems 1.3 as ListItem
78 import Ubuntu.OnlineAccounts 0.1
79+import Ubuntu.OnlineAccounts.Plugin 1.0
80
81 Column {
82 id: root
83@@ -33,9 +34,29 @@
84 id: providerModel
85 }
86
87+ ListModel {
88+ id: filteredProviderModel
89+ function populate() {
90+ var length = providerModel.count
91+ var usefulProviders = ApplicationManager.usefulProviders()
92+ for (var i = 0; i < length; i++) {
93+ var providerId = providerModel.get(i, "providerId")
94+ if (usefulProviders.indexOf(providerId) < 0) continue
95+ var provider = {
96+ "providerId": providerId,
97+ "displayName": providerModel.get(i, "displayName"),
98+ "iconName": providerModel.get(i, "iconName"),
99+ "isSingleAccount": providerModel.get(i, "isSingleAccount"),
100+ "translations": providerModel.get(i, "translations")
101+ }
102+ filteredProviderModel.append(provider)
103+ }
104+ }
105+ }
106+
107 Repeater {
108 id: repeater
109- model: providerModel
110+ model: filteredProviderModel
111
112 delegate: ListItem.Standard {
113 id: provider
114@@ -73,6 +94,8 @@
115 }
116 }
117
118+ Component.onCompleted: filteredProviderModel.populate()
119+
120 function clearPressedButtons() {
121 for (var i = 0; i < repeater.count; i++) {
122 repeater.itemAt(i).activated = false
123
124=== modified file 'tests/autopilot/autopilot.pro'
125--- tests/autopilot/autopilot.pro 2014-05-27 16:15:06 +0000
126+++ tests/autopilot/autopilot.pro 2015-11-26 16:02:38 +0000
127@@ -4,4 +4,21 @@
128
129 autopilot.path = $${INSTALL_PREFIX}/lib/python3/dist-packages/
130 autopilot.files = online_accounts_ui
131-INSTALLS = autopilot
132+INSTALLS += autopilot
133+
134+service.path = $${INSTALL_PREFIX}/share/accounts/services
135+service.files = \
136+ data/ussoa-fake-service.service \
137+ data/ussoa-test-login-photos.service
138+INSTALLS += service
139+
140+provider.path = $${INSTALL_PREFIX}/share/accounts/providers
141+provider.files = \
142+ data/ussoa-fake-oauth.provider \
143+ data/ussoa-test-login.provider
144+INSTALLS += provider
145+
146+application.path = $${INSTALL_PREFIX}/share/accounts/applications
147+application.files = \
148+ data/ussoa-integration-tests.application
149+INSTALLS += application
150
151=== added directory 'tests/autopilot/data'
152=== added file 'tests/autopilot/data/ussoa-fake-oauth.provider'
153--- tests/autopilot/data/ussoa-fake-oauth.provider 1970-01-01 00:00:00 +0000
154+++ tests/autopilot/data/ussoa-fake-oauth.provider 2015-11-26 16:02:38 +0000
155@@ -0,0 +1,27 @@
156+<?xml version="1.0" encoding="UTF-8"?>
157+<provider id="ussoa-fake-oauth">
158+ <name>FakeOAuth</name>
159+ <icon>fake-oauth</icon>
160+ <translations>account-plugins</translations>
161+ <domains>.*example\.com</domains>
162+ <plugin>generic-oauth</plugin>
163+
164+ <template>
165+ <group name="auth">
166+ <setting name="method">oauth2</setting>
167+ <setting name="mechanism">user_agent</setting>
168+ <group name="oauth2">
169+ <group name="user_agent">
170+ <setting name="Host">localhost:5120</setting>
171+ <setting name="AuthPath">o/oauth2/auth</setting>
172+ <setting name="RedirectUri">https://localhost:5120/success.html</setting>
173+
174+ <setting name="ResponseType">code</setting>
175+ <setting type="as" name="Scope">['read-data','write-data']</setting>
176+ <setting name="ClientId">niceclientid</setting>
177+ <setting name="IgnoreSslErrors" type="b">true</setting>
178+ </group>
179+ </group>
180+ </group>
181+ </template>
182+</provider>
183
184=== added file 'tests/autopilot/data/ussoa-fake-service.service'
185--- tests/autopilot/data/ussoa-fake-service.service 1970-01-01 00:00:00 +0000
186+++ tests/autopilot/data/ussoa-fake-service.service 2015-11-26 16:02:38 +0000
187@@ -0,0 +1,6 @@
188+<?xml version="1.0" encoding="UTF-8"?>
189+<service id="ussoa-fake-service">
190+ <type>other</type>
191+ <name>Integration tests</name>
192+ <provider>ussoa-fake-oauth</provider>
193+</service>
194
195=== added file 'tests/autopilot/data/ussoa-integration-tests.application'
196--- tests/autopilot/data/ussoa-integration-tests.application 1970-01-01 00:00:00 +0000
197+++ tests/autopilot/data/ussoa-integration-tests.application 2015-11-26 16:02:38 +0000
198@@ -0,0 +1,12 @@
199+<?xml version="1.0" encoding="UTF-8"?>
200+<application id="ussoa-integration-tests">
201+ <description>IntegrationTests</description>
202+ <services>
203+ <service id="ussoa-fake-service">
204+ <description>Integration test 1</description>
205+ </service>
206+ <service id="ussoa-test-login-photos">
207+ <description>Integration test 2</description>
208+ </service>
209+ </services>
210+</application>
211
212=== added file 'tests/autopilot/data/ussoa-test-login-photos.service'
213--- tests/autopilot/data/ussoa-test-login-photos.service 1970-01-01 00:00:00 +0000
214+++ tests/autopilot/data/ussoa-test-login-photos.service 2015-11-26 16:02:38 +0000
215@@ -0,0 +1,6 @@
216+<?xml version="1.0" encoding="UTF-8"?>
217+<service id="ussoa-test-login-photos">
218+ <type>ussoa-test-photos</type>
219+ <name>TestLogin Photos</name>
220+ <provider>ussoa-test-login</provider>
221+</service>
222
223=== added file 'tests/autopilot/data/ussoa-test-login.provider'
224--- tests/autopilot/data/ussoa-test-login.provider 1970-01-01 00:00:00 +0000
225+++ tests/autopilot/data/ussoa-test-login.provider 2015-11-26 16:02:38 +0000
226@@ -0,0 +1,14 @@
227+<?xml version="1.0" encoding="UTF-8"?>
228+<provider id="ussoa-test-login">
229+ <name>TestLogin</name>
230+ <icon>test-login</icon>
231+ <translations>account-plugins</translations>
232+ <domains>.*example\.com</domains>
233+
234+ <template>
235+ <group name="auth">
236+ <setting name="method">password</setting>
237+ <setting name="mechanism">password</setting>
238+ </group>
239+ </template>
240+</provider>
241
242=== modified file 'tests/plugin/tst_application_manager.cpp'
243--- tests/plugin/tst_application_manager.cpp 2014-11-07 08:34:05 +0000
244+++ tests/plugin/tst_application_manager.cpp 2015-11-26 16:02:38 +0000
245@@ -34,6 +34,18 @@
246
247 using namespace OnlineAccountsUi;
248
249+namespace QTest {
250+template<>
251+char *toString(const QSet<QString> &set)
252+{
253+ QByteArray ba = "QSet<QString>(";
254+ QStringList list = set.toList();
255+ ba += list.join(", ");
256+ ba += ")";
257+ return qstrdup(ba.data());
258+}
259+} // QTest namespace
260+
261 class ApplicationManagerTest: public QObject
262 {
263 Q_OBJECT
264@@ -54,6 +66,8 @@
265 void testApplicationFromProfile();
266 void testProviderInfo_data();
267 void testProviderInfo();
268+ void testUsefulProviders_data();
269+ void testUsefulProviders();
270
271 private:
272 void clearApplicationsDir();
273@@ -123,6 +137,7 @@
274 {
275 qputenv("ACCOUNTS", TEST_DIR);
276 qputenv("XDG_DATA_HOME", TEST_DIR);
277+ qputenv("XDG_DATA_DIRS", TEST_DIR);
278
279 clearTestDir();
280
281@@ -561,6 +576,128 @@
282 QCOMPARE(info.value("isSingleAccount").toBool(), isSingleAccount);
283 }
284
285-QTEST_MAIN(ApplicationManagerTest);
286+void ApplicationManagerTest::testUsefulProviders_data()
287+{
288+ QTest::addColumn<QStringList>("applicationIds");
289+ QTest::addColumn<QStringList>("contents");
290+ QTest::addColumn<QStringList>("expectedProviders");
291+
292+ QStringList applicationIds;
293+ QStringList contents;
294+ applicationIds << "com.ubuntu.test_MyApp";
295+ contents <<
296+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
297+ "<application id=\"com.ubuntu.test_MyApp\">\n"
298+ " <description>My application</description>\n"
299+ "</application>";
300+ QTest::newRow("no-services") <<
301+ applicationIds << contents <<
302+ QStringList();
303+ applicationIds.clear();
304+ contents.clear();
305+
306+ applicationIds <<
307+ "com.ubuntu.test_MyApp2";
308+ contents <<
309+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
310+ "<application id=\"com.ubuntu.test_MyApp2\">\n"
311+ " <description>My application 2</description>\n"
312+ " <service-types>\n"
313+ " <service-type id=\"some type\">Do something</service-type>\n"
314+ " </service-types>\n"
315+ "</application>";
316+ QTest::newRow("no-valid-services") <<
317+ applicationIds << contents <<
318+ QStringList();
319+ applicationIds.clear();
320+ contents.clear();
321+
322+ applicationIds <<
323+ "com.ubuntu.test_MyApp3";
324+ contents <<
325+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
326+ "<application id=\"com.ubuntu.test_MyApp3\">\n"
327+ " <description>My application 3</description>\n"
328+ " <service-types>\n"
329+ " <service-type id=\"tstemail\">\n"
330+ " <description>Send email</description>\n"
331+ " </service-type>\n"
332+ " </service-types>\n"
333+ "</application>";
334+ QTest::newRow("email-services") <<
335+ applicationIds << contents <<
336+ (QStringList() << "cool" << "bad");
337+ applicationIds.clear();
338+ contents.clear();
339+
340+ applicationIds <<
341+ "com.ubuntu.test_MyApp4";
342+ contents <<
343+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
344+ "<application id=\"com.ubuntu.test_MyApp4\">\n"
345+ " <description>My application 4</description>\n"
346+ " <services>\n"
347+ " <service id=\"cool-mail\">\n"
348+ " <description>Send email</description>\n"
349+ " </service>\n"
350+ " <service id=\"cool-sharing\">\n"
351+ " <description>Share stuff</description>\n"
352+ " </service>\n"
353+ " </services>\n"
354+ "</application>";
355+ QTest::newRow("cool-services") <<
356+ applicationIds << contents <<
357+ (QStringList() << "cool");
358+ applicationIds.clear();
359+ contents.clear();
360+
361+ applicationIds <<
362+ "com.ubuntu.test_MyApp5" <<
363+ "com.ubuntu.test_MyApp6";
364+ contents <<
365+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
366+ "<application id=\"com.ubuntu.test_MyApp5\">\n"
367+ " <description>My application 5</description>\n"
368+ " <services>\n"
369+ " <service id=\"cool-mail\">\n"
370+ " <description>Send email</description>\n"
371+ " </service>\n"
372+ " </services>\n"
373+ "</application>" <<
374+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
375+ "<application id=\"com.ubuntu.test_MyApp6\">\n"
376+ " <description>My application 6</description>\n"
377+ " <services>\n"
378+ " <service id=\"bad-sharing\">\n"
379+ " <description>Share stuff</description>\n"
380+ " </service>\n"
381+ " </services>\n"
382+ "</application>";
383+ QTest::newRow("two apps") <<
384+ applicationIds << contents <<
385+ (QStringList() << "cool" << "bad");
386+ applicationIds.clear();
387+ contents.clear();
388+}
389+
390+void ApplicationManagerTest::testUsefulProviders()
391+{
392+ clearApplicationsDir();
393+
394+ QFETCH(QStringList, applicationIds);
395+ QFETCH(QStringList, contents);
396+ QFETCH(QStringList, expectedProviders);
397+
398+ for (int i = 0; i < applicationIds.count(); i++) {
399+ writeAccountsFile(applicationIds[i] + ".application", contents[i]);
400+ }
401+
402+ ApplicationManager manager;
403+
404+ QStringList providers = manager.usefulProviders();
405+ QCOMPARE(providers.toSet(), expectedProviders.toSet());
406+}
407+
408+QTEST_GUILESS_MAIN(ApplicationManagerTest);
409
410 #include "tst_application_manager.moc"
411
412=== modified file 'tests/plugin/tst_application_manager.pro'
413--- tests/plugin/tst_application_manager.pro 2014-10-03 14:56:11 +0000
414+++ tests/plugin/tst_application_manager.pro 2015-11-26 16:02:38 +0000
415@@ -8,6 +8,7 @@
416 QT += \
417 dbus \
418 qml
419+QT -= gui
420
421 PKGCONFIG += \
422 accounts-qt5

Subscribers

People subscribed via source and target branches