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