messagingfw/msgtestfw/Framework/src/CMtfTestParameter.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18 */
       
    19  
       
    20 #include "CMtfTestParameter.h" 
       
    21 #include "CMtfTestCase.h"
       
    22 
       
    23 /** Ownership of aParameter is taken at the END. aParameter must be on the cleanup stack.
       
    24 aParameter must not be NULL. */
       
    25 CMtfTestParameter* CMtfTestParameter::NewL(const TDesC& aName, 
       
    26 	TMtfTestParameterGeneralType aGeneralTypeId, TMtfTestParameterSpecificType aSpecificTypeId, TAny* aParameter)
       
    27 {
       
    28 	__ASSERT_ALWAYS(aParameter != NULL, CMtfTestCase::Panic(CMtfTestCase::EMtfInvalidParameter));
       
    29 	CMtfTestParameter* self = new(ELeave) CMtfTestParameter(aGeneralTypeId,aSpecificTypeId);
       
    30 	CleanupStack::PushL(self);
       
    31 	self->ConstructL(aName);
       
    32 	CleanupStack::Pop(self);
       
    33 	self->iParameter = aParameter;
       
    34 	return self;	
       
    35 }
       
    36 
       
    37 CMtfTestParameter::CMtfTestParameter(TMtfTestParameterGeneralType aGeneralTypeId,TMtfTestParameterSpecificType aSpecificTypeId)
       
    38 :iGeneralTypeId(aGeneralTypeId),iSpecificTypeId(aSpecificTypeId)
       
    39 {
       
    40 }
       
    41 
       
    42 void CMtfTestParameter::ConstructL(const TDesC& aName)
       
    43 {
       
    44 	iName = aName.AllocL();
       
    45 }
       
    46 
       
    47 
       
    48 
       
    49 //#include "CMTFTestCase.h"
       
    50 
       
    51 //#include <e32base.h>
       
    52 #include "test/testexecutelog.h"
       
    53 #include "TMtfTestParameterType.h"
       
    54 
       
    55 /** Depending on the parameter type, attempt to cast back to the associated
       
    56 type and delete the parameter. */
       
    57 CMtfTestParameter::~CMtfTestParameter()
       
    58 	{
       
    59 	delete iName;
       
    60 	
       
    61 	switch (iGeneralTypeId)
       
    62 		{
       
    63 		case EMtfValueType:
       
    64 			if(iSpecificTypeId != EMtfTTime)
       
    65 				{
       
    66 				delete reinterpret_cast<HBufC8*>(iParameter);
       
    67 				}
       
    68 			break;
       
    69 		case EMtfHBufCType:
       
    70 		
       
    71 			switch (iSpecificTypeId)
       
    72 				{
       
    73 				case EMtfHBufC:
       
    74 					delete reinterpret_cast<HBufC*>(iParameter); 
       
    75 					break;
       
    76 				case EMtfHBufC8:
       
    77 					delete reinterpret_cast<HBufC8*>(iParameter); 
       
    78 					break;
       
    79 				default: 
       
    80 					User::Panic(KMtfUnrecognisedHBufCType,0); 
       
    81 					break;
       
    82 				}
       
    83 				break;
       
    84 				
       
    85 		case EMtfCBaseType:
       
    86 			if(iSpecificTypeId != EMtfTTime)
       
    87 				{
       
    88 				delete reinterpret_cast<CBase*>(iParameter);
       
    89 				}	
       
    90 			break;
       
    91 			
       
    92 		default:
       
    93 			User::Panic(KMtfParameterGeneralTypeUnrecognised,-781);
       
    94 			break;
       
    95 		}
       
    96 	}
       
    97 
       
    98 const TDesC& CMtfTestParameter::Name() const
       
    99 	{
       
   100 	// guaranteed not to be NULL
       
   101 	return *iName;
       
   102 	}
       
   103 
       
   104 TMtfTestParameterGeneralType CMtfTestParameter::GeneralTypeId() const
       
   105 {
       
   106 	return iGeneralTypeId;
       
   107 }
       
   108 
       
   109 TMtfTestParameterSpecificType CMtfTestParameter::SpecificTypeId() const
       
   110 {
       
   111 	return iSpecificTypeId;
       
   112 }
       
   113 
       
   114 TAny* CMtfTestParameter::Parameter() const
       
   115 {
       
   116 	return iParameter;
       
   117 }
       
   118