Merge lp:~boiko/telephony-service/fix_voicemail_detection into lp:telephony-service
- fix_voicemail_detection
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Tiago Salem Herrmann |
Approved revision: | 1083 |
Merged at revision: | 1071 |
Proposed branch: | lp:~boiko/telephony-service/fix_voicemail_detection |
Merge into: | lp:telephony-service |
Diff against target: |
1384 lines (+342/-159) 20 files modified
.bzrignore (+1/-0) cmake/modules/GenerateTest.cmake (+0/-1) libtelephonyservice/accountentry.cpp (+7/-2) libtelephonyservice/accountentry.h (+2/-0) libtelephonyservice/callentry.cpp (+1/-1) libtelephonyservice/ofonoaccountentry.cpp (+3/-1) libtelephonyservice/telepathyhelper.cpp (+1/-0) libtelephonyservice/telepathyhelper.h (+1/-0) tests/common/mock/connection.cpp (+10/-2) tests/common/mock/connection.h (+1/-0) tests/common/mock/mockconnectiondbus.cpp (+24/-0) tests/common/telepathytest.cpp (+13/-20) tests/common/telepathytest.h (+7/-1) tests/handler/HandlerTest.cpp (+23/-26) tests/libtelephonyservice/AccountEntryTest.cpp (+30/-34) tests/libtelephonyservice/CMakeLists.txt (+1/-0) tests/libtelephonyservice/CallEntryTest.cpp (+129/-0) tests/libtelephonyservice/ChatManagerTest.cpp (+9/-13) tests/libtelephonyservice/OfonoAccountEntryTest.cpp (+29/-31) tests/libtelephonyservice/TelepathyHelperTest.cpp (+50/-27) |
To merge this branch: | bzr merge lp:~boiko/telephony-service/fix_voicemail_detection |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Tiago Salem Herrmann (community) | Approve | ||
Review via email: mp+257694@code.launchpad.net |
Commit message
Fix voicemail detection on CallEntry.
Description of the change
Fix voicemail detection on CallEntry.
== 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
PS Jenkins bot (ps-jenkins) wrote : | # |
- 1066. By Gustavo Pichorim Boiko
-
Try to fix some flakiness.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1066
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 1067. By Gustavo Pichorim Boiko
-
Increase the timeout of all tests so that slow builders don't fail.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1067
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1068. By Gustavo Pichorim Boiko
-
Change the tests in a hope to finally remove the flakiness.
- 1069. By Gustavo Pichorim Boiko
-
Fix some possible points of flakiness. The connectedChanged() signal might be emitted more than just once.
- 1070. By Gustavo Pichorim Boiko
-
Use the account from telepathyhelper in the callentry test.
- 1071. By Gustavo Pichorim Boiko
-
Re-add dbus-monitor to debug the test failures.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1068
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1072. By Gustavo Pichorim Boiko
-
And one more.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1072
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1073. By Gustavo Pichorim Boiko
-
Only set mReady when the connection is actually ready.
- 1074. By Gustavo Pichorim Boiko
-
Revert the mReady change.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1074
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1075. By Gustavo Pichorim Boiko
-
Sometimes multiple status changed signals are emitted, so account for that in the tests.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1075
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1076. By Gustavo Pichorim Boiko
-
Some more test fixes.
- 1077. By Gustavo Pichorim Boiko
-
Merge latest changes from trunk.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1077
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 1078. By Gustavo Pichorim Boiko
-
Add debug on the mock dbus calls.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1078
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1079. By Gustavo Pichorim Boiko
-
Wait for the AccountEntry to change the status.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1079
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1080. By Gustavo Pichorim Boiko
-
Only set offline when really necessary.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1080
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1081. By Gustavo Pichorim Boiko
-
Fix some more flakiness points.
- 1082. By Gustavo Pichorim Boiko
-
Ignore status changes from the client side to mimic the behavior of telepathy-ofono.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1081
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1082
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Tiago Salem Herrmann (tiagosh) : | # |
- 1083. By Gustavo Pichorim Boiko
-
Not having a voicemail number is just a warning, not critical.
Gustavo Pichorim Boiko (boiko) wrote : | # |
Questions replied.
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.
No, not related to the changes.
Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
Yes
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1082
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1082
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2015-04-22 13:44:53 +0000 |
3 | +++ .bzrignore 2015-05-11 13:17:00 +0000 |
4 | @@ -33,6 +33,7 @@ |
5 | indicator/*.desktop |
6 | indicator/*.service |
7 | indicator/NotificationsInterface.* |
8 | +indicator/indicatoradaptor.* |
9 | |
10 | Testing |
11 | Ubuntu/Telephony/qmldir |
12 | |
13 | === modified file 'cmake/modules/GenerateTest.cmake' |
14 | --- cmake/modules/GenerateTest.cmake 2015-04-22 13:20:02 +0000 |
15 | +++ cmake/modules/GenerateTest.cmake 2015-05-11 13:17:00 +0000 |
16 | @@ -113,7 +113,6 @@ |
17 | --task dconf -p write -p /org/gnome/empathy/use-conn -p false --task-name dconf-write --wait-for ca.desrt.dconf --ignore-return |
18 | --task /usr/lib/telepathy/mission-control-5 --task-name mission-control --wait-for ca.desrt.dconf --ignore-return |
19 | --task ${CMAKE_BINARY_DIR}/tests/common/mock/telepathy-mock --task-name telepathy-mock --wait-for org.freedesktop.Telepathy.MissionControl5 --ignore-return |
20 | - --task dbus-monitor --task-name dbus-monitor --ignore-return |
21 | # FIXME: maybe it would be better to decide whether to run the handler in a per-test basis? |
22 | --task ${CMAKE_BINARY_DIR}/handler/telephony-service-handler --task-name telephony-service-handler --wait-for org.freedesktop.Telepathy.ConnectionManager.mock --ignore-return |
23 | ${ARG_TASKS}) |
24 | |
25 | === modified file 'libtelephonyservice/accountentry.cpp' |
26 | --- libtelephonyservice/accountentry.cpp 2015-04-16 16:45:59 +0000 |
27 | +++ libtelephonyservice/accountentry.cpp 2015-05-11 13:17:00 +0000 |
28 | @@ -22,14 +22,18 @@ |
29 | #include <TelepathyQt/PendingOperation> |
30 | #include <QTimer> |
31 | #include "accountentry.h" |
32 | -#include "telepathyhelper.h" |
33 | |
34 | AccountEntry::AccountEntry(const Tp::AccountPtr &account, QObject *parent) : |
35 | - QObject(parent), mAccount(account) |
36 | + QObject(parent), mAccount(account), mReady(false) |
37 | { |
38 | initialize(); |
39 | } |
40 | |
41 | +bool AccountEntry::ready() const |
42 | +{ |
43 | + return mReady; |
44 | +} |
45 | + |
46 | QString AccountEntry::accountId() const |
47 | { |
48 | if (mAccount.isNull()) { |
49 | @@ -184,6 +188,7 @@ |
50 | onConnectionChanged(); |
51 | } |
52 | |
53 | + mReady = true; |
54 | Q_EMIT accountReady(); |
55 | } |
56 | |
57 | |
58 | === modified file 'libtelephonyservice/accountentry.h' |
59 | --- libtelephonyservice/accountentry.h 2015-04-14 17:25:36 +0000 |
60 | +++ libtelephonyservice/accountentry.h 2015-05-11 13:17:00 +0000 |
61 | @@ -51,6 +51,7 @@ |
62 | GenericAccount |
63 | }; |
64 | |
65 | + bool ready() const; |
66 | QString accountId() const; |
67 | bool active() const; |
68 | QString displayName() const; |
69 | @@ -90,6 +91,7 @@ |
70 | |
71 | Tp::AccountPtr mAccount; |
72 | ConnectionInfo mConnectionInfo; |
73 | + bool mReady; |
74 | }; |
75 | |
76 | #endif // ACCOUNTENTRY_H |
77 | |
78 | === modified file 'libtelephonyservice/callentry.cpp' |
79 | --- libtelephonyservice/callentry.cpp 2015-02-06 20:44:14 +0000 |
80 | +++ libtelephonyservice/callentry.cpp 2015-05-11 13:17:00 +0000 |
81 | @@ -79,7 +79,7 @@ |
82 | |
83 | // in case the account is an ofono account, we can check the voicemail number |
84 | OfonoAccountEntry *ofonoAccount = qobject_cast<OfonoAccountEntry*>(mAccount); |
85 | - if (ofonoAccount && ofonoAccount->voicemailNumber().isEmpty()) { |
86 | + if (ofonoAccount && !ofonoAccount->voicemailNumber().isEmpty()) { |
87 | setVoicemail(phoneNumber() == ofonoAccount->voicemailNumber()); |
88 | } |
89 | |
90 | |
91 | === modified file 'libtelephonyservice/ofonoaccountentry.cpp' |
92 | --- libtelephonyservice/ofonoaccountentry.cpp 2015-04-16 22:26:23 +0000 |
93 | +++ libtelephonyservice/ofonoaccountentry.cpp 2015-05-11 13:17:00 +0000 |
94 | @@ -20,8 +20,8 @@ |
95 | */ |
96 | |
97 | #include "ofonoaccountentry.h" |
98 | +#include "phoneutils.h" |
99 | #include "telepathyhelper.h" |
100 | -#include "phoneutils.h" |
101 | |
102 | OfonoAccountEntry::OfonoAccountEntry(const Tp::AccountPtr &account, QObject *parent) : |
103 | AccountEntry(account, parent), mVoicemailCount(0), mVoicemailIndicator(false) |
104 | @@ -181,6 +181,8 @@ |
105 | if (replyNumber.isValid()) { |
106 | mVoicemailNumber = replyNumber.value(); |
107 | Q_EMIT voicemailNumberChanged(); |
108 | + } else { |
109 | + qWarning() << "Could not get voicemail number!"; |
110 | } |
111 | |
112 | // connect the voicemail count changed signal |
113 | |
114 | === modified file 'libtelephonyservice/telepathyhelper.cpp' |
115 | --- libtelephonyservice/telepathyhelper.cpp 2015-04-17 20:09:25 +0000 |
116 | +++ libtelephonyservice/telepathyhelper.cpp 2015-05-11 13:17:00 +0000 |
117 | @@ -451,6 +451,7 @@ |
118 | Q_EMIT activeAccountsChanged(); |
119 | onSettingsChanged("defaultSimForMessages"); |
120 | onSettingsChanged("defaultSimForCalls"); |
121 | + Q_EMIT accountAdded(accountEntry); |
122 | } |
123 | |
124 | void TelepathyHelper::onAccountManagerReady(Tp::PendingOperation *op) |
125 | |
126 | === modified file 'libtelephonyservice/telepathyhelper.h' |
127 | --- libtelephonyservice/telepathyhelper.h 2015-04-17 20:09:25 +0000 |
128 | +++ libtelephonyservice/telepathyhelper.h 2015-05-11 13:17:00 +0000 |
129 | @@ -110,6 +110,7 @@ |
130 | void connectedChanged(); |
131 | void accountIdsChanged(); |
132 | void accountsChanged(); |
133 | + void accountAdded(AccountEntry *account); |
134 | void phoneAccountsChanged(); |
135 | void activeAccountsChanged(); |
136 | void setupReady(); |
137 | |
138 | === modified file 'tests/common/mock/connection.cpp' |
139 | --- tests/common/mock/connection.cpp 2015-04-17 19:52:20 +0000 |
140 | +++ tests/common/mock/connection.cpp 2015-05-11 13:17:00 +0000 |
141 | @@ -77,7 +77,7 @@ |
142 | |
143 | // init presence interface |
144 | simplePresenceIface = Tp::BaseConnectionSimplePresenceInterface::create(); |
145 | - simplePresenceIface->setSetPresenceCallback(Tp::memFun(this,&MockConnection::setPresence)); |
146 | + simplePresenceIface->setSetPresenceCallback(Tp::memFun(this,&MockConnection::setPresenceFail)); |
147 | simplePresenceIface->setMaxmimumStatusMessageLength(255); |
148 | plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(simplePresenceIface)); |
149 | |
150 | @@ -137,7 +137,7 @@ |
151 | plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(voicemailIface)); |
152 | voicemailIface->setVoicemailCount(mVoicemailCount); |
153 | voicemailIface->setVoicemailIndicator(mVoicemailIndicator); |
154 | - mVoicemailNumber = "555"; |
155 | + mVoicemailNumber = "*555"; |
156 | |
157 | supplementaryServicesIface = BaseConnectionUSSDInterface::create(); |
158 | supplementaryServicesIface->setInitiateCallback(Tp::memFun(this,&MockConnection::USSDInitiate)); |
159 | @@ -151,6 +151,8 @@ |
160 | plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(supplementaryServicesIface)); |
161 | |
162 | mDBus = new MockConnectionDBus(this); |
163 | + |
164 | + setOnline(true); |
165 | } |
166 | |
167 | MockConnection::~MockConnection() |
168 | @@ -232,6 +234,12 @@ |
169 | return selfHandle(); |
170 | } |
171 | |
172 | +uint MockConnection::setPresenceFail(const QString &status, const QString &statusMessage, Tp::DBusError *error) |
173 | +{ |
174 | + error->set(TP_QT_ERROR_NOT_AVAILABLE, "Can't change online status: Operation not supported"); |
175 | + return selfHandle(); |
176 | +} |
177 | + |
178 | Tp::ContactAttributesMap MockConnection::getContactAttributes(const Tp::UIntList &handles, const QStringList &ifaces, Tp::DBusError *error) |
179 | { |
180 | qDebug() << "getContactAttributes" << handles << ifaces; |
181 | |
182 | === modified file 'tests/common/mock/connection.h' |
183 | --- tests/common/mock/connection.h 2015-04-17 19:52:20 +0000 |
184 | +++ tests/common/mock/connection.h 2015-05-11 13:17:00 +0000 |
185 | @@ -59,6 +59,7 @@ |
186 | uint targetHandle, const QVariantMap& hints, Tp::DBusError *error); |
187 | Tp::ContactAttributesMap getContactAttributes(const Tp::UIntList &handles, const QStringList &ifaces, Tp::DBusError *error); |
188 | uint setPresence(const QString& status, const QString& statusMessage, Tp::DBusError *error); |
189 | + uint setPresenceFail(const QString& status, const QString& statusMessage, Tp::DBusError *error); |
190 | void connect(Tp::DBusError *error); |
191 | void setOnline(bool online); |
192 | |
193 | |
194 | === modified file 'tests/common/mock/mockconnectiondbus.cpp' |
195 | --- tests/common/mock/mockconnectiondbus.cpp 2015-04-17 19:52:20 +0000 |
196 | +++ tests/common/mock/mockconnectiondbus.cpp 2015-05-11 13:17:00 +0000 |
197 | @@ -93,121 +93,145 @@ |
198 | |
199 | void MockConnectionDBus::PlaceIncomingMessage(const QString &message, const QVariantMap &properties) |
200 | { |
201 | + qDebug() << __PRETTY_FUNCTION__ << message << properties; |
202 | mConnection->placeIncomingMessage(message, properties); |
203 | } |
204 | |
205 | QString MockConnectionDBus::PlaceCall(const QVariantMap &properties) |
206 | { |
207 | + qDebug() << __PRETTY_FUNCTION__ << properties; |
208 | return mConnection->placeCall(properties); |
209 | } |
210 | |
211 | void MockConnectionDBus::HangupCall(const QString &callerId) |
212 | { |
213 | + qDebug() << __PRETTY_FUNCTION__ << callerId; |
214 | mConnection->hangupCall(callerId); |
215 | } |
216 | |
217 | void MockConnectionDBus::SetCallState(const QString &phoneNumber, const QString &state) |
218 | { |
219 | + qDebug() << __PRETTY_FUNCTION__ << phoneNumber << state; |
220 | mConnection->setCallState(phoneNumber, state); |
221 | } |
222 | |
223 | void MockConnectionDBus::SetOnline(bool online) |
224 | { |
225 | + qDebug() << __PRETTY_FUNCTION__ << online; |
226 | mConnection->setOnline(online); |
227 | } |
228 | |
229 | void MockConnectionDBus::SetPresence(const QString &status, const QString &statusMessage) |
230 | { |
231 | + qDebug() << __PRETTY_FUNCTION__ << status << statusMessage; |
232 | Tp::DBusError error; |
233 | mConnection->setPresence(status, statusMessage, &error); |
234 | } |
235 | |
236 | void MockConnectionDBus::SetVoicemailIndicator(bool active) |
237 | { |
238 | + qDebug() << __PRETTY_FUNCTION__ << active; |
239 | mConnection->setVoicemailIndicator(active); |
240 | } |
241 | |
242 | void MockConnectionDBus::SetVoicemailNumber(const QString &number) |
243 | { |
244 | + qDebug() << __PRETTY_FUNCTION__ << number; |
245 | mConnection->setVoicemailNumber(number); |
246 | } |
247 | |
248 | void MockConnectionDBus::SetVoicemailCount(int count) |
249 | { |
250 | + qDebug() << __PRETTY_FUNCTION__ << count; |
251 | mConnection->setVoicemailCount(count); |
252 | } |
253 | |
254 | void MockConnectionDBus::SetEmergencyNumbers(const QStringList &numbers) |
255 | { |
256 | + qDebug() << __PRETTY_FUNCTION__ << numbers; |
257 | mConnection->setEmergencyNumbers(numbers); |
258 | } |
259 | |
260 | QString MockConnectionDBus::Serial() |
261 | { |
262 | + qDebug() << __PRETTY_FUNCTION__ << mConnection->serial(); |
263 | return mConnection->serial(); |
264 | } |
265 | |
266 | void MockConnectionDBus::TriggerUSSDNotificationReceived(const QString &message) |
267 | { |
268 | + qDebug() << __PRETTY_FUNCTION__ << message; |
269 | mConnection->supplementaryServicesIface->NotificationReceived(message); |
270 | } |
271 | |
272 | void MockConnectionDBus::TriggerUSSDRequestReceived(const QString &message) |
273 | { |
274 | + qDebug() << __PRETTY_FUNCTION__ << message; |
275 | mConnection->supplementaryServicesIface->RequestReceived(message); |
276 | } |
277 | |
278 | void MockConnectionDBus::TriggerUSSDInitiateUSSDComplete(const QString &ussdResp) |
279 | { |
280 | + qDebug() << __PRETTY_FUNCTION__ << ussdResp; |
281 | mConnection->supplementaryServicesIface->InitiateUSSDComplete(ussdResp); |
282 | } |
283 | |
284 | void MockConnectionDBus::TriggerUSSDRespondComplete(bool success, const QString &ussdResp) |
285 | { |
286 | + qDebug() << __PRETTY_FUNCTION__ << ussdResp; |
287 | mConnection->supplementaryServicesIface->RespondComplete(success, ussdResp); |
288 | } |
289 | |
290 | void MockConnectionDBus::TriggerUSSDBarringComplete(const QString &ssOp, const QString &cbService, const QVariantMap &cbMap) |
291 | { |
292 | + qDebug() << __PRETTY_FUNCTION__ << ssOp << cbService << cbMap; |
293 | mConnection->supplementaryServicesIface->BarringComplete(ssOp, cbService, cbMap); |
294 | } |
295 | |
296 | void MockConnectionDBus::TriggerUSSDForwardingComplete(const QString &ssOp, const QString &cfService, const QVariantMap &cfMap) |
297 | { |
298 | + qDebug() << __PRETTY_FUNCTION__ << ssOp << cfService << cfMap; |
299 | mConnection->supplementaryServicesIface->ForwardingComplete(ssOp, cfService, cfMap); |
300 | } |
301 | |
302 | void MockConnectionDBus::TriggerUSSDWaitingComplete(const QString &ssOp, const QVariantMap &cwMap) |
303 | { |
304 | + qDebug() << __PRETTY_FUNCTION__ << ssOp << cwMap; |
305 | mConnection->supplementaryServicesIface->WaitingComplete(ssOp, cwMap); |
306 | } |
307 | |
308 | void MockConnectionDBus::TriggerUSSDCallingLinePresentationComplete(const QString &ssOp, const QString &status) |
309 | { |
310 | + qDebug() << __PRETTY_FUNCTION__ << ssOp << status; |
311 | mConnection->supplementaryServicesIface->CallingLinePresentationComplete(ssOp, status); |
312 | } |
313 | |
314 | void MockConnectionDBus::TriggerUSSDConnectedLinePresentationComplete(const QString &ssOp, const QString &status) |
315 | { |
316 | + qDebug() << __PRETTY_FUNCTION__ << ssOp << status; |
317 | mConnection->supplementaryServicesIface->ConnectedLinePresentationComplete(ssOp, status); |
318 | } |
319 | |
320 | void MockConnectionDBus::TriggerUSSDCallingLineRestrictionComplete(const QString &ssOp, const QString &status) |
321 | { |
322 | + qDebug() << __PRETTY_FUNCTION__ << ssOp << status; |
323 | mConnection->supplementaryServicesIface->CallingLineRestrictionComplete(ssOp, status); |
324 | } |
325 | |
326 | void MockConnectionDBus::TriggerUSSDConnectedLineRestrictionComplete(const QString &ssOp, const QString &status) |
327 | { |
328 | + qDebug() << __PRETTY_FUNCTION__ << ssOp << status; |
329 | mConnection->supplementaryServicesIface->ConnectedLineRestrictionComplete(ssOp, status); |
330 | } |
331 | |
332 | void MockConnectionDBus::TriggerUSSDInitiateFailed() |
333 | { |
334 | + qDebug() << __PRETTY_FUNCTION__; |
335 | mConnection->supplementaryServicesIface->InitiateFailed(); |
336 | } |
337 | |
338 | void MockConnectionDBus::TriggerUSSDStateChanged(const QString &state) |
339 | { |
340 | + qDebug() << __PRETTY_FUNCTION__ << state; |
341 | mConnection->supplementaryServicesIface->StateChanged(state); |
342 | } |
343 | |
344 | === modified file 'tests/common/telepathytest.cpp' |
345 | --- tests/common/telepathytest.cpp 2015-03-27 02:47:52 +0000 |
346 | +++ tests/common/telepathytest.cpp 2015-05-11 13:17:00 +0000 |
347 | @@ -17,7 +17,6 @@ |
348 | */ |
349 | |
350 | #include <QtCore/QObject> |
351 | -#include <QtTest/QtTest> |
352 | #include <TelepathyQt/PendingAccount> |
353 | #include <TelepathyQt/PendingOperation> |
354 | #include <TelepathyQt/Account> |
355 | @@ -29,15 +28,6 @@ |
356 | { |
357 | Tp::registerTypes(); |
358 | |
359 | - QSignalSpy spy(TelepathyHelper::instance(), SIGNAL(setupReady())); |
360 | - QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, DEFAULT_TIMEOUT); |
361 | - |
362 | - // just in case, remove any existing account that might be a leftover from |
363 | - // previous test runs |
364 | - Q_FOREACH(const AccountEntry *account, TelepathyHelper::instance()->accounts()) { |
365 | - QVERIFY(removeAccount(account->account())); |
366 | - } |
367 | - |
368 | // create an account manager instance to help testing |
369 | Tp::Features accountFeatures; |
370 | accountFeatures << Tp::Account::FeatureCore |
371 | @@ -65,13 +55,15 @@ |
372 | mReady = false; |
373 | connect(mAccountManager->becomeReady(Tp::AccountManager::FeatureCore), |
374 | &Tp::PendingOperation::finished, [=]{ |
375 | + Q_FOREACH(const Tp::AccountPtr &account, mAccountManager->allAccounts()) { |
376 | + Tp::PendingOperation *op = account->remove(); |
377 | + WAIT_FOR(op->isFinished()); |
378 | + } |
379 | + |
380 | mReady = true; |
381 | }); |
382 | |
383 | - QTRY_VERIFY(mReady); |
384 | - |
385 | - // give some time for telepathy stuff to settle |
386 | - QTest::qWait(1000); |
387 | + TRY_VERIFY(mReady); |
388 | } |
389 | |
390 | void TelepathyTest::doCleanup() |
391 | @@ -101,9 +93,11 @@ |
392 | finished = true; |
393 | }); |
394 | |
395 | - while (!finished) { |
396 | - QTest::qWait(100); |
397 | - } |
398 | + WAIT_FOR(finished); |
399 | + WAIT_FOR(!account->connection().isNull()); |
400 | + WAIT_FOR(account->connectionStatus() == Tp::ConnectionStatusConnected); |
401 | + WAIT_FOR(account->connection()->selfContact()->presence().type() == Tp::ConnectionPresenceTypeAvailable); |
402 | + |
403 | mAccounts << account; |
404 | return account; |
405 | } |
406 | @@ -119,9 +113,8 @@ |
407 | finished = true; |
408 | }); |
409 | |
410 | - while (!finished) { |
411 | - QTest::qWait(100); |
412 | - } |
413 | + WAIT_FOR(finished); |
414 | + |
415 | if (success) { |
416 | mAccounts.removeAll(account); |
417 | } |
418 | |
419 | === modified file 'tests/common/telepathytest.h' |
420 | --- tests/common/telepathytest.h 2015-03-30 18:48:38 +0000 |
421 | +++ tests/common/telepathytest.h 2015-05-11 13:17:00 +0000 |
422 | @@ -20,11 +20,17 @@ |
423 | #define TELEPATHYTEST_H |
424 | |
425 | #include <QtCore/QObject> |
426 | +#include <QtTest/QtTest> |
427 | #include <TelepathyQt/Account> |
428 | -#include "telepathyhelper.h" |
429 | +#include <TelepathyQt/AccountManager> |
430 | |
431 | #define DEFAULT_TIMEOUT 15000 |
432 | |
433 | +#define TRY_VERIFY(x) QTRY_VERIFY_WITH_TIMEOUT((x), DEFAULT_TIMEOUT) |
434 | +#define TRY_COMPARE(x, y) QTRY_COMPARE_WITH_TIMEOUT((x), (y), DEFAULT_TIMEOUT) |
435 | + |
436 | +#define WAIT_FOR(x) while (!(x)) { qDebug() << "Waiting for:" << #x ; QTest::qWait(100); } |
437 | + |
438 | class TelepathyTest : public QObject |
439 | { |
440 | Q_OBJECT |
441 | |
442 | === modified file 'tests/handler/HandlerTest.cpp' |
443 | --- tests/handler/HandlerTest.cpp 2015-04-17 21:26:25 +0000 |
444 | +++ tests/handler/HandlerTest.cpp 2015-05-11 13:17:00 +0000 |
445 | @@ -53,22 +53,19 @@ |
446 | { |
447 | initialize(); |
448 | |
449 | + QSignalSpy setupReadySpy(TelepathyHelper::instance(), SIGNAL(setupReady())); |
450 | + TRY_COMPARE(setupReadySpy.count(), 1); |
451 | + |
452 | // register the approver |
453 | mApprover = new Approver(this); |
454 | TelepathyHelper::instance()->registerClient(mApprover, "TelephonyTestApprover"); |
455 | // Tp-qt does not set registered status to approvers |
456 | - QTRY_VERIFY(QDBusConnection::sessionBus().interface()->isServiceRegistered(TELEPHONY_SERVICE_APPROVER)); |
457 | + TRY_VERIFY(QDBusConnection::sessionBus().interface()->isServiceRegistered(TELEPHONY_SERVICE_APPROVER)); |
458 | } |
459 | |
460 | void HandlerTest::init() |
461 | { |
462 | mTpAccount = addAccount("mock", "mock", "the account"); |
463 | - QVERIFY(!mTpAccount.isNull()); |
464 | - QTRY_VERIFY(mTpAccount->isReady(Tp::Account::FeatureCore)); |
465 | - |
466 | - // make sure the connection is available |
467 | - QTRY_VERIFY(!mTpAccount->connection().isNull()); |
468 | - QTRY_COMPARE(mTpAccount->connection()->selfContact()->presence().type(), Tp::ConnectionPresenceTypeAvailable); |
469 | |
470 | // and create the mock controller |
471 | mMockController = new MockController("mock", this); |
472 | @@ -86,7 +83,7 @@ |
473 | QSignalSpy callReceivedSpy(mMockController, SIGNAL(CallReceived(QString))); |
474 | // FIXME: add support for multiple accounts |
475 | HandlerController::instance()->startCall(callerId, mTpAccount->uniqueIdentifier()); |
476 | - QTRY_COMPARE(callReceivedSpy.count(), 1); |
477 | + TRY_COMPARE(callReceivedSpy.count(), 1); |
478 | QCOMPARE(callReceivedSpy.first().first().toString(), callerId); |
479 | |
480 | mMockController->HangupCall(callerId); |
481 | @@ -105,7 +102,7 @@ |
482 | QVERIFY(!objectPath.isEmpty()); |
483 | |
484 | // wait for the channel to hit the approver |
485 | - QTRY_COMPARE(approverCallSpy.count(), 1); |
486 | + TRY_COMPARE(approverCallSpy.count(), 1); |
487 | mApprover->acceptCall(); |
488 | |
489 | waitForCallActive(callerId); |
490 | @@ -113,7 +110,7 @@ |
491 | // and finally request the hangup |
492 | QSignalSpy callEndedSpy(mMockController, SIGNAL(CallEnded(QString))); |
493 | HandlerController::instance()->hangUpCall(objectPath); |
494 | - QTRY_COMPARE(callEndedSpy.count(), 1); |
495 | + TRY_COMPARE(callEndedSpy.count(), 1); |
496 | } |
497 | |
498 | void HandlerTest::testCallHold() |
499 | @@ -129,7 +126,7 @@ |
500 | QVERIFY(!objectPath.isEmpty()); |
501 | |
502 | // wait for the channel to hit the approver |
503 | - QTRY_COMPARE(approverCallSpy.count(), 1); |
504 | + TRY_COMPARE(approverCallSpy.count(), 1); |
505 | mApprover->acceptCall(); |
506 | |
507 | waitForCallActive(callerId); |
508 | @@ -138,13 +135,13 @@ |
509 | |
510 | // set the call on hold |
511 | HandlerController::instance()->setHold(objectPath, true); |
512 | - QTRY_COMPARE(callStateSpy.count(), 1); |
513 | + TRY_COMPARE(callStateSpy.count(), 1); |
514 | QCOMPARE(callStateSpy.first()[2].toString(), QString("held")); |
515 | |
516 | // and now set it as unheld again |
517 | callStateSpy.clear(); |
518 | HandlerController::instance()->setHold(objectPath, false); |
519 | - QTRY_COMPARE(callStateSpy.count(), 1); |
520 | + TRY_COMPARE(callStateSpy.count(), 1); |
521 | QCOMPARE(callStateSpy.first()[2].toString(), QString("active")); |
522 | |
523 | mMockController->HangupCall(callerId); |
524 | @@ -163,11 +160,11 @@ |
525 | mMockController->placeCall(properties); |
526 | |
527 | // wait for the channel to hit the approver |
528 | - QTRY_COMPARE(approverCallSpy.count(), 1); |
529 | + TRY_COMPARE(approverCallSpy.count(), 1); |
530 | mApprover->acceptCall(); |
531 | |
532 | // wait until the call properties are changed |
533 | - QTRY_VERIFY(handlerCallPropertiesSpy.count() > 0); |
534 | + TRY_VERIFY(handlerCallPropertiesSpy.count() > 0); |
535 | QString objectPath = handlerCallPropertiesSpy.last()[0].toString(); |
536 | QVariantMap propsFromSignal = handlerCallPropertiesSpy.last()[1].toMap(); |
537 | QVERIFY(!propsFromSignal.isEmpty()); |
538 | @@ -194,7 +191,7 @@ |
539 | for (int i = 0; i < dtmfString.length(); ++i) { |
540 | HandlerController::instance()->sendDTMF(objectPath, QString(dtmfString[i])); |
541 | } |
542 | - QTRY_COMPARE(handlerCallPropertiesSpy.count(), dtmfString.length()); |
543 | + TRY_COMPARE(handlerCallPropertiesSpy.count(), dtmfString.length()); |
544 | propsFromSignal = handlerCallPropertiesSpy.last()[1].toMap(); |
545 | propsFromMethod = HandlerController::instance()->getCallProperties(objectPath); |
546 | QString dtmfStringFromSignal = propsFromSignal["dtmfString"].toString(); |
547 | @@ -220,7 +217,7 @@ |
548 | QString call1 = mMockController->placeCall(properties); |
549 | |
550 | // wait for the channel to hit the approver |
551 | - QTRY_COMPARE(approverCallSpy.count(), 1); |
552 | + TRY_COMPARE(approverCallSpy.count(), 1); |
553 | mApprover->acceptCall(); |
554 | approverCallSpy.clear(); |
555 | waitForCallActive(callerId1); |
556 | @@ -229,7 +226,7 @@ |
557 | properties["Caller"] = callerId2; |
558 | QString call2 = mMockController->placeCall(properties); |
559 | // wait for the channel to hit the approver |
560 | - QTRY_COMPARE(approverCallSpy.count(), 1); |
561 | + TRY_COMPARE(approverCallSpy.count(), 1); |
562 | mApprover->acceptCall(); |
563 | approverCallSpy.clear(); |
564 | waitForCallActive(callerId2); |
565 | @@ -237,13 +234,13 @@ |
566 | // now create the conf call |
567 | QSignalSpy conferenceCreatedSpy(mMockController, SIGNAL(ConferenceCreated(QString))); |
568 | HandlerController::instance()->createConferenceCall(QStringList() << call1 << call2); |
569 | - QTRY_COMPARE(conferenceCreatedSpy.count(), 1); |
570 | + TRY_COMPARE(conferenceCreatedSpy.count(), 1); |
571 | QString conferenceObjectPath = conferenceCreatedSpy.first().first().toString(); |
572 | |
573 | // now place a third call and try to merge it |
574 | properties["Caller"] = callerId3; |
575 | QString call3 = mMockController->placeCall(properties); |
576 | - QTRY_COMPARE(approverCallSpy.count(), 1); |
577 | + TRY_COMPARE(approverCallSpy.count(), 1); |
578 | mApprover->acceptCall(); |
579 | approverCallSpy.clear(); |
580 | waitForCallActive(callerId3); |
581 | @@ -251,13 +248,13 @@ |
582 | // merge that call on the conference |
583 | QSignalSpy channelMergedSpy(mMockController, SIGNAL(ChannelMerged(QString))); |
584 | HandlerController::instance()->mergeCall(conferenceObjectPath, call3); |
585 | - QTRY_COMPARE(channelMergedSpy.count(), 1); |
586 | + TRY_COMPARE(channelMergedSpy.count(), 1); |
587 | QCOMPARE(channelMergedSpy.first().first().toString(), call3); |
588 | |
589 | // now try to split one of the channels |
590 | QSignalSpy channelSplittedSpy(mMockController, SIGNAL(ChannelSplitted(QString))); |
591 | HandlerController::instance()->splitCall(call2); |
592 | - QTRY_COMPARE(channelSplittedSpy.count(), 1); |
593 | + TRY_COMPARE(channelSplittedSpy.count(), 1); |
594 | QCOMPARE(channelSplittedSpy.first().first().toString(), call2); |
595 | |
596 | // now hangup the conference and the individual channels |
597 | @@ -277,7 +274,7 @@ |
598 | QSignalSpy messageSentSpy(mMockController, SIGNAL(MessageSent(QString,QVariantMap))); |
599 | // FIXME: add support for multiple accounts |
600 | HandlerController::instance()->sendMessage(recipient, message, mTpAccount->uniqueIdentifier()); |
601 | - QTRY_COMPARE(messageSentSpy.count(), 1); |
602 | + TRY_COMPARE(messageSentSpy.count(), 1); |
603 | QString sentMessage = messageSentSpy.first().first().toString(); |
604 | QVariantMap messageProperties = messageSentSpy.first().last().value<QVariantMap>(); |
605 | QCOMPARE(sentMessage, message); |
606 | @@ -293,14 +290,14 @@ |
607 | |
608 | // set the property to true |
609 | HandlerController::instance()->setCallIndicatorVisible(true); |
610 | - QTRY_COMPARE(spy.count(), 1); |
611 | + TRY_COMPARE(spy.count(), 1); |
612 | QVERIFY(spy.first().first().toBool()); |
613 | QVERIFY(HandlerController::instance()->callIndicatorVisible()); |
614 | |
615 | // and back to false |
616 | spy.clear(); |
617 | HandlerController::instance()->setCallIndicatorVisible(false); |
618 | - QTRY_COMPARE(spy.count(), 1); |
619 | + TRY_COMPARE(spy.count(), 1); |
620 | QVERIFY(!spy.first().first().toBool()); |
621 | QVERIFY(!HandlerController::instance()->callIndicatorVisible()); |
622 | } |
623 | @@ -314,7 +311,7 @@ |
624 | QString caller; |
625 | int tries = 0; |
626 | while (state != "active" && caller != callerId && tries < 5) { |
627 | - QTRY_COMPARE(callStateSpy.count(), 1); |
628 | + TRY_COMPARE(callStateSpy.count(), 1); |
629 | caller = callStateSpy.first()[0].toString(); |
630 | objectPath = callStateSpy.first()[1].toString(); |
631 | state = callStateSpy.first()[2].toString(); |
632 | |
633 | === modified file 'tests/libtelephonyservice/AccountEntryTest.cpp' |
634 | --- tests/libtelephonyservice/AccountEntryTest.cpp 2015-04-21 17:04:29 +0000 |
635 | +++ tests/libtelephonyservice/AccountEntryTest.cpp 2015-05-11 13:17:00 +0000 |
636 | @@ -21,7 +21,6 @@ |
637 | #include "telepathytest.h" |
638 | #include "accountentry.h" |
639 | #include "accountentryfactory.h" |
640 | -#include "telepathyhelper.h" |
641 | #include "mockcontroller.h" |
642 | |
643 | class AccountEntryTest : public TelepathyTest |
644 | @@ -61,21 +60,19 @@ |
645 | { |
646 | mTpAccount = addAccount("mock", "mock", "the account"); |
647 | QVERIFY(!mTpAccount.isNull()); |
648 | - QTRY_VERIFY(mTpAccount->isReady(Tp::Account::FeatureCore)); |
649 | |
650 | mAccount = AccountEntryFactory::createEntry(mTpAccount, this); |
651 | QVERIFY(mAccount); |
652 | + TRY_VERIFY(mAccount->ready()); |
653 | |
654 | // make sure the connection is available |
655 | - QTRY_VERIFY(!mTpAccount->connection().isNull()); |
656 | - QTRY_COMPARE(mTpAccount->connection()->selfContact()->presence().type(), Tp::ConnectionPresenceTypeAvailable); |
657 | - QTRY_VERIFY(mAccount->connected()); |
658 | + TRY_VERIFY(mAccount->connected()); |
659 | + |
660 | + // and make sure the status and status message are the ones we expect |
661 | + TRY_COMPARE(mAccount->status(), QString("available")); |
662 | |
663 | // and create the mock controller |
664 | mMockController = new MockController("mock", this); |
665 | - |
666 | - // just in case, wait some time |
667 | - QTest::qWait(1000); |
668 | } |
669 | |
670 | void AccountEntryTest::cleanup() |
671 | @@ -94,21 +91,23 @@ |
672 | |
673 | void AccountEntryTest::testActive() |
674 | { |
675 | + // the mock account is enabled/connected by default, so make sure it is like that |
676 | + QVERIFY(mAccount->active()); |
677 | + // FIXME: setting the account as offline, triggers an automatic reconnection and the |
678 | + // test fails. In the future we might want to re-enable this and test some other way. |
679 | QSignalSpy activeChangedSpy(mAccount, SIGNAL(activeChanged())); |
680 | |
681 | - // the mock account is enabled/connected by default, so make sure it is like that |
682 | - QVERIFY(mAccount->active()); |
683 | - |
684 | - // now set the account offline and see if the active flag changes correctly |
685 | + // now set the account away and see if the active flag changes correctly |
686 | mMockController->SetOnline(false); |
687 | - QTRY_VERIFY(!mAccount->active()); |
688 | - QCOMPARE(activeChangedSpy.count(), 1); |
689 | + TRY_VERIFY(!mAccount->active()); |
690 | + TRY_VERIFY(activeChangedSpy.count() > 0); |
691 | + |
692 | |
693 | // now re-enable the account and check that the entry is updated |
694 | activeChangedSpy.clear(); |
695 | mMockController->SetOnline(true); |
696 | - QTRY_VERIFY(mAccount->active()); |
697 | - QCOMPARE(activeChangedSpy.count(), 1); |
698 | + TRY_VERIFY(activeChangedSpy.count() > 0); |
699 | + QVERIFY(mAccount->active()); |
700 | |
701 | // check that for a null account active is false |
702 | QVERIFY(!mNullAccount->active()); |
703 | @@ -124,14 +123,14 @@ |
704 | // now try to set the display in the telepathy account directly and see that the entry gets updated |
705 | QString newDisplayName = "some other display name"; |
706 | mTpAccount->setDisplayName(newDisplayName); |
707 | - QTRY_COMPARE(mAccount->displayName(), newDisplayName); |
708 | + TRY_COMPARE(mAccount->displayName(), newDisplayName); |
709 | QCOMPARE(displayNameChangedSpy.count(), 1); |
710 | |
711 | // and try setting the display name in the entry itself |
712 | displayNameChangedSpy.clear(); |
713 | newDisplayName = "changing again"; |
714 | mAccount->setDisplayName(newDisplayName); |
715 | - QTRY_COMPARE(mAccount->displayName(), newDisplayName); |
716 | + TRY_COMPARE(mAccount->displayName(), newDisplayName); |
717 | QCOMPARE(displayNameChangedSpy.count(), 1); |
718 | QCOMPARE(mTpAccount->displayName(), newDisplayName); |
719 | |
720 | @@ -147,11 +146,10 @@ |
721 | QCOMPARE(mAccount->status(), mTpAccount->connection()->selfContact()->presence().status()); |
722 | |
723 | // and now set a new value |
724 | - Tp::Presence presence(Tp::ConnectionPresenceTypeAway, "away", "away"); |
725 | - mTpAccount->setRequestedPresence(presence); |
726 | + mMockController->SetPresence("away", "away"); |
727 | |
728 | - QTRY_COMPARE(mAccount->status(), QString("away")); |
729 | - QTRY_COMPARE(statusChangedSpy.count(), 1); |
730 | + TRY_COMPARE(statusChangedSpy.count(), 1); |
731 | + QCOMPARE(mAccount->status(), QString("away")); |
732 | |
733 | // check that for a null account the status is null |
734 | QVERIFY(mNullAccount->status().isNull()); |
735 | @@ -162,14 +160,14 @@ |
736 | QSignalSpy statusMessageChangedSpy(mAccount, SIGNAL(statusMessageChanged())); |
737 | |
738 | // check that the value is correct already |
739 | - QTRY_COMPARE(mAccount->statusMessage(), mTpAccount->connection()->selfContact()->presence().statusMessage()); |
740 | + TRY_COMPARE(mAccount->statusMessage(), mTpAccount->connection()->selfContact()->presence().statusMessage()); |
741 | |
742 | // and now set a new value |
743 | QString statusMessage("I am online"); |
744 | mMockController->SetPresence("available", statusMessage); |
745 | |
746 | - QTRY_COMPARE(mAccount->statusMessage(), statusMessage); |
747 | - QTRY_COMPARE(statusMessageChangedSpy.count(), 1); |
748 | + TRY_COMPARE(statusMessageChangedSpy.count(), 1); |
749 | + QCOMPARE(mAccount->statusMessage(), statusMessage); |
750 | |
751 | // check that for a null account the displayName is null |
752 | QVERIFY(mNullAccount->statusMessage().isNull()); |
753 | @@ -183,18 +181,16 @@ |
754 | QVERIFY(mAccount->connected()); |
755 | |
756 | // now set the account offline and see if the active flag changes correctly |
757 | - mMockController->SetOnline(false); |
758 | - QTRY_VERIFY(!mAccount->connected()); |
759 | - QTRY_COMPARE(connectedChangedSpy.count(), 1); |
760 | - |
761 | - // it shouldn't be necessary, but in any case |
762 | - QTest::qWait(500); |
763 | + mMockController->SetPresence("away", "away"); |
764 | + TRY_VERIFY(connectedChangedSpy.count() > 0); |
765 | + TRY_VERIFY(!mAccount->connected()); |
766 | |
767 | // now re-enable the account and check that the entry is updated |
768 | connectedChangedSpy.clear(); |
769 | - mMockController->SetOnline(true); |
770 | - QTRY_VERIFY(mAccount->connected()); |
771 | - QTRY_COMPARE(connectedChangedSpy.count(), 1); |
772 | + mMockController->SetPresence("available", "online"); |
773 | + // because of the way the mock was implemented, sometimes this can return two connectedChanged() signals. |
774 | + TRY_VERIFY(connectedChangedSpy.count() > 0); |
775 | + TRY_VERIFY(mAccount->connected()); |
776 | |
777 | // check that for a null account the displayName is null |
778 | QVERIFY(!mNullAccount->connected()); |
779 | |
780 | === modified file 'tests/libtelephonyservice/CMakeLists.txt' |
781 | --- tests/libtelephonyservice/CMakeLists.txt 2015-04-22 13:44:53 +0000 |
782 | +++ tests/libtelephonyservice/CMakeLists.txt 2015-05-11 13:17:00 +0000 |
783 | @@ -34,6 +34,7 @@ |
784 | |
785 | generate_telepathy_test(AccountEntryFactoryTest SOURCES AccountEntryFactoryTest.cpp) |
786 | generate_telepathy_test(AccountEntryTest SOURCES AccountEntryTest.cpp) |
787 | +generate_telepathy_test(CallEntryTest SOURCES CallEntryTest.cpp) |
788 | generate_telepathy_test(ChatManagerTest SOURCES ChatManagerTest.cpp) |
789 | generate_telepathy_test(OfonoAccountEntryTest SOURCES OfonoAccountEntryTest.cpp) |
790 | generate_telepathy_test(TelepathyHelperTest SOURCES TelepathyHelperTest.cpp) |
791 | |
792 | === added file 'tests/libtelephonyservice/CallEntryTest.cpp' |
793 | --- tests/libtelephonyservice/CallEntryTest.cpp 1970-01-01 00:00:00 +0000 |
794 | +++ tests/libtelephonyservice/CallEntryTest.cpp 2015-05-11 13:17:00 +0000 |
795 | @@ -0,0 +1,129 @@ |
796 | +/* |
797 | + * Copyright (C) 2015 Canonical, Ltd. |
798 | + * |
799 | + * This file is part of telephony-service. |
800 | + * |
801 | + * telephony-service is free software; you can redistribute it and/or modify |
802 | + * it under the terms of the GNU General Public License as published by |
803 | + * the Free Software Foundation; version 3. |
804 | + * |
805 | + * telephony-service is distributed in the hope that it will be useful, |
806 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
807 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
808 | + * GNU General Public License for more details. |
809 | + * |
810 | + * You should have received a copy of the GNU General Public License |
811 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
812 | + */ |
813 | + |
814 | +#include <QtCore/QObject> |
815 | +#include <QtTest/QtTest> |
816 | +#include "telepathytest.h" |
817 | +#include "callentry.h" |
818 | +#include "callmanager.h" |
819 | +#include "telepathyhelper.h" |
820 | +#include "mockcontroller.h" |
821 | +#include "ofonoaccountentry.h" |
822 | +#include "accountentryfactory.h" |
823 | + |
824 | +Q_DECLARE_METATYPE(AccountEntry*) |
825 | + |
826 | +class CallEntryTest : public TelepathyTest |
827 | +{ |
828 | + Q_OBJECT |
829 | + |
830 | +private Q_SLOTS: |
831 | + void initTestCase(); |
832 | + void init(); |
833 | + void cleanup(); |
834 | + void testIsVoicemail_data(); |
835 | + void testIsVoicemail(); |
836 | + |
837 | +protected Q_SLOTS: |
838 | + void onCallChannelAvailable(const Tp::CallChannelPtr &channel); |
839 | + |
840 | +private: |
841 | + Tp::AccountPtr mTpAccount; |
842 | + OfonoAccountEntry *mAccount; |
843 | + Tp::CallChannelPtr mCallChannel; |
844 | + MockController *mMockController; |
845 | +}; |
846 | + |
847 | +void CallEntryTest::initTestCase() |
848 | +{ |
849 | + qRegisterMetaType<AccountEntry*>(); |
850 | + initialize(); |
851 | + TelepathyHelper::instance()->registerChannelObserver(); |
852 | + connect(TelepathyHelper::instance()->channelObserver(), |
853 | + SIGNAL(callChannelAvailable(Tp::CallChannelPtr)), |
854 | + SLOT(onCallChannelAvailable(Tp::CallChannelPtr))); |
855 | +} |
856 | + |
857 | +void CallEntryTest::init() |
858 | +{ |
859 | + QSignalSpy accountSpy(TelepathyHelper::instance(), SIGNAL(accountAdded(AccountEntry*))); |
860 | + mTpAccount = addAccount("mock", "ofono", "the account"); |
861 | + QVERIFY(!mTpAccount.isNull()); |
862 | + TRY_COMPARE(accountSpy.count(), 1); |
863 | + mAccount = qobject_cast<OfonoAccountEntry*>(accountSpy.first().first().value<AccountEntry*>()); |
864 | + QVERIFY(mAccount); |
865 | + TRY_VERIFY(mAccount->ready()); |
866 | + TRY_COMPARE(mAccount->status(), QString("available")); |
867 | + |
868 | + // and create the mock controller |
869 | + mMockController = new MockController("ofono", this); |
870 | +} |
871 | + |
872 | +void CallEntryTest::cleanup() |
873 | +{ |
874 | + doCleanup(); |
875 | + |
876 | + mMockController->deleteLater(); |
877 | + mAccount->deleteLater(); |
878 | + mCallChannel = Tp::CallChannelPtr(); |
879 | + |
880 | + // wait until all the calls are gone before the next test |
881 | + TRY_VERIFY(!CallManager::instance()->hasCalls()); |
882 | +} |
883 | + |
884 | +void CallEntryTest::testIsVoicemail_data() |
885 | +{ |
886 | + QTest::addColumn<QString>("voicemailNumber"); |
887 | + QTest::addColumn<QString>("callNumber"); |
888 | + QTest::addColumn<bool>("isVoicemail"); |
889 | + |
890 | + QTest::newRow("calling voicemail") << "*1234" << "*1234" << true; |
891 | + QTest::newRow("calling other number") << "*1234" << "5555555" << false; |
892 | +} |
893 | + |
894 | +void CallEntryTest::testIsVoicemail() |
895 | +{ |
896 | + QFETCH(QString, voicemailNumber); |
897 | + QFETCH(QString, callNumber); |
898 | + QFETCH(bool, isVoicemail); |
899 | + |
900 | + mMockController->SetVoicemailNumber(voicemailNumber); |
901 | + TRY_COMPARE(mAccount->voicemailNumber(), voicemailNumber); |
902 | + |
903 | + // now place a call to a number that is not the voicemail number |
904 | + QVariantMap properties; |
905 | + properties["Caller"] = callNumber; |
906 | + properties["State"] = "incoming"; |
907 | + mMockController->placeCall(properties); |
908 | + TRY_VERIFY(!mCallChannel.isNull()); |
909 | + QCOMPARE(mCallChannel->targetContact()->id(), callNumber); |
910 | + |
911 | + CallEntry *callEntry = new CallEntry(mCallChannel); |
912 | + QCOMPARE(callEntry->isVoicemail(), isVoicemail); |
913 | + |
914 | + callEntry->endCall(); |
915 | + callEntry->deleteLater(); |
916 | +} |
917 | + |
918 | +void CallEntryTest::onCallChannelAvailable(const Tp::CallChannelPtr &channel) |
919 | +{ |
920 | + mCallChannel = channel; |
921 | +} |
922 | + |
923 | +QTEST_MAIN(CallEntryTest) |
924 | +#include "CallEntryTest.moc" |
925 | |
926 | === modified file 'tests/libtelephonyservice/ChatManagerTest.cpp' |
927 | --- tests/libtelephonyservice/ChatManagerTest.cpp 2015-04-17 21:26:25 +0000 |
928 | +++ tests/libtelephonyservice/ChatManagerTest.cpp 2015-05-11 13:17:00 +0000 |
929 | @@ -47,21 +47,16 @@ |
930 | void ChatManagerTest::initTestCase() |
931 | { |
932 | initialize(); |
933 | - |
934 | TelepathyHelper::instance()->registerChannelObserver(); |
935 | - |
936 | - // just give telepathy some time to register the observer |
937 | - QTest::qWait(1000); |
938 | } |
939 | |
940 | void ChatManagerTest::init() |
941 | { |
942 | // add two accounts |
943 | mGenericTpAccount = addAccount("mock", "mock", "the generic account"); |
944 | - QTRY_VERIFY(!mGenericTpAccount->connection().isNull()); |
945 | - |
946 | + QVERIFY(!mGenericTpAccount.isNull()); |
947 | mPhoneTpAccount = addAccount("mock", "ofono", "the phone account"); |
948 | - QTRY_VERIFY(!mPhoneTpAccount->connection().isNull()); |
949 | + QVERIFY(!mPhoneTpAccount.isNull()); |
950 | |
951 | // and create the mock controller |
952 | mGenericMockController = new MockController("mock", this); |
953 | @@ -103,7 +98,7 @@ |
954 | |
955 | ChatManager::instance()->sendMessage(recipients, message, accountId); |
956 | |
957 | - QTRY_COMPARE(controllerMessageSentSpy.count(), 1); |
958 | + TRY_COMPARE(controllerMessageSentSpy.count(), 1); |
959 | QString messageText = controllerMessageSentSpy.first()[0].toString(); |
960 | QVariantMap messageProperties = controllerMessageSentSpy.first()[1].toMap(); |
961 | QStringList messageRecipients = messageProperties["Recipients"].toStringList(); |
962 | @@ -111,7 +106,7 @@ |
963 | QCOMPARE(messageText, message); |
964 | QCOMPARE(messageRecipients, recipients); |
965 | |
966 | - QTRY_COMPARE(messageSentSpy.count(), 1); |
967 | + TRY_COMPARE(messageSentSpy.count(), 1); |
968 | messageRecipients = messageSentSpy.first()[0].toStringList(); |
969 | qSort(messageRecipients); |
970 | messageText = messageSentSpy.first()[1].toString(); |
971 | @@ -129,7 +124,7 @@ |
972 | QString message("Hi there"); |
973 | mGenericMockController->PlaceIncomingMessage(message, properties); |
974 | |
975 | - QTRY_COMPARE(messageReceivedSpy.count(), 1); |
976 | + TRY_COMPARE(messageReceivedSpy.count(), 1); |
977 | QString sender = messageReceivedSpy.first()[0].toString(); |
978 | QString receivedMessage = messageReceivedSpy.first()[1].toString(); |
979 | QCOMPARE(sender, properties["Sender"].toString()); |
980 | @@ -147,9 +142,10 @@ |
981 | messages << "Hi there" << "How are you" << "Always look on the bright side of life"; |
982 | Q_FOREACH(const QString &message, messages) { |
983 | mGenericMockController->PlaceIncomingMessage(message, properties); |
984 | - QTest::qWait(100); |
985 | + // the wait shouldn't be needed, but just in case |
986 | + QTest::qWait(50); |
987 | } |
988 | - QTRY_COMPARE(messageReceivedSpy.count(), messages.count()); |
989 | + TRY_COMPARE(messageReceivedSpy.count(), messages.count()); |
990 | |
991 | QStringList messageIds; |
992 | for (int i = 0; i < messages.count(); ++i) { |
993 | @@ -162,7 +158,7 @@ |
994 | ChatManager::instance()->acknowledgeMessage(properties["Recipients"].toStringList(), messageId, "mock/mock/account0"); |
995 | } |
996 | |
997 | - QTRY_COMPARE(messageReadSpy.count(), messageIds.count()); |
998 | + TRY_COMPARE(messageReadSpy.count(), messageIds.count()); |
999 | QStringList receivedIds; |
1000 | for (int i = 0; i < messageReadSpy.count(); ++i) { |
1001 | receivedIds << messageReadSpy[i][0].toString(); |
1002 | |
1003 | === modified file 'tests/libtelephonyservice/OfonoAccountEntryTest.cpp' |
1004 | --- tests/libtelephonyservice/OfonoAccountEntryTest.cpp 2015-04-22 14:26:41 +0000 |
1005 | +++ tests/libtelephonyservice/OfonoAccountEntryTest.cpp 2015-05-11 13:17:00 +0000 |
1006 | @@ -61,21 +61,18 @@ |
1007 | { |
1008 | mTpAccount = addAccount("mock", "ofono", "phone account"); |
1009 | QVERIFY(!mTpAccount.isNull()); |
1010 | - QTRY_VERIFY(mTpAccount->isReady(Tp::Account::FeatureCore)); |
1011 | - |
1012 | mAccount = qobject_cast<OfonoAccountEntry*>(AccountEntryFactory::createEntry(mTpAccount, this)); |
1013 | QVERIFY(mAccount); |
1014 | + TRY_VERIFY(mAccount->ready()); |
1015 | |
1016 | // make sure the connection is available |
1017 | - QTRY_VERIFY(!mTpAccount->connection().isNull()); |
1018 | - QTRY_COMPARE(mTpAccount->connection()->selfContact()->presence().type(), Tp::ConnectionPresenceTypeAvailable); |
1019 | - QTRY_VERIFY(mAccount->connected()); |
1020 | + TRY_VERIFY(mAccount->connected()); |
1021 | + |
1022 | + // and make sure the status and status message are the ones we expect |
1023 | + TRY_COMPARE(mAccount->status(), QString("available")); |
1024 | |
1025 | // create the mock controller |
1026 | mMockController = new MockController("ofono", this); |
1027 | - |
1028 | - // just in case, wait some time |
1029 | - QTest::qWait(1000); |
1030 | } |
1031 | |
1032 | void OfonoAccountEntryTest::cleanup() |
1033 | @@ -93,22 +90,23 @@ |
1034 | void OfonoAccountEntryTest::testConnected() |
1035 | { |
1036 | // the mock account is enabled/connected by default, so make sure it is like that |
1037 | - QTRY_VERIFY(mAccount->connected()); |
1038 | + TRY_VERIFY(mAccount->connected()); |
1039 | |
1040 | // right now the ofono account connection status behave exactly like the generic class, |
1041 | // but as the code path is different, test it again |
1042 | QSignalSpy connectedChangedSpy(mAccount, SIGNAL(connectedChanged())); |
1043 | |
1044 | // now set the account offline and see if the active flag changes correctly |
1045 | - mMockController->SetOnline(false); |
1046 | - QTRY_VERIFY(!mAccount->connected()); |
1047 | - QTRY_COMPARE(connectedChangedSpy.count(), 1); |
1048 | + mMockController->SetPresence("away", "away"); |
1049 | + TRY_VERIFY(connectedChangedSpy.count() > 0); |
1050 | + TRY_VERIFY(!mAccount->connected()); |
1051 | |
1052 | // now re-enable the account and check that the entry is updated |
1053 | connectedChangedSpy.clear(); |
1054 | - mMockController->SetOnline(true); |
1055 | - QTRY_VERIFY(mAccount->connected()); |
1056 | - QTRY_COMPARE(connectedChangedSpy.count(), 1); |
1057 | + mMockController->SetPresence("available", "online"); |
1058 | + // because of the way the mock was implemented, sometimes this can return two connectedChanged() signals. |
1059 | + TRY_VERIFY(connectedChangedSpy.count() > 0); |
1060 | + TRY_VERIFY(mAccount->connected()); |
1061 | } |
1062 | |
1063 | void OfonoAccountEntryTest::testCompareIds_data() |
1064 | @@ -142,7 +140,7 @@ |
1065 | numbers << "111" << "190" << "911"; |
1066 | qSort(numbers); |
1067 | mMockController->SetEmergencyNumbers(numbers); |
1068 | - QTRY_COMPARE(emergencyNumbersChangedSpy.count(), 1); |
1069 | + TRY_COMPARE(emergencyNumbersChangedSpy.count(), 1); |
1070 | |
1071 | QStringList emergencyNumbers = mAccount->emergencyNumbers(); |
1072 | qSort(emergencyNumbers); |
1073 | @@ -152,7 +150,7 @@ |
1074 | |
1075 | void OfonoAccountEntryTest::testSerial() |
1076 | { |
1077 | - QTRY_COMPARE(mAccount->serial(), mMockController->serial()); |
1078 | + TRY_COMPARE(mAccount->serial(), mMockController->serial()); |
1079 | } |
1080 | |
1081 | void OfonoAccountEntryTest::testVoicemailIndicator() |
1082 | @@ -164,27 +162,27 @@ |
1083 | |
1084 | // set to true |
1085 | mMockController->SetVoicemailIndicator(true); |
1086 | - QTRY_COMPARE(voiceMailIndicatorSpy.count(), 1); |
1087 | - QTRY_VERIFY(mAccount->voicemailIndicator()); |
1088 | + TRY_COMPARE(voiceMailIndicatorSpy.count(), 1); |
1089 | + QVERIFY(mAccount->voicemailIndicator()); |
1090 | |
1091 | // and set back to false |
1092 | voiceMailIndicatorSpy.clear(); |
1093 | mMockController->SetVoicemailIndicator(false); |
1094 | - QTRY_COMPARE(voiceMailIndicatorSpy.count(), 1); |
1095 | - QTRY_VERIFY(!mAccount->voicemailIndicator()); |
1096 | + TRY_COMPARE(voiceMailIndicatorSpy.count(), 1); |
1097 | + QVERIFY(!mAccount->voicemailIndicator()); |
1098 | } |
1099 | |
1100 | void OfonoAccountEntryTest::testVoicemailNumber() |
1101 | { |
1102 | + // check that the number is not empty at startup |
1103 | + TRY_VERIFY(!mAccount->voicemailNumber().isEmpty()); |
1104 | + |
1105 | QSignalSpy voicemailNumberSpy(mAccount, SIGNAL(voicemailNumberChanged())); |
1106 | |
1107 | - // check that the number is not empty at startup |
1108 | - QTRY_VERIFY(!mAccount->voicemailNumber().isEmpty()); |
1109 | - |
1110 | // try changing the number |
1111 | QString number("12345"); |
1112 | mMockController->SetVoicemailNumber(number); |
1113 | - QTRY_COMPARE(voicemailNumberSpy.count(), 1); |
1114 | + TRY_COMPARE(voicemailNumberSpy.count(), 1); |
1115 | QCOMPARE(mAccount->voicemailNumber(), number); |
1116 | } |
1117 | |
1118 | @@ -198,13 +196,13 @@ |
1119 | // set it to a bigger value |
1120 | int count = 10; |
1121 | mMockController->SetVoicemailCount(count); |
1122 | - QTRY_COMPARE(voicemailCountSpy.count(), 1); |
1123 | + TRY_COMPARE(voicemailCountSpy.count(), 1); |
1124 | QCOMPARE((int)mAccount->voicemailCount(), count); |
1125 | |
1126 | // and back to zero |
1127 | voicemailCountSpy.clear(); |
1128 | mMockController->SetVoicemailCount(0); |
1129 | - QTRY_COMPARE(voicemailCountSpy.count(), 1); |
1130 | + TRY_COMPARE(voicemailCountSpy.count(), 1); |
1131 | QCOMPARE((int)mAccount->voicemailCount(), 0); |
1132 | } |
1133 | |
1134 | @@ -217,7 +215,7 @@ |
1135 | |
1136 | // now try to set the status to simlocked |
1137 | mMockController->SetPresence("simlocked", "simlocked"); |
1138 | - QTRY_COMPARE(simLockedSpy.count(), 1); |
1139 | + TRY_COMPARE(simLockedSpy.count(), 1); |
1140 | QVERIFY(mAccount->simLocked()); |
1141 | } |
1142 | |
1143 | @@ -246,7 +244,7 @@ |
1144 | QFETCH(bool, available); |
1145 | |
1146 | mMockController->SetPresence(status, ""); |
1147 | - QTRY_COMPARE(mAccount->status(), status); |
1148 | + TRY_COMPARE(mAccount->status(), status); |
1149 | QCOMPARE(mAccount->emergencyCallsAvailable(), available); |
1150 | } |
1151 | |
1152 | @@ -258,8 +256,8 @@ |
1153 | QString statusMessage("SomeNetwork"); |
1154 | mMockController->SetPresence("available", statusMessage); |
1155 | |
1156 | - QTRY_COMPARE(mAccount->networkName(), statusMessage); |
1157 | - QTRY_COMPARE(networkNameChangedSpy.count(), 1); |
1158 | + TRY_COMPARE(networkNameChangedSpy.count(), 1); |
1159 | + QCOMPARE(mAccount->networkName(), statusMessage); |
1160 | } |
1161 | |
1162 | void OfonoAccountEntryTest::testAddressableVCardFields() |
1163 | |
1164 | === modified file 'tests/libtelephonyservice/TelepathyHelperTest.cpp' |
1165 | --- tests/libtelephonyservice/TelepathyHelperTest.cpp 2015-04-21 16:47:31 +0000 |
1166 | +++ tests/libtelephonyservice/TelepathyHelperTest.cpp 2015-05-11 13:17:00 +0000 |
1167 | @@ -27,6 +27,8 @@ |
1168 | #include "telepathyhelper.h" |
1169 | #include "mockcontroller.h" |
1170 | |
1171 | +Q_DECLARE_METATYPE(AccountEntry*) |
1172 | + |
1173 | class TelepathyHelperTest : public TelepathyTest |
1174 | { |
1175 | Q_OBJECT |
1176 | @@ -45,6 +47,11 @@ |
1177 | void testAccountForConnection(); |
1178 | void testEmergencyCallsAvailable(); |
1179 | |
1180 | +protected: |
1181 | + Tp::AccountPtr addAccountAndWait(const QString &manager, |
1182 | + const QString &protocol, |
1183 | + const QString &displayName, |
1184 | + const QVariantMap ¶meters = QVariantMap()); |
1185 | private: |
1186 | Tp::AccountPtr mGenericTpAccount; |
1187 | Tp::AccountPtr mPhoneTpAccount; |
1188 | @@ -54,24 +61,24 @@ |
1189 | |
1190 | void TelepathyHelperTest::initTestCase() |
1191 | { |
1192 | + qRegisterMetaType<AccountEntry*>(); |
1193 | initialize(); |
1194 | + QSignalSpy setupReadySpy(TelepathyHelper::instance(), SIGNAL(setupReady())); |
1195 | + TRY_COMPARE(setupReadySpy.count(), 1); |
1196 | } |
1197 | |
1198 | void TelepathyHelperTest::init() |
1199 | { |
1200 | // add two accounts |
1201 | - mGenericTpAccount = addAccount("mock", "mock", "the generic account"); |
1202 | - QTRY_VERIFY(!mGenericTpAccount->connection().isNull()); |
1203 | + mGenericTpAccount = addAccountAndWait("mock", "mock", "the generic account"); |
1204 | + QVERIFY(!mGenericTpAccount.isNull()); |
1205 | |
1206 | - mPhoneTpAccount = addAccount("mock", "ofono", "the phone account"); |
1207 | - QTRY_VERIFY(!mPhoneTpAccount->connection().isNull()); |
1208 | + mPhoneTpAccount = addAccountAndWait("mock", "ofono", "the phone account"); |
1209 | + QVERIFY(!mPhoneTpAccount.isNull()); |
1210 | |
1211 | // and create the mock controller |
1212 | mGenericController = new MockController("mock", this); |
1213 | mPhoneController = new MockController("ofono", this); |
1214 | - |
1215 | - // just in case, wait some time |
1216 | - QTest::qWait(1000); |
1217 | } |
1218 | |
1219 | void TelepathyHelperTest::cleanup() |
1220 | @@ -98,13 +105,13 @@ |
1221 | |
1222 | // and set the other account as offline too. This time connected needs to change to false |
1223 | mPhoneController->SetOnline(false); |
1224 | - QTRY_COMPARE(connectedChangedSpy.count(), 1); |
1225 | + TRY_COMPARE(connectedChangedSpy.count(), 1); |
1226 | QVERIFY(!TelepathyHelper::instance()->connected()); |
1227 | |
1228 | // now set one of the accounts back online |
1229 | connectedChangedSpy.clear(); |
1230 | mPhoneController->SetOnline(true); |
1231 | - QTRY_COMPARE(connectedChangedSpy.count(), 1); |
1232 | + TRY_COMPARE(connectedChangedSpy.count(), 1); |
1233 | QVERIFY(TelepathyHelper::instance()->connected()); |
1234 | |
1235 | // and the other one just in case |
1236 | @@ -124,10 +131,10 @@ |
1237 | |
1238 | // now check that new accounts are captured |
1239 | QSignalSpy accountsChangedSpy(TelepathyHelper::instance(), SIGNAL(accountsChanged())); |
1240 | - Tp::AccountPtr newAccount = addAccount("mock", "mock", "extra"); |
1241 | + Tp::AccountPtr newAccount = addAccountAndWait("mock", "mock", "extra"); |
1242 | QVERIFY(!newAccount.isNull()); |
1243 | |
1244 | - QTRY_COMPARE(accountsChangedSpy.count(), 1); |
1245 | + TRY_COMPARE(accountsChangedSpy.count(), 1); |
1246 | QCOMPARE(TelepathyHelper::instance()->accounts().count(), 3); |
1247 | |
1248 | bool accountFound = false; |
1249 | @@ -142,7 +149,7 @@ |
1250 | // now remove the extra account and make sure it is properly removed |
1251 | accountsChangedSpy.clear(); |
1252 | QVERIFY(removeAccount(newAccount)); |
1253 | - QTRY_COMPARE(accountsChangedSpy.count(), 1); |
1254 | + TRY_COMPARE(accountsChangedSpy.count(), 1); |
1255 | QCOMPARE(TelepathyHelper::instance()->accounts().count(), 2); |
1256 | QCOMPARE(TelepathyHelper::instance()->accounts()[0]->accountId(), first->accountId()); |
1257 | QCOMPARE(TelepathyHelper::instance()->accounts()[1]->accountId(), second->accountId()); |
1258 | @@ -184,15 +191,15 @@ |
1259 | // create two accounts with modem-objpath parameters and make sure they are listed first |
1260 | QVariantMap parameters; |
1261 | parameters["modem-objpath"] = "/phonesim1"; |
1262 | - Tp::AccountPtr firstAccount = addAccount("mock", "ofono", "firstPhoneAccount", parameters); |
1263 | + Tp::AccountPtr firstAccount = addAccountAndWait("mock", "ofono", "firstPhoneAccount", parameters); |
1264 | QVERIFY(!firstAccount.isNull()); |
1265 | |
1266 | parameters["modem-objpath"] = "/phonesim2"; |
1267 | - Tp::AccountPtr secondAccount = addAccount("mock", "ofono", "secondPhoneAccount", parameters); |
1268 | + Tp::AccountPtr secondAccount = addAccountAndWait("mock", "ofono", "secondPhoneAccount", parameters); |
1269 | QVERIFY(!secondAccount.isNull()); |
1270 | |
1271 | // wait for the accounts to appear; |
1272 | - QTRY_COMPARE(TelepathyHelper::instance()->accounts().count(), 4); |
1273 | + TRY_COMPARE(TelepathyHelper::instance()->accounts().count(), 4); |
1274 | |
1275 | // and check the order |
1276 | QCOMPARE(TelepathyHelper::instance()->accounts()[0]->accountId(), firstAccount->uniqueIdentifier()); |
1277 | @@ -200,11 +207,11 @@ |
1278 | |
1279 | // now add a third account that should go before the two others |
1280 | parameters["modem-objpath"] = "/phonesim0"; |
1281 | - Tp::AccountPtr thirdAccount = addAccount("mock", "ofono", "thirdPhoneAccount", parameters); |
1282 | + Tp::AccountPtr thirdAccount = addAccountAndWait("mock", "ofono", "thirdPhoneAccount", parameters); |
1283 | QVERIFY(!thirdAccount.isNull()); |
1284 | |
1285 | // wait for the accounts to appear; |
1286 | - QTRY_COMPARE(TelepathyHelper::instance()->accounts().count(), 5); |
1287 | + TRY_COMPARE(TelepathyHelper::instance()->accounts().count(), 5); |
1288 | QCOMPARE(TelepathyHelper::instance()->accounts()[0]->accountId(), thirdAccount->uniqueIdentifier()); |
1289 | |
1290 | // and remove the created accounts |
1291 | @@ -219,10 +226,10 @@ |
1292 | |
1293 | // now check that new accounts are captured |
1294 | QSignalSpy accountIdsChangedSpy(TelepathyHelper::instance(), SIGNAL(accountIdsChanged())); |
1295 | - Tp::AccountPtr newAccount = addAccount("mock", "mock", "extra"); |
1296 | + Tp::AccountPtr newAccount = addAccountAndWait("mock", "mock", "extra"); |
1297 | QVERIFY(!newAccount.isNull()); |
1298 | |
1299 | - QTRY_COMPARE(accountIdsChangedSpy.count(), 1); |
1300 | + TRY_COMPARE(accountIdsChangedSpy.count(), 1); |
1301 | QCOMPARE(TelepathyHelper::instance()->accountIds().count(), 3); |
1302 | |
1303 | // just to make sure check that each account id matches one account |
1304 | @@ -233,7 +240,7 @@ |
1305 | // now remove the extra account and make sure it is properly removed |
1306 | accountIdsChangedSpy.clear(); |
1307 | QVERIFY(removeAccount(newAccount)); |
1308 | - QTRY_COMPARE(accountIdsChangedSpy.count(), 1); |
1309 | + TRY_COMPARE(accountIdsChangedSpy.count(), 1); |
1310 | QCOMPARE(TelepathyHelper::instance()->accountIds().count(), 2); |
1311 | QCOMPARE(TelepathyHelper::instance()->accountIds()[0], TelepathyHelper::instance()->accounts()[0]->accountId()); |
1312 | QCOMPARE(TelepathyHelper::instance()->accountIds()[1], TelepathyHelper::instance()->accounts()[1]->accountId()); |
1313 | @@ -248,22 +255,22 @@ |
1314 | |
1315 | // now set one of the accounts as offline and make sure it is captured |
1316 | mGenericController->SetOnline(false); |
1317 | - QTRY_COMPARE_WITH_TIMEOUT(activeAccountsSpy.count(), 1, DEFAULT_TIMEOUT); |
1318 | + TRY_COMPARE(activeAccountsSpy.count(), 1); |
1319 | QTRY_COMPARE(TelepathyHelper::instance()->activeAccounts().count(), 1); |
1320 | QCOMPARE(TelepathyHelper::instance()->activeAccounts()[0]->accountId(), mPhoneTpAccount->uniqueIdentifier()); |
1321 | |
1322 | // set the other account offline to make sure |
1323 | activeAccountsSpy.clear(); |
1324 | mPhoneController->SetOnline(false); |
1325 | - QTRY_COMPARE_WITH_TIMEOUT(activeAccountsSpy.count(), 1, DEFAULT_TIMEOUT); |
1326 | + TRY_COMPARE(activeAccountsSpy.count(), 1); |
1327 | QVERIFY(TelepathyHelper::instance()->activeAccounts().isEmpty()); |
1328 | |
1329 | // and set both accounts online again |
1330 | activeAccountsSpy.clear(); |
1331 | mGenericController->SetOnline(true); |
1332 | mPhoneController->SetOnline(true); |
1333 | - QTRY_COMPARE_WITH_TIMEOUT(activeAccountsSpy.count(), 2, DEFAULT_TIMEOUT); |
1334 | - QTRY_COMPARE(TelepathyHelper::instance()->activeAccounts().count(), 2); |
1335 | + TRY_COMPARE(activeAccountsSpy.count(), 2); |
1336 | + QCOMPARE(TelepathyHelper::instance()->activeAccounts().count(), 2); |
1337 | } |
1338 | |
1339 | void TelepathyHelperTest::testAccountForId() |
1340 | @@ -291,7 +298,7 @@ |
1341 | QSignalSpy emergencyCallsSpy(TelepathyHelper::instance(), SIGNAL(emergencyCallsAvailableChanged())); |
1342 | |
1343 | // check that calls are available by default |
1344 | - QVERIFY(TelepathyHelper::instance()->emergencyCallsAvailable()); |
1345 | + TRY_VERIFY(TelepathyHelper::instance()->emergencyCallsAvailable()); |
1346 | |
1347 | // set the generic account as "flightmode" and make sure it doesn't affect the emergencyCallsAvailable |
1348 | mGenericController->SetPresence("flightmode", ""); |
1349 | @@ -301,7 +308,7 @@ |
1350 | |
1351 | // now set the phone account as "flightmode", and see if the emergencyCallsAvailable value |
1352 | mPhoneController->SetPresence("flightmode", ""); |
1353 | - QTRY_COMPARE(emergencyCallsSpy.count(), 1); |
1354 | + TRY_VERIFY(emergencyCallsSpy.count() > 0); |
1355 | QVERIFY(!TelepathyHelper::instance()->emergencyCallsAvailable()); |
1356 | |
1357 | // set the generic account online and check if it affects the value |
1358 | @@ -313,9 +320,25 @@ |
1359 | |
1360 | // and finally set the phone account back online |
1361 | mPhoneController->SetOnline(true); |
1362 | - QTRY_COMPARE(emergencyCallsSpy.count(), 1); |
1363 | + TRY_VERIFY(emergencyCallsSpy.count() > 0); |
1364 | QVERIFY(TelepathyHelper::instance()->emergencyCallsAvailable()); |
1365 | } |
1366 | |
1367 | +Tp::AccountPtr TelepathyHelperTest::addAccountAndWait(const QString &manager, const QString &protocol, const QString &displayName, const QVariantMap ¶meters) |
1368 | +{ |
1369 | + QSignalSpy accountAddedSpy(TelepathyHelper::instance(), SIGNAL(accountAdded(AccountEntry*))); |
1370 | + Tp::AccountPtr account = addAccount(manager, protocol, displayName, parameters); |
1371 | + |
1372 | + WAIT_FOR(accountAddedSpy.count() == 1); |
1373 | + |
1374 | + AccountEntry *accountEntry = accountAddedSpy.first().first().value<AccountEntry*>(); |
1375 | + WAIT_FOR(accountEntry->ready()); |
1376 | + |
1377 | + // and make sure the status and status message are the ones we expect |
1378 | + WAIT_FOR(accountEntry->status() == QString("available")); |
1379 | + |
1380 | + return account; |
1381 | +} |
1382 | + |
1383 | QTEST_MAIN(TelepathyHelperTest) |
1384 | #include "TelepathyHelperTest.moc" |
PASSED: Continuous integration, rev:1065 jenkins. qa.ubuntu. com/job/ telephony- service- ci/425/ jenkins. qa.ubuntu. com/job/ telephony- service- vivid-amd64- ci/93 jenkins. qa.ubuntu. com/job/ telephony- service- vivid-armhf- ci/93 jenkins. qa.ubuntu. com/job/ telephony- service- vivid-armhf- ci/93/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ telephony- service- vivid-i386- ci/93
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/telephony- service- ci/425/ rebuild
http://