messagingfw/msgtestfw/TestActions/Capabilities/src/CMtfTestActionSendEMsvCommandData.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 "CMtfTestActionSendEMsvCommandData.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 CMtfTestActionSendEMsvCommandData object
       
    41   @pre none
       
    42   @post none
       
    43 */
       
    44 CMtfTestAction* CMtfTestActionSendEMsvCommandData::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    45 	{
       
    46 	CMtfTestActionSendEMsvCommandData* self = new (ELeave) CMtfTestActionSendEMsvCommandData(aTestCase);
       
    47 	CleanupStack::PushL(self);
       
    48 	self->ConstructL(aActionParameters);
       
    49 	CleanupStack::Pop(self);
       
    50 	return self;
       
    51 	}
       
    52 
       
    53 /**
       
    54   Function : CMtfTestActionSendEMsvCommandData
       
    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 CMtfTestActionSendEMsvCommandData::CMtfTestActionSendEMsvCommandData(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
    63 	{
       
    64 	}
       
    65 	
       
    66 /**
       
    67   Function : ~CMtfTestActionSendEMsvCommandData
       
    68   Description : Destructor
       
    69   @internalTechnology
       
    70   @param :
       
    71   @return : 
       
    72   @pre 
       
    73   @post 
       
    74 */
       
    75 CMtfTestActionSendEMsvCommandData::~CMtfTestActionSendEMsvCommandData()
       
    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 CMtfTestActionSendEMsvCommandData::ExecuteActionL()
       
    93 	{
       
    94 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendEMsvCommandData);
       
    95 	// input params
       
    96 	TInt pass = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(0) );
       
    97 
       
    98 	RProxyServerSession RPSS;
       
    99 	TInt error = RPSS.Connect();
       
   100 	// Will auto start the server if not started.
       
   101 	
       
   102 	if (error!=KErrNone)
       
   103 		{
       
   104 		TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to start proxy server. !"), &KTestActionSendEMsvCommandData);
       
   105 		TestCase().SetTestStepResult(EFail);
       
   106 		}
       
   107 	else
       
   108 		{
       
   109 		TInt32 serverCaps;
       
   110 		RPSS.GetServerCapabilities(serverCaps);
       
   111 		TestCase().INFO_PRINTF2(_L("Proxy Server has capabilities: %x"), serverCaps);
       
   112 				
       
   113 		TInt error = 0;
       
   114 		CleanupClosePushL(RPSS);
       
   115 		
       
   116 		HBufC8* buffer = HBufC8::NewLC(KMsvSessionBufferLength);
       
   117 		
       
   118 		CMsvEntrySelection* entrySelection =  new (ELeave) (CMsvEntrySelection);
       
   119 		CleanupDeletePushL(entrySelection);
       
   120 		
       
   121 		entrySelection->SetReserveL(1);
       
   122 		entrySelection->AppendL(KMsvDraftEntryId);			
       
   123 					
       
   124 		TMsvPackedOperation packedOperation(buffer);
       
   125 		error = packedOperation.Pack(*entrySelection, KMsvLocalServiceIndexEntryId);
       
   126 		if (error)
       
   127 			{	
       
   128 			TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to pack the message") , &KTestActionSendEMsvCommandData );
       
   129 			TestCase().SetTestStepResult(EFail);						
       
   130 			User::LeaveIfError(error);			
       
   131 			}
       
   132 		
       
   133 		TMsvOp operationId=1;
       
   134 		_LIT8(KTestData , "TestData" );
       
   135 		
       
   136 		error=RPSS.SendReceive(EMsvCommandData , TIpcArgs(operationId, buffer, &KTestData) );
       
   137 		IPCCommandReportPassOrFailForCapsPermissions( TestCase(), KTestActionSendEMsvCommandData, error , pass );
       
   138 			// Note no need to use real data as we are just setting it up and sending it across.
       
   139 			// When we actually executed the command we would expect some sort of checking.
       
   140 	
       
   141 		// Note appear not to need to cancel or anything when passing data. 
       
   142 		// Assume server cleans up when connection closed.
       
   143 	
       
   144 
       
   145 		CleanupStack::Check(entrySelection);
       
   146 		CleanupStack::PopAndDestroy();
       
   147 
       
   148 		CleanupStack::Check(buffer);
       
   149 		CleanupStack::PopAndDestroy();
       
   150 		
       
   151 		CleanupStack::Check(&RPSS);
       
   152 		CleanupStack::PopAndDestroy();
       
   153 	
       
   154 		}
       
   155 			
       
   156 		
       
   157 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendEMsvCommandData);
       
   158 	TestCase().ActionCompletedL(*this);
       
   159 	
       
   160 
       
   161 	}