messagingfw/msgtestfw/TestActions/Capabilities/src/CMtfTestActionSendEMsvMoveEntries.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 "CMtfTestActionSendEMsvMoveEntries.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 CMtfTestActionSendEMsvMoveEntries object
       
    41   @pre none
       
    42   @post none
       
    43 */
       
    44 CMtfTestAction* CMtfTestActionSendEMsvMoveEntries::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    45 	{
       
    46 	CMtfTestActionSendEMsvMoveEntries* self = new (ELeave) CMtfTestActionSendEMsvMoveEntries(aTestCase);
       
    47 	CleanupStack::PushL(self);
       
    48 	self->ConstructL(aActionParameters);
       
    49 	CleanupStack::Pop(self);
       
    50 	return self;
       
    51 	}
       
    52 
       
    53 /**
       
    54   Function : CMtfTestActionSendEMsvMoveEntries
       
    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 CMtfTestActionSendEMsvMoveEntries::CMtfTestActionSendEMsvMoveEntries(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
    63 	{
       
    64 	}
       
    65 	
       
    66 /**
       
    67   Function : ~CMtfTestActionSendEMsvMoveEntries
       
    68   Description : Destructor
       
    69   @internalTechnology
       
    70   @param :
       
    71   @return : 
       
    72   @pre 
       
    73   @post 
       
    74 */
       
    75 CMtfTestActionSendEMsvMoveEntries::~CMtfTestActionSendEMsvMoveEntries()
       
    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 CMtfTestActionSendEMsvMoveEntries::ExecuteActionL()
       
    93 	{
       
    94 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendEMsvMoveEntries);
       
    95 	TMsvId multiMsg = 0;
       
    96 	
       
    97 	TMsvId messageIdFrom = ObtainValueParameterL<TMsvId>( TestCase(), ActionParameters().Parameter(0) );										
       
    98 	TMsvId parentIdTo = ObtainValueParameterL<TMsvId>( TestCase(), ActionParameters().Parameter(1) );										
       
    99 	TInt pass = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2));
       
   100 
       
   101 	if (ActionParameters().Count() > 3)
       
   102 	{
       
   103 		multiMsg = ObtainValueParameterL<TMsvId>( TestCase(), ActionParameters().Parameter(3) );
       
   104 	}
       
   105 	
       
   106 	RProxyServerSession RPSS;
       
   107 	TInt error = RPSS.Connect();
       
   108 	// Will auto start the server if not started.
       
   109 	
       
   110 	if (error!=KErrNone)
       
   111 		{
       
   112 		TestCase().ERR_PRINTF2(_L("%S :: Unable to start proxy server. !") , &KTestActionSendEMsvMoveEntries);
       
   113 		TestCase().SetTestStepResult(EFail);
       
   114 		}
       
   115 	else
       
   116 		{
       
   117 		TInt32 serverCaps;
       
   118 		RPSS.GetServerCapabilities(serverCaps);
       
   119 		TestCase().INFO_PRINTF2(_L("Proxy Server has capabilities: %x"), serverCaps);
       
   120 				
       
   121 		error = 0;
       
   122 		CleanupClosePushL(RPSS);
       
   123 		
       
   124 		HBufC8* buffer = HBufC8::NewLC(KMsvSessionBufferLength);						
       
   125 		TPtr8 ptr=buffer->Des();
       
   126 		
       
   127 		CMsvEntrySelection* entrySelection =  new (ELeave) (CMsvEntrySelection);
       
   128 		CleanupDeletePushL(entrySelection);
       
   129 		
       
   130 		entrySelection->SetReserveL(1);
       
   131 		entrySelection->AppendL(messageIdFrom);
       
   132 
       
   133 		if (multiMsg != 0)
       
   134 		{
       
   135 			entrySelection->AppendL(multiMsg);
       
   136 		}
       
   137 		
       
   138 		TMsvPackedOperation packedOperation(buffer);
       
   139 		error = packedOperation.Pack(*entrySelection, parentIdTo);
       
   140 		if (error)
       
   141 			{	
       
   142 			TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to pack the message") , &KTestActionSendEMsvMoveEntries );
       
   143 			TestCase().SetTestStepResult(EFail);						
       
   144 			User::LeaveIfError(error);			
       
   145 			}
       
   146 		
       
   147 		
       
   148 		TMsvOp operationId=1;
       
   149 
       
   150 		error= RPSS.SendReceive(EMsvOperationData, TIpcArgs(operationId,buffer));				
       
   151 		if (error)
       
   152 			{	
       
   153 			TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to send the created message") , &KTestActionSendEMsvMoveEntries  );
       
   154 			TestCase().SetTestStepResult(EFail);						
       
   155 			User::LeaveIfError(error);			
       
   156 			}
       
   157 			
       
   158 		error=RPSS.SendReceive(EMsvMoveEntries , TIpcArgs(operationId));
       
   159 
       
   160 		IPCCommandReportPassOrFailForCapsPermissions( TestCase(), KTestActionSendEMsvMoveEntries, error , pass );
       
   161 		if ( (pass == 0) && (error!=KErrNone ) )
       
   162 			{ // We expected it to fail and it did so do nothing else basically ignore the error. 
       
   163 			  // Appears to be no need to do EMsvOperationCompletion.
       
   164 			}
       
   165 		else
       
   166 			{
       
   167 
       
   168 			TMsvLocalOperationProgress progress;
       
   169 			TPckg<TMsvLocalOperationProgress> progressPack(progress);
       
   170 			TInt ret=RPSS.SendReceive(EMsvOperationCompletion , TIpcArgs(operationId, &progressPack));
       
   171 				// We need to indicate that we have finished and clean up otherwise we will get 
       
   172 				// a panic.
       
   173 				
       
   174 			if (ret>0)
       
   175 				{ // We are happy some sort of length returned.
       
   176 				}
       
   177 			else if (ret<0)
       
   178 				{	
       
   179 				TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to finish sending the modified message") , &KTestActionSendEMsvMoveEntries );
       
   180 				TestCase().SetTestStepResult(EFail);						
       
   181 				User::LeaveIfError(error);			
       
   182 				}
       
   183 			// else KErrNone
       
   184 			
       
   185 
       
   186 			}
       
   187 
       
   188 		CleanupStack::Check(entrySelection);
       
   189 		CleanupStack::PopAndDestroy();
       
   190 			
       
   191 		CleanupStack::Check(buffer);
       
   192 		CleanupStack::PopAndDestroy();
       
   193 		
       
   194 		CleanupStack::Check(&RPSS);
       
   195 		CleanupStack::PopAndDestroy();
       
   196 		}
       
   197 
       
   198 		
       
   199 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendEMsvMoveEntries);
       
   200 	TestCase().ActionCompletedL(*this);
       
   201 	}
       
   202