graphicsapitest/graphicssvs/wserv/src/T_DataFrame.cpp
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     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 "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-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_DataFrame.h"
       
    20 #include <fbs.h>
       
    21 
       
    22 /*@{*/
       
    23 //Commands
       
    24 _LIT(KCmdNew,							    "NewL");
       
    25 _LIT(KCmdDestroy,						    "~");
       
    26 _LIT(KCmdFrameInfo,						    "FrameInfo");
       
    27 _LIT(KCmdSetFrameInfo,					    "SetFrameInfo");
       
    28 _LIT(KCmdBitmap,						    "Bitmap");
       
    29 _LIT(KCmdSetBitmap,						    "SetBitmap");
       
    30 _LIT(KCmdMask,						        "Mask");
       
    31 _LIT(KCmdSetMask,						    "SetMask");
       
    32 // Fields
       
    33 _LIT(KFldFrameInfo,						    "frameinfostate");
       
    34 _LIT(KFldTFrame,						    "frame%d");
       
    35 _LIT(KFldUid,                               "uid");
       
    36 _LIT(KFldTWsGraphicId,					    "graphicid");
       
    37 _LIT(KFldSecureId,                          "secureid");
       
    38 _LIT(KFldSetMask,                           "setmask");
       
    39 _LIT(KFldSetFrameInfo,                      "setframeinfo");
       
    40 _LIT(KFldSetBitmap,                         "setbitmap");
       
    41 _LIT(KFldMask,                              "expected_mask");
       
    42 _LIT(KFldBitmap,                            "expected_bitmap");
       
    43 _LIT(KFldGotMask,                           "got_mask");
       
    44 _LIT(KFldGotBitmap,                         "got_bitmap");
       
    45 ///	Logging
       
    46 _LIT(KLogError,								"Error=%d");
       
    47 _LIT(KLogMissingParameter,					"Missing parameter '%S'");
       
    48 _LIT(KLogNotExpectedValue,					"Not expected value");
       
    49 
       
    50 _LIT(KLogNew,                               "execute CT_DataFrame::NewL()");
       
    51 _LIT(KLogFrameInfo,                         "execute CT_DataFrame::FrameInfo()");
       
    52 _LIT(KLogSetFrameInfo,                      "execute CT_DataFrame::SetFrameInfo(const TFrameInfo &aFrameInfo)");
       
    53 _LIT(KLogBitmap,                            "execute CT_DataFrame::Bitmap()");
       
    54 _LIT(KLogSetBitmap,                         "execute CT_DataFrame::SetBitmap(CFbsBitmap *aBitmap)");
       
    55 _LIT(KLogMask,                              "execute CT_DataFrame::Mask()");
       
    56 _LIT(KLogSetMask,                           "execute CT_DataFrame::SetMask(CFbsBitmap *aMask)");
       
    57 /*@}*/
       
    58 
       
    59 //////////////////////////////////////////////////////////////////////
       
    60 // Construction/Destruction
       
    61 //////////////////////////////////////////////////////////////////////
       
    62 
       
    63 CT_DataFrame::CT_DataFrame()
       
    64 :	CDataWrapperBase(),iFrame(NULL)
       
    65 	{
       
    66 	}
       
    67 
       
    68 CT_DataFrame* CT_DataFrame::NewL()
       
    69 	{
       
    70 	CT_DataFrame* ret=new (ELeave) CT_DataFrame();
       
    71 	CleanupStack::PushL(ret);
       
    72 	ret->ConstructL();
       
    73 	CleanupStack::Pop(ret);
       
    74 	return ret;
       
    75 	}
       
    76 
       
    77 void CT_DataFrame::ConstructL()
       
    78 	{
       
    79 	}
       
    80 
       
    81 CT_DataFrame::~CT_DataFrame()
       
    82 	{
       
    83 	DoCmdDestroy();
       
    84 	}
       
    85 
       
    86 /**
       
    87  * Called by TEF framework to set object.
       
    88  *
       
    89  * @param: None
       
    90  *
       
    91  * @return: None
       
    92  */
       
    93 void CT_DataFrame::SetObjectL(TAny* aAny)
       
    94 	{
       
    95 	DoCmdDestroy();
       
    96 	iFrame = static_cast<CWsGraphicBitmapAnimation::CFrame*> (aAny);
       
    97 	}
       
    98 
       
    99 /**
       
   100  * Called by TEF framework to disown the object.
       
   101  *
       
   102  * @param: None
       
   103  *
       
   104  * @return: None
       
   105  */
       
   106 void CT_DataFrame::DisownObjectL()
       
   107 	{
       
   108 	iFrame = NULL;
       
   109 	}
       
   110 
       
   111 /**
       
   112  * Destroy the object which has been constructed.
       
   113  *
       
   114  * @param: None
       
   115  *
       
   116  * @return: None
       
   117  */
       
   118 void CT_DataFrame::DoCmdDestroy()
       
   119 	{
       
   120 	delete iFrame;
       
   121 	iFrame = NULL;
       
   122 	}
       
   123 	
       
   124 /**
       
   125 * Process a command read from the ini file
       
   126 *
       
   127 * @param aCommand			the command to process
       
   128 * @param aSection			the entry in the ini file requiring the command to be processed
       
   129 * @param aAsyncErrorIndex	index of command. used for async calls
       
   130 *
       
   131 * @return ETrue if the command is processed
       
   132 */
       
   133 TBool CT_DataFrame::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
       
   134 	{
       
   135 	TBool ret = ETrue;
       
   136 
       
   137 	if ( aCommand==KCmdNew )
       
   138 		{
       
   139 		DoCmdNewL();
       
   140 		}
       
   141 	else if ( aCommand==KCmdDestroy )
       
   142 		{
       
   143 		DoCmdDestroy();
       
   144 		}
       
   145 	else if ( aCommand==KCmdFrameInfo )
       
   146 		{
       
   147 		DoCmdFrameInfo(aSection);
       
   148 		}
       
   149     else if ( aCommand==KCmdSetFrameInfo )
       
   150 		{
       
   151 		DoCmdSetFrameInfo(aSection);
       
   152 		}
       
   153     else if ( aCommand==KCmdBitmap )
       
   154 		{
       
   155 		DoCmdBitmapL(aSection);
       
   156 		}
       
   157     else if ( aCommand==KCmdSetBitmap )
       
   158 		{
       
   159 		DoCmdSetBitmapL(aSection);
       
   160 		}
       
   161     else if ( aCommand==KCmdMask )
       
   162 		{
       
   163 		DoCmdMaskL(aSection);
       
   164 		}
       
   165     else if ( aCommand==KCmdSetMask )
       
   166 		{
       
   167 		DoCmdSetMaskL(aSection);
       
   168 		}
       
   169 	else
       
   170 		{
       
   171 		ret=EFalse;
       
   172 		}
       
   173 
       
   174 	return ret;
       
   175 	}
       
   176 
       
   177 /**
       
   178  * Process new command
       
   179  *
       
   180  * @return: None
       
   181  */
       
   182 void CT_DataFrame::DoCmdNewL()
       
   183 	{
       
   184     // Execute command and log parameters
       
   185     INFO_PRINTF1(KLogNew);
       
   186     TInt err=KErrNone;
       
   187     TRAP( err, iFrame=CWsGraphicBitmapAnimation::CFrame::NewL());
       
   188 
       
   189 	if ( err!=KErrNone )
       
   190 		{
       
   191 		ERR_PRINTF2(KLogError, err);
       
   192 		SetError(err);
       
   193 		}
       
   194 	// No command return value and output parameter to display and check
       
   195 	}
       
   196 
       
   197 /**
       
   198  * Process FrameInfo command
       
   199  * 
       
   200  * @param aSection			the entry in the ini file requiring the command to be processed
       
   201  * 
       
   202  * @return: None
       
   203  */
       
   204 void CT_DataFrame::DoCmdFrameInfo(const TDesC& aSection)
       
   205 	{
       
   206 	INFO_PRINTF1(KLogFrameInfo);
       
   207     TFrameInfo frameinfo = iFrame->FrameInfo();
       
   208     
       
   209     // Get test data for command input parameter(s)
       
   210 	TFrameInfo expected;
       
   211 	if ( CT_GraphicsUtil::GetFrameInfo(*this, aSection, expected) )
       
   212 		{
       
   213 		if( frameinfo.iFlags!= expected.iFlags)		
       
   214 			{
       
   215 			ERR_PRINTF1(KLogNotExpectedValue);
       
   216    			SetBlockResult(EFail);
       
   217 			}
       
   218 		}
       
   219 	}
       
   220 
       
   221 /**
       
   222  * Process SetFrameInfo command
       
   223  * 
       
   224  * @param aSection			the entry in the ini file requiring the command to be processed 
       
   225  * 
       
   226  * @return: None
       
   227  */
       
   228 void CT_DataFrame::DoCmdSetFrameInfo(const TDesC& aSection)
       
   229 	{
       
   230     TFrameInfo frameinfo;
       
   231     
       
   232     if ( CT_GraphicsUtil::GetFrameInfo(*this,aSection, frameinfo) )
       
   233         {
       
   234         INFO_PRINTF1(KLogSetFrameInfo);
       
   235         iFrame->SetFrameInfo(frameinfo);
       
   236         }
       
   237     else
       
   238         {
       
   239         ERR_PRINTF2(KLogMissingParameter,KFldSetFrameInfo);
       
   240         SetBlockResult(EFail);
       
   241         }        
       
   242 	}
       
   243 
       
   244 /**
       
   245  * Process Bitmap command
       
   246  *
       
   247  * @param aSection			the entry in the ini file requiring the command to be processed
       
   248  *
       
   249  * @return: None
       
   250 */
       
   251  void CT_DataFrame::DoCmdBitmapL(const TDesC& aSection)
       
   252 	{
       
   253 	INFO_PRINTF1(KLogBitmap);
       
   254     CFbsBitmap* bitmap=const_cast<CFbsBitmap*>(iFrame->Bitmap());
       
   255         
       
   256     TPtrC gotBitmap;
       
   257     if(GetStringFromConfig(aSection,KFldGotBitmap,gotBitmap))
       
   258     	{
       
   259     	SetDataObjectL(gotBitmap,bitmap);
       
   260     	}
       
   261     
       
   262     // Get test data for command input parameter(s)
       
   263 	CFbsBitmap*	expected=NULL;
       
   264 	if ( CT_GraphicsUtil::GetFbsBitmapL(*this,aSection, KFldBitmap, expected) )
       
   265         {
       
   266         if ( bitmap!=expected )
       
   267 			{
       
   268 			ERR_PRINTF1(KLogNotExpectedValue);
       
   269 			SetBlockResult(EFail);
       
   270 			}  
       
   271         }
       
   272 	}
       
   273     
       
   274 /**
       
   275  * Process SetBitmap command
       
   276  *
       
   277  * @param aSection			the entry in the ini file requiring the command to be processed
       
   278  *
       
   279  * @return: None
       
   280 */
       
   281  void CT_DataFrame::DoCmdSetBitmapL(const TDesC& aSection)
       
   282 	{
       
   283     CFbsBitmap*  bitmap=NULL;
       
   284     
       
   285     if ( CT_GraphicsUtil::GetFbsBitmapL(*this,aSection, KFldSetBitmap, bitmap) )
       
   286         {
       
   287         INFO_PRINTF1(KLogSetBitmap);
       
   288         iFrame->SetBitmap(bitmap);
       
   289         }
       
   290     else
       
   291         {
       
   292         ERR_PRINTF2(KLogMissingParameter,KFldSetBitmap);
       
   293         SetBlockResult(EFail);
       
   294         }
       
   295 	}
       
   296 
       
   297 /**
       
   298  * Process Mask command
       
   299  *
       
   300  * @param aSection			the entry in the ini file requiring the command to be processed
       
   301  *
       
   302  * @return: None
       
   303 */
       
   304  void CT_DataFrame::DoCmdMaskL(const TDesC& aSection)
       
   305 	{
       
   306 	INFO_PRINTF1(KLogMask);
       
   307     CFbsBitmap* mask=const_cast<CFbsBitmap*>(iFrame->Mask());
       
   308     
       
   309     TPtrC gotMask;
       
   310     if(GetStringFromConfig(aSection,KFldGotMask,gotMask))
       
   311     	{
       
   312     	SetDataObjectL(gotMask,mask);
       
   313     	}
       
   314     
       
   315     // Get test data for command input parameter(s)
       
   316 	CFbsBitmap*	expected=NULL;
       
   317 	if ( CT_GraphicsUtil::GetFbsBitmapL(*this,aSection, KFldMask, expected) )
       
   318         {
       
   319         if ( mask!=expected )
       
   320 			{
       
   321 			ERR_PRINTF1(KLogNotExpectedValue);
       
   322 			SetBlockResult(EFail);
       
   323 			}  
       
   324         }
       
   325 	}
       
   326     
       
   327 /**
       
   328  * Process SetMask command
       
   329  *
       
   330  * @param aSection			the entry in the ini file requiring the command to be processed
       
   331  *
       
   332  * @return: None
       
   333 */
       
   334  void CT_DataFrame::DoCmdSetMaskL(const TDesC& aSection)
       
   335 	{
       
   336     CFbsBitmap*  bitmap=NULL;
       
   337     
       
   338     if ( CT_GraphicsUtil::GetFbsBitmapL(*this,aSection, KFldSetMask, bitmap) )
       
   339         {
       
   340         INFO_PRINTF1(KLogSetMask);
       
   341         iFrame->SetMask(bitmap);
       
   342         }
       
   343     else
       
   344         {
       
   345         ERR_PRINTF2(KLogMissingParameter,KFldSetMask);
       
   346         SetBlockResult(EFail);
       
   347         }
       
   348 	}