|
1 /* |
|
2 * Copyright (c) 2006 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: XIMP Framework Test Code |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "eunittools.h" |
|
20 |
|
21 #include <eunitmacros.h> |
|
22 #include <ecom/ecom.h> |
|
23 #include <badesca.h> |
|
24 |
|
25 |
|
26 #include <presencefeatures.h> |
|
27 #include <presenceauthorization.h> |
|
28 #include <presenceblocklistevent.h> |
|
29 #include <presenceblockinfo.h> |
|
30 |
|
31 |
|
32 #include <ximpclient.h> |
|
33 #include <ximpcontext.h> |
|
34 #include <presencefeatures.h> |
|
35 |
|
36 #include "t_presenceblocking.h" |
|
37 |
|
38 // blocking includes |
|
39 #include "presenceblockinfoimp.h" |
|
40 #include "presenceblocklisteventimp.h" |
|
41 |
|
42 // other datamodel and utils includes |
|
43 #include "ximpidentityimp.h" |
|
44 #include "ximpobjecthelpers.h" |
|
45 |
|
46 |
|
47 // testing tool includes |
|
48 #include "prfwtestpresencedatautils.h" |
|
49 |
|
50 #include "prfwtestmessaging.h" |
|
51 #include "prfwtestmessenger.h" |
|
52 #include "prfwtestcontextwrappermgr.h" |
|
53 #include "prfwtestcontextwrapper.h" |
|
54 |
|
55 |
|
56 #include "prfwtestfilesrvmsg.h" |
|
57 #include "prfwtestfiletool.h" |
|
58 #include "prfwtestlistener.h" |
|
59 #include "ximprequestcompleteeventimp.h" |
|
60 |
|
61 #include "prfwtestrobustnesstools.h" |
|
62 |
|
63 |
|
64 // ============================ MEMBER FUNCTIONS =============================== |
|
65 |
|
66 // CONSTRUCTION |
|
67 T_PresenceBlocking* T_PresenceBlocking::NewL() |
|
68 { |
|
69 T_PresenceBlocking* self = new( ELeave ) T_PresenceBlocking; |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL(); |
|
72 CleanupStack::Pop( self ); |
|
73 |
|
74 return self; |
|
75 } |
|
76 |
|
77 |
|
78 T_PresenceBlocking::~T_PresenceBlocking() |
|
79 { |
|
80 PrfwTestRobustness::DoPreCleaning(); |
|
81 } |
|
82 |
|
83 |
|
84 void T_PresenceBlocking::ConstructL() |
|
85 { |
|
86 CEUnitTestSuiteClass::ConstructL(); |
|
87 } |
|
88 |
|
89 |
|
90 T_PresenceBlocking::T_PresenceBlocking() |
|
91 { |
|
92 } |
|
93 |
|
94 |
|
95 |
|
96 // =========================================================================== |
|
97 // TEST CASE SETUP & TEARDOWN METHODS |
|
98 // =========================================================================== |
|
99 // |
|
100 |
|
101 void T_PresenceBlocking::Setup_L() |
|
102 { |
|
103 PrfwTestRobustness::DoPreCleaning(); |
|
104 |
|
105 iWrapperMgr = CXIMPTestContextWrapperMgr::NewL(); |
|
106 iWrapperMgr->CreateWrapperL(); |
|
107 } |
|
108 |
|
109 void T_PresenceBlocking::SetupMultiple_L() |
|
110 { |
|
111 PrfwTestRobustness::DoPreCleaning(); |
|
112 |
|
113 iWrapperMgr = CXIMPTestContextWrapperMgr::NewL(); |
|
114 iWrapperMgr->CreateWrapperL(); |
|
115 iWrapperMgr->CreateWrapperL(); |
|
116 iWrapperMgr->CreateWrapperL(); |
|
117 } |
|
118 |
|
119 |
|
120 void T_PresenceBlocking::BindL() |
|
121 { |
|
122 CXIMPTestContextWrapper* wrapper0 = iWrapperMgr->GetWrapperL( 0 ); |
|
123 |
|
124 wrapper0->BindL( 0 ); |
|
125 } |
|
126 |
|
127 void T_PresenceBlocking::BindAllL() |
|
128 { |
|
129 for( TInt a = 0; a < iWrapperMgr->WrapperCount(); ++a ) |
|
130 { |
|
131 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( a ); |
|
132 wrapper->BindL( 0 ); |
|
133 } |
|
134 } |
|
135 |
|
136 |
|
137 void T_PresenceBlocking::Teardown() |
|
138 { |
|
139 delete iWrapperMgr; |
|
140 iWrapperMgr = NULL; |
|
141 |
|
142 REComSession::FinalClose(); |
|
143 |
|
144 PrfwTestRobustness::DoPreCleaning(); |
|
145 } |
|
146 |
|
147 void T_PresenceBlocking::UnbindL() |
|
148 { |
|
149 // Do unbind |
|
150 CXIMPTestContextWrapper* wrapper0 = iWrapperMgr->GetWrapperL( 0 ); |
|
151 wrapper0->UnbindL(); |
|
152 } |
|
153 |
|
154 void T_PresenceBlocking::UnbindAllL() |
|
155 { |
|
156 for( TInt a = 0; a < iWrapperMgr->WrapperCount(); ++a ) |
|
157 { |
|
158 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( a ); |
|
159 wrapper->UnbindL(); |
|
160 } |
|
161 } |
|
162 |
|
163 |
|
164 // =========================================================================== |
|
165 // TEST CASES for presentity presence subscription |
|
166 // =========================================================================== |
|
167 |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // --------------------------------------------------------------------------- |
|
171 // Single client, empty filter |
|
172 void T_PresenceBlocking::T_SubscribeBlockList_Single_L() |
|
173 { |
|
174 EUNIT_PRINT( _L("Single presence block list subscription") ); |
|
175 |
|
176 BindL(); |
|
177 |
|
178 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
179 MXIMPContext* context = wrapper->GetContext(); |
|
180 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
181 |
|
182 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
183 CleanupStack::PushL( listener2 ); |
|
184 |
|
185 // Tell the protocol it should act normally |
|
186 messenger->SetNoError(); |
|
187 |
|
188 // Get the interfaces |
|
189 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
190 |
|
191 MPresenceAuthorization& presAuth = presFeat->PresenceAuthorization(); |
|
192 |
|
193 // Setup status event listener for RequestComplete |
|
194 // --------------------------------------------- |
|
195 listener2->Reset(); |
|
196 |
|
197 // normal request complete |
|
198 TXIMPRequestId reqIdDummy; // not checked |
|
199 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
200 listener2->ExpectL( evReqComplete ); |
|
201 CleanupStack::Pop( evReqComplete ); |
|
202 // --------------------------------------------- |
|
203 |
|
204 // subscribe |
|
205 // --------------------------------------------- |
|
206 TXIMPRequestId reqId = presAuth.SubscribePresenceBlockListL(); |
|
207 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" ); |
|
208 // --------------------------------------------- |
|
209 |
|
210 // verify that SubscribeBlockListL was called |
|
211 COMMONASSERT( messenger, EXIMPPlgTestSubscribePresenceBlockListCalled, "SubscribeBlockListL was not called", ETrue, NULL ); |
|
212 |
|
213 // Setup status event listener for RequestComplete |
|
214 // --------------------------------------------- |
|
215 listener2->Reset(); |
|
216 |
|
217 evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
218 listener2->ExpectL( evReqComplete ); |
|
219 CleanupStack::Pop( evReqComplete ); |
|
220 // --------------------------------------------- |
|
221 |
|
222 // unsubscribe |
|
223 // --------------------------------------------- |
|
224 reqId = presAuth.UnsubscribePresenceBlockListL(); |
|
225 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe failed" ); |
|
226 // --------------------------------------------- |
|
227 |
|
228 // verify that UnsubscribeBlockListL was called |
|
229 COMMONASSERT( messenger, EXIMPPlgTestUnsubscribePresenceBlockListCalled, "UnsubscribeBlockListL was not called", ETrue, NULL ); |
|
230 |
|
231 // Deinitiliaze event source from listener. |
|
232 listener2->SetEventSourceL( NULL ); |
|
233 |
|
234 UnbindL(); |
|
235 |
|
236 //CleanupStack::Pop(presFeat); |
|
237 //delete presFeat; |
|
238 //CleanupStack::PopAndDestroy(); |
|
239 CleanupStack::PopAndDestroy( listener2 ); |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // --------------------------------------------------------------------------- |
|
244 // Single client, empty filter |
|
245 void T_PresenceBlocking::T_SubscribeBlockListRefresh_Single_L() |
|
246 { |
|
247 EUNIT_PRINT( _L("Single presence block list subscription refresh") ); |
|
248 |
|
249 BindL(); |
|
250 |
|
251 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
252 MXIMPContext* context = wrapper->GetContext(); |
|
253 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
254 |
|
255 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
256 CleanupStack::PushL( listener2 ); |
|
257 |
|
258 // Tell the protocol it should act normally |
|
259 messenger->SetNoError(); |
|
260 |
|
261 // Get the interfaces |
|
262 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
263 MPresenceAuthorization& presAuth = presFeat->PresenceAuthorization(); |
|
264 |
|
265 // Setup status event listener for RequestComplete |
|
266 // --------------------------------------------- |
|
267 listener2->Reset(); |
|
268 |
|
269 // normal request complete |
|
270 TXIMPRequestId reqIdDummy; // not checked |
|
271 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
272 listener2->ExpectL( evReqComplete ); |
|
273 CleanupStack::Pop( evReqComplete ); |
|
274 // --------------------------------------------- |
|
275 |
|
276 // subscribe |
|
277 // --------------------------------------------- |
|
278 TXIMPRequestId reqId = presAuth.SubscribePresenceBlockListL(); |
|
279 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" ); |
|
280 // --------------------------------------------- |
|
281 |
|
282 // verify that SubscribeBlockListL was called |
|
283 COMMONASSERT( messenger, EXIMPPlgTestSubscribePresenceBlockListCalled, "SubscribeBlockListL was not called", ETrue, NULL ); |
|
284 |
|
285 // Setup status event listener for RequestComplete |
|
286 // --------------------------------------------- |
|
287 listener2->Reset(); |
|
288 |
|
289 evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
290 listener2->ExpectL( evReqComplete ); |
|
291 CleanupStack::Pop( evReqComplete ); |
|
292 |
|
293 RPrBlockInfoImpArray* currentList(NULL); |
|
294 CPresenceBlockListEventImp* event = CreateBlockListEventLCX( |
|
295 KNullDesC, KNullDesC, |
|
296 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
297 MXIMPDataSubscriptionState::EDataUnavailable, |
|
298 ETestPBlCurrent, currentList ); |
|
299 listener2->ExpectL( event ); |
|
300 CleanupStack::Pop(); //event 4 to go. |
|
301 // --------------------------------------------- |
|
302 |
|
303 // subscribe again |
|
304 // --------------------------------------------- |
|
305 reqId = presAuth.SubscribePresenceBlockListL(); |
|
306 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Refresh failed" ); |
|
307 CleanupStack::PopAndDestroy( 4 ); // rest of the items. |
|
308 // --------------------------------------------- |
|
309 |
|
310 // Setup status event listener for RequestComplete |
|
311 // --------------------------------------------- |
|
312 listener2->Reset(); |
|
313 |
|
314 evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
315 listener2->ExpectL( evReqComplete ); |
|
316 CleanupStack::Pop( evReqComplete ); |
|
317 // --------------------------------------------- |
|
318 |
|
319 // unsubscribe |
|
320 // --------------------------------------------- |
|
321 reqId = presAuth.UnsubscribePresenceBlockListL(); |
|
322 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe failed" ); |
|
323 // --------------------------------------------- |
|
324 |
|
325 // verify that UnsubscribeBlockListL was called |
|
326 COMMONASSERT( messenger, EXIMPPlgTestUnsubscribePresenceBlockListCalled, "UnsubscribeBlockListL was not called", ETrue, NULL ); |
|
327 |
|
328 listener2->SetEventSourceL( NULL ); |
|
329 |
|
330 UnbindL(); |
|
331 |
|
332 CleanupStack::PopAndDestroy( listener2 ); |
|
333 } |
|
334 |
|
335 // --------------------------------------------------------------------------- |
|
336 // --------------------------------------------------------------------------- |
|
337 // Single client, empty filter |
|
338 void T_PresenceBlocking::T_SubscribeBlockList_Multiple_L() |
|
339 { |
|
340 EUNIT_PRINT( _L("Multiple presence block list subscription") ); |
|
341 |
|
342 BindAllL(); |
|
343 |
|
344 TInt countOfWrappers = iWrapperMgr->WrapperCount(); |
|
345 TInt a(0); |
|
346 for( a = 0; a < countOfWrappers; ++a ) |
|
347 { |
|
348 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( a ); |
|
349 MXIMPContext* context = wrapper->GetContext(); |
|
350 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
351 |
|
352 // Get the interfaces |
|
353 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
354 MPresenceAuthorization& presAuth = presFeat->PresenceAuthorization(); |
|
355 |
|
356 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
357 CleanupStack::PushL( listener2 ); |
|
358 |
|
359 // Tell the protocol it should act normally |
|
360 messenger->SetNoError(); |
|
361 |
|
362 // expect normal request complete |
|
363 TXIMPRequestId reqIdDummy; // not checked |
|
364 CXIMPRequestCompleteEventImp* evReqComplete = |
|
365 CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
366 listener2->ExpectL( evReqComplete ); |
|
367 CleanupStack::Pop( evReqComplete ); |
|
368 |
|
369 // subscribe |
|
370 TXIMPRequestId reqId = presAuth.SubscribePresenceBlockListL(); |
|
371 |
|
372 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" ); |
|
373 |
|
374 // verify that SubscribePresenceBlockListL was called |
|
375 COMMONASSERT( messenger, EXIMPPlgTestSubscribePresenceBlockListCalled, "SubscribePresenceBlockListL was not called", ETrue, NULL ); |
|
376 |
|
377 CleanupStack::PopAndDestroy( listener2 ); |
|
378 } |
|
379 |
|
380 for( a = 0; a < countOfWrappers; ++a ) |
|
381 { |
|
382 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( a ); |
|
383 MXIMPContext* context = wrapper->GetContext(); |
|
384 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
385 |
|
386 // Get the interfaces |
|
387 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
388 MPresenceAuthorization& presAuth = presFeat->PresenceAuthorization(); |
|
389 |
|
390 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
391 CleanupStack::PushL( listener2 ); |
|
392 |
|
393 // Tell the protocol it should act normally |
|
394 messenger->SetNoError(); |
|
395 |
|
396 // expect normal request complete |
|
397 TXIMPRequestId reqIdDummy; // not checked |
|
398 CXIMPRequestCompleteEventImp* evReqComplete = |
|
399 CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
400 listener2->ExpectL( evReqComplete ); |
|
401 CleanupStack::Pop( evReqComplete ); |
|
402 |
|
403 // unsubscribe |
|
404 TXIMPRequestId reqId = presAuth.UnsubscribePresenceBlockListL(); |
|
405 |
|
406 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe failed" ); |
|
407 |
|
408 // verify that EXIMPPlgTestUnsubscribeBlockListCalled was called |
|
409 COMMONASSERT( messenger, EXIMPPlgTestUnsubscribePresenceBlockListCalled, |
|
410 "UnsubscribePresenceBlockListL was not called", |
|
411 ( a < 2 ) ? EFalse : ETrue, |
|
412 "UnsubscribePresenceBlockListL was called" ); |
|
413 |
|
414 CleanupStack::PopAndDestroy( listener2 ); |
|
415 } |
|
416 |
|
417 UnbindAllL(); |
|
418 } |
|
419 |
|
420 // --------------------------------------------------------------------------- |
|
421 // --------------------------------------------------------------------------- |
|
422 void T_PresenceBlocking::SubscribeL() |
|
423 { |
|
424 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
425 MXIMPContext* context = wrapper->GetContext(); |
|
426 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
427 |
|
428 // Get the interfaces |
|
429 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
430 MPresenceAuthorization& presAuth = presFeat->PresenceAuthorization(); |
|
431 |
|
432 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
433 CleanupStack::PushL( listener2 ); |
|
434 |
|
435 // ------------------------------------------------------ |
|
436 // expect normal request complete |
|
437 TXIMPRequestId reqIdDummy; // not checked |
|
438 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
439 listener2->ExpectL( evReqComplete ); |
|
440 CleanupStack::Pop( evReqComplete ); |
|
441 // ------------------------------------------------------ |
|
442 |
|
443 // subscribe |
|
444 TXIMPRequestId reqId = presAuth.SubscribePresenceBlockListL(); |
|
445 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" ); |
|
446 |
|
447 COMMONASSERT( messenger, EXIMPPlgTestSubscribePresenceBlockListCalled, "SubscribeBlockListL was not called", ETrue, NULL ); |
|
448 |
|
449 CleanupStack::PopAndDestroy( listener2 ); |
|
450 } |
|
451 |
|
452 // --------------------------------------------------------------------------- |
|
453 // --------------------------------------------------------------------------- |
|
454 void T_PresenceBlocking::UnsubscribeL() |
|
455 { |
|
456 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
457 MXIMPContext* context = wrapper->GetContext(); |
|
458 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
459 |
|
460 // Get the interfaces |
|
461 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
462 MPresenceAuthorization& presAuth = presFeat->PresenceAuthorization(); |
|
463 |
|
464 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
465 CleanupStack::PushL( listener2 ); |
|
466 |
|
467 // ------------------------------------------------------ |
|
468 // expect normal request complete |
|
469 TXIMPRequestId reqIdDummy; // not checked |
|
470 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
471 listener2->ExpectL( evReqComplete ); |
|
472 CleanupStack::Pop( evReqComplete ); |
|
473 // ------------------------------------------------------ |
|
474 |
|
475 // unsubscribe |
|
476 TXIMPRequestId reqId = presAuth.UnsubscribePresenceBlockListL(); |
|
477 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe failed" ); |
|
478 |
|
479 COMMONASSERT( messenger, EXIMPPlgTestUnsubscribePresenceBlockListCalled, "UnsubscribeBlockListL was not called", ETrue, NULL ); |
|
480 |
|
481 CleanupStack::PopAndDestroy( listener2 ); |
|
482 } |
|
483 |
|
484 |
|
485 // --------------------------------------------------------------------------- |
|
486 // --------------------------------------------------------------------------- |
|
487 void T_PresenceBlocking::T_HandlePresenceBlockList_L() |
|
488 { |
|
489 EUNIT_PRINT( _L("Handle presence block list.") ); |
|
490 |
|
491 // log in and subscribe a block list |
|
492 BindL(); |
|
493 SubscribeL(); |
|
494 |
|
495 // ------------------------------------------------------ |
|
496 // some startup stuff |
|
497 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
498 MXIMPContext* context = wrapper->GetContext(); |
|
499 |
|
500 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
501 CleanupStack::PushL( listener2 ); |
|
502 // ------------------------------------------------------ |
|
503 |
|
504 // Tell the protocol it should act normally |
|
505 wrapper->GetMessenger()->SetNoError(); |
|
506 |
|
507 // ------------------------------------------------------ |
|
508 // 1. Create faked server message about block list |
|
509 SendSrvMsgL( CXIMPTestFileSrvMsg::ETestSrvMsgPresenceBlockList ); |
|
510 |
|
511 // ------------------------------------------------------ |
|
512 // expect current(empty) MPresenceBlockList event. |
|
513 RPrBlockInfoImpArray* currentList(NULL); |
|
514 CPresenceBlockListEventImp* event = CreateBlockListEventLCX( |
|
515 KNullDesC, KNullDesC, |
|
516 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
517 MXIMPDataSubscriptionState::EDataAvailable, |
|
518 ETestPBlCurrent, currentList); |
|
519 |
|
520 listener2->ExpectL( event ); |
|
521 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
522 |
|
523 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "HandlePresenceBlockListL failed" ); |
|
524 CleanupStack::PopAndDestroy( 4 ); // lists |
|
525 // ------------------------------------------------------ |
|
526 |
|
527 CleanupStack::PopAndDestroy( listener2 ); |
|
528 |
|
529 // clean it up |
|
530 UnsubscribeL(); |
|
531 UnbindL(); |
|
532 } |
|
533 |
|
534 // --------------------------------------------------------------------------- |
|
535 // --------------------------------------------------------------------------- |
|
536 // Single client, empty filter |
|
537 void T_PresenceBlocking::T_BlockPresence_L() |
|
538 { |
|
539 EUNIT_PRINT( _L("Block presence") ); |
|
540 |
|
541 BindL(); |
|
542 |
|
543 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
544 MXIMPContext* context = wrapper->GetContext(); |
|
545 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
546 |
|
547 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
548 CleanupStack::PushL( listener2 ); |
|
549 |
|
550 // Tell the protocol it should act normally |
|
551 messenger->SetNoError(); |
|
552 |
|
553 // Get the interfaces |
|
554 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
555 MPresenceAuthorization& presAuth = presFeat->PresenceAuthorization(); |
|
556 |
|
557 // Setup status event listener for RequestComplete |
|
558 // --------------------------------------------- |
|
559 listener2->Reset(); |
|
560 |
|
561 // normal request complete |
|
562 TXIMPRequestId reqIdDummy; // not checked |
|
563 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
564 listener2->ExpectL( evReqComplete ); |
|
565 CleanupStack::Pop( evReqComplete ); |
|
566 |
|
567 // subscribe |
|
568 TXIMPRequestId reqId = presAuth.SubscribePresenceBlockListL(); |
|
569 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" ); |
|
570 |
|
571 // verify that SubscribePresenceBlockListL was called |
|
572 COMMONASSERT( messenger, EXIMPPlgTestSubscribePresenceBlockListCalled, "SubscribePresenceBlockListL was not called", ETrue, NULL ); |
|
573 |
|
574 |
|
575 // --------------------------------------------- |
|
576 // 1. Block presence |
|
577 |
|
578 CXIMPIdentityImp* identity = XIMPTestPresenceDataUtils::GenerateIdentityLC( &KNullDesC8 ); |
|
579 _LIT16( KDisplayName1, "DispnameA, LoremI" ); |
|
580 |
|
581 |
|
582 // Setup status event listener for RequestComplete |
|
583 // --------------------------------------------- |
|
584 listener2->Reset(); |
|
585 |
|
586 evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
587 listener2->ExpectL( evReqComplete ); |
|
588 CleanupStack::Pop( evReqComplete ); |
|
589 |
|
590 RPrBlockInfoImpArray* currentList(NULL); |
|
591 CPresenceBlockListEventImp* event = |
|
592 CreateBlockListEventLCX( identity->Identity(), |
|
593 KNullDesC, |
|
594 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
595 MXIMPDataSubscriptionState::EDataAvailable, |
|
596 ETestPBlAdded, currentList ); |
|
597 |
|
598 listener2->ExpectL( event ); |
|
599 CleanupStack::Pop( event ); |
|
600 |
|
601 // block |
|
602 reqId = presAuth.BlockPresenceForPresentityL( *identity ); |
|
603 |
|
604 //Waqas: fixed current list in event |
|
605 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Block failed" ); |
|
606 |
|
607 // verify that BlockPresenceForPresentityL was called |
|
608 COMMONASSERT( messenger, EXIMPPlgTestBlockPresenceForPresentityCalled, "BlockPresenceForPresentityL was not called", ETrue, NULL ); |
|
609 |
|
610 CleanupStack::PopAndDestroy( 4 ); // lists |
|
611 // --------------------------------------------- |
|
612 |
|
613 |
|
614 // --------------------------------------------- |
|
615 // 2. Re-block |
|
616 |
|
617 // Setup status event listener for RequestComplete |
|
618 listener2->Reset(); |
|
619 |
|
620 evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
621 listener2->ExpectL( evReqComplete ); |
|
622 CleanupStack::Pop( evReqComplete ); |
|
623 |
|
624 // we need to create current list to give to the event |
|
625 currentList = new ( ELeave ) RPrBlockInfoImpArray; // previous is destroyed |
|
626 CleanupDeletePushL( currentList ); |
|
627 // create the group info |
|
628 CPresenceBlockInfoImp* blockInfoForEvent = |
|
629 CPresenceBlockInfoImp::NewLC( *identity, KNullDesC ); |
|
630 currentList->AppendL( blockInfoForEvent ); |
|
631 CleanupStack::Pop( blockInfoForEvent ); |
|
632 CleanupStack::Pop( currentList ); |
|
633 |
|
634 // now make the event |
|
635 event = CreateBlockListEventLCX( identity->Identity(), |
|
636 KNullDesC, |
|
637 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
638 MXIMPDataSubscriptionState::EDataAvailable, |
|
639 ETestPBlCurrent, currentList ); |
|
640 |
|
641 listener2->ExpectL( event ); |
|
642 CleanupStack::Pop( event ); |
|
643 |
|
644 // re-block |
|
645 reqId = presAuth.BlockPresenceForPresentityL( *identity ); |
|
646 |
|
647 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Block failed" ); |
|
648 |
|
649 // verify that BlockPresenceForPresentityL was called |
|
650 COMMONASSERT( messenger, EXIMPPlgTestBlockPresenceForPresentityCalled, "BlockPresenceForPresentityL was not called", ETrue, NULL ); |
|
651 |
|
652 |
|
653 CleanupStack::PopAndDestroy( 4 ); // lists |
|
654 |
|
655 |
|
656 // Deinitiliaze event source from listener. |
|
657 listener2->SetEventSourceL( NULL ); |
|
658 |
|
659 UnbindL(); |
|
660 |
|
661 CleanupStack::PopAndDestroy( identity ); |
|
662 |
|
663 CleanupStack::PopAndDestroy( listener2 ); |
|
664 |
|
665 } |
|
666 // --------------------------------------------------------------------------- |
|
667 // --------------------------------------------------------------------------- |
|
668 // Single client, empty filter |
|
669 void T_PresenceBlocking::T_CancelBlockedPresence_L() |
|
670 { |
|
671 EUNIT_PRINT( _L("Cancel presence block") ); |
|
672 |
|
673 BindL(); |
|
674 |
|
675 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
676 MXIMPContext* context = wrapper->GetContext(); |
|
677 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
678 |
|
679 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
680 CleanupStack::PushL( listener2 ); |
|
681 |
|
682 // Tell the protocol it should act normally |
|
683 messenger->SetNoError(); |
|
684 |
|
685 // Get the interfaces |
|
686 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
687 MPresenceAuthorization& presAuth = presFeat->PresenceAuthorization(); |
|
688 |
|
689 // Setup status event listener for RequestComplete |
|
690 // --------------------------------------------- |
|
691 listener2->Reset(); |
|
692 |
|
693 // normal request complete |
|
694 TXIMPRequestId reqIdDummy; // not checked |
|
695 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
696 listener2->ExpectL( evReqComplete ); |
|
697 CleanupStack::Pop( evReqComplete ); |
|
698 // --------------------------------------------- |
|
699 |
|
700 // subscribe |
|
701 // --------------------------------------------- |
|
702 TXIMPRequestId reqId = presAuth.SubscribePresenceBlockListL(); |
|
703 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" ); |
|
704 // --------------------------------------------- |
|
705 |
|
706 // verify that SubscribePresenceBlockListL was called |
|
707 COMMONASSERT( messenger, EXIMPPlgTestSubscribePresenceBlockListCalled, "SubscribePresenceBlockListL was not called", ETrue, NULL ); |
|
708 |
|
709 |
|
710 CXIMPIdentityImp* identity = XIMPTestPresenceDataUtils::GenerateIdentityLC( &KNullDesC8 ); |
|
711 |
|
712 // --------------------------------------------- |
|
713 // 1. Cancel non-existing block (no blocks) |
|
714 |
|
715 // Setup status event listener for RequestComplete |
|
716 listener2->Reset(); |
|
717 |
|
718 evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
719 listener2->ExpectL( evReqComplete ); |
|
720 CleanupStack::Pop( evReqComplete ); |
|
721 |
|
722 RPrBlockInfoImpArray* currentList(NULL); |
|
723 CPresenceBlockListEventImp* event = |
|
724 CreateBlockListEventLCX( KNullDesC, |
|
725 KNullDesC, |
|
726 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
727 MXIMPDataSubscriptionState::EDataUnavailable, |
|
728 ETestPBlRemoved, currentList ); |
|
729 listener2->ExpectL( event ); |
|
730 CleanupStack::Pop( event ); |
|
731 |
|
732 // cancel nonexisting block |
|
733 reqId = presAuth.CancelPresenceBlockFromPresentityL( *identity ); |
|
734 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Cancel failed" ); |
|
735 // --------------------------------------------- |
|
736 |
|
737 // verify that method was called |
|
738 COMMONASSERT( messenger, EXIMPPlgTestCancelPresenceBlockFromPresentityCalled, "CancelPresenceBlockFromPresentityL was not called", ETrue, NULL ); |
|
739 |
|
740 CleanupStack::PopAndDestroy( 4 ); // lists |
|
741 |
|
742 |
|
743 // --------------------------------------------- |
|
744 // 2. Cancel block |
|
745 |
|
746 |
|
747 // Setup status event listener for RequestComplete |
|
748 listener2->Reset(); |
|
749 |
|
750 evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
751 listener2->ExpectL( evReqComplete ); |
|
752 CleanupStack::Pop( evReqComplete ); |
|
753 |
|
754 currentList = NULL; // previous is destroyed |
|
755 event = CreateBlockListEventLCX( identity->Identity(), |
|
756 KNullDesC, |
|
757 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
758 MXIMPDataSubscriptionState::EDataAvailable, |
|
759 ETestPBlAdded, currentList ); |
|
760 listener2->ExpectL( event ); |
|
761 CleanupStack::Pop( event ); |
|
762 |
|
763 // block a presentity |
|
764 reqId = presAuth.BlockPresenceForPresentityL( *identity ); |
|
765 // Waqas: Fixed current list in event |
|
766 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Block failed" ); |
|
767 |
|
768 // verify that method was called |
|
769 COMMONASSERT( messenger, EXIMPPlgTestBlockPresenceForPresentityCalled, "BlockPresenceForPresentityL was not called", ETrue, NULL ); |
|
770 CleanupStack::PopAndDestroy( 4 ); // lists |
|
771 // --------------------------------------------- |
|
772 |
|
773 |
|
774 // Setup status event listener for RequestComplete |
|
775 listener2->Reset(); |
|
776 |
|
777 evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
778 listener2->ExpectL( evReqComplete ); |
|
779 CleanupStack::Pop( evReqComplete ); |
|
780 |
|
781 // we need to create current list to give to the event |
|
782 currentList = new ( ELeave ) RPrBlockInfoImpArray; // previous is destroyed |
|
783 CleanupDeletePushL( currentList ); |
|
784 CPresenceBlockInfoImp* blockInfoForEvent = |
|
785 CPresenceBlockInfoImp::NewLC( *identity, KNullDesC ); |
|
786 currentList->AppendL( blockInfoForEvent ); |
|
787 CleanupStack::Pop( blockInfoForEvent ); |
|
788 CleanupStack::Pop( currentList ); |
|
789 |
|
790 // now create event and give currentList to it |
|
791 event = CreateBlockListEventLCX( identity->Identity(), |
|
792 KNullDesC, |
|
793 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
794 MXIMPDataSubscriptionState::EDataAvailable, |
|
795 ETestPBlRemoved, currentList ); |
|
796 listener2->ExpectL( event ); |
|
797 CleanupStack::Pop( event ); |
|
798 |
|
799 // cancel the existing block |
|
800 reqId = presAuth.CancelPresenceBlockFromPresentityL( *identity ); |
|
801 // Waqas: Fixed current list in event |
|
802 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Cancel block failed" ); |
|
803 |
|
804 // verify that method was called |
|
805 COMMONASSERT( messenger, EXIMPPlgTestCancelPresenceBlockFromPresentityCalled, "CancelPresenceBlockFromPresentityL was not called", ETrue, NULL ); |
|
806 CleanupStack::PopAndDestroy( 4 ); // lists |
|
807 // --------------------------------------------- |
|
808 |
|
809 |
|
810 // --------------------------------------------- |
|
811 // TODO 3. Cancel block (non-existing block, other blocks exist) |
|
812 |
|
813 |
|
814 // Deinitiliaze event source from listener. |
|
815 listener2->SetEventSourceL( NULL ); |
|
816 |
|
817 UnbindL(); |
|
818 |
|
819 CleanupStack::PopAndDestroy( identity ); |
|
820 |
|
821 CleanupStack::PopAndDestroy( listener2 ); |
|
822 } |
|
823 |
|
824 |
|
825 // --------------------------------------------------------------------------- |
|
826 // --------------------------------------------------------------------------- |
|
827 void T_PresenceBlocking::T_HandlePresenceBlocked_L() |
|
828 { |
|
829 EUNIT_PRINT( _L("Handle presence blocked") ); |
|
830 |
|
831 // log in and subscribe a block list |
|
832 BindL(); |
|
833 SubscribeL(); |
|
834 |
|
835 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
836 MXIMPContext* context = wrapper->GetContext(); |
|
837 |
|
838 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
839 CleanupStack::PushL( listener2 ); |
|
840 |
|
841 // Tell the protocol it should act normally |
|
842 wrapper->GetMessenger()->SetNoError(); |
|
843 |
|
844 |
|
845 CXIMPIdentityImp* identity = XIMPTestPresenceDataUtils::GenerateIdentityLC( &KNullDesC8 ); |
|
846 |
|
847 // ------------------------------------------------------ |
|
848 // 1. Create faked server message about blocked |
|
849 SendBlockedSrvMsgL( identity->Identity(), |
|
850 KNullDesC, |
|
851 CXIMPTestFileSrvMsg::ETestSrvMsgPresenceBlocked ); |
|
852 |
|
853 RPrBlockInfoImpArray* currentList(NULL); |
|
854 CPresenceBlockListEventImp* event = CreateBlockListEventLCX( |
|
855 identity->Identity(), KNullDesC, |
|
856 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
857 MXIMPDataSubscriptionState::EDataAvailable, |
|
858 ETestPBlAdded, currentList ); |
|
859 |
|
860 listener2->ExpectL( event ); |
|
861 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
862 |
|
863 // Waqas: Fixed current list handling |
|
864 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "HandlePresenceBlocked failed" ); |
|
865 |
|
866 CleanupStack::PopAndDestroy( 4 ); // lists |
|
867 // ------------------------------------------------------ |
|
868 |
|
869 CleanupStack::PopAndDestroy( identity ); |
|
870 CleanupStack::PopAndDestroy( listener2 ); |
|
871 |
|
872 // clean it up |
|
873 UnsubscribeL(); |
|
874 UnbindL(); |
|
875 |
|
876 } |
|
877 // --------------------------------------------------------------------------- |
|
878 // --------------------------------------------------------------------------- |
|
879 void T_PresenceBlocking::T_HandlePresenceBlockCanceled_L() |
|
880 { |
|
881 |
|
882 EUNIT_PRINT( _L("Handle presence block canceled") ); |
|
883 |
|
884 // log in and subscribe a block list |
|
885 BindL(); |
|
886 SubscribeL(); |
|
887 |
|
888 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
889 MXIMPContext* context = wrapper->GetContext(); |
|
890 |
|
891 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
892 CleanupStack::PushL( listener2 ); |
|
893 |
|
894 // Tell the protocol it should act normally |
|
895 wrapper->GetMessenger()->SetNoError(); |
|
896 |
|
897 |
|
898 CXIMPIdentityImp* identity = XIMPTestPresenceDataUtils::GenerateIdentityLC( &KNullDesC8 ); |
|
899 |
|
900 // ------------------------------------------------------ |
|
901 // 1. Cancel block (with no blocks) |
|
902 SendCanceledSrvMsgL( identity->Identity(), |
|
903 KNullDesC, |
|
904 CXIMPTestFileSrvMsg::ETestSrvMsgPresenceBlockCanceled ); |
|
905 |
|
906 RPrBlockInfoImpArray* currentList(NULL); |
|
907 CPresenceBlockListEventImp* event = CreateBlockListEventLCX( |
|
908 KNullDesC, KNullDesC, |
|
909 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
910 MXIMPDataSubscriptionState::EDataUnavailable, |
|
911 ETestPBlRemoved, currentList ); |
|
912 |
|
913 listener2->ExpectL( event ); |
|
914 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
915 |
|
916 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "HandlePresenceBlockCanceled failed" ); |
|
917 CleanupStack::PopAndDestroy( 4 ); // lists |
|
918 // ------------------------------------------------------ |
|
919 |
|
920 CleanupStack::PopAndDestroy( identity ); |
|
921 CleanupStack::PopAndDestroy( listener2 ); |
|
922 |
|
923 // clean it up |
|
924 UnsubscribeL(); |
|
925 UnbindL(); |
|
926 } |
|
927 |
|
928 // --------------------------------------------------------------------------- |
|
929 // --------------------------------------------------------------------------- |
|
930 // send a faked server-originated message with group info made |
|
931 // from the given uri and displayname |
|
932 // |
|
933 void T_PresenceBlocking::SendSrvMsgL( |
|
934 const TDesC& aUri, const TDesC& aDispName, |
|
935 TInt aMsgType ) |
|
936 { |
|
937 // we'll use hard-coded wrapper 0 instance for now. |
|
938 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
939 |
|
940 // create a grant req info contained within the server-originated |
|
941 // faked message |
|
942 RXIMPObjOwningPtrArray<CPresenceBlockInfoImp> blockList; |
|
943 CleanupClosePushL( blockList ); |
|
944 |
|
945 CXIMPIdentityImp* blockId = CXIMPIdentityImp::NewLC( aUri ); |
|
946 CPresenceBlockInfoImp* blockItem = |
|
947 CPresenceBlockInfoImp::NewLC( *blockId, aDispName ); |
|
948 blockList.AppendL( blockItem ); |
|
949 CleanupStack::Pop( blockItem ); |
|
950 CleanupStack::PopAndDestroy( blockId ); |
|
951 |
|
952 HBufC8* packedArray = |
|
953 TXIMPObjectPacker<CPresenceBlockInfoImp>::PackArrayL( blockList ); |
|
954 CleanupStack::PushL( packedArray ); |
|
955 |
|
956 // use filetool to send it for plugin. |
|
957 CXIMPTestFileSrvMsg* srvMsg = CXIMPTestFileSrvMsg::NewL( aMsgType, |
|
958 *packedArray ); |
|
959 CleanupStack::PushL( srvMsg ); |
|
960 wrapper->FileTool().CleanAllL(); |
|
961 wrapper->FileTool().SrvMsgStoreL( srvMsg ); |
|
962 CleanupStack::PopAndDestroy( 3 ); // srvMsg, packedArray, blockList |
|
963 } |
|
964 |
|
965 void T_PresenceBlocking::SendBlockedSrvMsgL( |
|
966 const TDesC& aUri, const TDesC& aDispName, |
|
967 TInt aMsgType ) |
|
968 { |
|
969 // we'll use hard-coded wrapper 0 instance for now. |
|
970 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
971 |
|
972 // create a grant req info contained within the server-originated |
|
973 // faked message |
|
974 CXIMPIdentityImp* blockId = CXIMPIdentityImp::NewLC( aUri ); |
|
975 CPresenceBlockInfoImp* blockItem = |
|
976 CPresenceBlockInfoImp::NewLC( *blockId, aDispName ); |
|
977 |
|
978 |
|
979 HBufC8* packedArray = |
|
980 TXIMPObjectPacker<CPresenceBlockInfoImp>::PackL( *blockItem ); |
|
981 CleanupStack::PushL( packedArray ); |
|
982 |
|
983 // use filetool to send it for plugin. |
|
984 CXIMPTestFileSrvMsg* srvMsg = CXIMPTestFileSrvMsg::NewL( aMsgType, |
|
985 *packedArray ); |
|
986 CleanupStack::PushL( srvMsg ); |
|
987 wrapper->FileTool().CleanAllL(); |
|
988 wrapper->FileTool().SrvMsgStoreL( srvMsg ); |
|
989 CleanupStack::PopAndDestroy( 4 ); // blockId, blockItem, packedArray, srvMsg |
|
990 } |
|
991 |
|
992 void T_PresenceBlocking::SendCanceledSrvMsgL( |
|
993 const TDesC& aUri, const TDesC& aDispName, |
|
994 TInt aMsgType ) |
|
995 { |
|
996 // we'll use hard-coded wrapper 0 instance for now. |
|
997 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
998 |
|
999 CXIMPIdentityImp* blockId = CXIMPIdentityImp::NewLC( aUri ); |
|
1000 |
|
1001 HBufC8* packedArray = |
|
1002 TXIMPObjectPacker<CXIMPIdentityImp>::PackL( *blockId ); |
|
1003 CleanupStack::PushL( packedArray ); |
|
1004 |
|
1005 // use filetool to send it for plugin. |
|
1006 CXIMPTestFileSrvMsg* srvMsg = CXIMPTestFileSrvMsg::NewL( aMsgType, |
|
1007 *packedArray ); |
|
1008 CleanupStack::PushL( srvMsg ); |
|
1009 wrapper->FileTool().CleanAllL(); |
|
1010 wrapper->FileTool().SrvMsgStoreL( srvMsg ); |
|
1011 CleanupStack::PopAndDestroy( 3 ); // blockId, packedArray, srvMsg |
|
1012 } |
|
1013 |
|
1014 // --------------------------------------------------------------------------- |
|
1015 // --------------------------------------------------------------------------- |
|
1016 // send a faked server-originated message with empty contents |
|
1017 // |
|
1018 void T_PresenceBlocking::SendSrvMsgL( TInt aMsgType ) |
|
1019 { |
|
1020 // we'll use hard-coded wrapper 0 instance for now. |
|
1021 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
1022 |
|
1023 // create a server-originated faked message with empty contents |
|
1024 RXIMPObjOwningPtrArray<CPresenceBlockInfoImp> blockList; |
|
1025 |
|
1026 HBufC8* packedArray = TXIMPObjectPacker<CPresenceBlockInfoImp>::PackArrayL( blockList ); |
|
1027 CleanupStack::PushL( packedArray ); |
|
1028 |
|
1029 // use filetool to send it for plugin. |
|
1030 CXIMPTestFileSrvMsg* srvMsg = CXIMPTestFileSrvMsg::NewL( aMsgType, |
|
1031 *packedArray ); |
|
1032 CleanupStack::PushL( srvMsg ); |
|
1033 wrapper->FileTool().CleanAllL(); |
|
1034 wrapper->FileTool().SrvMsgStoreL( srvMsg ); |
|
1035 CleanupStack::PopAndDestroy( 2 ); // srvMsg, packedArray |
|
1036 } |
|
1037 |
|
1038 // --------------------------------------------------------------------------- |
|
1039 // --------------------------------------------------------------------------- |
|
1040 // create a block list event with given arrays |
|
1041 // |
|
1042 CPresenceBlockListEventImp* |
|
1043 T_PresenceBlocking::CreateBlockListEventLCX( |
|
1044 const TDesC& aUri, |
|
1045 const TDesC& aDispName, |
|
1046 MXIMPDataSubscriptionState::TSubscriptionState aSubscriptionState, |
|
1047 MXIMPDataSubscriptionState::TDataState aDataState, |
|
1048 TTestPBlOperationSpecifier aOperation, |
|
1049 RPrBlockInfoImpArray* aCurrentList) |
|
1050 { |
|
1051 // create the arrays |
|
1052 |
|
1053 // new list |
|
1054 RPrBlockInfoImpArray* newList = new ( ELeave ) RPrBlockInfoImpArray; |
|
1055 CleanupDeletePushL( newList ); |
|
1056 |
|
1057 // current list, created by caller |
|
1058 if(!aCurrentList) // if client didnt created the list |
|
1059 aCurrentList = new ( ELeave ) RPrBlockInfoImpArray; |
|
1060 CleanupDeletePushL( aCurrentList ); |
|
1061 |
|
1062 // removed list |
|
1063 RPrBlockInfoImpArray* removedList = new ( ELeave ) RPrBlockInfoImpArray; |
|
1064 CleanupDeletePushL( removedList ); |
|
1065 |
|
1066 // updated list |
|
1067 RPrBlockInfoImpArray* updatedList = new ( ELeave ) RPrBlockInfoImpArray; |
|
1068 CleanupDeletePushL( updatedList ); |
|
1069 |
|
1070 // create subscription state |
|
1071 CXIMPDataSubscriptionStateImp* subsState = CXIMPDataSubscriptionStateImp::NewLC(); |
|
1072 |
|
1073 |
|
1074 // create the group info |
|
1075 CPresenceBlockInfoImp* blockInfoForEvent1 = NULL; |
|
1076 { |
|
1077 CXIMPIdentityImp* idForEvent = CXIMPIdentityImp::NewLC( aUri ); |
|
1078 blockInfoForEvent1 = CPresenceBlockInfoImp::NewLC( *idForEvent, aDispName ); |
|
1079 |
|
1080 CleanupStack::Pop( blockInfoForEvent1 ); |
|
1081 CleanupStack::PopAndDestroy( idForEvent ); |
|
1082 CleanupStack::PushL( blockInfoForEvent1 ); |
|
1083 } |
|
1084 |
|
1085 CPresenceBlockInfoImp* blockInfoForEvent2 = |
|
1086 TXIMPObjectCloner< CPresenceBlockInfoImp >::CloneLC( *blockInfoForEvent1 ); |
|
1087 |
|
1088 TInt count(0); |
|
1089 TBool found(EFalse); |
|
1090 TInt i(0); |
|
1091 |
|
1092 // put the given group info into the specified array |
|
1093 switch ( aOperation ) |
|
1094 { |
|
1095 case ETestPBlAdded: |
|
1096 { |
|
1097 newList->AppendL( blockInfoForEvent2 ); |
|
1098 CleanupStack::Pop( blockInfoForEvent2 ); |
|
1099 |
|
1100 aCurrentList->AppendL( blockInfoForEvent1 ); |
|
1101 CleanupStack::Pop( blockInfoForEvent1 ); |
|
1102 |
|
1103 break; |
|
1104 } |
|
1105 |
|
1106 case ETestPBlRemoved: |
|
1107 { |
|
1108 // search the given id in current list |
|
1109 count = aCurrentList->Count(); |
|
1110 for(i=0;i<count;i++) |
|
1111 { |
|
1112 // if dispname and id are same |
|
1113 if (( ((((*aCurrentList)[i])->BlockedEntityId()).Identity()) == aUri ) |
|
1114 && ( (((*aCurrentList)[i])->BlockedEntityDisplayName()) == aDispName )) |
|
1115 { |
|
1116 found = ETrue; |
|
1117 break; |
|
1118 } |
|
1119 } |
|
1120 if(found) // do we need to leave if error? Waqas |
|
1121 { |
|
1122 delete (*aCurrentList)[i]; |
|
1123 aCurrentList->Remove(i); |
|
1124 removedList->AppendL( blockInfoForEvent2 ); |
|
1125 CleanupStack::Pop( blockInfoForEvent2 ); |
|
1126 } |
|
1127 else |
|
1128 CleanupStack::PopAndDestroy( blockInfoForEvent2 ); |
|
1129 |
|
1130 CleanupStack::PopAndDestroy( blockInfoForEvent1 ); |
|
1131 } |
|
1132 break; |
|
1133 case ETestPBlUpdated: |
|
1134 { |
|
1135 updatedList->AppendL( blockInfoForEvent2 ); |
|
1136 CleanupStack::Pop( blockInfoForEvent2); |
|
1137 CleanupStack::PopAndDestroy( blockInfoForEvent1 ); |
|
1138 } |
|
1139 break; |
|
1140 |
|
1141 case ETestPBlCurrent: |
|
1142 { |
|
1143 // don't add, thus return what user has given |
|
1144 CleanupStack::PopAndDestroy( blockInfoForEvent2 ); // blockInfoForEvent2 |
|
1145 CleanupStack::PopAndDestroy( blockInfoForEvent1 ); // blockInfoForEvent1 |
|
1146 } |
|
1147 break; |
|
1148 |
|
1149 default: |
|
1150 { |
|
1151 User::Leave( KErrArgument ); |
|
1152 } |
|
1153 break; |
|
1154 } |
|
1155 |
|
1156 subsState->SetSubscriptionStateL(aSubscriptionState); |
|
1157 subsState->SetDataStateL(aDataState); |
|
1158 |
|
1159 // create the actual event |
|
1160 CPresenceBlockListEventImp* tmp = |
|
1161 CPresenceBlockListEventImp::NewLC( |
|
1162 newList, |
|
1163 aCurrentList, |
|
1164 removedList, |
|
1165 updatedList, |
|
1166 subsState ); |
|
1167 |
|
1168 // subState is owned by the event, we need to pop it out from the stack |
|
1169 CleanupStack::Pop( tmp ); |
|
1170 CleanupStack::Pop( subsState ); |
|
1171 CleanupStack::PushL( tmp ); |
|
1172 |
|
1173 /* |
|
1174 * In cleanupstack there are 5 items, FIFO |
|
1175 * - added/new list |
|
1176 * - current list |
|
1177 * - removed list |
|
1178 * - updated list |
|
1179 * - event imp |
|
1180 */ |
|
1181 |
|
1182 return tmp; |
|
1183 } |
|
1184 |
|
1185 // =========================================================================== |
|
1186 // TEST CASE TABLE |
|
1187 // =========================================================================== |
|
1188 // |
|
1189 EUNIT_BEGIN_TEST_TABLE( |
|
1190 T_PresenceBlocking, |
|
1191 "XIMPFW presence blocking tests", |
|
1192 "MODULE" ) |
|
1193 |
|
1194 PRFW_DECORATED_TEST( |
|
1195 "Subscribe block list", |
|
1196 "", |
|
1197 "", |
|
1198 "FUNCTIONALITY", |
|
1199 Setup_L, |
|
1200 T_SubscribeBlockList_Single_L, |
|
1201 Teardown ) |
|
1202 |
|
1203 PRFW_DECORATED_TEST( |
|
1204 "Refresh block list subscription", |
|
1205 "", |
|
1206 "", |
|
1207 "FUNCTIONALITY", |
|
1208 Setup_L, |
|
1209 T_SubscribeBlockListRefresh_Single_L, |
|
1210 Teardown ) |
|
1211 |
|
1212 PRFW_DECORATED_TEST( |
|
1213 "Subscribe block list, multiple", |
|
1214 "", |
|
1215 "", |
|
1216 "FUNCTIONALITY", |
|
1217 SetupMultiple_L, |
|
1218 T_SubscribeBlockList_Multiple_L, |
|
1219 Teardown ) |
|
1220 |
|
1221 |
|
1222 PRFW_DECORATED_TEST( |
|
1223 "Handle presence block list", |
|
1224 "", |
|
1225 "", |
|
1226 "FUNCTIONALITY", |
|
1227 Setup_L, |
|
1228 T_HandlePresenceBlockList_L, |
|
1229 Teardown ) |
|
1230 |
|
1231 PRFW_DECORATED_TEST( |
|
1232 "Block presence", |
|
1233 "", |
|
1234 "", |
|
1235 "FUNCTIONALITY", |
|
1236 Setup_L, |
|
1237 T_BlockPresence_L, |
|
1238 Teardown ) |
|
1239 |
|
1240 PRFW_DECORATED_TEST( |
|
1241 "Cancel presence block", |
|
1242 "", |
|
1243 "", |
|
1244 "FUNCTIONALITY", |
|
1245 Setup_L, |
|
1246 T_CancelBlockedPresence_L, |
|
1247 Teardown ) |
|
1248 |
|
1249 PRFW_DECORATED_TEST( |
|
1250 "Handle blocked and canceled blocks", |
|
1251 "", |
|
1252 "", |
|
1253 "FUNCTIONALITY", |
|
1254 Setup_L, |
|
1255 T_HandlePresenceBlocked_L, |
|
1256 Teardown ) |
|
1257 |
|
1258 PRFW_DECORATED_TEST( |
|
1259 "Handle blocked and canceled blocks", |
|
1260 "", |
|
1261 "", |
|
1262 "FUNCTIONALITY", |
|
1263 Setup_L, |
|
1264 T_HandlePresenceBlockCanceled_L, |
|
1265 Teardown ) |
|
1266 |
|
1267 EUNIT_END_TEST_TABLE |
|
1268 |
|
1269 |
|
1270 // =========================================================================== |
|
1271 // TEST SUITE CONSTRUCTION |
|
1272 // =========================================================================== |
|
1273 // |
|
1274 EXPORT_C MEUnitTest* CreateTestSuiteL() |
|
1275 { |
|
1276 return T_PresenceBlocking::NewL(); |
|
1277 } |
|
1278 |
|
1279 |
|
1280 // end of file |