messagingfw/msgtestfw/TestActions/Capabilities/src/CMtfTestActionSendEMsvOperationProgress.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     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 "CMtfTestActionSendEMsvOperationProgress.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 CMtfTestActionSendEMsvOperationProgress object
       
    41   @pre none
       
    42   @post none
       
    43 */
       
    44 CMtfTestAction* CMtfTestActionSendEMsvOperationProgress::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    45 	{
       
    46 	CMtfTestActionSendEMsvOperationProgress* self = new (ELeave) CMtfTestActionSendEMsvOperationProgress(aTestCase);
       
    47 	CleanupStack::PushL(self);
       
    48 	self->ConstructL(aActionParameters);
       
    49 	CleanupStack::Pop(self);
       
    50 	return self;
       
    51 	}
       
    52 
       
    53 /**
       
    54   Function : CMtfTestActionSendEMsvOperationProgress
       
    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 CMtfTestActionSendEMsvOperationProgress::CMtfTestActionSendEMsvOperationProgress(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
    63 	{
       
    64 	}
       
    65 	
       
    66 /**
       
    67   Function : ~CMtfTestActionSendEMsvOperationProgress
       
    68   Description : Destructor
       
    69   @internalTechnology
       
    70   @param :
       
    71   @return : 
       
    72   @pre 
       
    73   @post 
       
    74 */
       
    75 CMtfTestActionSendEMsvOperationProgress::~CMtfTestActionSendEMsvOperationProgress()
       
    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 CMtfTestActionSendEMsvOperationProgress::ExecuteActionL()
       
    93 	{
       
    94 	
       
    95 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendEMsvOperationProgress);
       
    96 	TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(0));
       
    97 	TMsvId paramParentId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
       
    98 	TInt useProxyServerSecurityId = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2) , 1);
       
    99 	TInt pass = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(3) );
       
   100 
       
   101 
       
   102 	TSecureId ownerId = 0;
       
   103 		// Assume set caps had set this correctly.
       
   104 	RProxyServerSession RPSS;
       
   105 	TInt error = RPSS.Connect();
       
   106 	// Will auto start the server if not started.
       
   107 
       
   108 	// Allow us to change the owning process of the message.
       
   109 	if (useProxyServerSecurityId)
       
   110 	{	// Use the security Id of  the proxy server.		
       
   111 		RPSS.GetServerSecureId( ownerId  );
       
   112 	}
       
   113 	else
       
   114 	{	// Use the security id of the test server. 
       
   115 	 	ownerId = RProcess().SecureId();
       
   116 	}
       
   117 		
       
   118 	if (error!=KErrNone)
       
   119 		{
       
   120 		TestCase().ERR_PRINTF2(_L("%S :: Unable to start proxy server. !"), &KTestActionSendEMsvOperationProgress);
       
   121 		TestCase().SetTestStepResult(EFail);
       
   122 		}
       
   123 	else
       
   124 		{		
       
   125 		TInt32 serverCaps;
       
   126 		RPSS.GetServerCapabilities(serverCaps);
       
   127 		TestCase().INFO_PRINTF2(_L("Proxy Server has capabilities: %x"), serverCaps);
       
   128 		
       
   129 		TInt error = 0;
       
   130 		CleanupClosePushL(RPSS);
       
   131 							
       
   132 		HBufC8* buffer = HBufC8::NewLC(KMsvSessionBufferLength);						
       
   133 		
       
   134 		TMsvEntryForward entry;
       
   135 		FillInSimpleMessageEntry( 0, paramParentId, paramServiceId, entry);
       
   136 
       
   137 		TMsvPackedEntry packedEntry(buffer);
       
   138 		error = packedEntry.PackEntry(entry);
       
   139 		if (error)
       
   140 			{	
       
   141 			TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to pack the message") , &KTestActionSendEMsvOperationProgress );
       
   142 			TestCase().SetTestStepResult(EFail);						
       
   143 			User::LeaveIfError(error);			
       
   144 			}
       
   145 		
       
   146 						
       
   147 		TMsvOp operationId=1;
       
   148 		
       
   149 		
       
   150 		
       
   151 		error= RPSS.SendReceive(EMsvOperationData, TIpcArgs(operationId,buffer));
       
   152 		if (error)
       
   153 			{	
       
   154 			TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to send the message data required to create the message") , &KTestActionSendEMsvOperationProgress );
       
   155 			TestCase().SetTestStepResult(EFail);						
       
   156 			User::LeaveIfError(error);			
       
   157 			}
       
   158 
       
   159 				
       
   160 		error=RPSS.SendReceive(EMsvCreateEntry , TIpcArgs(operationId, ownerId));		
       
   161 		if (error)
       
   162 			{	
       
   163 			TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to send the created message or create the data.") , &KTestActionSendEMsvOperationProgress );
       
   164 			TestCase().SetTestStepResult(EFail);						
       
   165 			User::LeaveIfError(error);			
       
   166 			}
       
   167 		
       
   168 			
       
   169 		TBuf8<64> progress;
       
   170 		TInt ret=RPSS.SendReceive(EMsvOperationProgress , TIpcArgs(operationId, &progress));
       
   171 			// Should never generate an error.
       
   172 		if (ret>=0)
       
   173 			{ // We are happy some sort of length returned or KErrNone.
       
   174 			error=KErrNone;
       
   175 			}
       
   176 		else 
       
   177 			{
       
   178 			error=KErrGeneral; // Just force an error.
       
   179 			}
       
   180 
       
   181 		IPCCommandReportPassOrFailForCapsPermissions( TestCase(), KTestActionSendEMsvOperationProgress, error , pass );
       
   182 		
       
   183 		
       
   184 		if ( (pass == 0) && (error!=KErrNone ) )
       
   185 			{ // We expected it to fail and it did so do nothing else basically ignore the error. 
       
   186 			  // Appears to be no need to do EMsvOperationCompletion. 
       
   187 			}
       
   188 		else
       
   189 			{ // Now just commit the message so that we do not get a panic.
       
   190 
       
   191 			TMsvLocalOperationProgress progress;
       
   192 			TPckg<TMsvLocalOperationProgress> progressPack(progress);
       
   193 			TInt ret=RPSS.SendReceive(EMsvOperationCompletion , TIpcArgs(operationId, &progressPack));
       
   194 				// We need to indicate that we have finished and clean up otherwise we will get 
       
   195 				// a panic.
       
   196 				
       
   197 			if (ret>0)
       
   198 				{ // We are happy some sort of length returned.
       
   199 				}
       
   200 			else if (ret<0)
       
   201 				{	
       
   202 				TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to finish sending the modified message") , &KTestActionSendEMsvOperationProgress );
       
   203 				TestCase().SetTestStepResult(EFail);						
       
   204 				User::LeaveIfError(error);			
       
   205 				}
       
   206 			// else KErrNone
       
   207 			}
       
   208 		
       
   209 		CleanupStack::Check(buffer);
       
   210 		CleanupStack::PopAndDestroy();
       
   211 		
       
   212 		CleanupStack::Check(&RPSS);
       
   213 		CleanupStack::PopAndDestroy();
       
   214 		}
       
   215 	
       
   216 		
       
   217 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendEMsvOperationProgress);
       
   218 	TestCase().ActionCompletedL(*this);		
       
   219 	}