Merge lp:~boiko/telephony-service/clear_call_notifications into lp:telephony-service

Proposed by Gustavo Pichorim Boiko
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
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://wiki.ubuntu.com/Process/Merges/TestPlan/<package-name>) on device or emulator?
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

To post a comment you must log in.
1078. By Gustavo Pichorim Boiko

Merge latest changes from trunk.

1079. By Gustavo Pichorim Boiko

Fix build when srcdir != builddir

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1080. By Gustavo Pichorim Boiko

Fix the property installing on the messaging menu mock.

Revision history for this message
Tiago Salem Herrmann (tiagosh) :
review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1081. By Gustavo Pichorim Boiko

Add missing copyright headers and remove some commented out include files.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1082. By Gustavo Pichorim Boiko

Use the memory contacts backend in the messaging menu test.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1083. By Gustavo Pichorim Boiko

Workaround a test failure that happens only on arm64.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
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

review: Approve
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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2015-05-07 16:44:43 +0000
+++ .bzrignore 2015-06-08 18:29:15 +0000
@@ -55,4 +55,4 @@
55tests/Ubuntu.Telephony/ContactWatcherTest55tests/Ubuntu.Telephony/ContactWatcherTest
56tests/libtelephonyservice/GreeterContactsTestExe56tests/libtelephonyservice/GreeterContactsTestExe
57tests/libtelephonyservice/GreeterContactsTestServerExe57tests/libtelephonyservice/GreeterContactsTestServerExe
58tests/libtelephonyservice/ToneGeneratorMock58tests/libtelephonyservice/*Mock
5959
=== modified file 'Ubuntu/Telephony/components.cpp'
--- Ubuntu/Telephony/components.cpp 2015-04-16 22:26:23 +0000
+++ Ubuntu/Telephony/components.cpp 2015-06-08 18:29:15 +0000
@@ -24,6 +24,7 @@
24#include "telepathyhelper.h"24#include "telepathyhelper.h"
25#include "callentry.h"25#include "callentry.h"
26#include "callmanager.h"26#include "callmanager.h"
27#include "callnotification.h"
27#include "ussdmanager.h"28#include "ussdmanager.h"
28#include "channelobserver.h"29#include "channelobserver.h"
29#include "chatmanager.h"30#include "chatmanager.h"
@@ -55,6 +56,7 @@
55 mRootContext->setContextProperty("chatManager", ChatManager::instance());56 mRootContext->setContextProperty("chatManager", ChatManager::instance());
56 mRootContext->setContextProperty("callManager", CallManager::instance());57 mRootContext->setContextProperty("callManager", CallManager::instance());
57 mRootContext->setContextProperty("greeter", GreeterContacts::instance());58 mRootContext->setContextProperty("greeter", GreeterContacts::instance());
59 mRootContext->setContextProperty("callNotification", CallNotification::instance());
5860
59}61}
6062
6163
=== modified file 'cmake/modules/GenerateTest.cmake'
--- cmake/modules/GenerateTest.cmake 2015-05-07 20:36:24 +0000
+++ cmake/modules/GenerateTest.cmake 2015-06-08 18:29:15 +0000
@@ -76,7 +76,8 @@
76 set(ARG_ENVIRONMENT HOME=${TMPDIR}76 set(ARG_ENVIRONMENT HOME=${TMPDIR}
77 HISTORY_SQLITE_DBPATH=:memory:77 HISTORY_SQLITE_DBPATH=:memory:
78 MC_ACCOUNT_DIR=${TMPDIR}78 MC_ACCOUNT_DIR=${TMPDIR}
79 MC_MANAGER_DIR=${TMPDIR})79 MC_MANAGER_DIR=${TMPDIR}
80 MC_CLIENTS_DIR=${TMPDIR})
80 endif ()81 endif ()
8182
82 set(TEST_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME} ${PLATFORM} -p -o -p -,txt -p -o -p ${CMAKE_BINARY_DIR}/test_${TESTNAME}.xml,xunitxml)83 set(TEST_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME} ${PLATFORM} -p -o -p -,txt -p -o -p ${CMAKE_BINARY_DIR}/test_${TESTNAME}.xml,xunitxml)
8384
=== modified file 'indicator/Indicator.xml'
--- indicator/Indicator.xml 2015-04-28 19:18:55 +0000
+++ indicator/Indicator.xml 2015-06-08 18:29:15 +0000
@@ -14,5 +14,11 @@
14 Remove any notification currently being displayed.14 Remove any notification currently being displayed.
15 ]]></dox:d>15 ]]></dox:d>
16 </method>16 </method>
17 <method name="ClearCallNotification">
18 <dox:d><![CDATA[
19 Remove notifications for the given call
20 ]]></dox:d>
21 <arg name="targetId" type="s" direction="in"/>
22 <arg name="accountId" type="s" direction="in"/>
17 </interface>23 </interface>
18</node>24</node>
1925
=== modified file 'indicator/indicatordbus.cpp'
--- indicator/indicatordbus.cpp 2015-04-29 14:56:59 +0000
+++ indicator/indicatordbus.cpp 2015-06-08 18:29:15 +0000
@@ -23,6 +23,7 @@
2323
24#include "indicatordbus.h"24#include "indicatordbus.h"
25#include "indicatoradaptor.h"25#include "indicatoradaptor.h"
26#include "messagingmenu.h"
2627
27// Qt28// Qt
28#include <QtDBus/QDBusConnection>29#include <QtDBus/QDBusConnection>
@@ -57,3 +58,8 @@
57 Q_EMIT clearNotificationsRequested();58 Q_EMIT clearNotificationsRequested();
58}59}
5960
61void IndicatorDBus::ClearCallNotification(const QString &targetId, const QString &accountId)
62{
63 MessagingMenu::instance()->removeCall(targetId, accountId);
64}
65
6066
=== modified file 'indicator/indicatordbus.h'
--- indicator/indicatordbus.h 2015-04-29 14:56:59 +0000
+++ indicator/indicatordbus.h 2015-06-08 18:29:15 +0000
@@ -43,6 +43,7 @@
4343
44public Q_SLOTS:44public Q_SLOTS:
45 Q_NOREPLY void ClearNotifications();45 Q_NOREPLY void ClearNotifications();
46 Q_NOREPLY void ClearCallNotification(const QString &targetId, const QString &accountId);
4647
47Q_SIGNALS:48Q_SIGNALS:
48 void clearNotificationsRequested();49 void clearNotificationsRequested();
4950
=== modified file 'indicator/messagingmenu.cpp'
--- indicator/messagingmenu.cpp 2015-03-04 18:02:13 +0000
+++ indicator/messagingmenu.cpp 2015-06-08 18:29:15 +0000
@@ -310,13 +310,17 @@
310 QContactFetchRequest *request = new QContactFetchRequest(this);310 QContactFetchRequest *request = new QContactFetchRequest(this);
311 request->setFilter(QContactPhoneNumber::match(targetId));311 request->setFilter(QContactPhoneNumber::match(targetId));
312312
313 //FIXME: on arm64 the connect() statement below fails at runtime with the following output:
314 //QObject::connect: signal not found in QtContacts::QContactFetchRequest
315 // so we just disable it
316#ifndef __aarch64__
313 // place the messaging-menu item only after the contact fetch request is finished, as we can´t simply update317 // place the messaging-menu item only after the contact fetch request is finished, as we can´t simply update
314 QObject::connect(request, &QContactAbstractRequest::stateChanged, [request, call, text, this]() {318 QObject::connect(request, &QContactAbstractRequest::stateChanged, [request, call, text, this]() {
315 // only process the results after the finished state is reached319 // only process the results after the finished state is reached
316 if (request->state() != QContactAbstractRequest::FinishedState) {320 if (request->state() != QContactAbstractRequest::FinishedState) {
317 return;321 return;
318 }322 }
319323#endif
320 Call newCall = call;324 Call newCall = call;
321 if (request->contacts().size() > 0) {325 if (request->contacts().size() > 0) {
322 QContact contact = request->contacts().at(0);326 QContact contact = request->contacts().at(0);
@@ -332,8 +336,10 @@
332 }336 }
333 }337 }
334 addCallToMessagingMenu(newCall, text);338 addCallToMessagingMenu(newCall, text);
339#ifndef __aarch64__
335 });340 });
336341
342
337 // FIXME: For accounts not based on phone numbers, don't try to match contacts for now343 // FIXME: For accounts not based on phone numbers, don't try to match contacts for now
338 if (account->type() == AccountEntry::PhoneAccount) {344 if (account->type() == AccountEntry::PhoneAccount) {
339 request->setManager(ContactUtils::sharedManager());345 request->setManager(ContactUtils::sharedManager());
@@ -342,6 +348,31 @@
342 // just emit the signal to pretend we did a contact search348 // just emit the signal to pretend we did a contact search
343 Q_EMIT request->stateChanged(QContactAbstractRequest::FinishedState);349 Q_EMIT request->stateChanged(QContactAbstractRequest::FinishedState);
344 }350 }
351#endif
352}
353
354void MessagingMenu::removeCall(const QString &targetId, const QString &accountId)
355{
356 Call call;
357 bool found = false;
358 AccountEntry *account = TelepathyHelper::instance()->accountForId(accountId);
359 if (!account) {
360 qWarning() << "Account not found for id" << accountId;
361 return;
362 }
363
364 Q_FOREACH(Call callMessage, mCalls) {
365 // FIXME: we need a better strategy to group calls from different accounts
366 if (account->compareIds(callMessage.targetId, targetId)) {
367 call = callMessage;
368 found = true;
369 mCalls.removeOne(callMessage);
370
371 // remove the previous entry and add a new one increasing the missed call count
372 messaging_menu_app_remove_message_by_id(mCallsApp, callMessage.messageId.toUtf8().data());
373 break;
374 }
375 }
345}376}
346377
347void MessagingMenu::showVoicemailEntry(AccountEntry *account)378void MessagingMenu::showVoicemailEntry(AccountEntry *account)
348379
=== modified file 'indicator/messagingmenu.h'
--- indicator/messagingmenu.h 2015-03-04 18:02:13 +0000
+++ indicator/messagingmenu.h 2015-06-08 18:29:15 +0000
@@ -57,6 +57,7 @@
57 void removeMessage(const QString &messageId);57 void removeMessage(const QString &messageId);
5858
59 void addCall(const QString &targetId, const QString &accountId, const QDateTime &timestamp);59 void addCall(const QString &targetId, const QString &accountId, const QDateTime &timestamp);
60 void removeCall(const QString &targetId, const QString &accountId);
60 void addCallToMessagingMenu(Call call, const QString &text);61 void addCallToMessagingMenu(Call call, const QString &text);
6162
62 static void flashMessageActivateCallback(MessagingMenuMessage *message, const char *actionId, GVariant *param, MessagingMenu *instance);63 static void flashMessageActivateCallback(MessagingMenuMessage *message, const char *actionId, GVariant *param, MessagingMenu *instance);
6364
=== modified file 'libtelephonyservice/applicationutils.cpp'
--- libtelephonyservice/applicationutils.cpp 2013-10-07 19:20:02 +0000
+++ libtelephonyservice/applicationutils.cpp 2015-06-08 18:29:15 +0000
@@ -25,6 +25,7 @@
25#include <QDBusConnectionInterface>25#include <QDBusConnectionInterface>
26#include <QDBusInterface>26#include <QDBusInterface>
27#include <QDBusReply>27#include <QDBusReply>
28#include <QDBusServiceWatcher>
28#include <QDebug>29#include <QDebug>
29#include <QProcess>30#include <QProcess>
30#include <TelepathyQt/Constants>31#include <TelepathyQt/Constants>
3132
=== modified file 'libtelephonyservice/applicationutils.h'
--- libtelephonyservice/applicationutils.h 2013-10-07 19:20:02 +0000
+++ libtelephonyservice/applicationutils.h 2015-06-08 18:29:15 +0000
@@ -23,7 +23,6 @@
23#define APPLICATIONUTILS_H23#define APPLICATIONUTILS_H
2424
25#include <QObject>25#include <QObject>
26#include <QDBusServiceWatcher>
27#include <QUrl>26#include <QUrl>
2827
29class ApplicationUtils : public QObject28class ApplicationUtils : public QObject
3029
=== modified file 'libtelephonyservice/callnotification.cpp'
--- libtelephonyservice/callnotification.cpp 2014-02-10 18:55:35 +0000
+++ libtelephonyservice/callnotification.cpp 2015-06-08 18:29:15 +0000
@@ -20,18 +20,16 @@
20 */20 */
2121
22#include "callnotification.h"22#include "callnotification.h"
23#include "contactutils.h"
24#include "config.h"23#include "config.h"
25#include <QContactAvatar>24
26#include <QContactFetchRequest>
27#include <QContactPhoneNumber>
28#include <libnotify/notify.h>
29namespace C {25namespace C {
30#include <libintl.h>26#include <libintl.h>
31}27}
3228
33CallNotification::CallNotification(QObject *parent) :29CallNotification::CallNotification(QObject *parent) :
34 QObject(parent)30 QObject(parent), mIndicatorIface("com.canonical.TelephonyServiceIndicator",
31 "/com/canonical/TelephonyServiceIndicator",
32 "com.canonical.TelephonyServiceIndicator")
35{33{
36}34}
3735
@@ -107,3 +105,8 @@
107 request->start();105 request->start();
108#endif106#endif
109}107}
108
109void CallNotification::clearCallNotification(const QString &participantId, const QString &accountId)
110{
111 mIndicatorIface.asyncCall("ClearCallNotification", participantId, accountId);
112}
110113
=== modified file 'libtelephonyservice/callnotification.h'
--- libtelephonyservice/callnotification.h 2014-01-20 12:57:43 +0000
+++ libtelephonyservice/callnotification.h 2015-06-08 18:29:15 +0000
@@ -23,6 +23,7 @@
23#define CALLNOTIFICATION_H23#define CALLNOTIFICATION_H
2424
25#include <QObject>25#include <QObject>
26#include <QDBusInterface>
2627
27class CallNotification : public QObject28class CallNotification : public QObject
28{29{
@@ -37,9 +38,11 @@
37public Q_SLOTS:38public Q_SLOTS:
38 static CallNotification *instance();39 static CallNotification *instance();
39 void showNotificationForCall(const QStringList &participants, NotificationReason reason);40 void showNotificationForCall(const QStringList &participants, NotificationReason reason);
41 void clearCallNotification(const QString &participantId, const QString &accountId);
4042
41private:43private:
42 explicit CallNotification(QObject *parent = 0);44 explicit CallNotification(QObject *parent = 0);
45 QDBusInterface mIndicatorIface;
43};46};
4447
45#endif // CALLNOTIFICATION_H48#endif // CALLNOTIFICATION_H
4649
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2015-03-20 21:50:47 +0000
+++ tests/CMakeLists.txt 2015-06-08 18:29:15 +0000
@@ -2,5 +2,6 @@
22
3add_subdirectory(common)3add_subdirectory(common)
4add_subdirectory(handler)4add_subdirectory(handler)
5add_subdirectory(indicator)
5add_subdirectory(libtelephonyservice)6add_subdirectory(libtelephonyservice)
6add_subdirectory(Ubuntu.Telephony)7add_subdirectory(Ubuntu.Telephony)
78
=== modified file 'tests/common/CMakeLists.txt'
--- tests/common/CMakeLists.txt 2015-04-21 16:22:55 +0000
+++ tests/common/CMakeLists.txt 2015-06-08 18:29:15 +0000
@@ -1,6 +1,7 @@
1include_directories(${TP_QT5_INCLUDE_DIRS}1include_directories(${TP_QT5_INCLUDE_DIRS}
2 ${CMAKE_SOURCE_DIR}/libtelephonyservice2 ${CMAKE_SOURCE_DIR}/libtelephonyservice
3 ${CMAKE_CURRENT_BINARY_DIR})3 ${CMAKE_CURRENT_BINARY_DIR}
4 ${GSETTINGS_QT_INCLUDE_DIRS})
45
5configure_file(dbus-session.conf.in ${CMAKE_CURRENT_BINARY_DIR}/dbus-session.conf)6configure_file(dbus-session.conf.in ${CMAKE_CURRENT_BINARY_DIR}/dbus-session.conf)
67
@@ -10,7 +11,7 @@
1011
11add_library(telepathytest STATIC telepathytest.cpp telepathytest.h)12add_library(telepathytest STATIC telepathytest.cpp telepathytest.h)
12qt5_use_modules(telepathytest Core DBus)13qt5_use_modules(telepathytest Core DBus)
13target_link_libraries(telepathytest telephonyservice ${TP_QT5_LIBRARIES})14target_link_libraries(telepathytest telephonyservice ${TP_QT5_LIBRARIES} ${GSETTINGS_QT_LDFLAGS})
1415
15add_subdirectory(mock)16add_subdirectory(mock)
16add_subdirectory(dbus-services)17add_subdirectory(dbus-services)
1718
=== modified file 'tests/common/telepathytest.cpp'
--- tests/common/telepathytest.cpp 2015-04-29 20:11:14 +0000
+++ tests/common/telepathytest.cpp 2015-06-08 18:29:15 +0000
@@ -24,6 +24,11 @@
24#include "telepathyhelper.h"24#include "telepathyhelper.h"
25#include "accountentry.h"25#include "accountentry.h"
2626
27TelepathyTest::TelepathyTest() : mPhoneSettings("com.ubuntu.phone")
28{
29
30}
31
27void TelepathyTest::initialize()32void TelepathyTest::initialize()
28{33{
29 Tp::registerTypes();34 Tp::registerTypes();
3035
=== modified file 'tests/common/telepathytest.h'
--- tests/common/telepathytest.h 2015-05-08 13:28:09 +0000
+++ tests/common/telepathytest.h 2015-06-08 18:29:15 +0000
@@ -22,6 +22,7 @@
22#include <QtCore/QObject>22#include <QtCore/QObject>
23#include <QtTest/QtTest>23#include <QtTest/QtTest>
24#include <TelepathyQt/Account>24#include <TelepathyQt/Account>
25#include "qgsettings.h"
25#include <TelepathyQt/AccountManager>26#include <TelepathyQt/AccountManager>
2627
27#define DEFAULT_TIMEOUT 1500028#define DEFAULT_TIMEOUT 15000
@@ -34,6 +35,8 @@
34class TelepathyTest : public QObject35class TelepathyTest : public QObject
35{36{
36 Q_OBJECT37 Q_OBJECT
38public:
39 TelepathyTest();
3740
38protected:41protected:
39 void initialize();42 void initialize();
@@ -51,6 +54,8 @@
51private Q_SLOTS:54private Q_SLOTS:
52 void cleanup();55 void cleanup();
5356
57protected:
58 QGSettings mPhoneSettings;
54private:59private:
55 Tp::AccountManagerPtr mAccountManager;60 Tp::AccountManagerPtr mAccountManager;
56 bool mReady;61 bool mReady;
5762
=== modified file 'tests/handler/CMakeLists.txt'
--- tests/handler/CMakeLists.txt 2015-04-21 16:29:11 +0000
+++ tests/handler/CMakeLists.txt 2015-06-08 18:29:15 +0000
@@ -5,6 +5,7 @@
5 ${CMAKE_SOURCE_DIR}/libtelephonyservice5 ${CMAKE_SOURCE_DIR}/libtelephonyservice
6 ${CMAKE_BINARY_DIR}/tests/common6 ${CMAKE_BINARY_DIR}/tests/common
7 ${TP_QT5_INCLUDE_DIRS}7 ${TP_QT5_INCLUDE_DIRS}
8 ${GSETTINGS_QT_INCLUDE_DIRS}
8 )9 )
910
10generate_telepathy_test(HandlerTest SOURCES HandlerTest.cpp handlercontroller.cpp approver.cpp)11generate_telepathy_test(HandlerTest SOURCES HandlerTest.cpp handlercontroller.cpp approver.cpp)
1112
=== added directory 'tests/indicator'
=== added file 'tests/indicator/CMakeLists.txt'
--- tests/indicator/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tests/indicator/CMakeLists.txt 2015-06-08 18:29:15 +0000
@@ -0,0 +1,14 @@
1include_directories(
2 ${CMAKE_CURRENT_BINARY_DIR}
3 ${CMAKE_CURRENT_SOURCE_DIR}/../common
4 ${CMAKE_SOURCE_DIR}
5 ${CMAKE_SOURCE_DIR}/libtelephonyservice
6 ${CMAKE_SOURCE_DIR}/indicator
7 ${MESSAGING_MENU_INCLUDE_DIRS}
8 ${TP_QT5_INCLUDE_DIRS}
9 ${HISTORY_INCLUDE_DIRS}
10 )
11
12generate_telepathy_test(MessagingMenuTest
13 SOURCES MessagingMenuTest.cpp messagingmenumock.cpp ${CMAKE_SOURCE_DIR}/indicator/messagingmenu.cpp
14 LIBRARIES ${TP_QT5_LIBRARIES} telephonyservice mockcontroller telepathytest ${HISTORY_LIBRARIES})
015
=== added file 'tests/indicator/MessagingMenuTest.cpp'
--- tests/indicator/MessagingMenuTest.cpp 1970-01-01 00:00:00 +0000
+++ tests/indicator/MessagingMenuTest.cpp 2015-06-08 18:29:15 +0000
@@ -0,0 +1,86 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This file is part of telephony-service.
5 *
6 * telephony-service is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * telephony-service is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <QtCore/QObject>
20#include <QtTest/QtTest>
21#include "contactutils.h"
22#include "telepathytest.h"
23#include "messagingmenu.h"
24#include "messagingmenumock.h"
25#include "telepathyhelper.h"
26
27class MessagingMenuTest : public TelepathyTest
28{
29 Q_OBJECT
30
31private Q_SLOTS:
32 void initTestCase();
33 void cleanupTestCase();
34 void cleanup();
35 void testCallNotificationAdded();
36 void testCallNotificationRemoved();
37private:
38 Tp::AccountPtr mAccount;
39};
40
41void MessagingMenuTest::initTestCase()
42{
43 initialize();
44
45 // just trigger the creation of the mock singleton
46 MessagingMenuMock::instance();
47
48 // use the memory contact backend
49 ContactUtils::sharedManager("memory");
50
51 QSignalSpy accountAddedSpy(TelepathyHelper::instance(), SIGNAL(accountAdded(AccountEntry*)));
52 mAccount = addAccount("mock", "ofono", "theAccount");
53 QTRY_COMPARE(accountAddedSpy.count(), 1);
54}
55
56void MessagingMenuTest::cleanupTestCase()
57{
58 doCleanup();
59}
60
61void MessagingMenuTest::cleanup()
62{
63 // just to prevent the doCleanup() to run on every test
64}
65
66void MessagingMenuTest::testCallNotificationAdded()
67{
68 QString caller("12345");
69 QSignalSpy messageAddedSpy(MessagingMenuMock::instance(), SIGNAL(messageAdded(QString,QString,QString,bool)));
70 MessagingMenu::instance()->addCall(caller, mAccount->uniqueIdentifier(), QDateTime::currentDateTime());
71 QTRY_COMPARE(messageAddedSpy.count(), 1);
72 QCOMPARE(messageAddedSpy.first()[1].toString(), caller);
73}
74
75void MessagingMenuTest::testCallNotificationRemoved()
76{
77 QString caller("2345678");
78 QSignalSpy messageRemovedSpy(MessagingMenuMock::instance(), SIGNAL(messageRemoved(QString,QString)));
79 MessagingMenu::instance()->addCall(caller, mAccount->uniqueIdentifier(), QDateTime::currentDateTime());
80 MessagingMenu::instance()->removeCall(caller, mAccount->uniqueIdentifier());
81 QCOMPARE(messageRemovedSpy.count(), 1);
82 QCOMPARE(messageRemovedSpy.first()[1].toString(), caller);
83}
84
85QTEST_MAIN(MessagingMenuTest)
86#include "MessagingMenuTest.moc"
087
=== added file 'tests/indicator/messagingmenumock.cpp'
--- tests/indicator/messagingmenumock.cpp 1970-01-01 00:00:00 +0000
+++ tests/indicator/messagingmenumock.cpp 2015-06-08 18:29:15 +0000
@@ -0,0 +1,300 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This file is part of telephony-service.
5 *
6 * telephony-service is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * telephony-service is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "messagingmenumock.h"
20#include "messaging-menu.h"
21#include <QDateTime>
22#include <QDebug>
23
24MessagingMenuMock *MessagingMenuMock::instance()
25{
26 static MessagingMenuMock *self = new MessagingMenuMock();
27 return self;
28}
29
30MessagingMenuMock::MessagingMenuMock(QObject *parent) :
31 QObject(parent)
32{
33}
34
35/*** Mock implementation of messaging messaging-menu functions ***/
36
37/*** MessagingMenuApp ***/
38struct _MessagingMenuApp {
39 GObject parent_instance;
40 gchar *desktopId;
41};
42
43G_DEFINE_TYPE(MessagingMenuApp, messaging_menu_app, G_TYPE_OBJECT)
44
45enum MessageProperties
46{
47 PROP_0,
48 PROP_ID,
49 PROP_ICON,
50 PROP_TITLE,
51 PROP_SUBTITLE,
52 PROP_BODY,
53 PROP_TIME,
54 PROP_DRAWS_ATTENTION,
55 NUM_PROPERTIES
56};
57
58#define PROP_DESKTOP_ID 1
59
60static void messaging_menu_app_set_property (GObject *object,
61 guint prop_id,
62 const GValue *value,
63 GParamSpec *pspec)
64{
65 qDebug() << __PRETTY_FUNCTION__;
66 if (prop_id == PROP_DESKTOP_ID) {
67 MessagingMenuApp *app = MESSAGING_MENU_APP (object);
68 app->desktopId = g_value_dup_string (value);
69 }
70}
71
72static void messaging_menu_app_class_init (MessagingMenuAppClass *klass)
73{
74 qDebug() << __PRETTY_FUNCTION__;
75 GObjectClass *object_class = G_OBJECT_CLASS (klass);
76 object_class->set_property = messaging_menu_app_set_property;
77
78 GParamSpec *prop = g_param_spec_string ("desktop-id",
79 "Desktop Id",
80 "The desktop id of the associated application",
81 NULL,
82 (GParamFlags)(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
83
84 g_object_class_install_property (object_class, PROP_DESKTOP_ID, prop);
85}
86
87static void messaging_menu_app_init (MessagingMenuApp *app)
88{
89 qDebug() << __PRETTY_FUNCTION__;
90 Q_UNUSED(app)
91 // FIXME: check what needs implementing
92}
93
94MessagingMenuApp *messaging_menu_app_new(const gchar *desktop_id)
95{
96 qDebug() << __PRETTY_FUNCTION__;
97 MessagingMenuApp *app = (MessagingMenuApp*)g_object_new (MESSAGING_MENU_TYPE_APP,
98 "desktop-id", desktop_id,
99 NULL);
100 Q_EMIT MessagingMenuMock::instance()->appCreated(app->desktopId);
101 return app;
102}
103
104void messaging_menu_app_register(MessagingMenuApp *app)
105{
106 qDebug() << __PRETTY_FUNCTION__;
107 Q_EMIT MessagingMenuMock::instance()->appRegistered(app->desktopId);
108}
109
110void messaging_menu_app_append_source(MessagingMenuApp *app, const gchar *id, GIcon *icon, const gchar *label)
111{
112 qDebug() << __PRETTY_FUNCTION__;
113 Q_EMIT MessagingMenuMock::instance()->sourceAdded(app->desktopId, id, g_icon_to_string(icon), label);
114}
115
116/*** MessagingMenuMessage ***/
117
118struct _MessagingMenuMessage {
119 GObject parent;
120
121 gchar *id;
122 GIcon *icon;
123 gchar *title;
124 gchar *subtitle;
125 gchar *body;
126 gint64 time;
127 gboolean draws_attention;
128};
129
130typedef GObjectClass MessagingMenuMessageClass;
131G_DEFINE_TYPE (MessagingMenuMessage, messaging_menu_message, G_TYPE_OBJECT)
132
133// MessagingMenuMessage's properties
134static GParamSpec *properties[NUM_PROPERTIES];
135
136static void messaging_menu_message_get_property(GObject *object,
137 guint property_id,
138 GValue *value,
139 GParamSpec *pspec)
140{
141 MessagingMenuMessage *msg = MESSAGING_MENU_MESSAGE (object);
142
143 switch (property_id) {
144 case PROP_ID:
145 g_value_set_string (value, msg->id);
146 break;
147 case PROP_ICON:
148 g_value_set_object (value, msg->icon);
149 break;
150 case PROP_TITLE:
151 g_value_set_string (value, msg->title);
152 break;
153 case PROP_SUBTITLE:
154 g_value_set_string (value, msg->subtitle);
155 break;
156 case PROP_BODY:
157 g_value_set_string (value, msg->body);
158 break;
159 case PROP_TIME:
160 g_value_set_int64 (value, msg->time);
161 break;
162 case PROP_DRAWS_ATTENTION:
163 g_value_set_boolean (value, msg->draws_attention);
164 break;
165 default:
166 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
167 }
168}
169
170static void messaging_menu_message_set_property(GObject *object,
171 guint property_id,
172 const GValue *value,
173 GParamSpec *pspec)
174{
175 qDebug() << __PRETTY_FUNCTION__;
176 MessagingMenuMessage *msg = MESSAGING_MENU_MESSAGE (object);
177
178 switch (property_id) {
179 case PROP_ID:
180 msg->id = g_value_dup_string (value);
181 break;
182 case PROP_ICON:
183 msg->icon = (GIcon*)g_value_dup_object (value);
184 break;
185 case PROP_TITLE:
186 msg->title = g_value_dup_string (value);
187 break;
188 case PROP_SUBTITLE:
189 msg->subtitle = g_value_dup_string (value);
190 break;
191 case PROP_BODY:
192 msg->body = g_value_dup_string (value);
193 break;
194 case PROP_TIME:
195 msg->time = g_value_get_int64 (value);
196 break;
197 case PROP_DRAWS_ATTENTION:
198 msg->draws_attention = g_value_get_boolean (value);
199 break;
200 default:
201 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
202 }
203}
204static void messaging_menu_message_class_init(MessagingMenuMessageClass *klass)
205{
206 GObjectClass *object_class = G_OBJECT_CLASS (klass);
207
208 object_class->get_property = messaging_menu_message_get_property;
209 object_class->set_property = messaging_menu_message_set_property;
210
211 properties[PROP_ID] = g_param_spec_string ("id", "Id",
212 "Unique id of the message",
213 NULL,
214 (GParamFlags)(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
215 properties[PROP_ICON] = g_param_spec_object ("icon", "Icon",
216 "Icon of the message",
217 G_TYPE_ICON,
218 (GParamFlags)(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
219 properties[PROP_TITLE] = g_param_spec_string ("title", "Title",
220 "Title of the message",
221 NULL,
222 (GParamFlags)(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
223 properties[PROP_SUBTITLE] = g_param_spec_string ("subtitle", "Subtitle",
224 "Subtitle of the message",
225 NULL,
226 (GParamFlags)(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
227 properties[PROP_BODY] = g_param_spec_string ("body", "Body",
228 "First lines of the body of the message",
229 NULL,
230 (GParamFlags)(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
231 properties[PROP_TIME] = g_param_spec_int64 ("time", "Time",
232 "Time the message was sent, in microseconds", 0, G_MAXINT64, 0,
233 (GParamFlags)(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
234 properties[PROP_DRAWS_ATTENTION] = g_param_spec_boolean ("draws-attention", "Draws attention",
235 "Whether the message should draw attention",
236 TRUE,
237 (GParamFlags)(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
238 g_object_class_install_properties (klass, NUM_PROPERTIES, properties);
239
240 g_signal_new ("activate",
241 MESSAGING_MENU_TYPE_MESSAGE,
242 (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_DETAILED),
243 0,
244 NULL, NULL,
245 g_cclosure_marshal_generic,
246 G_TYPE_NONE, 2,
247 G_TYPE_STRING,
248 G_TYPE_VARIANT);
249}
250
251static void messaging_menu_message_init(MessagingMenuMessage *self)
252{
253 self->draws_attention = TRUE;
254}
255
256MessagingMenuMessage *messaging_menu_message_new(const gchar *id, GIcon *icon, const gchar *title, const gchar *subtitle, const gchar *body, gint64 time)
257{
258 qDebug() << __PRETTY_FUNCTION__;
259 MessagingMenuMessage *message = (MessagingMenuMessage*) g_object_new(MESSAGING_MENU_TYPE_MESSAGE,
260 "id", id,
261 "icon", icon,
262 "title", title,
263 "subtitle", subtitle,
264 "body", body,
265 "time", time,
266 NULL);
267 Q_EMIT MessagingMenuMock::instance()->messageCreated(QString(message->id),
268 QString(g_icon_to_string(message->icon)),
269 QString(message->title),
270 QString(message->subtitle),
271 QString(message->body),
272 QDateTime::fromMSecsSinceEpoch(time / 1000));
273
274 return message;
275}
276
277void messaging_menu_message_add_action(MessagingMenuMessage *msg, const gchar *id, const gchar *label, const GVariantType *parameter_type, GVariant *parameter_hint)
278{
279 qDebug() << __PRETTY_FUNCTION__;
280 Q_EMIT MessagingMenuMock::instance()->actionAdded(msg->id, id, label);
281}
282
283void messaging_menu_app_remove_message_by_id(MessagingMenuApp *app, const gchar *id)
284{
285 qDebug() << __PRETTY_FUNCTION__;
286 Q_EMIT MessagingMenuMock::instance()->messageRemoved(app->desktopId, id);
287}
288
289const gchar *messaging_menu_message_get_id(MessagingMenuMessage *msg)
290{
291 qDebug() << __PRETTY_FUNCTION__;
292 return msg->id;
293}
294
295void messaging_menu_app_append_message(MessagingMenuApp *app, MessagingMenuMessage *msg, const gchar *source_id, gboolean notify)
296{
297 qDebug() << __PRETTY_FUNCTION__;
298 Q_EMIT MessagingMenuMock::instance()->messageAdded(QString(app->desktopId), QString(msg->id), QString(source_id), (bool)notify);
299}
300
0301
=== added file 'tests/indicator/messagingmenumock.h'
--- tests/indicator/messagingmenumock.h 1970-01-01 00:00:00 +0000
+++ tests/indicator/messagingmenumock.h 2015-06-08 18:29:15 +0000
@@ -0,0 +1,57 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This file is part of telephony-service.
5 *
6 * telephony-service is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * telephony-service is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef MESSAGINGMENUMOCK_H
20#define MESSAGINGMENUMOCK_H
21
22#include <QObject>
23
24class MessagingMenuMock : public QObject
25{
26 Q_OBJECT
27public:
28 static MessagingMenuMock *instance();
29
30
31Q_SIGNALS:
32 void appCreated(const QString &desktopId);
33 void appRegistered(const QString &desktopId);
34 void sourceAdded(const QString &app, const QString &id, const QString &icon, const QString &label);
35
36 void messageCreated(const QString &id,
37 const QString &icon,
38 const QString &title,
39 const QString &subtitle,
40 const QString &body,
41 const QDateTime &time);
42 void messageAdded(const QString &app,
43 const QString &messageId,
44 const QString &sourceId,
45 bool notify);
46 void messageRemoved(const QString &app,
47 const QString &id);
48 void actionAdded(const QString &messageId,
49 const QString &actionId,
50 const QString &label);
51
52private:
53 explicit MessagingMenuMock(QObject *parent = 0);
54
55};
56
57#endif // MESSAGINGMENUMOCK_H
058
=== modified file 'tests/libtelephonyservice/CMakeLists.txt'
--- tests/libtelephonyservice/CMakeLists.txt 2015-05-07 16:44:43 +0000
+++ tests/libtelephonyservice/CMakeLists.txt 2015-06-08 18:29:15 +0000
@@ -5,6 +5,7 @@
5 ${TP_QT5_INCLUDE_DIRS}5 ${TP_QT5_INCLUDE_DIRS}
6 ${CMAKE_SOURCE_DIR}/tests/common6 ${CMAKE_SOURCE_DIR}/tests/common
7 ${CMAKE_BINARY_DIR}/tests/common7 ${CMAKE_BINARY_DIR}/tests/common
8 ${GSETTINGS_QT_INCLUDE_DIRS}
8 )9 )
910
10add_executable(GreeterContactsTestServerExe GreeterContactsTestServer.cpp)11add_executable(GreeterContactsTestServerExe GreeterContactsTestServer.cpp)
@@ -13,6 +14,9 @@
13add_executable(ToneGeneratorMock ToneGeneratorMock.cpp)14add_executable(ToneGeneratorMock ToneGeneratorMock.cpp)
14qt5_use_modules(ToneGeneratorMock Core DBus)15qt5_use_modules(ToneGeneratorMock Core DBus)
1516
17add_executable(IndicatorMock IndicatorMock.cpp)
18qt5_use_modules(IndicatorMock Core DBus)
19
16generate_test(GreeterContactsTest USE_DBUS20generate_test(GreeterContactsTest USE_DBUS
17 SOURCES GreeterContactsTest.cpp ${LIBTELEPHONYSERVICE_DIR}/greetercontacts.cpp21 SOURCES GreeterContactsTest.cpp ${LIBTELEPHONYSERVICE_DIR}/greetercontacts.cpp
18 QT5_MODULES Contacts Core DBus Test22 QT5_MODULES Contacts Core DBus Test
@@ -29,6 +33,12 @@
29 WAIT_FOR com.Nokia.Telephony.Tones)33 WAIT_FOR com.Nokia.Telephony.Tones)
30add_dependencies(ToneGeneratorTest ToneGeneratorMock)34add_dependencies(ToneGeneratorTest ToneGeneratorMock)
3135
36generate_test(CallNotificationTest USE_DBUS
37 SOURCES CallNotificationTest.cpp ${LIBTELEPHONYSERVICE_DIR}/callnotification.cpp
38 QT5_MODULES Core DBus Test
39 TASKS --task ${CMAKE_CURRENT_BINARY_DIR}/IndicatorMock --task-name indicator --ignore-return
40 WAIT_FOR com.canonical.TelephonyServiceIndicator)
41
32generate_test(ContactUtilsTest SOURCES ContactUtilsTest.cpp QT5_MODULES Contacts Core Test LIBRARIES telephonyservice USE_UI)42generate_test(ContactUtilsTest SOURCES ContactUtilsTest.cpp QT5_MODULES Contacts Core Test LIBRARIES telephonyservice USE_UI)
33generate_test(PhoneUtilsTest SOURCES PhoneUtilsTest.cpp LIBRARIES telephonyservice USE_UI)43generate_test(PhoneUtilsTest SOURCES PhoneUtilsTest.cpp LIBRARIES telephonyservice USE_UI)
3444
3545
=== added file 'tests/libtelephonyservice/CallNotificationTest.cpp'
--- tests/libtelephonyservice/CallNotificationTest.cpp 1970-01-01 00:00:00 +0000
+++ tests/libtelephonyservice/CallNotificationTest.cpp 2015-06-08 18:29:15 +0000
@@ -0,0 +1,67 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This file is part of telephony-service.
5 *
6 * telephony-service is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * telephony-service is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <QtCore/QObject>
20#include <QtTest/QtTest>
21#include <QDBusInterface>
22
23#include "callnotification.h"
24
25#define INDICATOR_DBUS_SERVICE_NAME "com.canonical.TelephonyServiceIndicator"
26#define INDICATOR_DBUS_OBJ_PATH "/com/canonical/TelephonyServiceIndicator"
27
28class CallNotificationTest : public QObject
29{
30 Q_OBJECT
31
32private Q_SLOTS:
33 void initTestCase();
34 void cleanupTestCase();
35 void testClearCallNotification();
36
37private:
38 QDBusInterface *mIndicatorInterface;
39};
40
41void CallNotificationTest::initTestCase()
42{
43 mIndicatorInterface = new QDBusInterface(INDICATOR_DBUS_SERVICE_NAME,
44 INDICATOR_DBUS_OBJ_PATH,
45 INDICATOR_DBUS_SERVICE_NAME,
46 QDBusConnection::sessionBus(),
47 this);
48}
49
50void CallNotificationTest::cleanupTestCase()
51{
52 mIndicatorInterface->deleteLater();
53}
54
55void CallNotificationTest::testClearCallNotification()
56{
57 QSignalSpy clearNotificationSpy(mIndicatorInterface, SIGNAL(ClearCallNotificationRequested(QString, QString)));
58 QString targetId("theTargetId");
59 QString accountId("theAccountId");
60 CallNotification::instance()->clearCallNotification(targetId, accountId);
61 QTRY_COMPARE(clearNotificationSpy.count(), 1);
62 QCOMPARE(clearNotificationSpy.first()[0].toString(), targetId);
63 QCOMPARE(clearNotificationSpy.first()[1].toString(), accountId);
64}
65
66QTEST_MAIN(CallNotificationTest)
67#include "CallNotificationTest.moc"
068
=== modified file 'tests/libtelephonyservice/ChatManagerTest.cpp'
--- tests/libtelephonyservice/ChatManagerTest.cpp 2015-05-07 16:44:43 +0000
+++ tests/libtelephonyservice/ChatManagerTest.cpp 2015-06-08 18:29:15 +0000
@@ -47,6 +47,8 @@
47void ChatManagerTest::initTestCase()47void ChatManagerTest::initTestCase()
48{48{
49 initialize();49 initialize();
50 // set to false so group chat messages are not sent as MMS
51 mPhoneSettings.set("mmsGroupChatEnabled", false);
50 TelepathyHelper::instance()->registerChannelObserver();52 TelepathyHelper::instance()->registerChannelObserver();
51}53}
5254
5355
=== added file 'tests/libtelephonyservice/IndicatorMock.cpp'
--- tests/libtelephonyservice/IndicatorMock.cpp 1970-01-01 00:00:00 +0000
+++ tests/libtelephonyservice/IndicatorMock.cpp 2015-06-08 18:29:15 +0000
@@ -0,0 +1,66 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This file is part of telephony-service.
5 *
6 * telephony-service is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * telephony-service is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <QObject>
20#include <QCoreApplication>
21#include <QDBusConnection>
22#include <QDBusMessage>
23#include <QDBusObjectPath>
24#include <QDebug>
25
26#define INDICATOR_DBUS_SERVICE_NAME "com.canonical.TelephonyServiceIndicator"
27#define INDICATOR_DBUS_OBJ_PATH "/com/canonical/TelephonyServiceIndicator"
28
29class IndicatorMock : public QObject
30{
31 Q_OBJECT
32 Q_CLASSINFO("D-Bus Interface", INDICATOR_DBUS_SERVICE_NAME)
33
34public:
35 Q_SCRIPTABLE void ClearNotifications();
36 Q_SCRIPTABLE void ClearCallNotification(const QString &targetId, const QString &accountId);
37
38Q_SIGNALS:
39 Q_SCRIPTABLE void ClearNotificationsRequested();
40 Q_SCRIPTABLE void ClearCallNotificationRequested(const QString &targetId, const QString &accountId);
41};
42
43void IndicatorMock::ClearNotifications()
44{
45 Q_EMIT ClearNotificationsRequested();
46}
47
48void IndicatorMock::ClearCallNotification(const QString &targetId, const QString &accountId)
49{
50 Q_EMIT ClearCallNotificationRequested(targetId, accountId);
51}
52
53int main(int argc, char **argv)
54{
55 QCoreApplication a(argc, argv);
56
57 QDBusConnection connection = QDBusConnection::sessionBus();
58
59 IndicatorMock toneGen;
60 connection.registerObject(INDICATOR_DBUS_OBJ_PATH, &toneGen, QDBusConnection::ExportScriptableContents);
61 connection.registerService(INDICATOR_DBUS_SERVICE_NAME);
62
63 return a.exec();
64}
65
66#include "IndicatorMock.moc"
067
=== modified file 'tests/libtelephonyservice/TelepathyHelperTest.cpp'
--- tests/libtelephonyservice/TelepathyHelperTest.cpp 2015-05-08 21:57:06 +0000
+++ tests/libtelephonyservice/TelepathyHelperTest.cpp 2015-06-08 18:29:15 +0000
@@ -255,21 +255,21 @@
255255
256 // now set one of the accounts as offline and make sure it is captured256 // now set one of the accounts as offline and make sure it is captured
257 mGenericController->SetOnline(false);257 mGenericController->SetOnline(false);
258 TRY_COMPARE(activeAccountsSpy.count(), 1);258 TRY_VERIFY(activeAccountsSpy.count() >= 1);
259 QTRY_COMPARE(TelepathyHelper::instance()->activeAccounts().count(), 1);259 QTRY_COMPARE(TelepathyHelper::instance()->activeAccounts().count(), 1);
260 QCOMPARE(TelepathyHelper::instance()->activeAccounts()[0]->accountId(), mPhoneTpAccount->uniqueIdentifier());260 QCOMPARE(TelepathyHelper::instance()->activeAccounts()[0]->accountId(), mPhoneTpAccount->uniqueIdentifier());
261261
262 // set the other account offline to make sure262 // set the other account offline to make sure
263 activeAccountsSpy.clear();263 activeAccountsSpy.clear();
264 mPhoneController->SetOnline(false);264 mPhoneController->SetOnline(false);
265 TRY_COMPARE(activeAccountsSpy.count(), 1);265 TRY_VERIFY(activeAccountsSpy.count() >= 1);
266 QVERIFY(TelepathyHelper::instance()->activeAccounts().isEmpty());266 QVERIFY(TelepathyHelper::instance()->activeAccounts().isEmpty());
267267
268 // and set both accounts online again268 // and set both accounts online again
269 activeAccountsSpy.clear();269 activeAccountsSpy.clear();
270 mGenericController->SetOnline(true);270 mGenericController->SetOnline(true);
271 mPhoneController->SetOnline(true);271 mPhoneController->SetOnline(true);
272 TRY_COMPARE(activeAccountsSpy.count(), 2);272 TRY_VERIFY(activeAccountsSpy.count() >= 2);
273 QCOMPARE(TelepathyHelper::instance()->activeAccounts().count(), 2);273 QCOMPARE(TelepathyHelper::instance()->activeAccounts().count(), 2);
274}274}
275275

Subscribers

People subscribed via source and target branches