messagingfw/msgtestfw/TestActions/Base/src/CMtfTestActionCompareNumbers.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2003-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 // CompareNumbers
       
    17 // [Action Parameters]
       
    18 // TInt  Number1       <input> 			   : Value to be compared.
       
    19 // TInt  Number2       <input>			   : Value to be compared with.
       
    20 // [Action Description]
       
    21 // Succeeds if the two numbers are equal.
       
    22 // [APIs Used]
       
    23 // none.
       
    24 // __ACTION_INFO_END__
       
    25 // 
       
    26 //
       
    27 
       
    28 /**
       
    29  @file
       
    30 */
       
    31 
       
    32 #include "CMtfTestActionCompareNumbers.h"
       
    33 #include "CMtfTestCase.h"
       
    34 #include "CMtfTestActionParameters.h"
       
    35 
       
    36 
       
    37 // TODO - rename action to compare TMsvId
       
    38 
       
    39 CMtfTestAction* CMtfTestActionCompareNumbers::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    40 	{
       
    41 	CMtfTestActionCompareNumbers* self = new (ELeave) CMtfTestActionCompareNumbers(aTestCase);
       
    42 	CleanupStack::PushL(self);
       
    43 	self->ConstructL(aActionParameters);
       
    44 	CleanupStack::Pop();
       
    45 	return self;
       
    46 	}
       
    47 	
       
    48 CMtfTestActionCompareNumbers::CMtfTestActionCompareNumbers(CMtfTestCase& aTestCase)
       
    49 	: CMtfSynchronousTestAction(aTestCase)
       
    50 	{
       
    51 	}
       
    52 
       
    53 CMtfTestActionCompareNumbers::~CMtfTestActionCompareNumbers()
       
    54 	{
       
    55 	}
       
    56 
       
    57 void CMtfTestActionCompareNumbers::ExecuteActionL()
       
    58 	{
       
    59 	// todo - change the name of this test action to CMtfTestActionCompareTMsvIds
       
    60 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCompareNumbers);
       
    61 	TMsvId paramNumber1 = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(0));
       
    62 	TMsvId paramNumber2 = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
       
    63 	
       
    64 	
       
    65 	TInt shouldMatch = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2));
       
    66 	
       
    67 	if( shouldMatch )
       
    68 		{
       
    69 		if(paramNumber1 != paramNumber2)
       
    70 			{
       
    71 			TestCase().INFO_PRINTF3( _L("Numbers %d != %d do not match when they should !"), 
       
    72 				static_cast<TInt>(paramNumber1), static_cast<TInt>(paramNumber2) );
       
    73 			TestCase().SetTestStepResult(EFail);	
       
    74 			}
       
    75 		}
       
    76 	else   // numbers should not match
       
    77 		{
       
    78 		if(paramNumber1 == paramNumber2)
       
    79 			{
       
    80 			TestCase().INFO_PRINTF3( _L("Numbers %d != %d match when they should not!"), 
       
    81 				static_cast<TInt>(paramNumber1), static_cast<TInt>(paramNumber2) );
       
    82 			TestCase().SetTestStepResult(EFail);	
       
    83 			}
       
    84 		}
       
    85 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCompareNumbers);
       
    86 	TestCase().ActionCompletedL(*this);
       
    87 	}