messagingfw/msgtestfw/TestActions/Base/src/CMtfTestActionExecuteMtmCommand.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
child 58 6c34d0baa0b1
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2003-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 // ExecuteMtmCommand
       
    17 // [Action Parameters]
       
    18 // Command           <input>: Value of the command.
       
    19 // Mtm               <input>: Reference to the client MTM.
       
    20 // Selection         <input>: Reference to the selection.
       
    21 // CommandParameters <input>: Reference to the command parameters.
       
    22 // (SynchronousFlag) <input>: Value of the flag which specifies if the command is executed synchronously. 
       
    23 // Default is false (asynchronous).
       
    24 // [Action Description]
       
    25 // Executes the specific MTM command.
       
    26 // [APIs Used]
       
    27 // __ACTION_INFO_END__
       
    28 // 
       
    29 //
       
    30 
       
    31 /**
       
    32  @file
       
    33 */
       
    34 
       
    35 
       
    36 #include "CMtfTestActionExecuteMtmCommand.h"
       
    37 #include "CMtfTestCase.h"
       
    38 #include "CMtfTestActionParameters.h"
       
    39 #include "MtfTestActionUtilsUser.h"
       
    40 
       
    41 #include <impcmtm.h>
       
    42 
       
    43 
       
    44 CMtfTestAction* CMtfTestActionExecuteMtmCommand::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    45 	{
       
    46 	CMtfTestActionExecuteMtmCommand* self = new (ELeave) CMtfTestActionExecuteMtmCommand(aTestCase);
       
    47 	CleanupStack::PushL(self);
       
    48 	self->ConstructL(aActionParameters);
       
    49 	CleanupStack::Pop();
       
    50 	return self;
       
    51 	}
       
    52 	
       
    53 
       
    54 CMtfTestActionExecuteMtmCommand::CMtfTestActionExecuteMtmCommand(CMtfTestCase& aTestCase)
       
    55 	: CMtfTestAction(aTestCase)
       
    56 	{
       
    57 	}
       
    58 
       
    59 
       
    60 CMtfTestActionExecuteMtmCommand::~CMtfTestActionExecuteMtmCommand()
       
    61 	{
       
    62 	}
       
    63 
       
    64 
       
    65 void CMtfTestActionExecuteMtmCommand::ExecuteActionL()
       
    66 	{
       
    67 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionExecuteMtmCommand);
       
    68 	TInt paramCommand = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(0));
       
    69 	CBaseMtm* paramMtm = ObtainParameterReferenceL<CBaseMtm>(TestCase(),ActionParameters().Parameter(1));
       
    70 	CMsvEntrySelection* paramSelection = ObtainParameterReferenceL<CMsvEntrySelection>(TestCase(),ActionParameters().Parameter(2));
       
    71 	HBufC8* paramCommandParameters = ObtainParameterReferenceL<HBufC8>(TestCase(),ActionParameters().Parameter(3));
       
    72 	TInt paramSynchronousFlag = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(4),EFalse);
       
    73 
       
    74 	TPtr8 commandParameters = paramCommandParameters->Des();
       
    75 
       
    76 	if (paramSynchronousFlag)
       
    77 		{
       
    78 		paramMtm->InvokeSyncFunctionL(paramCommand,*paramSelection,commandParameters);
       
    79 		TestCase().ActionCompletedL(*this);
       
    80 		}
       
    81 	else
       
    82 		{
       
    83 		iOperation = paramMtm->InvokeAsyncFunctionL(paramCommand,*paramSelection,commandParameters,iStatus);
       
    84 		CActiveScheduler::Add(this);
       
    85 		SetActive();
       
    86 		}
       
    87 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionExecuteMtmCommand);
       
    88 	}
       
    89 
       
    90 
       
    91 void CMtfTestActionExecuteMtmCommand::DoCancel()
       
    92 	{
       
    93 	iOperation->Cancel();
       
    94 	}
       
    95 
       
    96 
       
    97 void CMtfTestActionExecuteMtmCommand::RunL()
       
    98 	{
       
    99 	TInt err = MtfTestActionUtilsUser::FinalProgressStatus(*iOperation,iStatus);
       
   100 	delete iOperation;
       
   101 	User::LeaveIfError(err);
       
   102 
       
   103 	TestCase().ActionCompletedL(*this);
       
   104 	}
       
   105