messagingfw/msgtestfw/TestActions/Base/src/CMtfTestActionCountAvailableAccounts.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 // CountAvailableAccounts
       
    17 // [Action Parameters]
       
    18 // CSendAsAccounts sendAsAccounts <input> : Reference to the CSendAsAccounts object
       
    19 // TInt		expectedCount  <input>: expected number of accounts names.
       
    20 // TInt 	index 		   <input>: Index of the account name to be verified
       
    21 // HbufC	accountName	   <input>: Expected account name
       
    22 // [Action Description]
       
    23 // Count Number of Available SendAs Account names. Verifies the account 
       
    24 // name string present at the specified index
       
    25 // [APIs Used]
       
    26 // CSendAsAccounts::AccountNames()
       
    27 // __ACTION_INFO_END__
       
    28 // 
       
    29 //
       
    30 
       
    31 /**
       
    32  @file
       
    33 */
       
    34 //system include
       
    35 #include <sendas2.h>
       
    36 
       
    37 //user include 
       
    38 #include "CMtfTestActionCountAvailableAccounts.h"
       
    39 #include "CMtfTestCase.h"
       
    40 #include "CMtfTestActionParameters.h"
       
    41 
       
    42 /**
       
    43   NewL()
       
    44   Constructs a CMtfTestActionCountAvailableAccounts object.
       
    45   Uses two phase construction and leaves nothing on the CleanupStack.   
       
    46   @internalTechnology
       
    47   @param  aTestCase         Test Case to which this Test Action belongs
       
    48   @param  aActionParameters Action parameters, must not be NULL
       
    49   @return Created object of type CMtfTestActionCountAvailableAccounts
       
    50   @pre    None
       
    51   @post   CMtfTestActionCountAvailableAccounts object is created
       
    52 */
       
    53 CMtfTestAction* CMtfTestActionCountAvailableAccounts::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    54 	{
       
    55 	CMtfTestActionCountAvailableAccounts* self = new (ELeave) CMtfTestActionCountAvailableAccounts(aTestCase);
       
    56 	CleanupStack::PushL(self);
       
    57 	self->ConstructL(aActionParameters);
       
    58 	CleanupStack::Pop();
       
    59 	return self;
       
    60 	}
       
    61 	
       
    62 /**
       
    63   CMtfTestActionCountAvailableAccounts constructor
       
    64   Calls the base class' constructor
       
    65   @internalTechnology  
       
    66   @param  aTestCase  Test Case to which this Test Action belongs
       
    67   @pre    None
       
    68   @post   None
       
    69 */ 
       
    70 CMtfTestActionCountAvailableAccounts::CMtfTestActionCountAvailableAccounts(CMtfTestCase& aTestCase)
       
    71 	: CMtfSynchronousTestAction(aTestCase)
       
    72 	{
       
    73 	}
       
    74 
       
    75 /**
       
    76   Function : ~CMtfTestActionCountAvailableAccounts
       
    77   Description : Destructor
       
    78   @internalTechnology
       
    79   @param :
       
    80   @return : 
       
    81   @pre 
       
    82   @post 
       
    83 */
       
    84 CMtfTestActionCountAvailableAccounts::~CMtfTestActionCountAvailableAccounts()
       
    85 	{
       
    86 	}
       
    87 
       
    88 /**
       
    89   ExecuteActionL
       
    90 	Verifies the count of the account names. Test case fails if the number of 
       
    91 	accounts does not match with the expected value.
       
    92 	Compares the account name present at the specified index with the expected value.
       
    93 	The test case fails if the account name does not match with the expected value.
       
    94   @internalTechnology 
       
    95   @pre    None
       
    96   @post   None
       
    97   @leave  System wide errors
       
    98 */
       
    99 void CMtfTestActionCountAvailableAccounts::ExecuteActionL()
       
   100 	{
       
   101 	if((TestCase().TestStepResult()) == EPass)
       
   102 		{
       
   103 		TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCountAvailableAccounts);
       
   104 		
       
   105 		// Get test action input parameters
       
   106 		CSendAsAccounts* paramAvailableAccounts	= ObtainParameterReferenceL<CSendAsAccounts>(TestCase(),
       
   107 																		ActionParameters().Parameter(0));
       
   108 				
       
   109 		TInt paramExpectedCount = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(1));
       
   110 
       
   111 
       
   112 		TInt paramIndex = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2));
       
   113 
       
   114 
       
   115 		HBufC* paramAccountName = ObtainParameterReferenceL<HBufC>(TestCase(),
       
   116 																ActionParameters().Parameter(3));
       
   117 														
       
   118 														
       
   119 														
       
   120 		TInt accountsCount = paramAvailableAccounts->AccountNames().MdcaCount();
       
   121 		
       
   122 		if(accountsCount == paramExpectedCount)
       
   123 			{
       
   124 			TestCase().INFO_PRINTF2(_L("Number of accounts matched the expcted count value %d"), accountsCount);
       
   125 			}
       
   126 		else
       
   127 			{
       
   128 			TestCase().ERR_PRINTF3(_L("Number of accounts did not match. Number of available accounts = %d, expected value = %d"), accountsCount, paramExpectedCount);
       
   129 			TestCase().SetTestStepResult(EFail);
       
   130 			}
       
   131 			
       
   132 		if((TestCase().TestStepResult()) == EPass)
       
   133 			{
       
   134 			TBufC<256> accountname = paramAvailableAccounts->AccountNames().MdcaPoint(paramIndex);
       
   135 			
       
   136 			if((accountname.Compare(paramAccountName->Des())) == 0)
       
   137 				{
       
   138 				TestCase().INFO_PRINTF1(_L("Comparison of account name was successful"));
       
   139 				}
       
   140 			else
       
   141 				{
       
   142 				TestCase().ERR_PRINTF1(_L("Comparison of account name falied"));
       
   143 				TestCase().SetTestStepResult(EFail);
       
   144 				}
       
   145 			}
       
   146 		TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCountAvailableAccounts);	
       
   147 		}
       
   148 		
       
   149 	TestCase().ActionCompletedL(*this);
       
   150 	}
       
   151