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
=== modified file 'debian/control'
--- debian/control 2015-11-02 07:28:44 +0000
+++ debian/control 2015-11-26 16:02:38 +0000
@@ -127,7 +127,6 @@
127 ${python3:Depends},127 ${python3:Depends},
128 autopilot-qt5,128 autopilot-qt5,
129 ubuntu-system-settings-online-accounts (>= ${binary:Version}),129 ubuntu-system-settings-online-accounts (>= ${binary:Version}),
130 uoa-integration-tests,
131 libqt5test5,130 libqt5test5,
132 python3-autopilot,131 python3-autopilot,
133Description: Online Accounts setup for Ubuntu Touch - tests132Description: Online Accounts setup for Ubuntu Touch - tests
134133
=== modified file 'debian/rules'
--- debian/rules 2014-10-06 08:44:37 +0000
+++ debian/rules 2015-11-26 16:02:38 +0000
@@ -15,7 +15,7 @@
1515
16override_dh_install:16override_dh_install:
17 rm -rf debian/*/usr/share/accounts/qml-plugins/example17 rm -rf debian/*/usr/share/accounts/qml-plugins/example
18 rm -rf debian/*/usr/share/accounts/providers18 rm -rf debian/*/usr/share/accounts/providers/example.provider
19 rm -rf debian/*/usr/tests19 rm -rf debian/*/usr/tests
20 dh_install --fail-missing20 dh_install --fail-missing
2121
2222
=== modified file 'debian/ubuntu-system-settings-online-accounts-autopilot.install'
--- debian/ubuntu-system-settings-online-accounts-autopilot.install 2013-09-25 11:38:44 +0000
+++ debian/ubuntu-system-settings-online-accounts-autopilot.install 2015-11-26 16:02:38 +0000
@@ -1,1 +1,2 @@
1usr/lib/python*/dist-packages/online_accounts_ui/*1usr/lib/python*/dist-packages/online_accounts_ui/*
2usr/share/accounts/
23
=== modified file 'plugins/OnlineAccountsPlugin/application-manager.cpp'
--- plugins/OnlineAccountsPlugin/application-manager.cpp 2014-11-07 08:34:05 +0000
+++ plugins/OnlineAccountsPlugin/application-manager.cpp 2015-11-26 16:02:38 +0000
@@ -205,6 +205,21 @@
205 return info;205 return info;
206}206}
207207
208QStringList ApplicationManager::usefulProviders() const
209{
210 AccountManager *manager = AccountManager::instance();
211 Accounts::ServiceList allServices = manager->serviceList();
212 QStringList providers;
213 Q_FOREACH(const Accounts::Service &service, allServices) {
214 if (providers.contains(service.provider())) continue;
215
216 if (!manager->applicationList(service).isEmpty()) {
217 providers.append(service.provider());
218 }
219 }
220 return providers;
221}
222
208QStringList223QStringList
209ApplicationManager::addApplicationToAcl(const QStringList &acl,224ApplicationManager::addApplicationToAcl(const QStringList &acl,
210 const QString &applicationId) const225 const QString &applicationId) const
211226
=== modified file 'plugins/OnlineAccountsPlugin/application-manager.h'
--- plugins/OnlineAccountsPlugin/application-manager.h 2014-10-03 14:56:11 +0000
+++ plugins/OnlineAccountsPlugin/application-manager.h 2015-11-26 16:02:38 +0000
@@ -44,6 +44,8 @@
44 const QString &profile);44 const QString &profile);
45 QVariantMap providerInfo(const QString &providerId) const;45 QVariantMap providerInfo(const QString &providerId) const;
4646
47 Q_INVOKABLE QStringList usefulProviders() const;
48
47 Q_INVOKABLE QStringList addApplicationToAcl(const QStringList &acl,49 Q_INVOKABLE QStringList addApplicationToAcl(const QStringList &acl,
48 const QString &appId) const;50 const QString &appId) const;
49 Q_INVOKABLE QStringList removeApplicationFromAcl(const QStringList &acl,51 Q_INVOKABLE QStringList removeApplicationFromAcl(const QStringList &acl,
5052
=== modified file 'system-settings-plugin/ProvidersList.qml'
--- system-settings-plugin/ProvidersList.qml 2015-10-29 13:43:52 +0000
+++ system-settings-plugin/ProvidersList.qml 2015-11-26 16:02:38 +0000
@@ -20,6 +20,7 @@
20import Ubuntu.Components 1.320import Ubuntu.Components 1.3
21import Ubuntu.Components.ListItems 1.3 as ListItem21import Ubuntu.Components.ListItems 1.3 as ListItem
22import Ubuntu.OnlineAccounts 0.122import Ubuntu.OnlineAccounts 0.1
23import Ubuntu.OnlineAccounts.Plugin 1.0
2324
24Column {25Column {
25 id: root26 id: root
@@ -33,9 +34,29 @@
33 id: providerModel34 id: providerModel
34 }35 }
3536
37 ListModel {
38 id: filteredProviderModel
39 function populate() {
40 var length = providerModel.count
41 var usefulProviders = ApplicationManager.usefulProviders()
42 for (var i = 0; i < length; i++) {
43 var providerId = providerModel.get(i, "providerId")
44 if (usefulProviders.indexOf(providerId) < 0) continue
45 var provider = {
46 "providerId": providerId,
47 "displayName": providerModel.get(i, "displayName"),
48 "iconName": providerModel.get(i, "iconName"),
49 "isSingleAccount": providerModel.get(i, "isSingleAccount"),
50 "translations": providerModel.get(i, "translations")
51 }
52 filteredProviderModel.append(provider)
53 }
54 }
55 }
56
36 Repeater {57 Repeater {
37 id: repeater58 id: repeater
38 model: providerModel59 model: filteredProviderModel
3960
40 delegate: ListItem.Standard {61 delegate: ListItem.Standard {
41 id: provider62 id: provider
@@ -73,6 +94,8 @@
73 }94 }
74 }95 }
7596
97 Component.onCompleted: filteredProviderModel.populate()
98
76 function clearPressedButtons() {99 function clearPressedButtons() {
77 for (var i = 0; i < repeater.count; i++) {100 for (var i = 0; i < repeater.count; i++) {
78 repeater.itemAt(i).activated = false101 repeater.itemAt(i).activated = false
79102
=== modified file 'tests/autopilot/autopilot.pro'
--- tests/autopilot/autopilot.pro 2014-05-27 16:15:06 +0000
+++ tests/autopilot/autopilot.pro 2015-11-26 16:02:38 +0000
@@ -4,4 +4,21 @@
44
5autopilot.path = $${INSTALL_PREFIX}/lib/python3/dist-packages/5autopilot.path = $${INSTALL_PREFIX}/lib/python3/dist-packages/
6autopilot.files = online_accounts_ui6autopilot.files = online_accounts_ui
7INSTALLS = autopilot7INSTALLS += autopilot
8
9service.path = $${INSTALL_PREFIX}/share/accounts/services
10service.files = \
11 data/ussoa-fake-service.service \
12 data/ussoa-test-login-photos.service
13INSTALLS += service
14
15provider.path = $${INSTALL_PREFIX}/share/accounts/providers
16provider.files = \
17 data/ussoa-fake-oauth.provider \
18 data/ussoa-test-login.provider
19INSTALLS += provider
20
21application.path = $${INSTALL_PREFIX}/share/accounts/applications
22application.files = \
23 data/ussoa-integration-tests.application
24INSTALLS += application
825
=== added directory 'tests/autopilot/data'
=== added file 'tests/autopilot/data/ussoa-fake-oauth.provider'
--- tests/autopilot/data/ussoa-fake-oauth.provider 1970-01-01 00:00:00 +0000
+++ tests/autopilot/data/ussoa-fake-oauth.provider 2015-11-26 16:02:38 +0000
@@ -0,0 +1,27 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<provider id="ussoa-fake-oauth">
3 <name>FakeOAuth</name>
4 <icon>fake-oauth</icon>
5 <translations>account-plugins</translations>
6 <domains>.*example\.com</domains>
7 <plugin>generic-oauth</plugin>
8
9 <template>
10 <group name="auth">
11 <setting name="method">oauth2</setting>
12 <setting name="mechanism">user_agent</setting>
13 <group name="oauth2">
14 <group name="user_agent">
15 <setting name="Host">localhost:5120</setting>
16 <setting name="AuthPath">o/oauth2/auth</setting>
17 <setting name="RedirectUri">https://localhost:5120/success.html</setting>
18
19 <setting name="ResponseType">code</setting>
20 <setting type="as" name="Scope">['read-data','write-data']</setting>
21 <setting name="ClientId">niceclientid</setting>
22 <setting name="IgnoreSslErrors" type="b">true</setting>
23 </group>
24 </group>
25 </group>
26 </template>
27</provider>
028
=== added file 'tests/autopilot/data/ussoa-fake-service.service'
--- tests/autopilot/data/ussoa-fake-service.service 1970-01-01 00:00:00 +0000
+++ tests/autopilot/data/ussoa-fake-service.service 2015-11-26 16:02:38 +0000
@@ -0,0 +1,6 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<service id="ussoa-fake-service">
3 <type>other</type>
4 <name>Integration tests</name>
5 <provider>ussoa-fake-oauth</provider>
6</service>
07
=== added file 'tests/autopilot/data/ussoa-integration-tests.application'
--- tests/autopilot/data/ussoa-integration-tests.application 1970-01-01 00:00:00 +0000
+++ tests/autopilot/data/ussoa-integration-tests.application 2015-11-26 16:02:38 +0000
@@ -0,0 +1,12 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<application id="ussoa-integration-tests">
3 <description>IntegrationTests</description>
4 <services>
5 <service id="ussoa-fake-service">
6 <description>Integration test 1</description>
7 </service>
8 <service id="ussoa-test-login-photos">
9 <description>Integration test 2</description>
10 </service>
11 </services>
12</application>
013
=== added file 'tests/autopilot/data/ussoa-test-login-photos.service'
--- tests/autopilot/data/ussoa-test-login-photos.service 1970-01-01 00:00:00 +0000
+++ tests/autopilot/data/ussoa-test-login-photos.service 2015-11-26 16:02:38 +0000
@@ -0,0 +1,6 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<service id="ussoa-test-login-photos">
3 <type>ussoa-test-photos</type>
4 <name>TestLogin Photos</name>
5 <provider>ussoa-test-login</provider>
6</service>
07
=== added file 'tests/autopilot/data/ussoa-test-login.provider'
--- tests/autopilot/data/ussoa-test-login.provider 1970-01-01 00:00:00 +0000
+++ tests/autopilot/data/ussoa-test-login.provider 2015-11-26 16:02:38 +0000
@@ -0,0 +1,14 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<provider id="ussoa-test-login">
3 <name>TestLogin</name>
4 <icon>test-login</icon>
5 <translations>account-plugins</translations>
6 <domains>.*example\.com</domains>
7
8 <template>
9 <group name="auth">
10 <setting name="method">password</setting>
11 <setting name="mechanism">password</setting>
12 </group>
13 </template>
14</provider>
015
=== modified file 'tests/plugin/tst_application_manager.cpp'
--- tests/plugin/tst_application_manager.cpp 2014-11-07 08:34:05 +0000
+++ tests/plugin/tst_application_manager.cpp 2015-11-26 16:02:38 +0000
@@ -34,6 +34,18 @@
3434
35using namespace OnlineAccountsUi;35using namespace OnlineAccountsUi;
3636
37namespace QTest {
38template<>
39char *toString(const QSet<QString> &set)
40{
41 QByteArray ba = "QSet<QString>(";
42 QStringList list = set.toList();
43 ba += list.join(", ");
44 ba += ")";
45 return qstrdup(ba.data());
46}
47} // QTest namespace
48
37class ApplicationManagerTest: public QObject49class ApplicationManagerTest: public QObject
38{50{
39 Q_OBJECT51 Q_OBJECT
@@ -54,6 +66,8 @@
54 void testApplicationFromProfile();66 void testApplicationFromProfile();
55 void testProviderInfo_data();67 void testProviderInfo_data();
56 void testProviderInfo();68 void testProviderInfo();
69 void testUsefulProviders_data();
70 void testUsefulProviders();
5771
58private:72private:
59 void clearApplicationsDir();73 void clearApplicationsDir();
@@ -123,6 +137,7 @@
123{137{
124 qputenv("ACCOUNTS", TEST_DIR);138 qputenv("ACCOUNTS", TEST_DIR);
125 qputenv("XDG_DATA_HOME", TEST_DIR);139 qputenv("XDG_DATA_HOME", TEST_DIR);
140 qputenv("XDG_DATA_DIRS", TEST_DIR);
126141
127 clearTestDir();142 clearTestDir();
128143
@@ -561,6 +576,128 @@
561 QCOMPARE(info.value("isSingleAccount").toBool(), isSingleAccount);576 QCOMPARE(info.value("isSingleAccount").toBool(), isSingleAccount);
562}577}
563578
564QTEST_MAIN(ApplicationManagerTest);579void ApplicationManagerTest::testUsefulProviders_data()
580{
581 QTest::addColumn<QStringList>("applicationIds");
582 QTest::addColumn<QStringList>("contents");
583 QTest::addColumn<QStringList>("expectedProviders");
584
585 QStringList applicationIds;
586 QStringList contents;
587 applicationIds << "com.ubuntu.test_MyApp";
588 contents <<
589 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
590 "<application id=\"com.ubuntu.test_MyApp\">\n"
591 " <description>My application</description>\n"
592 "</application>";
593 QTest::newRow("no-services") <<
594 applicationIds << contents <<
595 QStringList();
596 applicationIds.clear();
597 contents.clear();
598
599 applicationIds <<
600 "com.ubuntu.test_MyApp2";
601 contents <<
602 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
603 "<application id=\"com.ubuntu.test_MyApp2\">\n"
604 " <description>My application 2</description>\n"
605 " <service-types>\n"
606 " <service-type id=\"some type\">Do something</service-type>\n"
607 " </service-types>\n"
608 "</application>";
609 QTest::newRow("no-valid-services") <<
610 applicationIds << contents <<
611 QStringList();
612 applicationIds.clear();
613 contents.clear();
614
615 applicationIds <<
616 "com.ubuntu.test_MyApp3";
617 contents <<
618 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
619 "<application id=\"com.ubuntu.test_MyApp3\">\n"
620 " <description>My application 3</description>\n"
621 " <service-types>\n"
622 " <service-type id=\"tstemail\">\n"
623 " <description>Send email</description>\n"
624 " </service-type>\n"
625 " </service-types>\n"
626 "</application>";
627 QTest::newRow("email-services") <<
628 applicationIds << contents <<
629 (QStringList() << "cool" << "bad");
630 applicationIds.clear();
631 contents.clear();
632
633 applicationIds <<
634 "com.ubuntu.test_MyApp4";
635 contents <<
636 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
637 "<application id=\"com.ubuntu.test_MyApp4\">\n"
638 " <description>My application 4</description>\n"
639 " <services>\n"
640 " <service id=\"cool-mail\">\n"
641 " <description>Send email</description>\n"
642 " </service>\n"
643 " <service id=\"cool-sharing\">\n"
644 " <description>Share stuff</description>\n"
645 " </service>\n"
646 " </services>\n"
647 "</application>";
648 QTest::newRow("cool-services") <<
649 applicationIds << contents <<
650 (QStringList() << "cool");
651 applicationIds.clear();
652 contents.clear();
653
654 applicationIds <<
655 "com.ubuntu.test_MyApp5" <<
656 "com.ubuntu.test_MyApp6";
657 contents <<
658 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
659 "<application id=\"com.ubuntu.test_MyApp5\">\n"
660 " <description>My application 5</description>\n"
661 " <services>\n"
662 " <service id=\"cool-mail\">\n"
663 " <description>Send email</description>\n"
664 " </service>\n"
665 " </services>\n"
666 "</application>" <<
667 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
668 "<application id=\"com.ubuntu.test_MyApp6\">\n"
669 " <description>My application 6</description>\n"
670 " <services>\n"
671 " <service id=\"bad-sharing\">\n"
672 " <description>Share stuff</description>\n"
673 " </service>\n"
674 " </services>\n"
675 "</application>";
676 QTest::newRow("two apps") <<
677 applicationIds << contents <<
678 (QStringList() << "cool" << "bad");
679 applicationIds.clear();
680 contents.clear();
681}
682
683void ApplicationManagerTest::testUsefulProviders()
684{
685 clearApplicationsDir();
686
687 QFETCH(QStringList, applicationIds);
688 QFETCH(QStringList, contents);
689 QFETCH(QStringList, expectedProviders);
690
691 for (int i = 0; i < applicationIds.count(); i++) {
692 writeAccountsFile(applicationIds[i] + ".application", contents[i]);
693 }
694
695 ApplicationManager manager;
696
697 QStringList providers = manager.usefulProviders();
698 QCOMPARE(providers.toSet(), expectedProviders.toSet());
699}
700
701QTEST_GUILESS_MAIN(ApplicationManagerTest);
565702
566#include "tst_application_manager.moc"703#include "tst_application_manager.moc"
567704
=== modified file 'tests/plugin/tst_application_manager.pro'
--- tests/plugin/tst_application_manager.pro 2014-10-03 14:56:11 +0000
+++ tests/plugin/tst_application_manager.pro 2015-11-26 16:02:38 +0000
@@ -8,6 +8,7 @@
8QT += \8QT += \
9 dbus \9 dbus \
10 qml10 qml
11QT -= gui
1112
12PKGCONFIG += \13PKGCONFIG += \
13 accounts-qt514 accounts-qt5

Subscribers

People subscribed via source and target branches