common/tools/ats/smoketest/graphics/wserv/src/T_DataWsRedrawEvent.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_DataWsRedrawEvent.h"
       
    19 
       
    20 /*@{*/
       
    21 //Commands
       
    22 _LIT(KCmdnew,						"new");
       
    23 _LIT(KCmdDestructor,				"~");
       
    24 _LIT(KCmdHandle,					"Handle");
       
    25 _LIT(KCmdRect,						"Rect");
       
    26 
       
    27 ///	Fields
       
    28 _LIT(KFldExpected,					"expected");
       
    29 
       
    30 ///	Logging
       
    31 _LIT(KLogError,						"Error=%d");
       
    32 _LIT(KLogMissingExpectedValue,		"Missing expected value '%S'");
       
    33 _LIT(KLogNotAsExpectedValue,		"'%S' is not as expected value");
       
    34 _LIT(KLogNotExpectedValueInt,		"'%S' is not as expected=%d, actual=%d");
       
    35 /*@}*/
       
    36 
       
    37 //////////////////////////////////////////////////////////////////////
       
    38 // Construction/Destruction
       
    39 //////////////////////////////////////////////////////////////////////
       
    40 
       
    41 CT_DataWsRedrawEvent* CT_DataWsRedrawEvent::NewL()
       
    42 	{
       
    43 	CT_DataWsRedrawEvent*    ret=new (ELeave) CT_DataWsRedrawEvent();
       
    44 	CleanupStack::PushL(ret);
       
    45 	ret->ConstructL();
       
    46 	CleanupStack::Pop(ret);
       
    47 	return ret;
       
    48 	}
       
    49 
       
    50 CT_DataWsRedrawEvent::CT_DataWsRedrawEvent()
       
    51 :	CDataWrapperBase()
       
    52 ,	iWsRedrawEvent(NULL)
       
    53 	{
       
    54 	}
       
    55 
       
    56 void CT_DataWsRedrawEvent::ConstructL()
       
    57 	{
       
    58 	}
       
    59 
       
    60 CT_DataWsRedrawEvent::~CT_DataWsRedrawEvent()
       
    61 	{
       
    62 	DestroyData();
       
    63 	}
       
    64 
       
    65 void CT_DataWsRedrawEvent::SetObjectL(TAny* aAny)
       
    66 	{
       
    67 	DestroyData();
       
    68 	iWsRedrawEvent = static_cast<TWsRedrawEvent*> (aAny);
       
    69 	}
       
    70 
       
    71 void CT_DataWsRedrawEvent::DisownObjectL()
       
    72 	{
       
    73 	iWsRedrawEvent = NULL;
       
    74 	}
       
    75 
       
    76 void CT_DataWsRedrawEvent::DestroyData()
       
    77 	{
       
    78 	delete iWsRedrawEvent;
       
    79 	iWsRedrawEvent=NULL;
       
    80 	}
       
    81 
       
    82 /**
       
    83 * Process a command read from the ini file
       
    84 *
       
    85 * @param aCommand			the command to process
       
    86 * @param aSection			the entry in the ini file requiring the command to be processed
       
    87 * @param aAsyncErrorIndex	index of command. used for async calls
       
    88 *
       
    89 * @return ETrue if the command is processed
       
    90 */
       
    91 TBool CT_DataWsRedrawEvent::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
       
    92 	{
       
    93 	TBool	ret = ETrue;
       
    94 	if ( aCommand==KCmdnew )
       
    95 		{
       
    96 		DoCmdnew();
       
    97 		}
       
    98 	else if ( aCommand==KCmdDestructor )
       
    99 		{
       
   100 		DestroyData();
       
   101 		}
       
   102 	else if ( aCommand==KCmdHandle )
       
   103 		{
       
   104 		DoCmdHandle(aSection);
       
   105 		}
       
   106 	else if ( aCommand==KCmdRect )
       
   107 		{
       
   108 		DoCmdRect(aSection);
       
   109 		}
       
   110 	else
       
   111 		{
       
   112 		ret=EFalse;
       
   113 		}
       
   114 
       
   115 	return ret;
       
   116 	}
       
   117 
       
   118 
       
   119 void CT_DataWsRedrawEvent::DoCmdnew()
       
   120 	{
       
   121 	DestroyData();
       
   122 	INFO_PRINTF1(_L("execute new TWsRedrawEvent()"));
       
   123 	TRAPD(err, iWsRedrawEvent = new (ELeave) TWsRedrawEvent());
       
   124 	if ( err!=KErrNone )
       
   125 		{
       
   126 		ERR_PRINTF2(KLogError, err);
       
   127 		SetError(err);
       
   128 		}
       
   129 	}
       
   130 
       
   131 
       
   132 void CT_DataWsRedrawEvent::DoCmdHandle(const TDesC& aSection)
       
   133 	{
       
   134 	INFO_PRINTF1(_L("execute Handle()"));
       
   135 	TUint	actual=iWsRedrawEvent->Handle();
       
   136 	SetHandle(actual);
       
   137 
       
   138 	TInt	expected;
       
   139 	if ( !GetIntFromConfig(aSection, KFldExpected, expected) )
       
   140 		{
       
   141 		ERR_PRINTF2(KLogMissingExpectedValue, &KFldExpected);
       
   142 		SetBlockResult(EFail);
       
   143 		}
       
   144 	else
       
   145 		{
       
   146 		if ( actual!=(TUint)expected )
       
   147 			{
       
   148 			ERR_PRINTF4(KLogNotExpectedValueInt, &KFldExpected, expected, actual);
       
   149 			SetBlockResult(EFail);
       
   150 			}
       
   151 		}
       
   152 	}
       
   153 
       
   154 
       
   155 void CT_DataWsRedrawEvent::DoCmdRect(const TDesC& aSection)
       
   156 	{
       
   157 	INFO_PRINTF1(_L("execute Rect()"));
       
   158 	TRect	actual=iWsRedrawEvent->Rect();
       
   159 	LogRect(_L("Rect()"), actual);
       
   160 
       
   161 	TRect	expected;
       
   162 	if ( !GetRectFromConfig(aSection, KFldExpected, expected) )
       
   163 		{
       
   164 		ERR_PRINTF2(KLogMissingExpectedValue, &KFldExpected);
       
   165 		SetBlockResult(EFail);
       
   166 		}
       
   167 	else
       
   168 		{
       
   169 		if ( actual!=expected )
       
   170 			{
       
   171 			ERR_PRINTF2(KLogNotAsExpectedValue, &KFldExpected);
       
   172 			SetBlockResult(EFail);
       
   173 			}
       
   174 		}
       
   175 	}
       
   176