common/tools/ats/smoketest/graphics/wserv/src/T_DataDrawableWindow.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_DataDrawableWindow.h"
       
    19 
       
    20 /*@{*/
       
    21 //Commands
       
    22 _LIT(KCmdScroll,					"Scroll");
       
    23 _LIT(KCmdGetDrawRect,				"GetDrawRect");
       
    24 
       
    25 // Fields
       
    26 _LIT(KFldClipRect,					"cliprect");
       
    27 _LIT(KFldOffset,					"offset");
       
    28 _LIT(KFldRect,						"rect");
       
    29 _LIT(KFldExpected,					"expected");
       
    30 
       
    31 ///	Logging
       
    32 _LIT(KLogMissingParameter,			"Missing parameter '%S'");
       
    33 _LIT(KLogMissingExpectedValue,		"Missing expected value '%S'");
       
    34 _LIT(KLogNotAsExpectedValue,		"'%S' is not as expected value");
       
    35 
       
    36 /*@}*/
       
    37 
       
    38 //////////////////////////////////////////////////////////////////////
       
    39 // Construction/Destruction
       
    40 //////////////////////////////////////////////////////////////////////
       
    41 
       
    42 CT_DataDrawableWindow::CT_DataDrawableWindow()
       
    43 :	CT_DataWindowBase()
       
    44 	{
       
    45 	}
       
    46 
       
    47 RWindowBase* CT_DataDrawableWindow::GetWindowBase() const
       
    48 	{
       
    49 	return GetDrawableWindow();
       
    50 	}
       
    51 
       
    52 
       
    53 /**
       
    54 * Process a command read from the ini file
       
    55 *
       
    56 * @param aCommand			the command to process
       
    57 * @param aSection			the entry in the ini file requiring the command to be processed
       
    58 * @param aAsyncErrorIndex	index of command. used for async calls
       
    59 *
       
    60 * @return ETrue if the command is processed
       
    61 */
       
    62 TBool CT_DataDrawableWindow::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
       
    63 	{
       
    64 	TBool	ret = ETrue;
       
    65 
       
    66 	if ( aCommand==KCmdScroll )
       
    67 		{
       
    68 		DoCmdScroll(aSection);
       
    69 		}
       
    70 	else if ( aCommand==KCmdGetDrawRect )
       
    71 		{
       
    72 		DoCmdGetDrawRect(aSection);
       
    73 		}
       
    74 	else
       
    75 		{
       
    76 		ret=CT_DataWindowBase::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
       
    77 		}
       
    78 
       
    79 	return ret;
       
    80 	}
       
    81 
       
    82 
       
    83 void CT_DataDrawableWindow::DoCmdScroll(const TDesC& aSection)
       
    84 	{
       
    85 	// Get test data for command input parameter(s)
       
    86 	TPoint	datOffset;
       
    87 
       
    88 	if ( !GetPointFromConfig(aSection, KFldOffset, datOffset) )
       
    89 		{
       
    90 		ERR_PRINTF2(KLogMissingParameter, &KFldOffset);
       
    91 		SetBlockResult(EFail);
       
    92 		}
       
    93 	else
       
    94 		{
       
    95 		TRect	datRect;
       
    96 		TBool	hasRect = GetRectFromConfig(aSection, KFldRect, datRect);
       
    97 
       
    98 		TRect	datClipRect;
       
    99 
       
   100 		// Execute command and log parameters
       
   101 		if ( GetRectFromConfig(aSection, KFldClipRect,	datClipRect) )
       
   102 			{
       
   103 			if ( hasRect )
       
   104 				{
       
   105 				INFO_PRINTF1(_L("execute Scroll(TRect, TPoint, TRect)"));
       
   106 				GetDrawableWindow()->Scroll(datClipRect, datOffset, datRect);
       
   107 				}
       
   108 			else
       
   109 				{
       
   110 				INFO_PRINTF1(_L("execute Scroll(TRect, TPoint)"));
       
   111 				GetDrawableWindow()->Scroll(datClipRect, datOffset);
       
   112 				}
       
   113 			}
       
   114 		else
       
   115 			{
       
   116 			if ( hasRect )
       
   117 				{
       
   118 				INFO_PRINTF1(_L("execute Scroll(TPoint, TRect)"));
       
   119 				GetDrawableWindow()->Scroll(datOffset, datRect);
       
   120 				}
       
   121 			else
       
   122 				{
       
   123 				INFO_PRINTF1(_L("execute Scroll(TPoint)"));
       
   124 				GetDrawableWindow()->Scroll(datOffset);
       
   125 				}
       
   126 			}
       
   127 
       
   128 		// No command return value and output parameter to display and check
       
   129 		}
       
   130 	}
       
   131 
       
   132 
       
   133 void CT_DataDrawableWindow::DoCmdGetDrawRect(const TDesC& aSection)
       
   134 	{
       
   135 	// Execute command and log parameters
       
   136 	INFO_PRINTF1(_L("execute GetDrawRect()"));
       
   137 	TRect	actual=GetDrawableWindow()->GetDrawRect();
       
   138 	LogRect(_L("GetDrawableWindow()"), actual);
       
   139 
       
   140 	// Diaplay command return value, check if it matches the expected value
       
   141 	TRect	expected;
       
   142 	if ( !GetRectFromConfig(aSection, KFldExpected, expected) )
       
   143 		{
       
   144 		ERR_PRINTF2(KLogMissingExpectedValue, &KFldExpected);
       
   145 		SetBlockResult(EFail);
       
   146 		}
       
   147 	else
       
   148 		{
       
   149 		if ( actual!=expected )
       
   150 			{
       
   151 			ERR_PRINTF2(KLogNotAsExpectedValue, &KFldExpected);
       
   152 			SetBlockResult(EFail);
       
   153 			}
       
   154 		}
       
   155 	}