messagingfw/msgtestfw/TestActions/Email/Pop3/src/CMtfTestActionCountPopAccountsInArray.cpp
changeset 22 bde600d88860
parent 0 8e480a14352b
equal deleted inserted replaced
21:08008ce8a6df 22:bde600d88860
       
     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 // CountPopAccountsInArray
       
    17 // [Action Parameters]
       
    18 // accountArray		<input>:		TPopAccounts
       
    19 // numberToMatch	<input>:		Number to match count of array objects
       
    20 // Note :  TPopAccounts is defined as typedef RArray<TPOP3AccountId> TPopAccounts 
       
    21 // see TMtfTestParameterType.h for definition and parameter implementation
       
    22 // [Action Description]
       
    23 // CountPopAccountsInArray Test Action is intended to count the number of objects in
       
    24 // an TPopAccounts array and compare them against the provided number. Test action fails 
       
    25 // if count and number do not match.
       
    26 // [APIs Used]	
       
    27 // TPopAccounts::Count
       
    28 // __ACTION_INFO_END__
       
    29 // 
       
    30 //
       
    31 
       
    32 
       
    33 // system #includes
       
    34 #include <cemailaccounts.h>
       
    35 
       
    36 
       
    37 // user #includes
       
    38 #include "CMtfTestActionCountPopAccountsInArray.h"
       
    39 #include "TMtfTestParameterType.h"
       
    40 #include "CMtfTestCase.h"
       
    41 #include "CMtfTestActionParameters.h"
       
    42 
       
    43 /**
       
    44   Function : NewL
       
    45   Description : 
       
    46   @internalTechnology
       
    47   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    48   @param : aActionParams - CMtfTestActionParameters 
       
    49   @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionGetPopAccounts object
       
    50   @pre none
       
    51   @post none
       
    52 */
       
    53 CMtfTestAction* CMtfTestActionCountPopAccountsInArray::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    54 	{
       
    55 	CMtfTestActionCountPopAccountsInArray* self = new (ELeave) CMtfTestActionCountPopAccountsInArray(aTestCase);
       
    56 	CleanupStack::PushL(self);
       
    57 	self->ConstructL(aActionParameters);
       
    58 	CleanupStack::Pop(self);
       
    59 	return self;
       
    60 	}
       
    61 
       
    62 /**
       
    63   Function : CMtfTestActionGetPopAccounts
       
    64   Description : Constructor
       
    65   @internalTechnology
       
    66   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    67   @return : N/A
       
    68   @pre none
       
    69   @post none
       
    70 */
       
    71 CMtfTestActionCountPopAccountsInArray::CMtfTestActionCountPopAccountsInArray(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
    72 	{
       
    73 	}
       
    74 	
       
    75 /**
       
    76   Function : ~CMtfTestActionGetPopAccounts
       
    77   Description : Destructor
       
    78   @internalTechnology
       
    79   @param :
       
    80   @return : 
       
    81   @pre 
       
    82   @post 
       
    83 */
       
    84 CMtfTestActionCountPopAccountsInArray::~CMtfTestActionCountPopAccountsInArray()
       
    85 	{
       
    86 	}
       
    87 
       
    88 /**
       
    89   Function : ExecuteActionL
       
    90   Description : Entry point for the this test action in the test framework
       
    91   @internalTechnology
       
    92   @param : none
       
    93   @return : void
       
    94   @pre none 
       
    95   @post none
       
    96 */
       
    97 void CMtfTestActionCountPopAccountsInArray::ExecuteActionL()
       
    98 	{
       
    99 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCountPopAccountsInArray);
       
   100 	TInt numberToMatch = ObtainValueParameterL<TInt>(TestCase(), ActionParameters().Parameter(0));
       
   101 		
       
   102 	CEmailAccounts* accounts = CEmailAccounts::NewLC();	
       
   103 	RArray<TPopAccount> arrayPopAccounts;
       
   104 	accounts->GetPopAccountsL(arrayPopAccounts);
       
   105 	TInt count = arrayPopAccounts.Count();
       
   106 	CleanupStack::PopAndDestroy(accounts);
       
   107 	arrayPopAccounts.Reset();
       
   108 	
       
   109 	if ( count != numberToMatch )
       
   110 		{
       
   111 		// failed
       
   112 		TestCase().ERR_PRINTF3(_L("Number of POP accounts do not match ! expected = %d actual = %d"), 
       
   113 								  numberToMatch, count );
       
   114 		TestCase().SetTestStepResult(EFail);
       
   115 		}
       
   116 	
       
   117 	TestCase().INFO_PRINTF2(_L("Number of POP accounts matched value = %d !"), numberToMatch );
       
   118 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCountPopAccountsInArray);
       
   119 	TestCase().ActionCompletedL(*this);	
       
   120 	}