ximpfw/tsrc/src/t_presencegroupmembermngt/t_presencegroupmembermngt.cpp
changeset 0 e6b17d312c8b
child 41 eedf17a17c27
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     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 #include <e32std.h>
       
    25 
       
    26 #include <ximpclient.h>
       
    27 #include <ximpcontext.h>
       
    28 #include <ximpobjectfactory.h>
       
    29 #include <ximpcontextstateevent.h>
       
    30 #include <ximprequestcompleteevent.h>
       
    31 #include <ximpstatus.h>
       
    32 #include <presencefeatures.h>
       
    33 #include <presentitygroups.h>
       
    34 #include <presentitygroupmemberinfo.h>
       
    35 #include <presentitygroupcontentevent.h>
       
    36 
       
    37 
       
    38 #include "ximpeventcodec.h"
       
    39 
       
    40 #include "t_presencegroupmembermngt.h"
       
    41 #include "prfwteststatuseventlistener.h"
       
    42 #include "prfwtestmessaging.h"
       
    43 #include "prfwtestmessenger.h"
       
    44 #include "prfwtestlistener.h"
       
    45 #include "prfwtestcontextwrappermgr.h"
       
    46 #include "prfwtestcontextwrapper.h"
       
    47 #include "ximpcontextstateeventimp.h"
       
    48 #include "ximpcontextstateevent.h"
       
    49 
       
    50 #include "presenceinfoimp.h"
       
    51 #include "presenceinfofilterimp.h"
       
    52 #include "prfwtestpresencedatautils.h"
       
    53 #include "ximpidentityimp.h"
       
    54 #include "presentitygroupcontenteventimp.h"
       
    55 #include "ximprequestcompleteeventimp.h"
       
    56 #include "presentitygroupinfoimp.h"
       
    57 #include "presentitygrouplisteventimp.h"
       
    58 #include "presentitygroupmemberinfoimp.h"
       
    59 #include "ximprequestcompleteeventimp.h"
       
    60 #include "ximprestrictedobjectcollection.h"
       
    61 #include "ximpobjectfactoryimp.h"
       
    62 
       
    63 #include "prfwtestrobustnesstools.h"
       
    64 #include "ximpobjecthelpers.h"
       
    65 #include "prfwtestfilesrvmsg.h"
       
    66 #include "prfwtestfiletool.h"
       
    67 #include "prfwtestwaithelper.h"
       
    68 #include "prfwtesteventfactory.h"
       
    69 
       
    70 
       
    71 _LIT( KGroupId,   "wv:group/member@imps.com" );
       
    72 _LIT( KGroupId2,  "wv:group2/chutney@naan.com" );
       
    73 _LIT( KGroupDisplayName, "Salamapartio Z" );
       
    74 
       
    75 _LIT( KMemberId, "wv:member@imps.com" );
       
    76 _LIT( KMemberDisplayName,  "Stroustrup" );
       
    77 _LIT( KMemberDisplayName2, "Bjarne" );
       
    78 
       
    79 // ============================ MEMBER FUNCTIONS ===============================
       
    80 
       
    81 // CONSTRUCTION
       
    82 T_PresenceGroupMemberManagement* T_PresenceGroupMemberManagement::NewL()
       
    83     {
       
    84     T_PresenceGroupMemberManagement* self = new( ELeave ) T_PresenceGroupMemberManagement;
       
    85     CleanupStack::PushL( self );
       
    86     self->ConstructL();
       
    87     CleanupStack::Pop( self );
       
    88 
       
    89     return self;
       
    90     }
       
    91 
       
    92 T_PresenceGroupMemberManagement::~T_PresenceGroupMemberManagement()
       
    93     {
       
    94     delete iLastEvent;
       
    95 
       
    96     if ( iASWait && iASWait->IsStarted() )
       
    97         {
       
    98         iASWait->AsyncStop();
       
    99         }
       
   100     delete iASWait;
       
   101 
       
   102     delete iListener2;
       
   103 
       
   104     delete iCurrentGrId;
       
   105     }
       
   106 
       
   107 void T_PresenceGroupMemberManagement::ConstructL()
       
   108     {
       
   109     CEUnitTestSuiteClass::ConstructL();
       
   110     iASWait = new ( ELeave ) CActiveSchedulerWait();
       
   111     }
       
   112 
       
   113 
       
   114 T_PresenceGroupMemberManagement::T_PresenceGroupMemberManagement()
       
   115     {
       
   116     }
       
   117 
       
   118 // ===========================================================================
       
   119 // TEST CASE SETUP & TEARDOWN METHODS
       
   120 // ===========================================================================
       
   121 //
       
   122 
       
   123 void T_PresenceGroupMemberManagement::Setup_L()
       
   124     {
       
   125     PrfwTestRobustness::DoPreCleaning();
       
   126 
       
   127     iWrapperMgr = CXIMPTestContextWrapperMgr::NewL();
       
   128     iWrapperMgr->CreateWrapperL();
       
   129 
       
   130     // must reset these to EFalse
       
   131     iSkipSubscribe = EFalse;
       
   132     iSkipUnsubscribe = EFalse;
       
   133     }
       
   134 
       
   135 void T_PresenceGroupMemberManagement::SetupMultiple_L()
       
   136     {
       
   137     PrfwTestRobustness::DoPreCleaning();
       
   138 
       
   139     iWrapperMgr = CXIMPTestContextWrapperMgr::NewL();
       
   140     iWrapperMgr->CreateWrapperL();
       
   141     iWrapperMgr->CreateWrapperL();
       
   142     iWrapperMgr->CreateWrapperL();
       
   143 
       
   144     // must reset these to EFalse
       
   145     iSkipSubscribe = EFalse;
       
   146     iSkipUnsubscribe = EFalse;
       
   147     }
       
   148 
       
   149 // bind helper
       
   150 void T_PresenceGroupMemberManagement::BindAllL()
       
   151     {
       
   152     for( TInt a = 0; a < iWrapperMgr->WrapperCount(); ++a )
       
   153         {
       
   154         CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( a );
       
   155         wrapper->BindL( 0 );
       
   156         }
       
   157     }
       
   158 
       
   159 // unbind helper
       
   160 void T_PresenceGroupMemberManagement::UnbindAllL()
       
   161     {
       
   162     for( TInt a = 0; a < iWrapperMgr->WrapperCount(); ++a )
       
   163         {
       
   164         CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( a );
       
   165         wrapper->UnbindL();
       
   166         }
       
   167     }
       
   168 
       
   169 void T_PresenceGroupMemberManagement::TeardownTestSupport()
       
   170     {
       
   171     // anything NOT initialized by test case Setup method,
       
   172     // but initialized in the test case itself, goes here
       
   173     delete iCurrentGrId;
       
   174     iCurrentGrId = NULL;
       
   175 
       
   176     delete iListener2;
       
   177     iListener2 = NULL;
       
   178 
       
   179     delete iLastEvent;
       
   180     iLastEvent = NULL;
       
   181     }
       
   182 
       
   183 void T_PresenceGroupMemberManagement::Teardown()
       
   184     {
       
   185     TeardownTestSupport();
       
   186     // just in case to avoid memleaks. should not have anything to
       
   187     // delete anyway
       
   188 
       
   189     delete iWrapperMgr;
       
   190     iWrapperMgr = NULL;
       
   191 
       
   192     REComSession::FinalClose();
       
   193 
       
   194     // must reset these to EFalse
       
   195     iSkipSubscribe = EFalse;
       
   196     iSkipUnsubscribe = EFalse;
       
   197 
       
   198     // it's best to nuke the servers during exit too.
       
   199     PrfwTestRobustness::DoPreCleaning();
       
   200     }
       
   201 
       
   202 // ===========================================================================
       
   203 // TEST CASES for presentity presence subscription
       
   204 // ===========================================================================
       
   205 
       
   206 // General test case for single member
       
   207 void T_PresenceGroupMemberManagement::T_GenericSubAndUnsubL(
       
   208         TXIMPCallBack& aCbFuncL )
       
   209     {
       
   210     CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
       
   211     wrapper->BindL( 0 );
       
   212 
       
   213     // ------------------------------------------------------
       
   214     // some startup stuff
       
   215     MXIMPContext* context = wrapper->GetContext();
       
   216     CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
   217 
       
   218     // Get the interfaces
       
   219     MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
   220     MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
   221 
       
   222     iListener2 = CXIMPTestListener::NewL( context );
       
   223     // ------------------------------------------------------
       
   224 
       
   225     // Tell the protocol it should act normally
       
   226     wrapper->GetMessenger()->SetNoError();
       
   227 
       
   228     iCurrentGrId = context->ObjectFactory().NewIdentityLC();
       
   229     CleanupStack::Pop(); // iCurrentGrId
       
   230     iCurrentGrId->SetIdentityL( KGroupId );
       
   231 
       
   232     // ------------------------------------------------------
       
   233     // create presentity group
       
   234     //
       
   235     // expect events:
       
   236     // - request complete.
       
   237     // NOTE: no presentitygrouplistevent as we've not subscribed the group lists
       
   238 
       
   239     // normal request complete
       
   240     TXIMPRequestId reqIdDummy;  // not checked
       
   241     CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
   242 
       
   243     // identity + displayname
       
   244     CPresentityGroupInfoImp* infoImp = CPresentityGroupInfoImp::NewLC( *iCurrentGrId, KGroupDisplayName );
       
   245     evReqComplete->AppendParamL( infoImp );
       
   246     CleanupStack::Pop( infoImp );
       
   247 
       
   248     iListener2->ExpectL( evReqComplete );
       
   249     CleanupStack::Pop( evReqComplete );
       
   250 
       
   251     TXIMPRequestId reqId = presGroup.CreatePresentityGroupL( *iCurrentGrId, KGroupDisplayName );
       
   252 
       
   253     // and wait
       
   254     EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "CreatePresentityGroupL failed" );
       
   255     messenger->AssertCreatePresentityGroupCalled( ETrue );
       
   256 
       
   257     if ( ! iSkipSubscribe )
       
   258         {
       
   259         // ------------------------------------------------------
       
   260         // subscribe presentity group CONTENT
       
   261         //
       
   262         // expect events:
       
   263         // - request complete
       
   264         evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
   265         iListener2->ExpectL( evReqComplete );
       
   266         CleanupStack::Pop( evReqComplete );
       
   267 
       
   268         // do the call
       
   269         reqId = presGroup.SubscribePresentityGroupContentL( *iCurrentGrId );
       
   270 
       
   271         // and wait
       
   272         EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "SubscribePresentityGroupContentL failed" );
       
   273 
       
   274         // verify that subscribe was called
       
   275         messenger->AssertSubscribePresentityGroupContentCalled( ETrue );
       
   276         }
       
   277 
       
   278     // ------------------------------------------------------
       
   279     // do the actual test. this is a function pointer because the
       
   280     // "red tape" of each test is similar (create group, subscribe content, do
       
   281     // actual test, unsubscribe content, delete group) - this is the variable
       
   282     // part, the "do actual test".
       
   283     (this->*aCbFuncL)();
       
   284 
       
   285     if ( ! iSkipUnsubscribe )
       
   286         {
       
   287         // ------------------------------------------------------
       
   288         // unsubscribe presentity group content
       
   289         //
       
   290         // expect events:
       
   291         // - request complete
       
   292         // - presentity group content event
       
   293 
       
   294         evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
   295         iListener2->ExpectL( evReqComplete );
       
   296         CleanupStack::Pop( evReqComplete );
       
   297 
       
   298         CPresentityGroupContentEventImp* groupCntEvent =
       
   299             XIMPTestEventFactory::CreateGroupContentEventLCX(
       
   300                     KGroupId,
       
   301                     KNullDesC,
       
   302                     KNullDesC,
       
   303                     XIMPTestEventFactory::ETestPGLCntRemoved,
       
   304                     KNullDesC,
       
   305                     KNullDesC,
       
   306                     MXIMPDataSubscriptionState::ESubscriptionInactive,
       
   307                     MXIMPDataSubscriptionState::EDataUnavailable
       
   308                     );
       
   309 
       
   310         iListener2->ExpectL( groupCntEvent );
       
   311         CleanupStack::Pop( groupCntEvent ); // 5 more items in cleanupstack
       
   312 
       
   313         // do the call
       
   314         reqId = presGroup.UnsubscribePresentityGroupContentL( *iCurrentGrId );
       
   315 
       
   316         // and wait
       
   317         EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "UnsubscribePresentityGroupContentL failed" );
       
   318         CleanupStack::PopAndDestroy( 5 ); // lists
       
   319 
       
   320         // verify that unsubscribe was called
       
   321         messenger->AssertUnsubscribePresentityGroupContentCalled( ETrue );
       
   322         }
       
   323 
       
   324     // ------------------------------------------------------
       
   325     // delete presentity group
       
   326     //
       
   327     // expect events:
       
   328     // - request complete
       
   329     // NO presentity group content event as we've just unsubscribed it.
       
   330 
       
   331     evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
   332     iListener2->ExpectL( evReqComplete );
       
   333     CleanupStack::Pop( evReqComplete );
       
   334 
       
   335     // do the call
       
   336     reqId = presGroup.DeletePresentityGroupL( *iCurrentGrId );
       
   337 
       
   338     // and wait
       
   339     EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "DeletePresentityGroupL failed" );
       
   340 
       
   341     // ------------------------------------------------------
       
   342 
       
   343     // make sure the new listener is not listening for events!
       
   344     iListener2->SetEventSourceL( NULL );
       
   345 
       
   346     wrapper->UnbindL();
       
   347 
       
   348     TeardownTestSupport();
       
   349     }
       
   350 
       
   351 // ===========================================================================
       
   352 // Variant methods, this is where the actual testing happens.
       
   353 // Called by the generic subscribe and unsubscribe -method
       
   354 // ===========================================================================
       
   355 
       
   356 // ------------------------------------------------------
       
   357 // empty test variant method
       
   358 // test only the creation, subscribe and unsubcscribe
       
   359 // ------------------------------------------------------
       
   360 //
       
   361 void T_PresenceGroupMemberManagement::T_EmptyFunc()
       
   362     {
       
   363     // nothing
       
   364     }
       
   365 
       
   366 // ------------------------------------------------------
       
   367 // test adding members
       
   368 // ------------------------------------------------------
       
   369 //
       
   370 void T_PresenceGroupMemberManagement::T_TestAddMembersL()
       
   371     {
       
   372     CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
       
   373     MXIMPContext* context = wrapper->GetContext();
       
   374     CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
   375 
       
   376     // Get the interfaces
       
   377     MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
   378     MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
   379 
       
   380     // Tell the protocol it should act normally
       
   381     messenger->SetNoError();
       
   382 
       
   383     // ------------------------------------------------------
       
   384     // add presentity group member
       
   385     //
       
   386     // expect events:
       
   387     // - request complete,
       
   388     // - presentitygroupcontentevent
       
   389 
       
   390     MXIMPIdentity* member = context->ObjectFactory().NewIdentityLC();
       
   391     member->SetIdentityL( KMemberId );
       
   392 
       
   393     // normal request complete
       
   394     TXIMPRequestId reqIdDummy;  // not checked
       
   395     CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
   396 
       
   397     // group id
       
   398     CXIMPIdentityImp* identity = CXIMPIdentityImp::NewLC( iCurrentGrId->Identity() );
       
   399     evReqComplete->AppendParamL( identity );
       
   400     CleanupStack::Pop(); // identity
       
   401 
       
   402     // id for member info
       
   403     CXIMPIdentityImp* miId = CXIMPIdentityImp::NewLC( KMemberId );
       
   404     // member info
       
   405     CPresentityGroupMemberInfoImp* memInfoImp =
       
   406         CPresentityGroupMemberInfoImp::NewLC( *miId, KMemberDisplayName );
       
   407     evReqComplete->AppendParamL( memInfoImp );
       
   408     CleanupStack::Pop(); // memInfoImp owned by AppendParamL
       
   409     CleanupStack::PopAndDestroy( miId ); // copy was made
       
   410 
       
   411     iListener2->ExpectL( evReqComplete );
       
   412     CleanupStack::Pop( evReqComplete );
       
   413 
       
   414     // group content event
       
   415     CPresentityGroupContentEventImp* groupCntEvent =
       
   416         XIMPTestEventFactory::CreateGroupContentEventLCX(
       
   417                 iCurrentGrId->Identity(),
       
   418                 KMemberId,
       
   419                 KMemberDisplayName,
       
   420                 XIMPTestEventFactory::ETestPGLCntAdded,
       
   421                 KMemberId,
       
   422                 KMemberDisplayName,
       
   423                 MXIMPDataSubscriptionState::ESubscriptionActive,
       
   424                 MXIMPDataSubscriptionState::EDataAvailable
       
   425                 );
       
   426 
       
   427     iListener2->ExpectL( groupCntEvent );
       
   428     CleanupStack::Pop( groupCntEvent ); // 5 more items in cleanupstack
       
   429 
       
   430     // do the call
       
   431     TXIMPRequestId reqId = presGroup.AddPresentityGroupMemberL(
       
   432             *iCurrentGrId, *member, KMemberDisplayName );
       
   433 
       
   434     // and wait
       
   435     EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "AddPresentityGroupMemberL failed" );
       
   436     CleanupStack::PopAndDestroy( 5 ); // lists from groupCntEvent
       
   437 
       
   438     messenger->AssertAddPresentityGroupMemberCalled( ETrue );
       
   439 
       
   440     // ------------------------------------------------------
       
   441     CleanupStack::PopAndDestroy(); // member
       
   442     }
       
   443 
       
   444 // ------------------------------------------------------
       
   445 // test adding members when not subscribed
       
   446 // ------------------------------------------------------
       
   447 //
       
   448 void T_PresenceGroupMemberManagement::T_TestAddMembers_NonSub_L()
       
   449     {
       
   450     CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
       
   451     MXIMPContext* context = wrapper->GetContext();
       
   452     CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
   453 
       
   454     // Get the interfaces
       
   455     MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
   456     MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
   457 
       
   458     // Tell the protocol it should act normally
       
   459     messenger->SetNoError();
       
   460 
       
   461     // ------------------------------------------------------
       
   462     // add presentity group member
       
   463     //
       
   464     // expect events:
       
   465     // - request complete,
       
   466 
       
   467     MXIMPIdentity* member = context->ObjectFactory().NewIdentityLC();
       
   468     member->SetIdentityL( KMemberId );
       
   469 
       
   470     // normal request complete
       
   471     TXIMPRequestId reqIdDummy;  // not checked
       
   472     CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
   473 
       
   474     // group id
       
   475     CXIMPIdentityImp* identity = CXIMPIdentityImp::NewLC( iCurrentGrId->Identity() );
       
   476     evReqComplete->AppendParamL( identity );
       
   477     CleanupStack::Pop(); // identity
       
   478 
       
   479     // id for member info
       
   480     CXIMPIdentityImp* miId = CXIMPIdentityImp::NewLC( KMemberId );
       
   481     // member info
       
   482     CPresentityGroupMemberInfoImp* memInfoImp =
       
   483         CPresentityGroupMemberInfoImp::NewLC( *miId, KMemberDisplayName );
       
   484     evReqComplete->AppendParamL( memInfoImp );
       
   485     CleanupStack::Pop(); // memInfoImp owned by AppendParamL
       
   486     CleanupStack::PopAndDestroy( miId ); // copy was made
       
   487 
       
   488     iListener2->ExpectL( evReqComplete );
       
   489     CleanupStack::Pop( evReqComplete );
       
   490 
       
   491     // do the call
       
   492     TXIMPRequestId reqId = presGroup.AddPresentityGroupMemberL(
       
   493             *iCurrentGrId, *member, KMemberDisplayName );
       
   494 
       
   495     // and wait
       
   496     EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "AddPresentityGroupMemberL failed" );
       
   497 
       
   498     messenger->AssertAddPresentityGroupMemberCalled( ETrue );
       
   499 
       
   500     // ------------------------------------------------------
       
   501     CleanupStack::PopAndDestroy(); // member
       
   502     }
       
   503 
       
   504 // ------------------------------------------------------
       
   505 // test removing members
       
   506 // ------------------------------------------------------
       
   507 //
       
   508 void T_PresenceGroupMemberManagement::T_TestRemoveMembersL()
       
   509     {
       
   510     // add a member
       
   511     T_TestAddMembersL();
       
   512 
       
   513     CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
       
   514     MXIMPContext* context = wrapper->GetContext();
       
   515     CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
   516 
       
   517     // Get the interfaces
       
   518     MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
   519     MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
   520 
       
   521     // Tell the protocol it should act normally
       
   522     messenger->SetNoError();
       
   523 
       
   524     // ------------------------------------------------------
       
   525     // remove presentity group member
       
   526     //
       
   527     // expect events:
       
   528     // - request complete,
       
   529     // - presentitygroupcontentevent
       
   530 
       
   531     MXIMPIdentity* member = context->ObjectFactory().NewIdentityLC();
       
   532     member->SetIdentityL( KMemberId );
       
   533 
       
   534     // normal request complete
       
   535     TXIMPRequestId reqIdDummy;  // not checked
       
   536     CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
   537     iListener2->ExpectL( evReqComplete );
       
   538     CleanupStack::Pop( evReqComplete );
       
   539 
       
   540     // group content event
       
   541     CPresentityGroupContentEventImp* groupCntEvent =
       
   542         XIMPTestEventFactory::CreateGroupContentEventLCX(
       
   543                 iCurrentGrId->Identity(),
       
   544                 KMemberId,
       
   545                 KNullDesC,
       
   546                 XIMPTestEventFactory::ETestPGLCntRemoved,
       
   547                 KNullDesC,
       
   548                 KNullDesC,
       
   549                 MXIMPDataSubscriptionState::ESubscriptionActive,
       
   550                 MXIMPDataSubscriptionState::EDataAvailable
       
   551                 );
       
   552 
       
   553     iListener2->ExpectL( groupCntEvent );
       
   554     CleanupStack::Pop( groupCntEvent ); // 5 more items in cleanupstack
       
   555 
       
   556     // do the call
       
   557     TXIMPRequestId reqId = presGroup.RemovePresentityGroupMemberL(
       
   558             *iCurrentGrId, *member );
       
   559 
       
   560     // and wait
       
   561     EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "RemovePresentityGroupMemberL failed" );
       
   562     CleanupStack::PopAndDestroy( 5 ); // lists from groupCntEvent
       
   563 
       
   564     messenger->AssertRemovePresentityGroupMemberCalled( ETrue );
       
   565 
       
   566     // ------------------------------------------------------
       
   567     CleanupStack::PopAndDestroy(); //member
       
   568     }
       
   569 
       
   570 // ------------------------------------------------------
       
   571 // test removing members when non-subscribed
       
   572 // ------------------------------------------------------
       
   573 //
       
   574 void T_PresenceGroupMemberManagement::T_TestRemoveMembers_NonSub_L()
       
   575     {
       
   576     // add a member
       
   577     T_TestAddMembers_NonSub_L();
       
   578 
       
   579     CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
       
   580     MXIMPContext* context = wrapper->GetContext();
       
   581     CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
   582 
       
   583     // Get the interfaces
       
   584     MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
   585     MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
   586 
       
   587     // Tell the protocol it should act normally
       
   588     messenger->SetNoError();
       
   589 
       
   590     // ------------------------------------------------------
       
   591     // remove presentity group member
       
   592     //
       
   593     // expect events:
       
   594     // - request complete,
       
   595     // - presentitygroupcontentevent
       
   596 
       
   597     MXIMPIdentity* member = context->ObjectFactory().NewIdentityLC();
       
   598     member->SetIdentityL( KMemberId );
       
   599 
       
   600     // normal request complete
       
   601     TXIMPRequestId reqIdDummy;  // not checked
       
   602     CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
   603     iListener2->ExpectL( evReqComplete );
       
   604     CleanupStack::Pop( evReqComplete );
       
   605 
       
   606     // do the call
       
   607     TXIMPRequestId reqId = presGroup.RemovePresentityGroupMemberL(
       
   608             *iCurrentGrId, *member );
       
   609 
       
   610     // and wait
       
   611     EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "RemovePresentityGroupMemberL failed" );
       
   612 
       
   613     messenger->AssertRemovePresentityGroupMemberCalled( ETrue );
       
   614 
       
   615     // ------------------------------------------------------
       
   616     CleanupStack::PopAndDestroy(); //member
       
   617     }
       
   618 
       
   619 // test removing nonexisting members
       
   620 void T_PresenceGroupMemberManagement::T_TestRemoveMembers_NonExisting_L()
       
   621     {
       
   622     CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
       
   623     MXIMPContext* context = wrapper->GetContext();
       
   624     CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
   625 
       
   626     // Get the interfaces
       
   627     MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
   628     MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
   629 
       
   630     // Tell the protocol it should act normally
       
   631     messenger->SetNoError();
       
   632 
       
   633     // ------------------------------------------------------
       
   634     // remove presentity group member
       
   635     //
       
   636     // expect events:
       
   637     // - request complete,
       
   638 
       
   639     MXIMPIdentity* member = context->ObjectFactory().NewIdentityLC();
       
   640     member->SetIdentityL( KMemberId );
       
   641 
       
   642     // normal request complete
       
   643     TXIMPRequestId reqIdDummy;  // not checked
       
   644     CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
   645     iListener2->ExpectL( evReqComplete );
       
   646     CleanupStack::Pop( evReqComplete );
       
   647 
       
   648     // do the call
       
   649     TXIMPRequestId reqId = presGroup.RemovePresentityGroupMemberL(
       
   650             *iCurrentGrId, *member );
       
   651 
       
   652     // and wait
       
   653     EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "RemovePresentityGroupMemberL failed" );
       
   654 
       
   655     messenger->AssertRemovePresentityGroupMemberCalled( ETrue );
       
   656 
       
   657     // ------------------------------------------------------
       
   658     CleanupStack::PopAndDestroy(); //member
       
   659     }
       
   660 
       
   661 // ------------------------------------------------------
       
   662 // test updating members
       
   663 // ------------------------------------------------------
       
   664 //
       
   665 void T_PresenceGroupMemberManagement::T_TestUpdateMembers_L()
       
   666     {
       
   667     // add a member
       
   668     T_TestAddMembersL();
       
   669 
       
   670     CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
       
   671     MXIMPContext* context = wrapper->GetContext();
       
   672     CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
   673 
       
   674     // Get the interfaces
       
   675     MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
   676     MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
   677 
       
   678     // Tell the protocol it should act normally
       
   679     messenger->SetNoError();
       
   680 
       
   681     // ------------------------------------------------------
       
   682     // update presentity group member
       
   683     //
       
   684     // expect events:
       
   685     // - request complete,
       
   686     // - presentitygroupcontentevent
       
   687 
       
   688     MXIMPIdentity* member = context->ObjectFactory().NewIdentityLC();
       
   689     member->SetIdentityL( KMemberId );
       
   690 
       
   691     // group content request complete
       
   692     TXIMPRequestId reqIdDummy;  // not checked
       
   693     CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
   694     CXIMPIdentityImp* identity = CXIMPIdentityImp::NewLC( iCurrentGrId->Identity() );
       
   695     evReqComplete->AppendParamL( identity );
       
   696     CleanupStack::Pop( identity );
       
   697 
       
   698     CPresentityGroupMemberInfoImp* mbrInfo = CPresentityGroupMemberInfoImp::NewLC( *member, KMemberDisplayName2 );
       
   699     evReqComplete->AppendParamL( mbrInfo );
       
   700     CleanupStack::Pop( mbrInfo );
       
   701 
       
   702     iListener2->ExpectL( evReqComplete );
       
   703     CleanupStack::Pop( evReqComplete );
       
   704 
       
   705     // group content event
       
   706     CPresentityGroupContentEventImp* groupCntEvent =
       
   707         XIMPTestEventFactory::CreateGroupContentEventLCX(
       
   708                 iCurrentGrId->Identity(),
       
   709                 KMemberId,
       
   710                 KMemberDisplayName2,
       
   711                 XIMPTestEventFactory::ETestPGLCntUpdated,
       
   712                 KMemberId,
       
   713                 KMemberDisplayName2,
       
   714                 MXIMPDataSubscriptionState::ESubscriptionActive,
       
   715                 MXIMPDataSubscriptionState::EDataAvailable
       
   716                 );
       
   717 
       
   718     iListener2->ExpectL( groupCntEvent );
       
   719     CleanupStack::Pop( groupCntEvent ); // 5 more items in cleanupstack
       
   720 
       
   721     // do the call
       
   722     TXIMPRequestId reqId = presGroup.UpdatePresentityGroupMemberDisplayNameL(
       
   723             *iCurrentGrId, *member, KMemberDisplayName2 );
       
   724 
       
   725     // and wait
       
   726     EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "UpdatePresentityGroupMemberDisplayNameL failed" );
       
   727     CleanupStack::PopAndDestroy( 5 ); // lists from groupCntEvent
       
   728 
       
   729     messenger->AssertUpdatePresentityGroupMemberDisplayNameCalled( ETrue );
       
   730 
       
   731     // ------------------------------------------------------
       
   732     CleanupStack::PopAndDestroy();
       
   733     }
       
   734 
       
   735 // ------------------------------------------------------
       
   736 // test updating members (nonsubscribed)
       
   737 // ------------------------------------------------------
       
   738 //
       
   739 void T_PresenceGroupMemberManagement::T_TestUpdateMembers_NonSub_L()
       
   740     {
       
   741     // add a member
       
   742     T_TestAddMembers_NonSub_L();
       
   743 
       
   744     CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
       
   745     MXIMPContext* context = wrapper->GetContext();
       
   746     CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
   747 
       
   748     // Get the interfaces
       
   749     MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
   750     MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
   751 
       
   752     // Tell the protocol it should act normally
       
   753     messenger->SetNoError();
       
   754 
       
   755     // ------------------------------------------------------
       
   756     // update presentity group member
       
   757     //
       
   758     // expect events:
       
   759     // - request complete,
       
   760 
       
   761     MXIMPIdentity* member = context->ObjectFactory().NewIdentityLC();
       
   762     member->SetIdentityL( KMemberId );
       
   763 
       
   764     // group content request complete
       
   765     TXIMPRequestId reqIdDummy;  // not checked
       
   766     CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
   767     CXIMPIdentityImp* identity = CXIMPIdentityImp::NewLC( iCurrentGrId->Identity() );
       
   768     evReqComplete->AppendParamL( identity );
       
   769     CleanupStack::Pop( identity );
       
   770 
       
   771     CPresentityGroupMemberInfoImp* mbrInfo = CPresentityGroupMemberInfoImp::NewLC( *member, KMemberDisplayName2 );
       
   772     evReqComplete->AppendParamL( mbrInfo );
       
   773     CleanupStack::Pop( mbrInfo );
       
   774 
       
   775     iListener2->ExpectL( evReqComplete );
       
   776     CleanupStack::Pop( evReqComplete );
       
   777 
       
   778     // do the call
       
   779     TXIMPRequestId reqId = presGroup.UpdatePresentityGroupMemberDisplayNameL(
       
   780             *iCurrentGrId, *member, KMemberDisplayName2 );
       
   781 
       
   782     // and wait
       
   783     EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "UpdatePresentityGroupMemberDisplayNameL failed" );
       
   784 
       
   785     messenger->AssertUpdatePresentityGroupMemberDisplayNameCalled( ETrue );
       
   786 
       
   787     // ------------------------------------------------------
       
   788     CleanupStack::PopAndDestroy();
       
   789     }
       
   790 
       
   791 // ------------------------------------------------------
       
   792 // test updating members with non-existing id
       
   793 // ------------------------------------------------------
       
   794 //
       
   795 void T_PresenceGroupMemberManagement::T_TestUpdateMembers_NonExisting_L()
       
   796     {
       
   797     CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
       
   798     MXIMPContext* context = wrapper->GetContext();
       
   799     CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
   800 
       
   801     // Get the interfaces
       
   802     MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
   803     MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
   804     
       
   805     // Tell the protocol it should act normally
       
   806     messenger->SetNoError();
       
   807 
       
   808     // ------------------------------------------------------
       
   809     // update presentity group member
       
   810     //
       
   811     // expect events:
       
   812     // - request complete,
       
   813 
       
   814     MXIMPIdentity* member = context->ObjectFactory().NewIdentityLC();
       
   815     member->SetIdentityL( KMemberId );
       
   816 
       
   817     // group content request complete
       
   818     TXIMPRequestId reqIdDummy;  // not checked
       
   819     CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
   820     CXIMPIdentityImp* identity = CXIMPIdentityImp::NewLC( iCurrentGrId->Identity() );
       
   821     evReqComplete->AppendParamL( identity );
       
   822     CleanupStack::Pop( identity );
       
   823 
       
   824     CPresentityGroupMemberInfoImp* mbrInfo = CPresentityGroupMemberInfoImp::NewLC( *member, KMemberDisplayName2 );
       
   825     evReqComplete->AppendParamL( mbrInfo );
       
   826     CleanupStack::Pop( mbrInfo );
       
   827 
       
   828     iListener2->ExpectL( evReqComplete );
       
   829     CleanupStack::Pop( evReqComplete );
       
   830 
       
   831     // do the call
       
   832     TXIMPRequestId reqId = presGroup.UpdatePresentityGroupMemberDisplayNameL(
       
   833             *iCurrentGrId, *member, KMemberDisplayName2 );
       
   834 
       
   835     // and wait
       
   836     EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "UpdatePresentityGroupMemberDisplayNameL failed" );
       
   837 
       
   838     messenger->AssertUpdatePresentityGroupMemberDisplayNameCalled( ETrue );
       
   839 
       
   840     // ------------------------------------------------------
       
   841     CleanupStack::PopAndDestroy();
       
   842     }
       
   843 
       
   844 // ===========================================================================
       
   845 // Test case methods
       
   846 // ===========================================================================
       
   847 
       
   848 // Subscribe and unsubscribe test
       
   849 void T_PresenceGroupMemberManagement::T_SubUnsubGroupContent_Single_L()
       
   850     {
       
   851     EUNIT_PRINT( _L("Single presentity group content sub and unsub") );
       
   852 
       
   853     TXIMPCallBack callback = &T_PresenceGroupMemberManagement::T_EmptyFunc;
       
   854     T_GenericSubAndUnsubL( callback );
       
   855     }
       
   856 
       
   857 // subscribe and unsubscribe, altered id
       
   858 void T_PresenceGroupMemberManagement::T_SubUnsubGroupContent_Altered_Single_L()
       
   859     {
       
   860     EUNIT_PRINT( _L("Single presentity group content sub and unsub with altered id") );
       
   861 
       
   862     CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
       
   863     wrapper->BindL( 0 );
       
   864 
       
   865     // ------------------------------------------------------
       
   866     // some startup stuff
       
   867     MXIMPContext* context = wrapper->GetContext();
       
   868     CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
   869 
       
   870     // Get the interfaces
       
   871     MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
   872     MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
   873 
       
   874     iListener2 = CXIMPTestListener::NewL( context );
       
   875     // ------------------------------------------------------
       
   876 
       
   877     // Tell the protocol it should act normally
       
   878     wrapper->GetMessenger()->SetNoError();
       
   879 
       
   880     iCurrentGrId = context->ObjectFactory().NewIdentityLC();
       
   881     CleanupStack::Pop(); // iCurrentGrId
       
   882     iCurrentGrId->SetIdentityL( KGroupId );
       
   883 
       
   884     // ------------------------------------------------------
       
   885     // create presentity group
       
   886     //
       
   887     // expect events:
       
   888     // - request complete.
       
   889     // NOTE: no presentitygrouplistevent as we've not subscribed the group lists
       
   890 
       
   891     // normal request complete
       
   892     TXIMPRequestId reqIdDummy;  // not checked
       
   893     CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
   894 
       
   895     // identity + displayname
       
   896     CPresentityGroupInfoImp* infoImp = CPresentityGroupInfoImp::NewLC( *iCurrentGrId, KGroupDisplayName );
       
   897     evReqComplete->AppendParamL( infoImp );
       
   898     CleanupStack::Pop( infoImp );
       
   899 
       
   900     iListener2->ExpectL( evReqComplete );
       
   901     CleanupStack::Pop( evReqComplete );
       
   902 
       
   903     TXIMPRequestId reqId = presGroup.CreatePresentityGroupL( *iCurrentGrId, KGroupDisplayName );
       
   904 
       
   905     // and wait
       
   906     EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "CreatePresentityGroupL failed" );
       
   907     messenger->AssertCreatePresentityGroupCalled( ETrue );
       
   908 
       
   909     // ------------------------------------------------------
       
   910     // subscribe presentity group CONTENT
       
   911     //
       
   912     // expect events:
       
   913     // - request complete
       
   914     evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
   915     iListener2->ExpectL( evReqComplete );
       
   916     CleanupStack::Pop( evReqComplete );
       
   917 
       
   918     // tell the test protocol to send back an altered id
       
   919     MXIMPIdentity* identityParam = context->ObjectFactory().NewIdentityLC();
       
   920     identityParam->SetIdentityL( KGroupId2 );
       
   921 
       
   922     CXIMPIdentityImp* identityParamImp =
       
   923              ( CXIMPIdentityImp* ) identityParam->GetInterface(
       
   924                                         CXIMPIdentityImp::KClassId,
       
   925                                         MXIMPBase::EPanicIfUnknown );
       
   926     HBufC8* packedId = TXIMPObjectPacker< CXIMPIdentityImp >::PackL( *identityParamImp );
       
   927     CleanupStack::PopAndDestroy(); // identityParam
       
   928     CleanupStack::PushL( packedId );
       
   929     CXIMPTestFileSrvMsg* srvMsg = CXIMPTestFileSrvMsg::NewL( CXIMPTestFileSrvMsg::ETestSrvMsgReqParamIdentity,
       
   930                                                              *packedId );
       
   931     CleanupStack::PopAndDestroy( packedId );
       
   932     CleanupStack::PushL( srvMsg );
       
   933     wrapper->FileTool().SrvMsgStoreL( srvMsg );
       
   934     CleanupStack::PopAndDestroy( srvMsg );
       
   935 
       
   936     // Wait for server to handle srvmsg.
       
   937     User::After( 2 );
       
   938     // now the adaptation should know how to answer
       
   939 
       
   940     // do the call
       
   941     reqId = presGroup.SubscribePresentityGroupContentL( *iCurrentGrId );
       
   942 
       
   943     // and wait
       
   944     EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "SubscribePresentityGroupContentL failed" );
       
   945 
       
   946     // verify that subscribe was called
       
   947     messenger->AssertSubscribePresentityGroupContentCalled( ETrue );
       
   948 
       
   949     // ------------------------------------------------------
       
   950 
       
   951     // make sure the new listener is not listening for events!
       
   952     iListener2->SetEventSourceL( NULL );
       
   953 
       
   954     wrapper->UnbindL();
       
   955 
       
   956     TeardownTestSupport();
       
   957     }
       
   958 
       
   959 // subscribe and unsubscribe, altered id is the same
       
   960 void T_PresenceGroupMemberManagement::T_SubUnsubGroupContent_AlteredSame_Single_L()
       
   961     {
       
   962     EUNIT_PRINT( _L("Single presentity group content sub and unsub with altered but same id") );
       
   963 
       
   964     CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
       
   965     wrapper->BindL( 0 );
       
   966 
       
   967     // ------------------------------------------------------
       
   968     // some startup stuff
       
   969     MXIMPContext* context = wrapper->GetContext();
       
   970     CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
   971 
       
   972     // Get the interfaces
       
   973     MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
   974     MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
   975 
       
   976     iListener2 = CXIMPTestListener::NewL( context );
       
   977     // ------------------------------------------------------
       
   978 
       
   979     // Tell the protocol it should act normally
       
   980     wrapper->GetMessenger()->SetNoError();
       
   981 
       
   982     iCurrentGrId = context->ObjectFactory().NewIdentityLC();
       
   983     CleanupStack::Pop(); // iCurrentGrId
       
   984     iCurrentGrId->SetIdentityL( KGroupId );
       
   985 
       
   986     // ------------------------------------------------------
       
   987     // create presentity group
       
   988     //
       
   989     // expect events:
       
   990     // - request complete.
       
   991     // NOTE: no presentitygrouplistevent as we've not subscribed the group lists
       
   992 
       
   993     // normal request complete
       
   994     TXIMPRequestId reqIdDummy;  // not checked
       
   995     CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
   996 
       
   997     // identity + displayname
       
   998     CPresentityGroupInfoImp* infoImp = CPresentityGroupInfoImp::NewLC( *iCurrentGrId, KGroupDisplayName );
       
   999     evReqComplete->AppendParamL( infoImp );
       
  1000     CleanupStack::Pop( infoImp );
       
  1001 
       
  1002     iListener2->ExpectL( evReqComplete );
       
  1003     CleanupStack::Pop( evReqComplete );
       
  1004 
       
  1005     TXIMPRequestId reqId = presGroup.CreatePresentityGroupL( *iCurrentGrId, KGroupDisplayName );
       
  1006 
       
  1007     // and wait
       
  1008     EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "CreatePresentityGroupL failed" );
       
  1009     messenger->AssertCreatePresentityGroupCalled( ETrue );
       
  1010 
       
  1011     // ------------------------------------------------------
       
  1012     // subscribe presentity group CONTENT
       
  1013     //
       
  1014     // expect events:
       
  1015     // - request complete
       
  1016     evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1017     iListener2->ExpectL( evReqComplete );
       
  1018     CleanupStack::Pop( evReqComplete );
       
  1019 
       
  1020     // tell the test protocol to send back an altered id
       
  1021     MXIMPIdentity* identityParam = context->ObjectFactory().NewIdentityLC();
       
  1022     identityParam->SetIdentityL( KGroupId );
       
  1023 
       
  1024     CXIMPIdentityImp* identityParamImp =
       
  1025              ( CXIMPIdentityImp* ) identityParam->GetInterface(
       
  1026                                         CXIMPIdentityImp::KClassId,
       
  1027                                         MXIMPBase::EPanicIfUnknown );
       
  1028     HBufC8* packedId = TXIMPObjectPacker< CXIMPIdentityImp >::PackL( *identityParamImp );
       
  1029     CleanupStack::PopAndDestroy(); // identityParam
       
  1030     CleanupStack::PushL( packedId );
       
  1031     CXIMPTestFileSrvMsg* srvMsg = CXIMPTestFileSrvMsg::NewL( CXIMPTestFileSrvMsg::ETestSrvMsgReqParamIdentity,
       
  1032                                                              *packedId );
       
  1033     CleanupStack::PopAndDestroy( packedId );
       
  1034     CleanupStack::PushL( srvMsg );
       
  1035     wrapper->FileTool().SrvMsgStoreL( srvMsg );
       
  1036     CleanupStack::PopAndDestroy( srvMsg );
       
  1037 
       
  1038     // Wait for server to handle srvmsg.
       
  1039     User::After( 2 );
       
  1040     // now the adaptation should know how to answer
       
  1041 
       
  1042     // do the call
       
  1043     reqId = presGroup.SubscribePresentityGroupContentL( *iCurrentGrId );
       
  1044 
       
  1045     // and wait
       
  1046     EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "SubscribePresentityGroupContentL failed" );
       
  1047 
       
  1048     // verify that subscribe was called
       
  1049     messenger->AssertSubscribePresentityGroupContentCalled( ETrue );
       
  1050 
       
  1051     // ------------------------------------------------------
       
  1052 
       
  1053     // make sure the new listener is not listening for events!
       
  1054     iListener2->SetEventSourceL( NULL );
       
  1055 
       
  1056     wrapper->UnbindL();
       
  1057 
       
  1058     TeardownTestSupport();
       
  1059     }
       
  1060 
       
  1061 
       
  1062 // Add members
       
  1063 void T_PresenceGroupMemberManagement::T_AddGroupMembers_Single_L()
       
  1064     {
       
  1065     EUNIT_PRINT( _L("Single add members to group") );
       
  1066 
       
  1067     TXIMPCallBack callback = &T_PresenceGroupMemberManagement::T_TestAddMembersL;
       
  1068     T_GenericSubAndUnsubL( callback );
       
  1069     }
       
  1070 
       
  1071 // Remove members
       
  1072 void T_PresenceGroupMemberManagement::T_RemoveGroupMembers_Single_L()
       
  1073     {
       
  1074     EUNIT_PRINT( _L("Single remove member of group") );
       
  1075 
       
  1076     TXIMPCallBack callback = &T_PresenceGroupMemberManagement::T_TestRemoveMembersL;
       
  1077     T_GenericSubAndUnsubL( callback );
       
  1078     }
       
  1079 
       
  1080 // Update members
       
  1081 void T_PresenceGroupMemberManagement::T_UpdateGroupMembers_Single_L()
       
  1082     {
       
  1083     EUNIT_PRINT( _L("Single update member of group") );
       
  1084 
       
  1085     TXIMPCallBack callback = &T_PresenceGroupMemberManagement::T_TestUpdateMembers_L;
       
  1086     T_GenericSubAndUnsubL( callback );
       
  1087     }
       
  1088 
       
  1089 // Update members without subscription
       
  1090 void T_PresenceGroupMemberManagement::T_UpdateGroupMembers_NonSub_Single_L()
       
  1091     {
       
  1092     EUNIT_PRINT( _L("Single update member of group, unsubscribed") );
       
  1093 
       
  1094     TXIMPCallBack callback = &T_PresenceGroupMemberManagement::T_TestUpdateMembers_NonSub_L;
       
  1095     iSkipSubscribe = ETrue;
       
  1096     iSkipUnsubscribe = ETrue;
       
  1097     T_GenericSubAndUnsubL( callback );
       
  1098     }
       
  1099 
       
  1100 // Update members with non-existing member
       
  1101 void T_PresenceGroupMemberManagement::T_UpdateGroupMembers_NonExist_Single_L()
       
  1102     {
       
  1103     EUNIT_PRINT( _L("Single update nonexisting member of group") );
       
  1104 
       
  1105     TXIMPCallBack callback = &T_PresenceGroupMemberManagement::T_TestUpdateMembers_NonExisting_L;
       
  1106     T_GenericSubAndUnsubL( callback );
       
  1107     }
       
  1108 
       
  1109 // Remove members without subscription
       
  1110 void T_PresenceGroupMemberManagement::T_RemoveGroupMembers_NonSub_Single_L()
       
  1111     {
       
  1112     EUNIT_PRINT( _L("Single remove member of group, unsubscribed") );
       
  1113 
       
  1114     TXIMPCallBack callback = &T_PresenceGroupMemberManagement::T_TestRemoveMembers_NonSub_L;
       
  1115     iSkipSubscribe = ETrue;
       
  1116     iSkipUnsubscribe = ETrue;
       
  1117     T_GenericSubAndUnsubL( callback );
       
  1118     }
       
  1119 
       
  1120 // Remove members with non-existing member
       
  1121 void T_PresenceGroupMemberManagement::T_RemoveGroupMembers_NonExist_Single_L()
       
  1122     {
       
  1123     EUNIT_PRINT( _L("Single remove nonexisting member of group") );
       
  1124 
       
  1125     TXIMPCallBack callback = &T_PresenceGroupMemberManagement::T_TestRemoveMembers_NonExisting_L;
       
  1126     T_GenericSubAndUnsubL( callback );
       
  1127     }
       
  1128 
       
  1129 // ------------------------------------------------------
       
  1130 // expire non-subscribed data
       
  1131 // ------------------------------------------------------
       
  1132 //
       
  1133 void T_PresenceGroupMemberManagement::T_ExpireNonSubscribedData_L()
       
  1134     {
       
  1135     EUNIT_PRINT( _L("Expire non subscribed data") );
       
  1136 
       
  1137     CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
       
  1138     wrapper->BindL( 0 );
       
  1139 
       
  1140     MXIMPContext* context = wrapper->GetContext();
       
  1141     CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
  1142 
       
  1143     // Get the interfaces
       
  1144     MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
  1145     MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
  1146 
       
  1147     iCurrentGrId = context->ObjectFactory().NewIdentityLC();
       
  1148     CleanupStack::Pop(); // iCurrentGrId
       
  1149     iCurrentGrId->SetIdentityL( KGroupId );
       
  1150 
       
  1151     // Tell the protocol it should act normally
       
  1152     messenger->SetNoError();
       
  1153 
       
  1154     // 1. Create notification
       
  1155     RXIMPObjOwningPtrArray<CPresentityGroupMemberInfoImp> groupMemberList;
       
  1156     CXIMPIdentityImp* identityImp =
       
  1157              ( CXIMPIdentityImp* ) iCurrentGrId->GetInterface(
       
  1158                                         CXIMPIdentityImp::KClassId,
       
  1159                                         MXIMPBase::EPanicIfUnknown );
       
  1160     HBufC8* packedId = TXIMPObjectPacker< CXIMPIdentityImp >::PackL( *identityImp );
       
  1161     CleanupStack::PushL( packedId );
       
  1162     HBufC8* packedArray = TXIMPObjectPacker<CPresentityGroupMemberInfoImp>::PackArrayL( groupMemberList );
       
  1163     CleanupStack::PushL( packedArray );
       
  1164     RPointerArray< HBufC8 > bufferArray;
       
  1165     CleanupClosePushL( bufferArray );
       
  1166     bufferArray.AppendL( packedId );
       
  1167     bufferArray.AppendL( packedArray );
       
  1168     HBufC8* packedBufferArray = TXIMPHBuf8Packer::PackArrayL( bufferArray );
       
  1169     CleanupStack::PopAndDestroy( 2, packedArray ); // bufferArray, packedArray
       
  1170     CleanupStack::PushL( packedBufferArray );
       
  1171 
       
  1172     // 2. Use filetool to send it for plugin.
       
  1173     CXIMPTestFileSrvMsg* srvMsg = CXIMPTestFileSrvMsg::NewL( CXIMPTestFileSrvMsg::ETestSrvMsgPresentityGroupMemberList,
       
  1174                                                              *packedBufferArray );
       
  1175     CleanupStack::PopAndDestroy( packedBufferArray );
       
  1176     CleanupStack::PushL( srvMsg );
       
  1177     wrapper->FileTool().CleanAllL();
       
  1178     wrapper->FileTool().SrvMsgStoreL( srvMsg );
       
  1179     CleanupStack::PopAndDestroy( srvMsg );
       
  1180 
       
  1181     // Wait for server to handle srvmsg.
       
  1182     CXIMPTestWaitHelper* wait = CXIMPTestWaitHelper::NewL();
       
  1183     CleanupStack::PushL( wait );
       
  1184     wait->WaitForL( 2 );
       
  1185 
       
  1186     // 3. Create and send check notification to server
       
  1187     srvMsg = CXIMPTestFileSrvMsg::NewL( CXIMPTestFileSrvMsg::ETestCheckIfGroupMemberExists,
       
  1188                                                              *packedId );
       
  1189     CleanupStack::PushL( srvMsg );
       
  1190     wrapper->FileTool().SrvMsgStoreL( srvMsg );
       
  1191 
       
  1192     // Wait for server to handle srvmsg.
       
  1193     wait->WaitForL( 2 );
       
  1194 
       
  1195     TInt value = messenger->GetValueFor( EXIMPPlgTestExistsGroupContentInCache );
       
  1196     EUNIT_ASSERT_DESC( value == 1, "Data not cached temporarly" );
       
  1197 
       
  1198    // 4. Wait for cache to clear.
       
  1199     wait->WaitForL( 15 );
       
  1200 
       
  1201     // 5. Send check notification to server
       
  1202     wrapper->FileTool().SrvMsgStoreL( srvMsg );
       
  1203     CleanupStack::PopAndDestroy( srvMsg );
       
  1204 
       
  1205     // Wait for server to handle srvmsg.
       
  1206     wait->WaitForL( 2 );
       
  1207     CleanupStack::PopAndDestroy( wait );
       
  1208     CleanupStack::PopAndDestroy( packedId );
       
  1209     value = messenger->GetValueFor( EXIMPPlgTestExistsGroupContentInCache );
       
  1210     EUNIT_ASSERT_DESC( value == KErrNotFound, "Data not cleared like it should" );
       
  1211     wrapper->UnbindL();
       
  1212     }
       
  1213 
       
  1214 // ------------------------------------------------------
       
  1215 // expire non-subscribed data, update multiple
       
  1216 // ------------------------------------------------------
       
  1217 //
       
  1218 void T_PresenceGroupMemberManagement::T_ExpireNonSubscribedDataUpdateMultiple_L()
       
  1219     {
       
  1220     EUNIT_PRINT( _L("Expire non subscribed data, update multiple") );
       
  1221 
       
  1222     // Wait for server to handle srvmsg.
       
  1223     CXIMPTestWaitHelper* wait = CXIMPTestWaitHelper::NewL();
       
  1224     CleanupStack::PushL( wait );
       
  1225 
       
  1226     CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
       
  1227     wrapper->BindL( 0 );
       
  1228 
       
  1229     MXIMPContext* context = wrapper->GetContext();
       
  1230     CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
  1231 
       
  1232     // Get the interfaces
       
  1233     MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
  1234     MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
  1235 
       
  1236     iCurrentGrId = context->ObjectFactory().NewIdentityLC();
       
  1237     CleanupStack::Pop(); // iCurrentGrId
       
  1238     iCurrentGrId->SetIdentityL( KGroupId );
       
  1239 
       
  1240     // Tell the protocol it should act normally
       
  1241     messenger->SetNoError();
       
  1242 
       
  1243     // 1. Create notification
       
  1244     RXIMPObjOwningPtrArray<CPresentityGroupMemberInfoImp> groupMemberList;
       
  1245     CXIMPIdentityImp* identityImp =
       
  1246              ( CXIMPIdentityImp* ) iCurrentGrId->GetInterface(
       
  1247                                         CXIMPIdentityImp::KClassId,
       
  1248                                         MXIMPBase::EPanicIfUnknown );
       
  1249     HBufC8* packedId = TXIMPObjectPacker< CXIMPIdentityImp >::PackL( *identityImp );
       
  1250     CleanupStack::PushL( packedId );
       
  1251     HBufC8* packedArray = TXIMPObjectPacker<CPresentityGroupMemberInfoImp>::PackArrayL( groupMemberList );
       
  1252     CleanupStack::PushL( packedArray );
       
  1253     RPointerArray< HBufC8 > bufferArray;
       
  1254     CleanupClosePushL( bufferArray );
       
  1255     bufferArray.AppendL( packedId );
       
  1256     bufferArray.AppendL( packedArray );
       
  1257     HBufC8* packedBufferArray = TXIMPHBuf8Packer::PackArrayL( bufferArray );
       
  1258     CleanupStack::PopAndDestroy( 2, packedArray ); // bufferArray, packedArray
       
  1259     CleanupStack::PushL( packedBufferArray );
       
  1260 
       
  1261     // 2. Use filetool to send it for plugin.
       
  1262     CXIMPTestFileSrvMsg* srvMsg = CXIMPTestFileSrvMsg::NewL( CXIMPTestFileSrvMsg::ETestSrvMsgPresentityGroupMemberList,
       
  1263                                                              *packedBufferArray );
       
  1264     CleanupStack::PopAndDestroy( packedBufferArray );
       
  1265     CleanupStack::PushL( srvMsg );
       
  1266     wrapper->FileTool().CleanAllL();
       
  1267     wrapper->FileTool().SrvMsgStoreL( srvMsg );
       
  1268 
       
  1269     wait->WaitForL( 2 );
       
  1270 
       
  1271     // 3. Create and send check notification to server
       
  1272     CXIMPTestFileSrvMsg* srvMsg2 = CXIMPTestFileSrvMsg::NewL( CXIMPTestFileSrvMsg::ETestCheckIfGroupMemberExists,
       
  1273                                                              *packedId );
       
  1274     CleanupStack::PushL( srvMsg2 );
       
  1275     wrapper->FileTool().SrvMsgStoreL( srvMsg2 );
       
  1276 
       
  1277     // Wait for server to handle srvmsg.
       
  1278     wait->WaitForL( 2 );
       
  1279 
       
  1280     TInt value = messenger->GetValueFor( EXIMPPlgTestExistsGroupContentInCache );
       
  1281     EUNIT_ASSERT_DESC( value == 1, "Data not cached temporarly" );
       
  1282 
       
  1283    // 4. Wait for cache to clear.
       
  1284     wait->WaitForL( 5 );
       
  1285 
       
  1286     // Refresh temporar cache.
       
  1287     wrapper->FileTool().SrvMsgStoreL( srvMsg );
       
  1288 
       
  1289    // 4. Wait for cache to clear.
       
  1290     wait->WaitForL( 10 );
       
  1291 
       
  1292     // 5. Send check notification to server
       
  1293     wrapper->FileTool().SrvMsgStoreL( srvMsg2 );
       
  1294     CleanupStack::PopAndDestroy( 3, packedId ); //packedId, srvMsg, srvMsg2
       
  1295 
       
  1296     // Wait for server to handle srvmsg.
       
  1297     wait->WaitForL( 2 );
       
  1298     value = messenger->GetValueFor( EXIMPPlgTestExistsGroupContentInCache );
       
  1299     EUNIT_ASSERT_DESC( value == 1, "Data not cached temporarly, but it should be" );
       
  1300 
       
  1301     wrapper->UnbindL();
       
  1302 
       
  1303     CleanupStack::PopAndDestroy( wait );
       
  1304     }
       
  1305 
       
  1306 // ------------------------------------------------------
       
  1307 // General subscribe and unsubscribe for multiple
       
  1308 // ------------------------------------------------------
       
  1309 //
       
  1310 void T_PresenceGroupMemberManagement::T_SubUnsubGroupContent_Multi_L()
       
  1311     {
       
  1312     BindAllL();
       
  1313 
       
  1314     TInt countOfWrappers = iWrapperMgr->WrapperCount();
       
  1315 
       
  1316     CXIMPObjectFactoryImp* factory = CXIMPObjectFactoryImp::NewL();
       
  1317     CleanupStack::PushL( factory );
       
  1318 
       
  1319     MXIMPIdentity* currentGrId = factory->NewIdentityLC();
       
  1320     currentGrId->SetIdentityL( KGroupId );
       
  1321 
       
  1322     // create group to all connections
       
  1323     for ( TInt i = 0; i < countOfWrappers; i++ )
       
  1324         {
       
  1325         CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( i );
       
  1326 
       
  1327         // ------------------------------------------------------
       
  1328         // some startup stuff
       
  1329         MXIMPContext* context = wrapper->GetContext();
       
  1330         CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
  1331 
       
  1332         // Get the interfaces
       
  1333         MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
  1334         MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
  1335 
       
  1336         CXIMPTestListener* listener = CXIMPTestListener::NewL( context );
       
  1337         CleanupStack::PushL( listener );
       
  1338         // ------------------------------------------------------
       
  1339 
       
  1340         // Tell the protocol it should act normally
       
  1341         wrapper->GetMessenger()->SetNoError();
       
  1342 
       
  1343         // ------------------------------------------------------
       
  1344         // create presentity group
       
  1345         //
       
  1346         // expect events:
       
  1347         // - request complete.
       
  1348         // NOTE: no presentitygrouplistevent as we've not subscribed the group lists
       
  1349 
       
  1350         // normal request complete
       
  1351         TXIMPRequestId reqIdDummy;  // not checked
       
  1352         CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1353 
       
  1354         // identity + displayname
       
  1355         CPresentityGroupInfoImp* infoImp = CPresentityGroupInfoImp::NewLC( *currentGrId, KGroupDisplayName );
       
  1356         evReqComplete->AppendParamL( infoImp );
       
  1357         CleanupStack::Pop( infoImp );
       
  1358 
       
  1359         listener->ExpectL( evReqComplete );
       
  1360         CleanupStack::Pop( evReqComplete );
       
  1361 
       
  1362         TXIMPRequestId reqId = presGroup.CreatePresentityGroupL( *currentGrId, KGroupDisplayName );
       
  1363 
       
  1364         // and wait
       
  1365         EUNIT_ASSERT_DESC( KErrNone == listener->WaitAndAssertL(), "CreatePresentityGroupL failed" );
       
  1366 
       
  1367         // verify that create was called
       
  1368         messenger->AssertCreatePresentityGroupCalled( ETrue );
       
  1369 
       
  1370         CleanupStack::PopAndDestroy( listener );
       
  1371         }
       
  1372 
       
  1373     // subscribe presentity group content in all connections
       
  1374     for ( TInt i = 0; i < countOfWrappers; i++ )
       
  1375         {
       
  1376         CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( i );
       
  1377 
       
  1378         // ------------------------------------------------------
       
  1379         // some startup stuff
       
  1380         MXIMPContext* context = wrapper->GetContext();
       
  1381         CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
  1382 
       
  1383         // Get the interfaces
       
  1384         MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
  1385         MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
  1386 
       
  1387         CXIMPTestListener* listener = CXIMPTestListener::NewL( context );
       
  1388         CleanupStack::PushL( listener );
       
  1389         // ------------------------------------------------------
       
  1390 
       
  1391         // ------------------------------------------------------
       
  1392         // subscribe presentity group CONTENT
       
  1393         //
       
  1394         // expect events:
       
  1395         // - request complete
       
  1396         TXIMPRequestId reqIdDummy;  // not checked
       
  1397         CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1398         listener->ExpectL( evReqComplete );
       
  1399         CleanupStack::Pop( evReqComplete );
       
  1400 
       
  1401         // do the call
       
  1402         TXIMPRequestId reqId = presGroup.SubscribePresentityGroupContentL( *currentGrId );
       
  1403 
       
  1404         // and wait
       
  1405         EUNIT_ASSERT_DESC( KErrNone == listener->WaitAndAssertL(), "SubscribePresentityGroupContentL failed" );
       
  1406 
       
  1407         // verify that subscribe was called
       
  1408         messenger->AssertSubscribePresentityGroupContentCalled( ETrue );
       
  1409 
       
  1410         CleanupStack::PopAndDestroy( listener );
       
  1411         }
       
  1412 
       
  1413     // unsubscribe presentity group content in all connections
       
  1414     for ( TInt i = 0; i < countOfWrappers; i++ )
       
  1415         {
       
  1416         CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( i );
       
  1417 
       
  1418         // ------------------------------------------------------
       
  1419         // some startup stuff
       
  1420         MXIMPContext* context = wrapper->GetContext();
       
  1421         CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
  1422 
       
  1423         // Get the interfaces
       
  1424         MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
  1425         MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
  1426 
       
  1427         CXIMPTestListener* listener = CXIMPTestListener::NewL( context );
       
  1428         CleanupStack::PushL( listener );
       
  1429         // ------------------------------------------------------
       
  1430 
       
  1431         // ------------------------------------------------------
       
  1432         // unsubscribe presentity group content
       
  1433         //
       
  1434         // expect events:
       
  1435         // - request complete
       
  1436         // - presentity group content event
       
  1437 
       
  1438         TXIMPRequestId reqIdDummy;  // not checked
       
  1439         CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1440         listener->ExpectL( evReqComplete );
       
  1441         CleanupStack::Pop( evReqComplete );
       
  1442 
       
  1443         CPresentityGroupContentEventImp* groupCntEvent =
       
  1444             XIMPTestEventFactory::CreateGroupContentEventLCX(
       
  1445                     KGroupId,
       
  1446                     KNullDesC,
       
  1447                     KNullDesC,
       
  1448                     XIMPTestEventFactory::ETestPGLCntRemoved,
       
  1449                     KNullDesC,
       
  1450                     KNullDesC,
       
  1451                     MXIMPDataSubscriptionState::ESubscriptionInactive,
       
  1452                     MXIMPDataSubscriptionState::EDataUnavailable
       
  1453                     );
       
  1454 
       
  1455         listener->ExpectL( groupCntEvent );
       
  1456         CleanupStack::Pop( groupCntEvent ); // 5 more items in cleanupstack
       
  1457 
       
  1458         // do the call
       
  1459         TXIMPRequestId reqId = presGroup.UnsubscribePresentityGroupContentL( *currentGrId );
       
  1460 
       
  1461         // and wait
       
  1462         EUNIT_ASSERT_DESC( KErrNone == listener->WaitAndAssertL(), "UnsubscribePresentityGroupContentL failed" );
       
  1463         CleanupStack::PopAndDestroy( 5 ); // lists
       
  1464 
       
  1465         // verify that unsubscribe was called
       
  1466         // unsubscribe really called only on the last one
       
  1467         messenger->AssertUnsubscribePresentityGroupContentCalled( i == countOfWrappers-1 ? ETrue : EFalse );
       
  1468 
       
  1469         CleanupStack::PopAndDestroy( listener );
       
  1470         }
       
  1471 
       
  1472     // delete presentity group in all connections
       
  1473     for ( TInt i = 0; i < countOfWrappers; i++ )
       
  1474         {
       
  1475         CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( i );
       
  1476 
       
  1477         // ------------------------------------------------------
       
  1478         // some startup stuff
       
  1479         MXIMPContext* context = wrapper->GetContext();
       
  1480         CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
  1481 
       
  1482         // Get the interfaces
       
  1483         MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
  1484         MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
  1485 
       
  1486         CXIMPTestListener* listener = CXIMPTestListener::NewL( context );
       
  1487         CleanupStack::PushL( listener );
       
  1488         // ------------------------------------------------------
       
  1489 
       
  1490         // ------------------------------------------------------
       
  1491         // delete presentity group
       
  1492         //
       
  1493         // expect events:
       
  1494         // - request complete
       
  1495         // NO presentity group content event as we've just unsubscribed it.
       
  1496 
       
  1497         TXIMPRequestId reqIdDummy;  // not checked
       
  1498         CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1499         listener->ExpectL( evReqComplete );
       
  1500         CleanupStack::Pop( evReqComplete );
       
  1501 
       
  1502         // do the call
       
  1503         TXIMPRequestId reqId = presGroup.DeletePresentityGroupL( *currentGrId );
       
  1504 
       
  1505         // and wait
       
  1506         EUNIT_ASSERT_DESC( KErrNone == listener->WaitAndAssertL(), "DeletePresentityGroupL failed" );
       
  1507 
       
  1508         CleanupStack::PopAndDestroy( listener );
       
  1509         }
       
  1510 
       
  1511     // ------------------------------------------------------
       
  1512 
       
  1513     CleanupStack::PopAndDestroy( 2 ); // currentGrId, factory
       
  1514 
       
  1515 
       
  1516     UnbindAllL();
       
  1517 
       
  1518     TeardownTestSupport();
       
  1519     }
       
  1520 
       
  1521 // ------------------------------------------------------
       
  1522 // General subscribe and unsubscribe for multiple
       
  1523 // Subscribed for all contexts, force refresh
       
  1524 // ------------------------------------------------------
       
  1525 //
       
  1526 void T_PresenceGroupMemberManagement::T_SubUnsubGroupContent_All_Multi_L()
       
  1527     {
       
  1528     BindAllL();
       
  1529 
       
  1530     TInt countOfWrappers = iWrapperMgr->WrapperCount();
       
  1531 
       
  1532     CXIMPObjectFactoryImp* factory = CXIMPObjectFactoryImp::NewL();
       
  1533     CleanupStack::PushL( factory );
       
  1534 
       
  1535     MXIMPIdentity* currentGrId = factory->NewIdentityLC();
       
  1536     currentGrId->SetIdentityL( KGroupId );
       
  1537 
       
  1538     // create group to all connections
       
  1539     CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
       
  1540 
       
  1541     // ------------------------------------------------------
       
  1542     // some startup stuff
       
  1543     MXIMPContext* context = wrapper->GetContext();
       
  1544     CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
  1545 
       
  1546     // Get the interfaces
       
  1547     MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
  1548     MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
  1549 
       
  1550     CXIMPTestListener* listener = CXIMPTestListener::NewL( context );
       
  1551     CleanupStack::PushL( listener );
       
  1552     // ------------------------------------------------------
       
  1553 
       
  1554     // Tell the protocol it should act normally
       
  1555     wrapper->GetMessenger()->SetNoError();
       
  1556 
       
  1557     // ------------------------------------------------------
       
  1558     // create presentity group
       
  1559     //
       
  1560     // expect events:
       
  1561     // - request complete.
       
  1562     // NOTE: no presentitygrouplistevent as we've not subscribed the group lists
       
  1563 
       
  1564     // normal request complete
       
  1565     TXIMPRequestId reqIdDummy;  // not checked
       
  1566     CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1567 
       
  1568     // identity + displayname
       
  1569     CPresentityGroupInfoImp* infoImp = CPresentityGroupInfoImp::NewLC( *currentGrId, KGroupDisplayName );
       
  1570     evReqComplete->AppendParamL( infoImp );
       
  1571     CleanupStack::Pop( infoImp );
       
  1572 
       
  1573     listener->ExpectL( evReqComplete );
       
  1574     CleanupStack::Pop( evReqComplete );
       
  1575 
       
  1576     TXIMPRequestId reqId = presGroup.CreatePresentityGroupL( *currentGrId, KGroupDisplayName );
       
  1577 
       
  1578     // and wait
       
  1579     EUNIT_ASSERT_DESC( KErrNone == listener->WaitAndAssertL(), "CreatePresentityGroupL failed" );
       
  1580 
       
  1581     // verify that create was called
       
  1582     messenger->AssertCreatePresentityGroupCalled( ETrue );
       
  1583 
       
  1584     // we'll make a new listener below, disable temporarily
       
  1585     listener->SetEventSourceL( NULL );
       
  1586 
       
  1587     // subscribe presentity group content in all connections
       
  1588     for ( TInt i = 0; i < countOfWrappers; i++ )
       
  1589         {
       
  1590         CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( i );
       
  1591 
       
  1592         // ------------------------------------------------------
       
  1593         // some startup stuff
       
  1594         MXIMPContext* context = wrapper->GetContext();
       
  1595         CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
  1596 
       
  1597         // Get the interfaces
       
  1598         MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
  1599         MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
  1600 
       
  1601         CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context );
       
  1602         CleanupStack::PushL( listener2 );
       
  1603         // ------------------------------------------------------
       
  1604 
       
  1605         // ------------------------------------------------------
       
  1606         // subscribe presentity group content for ALL contexts
       
  1607         //
       
  1608         // expect events:
       
  1609         // - request complete
       
  1610         evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1611         listener2->ExpectL( evReqComplete );
       
  1612         CleanupStack::Pop( evReqComplete );
       
  1613 
       
  1614         // do the call
       
  1615         reqId = presGroup.SubscribePresentityGroupContentL( *currentGrId );
       
  1616 
       
  1617         // and wait
       
  1618         EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "SubscribePresentityGroupContentL failed" );
       
  1619 
       
  1620         // verify that subscribe was called for first only
       
  1621         if ( i == 0 )
       
  1622             {
       
  1623             messenger->AssertSubscribePresentityGroupContentCalled( ETrue );
       
  1624             // reset flag
       
  1625             messenger->SetValueFor(
       
  1626                     EXIMPPlgTestSubscribePresentityGroupContentCalled,
       
  1627                     EFalse );
       
  1628             }
       
  1629         else
       
  1630             {
       
  1631             messenger->AssertSubscribePresentityGroupContentCalled( EFalse );
       
  1632             }
       
  1633 
       
  1634         CleanupStack::PopAndDestroy( listener2 );
       
  1635         }
       
  1636 
       
  1637     for ( TInt i = 0; i < countOfWrappers; i++ )
       
  1638         {
       
  1639         CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( i );
       
  1640 
       
  1641         // ------------------------------------------------------
       
  1642         // some startup stuff
       
  1643         MXIMPContext* context = wrapper->GetContext();
       
  1644         CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
  1645 
       
  1646         // Get the interfaces
       
  1647         MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
  1648         MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
  1649 
       
  1650         CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context );
       
  1651         CleanupStack::PushL( listener2 );
       
  1652         // ------------------------------------------------------
       
  1653 
       
  1654         // ------------------------------------------------------
       
  1655         // subscribe presentity group content, making a REFRESH case
       
  1656         // with multiple contexts
       
  1657         //
       
  1658         // expect events:
       
  1659         // - request complete
       
  1660         // - group content event
       
  1661 
       
  1662         evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1663         listener2->ExpectL( evReqComplete );
       
  1664         CleanupStack::Pop( evReqComplete );
       
  1665 
       
  1666         CPresentityGroupContentEventImp* groupCntEvent =
       
  1667             XIMPTestEventFactory::CreateGroupContentEventLCX(
       
  1668                     KGroupId,
       
  1669                     KNullDesC,
       
  1670                     KNullDesC,
       
  1671                     XIMPTestEventFactory::ETestPGLCntUpdated,
       
  1672                     KNullDesC,
       
  1673                     KNullDesC,
       
  1674                     MXIMPDataSubscriptionState::ESubscriptionActive,
       
  1675                     MXIMPDataSubscriptionState::EDataUnavailable
       
  1676                     );
       
  1677 
       
  1678         listener2->ExpectL( groupCntEvent );
       
  1679         CleanupStack::Pop( groupCntEvent ); // 5 more items in cleanupstack
       
  1680 
       
  1681         // do the call
       
  1682         reqId = presGroup.SubscribePresentityGroupContentL( *currentGrId );
       
  1683 
       
  1684         // and wait
       
  1685         EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "SubscribePresentityGroupContentL failed" );
       
  1686 
       
  1687         CleanupStack::PopAndDestroy( 5 ); // rest of group the content event
       
  1688 
       
  1689         // subscribe is not called in the adaptation, this is a refresh case
       
  1690         messenger->AssertSubscribePresentityGroupContentCalled( EFalse );
       
  1691 
       
  1692         CleanupStack::PopAndDestroy( listener2 );
       
  1693         }
       
  1694 
       
  1695     // continue listening
       
  1696     listener->SetEventSourceL( context );
       
  1697 
       
  1698     // ------------------------------------------------------
       
  1699     // unsubscribe presentity group content
       
  1700     //
       
  1701     // expect events:
       
  1702     // - request complete
       
  1703     // - presentity group content event
       
  1704 
       
  1705     evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1706     listener->ExpectL( evReqComplete );
       
  1707     CleanupStack::Pop( evReqComplete );
       
  1708 
       
  1709     CPresentityGroupContentEventImp* groupCntEvent =
       
  1710         XIMPTestEventFactory::CreateGroupContentEventLCX(
       
  1711                 KGroupId,
       
  1712                 KNullDesC,
       
  1713                 KNullDesC,
       
  1714                 XIMPTestEventFactory::ETestPGLCntRemoved,
       
  1715                 KNullDesC,
       
  1716                 KNullDesC,
       
  1717                 MXIMPDataSubscriptionState::ESubscriptionInactive,
       
  1718                 MXIMPDataSubscriptionState::EDataUnavailable
       
  1719                 );
       
  1720 
       
  1721     listener->ExpectL( groupCntEvent );
       
  1722     CleanupStack::Pop( groupCntEvent ); // 5 more items in cleanupstack
       
  1723 
       
  1724     // do the call
       
  1725     reqId = presGroup.UnsubscribePresentityGroupContentL( *currentGrId );
       
  1726 
       
  1727     // and wait
       
  1728     EUNIT_ASSERT_DESC( KErrNone == listener->WaitAndAssertL(), "UnsubscribePresentityGroupContentL failed" );
       
  1729     CleanupStack::PopAndDestroy( 5 ); // lists
       
  1730 
       
  1731     // verify that unsubscribe was NOT called (other contexts are listening too),
       
  1732     // and it will be unscubscribed on the last call
       
  1733     messenger->AssertUnsubscribePresentityGroupContentCalled( EFalse );
       
  1734 
       
  1735     // ------------------------------------------------------
       
  1736     // delete presentity group
       
  1737     //
       
  1738     // expect events:
       
  1739     // - request complete
       
  1740     // NO presentity group content event as we've just unsubscribed it.
       
  1741 
       
  1742     evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1743     listener->ExpectL( evReqComplete );
       
  1744     CleanupStack::Pop( evReqComplete );
       
  1745 
       
  1746     // do the call
       
  1747     reqId = presGroup.DeletePresentityGroupL( *currentGrId );
       
  1748 
       
  1749     // and wait
       
  1750     EUNIT_ASSERT_DESC( KErrNone == listener->WaitAndAssertL(), "DeletePresentityGroupL failed" );
       
  1751 
       
  1752     // ------------------------------------------------------
       
  1753 
       
  1754     CleanupStack::PopAndDestroy( 3 ); // listener, currentGrId, factory
       
  1755 
       
  1756     UnbindAllL();
       
  1757 
       
  1758     TeardownTestSupport();
       
  1759     }
       
  1760 
       
  1761 // ------------------------------------------------------
       
  1762 // General subscribe and unsubscribe for multiple
       
  1763 // Subscribed for one context only
       
  1764 // ------------------------------------------------------
       
  1765 //
       
  1766 void T_PresenceGroupMemberManagement::T_SubUnsubGroupContent_One_Multi_L()
       
  1767     {
       
  1768     BindAllL();
       
  1769 
       
  1770     CXIMPObjectFactoryImp* factory = CXIMPObjectFactoryImp::NewL();
       
  1771     CleanupStack::PushL( factory );
       
  1772 
       
  1773     MXIMPIdentity* currentGrId = factory->NewIdentityLC();
       
  1774     currentGrId->SetIdentityL( KGroupId );
       
  1775 
       
  1776     // create group to all connections
       
  1777     CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
       
  1778 
       
  1779     // ------------------------------------------------------
       
  1780     // some startup stuff
       
  1781     MXIMPContext* context = wrapper->GetContext();
       
  1782     CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
  1783 
       
  1784     // Get the interfaces
       
  1785     MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
  1786     MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
  1787 
       
  1788     CXIMPTestListener* listener = CXIMPTestListener::NewL( context );
       
  1789     CleanupStack::PushL( listener );
       
  1790     // ------------------------------------------------------
       
  1791 
       
  1792     // Tell the protocol it should act normally
       
  1793     wrapper->GetMessenger()->SetNoError();
       
  1794 
       
  1795     // ------------------------------------------------------
       
  1796     // create presentity group
       
  1797     //
       
  1798     // expect events:
       
  1799     // - request complete.
       
  1800     // NOTE: no presentitygrouplistevent as we've not subscribed the group lists
       
  1801 
       
  1802     // normal request complete
       
  1803     TXIMPRequestId reqIdDummy;  // not checked
       
  1804     CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1805 
       
  1806     // identity + displayname
       
  1807     CPresentityGroupInfoImp* infoImp = CPresentityGroupInfoImp::NewLC( *currentGrId, KGroupDisplayName );
       
  1808     evReqComplete->AppendParamL( infoImp );
       
  1809     CleanupStack::Pop( infoImp );
       
  1810 
       
  1811     listener->ExpectL( evReqComplete );
       
  1812     CleanupStack::Pop( evReqComplete );
       
  1813 
       
  1814     TXIMPRequestId reqId = presGroup.CreatePresentityGroupL( *currentGrId, KGroupDisplayName );
       
  1815 
       
  1816     // and wait
       
  1817     EUNIT_ASSERT_DESC( KErrNone == listener->WaitAndAssertL(), "CreatePresentityGroupL failed" );
       
  1818 
       
  1819     // verify that create was called
       
  1820     messenger->AssertCreatePresentityGroupCalled( ETrue );
       
  1821 
       
  1822     // ------------------------------------------------------
       
  1823     // subscribe presentity group CONTENT
       
  1824     //
       
  1825     // expect events:
       
  1826     // - request complete
       
  1827     evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1828     listener->ExpectL( evReqComplete );
       
  1829     CleanupStack::Pop( evReqComplete );
       
  1830 
       
  1831     // do the call
       
  1832     reqId = presGroup.SubscribePresentityGroupContentL( *currentGrId );
       
  1833 
       
  1834     // and wait
       
  1835     EUNIT_ASSERT_DESC( KErrNone == listener->WaitAndAssertL(), "SubscribePresentityGroupContentL failed" );
       
  1836 
       
  1837     // verify that subscribe was called
       
  1838     messenger->AssertSubscribePresentityGroupContentCalled( ETrue );
       
  1839 
       
  1840     // ------------------------------------------------------
       
  1841     // subscribe presentity group content, making a REFRESH case
       
  1842     // with multiple contexts
       
  1843     //
       
  1844     // expect events:
       
  1845     // - request complete
       
  1846     // - group content event
       
  1847 
       
  1848     evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1849     listener->ExpectL( evReqComplete );
       
  1850     CleanupStack::Pop( evReqComplete );
       
  1851 
       
  1852     CPresentityGroupContentEventImp* groupCntEvent =
       
  1853         XIMPTestEventFactory::CreateGroupContentEventLCX(
       
  1854                 KGroupId,
       
  1855                 KNullDesC,
       
  1856                 KNullDesC,
       
  1857                 XIMPTestEventFactory::ETestPGLCntUpdated,
       
  1858                 KNullDesC,
       
  1859                 KNullDesC,
       
  1860                 MXIMPDataSubscriptionState::ESubscriptionActive,
       
  1861                 MXIMPDataSubscriptionState::EDataUnavailable
       
  1862                 );
       
  1863 
       
  1864     listener->ExpectL( groupCntEvent );
       
  1865     CleanupStack::Pop( groupCntEvent ); // 5 more items in cleanupstack
       
  1866 
       
  1867     // do the call
       
  1868     reqId = presGroup.SubscribePresentityGroupContentL( *currentGrId );
       
  1869 
       
  1870     // and wait
       
  1871     EUNIT_ASSERT_DESC( KErrNone == listener->WaitAndAssertL(), "SubscribePresentityGroupContentL failed" );
       
  1872 
       
  1873     CleanupStack::PopAndDestroy( 5 ); // rest of group the content event
       
  1874 
       
  1875     // verify that subscribe was called
       
  1876     messenger->AssertSubscribePresentityGroupContentCalled( ETrue );
       
  1877 
       
  1878     // ------------------------------------------------------
       
  1879     // unsubscribe presentity group content
       
  1880     //
       
  1881     // expect events:
       
  1882     // - request complete
       
  1883     // - presentity group content event
       
  1884 
       
  1885     evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1886     listener->ExpectL( evReqComplete );
       
  1887     CleanupStack::Pop( evReqComplete );
       
  1888 
       
  1889     groupCntEvent =
       
  1890         XIMPTestEventFactory::CreateGroupContentEventLCX(
       
  1891                 KGroupId,
       
  1892                 KNullDesC,
       
  1893                 KNullDesC,
       
  1894                 XIMPTestEventFactory::ETestPGLCntRemoved,
       
  1895                 KNullDesC,
       
  1896                 KNullDesC,
       
  1897                 MXIMPDataSubscriptionState::ESubscriptionInactive,
       
  1898                 MXIMPDataSubscriptionState::EDataUnavailable
       
  1899                 );
       
  1900 
       
  1901     listener->ExpectL( groupCntEvent );
       
  1902     CleanupStack::Pop( groupCntEvent ); // 5 more items in cleanupstack
       
  1903 
       
  1904     // do the call
       
  1905     reqId = presGroup.UnsubscribePresentityGroupContentL( *currentGrId );
       
  1906 
       
  1907     // and wait
       
  1908     EUNIT_ASSERT_DESC( KErrNone == listener->WaitAndAssertL(), "UnsubscribePresentityGroupContentL failed" );
       
  1909     CleanupStack::PopAndDestroy( 5 ); // lists
       
  1910 
       
  1911     // verify that unsubscribe was called
       
  1912     // unsubscribe really called only on the last one
       
  1913     messenger->AssertUnsubscribePresentityGroupContentCalled( ETrue );
       
  1914 
       
  1915     // ------------------------------------------------------
       
  1916     // delete presentity group
       
  1917     //
       
  1918     // expect events:
       
  1919     // - request complete
       
  1920     // NO presentity group content event as we've just unsubscribed it.
       
  1921 
       
  1922     evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1923     listener->ExpectL( evReqComplete );
       
  1924     CleanupStack::Pop( evReqComplete );
       
  1925 
       
  1926     // do the call
       
  1927     reqId = presGroup.DeletePresentityGroupL( *currentGrId );
       
  1928 
       
  1929     // and wait
       
  1930     EUNIT_ASSERT_DESC( KErrNone == listener->WaitAndAssertL(), "DeletePresentityGroupL failed" );
       
  1931 
       
  1932     // ------------------------------------------------------
       
  1933 
       
  1934     CleanupStack::PopAndDestroy( 3 ); // listener, currentGrId, factory
       
  1935 
       
  1936     UnbindAllL();
       
  1937 
       
  1938     TeardownTestSupport();
       
  1939     }
       
  1940 
       
  1941 // Unsubscribe non-subscribed
       
  1942 void T_PresenceGroupMemberManagement::T_UnsubscribeNonSubscribed_L()
       
  1943     {
       
  1944     CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
       
  1945     wrapper->BindL( 0 );
       
  1946 
       
  1947     // ------------------------------------------------------
       
  1948     // some startup stuff
       
  1949     MXIMPContext* context = wrapper->GetContext();
       
  1950     CXIMPTestMessenger* messenger = wrapper->GetMessenger();
       
  1951 
       
  1952     // Get the interfaces
       
  1953     MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
       
  1954     MPresentityGroups& presGroup = presFeat->PresentityGroups();
       
  1955 
       
  1956     iListener2 = CXIMPTestListener::NewL( context );
       
  1957     // ------------------------------------------------------
       
  1958 
       
  1959     // Tell the protocol it should act normally
       
  1960     wrapper->GetMessenger()->SetNoError();
       
  1961 
       
  1962     iCurrentGrId = context->ObjectFactory().NewIdentityLC();
       
  1963     CleanupStack::Pop(); // iCurrentGrId
       
  1964     iCurrentGrId->SetIdentityL( KGroupId );
       
  1965 
       
  1966     // ------------------------------------------------------
       
  1967     // create presentity group
       
  1968     //
       
  1969     // expect events:
       
  1970     // - request complete.
       
  1971     // NOTE: no presentitygrouplistevent as we've not subscribed the group lists
       
  1972 
       
  1973     // normal request complete
       
  1974     TXIMPRequestId reqIdDummy;  // not checked
       
  1975     CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1976 
       
  1977     // identity + displayname
       
  1978     CPresentityGroupInfoImp* infoImp = CPresentityGroupInfoImp::NewLC( *iCurrentGrId, KGroupDisplayName );
       
  1979     evReqComplete->AppendParamL( infoImp );
       
  1980     CleanupStack::Pop( infoImp );
       
  1981 
       
  1982     iListener2->ExpectL( evReqComplete );
       
  1983     CleanupStack::Pop( evReqComplete );
       
  1984 
       
  1985     TXIMPRequestId reqId = presGroup.CreatePresentityGroupL( *iCurrentGrId, KGroupDisplayName );
       
  1986 
       
  1987     // and wait
       
  1988     EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "CreatePresentityGroupL failed" );
       
  1989     messenger->AssertCreatePresentityGroupCalled( ETrue );
       
  1990 
       
  1991     // ------------------------------------------------------
       
  1992     // unsubscribe presentity group content
       
  1993     //
       
  1994     // expect events:
       
  1995     // - request complete
       
  1996     // - presentity group content event
       
  1997 
       
  1998     evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
       
  1999     iListener2->ExpectL( evReqComplete );
       
  2000     CleanupStack::Pop( evReqComplete );
       
  2001 
       
  2002     CPresentityGroupContentEventImp* groupCntEvent =
       
  2003         XIMPTestEventFactory::CreateGroupContentEventLCX(
       
  2004                 KGroupId,
       
  2005                 KNullDesC,
       
  2006                 KNullDesC,
       
  2007                 XIMPTestEventFactory::ETestPGLCntRemoved,
       
  2008                 KNullDesC,
       
  2009                 KNullDesC,
       
  2010                 MXIMPDataSubscriptionState::ESubscriptionInactive,
       
  2011                 MXIMPDataSubscriptionState::EDataUnavailable
       
  2012                 );
       
  2013 
       
  2014     iListener2->ExpectL( groupCntEvent );
       
  2015     CleanupStack::Pop( groupCntEvent ); // 5 more items in cleanupstack
       
  2016 
       
  2017     // do the call
       
  2018     reqId = presGroup.UnsubscribePresentityGroupContentL( *iCurrentGrId );
       
  2019 
       
  2020     // and wait
       
  2021     EUNIT_ASSERT_DESC( KErrNone == iListener2->WaitAndAssertL(), "UnsubscribePresentityGroupContentL failed" );
       
  2022 
       
  2023     CleanupStack::PopAndDestroy( 5 ); // lists
       
  2024 
       
  2025     // verify that unsubscribe was not called, not subscribed, so won't
       
  2026     // unsubscribe
       
  2027     messenger->AssertUnsubscribePresentityGroupContentCalled( EFalse );
       
  2028 
       
  2029     // make sure the new listener is not listening for events!
       
  2030     iListener2->SetEventSourceL( NULL );
       
  2031 
       
  2032     wrapper->UnbindL();
       
  2033 
       
  2034     TeardownTestSupport();
       
  2035     }
       
  2036 
       
  2037 // ===========================================================================
       
  2038 // SETUP HELPERS FOR THE LISTENER
       
  2039 // ===========================================================================
       
  2040 //
       
  2041 void T_PresenceGroupMemberManagement::SetupListenerReqCompleteL( CXIMPTestContextWrapper* aWrapper, TXIMPTestStatusEventTemplate aEventType )
       
  2042     {
       
  2043     RArray< TInt32 > array;
       
  2044     CleanupClosePushL( array );
       
  2045     array.Append( MXIMPContextStateEvent::KInterfaceId );
       
  2046     array.Append( MPresentityGroupListEvent::KInterfaceId );
       
  2047     aWrapper->SetupListenerReqCompleteL( aEventType, &array );
       
  2048     CleanupStack::PopAndDestroy(); // array
       
  2049     }
       
  2050 
       
  2051 void T_PresenceGroupMemberManagement::SetupListenerReqCompleteAllowEventsL(  CXIMPTestContextWrapper* aWrapper, TXIMPTestStatusEventTemplate aEventType )
       
  2052     {
       
  2053     RArray< TInt32 > array;
       
  2054     CleanupClosePushL( array );
       
  2055     array.AppendL( MXIMPRequestCompleteEvent::KInterfaceId );
       
  2056     array.AppendL( MXIMPContextStateEvent::KInterfaceId );
       
  2057     array.Append( MPresentityGroupListEvent::KInterfaceId );
       
  2058     array.Append( MXIMPContextStateEvent::KInterfaceId );
       
  2059     array.Append( MPresentityGroupListEvent::KInterfaceId );
       
  2060     array.Append( MPresentityGroupContentEvent::KInterfaceId );
       
  2061     aWrapper->SetupListenerReqCompleteL( aEventType, &array );
       
  2062     CleanupStack::PopAndDestroy(); // array
       
  2063     }
       
  2064 
       
  2065 // ===========================================================================
       
  2066 // TEST CASE TABLE
       
  2067 // ===========================================================================
       
  2068 //
       
  2069 EUNIT_BEGIN_TEST_TABLE(
       
  2070         T_PresenceGroupMemberManagement,
       
  2071         "XIMP presence group member management tests",
       
  2072         "MODULE" )
       
  2073 
       
  2074 PRFW_DECORATED_TEST(
       
  2075         "Subscribe and unsubscribe presentity group content",
       
  2076         "",
       
  2077         "",
       
  2078         "FUNCTIONALITY",
       
  2079         Setup_L,
       
  2080         T_SubUnsubGroupContent_Single_L,
       
  2081         Teardown )
       
  2082 
       
  2083 PRFW_DECORATED_TEST(
       
  2084         "Subscribe and unsubscribe multiple",
       
  2085         "",
       
  2086         "",
       
  2087         "FUNCTIONALITY",
       
  2088         SetupMultiple_L,
       
  2089         T_SubUnsubGroupContent_Multi_L,
       
  2090         Teardown )
       
  2091 
       
  2092 PRFW_DECORATED_TEST(
       
  2093         "Refresh subscription for one, multiple",
       
  2094         "",
       
  2095         "",
       
  2096         "FUNCTIONALITY",
       
  2097         SetupMultiple_L,
       
  2098         T_SubUnsubGroupContent_One_Multi_L,
       
  2099         Teardown )
       
  2100 
       
  2101 PRFW_DECORATED_TEST(
       
  2102         "Refresh subscription for all, multiple",
       
  2103         "",
       
  2104         "",
       
  2105         "FUNCTIONALITY",
       
  2106         SetupMultiple_L,
       
  2107         T_SubUnsubGroupContent_All_Multi_L,
       
  2108         Teardown )
       
  2109 
       
  2110 PRFW_DECORATED_TEST(
       
  2111         "Subscribe content and receive altered id",
       
  2112         "",
       
  2113         "",
       
  2114         "FUNCTIONALITY",
       
  2115         Setup_L,
       
  2116         T_SubUnsubGroupContent_Altered_Single_L,
       
  2117         Teardown )
       
  2118 
       
  2119 PRFW_DECORATED_TEST(
       
  2120         "Subscribe content and receive altered but same id",
       
  2121         "",
       
  2122         "",
       
  2123         "FUNCTIONALITY",
       
  2124         Setup_L,
       
  2125         T_SubUnsubGroupContent_AlteredSame_Single_L,
       
  2126         Teardown )
       
  2127 
       
  2128 PRFW_DECORATED_TEST(
       
  2129         "Unsubscribe non-subscribed",
       
  2130         "",
       
  2131         "",
       
  2132         "FUNCTIONALITY",
       
  2133         Setup_L,
       
  2134         T_UnsubscribeNonSubscribed_L,
       
  2135         Teardown )
       
  2136 
       
  2137 PRFW_DECORATED_TEST(
       
  2138         "Add members to group",
       
  2139         "",
       
  2140         "",
       
  2141         "FUNCTIONALITY",
       
  2142         Setup_L,
       
  2143         T_AddGroupMembers_Single_L,
       
  2144         Teardown )
       
  2145 
       
  2146 PRFW_DECORATED_TEST(
       
  2147         "Remove members from group",
       
  2148         "",
       
  2149         "",
       
  2150         "FUNCTIONALITY",
       
  2151         Setup_L,
       
  2152         T_RemoveGroupMembers_Single_L,
       
  2153         Teardown )
       
  2154 
       
  2155 PRFW_DECORATED_TEST(
       
  2156         "Remove members from unsubscribed group",
       
  2157         "",
       
  2158         "",
       
  2159         "FUNCTIONALITY",
       
  2160         Setup_L,
       
  2161         T_RemoveGroupMembers_NonSub_Single_L,
       
  2162         Teardown )
       
  2163 
       
  2164 PRFW_DECORATED_TEST(
       
  2165         "Remove nonexisting member from group",
       
  2166         "",
       
  2167         "",
       
  2168         "FUNCTIONALITY",
       
  2169         Setup_L,
       
  2170         T_RemoveGroupMembers_NonExist_Single_L,
       
  2171         Teardown )
       
  2172 
       
  2173 PRFW_DECORATED_TEST(
       
  2174         "Updated members from group",
       
  2175         "",
       
  2176         "",
       
  2177         "FUNCTIONALITY",
       
  2178         Setup_L,
       
  2179         T_UpdateGroupMembers_Single_L,
       
  2180         Teardown )
       
  2181 
       
  2182 PRFW_DECORATED_TEST(
       
  2183         "Updated members from nonsubscribed group",
       
  2184         "",
       
  2185         "",
       
  2186         "FUNCTIONALITY",
       
  2187         Setup_L,
       
  2188         T_UpdateGroupMembers_NonSub_Single_L,
       
  2189         Teardown )
       
  2190 
       
  2191 PRFW_DECORATED_TEST(
       
  2192         "Updated nonexisting member of group",
       
  2193         "",
       
  2194         "",
       
  2195         "FUNCTIONALITY",
       
  2196         Setup_L,
       
  2197         T_UpdateGroupMembers_NonExist_Single_L,
       
  2198         Teardown )
       
  2199 
       
  2200 PRFW_DECORATED_TEST(
       
  2201         "Expire non-subscribed data",
       
  2202         "",
       
  2203         "",
       
  2204         "FUNCTIONALITY",
       
  2205         Setup_L,
       
  2206         T_ExpireNonSubscribedData_L,
       
  2207         Teardown )
       
  2208 
       
  2209 PRFW_DECORATED_TEST(
       
  2210         "Expire non-subscribed data. Update multiple times",
       
  2211         "",
       
  2212         "",
       
  2213         "FUNCTIONALITY",
       
  2214         Setup_L,
       
  2215         T_ExpireNonSubscribedDataUpdateMultiple_L,
       
  2216         Teardown )
       
  2217 
       
  2218 
       
  2219 EUNIT_END_TEST_TABLE
       
  2220 
       
  2221 
       
  2222 // ===========================================================================
       
  2223 // TEST SUITE CONSTRUCTION
       
  2224 // ===========================================================================
       
  2225 //
       
  2226 EXPORT_C MEUnitTest* CreateTestSuiteL()
       
  2227     {
       
  2228     return T_PresenceGroupMemberManagement::NewL();
       
  2229     }
       
  2230 
       
  2231 // TODO implement this (split this file to multiple parts):
       
  2232 /*
       
  2233 // ===========================================================================
       
  2234 // TEST SUITE CONSTRUCTION
       
  2235 // ===========================================================================
       
  2236 //
       
  2237 EXPORT_C MEUnitTest* CreateTestSuiteL()
       
  2238     {
       
  2239     CEUnitTestSuite* suiteCollection = CEUnitTestSuite::NewLC( _L("XIMP group list management tests") );
       
  2240 
       
  2241     CEUnitTestSuite* suite = T_PresenceGroupListManagement::NewL();
       
  2242     CleanupStack::PushL( suite );
       
  2243     suiteCollection->AddL( suite );
       
  2244     CleanupStack::Pop( suite );
       
  2245 
       
  2246     suite = T_xxx::NewL();
       
  2247     CleanupStack::PushL( suite );
       
  2248     suiteCollection->AddL( suite );
       
  2249     CleanupStack::Pop( suite );
       
  2250 
       
  2251     CleanupStack::Pop( suiteCollection );
       
  2252     return suiteCollection;
       
  2253     }
       
  2254 
       
  2255 */
       
  2256 
       
  2257 
       
  2258 
       
  2259 // ===========================================================================
       
  2260 // MISC
       
  2261 // ===========================================================================
       
  2262 //
       
  2263 //Exception handler function
       
  2264 void MyExceptionHandler( TExcType /*aType*/ )
       
  2265     {
       
  2266     __BREAKPOINT();
       
  2267     }
       
  2268 
       
  2269 void T_PresenceGroupMemberManagement::UseMyOwnExceptionHandler()
       
  2270     {
       
  2271     //Register exeption handler
       
  2272     TInt r = User::SetExceptionHandler( MyExceptionHandler, 0xFFFFFFFF );
       
  2273     if (r != KErrNone)
       
  2274         {
       
  2275         User::Panic( _L("MyExHandler"), 1 );
       
  2276         }
       
  2277     }
       
  2278 
       
  2279 
       
  2280 // end of file