messagingfw/msgtestfw/TestActions/Email/Pop3/src/CMtfTestActionGetDefaultPopService.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 // GetDefaultPopService
       
    17 // [Action Parameters]
       
    18 // popClientMtm	<input>:	CPop3ClientMtm
       
    19 // serviceId	<output>:	TMsvId
       
    20 // [Action Description]
       
    21 // GetDefaultPopService Test Action is intended to get the default POP3 service ID.
       
    22 // [APIs Used]	
       
    23 // CPOP3ClientMtm::DefaultServiceL
       
    24 // __ACTION_INFO_END__
       
    25 // 
       
    26 //
       
    27 
       
    28 // system #includes
       
    29 #include <popcmtm.h>
       
    30 
       
    31 // user #includes
       
    32 #include "CMtfTestActionGetDefaultPopService.h"
       
    33 #include "TMtfTestParameterType.h"
       
    34 #include "CMtfTestCase.h"
       
    35 #include "CMtfTestActionParameters.h"
       
    36 
       
    37 /**
       
    38   Function : NewL
       
    39   Description : 
       
    40   @internalTechnology
       
    41   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    42   @param : aActionParams - CMtfTestActionParameters 
       
    43   @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionGetPopAccounts object
       
    44   @pre none
       
    45   @post none
       
    46 */
       
    47 CMtfTestAction* CMtfTestActionGetDefaultPopService::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    48 	{
       
    49 	CMtfTestActionGetDefaultPopService* self = new (ELeave) CMtfTestActionGetDefaultPopService(aTestCase);
       
    50 	CleanupStack::PushL(self);
       
    51 	self->ConstructL(aActionParameters);
       
    52 	CleanupStack::Pop(self);
       
    53 	return self;
       
    54 	}
       
    55 
       
    56 /**
       
    57   Function : CMtfTestActionGetPopAccounts
       
    58   Description : Constructor
       
    59   @internalTechnology
       
    60   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    61   @return : N/A
       
    62   @pre none
       
    63   @post none
       
    64 */
       
    65 CMtfTestActionGetDefaultPopService::CMtfTestActionGetDefaultPopService(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
    66 	{
       
    67 	}
       
    68 	
       
    69 /**
       
    70   Function : ~CMtfTestActionGetPopAccounts
       
    71   Description : Destructor
       
    72   @internalTechnology
       
    73   @param :
       
    74   @return : 
       
    75   @pre 
       
    76   @post 
       
    77 */
       
    78 CMtfTestActionGetDefaultPopService::~CMtfTestActionGetDefaultPopService()
       
    79 	{
       
    80 	}
       
    81 
       
    82 /**
       
    83   Function : ExecuteActionL
       
    84   Description : Entry point for the this test action in the test framework
       
    85   @internalTechnology
       
    86   @param : none
       
    87   @return : void
       
    88   @pre none 
       
    89   @post none
       
    90 */
       
    91 void CMtfTestActionGetDefaultPopService::ExecuteActionL()
       
    92 	{
       
    93 
       
    94 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionGetDefaultPopService);
       
    95 	CPop3ClientMtm* popClientMtm = 
       
    96 		ObtainParameterReferenceL<CPop3ClientMtm>(TestCase(), ActionParameters().Parameter(0));
       
    97 	TInt shouldFail = ObtainValueParameterL<TInt>( TestCase(),ActionParameters().Parameter(1), 0 );
       
    98 	TMsvId serviceId = 0;
       
    99 	
       
   100 	TRAPD( error, serviceId = popClientMtm->DefaultServiceL() );
       
   101 
       
   102 	if( shouldFail )
       
   103 		{
       
   104 		if ( error == KErrNone ) // pass check
       
   105 			{
       
   106 			TestCase().SetTestStepResult(EFail);
       
   107 			}
       
   108 		}
       
   109 	else 
       
   110 		{		
       
   111 		if( error != KErrNone || serviceId < 0 ) // failure check 
       
   112 			{
       
   113 			TestCase().SetTestStepResult(EFail);
       
   114 			}
       
   115 		}
       
   116 
       
   117 	StoreParameterL<TMsvId>(TestCase(), serviceId, ActionParameters().Parameter(2));
       
   118 	TestCase().INFO_PRINTF3(_L("GetDefaultPopService Completed service id = %d should Fail = %d"), serviceId, shouldFail );
       
   119 
       
   120 	TestCase().ActionCompletedL(*this);						
       
   121 	}
       
   122 	
       
   123