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