84 //verify that the contact has a phonenumber |
80 //verify that the contact has a phonenumber |
85 QList<QContactPhoneNumber> numberList = contact.details<QContactPhoneNumber>(); |
81 QList<QContactPhoneNumber> numberList = contact.details<QContactPhoneNumber>(); |
86 QVERIFY(numberList.count() > 0); |
82 QVERIFY(numberList.count() > 0); |
87 |
83 |
88 //get the actions |
84 //get the actions |
89 QStringList actions = contact.availableActions(); |
85 QList<QContactActionDescriptor> actionDescriptors = contact.availableActions(); |
|
86 QStringList actions; |
|
87 for (int i = 0;i < actionDescriptors.count();i++) |
|
88 { |
|
89 QString action = actionDescriptors.at(i).actionName(); |
|
90 actions << action; |
|
91 } |
90 |
92 |
91 //verify that it includes the actiosn |
93 //verify that it includes the actiosn |
92 QVERIFY(actions.contains("call", Qt::CaseInsensitive)); |
94 QVERIFY(actions.contains("call", Qt::CaseInsensitive)); |
93 |
95 |
94 //verify that the action works |
96 //verify that the action works |
95 QList<QContactActionDescriptor> callActionDescriptors = QContactAction::actionDescriptors("call", "symbian"); |
97 QList<QContactActionDescriptor> callActionDescriptors = QContactAction::actionDescriptors("call", "symbian"); |
96 QVERIFY(callActionDescriptors.count() == 1); |
98 QVERIFY(callActionDescriptors.count() == 1); |
97 QContactAction *callAction = QContactAction::action(callActionDescriptors.at(0)); |
99 QContactAction *callAction = QContactAction::action(callActionDescriptors.at(0)); |
98 QVERIFY(callAction != 0); |
100 QVERIFY(callAction != 0); |
99 QVERIFY(callAction->supportsDetail(numberList.at(0)) == true); |
101 QVERIFY(callAction->isDetailSupported(numberList.at(0)) == true); |
100 QVariantMap variantMap = callAction->metadata(); |
102 QVariantMap variantMap = callAction->metaData(); |
101 QVERIFY(variantMap.count() == 0); |
103 QVERIFY(variantMap.count() == 0); |
102 QVERIFY(variantMap.count() == 0); |
104 variantMap = callAction->results(); |
103 variantMap = callAction->result(); |
105 QVERIFY(variantMap.count() == 0); |
104 QSignalSpy spyCallAction(callAction, SIGNAL(progress(QContactAction::Status, const QVariantMap &))); |
106 QSignalSpy spyCallAction(callAction, SIGNAL(stateChanged(QContactAction::State))); |
105 callAction->invokeAction(contact, numberList.at(0)); |
107 callAction->invokeAction(contact, numberList.at(0)); |
106 callAction->invokeAction(contact); |
108 callAction->invokeAction(contact); |
107 QTRY_COMPARE(spyCallAction.count(), 2); // make sure the signal was emitted exactly one time |
109 QTRY_COMPARE(spyCallAction.count(), 2); // make sure the signal was emitted exactly one time |
108 //Verify that the data is correct |
|
109 //QList<QVariant> arguments = spy.takeFirst(); // take the first signal |
|
110 //QContactAction::Status status = arguments.at(0).value<QContactAction::Status>(); |
|
111 //QVariantMap map = (arguments.at(1)).toMap(); |
|
112 delete callAction; |
110 delete callAction; |
113 } |
111 } |
114 |
112 |
115 void TestMobCntActions::phonenumberNoCallSupport() |
113 void TestMobCntActions::phonenumberNoCallSupport() |
116 { |
114 { |
117 QContact contact; |
115 QContact contact; |
118 |
116 m_manager->saveContact(&contact); |
119 QContactPhoneNumber faxNumber; |
|
120 faxNumber.setNumber("555111222"); |
|
121 faxNumber.setSubTypes(QContactPhoneNumber::SubTypeFacsimile); |
|
122 contact.saveDetail(&faxNumber); |
|
123 m_manager->saveContact(&contact); |
|
124 |
|
125 //one number exist in contact |
|
126 QList<QContactPhoneNumber> numberList = contact.details<QContactPhoneNumber>(); |
|
127 QVERIFY(numberList.count() == 1); |
|
128 |
|
129 QStringList subTypeList = numberList.at(0).subTypes(); |
|
130 |
|
131 QVERIFY(subTypeList.count() == 1); |
|
132 QVERIFY(subTypeList.contains(QContactPhoneNumber::SubTypeFacsimile)); |
|
133 |
117 |
134 //no actions expected |
118 //no actions expected |
135 QStringList actions = contact.availableActions(); |
119 QList<QContactActionDescriptor> actionDescriptors = contact.availableActions(); |
136 |
120 QStringList actions; |
137 QVERIFY(actions.contains("call", Qt::CaseInsensitive) == false); |
121 for (int i = 0;i < actionDescriptors.count();i++) |
|
122 { |
|
123 QString action = actionDescriptors.at(i).actionName(); |
|
124 actions << action; |
|
125 } |
|
126 |
|
127 QVERIFY(actions.contains("call", Qt::CaseInsensitive) == false); |
138 } |
128 } |
139 |
129 |
140 void TestMobCntActions::phonenumberMessageSupport() |
130 void TestMobCntActions::phonenumberMessageSupport() |
141 { |
131 { |
142 QContact contact; |
132 QContact contact; |
151 //verify that the contact has a phonenumber |
141 //verify that the contact has a phonenumber |
152 QList<QContactPhoneNumber> numberList = contact.details<QContactPhoneNumber>(); |
142 QList<QContactPhoneNumber> numberList = contact.details<QContactPhoneNumber>(); |
153 QVERIFY(numberList.count() > 0); |
143 QVERIFY(numberList.count() > 0); |
154 |
144 |
155 //get the actions |
145 //get the actions |
156 QStringList actions = contact.availableActions(); |
146 QList<QContactActionDescriptor> actionDescriptors = contact.availableActions(); |
|
147 QStringList actions; |
|
148 for (int i = 0;i < actionDescriptors.count();i++) |
|
149 { |
|
150 QString action = actionDescriptors.at(i).actionName(); |
|
151 actions << action; |
|
152 } |
157 |
153 |
158 //verify that it includes the actiosn |
154 //verify that it includes the actiosn |
159 QVERIFY(actions.contains("message", Qt::CaseInsensitive)); |
155 QVERIFY(actions.contains("message", Qt::CaseInsensitive)); |
160 |
156 |
161 QList<QContactActionDescriptor> messageActionDescriptors = QContactAction::actionDescriptors("message", "symbian"); |
157 QList<QContactActionDescriptor> messageActionDescriptors = QContactAction::actionDescriptors("message", "symbian"); |
162 QVERIFY(messageActionDescriptors.count() == 1); |
158 QVERIFY(messageActionDescriptors.count() == 1); |
163 QContactAction *messageAction = QContactAction::action(messageActionDescriptors.at(0)); |
159 QContactAction *messageAction = QContactAction::action(messageActionDescriptors.at(0)); |
164 QVERIFY(messageAction != 0); |
160 QVERIFY(messageAction != 0); |
165 QVERIFY(messageAction->supportsDetail(numberList.at(0)) == true); |
161 QVERIFY(messageAction->isDetailSupported(numberList.at(0)) == true); |
166 QVariantMap variantMap = messageAction->metadata(); |
162 QVariantMap variantMap = messageAction->metaData(); |
167 QVERIFY(variantMap.count() == 0); |
163 QVERIFY(variantMap.count() == 0); |
168 variantMap = messageAction->result(); |
164 variantMap = messageAction->results(); |
169 QVERIFY(variantMap.count() == 0); |
165 QVERIFY(variantMap.count() == 0); |
170 QSignalSpy spyMessageAction(messageAction, SIGNAL(progress(QContactAction::Status, const QVariantMap &))); |
166 QSignalSpy spyMessageAction(messageAction, SIGNAL(stateChanged(QContactAction::State))); |
171 messageAction->invokeAction(contact, numberList.at(0)); |
167 messageAction->invokeAction(contact, numberList.at(0)); |
172 messageAction->invokeAction(contact); |
168 messageAction->invokeAction(contact); |
173 QTRY_COMPARE(spyMessageAction.count(), 2); // make sure the signal was emitted exactly one time |
169 QTRY_COMPARE(spyMessageAction.count(), 2); // make sure the signal was emitted exactly one time |
174 delete messageAction; |
170 delete messageAction; |
175 } |
171 } |
176 |
172 |
177 void TestMobCntActions::phonenumberNoMessageSupport() |
173 void TestMobCntActions::phonenumberNoMessageSupport() |
178 { |
174 { |
179 QContact contact; |
|
180 |
|
181 QContactPhoneNumber faxNumber; |
175 QContactPhoneNumber faxNumber; |
182 faxNumber.setNumber("555111222"); |
176 faxNumber.setNumber("555111222"); |
183 faxNumber.setSubTypes(QContactPhoneNumber::SubTypeFacsimile); |
177 faxNumber.setSubTypes(QContactPhoneNumber::SubTypeFacsimile); |
184 contact.saveDetail(&faxNumber); |
178 |
185 m_manager->saveContact(&contact); |
179 QList<QContactActionDescriptor> actionDescriptors = QContactAction::actionDescriptors("message", "symbian"); |
186 |
180 |
187 //one number exist in contact |
181 QContactAction* contactAction = QContactAction::action(actionDescriptors.first()); |
188 QList<QContactPhoneNumber> numberList = contact.details<QContactPhoneNumber>(); |
182 bool isSupportDetail = contactAction->isDetailSupported(faxNumber); |
189 QVERIFY(numberList.count() == 1); |
183 |
190 |
184 delete contactAction; |
191 QStringList subTypeList = numberList.at(0).subTypes(); |
185 |
192 |
186 QVERIFY(isSupportDetail == false); |
193 QVERIFY(subTypeList.count() == 1); |
|
194 QVERIFY(subTypeList.contains(QContactPhoneNumber::SubTypeFacsimile)); |
|
195 |
|
196 //no actions expected |
|
197 QStringList actions = contact.availableActions(); |
|
198 |
|
199 QVERIFY(actions.contains("message", Qt::CaseInsensitive) == false); |
|
200 } |
187 } |
201 |
188 |
202 void TestMobCntActions::phonenumberVideoCallSupport() |
189 void TestMobCntActions::phonenumberVideoCallSupport() |
203 { |
190 { |
204 QContact contact; |
191 QContact contact; |
213 //verify that the contact has a phonenumber |
200 //verify that the contact has a phonenumber |
214 QList<QContactPhoneNumber> numberList = contact.details<QContactPhoneNumber>(); |
201 QList<QContactPhoneNumber> numberList = contact.details<QContactPhoneNumber>(); |
215 QVERIFY(numberList.count() > 0); |
202 QVERIFY(numberList.count() > 0); |
216 |
203 |
217 //get the actions |
204 //get the actions |
218 QStringList actions = contact.availableActions(); |
205 QList<QContactActionDescriptor> actionDescriptors = contact.availableActions(); |
|
206 QStringList actions; |
|
207 for (int i = 0;i < actionDescriptors.count();i++) |
|
208 { |
|
209 QString action = actionDescriptors.at(i).actionName(); |
|
210 actions << action; |
|
211 } |
219 |
212 |
220 //verify that it includes the actiosn |
213 //verify that it includes the actiosn |
221 QVERIFY(actions.contains("videocall", Qt::CaseInsensitive)); |
214 QVERIFY(actions.contains("videocall", Qt::CaseInsensitive)); |
222 |
215 |
223 //Test Video Call action |
216 //Test Video Call action |
224 QList<QContactActionDescriptor> videoCallActionDescriptors = QContactAction::actionDescriptors("videocall", "symbian"); |
217 QList<QContactActionDescriptor> videoCallActionDescriptors = QContactAction::actionDescriptors("videocall", "symbian"); |
225 QVERIFY(videoCallActionDescriptors.count() == 1); |
218 QVERIFY(videoCallActionDescriptors.count() == 1); |
226 QContactAction *videoCallAction = QContactAction::action(videoCallActionDescriptors.at(0)); |
219 QContactAction *videoCallAction = QContactAction::action(videoCallActionDescriptors.at(0)); |
227 QVERIFY(videoCallAction != 0); |
220 QVERIFY(videoCallAction != 0); |
228 QVERIFY(videoCallAction->supportsDetail(numberList.at(0)) == true); |
221 QVERIFY(videoCallAction->isDetailSupported(numberList.at(0)) == true); |
229 QVariantMap variantMap = videoCallAction->metadata(); |
222 QVariantMap variantMap = videoCallAction->metaData(); |
230 QVERIFY(variantMap.count() == 0); |
223 QVERIFY(variantMap.count() == 0); |
231 variantMap = videoCallAction->result(); |
224 variantMap = videoCallAction->results(); |
232 QVERIFY(variantMap.count() == 0); |
225 QVERIFY(variantMap.count() == 0); |
233 QSignalSpy spyVideoCallAction(videoCallAction, SIGNAL(progress(QContactAction::Status, const QVariantMap &))); |
226 QSignalSpy spyVideoCallAction(videoCallAction, SIGNAL(stateChanged(QContactAction::State))); |
234 videoCallAction->invokeAction(contact, numberList.at(0)); |
227 videoCallAction->invokeAction(contact, numberList.at(0)); |
235 videoCallAction->invokeAction(contact); |
228 videoCallAction->invokeAction(contact); |
236 QTRY_COMPARE(spyVideoCallAction.count(), 2); // make sure the signal was emitted exactly one time |
229 QTRY_COMPARE(spyVideoCallAction.count(), 2); // make sure the signal was emitted exactly one time |
237 delete videoCallAction; |
230 delete videoCallAction; |
238 } |
231 } |
239 |
232 |
240 void TestMobCntActions::phonenumberNoVideoCallSupport() |
233 void TestMobCntActions::phonenumberNoVideoCallSupport() |
241 { |
234 { |
242 QContact contact; |
235 QContact contact; |
243 |
236 m_manager->saveContact(&contact); |
244 QContactPhoneNumber faxNumber; |
237 |
245 faxNumber.setNumber("555111222"); |
238 //expected no actions found |
246 faxNumber.setSubTypes(QContactPhoneNumber::SubTypeFacsimile); |
239 QList<QContactActionDescriptor> actionDescriptors = contact.availableActions(); |
247 contact.saveDetail(&faxNumber); |
240 QStringList actions; |
248 m_manager->saveContact(&contact); |
241 for (int i = 0;i < actionDescriptors.count();i++) |
249 |
242 { |
250 //one number exist in contact |
243 QString action = actionDescriptors.at(i).actionName(); |
251 QList<QContactPhoneNumber> numberList = contact.details<QContactPhoneNumber>(); |
244 actions << action; |
252 QVERIFY(numberList.count() == 1); |
245 } |
253 |
|
254 QStringList subTypeList = numberList.at(0).subTypes(); |
|
255 |
|
256 QVERIFY(subTypeList.count() == 1); |
|
257 QVERIFY(subTypeList.contains(QContactPhoneNumber::SubTypeFacsimile)); |
|
258 |
|
259 //no actions expected |
|
260 QStringList actions = contact.availableActions(); |
|
261 |
|
262 QVERIFY(actions.contains("videocall", Qt::CaseInsensitive) == false); |
246 QVERIFY(actions.contains("videocall", Qt::CaseInsensitive) == false); |
263 } |
247 } |
264 |
248 |
265 void TestMobCntActions::phonenumberEmailSupport() |
249 void TestMobCntActions::emailSupport() |
266 { |
250 { |
267 QContact contact; |
251 QContact contact; |
268 QContactEmailAddress email; |
252 QContactEmailAddress email; |
269 email.setEmailAddress("test@test.com"); |
253 email.setEmailAddress("test@test.com"); |
270 contact.saveDetail(&email); |
254 contact.saveDetail(&email); |
272 |
256 |
273 //one number exist in contact |
257 //one number exist in contact |
274 QList<QContactEmailAddress> emailList = contact.details<QContactEmailAddress>(); |
258 QList<QContactEmailAddress> emailList = contact.details<QContactEmailAddress>(); |
275 QVERIFY(emailList.count() == 1); |
259 QVERIFY(emailList.count() == 1); |
276 |
260 |
277 //no actions expected |
261 //one action expected |
278 QStringList actions = contact.availableActions(); |
262 QList<QContactActionDescriptor> actionDescriptors = contact.availableActions(); |
|
263 QStringList actions; |
|
264 for (int i = 0;i < actionDescriptors.count();i++) |
|
265 { |
|
266 QString action = actionDescriptors.at(i).actionName(); |
|
267 actions << action; |
|
268 } |
279 QVERIFY(actions.count() == 1); |
269 QVERIFY(actions.count() == 1); |
280 QVERIFY(actions.contains("email", Qt::CaseInsensitive)); |
270 QVERIFY(actions.contains("email", Qt::CaseInsensitive)); |
281 |
271 |
282 //pick first number for the actions |
272 //pick first number for the actions |
283 QContactEmailAddress emailAddress = contact.detail<QContactEmailAddress>(); |
273 QContactEmailAddress emailAddress = contact.detail<QContactEmailAddress>(); |
285 //Test Email action |
275 //Test Email action |
286 QList<QContactActionDescriptor> emailActionDescriptors = QContactAction::actionDescriptors("email", "symbian"); |
276 QList<QContactActionDescriptor> emailActionDescriptors = QContactAction::actionDescriptors("email", "symbian"); |
287 QVERIFY(emailActionDescriptors.count() == 1); |
277 QVERIFY(emailActionDescriptors.count() == 1); |
288 QContactAction *emailAction = QContactAction::action(emailActionDescriptors.at(0)); |
278 QContactAction *emailAction = QContactAction::action(emailActionDescriptors.at(0)); |
289 QVERIFY(emailAction != 0); |
279 QVERIFY(emailAction != 0); |
290 QVERIFY(emailAction->supportsDetail(emailList.at(0)) == true); |
280 QVERIFY(emailAction->isDetailSupported(emailList.at(0)) == true); |
291 QVariantMap variantMap = emailAction->metadata(); |
281 QVariantMap variantMap = emailAction->metaData(); |
292 QVERIFY(variantMap.count() == 0); |
282 QVERIFY(variantMap.count() == 0); |
293 variantMap = emailAction->result(); |
283 variantMap = emailAction->results(); |
294 QVERIFY(variantMap.count() == 0); |
284 QVERIFY(variantMap.count() == 0); |
295 QSignalSpy spyEmailAction(emailAction, SIGNAL(progress(QContactAction::Status, const QVariantMap &))); |
285 QSignalSpy spyEmailAction(emailAction, SIGNAL(stateChanged(QContactAction::State))); |
296 emailAction->invokeAction(contact, emailAddress); |
286 emailAction->invokeAction(contact, emailAddress); |
297 emailAction->invokeAction(contact); |
287 emailAction->invokeAction(contact); |
298 QTRY_COMPARE(spyEmailAction.count(), 2); // make sure the signal was emitted exactly one time |
288 QTRY_COMPARE(spyEmailAction.count(), 2); // make sure the signal was emitted exactly one time |
299 delete emailAction; |
289 delete emailAction; |
300 } |
290 } |
301 |
291 |
302 void TestMobCntActions::phonenumberNoEmailSupport() |
292 void TestMobCntActions::noEmailSupport() |
303 { |
293 { |
304 QContact contact; |
294 QContact contact; |
305 m_manager->saveContact(&contact); |
295 m_manager->saveContact(&contact); |
306 |
296 |
307 //expected no actions found |
297 //expected no actions found |
308 QStringList actions = contact.availableActions(); |
298 QList<QContactActionDescriptor> actionDescriptors = contact.availableActions(); |
|
299 QStringList actions; |
|
300 for (int i = 0;i < actionDescriptors.count();i++) |
|
301 { |
|
302 QString action = actionDescriptors.at(i).actionName(); |
|
303 actions << action; |
|
304 } |
309 QVERIFY(actions.contains("email", Qt::CaseInsensitive) == false); |
305 QVERIFY(actions.contains("email", Qt::CaseInsensitive) == false); |
310 } |
306 } |
311 |
307 |
|
308 void TestMobCntActions::urlSupport() |
|
309 { |
|
310 QContact contact; |
|
311 QContactUrl url; |
|
312 url.setUrl("www.test.com"); |
|
313 contact.saveDetail(&url); |
|
314 m_manager->saveContact(&contact); |
|
315 |
|
316 //one number exist in contact |
|
317 QList<QContactUrl> urlList = contact.details<QContactUrl>(); |
|
318 QVERIFY(urlList.count() == 1); |
|
319 |
|
320 //no actions expected |
|
321 QList<QContactActionDescriptor> actionDescriptors = contact.availableActions(); |
|
322 QStringList actions; |
|
323 for (int i = 0;i < actionDescriptors.count();i++) |
|
324 { |
|
325 QString action = actionDescriptors.at(i).actionName(); |
|
326 actions << action; |
|
327 } |
|
328 QVERIFY(actions.count() == 1); |
|
329 QVERIFY(actions.contains("url", Qt::CaseInsensitive)); |
|
330 |
|
331 //pick first number for the actions |
|
332 QContactUrl urlAddress = contact.detail<QContactUrl>(); |
|
333 |
|
334 //Test Email action |
|
335 QList<QContactActionDescriptor> urlActionDescriptors = QContactAction::actionDescriptors("url", "symbian"); |
|
336 QVERIFY(urlActionDescriptors.count() == 1); |
|
337 QContactAction *urlAction = QContactAction::action(urlActionDescriptors.at(0)); |
|
338 QVERIFY(urlAction != 0); |
|
339 QVERIFY(urlAction->isDetailSupported(urlList.at(0)) == true); |
|
340 QVariantMap variantMap = urlAction->metaData(); |
|
341 QVERIFY(variantMap.count() == 0); |
|
342 variantMap = urlAction->results(); |
|
343 QVERIFY(variantMap.count() == 0); |
|
344 QSignalSpy spyUrlAction(urlAction, SIGNAL(stateChanged(QContactAction::State))); |
|
345 urlAction->invokeAction(contact, urlAddress); |
|
346 urlAction->invokeAction(contact); |
|
347 QTRY_COMPARE(spyUrlAction.count(), 2); // make sure the signal was emitted exactly once each time |
|
348 delete urlAction; |
|
349 } |
|
350 |
|
351 void TestMobCntActions::noUrlSupport() |
|
352 { |
|
353 QContact contact; |
|
354 m_manager->saveContact(&contact); |
|
355 |
|
356 //expected no actions found |
|
357 QList<QContactActionDescriptor> actionDescriptors = contact.availableActions(); |
|
358 QStringList actions; |
|
359 for (int i = 0;i < actionDescriptors.count();i++) |
|
360 { |
|
361 QString action = actionDescriptors.at(i).actionName(); |
|
362 actions << action; |
|
363 } |
|
364 QVERIFY(actions.contains("url", Qt::CaseInsensitive) == false); |
|
365 } |
|
366 |
312 QTEST_MAIN(TestMobCntActions); |
367 QTEST_MAIN(TestMobCntActions); |