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