1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 */ |
|
16 #include <QtTest/QtTest> |
|
17 #include <QtDebug> |
|
18 #include <QTimer> |
|
19 #include <QSignalSpy> |
|
20 #include <xqconversions.h> |
|
21 #include <csmsaccount.h> |
|
22 |
|
23 #include "convergedmessage.h" |
|
24 #include "unidatamodelplugininterface.h" |
|
25 #include "unidatamodelloader.h" |
|
26 #include "serviceinfo.h" |
|
27 #include "testunidatamodelsmsplugin.h" |
|
28 #include "testunidatamodelsmsplugin.ini" |
|
29 _LIT(KUnixEpoch, "19700000:000000.000000"); |
|
30 |
|
31 //--------------------------------------------------------------- |
|
32 // TestUniDataModelSMSPlugin::init |
|
33 //--------------------------------------------------------------- |
|
34 |
|
35 void TestUniDataModelSMSPlugin::init() |
|
36 { |
|
37 iObserver = new (ELeave) TestObserver(); |
|
38 |
|
39 // Create a new messaging server session.. |
|
40 iMSession = CMsvSession::OpenSyncL(*iObserver); |
|
41 // Create the client mtm registry |
|
42 iMtmReg = CClientMtmRegistry::NewL(*iMSession); |
|
43 |
|
44 // Get the SMS clientmtm |
|
45 iSmsClientMtm |
|
46 = static_cast<CSmsClientMtm*> (iMtmReg->NewMtmL(KUidMsgTypeSMS)); |
|
47 |
|
48 TRAPD(err, iSmsClientMtm->DefaultServiceL()) ; |
|
49 |
|
50 if( err == KErrNotFound) |
|
51 { |
|
52 CSmsAccount* account = CSmsAccount::NewL(); |
|
53 CleanupStack::PushL(account); |
|
54 CSmsSettings* settings = CSmsSettings::NewL(); |
|
55 CleanupStack::PushL(settings); |
|
56 account->InitialiseDefaultSettingsL(*settings); |
|
57 CleanupStack::PopAndDestroy(2); |
|
58 |
|
59 } |
|
60 messageId = 0; |
|
61 pluginLoader = new UniDataModelLoader(); |
|
62 retTimeStamp = QDateTime::currentDateTime(); |
|
63 } |
|
64 |
|
65 //--------------------------------------------------------------- |
|
66 // TestUniDataModelSMSPlugin::cleanup |
|
67 //--------------------------------------------------------------- |
|
68 void TestUniDataModelSMSPlugin::cleanup() |
|
69 { |
|
70 |
|
71 if (messageId > 0) |
|
72 iSmsClientMtm->Entry().DeleteL(messageId); |
|
73 |
|
74 delete iObserver; |
|
75 iObserver = NULL; |
|
76 delete iSmsClientMtm; |
|
77 iSmsClientMtm = NULL; |
|
78 delete iMtmReg; |
|
79 iMtmReg = NULL; |
|
80 delete iMSession; |
|
81 iMSession = NULL; |
|
82 |
|
83 delete pluginLoader; |
|
84 } |
|
85 |
|
86 //--------------------------------------------------------------- |
|
87 // TestUniDataModelSMSPlugin::validateMsg |
|
88 //--------------------------------------------------------------- |
|
89 void TestUniDataModelSMSPlugin::createInboxSMS() |
|
90 { |
|
91 TRAPD(err, iSmsClientMtm->SwitchCurrentEntryL(KMsvGlobalInBoxIndexEntryId)); |
|
92 |
|
93 // Create a SMS message |
|
94 iSmsClientMtm->CreateMessageL(iSmsClientMtm->DefaultServiceL()); |
|
95 TMsvEntry indexEntry = iSmsClientMtm->Entry().Entry(); |
|
96 |
|
97 indexEntry.SetInPreparation(ETrue); |
|
98 indexEntry.iMtm = KUidMsgTypeSMS; |
|
99 indexEntry.iType = KUidMsvMessageEntry; |
|
100 indexEntry.iServiceId = iSmsClientMtm->ServiceId(); |
|
101 indexEntry.iDate.HomeTime(); |
|
102 |
|
103 // Convert TTime to QDateTime , this will be used for comparing the time of message |
|
104 // when fetched from datamodel |
|
105 TTime unixEpoch(KUnixEpoch); |
|
106 TTimeIntervalSeconds seconds; |
|
107 TTime timeStamp = indexEntry.iDate; |
|
108 timeStamp.SecondsFrom(unixEpoch, seconds); |
|
109 retTimeStamp.setTime_t(seconds.Int()); |
|
110 |
|
111 //AddBody |
|
112 QString body(TEST_MSG_BODY); |
|
113 |
|
114 HBufC* bodyText = XQConversions::qStringToS60Desc(body); |
|
115 if (bodyText) |
|
116 { |
|
117 CleanupStack::PushL(bodyText); |
|
118 // Set the Body of the message |
|
119 CRichText & body = iSmsClientMtm->Body(); |
|
120 body.Reset(); |
|
121 body.InsertL(0, *bodyText); |
|
122 |
|
123 TBuf<32> buf; |
|
124 buf.Copy(bodyText->Left(32)); |
|
125 indexEntry.iDescription.Set(buf); |
|
126 |
|
127 CleanupStack::PopAndDestroy(bodyText); |
|
128 } |
|
129 |
|
130 QString recepient(TEST_MSG_FROM1); |
|
131 QString recepient2(TEST_MSG_FROM2); |
|
132 QString alias(TEST_MSG_ALIAS1); |
|
133 |
|
134 HBufC* addr = XQConversions::qStringToS60Desc(recepient); |
|
135 HBufC* addr2 = XQConversions::qStringToS60Desc(recepient2); |
|
136 HBufC* alias1 = XQConversions::qStringToS60Desc(alias); |
|
137 |
|
138 if (addr) |
|
139 { |
|
140 CleanupStack::PushL(addr); |
|
141 TBuf<32> name; |
|
142 name.Copy(addr->Left(32)); |
|
143 indexEntry.iDetails.Set(name); |
|
144 CSmsHeader& smsHeader = iSmsClientMtm->SmsHeader(); |
|
145 smsHeader.SetFromAddressL(*addr); |
|
146 messageId = indexEntry.Id(); |
|
147 |
|
148 CleanupStack::PopAndDestroy(addr); |
|
149 } |
|
150 |
|
151 indexEntry.SetAttachment(EFalse); |
|
152 indexEntry.SetVisible(ETrue); |
|
153 indexEntry.SetInPreparation(EFalse); |
|
154 |
|
155 indexEntry.SetComplete(ETrue); |
|
156 iSmsClientMtm->Entry().ChangeL(indexEntry); |
|
157 iSmsClientMtm->SaveMessageL(); |
|
158 |
|
159 } |
|
160 |
|
161 void TestUniDataModelSMSPlugin::createOutboxSMS() |
|
162 { |
|
163 TRAPD(err, iSmsClientMtm->SwitchCurrentEntryL(KMsvGlobalOutBoxIndexEntryId)); |
|
164 |
|
165 // Create a SMS message |
|
166 iSmsClientMtm->CreateMessageL(iSmsClientMtm->DefaultServiceL()); |
|
167 TMsvEntry indexEntry = iSmsClientMtm->Entry().Entry(); |
|
168 |
|
169 indexEntry.SetInPreparation(ETrue); |
|
170 indexEntry.iMtm = KUidMsgTypeSMS; |
|
171 indexEntry.iType = KUidMsvMessageEntry; |
|
172 indexEntry.iServiceId = iSmsClientMtm->ServiceId(); |
|
173 indexEntry.iDate.HomeTime(); |
|
174 |
|
175 // Convert TTime to QDateTime , this will be used for comparing the time of message |
|
176 // when fetched from datamodel |
|
177 TTime unixEpoch(KUnixEpoch); |
|
178 TTimeIntervalSeconds seconds; |
|
179 TTime timeStamp = indexEntry.iDate; |
|
180 timeStamp.SecondsFrom(unixEpoch, seconds); |
|
181 retTimeStamp.setTime_t(seconds.Int()); |
|
182 |
|
183 //AddBody |
|
184 QString body(TEST_MSG_BODY); |
|
185 |
|
186 HBufC* bodyText = XQConversions::qStringToS60Desc(body); |
|
187 if (bodyText) |
|
188 { |
|
189 CleanupStack::PushL(bodyText); |
|
190 // Set the Body of the message |
|
191 CRichText & body = iSmsClientMtm->Body(); |
|
192 body.Reset(); |
|
193 body.InsertL(0, *bodyText); |
|
194 |
|
195 TBuf<32> buf; |
|
196 buf.Copy(bodyText->Left(32)); |
|
197 indexEntry.iDescription.Set(buf); |
|
198 |
|
199 CleanupStack::PopAndDestroy(bodyText); |
|
200 } |
|
201 |
|
202 QString recepient(TEST_MSG_FROM1); |
|
203 QString recepient2(TEST_MSG_FROM2); |
|
204 QString alias(TEST_MSG_ALIAS1); |
|
205 |
|
206 HBufC* addr = XQConversions::qStringToS60Desc(recepient); |
|
207 HBufC* addr2 = XQConversions::qStringToS60Desc(recepient2); |
|
208 HBufC* alias1 = XQConversions::qStringToS60Desc(alias); |
|
209 |
|
210 if (addr) |
|
211 { |
|
212 CleanupStack::PushL(addr); |
|
213 TBuf<32> name; |
|
214 name.Copy(addr->Left(32)); |
|
215 indexEntry.iDetails.Set(name); |
|
216 |
|
217 // If drafts/ outbox message , set the recipients |
|
218 iSmsClientMtm->AddAddresseeL(*addr, TPtrC()); |
|
219 iSmsClientMtm->AddAddresseeL(*addr2, *alias1); |
|
220 indexEntry.SetSendingState(KMsvSendStateWaiting); |
|
221 messageId = indexEntry.Id(); |
|
222 CleanupStack::PopAndDestroy(addr); |
|
223 } |
|
224 |
|
225 indexEntry.SetAttachment(EFalse); |
|
226 indexEntry.SetVisible(ETrue); |
|
227 indexEntry.SetInPreparation(EFalse); |
|
228 |
|
229 indexEntry.SetComplete(ETrue); |
|
230 iSmsClientMtm->Entry().ChangeL(indexEntry); |
|
231 iSmsClientMtm->SaveMessageL(); |
|
232 |
|
233 } |
|
234 |
|
235 void TestUniDataModelSMSPlugin::createSentSMS() |
|
236 { |
|
237 TRAPD(err, iSmsClientMtm->SwitchCurrentEntryL(KMsvSentEntryId)); |
|
238 |
|
239 // Create a SMS message |
|
240 iSmsClientMtm->CreateMessageL(iSmsClientMtm->DefaultServiceL()); |
|
241 TMsvEntry indexEntry = iSmsClientMtm->Entry().Entry(); |
|
242 |
|
243 indexEntry.SetInPreparation(ETrue); |
|
244 indexEntry.iMtm = KUidMsgTypeSMS; |
|
245 indexEntry.iType = KUidMsvMessageEntry; |
|
246 indexEntry.iServiceId = iSmsClientMtm->ServiceId(); |
|
247 indexEntry.iDate.HomeTime(); |
|
248 |
|
249 // Convert TTime to QDateTime , this will be used for comparing the time of message |
|
250 // when fetched from datamodel |
|
251 |
|
252 TTime unixEpoch(KUnixEpoch); |
|
253 TTimeIntervalSeconds seconds; |
|
254 TTime timeStamp = indexEntry.iDate; |
|
255 timeStamp.SecondsFrom(unixEpoch, seconds); |
|
256 retTimeStamp.setTime_t(seconds.Int()); |
|
257 |
|
258 //AddBody |
|
259 QString body(TEST_MSG_BODY); |
|
260 |
|
261 HBufC* bodyText = XQConversions::qStringToS60Desc(body); |
|
262 if (bodyText) |
|
263 { |
|
264 CleanupStack::PushL(bodyText); |
|
265 // Set the Body of the message |
|
266 CRichText & body = iSmsClientMtm->Body(); |
|
267 body.Reset(); |
|
268 body.InsertL(0, *bodyText); |
|
269 |
|
270 TBuf<32> buf; |
|
271 buf.Copy(bodyText->Left(32)); |
|
272 indexEntry.iDescription.Set(buf); |
|
273 |
|
274 CleanupStack::PopAndDestroy(bodyText); |
|
275 } |
|
276 |
|
277 QString recepient(TEST_MSG_FROM1); |
|
278 QString recepient2(TEST_MSG_FROM2); |
|
279 QString alias(TEST_MSG_ALIAS1); |
|
280 |
|
281 HBufC* addr = XQConversions::qStringToS60Desc(recepient); |
|
282 HBufC* addr2 = XQConversions::qStringToS60Desc(recepient2); |
|
283 HBufC* alias1 = XQConversions::qStringToS60Desc(alias); |
|
284 |
|
285 if (addr) |
|
286 { |
|
287 CleanupStack::PushL(addr); |
|
288 TBuf<32> name; |
|
289 name.Copy(addr->Left(32)); |
|
290 indexEntry.iDetails.Set(name); |
|
291 |
|
292 // If inbox/ sent folder message , set the from address |
|
293 CSmsHeader& smsHeader = iSmsClientMtm->SmsHeader(); |
|
294 smsHeader.SetFromAddressL(*addr); |
|
295 messageId = indexEntry.Id(); |
|
296 |
|
297 CleanupStack::PopAndDestroy(addr); |
|
298 } |
|
299 |
|
300 indexEntry.SetAttachment(EFalse); |
|
301 indexEntry.SetVisible(ETrue); |
|
302 indexEntry.SetInPreparation(EFalse); |
|
303 |
|
304 indexEntry.SetComplete(ETrue); |
|
305 iSmsClientMtm->Entry().ChangeL(indexEntry); |
|
306 iSmsClientMtm->SaveMessageL(); |
|
307 |
|
308 } |
|
309 |
|
310 void TestUniDataModelSMSPlugin::createDraftsSMS() |
|
311 { |
|
312 TRAPD(err, iSmsClientMtm->SwitchCurrentEntryL(KMsvDraftEntryId)); |
|
313 // Create a SMS message |
|
314 iSmsClientMtm->CreateMessageL(iSmsClientMtm->DefaultServiceL()); |
|
315 TMsvEntry indexEntry = iSmsClientMtm->Entry().Entry(); |
|
316 |
|
317 indexEntry.SetInPreparation(ETrue); |
|
318 indexEntry.iMtm = KUidMsgTypeSMS; |
|
319 indexEntry.iType = KUidMsvMessageEntry; |
|
320 indexEntry.iServiceId = iSmsClientMtm->ServiceId(); |
|
321 indexEntry.iDate.HomeTime(); |
|
322 |
|
323 // Convert TTime to QDateTime , this will be used for comparing the time of message |
|
324 // when fetched from datamodel |
|
325 TTime unixEpoch(KUnixEpoch); |
|
326 TTimeIntervalSeconds seconds; |
|
327 TTime timeStamp = indexEntry.iDate; |
|
328 timeStamp.SecondsFrom(unixEpoch, seconds); |
|
329 retTimeStamp.setTime_t(seconds.Int()); |
|
330 |
|
331 //AddBody |
|
332 QString body(TEST_MSG_BODY); |
|
333 |
|
334 HBufC* bodyText = XQConversions::qStringToS60Desc(body); |
|
335 if (bodyText) |
|
336 { |
|
337 CleanupStack::PushL(bodyText); |
|
338 // Set the Body of the message |
|
339 CRichText & body = iSmsClientMtm->Body(); |
|
340 body.Reset(); |
|
341 body.InsertL(0, *bodyText); |
|
342 |
|
343 TBuf<32> buf; |
|
344 buf.Copy(bodyText->Left(32)); |
|
345 indexEntry.iDescription.Set(buf); |
|
346 |
|
347 CleanupStack::PopAndDestroy(bodyText); |
|
348 } |
|
349 |
|
350 QString recipient(TEST_MSG_FROM1); |
|
351 QString recipient2(TEST_MSG_FROM2); |
|
352 QString alias(TEST_MSG_ALIAS1); |
|
353 |
|
354 HBufC* addr = XQConversions::qStringToS60Desc(recipient); |
|
355 HBufC* addr2 = XQConversions::qStringToS60Desc(recipient2); |
|
356 HBufC* alias1 = XQConversions::qStringToS60Desc(alias); |
|
357 |
|
358 if (addr) |
|
359 { |
|
360 CleanupStack::PushL(addr); |
|
361 TBuf<32> name; |
|
362 name.Copy(addr->Left(32)); |
|
363 indexEntry.iDetails.Set(name); |
|
364 |
|
365 // If drafts/ outbox message , set the recipients |
|
366 iSmsClientMtm->AddAddresseeL(*addr, TPtrC()); |
|
367 indexEntry.SetSendingState(KMsvSendStateWaiting); |
|
368 messageId = indexEntry.Id(); |
|
369 |
|
370 CleanupStack::PopAndDestroy(addr); |
|
371 } |
|
372 |
|
373 indexEntry.SetAttachment(EFalse); |
|
374 indexEntry.SetVisible(ETrue); |
|
375 indexEntry.SetInPreparation(EFalse); |
|
376 |
|
377 indexEntry.SetComplete(ETrue); |
|
378 iSmsClientMtm->Entry().ChangeL(indexEntry); |
|
379 iSmsClientMtm->SaveMessageL(); |
|
380 |
|
381 } |
|
382 |
|
383 void TestUniDataModelSMSPlugin::createDraftsSMSNoRecipient() |
|
384 { |
|
385 TRAPD(err, iSmsClientMtm->SwitchCurrentEntryL(KMsvDraftEntryId)); |
|
386 // Create a SMS message |
|
387 iSmsClientMtm->CreateMessageL(iSmsClientMtm->DefaultServiceL()); |
|
388 TMsvEntry indexEntry = iSmsClientMtm->Entry().Entry(); |
|
389 |
|
390 indexEntry.SetInPreparation(ETrue); |
|
391 indexEntry.iMtm = KUidMsgTypeSMS; |
|
392 indexEntry.iType = KUidMsvMessageEntry; |
|
393 indexEntry.iServiceId = iSmsClientMtm->ServiceId(); |
|
394 indexEntry.iDate.HomeTime(); |
|
395 |
|
396 //AddBody |
|
397 QString body(TEST_MSG_BODY); |
|
398 |
|
399 HBufC* bodyText = XQConversions::qStringToS60Desc(body); |
|
400 if (bodyText) |
|
401 { |
|
402 CleanupStack::PushL(bodyText); |
|
403 // Set the Body of the message |
|
404 CRichText & body = iSmsClientMtm->Body(); |
|
405 body.Reset(); |
|
406 body.InsertL(0, *bodyText); |
|
407 |
|
408 TBuf<32> buf; |
|
409 buf.Copy(bodyText->Left(32)); |
|
410 indexEntry.iDescription.Set(buf); |
|
411 |
|
412 CleanupStack::PopAndDestroy(bodyText); |
|
413 } |
|
414 |
|
415 indexEntry.SetSendingState(KMsvSendStateWaiting); |
|
416 messageId = indexEntry.Id(); |
|
417 |
|
418 indexEntry.SetAttachment(EFalse); |
|
419 indexEntry.SetVisible(ETrue); |
|
420 indexEntry.SetInPreparation(EFalse); |
|
421 |
|
422 indexEntry.SetComplete(ETrue); |
|
423 iSmsClientMtm->Entry().ChangeL(indexEntry); |
|
424 iSmsClientMtm->SaveMessageL(); |
|
425 |
|
426 } |
|
427 |
|
428 void TestUniDataModelSMSPlugin::testInboxMessage() |
|
429 { |
|
430 createInboxSMS(); |
|
431 |
|
432 // Get the SMS data modelplugin |
|
433 pluginInterface = pluginLoader->getDataModelPlugin(ConvergedMessage::Sms); |
|
434 |
|
435 pluginInterface->setMessageId(messageId); |
|
436 |
|
437 int size = pluginInterface->messageSize(); |
|
438 |
|
439 QVERIFY(pluginInterface->timeStamp() == retTimeStamp); |
|
440 |
|
441 QString body; |
|
442 pluginInterface->body(body); |
|
443 QString origBody(TEST_MSG_BODY); |
|
444 QVERIFY(origBody == body); |
|
445 |
|
446 ConvergedMessageAddressList recipientList; |
|
447 pluginInterface->toRecipientList(recipientList); |
|
448 |
|
449 QString recipient(TEST_MSG_FROM1); |
|
450 QString recipient2(TEST_MSG_FROM2); |
|
451 QString origalias(TEST_MSG_ALIAS1); |
|
452 |
|
453 QVERIFY(recipientList.count() == 0); |
|
454 |
|
455 int size1 = pluginInterface->messageSize(); |
|
456 |
|
457 QString fromaddress; |
|
458 pluginInterface->fromAddress(fromaddress); |
|
459 QVERIFY(recipient == fromaddress); |
|
460 TRAPD(err, iSmsClientMtm->SwitchCurrentEntryL(KMsvGlobalInBoxIndexEntryId)); |
|
461 } |
|
462 |
|
463 void TestUniDataModelSMSPlugin::testOutboxMessage() |
|
464 { |
|
465 createOutboxSMS(); |
|
466 // Get the SMS data modelplugin |
|
467 pluginInterface = pluginLoader->getDataModelPlugin(ConvergedMessage::Sms); |
|
468 |
|
469 // Get the data for the first message in DRAFTS |
|
470 pluginInterface->setMessageId(messageId); |
|
471 int size = pluginInterface->messageSize(); |
|
472 |
|
473 QVERIFY(pluginInterface->timeStamp() == retTimeStamp); |
|
474 |
|
475 QString body; |
|
476 pluginInterface->body(body); |
|
477 QString origBody(TEST_MSG_BODY); |
|
478 QVERIFY(origBody == body); |
|
479 |
|
480 ConvergedMessageAddressList recipientList; |
|
481 pluginInterface->toRecipientList(recipientList); |
|
482 |
|
483 QString recipient(TEST_MSG_FROM1); |
|
484 QString recipient2(TEST_MSG_FROM2); |
|
485 QString origalias(TEST_MSG_ALIAS1); |
|
486 |
|
487 QVERIFY(recipientList.count() == 2); |
|
488 QVERIFY(recipient == recipientList[0]->address() |
|
489 && recipientList[0]->alias().isEmpty()); |
|
490 |
|
491 const QString& as = recipientList[1]->address(); |
|
492 const QString& as1 = recipientList[1]->alias(); |
|
493 QVERIFY(recipient2 == as); |
|
494 |
|
495 // ConvergedMessageAddress::alias return a QSting with a space |
|
496 origalias.append(' '); |
|
497 QVERIFY(origalias == as1); |
|
498 |
|
499 int size1 = pluginInterface->messageSize(); |
|
500 |
|
501 QString fromaddress; |
|
502 pluginInterface->fromAddress(fromaddress); |
|
503 QVERIFY(fromaddress.isEmpty()); |
|
504 TRAPD(err, iSmsClientMtm->SwitchCurrentEntryL(KMsvGlobalOutBoxIndexEntryId)); |
|
505 } |
|
506 |
|
507 void TestUniDataModelSMSPlugin::testSentMessage() |
|
508 { |
|
509 createSentSMS(); |
|
510 // Get the SMS data modelplugin |
|
511 pluginInterface = pluginLoader->getDataModelPlugin(ConvergedMessage::Sms); |
|
512 |
|
513 pluginInterface->setMessageId(messageId); |
|
514 |
|
515 int size = pluginInterface->messageSize(); |
|
516 |
|
517 QVERIFY(pluginInterface->timeStamp() == retTimeStamp); |
|
518 |
|
519 QString body; |
|
520 pluginInterface->body(body); |
|
521 QString origBody(TEST_MSG_BODY); |
|
522 QVERIFY(origBody == body); |
|
523 |
|
524 ConvergedMessageAddressList recipientList; |
|
525 pluginInterface->toRecipientList(recipientList); |
|
526 |
|
527 QString recipient(TEST_MSG_FROM1); |
|
528 QString recipient2(TEST_MSG_FROM2); |
|
529 QString origalias(TEST_MSG_ALIAS1); |
|
530 |
|
531 QVERIFY(recipientList.count() == 0); |
|
532 |
|
533 QString fromaddress; |
|
534 pluginInterface->fromAddress(fromaddress); |
|
535 QVERIFY(recipient == fromaddress); |
|
536 TRAPD(err, iSmsClientMtm->SwitchCurrentEntryL(KMsvSentEntryId)); |
|
537 } |
|
538 |
|
539 void TestUniDataModelSMSPlugin::testDraftsMessage() |
|
540 { |
|
541 createDraftsSMS(); |
|
542 // Get the SMS data modelplugin |
|
543 pluginInterface = pluginLoader->getDataModelPlugin(ConvergedMessage::Sms); |
|
544 |
|
545 // Get the data for the first message in DRAFTS |
|
546 pluginInterface->setMessageId(messageId); |
|
547 int size = pluginInterface->messageSize(); |
|
548 |
|
549 QVERIFY(pluginInterface->timeStamp() == retTimeStamp); |
|
550 |
|
551 QString body; |
|
552 pluginInterface->body(body); |
|
553 QString origBody(TEST_MSG_BODY); |
|
554 QVERIFY(origBody == body); |
|
555 |
|
556 ConvergedMessageAddressList recipientList; |
|
557 pluginInterface->toRecipientList(recipientList); |
|
558 |
|
559 QString recipient(TEST_MSG_FROM1); |
|
560 |
|
561 QVERIFY(recipientList.count() == 1); |
|
562 QVERIFY(recipient == recipientList[0]->address() |
|
563 && recipientList[0]->alias().isEmpty()); |
|
564 |
|
565 QString fromaddress; |
|
566 pluginInterface->fromAddress(fromaddress); |
|
567 QVERIFY(fromaddress.isEmpty()); |
|
568 TRAPD(err, iSmsClientMtm->SwitchCurrentEntryL(KMsvDraftEntryId)); |
|
569 } |
|
570 |
|
571 void TestUniDataModelSMSPlugin::testDraftsMessageNoRecipient() |
|
572 { |
|
573 createDraftsSMSNoRecipient(); |
|
574 // Get the SMS data modelplugin |
|
575 pluginInterface = pluginLoader->getDataModelPlugin(ConvergedMessage::Sms); |
|
576 |
|
577 // Get the data for the first message in DRAFTS |
|
578 pluginInterface->setMessageId(messageId); |
|
579 int size = pluginInterface->messageSize(); |
|
580 |
|
581 QString body; |
|
582 pluginInterface->body(body); |
|
583 QString origBody(TEST_MSG_BODY); |
|
584 QVERIFY(origBody == body); |
|
585 |
|
586 ConvergedMessageAddressList recipientList; |
|
587 pluginInterface->toRecipientList(recipientList); |
|
588 |
|
589 QVERIFY(recipientList.count() == 0); |
|
590 |
|
591 QString fromaddress; |
|
592 pluginInterface->fromAddress(fromaddress); |
|
593 QVERIFY(fromaddress.isEmpty()); |
|
594 TRAPD(err, iSmsClientMtm->SwitchCurrentEntryL(KMsvDraftEntryId)); |
|
595 } |
|
596 |
|
597 void TestUniDataModelSMSPlugin::testGetPluginWithoutLoading() |
|
598 { |
|
599 pluginInterface = pluginLoader->getDataModelPlugin(ConvergedMessage::Sms); |
|
600 QVERIFY(pluginInterface == NULL); |
|
601 |
|
602 // Try to geta plugin for a differnt message type |
|
603 pluginInterface = pluginLoader->getDataModelPlugin(ConvergedMessage::Mms); |
|
604 QVERIFY(pluginInterface == NULL); |
|
605 } |
|
606 |
|
607 void TestUniDataModelSMSPlugin::testUnusedAPIs() |
|
608 { |
|
609 pluginInterface = pluginLoader->getDataModelPlugin(ConvergedMessage::Sms); |
|
610 |
|
611 QVERIFY(pluginInterface->hasAttachment() == false); |
|
612 |
|
613 UniMessageInfoList attachmentlist = pluginInterface->attachmentList(); |
|
614 QVERIFY(attachmentlist.isEmpty()); |
|
615 |
|
616 QVERIFY(pluginInterface->objectCount() == 0); |
|
617 |
|
618 UniMessageInfoList objectlist = pluginInterface->objectList(); |
|
619 QVERIFY(objectlist.isEmpty()); |
|
620 |
|
621 QVERIFY(pluginInterface->slideCount() == 0); |
|
622 |
|
623 UniMessageInfoList slidelist = pluginInterface->slideContent(0); |
|
624 QVERIFY(slidelist.isEmpty()); |
|
625 |
|
626 ConvergedMessageAddressList recipientList; |
|
627 |
|
628 pluginInterface->ccRecipientList(recipientList); |
|
629 QVERIFY(recipientList.count() == 0); |
|
630 |
|
631 pluginInterface->bccRecipientList(recipientList); |
|
632 QVERIFY(recipientList.count() == 0); |
|
633 |
|
634 MsgPriority priority = pluginInterface->messagePriority(); |
|
635 // Normal priority |
|
636 qDebug() << "prority" << priority; |
|
637 QVERIFY(priority == 1); |
|
638 int count = pluginInterface->attachmentCount(); |
|
639 QVERIFY(count == 0); |
|
640 |
|
641 } |
|
642 |
|
643 void TestObserver::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, |
|
644 TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
|
645 { |
|
646 } |
|