|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "eunittools.h" |
|
20 |
|
21 #include <eunitmacros.h> |
|
22 #include <ecom/ecom.h> |
|
23 #include <badesca.h> |
|
24 |
|
25 #include <ximpbase.h> |
|
26 #include <ximpclient.h> |
|
27 #include <ximpcontext.h> |
|
28 #include <presencefeatures.h> |
|
29 #include <presentitygroups.h> |
|
30 #include <presentitygroupinfo.h> |
|
31 #include <presentitygrouplistevent.h> |
|
32 #include <ximpobjectfactory.h> |
|
33 |
|
34 #include "ximpstatusimp.h" |
|
35 #include "ximprequestcompleteeventimp.h" |
|
36 #include "t_presencegrouplistmngt.h" |
|
37 #include "prfwteststatuseventlistener.h" |
|
38 #include "prfwtestmessaging.h" |
|
39 #include "prfwtestmessenger.h" |
|
40 #include "prfwtestcontextwrappermgr.h" |
|
41 #include "prfwtestcontextwrapper.h" |
|
42 #include "prfwtesteventfactory.h" |
|
43 |
|
44 #include "presenceinfoimp.h" |
|
45 #include "presenceinfofilterimp.h" |
|
46 #include "prfwtestpresencedatautils.h" |
|
47 #include "ximpidentityimp.h" |
|
48 #include "ximpobjecthelpers.h" |
|
49 #include "presentitygroupinfoimp.h" |
|
50 #include "presentitygrouplisteventimp.h" |
|
51 #include "presentitygroupcontenteventimp.h" |
|
52 #include "prfwtestfilesrvmsg.h" |
|
53 #include "prfwtestfiletool.h" |
|
54 #include "prfwtestlistener.h" |
|
55 |
|
56 #include "prfwtestrobustnesstools.h" |
|
57 |
|
58 // ============================ MEMBER FUNCTIONS =============================== |
|
59 |
|
60 // CONSTRUCTION |
|
61 T_PresenceGroupListManagement* T_PresenceGroupListManagement::NewL() |
|
62 { |
|
63 T_PresenceGroupListManagement* self = new( ELeave ) T_PresenceGroupListManagement; |
|
64 CleanupStack::PushL( self ); |
|
65 self->ConstructL(); |
|
66 CleanupStack::Pop( self ); |
|
67 |
|
68 return self; |
|
69 } |
|
70 |
|
71 |
|
72 T_PresenceGroupListManagement::~T_PresenceGroupListManagement() |
|
73 { |
|
74 PrfwTestRobustness::DoPreCleaning(); |
|
75 } |
|
76 |
|
77 |
|
78 void T_PresenceGroupListManagement::ConstructL() |
|
79 { |
|
80 CEUnitTestSuiteClass::ConstructL(); |
|
81 } |
|
82 |
|
83 |
|
84 T_PresenceGroupListManagement::T_PresenceGroupListManagement() |
|
85 { |
|
86 } |
|
87 |
|
88 |
|
89 |
|
90 // =========================================================================== |
|
91 // TEST CASE SETUP & TEARDOWN METHODS |
|
92 // =========================================================================== |
|
93 // |
|
94 |
|
95 void T_PresenceGroupListManagement::Setup_L() |
|
96 { |
|
97 PrfwTestRobustness::DoPreCleaning(); |
|
98 |
|
99 iWrapperMgr = CXIMPTestContextWrapperMgr::NewL(); |
|
100 iWrapperMgr->CreateWrapperL(); |
|
101 } |
|
102 |
|
103 void T_PresenceGroupListManagement::SetupMultiple_L() |
|
104 { |
|
105 PrfwTestRobustness::DoPreCleaning(); |
|
106 |
|
107 |
|
108 iWrapperMgr = CXIMPTestContextWrapperMgr::NewL(); |
|
109 iWrapperMgr->CreateWrapperL(); |
|
110 iWrapperMgr->CreateWrapperL(); |
|
111 iWrapperMgr->CreateWrapperL(); |
|
112 } |
|
113 |
|
114 |
|
115 void T_PresenceGroupListManagement::BindL() |
|
116 { |
|
117 CXIMPTestContextWrapper* wrapper0 = iWrapperMgr->GetWrapperL( 0 ); |
|
118 |
|
119 wrapper0->BindL( 0 ); |
|
120 } |
|
121 |
|
122 void T_PresenceGroupListManagement::BindAllL() |
|
123 { |
|
124 for( TInt a = 0; a < iWrapperMgr->WrapperCount(); ++a ) |
|
125 { |
|
126 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( a ); |
|
127 wrapper->BindL( 0 ); |
|
128 } |
|
129 } |
|
130 |
|
131 |
|
132 void T_PresenceGroupListManagement::Teardown() |
|
133 { |
|
134 delete iWrapperMgr; |
|
135 iWrapperMgr = NULL; |
|
136 |
|
137 REComSession::FinalClose(); |
|
138 |
|
139 PrfwTestRobustness::DoPreCleaning(); |
|
140 } |
|
141 |
|
142 void T_PresenceGroupListManagement::UnbindL() |
|
143 { |
|
144 // Do unbind |
|
145 CXIMPTestContextWrapper* wrapper0 = iWrapperMgr->GetWrapperL( 0 ); |
|
146 wrapper0->UnbindL(); |
|
147 } |
|
148 |
|
149 void T_PresenceGroupListManagement::UnbindAllL() |
|
150 { |
|
151 for( TInt a = 0; a < iWrapperMgr->WrapperCount(); ++a ) |
|
152 { |
|
153 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( a ); |
|
154 wrapper->UnbindL(); |
|
155 } |
|
156 } |
|
157 |
|
158 |
|
159 // =========================================================================== |
|
160 // TEST CASES for presentity presence subscription |
|
161 // =========================================================================== |
|
162 |
|
163 |
|
164 // Single client, empty filter |
|
165 void T_PresenceGroupListManagement::T_SubscribePresentityGroup_Single_L() |
|
166 { |
|
167 EUNIT_PRINT( _L("Single presentity group list subscription") ); |
|
168 |
|
169 BindL(); |
|
170 |
|
171 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
172 MXIMPContext* context = wrapper->GetContext(); |
|
173 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
174 |
|
175 // Get the interfaces |
|
176 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
177 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
178 |
|
179 |
|
180 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
181 CleanupStack::PushL( listener2 ); |
|
182 |
|
183 // Tell the protocol it should act normally |
|
184 messenger->SetNoError(); |
|
185 |
|
186 // --------------------------------------------- |
|
187 // normal request complete |
|
188 TXIMPRequestId reqIdDummy; // not checked |
|
189 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
190 listener2->ExpectL( evReqComplete ); |
|
191 CleanupStack::Pop( evReqComplete ); |
|
192 |
|
193 // subscribe |
|
194 TXIMPRequestId reqId = presGroup.SubscribePresentityGroupListL(); |
|
195 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" ); |
|
196 messenger->AssertSubscribePresentityGroupListCalled( ETrue ); |
|
197 |
|
198 // --------------------------------------------- |
|
199 evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
200 listener2->ExpectL( evReqComplete ); |
|
201 CleanupStack::Pop( evReqComplete ); |
|
202 |
|
203 |
|
204 |
|
205 CPresentityGroupListEventImp* event = XIMPTestEventFactory::CreateGroupListEventLCX( |
|
206 KNullDesC, KNullDesC, |
|
207 XIMPTestEventFactory::ETestPGLEmpty, |
|
208 KNullDesC, KNullDesC, |
|
209 MXIMPDataSubscriptionState::ESubscriptionInactive, |
|
210 MXIMPDataSubscriptionState::EDataUnavailable |
|
211 ); |
|
212 |
|
213 listener2->ExpectL( event ); |
|
214 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
215 |
|
216 // unsubscribe |
|
217 // --------------------------------------------- |
|
218 reqId = presGroup.UnsubscribePresentityGroupListL(); |
|
219 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe failed" ); |
|
220 CleanupStack::PopAndDestroy( 4 ); // group list event imp |
|
221 messenger->AssertUnsubscribePresentityGroupListCalled( ETrue ); |
|
222 |
|
223 CleanupStack::PopAndDestroy( listener2 ); |
|
224 |
|
225 UnbindL(); |
|
226 } |
|
227 |
|
228 // Single client, empty filter, error in unsubscribe |
|
229 void T_PresenceGroupListManagement::T_UnsubscribePresentityGroup_Error_Single_L() |
|
230 { |
|
231 EUNIT_PRINT( _L("Single presentity group list unsubscribe with error") ); |
|
232 |
|
233 BindL(); |
|
234 |
|
235 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
236 MXIMPContext* context = wrapper->GetContext(); |
|
237 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
238 |
|
239 // Get the interfaces |
|
240 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
241 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
242 |
|
243 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
244 CleanupStack::PushL( listener2 ); |
|
245 |
|
246 // Tell the protocol it should act normally |
|
247 messenger->SetNoError(); |
|
248 |
|
249 // --------------------------------------------- |
|
250 // subscribe |
|
251 TXIMPRequestId reqIdDummy; // not checked |
|
252 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
253 listener2->ExpectL( evReqComplete ); |
|
254 CleanupStack::Pop( evReqComplete ); |
|
255 |
|
256 TXIMPRequestId reqId = presGroup.SubscribePresentityGroupListL(); |
|
257 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" ); |
|
258 messenger->AssertSubscribePresentityGroupListCalled( ETrue ); |
|
259 |
|
260 // --------------------------------------------- |
|
261 // unsubscribe |
|
262 messenger->SetError( KErrArgument ); |
|
263 evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
264 evReqComplete->CompletionResultImp().SetResultCode( KErrArgument ); |
|
265 listener2->ExpectL( evReqComplete ); |
|
266 CleanupStack::Pop( evReqComplete ); |
|
267 |
|
268 reqId = presGroup.UnsubscribePresentityGroupListL(); |
|
269 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe failed" ); |
|
270 messenger->AssertUnsubscribePresentityGroupListCalled( ETrue ); |
|
271 |
|
272 CleanupStack::PopAndDestroy( listener2 ); |
|
273 |
|
274 UnbindL(); |
|
275 } |
|
276 |
|
277 // Single client, empty filter, error in sub |
|
278 void T_PresenceGroupListManagement::T_SubscribePresentityGroup_Error_Single_L() |
|
279 { |
|
280 EUNIT_PRINT( _L("Single presentity group list subscribe with error") ); |
|
281 |
|
282 BindL(); |
|
283 |
|
284 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
285 MXIMPContext* context = wrapper->GetContext(); |
|
286 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
287 |
|
288 // Get the interfaces |
|
289 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
290 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
291 |
|
292 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
293 CleanupStack::PushL( listener2 ); |
|
294 |
|
295 // Tell the protocol it should act normally |
|
296 messenger->SetError( KErrArgument ); |
|
297 |
|
298 // --------------------------------------------- |
|
299 // subscribe |
|
300 TXIMPRequestId reqIdDummy; // not checked |
|
301 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
302 evReqComplete->CompletionResultImp().SetResultCode( KErrArgument ); |
|
303 listener2->ExpectL( evReqComplete ); |
|
304 CleanupStack::Pop( evReqComplete ); |
|
305 |
|
306 TXIMPRequestId reqId = presGroup.SubscribePresentityGroupListL(); |
|
307 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" ); |
|
308 messenger->AssertSubscribePresentityGroupListCalled( ETrue ); |
|
309 |
|
310 CleanupStack::PopAndDestroy( listener2 ); |
|
311 |
|
312 UnbindL(); |
|
313 } |
|
314 |
|
315 |
|
316 // multiple clients, all subscribe + unsubscribe |
|
317 void T_PresenceGroupListManagement::T_SubscribePresentityGroup_Multiple_L() |
|
318 { |
|
319 EUNIT_PRINT( _L("Multiple presentity group list subscription") ); |
|
320 |
|
321 BindAllL(); |
|
322 |
|
323 TInt countOfWrappers = iWrapperMgr->WrapperCount(); |
|
324 for( TInt a = 0; a < countOfWrappers; ++a ) |
|
325 { |
|
326 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( a ); |
|
327 MXIMPContext* context = wrapper->GetContext(); |
|
328 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
329 |
|
330 // Get the interfaces |
|
331 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
332 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
333 |
|
334 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
335 CleanupStack::PushL( listener2 ); |
|
336 |
|
337 // Tell the protocol it should act normally |
|
338 messenger->SetNoError(); |
|
339 |
|
340 // expect normal request complete |
|
341 TXIMPRequestId reqIdDummy; // not checked |
|
342 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
343 listener2->ExpectL( evReqComplete ); |
|
344 CleanupStack::Pop( evReqComplete ); |
|
345 |
|
346 // subscribe |
|
347 TXIMPRequestId reqId = presGroup.SubscribePresentityGroupListL(); |
|
348 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" ); |
|
349 messenger->AssertSubscribePresentityGroupListCalled( ETrue ); |
|
350 |
|
351 CleanupStack::PopAndDestroy( listener2 ); |
|
352 } |
|
353 |
|
354 for( TInt a = 0; a < countOfWrappers; ++a ) |
|
355 { |
|
356 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( a ); |
|
357 MXIMPContext* context = wrapper->GetContext(); |
|
358 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
359 |
|
360 // Get the interfaces |
|
361 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
362 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
363 |
|
364 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
365 CleanupStack::PushL( listener2 ); |
|
366 |
|
367 // Tell the protocol it should act normally |
|
368 messenger->SetNoError(); |
|
369 |
|
370 // expect normal request complete |
|
371 TXIMPRequestId reqIdDummy; // not checked |
|
372 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
373 listener2->ExpectL( evReqComplete ); |
|
374 CleanupStack::Pop( evReqComplete ); |
|
375 |
|
376 CPresentityGroupListEventImp* event = XIMPTestEventFactory::CreateGroupListEventLCX( |
|
377 KNullDesC, KNullDesC, |
|
378 XIMPTestEventFactory::ETestPGLEmpty, |
|
379 KNullDesC, KNullDesC, |
|
380 MXIMPDataSubscriptionState::ESubscriptionInactive, |
|
381 MXIMPDataSubscriptionState::EDataUnavailable |
|
382 ); |
|
383 |
|
384 listener2->ExpectL( event ); |
|
385 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
386 |
|
387 // unsubscribe |
|
388 TXIMPRequestId reqId = presGroup.UnsubscribePresentityGroupListL(); |
|
389 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe failed" ); |
|
390 CleanupStack::PopAndDestroy( 4 ); // group list event imp |
|
391 messenger->AssertUnsubscribePresentityGroupListCalled( a == countOfWrappers-1 ? ETrue : EFalse ); |
|
392 |
|
393 CleanupStack::PopAndDestroy( listener2 ); |
|
394 } |
|
395 |
|
396 UnbindAllL(); |
|
397 } |
|
398 |
|
399 // Multiple clients, all subscribe and refresh |
|
400 void T_PresenceGroupListManagement::T_RefreshPresentityGroup_Multiple_L() |
|
401 { |
|
402 EUNIT_PRINT( _L("Multiple presentity group list subscription refresh") ); |
|
403 |
|
404 BindAllL(); |
|
405 |
|
406 // SUBSCRIBE |
|
407 TInt countOfWrappers = iWrapperMgr->WrapperCount(); |
|
408 for( TInt a = 0; a < countOfWrappers; ++a ) |
|
409 { |
|
410 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( a ); |
|
411 MXIMPContext* context = wrapper->GetContext(); |
|
412 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
413 |
|
414 // Get the interfaces |
|
415 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
416 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
417 |
|
418 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
419 CleanupStack::PushL( listener2 ); |
|
420 |
|
421 // Tell the protocol it should act normally |
|
422 messenger->SetNoError(); |
|
423 |
|
424 // expect normal request complete |
|
425 TXIMPRequestId reqIdDummy; // not checked |
|
426 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
427 listener2->ExpectL( evReqComplete ); |
|
428 CleanupStack::Pop( evReqComplete ); |
|
429 |
|
430 // subscribe |
|
431 TXIMPRequestId reqId = presGroup.SubscribePresentityGroupListL(); |
|
432 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" ); |
|
433 messenger->AssertSubscribePresentityGroupListCalled( ETrue ); |
|
434 |
|
435 CleanupStack::PopAndDestroy( listener2 ); |
|
436 } |
|
437 |
|
438 // REFRESH |
|
439 for( TInt a = 0; a < countOfWrappers; ++a ) |
|
440 { |
|
441 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( a ); |
|
442 MXIMPContext* context = wrapper->GetContext(); |
|
443 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
444 |
|
445 // Get the interfaces |
|
446 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
447 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
448 |
|
449 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
450 CleanupStack::PushL( listener2 ); |
|
451 |
|
452 // Tell the protocol it should act normally |
|
453 messenger->SetNoError(); |
|
454 |
|
455 // refresh subscription |
|
456 TXIMPRequestId reqIdDummy; // not checked |
|
457 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
458 listener2->ExpectL( evReqComplete ); |
|
459 CleanupStack::Pop( evReqComplete ); |
|
460 |
|
461 CPresentityGroupListEventImp* event = XIMPTestEventFactory::CreateGroupListEventLCX( |
|
462 KNullDesC, KNullDesC, |
|
463 XIMPTestEventFactory::ETestPGLUpdated, |
|
464 KNullDesC, KNullDesC, |
|
465 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
466 MXIMPDataSubscriptionState::EDataUnavailable |
|
467 ); |
|
468 |
|
469 listener2->ExpectL( event ); |
|
470 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
471 |
|
472 TXIMPRequestId reqId = presGroup.SubscribePresentityGroupListL(); |
|
473 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" ); |
|
474 CleanupStack::PopAndDestroy( 4 ); // group list event imp |
|
475 messenger->AssertSubscribePresentityGroupListCalled( ETrue ); |
|
476 |
|
477 CleanupStack::PopAndDestroy( listener2 ); |
|
478 } |
|
479 |
|
480 // unsubscribe all |
|
481 for( TInt a = 0; a < countOfWrappers; ++a ) |
|
482 { |
|
483 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( a ); |
|
484 MXIMPContext* context = wrapper->GetContext(); |
|
485 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
486 |
|
487 // Get the interfaces |
|
488 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
489 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
490 |
|
491 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
492 CleanupStack::PushL( listener2 ); |
|
493 |
|
494 // Tell the protocol it should act normally |
|
495 messenger->SetNoError(); |
|
496 |
|
497 // expect normal request complete |
|
498 TXIMPRequestId reqIdDummy; // not checked |
|
499 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
500 listener2->ExpectL( evReqComplete ); |
|
501 CleanupStack::Pop( evReqComplete ); |
|
502 |
|
503 CPresentityGroupListEventImp* event = XIMPTestEventFactory::CreateGroupListEventLCX( |
|
504 KNullDesC, KNullDesC, |
|
505 XIMPTestEventFactory::ETestPGLEmpty, |
|
506 KNullDesC, KNullDesC, |
|
507 MXIMPDataSubscriptionState::ESubscriptionInactive, |
|
508 MXIMPDataSubscriptionState::EDataUnavailable |
|
509 ); |
|
510 |
|
511 listener2->ExpectL( event ); |
|
512 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
513 |
|
514 // unsubscribe |
|
515 TXIMPRequestId reqId = presGroup.UnsubscribePresentityGroupListL(); |
|
516 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe failed" ); |
|
517 CleanupStack::PopAndDestroy( 4 ); // group list event imp |
|
518 messenger->AssertUnsubscribePresentityGroupListCalled( a == countOfWrappers-1 ? ETrue : EFalse ); |
|
519 |
|
520 CleanupStack::PopAndDestroy( listener2 ); |
|
521 } |
|
522 |
|
523 UnbindAllL(); |
|
524 } |
|
525 |
|
526 |
|
527 // Multiple clients, all but one subscribe and all do unsubscribe |
|
528 void T_PresenceGroupListManagement::T_SubscribeAll_One_Unsub_Multiple_L() |
|
529 { |
|
530 EUNIT_PRINT( _L("Multiple, all but one subscribes and all unsubscribe") ); |
|
531 |
|
532 BindAllL(); |
|
533 |
|
534 // SUBSCRIBE |
|
535 TInt countOfWrappers = iWrapperMgr->WrapperCount(); |
|
536 TInt skipIndex = 1; |
|
537 for( TInt a = 0; a < countOfWrappers; ++a ) |
|
538 { |
|
539 if ( skipIndex != a ) |
|
540 { |
|
541 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( a ); |
|
542 MXIMPContext* context = wrapper->GetContext(); |
|
543 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
544 |
|
545 // Get the interfaces |
|
546 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
547 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
548 |
|
549 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
550 CleanupStack::PushL( listener2 ); |
|
551 |
|
552 // Tell the protocol it should act normally |
|
553 messenger->SetNoError(); |
|
554 |
|
555 // expect normal request complete |
|
556 TXIMPRequestId reqIdDummy; // not checked |
|
557 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
558 listener2->ExpectL( evReqComplete ); |
|
559 CleanupStack::Pop( evReqComplete ); |
|
560 |
|
561 // subscribe |
|
562 TXIMPRequestId reqId = presGroup.SubscribePresentityGroupListL(); |
|
563 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" ); |
|
564 messenger->AssertSubscribePresentityGroupListCalled( ETrue ); |
|
565 |
|
566 CleanupStack::PopAndDestroy( listener2 ); |
|
567 } |
|
568 } |
|
569 |
|
570 // unsubscribe all |
|
571 for( TInt a = 0; a < countOfWrappers; ++a ) |
|
572 { |
|
573 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( a ); |
|
574 MXIMPContext* context = wrapper->GetContext(); |
|
575 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
576 |
|
577 // Get the interfaces |
|
578 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
579 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
580 |
|
581 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
582 CleanupStack::PushL( listener2 ); |
|
583 |
|
584 // Tell the protocol it should act normally |
|
585 messenger->SetNoError(); |
|
586 |
|
587 // expect normal request complete |
|
588 TXIMPRequestId reqIdDummy; // not checked |
|
589 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
590 listener2->ExpectL( evReqComplete ); |
|
591 CleanupStack::Pop( evReqComplete ); |
|
592 |
|
593 CPresentityGroupListEventImp* event = XIMPTestEventFactory::CreateGroupListEventLCX( |
|
594 KNullDesC, KNullDesC, |
|
595 XIMPTestEventFactory::ETestPGLEmpty, |
|
596 KNullDesC, KNullDesC, |
|
597 MXIMPDataSubscriptionState::ESubscriptionInactive, |
|
598 MXIMPDataSubscriptionState::EDataUnavailable |
|
599 ); |
|
600 |
|
601 listener2->ExpectL( event ); |
|
602 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
603 |
|
604 // unsubscribe |
|
605 TXIMPRequestId reqId = presGroup.UnsubscribePresentityGroupListL(); |
|
606 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe failed" ); |
|
607 CleanupStack::PopAndDestroy( 4 ); // group list event imp |
|
608 |
|
609 messenger->AssertUnsubscribePresentityGroupListCalled( a == countOfWrappers-1 ? ETrue : EFalse ); |
|
610 |
|
611 CleanupStack::PopAndDestroy( listener2 ); |
|
612 } |
|
613 |
|
614 UnbindAllL(); |
|
615 } |
|
616 |
|
617 // Multiple clients, refresh case for one |
|
618 void T_PresenceGroupListManagement::T_RefreshPresentityGroup_One_Multiple_L() |
|
619 { |
|
620 EUNIT_PRINT( _L("Multiple, one context does presentity group list refresh") ); |
|
621 |
|
622 BindAllL(); |
|
623 |
|
624 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
625 MXIMPContext* context = wrapper->GetContext(); |
|
626 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
627 |
|
628 // Get the interfaces |
|
629 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
630 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
631 |
|
632 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
633 CleanupStack::PushL( listener2 ); |
|
634 |
|
635 // Tell the protocol it should act normally |
|
636 messenger->SetNoError(); |
|
637 |
|
638 // --------------------------------------------- |
|
639 // subscribe |
|
640 TXIMPRequestId reqIdDummy; // not checked |
|
641 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
642 listener2->ExpectL( evReqComplete ); |
|
643 CleanupStack::Pop( evReqComplete ); |
|
644 |
|
645 TXIMPRequestId reqId = presGroup.SubscribePresentityGroupListL(); |
|
646 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" ); |
|
647 messenger->AssertSubscribePresentityGroupListCalled( ETrue ); |
|
648 |
|
649 // --------------------------------------------- |
|
650 // refresh subscribe |
|
651 |
|
652 messenger->SetValueFor( |
|
653 EXIMPPlgTestSubscribeGroupListCalled, |
|
654 EFalse ); |
|
655 |
|
656 evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
657 listener2->ExpectL( evReqComplete ); |
|
658 CleanupStack::Pop( evReqComplete ); |
|
659 |
|
660 CPresentityGroupListEventImp* event = XIMPTestEventFactory::CreateGroupListEventLCX( |
|
661 KNullDesC, KNullDesC, |
|
662 XIMPTestEventFactory::ETestPGLUpdated, |
|
663 KNullDesC, KNullDesC, |
|
664 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
665 MXIMPDataSubscriptionState::EDataUnavailable |
|
666 ); |
|
667 |
|
668 listener2->ExpectL( event ); |
|
669 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
670 |
|
671 reqId = presGroup.SubscribePresentityGroupListL(); |
|
672 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe refresh failed" ); |
|
673 CleanupStack::PopAndDestroy( 4 ); // group list event imp |
|
674 messenger->AssertSubscribePresentityGroupListCalled( EFalse ); |
|
675 |
|
676 // --------------------------------------------- |
|
677 // unsubscribe |
|
678 evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
679 listener2->ExpectL( evReqComplete ); |
|
680 CleanupStack::Pop( evReqComplete ); |
|
681 |
|
682 event = XIMPTestEventFactory::CreateGroupListEventLCX( |
|
683 KNullDesC, KNullDesC, |
|
684 XIMPTestEventFactory::ETestPGLEmpty, |
|
685 KNullDesC, KNullDesC, |
|
686 MXIMPDataSubscriptionState::ESubscriptionInactive, |
|
687 MXIMPDataSubscriptionState::EDataUnavailable |
|
688 ); |
|
689 |
|
690 listener2->ExpectL( event ); |
|
691 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
692 |
|
693 reqId = presGroup.UnsubscribePresentityGroupListL(); |
|
694 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe failed" ); |
|
695 CleanupStack::PopAndDestroy( 4 ); // group list event imp |
|
696 messenger->AssertUnsubscribePresentityGroupListCalled( ETrue ); |
|
697 |
|
698 CleanupStack::PopAndDestroy( listener2 ); |
|
699 |
|
700 UnbindAllL(); |
|
701 } |
|
702 |
|
703 |
|
704 |
|
705 void T_PresenceGroupListManagement::SubscribeL() |
|
706 { |
|
707 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
708 MXIMPContext* context = wrapper->GetContext(); |
|
709 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
710 |
|
711 // Get the interfaces |
|
712 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
713 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
714 |
|
715 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
716 CleanupStack::PushL( listener2 ); |
|
717 |
|
718 // ------------------------------------------------------ |
|
719 // expect normal request complete |
|
720 TXIMPRequestId reqIdDummy; // not checked |
|
721 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
722 listener2->ExpectL( evReqComplete ); |
|
723 CleanupStack::Pop( evReqComplete ); |
|
724 // ------------------------------------------------------ |
|
725 |
|
726 // subscribe |
|
727 TXIMPRequestId reqId = presGroup.SubscribePresentityGroupListL(); |
|
728 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" ); |
|
729 messenger->AssertSubscribePresentityGroupListCalled( ETrue ); |
|
730 |
|
731 CleanupStack::PopAndDestroy( listener2 ); |
|
732 } |
|
733 |
|
734 |
|
735 |
|
736 void T_PresenceGroupListManagement::SubscribeGroupL( const TDesC& aGroupId ) |
|
737 { |
|
738 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
739 MXIMPContext* context = wrapper->GetContext(); |
|
740 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
741 |
|
742 // Get the interfaces |
|
743 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
744 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
745 |
|
746 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
747 CleanupStack::PushL( listener2 ); |
|
748 |
|
749 // ------------------------------------------------------ |
|
750 // expect normal request complete |
|
751 TXIMPRequestId reqIdDummy; // not checked |
|
752 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
753 listener2->ExpectL( evReqComplete ); |
|
754 CleanupStack::Pop( evReqComplete ); |
|
755 // ------------------------------------------------------ |
|
756 |
|
757 // subscribe group content |
|
758 MXIMPIdentity* identity = context->ObjectFactory().NewIdentityLC(); |
|
759 identity->SetIdentityL( aGroupId ); |
|
760 |
|
761 TXIMPRequestId reqId = presGroup.SubscribePresentityGroupContentL( *identity ); |
|
762 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe content failed" ); |
|
763 |
|
764 COMMONASSERT( messenger, EXIMPPlgTestSubscribePresentityGroupContentCalled, "SubscribeGroupContentL was not called", ETrue, NULL ); |
|
765 |
|
766 CleanupStack::PopAndDestroy(); // identity |
|
767 CleanupStack::PopAndDestroy( listener2 ); |
|
768 } |
|
769 |
|
770 |
|
771 |
|
772 void T_PresenceGroupListManagement::UnsubscribeL() |
|
773 { |
|
774 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
775 MXIMPContext* context = wrapper->GetContext(); |
|
776 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
777 |
|
778 // Get the interfaces |
|
779 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
780 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
781 |
|
782 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
783 CleanupStack::PushL( listener2 ); |
|
784 |
|
785 // ------------------------------------------------------ |
|
786 // expect normal request complete |
|
787 TXIMPRequestId reqIdDummy; // not checked |
|
788 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
789 listener2->ExpectL( evReqComplete ); |
|
790 CleanupStack::Pop( evReqComplete ); |
|
791 |
|
792 CPresentityGroupListEventImp* event = XIMPTestEventFactory::CreateGroupListEventLCX( |
|
793 KNullDesC, KNullDesC, |
|
794 XIMPTestEventFactory::ETestPGLEmpty, |
|
795 KNullDesC, KNullDesC, |
|
796 MXIMPDataSubscriptionState::ESubscriptionInactive, |
|
797 MXIMPDataSubscriptionState::EDataUnavailable |
|
798 ); |
|
799 |
|
800 listener2->ExpectL( event ); |
|
801 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
802 |
|
803 // unsubscribe |
|
804 TXIMPRequestId reqId = presGroup.UnsubscribePresentityGroupListL(); |
|
805 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe failed" ); |
|
806 CleanupStack::PopAndDestroy( 4 ); // group list event imp |
|
807 messenger->AssertUnsubscribePresentityGroupListCalled( ETrue ); |
|
808 |
|
809 CleanupStack::PopAndDestroy( listener2 ); |
|
810 } |
|
811 |
|
812 |
|
813 void T_PresenceGroupListManagement::UnsubscribeGroupL( const TDesC& aGroupId ) |
|
814 { |
|
815 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
816 MXIMPContext* context = wrapper->GetContext(); |
|
817 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
818 |
|
819 // Get the interfaces |
|
820 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
821 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
822 |
|
823 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
824 CleanupStack::PushL( listener2 ); |
|
825 |
|
826 // ------------------------------------------------------ |
|
827 // expect normal request complete |
|
828 TXIMPRequestId reqIdDummy; // not checked |
|
829 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
830 listener2->ExpectL( evReqComplete ); |
|
831 CleanupStack::Pop( evReqComplete ); |
|
832 |
|
833 // and a group content event, IF we have subscribed the group beforehand |
|
834 // i.e. SubscribeGroupL has been called before this |
|
835 |
|
836 MXIMPIdentity* identity = context->ObjectFactory().NewIdentityLC(); |
|
837 identity->SetIdentityL( aGroupId ); |
|
838 |
|
839 CPresentityGroupContentEventImp* groupCntEvent = |
|
840 XIMPTestEventFactory::CreateGroupContentEventLCX( |
|
841 aGroupId, |
|
842 KNullDesC, |
|
843 KNullDesC, |
|
844 XIMPTestEventFactory::ETestPGLCntRemoved, |
|
845 KNullDesC, |
|
846 KNullDesC, |
|
847 MXIMPDataSubscriptionState::ESubscriptionInactive, |
|
848 MXIMPDataSubscriptionState::EDataUnavailable |
|
849 ); |
|
850 |
|
851 listener2->ExpectL( groupCntEvent ); |
|
852 CleanupStack::Pop( groupCntEvent ); |
|
853 |
|
854 // ------------------------------------------------------ |
|
855 |
|
856 // unsubscribe |
|
857 |
|
858 TXIMPRequestId reqId = presGroup.UnsubscribePresentityGroupContentL( *identity ); |
|
859 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe group content failed" ); |
|
860 messenger->AssertUnsubscribePresentityGroupContentCalled( ETrue ); |
|
861 |
|
862 CleanupStack::PopAndDestroy( 5 ); // rest of the group content event |
|
863 CleanupStack::PopAndDestroy(); // identity |
|
864 |
|
865 CleanupStack::PopAndDestroy( listener2 ); |
|
866 } |
|
867 |
|
868 |
|
869 |
|
870 // Single client, empty filter |
|
871 void T_PresenceGroupListManagement::T_HandlePresentityGroupList_L() |
|
872 { |
|
873 EUNIT_PRINT( _L("Handle presentity group list.") ); |
|
874 |
|
875 // log in and subscribe a group list |
|
876 BindL(); |
|
877 SubscribeL(); |
|
878 |
|
879 // ------------------------------------------------------ |
|
880 // some startup stuff |
|
881 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
882 MXIMPContext* context = wrapper->GetContext(); |
|
883 |
|
884 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
885 CleanupStack::PushL( listener2 ); |
|
886 // ------------------------------------------------------ |
|
887 |
|
888 // Tell the protocol it should act normally |
|
889 wrapper->GetMessenger()->SetNoError(); |
|
890 |
|
891 // ------------------------------------------------------ |
|
892 // 1. Create faked server message about group list |
|
893 SendSrvMsgL( CXIMPTestFileSrvMsg::ETestSrvMsgPresentityGroupList ); |
|
894 |
|
895 // ------------------------------------------------------ |
|
896 // expect empty MPresentityGroupList event. |
|
897 |
|
898 CPresentityGroupListEventImp* event = XIMPTestEventFactory::CreateGroupListEventLCX( |
|
899 KNullDesC, KNullDesC, |
|
900 XIMPTestEventFactory::ETestPGLEmpty, |
|
901 KNullDesC, KNullDesC, |
|
902 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
903 MXIMPDataSubscriptionState::EDataAvailable |
|
904 ); |
|
905 |
|
906 listener2->ExpectL( event ); |
|
907 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
908 |
|
909 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "HandlePresentityGroupListL failed" ); |
|
910 CleanupStack::PopAndDestroy( 4 ); // lists |
|
911 // ------------------------------------------------------ |
|
912 |
|
913 CleanupStack::PopAndDestroy( listener2 ); |
|
914 |
|
915 // clean it up |
|
916 UnsubscribeL(); |
|
917 UnbindL(); |
|
918 } |
|
919 |
|
920 |
|
921 |
|
922 _LIT16( KPresentUri1, "http://lorem.ipsum.com" ); |
|
923 _LIT16( KPresentUri2, "http://carpe.diem.com" ); |
|
924 _LIT16( KPresentDispName1, "DispnameA, LoremI" ); |
|
925 _LIT16( KPresentDispName2, "DispnameB, CarpeD" ); |
|
926 _LIT16( KPresentProtAddr1, "ABC" ); |
|
927 _LIT16( KPresentProtAddr2, "HIJ" ); |
|
928 |
|
929 void T_PresenceGroupListManagement::T_HandlePresentityGroupCreateAndDelete_L() |
|
930 { |
|
931 EUNIT_PRINT( _L("Handle presentity group creation and deletion.") ); |
|
932 |
|
933 // log in and subscribe a group list |
|
934 BindL(); |
|
935 SubscribeL(); |
|
936 |
|
937 // ------------------------------------------------------ |
|
938 // some startup stuff |
|
939 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
940 MXIMPContext* context = wrapper->GetContext(); |
|
941 |
|
942 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
943 CleanupStack::PushL( listener2 ); |
|
944 // ------------------------------------------------------ |
|
945 |
|
946 // Tell the protocol it should act normally |
|
947 wrapper->GetMessenger()->SetNoError(); |
|
948 |
|
949 // ------------------------------------------------------ |
|
950 // 1. Create faked notification about create |
|
951 SendSrvMsgL( KPresentUri1, KPresentDispName1, |
|
952 CXIMPTestFileSrvMsg::ETestSrvMsgPresentityGroupCreate ); |
|
953 |
|
954 // ------------------------------------------------------ |
|
955 // expect MPresentityGroupList event. |
|
956 CPresentityGroupListEventImp* event = XIMPTestEventFactory::CreateGroupListEventLCX( |
|
957 KPresentUri1, KPresentDispName1, |
|
958 XIMPTestEventFactory::ETestPGLCreated, |
|
959 |
|
960 KPresentUri1, KPresentDispName1, |
|
961 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
962 MXIMPDataSubscriptionState::EDataAvailable |
|
963 ); |
|
964 |
|
965 listener2->ExpectL( event ); |
|
966 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
967 |
|
968 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "HandlePresentityGroupListL failed (Creation)" ); |
|
969 CleanupStack::PopAndDestroy( 4 ); // lists |
|
970 |
|
971 // ------------------------------------------------------ |
|
972 // Send a faked delete message |
|
973 |
|
974 SendSrvMsgL( KPresentUri1, KPresentDispName1, |
|
975 CXIMPTestFileSrvMsg::ETestSrvMsgPresentityGroupDelete ); |
|
976 |
|
977 // ------------------------------------------------------ |
|
978 // expect MPresentityGroupList event. |
|
979 |
|
980 event = XIMPTestEventFactory::CreateGroupListEventLCX( |
|
981 KPresentUri1, KNullDesC, |
|
982 XIMPTestEventFactory::ETestPGLDeleted, |
|
983 KNullDesC, KNullDesC, |
|
984 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
985 MXIMPDataSubscriptionState::EDataAvailable |
|
986 ); |
|
987 |
|
988 listener2->ExpectL( event ); |
|
989 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
990 |
|
991 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "HandlePresentityGroupListL failed (Deletion)" ); |
|
992 CleanupStack::PopAndDestroy( 4 ); // lists |
|
993 // ------------------------------------------------------ |
|
994 |
|
995 CleanupStack::PopAndDestroy( listener2 ); |
|
996 |
|
997 // unsubscribe group list and log out |
|
998 UnsubscribeL(); |
|
999 UnbindL(); |
|
1000 } |
|
1001 |
|
1002 // Single client, subscribed to the group, then subscribe list |
|
1003 void T_PresenceGroupListManagement::T_HandlePresentityGroupList_Subscribed_L() |
|
1004 { |
|
1005 EUNIT_PRINT( _L("Handle presentity group list, subscribed to the group.") ); |
|
1006 |
|
1007 // log in |
|
1008 BindL(); |
|
1009 SubscribeGroupL( KPresentUri1 ); |
|
1010 SubscribeL(); |
|
1011 |
|
1012 // ------------------------------------------------------ |
|
1013 // some startup stuff |
|
1014 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
1015 MXIMPContext* context = wrapper->GetContext(); |
|
1016 |
|
1017 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
1018 CleanupStack::PushL( listener2 ); |
|
1019 // ------------------------------------------------------ |
|
1020 |
|
1021 // Tell the protocol it should act normally |
|
1022 wrapper->GetMessenger()->SetNoError(); |
|
1023 |
|
1024 // ------------------------------------------------------ |
|
1025 // 1. Create faked server message about group list |
|
1026 SendSrvMsgL( KPresentUri1, |
|
1027 KPresentDispName1, |
|
1028 CXIMPTestFileSrvMsg::ETestSrvMsgPresentityGroupCreate ); |
|
1029 |
|
1030 // ------------------------------------------------------ |
|
1031 // expect empty MPresentityGroupList event. |
|
1032 |
|
1033 CPresentityGroupListEventImp* event = XIMPTestEventFactory::CreateGroupListEventLCX( |
|
1034 KPresentUri1, KPresentDispName1, |
|
1035 XIMPTestEventFactory::ETestPGLCreated, |
|
1036 KPresentUri1, KPresentDispName1, |
|
1037 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
1038 MXIMPDataSubscriptionState::EDataAvailable |
|
1039 ); |
|
1040 |
|
1041 listener2->ExpectL( event ); |
|
1042 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
1043 |
|
1044 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "HandlePresentityGroupListL failed" ); |
|
1045 CleanupStack::PopAndDestroy( 4 ); // lists |
|
1046 // ------------------------------------------------------ |
|
1047 |
|
1048 CleanupStack::PopAndDestroy( listener2 ); |
|
1049 |
|
1050 // clean it up |
|
1051 UnsubscribeL(); |
|
1052 UnsubscribeGroupL( KPresentUri1 ); |
|
1053 UnbindL(); |
|
1054 } |
|
1055 |
|
1056 void T_PresenceGroupListManagement::T_HandlePresentityGroupUpdate_L() |
|
1057 { |
|
1058 EUNIT_PRINT( _L("Handle presentity group displayname update.") ); |
|
1059 |
|
1060 // log in and subscribe a group list |
|
1061 BindL(); |
|
1062 SubscribeL(); |
|
1063 |
|
1064 // ------------------------------------------------------ |
|
1065 // some startup stuff |
|
1066 |
|
1067 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
1068 MXIMPContext* context = wrapper->GetContext(); |
|
1069 |
|
1070 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
1071 CleanupStack::PushL( listener2 ); |
|
1072 // ------------------------------------------------------ |
|
1073 |
|
1074 // Tell the protocol it should act normally |
|
1075 wrapper->GetMessenger()->SetNoError(); |
|
1076 |
|
1077 // ------------------------------------------------------ |
|
1078 // 1. Create faked notification about create |
|
1079 SendSrvMsgL( KPresentUri1, KPresentDispName1, |
|
1080 CXIMPTestFileSrvMsg::ETestSrvMsgPresentityGroupCreate ); |
|
1081 |
|
1082 // ------------------------------------------------------ |
|
1083 // expect MPresentityGroupList event. |
|
1084 |
|
1085 CPresentityGroupListEventImp* event = XIMPTestEventFactory::CreateGroupListEventLCX( |
|
1086 KPresentUri1, KPresentDispName1, |
|
1087 XIMPTestEventFactory::ETestPGLCreated, |
|
1088 KPresentUri1, KPresentDispName1, |
|
1089 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
1090 MXIMPDataSubscriptionState::EDataAvailable |
|
1091 ); |
|
1092 |
|
1093 listener2->ExpectL( event ); |
|
1094 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
1095 |
|
1096 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "HandlePresentityGroupListL failed (Creation)" ); |
|
1097 CleanupStack::PopAndDestroy( 4 ); // lists |
|
1098 |
|
1099 // ------------------------------------------------------ |
|
1100 // 4. Change displayname of group and send faked notification about |
|
1101 // update |
|
1102 |
|
1103 SendSrvMsgL( KPresentUri1, KPresentDispName2, |
|
1104 CXIMPTestFileSrvMsg::ETestSrvMsgPresentityGroupUpdate ); |
|
1105 |
|
1106 // ------------------------------------------------------ |
|
1107 // expect MPresentityGroupList event. |
|
1108 |
|
1109 event = XIMPTestEventFactory::CreateGroupListEventLCX( |
|
1110 KPresentUri1, KPresentDispName2, |
|
1111 XIMPTestEventFactory::ETestPGLUpdated, |
|
1112 KPresentUri1, KPresentDispName2, |
|
1113 MXIMPDataSubscriptionState::ESubscriptionActive, |
|
1114 MXIMPDataSubscriptionState::EDataAvailable |
|
1115 ); |
|
1116 |
|
1117 listener2->ExpectL( event ); |
|
1118 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
1119 |
|
1120 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "HandlePresentityGroupListL failed (Update)" ); |
|
1121 CleanupStack::PopAndDestroy( 4 ); // lists |
|
1122 // ------------------------------------------------------ |
|
1123 |
|
1124 CleanupStack::PopAndDestroy( listener2 ); |
|
1125 |
|
1126 // unsubscribe group list and log out |
|
1127 UnsubscribeL(); |
|
1128 UnbindL(); |
|
1129 } |
|
1130 |
|
1131 // =========================================================================== |
|
1132 // SETUP HELPERS FOR THE LISTENER |
|
1133 // =========================================================================== |
|
1134 // |
|
1135 |
|
1136 // send a faked server-originated message with group info made |
|
1137 // from the given uri and displayname |
|
1138 // |
|
1139 void T_PresenceGroupListManagement::SendSrvMsgL( |
|
1140 const TDesC& aUri, const TDesC& aDispName, |
|
1141 TInt aMsgType ) |
|
1142 { |
|
1143 // we'll use hard-coded wrapper 0 instance for now. |
|
1144 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
1145 |
|
1146 // create a group info contained within the server-originated |
|
1147 // faked message |
|
1148 CXIMPIdentityImp* groupId = CXIMPIdentityImp::NewLC( aUri ); |
|
1149 CPresentityGroupInfoImp* groupItem = CPresentityGroupInfoImp::NewLC( *groupId, aDispName ); |
|
1150 HBufC8* packet = NULL; |
|
1151 if( aMsgType == CXIMPTestFileSrvMsg::ETestSrvMsgPresentityGroupDelete ) |
|
1152 { |
|
1153 packet = TXIMPObjectPacker< CXIMPIdentityImp >::PackL( *groupId ); |
|
1154 } |
|
1155 else |
|
1156 { |
|
1157 packet = TXIMPObjectPacker< CPresentityGroupInfoImp >::PackL( *groupItem ); |
|
1158 } |
|
1159 CleanupStack::PushL( packet ); |
|
1160 |
|
1161 // use filetool to send it for plugin. |
|
1162 CXIMPTestFileSrvMsg* srvMsg = CXIMPTestFileSrvMsg::NewL( aMsgType, *packet ); |
|
1163 CleanupStack::PushL( srvMsg ); |
|
1164 wrapper->FileTool().CleanAllL(); |
|
1165 wrapper->FileTool().SrvMsgStoreL( srvMsg ); |
|
1166 CleanupStack::PopAndDestroy( 4, groupId ); // srvMsg, packet, groupItem, groupId |
|
1167 } |
|
1168 |
|
1169 // send a faked server-originated message with empty contents |
|
1170 // |
|
1171 void T_PresenceGroupListManagement::SendSrvMsgL( TInt aMsgType ) |
|
1172 { |
|
1173 // we'll use hard-coded wrapper 0 instance for now. |
|
1174 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
1175 |
|
1176 // create a server-originated faked message with empty contents |
|
1177 RXIMPObjOwningPtrArray<CPresentityGroupInfoImp> groupList; |
|
1178 |
|
1179 HBufC8* packedArray = TXIMPObjectPacker<CPresentityGroupInfoImp>::PackArrayL( groupList ); |
|
1180 CleanupStack::PushL( packedArray ); |
|
1181 |
|
1182 // use filetool to send it for plugin. |
|
1183 CXIMPTestFileSrvMsg* srvMsg = CXIMPTestFileSrvMsg::NewL( aMsgType, |
|
1184 *packedArray ); |
|
1185 CleanupStack::PushL( srvMsg ); |
|
1186 wrapper->FileTool().CleanAllL(); |
|
1187 wrapper->FileTool().SrvMsgStoreL( srvMsg ); |
|
1188 CleanupStack::PopAndDestroy( 2 ); // srvMsg, packedArray |
|
1189 } |
|
1190 |
|
1191 // update display name of group without having subscribed to it |
|
1192 void T_PresenceGroupListManagement::T_UpdateDisplayNameL( |
|
1193 const TDesC& aGroupId, |
|
1194 const TDesC& aDispName ) |
|
1195 { |
|
1196 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
1197 MXIMPContext* context = wrapper->GetContext(); |
|
1198 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
1199 |
|
1200 // Get the interfaces |
|
1201 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
1202 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
1203 |
|
1204 wrapper->GetMessenger()->SetNoError(); |
|
1205 |
|
1206 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
1207 CleanupStack::PushL( listener2 ); |
|
1208 |
|
1209 MXIMPIdentity* groupId = context->ObjectFactory().NewIdentityLC(); |
|
1210 groupId->SetIdentityL( aGroupId ); |
|
1211 |
|
1212 // ------------------------------------------------------ |
|
1213 // expect request complete with a group info imp inside |
|
1214 TXIMPRequestId reqIdDummy; // not checked |
|
1215 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
1216 |
|
1217 CPresentityGroupInfoImp* grpInfo = CPresentityGroupInfoImp::NewLC( |
|
1218 *groupId, |
|
1219 aDispName ); |
|
1220 |
|
1221 evReqComplete->AppendParamL( grpInfo ); |
|
1222 CleanupStack::Pop(); // grpInfo |
|
1223 |
|
1224 listener2->ExpectL( evReqComplete ); |
|
1225 CleanupStack::Pop( evReqComplete ); |
|
1226 |
|
1227 // ------------------------------------------------------ |
|
1228 // update |
|
1229 TXIMPRequestId reqId = presGroup.UpdatePresentityGroupDisplayNameL( |
|
1230 *groupId, |
|
1231 aDispName ); |
|
1232 |
|
1233 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe group content failed" ); |
|
1234 |
|
1235 messenger->AssertUpdatePresentityGroupDisplayNameCalled( ETrue ); |
|
1236 |
|
1237 CleanupStack::PopAndDestroy(); // groupId |
|
1238 CleanupStack::PopAndDestroy( listener2 ); |
|
1239 } |
|
1240 |
|
1241 |
|
1242 // test method for updating display name of group without having subscribed |
|
1243 // to it |
|
1244 void T_PresenceGroupListManagement::T_UpdateDisplayName_Single_L() |
|
1245 { |
|
1246 EUNIT_PRINT( _L("Update presentity group displayname, single.") ); |
|
1247 |
|
1248 BindL(); |
|
1249 |
|
1250 T_UpdateDisplayNameL( KPresentUri1, KPresentDispName1 ); |
|
1251 |
|
1252 UnbindL(); |
|
1253 } |
|
1254 |
|
1255 |
|
1256 |
|
1257 // Single client, unsubscribe nonsubscribed |
|
1258 void T_PresenceGroupListManagement::T_UnsubNonsubscribed_Single_L() |
|
1259 { |
|
1260 EUNIT_PRINT( _L("Single unsubscribe nonsubscribed") ); |
|
1261 |
|
1262 BindL(); |
|
1263 |
|
1264 CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 ); |
|
1265 MXIMPContext* context = wrapper->GetContext(); |
|
1266 CXIMPTestMessenger* messenger = wrapper->GetMessenger(); |
|
1267 |
|
1268 // Get the interfaces |
|
1269 MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures(); |
|
1270 MPresentityGroups& presGroup = presFeat->PresentityGroups(); |
|
1271 |
|
1272 CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context ); |
|
1273 CleanupStack::PushL( listener2 ); |
|
1274 |
|
1275 // Tell the protocol it should act normally |
|
1276 messenger->SetNoError(); |
|
1277 |
|
1278 // --------------------------------------------- |
|
1279 // unsubscribe |
|
1280 TXIMPRequestId reqIdDummy; // not checked |
|
1281 CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy ); |
|
1282 listener2->ExpectL( evReqComplete ); |
|
1283 CleanupStack::Pop( evReqComplete ); |
|
1284 |
|
1285 // group list event with Unsubscribed |
|
1286 CPresentityGroupListEventImp* event = XIMPTestEventFactory::CreateGroupListEventLCX( |
|
1287 KNullDesC, KNullDesC, |
|
1288 XIMPTestEventFactory::ETestPGLEmpty, |
|
1289 |
|
1290 KNullDesC, KNullDesC, |
|
1291 MXIMPDataSubscriptionState::ESubscriptionInactive, |
|
1292 MXIMPDataSubscriptionState::EDataUnavailable |
|
1293 ); |
|
1294 |
|
1295 listener2->ExpectL( event ); |
|
1296 CleanupStack::Pop( event ); // 4 more items in cleanupstack |
|
1297 |
|
1298 TXIMPRequestId reqId = presGroup.UnsubscribePresentityGroupListL(); |
|
1299 EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe failed" ); |
|
1300 CleanupStack::PopAndDestroy( 4 ); // rest of the group list event |
|
1301 messenger->AssertUnsubscribePresentityGroupListCalled( EFalse ); // should not be called, no subscriptions |
|
1302 |
|
1303 CleanupStack::PopAndDestroy( listener2 ); |
|
1304 |
|
1305 UnbindL(); |
|
1306 } |
|
1307 |
|
1308 // =========================================================================== |
|
1309 // TEST CASE TABLE |
|
1310 // =========================================================================== |
|
1311 // |
|
1312 EUNIT_BEGIN_TEST_TABLE( |
|
1313 T_PresenceGroupListManagement, |
|
1314 "XIMP presence group list management tests", |
|
1315 "MODULE" ) |
|
1316 |
|
1317 PRFW_DECORATED_TEST( |
|
1318 "Subscribe single presence", |
|
1319 "", |
|
1320 "", |
|
1321 "FUNCTIONALITY", |
|
1322 Setup_L, |
|
1323 T_SubscribePresentityGroup_Single_L, |
|
1324 Teardown ) |
|
1325 |
|
1326 PRFW_DECORATED_TEST( |
|
1327 "Subscribe single presence with error", |
|
1328 "", |
|
1329 "", |
|
1330 "FUNCTIONALITY", |
|
1331 Setup_L, |
|
1332 T_SubscribePresentityGroup_Error_Single_L, |
|
1333 Teardown ) |
|
1334 |
|
1335 PRFW_DECORATED_TEST( |
|
1336 "Unsubscribe single presence with error", |
|
1337 "", |
|
1338 "", |
|
1339 "FUNCTIONALITY", |
|
1340 Setup_L, |
|
1341 T_UnsubscribePresentityGroup_Error_Single_L, |
|
1342 Teardown ) |
|
1343 |
|
1344 PRFW_DECORATED_TEST( |
|
1345 "Unsubscribe nonsubscribed", |
|
1346 "", |
|
1347 "", |
|
1348 "FUNCTIONALITY", |
|
1349 Setup_L, |
|
1350 T_UnsubNonsubscribed_Single_L, |
|
1351 Teardown ) |
|
1352 |
|
1353 PRFW_DECORATED_TEST( |
|
1354 "Subscribe multiple presence", |
|
1355 "", |
|
1356 "", |
|
1357 "FUNCTIONALITY", |
|
1358 SetupMultiple_L, |
|
1359 T_SubscribePresentityGroup_Multiple_L, |
|
1360 Teardown ) |
|
1361 |
|
1362 PRFW_DECORATED_TEST( |
|
1363 "Multiple subscribe all but one, unsub all", |
|
1364 "", |
|
1365 "", |
|
1366 "FUNCTIONALITY", |
|
1367 SetupMultiple_L, |
|
1368 T_SubscribeAll_One_Unsub_Multiple_L, |
|
1369 Teardown ) |
|
1370 |
|
1371 PRFW_DECORATED_TEST( |
|
1372 "Single refresh multiple presence", |
|
1373 "", |
|
1374 "", |
|
1375 "FUNCTIONALITY", |
|
1376 SetupMultiple_L, |
|
1377 T_RefreshPresentityGroup_One_Multiple_L, |
|
1378 Teardown ) |
|
1379 |
|
1380 PRFW_DECORATED_TEST( |
|
1381 "Multiple refresh presence", |
|
1382 "", |
|
1383 "", |
|
1384 "FUNCTIONALITY", |
|
1385 SetupMultiple_L, |
|
1386 T_RefreshPresentityGroup_Multiple_L, |
|
1387 Teardown ) |
|
1388 |
|
1389 PRFW_DECORATED_TEST( |
|
1390 "Handle Presentity Group List", |
|
1391 "", |
|
1392 "", |
|
1393 "FUNCTIONALITY", |
|
1394 Setup_L, |
|
1395 T_HandlePresentityGroupList_L, |
|
1396 Teardown ) |
|
1397 |
|
1398 PRFW_DECORATED_TEST( |
|
1399 "Handle Presentity Group List (subscribed group)", |
|
1400 "", |
|
1401 "", |
|
1402 "FUNCTIONALITY", |
|
1403 Setup_L, |
|
1404 T_HandlePresentityGroupList_Subscribed_L, |
|
1405 Teardown ) |
|
1406 |
|
1407 PRFW_DECORATED_TEST( |
|
1408 "Create and delete group.", |
|
1409 "", |
|
1410 "", |
|
1411 "FUNCTIONALITY", |
|
1412 Setup_L, |
|
1413 T_HandlePresentityGroupCreateAndDelete_L, |
|
1414 Teardown ) |
|
1415 |
|
1416 PRFW_DECORATED_TEST( |
|
1417 "Handle update displayname", |
|
1418 "", |
|
1419 "", |
|
1420 "FUNCTIONALITY", |
|
1421 Setup_L, |
|
1422 T_HandlePresentityGroupUpdate_L, |
|
1423 Teardown ) |
|
1424 |
|
1425 PRFW_DECORATED_TEST( |
|
1426 "Update displayname", |
|
1427 "", |
|
1428 "", |
|
1429 "FUNCTIONALITY", |
|
1430 Setup_L, |
|
1431 T_UpdateDisplayName_Single_L, |
|
1432 Teardown ) |
|
1433 |
|
1434 EUNIT_END_TEST_TABLE |
|
1435 |
|
1436 |
|
1437 // =========================================================================== |
|
1438 // TEST SUITE CONSTRUCTION |
|
1439 // =========================================================================== |
|
1440 // |
|
1441 EXPORT_C MEUnitTest* CreateTestSuiteL() |
|
1442 { |
|
1443 return T_PresenceGroupListManagement::NewL(); |
|
1444 } |
|
1445 |
|
1446 |
|
1447 // end of file |