Merge lp:~boiko/telephony-service/clear_call_notifications into lp:telephony-service
- clear_call_notifications
- Merge into trunk
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~boiko/telephony-service/clear_call_notifications | ||||
Merge into: | lp:telephony-service | ||||
Diff against target: |
1042 lines (+684/-15) 26 files modified
.bzrignore (+1/-1) Ubuntu/Telephony/components.cpp (+2/-0) cmake/modules/GenerateTest.cmake (+2/-1) indicator/Indicator.xml (+6/-0) indicator/indicatordbus.cpp (+6/-0) indicator/indicatordbus.h (+1/-0) indicator/messagingmenu.cpp (+32/-1) indicator/messagingmenu.h (+1/-0) libtelephonyservice/applicationutils.cpp (+1/-0) libtelephonyservice/applicationutils.h (+0/-1) libtelephonyservice/callnotification.cpp (+9/-6) libtelephonyservice/callnotification.h (+3/-0) tests/CMakeLists.txt (+1/-0) tests/common/CMakeLists.txt (+3/-2) tests/common/telepathytest.cpp (+5/-0) tests/common/telepathytest.h (+5/-0) tests/handler/CMakeLists.txt (+1/-0) tests/indicator/CMakeLists.txt (+14/-0) tests/indicator/MessagingMenuTest.cpp (+86/-0) tests/indicator/messagingmenumock.cpp (+300/-0) tests/indicator/messagingmenumock.h (+57/-0) tests/libtelephonyservice/CMakeLists.txt (+10/-0) tests/libtelephonyservice/CallNotificationTest.cpp (+67/-0) tests/libtelephonyservice/ChatManagerTest.cpp (+2/-0) tests/libtelephonyservice/IndicatorMock.cpp (+66/-0) tests/libtelephonyservice/TelepathyHelperTest.cpp (+3/-3) |
||||
To merge this branch: | bzr merge lp:~boiko/telephony-service/clear_call_notifications | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tiago Salem Herrmann (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+259830@code.launchpad.net |
This proposal has been superseded by a proposal from 2015-06-08.
Commit message
Make it possible to remove call notifications from the messaging menu
Description of the change
Make it possible to remove call notifications from the messaging menu
== Checklist ==
Are there any related MPs required for this MP to build/function as expected? Please list.
No
Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
Yes
Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
Yes
Did you successfully run all tests found in your component's Test Plan (https:/
Yes
If you changed the UI, was the change specified/approved by design?
N/A
If you changed UI labels, did you update the pot file?
N/A
If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?
N/A
- 1078. By Gustavo Pichorim Boiko
-
Merge latest changes from trunk.
- 1079. By Gustavo Pichorim Boiko
-
Fix build when srcdir != builddir
PS Jenkins bot (ps-jenkins) wrote : | # |
- 1080. By Gustavo Pichorim Boiko
-
Fix the property installing on the messaging menu mock.
Tiago Salem Herrmann (tiagosh) : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1080
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 1081. By Gustavo Pichorim Boiko
-
Add missing copyright headers and remove some commented out include files.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1081
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 1082. By Gustavo Pichorim Boiko
-
Use the memory contacts backend in the messaging menu test.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1082
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1083. By Gustavo Pichorim Boiko
-
Workaround a test failure that happens only on arm64.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1083
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Tiago Salem Herrmann (tiagosh) wrote : | # |
Looks good.
--Checklist--
Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
Yes
Did CI run pass? If not, please explain why.
Yes
Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
Yes
- 1084. By Gustavo Pichorim Boiko
-
Merge latest changes from trunk.
- 1085. By Gustavo Pichorim Boiko
-
Revert the TelepathyHelperTest fix, it is being fixed in a separate MP.
- 1086. By Gustavo Pichorim Boiko
-
Merge test fixing branch.
- 1087. By Gustavo Pichorim Boiko
-
Merge latest changes from parent branch.
- 1088. By Gustavo Pichorim Boiko
-
Fix building.
Unmerged revisions
Preview Diff
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2015-05-07 16:44:43 +0000 |
3 | +++ .bzrignore 2015-06-08 18:29:15 +0000 |
4 | @@ -55,4 +55,4 @@ |
5 | tests/Ubuntu.Telephony/ContactWatcherTest |
6 | tests/libtelephonyservice/GreeterContactsTestExe |
7 | tests/libtelephonyservice/GreeterContactsTestServerExe |
8 | -tests/libtelephonyservice/ToneGeneratorMock |
9 | +tests/libtelephonyservice/*Mock |
10 | |
11 | === modified file 'Ubuntu/Telephony/components.cpp' |
12 | --- Ubuntu/Telephony/components.cpp 2015-04-16 22:26:23 +0000 |
13 | +++ Ubuntu/Telephony/components.cpp 2015-06-08 18:29:15 +0000 |
14 | @@ -24,6 +24,7 @@ |
15 | #include "telepathyhelper.h" |
16 | #include "callentry.h" |
17 | #include "callmanager.h" |
18 | +#include "callnotification.h" |
19 | #include "ussdmanager.h" |
20 | #include "channelobserver.h" |
21 | #include "chatmanager.h" |
22 | @@ -55,6 +56,7 @@ |
23 | mRootContext->setContextProperty("chatManager", ChatManager::instance()); |
24 | mRootContext->setContextProperty("callManager", CallManager::instance()); |
25 | mRootContext->setContextProperty("greeter", GreeterContacts::instance()); |
26 | + mRootContext->setContextProperty("callNotification", CallNotification::instance()); |
27 | |
28 | } |
29 | |
30 | |
31 | === modified file 'cmake/modules/GenerateTest.cmake' |
32 | --- cmake/modules/GenerateTest.cmake 2015-05-07 20:36:24 +0000 |
33 | +++ cmake/modules/GenerateTest.cmake 2015-06-08 18:29:15 +0000 |
34 | @@ -76,7 +76,8 @@ |
35 | set(ARG_ENVIRONMENT HOME=${TMPDIR} |
36 | HISTORY_SQLITE_DBPATH=:memory: |
37 | MC_ACCOUNT_DIR=${TMPDIR} |
38 | - MC_MANAGER_DIR=${TMPDIR}) |
39 | + MC_MANAGER_DIR=${TMPDIR} |
40 | + MC_CLIENTS_DIR=${TMPDIR}) |
41 | endif () |
42 | |
43 | set(TEST_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME} ${PLATFORM} -p -o -p -,txt -p -o -p ${CMAKE_BINARY_DIR}/test_${TESTNAME}.xml,xunitxml) |
44 | |
45 | === modified file 'indicator/Indicator.xml' |
46 | --- indicator/Indicator.xml 2015-04-28 19:18:55 +0000 |
47 | +++ indicator/Indicator.xml 2015-06-08 18:29:15 +0000 |
48 | @@ -14,5 +14,11 @@ |
49 | Remove any notification currently being displayed. |
50 | ]]></dox:d> |
51 | </method> |
52 | + <method name="ClearCallNotification"> |
53 | + <dox:d><![CDATA[ |
54 | + Remove notifications for the given call |
55 | + ]]></dox:d> |
56 | + <arg name="targetId" type="s" direction="in"/> |
57 | + <arg name="accountId" type="s" direction="in"/> |
58 | </interface> |
59 | </node> |
60 | |
61 | === modified file 'indicator/indicatordbus.cpp' |
62 | --- indicator/indicatordbus.cpp 2015-04-29 14:56:59 +0000 |
63 | +++ indicator/indicatordbus.cpp 2015-06-08 18:29:15 +0000 |
64 | @@ -23,6 +23,7 @@ |
65 | |
66 | #include "indicatordbus.h" |
67 | #include "indicatoradaptor.h" |
68 | +#include "messagingmenu.h" |
69 | |
70 | // Qt |
71 | #include <QtDBus/QDBusConnection> |
72 | @@ -57,3 +58,8 @@ |
73 | Q_EMIT clearNotificationsRequested(); |
74 | } |
75 | |
76 | +void IndicatorDBus::ClearCallNotification(const QString &targetId, const QString &accountId) |
77 | +{ |
78 | + MessagingMenu::instance()->removeCall(targetId, accountId); |
79 | +} |
80 | + |
81 | |
82 | === modified file 'indicator/indicatordbus.h' |
83 | --- indicator/indicatordbus.h 2015-04-29 14:56:59 +0000 |
84 | +++ indicator/indicatordbus.h 2015-06-08 18:29:15 +0000 |
85 | @@ -43,6 +43,7 @@ |
86 | |
87 | public Q_SLOTS: |
88 | Q_NOREPLY void ClearNotifications(); |
89 | + Q_NOREPLY void ClearCallNotification(const QString &targetId, const QString &accountId); |
90 | |
91 | Q_SIGNALS: |
92 | void clearNotificationsRequested(); |
93 | |
94 | === modified file 'indicator/messagingmenu.cpp' |
95 | --- indicator/messagingmenu.cpp 2015-03-04 18:02:13 +0000 |
96 | +++ indicator/messagingmenu.cpp 2015-06-08 18:29:15 +0000 |
97 | @@ -310,13 +310,17 @@ |
98 | QContactFetchRequest *request = new QContactFetchRequest(this); |
99 | request->setFilter(QContactPhoneNumber::match(targetId)); |
100 | |
101 | + //FIXME: on arm64 the connect() statement below fails at runtime with the following output: |
102 | + //QObject::connect: signal not found in QtContacts::QContactFetchRequest |
103 | + // so we just disable it |
104 | +#ifndef __aarch64__ |
105 | // place the messaging-menu item only after the contact fetch request is finished, as we can´t simply update |
106 | QObject::connect(request, &QContactAbstractRequest::stateChanged, [request, call, text, this]() { |
107 | // only process the results after the finished state is reached |
108 | if (request->state() != QContactAbstractRequest::FinishedState) { |
109 | return; |
110 | } |
111 | - |
112 | +#endif |
113 | Call newCall = call; |
114 | if (request->contacts().size() > 0) { |
115 | QContact contact = request->contacts().at(0); |
116 | @@ -332,8 +336,10 @@ |
117 | } |
118 | } |
119 | addCallToMessagingMenu(newCall, text); |
120 | +#ifndef __aarch64__ |
121 | }); |
122 | |
123 | + |
124 | // FIXME: For accounts not based on phone numbers, don't try to match contacts for now |
125 | if (account->type() == AccountEntry::PhoneAccount) { |
126 | request->setManager(ContactUtils::sharedManager()); |
127 | @@ -342,6 +348,31 @@ |
128 | // just emit the signal to pretend we did a contact search |
129 | Q_EMIT request->stateChanged(QContactAbstractRequest::FinishedState); |
130 | } |
131 | +#endif |
132 | +} |
133 | + |
134 | +void MessagingMenu::removeCall(const QString &targetId, const QString &accountId) |
135 | +{ |
136 | + Call call; |
137 | + bool found = false; |
138 | + AccountEntry *account = TelepathyHelper::instance()->accountForId(accountId); |
139 | + if (!account) { |
140 | + qWarning() << "Account not found for id" << accountId; |
141 | + return; |
142 | + } |
143 | + |
144 | + Q_FOREACH(Call callMessage, mCalls) { |
145 | + // FIXME: we need a better strategy to group calls from different accounts |
146 | + if (account->compareIds(callMessage.targetId, targetId)) { |
147 | + call = callMessage; |
148 | + found = true; |
149 | + mCalls.removeOne(callMessage); |
150 | + |
151 | + // remove the previous entry and add a new one increasing the missed call count |
152 | + messaging_menu_app_remove_message_by_id(mCallsApp, callMessage.messageId.toUtf8().data()); |
153 | + break; |
154 | + } |
155 | + } |
156 | } |
157 | |
158 | void MessagingMenu::showVoicemailEntry(AccountEntry *account) |
159 | |
160 | === modified file 'indicator/messagingmenu.h' |
161 | --- indicator/messagingmenu.h 2015-03-04 18:02:13 +0000 |
162 | +++ indicator/messagingmenu.h 2015-06-08 18:29:15 +0000 |
163 | @@ -57,6 +57,7 @@ |
164 | void removeMessage(const QString &messageId); |
165 | |
166 | void addCall(const QString &targetId, const QString &accountId, const QDateTime ×tamp); |
167 | + void removeCall(const QString &targetId, const QString &accountId); |
168 | void addCallToMessagingMenu(Call call, const QString &text); |
169 | |
170 | static void flashMessageActivateCallback(MessagingMenuMessage *message, const char *actionId, GVariant *param, MessagingMenu *instance); |
171 | |
172 | === modified file 'libtelephonyservice/applicationutils.cpp' |
173 | --- libtelephonyservice/applicationutils.cpp 2013-10-07 19:20:02 +0000 |
174 | +++ libtelephonyservice/applicationutils.cpp 2015-06-08 18:29:15 +0000 |
175 | @@ -25,6 +25,7 @@ |
176 | #include <QDBusConnectionInterface> |
177 | #include <QDBusInterface> |
178 | #include <QDBusReply> |
179 | +#include <QDBusServiceWatcher> |
180 | #include <QDebug> |
181 | #include <QProcess> |
182 | #include <TelepathyQt/Constants> |
183 | |
184 | === modified file 'libtelephonyservice/applicationutils.h' |
185 | --- libtelephonyservice/applicationutils.h 2013-10-07 19:20:02 +0000 |
186 | +++ libtelephonyservice/applicationutils.h 2015-06-08 18:29:15 +0000 |
187 | @@ -23,7 +23,6 @@ |
188 | #define APPLICATIONUTILS_H |
189 | |
190 | #include <QObject> |
191 | -#include <QDBusServiceWatcher> |
192 | #include <QUrl> |
193 | |
194 | class ApplicationUtils : public QObject |
195 | |
196 | === modified file 'libtelephonyservice/callnotification.cpp' |
197 | --- libtelephonyservice/callnotification.cpp 2014-02-10 18:55:35 +0000 |
198 | +++ libtelephonyservice/callnotification.cpp 2015-06-08 18:29:15 +0000 |
199 | @@ -20,18 +20,16 @@ |
200 | */ |
201 | |
202 | #include "callnotification.h" |
203 | -#include "contactutils.h" |
204 | #include "config.h" |
205 | -#include <QContactAvatar> |
206 | -#include <QContactFetchRequest> |
207 | -#include <QContactPhoneNumber> |
208 | -#include <libnotify/notify.h> |
209 | + |
210 | namespace C { |
211 | #include <libintl.h> |
212 | } |
213 | |
214 | CallNotification::CallNotification(QObject *parent) : |
215 | - QObject(parent) |
216 | + QObject(parent), mIndicatorIface("com.canonical.TelephonyServiceIndicator", |
217 | + "/com/canonical/TelephonyServiceIndicator", |
218 | + "com.canonical.TelephonyServiceIndicator") |
219 | { |
220 | } |
221 | |
222 | @@ -107,3 +105,8 @@ |
223 | request->start(); |
224 | #endif |
225 | } |
226 | + |
227 | +void CallNotification::clearCallNotification(const QString &participantId, const QString &accountId) |
228 | +{ |
229 | + mIndicatorIface.asyncCall("ClearCallNotification", participantId, accountId); |
230 | +} |
231 | |
232 | === modified file 'libtelephonyservice/callnotification.h' |
233 | --- libtelephonyservice/callnotification.h 2014-01-20 12:57:43 +0000 |
234 | +++ libtelephonyservice/callnotification.h 2015-06-08 18:29:15 +0000 |
235 | @@ -23,6 +23,7 @@ |
236 | #define CALLNOTIFICATION_H |
237 | |
238 | #include <QObject> |
239 | +#include <QDBusInterface> |
240 | |
241 | class CallNotification : public QObject |
242 | { |
243 | @@ -37,9 +38,11 @@ |
244 | public Q_SLOTS: |
245 | static CallNotification *instance(); |
246 | void showNotificationForCall(const QStringList &participants, NotificationReason reason); |
247 | + void clearCallNotification(const QString &participantId, const QString &accountId); |
248 | |
249 | private: |
250 | explicit CallNotification(QObject *parent = 0); |
251 | + QDBusInterface mIndicatorIface; |
252 | }; |
253 | |
254 | #endif // CALLNOTIFICATION_H |
255 | |
256 | === modified file 'tests/CMakeLists.txt' |
257 | --- tests/CMakeLists.txt 2015-03-20 21:50:47 +0000 |
258 | +++ tests/CMakeLists.txt 2015-06-08 18:29:15 +0000 |
259 | @@ -2,5 +2,6 @@ |
260 | |
261 | add_subdirectory(common) |
262 | add_subdirectory(handler) |
263 | +add_subdirectory(indicator) |
264 | add_subdirectory(libtelephonyservice) |
265 | add_subdirectory(Ubuntu.Telephony) |
266 | |
267 | === modified file 'tests/common/CMakeLists.txt' |
268 | --- tests/common/CMakeLists.txt 2015-04-21 16:22:55 +0000 |
269 | +++ tests/common/CMakeLists.txt 2015-06-08 18:29:15 +0000 |
270 | @@ -1,6 +1,7 @@ |
271 | include_directories(${TP_QT5_INCLUDE_DIRS} |
272 | ${CMAKE_SOURCE_DIR}/libtelephonyservice |
273 | - ${CMAKE_CURRENT_BINARY_DIR}) |
274 | + ${CMAKE_CURRENT_BINARY_DIR} |
275 | + ${GSETTINGS_QT_INCLUDE_DIRS}) |
276 | |
277 | configure_file(dbus-session.conf.in ${CMAKE_CURRENT_BINARY_DIR}/dbus-session.conf) |
278 | |
279 | @@ -10,7 +11,7 @@ |
280 | |
281 | add_library(telepathytest STATIC telepathytest.cpp telepathytest.h) |
282 | qt5_use_modules(telepathytest Core DBus) |
283 | -target_link_libraries(telepathytest telephonyservice ${TP_QT5_LIBRARIES}) |
284 | +target_link_libraries(telepathytest telephonyservice ${TP_QT5_LIBRARIES} ${GSETTINGS_QT_LDFLAGS}) |
285 | |
286 | add_subdirectory(mock) |
287 | add_subdirectory(dbus-services) |
288 | |
289 | === modified file 'tests/common/telepathytest.cpp' |
290 | --- tests/common/telepathytest.cpp 2015-04-29 20:11:14 +0000 |
291 | +++ tests/common/telepathytest.cpp 2015-06-08 18:29:15 +0000 |
292 | @@ -24,6 +24,11 @@ |
293 | #include "telepathyhelper.h" |
294 | #include "accountentry.h" |
295 | |
296 | +TelepathyTest::TelepathyTest() : mPhoneSettings("com.ubuntu.phone") |
297 | +{ |
298 | + |
299 | +} |
300 | + |
301 | void TelepathyTest::initialize() |
302 | { |
303 | Tp::registerTypes(); |
304 | |
305 | === modified file 'tests/common/telepathytest.h' |
306 | --- tests/common/telepathytest.h 2015-05-08 13:28:09 +0000 |
307 | +++ tests/common/telepathytest.h 2015-06-08 18:29:15 +0000 |
308 | @@ -22,6 +22,7 @@ |
309 | #include <QtCore/QObject> |
310 | #include <QtTest/QtTest> |
311 | #include <TelepathyQt/Account> |
312 | +#include "qgsettings.h" |
313 | #include <TelepathyQt/AccountManager> |
314 | |
315 | #define DEFAULT_TIMEOUT 15000 |
316 | @@ -34,6 +35,8 @@ |
317 | class TelepathyTest : public QObject |
318 | { |
319 | Q_OBJECT |
320 | +public: |
321 | + TelepathyTest(); |
322 | |
323 | protected: |
324 | void initialize(); |
325 | @@ -51,6 +54,8 @@ |
326 | private Q_SLOTS: |
327 | void cleanup(); |
328 | |
329 | +protected: |
330 | + QGSettings mPhoneSettings; |
331 | private: |
332 | Tp::AccountManagerPtr mAccountManager; |
333 | bool mReady; |
334 | |
335 | === modified file 'tests/handler/CMakeLists.txt' |
336 | --- tests/handler/CMakeLists.txt 2015-04-21 16:29:11 +0000 |
337 | +++ tests/handler/CMakeLists.txt 2015-06-08 18:29:15 +0000 |
338 | @@ -5,6 +5,7 @@ |
339 | ${CMAKE_SOURCE_DIR}/libtelephonyservice |
340 | ${CMAKE_BINARY_DIR}/tests/common |
341 | ${TP_QT5_INCLUDE_DIRS} |
342 | + ${GSETTINGS_QT_INCLUDE_DIRS} |
343 | ) |
344 | |
345 | generate_telepathy_test(HandlerTest SOURCES HandlerTest.cpp handlercontroller.cpp approver.cpp) |
346 | |
347 | === added directory 'tests/indicator' |
348 | === added file 'tests/indicator/CMakeLists.txt' |
349 | --- tests/indicator/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
350 | +++ tests/indicator/CMakeLists.txt 2015-06-08 18:29:15 +0000 |
351 | @@ -0,0 +1,14 @@ |
352 | +include_directories( |
353 | + ${CMAKE_CURRENT_BINARY_DIR} |
354 | + ${CMAKE_CURRENT_SOURCE_DIR}/../common |
355 | + ${CMAKE_SOURCE_DIR} |
356 | + ${CMAKE_SOURCE_DIR}/libtelephonyservice |
357 | + ${CMAKE_SOURCE_DIR}/indicator |
358 | + ${MESSAGING_MENU_INCLUDE_DIRS} |
359 | + ${TP_QT5_INCLUDE_DIRS} |
360 | + ${HISTORY_INCLUDE_DIRS} |
361 | + ) |
362 | + |
363 | +generate_telepathy_test(MessagingMenuTest |
364 | + SOURCES MessagingMenuTest.cpp messagingmenumock.cpp ${CMAKE_SOURCE_DIR}/indicator/messagingmenu.cpp |
365 | + LIBRARIES ${TP_QT5_LIBRARIES} telephonyservice mockcontroller telepathytest ${HISTORY_LIBRARIES}) |
366 | |
367 | === added file 'tests/indicator/MessagingMenuTest.cpp' |
368 | --- tests/indicator/MessagingMenuTest.cpp 1970-01-01 00:00:00 +0000 |
369 | +++ tests/indicator/MessagingMenuTest.cpp 2015-06-08 18:29:15 +0000 |
370 | @@ -0,0 +1,86 @@ |
371 | +/* |
372 | + * Copyright (C) 2015 Canonical, Ltd. |
373 | + * |
374 | + * This file is part of telephony-service. |
375 | + * |
376 | + * telephony-service is free software; you can redistribute it and/or modify |
377 | + * it under the terms of the GNU General Public License as published by |
378 | + * the Free Software Foundation; version 3. |
379 | + * |
380 | + * telephony-service is distributed in the hope that it will be useful, |
381 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
382 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
383 | + * GNU General Public License for more details. |
384 | + * |
385 | + * You should have received a copy of the GNU General Public License |
386 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
387 | + */ |
388 | + |
389 | +#include <QtCore/QObject> |
390 | +#include <QtTest/QtTest> |
391 | +#include "contactutils.h" |
392 | +#include "telepathytest.h" |
393 | +#include "messagingmenu.h" |
394 | +#include "messagingmenumock.h" |
395 | +#include "telepathyhelper.h" |
396 | + |
397 | +class MessagingMenuTest : public TelepathyTest |
398 | +{ |
399 | + Q_OBJECT |
400 | + |
401 | +private Q_SLOTS: |
402 | + void initTestCase(); |
403 | + void cleanupTestCase(); |
404 | + void cleanup(); |
405 | + void testCallNotificationAdded(); |
406 | + void testCallNotificationRemoved(); |
407 | +private: |
408 | + Tp::AccountPtr mAccount; |
409 | +}; |
410 | + |
411 | +void MessagingMenuTest::initTestCase() |
412 | +{ |
413 | + initialize(); |
414 | + |
415 | + // just trigger the creation of the mock singleton |
416 | + MessagingMenuMock::instance(); |
417 | + |
418 | + // use the memory contact backend |
419 | + ContactUtils::sharedManager("memory"); |
420 | + |
421 | + QSignalSpy accountAddedSpy(TelepathyHelper::instance(), SIGNAL(accountAdded(AccountEntry*))); |
422 | + mAccount = addAccount("mock", "ofono", "theAccount"); |
423 | + QTRY_COMPARE(accountAddedSpy.count(), 1); |
424 | +} |
425 | + |
426 | +void MessagingMenuTest::cleanupTestCase() |
427 | +{ |
428 | + doCleanup(); |
429 | +} |
430 | + |
431 | +void MessagingMenuTest::cleanup() |
432 | +{ |
433 | + // just to prevent the doCleanup() to run on every test |
434 | +} |
435 | + |
436 | +void MessagingMenuTest::testCallNotificationAdded() |
437 | +{ |
438 | + QString caller("12345"); |
439 | + QSignalSpy messageAddedSpy(MessagingMenuMock::instance(), SIGNAL(messageAdded(QString,QString,QString,bool))); |
440 | + MessagingMenu::instance()->addCall(caller, mAccount->uniqueIdentifier(), QDateTime::currentDateTime()); |
441 | + QTRY_COMPARE(messageAddedSpy.count(), 1); |
442 | + QCOMPARE(messageAddedSpy.first()[1].toString(), caller); |
443 | +} |
444 | + |
445 | +void MessagingMenuTest::testCallNotificationRemoved() |
446 | +{ |
447 | + QString caller("2345678"); |
448 | + QSignalSpy messageRemovedSpy(MessagingMenuMock::instance(), SIGNAL(messageRemoved(QString,QString))); |
449 | + MessagingMenu::instance()->addCall(caller, mAccount->uniqueIdentifier(), QDateTime::currentDateTime()); |
450 | + MessagingMenu::instance()->removeCall(caller, mAccount->uniqueIdentifier()); |
451 | + QCOMPARE(messageRemovedSpy.count(), 1); |
452 | + QCOMPARE(messageRemovedSpy.first()[1].toString(), caller); |
453 | +} |
454 | + |
455 | +QTEST_MAIN(MessagingMenuTest) |
456 | +#include "MessagingMenuTest.moc" |
457 | |
458 | === added file 'tests/indicator/messagingmenumock.cpp' |
459 | --- tests/indicator/messagingmenumock.cpp 1970-01-01 00:00:00 +0000 |
460 | +++ tests/indicator/messagingmenumock.cpp 2015-06-08 18:29:15 +0000 |
461 | @@ -0,0 +1,300 @@ |
462 | +/* |
463 | + * Copyright (C) 2015 Canonical, Ltd. |
464 | + * |
465 | + * This file is part of telephony-service. |
466 | + * |
467 | + * telephony-service is free software; you can redistribute it and/or modify |
468 | + * it under the terms of the GNU General Public License as published by |
469 | + * the Free Software Foundation; version 3. |
470 | + * |
471 | + * telephony-service is distributed in the hope that it will be useful, |
472 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
473 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
474 | + * GNU General Public License for more details. |
475 | + * |
476 | + * You should have received a copy of the GNU General Public License |
477 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
478 | + */ |
479 | + |
480 | +#include "messagingmenumock.h" |
481 | +#include "messaging-menu.h" |
482 | +#include <QDateTime> |
483 | +#include <QDebug> |
484 | + |
485 | +MessagingMenuMock *MessagingMenuMock::instance() |
486 | +{ |
487 | + static MessagingMenuMock *self = new MessagingMenuMock(); |
488 | + return self; |
489 | +} |
490 | + |
491 | +MessagingMenuMock::MessagingMenuMock(QObject *parent) : |
492 | + QObject(parent) |
493 | +{ |
494 | +} |
495 | + |
496 | +/*** Mock implementation of messaging messaging-menu functions ***/ |
497 | + |
498 | +/*** MessagingMenuApp ***/ |
499 | +struct _MessagingMenuApp { |
500 | + GObject parent_instance; |
501 | + gchar *desktopId; |
502 | +}; |
503 | + |
504 | +G_DEFINE_TYPE(MessagingMenuApp, messaging_menu_app, G_TYPE_OBJECT) |
505 | + |
506 | +enum MessageProperties |
507 | +{ |
508 | + PROP_0, |
509 | + PROP_ID, |
510 | + PROP_ICON, |
511 | + PROP_TITLE, |
512 | + PROP_SUBTITLE, |
513 | + PROP_BODY, |
514 | + PROP_TIME, |
515 | + PROP_DRAWS_ATTENTION, |
516 | + NUM_PROPERTIES |
517 | +}; |
518 | + |
519 | +#define PROP_DESKTOP_ID 1 |
520 | + |
521 | +static void messaging_menu_app_set_property (GObject *object, |
522 | + guint prop_id, |
523 | + const GValue *value, |
524 | + GParamSpec *pspec) |
525 | +{ |
526 | + qDebug() << __PRETTY_FUNCTION__; |
527 | + if (prop_id == PROP_DESKTOP_ID) { |
528 | + MessagingMenuApp *app = MESSAGING_MENU_APP (object); |
529 | + app->desktopId = g_value_dup_string (value); |
530 | + } |
531 | +} |
532 | + |
533 | +static void messaging_menu_app_class_init (MessagingMenuAppClass *klass) |
534 | +{ |
535 | + qDebug() << __PRETTY_FUNCTION__; |
536 | + GObjectClass *object_class = G_OBJECT_CLASS (klass); |
537 | + object_class->set_property = messaging_menu_app_set_property; |
538 | + |
539 | + GParamSpec *prop = g_param_spec_string ("desktop-id", |
540 | + "Desktop Id", |
541 | + "The desktop id of the associated application", |
542 | + NULL, |
543 | + (GParamFlags)(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); |
544 | + |
545 | + g_object_class_install_property (object_class, PROP_DESKTOP_ID, prop); |
546 | +} |
547 | + |
548 | +static void messaging_menu_app_init (MessagingMenuApp *app) |
549 | +{ |
550 | + qDebug() << __PRETTY_FUNCTION__; |
551 | + Q_UNUSED(app) |
552 | + // FIXME: check what needs implementing |
553 | +} |
554 | + |
555 | +MessagingMenuApp *messaging_menu_app_new(const gchar *desktop_id) |
556 | +{ |
557 | + qDebug() << __PRETTY_FUNCTION__; |
558 | + MessagingMenuApp *app = (MessagingMenuApp*)g_object_new (MESSAGING_MENU_TYPE_APP, |
559 | + "desktop-id", desktop_id, |
560 | + NULL); |
561 | + Q_EMIT MessagingMenuMock::instance()->appCreated(app->desktopId); |
562 | + return app; |
563 | +} |
564 | + |
565 | +void messaging_menu_app_register(MessagingMenuApp *app) |
566 | +{ |
567 | + qDebug() << __PRETTY_FUNCTION__; |
568 | + Q_EMIT MessagingMenuMock::instance()->appRegistered(app->desktopId); |
569 | +} |
570 | + |
571 | +void messaging_menu_app_append_source(MessagingMenuApp *app, const gchar *id, GIcon *icon, const gchar *label) |
572 | +{ |
573 | + qDebug() << __PRETTY_FUNCTION__; |
574 | + Q_EMIT MessagingMenuMock::instance()->sourceAdded(app->desktopId, id, g_icon_to_string(icon), label); |
575 | +} |
576 | + |
577 | +/*** MessagingMenuMessage ***/ |
578 | + |
579 | +struct _MessagingMenuMessage { |
580 | + GObject parent; |
581 | + |
582 | + gchar *id; |
583 | + GIcon *icon; |
584 | + gchar *title; |
585 | + gchar *subtitle; |
586 | + gchar *body; |
587 | + gint64 time; |
588 | + gboolean draws_attention; |
589 | +}; |
590 | + |
591 | +typedef GObjectClass MessagingMenuMessageClass; |
592 | +G_DEFINE_TYPE (MessagingMenuMessage, messaging_menu_message, G_TYPE_OBJECT) |
593 | + |
594 | +// MessagingMenuMessage's properties |
595 | +static GParamSpec *properties[NUM_PROPERTIES]; |
596 | + |
597 | +static void messaging_menu_message_get_property(GObject *object, |
598 | + guint property_id, |
599 | + GValue *value, |
600 | + GParamSpec *pspec) |
601 | +{ |
602 | + MessagingMenuMessage *msg = MESSAGING_MENU_MESSAGE (object); |
603 | + |
604 | + switch (property_id) { |
605 | + case PROP_ID: |
606 | + g_value_set_string (value, msg->id); |
607 | + break; |
608 | + case PROP_ICON: |
609 | + g_value_set_object (value, msg->icon); |
610 | + break; |
611 | + case PROP_TITLE: |
612 | + g_value_set_string (value, msg->title); |
613 | + break; |
614 | + case PROP_SUBTITLE: |
615 | + g_value_set_string (value, msg->subtitle); |
616 | + break; |
617 | + case PROP_BODY: |
618 | + g_value_set_string (value, msg->body); |
619 | + break; |
620 | + case PROP_TIME: |
621 | + g_value_set_int64 (value, msg->time); |
622 | + break; |
623 | + case PROP_DRAWS_ATTENTION: |
624 | + g_value_set_boolean (value, msg->draws_attention); |
625 | + break; |
626 | + default: |
627 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
628 | + } |
629 | +} |
630 | + |
631 | +static void messaging_menu_message_set_property(GObject *object, |
632 | + guint property_id, |
633 | + const GValue *value, |
634 | + GParamSpec *pspec) |
635 | +{ |
636 | + qDebug() << __PRETTY_FUNCTION__; |
637 | + MessagingMenuMessage *msg = MESSAGING_MENU_MESSAGE (object); |
638 | + |
639 | + switch (property_id) { |
640 | + case PROP_ID: |
641 | + msg->id = g_value_dup_string (value); |
642 | + break; |
643 | + case PROP_ICON: |
644 | + msg->icon = (GIcon*)g_value_dup_object (value); |
645 | + break; |
646 | + case PROP_TITLE: |
647 | + msg->title = g_value_dup_string (value); |
648 | + break; |
649 | + case PROP_SUBTITLE: |
650 | + msg->subtitle = g_value_dup_string (value); |
651 | + break; |
652 | + case PROP_BODY: |
653 | + msg->body = g_value_dup_string (value); |
654 | + break; |
655 | + case PROP_TIME: |
656 | + msg->time = g_value_get_int64 (value); |
657 | + break; |
658 | + case PROP_DRAWS_ATTENTION: |
659 | + msg->draws_attention = g_value_get_boolean (value); |
660 | + break; |
661 | + default: |
662 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
663 | + } |
664 | +} |
665 | +static void messaging_menu_message_class_init(MessagingMenuMessageClass *klass) |
666 | +{ |
667 | + GObjectClass *object_class = G_OBJECT_CLASS (klass); |
668 | + |
669 | + object_class->get_property = messaging_menu_message_get_property; |
670 | + object_class->set_property = messaging_menu_message_set_property; |
671 | + |
672 | + properties[PROP_ID] = g_param_spec_string ("id", "Id", |
673 | + "Unique id of the message", |
674 | + NULL, |
675 | + (GParamFlags)(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
676 | + properties[PROP_ICON] = g_param_spec_object ("icon", "Icon", |
677 | + "Icon of the message", |
678 | + G_TYPE_ICON, |
679 | + (GParamFlags)(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
680 | + properties[PROP_TITLE] = g_param_spec_string ("title", "Title", |
681 | + "Title of the message", |
682 | + NULL, |
683 | + (GParamFlags)(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
684 | + properties[PROP_SUBTITLE] = g_param_spec_string ("subtitle", "Subtitle", |
685 | + "Subtitle of the message", |
686 | + NULL, |
687 | + (GParamFlags)(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
688 | + properties[PROP_BODY] = g_param_spec_string ("body", "Body", |
689 | + "First lines of the body of the message", |
690 | + NULL, |
691 | + (GParamFlags)(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
692 | + properties[PROP_TIME] = g_param_spec_int64 ("time", "Time", |
693 | + "Time the message was sent, in microseconds", 0, G_MAXINT64, 0, |
694 | + (GParamFlags)(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
695 | + properties[PROP_DRAWS_ATTENTION] = g_param_spec_boolean ("draws-attention", "Draws attention", |
696 | + "Whether the message should draw attention", |
697 | + TRUE, |
698 | + (GParamFlags)(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
699 | + g_object_class_install_properties (klass, NUM_PROPERTIES, properties); |
700 | + |
701 | + g_signal_new ("activate", |
702 | + MESSAGING_MENU_TYPE_MESSAGE, |
703 | + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_DETAILED), |
704 | + 0, |
705 | + NULL, NULL, |
706 | + g_cclosure_marshal_generic, |
707 | + G_TYPE_NONE, 2, |
708 | + G_TYPE_STRING, |
709 | + G_TYPE_VARIANT); |
710 | +} |
711 | + |
712 | +static void messaging_menu_message_init(MessagingMenuMessage *self) |
713 | +{ |
714 | + self->draws_attention = TRUE; |
715 | +} |
716 | + |
717 | +MessagingMenuMessage *messaging_menu_message_new(const gchar *id, GIcon *icon, const gchar *title, const gchar *subtitle, const gchar *body, gint64 time) |
718 | +{ |
719 | + qDebug() << __PRETTY_FUNCTION__; |
720 | + MessagingMenuMessage *message = (MessagingMenuMessage*) g_object_new(MESSAGING_MENU_TYPE_MESSAGE, |
721 | + "id", id, |
722 | + "icon", icon, |
723 | + "title", title, |
724 | + "subtitle", subtitle, |
725 | + "body", body, |
726 | + "time", time, |
727 | + NULL); |
728 | + Q_EMIT MessagingMenuMock::instance()->messageCreated(QString(message->id), |
729 | + QString(g_icon_to_string(message->icon)), |
730 | + QString(message->title), |
731 | + QString(message->subtitle), |
732 | + QString(message->body), |
733 | + QDateTime::fromMSecsSinceEpoch(time / 1000)); |
734 | + |
735 | + return message; |
736 | +} |
737 | + |
738 | +void messaging_menu_message_add_action(MessagingMenuMessage *msg, const gchar *id, const gchar *label, const GVariantType *parameter_type, GVariant *parameter_hint) |
739 | +{ |
740 | + qDebug() << __PRETTY_FUNCTION__; |
741 | + Q_EMIT MessagingMenuMock::instance()->actionAdded(msg->id, id, label); |
742 | +} |
743 | + |
744 | +void messaging_menu_app_remove_message_by_id(MessagingMenuApp *app, const gchar *id) |
745 | +{ |
746 | + qDebug() << __PRETTY_FUNCTION__; |
747 | + Q_EMIT MessagingMenuMock::instance()->messageRemoved(app->desktopId, id); |
748 | +} |
749 | + |
750 | +const gchar *messaging_menu_message_get_id(MessagingMenuMessage *msg) |
751 | +{ |
752 | + qDebug() << __PRETTY_FUNCTION__; |
753 | + return msg->id; |
754 | +} |
755 | + |
756 | +void messaging_menu_app_append_message(MessagingMenuApp *app, MessagingMenuMessage *msg, const gchar *source_id, gboolean notify) |
757 | +{ |
758 | + qDebug() << __PRETTY_FUNCTION__; |
759 | + Q_EMIT MessagingMenuMock::instance()->messageAdded(QString(app->desktopId), QString(msg->id), QString(source_id), (bool)notify); |
760 | +} |
761 | + |
762 | |
763 | === added file 'tests/indicator/messagingmenumock.h' |
764 | --- tests/indicator/messagingmenumock.h 1970-01-01 00:00:00 +0000 |
765 | +++ tests/indicator/messagingmenumock.h 2015-06-08 18:29:15 +0000 |
766 | @@ -0,0 +1,57 @@ |
767 | +/* |
768 | + * Copyright (C) 2015 Canonical, Ltd. |
769 | + * |
770 | + * This file is part of telephony-service. |
771 | + * |
772 | + * telephony-service is free software; you can redistribute it and/or modify |
773 | + * it under the terms of the GNU General Public License as published by |
774 | + * the Free Software Foundation; version 3. |
775 | + * |
776 | + * telephony-service is distributed in the hope that it will be useful, |
777 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
778 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
779 | + * GNU General Public License for more details. |
780 | + * |
781 | + * You should have received a copy of the GNU General Public License |
782 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
783 | + */ |
784 | + |
785 | +#ifndef MESSAGINGMENUMOCK_H |
786 | +#define MESSAGINGMENUMOCK_H |
787 | + |
788 | +#include <QObject> |
789 | + |
790 | +class MessagingMenuMock : public QObject |
791 | +{ |
792 | + Q_OBJECT |
793 | +public: |
794 | + static MessagingMenuMock *instance(); |
795 | + |
796 | + |
797 | +Q_SIGNALS: |
798 | + void appCreated(const QString &desktopId); |
799 | + void appRegistered(const QString &desktopId); |
800 | + void sourceAdded(const QString &app, const QString &id, const QString &icon, const QString &label); |
801 | + |
802 | + void messageCreated(const QString &id, |
803 | + const QString &icon, |
804 | + const QString &title, |
805 | + const QString &subtitle, |
806 | + const QString &body, |
807 | + const QDateTime &time); |
808 | + void messageAdded(const QString &app, |
809 | + const QString &messageId, |
810 | + const QString &sourceId, |
811 | + bool notify); |
812 | + void messageRemoved(const QString &app, |
813 | + const QString &id); |
814 | + void actionAdded(const QString &messageId, |
815 | + const QString &actionId, |
816 | + const QString &label); |
817 | + |
818 | +private: |
819 | + explicit MessagingMenuMock(QObject *parent = 0); |
820 | + |
821 | +}; |
822 | + |
823 | +#endif // MESSAGINGMENUMOCK_H |
824 | |
825 | === modified file 'tests/libtelephonyservice/CMakeLists.txt' |
826 | --- tests/libtelephonyservice/CMakeLists.txt 2015-05-07 16:44:43 +0000 |
827 | +++ tests/libtelephonyservice/CMakeLists.txt 2015-06-08 18:29:15 +0000 |
828 | @@ -5,6 +5,7 @@ |
829 | ${TP_QT5_INCLUDE_DIRS} |
830 | ${CMAKE_SOURCE_DIR}/tests/common |
831 | ${CMAKE_BINARY_DIR}/tests/common |
832 | + ${GSETTINGS_QT_INCLUDE_DIRS} |
833 | ) |
834 | |
835 | add_executable(GreeterContactsTestServerExe GreeterContactsTestServer.cpp) |
836 | @@ -13,6 +14,9 @@ |
837 | add_executable(ToneGeneratorMock ToneGeneratorMock.cpp) |
838 | qt5_use_modules(ToneGeneratorMock Core DBus) |
839 | |
840 | +add_executable(IndicatorMock IndicatorMock.cpp) |
841 | +qt5_use_modules(IndicatorMock Core DBus) |
842 | + |
843 | generate_test(GreeterContactsTest USE_DBUS |
844 | SOURCES GreeterContactsTest.cpp ${LIBTELEPHONYSERVICE_DIR}/greetercontacts.cpp |
845 | QT5_MODULES Contacts Core DBus Test |
846 | @@ -29,6 +33,12 @@ |
847 | WAIT_FOR com.Nokia.Telephony.Tones) |
848 | add_dependencies(ToneGeneratorTest ToneGeneratorMock) |
849 | |
850 | +generate_test(CallNotificationTest USE_DBUS |
851 | + SOURCES CallNotificationTest.cpp ${LIBTELEPHONYSERVICE_DIR}/callnotification.cpp |
852 | + QT5_MODULES Core DBus Test |
853 | + TASKS --task ${CMAKE_CURRENT_BINARY_DIR}/IndicatorMock --task-name indicator --ignore-return |
854 | + WAIT_FOR com.canonical.TelephonyServiceIndicator) |
855 | + |
856 | generate_test(ContactUtilsTest SOURCES ContactUtilsTest.cpp QT5_MODULES Contacts Core Test LIBRARIES telephonyservice USE_UI) |
857 | generate_test(PhoneUtilsTest SOURCES PhoneUtilsTest.cpp LIBRARIES telephonyservice USE_UI) |
858 | |
859 | |
860 | === added file 'tests/libtelephonyservice/CallNotificationTest.cpp' |
861 | --- tests/libtelephonyservice/CallNotificationTest.cpp 1970-01-01 00:00:00 +0000 |
862 | +++ tests/libtelephonyservice/CallNotificationTest.cpp 2015-06-08 18:29:15 +0000 |
863 | @@ -0,0 +1,67 @@ |
864 | +/* |
865 | + * Copyright (C) 2015 Canonical, Ltd. |
866 | + * |
867 | + * This file is part of telephony-service. |
868 | + * |
869 | + * telephony-service is free software; you can redistribute it and/or modify |
870 | + * it under the terms of the GNU General Public License as published by |
871 | + * the Free Software Foundation; version 3. |
872 | + * |
873 | + * telephony-service is distributed in the hope that it will be useful, |
874 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
875 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
876 | + * GNU General Public License for more details. |
877 | + * |
878 | + * You should have received a copy of the GNU General Public License |
879 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
880 | + */ |
881 | + |
882 | +#include <QtCore/QObject> |
883 | +#include <QtTest/QtTest> |
884 | +#include <QDBusInterface> |
885 | + |
886 | +#include "callnotification.h" |
887 | + |
888 | +#define INDICATOR_DBUS_SERVICE_NAME "com.canonical.TelephonyServiceIndicator" |
889 | +#define INDICATOR_DBUS_OBJ_PATH "/com/canonical/TelephonyServiceIndicator" |
890 | + |
891 | +class CallNotificationTest : public QObject |
892 | +{ |
893 | + Q_OBJECT |
894 | + |
895 | +private Q_SLOTS: |
896 | + void initTestCase(); |
897 | + void cleanupTestCase(); |
898 | + void testClearCallNotification(); |
899 | + |
900 | +private: |
901 | + QDBusInterface *mIndicatorInterface; |
902 | +}; |
903 | + |
904 | +void CallNotificationTest::initTestCase() |
905 | +{ |
906 | + mIndicatorInterface = new QDBusInterface(INDICATOR_DBUS_SERVICE_NAME, |
907 | + INDICATOR_DBUS_OBJ_PATH, |
908 | + INDICATOR_DBUS_SERVICE_NAME, |
909 | + QDBusConnection::sessionBus(), |
910 | + this); |
911 | +} |
912 | + |
913 | +void CallNotificationTest::cleanupTestCase() |
914 | +{ |
915 | + mIndicatorInterface->deleteLater(); |
916 | +} |
917 | + |
918 | +void CallNotificationTest::testClearCallNotification() |
919 | +{ |
920 | + QSignalSpy clearNotificationSpy(mIndicatorInterface, SIGNAL(ClearCallNotificationRequested(QString, QString))); |
921 | + QString targetId("theTargetId"); |
922 | + QString accountId("theAccountId"); |
923 | + CallNotification::instance()->clearCallNotification(targetId, accountId); |
924 | + QTRY_COMPARE(clearNotificationSpy.count(), 1); |
925 | + QCOMPARE(clearNotificationSpy.first()[0].toString(), targetId); |
926 | + QCOMPARE(clearNotificationSpy.first()[1].toString(), accountId); |
927 | +} |
928 | + |
929 | +QTEST_MAIN(CallNotificationTest) |
930 | +#include "CallNotificationTest.moc" |
931 | |
932 | === modified file 'tests/libtelephonyservice/ChatManagerTest.cpp' |
933 | --- tests/libtelephonyservice/ChatManagerTest.cpp 2015-05-07 16:44:43 +0000 |
934 | +++ tests/libtelephonyservice/ChatManagerTest.cpp 2015-06-08 18:29:15 +0000 |
935 | @@ -47,6 +47,8 @@ |
936 | void ChatManagerTest::initTestCase() |
937 | { |
938 | initialize(); |
939 | + // set to false so group chat messages are not sent as MMS |
940 | + mPhoneSettings.set("mmsGroupChatEnabled", false); |
941 | TelepathyHelper::instance()->registerChannelObserver(); |
942 | } |
943 | |
944 | |
945 | === added file 'tests/libtelephonyservice/IndicatorMock.cpp' |
946 | --- tests/libtelephonyservice/IndicatorMock.cpp 1970-01-01 00:00:00 +0000 |
947 | +++ tests/libtelephonyservice/IndicatorMock.cpp 2015-06-08 18:29:15 +0000 |
948 | @@ -0,0 +1,66 @@ |
949 | +/* |
950 | + * Copyright (C) 2015 Canonical, Ltd. |
951 | + * |
952 | + * This file is part of telephony-service. |
953 | + * |
954 | + * telephony-service is free software; you can redistribute it and/or modify |
955 | + * it under the terms of the GNU General Public License as published by |
956 | + * the Free Software Foundation; version 3. |
957 | + * |
958 | + * telephony-service is distributed in the hope that it will be useful, |
959 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
960 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
961 | + * GNU General Public License for more details. |
962 | + * |
963 | + * You should have received a copy of the GNU General Public License |
964 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
965 | + */ |
966 | + |
967 | +#include <QObject> |
968 | +#include <QCoreApplication> |
969 | +#include <QDBusConnection> |
970 | +#include <QDBusMessage> |
971 | +#include <QDBusObjectPath> |
972 | +#include <QDebug> |
973 | + |
974 | +#define INDICATOR_DBUS_SERVICE_NAME "com.canonical.TelephonyServiceIndicator" |
975 | +#define INDICATOR_DBUS_OBJ_PATH "/com/canonical/TelephonyServiceIndicator" |
976 | + |
977 | +class IndicatorMock : public QObject |
978 | +{ |
979 | + Q_OBJECT |
980 | + Q_CLASSINFO("D-Bus Interface", INDICATOR_DBUS_SERVICE_NAME) |
981 | + |
982 | +public: |
983 | + Q_SCRIPTABLE void ClearNotifications(); |
984 | + Q_SCRIPTABLE void ClearCallNotification(const QString &targetId, const QString &accountId); |
985 | + |
986 | +Q_SIGNALS: |
987 | + Q_SCRIPTABLE void ClearNotificationsRequested(); |
988 | + Q_SCRIPTABLE void ClearCallNotificationRequested(const QString &targetId, const QString &accountId); |
989 | +}; |
990 | + |
991 | +void IndicatorMock::ClearNotifications() |
992 | +{ |
993 | + Q_EMIT ClearNotificationsRequested(); |
994 | +} |
995 | + |
996 | +void IndicatorMock::ClearCallNotification(const QString &targetId, const QString &accountId) |
997 | +{ |
998 | + Q_EMIT ClearCallNotificationRequested(targetId, accountId); |
999 | +} |
1000 | + |
1001 | +int main(int argc, char **argv) |
1002 | +{ |
1003 | + QCoreApplication a(argc, argv); |
1004 | + |
1005 | + QDBusConnection connection = QDBusConnection::sessionBus(); |
1006 | + |
1007 | + IndicatorMock toneGen; |
1008 | + connection.registerObject(INDICATOR_DBUS_OBJ_PATH, &toneGen, QDBusConnection::ExportScriptableContents); |
1009 | + connection.registerService(INDICATOR_DBUS_SERVICE_NAME); |
1010 | + |
1011 | + return a.exec(); |
1012 | +} |
1013 | + |
1014 | +#include "IndicatorMock.moc" |
1015 | |
1016 | === modified file 'tests/libtelephonyservice/TelepathyHelperTest.cpp' |
1017 | --- tests/libtelephonyservice/TelepathyHelperTest.cpp 2015-05-08 21:57:06 +0000 |
1018 | +++ tests/libtelephonyservice/TelepathyHelperTest.cpp 2015-06-08 18:29:15 +0000 |
1019 | @@ -255,21 +255,21 @@ |
1020 | |
1021 | // now set one of the accounts as offline and make sure it is captured |
1022 | mGenericController->SetOnline(false); |
1023 | - TRY_COMPARE(activeAccountsSpy.count(), 1); |
1024 | + TRY_VERIFY(activeAccountsSpy.count() >= 1); |
1025 | QTRY_COMPARE(TelepathyHelper::instance()->activeAccounts().count(), 1); |
1026 | QCOMPARE(TelepathyHelper::instance()->activeAccounts()[0]->accountId(), mPhoneTpAccount->uniqueIdentifier()); |
1027 | |
1028 | // set the other account offline to make sure |
1029 | activeAccountsSpy.clear(); |
1030 | mPhoneController->SetOnline(false); |
1031 | - TRY_COMPARE(activeAccountsSpy.count(), 1); |
1032 | + TRY_VERIFY(activeAccountsSpy.count() >= 1); |
1033 | QVERIFY(TelepathyHelper::instance()->activeAccounts().isEmpty()); |
1034 | |
1035 | // and set both accounts online again |
1036 | activeAccountsSpy.clear(); |
1037 | mGenericController->SetOnline(true); |
1038 | mPhoneController->SetOnline(true); |
1039 | - TRY_COMPARE(activeAccountsSpy.count(), 2); |
1040 | + TRY_VERIFY(activeAccountsSpy.count() >= 2); |
1041 | QCOMPARE(TelepathyHelper::instance()->activeAccounts().count(), 2); |
1042 | } |
1043 |
FAILED: Continuous integration, rev:1079 jenkins. qa.ubuntu. com/job/ telephony- service- ci/446/ jenkins. qa.ubuntu. com/job/ telephony- service- vivid-amd64- ci/118/ console jenkins. qa.ubuntu. com/job/ telephony- service- vivid-armhf- ci/114/ console jenkins. qa.ubuntu. com/job/ telephony- service- vivid-i386- ci/114/ console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/telephony- service- ci/446/ rebuild
http://