messagingfw/msgtestfw/TestActions/Capabilities/src/cmtftestactionsendemsvupdateheaderentry.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: Implementation of CMtfTestActionSendEMsvUpdateHeaderEntry
       
    14 //
       
    15 
       
    16 #include "cmtftestactionsendemsvupdateheaderentry.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 CMtfTestActionSendEMsvUpdateHeaderEntry object
       
    41   @pre none
       
    42   @post none
       
    43 */
       
    44 CMtfTestAction* CMtfTestActionSendEMsvUpdateHeaderEntry::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    45 	{
       
    46 	CMtfTestActionSendEMsvUpdateHeaderEntry* self = new (ELeave) CMtfTestActionSendEMsvUpdateHeaderEntry(aTestCase);
       
    47 	CleanupStack::PushL(self);
       
    48 	self->ConstructL(aActionParameters);
       
    49 	CleanupStack::Pop(self);
       
    50 	return self;
       
    51 	}
       
    52 
       
    53 /**
       
    54   Function : CMtfTestActionSendEMsvUpdateHeaderEntry
       
    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 CMtfTestActionSendEMsvUpdateHeaderEntry::CMtfTestActionSendEMsvUpdateHeaderEntry(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
    63 	{
       
    64 	}
       
    65 
       
    66 /**
       
    67   Function : ~CMtfTestActionSendEMsvUpdateHeaderEntry
       
    68   Description : Destructor
       
    69   @internalTechnology
       
    70   @param :
       
    71   @return :
       
    72   @pre
       
    73   @post
       
    74 */
       
    75 CMtfTestActionSendEMsvUpdateHeaderEntry::~CMtfTestActionSendEMsvUpdateHeaderEntry()
       
    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 void CMtfTestActionSendEMsvUpdateHeaderEntry::ExecuteActionL()
       
    89 	{
       
    90 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendEMsvUpdateHeaderEntry);
       
    91 	// input params
       
    92 	TUid mtmUid = KUidMsgTypeIMAP4;
       
    93 	TInt pass = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(1) );
       
    94 
       
    95 	RProxyServerSession RPSS;
       
    96 	TInt error = RPSS.Connect();
       
    97 	CleanupClosePushL(RPSS);
       
    98 
       
    99 	// Will auto start the server if not started.
       
   100 	if (error!=KErrNone)
       
   101 		{
       
   102 		TestCase().ERR_PRINTF1(_L("CMtfTestActionSendEMsvUpdateHeaderEntry :: Unable to start proxy server. !"));
       
   103 		TestCase().SetTestStepResult(EFail);
       
   104 		}
       
   105 	else
       
   106 		{
       
   107 		TInt32 serverCaps;
       
   108 		RPSS.GetServerCapabilities(serverCaps);
       
   109 		TestCase().INFO_PRINTF2(_L("Proxy Server has capabilities: %x"), serverCaps);
       
   110 
       
   111 		RPointerArray<CHeaderFields> fieldPairList;
       
   112 		CleanupClosePushL(fieldPairList);
       
   113 
       
   114 		CHeaderFields* headerField = new(ELeave) CHeaderFields();
       
   115 		CleanupStack::PushL(headerField);
       
   116 		headerField->iUid = TUid::Uid(1001);
       
   117 
       
   118 		CFieldPair* fieldPair = new(ELeave) CFieldPair();
       
   119 		CleanupStack::PushL(fieldPair);
       
   120 
       
   121 		fieldPair->iFieldType = ETextField;
       
   122 
       
   123 		_LIT(KFieldText1, "!¬\"£$%^ &*()_+-=");
       
   124 		fieldPair->iFieldTextValue = KFieldText1().AllocL();
       
   125 		headerField->iFieldPairList.AppendL(fieldPair);
       
   126 
       
   127 		fieldPairList.AppendL(headerField);
       
   128 
       
   129 		HBufC8* buffer = HBufC8::New(KMsvSessionBufferLength);
       
   130 
       
   131 		TMsvPackedHeaderData packedHeaderData(buffer);
       
   132 		TInt error = packedHeaderData.Pack(fieldPairList);
       
   133 		while(error!=KErrNone)
       
   134 			{
       
   135 			// increase the size of the buffer and try again
       
   136 			buffer->Des().SetLength(0); // to avoid copying contents
       
   137 			buffer = buffer->ReAllocL(buffer->Des().MaxSize() + KMsvSessionBufferLength);
       
   138 			error = packedHeaderData.Pack(fieldPairList);
       
   139 			}
       
   140 
       
   141 		TInt err = RPSS.SendReceive(EMsvUpdateHeaderEntry, TIpcArgs(mtmUid.iUid, (TMsvId)40000, buffer));
       
   142 
       
   143 		IPCCommandReportPassOrFailForCapsPermissions( TestCase(), KMsvServerName, err , pass );
       
   144 
       
   145 		CleanupStack::Pop(); // CFieldPair
       
   146 
       
   147 		CleanupStack::Pop(); // CHeaderFields
       
   148 		delete headerField;
       
   149 
       
   150 		CleanupStack::PopAndDestroy();
       
   151 		}
       
   152 
       
   153 	CleanupStack::Check(&RPSS);
       
   154 	CleanupStack::PopAndDestroy(); // RPSS
       
   155 
       
   156 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendEMsvUpdateHeaderEntry);
       
   157 	TestCase().ActionCompletedL(*this);
       
   158 	}