messagingfw/msgtestfw/TestActions/Capabilities/src/CMtfTestActionSendEMsvCancelOperation.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "CMtfTestActionSendEMsvCancelOperation.h"
       
    17 
       
    18 #include <e32std.h>
       
    19 #include <e32base.h>
       
    20 
       
    21 #include <msvipc.h>
       
    22 #include "MCLIENT.H"
       
    23 #include "MSERVER.H"
       
    24 
       
    25 
       
    26 #include "CMtfTestCase.h"
       
    27 #include "CMtfTestActionParameters.h"
       
    28 
       
    29 #include "IPCCommandForCapsPermissions.h"
       
    30 #include "SendProxyClient.h"
       
    31 #include "SendProxyserver.h"
       
    32 
       
    33 
       
    34 /**
       
    35   Function : NewL
       
    36   Description : 
       
    37   @internalTechnology
       
    38   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    39   @param : aActionParams - CMtfTestActionParameters 
       
    40   @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionSendEMsvCancelOperation object
       
    41   @pre none
       
    42   @post none
       
    43 */
       
    44 CMtfTestAction* CMtfTestActionSendEMsvCancelOperation::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    45 	{
       
    46 	CMtfTestActionSendEMsvCancelOperation* self = new (ELeave) CMtfTestActionSendEMsvCancelOperation(aTestCase);
       
    47 	CleanupStack::PushL(self);
       
    48 	self->ConstructL(aActionParameters);
       
    49 	CleanupStack::Pop(self);
       
    50 	return self;
       
    51 	}
       
    52 
       
    53 /**
       
    54   Function : CMtfTestActionSendEMsvCancelOperation
       
    55   Description : Constructor
       
    56   @internalTechnology
       
    57   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    58   @return : N/A
       
    59   @pre none
       
    60   @post none
       
    61 */
       
    62 CMtfTestActionSendEMsvCancelOperation::CMtfTestActionSendEMsvCancelOperation(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
    63 	{
       
    64 	}
       
    65 	
       
    66 /**
       
    67   Function : ~CMtfTestActionSendEMsvCancelOperation
       
    68   Description : Destructor
       
    69   @internalTechnology
       
    70   @param :
       
    71   @return : 
       
    72   @pre 
       
    73   @post 
       
    74 */
       
    75 CMtfTestActionSendEMsvCancelOperation::~CMtfTestActionSendEMsvCancelOperation()
       
    76 	{
       
    77 	}
       
    78 
       
    79 /**
       
    80   Function : ExecuteActionL
       
    81   Description : Entry point for the this test action in the test framework
       
    82   @internalTechnology
       
    83   @param : none
       
    84   @return : void
       
    85   @pre none 
       
    86   @post none
       
    87 */
       
    88 
       
    89 
       
    90 
       
    91 
       
    92 void CMtfTestActionSendEMsvCancelOperation::ExecuteActionL()
       
    93 	{
       
    94 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendEMsvCancelOperation);
       
    95 	TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(0));
       
    96 	TMsvId paramParentId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
       
    97 	TInt useProxyServerSecurityId = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2) , 1);
       
    98 	TInt pass = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(3) );
       
    99 
       
   100 	TSecureId ownerId = 0;
       
   101 	RProxyServerSession RPSS;
       
   102 	TInt error = RPSS.Connect();
       
   103 	// Will auto start the server if not started.
       
   104 
       
   105 	// Allow us to change the owning process of the message.
       
   106 	if (useProxyServerSecurityId)
       
   107 	{	// Use the security Id of  the proxy server.		
       
   108 		RPSS.GetServerSecureId( ownerId  );
       
   109 	}
       
   110 	else
       
   111 	{	// Use the security id of the test server. 
       
   112 	 	ownerId = RProcess().SecureId();
       
   113 	}
       
   114 
       
   115 	
       
   116 	if (error!=KErrNone)
       
   117 		{
       
   118 		TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to start proxy server. !"), &KTestActionSendEMsvCancelOperation);
       
   119 		TestCase().SetTestStepResult(EFail);
       
   120 		}
       
   121 	else
       
   122 		{
       
   123 		TInt32 serverCaps;
       
   124 		RPSS.GetServerCapabilities(serverCaps);
       
   125 		TestCase().INFO_PRINTF2(_L("Proxy Server has capabilities: %x"), serverCaps);
       
   126 		
       
   127 		TInt error = 0;
       
   128 		CleanupClosePushL(RPSS);
       
   129 		
       
   130 		HBufC8* buffer = HBufC8::NewLC(KMsvSessionBufferLength);
       
   131 
       
   132 		TMsvEntryForward entry;
       
   133 		FillInSimpleMessageEntry( 0, paramParentId, paramServiceId, entry);
       
   134 					
       
   135 		TMsvPackedEntry packedEntry(buffer);
       
   136 		error = packedEntry.PackEntry(entry);
       
   137 		if (error)
       
   138 			{	
       
   139 			TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to pack the message") , &KTestActionSendEMsvCancelOperation );
       
   140 			TestCase().SetTestStepResult(EFail);						
       
   141 			User::LeaveIfError(error);			
       
   142 			}
       
   143 		
       
   144 		TMsvOp operationId=1;
       
   145 		
       
   146 		error= RPSS.SendReceive(EMsvOperationData, TIpcArgs(operationId,buffer));
       
   147 			// Lets pretend we are going to perform some operation 1st we send some data.
       
   148 		if (error)
       
   149 			{	
       
   150 			TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to send the created message data") , &KTestActionSendEMsvCancelOperation );
       
   151 			TestCase().SetTestStepResult(EFail);						
       
   152 			User::LeaveIfError(error);			
       
   153 			}
       
   154 		
       
   155 		
       
   156 		RPSS.SendReceive(EMsvCreateEntry , TIpcArgs(operationId, ownerId) );
       
   157 		
       
   158 		TBuf8<64> complete;	
       
   159 		TInt ret =RPSS.SendReceive(EMsvCancelOperation , 
       
   160 						TIpcArgs(operationId,  &complete ) );
       
   161 			// Now lets cancel.
       
   162 		if (ret>=0)
       
   163 			{ // We are happy some sort of length returned or KErrNone.
       
   164 			error=KErrNone;
       
   165 			}
       
   166 		else 
       
   167 			{
       
   168 			error=KErrGeneral; // Just force an error.
       
   169 			}
       
   170 		
       
   171 		IPCCommandReportPassOrFailForCapsPermissions( TestCase(), KTestActionSendEMsvCancelOperation, error , pass );
       
   172 			// Note no need to use real data as we are just setting it up and sending it across.
       
   173 			// When we actually executed the command we would expect some sort of checking.
       
   174 	
       
   175 		// Note appear not to need to cancel or anything when passing data. 
       
   176 		// Assume server cleans up when connection closed.
       
   177 	
       
   178 
       
   179 		CleanupStack::Check(buffer);
       
   180 		CleanupStack::PopAndDestroy();
       
   181 		
       
   182 		CleanupStack::Check(&RPSS);
       
   183 		CleanupStack::PopAndDestroy();
       
   184 	
       
   185 		}
       
   186 			
       
   187 		
       
   188 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendEMsvCancelOperation);
       
   189 	TestCase().ActionCompletedL(*this);
       
   190 		
       
   191 	
       
   192 	}