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