common/tools/ats/smoketest/graphics/fntstore/src/T_DataAlgStyle.cpp
changeset 833 6ffc235847d0
child 872 17498133d9ad
equal deleted inserted replaced
832:9b2bf01d4d36 833:6ffc235847d0
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 /**
       
    19 @test
       
    20 @internalComponent
       
    21 
       
    22 This contains CT_DataAlgStyle
       
    23 */
       
    24 
       
    25 #include "T_DataAlgStyle.h"
       
    26 
       
    27 
       
    28 /*@{*/
       
    29 ///	Parameters
       
    30 _LIT(KFactor,									"factor");
       
    31 
       
    32 ///	Commands
       
    33 _LIT(KCmdNew,									"new");
       
    34 _LIT(KCmdSetWidthFactor,						"SetWidthFactor");
       
    35 _LIT(KCmdSetHeightFactor,						"SetHeightFactor");
       
    36 _LIT(KCleanup,									"~");
       
    37 
       
    38 /*@}*/
       
    39 
       
    40 
       
    41 /**
       
    42 * Two phase constructor
       
    43 */
       
    44 CT_DataAlgStyle* CT_DataAlgStyle::NewL()
       
    45 	{
       
    46 	CT_DataAlgStyle* ret = new (ELeave) CT_DataAlgStyle();
       
    47 	CleanupStack::PushL(ret);
       
    48 	ret->ConstructL();
       
    49 	CleanupStack::Pop(ret);
       
    50 	return ret;
       
    51 	}
       
    52 
       
    53 
       
    54 /**
       
    55 * Protected constructor. First phase construction
       
    56 */
       
    57 CT_DataAlgStyle::CT_DataAlgStyle()
       
    58 :	CDataWrapperBase()
       
    59 ,	iAlgStyle(NULL)
       
    60 	{
       
    61 	}
       
    62 
       
    63 
       
    64 /**
       
    65 * Protected second phase construction
       
    66 */
       
    67 void CT_DataAlgStyle::ConstructL()
       
    68 	{
       
    69 	}
       
    70 
       
    71 
       
    72 /**
       
    73 * Destructor.
       
    74 */
       
    75 CT_DataAlgStyle::~CT_DataAlgStyle()
       
    76 	{
       
    77 	DestroyData();
       
    78 	}
       
    79 
       
    80 
       
    81 /**
       
    82 * cleanup implementation.
       
    83 */
       
    84 void CT_DataAlgStyle::DestroyData()
       
    85 	{
       
    86 	delete iAlgStyle;
       
    87 	iAlgStyle = NULL;
       
    88 	}
       
    89 
       
    90 TAny* CT_DataAlgStyle::GetObject()
       
    91 	{
       
    92 	return iAlgStyle;
       
    93 	}
       
    94 
       
    95 void CT_DataAlgStyle::SetObjectL(TAny* aObject)
       
    96 	{
       
    97 	DestroyData();
       
    98 	iAlgStyle	= static_cast<TAlgStyle*> (aObject);
       
    99 	}
       
   100 		
       
   101 void CT_DataAlgStyle::DisownObjectL() 
       
   102 	{
       
   103 	iAlgStyle = NULL;
       
   104 	}
       
   105 
       
   106 /**
       
   107 * Process a command read from the ini file
       
   108 *
       
   109 * @param aDataWrapper	test step requiring command to be processed
       
   110 * @param aCommand	the command to process
       
   111 * @param aSection		the entry in the ini file requiring the command to be processed
       
   112 *
       
   113 * @return ETrue if the command is processed
       
   114 */
       
   115 TBool CT_DataAlgStyle::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
       
   116 	{
       
   117 	TBool retVal = ETrue;
       
   118 
       
   119 	if (aCommand == KCmdNew)
       
   120 		{
       
   121 		DoCmdNew();
       
   122 		}
       
   123 	else if (aCommand == KCmdSetWidthFactor)
       
   124 		{
       
   125 		DoCmdSetWidthFactor(aSection);
       
   126 		}
       
   127 	else if (aCommand == KCmdSetHeightFactor)
       
   128 		{
       
   129 		DoCmdSetHeightFactor(aSection);
       
   130 		}
       
   131 	else if (aCommand == KCleanup)
       
   132 		{
       
   133 		DestroyData();
       
   134 		}
       
   135 	else
       
   136 		{
       
   137 		retVal=EFalse;
       
   138 		}
       
   139 
       
   140 	return retVal;
       
   141 	}
       
   142 
       
   143 
       
   144 ////////////////// COMMANDS IMPLEMENTATION  ////////////////////////
       
   145 
       
   146 /** Creates an instance of TAlgSAtyle structure */
       
   147 void CT_DataAlgStyle::DoCmdNew()
       
   148 	{
       
   149 	INFO_PRINTF1(_L("Creates an instance of TAlgSAtyle structure"));
       
   150 
       
   151 	// cleanup if any
       
   152 	DestroyData();
       
   153 
       
   154 	// call new operator
       
   155 	TRAPD(err, iAlgStyle = new (ELeave) TAlgStyle());
       
   156 
       
   157 	// check error code
       
   158 	if (err != KErrNone)
       
   159 		{
       
   160 		ERR_PRINTF2(_L("Error creating an instance: %d"), err);
       
   161 		SetError(err);
       
   162 		}
       
   163 	}
       
   164 
       
   165 
       
   166 /** Calls TAlgSAtyle::SetWidthFactor() */
       
   167 void CT_DataAlgStyle::DoCmdSetWidthFactor(const TDesC& aSection)
       
   168 	{
       
   169 	INFO_PRINTF1(_L("Calls TAlgSAtyle::SetWidthFactor()"));
       
   170 	// get factor from parameters
       
   171 	TInt	factor;
       
   172 	if (!GetIntFromConfig(aSection, KFactor(), factor) )
       
   173 		{
       
   174 		ERR_PRINTF2(_L("No %S"), &KFactor());
       
   175 		SetBlockResult(EFail);
       
   176 		}
       
   177 
       
   178 	// call SetWidthFactor()		
       
   179 	iAlgStyle->SetWidthFactor(factor);
       
   180 	}
       
   181 
       
   182 
       
   183 /** Calls TAlgSAtyle::SetWidthFactor() */
       
   184 void CT_DataAlgStyle::DoCmdSetHeightFactor(const TDesC& aSection)
       
   185 	{
       
   186 	INFO_PRINTF1(_L("Calls TAlgSAtyle::SetHeightFactor()"));
       
   187 
       
   188 	// get factor from parameters
       
   189 	TInt	factor;
       
   190 	if (!GetIntFromConfig(aSection, KFactor(), factor) )
       
   191 		{
       
   192 		ERR_PRINTF2(_L("No %S"), &KFactor());
       
   193 		SetBlockResult(EFail);
       
   194 		}
       
   195 
       
   196 	// call SetHeightFactor()		
       
   197 	iAlgStyle->SetHeightFactor(factor);
       
   198 	}
       
   199 
       
   200