Ejemplo n.º 1
0
void T_CGlxCache::T_CGlxCache_Delete_SubTest5L(  )
    {
    // Create helper class
    T_CacheTestHelpers cacheTestHelper(iCGlxCache);

    // Create media user class
    CGlxMediaUserTest* mediaUser = CGlxMediaUserTest::NewL();
    CleanupStack::PushL(mediaUser);

    cacheTestHelper.ItemPool()[1]->ReserveUsersL(1);
    cacheTestHelper.ItemPool()[1]->AddUser(*mediaUser, KErrNotFound);

    // Delete item where user has reference to media
    EUNIT_PRINT(_L("Delete item where user has reference to media"));
    iCGlxCache->Delete(1);

    EUNIT_PRINT(_L("Check item deleted"));
    EUNIT_ASSERT_DESC(cacheTestHelper.ItemPool().Count() == 1, "Cache doesn't contain one item");

    TInt media1Index = cacheTestHelper.ItemPool().FindInOrder(TGlxMediaId(KMediaId1), T_CacheTestHelpers::MediaItemOrderByKey);
    EUNIT_ASSERT_DESC(media1Index != KErrNotFound, "Incorrect item deleted from cache");

    EUNIT_PRINT(_L("Check user called to remove reference"));
    EUNIT_ASSERT_DESC(mediaUser->RemoveReferenceCalled(), "User not called to remove reference");

    CleanupStack::PopAndDestroy(mediaUser);
    }
Ejemplo n.º 2
0
void T_CGlxCache::T_CGlxCache_Delete_SubTest3L(  )
    {
    // Create helper class
    T_CacheTestHelpers cacheTestHelper(iCGlxCache);

    // Create item without users
    CGlxMedia* media3 = new (ELeave) CGlxMedia(TGlxMediaId(KMediaId3));
    CleanupStack::PushL(media3);

    media3->SetTObjectValueL<TBool>(KGlxMediaGeneralSystemItem, EFalse);
    cacheTestHelper.ItemPool().AppendL(media3);

    CleanupStack::Pop(media3);

    // Delete item without users
    EUNIT_PRINT(_L("Delete item without users"));
    iCGlxCache->Delete(2);

    EUNIT_PRINT(_L("Check item deleted"));
    EUNIT_ASSERT_DESC(cacheTestHelper.ItemPool().Count() == 2, "Cache doesn't contain two items");

    TInt media1Index = cacheTestHelper.ItemPool().FindInOrder(TGlxMediaId(KMediaId1), T_CacheTestHelpers::MediaItemOrderByKey);
    TInt media2Index = cacheTestHelper.ItemPool().FindInOrder(TGlxMediaId(KMediaId2), T_CacheTestHelpers::MediaItemOrderByKey);
    EUNIT_ASSERT_DESC((media1Index != KErrNotFound) && (media2Index != KErrNotFound), "Incorrect item deleted from cache");
    }
// Single client, empty filter
void T_PresencePublishing::T_SubscribeOwnPresence_Single_Empty_L()
    {
    EUNIT_PRINT( _L("Single interest registration") );

    BindL();

    CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
    MXIMPContext* context = wrapper->GetContext();
    CXIMPTestMessenger* messenger = wrapper->GetMessenger();


    CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context );
    CleanupStack::PushL( listener2 );

    // Tell the protocol it should act normally
    messenger->SetNoError();

    // Get the interfaces
    MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
    MPresencePublishing& presPub = presFeat->PresencePublishing();

    // Create the empty presence info filter
    CPresenceInfoFilterImp* pif = CPresenceInfoFilterImp::NewLC();

    // Setup status event listener for RequestComplete
    listener2->Reset();
    // normal request complete
    TXIMPRequestId reqIdDummy;  // not checked
    CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
    listener2->ExpectL( evReqComplete );
    CleanupStack::Pop( evReqComplete );

    // subscribe own presence
    TXIMPRequestId reqId = presPub.SubscribeOwnPresenceL( *pif );

    // Wait for events on the request
    EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "SubscribeOwnPresence failed" );

    // verify that SubscribeOwnPresenceL was called
    COMMONASSERT( messenger, EXIMPPlgTestSubscribeOwnPresenceCalled, "SubscribeOwnPresenceL was not called", ETrue, NULL );

    // Setup status event listener for RequestComplete
    listener2->Reset();
    evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
    listener2->ExpectL( evReqComplete );
    CleanupStack::Pop( evReqComplete );
  
    // unsubscribe own presence
    reqId = presPub.UnsubscribeOwnPresenceL();

    // Wait for events on the request
    EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "UnsubscribeOwnPresence failed" );
    
    // verify that UnsubscribeOwnPresenceL was called
    COMMONASSERT( messenger, EXIMPPlgTestUnsubscribeOwnPresenceCalled, "UnsubscribeOwnPresenceL was not called", ETrue, NULL );

    CleanupStack::PopAndDestroy( pif );
    CleanupStack::PopAndDestroy( listener2 );
    UnbindL();
    }
// from MCFContextSource
void UT_CCFContextManager::NoSubscribers( const TDesC& aContextSource,
    const TDesC& aContextType )
	{
	iNoSubscribersCalled = ETrue;
	EUNIT_ASSERT_DESC( iExpectedSubscribersSource.Compare( aContextSource ) == 0,
	"No expected source");
	EUNIT_ASSERT_DESC( iExpectedSubscribersType.Compare( aContextType ) == 0,
	"No expected type");
	}
Ejemplo n.º 5
0
void UT_CCFEngine::UT_RemoveSubscriptionDuringIdicationL()
    {
    RThread thread;
    CleanupClosePushL(thread);

    CCFContextSubscription* subscription1 = CCFContextSubscription::NewLC();
    subscription1->SetContextSourceL(_L("testsource"));
    subscription1->SetContextTypeL(_L("listenedtype"));
    CleanupStack::Pop( subscription1 );

    // make the dummy subscription
    TInt error = iCFContextInterface->SubscribeContext(subscription1,
        this, thread);
    EUNIT_ASSERT_DESC ( error == KErrNone, "Subscription did not succeeded!");

    CCFContextSubscription* subscription2 = CCFContextSubscription::NewLC();
    subscription2->SetContextSourceL(_L("testsource"));
    subscription2->SetContextTypeL(_L("listenedtype"));
    CleanupStack::Pop( subscription2 );

    // make subscription    
    error = iCFContextInterface->SubscribeContext(subscription2, this, thread);
    EUNIT_ASSERT_DESC ( error == KErrNone, "Subscription did not succeeded!");

    // define context
    static _LIT_SECURITY_POLICY_PASS( alwaysPass );
    error = iCFContextInterface->DefineContext( _L("testsource"),
        _L("listenedtype"), alwaysPass );
    EUNIT_ASSERT_DESC ( error == KErrNone, "DefineContext did not succeeded!");

    // Set remove susbcription that will be removed during next context
    // indication
    iRemoveSubscription = subscription1;

    iIndication = EFalse;
    CCFContextObject* co = CCFContextObject::NewLC();
    co->SetSourceL(_L("testsource"));
    co->SetTypeL(_L("listenedtype"));
    co->SetValueL(_L("testvalue"));
    error = iCFContextInterface->PublishContext( *co, thread );

    iTestDelay->Start( KSecond / 2 );

    // check that we get the published context
    EUNIT_ASSERT_DESC ( iIndication, "Context indication shoud have arrived");
    iIndication = EFalse;

    CleanupStack::PopAndDestroy( co );
    CleanupStack::PopAndDestroy( &thread );
    }
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
void T_PresenceWatcherListManagement::UnsubscribeL()
    {
    CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
    MXIMPContext* context = wrapper->GetContext();
    CXIMPTestMessenger* messenger = wrapper->GetMessenger();

    // Get the interfaces
    MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
    MPresencePublishing& presPub = presFeat->PresencePublishing();

    // Setup status event listener for RequestComplete
    CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context );
    CleanupStack::PushL( listener2 );

    // Setup status event listener for RequestComplete
    listener2->Reset();

    TXIMPRequestId reqIdDummy;  // not checked
    CXIMPRequestCompleteEventImp* evReqComplete =
                    CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
    listener2->ExpectL( evReqComplete );
    CleanupStack::Pop( evReqComplete );

    // unsubscribe
    TXIMPRequestId reqId = presPub.UnsubscribePresenceWatcherListL();

    EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsbscribe failed" );

    // verify that UnsubscribeWatcherListL was called
    COMMONASSERT( messenger, EXIMPPlgTestUnsubscribePresenceWatcherListCalled, "UnsubscribeWatcherListL was not called", ETrue, NULL );

    CleanupStack::PopAndDestroy( listener2 );

    }
Ejemplo n.º 7
0
// ===========================================================================
// USAGE SCENARIO:
//
// ===========================================================================
//
void T_RootServices::Test_ListProtocolsAndTheirCapabilities_L()
    {
    //Initialize XIMP client
    MXIMPClient* presClient = MXIMPClient::NewClientL();
    CleanupDeletePushL( presClient );

    RXIMPObjOwningPtrArray< MXIMPProtocolInfo > protocolList;
    CleanupClosePushL( protocolList );

    //List & dump all available protocols
    presClient->GetProtocolsL( protocolList );
    __DumpProtocolListL( protocolList );

    //Verify that atleast main test protocol exist in list
    //And for it is reported corect properties
    TBool mainTestProtocolFound( EFalse );
    for ( TInt index( 0 ); index < protocolList.Count(); index++ )
        {
        MXIMPProtocolInfo& protocol = *protocolList[ index ];
        if (protocol.DisplayName() == K_PRFW_TST_PROTOCOL_1_DISPLAY_NAME )
            {
            if ( protocol.ImplementationUid() == TUid::Uid( K_PRFW_TST_PROTOCOL_1_IMPLEMENTATION_UID ) ) 
                {
                mainTestProtocolFound = ETrue;
                break;
                }
            }
        }

    EUNIT_ASSERT_DESC( mainTestProtocolFound, "Primary test protocol not found." );

    CleanupStack::PopAndDestroy(); //protocolList
    CleanupStack::PopAndDestroy(); //presClient
    }
 ///NEW BIND   
 EXPORT_C void CXIMPTestContextWrapper::BindWithSettingsL( TInt aId )
    {
    SetupListenerL( EXIMPTestStatusEvents_BindingOk );
    iMessenger->SetNoError();
    iMessenger->SetPluginIndex( 0/*aId*/ );

    // create fake info
    TInt extraLength = 8; // bad style... but length is enough

    HBufC* fakeSrv = HBufC::NewLC( KTestFakeServer().Length() + extraLength );
    fakeSrv->Des().AppendFormat( KTestFakeServer, aId );

    HBufC* fakeUser = HBufC::NewLC( KTestFakeUser().Length() + extraLength );
    fakeUser->Des().AppendFormat( KTestFakeUser, aId );

    HBufC* fakePass = HBufC::NewLC( KTestFakePassword().Length() + extraLength );
    fakePass->Des().AppendFormat( KTestFakePassword, aId );

    delete iFileTool;
    iFileTool = NULL;
    iFileTool = CXIMPTestFileTool::NewL( KTestProtocolUid.iUid, iIndex );

    TXIMPRequestId reqId = iContext->BindToL(
            KTestProtocolUid, aId );

    CleanupStack::PopAndDestroy( 3, fakeSrv );

    WaitRequestAndStackEvents( reqId );
    VerifyEventStackL( _L8("Binding (wrapper BindWithSettingsL): ") );

    EUNIT_ASSERT_DESC( iMessenger->GetBoolean( EXIMPPlgTestOpenSessionCalled ) ||
                       iMessenger->GetBoolean( EXIMPPlgTestShareSessionCalled ), "OpenSessionL was not called" );
    }
void T_PresenceGroupListManagement::SubscribeL()
    {
    CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
    MXIMPContext* context = wrapper->GetContext();
    CXIMPTestMessenger* messenger = wrapper->GetMessenger();

    // Get the interfaces
    MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
    MPresentityGroups& presGroup = presFeat->PresentityGroups();

    CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context );
    CleanupStack::PushL( listener2 );

    // ------------------------------------------------------
    // expect normal request complete
    TXIMPRequestId reqIdDummy;  // not checked
    CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
    listener2->ExpectL( evReqComplete );
    CleanupStack::Pop( evReqComplete );
    // ------------------------------------------------------

    // subscribe
    TXIMPRequestId reqId = presGroup.SubscribePresentityGroupListL();
    EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" );
    messenger->AssertSubscribePresentityGroupListCalled( ETrue );

    CleanupStack::PopAndDestroy( listener2 );
    }
// ---------------------------------------------------------------------------
// ?description_if_needed
// ---------------------------------------------------------------------------
//
EXPORT_C void CXIMPTestContextWrapper::BindL(
        TUid aUid,
        const TDesC& aServer,
        const TDesC& aUser,
        const TDesC& aPassword )
    {
    SetupListenerL( EXIMPTestStatusEvents_BindingOk );
    iMessenger->SetNoError();
    iMessenger->SetPluginIndex( iIndex );

    delete iFileTool;
    iFileTool = NULL;
    iFileTool = CXIMPTestFileTool::NewL( aUid.iUid, iIndex );

    TXIMPRequestId reqId = iContext->BindToL(
            aUid,
            aServer,
            aUser,
            aPassword,
            *iInstance,
            iIndex );

    WaitRequestAndStackEvents( reqId );
    VerifyEventStackL( _L8("Binding (wrapper BindL): ") );

    EUNIT_ASSERT_DESC( iMessenger->GetBoolean( EXIMPPlgTestOpenSessionCalled ) ||
                       iMessenger->GetBoolean( EXIMPPlgTestShareSessionCalled ), "OpenSessionL was not called" );
    }
void T_PresenceGroupListManagement::SubscribeGroupL( const TDesC& aGroupId )
    {
    CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
    MXIMPContext* context = wrapper->GetContext();
    CXIMPTestMessenger* messenger = wrapper->GetMessenger();

    // Get the interfaces
    MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
    MPresentityGroups& presGroup = presFeat->PresentityGroups();

    CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context );
    CleanupStack::PushL( listener2 );

    // ------------------------------------------------------
    // expect normal request complete
    TXIMPRequestId reqIdDummy;  // not checked
    CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
    listener2->ExpectL( evReqComplete );
    CleanupStack::Pop( evReqComplete );
    // ------------------------------------------------------

    // subscribe group content
    MXIMPIdentity* identity = context->ObjectFactory().NewIdentityLC();
    identity->SetIdentityL( aGroupId );

    TXIMPRequestId reqId = presGroup.SubscribePresentityGroupContentL( *identity );
    EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe content failed" );

    COMMONASSERT( messenger, EXIMPPlgTestSubscribePresentityGroupContentCalled, "SubscribeGroupContentL was not called", ETrue, NULL );

    CleanupStack::PopAndDestroy(); // identity
    CleanupStack::PopAndDestroy( listener2 );
    }
void UT_CCFContextManager::UT_CCFContextManager_NewLL(  )
    {
    CCFContextManager* instance = CCFContextManager::NewL( *this );
    CleanupStack::PushL ( instance );
    EUNIT_ASSERT_DESC ( instance, "CCFContextManager not created!" );
    CleanupStack::PopAndDestroy( instance );
    }
// Single client, empty filter, error in unsubscribe
void T_PresenceGroupListManagement::T_UnsubscribePresentityGroup_Error_Single_L()
    {
    EUNIT_PRINT( _L("Single presentity group list unsubscribe with error") );

    BindL();

    CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
    MXIMPContext* context = wrapper->GetContext();
    CXIMPTestMessenger* messenger = wrapper->GetMessenger();

    // Get the interfaces
    MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
    MPresentityGroups& presGroup = presFeat->PresentityGroups();

    CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context );
    CleanupStack::PushL( listener2 );

    // Tell the protocol it should act normally
    messenger->SetNoError();

    // ---------------------------------------------
    // subscribe
    TXIMPRequestId reqIdDummy;  // not checked
    CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
    listener2->ExpectL( evReqComplete );
    CleanupStack::Pop( evReqComplete );

    TXIMPRequestId reqId = presGroup.SubscribePresentityGroupListL();
    EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Subscribe failed" );
    messenger->AssertSubscribePresentityGroupListCalled( ETrue );

    // ---------------------------------------------
    // unsubscribe
    messenger->SetError( KErrArgument );
    evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
    evReqComplete->CompletionResultImp().SetResultCode( KErrArgument );
    listener2->ExpectL( evReqComplete );
    CleanupStack::Pop( evReqComplete );

    reqId = presGroup.UnsubscribePresentityGroupListL();
    EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe failed" );
    messenger->AssertUnsubscribePresentityGroupListCalled( ETrue );

    CleanupStack::PopAndDestroy( listener2 );

    UnbindL();
    }
Ejemplo n.º 14
0
void T_CGlxCache::T_CGlxCache_MediaL(  )
    {
    // Create helper class
    T_CacheTestHelpers cacheTestHelper(iCGlxCache);

    EUNIT_PRINT(_L("Obtain non-existing media by id"));
    CGlxMedia* media = iCGlxCache->Media(TGlxMediaId(KMediaId3));

    EUNIT_PRINT(_L("Check returned media"));
    EUNIT_ASSERT_DESC(media == NULL, "Media returned");

    EUNIT_PRINT(_L("Obtain media by id"));
    media = iCGlxCache->Media(TGlxMediaId(KMediaId1));

    EUNIT_PRINT(_L("Check returned media"));
    EUNIT_ASSERT_DESC(media == cacheTestHelper.ItemPool()[0], "Incorrect media returned");
    }
Ejemplo n.º 15
0
void T_CGlxCache::T_CGlxCache_CountL(  )
    {
    EUNIT_PRINT(_L("Obtain media count"));
    TInt count = iCGlxCache->Count();

    EUNIT_PRINT(_L("Check media count"));
    EUNIT_ASSERT_DESC(count == 2, "Incorrect media count");
    }
Ejemplo n.º 16
0
void T_CGlxCache::T_CGlxCache_Media2L(  )
    {
    EUNIT_PRINT(_L("Obtain media by index"));
    CGlxMedia& media = iCGlxCache->Media(1);

    EUNIT_PRINT(_L("Check returned media"));
    EUNIT_ASSERT_DESC(media.Id().Value() == KMediaId2, "Incorrect media returned");
    }
//-----------------------------------------------------------------------------
// MT_CFOperationPluginManager::T_CCFOperationPluginManager_NewLL
//-----------------------------------------------------------------------------
//
void MT_CFOperationPluginManager::T_CCFOperationPluginManager_NewLCL(  )
    {
    CCFOperationPluginManager* instance =
    CCFOperationPluginManager::NewLC( *this );

    EUNIT_ASSERT_DESC( instance, "CCFOperationPluginManager instance not created!" );
    
    CleanupStack::PopAndDestroy( instance );
    }
Ejemplo n.º 18
0
void T_CGlxCache::T_CGlxCache_FindItemForceCreateLL(  )
    {
    // Create helper class
    T_CacheTestHelpers cacheTestHelper(iCGlxCache);

    // Find existing instance
    EUNIT_PRINT(_L("Find existing media"));
    CGlxMedia* media = iCGlxCache->FindItemForceCreateL(TGlxMediaId(KMediaId1));

    EUNIT_PRINT(_L("Check returned media"));
    EUNIT_ASSERT_DESC(media == cacheTestHelper.ItemPool()[0], "Incorrect media returned");

    // Find non-existing media
    EUNIT_PRINT(_L("Find non-existing media"));
    media = iCGlxCache->FindItemForceCreateL(TGlxMediaId(KMediaId3));

    EUNIT_PRINT(_L("Check returned media"));
    EUNIT_ASSERT_DESC(media == cacheTestHelper.ItemPool()[2], "Incorrect media returned");
    }
Ejemplo n.º 19
0
void UT_CCFEngine::UT_CCFEngine_NewLCL(  )
    {
    CCFEngine* engine = CCFEngine::NewLC( *this );
    
    EUNIT_ASSERT_DESC( engine, "CFEngine not created!" );
    
    iTestDelay->Start( KSecond * 2 );

    CleanupStack::PopAndDestroy(engine);
    }
Ejemplo n.º 20
0
void UT_CCFEngine::UT_RemoveContextSubscriptionL()
	{
	RThread thread;
	CleanupClosePushL(thread);

	CCFContextSubscription* subscription = CCFContextSubscription::NewLC();
	subscription->SetContextSourceL(_L("testsource"));
	subscription->SetContextTypeL(_L("listenedtype"));
	CleanupStack::Pop( subscription );

	// make subscription	
	TInt error = iCFContextInterface->SubscribeContext(subscription,
		this, thread);
	EUNIT_ASSERT_DESC ( !error, "Subscription did not succeeded!");

	// define context
	static _LIT_SECURITY_POLICY_PASS( alwaysPass );
	error = iCFContextInterface->DefineContext( _L("testsource"),
		_L("listenedtype"), alwaysPass );
	EUNIT_ASSERT_DESC ( !error, "Could not define context!" );

	iCFContextInterface->UnsubscribeContext(*subscription,
		*this);
	EUNIT_ASSERT_DESC ( !error, "Could not remove context subscription!" );	
    
    iTestDelay->Start( KSecond / 2 );

	CCFContextObject* co = CCFContextObject::NewLC();
	co->SetSourceL(_L("testsource"));
	co->SetTypeL(_L("listenedtype"));
	co->SetValueL(_L("testvalue"));
	error = iCFContextInterface->PublishContext( *co, thread );	
	EUNIT_ASSERT_DESC ( !error, "Context publish returned an error!" );

    iTestDelay->Start( KSecond / 2 );

	// check that we get the published context
	EUNIT_ASSERT_DESC ( !iIndication, "Context indication did arrive");
	iIndication = EFalse;
		
	CleanupStack::PopAndDestroy( co );	
	CleanupStack::PopAndDestroy( &thread );	
	}
void T_PresenceGroupListManagement::UnsubscribeGroupL( const TDesC& aGroupId )
    {
    CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
    MXIMPContext* context = wrapper->GetContext();
    CXIMPTestMessenger* messenger = wrapper->GetMessenger();

    // Get the interfaces
    MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
    MPresentityGroups& presGroup = presFeat->PresentityGroups();

    CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context );
    CleanupStack::PushL( listener2 );

    // ------------------------------------------------------
    // expect normal request complete
    TXIMPRequestId reqIdDummy;  // not checked
    CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
    listener2->ExpectL( evReqComplete );
    CleanupStack::Pop( evReqComplete );

    // and a group content event, IF we have subscribed the group beforehand
    // i.e. SubscribeGroupL has been called before this

    MXIMPIdentity* identity = context->ObjectFactory().NewIdentityLC();
    identity->SetIdentityL( aGroupId );

    CPresentityGroupContentEventImp* groupCntEvent =
        XIMPTestEventFactory::CreateGroupContentEventLCX(
                aGroupId,
                KNullDesC,
                KNullDesC,
                XIMPTestEventFactory::ETestPGLCntRemoved,
                KNullDesC,
                KNullDesC,
                MXIMPDataSubscriptionState::ESubscriptionInactive,
                MXIMPDataSubscriptionState::EDataUnavailable
                );

    listener2->ExpectL( groupCntEvent );
    CleanupStack::Pop( groupCntEvent );

    // ------------------------------------------------------

    // unsubscribe

    TXIMPRequestId reqId = presGroup.UnsubscribePresentityGroupContentL( *identity );
    EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe group content failed" );
    messenger->AssertUnsubscribePresentityGroupContentCalled( ETrue );

    CleanupStack::PopAndDestroy( 5 ); // rest of the group content event
    CleanupStack::PopAndDestroy(); // identity

    CleanupStack::PopAndDestroy( listener2 );
    }
Ejemplo n.º 22
0
void UT_CCFEngine::UT_DefineContextL()
	{
	RThread thread;
	CleanupClosePushL( thread );
    static _LIT_SECURITY_POLICY_PASS( alwaysPass );

    // x. Define test context
    //--------------------------------------------------------------------------
    TInt err = iCFContextInterface->DefineContext(
        _L("testsource"), _L("testtype"), alwaysPass );
    EUNIT_ASSERT_DESC ( err == KErrNone, "Define context failed" );

    // x. Re-define test context
    //--------------------------------------------------------------------------
    err = iCFContextInterface->DefineContext(
        _L("testsource"), _L("testtype"), alwaysPass );
    EUNIT_ASSERT_DESC ( err == KErrNone, "Define context failed" );

	CleanupStack::PopAndDestroy( &thread );
	}
void UT_CCFContextManager::UT_CCFContextManager_RequestContextL_3L(  )
    {
	RThread thread;
	CleanupClosePushL(thread);
	
	SetupContextCacheL();
	CCFContextObject* co;
	
    EUNIT_ASSERT_NO_LEAVE( 
    	co = iCFContextManagerInterface->RequestContextL(
    	_L("TypeA"),
        _L("SourceA"),
        thread )
		);

	EUNIT_ASSERT_DESC( co->Source() == _L("SourceA"), "Source doesn't match!");
	EUNIT_ASSERT_DESC( co->Type() == _L("TypeA"), "Type doesn't match!");
	EUNIT_ASSERT_DESC( co->Value() == _L("ValueBA"), "Value doesn't match!");

	CleanupStack::PopAndDestroy( &thread );	
    }
// Single client, subscribed to the group, then subscribe list
void T_PresenceGroupListManagement::T_HandlePresentityGroupList_Subscribed_L()
    {
    EUNIT_PRINT( _L("Handle presentity group list, subscribed to the group.") );

    // log in
    BindL();
    SubscribeGroupL( KPresentUri1 );
    SubscribeL();

    // ------------------------------------------------------
    // some startup stuff
    CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
    MXIMPContext* context = wrapper->GetContext();

    CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context );
    CleanupStack::PushL( listener2 );
    // ------------------------------------------------------

    // Tell the protocol it should act normally
    wrapper->GetMessenger()->SetNoError();

    // ------------------------------------------------------
    // 1. Create faked server message about group list
    SendSrvMsgL( KPresentUri1,
            KPresentDispName1,
            CXIMPTestFileSrvMsg::ETestSrvMsgPresentityGroupCreate );

    // ------------------------------------------------------
    // expect empty MPresentityGroupList event.

    CPresentityGroupListEventImp* event = XIMPTestEventFactory::CreateGroupListEventLCX(
            KPresentUri1, KPresentDispName1,
            XIMPTestEventFactory::ETestPGLCreated,
            KPresentUri1, KPresentDispName1,
            MXIMPDataSubscriptionState::ESubscriptionActive,
            MXIMPDataSubscriptionState::EDataAvailable
            );

    listener2->ExpectL( event );
    CleanupStack::Pop( event ); // 4 more items in cleanupstack

    EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "HandlePresentityGroupListL failed" );
    CleanupStack::PopAndDestroy( 4 ); // lists
    // ------------------------------------------------------

    CleanupStack::PopAndDestroy( listener2 );

    // clean it up
    UnsubscribeL();
    UnsubscribeGroupL( KPresentUri1 );
    UnbindL();
    }
Ejemplo n.º 25
0
void T_CGlxCache::T_CGlxCache_HandleItemModifiedL(  )
    {
    // Create helper class
    T_CacheTestHelpers cacheTestHelper(iCGlxCache);

    RArray<TMPXAttribute> attributes;
    CleanupClosePushL(attributes);

    attributes.AppendL(KMPXMediaDrmProtected);

    EUNIT_PRINT(_L("Modify item attributes"));
    iCGlxCache->HandleItemModified(TGlxMediaId(KMediaId1), attributes);

    CleanupStack::PopAndDestroy(&attributes);

    EUNIT_PRINT(_L("Check attribute deleted as result of item modification"));
    TInt Media1AttributeCount = cacheTestHelper.ItemPool()[0]->Count();
    TInt Media2AttributeCount = cacheTestHelper.ItemPool()[1]->Count();
    
    EUNIT_ASSERT_DESC(Media1AttributeCount == 0, "Attribute not deleted for item modified");
    EUNIT_ASSERT_DESC(Media2AttributeCount == 1, "Attribute deleted for item not modified");
    }
// Single client, unsubscribe nonsubscribed
void T_PresenceGroupListManagement::T_UnsubNonsubscribed_Single_L()
    {
    EUNIT_PRINT( _L("Single unsubscribe nonsubscribed") );

    BindL();

    CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
    MXIMPContext* context = wrapper->GetContext();
    CXIMPTestMessenger* messenger = wrapper->GetMessenger();

    // Get the interfaces
    MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
    MPresentityGroups& presGroup = presFeat->PresentityGroups();

    CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context );
    CleanupStack::PushL( listener2 );

    // Tell the protocol it should act normally
    messenger->SetNoError();

    // ---------------------------------------------
    // unsubscribe
    TXIMPRequestId reqIdDummy;  // not checked
    CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );
    listener2->ExpectL( evReqComplete );
    CleanupStack::Pop( evReqComplete );

    // group list event with Unsubscribed
    CPresentityGroupListEventImp* event = XIMPTestEventFactory::CreateGroupListEventLCX(
            KNullDesC, KNullDesC,
            XIMPTestEventFactory::ETestPGLEmpty,

            KNullDesC, KNullDesC,
            MXIMPDataSubscriptionState::ESubscriptionInactive,
            MXIMPDataSubscriptionState::EDataUnavailable
            );

    listener2->ExpectL( event );
    CleanupStack::Pop( event ); // 4 more items in cleanupstack

    TXIMPRequestId reqId = presGroup.UnsubscribePresentityGroupListL();
    EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe failed" );
    CleanupStack::PopAndDestroy( 4 ); // rest of the group list event
    messenger->AssertUnsubscribePresentityGroupListCalled( EFalse );  // should not be called, no subscriptions

    CleanupStack::PopAndDestroy( listener2 );

    UnbindL();
    }
void UT_CCFContextManager::UT_CCFContextManager_RemoveSubscription2L()
    {
    RThread thread;
    CleanupClosePushL(thread);

    CCFContextSubscription* dummySubscription = CCFContextSubscription::NewLC();
    dummySubscription->SetContextSourceL(_L("testsource"));
    dummySubscription->SetContextTypeL(_L("listenedtype"));
    CleanupStack::Pop( dummySubscription );

    // make the dummy subscription
    EUNIT_ASSERT_NO_LEAVE (
        iCFContextManagerInterface->SubscribeContextL(dummySubscription,
        this, thread) );

    CCFContextSubscription* subscription = CCFContextSubscription::NewLC();
    subscription->SetContextSourceL(_L("testsource"));
    subscription->SetContextTypeL(_L("listenedtype"));
    CleanupStack::Pop( subscription );

    // make subscription    
    EUNIT_ASSERT_NO_LEAVE (
        iCFContextManagerInterface->SubscribeContextL(subscription,
        this, thread) );

    // define context
    static _LIT_SECURITY_POLICY_PASS( alwaysPass );
    EUNIT_ASSERT_NO_LEAVE (
        iCFContextManagerInterface->DefineContextL( _L("testsource"),
        _L("listenedtype"), alwaysPass, alwaysPass ) );

    EUNIT_ASSERT_NO_LEAVE (
        iCFContextManagerInterface->RemoveSubscription(*subscription,
        *this) );

    CCFContextObject* co = CCFContextObject::NewLC();
    co->SetSourceL(_L("testsource"));
    co->SetTypeL(_L("listenedtype"));
    co->SetValueL(_L("testvalue"));
    EUNIT_ASSERT_NO_LEAVE (
        iCFContextManagerInterface->PublishContextL( *co, thread ) );   
    
    // check that we get the published context
    EUNIT_ASSERT_DESC ( !iIndication, "Context indication shoud not have arrived");
    iIndication = EFalse;

    CleanupStack::PopAndDestroy( co );
    CleanupStack::PopAndDestroy( &thread );
    }
Ejemplo n.º 28
0
void UT_CCFEngine::UT_PublishContextL( )
	{
	RThread thread;
	CleanupClosePushL(thread);

	CCFContextObject* co = CCFContextObject::NewLC();
	co->SetSourceL(_L("testsource"));
	co->SetTypeL(_L("testtype"));
	co->SetValueL(_L("testvalue"));
	TInt error = iCFContextInterface->PublishContext( *co, thread );	
	EUNIT_ASSERT_DESC ( error, "Context published succeed without defining!" );
	
	static _LIT_SECURITY_POLICY_PASS( alwaysPass );
	error = iCFContextInterface->DefineContext( _L("testsource"),
		_L("testtype"), alwaysPass );
	
	EUNIT_ASSERT_DESC ( !error, "Could not define context!" );
	
	error = iCFContextInterface->PublishContext( *co, thread );	
	EUNIT_ASSERT_DESC ( !error, "Context published returned an error!" );
		
	CleanupStack::PopAndDestroy( co );
	CleanupStack::PopAndDestroy( &thread );
	}
// update display name of group without having subscribed to it
void T_PresenceGroupListManagement::T_UpdateDisplayNameL(
        const TDesC& aGroupId,
        const TDesC& aDispName )
    {
    CXIMPTestContextWrapper* wrapper = iWrapperMgr->GetWrapperL( 0 );
    MXIMPContext* context = wrapper->GetContext();
    CXIMPTestMessenger* messenger = wrapper->GetMessenger();

    // Get the interfaces
    MPresenceFeatures* presFeat = wrapper->GetPresenceFeatures();
    MPresentityGroups& presGroup = presFeat->PresentityGroups();

    wrapper->GetMessenger()->SetNoError();

    CXIMPTestListener* listener2 = CXIMPTestListener::NewL( context );
    CleanupStack::PushL( listener2 );

    MXIMPIdentity* groupId = context->ObjectFactory().NewIdentityLC();
    groupId->SetIdentityL( aGroupId );

    // ------------------------------------------------------
    // expect request complete with a group info imp inside
    TXIMPRequestId reqIdDummy;  // not checked
    CXIMPRequestCompleteEventImp* evReqComplete = CXIMPRequestCompleteEventImp::NewLC( reqIdDummy );

    CPresentityGroupInfoImp* grpInfo = CPresentityGroupInfoImp::NewLC(
            *groupId,
            aDispName );

    evReqComplete->AppendParamL( grpInfo );
    CleanupStack::Pop(); // grpInfo

    listener2->ExpectL( evReqComplete );
    CleanupStack::Pop( evReqComplete );

    // ------------------------------------------------------
    // update
    TXIMPRequestId reqId = presGroup.UpdatePresentityGroupDisplayNameL(
            *groupId,
            aDispName );

    EUNIT_ASSERT_DESC( KErrNone == listener2->WaitAndAssertL(), "Unsubscribe group content failed" );

    messenger->AssertUpdatePresentityGroupDisplayNameCalled( ETrue );

    CleanupStack::PopAndDestroy(); // groupId
    CleanupStack::PopAndDestroy( listener2 );
    }
// ---------------------------------------------------------------------------
// ?description_if_needed
// ---------------------------------------------------------------------------
//
EXPORT_C void CXIMPTestContextWrapper::UnbindL()
    {
    SetupListenerL( EXIMPTestStatusEvents_UnbindingOk );
    iMessenger->SetNoError();
    TXIMPRequestId reqId = iContext->UnbindL();

    WaitRequestAndStackEvents( reqId );
    VerifyEventStackL( _L8("Unbinding (wrapper UnbindL): ") );

    EUNIT_ASSERT_DESC( iMessenger->GetBoolean( EXIMPPlgTestCloseSessionCalled ) ||
                       iMessenger->GetBoolean( EXIMPPlgTestUnshareSessionCalled ) , "CloseSession was not called" );
    if( iMessenger->GetBoolean( EXIMPPlgTestCloseSessionCalled ) )
        {
        DeletePresenceContext();
        //EUNIT_ASSERT_DESC( iMessenger->GetBoolean( EXIMPPlgTestDeath ), "Plugin did not die, destructor not called.");
        }
    }