messagingfw/msgtestfw/TestActions/Email/Imap4/src/CMtfTestActionDeleteImapAccounts.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 // DeleteImapAccounts
       
    17 // [Action Parameters]
       
    18 // accountIds	input 	TImapAccounts
       
    19 // Index	TInt
       
    20 // Note : TImapAccounts is defined as typedef RArray<TIMAP4Account> TImapAccounts;
       
    21 // see TMtfTestParameterType.h for details
       
    22 // [Action Description]
       
    23 // DeleteImapAccounts Test Action is intended to delete IMAP accounts from the 
       
    24 // Central Repository. This Test Action takes TIMAP4Account array and an index 
       
    25 // value as input parameters.  If an integer value is provided for the index, 
       
    26 // the IMAP account at the specified index will be deleted.  In case of default 
       
    27 // value provided as index, all the IMAP accounts will be deleted.
       
    28 // [APIs Used]	
       
    29 // CEmailAccounts::DeleteImapAccountL
       
    30 // __ACTION_INFO_END__
       
    31 // 
       
    32 //
       
    33 
       
    34 
       
    35 #include "CMtfTestActionDeleteImapAccounts.h"
       
    36 
       
    37 #include <cemailaccounts.h>
       
    38 
       
    39 
       
    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 CMtfTestActionDeleteImapAccounts object
       
    50   @pre none
       
    51   @post none
       
    52 */
       
    53 CMtfTestAction* CMtfTestActionDeleteImapAccounts::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    54 	{
       
    55 	CMtfTestActionDeleteImapAccounts* self = new (ELeave) CMtfTestActionDeleteImapAccounts(aTestCase);
       
    56 	CleanupStack::PushL(self);
       
    57 	self->ConstructL(aActionParameters);
       
    58 	CleanupStack::Pop(self);
       
    59 	return self;
       
    60 	}
       
    61 
       
    62 /**
       
    63   Function : CMtfTestActionDeleteImapAccounts
       
    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 CMtfTestActionDeleteImapAccounts::CMtfTestActionDeleteImapAccounts(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
    72 	{
       
    73 	}
       
    74 
       
    75 /**
       
    76   Function : ~CMtfTestActionDeleteImapAccounts
       
    77   Description : Destructor
       
    78   @internalTechnology
       
    79   @param :
       
    80   @return : 
       
    81   @pre 
       
    82   @post 
       
    83 */
       
    84 CMtfTestActionDeleteImapAccounts::~CMtfTestActionDeleteImapAccounts()
       
    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 
       
    98 // Note if want no accounts you must call "DeleteImapAccounts accountsIdList" to ensure that 
       
    99 // all accounts are cleared at the start. 
       
   100 // You can not gaurantee that some other Test has left it clean.
       
   101 // A test might leave, leaveing all the accounts in the central repository. 
       
   102 
       
   103 
       
   104 void CMtfTestActionDeleteImapAccounts::ExecuteActionL()
       
   105 	{
       
   106 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionDeleteImapAccounts);
       
   107 	TInt paramDefaultIndex = ObtainValueParameterL<TInt>( TestCase(),ActionParameters().Parameter(0) ,-1 );
       
   108 
       
   109 	CEmailAccounts* account = CEmailAccounts::NewLC();
       
   110 	
       
   111 	RArray<TImapAccount> arrayImap4Accounts;
       
   112 	CleanupClosePushL(arrayImap4Accounts);
       
   113 	account->GetImapAccountsL(arrayImap4Accounts);
       
   114 	
       
   115 	if ( paramDefaultIndex >= 0 ) 
       
   116 		{ // Delete the specified id.
       
   117 		account->DeleteImapAccountL(arrayImap4Accounts[paramDefaultIndex]);
       
   118 			// Just ensure that if we try to delete it again we hopefuly get an error
       
   119 			// or can see that it has been deleted.
       
   120 		arrayImap4Accounts.Remove(paramDefaultIndex);
       
   121 		}
       
   122 	else if (paramDefaultIndex == -1 )
       
   123 		{
       
   124 		// Assume delete all the indexs		
       
   125 		TInt count=arrayImap4Accounts.Count();
       
   126 		TestCase().INFO_PRINTF2(_L("CMtfTestActionDeletePopAccounts deleting all accounts count = %d"), count );
       
   127 		
       
   128 		for(TInt i=0; i<count; i++)
       
   129 			{
       
   130 			TImapAccount id = arrayImap4Accounts[i];
       
   131 			account->DeleteImapAccountL(id);
       
   132 			}
       
   133 		
       
   134 		}
       
   135 	else
       
   136 		{	// Bad value.
       
   137 		TestCase().ERR_PRINTF1(_L("DeleteImapAccounts : Index value must be -1 or greater than 0\n"));
       
   138 		TestCase().SetTestStepResult(EFail);
       
   139 		}		
       
   140 
       
   141 	CleanupStack::PopAndDestroy(2, account);
       
   142 	
       
   143 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionDeleteImapAccounts);
       
   144 	TestCase().ActionCompletedL(*this);	
       
   145 		
       
   146 	}
       
   147 
       
   148