|
1 // Copyright (c) 1997-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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 */ |
|
19 |
|
20 #include <e32test.h> |
|
21 |
|
22 #include "TE_EtelMMTestStepBase.h" |
|
23 #include "TE_mmbroadcast.h" |
|
24 #include "testdef.h" |
|
25 |
|
26 CTestBroadcastMessaging::CTestBroadcastMessaging() |
|
27 /** Each test step initialises it's own name |
|
28 */ |
|
29 { |
|
30 // store the name of this test case |
|
31 // this is the name that is used by the script file |
|
32 SetTestStepName(_L("TestBrdcastMessaging")); |
|
33 } |
|
34 |
|
35 /** |
|
36 Test Broadcast Messaging Functions |
|
37 This test step tests performs the following tests: |
|
38 |
|
39 Test 1 - RMobileBroadcastMessaging::GetCaps (sync) |
|
40 Test 2 - RMobileBroadcastMessaging::ReceiveMessage (test asynchronous call, then test call and cancel request) |
|
41 Test 3 - RMobileBroadcastMessaging::ReceiveMessage using V2params (test asynchronous call, then test call and cancel request) |
|
42 Test 4 - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (buffer too big) (async call). Tests fix for INC072923. |
|
43 Test 5 - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (buffer too small) (async call). Tests fix for INC072923. |
|
44 Test 6 - RMobileBroadcastMessaging::GetFilterSetting (sync) |
|
45 Test 7 - RMobileBroadcastMessaging::NotifyFilterSettingChange (test asynchronous call, then test call and cancel request) |
|
46 Test 8 - RMobileBroadcastMessaging::SetFilterSetting (test asynchronous call, then test call and cancel request) |
|
47 Test 9 - RMobileBroadcastMessaging::GetLanguageFilter (test asynchronous call, then test call and cancel request) |
|
48 Test 10 - RMobileBroadcastMessaging::SetLanguageFilter (test asynchronous call, then test call and cancel request) |
|
49 Test 11 - RMobileBroadcastMessaging::NotifyLanguageFilterChange (test asynchronous call, then test call and cancel request) |
|
50 Test 12 - Test CRetrieveMobilePhoneBroadcastIdList (test asynchronous call, then test call and cancel request) |
|
51 Test 13 - Test StoreBroadcastIdListL (test asynchronous call, then test call and cancel request) |
|
52 Test 14 - RMobileBroadcastMessaging::NotifyBroadcastIdListChange (test asynchronous call, then test call and cancel request) |
|
53 |
|
54 @return The verdict of the test step. |
|
55 */ |
|
56 enum TVerdict CTestBroadcastMessaging::doTestStepL() |
|
57 // |
|
58 // Test Broadcast Messaging Functions |
|
59 // |
|
60 { |
|
61 iTestCount=1; |
|
62 INFO_PRINTF1(_L("")); |
|
63 INFO_PRINTF1(_L("Test Mobile Broadcast Messaging Functionality")); |
|
64 // LOGTEXT(_L8("Test Mobile Broadcast Messaging Functionality")); |
|
65 |
|
66 RMobilePhone mmPhone; |
|
67 TInt ret=mmPhone.Open(iTelServer,DMMTSY_PHONE_NAME); |
|
68 TEST(ret==KErrNone); |
|
69 |
|
70 RMobileBroadcastMessaging cbsMessaging; |
|
71 ret=cbsMessaging.Open(mmPhone); |
|
72 TEST(ret==KErrNone); |
|
73 |
|
74 TRequestStatus reqStatus; |
|
75 |
|
76 // Get Broadcast messaging caps |
|
77 RMobileBroadcastMessaging::TMobileBroadcastCapsV1 cbsCaps; |
|
78 RMobileBroadcastMessaging::TMobileBroadcastCapsV1Pckg cbsCapsPckg(cbsCaps); |
|
79 |
|
80 TEST(cbsMessaging.GetCaps(cbsCapsPckg)==KErrNone); |
|
81 |
|
82 TEST(cbsCaps.iModeCaps==DMMTSY_BROADCAST_MESSAGING_MODE_CAPS); |
|
83 TEST(cbsCaps.iFilterCaps==DMMTSY_BROADCAST_MESSAGING_FILTER_CAPS); |
|
84 |
|
85 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::GetCaps (sync) passed"), iTestCount++); |
|
86 // test.Next(_L("OK: RMobileBroadcastMessaging's Get Broadcast caps")); |
|
87 |
|
88 // Receiving broadcast messages |
|
89 |
|
90 RMobileBroadcastMessaging::TBroadcastPageData msgData; |
|
91 RMobileBroadcastMessaging::TMobileBroadcastAttributesV1 msgAtts; |
|
92 RMobileBroadcastMessaging::TMobileBroadcastAttributesV1Pckg msgAttsPckg(msgAtts); |
|
93 |
|
94 cbsMessaging.ReceiveMessage(reqStatus, msgData, msgAttsPckg); |
|
95 User::WaitForRequest(reqStatus); |
|
96 TEST(reqStatus.Int()==KErrNone); |
|
97 |
|
98 TEST(msgAtts.iFormat==DMMTSY_CBS_MESSAGE_PDU_FORMAT); |
|
99 TEST(msgAtts.iFlags==DMMTSY_BROADCAST_MESSAGING_ATT_FLAGS); |
|
100 TEST(msgData.Compare(DMMTSY_CBS_MESSAGE_PDU) == 0); |
|
101 |
|
102 // Test cancel |
|
103 |
|
104 cbsMessaging.ReceiveMessage(reqStatus, msgData, msgAttsPckg); |
|
105 cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingReceiveMessage); |
|
106 User::WaitForRequest(reqStatus); |
|
107 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
108 if (reqStatus.Int()==KErrCancel) |
|
109 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
110 else |
|
111 { |
|
112 TEST(msgAtts.iFormat==DMMTSY_CBS_MESSAGE_PDU_FORMAT); |
|
113 TEST(msgAtts.iFlags==DMMTSY_BROADCAST_MESSAGING_ATT_FLAGS); |
|
114 TEST(msgData.Compare(DMMTSY_CBS_MESSAGE_PDU) == 0); |
|
115 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
116 } |
|
117 |
|
118 // test.Next(_L("OK: RMobileBroadcastMessaging's Receive Message")); |
|
119 |
|
120 // Receiving broadcast messages V2 |
|
121 |
|
122 RMobileBroadcastMessaging::TBroadcastPageData msgPage; |
|
123 RMobileBroadcastMessaging::TMobileBroadcastAttributesV2 msgAttsV2; |
|
124 RMobileBroadcastMessaging::TMobileBroadcastAttributesV2Pckg msgAttsV2Pckg(msgAttsV2); |
|
125 |
|
126 cbsMessaging.ReceiveMessage(reqStatus, msgPage, msgAttsV2Pckg); |
|
127 User::WaitForRequest(reqStatus); |
|
128 TEST(reqStatus.Int()==KErrNone); |
|
129 |
|
130 TEST(msgAttsV2.iFormat==DMMTSY_CBS_MESSAGE_PDU_FORMAT); |
|
131 TEST(msgAttsV2.iFlags==DMMTSY_BROADCAST_MESSAGING_ATT_FLAGS); |
|
132 TEST(msgPage.Compare(DMMTSY_CBS_MESSAGE_PDU) == 0); |
|
133 |
|
134 // Test cancel |
|
135 |
|
136 cbsMessaging.ReceiveMessage(reqStatus, msgPage, msgAttsV2Pckg); |
|
137 cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingReceiveMessage); |
|
138 User::WaitForRequest(reqStatus); |
|
139 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
140 if (reqStatus.Int()==KErrCancel) |
|
141 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage V2params (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
142 else |
|
143 { |
|
144 TEST(msgAttsV2.iFormat==DMMTSY_CBS_MESSAGE_PDU_FORMAT); |
|
145 TEST(msgAttsV2.iFlags==DMMTSY_BROADCAST_MESSAGING_ATT_FLAGS); |
|
146 TEST(msgPage.Compare(DMMTSY_CBS_MESSAGE_PDU) == 0); |
|
147 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage V2params (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
148 } |
|
149 // Receiving broadcast messages when buffer size incorrect |
|
150 |
|
151 // Test if client uses buffer of size not equal to |
|
152 // RMobileBroadcastMessaging::TBroadcastPageData to hold the |
|
153 // received message |
|
154 const TInt KIncorrectBroadcastPageSizeTooBig = 255; |
|
155 TBuf8<KIncorrectBroadcastPageSizeTooBig> incorrectMsgPageTooBig; |
|
156 RMobileBroadcastMessaging::TMobileBroadcastAttributesV1 msgAttributesV1; |
|
157 RMobileBroadcastMessaging::TMobileBroadcastAttributesV1Pckg msgAttributesV1Pckg(msgAttributesV1); |
|
158 |
|
159 cbsMessaging.ReceiveMessage(reqStatus, incorrectMsgPageTooBig, msgAttributesV1Pckg); |
|
160 User::WaitForRequest(reqStatus); |
|
161 // RMobileBroadcastMessaging::ReceiveMessage should detect |
|
162 // incorrect buffer size and return KErrArgument |
|
163 TEST(reqStatus.Int()==KErrArgument); |
|
164 if (reqStatus.Int()==KErrArgument) |
|
165 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (too big) passed"), iTestCount++); |
|
166 else |
|
167 { |
|
168 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (too big) failed"), iTestCount++); |
|
169 INFO_PRINTF3(_L("reqStatus = %d, expected reqStatus = %d"), reqStatus.Int(), KErrArgument); |
|
170 } |
|
171 |
|
172 const TInt KIncorrectBroadcastPageSizeTooSmall = 35; |
|
173 TBuf8<KIncorrectBroadcastPageSizeTooSmall> incorrectMsgPageTooSmall; |
|
174 cbsMessaging.ReceiveMessage(reqStatus, incorrectMsgPageTooSmall, msgAttributesV1Pckg); |
|
175 User::WaitForRequest(reqStatus); |
|
176 // RMobileBroadcastMessaging::ReceiveMessage should detect |
|
177 // incorrect buffer size and return KErrArgument |
|
178 TEST(reqStatus.Int()==KErrArgument); |
|
179 if (reqStatus.Int()==KErrArgument) |
|
180 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (too small) passed"), iTestCount++); |
|
181 else |
|
182 { |
|
183 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (too small) failed"), iTestCount++); |
|
184 INFO_PRINTF3(_L("reqStatus = %d, expected reqStatus = %d"), reqStatus.Int(), KErrArgument); |
|
185 } |
|
186 // Get/Set/Notify broadcast receive setting |
|
187 |
|
188 RMobileBroadcastMessaging::TMobilePhoneBroadcastFilter setting; |
|
189 |
|
190 TEST(cbsMessaging.GetFilterSetting(setting)==KErrNone); |
|
191 TEST(setting==DMMTSY_BROADCAST_RECEIVE_SETTING1); |
|
192 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::GetFilterSetting (sync) passed"), iTestCount++); |
|
193 |
|
194 // NotifyFilterSettingChange |
|
195 |
|
196 // Asynchronous |
|
197 |
|
198 cbsMessaging.NotifyFilterSettingChange(reqStatus, setting); |
|
199 User::WaitForRequest(reqStatus); |
|
200 TEST(reqStatus.Int()==KErrNone); |
|
201 TEST(setting==DMMTSY_BROADCAST_RECEIVE_SETTING2); |
|
202 |
|
203 // Asynchronous & cancel |
|
204 |
|
205 cbsMessaging.NotifyFilterSettingChange(reqStatus, setting); |
|
206 cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingNotifyFilterSettingChange); |
|
207 |
|
208 User::WaitForRequest(reqStatus); |
|
209 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
210 if (reqStatus.Int()==KErrCancel) |
|
211 { |
|
212 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyFilterSettingChange (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
213 |
|
214 // The cancel function currently alters the value of setting. This occurs because the Tsy |
|
215 // calls completeReq when cancelling requests. This need to verified to determine whether this |
|
216 // behaviour is correct. So the rest of the script can proceed, reset setting. |
|
217 |
|
218 setting=DMMTSY_BROADCAST_RECEIVE_SETTING2; |
|
219 } |
|
220 else |
|
221 { |
|
222 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyFilterSettingChange (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
223 TEST(setting==DMMTSY_BROADCAST_RECEIVE_SETTING2); |
|
224 } |
|
225 |
|
226 // set filter setting - async |
|
227 cbsMessaging.SetFilterSetting(reqStatus, setting); |
|
228 User::WaitForRequest(reqStatus); |
|
229 TEST(reqStatus.Int()==KErrNone); |
|
230 |
|
231 // asynchronous & cancel |
|
232 |
|
233 cbsMessaging.SetFilterSetting(reqStatus, setting); |
|
234 cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingSetFilterSetting); |
|
235 User::WaitForRequest(reqStatus); |
|
236 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
237 if (reqStatus.Int()==KErrCancel) |
|
238 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::SetFilterSetting (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
239 else |
|
240 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::SetFilterSetting (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
241 |
|
242 |
|
243 // test.Next(_L("OK: RMobileBroadcastMessaging's Broadcast receive setting")); |
|
244 |
|
245 TBuf16<16> setLangFilter(DMMTSY_CBS_MESSAGE_LANGUAGE_FILTER); |
|
246 TBuf16<16> getLangFilter; |
|
247 |
|
248 // Test Get Language Filter |
|
249 |
|
250 // asynchronous |
|
251 |
|
252 cbsMessaging.GetLanguageFilter(reqStatus,getLangFilter); |
|
253 User::WaitForRequest(reqStatus); |
|
254 TEST(reqStatus.Int()==KErrNone); |
|
255 TEST(getLangFilter.Compare(DMMTSY_CBS_MESSAGE_LANGUAGE_FILTER) == 0); |
|
256 |
|
257 // asynchronous & cancel |
|
258 |
|
259 cbsMessaging.GetLanguageFilter(reqStatus,getLangFilter); |
|
260 cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingGetLanguageFilter); |
|
261 User::WaitForRequest(reqStatus); |
|
262 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
263 if (reqStatus.Int()==KErrCancel) |
|
264 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::GetLanguageFilter (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
265 else |
|
266 { |
|
267 TEST(getLangFilter.Compare(DMMTSY_CBS_MESSAGE_LANGUAGE_FILTER) == 0); |
|
268 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::GetLanguageFilter (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
269 } |
|
270 |
|
271 // Test Set Language Filter |
|
272 |
|
273 // asynchronous |
|
274 |
|
275 cbsMessaging.SetLanguageFilter(reqStatus,setLangFilter); |
|
276 User::WaitForRequest(reqStatus); |
|
277 TEST(reqStatus.Int()==KErrNone); |
|
278 |
|
279 // asynchronous & cancel |
|
280 |
|
281 cbsMessaging.SetLanguageFilter(reqStatus,setLangFilter); |
|
282 cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingSetLanguageFilter); |
|
283 User::WaitForRequest(reqStatus); |
|
284 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
285 if (reqStatus.Int()==KErrCancel) |
|
286 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::SetLanguageFilter (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
287 else |
|
288 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::SetLanguageFilter (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
289 |
|
290 // Test Notify Language Filter Change |
|
291 |
|
292 // asynchronous |
|
293 |
|
294 cbsMessaging.NotifyLanguageFilterChange(reqStatus,getLangFilter); |
|
295 User::WaitForRequest(reqStatus); |
|
296 TEST(reqStatus.Int()==KErrNone); |
|
297 TEST(getLangFilter.Compare(DMMTSY_CBS_MESSAGE_LANGUAGE_FILTER) == 0); |
|
298 |
|
299 // asynchronous & cancel |
|
300 |
|
301 cbsMessaging.NotifyLanguageFilterChange(reqStatus,getLangFilter); |
|
302 cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingNotifyLanguageFilterChange); |
|
303 User::WaitForRequest(reqStatus); |
|
304 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
305 if (reqStatus.Int()==KErrCancel) |
|
306 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyLanguageFilterChange (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
307 else |
|
308 { |
|
309 TEST(getLangFilter.Compare(DMMTSY_CBS_MESSAGE_LANGUAGE_FILTER) == 0); |
|
310 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyLanguageFilterChange (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
311 } |
|
312 |
|
313 //Test deletion of list object whilst async request in progress |
|
314 CRetrieveMobilePhoneBroadcastIdList* retrieve=CRetrieveMobilePhoneBroadcastIdList::NewL(cbsMessaging); |
|
315 retrieve->Start(reqStatus,DMMTSY_BROADCAST_ID_TYPE); |
|
316 delete retrieve; |
|
317 retrieve = NULL; |
|
318 User::WaitForRequest(reqStatus); |
|
319 TEST(reqStatus == KErrCancel); |
|
320 |
|
321 // Get CBMI list using asynchronous AO version |
|
322 |
|
323 CTestGetCbmiList* getCbmiList=CTestGetCbmiList::NewLC(cbsMessaging, this); |
|
324 getCbmiList->Start(); |
|
325 CActiveScheduler::Start(); |
|
326 |
|
327 // Lets ensure that the same ao can be used to retrieve more than one list. |
|
328 |
|
329 getCbmiList->Start(); |
|
330 CActiveScheduler::Start(); |
|
331 |
|
332 // I only need to delete the retrieval object because the destructor |
|
333 // of this will also delete the list object. |
|
334 CleanupStack::PopAndDestroy(); // getCbmiList |
|
335 |
|
336 // Now test the cancelling |
|
337 |
|
338 getCbmiList=CTestGetCbmiList::NewLC(cbsMessaging, this); |
|
339 getCbmiList->Start(); |
|
340 |
|
341 CTestCanceller* cancelGetCbmiList = getCbmiList->RetrieveCancelPtr(); |
|
342 cancelGetCbmiList->Call(); |
|
343 |
|
344 CActiveScheduler::Start(); |
|
345 |
|
346 TBool cancelled = (getCbmiList->iStatus == KErrCancel); |
|
347 |
|
348 // Finally, lets just ensure that the object can be resused even after it has been cancelled |
|
349 |
|
350 getCbmiList->Start(); |
|
351 CActiveScheduler::Start(); |
|
352 |
|
353 if (cancelled) |
|
354 INFO_PRINTF2(_L("Test %d - Test CRetrieveMobilePhoneBroadcastIdList (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
355 else |
|
356 INFO_PRINTF2(_L("Test %d - Test CRetrieveMobilePhoneBroadcastIdList (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
357 |
|
358 CleanupStack::PopAndDestroy(); // getCbmiList |
|
359 |
|
360 // test.Next(_L("OK: RMobileCbmiStore's Read All Entries")); |
|
361 |
|
362 |
|
363 // Test StoreCbmiList |
|
364 |
|
365 CTestStoreCbmiList *storeList = CTestStoreCbmiList::NewLC(cbsMessaging, this); |
|
366 |
|
367 storeList->StartL(); |
|
368 CActiveScheduler::Start(); |
|
369 |
|
370 // Lets just perform the operation twice to make sure etelmm handles the cleanup of all |
|
371 // internal buffers correctly. |
|
372 |
|
373 storeList->StartL(); |
|
374 CActiveScheduler::Start(); |
|
375 |
|
376 CleanupStack::PopAndDestroy(); |
|
377 |
|
378 // Test Cancel |
|
379 |
|
380 storeList = CTestStoreCbmiList::NewLC(cbsMessaging, this); |
|
381 |
|
382 storeList->StartL(); |
|
383 storeList->RetrieveCancelPtr()->Call(); |
|
384 CActiveScheduler::Start(); |
|
385 |
|
386 if (storeList->iStatus == KErrCancel) |
|
387 INFO_PRINTF2(_L("Test %d - Test StoreBroadcastIdListL (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
388 else |
|
389 INFO_PRINTF2(_L("Test %d - Test StoreBroadcastIdListL (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
390 |
|
391 CleanupStack::PopAndDestroy(); |
|
392 |
|
393 // Test NotifyCbmi List Change |
|
394 |
|
395 cbsMessaging.NotifyBroadcastIdListChange(reqStatus); |
|
396 User::WaitForRequest(reqStatus); |
|
397 TEST(reqStatus.Int()==KErrNone); |
|
398 |
|
399 // asynchronous & cancel |
|
400 |
|
401 cbsMessaging.NotifyBroadcastIdListChange(reqStatus); |
|
402 cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingNotifyIdListChange); |
|
403 User::WaitForRequest(reqStatus); |
|
404 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
405 if (reqStatus.Int()==KErrCancel) |
|
406 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyBroadcastIdListChange (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
407 else |
|
408 INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyBroadcastIdListChange (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
409 |
|
410 // test.Next(_L("OK: RMobileBroadcastMessaging Ok")); |
|
411 |
|
412 INFO_PRINTF1(_L("")); |
|
413 cbsMessaging.Close(); |
|
414 mmPhone.Close(); |
|
415 |
|
416 return TestStepResult(); |
|
417 } |
|
418 |
|
419 /**************************************************************/ |
|
420 // |
|
421 // Testing asynchronous retrieve of CBMI list |
|
422 // |
|
423 /**************************************************************/ |
|
424 |
|
425 CTestBroadcastMessaging::CTestGetCbmiList* CTestBroadcastMessaging::CTestGetCbmiList::NewLC(RMobileBroadcastMessaging& aMessaging, CTestBroadcastMessaging* aTestBroadcastMessaging) |
|
426 { |
|
427 CTestGetCbmiList* r=new(ELeave) CTestGetCbmiList(aMessaging, aTestBroadcastMessaging); |
|
428 CleanupStack::PushL(r); |
|
429 r->ConstructL(); |
|
430 return r; |
|
431 } |
|
432 |
|
433 CTestBroadcastMessaging::CTestGetCbmiList::CTestGetCbmiList(RMobileBroadcastMessaging& aMessaging, CTestBroadcastMessaging* aTestBroadcastMessaging) |
|
434 : CActive(EPriorityNormal), iMessaging(aMessaging), iTestBroadcastMessaging(aTestBroadcastMessaging) |
|
435 { |
|
436 iIdType=DMMTSY_BROADCAST_ID_TYPE; |
|
437 } |
|
438 |
|
439 |
|
440 void CTestBroadcastMessaging::CTestGetCbmiList::ConstructL() |
|
441 { |
|
442 CActiveScheduler::Add(this); |
|
443 iRetrieve=CRetrieveMobilePhoneBroadcastIdList::NewL(iMessaging); |
|
444 iCanceller=new (ELeave) CTestCanceller(this); |
|
445 } |
|
446 |
|
447 CTestBroadcastMessaging::CTestGetCbmiList::~CTestGetCbmiList() |
|
448 { |
|
449 Cancel(); |
|
450 delete iRetrieve; |
|
451 delete iCanceller; |
|
452 } |
|
453 |
|
454 void CTestBroadcastMessaging::CTestGetCbmiList::Start() |
|
455 { |
|
456 iRetrieve->Start(iStatus,iIdType); |
|
457 TRequestStatus tmpStatus; |
|
458 iRetrieve->Start(tmpStatus,iIdType); |
|
459 User::WaitForRequest(tmpStatus); |
|
460 iTestBroadcastMessaging->TEST(tmpStatus.Int() == KErrInUse); |
|
461 SetActive(); |
|
462 } |
|
463 |
|
464 CTestCanceller* CTestBroadcastMessaging::CTestGetCbmiList::RetrieveCancelPtr() |
|
465 { |
|
466 return iCanceller; |
|
467 } |
|
468 |
|
469 void CTestBroadcastMessaging::CTestGetCbmiList::RunL() |
|
470 { |
|
471 TInt ret=iStatus.Int(); |
|
472 TInt count=iTestBroadcastMessaging->iTestCount; |
|
473 |
|
474 if (!ret) |
|
475 ret=CheckResults(); |
|
476 |
|
477 if(ret!=KErrNone) |
|
478 { |
|
479 if(!(((count)>=KOOMTestNumberStart)&&(ret==KErrNoMemory))) |
|
480 iTestBroadcastMessaging->INFO_PRINTF3(_L("Test %d - TTestBroadcastMessaging::CTestGetCbmiList failed with error %d"), count++, ret); |
|
481 } |
|
482 |
|
483 CActiveScheduler::Stop(); |
|
484 } |
|
485 |
|
486 void CTestBroadcastMessaging::CTestGetCbmiList::DoCancel() |
|
487 { |
|
488 iRetrieve->Cancel(); |
|
489 } |
|
490 |
|
491 |
|
492 TInt CTestBroadcastMessaging::CTestGetCbmiList::CheckResults() |
|
493 { |
|
494 TInt ret=KErrNone; |
|
495 CMobilePhoneBroadcastIdList* cbmiList=NULL; |
|
496 |
|
497 TInt leaveCode=KErrNone; |
|
498 TRAP(leaveCode, cbmiList=iRetrieve->RetrieveListL();); |
|
499 |
|
500 if (cbmiList) |
|
501 { |
|
502 iTestBroadcastMessaging->TEST(cbmiList->Enumerate()==DMMTSY_CBMI_STORE_COUNT); |
|
503 |
|
504 // Get each detected network entry |
|
505 RMobileBroadcastMessaging::TMobileBroadcastIdEntryV1 entry; |
|
506 |
|
507 for (TInt i=0; i<DMMTSY_CBMI_STORE_COUNT; ++i) |
|
508 { |
|
509 TRAP(ret,entry=cbmiList->GetEntryL(i)); |
|
510 if (ret != KErrNone) |
|
511 break; |
|
512 switch(i) |
|
513 { |
|
514 case 0: |
|
515 { |
|
516 iTestBroadcastMessaging->TEST(entry.iId==DMMTSY_CBMI_ID1); |
|
517 break; |
|
518 } |
|
519 case 1: |
|
520 { |
|
521 iTestBroadcastMessaging->TEST(entry.iId==DMMTSY_CBMI_ID2); |
|
522 break; |
|
523 } |
|
524 case 2: |
|
525 { |
|
526 iTestBroadcastMessaging->TEST(entry.iId==DMMTSY_CBMI_ID3); |
|
527 break; |
|
528 } |
|
529 default: |
|
530 break; |
|
531 } |
|
532 } |
|
533 // now free-up cbmiList |
|
534 delete cbmiList; |
|
535 } |
|
536 |
|
537 return ret; |
|
538 } |
|
539 |
|
540 /**************************************************************/ |
|
541 // |
|
542 // Testing RMobileBroadcastMessaging::StoreCbmiList |
|
543 // |
|
544 /**************************************************************/ |
|
545 |
|
546 CTestBroadcastMessaging::CTestStoreCbmiList* CTestBroadcastMessaging::CTestStoreCbmiList::NewLC(RMobileBroadcastMessaging& aMessaging, CTestBroadcastMessaging* aTestBroadcastMessaging) |
|
547 { |
|
548 CTestStoreCbmiList* r=new(ELeave) CTestStoreCbmiList(aMessaging, aTestBroadcastMessaging); |
|
549 CleanupStack::PushL(r); |
|
550 r->ConstructL(); |
|
551 return r; |
|
552 } |
|
553 |
|
554 CTestBroadcastMessaging::CTestStoreCbmiList::CTestStoreCbmiList(RMobileBroadcastMessaging& aMessaging, CTestBroadcastMessaging* aTestBroadcastMessaging) |
|
555 : CActive(EPriorityNormal), iMessaging(aMessaging ), iTestBroadcastMessaging(aTestBroadcastMessaging) |
|
556 { |
|
557 iIdType=DMMTSY_BROADCAST_ID_TYPE; |
|
558 } |
|
559 |
|
560 void CTestBroadcastMessaging::CTestStoreCbmiList::ConstructL() |
|
561 { |
|
562 CActiveScheduler::Add(this); |
|
563 iCanceller=new (ELeave) CTestCanceller(this); |
|
564 } |
|
565 |
|
566 CTestBroadcastMessaging::CTestStoreCbmiList::~CTestStoreCbmiList() |
|
567 { |
|
568 delete iCanceller; |
|
569 delete iList; |
|
570 } |
|
571 |
|
572 void CTestBroadcastMessaging::CTestStoreCbmiList::StartL() |
|
573 { |
|
574 TInt i; |
|
575 RMobileBroadcastMessaging::TMobileBroadcastIdEntryV1 entry; |
|
576 |
|
577 delete iList; |
|
578 iList = CMobilePhoneBroadcastIdList::NewL(); |
|
579 |
|
580 for (i = 0; i < DMMTSY_CBMI_STORE_COUNT; i++) |
|
581 { |
|
582 entry.iId = DMMTSY_CBMI_ID1; |
|
583 iList->AddEntryL(entry); |
|
584 } |
|
585 iMessaging.StoreBroadcastIdListL(iStatus,iList,iIdType); |
|
586 SetActive(); |
|
587 } |
|
588 |
|
589 CTestCanceller* CTestBroadcastMessaging::CTestStoreCbmiList::RetrieveCancelPtr() |
|
590 { |
|
591 return iCanceller; |
|
592 } |
|
593 |
|
594 void CTestBroadcastMessaging::CTestStoreCbmiList::RunL() |
|
595 { |
|
596 if (iStatus!=KErrNone) |
|
597 { |
|
598 iTestBroadcastMessaging->INFO_PRINTF3(_L("Test %d - TTestBroadcastMessaging::CTestStoreCbmiList failed with error %d"), iTestBroadcastMessaging->iTestCount++, iStatus.Int()); |
|
599 } |
|
600 |
|
601 CActiveScheduler::Stop(); |
|
602 } |
|
603 |
|
604 |
|
605 void CTestBroadcastMessaging::CTestStoreCbmiList::DoCancel() |
|
606 { |
|
607 iMessaging.CancelAsyncRequest(EMobileBroadcastMessagingStoreIdList); |
|
608 } |