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

Proposed by Gustavo Pichorim Boiko
Status: Merged
Approved by: Tiago Salem Herrmann
Approved revision: 1111
Merged at revision: 1106
Proposed branch: lp:~boiko/telephony-service/do_not_accept_outgoing_channels
Merge into: lp:telephony-service
Diff against target: 200 lines (+86/-9)
5 files modified
approver/approver.cpp (+7/-4)
approver/approver.h (+1/-0)
tests/approver/ApproverTest.cpp (+61/-0)
tests/common/mock/callchannel.cpp (+10/-2)
tests/handler/HandlerTest.cpp (+7/-3)
To merge this branch: bzr merge lp:~boiko/telephony-service/do_not_accept_outgoing_channels
Reviewer Review Type Date Requested Status
Tiago Salem Herrmann (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+265606@code.launchpad.net

Commit message

Make sure outgoing calls are not set as accepted by the approver.

Description of the change

Make sure outgoing calls are not set as accepted by the approver.

== 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.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
1107. By Gustavo Pichorim Boiko

Add a unit test for the bug.

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

Fix handler test.

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 :

Just one small remark.
Looks good otherwise.

review: Needs Fixing
1109. By Gustavo Pichorim Boiko

Use initialised instead of initialized to be consistent with telepathy.

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

Update tests.

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

Make sure the approver don't call accept() on call channels that are already active.

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 now. thanks.

--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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'approver/approver.cpp'
2--- approver/approver.cpp 2015-07-02 03:35:20 +0000
3+++ approver/approver.cpp 2015-07-27 19:38:20 +0000
4@@ -302,9 +302,7 @@
5 return;
6 }
7
8- bool isIncoming = channel->initiatorContact() != dispatchOp->connection()->selfContact();
9-
10- if (isIncoming && !callChannel->isRequested() && callChannel->callState() == Tp::CallStateInitialised) {
11+ if (isIncoming(channel) && !callChannel->isRequested() && callChannel->callState() == Tp::CallStateInitialised) {
12 callChannel->setRinging();
13 } else {
14 onApproved(dispatchOp);
15@@ -562,7 +560,7 @@
16 // accept all channels
17 Q_FOREACH(Tp::ChannelPtr channel, dispatchOp->channels()) {
18 Tp::CallChannelPtr callChannel = Tp::CallChannelPtr::dynamicCast(channel);
19- if (callChannel) {
20+ if (callChannel && isIncoming(callChannel) && callChannel->callState() != Tp::CallStateActive) {
21 callChannel->accept();
22 }
23 }
24@@ -591,6 +589,11 @@
25 return callDispatchOp;
26 }
27
28+bool Approver::isIncoming(const Tp::ChannelPtr &channel)
29+{
30+ return channel->initiatorContact() != channel->connection()->selfContact();
31+}
32+
33 void Approver::processChannels()
34 {
35 Q_FOREACH (Tp::ChannelDispatchOperationPtr dispatchOperation, mDispatchOps) {
36
37=== modified file 'approver/approver.h'
38--- approver/approver.h 2015-07-01 21:29:58 +0000
39+++ approver/approver.h 2015-07-27 19:38:20 +0000
40@@ -61,6 +61,7 @@
41
42 protected:
43 Tp::ChannelDispatchOperationPtr dispatchOperationForIncomingCall();
44+ bool isIncoming(const Tp::ChannelPtr &channel);
45
46 private Q_SLOTS:
47 void processChannels();
48
49=== modified file 'tests/approver/ApproverTest.cpp'
50--- tests/approver/ApproverTest.cpp 2015-07-08 21:11:14 +0000
51+++ tests/approver/ApproverTest.cpp 2015-07-27 19:38:20 +0000
52@@ -35,6 +35,8 @@
53 void cleanup();
54 void testSnapDecisionTimeout();
55 void testAcceptCall();
56+ void testCarKitOutgoingCall();
57+ void testCarKitIncomingCall();
58
59 private:
60 void waitForCallActive(const QString &callerId);
61@@ -104,5 +106,64 @@
62 mMockController->HangupCall(callerId);
63 }
64
65+void ApproverTest::testCarKitOutgoingCall()
66+{
67+ // make sure that an outgoing call placed outside of telepathy is handle correctly
68+ QString callerId("2345678");
69+
70+ QVariantMap properties;
71+ properties["Caller"] = callerId;
72+ properties["State"] = "outgoing";
73+
74+ QSignalSpy callStateSpy(mMockController, SIGNAL(CallStateChanged(QString,QString,QString)));
75+
76+ QDBusInterface notificationsMock("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications");
77+ QSignalSpy notificationSpy(&notificationsMock, SIGNAL(MockNotificationReceived(QString, uint, QString, QString, QString, QStringList, QVariantMap, int)));
78+ QString objectPath = mMockController->placeCall(properties);
79+
80+ // wait for a few seconds and check that no notification was displayed
81+ QTest::qWait(3000);
82+ QCOMPARE(notificationSpy.count(), 0);
83+
84+ // check that the call state is not "accepted"
85+ TRY_VERIFY(callStateSpy.count() > 0);
86+ QCOMPARE(callStateSpy.last()[0].toString(), callerId);
87+ QCOMPARE(callStateSpy.last()[1].toString(), objectPath);
88+ QCOMPARE(callStateSpy.last()[2].toString(), QString("initialised"));
89+ mMockController->HangupCall(callerId);
90+}
91+
92+void ApproverTest::testCarKitIncomingCall()
93+{
94+ // make sure that an outgoing call placed outside of telepathy is handle correctly
95+ QString callerId("3456789");
96+
97+ QVariantMap properties;
98+ properties["Caller"] = callerId;
99+ properties["State"] = "incoming";
100+
101+ QDBusInterface notificationsMock("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications");
102+ QSignalSpy notificationSpy(&notificationsMock, SIGNAL(MockNotificationReceived(QString, uint, QString, QString, QString, QStringList, QVariantMap, int)));
103+ QString objectPath = mMockController->placeCall(properties);
104+
105+ TRY_COMPARE(notificationSpy.count(), 1);
106+
107+ // at this point we are already sure the approver has the call, as the notification was placed
108+ QSignalSpy callStateSpy(mMockController, SIGNAL(CallStateChanged(QString,QString,QString)));
109+
110+ // now set the call state as active to simulate the call being answered on the car kit
111+ mMockController->SetCallState(callerId, "active");
112+
113+ // wait for a few seconds while the approver approves the channel and give it to the handler
114+ QTest::qWait(3000);
115+ QCOMPARE(callStateSpy.count(), 1);
116+ QCOMPARE(callStateSpy.first()[0].toString(), callerId);
117+ QCOMPARE(callStateSpy.first()[1].toString(), objectPath);
118+
119+ // the call state needs to be active. If it is in any other state, it is because the approver wrongly called Accept() on the channel
120+ QCOMPARE(callStateSpy.first()[2].toString(), QString("active"));
121+ mMockController->HangupCall(callerId);
122+}
123+
124 QTEST_MAIN(ApproverTest)
125 #include "ApproverTest.moc"
126
127=== modified file 'tests/common/mock/callchannel.cpp'
128--- tests/common/mock/callchannel.cpp 2015-07-17 18:18:57 +0000
129+++ tests/common/mock/callchannel.cpp 2015-07-27 19:38:20 +0000
130@@ -89,17 +89,19 @@
131 mIncoming = mState == "incoming" || mState == "waiting";
132
133 identifiers[mTargetHandle] = mPhoneNumber;
134+
135 reason.actor = 0;
136 reason.reason = Tp::CallStateChangeReasonProgressMade;
137 reason.message = "";
138 reason.DBusReason = "";
139+
140 if (mIncoming) {
141 memberFlags[mTargetHandle] = 0;
142 } else {
143 memberFlags[mTargetHandle] = Tp::CallMemberFlagRinging;
144 }
145
146- mCallChannel->setCallState(Tp::CallStateInitialising, 0, reason, stateDetails);
147+ setCallState("initialising");
148
149 mCallContent = Tp::BaseCallContent::create(baseChannel()->dbusConnection(), baseChannel().data(), "audio", Tp::MediaStreamTypeAudio, Tp::MediaStreamDirectionNone);
150
151@@ -112,7 +114,7 @@
152
153 mCallChannel->setMembersFlags(memberFlags, identifiers, Tp::UIntList(), reason);
154
155- mCallChannel->setCallState(Tp::CallStateInitialised, 0, reason, stateDetails);
156+ setCallState("initialised");
157 QObject::connect(mBaseChannel.data(), SIGNAL(closed()), this, SLOT(deleteLater()));
158 }
159
160@@ -223,6 +225,12 @@
161 } else if (state == "waiting") {
162 mIncoming = true;
163 qDebug() << "waiting";
164+ } else if (state == "initialising") {
165+ reason.reason = Tp::CallStateChangeReasonProgressMade;
166+ mCallChannel->setCallState(Tp::CallStateInitialising, 0, reason, stateDetails);
167+ } else if (state == "initialised") {
168+ reason.reason = Tp::CallStateChangeReasonProgressMade;
169+ mCallChannel->setCallState(Tp::CallStateInitialised, 0, reason, stateDetails);
170 }
171
172 mState = state;
173
174=== modified file 'tests/handler/HandlerTest.cpp'
175--- tests/handler/HandlerTest.cpp 2015-07-02 00:07:05 +0000
176+++ tests/handler/HandlerTest.cpp 2015-07-27 19:38:20 +0000
177@@ -306,7 +306,8 @@
178 void HandlerTest::testNotApprovedChannels()
179 {
180 QVariantMap properties;
181- properties["Caller"] = "123456";
182+ QString callerId = "123456";
183+ properties["Caller"] = callerId;
184 properties["State"] = "incoming";
185
186 QSignalSpy approverCallSpy(mApprover, SIGNAL(newCall()));
187@@ -324,8 +325,11 @@
188 // wait for a few seconds
189 QTest::qWait(3000);
190
191- // no state changes should happen, as the channel was not accepted
192- QVERIFY(callStateSpy.isEmpty());
193+ // the last state received should be initialised
194+ TRY_VERIFY(callStateSpy.count() > 0);
195+ QCOMPARE(callStateSpy.last()[0].toString(), callerId);
196+ QCOMPARE(callStateSpy.last()[1].toString(), objectPath);
197+ QCOMPARE(callStateSpy.last()[2].toString(), QString("initialised"));
198 }
199
200 void HandlerTest::registerApprover()

Subscribers

People subscribed via source and target branches