common/tools/ats/smoketest/graphics/wserv/src/T_DataAnimDll.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 #include "T_DataAnimDll.h"
       
    19 #include "T_GraphicsUtil.h"
       
    20 
       
    21 /*@{*/
       
    22 _LIT(KDataClassname,							"RAnimDll");
       
    23 
       
    24 ///	Fields
       
    25 _LIT(KFldWs,									"ws");
       
    26 _LIT(KPlugInFileName,							"filename");
       
    27 
       
    28 ///	Commands
       
    29 _LIT(KCmdnew,									"new");
       
    30 _LIT(KCmdDestructorGeneral,						"~");
       
    31 _LIT(KCmdDestructor,							"~RAnimDll");
       
    32 _LIT(KCmdLoad,									"Load");
       
    33 _LIT(KCmdDestroy,								"Destroy");
       
    34 _LIT(KCmdClose,									"Close");
       
    35 
       
    36 ///	Logging
       
    37 _LIT(KLogErrNum,			"Error=%d");
       
    38 _LIT(KLogErrMissingPara,	"Missing parameter '%S'");
       
    39 _LIT(KLogErrLoad,			"Load file error %d. File name: %S");
       
    40 _LIT(KLogInfoCmdnewL1,		"execute new RAnimDll(RWsSession &)");
       
    41 _LIT(KLogInfoCmdnewL2,		"execute new RAnimDll()");
       
    42 _LIT(KLogInfoCmdLoad1,		"execute RAnimDll::Load(const TDesC &)");
       
    43 _LIT(KLogInfoCmdClose1,		"execute RAnimDll::Close()");
       
    44 _LIT(KLogInfoCmdDestroy1,	"execute RAnimDll::Destroy()");
       
    45 _LIT(KLogInfoCmdDestructor1,"execute ~RAnimDll()");
       
    46 /*@}*/
       
    47 
       
    48 CT_DataAnimDll* CT_DataAnimDll::NewL()
       
    49 	{
       
    50 	CT_DataAnimDll*	ret = new (ELeave) CT_DataAnimDll();
       
    51 	CleanupStack::PushL(ret);
       
    52 	ret->ConstructL();
       
    53 	CleanupStack::Pop(ret);
       
    54 	return ret;
       
    55 	}
       
    56 
       
    57 CT_DataAnimDll::CT_DataAnimDll()
       
    58 :	iAnimDll(NULL)
       
    59 	{
       
    60 	}
       
    61 
       
    62 void CT_DataAnimDll::ConstructL()
       
    63 	{
       
    64 	}
       
    65 
       
    66 CT_DataAnimDll::~CT_DataAnimDll()
       
    67 	{
       
    68 	DestroyData();
       
    69 	}
       
    70 
       
    71 TAny* CT_DataAnimDll::GetObject()
       
    72 	{
       
    73 	return iAnimDll;
       
    74 	}
       
    75 
       
    76 void CT_DataAnimDll::SetObjectL(TAny* aAny)
       
    77 	{
       
    78 	DestroyData();
       
    79 	iAnimDll = static_cast<RAnimDll*> (aAny);
       
    80 	}
       
    81 
       
    82 void CT_DataAnimDll::DisownObjectL()
       
    83 	{
       
    84 	iAnimDll = NULL;
       
    85 	}
       
    86 
       
    87 void CT_DataAnimDll::DestroyData()
       
    88 	{
       
    89 	DoCmdDestructor();
       
    90 	}
       
    91 
       
    92 MWsClientClass* CT_DataAnimDll::GetClientClass() const
       
    93 	{
       
    94 	return iAnimDll;
       
    95 	}
       
    96 
       
    97 /**
       
    98 * Process a command read from the ini file
       
    99 *
       
   100 * @param aCommand			the command to process
       
   101 * @param aSection			the entry in the ini file requiring the command to be processed
       
   102 * @param aAsyncErrorIndex	index of command. used for async calls
       
   103 *
       
   104 * @return ETrue if the command is processed
       
   105 */
       
   106 TBool CT_DataAnimDll::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
       
   107 	{
       
   108 	TBool	ret = ETrue;
       
   109 
       
   110 	if ( aCommand==KCmdDestructorGeneral || aCommand==KCmdDestructor )
       
   111 		{
       
   112 		DoCmdDestructor();
       
   113 		}
       
   114 	else if ( aCommand==KCmdnew || aCommand==KDataClassname )
       
   115 		{
       
   116 		DoCmdnewL(aSection);
       
   117 		}
       
   118 	else if ( aCommand==KCmdLoad )
       
   119 		{
       
   120 		DoCmdLoad(aSection);
       
   121 		}
       
   122 	else if ( aCommand==KCmdDestroy )
       
   123 		{
       
   124 		DoCmdDestroy();
       
   125 		}
       
   126 	else if ( aCommand==KCmdClose )
       
   127 		{
       
   128 		DoCmdClose();
       
   129 		}
       
   130 	else
       
   131 		{
       
   132 		ret=CT_DataWsClientClass::DoCommandL(*this, aCommand, aSection, aAsyncErrorIndex);
       
   133 		}
       
   134 
       
   135 	return ret;
       
   136 	}
       
   137 
       
   138 void CT_DataAnimDll::DoCmdnewL(const TDesC& aSection)
       
   139 	{
       
   140 	DestroyData();
       
   141 
       
   142 	// Get test data for command input parameter(s)
       
   143 	TPtrC		wsName;
       
   144 	RWsSession*	ws = NULL;
       
   145 	if ( GetStringFromConfig(aSection, KFldWs, wsName) )
       
   146 		{
       
   147 		ws = static_cast<RWsSession*>(GetDataObjectL(wsName));
       
   148 		}
       
   149 
       
   150 	TInt err = KErrNone;
       
   151 	if ( ws!= NULL )
       
   152 		{
       
   153 		// Execute command and log parameters
       
   154 		INFO_PRINTF1(KLogInfoCmdnewL1);
       
   155 		TRAP( err, iAnimDll = new (ELeave) RAnimDll(*ws) );
       
   156 		}
       
   157 	else
       
   158 		{
       
   159 		// Execute command and log parameters
       
   160 		INFO_PRINTF1(KLogInfoCmdnewL2);
       
   161 		TRAP(err, iAnimDll = new (ELeave) RAnimDll());
       
   162 		}
       
   163 	
       
   164 	// Check the command return code
       
   165 	if ( err!=KErrNone )
       
   166 		{
       
   167 		ERR_PRINTF2(KLogErrNum, err);
       
   168 		SetError(err);
       
   169 		}
       
   170 	}
       
   171 
       
   172 void CT_DataAnimDll::DoCmdLoad(const TDesC& aSection)
       
   173 	{
       
   174 	TInt err = KErrNone;
       
   175 	
       
   176 	// Get test data for command input parameter(s)
       
   177 	TPtrC fileName;
       
   178 	if(!GetStringFromConfig(aSection, KPlugInFileName(), fileName))
       
   179 		{
       
   180 		ERR_PRINTF2(KLogErrMissingPara, &KPlugInFileName());
       
   181 		SetBlockResult(EFail);
       
   182 		}
       
   183 	else
       
   184 		{	
       
   185 		// Execute command and log parameters
       
   186 		if (iAnimDll != NULL)
       
   187 			{
       
   188 			INFO_PRINTF1(KLogInfoCmdLoad1);
       
   189 			err = iAnimDll->Load(fileName);
       
   190 			}
       
   191 		
       
   192 		// Check the command return code
       
   193 		if(err != KErrNone)
       
   194 			{
       
   195 			ERR_PRINTF3(KLogErrLoad, err, &fileName);
       
   196 			SetError(err);
       
   197 			}
       
   198 		}
       
   199 	}
       
   200 
       
   201 void CT_DataAnimDll::DoCmdClose()
       
   202 	{
       
   203 	// Execute command and log parameters
       
   204 	if (iAnimDll != NULL)
       
   205 		{
       
   206 		INFO_PRINTF1(KLogInfoCmdClose1);
       
   207 		iAnimDll->Close();
       
   208 		}
       
   209 	}
       
   210 
       
   211 void CT_DataAnimDll::DoCmdDestroy()
       
   212 	{
       
   213 	// Execute command and log parameters
       
   214 	if (iAnimDll != NULL)
       
   215 		{
       
   216 		INFO_PRINTF1(KLogInfoCmdDestroy1);
       
   217 		iAnimDll->Destroy();
       
   218 		iAnimDll = NULL;
       
   219 		}
       
   220 	}
       
   221 
       
   222 void CT_DataAnimDll::DoCmdDestructor()
       
   223 	{
       
   224 	// Execute command and log parameters
       
   225 	INFO_PRINTF1(KLogInfoCmdDestructor1);
       
   226 	delete iAnimDll;
       
   227 	iAnimDll = NULL;
       
   228 	}
       
   229