commonuisupport/uikon/test/tcolours/tcolovr/TCOLOVRSTEP.CPP
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Tests color overriding for a few controls - namely
       
    15 // 1) Labels
       
    16 // 2) Listboxes
       
    17 // 3) Dialogs
       
    18 // 4) Command buttons
       
    19 // 5) Scrollbars
       
    20 // The colors are first overriden using the logical color names 
       
    21 // for the colors that the controls employ.
       
    22 // Choose 'Override fore and back' from the menu
       
    23 // to override the foreground and background colors using the color
       
    24 // use list that the controls publish. 
       
    25 // 
       
    26 //
       
    27 
       
    28 /**
       
    29  @file
       
    30  @internalComponent - Internal Symbian test code
       
    31 */
       
    32 
       
    33 #include <barsread.h>
       
    34 #include <s32file.h>
       
    35 #include <gdi.h>
       
    36 #include <gulutil.h>
       
    37 
       
    38 #include <techview/eikon.hrh>
       
    39 #include <techview/eikon.rsg>
       
    40 #include <ecom/ecom.h>
       
    41 
       
    42 #include <spaneinit.rsg>
       
    43 #include "TCOLOVRStep.h"
       
    44 #include "TCOLOVRSTEP.HRH"
       
    45 #include <tcolovrstep.rsg>
       
    46 
       
    47 
       
    48 // constants and definitions
       
    49 #define KRgbLilac TRgb(206,207,255)
       
    50 
       
    51 _LIT(KTCOLOVRResourceFilePath,"z:\\system\\test\\colours\\tcolovr\\tcolovrstep.rsc");
       
    52 
       
    53 enum TTestAppUiPanic
       
    54 	{
       
    55 	EBadCommandPanic,
       
    56 	};
       
    57 
       
    58 LOCAL_D void Panic(TTestAppUiPanic aPanic)
       
    59 	{
       
    60 	User::Panic(_L("TCOLOVR"), aPanic);
       
    61 	}
       
    62 
       
    63 
       
    64 //
       
    65 //  TColorUtils  //
       
    66 //
       
    67 
       
    68 /**
       
    69 	 Provides some colour utility functions.
       
    70 */
       
    71 class TColorUtils
       
    72     {
       
    73 public:
       
    74 	static void SetForegroundColorL(CCoeControl& aControl, TRgb aRgb);
       
    75 	static void SetBackgroundColorL(CCoeControl& aControl, TRgb aRgb);
       
    76 	static void ResetEnvColorsL(CCoeControl& aControl);
       
    77 	};
       
    78 
       
    79 /**
       
    80    This method overrides foreground colours. If there are any contents then
       
    81    these colours are not overridden, otherwise all colours are overridden.
       
    82    It doesnot override highlight colours.   
       
    83  */
       
    84 void TColorUtils::SetForegroundColorL(CCoeControl& aControl, TRgb aRgb)
       
    85 	{
       
    86 	CArrayFixFlat<TCoeColorUse>* useList=new(ELeave) CArrayFixFlat<TCoeColorUse>(1);
       
    87 	CleanupStack::PushL(useList);	
       
    88 	aControl.GetColorUseListL(*useList);
       
    89 
       
    90 	const TInt count = useList->Count();
       
    91 	
       
    92 	//
       
    93 	// Count number of content colors
       
    94 	//
       
    95 	TInt numContentColors = 0;
       
    96 	TInt ii=0;
       
    97 	for(ii=0;ii<count;ii++)
       
    98 		{
       
    99 		TCoeColorUse colorUse = (*useList)[ii];
       
   100 		if (colorUse.IsForeground() && (colorUse.IsContents()))
       
   101 			{
       
   102 			numContentColors++;
       
   103 			}
       
   104 		}
       
   105 
       
   106 
       
   107 	// Override colors
       
   108     // Do not override highlight colors
       
   109 	// If there are any contents colors only override these
       
   110 	// Otherwise override all colors
       
   111 
       
   112 	TInt numGrays=0;
       
   113 	TInt numColors=0;
       
   114 	TDisplayMode displayMode=CEikonEnv::Static()->WsSession().GetDefModeMaxNumColors(numColors, numGrays);
       
   115 	const TRgb dimmedColor( ColorUtils::RgbLighterColor(aRgb, displayMode) );
       
   116 	for(ii=0;ii<count;ii++)
       
   117 		{
       
   118 		TCoeColorUse colorUse = (*useList)[ii];
       
   119 		if (colorUse.IsForeground() && !(colorUse.IsHighlights()) &&
       
   120 				( (numContentColors && colorUse.IsContents()) || (!numContentColors && !colorUse.IsContents()) ) )
       
   121 			{
       
   122 			if (colorUse.IsDimmed())
       
   123 				{
       
   124 				aControl.OverrideColorL(colorUse.LogicalColor(),dimmedColor);
       
   125 				}
       
   126 			else
       
   127 				{
       
   128 				aControl.OverrideColorL(colorUse.LogicalColor(),aRgb);
       
   129 				}
       
   130 			}
       
   131 		}
       
   132 
       
   133 	CleanupStack::PopAndDestroy();	// useList
       
   134 
       
   135 	aControl.HandleResourceChange(KEikColorResourceChange);
       
   136 	}
       
   137 
       
   138 /**
       
   139    This method overrides background colours. If there are any contents then
       
   140    these colours are not overridden, otherwise all colours are overridden. It 
       
   141    doesnot override highlight colours. Dimmed colours are a darker shade
       
   142    of new background colour.   
       
   143  */
       
   144 void TColorUtils::SetBackgroundColorL(CCoeControl& aControl, TRgb aRgb)
       
   145 	{
       
   146 	CArrayFixFlat<TCoeColorUse>* useList=new(ELeave) CArrayFixFlat<TCoeColorUse>(1);
       
   147 	CleanupStack::PushL(useList);	
       
   148 	aControl.GetColorUseListL(*useList);
       
   149 
       
   150 	const TInt count = useList->Count();
       
   151 
       
   152 	//
       
   153 	// Count number of content colours
       
   154 	//
       
   155 	TInt numContentColors = 0;
       
   156 	TInt ii=0;
       
   157 	for(ii=0;ii<count;ii++)
       
   158 		{
       
   159 		TCoeColorUse colorUse = (*useList)[ii];
       
   160 		if (colorUse.IsForeground() && (colorUse.IsContents()))
       
   161 			{
       
   162 			numContentColors++;
       
   163 			}
       
   164 		}
       
   165 
       
   166 	
       
   167 	// Override  colors
       
   168 	// Do not override highlight colors
       
   169 	// If there are any contents colors only override these
       
   170 	// Otherwise override all colors
       
   171 	// Dimmed colours are made darker shade of new background color
       
   172 
       
   173 	TInt numGrays=0;
       
   174 	TInt numColors=0;
       
   175 	TDisplayMode displayMode=CEikonEnv::Static()->WsSession().GetDefModeMaxNumColors(numColors, numGrays);
       
   176 	const TRgb dimmedColor( ColorUtils::RgbMidDarkerColor(aRgb, displayMode) );
       
   177 	for(ii=0;ii<count;ii++)
       
   178 		{
       
   179 		TCoeColorUse colorUse = (*useList)[ii];
       
   180 		if (colorUse.IsBackground() && !(colorUse.IsHighlights()) &&
       
   181 				( (numContentColors && colorUse.IsContents()) || (!numContentColors && !colorUse.IsContents()) ) )
       
   182 			{
       
   183 			if (colorUse.IsDimmed())
       
   184 				{
       
   185 				aControl.OverrideColorL(colorUse.LogicalColor(),dimmedColor);
       
   186 				}
       
   187 			else
       
   188 				{
       
   189 				aControl.OverrideColorL(colorUse.LogicalColor(),aRgb);
       
   190 				}
       
   191 			}
       
   192 		}
       
   193 
       
   194 	CleanupStack::PopAndDestroy();	// useList
       
   195 
       
   196 	aControl.HandleResourceChange(KEikColorResourceChange);
       
   197 	}
       
   198 
       
   199 /**
       
   200    The method restores the system colour setting for a specified control. The
       
   201    method invokes CCoeControl::OverrideColorL() to change the colour mapping
       
   202    used in this control.
       
   203  */
       
   204 void TColorUtils::ResetEnvColorsL(CCoeControl& aControl)
       
   205 	{
       
   206 	CArrayFixFlat<TCoeColorUse>* useList=new(ELeave) CArrayFixFlat<TCoeColorUse>(1);
       
   207 	CleanupStack::PushL(useList);	
       
   208 	aControl.GetColorUseListL(*useList);
       
   209 	
       
   210 	CEikonEnv* env=CEikonEnv::Static();
       
   211 
       
   212 	const TInt count = useList->Count();
       
   213 	for(TInt ii=0;ii<count;ii++)
       
   214 		{
       
   215 		TInt logicalColor=STATIC_CAST(TLogicalColor,(*useList)[ii].LogicalColor());
       
   216 		aControl.OverrideColorL(STATIC_CAST(TLogicalColor,logicalColor),env->Color(STATIC_CAST(TLogicalColor,logicalColor)));
       
   217 		}
       
   218 
       
   219 	CleanupStack::PopAndDestroy();	// useList
       
   220 
       
   221 	aControl.HandleResourceChange(KEikColorResourceChange);
       
   222 	}
       
   223 
       
   224 
       
   225 //
       
   226 //  CStandaloneLabel  //
       
   227 //
       
   228 
       
   229 CStandaloneLabel::CStandaloneLabel()
       
   230 	{
       
   231 	}
       
   232 
       
   233 /**
       
   234    This method is an override from CCoeControl. The method is used to colour the
       
   235    label control with the system background & foreground colour.   
       
   236  */
       
   237 void CStandaloneLabel::Draw(const TRect& aRect) const 
       
   238 	{
       
   239 	CWindowGc& gc = SystemGc();
       
   240 	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   241 	gc.SetBrushColor(iEikonEnv->ControlColor(EColorWindowBackground,*this));
       
   242 	gc.SetPenStyle(CGraphicsContext::ESolidPen);
       
   243 	gc.SetPenColor(iEikonEnv->ControlColor(EColorWindowText,*this));
       
   244 	gc.DrawRect(Rect());
       
   245 
       
   246 	CEikLabel::Draw(aRect);
       
   247 	}
       
   248 
       
   249 /**
       
   250    This method is an override from CCoeControl. It gets the list of logical
       
   251    colours used to draw the control defines how each colour is to be used by the
       
   252    label control.    
       
   253  */	
       
   254 void CStandaloneLabel::GetColorUseListL (CArrayFix<TCoeColorUse>& aColorUseList) const
       
   255 	{
       
   256 	CEikLabel::GetColorUseListL(aColorUseList);
       
   257 
       
   258 	TInt commonAttributes = TCoeColorUse::ESurrounds|TCoeColorUse::EActive|TCoeColorUse::ENormal|TCoeColorUse::ENeutral;
       
   259 	TCoeColorUse colorUse;
       
   260 
       
   261 	colorUse.SetLogicalColor(EColorWindowText);
       
   262 	colorUse.SetUse(TCoeColorUse::EFore|commonAttributes);
       
   263 	aColorUseList.AppendL(colorUse);
       
   264 
       
   265 	colorUse.SetLogicalColor(EColorWindowBackground);
       
   266 	colorUse.SetUse(TCoeColorUse::EBack|commonAttributes);
       
   267 	aColorUseList.AppendL(colorUse);
       
   268 	}
       
   269 
       
   270 
       
   271 
       
   272 //
       
   273 //  CColorOverrideControl  //
       
   274 //
       
   275 
       
   276 CColorOverrideControl::CColorOverrideControl() : iPtr(_L("Edwin"))
       
   277 	{
       
   278 	}
       
   279 /**
       
   280    This method is overriden from CCoeControl.It returns the number of
       
   281    controls on the compound colour scheme control.
       
   282  */
       
   283 TInt CColorOverrideControl::CountComponentControls() const
       
   284     {
       
   285     return(15);
       
   286     }
       
   287 
       
   288 /**
       
   289    This method is overriden from CCOeControl.It returns the specified
       
   290    component of compound custom colour scheme control.
       
   291  */
       
   292 CCoeControl* CColorOverrideControl::ComponentControl(TInt aIndex) const
       
   293     {			 
       
   294 	switch (aIndex)
       
   295 		{
       
   296 		case 0:
       
   297 		default:
       
   298 		return iOverrideLabel;
       
   299 		
       
   300 		case 1:
       
   301 		return iListBox;
       
   302 
       
   303 		case 2:
       
   304 		return iButton;
       
   305 
       
   306 		case 3:
       
   307 		return iScrollBar;
       
   308 		
       
   309 		case 4:
       
   310 		return iEdwin;
       
   311 
       
   312 		case 5:
       
   313 		return iChoiceList;
       
   314 
       
   315 		case 6:
       
   316 		return iCaptionedCheckBox;
       
   317 
       
   318 		case 7:
       
   319 		return(iOpBut[0]);
       
   320 
       
   321 		case 8:
       
   322 		return(iOpBut[1]);
       
   323 
       
   324 		case 9:
       
   325 		return(iOpBut[2]);
       
   326 
       
   327 		case 10:
       
   328 		return iNumberEditor;
       
   329 
       
   330 		case 11:
       
   331 		return iComboBox;
       
   332 
       
   333 		case 12:
       
   334 		return iSecretEditor;
       
   335 
       
   336 		case 13:
       
   337 		return iProgressInfo;
       
   338 
       
   339 		case 14:
       
   340 		return iClock;
       
   341 		}
       
   342     }
       
   343 
       
   344 const TInt KXStart = 10;
       
   345 const TInt KYStart = 10;
       
   346 const TInt KXSpacing = 5;
       
   347 const TInt KYSpacing = 2;
       
   348 const TInt KControlWidth = 180;
       
   349 const TInt KLbxHeight = 50;
       
   350 
       
   351 const TInt KLongEnoughToCauseComponentsToBeCreated=200;
       
   352 
       
   353 /**
       
   354    This method creates custom colour scheme control. The custom colour scheme
       
   355    control consists of (1) Label Control (2) Text Button (3) Edwin control
       
   356    (4) List box (5) Choice List control (6) Scroll Bar (7) Captioned Control
       
   357    (8) Integer Editor control (9) Combo Box (10) Progress Bar (11) Secret
       
   358    Editor (12) Menu Bar and (13) Clock Control.
       
   359  */
       
   360 void CColorOverrideControl::ConstructL(const TRect& aRect)
       
   361     {
       
   362     CreateWindowL();
       
   363     Window().SetShadowDisabled(ETrue);
       
   364     SetRect(aRect);
       
   365 
       
   366 	iBrushAndPenContext=CCoeBrushAndPenContext::NewL();
       
   367 	iBrushAndPenContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   368 	iBrushAndPenContext->SetBrushColor(iEikonEnv->ControlColor(EColorToolbarBackground,*this));
       
   369 	iBrushAndPenContext->SetPenColor(iEikonEnv->ControlColor(EColorToolbarText,*this));
       
   370 
       
   371 	TInt yPos = KYStart;
       
   372 	TInt xPos = KXStart;
       
   373 
       
   374 	TInt halfWidth = (KControlWidth-KXSpacing)/2;
       
   375 
       
   376 	iOverrideLabel = new(ELeave) CStandaloneLabel;
       
   377 	iOverrideLabel->SetContainerWindowL(*this);
       
   378 	iOverrideLabel->SetTextL(_L("Label"));
       
   379 	iOverrideLabel->SetControlContext(iOverrideLabel);
       
   380 	TSize size=iOverrideLabel->MinimumSize();
       
   381 	size.iWidth=halfWidth;
       
   382 	iOverrideLabel->SetRect(TRect(TPoint(xPos,yPos),size));
       
   383 
       
   384 	iButton = new(ELeave) CEikTextButton;
       
   385 	iButton->SetContainerWindowL(*this);
       
   386 	iButton->SetTextL(_L("Button text"),CEikCommandButtonBase::EFirst);
       
   387 	size=iButton->MinimumSize();
       
   388 	size.iWidth=halfWidth;
       
   389 	iButton->SetRect(TRect(TPoint(xPos+halfWidth+KXSpacing,yPos),size));
       
   390 
       
   391 	yPos+=size.iHeight+KYSpacing;
       
   392 
       
   393 	iEdwin=new(ELeave) CEikEdwin;
       
   394 	iEdwin->SetContainerWindowL(*this);
       
   395 	iEdwin->ConstructL(EEikEdwinNoWrap|EEikEdwinInclusiveSizeFixed,150,0,3);
       
   396 	iEdwin->SetTextL(&iPtr);
       
   397 	size=iEdwin->MinimumSize();
       
   398 	size.iWidth=KControlWidth;
       
   399 	iEdwin->SetRect(TRect(TPoint(xPos,yPos),size));
       
   400 	iEdwin->CreatePreAllocatedScrollBarFrameL()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOn,CEikScrollBarFrame::EOn);
       
   401 	iEdwin->ForceScrollBarUpdateL();
       
   402 
       
   403 	yPos+=size.iHeight+KYSpacing;
       
   404 
       
   405 	iListBox = new(ELeave) CEikTextListBox;
       
   406 	iListBox->SetContainerWindowL(*this);
       
   407 	TResourceReader resourceReader;
       
   408 	iCoeEnv->CreateResourceReaderLC(resourceReader, R_TCOLOVR_LBX);
       
   409 	iListBox->ConstructFromResourceL(resourceReader);
       
   410 	CleanupStack::PopAndDestroy(); // resourceReader
       
   411 	CEikScrollBarFrame* sbFrame=iListBox->CreateScrollBarFrameL();
       
   412 	sbFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOn);
       
   413 	size.iHeight=KLbxHeight;
       
   414 	size.iWidth=KControlWidth;
       
   415 	iListBox->SetRect(TRect(TPoint(xPos,yPos),size));
       
   416 
       
   417 	iListBox->SetFocus(ETrue);
       
   418 
       
   419 	yPos+=KLbxHeight+KYSpacing;
       
   420 
       
   421 	iChoiceList = new(ELeave) CEikChoiceList;
       
   422 	iChoiceList->SetContainerWindowL(*this);
       
   423 	iChoiceList->SetArrayL(R_TCOLOVR_CHOICES);
       
   424 	size=iChoiceList->MinimumSize();
       
   425 	size.iWidth=halfWidth;
       
   426 	iChoiceList->SetRect(TRect(TPoint(xPos,yPos),size));
       
   427 
       
   428 	iScrollBar = new(ELeave) CEikScrollBar;
       
   429 	iScrollBar->ConstructL(NULL,this,CEikScrollBar::EHorizontal,KLongEnoughToCauseComponentsToBeCreated,CEikScrollBar::EButtonsEitherSideOfShaft); 
       
   430 	size=iScrollBar->MinimumSize();
       
   431 	size.iWidth=halfWidth;
       
   432 	iScrollBar->SetLengthL(halfWidth);
       
   433 	iScrollBar->SetRect(TRect(TPoint(xPos+halfWidth+KXSpacing,yPos),size));
       
   434 
       
   435 	yPos+=size.iHeight+KYSpacing;
       
   436 	
       
   437 	iCaptionedCheckBox=new(ELeave) CEikCaptionedControl;
       
   438 	CEikLabel* label=new(ELeave) CEikLabel;
       
   439 	label->SetContainerWindowL(*this);
       
   440 	iCaptionedCheckBox->iCaption=label;
       
   441 	_LIT(KCaption,"Caption");
       
   442 	label->SetTextL(KCaption);
       
   443 	CEikCheckBox* checkBox=new(ELeave) CEikCheckBox;
       
   444 	checkBox->SetContainerWindowL(*this);
       
   445 	iCaptionedCheckBox->iControl=checkBox;
       
   446 	iCaptionedCheckBox->SetContainerWindowL(*this);	
       
   447 	size=iCaptionedCheckBox->MinimumSize();
       
   448 	iCaptionedCheckBox->SetRect(TRect(TPoint(xPos,yPos),size));
       
   449 
       
   450 	iBCoord=new(ELeave) TEikButtonCoordinator;
       
   451     for (TInt ii=0; ii<3; ii++)
       
   452         {
       
   453 		CEikOptionButton* tmp=new(ELeave) CEikOptionButton;
       
   454         iOpBut[ii]=tmp;
       
   455 		tmp->ConstructL();
       
   456         tmp->SetContainerWindowL(*this);
       
   457 		tmp->SetCoordinator(iBCoord);
       
   458 		tmp->SetState(ii==0? CEikButtonBase::ESet: CEikButtonBase::EClear);
       
   459 		size=tmp->MinimumSize();
       
   460 		tmp->SetRect(TRect(TPoint(xPos+KControlWidth-(ii+1)*size.iWidth,yPos),size));
       
   461         }
       
   462 	
       
   463 	yPos+=size.iHeight+KYSpacing;
       
   464 
       
   465 	iNumberEditor=new(ELeave) CEikNumberEditor();
       
   466 	iNumberEditor->SetContainerWindowL(*this);
       
   467 	iNumberEditor->ConstructL(0,100,50); 
       
   468 	size=iNumberEditor->MinimumSize();
       
   469 	size.iWidth=halfWidth;
       
   470 	iNumberEditor->SetRect(TRect(TPoint(xPos,yPos),size));
       
   471 
       
   472 	iComboBox=new(ELeave) CEikComboBox();
       
   473 	iComboBox->ConstructL(*this,10,10,5);
       
   474 	CDesCArray* itemArray=new(ELeave) CDesCArrayFlat(5);
       
   475 	itemArray->AppendL(_L("Combo Item"));
       
   476 	itemArray->AppendL(_L("Combo Item"));
       
   477 	itemArray->AppendL(_L("Combo Item"));
       
   478 	itemArray->AppendL(_L("Combo Item"));
       
   479 	iComboBox->SetArray(itemArray);
       
   480 	size=iComboBox->MinimumSize();
       
   481 	size.iWidth=halfWidth;
       
   482 	iComboBox->SetRect(TRect(TPoint(xPos+halfWidth+KXSpacing,yPos),size));
       
   483     
       
   484 
       
   485 	yPos = KYStart;
       
   486 	xPos = KXStart + 3*KControlWidth/2;
       
   487 
       
   488 	iSecretEditor = new(ELeave) CEikSecretEditor();
       
   489 	iSecretEditor->SetContainerWindowL(*this);
       
   490 	size=iSecretEditor->MinimumSize();
       
   491 	size.iWidth=halfWidth;
       
   492 	iSecretEditor->SetRect(TRect(TPoint(xPos,yPos),size));
       
   493 
       
   494 
       
   495 	CEikProgressInfo::SInfo info;
       
   496 	info.iSplitsInBlock=0;
       
   497 	info.iFinalValue=100;
       
   498 	info.iWidth=halfWidth;
       
   499 	info.iHeight=20;
       
   500 
       
   501 	iProgressInfo = new(ELeave) CEikProgressInfo(info);
       
   502 	iProgressInfo->SetContainerWindowL(*this);
       
   503 	iProgressInfo->SetFinalValue(100);
       
   504 	iProgressInfo->SetAndDraw(20);
       
   505 	size=iProgressInfo->MinimumSize();
       
   506 	size.iWidth=halfWidth;
       
   507 	iProgressInfo->SetRect(TRect(TPoint(xPos+halfWidth+KXSpacing,yPos),size));
       
   508 
       
   509 	yPos+=size.iHeight+KYSpacing;
       
   510 
       
   511 	iMenuBar = new(ELeave) CEikMenuBar();
       
   512 	iMenuBar->ConstructL(this);
       
   513 	iMenuBar->SetMenuTitleResourceId(R_TCOLOVR_MENUS);
       
   514 	iMenuBar->TryDisplayMenuBarL();
       
   515 	size=iMenuBar->MinimumSize();
       
   516 	size.iWidth=KControlWidth;
       
   517 	iMenuBarRect=TRect(TPoint(xPos,yPos),size);
       
   518 	iMenuBar->SetRect(iMenuBarRect);
       
   519 
       
   520 	yPos+=size.iHeight+3*KYSpacing;
       
   521 	
       
   522 	iClock = new(ELeave) CEikClock();
       
   523 	iClock->SetContainerWindowL(*this);
       
   524 	iClock->SetControlContext(iBrushAndPenContext);
       
   525 	iCoeEnv->CreateResourceReaderLC(resourceReader, R_TCOLOVR_CLOCK);
       
   526 	iClock->ConstructFromResourceL(resourceReader);
       
   527 	CleanupStack::PopAndDestroy(); // resourceReader
       
   528 	size=iClock->MinimumSize();
       
   529 	size.iWidth=KControlWidth;
       
   530 	iClock->SetRect(TRect(TPoint(xPos,yPos),size));
       
   531 
       
   532 	yPos+=size.iHeight+3*KYSpacing;
       
   533 
       
   534 	iConsole = new(ELeave) CEikConsoleControl();
       
   535 	size.iHeight=20;
       
   536 	size.iWidth=KControlWidth;
       
   537 	iConsole->ConstructL(TPoint(xPos,yPos),size,0,EEikConsWinInPixels);
       
   538 
       
   539 	yPos+=size.iHeight+3*KYSpacing;
       
   540 
       
   541 	iMenu = new(ELeave) CEikMenuPane(this); 
       
   542 	iMenu->ConstructL(NULL);
       
   543 	RestoreMenuL(iMenu,R_TCOLOVR_MENU,MEikMenuObserver::EMenuPane);
       
   544 	size=iMenu->MinimumSize();
       
   545 	size.iWidth=KControlWidth;
       
   546 	iMenu->SetRect(TRect(TPoint(xPos,yPos),size));	
       
   547 	iMenu->StartDisplayingMenuPane(NULL,TPoint(xPos,yPos),NULL,0);
       
   548 
       
   549 	ActivateL();
       
   550     }
       
   551 
       
   552 /**
       
   553    @SYMTestCaseID UIF-tcolovrstep-ToggleFloatingMenuL
       
   554   
       
   555    @SYMPREQ
       
   556   
       
   557    @SYMTestCaseDesc Test making the Menu Bar visible / invisible.
       
   558   
       
   559    @SYMTestPriority High
       
   560   
       
   561    @SYMTestStatus Implemented
       
   562    
       
   563    @SYMTestActions The method checks whether the menu bar is visible or not and
       
   564    makes the menu bar invisible or visible correspondingly.
       
   565   
       
   566    @SYMTestExpectedResults If the menu bar is visible then it should be made invisible and vice versa.
       
   567  */
       
   568 void CColorOverrideControl::ToggleFloatingMenuL()
       
   569 	{
       
   570 	if(iMenuBar->IsVisible())
       
   571 		iMenuBar->StopDisplayingMenuBar();
       
   572 	else
       
   573 		{
       
   574 		iMenuBar->TryDisplayMenuBarL();
       
   575 		iMenuBar->SetRect(iMenuBarRect);
       
   576 		}
       
   577 	}
       
   578 
       
   579 /**
       
   580    @SYMTestCaseID UIF-tcolovrstep-Dim
       
   581   
       
   582    @SYMPREQ
       
   583   
       
   584    @SYMTestCaseDesc Test making contols on the colour scheme control dimmed.
       
   585  
       
   586    @SYMTestPriority High
       
   587   
       
   588    @SYMTestStatus Implemented
       
   589    
       
   590    @SYMTestActions The method checks whether each control on the colour scheme
       
   591    control is dimmed. It then makes each control dim if it is not already dimmed
       
   592    by calling CCoeControl::SetDimmed().
       
   593   
       
   594    @SYMTestExpectedResults The controls should be dimmed if it is not already dimmed.
       
   595  */
       
   596 void CColorOverrideControl::Dim()
       
   597 	{
       
   598 	const TInt count=CountComponentControls();
       
   599 	for(TInt i=0;i<count;i++)
       
   600 		{
       
   601 		CCoeControl* ctl=ComponentControl(i);
       
   602 		ctl->SetDimmed(!ctl->IsDimmed());
       
   603 		}
       
   604 	}
       
   605 
       
   606 /**
       
   607    @SYMTestCaseID UIF-tcolovrstep-SetSystemColorsL
       
   608   
       
   609    @SYMPREQ
       
   610   
       
   611    @SYMTestCaseDesc Test restoring a control's colour setting.
       
   612   
       
   613    @SYMTestPriority High
       
   614   
       
   615    @SYMTestStatus Implemented
       
   616    
       
   617    @SYMTestActions The method tests restoring the system colour setting for the
       
   618    custom colour scheme control. To perform this, handle for each of the
       
   619    controls on the colour scheme control is obtained and
       
   620    CCoeControl::OverrideColorL() method is called to change the colour
       
   621    mapping used in this control.
       
   622   
       
   623    @SYMTestExpectedResults The method should restore the system colour setting
       
   624    for the custom colour scheme control.
       
   625  */
       
   626 void CColorOverrideControl::SetSystemColorsL()
       
   627 	{
       
   628 	const TInt count=CountComponentControls();
       
   629 	for(TInt i=0;i<count;i++)
       
   630 		{
       
   631 		CCoeControl* ctl=ComponentControl(i);
       
   632 		TColorUtils::ResetEnvColorsL(*ctl);
       
   633 		}
       
   634 	TColorUtils::ResetEnvColorsL(*iMenuBar);
       
   635 	iMenuBar->StopDisplayingMenuBar();
       
   636 	iMenuBar->TryDisplayMenuBarL();
       
   637 	iMenuBar->SetRect(iMenuBarRect);
       
   638 	TColorUtils::ResetEnvColorsL(*iMenu);
       
   639 	iMenu->DrawNow();
       
   640 	}
       
   641 
       
   642 /**
       
   643    The method is an override from MEikMenuObserver. It is called by the Uikon
       
   644    framework to handle the emphasising or de-emphasising of a menu window. 
       
   645  */
       
   646 void CColorOverrideControl::SetEmphasis(CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/)
       
   647 	{
       
   648 	}
       
   649 
       
   650 /**
       
   651    The method is an override from MEikMenuObserver. It processes user commands.
       
   652  */
       
   653 void CColorOverrideControl::ProcessCommandL(TInt /*aCommandId*/)
       
   654 	{
       
   655 	}
       
   656 
       
   657 const TInt KWidth = 7;
       
   658 const TInt KHeight = 7;
       
   659 
       
   660 /**
       
   661    The method draws the list of colour used to draw a given control.
       
   662  */
       
   663 void CColorOverrideControl::DrawColorBlocks(CCoeControl& aControl, TInt aXPos, TInt aYPos, CWindowGc& aGc ) const
       
   664 	{
       
   665 	TRAPD(err,
       
   666 		CArrayFixFlat<TCoeColorUse>* useList=new(ELeave) CArrayFixFlat<TCoeColorUse>(1);
       
   667 		CleanupStack::PushL(useList);	
       
   668 		aControl.GetColorUseListL(*useList);
       
   669 
       
   670 		const TInt xInc = KWidth-1;
       
   671 
       
   672 		TInt count = useList->Count();
       
   673 		for(TInt ii=0;ii<count;ii++)
       
   674 			{
       
   675 			TRect rect(TPoint(aXPos,aYPos),TSize(KWidth,KHeight));
       
   676 			aGc.SetBrushColor(iEikonEnv->ControlColor(STATIC_CAST(TLogicalColor,(*useList)[ii].LogicalColor()),aControl));
       
   677 			aGc.DrawRect(rect);
       
   678 			aXPos+=xInc;
       
   679 			}
       
   680 	/*
       
   681 		aXPos = KXStart+2*(KControlWidth+KXSpacing);
       
   682 
       
   683 		for(ii=0;ii<count;ii++)
       
   684 			{
       
   685 			TRect rect(TPoint(aXPos,aYPos),TSize(KWidth,KHeight));
       
   686 			aGc.SetBrushColor(iEikonEnv->Color(STATIC_CAST(TLogicalColor,(*useList)[ii].LogicalColor())));
       
   687 			aGc.DrawRect(rect);
       
   688 			aXPos+=xInc;
       
   689 			}
       
   690 	*/
       
   691 		CleanupStack::PopAndDestroy();	// useList
       
   692 		);
       
   693 		__ASSERT_ALWAYS(!err,User::Panic(_L("DrawColorBlocks"),err));
       
   694 	}
       
   695 
       
   696 /**
       
   697    This method is an override from CCoeControl. The method is used to draw the
       
   698    list of colours used to draw each control in the colour scheme control.
       
   699  */
       
   700 void CColorOverrideControl::Draw(const TRect& /*aRect*/) const
       
   701 	{
       
   702 	CWindowGc& gc = SystemGc();
       
   703 	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   704 	gc.SetBrushColor(iEikonEnv->ControlColor(EColorWindowBackground,*this));
       
   705 	gc.DrawRect(Rect());
       
   706 
       
   707 	TInt blockXStart = KXStart+KControlWidth+KXSpacing;
       
   708 
       
   709 	DrawColorBlocks(*iOverrideLabel, blockXStart, iOverrideLabel->Rect().iTl.iY, gc);	
       
   710 	DrawColorBlocks(*iButton, blockXStart, iButton->Rect().iTl.iY + KHeight + 2, gc);
       
   711 	DrawColorBlocks(*iEdwin, blockXStart, iEdwin->Rect().iTl.iY, gc);
       
   712 	DrawColorBlocks(*iListBox, blockXStart, iListBox->Rect().iTl.iY, gc);
       
   713 	DrawColorBlocks(*iChoiceList, blockXStart, iChoiceList->Rect().iTl.iY, gc);
       
   714 	DrawColorBlocks(*iScrollBar, blockXStart, iScrollBar->Position().iY + KHeight + 2, gc);
       
   715 	DrawColorBlocks(*iCaptionedCheckBox, blockXStart, iCaptionedCheckBox->Rect().iTl.iY, gc);
       
   716 	DrawColorBlocks(*iOpBut[0], blockXStart, iOpBut[0]->Rect().iTl.iY + KHeight + 2, gc);
       
   717 	DrawColorBlocks(*iNumberEditor, blockXStart, iNumberEditor->Rect().iTl.iY, gc);
       
   718 	DrawColorBlocks(*iComboBox, blockXStart, iComboBox->Rect().iTl.iY + KHeight + 2, gc);
       
   719 
       
   720 	blockXStart = KXStart+5*KControlWidth/2+2*KXSpacing;
       
   721 
       
   722 	DrawColorBlocks(*iSecretEditor, blockXStart, iSecretEditor->Position().iY, gc);
       
   723 	DrawColorBlocks(*iProgressInfo, blockXStart, iProgressInfo->Position().iY + KHeight + 2, gc);
       
   724 	DrawColorBlocks(*iMenuBar, blockXStart, iMenuBar->Position().iY, gc);
       
   725 	DrawColorBlocks(*iClock, blockXStart, iClock->Position().iY, gc);
       
   726 	DrawColorBlocks(*iConsole, blockXStart, iConsole->Position().iY, gc);
       
   727 	DrawColorBlocks(*iMenu, blockXStart, iMenu->Position().iY, gc);
       
   728 	}
       
   729 
       
   730 /**
       
   731    The method calls TColorUtils::SetForegroundColorL() to override the system
       
   732    foreground colour for the control specified.
       
   733  */
       
   734 void CColorOverrideControl::SetForegroundColorL(CCoeControl& aControl, TRgb aRgb)
       
   735 	{
       
   736 	TColorUtils::SetForegroundColorL(aControl,aRgb);
       
   737 	}
       
   738 
       
   739 /**
       
   740    The method calls TColorUtils::SetBackgroundColorL() to override the system
       
   741    background colour for the control specified.   
       
   742  */
       
   743 void CColorOverrideControl::SetBackgroundColorL(CCoeControl& aControl, TRgb aRgb)
       
   744 	{
       
   745 	TColorUtils::SetBackgroundColorL(aControl,aRgb);
       
   746 	}
       
   747 
       
   748 /**
       
   749    @SYMTestCaseID UIF-tcolovrstep-UserOverrideForeAndBackColorsL
       
   750   
       
   751    @SYMPREQ
       
   752   
       
   753    @SYMTestCaseDesc Test overriding system foreground & background colour of the
       
   754    colour scheme control.
       
   755   
       
   756    @SYMTestPriority High
       
   757   
       
   758    @SYMTestStatus Implemented
       
   759    
       
   760    @SYMTestActions This method tests overriding of foreground & background colour
       
   761    of controls on the colour scheme control. 
       
   762   
       
   763    @SYMTestExpectedResults The method should override the foreground & background
       
   764    colour of controls on the custom colour scheme control.
       
   765    
       
   766  */
       
   767 void CColorOverrideControl::UserOverrideForeAndBackColorsL(TRgb aForeColor, TRgb aBackColor)
       
   768 	{
       
   769 	const TInt count=CountComponentControls();
       
   770 	for(TInt i=0;i<count;i++)
       
   771 		{
       
   772 		CCoeControl* ctl=ComponentControl(i);
       
   773 		SetForegroundColorL(*ctl,aForeColor);
       
   774 		SetBackgroundColorL(*ctl,aBackColor);
       
   775 		}
       
   776 	
       
   777 	SetForegroundColorL(*iMenuBar,aForeColor);
       
   778 	SetBackgroundColorL(*iMenuBar,aBackColor);
       
   779 	iMenuBar->StopDisplayingMenuBar();
       
   780 	iMenuBar->TryDisplayMenuBarL();
       
   781 	iMenuBar->SetRect(iMenuBarRect);
       
   782 	SetForegroundColorL(*iMenu,aForeColor);
       
   783 	SetBackgroundColorL(*iMenu,aBackColor);
       
   784 	iMenu->DrawNow();
       
   785 	}
       
   786 
       
   787 /**
       
   788    This method is an override from CCoeControl. It is used to process key
       
   789    events.
       
   790  */
       
   791 TKeyResponse CColorOverrideControl::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
       
   792 	{
       
   793 	return EKeyWasNotConsumed;
       
   794 	}
       
   795 
       
   796 CColorOverrideControl::~CColorOverrideControl()
       
   797 	{
       
   798 	delete iOverrideLabel;
       
   799 	delete iListBox;
       
   800 	delete iButton;
       
   801 	delete iScrollBar;
       
   802 	delete iEdwin;
       
   803 	delete iChoiceList;
       
   804 	delete iCaptionedCheckBox;
       
   805 	for (TInt ii=0; ii<3; ii++)
       
   806         delete(iOpBut[ii]);
       
   807 	delete iBCoord;
       
   808 	delete iNumberEditor;
       
   809 	delete iComboBox;
       
   810 	delete iMenuBar;
       
   811 	delete iSecretEditor;
       
   812 	delete iProgressInfo;
       
   813 	delete iClock;
       
   814 	delete iConsole;
       
   815 	delete iBrushAndPenContext;
       
   816 	delete iMenu;
       
   817 	}
       
   818 
       
   819 
       
   820 //
       
   821 //  CColorOverrideDlg  // 
       
   822 //
       
   823 
       
   824 /**
       
   825 	A dialog control for testing overriding of colour.
       
   826 */
       
   827 class CColorOverrideDlg : public CEikDialog
       
   828     {
       
   829 public:
       
   830     CColorOverrideDlg();
       
   831 	~CColorOverrideDlg() {};
       
   832 private: // from CEikDialog
       
   833     TBool OkToExitL(TInt aKeycode);
       
   834 	void PreLayoutDynInitL();
       
   835     };
       
   836 
       
   837 CColorOverrideDlg::CColorOverrideDlg() 
       
   838 	{
       
   839 	} 
       
   840 
       
   841 /**
       
   842    This method is an override from CEikDialog. It is used to perform
       
   843    pre-layout dialog initialisation. 
       
   844  */
       
   845 void CColorOverrideDlg::PreLayoutDynInitL()
       
   846 	{
       
   847 	TColorUtils::SetForegroundColorL(*this,KRgbWhite);
       
   848 	TColorUtils::SetBackgroundColorL(*this,KRgbDarkMagenta);
       
   849 	HandleResourceChange(KEikColorResourceChange);
       
   850 	}
       
   851 
       
   852 /**
       
   853    This method is an override from CEikDialog. It handles a dialog
       
   854    button press for the specified button 
       
   855  */
       
   856 TBool CColorOverrideDlg::OkToExitL(TInt /*aControlId*/)
       
   857     {
       
   858 	return(ETrue);
       
   859     }
       
   860 
       
   861 
       
   862 //
       
   863 // class CColorOverrideAppUi  //
       
   864 //
       
   865 
       
   866 CColorOverrideAppUi::CColorOverrideAppUi(CTmsTestStep* aStep) :
       
   867 	CTestAppUi(aStep,KTCOLOVRResourceFilePath, R_TCOLOVR_HOTKEYS, R_TCOLOVR_MENUBAR, R_TCOLOVR_TOOLBAR)
       
   868 	{
       
   869 	}
       
   870 
       
   871 /**
       
   872    This method sets the status pane layout as specified by the application and
       
   873    creates tool bar & custom colour scheme control. It also initiates the
       
   874    tests.
       
   875  */
       
   876 void CColorOverrideAppUi::ConstructL()
       
   877     {
       
   878     CTestAppUi::ConstructL();
       
   879 	INFO_PRINTF1(_L("Building Status Pane"));
       
   880 	if( iEikonEnv->AppUiFactory()->StatusPane() )
       
   881 		{
       
   882 		iEikonEnv->AppUiFactory()->StatusPane()->SwitchLayoutL(R_STATUS_PANE_LAYOUT_SHELL);
       
   883 		iEikonEnv->AppUiFactory()->StatusPane()->ApplyCurrentSettingsL();
       
   884 		}
       
   885 	INFO_PRINTF1(_L("Building Tool Bar"));
       
   886 	iToolBar=CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::EToolbar,  CEikButtonGroupContainer::EVertical, this, R_TCOLOVR_TOOLBAR);
       
   887 	const TRect boundingRect=ClientRect(); // make toolband stretch to the screen width by default
       
   888 	iToolBar->SetBoundingRect(boundingRect);
       
   889 	iToolBar->MakeVisible(ETrue);
       
   890 	AddToStackL(iToolBar);
       
   891 
       
   892 	INFO_PRINTF1(_L("Building Colour Scheme\n"));
       
   893 	iColorSchemeControl=new(ELeave) CColorOverrideControl;
       
   894     iColorSchemeControl->ConstructL(ClientRect());
       
   895 	AddToStackL(iColorSchemeControl);
       
   896 	
       
   897  	AutoTestManager().StartAutoTest();
       
   898     }
       
   899 
       
   900 
       
   901 CColorOverrideAppUi::~CColorOverrideAppUi()
       
   902     {
       
   903 	RemoveFromStack(iColorSchemeControl);
       
   904 	delete iColorSchemeControl;
       
   905 	RemoveFromStack(iToolBar);
       
   906 	delete iToolBar;
       
   907     }
       
   908 
       
   909 /**
       
   910    The method is an override from CTestAppUi. The method initiates all tests
       
   911    by calling CColorOverrideAppUi::HandleCommandL().
       
   912  */
       
   913 void CColorOverrideAppUi::RunTestStepL(TInt aNumStep)
       
   914  	{
       
   915 	User::After(500000);
       
   916  	switch(aNumStep)
       
   917  		{
       
   918  	case 1:
       
   919 		{
       
   920 		INFO_PRINTF1(_L("Test Case 1:"));
       
   921  		INFO_PRINTF1(_L("Toggle Status Pane Off"));
       
   922  		TRAPD(ret,HandleCommandL(EAppCmdToggleSpane));
       
   923  		TEST(ret==KErrNone);
       
   924  		INFO_PRINTF2(_L("Test case finished with return value = '%d'.\n"), ret);
       
   925 		}
       
   926 		break;
       
   927 	case 2:
       
   928 		{
       
   929 		INFO_PRINTF1(_L("Test Case 2:"));
       
   930  		INFO_PRINTF1(_L("Toggle Status Pane Off"));
       
   931  		TRAPD(ret, HandleCommandL(EAppCmdToggleSpane));
       
   932  		TEST(ret==KErrNone);
       
   933  		INFO_PRINTF2(_L("Test case finished with return value = '%d'.\n"), ret);
       
   934 		}
       
   935 		break;
       
   936 	case 3:
       
   937 		{
       
   938 		INFO_PRINTF1(_L("Test Case 3:"));
       
   939 		INFO_PRINTF1(_L("Toggle Dialog display On"));
       
   940  		TRAPD(ret, HandleCommandL(EAppCmdShowAutoDlg));
       
   941  		TEST(ret==KErrNone);
       
   942 		User::After(5000000);
       
   943 		//Simulate key entry and flush the buffer to send event to windows server session.
       
   944 		TKeyEvent event;
       
   945 		//Set up key event "enter" to simulate key enter to replace clicking "ok" on dialog.
       
   946 		event.iCode=event.iScanCode=EKeyEnter;
       
   947 		event.iModifiers= 0;
       
   948 		event.iRepeats=0;
       
   949 		RWsSession& ws=CEikonEnv::Static()->WsSession();
       
   950 		ws.SimulateKeyEvent(event);
       
   951 		ws.Flush();
       
   952  		INFO_PRINTF2(_L("Test case finished with return value = '%d'.\n"), ret);
       
   953 		}
       
   954 		break;
       
   955 	case 4:
       
   956 		{
       
   957 		INFO_PRINTF1(_L("Test Case 4:"));
       
   958  		INFO_PRINTF1(_L("Toggle Floating Menu Off"));
       
   959  		SetTestStepID(_L("UIF-tcolovrstep-ToggleFloatingMenuL"));
       
   960  		TRAPD(ret, HandleCommandL(EAppCmdToggleFloatingMenu));
       
   961  		TEST(ret==KErrNone);
       
   962  		INFO_PRINTF2(_L("Test case finished with return value = '%d'.\n"), ret);
       
   963  		RecordTestResultL();
       
   964 		}
       
   965 		break;
       
   966 	case 5:
       
   967 		{
       
   968 		INFO_PRINTF1(_L("Test Case 5:"));
       
   969  		INFO_PRINTF1(_L("Toggle Floating Menu On"));
       
   970  		SetTestStepID(_L("UIF-tcolovrstep-ToggleFloatingMenuL"));
       
   971  		TRAPD(ret, HandleCommandL(EAppCmdToggleFloatingMenu));
       
   972  		TEST(ret==KErrNone);
       
   973  		INFO_PRINTF2(_L("Test case finished with return value = '%d'.\n"), ret);
       
   974 		RecordTestResultL();
       
   975 		}
       
   976 		break;
       
   977 	case 6:
       
   978 		{
       
   979 		INFO_PRINTF1(_L("Test Case 6:"));
       
   980  		INFO_PRINTF1(_L("Override foreground and background colours to light on dark"));
       
   981  		SetTestStepID(_L("UIF-tcolovrstep-UserOverrideForeAndBackColorsL"));
       
   982  		TRAPD(ret, HandleCommandL(EAppCmdOverrideForeAndBackToLightOnDark));
       
   983  		TEST(ret==KErrNone);
       
   984  		INFO_PRINTF2(_L("Test case finished with return value = '%d'.\n"), ret);
       
   985  		User::After(5000000);
       
   986  		RecordTestResultL();
       
   987 		}
       
   988 		break;
       
   989 	case 7:
       
   990 		{
       
   991 		INFO_PRINTF1(_L("Test Case 7:"));
       
   992  		INFO_PRINTF1(_L("Override foreground and background colours to dark on light"));
       
   993  		SetTestStepID(_L("UIF-tcolovrstep-UserOverrideForeAndBackColorsL"));
       
   994  		TRAPD(ret, HandleCommandL(EAppCmdOverrideForeAndBackToLightOnDark));
       
   995  		TEST(ret==KErrNone);
       
   996  		INFO_PRINTF2(_L("Test case finished with return value = '%d'.\n"), ret);
       
   997  		User::After(5000000);
       
   998  		RecordTestResultL();
       
   999 		}
       
  1000 		break;
       
  1001 	case 8:
       
  1002 		{
       
  1003 		INFO_PRINTF1(_L("Test Case 8:"));
       
  1004  		INFO_PRINTF1(_L("Dim the text"));
       
  1005  		SetTestStepID(_L("UIF-tcolovrstep-Dim"));
       
  1006  		TRAPD(ret, HandleCommandL(EAppCmdDim));
       
  1007  		TEST(ret==KErrNone);
       
  1008  		INFO_PRINTF2(_L("Test case finished with return value = '%d'.\n"), ret);
       
  1009  		RecordTestResultL();
       
  1010 		}
       
  1011 		break;
       
  1012 	case 9:
       
  1013 		{
       
  1014 		INFO_PRINTF1(_L("Test Case 9:"));
       
  1015  		INFO_PRINTF1(_L("Override f/g and b/g to light on dark"));
       
  1016  		SetTestStepID(_L("UIF-tcolovrstep-UserOverrideForeAndBackColorsL"));
       
  1017  		TRAPD(ret, HandleCommandL(EAppCmdOverrideForeAndBackToLightOnDark));
       
  1018  		TEST(ret==KErrNone);
       
  1019  		INFO_PRINTF2(_L("Test case finished with return value = '%d'.\n"), ret);
       
  1020  		User::After(5000000);
       
  1021  		RecordTestResultL();
       
  1022 		}
       
  1023 		break;
       
  1024 	case 10:
       
  1025 		{
       
  1026 		INFO_PRINTF1(_L("Test Case 10:"));
       
  1027  		INFO_PRINTF1(_L("Override f/g and b/g to dark on light with dimmed text"));
       
  1028  		SetTestStepID(_L("UIF-tcolovrstep-Dim"));
       
  1029  		TRAPD(ret1, HandleCommandL(EAppCmdDim));
       
  1030  		TEST(ret1==KErrNone);
       
  1031  		RecordTestResultL();
       
  1032 		SetTestStepID(_L("UIF-tcolovrstep-UserOverrideForeAndBackColorsL"));
       
  1033  		TRAPD(ret2, HandleCommandL(EAppCmdOverrideForeAndBackToLightOnDark));
       
  1034  		TEST(ret2==KErrNone);
       
  1035  		INFO_PRINTF3(_L("Test case finished with return values = '%d' and '%d'.\n"), ret1, ret2);
       
  1036  		User::After(5000000);
       
  1037  		RecordTestResultL();
       
  1038 		}
       
  1039 		break;
       
  1040 	case 11:
       
  1041 		{
       
  1042 		INFO_PRINTF1(_L("Test Case 11:"));
       
  1043  		INFO_PRINTF1(_L("Select System Colours"));
       
  1044  		SetTestStepID(_L("UIF-tcolovrstep-SetSystemColorsL"));
       
  1045  		TRAPD(ret, HandleCommandL(EAppCmdSystemColors));
       
  1046  		TEST(ret==KErrNone);
       
  1047  		INFO_PRINTF2(_L("Test case finished with return value = '%d'.\n"), ret);
       
  1048  		RecordTestResultL();
       
  1049  		CloseTMSGraphicsStep();
       
  1050 		}
       
  1051 		break;
       
  1052 	case 12:
       
  1053 		{
       
  1054  		AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass);
       
  1055 		}
       
  1056 		break;	
       
  1057 	default:
       
  1058  		break;
       
  1059  		}
       
  1060  	}
       
  1061 
       
  1062 
       
  1063 /**
       
  1064    This method is called by CColorOverrideAppUi::RunTestStepL() to initiate the tests.
       
  1065  */
       
  1066 void CColorOverrideAppUi::HandleCommandL(TInt aCommand)
       
  1067     {
       
  1068     switch (aCommand)
       
  1069         {
       
  1070     case EEikCmdExit:
       
  1071         Exit();
       
  1072         break;
       
  1073 	case EAppCmdToggleSpane:
       
  1074 		if( iEikonEnv->AppUiFactory()->StatusPane() )
       
  1075 		{
       
  1076 			iEikonEnv->AppUiFactory()->StatusPane()->MakeVisible( !iEikonEnv->AppUiFactory()->StatusPane()->IsVisible() );
       
  1077 			iColorSchemeControl->SetRect( ClientRect() );
       
  1078 			iColorSchemeControl->DrawNow();
       
  1079 		}
       
  1080 		break;
       
  1081 	case EAppCmdShowDlg:
       
  1082 		{
       
  1083 		CEikDialog* dialog=new(ELeave) CColorOverrideDlg();	
       
  1084 		dialog->ExecuteLD(R_TCOLOVR_DIALOG);
       
  1085 		}
       
  1086 		break;
       
  1087 	case EAppCmdShowAutoDlg:
       
  1088 		{
       
  1089 		//destroyed when goes out of scope by base class
       
  1090 		CEikDialog* dialog=new(ELeave) CColorOverrideDlg();	
       
  1091 		dialog->ExecuteLD(R_TCOLOVR_AUTO_DIALOG);
       
  1092 		}
       
  1093 		break;
       
  1094 	case EAppCmdSystemColors:
       
  1095 		iColorSchemeControl->SetSystemColorsL();
       
  1096 		iColorSchemeControl->DrawNow();
       
  1097 		break;
       
  1098 	case EAppCmdOverrideForeAndBackToLightOnDark:
       
  1099 		iColorSchemeControl->UserOverrideForeAndBackColorsL(KRgbWhite,KRgbDarkMagenta);
       
  1100 		iColorSchemeControl->DrawNow();
       
  1101 		
       
  1102 		TColorUtils::SetForegroundColorL(*iToolBar,KRgbWhite);
       
  1103 		TColorUtils::SetBackgroundColorL(*iToolBar,KRgbDarkMagenta);
       
  1104 		iToolBar->HandleResourceChange(KEikColorResourceChange);
       
  1105 		iToolBar->DrawNow();
       
  1106 		break;
       
  1107 	case EAppCmdOverrideForeAndBackToDarkOnLight:
       
  1108 		iColorSchemeControl->UserOverrideForeAndBackColorsL(KRgbBlack,KRgbLilac);
       
  1109 		iColorSchemeControl->DrawNow();
       
  1110 		
       
  1111 		TColorUtils::SetForegroundColorL(*iToolBar,KRgbWhite);
       
  1112 		TColorUtils::SetBackgroundColorL(*iToolBar,KRgbDarkMagenta);
       
  1113 		iToolBar->HandleResourceChange(KEikColorResourceChange);
       
  1114 		iToolBar->DrawNow();
       
  1115 		break;
       
  1116 	case EAppCmdToggleFloatingMenu:
       
  1117 		iColorSchemeControl->ToggleFloatingMenuL();
       
  1118 		break;
       
  1119 	case EAppCmdDim:
       
  1120 		iColorSchemeControl->Dim();
       
  1121 		iColorSchemeControl->DrawNow();
       
  1122 		break;
       
  1123 	default:
       
  1124 		Panic(EBadCommandPanic);
       
  1125 
       
  1126         }
       
  1127     }
       
  1128 
       
  1129 /**
       
  1130    The method creates & sets the application's user interface object.
       
  1131  */
       
  1132 void CTColOvrStep::ConstructAppL(CEikonEnv* aEikEnv)
       
  1133 	{
       
  1134 	aEikEnv->ConstructL();
       
  1135  	CColorOverrideAppUi* appUi=new(ELeave) CColorOverrideAppUi(this);
       
  1136  	appUi->ConstructL();
       
  1137 	CleanupStack::PushL(appUi);
       
  1138  	aEikEnv->SetAppUi(appUi);
       
  1139 	CleanupStack::Pop();
       
  1140 	// goes out of scope when function leaves and private members are destroyed. App Architecture handles CEikAppUI destruction
       
  1141 	}
       
  1142 
       
  1143 
       
  1144 TVerdict CTColOvrStep::doTestStepPreambleL()
       
  1145 	{
       
  1146 	SetTestStepResult(EPass);
       
  1147 	return TestStepResult();
       
  1148 	}
       
  1149 
       
  1150 CTColOvrStep::~CTColOvrStep()
       
  1151 	{
       
  1152 	}
       
  1153 
       
  1154 CTColOvrStep::CTColOvrStep()
       
  1155 	{
       
  1156 	// Call base class method to set up the human readable name for logging
       
  1157 	SetTestStepName(KTColOvrStep);
       
  1158 	}
       
  1159 
       
  1160 /**
       
  1161    The method creates & sets the test step's user interface object and launches the test step.
       
  1162    
       
  1163  */
       
  1164 TVerdict CTColOvrStep::doTestStepL()
       
  1165 	{
       
  1166 	CloseAllPanicWindowsL(); //this function call is added, because tcolovr test is sensitive to windows left open by tests that have run previously
       
  1167 	INFO_PRINTF1(_L("Test Started"));
       
  1168 
       
  1169 	PreallocateHALBuffer();
       
  1170 
       
  1171      __UHEAP_MARK;
       
  1172  
       
  1173  	CEikonEnv* eikEnv=new CEikonEnv;
       
  1174  	TEST(eikEnv!=NULL);
       
  1175  	if (eikEnv==NULL)
       
  1176 		{
       
  1177 		INFO_PRINTF1(_L("Failed to create Eikon Environment due to lack of Memory"));
       
  1178  		return TestStepResult();
       
  1179 		}
       
  1180 		
       
  1181  	TRAPD(err,ConstructAppL(eikEnv));
       
  1182 	TEST(err==KErrNone);
       
  1183  	if (err!=KErrNone)
       
  1184 		{
       
  1185 		INFO_PRINTF1(_L("Failed to construct Eikon Environment"));
       
  1186  		delete eikEnv;
       
  1187 		}
       
  1188  	else
       
  1189  		eikEnv->ExecuteD();
       
  1190 
       
  1191 	 
       
  1192 	REComSession::FinalClose();	
       
  1193  	__UHEAP_MARKEND;
       
  1194  
       
  1195 	INFO_PRINTF1(_L("Test Finished!"));
       
  1196 	return TestStepResult();
       
  1197     }
       
  1198 
       
  1199 
       
  1200