messagingfw/msgtestfw/TestActions/Base/src/CMtfTestActionInstallMtmGroup.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 // CMtfTestActionInstallMtm.cpp
       
    15 // __ACTION_INFO_BEGIN__ 
       
    16 // [Action Name]
       
    17 // InstallMtmGroup
       
    18 // [Action Parameters]
       
    19 // Session     <input>: Reference to the session.
       
    20 // FileName	   <input>: Data component file name
       
    21 // [Action Description]
       
    22 // Installs a new group of MTMs.
       
    23 // [APIs Used]
       
    24 // CMsvSession::InstallMtmGroup
       
    25 // __ACTION_INFO_END__
       
    26 // 
       
    27 //
       
    28 
       
    29 
       
    30 #include "CMtfTestActionInstallMtmGroup.h"
       
    31 #include "CMtfTestCase.h"
       
    32 #include "CMtfTestActionParameters.h"
       
    33 
       
    34 #include <msvapi.h>
       
    35 
       
    36 /**
       
    37   Function : NewL
       
    38   Description				:Creates a new CMtfTestActionInstallMtmGroup object
       
    39   @internalTechnology
       
    40   @param : aTestCase 		:Reference to the Test case
       
    41   @param : aActionParams 	:Test Action parameters 
       
    42   @return : CMtfTestAction* :a base class pointer to the newly created object
       
    43   @pre none
       
    44   @post none
       
    45 */
       
    46 CMtfTestAction* CMtfTestActionInstallMtmGroup::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    47 	{
       
    48 	CMtfTestActionInstallMtmGroup* self = new (ELeave) CMtfTestActionInstallMtmGroup(aTestCase);
       
    49 	CleanupStack::PushL(self);
       
    50 	self->ConstructL(aActionParameters);
       
    51 	CleanupStack::Pop(self);
       
    52 	return self;
       
    53 	}
       
    54 	
       
    55 /**
       
    56   Function : CMtfTestActionInstallMtmGroup
       
    57   Description : Constructor
       
    58   @internalTechnology
       
    59   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    60   @pre none
       
    61   @post none
       
    62 */
       
    63 CMtfTestActionInstallMtmGroup::CMtfTestActionInstallMtmGroup(CMtfTestCase& aTestCase)
       
    64 	: CMtfSynchronousTestAction(aTestCase)
       
    65 	{
       
    66 	}
       
    67 
       
    68 /**
       
    69   Function : ~CMtfTestActionInstallMtmGroup
       
    70   Description : Destructor
       
    71   @internalTechnology
       
    72 */
       
    73 CMtfTestActionInstallMtmGroup::~CMtfTestActionInstallMtmGroup()
       
    74 	{
       
    75 	}
       
    76 
       
    77 /**
       
    78   Function : ExecuteActionL
       
    79   Description		: Installs a new group of MTMs
       
    80   @internalTechnology
       
    81   @param			: none
       
    82   @return			: void
       
    83   @pre		: 
       
    84   @post	: none
       
    85 */
       
    86 void CMtfTestActionInstallMtmGroup::ExecuteActionL()
       
    87 	{
       
    88 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionInstallMtmGroup);
       
    89 	// Obtain input parameters
       
    90 	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),
       
    91 												 ActionParameters().Parameter(0));
       
    92 
       
    93 	HBufC* paramFileName = ObtainParameterReferenceL<HBufC>(TestCase(),
       
    94 												ActionParameters().Parameter(1));
       
    95 												
       
    96 	// If valid parameters received, call install MTM group
       
    97 	if( (paramFileName != NULL) && (paramSession != NULL) )
       
    98 		{
       
    99 		TInt result  = paramSession->InstallMtmGroup(*paramFileName); 
       
   100 		
       
   101 		// Print the result
       
   102 		if(result == KErrAlreadyExists)
       
   103 			{
       
   104 			TestCase().INFO_PRINTF1(_L("MTM already installed"));
       
   105 			}
       
   106 		else if(result == KErrNone)
       
   107 			{
       
   108 			TestCase().INFO_PRINTF1(_L("MTM installed successfully"));
       
   109 			}
       
   110 		else
       
   111 			{
       
   112 			TestCase().ERR_PRINTF2(_L("MTM installation Failed with error %d"), result);
       
   113 			User::Leave(result);
       
   114 			}
       
   115 		}
       
   116 	else
       
   117 		{
       
   118 		// Invaid parameters received, leave the Test Action
       
   119 		User::Leave(KErrArgument);
       
   120 		}	
       
   121 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionInstallMtmGroup);
       
   122 	TestCase().ActionCompletedL(*this);
       
   123 	}