|
1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Contains tests for RMobileSmsMessaging API |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32test.h> |
|
19 |
|
20 #include "TE_EtelMMTestStepBase.h" |
|
21 #include "TE_mmsms.h" |
|
22 #include "testdef.h" |
|
23 |
|
24 CTestSmsMessaging::CTestSmsMessaging() |
|
25 /** Each test step initialises it's own name |
|
26 */ |
|
27 { |
|
28 // store the name of this test case |
|
29 // this is the name that is used by the script file |
|
30 SetTestStepName(_L("TestSmsMessaging")); |
|
31 } |
|
32 |
|
33 enum TVerdict CTestSmsMessaging::doTestStepL() |
|
34 // |
|
35 // Test SMS Messaging Functions |
|
36 // |
|
37 { |
|
38 iTestCount=1; |
|
39 INFO_PRINTF1(_L("")); |
|
40 INFO_PRINTF1(_L("Test Mobile SMS Messaging Functionality")); |
|
41 // LOGTEXT(_L8("Test Mobile SMS Messaging Functionality")); |
|
42 |
|
43 RMobilePhone mmPhone; |
|
44 TInt ret=mmPhone.Open(iTelServer,DMMTSY_PHONE_NAME); |
|
45 TEST(ret==KErrNone); |
|
46 |
|
47 RMobileSmsMessaging smsMessaging; |
|
48 ret=smsMessaging.Open(mmPhone); |
|
49 TEST(ret==KErrNone); |
|
50 |
|
51 TRequestStatus reqStatus; |
|
52 |
|
53 // Get SMS messaging caps |
|
54 RMobileSmsMessaging::TMobileSmsCapsV1 smsCaps; |
|
55 RMobileSmsMessaging::TMobileSmsCapsV1Pckg smsCapsPckg(smsCaps); |
|
56 |
|
57 TEST(smsMessaging.GetCaps(smsCapsPckg)==KErrNone); |
|
58 TEST(smsCaps.iSmsMode==DMMTSY_SMS_MESSAGING_MODE_CAPS); |
|
59 TEST(smsCaps.iSmsControl==DMMTSY_SMS_MESSAGING_CONTROL_CAPS); |
|
60 |
|
61 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::GetCaps (sync) passed"), iTestCount++); |
|
62 |
|
63 // test.Next(_L("OK: RMobileSmsMessaging's Get SMS caps")); |
|
64 |
|
65 // Receive Mode |
|
66 RMobileSmsMessaging::TMobileSmsReceiveMode receiveMode; |
|
67 |
|
68 TEST(smsMessaging.GetReceiveMode(receiveMode)==KErrNone); |
|
69 TEST(receiveMode==DMMTSY_SMS_MESSAGING_RECEIVE_MODE1); |
|
70 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::GetReceiveMode (sync) passed"), iTestCount++); |
|
71 |
|
72 smsMessaging.SetReceiveMode(reqStatus, receiveMode); |
|
73 User::WaitForRequest(reqStatus); |
|
74 TEST(reqStatus.Int()==KErrNone); |
|
75 |
|
76 smsMessaging.SetReceiveMode(reqStatus, receiveMode); |
|
77 smsMessaging.CancelAsyncRequest(EMobileSmsMessagingSetReceiveMode); |
|
78 User::WaitForRequest(reqStatus); |
|
79 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
80 if (reqStatus.Int()==KErrCancel) |
|
81 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::SetReceiveMode (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
82 else |
|
83 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::SetReceiveMode (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
84 |
|
85 smsMessaging.NotifyReceiveModeChange(reqStatus, receiveMode); |
|
86 User::WaitForRequest(reqStatus); |
|
87 TEST(reqStatus.Int()==KErrNone); |
|
88 TEST(receiveMode==DMMTSY_SMS_MESSAGING_RECEIVE_MODE2); |
|
89 |
|
90 smsMessaging.NotifyReceiveModeChange(reqStatus, receiveMode); |
|
91 smsMessaging.CancelAsyncRequest(EMobileSmsMessagingNotifyReceiveModeChange); |
|
92 User::WaitForRequest(reqStatus); |
|
93 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
94 if (reqStatus.Int()==KErrCancel) |
|
95 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::NotifyReceiveModeChange (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
96 else |
|
97 { |
|
98 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::NotifyReceiveModeChange (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
99 } |
|
100 |
|
101 // test.Next(_L("OK: RMobileSmsMessaging's SMS Receive Mode")); |
|
102 |
|
103 // Receive Incoming Message |
|
104 RMobileSmsMessaging::TMobileSmsGsmTpdu gsmMsg; |
|
105 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1 recAtt; |
|
106 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1Pckg recAttPckg(recAtt); |
|
107 |
|
108 smsMessaging.ReceiveMessage(reqStatus, gsmMsg, recAttPckg); |
|
109 User::WaitForRequest(reqStatus); |
|
110 TEST(reqStatus.Int()==KErrNone); |
|
111 ValidateReceivedSmsMessage(gsmMsg, recAtt); |
|
112 |
|
113 smsMessaging.ReceiveMessage(reqStatus, gsmMsg, recAttPckg); |
|
114 smsMessaging.CancelAsyncRequest(EMobileSmsMessagingReceiveMessage); |
|
115 User::WaitForRequest(reqStatus); |
|
116 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
117 if (reqStatus.Int()==KErrCancel) |
|
118 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::ReceiveMessage (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
119 else |
|
120 { |
|
121 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::ReceiveMessage (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
122 } |
|
123 |
|
124 // test.Next(_L("OK: RMobileSmsMessaging's Receive Message")); |
|
125 |
|
126 // AckSmsStored - test no PDU supplied first |
|
127 TPtrC8 emptyPdu(NULL,0); |
|
128 |
|
129 smsMessaging.AckSmsStored(reqStatus, emptyPdu, DMMTSY_SMS_MESSAGE_FULL); |
|
130 User::WaitForRequest(reqStatus); |
|
131 TEST(reqStatus.Int()==KErrNone); |
|
132 |
|
133 // AckSmsStored - test PDU supplied second |
|
134 TPtrC8 pdu(DMMTSY_SMS_MESSAGE_PDU1); |
|
135 |
|
136 smsMessaging.AckSmsStored(reqStatus, pdu, DMMTSY_SMS_MESSAGE_FULL); |
|
137 User::WaitForRequest(reqStatus); |
|
138 TEST(reqStatus.Int()==KErrNone); |
|
139 |
|
140 // asynchronous & cancel |
|
141 |
|
142 smsMessaging.AckSmsStored(reqStatus, pdu, DMMTSY_SMS_MESSAGE_FULL); |
|
143 smsMessaging.CancelAsyncRequest(EMobileSmsMessagingAckSmsStored); |
|
144 User::WaitForRequest(reqStatus); |
|
145 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
146 if (reqStatus.Int()==KErrCancel) |
|
147 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::AckSmsStored (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
148 else |
|
149 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::AckSmsStored (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
150 |
|
151 // Test NackSmsStored |
|
152 |
|
153 // asynchronous |
|
154 |
|
155 smsMessaging.NackSmsStored(reqStatus, pdu, DMMTSY_SMS_MESSAGE_NACK_CAUSE); |
|
156 User::WaitForRequest(reqStatus); |
|
157 TEST(reqStatus.Int()==KErrNone); |
|
158 |
|
159 // asynchronous & cancel |
|
160 |
|
161 smsMessaging.NackSmsStored(reqStatus, pdu, DMMTSY_SMS_MESSAGE_NACK_CAUSE); |
|
162 smsMessaging.CancelAsyncRequest(EMobileSmsMessagingNackSmsStored); |
|
163 User::WaitForRequest(reqStatus); |
|
164 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
165 if (reqStatus.Int()==KErrCancel) |
|
166 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::NackSmsStored (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
167 else |
|
168 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::NackSmsStored (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
169 |
|
170 // Test Resume Sms Reception |
|
171 |
|
172 smsMessaging.ResumeSmsReception(reqStatus); |
|
173 User::WaitForRequest(reqStatus); |
|
174 TEST(reqStatus.Int() == KErrNone); |
|
175 |
|
176 smsMessaging.ResumeSmsReception(reqStatus); |
|
177 smsMessaging.CancelAsyncRequest(EMobileSmsMessagingResumeSmsReception); |
|
178 User::WaitForRequest(reqStatus); |
|
179 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
180 if (reqStatus.Int()==KErrCancel) |
|
181 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::ResumeSmsReception (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
182 else |
|
183 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::ResumeSmsReception (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
184 |
|
185 |
|
186 // Test Get/Set SMS Bearer |
|
187 RMobileSmsMessaging::TMobileSmsBearer bearer; |
|
188 |
|
189 TEST(smsMessaging.GetMoSmsBearer(bearer)==KErrNone); |
|
190 TEST(bearer==DMMTSY_SMS_MESSAGING_BEARER1); |
|
191 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::GetMoSmsBearer (sync) passed"), iTestCount++); |
|
192 |
|
193 smsMessaging.SetMoSmsBearer(reqStatus, bearer); |
|
194 User::WaitForRequest(reqStatus); |
|
195 TEST(reqStatus.Int()==KErrNone); |
|
196 |
|
197 smsMessaging.SetMoSmsBearer(reqStatus, bearer); |
|
198 smsMessaging.CancelAsyncRequest(EMobileSmsMessagingSetMoSmsBearer); |
|
199 User::WaitForRequest(reqStatus); |
|
200 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
201 if (reqStatus.Int()==KErrCancel) |
|
202 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::SetMoSmsBearer (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
203 else |
|
204 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::SetMoSmsBearer (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
205 |
|
206 smsMessaging.NotifyMoSmsBearerChange(reqStatus, bearer); |
|
207 User::WaitForRequest(reqStatus); |
|
208 TEST(reqStatus.Int()==KErrNone); |
|
209 TEST(bearer==DMMTSY_SMS_MESSAGING_BEARER2); |
|
210 |
|
211 smsMessaging.NotifyMoSmsBearerChange(reqStatus, bearer); |
|
212 smsMessaging.CancelAsyncRequest(EMobileSmsMessagingNotifyMoSmsBearerChange); |
|
213 User::WaitForRequest(reqStatus); |
|
214 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
215 if (reqStatus.Int()==KErrCancel) |
|
216 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::NotifyMoSmsBearerChange (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
217 else |
|
218 { |
|
219 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::NotifyMoSmsBearerChange (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
220 } |
|
221 |
|
222 // test.Next(_L("OK: RMobileSmsMessaging's Get/Set SMS Bearer")); |
|
223 |
|
224 // Test SendMessage |
|
225 |
|
226 // asynchronous |
|
227 |
|
228 RMobileSmsMessaging::TMobileSmsSendAttributesV1 atts; |
|
229 RMobileSmsMessaging::TMobileSmsSendAttributesV1Pckg attsPckg(atts); |
|
230 |
|
231 atts.iFlags = DMMTSY_SMS_MESSAGE_FLAGS2; |
|
232 atts.iDataFormat = DMMTSY_SMS_MESSAGE_FORMAT1; |
|
233 atts.iDestination.iTelNumber=DMMTSY_PHONE_TEL_NUMBER; |
|
234 atts.iMore = DMMTSY_SMS_MESSAGE_MORE; |
|
235 |
|
236 TBuf8<32> pduBuf(DMMTSY_SMS_MESSAGE_PDU1); |
|
237 |
|
238 smsMessaging.SendMessage(reqStatus, pduBuf, attsPckg); |
|
239 User::WaitForRequest(reqStatus); |
|
240 TEST(reqStatus.Int()==KErrNone); |
|
241 TEST(atts.iMsgRef==DMMTSY_SMS_MESSAGE_MSGREF); |
|
242 TEST(atts.iSubmitReport==DMMTSY_SMS_MESSAGE_PDU2); |
|
243 |
|
244 // asynchronous & cancel |
|
245 |
|
246 smsMessaging.SendMessage(reqStatus, pduBuf, attsPckg); |
|
247 smsMessaging.CancelAsyncRequest(EMobileSmsMessagingSendMessage); |
|
248 User::WaitForRequest(reqStatus); |
|
249 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
250 if (reqStatus.Int()==KErrCancel) |
|
251 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::SendMessage (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
252 else |
|
253 { |
|
254 TEST(atts.iMsgRef==DMMTSY_SMS_MESSAGE_MSGREF); |
|
255 TEST(atts.iSubmitReport==DMMTSY_SMS_MESSAGE_PDU2); |
|
256 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::SendMessage (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
257 } |
|
258 |
|
259 // Test SendMessage - CDMA |
|
260 |
|
261 // asynchronous |
|
262 |
|
263 RMobileSmsMessaging::TMobileSmsCdmaSendAttributesV4 attsV4; |
|
264 RMobileSmsMessaging::TMobileSmsCdmaSendAttributesV4Pckg attsV4Pckg(attsV4); |
|
265 |
|
266 attsV4.iFlags = DMMTSY_SMS_MESSAGE_CDMA_FLAGS; |
|
267 attsV4.iDataFormat = DMMTSY_SMS_MESSAGE_CDMA_FORMAT; |
|
268 attsV4.iCdmaTeleservice = DMMTSY_SMS_MESSAGE_CDMA_TELESERVICE; |
|
269 attsV4.iCdmaServiceCategory = DMMTSY_SMS_MESSAGE_CDMA_SERVICE_CATEGORY; |
|
270 attsV4.iMore = DMMTSY_SMS_MESSAGE_MORE; |
|
271 attsV4.iDestination.iTypeOfNumber = DMMTSY_SMS_MESSAGE_TON; |
|
272 attsV4.iDestination.iNumberPlan = DMMTSY_SMS_MESSAGE_NP; |
|
273 attsV4.iDestination.iTelNumber = DMMTSY_PHONE_TEL_NUMBER; |
|
274 attsV4.iAddressAuthentication = DMMTSY_SMS_MESSAGE_ADDRESS_AUTHENTICATION; |
|
275 |
|
276 smsMessaging.SendMessage(reqStatus, pduBuf, attsV4Pckg); |
|
277 User::WaitForRequest(reqStatus); |
|
278 TEST(reqStatus.Int() == KErrNone); |
|
279 TEST(attsV4.iMsgRef == DMMTSY_SMS_MESSAGE_MSGREF); |
|
280 TEST(attsV4.iTLAck == DMMTSY_SMS_MESSAGE_TLACK); |
|
281 |
|
282 // test.Next(_L("OK: RMobileSmsMessaging's Send Message")); |
|
283 |
|
284 // Test SendMessageNoFdnCheck |
|
285 |
|
286 // asynchronous |
|
287 |
|
288 atts.iFlags = DMMTSY_SMS_MESSAGE_FLAGS2; |
|
289 atts.iDataFormat = DMMTSY_SMS_MESSAGE_FORMAT1; |
|
290 atts.iDestination.iTelNumber=DMMTSY_PHONE_TEL_NUMBER; |
|
291 atts.iMore = DMMTSY_SMS_MESSAGE_MORE; |
|
292 |
|
293 smsMessaging.SendMessageNoFdnCheck(reqStatus, pduBuf, attsPckg); |
|
294 User::WaitForRequest(reqStatus); |
|
295 TEST(reqStatus.Int()==KErrNone); |
|
296 TEST(atts.iMsgRef==DMMTSY_SMS_MESSAGE_MSGREF); |
|
297 TEST(atts.iSubmitReport==DMMTSY_SMS_MESSAGE_PDU2); |
|
298 |
|
299 // asynchronous & cancel |
|
300 |
|
301 smsMessaging.SendMessageNoFdnCheck(reqStatus, pduBuf, attsPckg); |
|
302 smsMessaging.CancelAsyncRequest(EMobileSmsMessagingSendMessageNoFdnCheck); |
|
303 User::WaitForRequest(reqStatus); |
|
304 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
305 if (reqStatus.Int()==KErrCancel) |
|
306 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::SendMessageNoFdnCheck (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
307 else |
|
308 { |
|
309 TEST(atts.iMsgRef==DMMTSY_SMS_MESSAGE_MSGREF); |
|
310 TEST(atts.iSubmitReport==DMMTSY_SMS_MESSAGE_PDU2); |
|
311 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::SendMessageNoFdnCheck (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
312 } |
|
313 |
|
314 // test.Next(_L("OK: RMobileSmsMessaging's Send Message with No Fdn Check")); |
|
315 |
|
316 // Test Enumerate Message Stores |
|
317 |
|
318 TInt count=0; |
|
319 TEST(smsMessaging.EnumerateMessageStores(count)==KErrNone); |
|
320 TEST(count==DMMTSY_PHONE_MESSAGE_STORE_COUNT); |
|
321 |
|
322 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::EnumerateMessageStores (sync) passed"), iTestCount++); |
|
323 |
|
324 // Get Message Store Info |
|
325 |
|
326 // asynchronous |
|
327 |
|
328 RMobilePhoneStore::TMobilePhoneStoreInfoV1 asyncInfo; |
|
329 RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg asyncInfoPckg(asyncInfo); |
|
330 smsMessaging.GetMessageStoreInfo(reqStatus, DMMTSY_SMS_STORE_INDEX1, asyncInfoPckg); |
|
331 User::WaitForRequest(reqStatus); |
|
332 TEST(reqStatus.Int()==KErrNone); |
|
333 ValidateGetSmsMessageStoreInfo(asyncInfo); |
|
334 |
|
335 // asynchronous & cancel |
|
336 |
|
337 smsMessaging.GetMessageStoreInfo(reqStatus, DMMTSY_SMS_STORE_INDEX1, asyncInfoPckg); |
|
338 smsMessaging.CancelAsyncRequest(EMobileSmsMessagingGetMessageStoreInfo); |
|
339 User::WaitForRequest(reqStatus); |
|
340 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
341 if (reqStatus.Int()==KErrCancel) |
|
342 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::GetMessageStoreInfo (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
343 else |
|
344 { |
|
345 ValidateGetSmsMessageStoreInfo(asyncInfo); |
|
346 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::GetMessageStoreInfo (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
347 } |
|
348 |
|
349 // test.Next(_L("OK: RMobileSmsMessaging's Get Message Store Info")); |
|
350 |
|
351 //Test deletion of list object whilst async request in progress |
|
352 CRetrieveMobilePhoneSmspList* retrieve=CRetrieveMobilePhoneSmspList::NewL(smsMessaging); |
|
353 retrieve->Start(reqStatus); |
|
354 delete retrieve; |
|
355 retrieve = NULL; |
|
356 User::WaitForRequest(reqStatus); |
|
357 TEST(reqStatus == KErrCancel); |
|
358 |
|
359 // Get SMSP list using asynchronous AO version |
|
360 |
|
361 CTestGetSmspList* getSmspList=CTestGetSmspList::NewLC(smsMessaging, this); |
|
362 getSmspList->Start(); |
|
363 CActiveScheduler::Start(); |
|
364 |
|
365 // Lets ensure that the same ao can be used to retrieve more than one list. |
|
366 |
|
367 getSmspList->Start(); |
|
368 CActiveScheduler::Start(); |
|
369 |
|
370 // I only need to delete the retrieval object because the destructor |
|
371 // of this will also delete the list object. |
|
372 CleanupStack::PopAndDestroy(); // getSmspList |
|
373 |
|
374 // Now test the cancelling |
|
375 |
|
376 getSmspList=CTestGetSmspList::NewLC(smsMessaging, this); |
|
377 getSmspList->Start(); |
|
378 |
|
379 CTestCanceller* cancelGetSmspList = getSmspList->RetrieveCancelPtr(); |
|
380 cancelGetSmspList->Call(); |
|
381 |
|
382 CActiveScheduler::Start(); |
|
383 |
|
384 TBool cancelled = (getSmspList->iStatus == KErrCancel); |
|
385 |
|
386 // Finally, lets just ensure that the object can be resused even after it has been cancelled |
|
387 |
|
388 getSmspList->Start(); |
|
389 CActiveScheduler::Start(); |
|
390 |
|
391 if (cancelled) |
|
392 INFO_PRINTF2(_L("Test %d - Test CRetrieveMobilePhoneSmspList (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
393 else |
|
394 INFO_PRINTF2(_L("Test %d - Test CRetrieveMobilePhoneSmspList (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
395 |
|
396 CleanupStack::PopAndDestroy(); // getSmspList |
|
397 |
|
398 // test.Next(_L("OK: RMobileSmsMessaging's Read SMSP List")); |
|
399 |
|
400 // Storing a new version of the list |
|
401 |
|
402 RMobileSmsMessaging::TMobileSmspEntryV1 storeEntry; |
|
403 |
|
404 CMobilePhoneSmspList* smspList = CMobilePhoneSmspList::NewL(); |
|
405 CleanupStack::PushL(smspList); |
|
406 |
|
407 InitSmspEntry(storeEntry); |
|
408 storeEntry.iIndex = DMMTSY_SMSP_STORE_INDEX1; |
|
409 |
|
410 smspList->AddEntryL(storeEntry); |
|
411 storeEntry.iIndex = DMMTSY_SMSP_STORE_INDEX2; |
|
412 smspList->AddEntryL(storeEntry); |
|
413 |
|
414 // asynchronous |
|
415 |
|
416 smsMessaging.StoreSmspListL(reqStatus, smspList); |
|
417 User::WaitForRequest(reqStatus); |
|
418 TEST(reqStatus.Int()==KErrNone); |
|
419 |
|
420 // aynchronous & cancel |
|
421 |
|
422 smsMessaging.StoreSmspListL(reqStatus, smspList); |
|
423 smsMessaging.CancelAsyncRequest(EMobileSmsMessagingStoreSmspList); |
|
424 User::WaitForRequest(reqStatus); |
|
425 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
426 cancelled = (reqStatus.Int()==KErrCancel); |
|
427 |
|
428 // Ensure that list can be stored after previous store attempt was cancelled. |
|
429 |
|
430 smsMessaging.StoreSmspListL(reqStatus, smspList); |
|
431 User::WaitForRequest(reqStatus); |
|
432 TEST(reqStatus.Int()==KErrNone); |
|
433 |
|
434 if (cancelled) |
|
435 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::StoreSmspListL (sync & async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
436 else |
|
437 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::StoreSmspListL (sync & async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
438 |
|
439 CleanupStack::PopAndDestroy(); // smspList |
|
440 |
|
441 // test.Next(_L("OK: RMobileSmsMessaging's Store SMSP List")); |
|
442 |
|
443 // Test NotifySmspListChange |
|
444 |
|
445 smsMessaging.NotifySmspListChange(reqStatus); |
|
446 User::WaitForRequest(reqStatus); |
|
447 TEST(reqStatus.Int()==KErrNone); |
|
448 |
|
449 // asynchronous & cancel |
|
450 |
|
451 smsMessaging.NotifySmspListChange(reqStatus); |
|
452 smsMessaging.CancelAsyncRequest(EMobileSmsMessagingNotifySmspListChange); |
|
453 User::WaitForRequest(reqStatus); |
|
454 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
455 if (reqStatus.Int()==KErrCancel) |
|
456 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::NotifySmspListChange (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
457 else |
|
458 INFO_PRINTF2(_L("Test %d - RMobileSmsMessaging::NotifySmspListChange (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
459 |
|
460 smsMessaging.Close(); |
|
461 mmPhone.Close(); |
|
462 INFO_PRINTF1(_L("")); |
|
463 |
|
464 return TestStepResult(); |
|
465 } |
|
466 |
|
467 void CTestSmsMessaging::ValidateReceivedSmsMessage(RMobileSmsMessaging::TMobileSmsGsmTpdu& aMsg, RMobileSmsMessaging::TMobileSmsReceiveAttributesV1& aAtt) |
|
468 { |
|
469 TEST(aMsg==DMMTSY_SMS_MESSAGE_PDU1); |
|
470 TEST(aAtt.iFlags==DMMTSY_SMS_MESSAGE_FLAGS1); |
|
471 TEST(aAtt.iGsmServiceCentre.iTelNumber.Compare(DMMTSY_SMS_MESSAGE_SC1)==0); |
|
472 TEST(aAtt.iDataFormat==DMMTSY_SMS_MESSAGE_FORMAT1); |
|
473 TEST(aAtt.iOriginator.iTelNumber.Compare(DMMTSY_SMS_MESSAGE_REMOTEPARTYNUMBER1)==0); |
|
474 TEST(aAtt.iStatus==DMMTSY_SMS_MESSAGE_STATUS1); |
|
475 TEST(aAtt.iStore.Compare(DMMTSY_MESSAGE_STORE_NAME)==0); |
|
476 TEST(aAtt.iStoreIndex==DMMTSY_SMS_STORE_INDEX1); |
|
477 } |
|
478 |
|
479 void CTestSmsMessaging::ValidateGetSmsMessageStoreInfo(const RMobilePhoneStore::TMobilePhoneStoreInfoV1 &aSyncInfo) |
|
480 { |
|
481 TEST(aSyncInfo.iName.Compare(DMMTSY_MESSAGE_STORE_NAME)==0); |
|
482 TEST(aSyncInfo.iType==DMMTSY_MESSAGE_STORE_TYPE); |
|
483 TEST(aSyncInfo.iTotalEntries==DMMTSY_MESSAGE_STORE_TOTAL_ENTRIES); |
|
484 TEST(aSyncInfo.iUsedEntries==DMMTSY_MESSAGE_STORE_USED_ENTRIES); |
|
485 TEST(aSyncInfo.iCaps==DMMTSY_MESSAGE_STORE_CAPS); |
|
486 } |
|
487 |
|
488 void CTestSmsMessaging::ValidateSmspEntry(const RMobileSmsMessaging::TMobileSmspEntryV1& aEntry) |
|
489 { |
|
490 TEST(aEntry.iText.Compare(DMMTSY_SMSP_STORE_TEXT1)==0); |
|
491 TEST(aEntry.iValidParams==DMMTSY_SMSP_STORE_VALID_PARAMS1); |
|
492 TEST(aEntry.iDestination.iTelNumber.Compare(DMMTSY_PHONE_TEL_NUMBER)==0); |
|
493 TEST(aEntry.iValidityPeriod==DMMTSY_SMSP_STORE_VALIDITY1); |
|
494 TEST(aEntry.iServiceCentre.iTelNumber.Compare(DMMTSY_SMSP_STORE_SCA)==0); |
|
495 TEST(aEntry.iProtocolId==DMMTSY_SMSP_STORE_PID1); |
|
496 TEST(aEntry.iDcs==DMMTSY_SMSP_STORE_DCS1); |
|
497 } |
|
498 |
|
499 void CTestSmsMessaging::InitSmspEntry(RMobileSmsMessaging::TMobileSmspEntryV1& aEntry) |
|
500 { |
|
501 aEntry.iText = DMMTSY_SMSP_STORE_TEXT1; |
|
502 aEntry.iValidParams = DMMTSY_SMSP_STORE_VALID_PARAMS1; |
|
503 aEntry.iDestination.iTelNumber = DMMTSY_PHONE_TEL_NUMBER; |
|
504 aEntry.iValidityPeriod = DMMTSY_SMSP_STORE_VALIDITY1; |
|
505 aEntry.iServiceCentre.iTelNumber = DMMTSY_SMSP_STORE_SCA; |
|
506 aEntry.iProtocolId = DMMTSY_SMSP_STORE_PID1; |
|
507 aEntry.iDcs = DMMTSY_SMSP_STORE_DCS1; |
|
508 } |
|
509 |
|
510 /**************************************************************/ |
|
511 // |
|
512 // Testing asynchronous retrieve of SMSP list |
|
513 // |
|
514 /**************************************************************/ |
|
515 |
|
516 CTestSmsMessaging::CTestGetSmspList* CTestSmsMessaging::CTestGetSmspList::NewLC(RMobileSmsMessaging& aMessaging, CTestSmsMessaging* aTestSmsMessaging) |
|
517 { |
|
518 CTestGetSmspList* r=new(ELeave) CTestGetSmspList(aMessaging, aTestSmsMessaging); |
|
519 CleanupStack::PushL(r); |
|
520 r->ConstructL(); |
|
521 return r; |
|
522 } |
|
523 |
|
524 CTestSmsMessaging::CTestGetSmspList::CTestGetSmspList(RMobileSmsMessaging& aMessaging, CTestSmsMessaging* aTestSmsMessaging) |
|
525 : CActive(EPriorityNormal), iMessaging(aMessaging), iTestSmsMessaging(aTestSmsMessaging) |
|
526 {} |
|
527 |
|
528 |
|
529 void CTestSmsMessaging::CTestGetSmspList::ConstructL() |
|
530 { |
|
531 CActiveScheduler::Add(this); |
|
532 iRetrieve=CRetrieveMobilePhoneSmspList::NewL(iMessaging); |
|
533 iCanceller=new (ELeave) CTestCanceller(this); |
|
534 } |
|
535 |
|
536 CTestSmsMessaging::CTestGetSmspList::~CTestGetSmspList() |
|
537 { |
|
538 delete iRetrieve; |
|
539 delete iCanceller; |
|
540 } |
|
541 |
|
542 void CTestSmsMessaging::CTestGetSmspList::Start() |
|
543 { |
|
544 iRetrieve->Start(iStatus); |
|
545 TRequestStatus tmpStatus; |
|
546 iRetrieve->Start(tmpStatus); |
|
547 User::WaitForRequest(tmpStatus); |
|
548 iTestSmsMessaging->TEST(tmpStatus.Int() == KErrInUse); |
|
549 SetActive(); |
|
550 } |
|
551 |
|
552 CTestCanceller* CTestSmsMessaging::CTestGetSmspList::RetrieveCancelPtr() |
|
553 { |
|
554 return iCanceller; |
|
555 } |
|
556 |
|
557 void CTestSmsMessaging::CTestGetSmspList::RunL() |
|
558 { |
|
559 TInt ret=iStatus.Int(); |
|
560 |
|
561 User::LeaveIfError(ret); |
|
562 ret=CheckResults(); |
|
563 User::LeaveIfError(ret); |
|
564 |
|
565 CActiveScheduler::Stop(); |
|
566 } |
|
567 |
|
568 void CTestSmsMessaging::CTestGetSmspList::DoCancel() |
|
569 { |
|
570 iRetrieve->Cancel(); |
|
571 } |
|
572 |
|
573 |
|
574 TInt CTestSmsMessaging::CTestGetSmspList::CheckResults() |
|
575 { |
|
576 TInt ret=KErrNone; |
|
577 |
|
578 CMobilePhoneSmspList* smspList=NULL; |
|
579 TInt leaveCode=KErrNone; |
|
580 TRAP(leaveCode, smspList=iRetrieve->RetrieveListL();); |
|
581 |
|
582 if (smspList) |
|
583 { |
|
584 iTestSmsMessaging->TEST(smspList->Enumerate()==DMMTSY_SMSP_STORE_COUNT); |
|
585 |
|
586 // Get each detected network entry |
|
587 RMobileSmsMessaging::TMobileSmspEntryV1 entry; |
|
588 |
|
589 for (TInt i=0; i<DMMTSY_SMSP_STORE_COUNT; ++i) |
|
590 { |
|
591 TRAP(ret,entry=smspList->GetEntryL(i)); |
|
592 if (ret != KErrNone) |
|
593 break; |
|
594 switch(i) |
|
595 { |
|
596 case 0: |
|
597 { |
|
598 iTestSmsMessaging->ValidateSmspEntry(entry); |
|
599 iTestSmsMessaging->TEST(entry.iIndex==DMMTSY_SMSP_STORE_INDEX1); |
|
600 break; |
|
601 } |
|
602 case 1: |
|
603 { |
|
604 iTestSmsMessaging->ValidateSmspEntry(entry); |
|
605 iTestSmsMessaging->TEST(entry.iIndex==DMMTSY_SMSP_STORE_INDEX2); |
|
606 break; |
|
607 } |
|
608 default: |
|
609 break; |
|
610 } |
|
611 } |
|
612 delete smspList; |
|
613 } |
|
614 |
|
615 return ret; |
|
616 } |
|
617 |