common/tools/ats/smoketest/graphics/wserv/src/T_DataWsGraphicBitmapAnimation.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_GraphicsUtil.h"
       
    19 #include "T_DataWsGraphicBitmapAnimation.h"
       
    20 
       
    21 /*@{*/
       
    22 //Commands
       
    23 _LIT(KCmdNew,							    "NewL");
       
    24 _LIT(KCmdDestroy,						    "~");
       
    25 _LIT(KCmdUtil_StartAnimTesterClientL,		"Util_StartAnimTesterClientL");
       
    26 _LIT(KCmdUtil_CloseAnimTesterClientL,		"Util_CloseAnimTesterClientL");
       
    27 
       
    28 // Fields
       
    29 _LIT(KFldFrameCount,						"framescount");
       
    30 _LIT(KFldTFrame,						    "frame%d");
       
    31 _LIT(KFldUid,                               "uid");
       
    32 _LIT(KFldReplace,					        "replace");
       
    33 ///	Logging
       
    34 _LIT(KLogError,								"Error=%d");
       
    35 _LIT(KLogMissingParameter,					"Missing parameter '%S'");
       
    36 
       
    37 _LIT(KLogNew,                               "execute CWsGraphicBitmapAnimation::NewL(const TFrames &aFrames)");
       
    38 _LIT(KLogNew2,                              "execute CWsGraphicBitmapAnimation::NewL(TUid aUid, const TFrames &aFrames)");
       
    39 _LIT(KLogNew3,                              "execute CWsGraphicBitmapAnimation::NewL(const TWsGraphicId &aReplace, const TFrames &aFrames)");
       
    40 _LIT(KLogUtil_StartAnimTesterClientL,		"execute CWsGraphicBitmapAnimation::Util_StartAnimTesterClientL(const TDesC& aSection)");
       
    41 _LIT(KLogUtil_CloseAnimTesterClientL,		"execute CWsGraphicBitmapAnimation::Util_CloseAnimTesterClientL()");
       
    42 /*@}*/
       
    43 
       
    44 //////////////////////////////////////////////////////////////////////
       
    45 // Construction/Destruction
       
    46 //////////////////////////////////////////////////////////////////////
       
    47 
       
    48 CT_DataWsGraphicBitmapAnimation::CT_DataWsGraphicBitmapAnimation()
       
    49 :	CT_DataWsGraphic(),iWsGraphicBitmapAnimation(NULL)
       
    50 	{
       
    51 	}
       
    52 
       
    53 CT_DataWsGraphicBitmapAnimation*	CT_DataWsGraphicBitmapAnimation::NewL()
       
    54 	{
       
    55 	CT_DataWsGraphicBitmapAnimation*    ret=new (ELeave) CT_DataWsGraphicBitmapAnimation();
       
    56 	CleanupStack::PushL(ret);
       
    57 	ret->ConstructL();
       
    58 	CleanupStack::Pop(ret);
       
    59 	return ret;
       
    60 	}
       
    61 
       
    62 void CT_DataWsGraphicBitmapAnimation::ConstructL()
       
    63 	{
       
    64 	}
       
    65 
       
    66 CT_DataWsGraphicBitmapAnimation::~CT_DataWsGraphicBitmapAnimation()
       
    67 	{
       
    68 	DoCmdDestroy();
       
    69 	}
       
    70 
       
    71 /**
       
    72  * Called by TEF framework to set object.
       
    73  *
       
    74  * @param: None
       
    75  *
       
    76  * @return: None
       
    77  */
       
    78 void CT_DataWsGraphicBitmapAnimation::SetObjectL(TAny* aAny)
       
    79 	{
       
    80 	DoCmdDestroy();
       
    81 	iWsGraphicBitmapAnimation = static_cast<CWsGraphicBitmapAnimation*> (aAny);
       
    82 	}
       
    83 
       
    84 /**
       
    85  * Called by TEF framework to disown the object.
       
    86  *
       
    87  * @param: None
       
    88  *
       
    89  * @return: None
       
    90  */
       
    91 void CT_DataWsGraphicBitmapAnimation::DisownObjectL()
       
    92 	{
       
    93 	iWsGraphicBitmapAnimation = NULL;
       
    94 	}
       
    95 
       
    96 /**
       
    97  * Destroy the object which has been constructed.
       
    98  *
       
    99  * @param: None
       
   100  *
       
   101  * @return: None
       
   102  */
       
   103 void CT_DataWsGraphicBitmapAnimation::DoCmdDestroy()
       
   104 	{
       
   105 		delete iWsGraphicBitmapAnimation;
       
   106 		iWsGraphicBitmapAnimation = NULL;
       
   107 	}
       
   108 	
       
   109 /**
       
   110 * Process a command read from the ini file
       
   111 *
       
   112 * @param aCommand			the command to process
       
   113 * @param aSection			the entry in the ini file requiring the command to be processed
       
   114 * @param aAsyncErrorIndex	index of command. used for async calls
       
   115 *
       
   116 * @return ETrue if the command is processed
       
   117 */
       
   118 TBool CT_DataWsGraphicBitmapAnimation::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
       
   119 	{
       
   120 	TBool ret = ETrue;
       
   121 
       
   122 	if ( aCommand==KCmdNew )
       
   123 		{
       
   124 		DoCmdNewL(aSection);
       
   125 		}
       
   126 	else if ( aCommand==KCmdDestroy )
       
   127 		{
       
   128 		DoCmdDestroy();
       
   129 		}
       
   130 	else if ( aCommand==KCmdUtil_StartAnimTesterClientL )
       
   131 		{
       
   132 		Util_StartAnimTesterClientL(aSection);
       
   133 		}
       
   134 	else if ( aCommand==KCmdUtil_CloseAnimTesterClientL )
       
   135 		{
       
   136 		Util_CloseAnimTesterClientL(aSection);
       
   137 		}
       
   138 	else
       
   139 		{
       
   140 		ret=CT_DataWsGraphic::DoCommandL(aCommand,aSection,aAsyncErrorIndex);
       
   141 		}
       
   142 
       
   143 	return ret;
       
   144 	}
       
   145 
       
   146 /**
       
   147  * Process new command
       
   148  *
       
   149  * @param aSection			the entry in the ini file requiring the command to be processed
       
   150  *
       
   151  * @return: None
       
   152  */
       
   153 void CT_DataWsGraphicBitmapAnimation::DoCmdNewL(const TDesC& aSection)
       
   154 	{
       
   155 	TBool dataOk=ETrue;
       
   156 	RPointerArray<CWsGraphicBitmapAnimation::CFrame> frames;
       
   157 
       
   158 	//CWsGraphicBitmapAnimation::TFrames frames;
       
   159     TInt nFrameCount=0;
       
   160     
       
   161     if(!GetIntFromConfig(aSection,KFldFrameCount,nFrameCount))
       
   162         {
       
   163         ERR_PRINTF2(KLogMissingParameter,KFldFrameCount);
       
   164         SetBlockResult(EFail);
       
   165         dataOk=EFalse;
       
   166         }
       
   167     else
       
   168         {
       
   169         RBuf info;
       
   170     	info.Create(256);
       
   171         TPtrC	framename;
       
   172         for(TInt i=0;i<nFrameCount;i++)
       
   173             {
       
   174             info.Format(KFldTFrame,i+1);
       
   175             
       
   176             if(!GetStringFromConfig(aSection,info, framename))
       
   177                 {
       
   178                 ERR_PRINTF2(KLogMissingParameter,info.Ptr());
       
   179                 SetBlockResult(EFail);
       
   180                 dataOk=EFalse;
       
   181                 }
       
   182             else
       
   183                 {
       
   184             	frames.Append(static_cast<CWsGraphicBitmapAnimation::CFrame*>(GetDataObjectL(framename)));
       
   185                 }
       
   186             }
       
   187         info.Close();
       
   188         }
       
   189 		
       
   190 	TInt err=KErrNone;
       
   191 	
       
   192 	if ( dataOk )
       
   193 		{
       
   194         TInt ndata;
       
   195         TWsGraphicId	datReplace(TWsGraphicId::EUninitialized);
       
   196         if(GetIntFromConfig(aSection,KFldUid,ndata))
       
   197             {
       
   198             // Execute command and log parameters
       
   199     		INFO_PRINTF1(KLogNew2);
       
   200      		TRAP( err, iWsGraphicBitmapAnimation=CWsGraphicBitmapAnimation::NewL(TUid::Uid(ndata),frames.Array()));
       
   201             }
       
   202         else if(GetWsGraphicIdFromConfigL(aSection, KFldReplace, datReplace))
       
   203             {
       
   204             // Execute command and log parameters
       
   205     		INFO_PRINTF1(KLogNew3);
       
   206     		TRAP( err, iWsGraphicBitmapAnimation=CWsGraphicBitmapAnimation::NewL(datReplace,frames.Array()));
       
   207             }
       
   208         else
       
   209             {
       
   210             // Execute command and log parameters
       
   211     		INFO_PRINTF1(KLogNew);
       
   212     		TRAP( err, iWsGraphicBitmapAnimation=CWsGraphicBitmapAnimation::NewL(frames.Array()));
       
   213             }
       
   214 		}
       
   215 
       
   216 	if ( err!=KErrNone )
       
   217 		{
       
   218 		ERR_PRINTF2(KLogError, err);
       
   219 		SetError(err);
       
   220 		}
       
   221 	// No command return value and output parameter to display and check
       
   222 	}
       
   223 
       
   224 /**
       
   225  * Process Util_StartAnimTesterClientL command
       
   226  *
       
   227  * @param aSection			the entry in the ini file requiring the command to be processed
       
   228  *
       
   229  * @return: None
       
   230  */
       
   231 void CT_DataWsGraphicBitmapAnimation::Util_StartAnimTesterClientL(const TDesC& aSection)
       
   232 	{
       
   233 	TInt dataOK;
       
   234 	TRAPD( err, dataOK = CT_GraphicsUtil::StartAnimTesterClientL(*this, aSection) );
       
   235 	if( dataOK )
       
   236 		{
       
   237 	    if ( KErrNone == err )
       
   238 	        {
       
   239 	        INFO_PRINTF1(KLogUtil_StartAnimTesterClientL);
       
   240 	        }
       
   241 	    else
       
   242 	        {
       
   243 	        ERR_PRINTF2(KLogError, err);
       
   244 	        SetBlockResult(EFail);
       
   245 	        }
       
   246 		}
       
   247 	else
       
   248 		{
       
   249 		ERR_PRINTF2(KLogMissingParameter, KLogUtil_StartAnimTesterClientL);
       
   250 		}
       
   251 	}
       
   252 
       
   253 /**
       
   254  * Process Util_CloseAnimTesterClientL command
       
   255  *
       
   256  * @param: None
       
   257  *
       
   258  * @return: None
       
   259  */
       
   260 void CT_DataWsGraphicBitmapAnimation::Util_CloseAnimTesterClientL(const TDesC& aSection)
       
   261 	{
       
   262 	TInt dataOK;
       
   263 	TRAPD( err, dataOK = CT_GraphicsUtil::CloseAnimTesterClientL(*this, aSection) );
       
   264 	if( dataOK )
       
   265 		{
       
   266 	    if ( KErrNone == err )
       
   267 	        {
       
   268 	        INFO_PRINTF1(KLogUtil_CloseAnimTesterClientL);
       
   269 	        }
       
   270 	    else
       
   271 	        {
       
   272 	        ERR_PRINTF2(KLogError, err);
       
   273 	        SetBlockResult(EFail);
       
   274 	        }	
       
   275 		}
       
   276 	else
       
   277 		{
       
   278 		ERR_PRINTF2(KLogMissingParameter, KLogUtil_CloseAnimTesterClientL);
       
   279 		}
       
   280 	}
       
   281 
       
   282 
       
   283 TInt CT_DataWsGraphicBitmapAnimation::ShareGlobally()
       
   284 	{
       
   285 	return iWsGraphicBitmapAnimation->ShareGlobally();
       
   286 	}
       
   287 
       
   288 TInt CT_DataWsGraphicBitmapAnimation::UnShareGlobally()
       
   289 	{
       
   290     return iWsGraphicBitmapAnimation->UnShareGlobally();
       
   291   	}
       
   292 
       
   293 
       
   294  TInt CT_DataWsGraphicBitmapAnimation::Share(TSecureId aClientId)
       
   295 	{
       
   296     return iWsGraphicBitmapAnimation->Share(aClientId);
       
   297 	}
       
   298     
       
   299 
       
   300  TInt CT_DataWsGraphicBitmapAnimation::UnShare(TSecureId aClientId)
       
   301 	{
       
   302     return iWsGraphicBitmapAnimation->UnShare(aClientId);    
       
   303 	}