common/tools/ats/smoketest/graphics/fntstore/src/T_DataOpenFontGlyphData.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_DataOpenFontGlyphData
       
    23 */
       
    24 
       
    25 #include "T_DataOpenFontGlyphData.h"
       
    26 
       
    27 
       
    28 /*@{*/
       
    29 ///	Parameters
       
    30 _LIT(KFldBufferSize,							"buffer_size");
       
    31 
       
    32 ///	Commands
       
    33 _LIT(KCmdNew,									"New");
       
    34 _LIT(KCmdDestructor,							"~");
       
    35 
       
    36 /// Logs
       
    37 _LIT(KLogMissingParameter,						"Missing parameter '%S'");
       
    38 
       
    39 /*@}*/
       
    40 
       
    41 /**
       
    42 * Two phase constructor
       
    43 */
       
    44 CT_DataOpenFontGlyphData* CT_DataOpenFontGlyphData::NewL()
       
    45 	{
       
    46 	CT_DataOpenFontGlyphData* ret = new (ELeave) CT_DataOpenFontGlyphData();
       
    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_DataOpenFontGlyphData::CT_DataOpenFontGlyphData()
       
    58 :	CDataWrapperBase()
       
    59 ,	iGlyphData(NULL)
       
    60 	{
       
    61 	}
       
    62 
       
    63 
       
    64 /**
       
    65 * Protected second phase construction
       
    66 */
       
    67 void CT_DataOpenFontGlyphData::ConstructL()
       
    68 	{
       
    69 	}
       
    70 
       
    71 
       
    72 /**
       
    73 * Destructor.
       
    74 */
       
    75 CT_DataOpenFontGlyphData::~CT_DataOpenFontGlyphData()
       
    76 	{
       
    77 	if (iGlyphData != NULL)
       
    78 		DestroyData();
       
    79 	}
       
    80 
       
    81 
       
    82 /**
       
    83 * cleanup implementation.
       
    84 */
       
    85 void CT_DataOpenFontGlyphData::DestroyData()
       
    86 	{
       
    87 	User::Heap().Free(iGlyphData);
       
    88 	iGlyphData = NULL;
       
    89 	}
       
    90 
       
    91 TAny* CT_DataOpenFontGlyphData::GetObject()
       
    92 	{
       
    93 	return iGlyphData;
       
    94 	}
       
    95 
       
    96 void CT_DataOpenFontGlyphData::SetObjectL(TAny* aObject)
       
    97 	{
       
    98 	DestroyData();
       
    99 	iGlyphData	= static_cast<TOpenFontGlyphData*> (aObject);
       
   100 	}
       
   101 		
       
   102 void CT_DataOpenFontGlyphData::DisownObjectL() 
       
   103 	{
       
   104 	iGlyphData = NULL;
       
   105 	}
       
   106 
       
   107 /**
       
   108 * Process a command read from the ini file
       
   109 *
       
   110 * @param aDataWrapper	test step requiring command to be processed
       
   111 * @param aCommand	the command to process
       
   112 * @param aSection		the entry in the ini file requiring the command to be processed
       
   113 *
       
   114 * @return ETrue if the command is processed
       
   115 */
       
   116 TBool CT_DataOpenFontGlyphData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
       
   117 	{
       
   118 	TBool retVal = ETrue;
       
   119 
       
   120 	if (aCommand == KCmdNew)
       
   121 		{
       
   122 		DoCmdNew(aSection);
       
   123 		}
       
   124 	else if (aCommand == KCmdDestructor)
       
   125 		{
       
   126 		DoCmdDestructor();
       
   127 		}
       
   128 	else
       
   129 		{
       
   130 		retVal=EFalse;
       
   131 		}
       
   132 
       
   133 	return retVal;
       
   134 	}
       
   135 
       
   136 
       
   137 ////////////////// COMMANDS IMPLEMENTATION  ////////////////////////
       
   138 
       
   139 /** Creates an instance of TOpenFontGlyphData structure */
       
   140 void CT_DataOpenFontGlyphData::DoCmdNew(const TDesC& aSection)
       
   141 	{
       
   142 	INFO_PRINTF1(_L("Creates an object of TOpenFontGlyphData"));
       
   143 
       
   144 	// cleanup if any
       
   145 	DestroyData();
       
   146 
       
   147 	TInt	bufsize;
       
   148 	if (!GetIntFromConfig(aSection, KFldBufferSize, bufsize))
       
   149 		{
       
   150 		ERR_PRINTF2(KLogMissingParameter, &KFldBufferSize());
       
   151 		SetBlockResult(EFail);
       
   152 		}
       
   153 	
       
   154 	// call TOpenFontGlyphData::New()
       
   155 	INFO_PRINTF1(_L("execute TOpenFontGlyphData::New(RHeap*, TInt)"));
       
   156 	iGlyphData = TOpenFontGlyphData::New(&(User::Heap()), bufsize);
       
   157 
       
   158 	if (iGlyphData == NULL)
       
   159 		{
       
   160 		ERR_PRINTF1(_L("No enough memory"));
       
   161 		SetError(KErrNoMemory);
       
   162 		}
       
   163 	}
       
   164 
       
   165 void CT_DataOpenFontGlyphData::DoCmdDestructor()
       
   166 	{
       
   167 	DestroyData();
       
   168 	}