messagingfw/msgtestfw/TestActions/Email/Imap4/src/CMtfTestActionGetImapAccountInArray.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:
       
    14 // __ACTION_INFO_BEGIN__ 
       
    15 // [Action Name]
       
    16 // GetImapAccountInArray
       
    17 // [Action Parameters]
       
    18 // accountArray		<input>:		TImapAccounts
       
    19 // indexNumber		<input>:		Index of account to get
       
    20 // accountId		<output>:		TIMAP4Account ID
       
    21 // Note :  TImapAccounts is defined as typedef RArray<TIMAP4AccountId> TImapAccounts 
       
    22 // see TMtfTestParameterType.h for definition and parameter implementation
       
    23 // [Action Description]
       
    24 // GetImapAccountInArray Test Action is intended to get a TIMAP4AccountId specified 
       
    25 // by indexNumebr from an TImapAccounts array.
       
    26 // [APIs Used]	
       
    27 // __ACTION_INFO_END__
       
    28 // 
       
    29 //
       
    30 
       
    31 
       
    32 #include <cemailaccounts.h>
       
    33 
       
    34 
       
    35 #include "CMtfTestActionGetImapAccountInArray.h"
       
    36 #include "TMtfTestParameterType.h"
       
    37 #include "CMtfTestCase.h"
       
    38 #include "CMtfTestActionParameters.h"
       
    39 
       
    40 /**
       
    41   Function : NewL
       
    42   Description : 
       
    43   @internalTechnology
       
    44   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    45   @param : aActionParams - CMtfTestActionParameters 
       
    46   @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionGetImapAccounts object
       
    47   @pre none
       
    48   @post none
       
    49 */
       
    50 CMtfTestAction* CMtfTestActionGetImapAccountInArray::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    51 	{
       
    52 	CMtfTestActionGetImapAccountInArray* self = new (ELeave) CMtfTestActionGetImapAccountInArray(aTestCase);
       
    53 	CleanupStack::PushL(self);
       
    54 	self->ConstructL(aActionParameters);
       
    55 	CleanupStack::Pop(self);
       
    56 	return self;
       
    57 	}
       
    58 
       
    59 /**
       
    60   Function : CMtfTestActionGetImapAccounts
       
    61   Description : Constructor
       
    62   @internalTechnology
       
    63   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    64   @return : N/A
       
    65   @pre none
       
    66   @post none
       
    67 */
       
    68 CMtfTestActionGetImapAccountInArray::CMtfTestActionGetImapAccountInArray(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
    69 	{
       
    70 	}
       
    71 	
       
    72 /**
       
    73   Function : ~CMtfTestActionGetImapAccounts
       
    74   Description : Destructor
       
    75   @internalTechnology
       
    76   @param :
       
    77   @return : 
       
    78   @pre 
       
    79   @post 
       
    80 */
       
    81 CMtfTestActionGetImapAccountInArray::~CMtfTestActionGetImapAccountInArray()
       
    82 	{
       
    83 	}
       
    84 
       
    85 /**
       
    86   Function : ExecuteActionL
       
    87   Description : Entry point for the this test action in the test framework
       
    88   @internalTechnology
       
    89   @param : none
       
    90   @return : void
       
    91   @pre none 
       
    92   @post none
       
    93 */
       
    94 void CMtfTestActionGetImapAccountInArray::ExecuteActionL()
       
    95 	{
       
    96 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionGetImapAccountInArray);
       
    97 	TInt indexNumber = ObtainValueParameterL<TInt>(TestCase(), ActionParameters().Parameter(0));
       
    98 	CEmailAccounts* account = CEmailAccounts::NewLC();	
       
    99 	RArray<TImapAccount> accountArray;
       
   100 	CleanupClosePushL(accountArray);
       
   101 	account->GetImapAccountsL(accountArray);
       
   102 	
       
   103 	// make sure we're not out of range
       
   104 	if (indexNumber >= 0 && indexNumber < accountArray.Count())
       
   105 		{
       
   106 		TImapAccount id = accountArray[indexNumber];	
       
   107 		StoreParameterL<TImapAccount>(TestCase(), id, ActionParameters().Parameter(1));
       
   108 		}
       
   109 	else
       
   110 		{
       
   111 		TestCase().ERR_PRINTF1(_L("Index is out of range!"));
       
   112 		TestCase().SetTestStepResult(EFail);
       
   113 		}
       
   114 
       
   115 	CleanupStack::PopAndDestroy( 2, account );	
       
   116 	
       
   117 
       
   118 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionGetImapAccountInArray);
       
   119 	TestCase().ActionCompletedL(*this);	
       
   120 	}