Merge lp:~online-accounts/ubuntu-system-settings-online-accounts/master into lp:ubuntu-system-settings-online-accounts
- master
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | David Barth on 2015-03-20 |
Approved revision: | 234 |
Merged at revision: | 242 |
Proposed branch: | lp:~online-accounts/ubuntu-system-settings-online-accounts/master |
Merge into: | lp:ubuntu-system-settings-online-accounts |
Diff against target: |
1002 lines (+687/-31) 19 files modified
.bzrignore (+1/-0) click-hooks/main.cpp (+28/-6) debian/changelog (+10/-0) online-accounts-service/mir-helper-stub.cpp (+9/-0) online-accounts-service/mir-helper.h (+2/-0) online-accounts-service/ui-proxy.cpp (+14/-16) online-accounts-ui/browser-request.cpp (+2/-0) online-accounts-ui/signonui-request.cpp (+9/-0) system-settings-plugin/online-accounts.settings (+2/-6) system-settings-plugin/plugin.cpp (+116/-0) system-settings-plugin/plugin.h (+36/-0) system-settings-plugin/system-settings-plugin.pro (+24/-1) tests/click-hooks/click-hooks.pro (+5/-1) tests/click-hooks/tst_online_accounts_hooks.cpp (+63/-0) tests/online-accounts-service/tst_ui_proxy.cpp (+39/-0) tests/online-accounts-service/tst_ui_proxy.pro (+1/-0) tests/system-settings-plugin/system-settings-plugin.pro (+32/-0) tests/system-settings-plugin/tst_plugin.cpp (+292/-0) tests/tests.pro (+2/-1) |
To merge this branch: | bzr merge lp:~online-accounts/ubuntu-system-settings-online-accounts/master |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve on 2015-02-23 | |
Online Accounts | 2015-02-18 | Pending | |
Review via email:
|
- 232. By Alberto Mardegan on 2015-02-18
-
From trunk
[ CI Train Bot ]
* Fix tests with Qt 5.4
[ Timo Jyrinki ]
* Use qt_gl_set_global_ share_context with Qt 5.4 (LP: #1398372) (LP:
#1398372) - 233. By Alberto Mardegan on 2015-02-18
-
fix version
- 234. By Alberto Mardegan on 2015-02-23
-
Disconnect from signal
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:234
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2014-12-11 12:51:46 +0000 | |||
3 | +++ .bzrignore 2015-02-23 09:45:54 +0000 | |||
4 | @@ -57,3 +57,4 @@ | |||
5 | 57 | /tests/online-accounts-ui/tst_notification | 57 | /tests/online-accounts-ui/tst_notification |
6 | 58 | /tests/online-accounts-ui/tst_signonui_request | 58 | /tests/online-accounts-ui/tst_signonui_request |
7 | 59 | /tests/plugin/tst_application_manager | 59 | /tests/plugin/tst_application_manager |
8 | 60 | /tests/system-settings-plugin/tst_plugin | ||
9 | 60 | 61 | ||
10 | === modified file 'click-hooks/main.cpp' | |||
11 | --- click-hooks/main.cpp 2015-01-21 15:11:36 +0000 | |||
12 | +++ click-hooks/main.cpp 2015-02-23 09:45:54 +0000 | |||
13 | @@ -217,7 +217,20 @@ | |||
14 | 217 | } | 217 | } |
15 | 218 | } | 218 | } |
16 | 219 | 219 | ||
18 | 220 | static void removeStaleFiles(const QStringList &fileTypes, | 220 | static void removeStaleAccounts(Accounts::Manager *manager, |
19 | 221 | const QString &providerName) | ||
20 | 222 | { | ||
21 | 223 | Q_FOREACH(Accounts::AccountId id, manager->accountList()) { | ||
22 | 224 | Accounts::Account *account = manager->account(id); | ||
23 | 225 | if (account->providerName() == providerName) { | ||
24 | 226 | account->remove(); | ||
25 | 227 | account->syncAndBlock(); | ||
26 | 228 | } | ||
27 | 229 | } | ||
28 | 230 | } | ||
29 | 231 | |||
30 | 232 | static void removeStaleFiles(Accounts::Manager *manager, | ||
31 | 233 | const QStringList &fileTypes, | ||
32 | 221 | const QString &localShare, | 234 | const QString &localShare, |
33 | 222 | const QDir &hooksDirIn) | 235 | const QDir &hooksDirIn) |
34 | 223 | { | 236 | { |
35 | @@ -245,8 +258,13 @@ | |||
36 | 245 | * means that the click package was removed, and we must remove our | 258 | * means that the click package was removed, and we must remove our |
37 | 246 | * copy as well. */ | 259 | * copy as well. */ |
38 | 247 | QString hookFileName = profile + "." + fileType; | 260 | QString hookFileName = profile + "." + fileType; |
41 | 248 | if (!hooksDirIn.exists(hookFileName)) { | 261 | if (hooksDirIn.exists(hookFileName)) continue; |
42 | 249 | QFile::remove(fileInfo.filePath()); | 262 | |
43 | 263 | QFile::remove(fileInfo.filePath()); | ||
44 | 264 | /* If this is a provider, we must also remove any accounts | ||
45 | 265 | * associated with it */ | ||
46 | 266 | if (fileType == QStringLiteral("provider")) { | ||
47 | 267 | removeStaleAccounts(manager, fileInfo.completeBaseName()); | ||
48 | 250 | } | 268 | } |
49 | 251 | } | 269 | } |
50 | 252 | } | 270 | } |
51 | @@ -256,6 +274,12 @@ | |||
52 | 256 | { | 274 | { |
53 | 257 | QCoreApplication app(argc, argv); | 275 | QCoreApplication app(argc, argv); |
54 | 258 | 276 | ||
55 | 277 | Accounts::Manager::Options managerOptions; | ||
56 | 278 | if (qgetenv("DBUS_SESSION_BUS_ADDRESS").isEmpty()) { | ||
57 | 279 | managerOptions |= Accounts::Manager::DisableNotifications; | ||
58 | 280 | } | ||
59 | 281 | Accounts::Manager *manager = new Accounts::Manager(managerOptions); | ||
60 | 282 | |||
61 | 259 | /* Go through the hook files in ~/.local/share/online-accounts-hooks/ and | 283 | /* Go through the hook files in ~/.local/share/online-accounts-hooks/ and |
62 | 260 | * check if they have already been processed into a file under | 284 | * check if they have already been processed into a file under |
63 | 261 | * ~/.local/share/accounts/{providers,services,service-types,applications}/; | 285 | * ~/.local/share/accounts/{providers,services,service-types,applications}/; |
64 | @@ -274,7 +298,7 @@ | |||
65 | 274 | QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); | 298 | QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); |
66 | 275 | QDir hooksDirIn(localShare + "/" HOOK_FILES_SUBDIR); | 299 | QDir hooksDirIn(localShare + "/" HOOK_FILES_SUBDIR); |
67 | 276 | 300 | ||
69 | 277 | removeStaleFiles(fileTypes, localShare, hooksDirIn); | 301 | removeStaleFiles(manager, fileTypes, localShare, hooksDirIn); |
70 | 278 | 302 | ||
71 | 279 | Q_FOREACH(const QFileInfo &fileInfo, hooksDirIn.entryInfoList()) { | 303 | Q_FOREACH(const QFileInfo &fileInfo, hooksDirIn.entryInfoList()) { |
72 | 280 | const QString fileType = fileInfo.suffix(); | 304 | const QString fileType = fileInfo.suffix(); |
73 | @@ -320,8 +344,6 @@ | |||
74 | 320 | /* To ensure that all the installed services are parsed into | 344 | /* To ensure that all the installed services are parsed into |
75 | 321 | * libaccounts' DB, we enumerate them now. | 345 | * libaccounts' DB, we enumerate them now. |
76 | 322 | */ | 346 | */ |
77 | 323 | Accounts::Manager *manager = | ||
78 | 324 | new Accounts::Manager(Accounts::Manager::DisableNotifications); | ||
79 | 325 | manager->serviceList(); | 347 | manager->serviceList(); |
80 | 326 | delete manager; | 348 | delete manager; |
81 | 327 | 349 | ||
82 | 328 | 350 | ||
83 | === modified file 'debian/changelog' | |||
84 | --- debian/changelog 2015-02-11 06:39:10 +0000 | |||
85 | +++ debian/changelog 2015-02-23 09:45:54 +0000 | |||
86 | @@ -1,3 +1,13 @@ | |||
87 | 1 | ubuntu-system-settings-online-accounts (0.6+15.04.20150211-0ubuntu2) UNRELEASED; urgency=medium | ||
88 | 2 | |||
89 | 3 | * Merge from upstream | ||
90 | 4 | - Add account data as search keywords (LP: #1373279) | ||
91 | 5 | - Delete accounts when their plugin is removed (LP: #1413542) | ||
92 | 6 | - More fixes for plugin confinement (LP: #1219644) | ||
93 | 7 | - Fail initialization if trust session cannot be setup (LP: #1420847) | ||
94 | 8 | |||
95 | 9 | -- Alberto Mardegan <alberto.mardegan@canonical.com> Wed, 18 Feb 2015 09:34:01 +0200 | ||
96 | 10 | |||
97 | 1 | ubuntu-system-settings-online-accounts (0.6+15.04.20150211-0ubuntu1) vivid; urgency=medium | 11 | ubuntu-system-settings-online-accounts (0.6+15.04.20150211-0ubuntu1) vivid; urgency=medium |
98 | 2 | 12 | ||
99 | 3 | [ CI Train Bot ] | 13 | [ CI Train Bot ] |
100 | 4 | 14 | ||
101 | === modified file 'online-accounts-service/mir-helper-stub.cpp' | |||
102 | --- online-accounts-service/mir-helper-stub.cpp 2014-11-25 13:34:16 +0000 | |||
103 | +++ online-accounts-service/mir-helper-stub.cpp 2015-02-23 09:45:54 +0000 | |||
104 | @@ -40,7 +40,11 @@ | |||
105 | 40 | 40 | ||
106 | 41 | QString PromptSession::requestSocket() | 41 | QString PromptSession::requestSocket() |
107 | 42 | { | 42 | { |
108 | 43 | #ifdef BUILDING_TESTS | ||
109 | 44 | return QString::fromUtf8(qgetenv("TEST_MIR_HELPER_SOCKET")); | ||
110 | 45 | #else | ||
111 | 43 | return QString(); | 46 | return QString(); |
112 | 47 | #endif | ||
113 | 44 | } | 48 | } |
114 | 45 | 49 | ||
115 | 46 | MirHelper::MirHelper(QObject *parent): | 50 | MirHelper::MirHelper(QObject *parent): |
116 | @@ -65,5 +69,10 @@ | |||
117 | 65 | PromptSessionP MirHelper::createPromptSession(pid_t initiatorPid) | 69 | PromptSessionP MirHelper::createPromptSession(pid_t initiatorPid) |
118 | 66 | { | 70 | { |
119 | 67 | Q_UNUSED(initiatorPid); | 71 | Q_UNUSED(initiatorPid); |
120 | 72 | #ifdef BUILDING_TESTS | ||
121 | 73 | return qgetenv("TEST_MIR_HELPER_FAIL_CREATE").isEmpty() ? | ||
122 | 74 | PromptSessionP(new PromptSession(0)) : PromptSessionP(); | ||
123 | 75 | #else | ||
124 | 68 | return PromptSessionP(); | 76 | return PromptSessionP(); |
125 | 77 | #endif | ||
126 | 69 | } | 78 | } |
127 | 70 | 79 | ||
128 | === modified file 'online-accounts-service/mir-helper.h' | |||
129 | --- online-accounts-service/mir-helper.h 2014-11-21 13:50:15 +0000 | |||
130 | +++ online-accounts-service/mir-helper.h 2015-02-23 09:45:54 +0000 | |||
131 | @@ -27,6 +27,7 @@ | |||
132 | 27 | namespace OnlineAccountsUi { | 27 | namespace OnlineAccountsUi { |
133 | 28 | 28 | ||
134 | 29 | class PromptSessionPrivate; | 29 | class PromptSessionPrivate; |
135 | 30 | class MirHelper; | ||
136 | 30 | class MirHelperPrivate; | 31 | class MirHelperPrivate; |
137 | 31 | 32 | ||
138 | 32 | class PromptSession: public QObject | 33 | class PromptSession: public QObject |
139 | @@ -45,6 +46,7 @@ | |||
140 | 45 | explicit PromptSession(PromptSessionPrivate *priv); | 46 | explicit PromptSession(PromptSessionPrivate *priv); |
141 | 46 | 47 | ||
142 | 47 | private: | 48 | private: |
143 | 49 | friend class MirHelper; | ||
144 | 48 | friend class MirHelperPrivate; | 50 | friend class MirHelperPrivate; |
145 | 49 | PromptSessionPrivate *d_ptr; | 51 | PromptSessionPrivate *d_ptr; |
146 | 50 | Q_DECLARE_PRIVATE(PromptSession) | 52 | Q_DECLARE_PRIVATE(PromptSession) |
147 | 51 | 53 | ||
148 | === modified file 'online-accounts-service/ui-proxy.cpp' | |||
149 | --- online-accounts-service/ui-proxy.cpp 2015-02-03 10:21:46 +0000 | |||
150 | +++ online-accounts-service/ui-proxy.cpp 2015-02-23 09:45:54 +0000 | |||
151 | @@ -225,6 +225,8 @@ | |||
152 | 225 | { | 225 | { |
153 | 226 | Q_Q(UiProxy); | 226 | Q_Q(UiProxy); |
154 | 227 | 227 | ||
155 | 228 | if (!m_clientPid) return false; | ||
156 | 229 | |||
157 | 228 | PromptSessionP session = | 230 | PromptSessionP session = |
158 | 229 | MirHelper::instance()->createPromptSession(m_clientPid); | 231 | MirHelper::instance()->createPromptSession(m_clientPid); |
159 | 230 | if (!session) return false; | 232 | if (!session) return false; |
160 | @@ -246,15 +248,20 @@ | |||
161 | 246 | 248 | ||
162 | 247 | bool UiProxyPrivate::init() | 249 | bool UiProxyPrivate::init() |
163 | 248 | { | 250 | { |
168 | 249 | m_arguments.clear(); | 251 | QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); |
169 | 250 | if (!m_promptSession) { | 252 | if (env.value("QT_QPA_PLATFORM").startsWith("ubuntu")) { |
170 | 251 | /* the first argument is required to be the desktop file */ | 253 | if (!setupPromptSession()) { |
171 | 252 | m_arguments.append("--desktop_file_hint=/usr/share/applications/online-accounts-ui.desktop"); | 254 | qWarning() << "Couldn't setup prompt session"; |
172 | 255 | return false; | ||
173 | 256 | } | ||
174 | 253 | } | 257 | } |
175 | 254 | 258 | ||
179 | 255 | if (m_clientPid) { | 259 | /* We also create ~/cache/online-accounts-ui/, since the plugin might not |
180 | 256 | setupPromptSession(); | 260 | * have permissions to do that. */ |
181 | 257 | } | 261 | QString userCacheDir = |
182 | 262 | QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation); | ||
183 | 263 | QDir cacheDir(userCacheDir + "/online-accounts-ui"); | ||
184 | 264 | if (!cacheDir.exists()) cacheDir.mkpath("."); | ||
185 | 258 | 265 | ||
186 | 259 | return true; | 266 | return true; |
187 | 260 | } | 267 | } |
188 | @@ -313,15 +320,6 @@ | |||
189 | 313 | m_arguments.prepend(accountsUi); | 320 | m_arguments.prepend(accountsUi); |
190 | 314 | } | 321 | } |
191 | 315 | 322 | ||
192 | 316 | QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); | ||
193 | 317 | if (env.value("QT_QPA_PLATFORM").startsWith("ubuntu")) { | ||
194 | 318 | if (!setupPromptSession()) { | ||
195 | 319 | qWarning() << "Couldn't setup prompt session"; | ||
196 | 320 | setStatus(UiProxy::Error); | ||
197 | 321 | return; | ||
198 | 322 | } | ||
199 | 323 | } | ||
200 | 324 | |||
201 | 325 | setStatus(UiProxy::Loading); | 323 | setStatus(UiProxy::Loading); |
202 | 326 | m_process.start(processName, m_arguments); | 324 | m_process.start(processName, m_arguments); |
203 | 327 | if (Q_UNLIKELY(!m_process.waitForStarted())) { | 325 | if (Q_UNLIKELY(!m_process.waitForStarted())) { |
204 | 328 | 326 | ||
205 | === modified file 'online-accounts-ui/browser-request.cpp' | |||
206 | --- online-accounts-ui/browser-request.cpp 2015-01-09 10:12:03 +0000 | |||
207 | +++ online-accounts-ui/browser-request.cpp 2015-02-23 09:45:54 +0000 | |||
208 | @@ -265,6 +265,8 @@ | |||
209 | 265 | Q_Q(BrowserRequest); | 265 | Q_Q(BrowserRequest); |
210 | 266 | 266 | ||
211 | 267 | DEBUG() << "Browser dialog closed"; | 267 | DEBUG() << "Browser dialog closed"; |
212 | 268 | QObject::disconnect(m_dialog, SIGNAL(finished(int)), | ||
213 | 269 | this, SLOT(onFinished())); | ||
214 | 268 | 270 | ||
215 | 269 | QVariantMap reply; | 271 | QVariantMap reply; |
216 | 270 | QUrl url = m_responseUrl.isEmpty() ? m_currentUrl : m_responseUrl; | 272 | QUrl url = m_responseUrl.isEmpty() ? m_currentUrl : m_responseUrl; |
217 | 271 | 273 | ||
218 | === modified file 'online-accounts-ui/signonui-request.cpp' | |||
219 | --- online-accounts-ui/signonui-request.cpp 2015-01-14 09:31:14 +0000 | |||
220 | +++ online-accounts-ui/signonui-request.cpp 2015-02-23 09:45:54 +0000 | |||
221 | @@ -33,6 +33,8 @@ | |||
222 | 33 | #include <SignOn/uisessiondata.h> | 33 | #include <SignOn/uisessiondata.h> |
223 | 34 | #include <SignOn/uisessiondata_priv.h> | 34 | #include <SignOn/uisessiondata_priv.h> |
224 | 35 | #include <sys/apparmor.h> | 35 | #include <sys/apparmor.h> |
225 | 36 | #include <sys/types.h> | ||
226 | 37 | #include <unistd.h> | ||
227 | 36 | 38 | ||
228 | 37 | using namespace SignOnUi; | 39 | using namespace SignOnUi; |
229 | 38 | 40 | ||
230 | @@ -135,6 +137,13 @@ | |||
231 | 135 | if (profile == "unconfined" && | 137 | if (profile == "unconfined" && |
232 | 136 | parameters.contains(SSOUI_KEY_PID)) { | 138 | parameters.contains(SSOUI_KEY_PID)) { |
233 | 137 | pid_t pid = parameters.value(SSOUI_KEY_PID).toUInt(); | 139 | pid_t pid = parameters.value(SSOUI_KEY_PID).toUInt(); |
234 | 140 | if (pid == getpid()) { | ||
235 | 141 | /* If the request was initiated by our own process, we might not | ||
236 | 142 | * have the rights to call the aa_* functions (we might be | ||
237 | 143 | * confined). */ | ||
238 | 144 | return QString(); | ||
239 | 145 | } | ||
240 | 146 | |||
241 | 138 | char *con = NULL, *mode = NULL; | 147 | char *con = NULL, *mode = NULL; |
242 | 139 | int ret = aa_gettaskcon(pid, &con, &mode); | 148 | int ret = aa_gettaskcon(pid, &con, &mode); |
243 | 140 | if (Q_LIKELY(ret >= 0)) { | 149 | if (Q_LIKELY(ret >= 0)) { |
244 | 141 | 150 | ||
245 | === modified file 'system-settings-plugin/online-accounts.settings' | |||
246 | --- system-settings-plugin/online-accounts.settings 2014-09-24 19:05:32 +0000 | |||
247 | +++ system-settings-plugin/online-accounts.settings 2015-02-23 09:45:54 +0000 | |||
248 | @@ -14,14 +14,10 @@ | |||
249 | 14 | "access", | 14 | "access", |
250 | 15 | "authorize", | 15 | "authorize", |
251 | 16 | "revoke", | 16 | "revoke", |
258 | 17 | "web", | 17 | "web" |
253 | 18 | "facebook", | ||
254 | 19 | "twitter", | ||
255 | 20 | "flickr", | ||
256 | 21 | "google", | ||
257 | 22 | "gmail" | ||
259 | 23 | ], | 18 | ], |
260 | 24 | "has-dynamic-keywords": true, | 19 | "has-dynamic-keywords": true, |
261 | 25 | "has-dynamic-visibility": false, | 20 | "has-dynamic-visibility": false, |
262 | 21 | "plugin": "online-accounts", | ||
263 | 26 | "page-component": "MainPage.qml" | 22 | "page-component": "MainPage.qml" |
264 | 27 | } | 23 | } |
265 | 28 | 24 | ||
266 | === added file 'system-settings-plugin/plugin.cpp' | |||
267 | --- system-settings-plugin/plugin.cpp 1970-01-01 00:00:00 +0000 | |||
268 | +++ system-settings-plugin/plugin.cpp 2015-02-23 09:45:54 +0000 | |||
269 | @@ -0,0 +1,116 @@ | |||
270 | 1 | /* | ||
271 | 2 | * Copyright (C) 2015 Canonical Ltd. | ||
272 | 3 | * | ||
273 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
274 | 5 | * | ||
275 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
276 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
277 | 8 | * by the Free Software Foundation. | ||
278 | 9 | * | ||
279 | 10 | * This program is distributed in the hope that it will be useful, but | ||
280 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
281 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
282 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
283 | 14 | * | ||
284 | 15 | * You should have received a copy of the GNU General Public License along | ||
285 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
286 | 17 | */ | ||
287 | 18 | |||
288 | 19 | #include "plugin.h" | ||
289 | 20 | |||
290 | 21 | #include <Accounts/Account> | ||
291 | 22 | #include <Accounts/Manager> | ||
292 | 23 | #include <Accounts/Provider> | ||
293 | 24 | #include <Accounts/Service> | ||
294 | 25 | #include <QDebug> | ||
295 | 26 | #include <QStringList> | ||
296 | 27 | #include <SystemSettings/ItemBase> | ||
297 | 28 | #include <libintl.h> | ||
298 | 29 | |||
299 | 30 | using namespace SystemSettings; | ||
300 | 31 | |||
301 | 32 | class Item: public ItemBase | ||
302 | 33 | { | ||
303 | 34 | Q_OBJECT | ||
304 | 35 | |||
305 | 36 | public: | ||
306 | 37 | Item(const QVariantMap &staticData, QObject *parent = 0); | ||
307 | 38 | ~Item(); | ||
308 | 39 | |||
309 | 40 | private: | ||
310 | 41 | void computeKeywords(); | ||
311 | 42 | }; | ||
312 | 43 | |||
313 | 44 | Item::Item(const QVariantMap &staticData, QObject *parent): | ||
314 | 45 | ItemBase(staticData, parent) | ||
315 | 46 | { | ||
316 | 47 | computeKeywords(); | ||
317 | 48 | } | ||
318 | 49 | |||
319 | 50 | Item::~Item() | ||
320 | 51 | { | ||
321 | 52 | } | ||
322 | 53 | |||
323 | 54 | static QStringList translations(const QString &text, const QString &domain) | ||
324 | 55 | { | ||
325 | 56 | /* Return a list of keywords based on a translatable name: | ||
326 | 57 | * - the untranslated text (lowercase, split into words) | ||
327 | 58 | * - the translated text (lowercase, split into words) | ||
328 | 59 | */ | ||
329 | 60 | QStringList keys; | ||
330 | 61 | keys = text.toLower().split(" ", QString::SkipEmptyParts); | ||
331 | 62 | if (!domain.isEmpty()) { | ||
332 | 63 | QByteArray baText = text.toUtf8(); | ||
333 | 64 | QByteArray baDomain = domain.toUtf8(); | ||
334 | 65 | QString translated = QString::fromUtf8(dgettext(baDomain.constData(), | ||
335 | 66 | baText.constData())); | ||
336 | 67 | if (translated != text) { | ||
337 | 68 | keys.append(translated.toLower().split(" ", | ||
338 | 69 | QString::SkipEmptyParts)); | ||
339 | 70 | } | ||
340 | 71 | } | ||
341 | 72 | return keys; | ||
342 | 73 | } | ||
343 | 74 | |||
344 | 75 | void Item::computeKeywords() | ||
345 | 76 | { | ||
346 | 77 | Accounts::Manager *manager = new Accounts::Manager; | ||
347 | 78 | |||
348 | 79 | QStringList keywords; | ||
349 | 80 | |||
350 | 81 | /* List available providers, and add their names to the search keywords */ | ||
351 | 82 | Q_FOREACH(const Accounts::Provider &provider, manager->providerList()) { | ||
352 | 83 | keywords.append(provider.name().toLower()); | ||
353 | 84 | keywords.append(translations(provider.displayName(), | ||
354 | 85 | provider.trCatalog())); | ||
355 | 86 | } | ||
356 | 87 | |||
357 | 88 | /* Same for services */ | ||
358 | 89 | Q_FOREACH(const Accounts::Service &service, manager->serviceList()) { | ||
359 | 90 | keywords.append(service.name().toLower()); | ||
360 | 91 | keywords.append(translations(service.displayName(), | ||
361 | 92 | service.trCatalog())); | ||
362 | 93 | } | ||
363 | 94 | |||
364 | 95 | /* Also add the account display names */ | ||
365 | 96 | Q_FOREACH(Accounts::AccountId id, manager->accountList()) { | ||
366 | 97 | Accounts::Account *account = manager->account(id); | ||
367 | 98 | if (Q_UNLIKELY(!account)) continue; | ||
368 | 99 | QString name = account->displayName().toLower(); | ||
369 | 100 | if (!name.isEmpty()) { | ||
370 | 101 | keywords.append(name); | ||
371 | 102 | } | ||
372 | 103 | } | ||
373 | 104 | |||
374 | 105 | delete manager; | ||
375 | 106 | |||
376 | 107 | setKeywords(keywords); | ||
377 | 108 | } | ||
378 | 109 | |||
379 | 110 | ItemBase *Plugin::createItem(const QVariantMap &staticData, | ||
380 | 111 | QObject *parent) | ||
381 | 112 | { | ||
382 | 113 | return new Item(staticData, parent); | ||
383 | 114 | } | ||
384 | 115 | |||
385 | 116 | #include "plugin.moc" | ||
386 | 0 | 117 | ||
387 | === added file 'system-settings-plugin/plugin.h' | |||
388 | --- system-settings-plugin/plugin.h 1970-01-01 00:00:00 +0000 | |||
389 | +++ system-settings-plugin/plugin.h 2015-02-23 09:45:54 +0000 | |||
390 | @@ -0,0 +1,36 @@ | |||
391 | 1 | /* | ||
392 | 2 | * Copyright (C) 2015 Canonical Ltd. | ||
393 | 3 | * | ||
394 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
395 | 5 | * | ||
396 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
397 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
398 | 8 | * by the Free Software Foundation. | ||
399 | 9 | * | ||
400 | 10 | * This program is distributed in the hope that it will be useful, but | ||
401 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
402 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
403 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
404 | 14 | * | ||
405 | 15 | * You should have received a copy of the GNU General Public License along | ||
406 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
407 | 17 | */ | ||
408 | 18 | |||
409 | 19 | #ifndef ONLINE_ACCOUNTS_SYSTEM_SETTINGS_PLUGIN_H | ||
410 | 20 | #define ONLINE_ACCOUNTS_SYSTEM_SETTINGS_PLUGIN_H | ||
411 | 21 | |||
412 | 22 | #include <QObject> | ||
413 | 23 | #include <SystemSettings/PluginInterface> | ||
414 | 24 | |||
415 | 25 | class Plugin: public QObject, public SystemSettings::PluginInterface2 | ||
416 | 26 | { | ||
417 | 27 | Q_OBJECT | ||
418 | 28 | Q_PLUGIN_METADATA(IID "com.ubuntu.SystemSettings.PluginInterface/2.0") | ||
419 | 29 | Q_INTERFACES(SystemSettings::PluginInterface2) | ||
420 | 30 | |||
421 | 31 | public: | ||
422 | 32 | SystemSettings::ItemBase *createItem(const QVariantMap &staticData, | ||
423 | 33 | QObject *parent = 0); | ||
424 | 34 | }; | ||
425 | 35 | |||
426 | 36 | #endif // ONLINE_ACCOUNTS_SYSTEM_SETTINGS_PLUGIN_H | ||
427 | 0 | 37 | ||
428 | === modified file 'system-settings-plugin/system-settings-plugin.pro' | |||
429 | --- system-settings-plugin/system-settings-plugin.pro 2014-08-13 13:11:06 +0000 | |||
430 | +++ system-settings-plugin/system-settings-plugin.pro 2015-02-23 09:45:54 +0000 | |||
431 | @@ -1,7 +1,27 @@ | |||
432 | 1 | include(../common-project-config.pri) | 1 | include(../common-project-config.pri) |
433 | 2 | include($${TOP_SRC_DIR}/common-vars.pri) | 2 | include($${TOP_SRC_DIR}/common-vars.pri) |
434 | 3 | 3 | ||
436 | 4 | TEMPLATE=aux | 4 | TEMPLATE=lib |
437 | 5 | TARGET = online-accounts | ||
438 | 6 | |||
439 | 7 | CONFIG += \ | ||
440 | 8 | link_pkgconfig \ | ||
441 | 9 | plugin \ | ||
442 | 10 | qt | ||
443 | 11 | |||
444 | 12 | QT += \ | ||
445 | 13 | core \ | ||
446 | 14 | qml | ||
447 | 15 | |||
448 | 16 | PKGCONFIG += \ | ||
449 | 17 | SystemSettings \ | ||
450 | 18 | accounts-qt5 | ||
451 | 19 | |||
452 | 20 | SOURCES += \ | ||
453 | 21 | plugin.cpp | ||
454 | 22 | |||
455 | 23 | HEADERS += \ | ||
456 | 24 | plugin.h | ||
457 | 5 | 25 | ||
458 | 6 | QML_SOURCES = \ | 26 | QML_SOURCES = \ |
459 | 7 | AccountEditPage.qml \ | 27 | AccountEditPage.qml \ |
460 | @@ -19,6 +39,9 @@ | |||
461 | 19 | settings.path = $${PLUGIN_MANIFEST_DIR} | 39 | settings.path = $${PLUGIN_MANIFEST_DIR} |
462 | 20 | INSTALLS += settings | 40 | INSTALLS += settings |
463 | 21 | 41 | ||
464 | 42 | target.path = $${PLUGIN_MODULE_DIR} | ||
465 | 43 | INSTALLS += target | ||
466 | 44 | |||
467 | 22 | image.files = settings-accounts.svg | 45 | image.files = settings-accounts.svg |
468 | 23 | image.path = $${PLUGIN_MANIFEST_DIR}/icons | 46 | image.path = $${PLUGIN_MANIFEST_DIR}/icons |
469 | 24 | INSTALLS += image | 47 | INSTALLS += image |
470 | 25 | 48 | ||
471 | === modified file 'tests/click-hooks/click-hooks.pro' | |||
472 | --- tests/click-hooks/click-hooks.pro 2014-05-16 09:42:06 +0000 | |||
473 | +++ tests/click-hooks/click-hooks.pro 2015-02-23 09:45:54 +0000 | |||
474 | @@ -3,13 +3,17 @@ | |||
475 | 3 | TARGET = tst_online_accounts_hooks | 3 | TARGET = tst_online_accounts_hooks |
476 | 4 | 4 | ||
477 | 5 | CONFIG += \ | 5 | CONFIG += \ |
479 | 6 | debug | 6 | debug \ |
480 | 7 | link_pkgconfig | ||
481 | 7 | 8 | ||
482 | 8 | QT += \ | 9 | QT += \ |
483 | 9 | core \ | 10 | core \ |
484 | 10 | testlib \ | 11 | testlib \ |
485 | 11 | xml | 12 | xml |
486 | 12 | 13 | ||
487 | 14 | PKGCONFIG += \ | ||
488 | 15 | accounts-qt5 | ||
489 | 16 | |||
490 | 13 | DEFINES += \ | 17 | DEFINES += \ |
491 | 14 | DEBUG_ENABLED \ | 18 | DEBUG_ENABLED \ |
492 | 15 | HOOK_PROCESS=\\\"../../click-hooks/online-accounts-hooks\\\" | 19 | HOOK_PROCESS=\\\"../../click-hooks/online-accounts-hooks\\\" |
493 | 16 | 20 | ||
494 | === modified file 'tests/click-hooks/tst_online_accounts_hooks.cpp' | |||
495 | --- tests/click-hooks/tst_online_accounts_hooks.cpp 2014-11-04 12:26:46 +0000 | |||
496 | +++ tests/click-hooks/tst_online_accounts_hooks.cpp 2015-02-23 09:45:54 +0000 | |||
497 | @@ -18,6 +18,8 @@ | |||
498 | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
499 | 19 | */ | 19 | */ |
500 | 20 | 20 | ||
501 | 21 | #include <Accounts/Account> | ||
502 | 22 | #include <Accounts/Manager> | ||
503 | 21 | #include <QDebug> | 23 | #include <QDebug> |
504 | 22 | #include <QDir> | 24 | #include <QDir> |
505 | 23 | #include <QDomDocument> | 25 | #include <QDomDocument> |
506 | @@ -42,6 +44,7 @@ | |||
507 | 42 | void testValidHooks_data(); | 44 | void testValidHooks_data(); |
508 | 43 | void testValidHooks(); | 45 | void testValidHooks(); |
509 | 44 | void testRemoval(); | 46 | void testRemoval(); |
510 | 47 | void testAccountRemoval(); | ||
511 | 45 | void testUpdate(); | 48 | void testUpdate(); |
512 | 46 | void testDesktopEntry_data(); | 49 | void testDesktopEntry_data(); |
513 | 47 | void testDesktopEntry(); | 50 | void testDesktopEntry(); |
514 | @@ -139,6 +142,8 @@ | |||
515 | 139 | { | 142 | { |
516 | 140 | qputenv("XDG_DATA_HOME", TEST_DIR); | 143 | qputenv("XDG_DATA_HOME", TEST_DIR); |
517 | 141 | qputenv("OAH_CLICK_DIR", m_packageDir.path().toUtf8()); | 144 | qputenv("OAH_CLICK_DIR", m_packageDir.path().toUtf8()); |
518 | 145 | qputenv("ACCOUNTS", TEST_DIR); | ||
519 | 146 | |||
520 | 142 | // The hook must be able to run without a D-Bus session | 147 | // The hook must be able to run without a D-Bus session |
521 | 143 | qunsetenv("DBUS_SESSION_BUS_ADDRESS"); | 148 | qunsetenv("DBUS_SESSION_BUS_ADDRESS"); |
522 | 144 | 149 | ||
523 | @@ -377,6 +382,64 @@ | |||
524 | 377 | QVERIFY(m_installDir.exists(noProfile)); | 382 | QVERIFY(m_installDir.exists(noProfile)); |
525 | 378 | } | 383 | } |
526 | 379 | 384 | ||
527 | 385 | void OnlineAccountsHooksTest::testAccountRemoval() | ||
528 | 386 | { | ||
529 | 387 | clearHooksDir(); | ||
530 | 388 | clearInstallDir(); | ||
531 | 389 | |||
532 | 390 | Accounts::Manager *manager = | ||
533 | 391 | new Accounts::Manager(Accounts::Manager::DisableNotifications); | ||
534 | 392 | |||
535 | 393 | QString stillInstalled("providers/com.ubuntu.test_StillInstalled.provider"); | ||
536 | 394 | writeInstalledFile(stillInstalled, | ||
537 | 395 | "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" | ||
538 | 396 | "<provider>\n" | ||
539 | 397 | " <profile>com-ubuntu.test_StillInstalled_2.0</profile>\n" | ||
540 | 398 | "</provider>"); | ||
541 | 399 | QVERIFY(m_installDir.exists(stillInstalled)); | ||
542 | 400 | |||
543 | 401 | writeHookFile("com-ubuntu.test_StillInstalled_2.0.provider", | ||
544 | 402 | "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" | ||
545 | 403 | "<provider>\n" | ||
546 | 404 | "</provider>"); | ||
547 | 405 | |||
548 | 406 | Accounts::Account *account = | ||
549 | 407 | manager->createAccount("com.ubuntu.test_StillInstalled"); | ||
550 | 408 | account->setDisplayName("Still alive"); | ||
551 | 409 | account->syncAndBlock(); | ||
552 | 410 | Accounts::AccountId idPreserved = account->id(); | ||
553 | 411 | QVERIFY(idPreserved > 0); | ||
554 | 412 | |||
555 | 413 | QString myProvider("providers/com.ubuntu.test_MyProvider.provider"); | ||
556 | 414 | writeInstalledFile(myProvider, | ||
557 | 415 | "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" | ||
558 | 416 | "<provider>\n" | ||
559 | 417 | " <profile>com-ubuntu.test_MyProvider_3.0</profile>\n" | ||
560 | 418 | "</provider>"); | ||
561 | 419 | QVERIFY(m_installDir.exists(myProvider)); | ||
562 | 420 | |||
563 | 421 | account = manager->createAccount("com.ubuntu.test_MyProvider"); | ||
564 | 422 | account->setDisplayName("Must die"); | ||
565 | 423 | account->syncAndBlock(); | ||
566 | 424 | Accounts::AccountId idRemoved = account->id(); | ||
567 | 425 | QVERIFY(idRemoved > 0); | ||
568 | 426 | |||
569 | 427 | delete manager; | ||
570 | 428 | |||
571 | 429 | QVERIFY(runHookProcess()); | ||
572 | 430 | |||
573 | 431 | QVERIFY(m_installDir.exists(stillInstalled)); | ||
574 | 432 | QVERIFY(!m_installDir.exists(myProvider)); | ||
575 | 433 | |||
576 | 434 | manager = new Accounts::Manager(Accounts::Manager::DisableNotifications); | ||
577 | 435 | account = manager->account(idPreserved); | ||
578 | 436 | QVERIFY(account != 0); | ||
579 | 437 | account = manager->account(idRemoved); | ||
580 | 438 | QVERIFY(account == 0); | ||
581 | 439 | |||
582 | 440 | delete manager; | ||
583 | 441 | } | ||
584 | 442 | |||
585 | 380 | void OnlineAccountsHooksTest::testUpdate() | 443 | void OnlineAccountsHooksTest::testUpdate() |
586 | 381 | { | 444 | { |
587 | 382 | clearHooksDir(); | 445 | clearHooksDir(); |
588 | 383 | 446 | ||
589 | === modified file 'tests/online-accounts-service/tst_ui_proxy.cpp' | |||
590 | --- tests/online-accounts-service/tst_ui_proxy.cpp 2014-12-03 13:42:09 +0000 | |||
591 | +++ tests/online-accounts-service/tst_ui_proxy.cpp 2015-02-23 09:45:54 +0000 | |||
592 | @@ -204,6 +204,8 @@ | |||
593 | 204 | void testRequestDelay(); | 204 | void testRequestDelay(); |
594 | 205 | void testHandler(); | 205 | void testHandler(); |
595 | 206 | void testWrapper(); | 206 | void testWrapper(); |
596 | 207 | void testTrustSessionError_data(); | ||
597 | 208 | void testTrustSessionError(); | ||
598 | 207 | 209 | ||
599 | 208 | private: | 210 | private: |
600 | 209 | QDBusConnection m_connection; | 211 | QDBusConnection m_connection; |
601 | @@ -477,6 +479,43 @@ | |||
602 | 477 | delete proxy; | 479 | delete proxy; |
603 | 478 | } | 480 | } |
604 | 479 | 481 | ||
605 | 482 | void UiProxyTest::testTrustSessionError_data() | ||
606 | 483 | { | ||
607 | 484 | QTest::addColumn<int>("clientPid"); | ||
608 | 485 | QTest::addColumn<QString>("envVar"); | ||
609 | 486 | QTest::addColumn<bool>("expectSuccess"); | ||
610 | 487 | |||
611 | 488 | QTest::newRow("PID 0") << 0 << "" << false; | ||
612 | 489 | |||
613 | 490 | QTest::newRow("fail creation") << 4 << | ||
614 | 491 | "TEST_MIR_HELPER_FAIL_CREATE=1" << false; | ||
615 | 492 | |||
616 | 493 | QTest::newRow("return empty socket") << 4 << | ||
617 | 494 | "" << false; | ||
618 | 495 | |||
619 | 496 | QTest::newRow("success") << 4 << | ||
620 | 497 | "TEST_MIR_HELPER_SOCKET=something" << true; | ||
621 | 498 | } | ||
622 | 499 | |||
623 | 500 | void UiProxyTest::testTrustSessionError() | ||
624 | 501 | { | ||
625 | 502 | QFETCH(int, clientPid); | ||
626 | 503 | QFETCH(QString, envVar); | ||
627 | 504 | QFETCH(bool, expectSuccess); | ||
628 | 505 | |||
629 | 506 | qputenv("QT_QPA_PLATFORM", "ubuntu-something"); | ||
630 | 507 | |||
631 | 508 | QStringList envVarSplit = envVar.split('='); | ||
632 | 509 | QByteArray envVarKey = envVarSplit.value(0, "").toUtf8(); | ||
633 | 510 | QByteArray envVarValue = envVarSplit.value(1, "").toUtf8(); | ||
634 | 511 | qputenv(envVarKey.constData(), envVarValue); | ||
635 | 512 | UiProxy *proxy = new UiProxy(clientPid, this); | ||
636 | 513 | QCOMPARE(proxy->init(), expectSuccess); | ||
637 | 514 | delete proxy; | ||
638 | 515 | |||
639 | 516 | qunsetenv(envVarKey.constData()); | ||
640 | 517 | } | ||
641 | 518 | |||
642 | 480 | QTEST_MAIN(UiProxyTest); | 519 | QTEST_MAIN(UiProxyTest); |
643 | 481 | 520 | ||
644 | 482 | #include "tst_ui_proxy.moc" | 521 | #include "tst_ui_proxy.moc" |
645 | 483 | 522 | ||
646 | === modified file 'tests/online-accounts-service/tst_ui_proxy.pro' | |||
647 | --- tests/online-accounts-service/tst_ui_proxy.pro 2014-12-08 16:22:39 +0000 | |||
648 | +++ tests/online-accounts-service/tst_ui_proxy.pro 2015-02-23 09:45:54 +0000 | |||
649 | @@ -13,6 +13,7 @@ | |||
650 | 13 | testlib | 13 | testlib |
651 | 14 | 14 | ||
652 | 15 | DEFINES += \ | 15 | DEFINES += \ |
653 | 16 | BUILDING_TESTS \ | ||
654 | 16 | INSTALL_BIN_DIR=\\\"$${INSTALL_PREFIX}/bin\\\" | 17 | INSTALL_BIN_DIR=\\\"$${INSTALL_PREFIX}/bin\\\" |
655 | 17 | 18 | ||
656 | 18 | PKGCONFIG += \ | 19 | PKGCONFIG += \ |
657 | 19 | 20 | ||
658 | === added directory 'tests/system-settings-plugin' | |||
659 | === added file 'tests/system-settings-plugin/system-settings-plugin.pro' | |||
660 | --- tests/system-settings-plugin/system-settings-plugin.pro 1970-01-01 00:00:00 +0000 | |||
661 | +++ tests/system-settings-plugin/system-settings-plugin.pro 2015-02-23 09:45:54 +0000 | |||
662 | @@ -0,0 +1,32 @@ | |||
663 | 1 | include(../../common-project-config.pri) | ||
664 | 2 | |||
665 | 3 | TARGET = tst_plugin | ||
666 | 4 | |||
667 | 5 | CONFIG += \ | ||
668 | 6 | debug \ | ||
669 | 7 | link_pkgconfig | ||
670 | 8 | |||
671 | 9 | QT += \ | ||
672 | 10 | core \ | ||
673 | 11 | qml \ | ||
674 | 12 | testlib | ||
675 | 13 | |||
676 | 14 | PKGCONFIG += \ | ||
677 | 15 | SystemSettings \ | ||
678 | 16 | accounts-qt5 | ||
679 | 17 | |||
680 | 18 | SYSTEM_SETTINGS_PLUGIN_DIR = $${TOP_SRC_DIR}/system-settings-plugin | ||
681 | 19 | |||
682 | 20 | INCLUDEPATH += \ | ||
683 | 21 | $${SYSTEM_SETTINGS_PLUGIN_DIR} | ||
684 | 22 | |||
685 | 23 | SOURCES += \ | ||
686 | 24 | $${SYSTEM_SETTINGS_PLUGIN_DIR}/plugin.cpp \ | ||
687 | 25 | tst_plugin.cpp | ||
688 | 26 | |||
689 | 27 | HEADERS += \ | ||
690 | 28 | $${SYSTEM_SETTINGS_PLUGIN_DIR}/plugin.h | ||
691 | 29 | |||
692 | 30 | check.commands = "xvfb-run -s '-screen 0 640x480x24' -a dbus-test-runner -t ./$${TARGET}" | ||
693 | 31 | check.depends = $${TARGET} | ||
694 | 32 | QMAKE_EXTRA_TARGETS += check | ||
695 | 0 | 33 | ||
696 | === added file 'tests/system-settings-plugin/tst_plugin.cpp' | |||
697 | --- tests/system-settings-plugin/tst_plugin.cpp 1970-01-01 00:00:00 +0000 | |||
698 | +++ tests/system-settings-plugin/tst_plugin.cpp 2015-02-23 09:45:54 +0000 | |||
699 | @@ -0,0 +1,292 @@ | |||
700 | 1 | /* | ||
701 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
702 | 3 | * | ||
703 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
704 | 5 | * | ||
705 | 6 | * This file is part of online-accounts-ui | ||
706 | 7 | * | ||
707 | 8 | * This program is free software: you can redistribute it and/or modify it | ||
708 | 9 | * under the terms of the GNU General Public License version 3, as published | ||
709 | 10 | * by the Free Software Foundation. | ||
710 | 11 | * | ||
711 | 12 | * This program is distributed in the hope that it will be useful, but | ||
712 | 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
713 | 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
714 | 15 | * PURPOSE. See the GNU General Public License for more details. | ||
715 | 16 | * | ||
716 | 17 | * You should have received a copy of the GNU General Public License along | ||
717 | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
718 | 19 | */ | ||
719 | 20 | |||
720 | 21 | #include <Accounts/Account> | ||
721 | 22 | #include <Accounts/Manager> | ||
722 | 23 | |||
723 | 24 | #include <QDebug> | ||
724 | 25 | #include <QDir> | ||
725 | 26 | #include <QDomDocument> | ||
726 | 27 | #include <QDomElement> | ||
727 | 28 | #include <QFile> | ||
728 | 29 | #include <QSignalSpy> | ||
729 | 30 | #include <QTemporaryDir> | ||
730 | 31 | #include <QTest> | ||
731 | 32 | |||
732 | 33 | #include <SystemSettings/ItemBase> | ||
733 | 34 | |||
734 | 35 | #include "plugin.h" | ||
735 | 36 | |||
736 | 37 | namespace QTest { | ||
737 | 38 | template<> | ||
738 | 39 | char *toString(const QSet<QString> &set) | ||
739 | 40 | { | ||
740 | 41 | QByteArray ba = "QSet<QString>("; | ||
741 | 42 | QStringList list = set.toList(); | ||
742 | 43 | ba += list.join(", "); | ||
743 | 44 | ba += ")"; | ||
744 | 45 | return qstrdup(ba.data()); | ||
745 | 46 | } | ||
746 | 47 | } // QTest namespace | ||
747 | 48 | |||
748 | 49 | /* mocking libintl { */ | ||
749 | 50 | static QHash<QString,QHash<QByteArray,QByteArray> > m_translations; | ||
750 | 51 | extern "C" { | ||
751 | 52 | char *dgettext(const char *domainname, const char *msgid) | ||
752 | 53 | { | ||
753 | 54 | return (char *)m_translations[domainname].value(msgid).data(); | ||
754 | 55 | } | ||
755 | 56 | char *dcgettext(const char *__domainname, const char *__msgid, int __category) | ||
756 | 57 | { | ||
757 | 58 | Q_UNUSED(__category); | ||
758 | 59 | return dgettext(__domainname, __msgid); | ||
759 | 60 | } | ||
760 | 61 | } // extern C | ||
761 | 62 | /* } mocking libintl */ | ||
762 | 63 | |||
763 | 64 | class PluginTest: public QObject | ||
764 | 65 | { | ||
765 | 66 | Q_OBJECT | ||
766 | 67 | |||
767 | 68 | struct FileData { | ||
768 | 69 | FileData() {} | ||
769 | 70 | FileData(const QString &name, const QString &domain): | ||
770 | 71 | name(name), domain(domain) {} | ||
771 | 72 | QString name; | ||
772 | 73 | QString domain; | ||
773 | 74 | }; | ||
774 | 75 | |||
775 | 76 | public: | ||
776 | 77 | PluginTest(); | ||
777 | 78 | |||
778 | 79 | private Q_SLOTS: | ||
779 | 80 | void testKeywords_data(); | ||
780 | 81 | void testKeywords(); | ||
781 | 82 | |||
782 | 83 | private: | ||
783 | 84 | void setDataDir(const QTemporaryDir &dir); | ||
784 | 85 | void writeProvider(const QString &id, const QString &name, | ||
785 | 86 | const QString &domain); | ||
786 | 87 | void writeService(const QString &id, const QString &name, | ||
787 | 88 | const QString &domain); | ||
788 | 89 | void writeLibaccountsFile(const QString &type, const QString &id, | ||
789 | 90 | const QString &name, const QString &domain); | ||
790 | 91 | void createAccount(const QString &name); | ||
791 | 92 | |||
792 | 93 | private: | ||
793 | 94 | QHash<QString,FileData> m_providersData; | ||
794 | 95 | QHash<QString,FileData> m_servicesData; | ||
795 | 96 | QDir m_dataDir; | ||
796 | 97 | }; | ||
797 | 98 | |||
798 | 99 | PluginTest::PluginTest(): | ||
799 | 100 | QObject(0) | ||
800 | 101 | { | ||
801 | 102 | m_providersData["provider_noname"] = FileData("", ""); | ||
802 | 103 | m_providersData["provider_nodomain"] = FileData("Happy", ""); | ||
803 | 104 | m_providersData["provider_translated"] = FileData("Joyful", "translations1"); | ||
804 | 105 | |||
805 | 106 | m_servicesData["service_nodomain"] = FileData("Sad", ""); | ||
806 | 107 | m_servicesData["service_translated"] = FileData("Depressed", "translations1"); | ||
807 | 108 | m_servicesData["service_translated2"] = FileData("Depressed", "translations2"); | ||
808 | 109 | |||
809 | 110 | m_translations["translations1"]["Happy"] = "Contento"; | ||
810 | 111 | m_translations["translations1"]["Joyful"] = "Gioioso"; | ||
811 | 112 | m_translations["translations1"]["Sad"] = "Triste"; | ||
812 | 113 | m_translations["translations1"]["Depressed"] = "Depresso1"; | ||
813 | 114 | m_translations["translations1"]["Black"] = "Nero"; | ||
814 | 115 | m_translations["translations1"]["White"] = "Bianco"; | ||
815 | 116 | |||
816 | 117 | m_translations["translations2"]["Depressed"] = "Depresso2"; | ||
817 | 118 | } | ||
818 | 119 | |||
819 | 120 | void PluginTest::setDataDir(const QTemporaryDir &dir) | ||
820 | 121 | { | ||
821 | 122 | QVERIFY(dir.isValid()); | ||
822 | 123 | |||
823 | 124 | m_dataDir = QDir(dir.path()); | ||
824 | 125 | |||
825 | 126 | QByteArray dataPath = dir.path().toUtf8(); | ||
826 | 127 | qputenv("ACCOUNTS", dataPath); | ||
827 | 128 | qputenv("AG_PROVIDERS", dataPath); | ||
828 | 129 | qputenv("AG_SERVICES", dataPath); | ||
829 | 130 | } | ||
830 | 131 | |||
831 | 132 | void PluginTest::writeProvider(const QString &id, const QString &name, | ||
832 | 133 | const QString &domain) | ||
833 | 134 | { | ||
834 | 135 | writeLibaccountsFile("provider", id, name, domain); | ||
835 | 136 | } | ||
836 | 137 | |||
837 | 138 | void PluginTest::writeService(const QString &id, const QString &name, | ||
838 | 139 | const QString &domain) | ||
839 | 140 | { | ||
840 | 141 | writeLibaccountsFile("service", id, name, domain); | ||
841 | 142 | } | ||
842 | 143 | |||
843 | 144 | void PluginTest::writeLibaccountsFile(const QString &type, const QString &id, | ||
844 | 145 | const QString &name, const QString &domain) | ||
845 | 146 | { | ||
846 | 147 | QDomDocument doc; | ||
847 | 148 | QDomElement root = doc.createElement(type); | ||
848 | 149 | root.setAttribute("id", id); | ||
849 | 150 | doc.appendChild(root); | ||
850 | 151 | |||
851 | 152 | QDomElement nameTag = doc.createElement("name"); | ||
852 | 153 | nameTag.appendChild(doc.createTextNode(name)); | ||
853 | 154 | root.appendChild(nameTag); | ||
854 | 155 | |||
855 | 156 | QDomElement domainTag = doc.createElement("translations"); | ||
856 | 157 | domainTag.appendChild(doc.createTextNode(domain)); | ||
857 | 158 | root.appendChild(domainTag); | ||
858 | 159 | |||
859 | 160 | if (type == "service") { | ||
860 | 161 | QDomElement typeTag = doc.createElement("type"); | ||
861 | 162 | typeTag.appendChild(doc.createTextNode("something")); | ||
862 | 163 | root.appendChild(typeTag); | ||
863 | 164 | } | ||
864 | 165 | |||
865 | 166 | QFile file(m_dataDir.filePath(id + "." + type)); | ||
866 | 167 | if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { | ||
867 | 168 | qWarning() << "Could not write file" << file.fileName(); | ||
868 | 169 | return; | ||
869 | 170 | } | ||
870 | 171 | |||
871 | 172 | file.write(doc.toString().toUtf8()); | ||
872 | 173 | } | ||
873 | 174 | |||
874 | 175 | void PluginTest::createAccount(const QString &name) | ||
875 | 176 | { | ||
876 | 177 | Accounts::Manager *manager = new Accounts::Manager; | ||
877 | 178 | |||
878 | 179 | Accounts::Account *account = manager->createAccount("any"); | ||
879 | 180 | account->setDisplayName(name); | ||
880 | 181 | account->syncAndBlock(); | ||
881 | 182 | |||
882 | 183 | delete manager; | ||
883 | 184 | } | ||
884 | 185 | |||
885 | 186 | void PluginTest::testKeywords_data() | ||
886 | 187 | { | ||
887 | 188 | QTest::addColumn<QStringList>("providers"); | ||
888 | 189 | QTest::addColumn<QStringList>("services"); | ||
889 | 190 | QTest::addColumn<QStringList>("accountNames"); | ||
890 | 191 | QTest::addColumn<QStringList>("keywords"); | ||
891 | 192 | |||
892 | 193 | QTest::newRow("provider, no name") << | ||
893 | 194 | (QStringList() << "provider_noname") << | ||
894 | 195 | QStringList() << | ||
895 | 196 | QStringList() << | ||
896 | 197 | (QStringList() << "provider_noname"); | ||
897 | 198 | |||
898 | 199 | QTest::newRow("provider, untranslated") << | ||
899 | 200 | (QStringList() << "provider_nodomain") << | ||
900 | 201 | QStringList() << | ||
901 | 202 | QStringList() << | ||
902 | 203 | (QStringList() << "provider_nodomain" << "happy"); | ||
903 | 204 | |||
904 | 205 | QTest::newRow("provider, translated") << | ||
905 | 206 | (QStringList() << "provider_translated") << | ||
906 | 207 | QStringList() << | ||
907 | 208 | QStringList() << | ||
908 | 209 | (QStringList() << "provider_translated" << "joyful" << "gioioso"); | ||
909 | 210 | |||
910 | 211 | QTest::newRow("service, untranslated") << | ||
911 | 212 | QStringList() << | ||
912 | 213 | (QStringList() << "service_nodomain") << | ||
913 | 214 | QStringList() << | ||
914 | 215 | (QStringList() << "service_nodomain" << "sad"); | ||
915 | 216 | |||
916 | 217 | QTest::newRow("service, translated 1") << | ||
917 | 218 | QStringList() << | ||
918 | 219 | (QStringList() << "service_translated") << | ||
919 | 220 | QStringList() << | ||
920 | 221 | (QStringList() << "service_translated" << "depressed" << "depresso1"); | ||
921 | 222 | |||
922 | 223 | QTest::newRow("service, translated 2") << | ||
923 | 224 | QStringList() << | ||
924 | 225 | (QStringList() << "service_translated2") << | ||
925 | 226 | QStringList() << | ||
926 | 227 | (QStringList() << "service_translated2" << "depressed" << "depresso2"); | ||
927 | 228 | |||
928 | 229 | QTest::newRow("one account, one word") << | ||
929 | 230 | QStringList() << | ||
930 | 231 | QStringList() << | ||
931 | 232 | (QStringList() << "tom@example.com") << | ||
932 | 233 | (QStringList() << "tom@example.com"); | ||
933 | 234 | |||
934 | 235 | QTest::newRow("one account, many words") << | ||
935 | 236 | QStringList() << | ||
936 | 237 | QStringList() << | ||
937 | 238 | (QStringList() << "My little sweet account") << | ||
938 | 239 | (QStringList() << "my little sweet account"); | ||
939 | 240 | |||
940 | 241 | QTest::newRow("combined") << | ||
941 | 242 | (QStringList() << "provider_translated" << "provider_nodomain") << | ||
942 | 243 | (QStringList() << "service_translated" << "service_translated2") << | ||
943 | 244 | (QStringList() << "john@invalid" << "harry@mysite.com") << | ||
944 | 245 | (QStringList() << "provider_translated" << "joyful" << "gioioso" << | ||
945 | 246 | "provider_nodomain" << "happy" << | ||
946 | 247 | "service_translated" << "depressed" << "depresso1" << | ||
947 | 248 | "service_translated2" << "depressed" << "depresso2" << | ||
948 | 249 | "john@invalid" << "harry@mysite.com"); | ||
949 | 250 | } | ||
950 | 251 | |||
951 | 252 | void PluginTest::testKeywords() | ||
952 | 253 | { | ||
953 | 254 | QFETCH(QStringList, providers); | ||
954 | 255 | QFETCH(QStringList, services); | ||
955 | 256 | QFETCH(QStringList, accountNames); | ||
956 | 257 | QFETCH(QStringList, keywords); | ||
957 | 258 | |||
958 | 259 | QTemporaryDir dataDir; | ||
959 | 260 | |||
960 | 261 | setDataDir(dataDir); | ||
961 | 262 | |||
962 | 263 | /* Create the needed files */ | ||
963 | 264 | Q_FOREACH(const QString &providerId, providers) { | ||
964 | 265 | writeProvider(providerId, | ||
965 | 266 | m_providersData[providerId].name, | ||
966 | 267 | m_providersData[providerId].domain); | ||
967 | 268 | } | ||
968 | 269 | |||
969 | 270 | Q_FOREACH(const QString &serviceId, services) { | ||
970 | 271 | writeService(serviceId, | ||
971 | 272 | m_servicesData[serviceId].name, | ||
972 | 273 | m_servicesData[serviceId].domain); | ||
973 | 274 | } | ||
974 | 275 | |||
975 | 276 | /* create the accounts */ | ||
976 | 277 | Q_FOREACH(const QString &displayName, accountNames) { | ||
977 | 278 | createAccount(displayName); | ||
978 | 279 | } | ||
979 | 280 | |||
980 | 281 | /* Now do the actual test */ | ||
981 | 282 | Plugin plugin; | ||
982 | 283 | |||
983 | 284 | SystemSettings::ItemBase *item = plugin.createItem(QVariantMap()); | ||
984 | 285 | QStringList pluginKeywords = item->keywords(); | ||
985 | 286 | |||
986 | 287 | QCOMPARE(pluginKeywords.toSet(), keywords.toSet()); | ||
987 | 288 | } | ||
988 | 289 | |||
989 | 290 | QTEST_MAIN(PluginTest); | ||
990 | 291 | |||
991 | 292 | #include "tst_plugin.moc" | ||
992 | 0 | 293 | ||
993 | === modified file 'tests/tests.pro' | |||
994 | --- tests/tests.pro 2014-10-03 14:56:11 +0000 | |||
995 | +++ tests/tests.pro 2015-02-23 09:45:54 +0000 | |||
996 | @@ -5,4 +5,5 @@ | |||
997 | 5 | client \ | 5 | client \ |
998 | 6 | online-accounts-service \ | 6 | online-accounts-service \ |
999 | 7 | online-accounts-ui \ | 7 | online-accounts-ui \ |
1001 | 8 | plugin | 8 | plugin \ |
1002 | 9 | system-settings-plugin |
PASSED: Continuous integration, rev:233 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- online- accounts- ci/198/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- vivid-touch/ 1407 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- online- accounts- vivid-amd64- ci/20 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- online- accounts- vivid-i386- ci/18 jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- runner- vivid-mako/ 1244 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 1405 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 1405/artifact/ work/output/ *zip*/output. zip s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 18142
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- system- settings- online- accounts- ci/198/ rebuild
http://