messagingfw/msgtestfw/TestActions/SendAs/src/CMtfTestActionSendAsSetSubject.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     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 // __ACTION_INFO_BEGIN__ 
       
    15 // [Action Name]
       
    16 // SendAsSetSubject
       
    17 // [Action Parameters]
       
    18 // RSendAsMessage		sendAsMessage<input> : Reference of  the RSendAsMessage object
       
    19 // HBufC				Subject		 <input> : String containing the Subject to be set 
       
    20 // for the message
       
    21 // [Action Description]
       
    22 // Sets subject field for a message created using SendAs API
       
    23 // [APIs Used]
       
    24 // RSendAsMessage::SetSubject (const TDesC& aSubject)
       
    25 // __ACTION_INFO_END__
       
    26 // 
       
    27 //
       
    28 
       
    29 /**
       
    30  @file 
       
    31  @internalTechnology 
       
    32 */
       
    33 
       
    34 
       
    35 // User include
       
    36 #include "CMtfTestActionSendAsSetSubject.h"
       
    37 #include "CMtfTestCase.h"
       
    38 #include "CMtfTestActionParameters.h"
       
    39 
       
    40 
       
    41 /**
       
    42   NewL()
       
    43   Constructs a CMtfTestActionSendAsSetSubject object.
       
    44   Uses two phase construction and leaves nothing on the CleanupStack.   
       
    45   @internalTechnology
       
    46   @param  aTestCase         Test Case to which this Test Action belongs
       
    47   @param  aActionParameters Action parameters, must not be NULL
       
    48   @return Created object of type CMtfTestActionSendAsSetSubject
       
    49   @pre    None
       
    50   @post   CMtfTestActionSendAsSetSubject object is created
       
    51 */
       
    52 CMtfTestAction* CMtfTestActionSendAsSetSubject::
       
    53 		NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    54 	{
       
    55 	CMtfTestActionSendAsSetSubject* self = 
       
    56 							new (ELeave) CMtfTestActionSendAsSetSubject(aTestCase);
       
    57 
       
    58 	CleanupStack::PushL(self);
       
    59 	self->ConstructL(aActionParameters);
       
    60 	CleanupStack::Pop(self);
       
    61 	return self;
       
    62 	}
       
    63 	
       
    64 
       
    65 /**
       
    66   CMtfTestActionSendAsSetSubject constructor
       
    67   Calls the base class' constructor
       
    68   @internalTechnology  
       
    69   @param  aTestCase  Test Case to which this Test Action belongs
       
    70   @pre    None
       
    71   @post   None
       
    72 */ 
       
    73 CMtfTestActionSendAsSetSubject::CMtfTestActionSendAsSetSubject(CMtfTestCase& aTestCase)
       
    74 	: CMtfSynchronousTestAction(aTestCase)
       
    75 	{
       
    76 	}
       
    77 
       
    78 /**
       
    79   Function : ~CMtfTestActionSendAsSetSubject
       
    80   Description : Destructor
       
    81   @internalTechnology
       
    82   @param :
       
    83   @return : 
       
    84   @pre 
       
    85   @post 
       
    86 */
       
    87 CMtfTestActionSendAsSetSubject::~CMtfTestActionSendAsSetSubject()
       
    88 	{
       
    89 	}
       
    90 	
       
    91 /**
       
    92   ExecuteActionL
       
    93    Sets the subject for a message created using SendAs API
       
    94   @internalTechnology 
       
    95   @pre    None
       
    96   @post   None
       
    97   @leave  System wide errors
       
    98 */
       
    99 void CMtfTestActionSendAsSetSubject::ExecuteActionL()
       
   100 	{
       
   101 	if((TestCase().TestStepResult()) == EPass)
       
   102 		{
       
   103 		TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendAsSetSubject);
       
   104 	
       
   105 		// Get Test action input parameters
       
   106 		RSendAsMessage sendAsMessage = ObtainValueParameterL<RSendAsMessage>(TestCase(),
       
   107 												ActionParameters().Parameter(0));
       
   108 
       
   109 		HBufC* subject = ObtainParameterReferenceL<HBufC>(TestCase(),
       
   110 												ActionParameters().Parameter(1));
       
   111 		
       
   112 		TInt paramExpectedResult = ObtainValueParameterL<TInt>(TestCase(),
       
   113 												ActionParameters().Parameter(2));
       
   114 	
       
   115 		// Set the subject field
       
   116 		TRAPD(err,sendAsMessage.SetSubjectL(subject->Des()));
       
   117 		
       
   118 		if(err != paramExpectedResult)
       
   119 			{
       
   120 			TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to set subject") , &KTestActionSendAsSetSubject);
       
   121 			TestCase().SetTestStepResult(EFail);
       
   122 			}
       
   123 		else if((paramExpectedResult == KErrNone) && (paramExpectedResult == err))
       
   124 			{
       
   125 			TestCase().INFO_PRINTF2(_L("Subject filed was set successfully."), &KTestActionSendAsSetSubject);
       
   126 			}
       
   127 		else
       
   128 			{
       
   129 			TestCase().INFO_PRINTF2(_L("Set Subject filed: The error code matches the expected error value %d"), err);
       
   130 			}
       
   131 			
       
   132 		}
       
   133 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendAsSetSubject);		
       
   134 	TestCase().ActionCompletedL(*this);
       
   135 	}
       
   136