windowing/windowserver/tauto/TDirectA.CPP
changeset 0 5d03bc08d59c
child 45 36b2e23a8629
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 1996-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 // Test Direct Screen Access
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "tdirecta.h"
       
    19 
       
    20 static TRect WinExt;
       
    21 static TInt WinCol=0;
       
    22 static TTimeIntervalMicroSeconds32 MoveInterval;
       
    23 static TTimeIntervalMicroSeconds32 ModeInterval;
       
    24 static TTimeIntervalMicroSeconds32 FlipInterval;
       
    25 static TBool ImmediateModeSwitch;
       
    26 #if defined(LOGGING)
       
    27 	LOCAL_D TLogMessageText LogMessageText;
       
    28 #endif
       
    29 
       
    30 _LIT(SemControl,"Control");
       
    31 _LIT(SemNextOp,"TrigerWindow");
       
    32 _LIT(FontName,"DejaVu Serif Condensed");
       
    33 _LIT(QueueControl,"Queue");
       
    34 
       
    35 LOCAL_D TSize FullScreenModeSize;
       
    36 LOCAL_D TInt Copy2ndHalfOfScreen;
       
    37 
       
    38 const TBool KRegionTrackingOnly = ETrue;
       
    39 const TBool KDrawingDsa = EFalse;
       
    40 
       
    41 const TInt KPanicTestOrdinalPriority=65536;
       
    42 const TInt KMainTestOrdinalPriority=65535;
       
    43 const TInt KMainTestBaseWindow=KMainTestOrdinalPriority/3;
       
    44 const TInt KAboveMainTestBaseWindow = KMainTestBaseWindow +1;
       
    45 
       
    46 const TInt KMaxIdlingTime = 25; //used for RegionTrackingOnly DSAs, it represents the maximum number of times the Idling function can be called
       
    47 //Ids of two RegionTrackingOnly DSAs
       
    48 const TInt KRegionTrackingOnlyDsaWaitingForAbortSignal = 25;
       
    49 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
       
    50 const TInt KRegionTrackingOnlyDsaNoAbortSignal = 26;
       
    51 #endif
       
    52 
       
    53 const TInt KRegionTrackingOnlyDsaExistLast = 0;
       
    54 const TInt KDrawingDsaExistLast = 1;
       
    55 const TInt KShortDelay = 5000;
       
    56 #define SHORT_DELAY	TTimeIntervalMicroSeconds32(KShortDelay)
       
    57 
       
    58 _LIT(KSem_DefectFix_KAA_5J3BLW_Name, "DefectFix_KAA_5J3BLW");
       
    59 
       
    60 GLDEF_C TInt ProcDirect(TAny *aScreenNumber)
       
    61 	{
       
    62 	CTrapCleanup* cleanupStack = NULL;
       
    63 	User::LeaveIfNull(cleanupStack = CTrapCleanup::New());
       
    64 
       
    65 #if defined(LOGGING)
       
    66 	_LIT(KWindow,"Window Toggle Vis=");
       
    67 	_LIT(KParams,"%d, Pos=(%d,%d,%d,%d), Col=%d");
       
    68 #endif
       
    69 	RSemaphore controlSem;
       
    70 	RSemaphore windowSem;
       
    71 	User::LeaveIfError(controlSem.OpenGlobal(SemControl));
       
    72 	User::LeaveIfError(windowSem.OpenGlobal(SemNextOp));
       
    73 	RWsSession ws;
       
    74 	User::LeaveIfError(ws.Connect());
       
    75 
       
    76 	// assign to the correct screen
       
    77 	CWsScreenDevice* screen = NULL;
       
    78 	TInt err;
       
    79 	TRAP(err, screen = new (ELeave) CWsScreenDevice(ws));
       
    80 	if (err!=KErrNone)
       
    81 		return err;
       
    82 
       
    83 	if ((err=screen->Construct((TInt)aScreenNumber))!=KErrNone)
       
    84 		{
       
    85 		delete screen;
       
    86 		return err;
       
    87 		}
       
    88 
       
    89 	RWindowGroup group(ws);
       
    90 	User::LeaveIfError(group.Construct(898));
       
    91 	group.EnableReceiptOfFocus(EFalse);
       
    92 	group.SetOrdinalPosition(0,KAboveMainTestBaseWindow );
       
    93 	RBlankWindow window(ws);
       
    94 	User::LeaveIfError(window.Construct(group,899));
       
    95 	TBool vis=EFalse;
       
    96 	window.SetVisible(vis);
       
    97 	window.Activate();
       
    98 	ws.Flush();
       
    99 	controlSem.Signal();
       
   100 	windowSem.Wait();
       
   101 	RMsgQueueBase queue;
       
   102 	TInt open = queue.OpenGlobal(QueueControl);
       
   103 	TInt data;
       
   104 	while (queue.Receive(&data,sizeof(TInt)) != KErrNone)
       
   105 		{
       
   106 		vis=!vis;
       
   107 		if (vis)
       
   108 			{
       
   109 			window.SetColor(TRgb::Gray4(WinCol));
       
   110 			window.SetExtent(WinExt.iTl,WinExt.Size());
       
   111 		#if defined(LOGGING)
       
   112 			LogMessageText.Copy(KWindow);
       
   113 			LogMessageText.AppendFormat(KParams,vis,WinExt.iTl.iX,WinExt.iTl.iY,WinExt.iBr.iX,WinExt.iBr.iY,WinCol);
       
   114 			ws.LogMessage(LogMessageText);
       
   115 		#endif
       
   116 			}
       
   117 		window.SetVisible(vis);
       
   118 		ws.Flush();
       
   119 		windowSem.Wait();
       
   120 		}
       
   121 	queue.Close();
       
   122 
       
   123 	window.Close();
       
   124 	group.Close();
       
   125 
       
   126 	delete screen;
       
   127 	ws.Close();
       
   128 	controlSem.Close();
       
   129 	windowSem.Close();
       
   130 
       
   131 	delete cleanupStack;
       
   132 	return(KErrNone);
       
   133 	}
       
   134 
       
   135 
       
   136 /*CDirectScreenAccessOld*/
       
   137 
       
   138 CDirectScreenAccessOld* CDirectScreenAccessOld::NewL(RWsSession& aWs,MAbortDirectScreenAccess& aAborter)
       
   139 	{
       
   140 	CDirectScreenAccessOld* self=new(ELeave) CDirectScreenAccessOld(aWs,aAborter);
       
   141 	CleanupStack::PushL(self);
       
   142 	self->ConstructL();
       
   143 	CleanupStack::Pop(self);
       
   144 	return self;
       
   145 	}
       
   146 
       
   147 CDirectScreenAccessOld::~CDirectScreenAccessOld()
       
   148 	{
       
   149 	__ASSERT_ALWAYS(!iAborting,AutoPanic(EAutoPanicDirect));
       
   150 	Cancel();
       
   151 	iDirectAccess.Close();
       
   152 	}
       
   153 
       
   154 void CDirectScreenAccessOld::ConstructL()
       
   155 	{
       
   156 	User::LeaveIfError(iDirectAccess.Construct());
       
   157 	CActiveScheduler::Add(this);
       
   158 	}
       
   159 
       
   160 TInt CDirectScreenAccessOld::Request(RRegion*& aRegion, RWindowBase& aWindow)
       
   161 	{
       
   162 	TInt ret=iDirectAccess.Request(aRegion,iStatus,aWindow);
       
   163 	if (ret==KErrNone)
       
   164 		SetActive();
       
   165 	return ret;
       
   166 	}
       
   167 
       
   168 void CDirectScreenAccessOld::DoCancel()
       
   169 	{
       
   170 	iDirectAccess.Cancel();
       
   171 	}
       
   172 
       
   173 void CDirectScreenAccessOld::RunL()
       
   174 	{
       
   175 	iAborting=ETrue;
       
   176 	iAborter.AbortNow(REINTERPRET_CAST(RDirectScreenAccess::TTerminationReasons&,iStatus));
       
   177 	iAborting=EFalse;
       
   178 	iDirectAccess.Completed();
       
   179 	}
       
   180 
       
   181 
       
   182 /*CColorAnimation*/
       
   183 
       
   184 CColorAnimation* CColorAnimation::NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWinBase& aParent,TRect aExtent,TBool aStart,TBool aRegionTrackingOnly)
       
   185 	{
       
   186 	CColorAnimation* self=new(ELeave) CColorAnimation(aScreenNumber,aId,aCallBack);
       
   187 	CleanupStack::PushL(self);
       
   188 	self->ConstructL(aParent,aExtent,aRegionTrackingOnly);
       
   189 	if (aStart)
       
   190 		self->StartL();
       
   191 	CleanupStack::Pop(self);
       
   192 	return self;
       
   193 	}
       
   194 
       
   195 CColorAnimation::~CColorAnimation()
       
   196 	{
       
   197 	delete iTimer;
       
   198 	delete iDrawer;
       
   199 	delete iWindow;
       
   200 	delete iWindow2;
       
   201 	TheClient->Flush();
       
   202 	}
       
   203 
       
   204 void CColorAnimation::ConstructL(CTWinBase& aParent,TRect aExtent,TBool aRegionTrackingOnly,TInt aTypeWindow/*=0*/,TInt aSingleWinForMultipleDSA/*=0*/)
       
   205 	{	
       
   206 	iRegionTrackingOnly = aRegionTrackingOnly;
       
   207 	// Make sure that the top right corner is not 0,0
       
   208 	if (aTypeWindow && aExtent.iTl==TPoint(0,0))
       
   209 		{
       
   210 		aExtent.iTl=TPoint(10,10);
       
   211 		}
       
   212 	RWindowBase* win=NULL;
       
   213 	iSingleWinForMultipleDSA=aSingleWinForMultipleDSA;
       
   214 	if (aSingleWinForMultipleDSA)
       
   215 		{
       
   216 		win=iCallBack.iCallBackWin->BaseWin();
       
   217 		iWinSize=TheClient->iScreen->SizeInPixels();
       
   218 		}
       
   219 	else
       
   220 		{
       
   221 		iWindow=new(ELeave) CTBlankWindow();
       
   222 		iWinSize=aExtent.Size();
       
   223 		iWindow->ConstructExtLD(aParent,aExtent.iTl,iWinSize);
       
   224 		ChangeModeL(iCallBack.DisplayMode(iId));
       
   225 		win=iWindow->BaseWin();
       
   226 		win->SetShadowDisabled(ETrue);
       
   227 		win->Activate();
       
   228 		}
       
   229 	if (!aTypeWindow)
       
   230 		{
       
   231 		if(iRegionTrackingOnly)
       
   232 			{
       
   233 			iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,*win,*this,iRegionTrackingOnly);
       
   234 			}
       
   235 		else
       
   236 			{
       
   237 			//needed for the non NGA case: only the old API is allowed to be used
       
   238 			iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,*win,*this);
       
   239 			}
       
   240 		}
       
   241 	else
       
   242 		{
       
   243 		TRect childRect(0,0,100,100);
       
   244 		switch(aTypeWindow)
       
   245 			{
       
   246 			case 1:
       
   247 				{
       
   248 				// Create a Blank Window smaller than it's parent and its top left corner within the parent area and withn the screen area
       
   249 	 			childRect.Shrink(10,10);
       
   250 				break;
       
   251 				}
       
   252 			case 2:
       
   253 				{
       
   254 				// Create a Blank Window with its top left corner being left side of its parent
       
   255 				childRect.Move(-10,0);
       
   256 				break;
       
   257 				}
       
   258 			}
       
   259 		iWindow2=new(ELeave) CTBlankWindow();
       
   260 		iWindow2->ConstructExtLD(*iWindow,childRect.iTl,childRect.Size());
       
   261 		// Finish constructing the window
       
   262 	 	RWindowBase& win=*iWindow2->BaseWin();
       
   263 	 	win.SetShadowDisabled(ETrue);
       
   264 	 	win.Activate();
       
   265 		// Create the Direct Screen Access object
       
   266 	 	if(iRegionTrackingOnly)
       
   267 	 		{
       
   268 	 		iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,win,*this,iRegionTrackingOnly);
       
   269 	 		}
       
   270 	 	else
       
   271 	 		{
       
   272 	 		//needed for the non NGA case: only the old API is allowed to be used
       
   273 	 		iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,win,*this);
       
   274 	 		}
       
   275 		}
       
   276 	TheClient->Flush();
       
   277 	iTimer=CPeriodic::NewL(0);
       
   278 	}
       
   279 
       
   280 TPoint CColorAnimation::AbsoluteWindowPosition(TInt aWindowId/*=0*/)
       
   281 	{
       
   282 	if (iSingleWinForMultipleDSA)
       
   283 		{
       
   284 		return iCallBack.iCallBackWin->BaseWin()->AbsPosition();
       
   285 		}
       
   286 	if (!aWindowId)
       
   287 		{
       
   288 		// Return the absolute position of iWindow, if Color Animation is not for Position Relative to Screen test.
       
   289 		return iWindow->BaseWin()->AbsPosition();
       
   290 		}
       
   291 	else
       
   292 		{
       
   293 		// Return the absolute position of iWindow2, if it is for Position Relative to Screen test.
       
   294 		return iWindow2->BaseWin()->AbsPosition();
       
   295 		}
       
   296 	}
       
   297 
       
   298 TInt CColorAnimation::DrawColorL(TAny* aAnimation)
       
   299 	{
       
   300 	STATIC_CAST(CColorAnimation*,aAnimation)->DrawColorL();
       
   301 	return(KErrNone);
       
   302 	}
       
   303 
       
   304 TInt CColorAnimation::IdlingL(TAny* aAnimation)
       
   305 	{
       
   306 	(static_cast<CColorAnimation*>(aAnimation))->IdlingL();
       
   307 	return(KErrNone);
       
   308 	}
       
   309 
       
   310 void CColorAnimation::StartL(TBool aChildWindow/*=EFalse*/)
       
   311 	{
       
   312 	iDrawer->StartL();
       
   313 	TRect bounding=iDrawer->DrawingRegion()->BoundingRect();
       
   314 	TRect window;
       
   315 	if (aChildWindow)
       
   316 		{
       
   317 		window.SetRect(AbsoluteWindowPosition(1),iWinSize);
       
   318 		}
       
   319 	else
       
   320 		{
       
   321 		window.SetRect(AbsoluteWindowPosition(),iWinSize);
       
   322 		}
       
   323 	// Check that the window contains the bounding area (a bounding rect of (0,0,0,0) shouldn't fail the test)
       
   324 	if (!(window.Contains(bounding.iTl) && window.Contains(bounding.iBr-TPoint(1,1))) && bounding.Size()!=TSize(0,0))
       
   325 		{
       
   326 		iCallBack.Fail();
       
   327 	//	iDrawer->Cancel();
       
   328 	//	iDrawer->StartL();
       
   329 	//	bounding=iDrawer->DrawingRegion()->BoundingRect();
       
   330 		}
       
   331 	if(!iRegionTrackingOnly)                                                                                                                                                          
       
   332 		{
       
   333 		iTimer->Start(0,iCallBack.TimerInterval(iId),TCallBack(CColorAnimation::DrawColorL,this));
       
   334 		iDrawer->Gc()->SetPenStyle(CGraphicsContext::ENullPen);
       
   335 		iDrawer->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   336 		}                                                                                                                                                                                
       
   337 	else                                                                                                                                                                              
       
   338 		{
       
   339 		iTimer->Start(0,iCallBack.TimerInterval(iId),TCallBack(CColorAnimation::IdlingL,this));
       
   340 		}
       
   341 	}
       
   342 
       
   343 void CColorAnimation::StartOrPanic()
       
   344 	{
       
   345 	TRAPD(err,StartL());
       
   346 	if (err!=KErrNone)
       
   347 		{
       
   348 		iCallBack.LogLeave(err);
       
   349 		iCallBack.Fail();
       
   350 		}
       
   351 	}
       
   352 
       
   353 void CColorAnimation::Stop()
       
   354 	{
       
   355 	iTimer->Cancel();
       
   356 	iDrawer->Cancel();
       
   357 	}
       
   358 
       
   359 void CColorAnimation::BringWindowToFront()
       
   360 	{
       
   361 	iWindow->WinTreeNode()->SetOrdinalPosition(0);
       
   362 	}
       
   363 
       
   364 void CColorAnimation::ChangeModeL(TDisplayMode aMode)
       
   365 	{
       
   366 	User::LeaveIfError(iWindow->BaseWin()->SetRequiredDisplayMode(aMode));
       
   367 	TheClient->Flush();
       
   368 	}
       
   369 
       
   370 void CColorAnimation::FinishTest()
       
   371 	{
       
   372 	iCallBack.Finished(iId);
       
   373 	}
       
   374 
       
   375 inline CDirectScreenAccess* CColorAnimation::GetDrawer()
       
   376 	{
       
   377 	return iDrawer;
       
   378 	}
       
   379 
       
   380 void CColorAnimation::DrawColorL()
       
   381 	{
       
   382 	TBool aFinished;
       
   383 	iDrawer->Gc()->SetBrushColor(iCallBack.BrushColorL(iId,iColor,aFinished));
       
   384 	if (iSingleWinForMultipleDSA==1)
       
   385 		{
       
   386 		iDrawer->Gc()->DrawRect(iWinSize-TSize(iWinSize.iWidth/2,iWinSize.iHeight/2));
       
   387 		}
       
   388 	else if (iSingleWinForMultipleDSA==2)
       
   389 		{
       
   390 		iDrawer->Gc()->DrawRect(TRect(TPoint(iWinSize.iWidth/2,iWinSize.iHeight/2),TSize(iWinSize.iWidth/2,iWinSize.iHeight/2)));
       
   391 		}
       
   392 	else
       
   393 		{
       
   394 		iDrawer->Gc()->DrawRect(iWinSize);
       
   395 		}
       
   396 	iDrawer->ScreenDevice()->Update();
       
   397 	if (aFinished)
       
   398 		{
       
   399 		if (iId==1)
       
   400 			{
       
   401 			iWindow->SetSize(TSize(48,52));
       
   402 			TheClient->Flush();
       
   403 			}
       
   404 		if (aFinished==1)
       
   405 			Stop();
       
   406 		iCallBack.Finished(iId);
       
   407 		}
       
   408 	}
       
   409 
       
   410 void CColorAnimation::IdlingL()
       
   411 	{
       
   412 	iIdling++;
       
   413 	if(iIdling == KMaxIdlingTime)
       
   414 		{
       
   415 		Stop();
       
   416 		iIdling = 0;
       
   417 		if (iId == KRegionTrackingOnlyDsaWaitingForAbortSignal)
       
   418 			{
       
   419 			_LIT(KErrorAbortNotReceived,"DSA didn't get an abort signal even though the window was opened in front");
       
   420 			CallBack().Log((TText8*)__FILE__,__LINE__, ESevrErr,KErrorAbortNotReceived);
       
   421 			CallBack().Fail();
       
   422 			}
       
   423 		iCallBack.Finished(iId);
       
   424 		}
       
   425 	}
       
   426 
       
   427 void CColorAnimation::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
       
   428 	{
       
   429 	TInt slow=iCallBack.SlowStopping(iId,iCount);
       
   430 	switch (slow)
       
   431 		{
       
   432 	case eAbortAll:
       
   433 		iCallBack.Finished(iId);
       
   434 	case eAbort:
       
   435 		Stop();
       
   436 		return;
       
   437 	case eStopDelayed:
       
   438 		User::After(750000);		//0.75 secs
       
   439 		break;
       
   440 	default:;
       
   441 		}
       
   442 	++iCount;
       
   443 	iTimer->Cancel();
       
   444 	}
       
   445 
       
   446 void CColorAnimation::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/)
       
   447 	{
       
   448 	TRAPD(err,StartL());
       
   449 	if (err!=KErrNone)
       
   450 		iCallBack.FailedReStart(iId,err);
       
   451 	}
       
   452 
       
   453 
       
   454 /*CScrollingTextDrawer*/
       
   455 
       
   456 CScrollingTextDrawer* CScrollingTextDrawer::NewL(TInt aScreenNumber,CFbsScreenDevice*& aDevice,CFbsBitGc& aGc)
       
   457 	{
       
   458 	CScrollingTextDrawer* self=new(ELeave) CScrollingTextDrawer(aDevice,aGc);
       
   459 	CleanupStack::PushL(self);
       
   460 	self->ConstructL(aScreenNumber);
       
   461 	CleanupStack::Pop(self);
       
   462 	return self;
       
   463 	}
       
   464 
       
   465 CScrollingTextDrawer::~CScrollingTextDrawer()
       
   466 	{
       
   467 	if(iFontDevice)
       
   468 		{
       
   469 		iFontDevice->ReleaseFont(iFont);
       
   470 		delete iFontDevice;
       
   471 		}
       
   472 	}
       
   473 
       
   474 void CScrollingTextDrawer::ConstructL(TInt aScreenNumber)
       
   475 	{
       
   476 	iFontDevice=CFbsScreenDevice::NewL(aScreenNumber,iDevice->DisplayMode());
       
   477 	_LIT(text,"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
       
   478 	iText=text;
       
   479 	CreateFontL();
       
   480 	//iFirstChar=0;
       
   481 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   482 #if defined(LOGGING)
       
   483 	iWs.Connect();
       
   484 	// point to correct screen
       
   485 	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(iWs);
       
   486 	CleanupStack::PushL(screen);
       
   487 	User::LeaveIfError(screen->Construct(aScreenNumber));
       
   488 	CleanupStack::Pop(screen);
       
   489 
       
   490 	_LIT(KConstTextDrawer,"Constructed Text Drawer");
       
   491 	LogMessageText.Copy(KConstTextDrawer);
       
   492 	iWs.LogMessage(LogMessageText);
       
   493 	iWs.Flush();
       
   494 
       
   495 	delete screen;
       
   496 	iWs.Close();
       
   497 #endif
       
   498 	}
       
   499 
       
   500 void CScrollingTextDrawer::CreateFontL()
       
   501 	{
       
   502 	TInt screenHeight=iDevice->SizeInPixels().iHeight;
       
   503 	TFontSpec fontSpec(FontName,screenHeight);
       
   504 	User::LeaveIfError(iFontDevice->GetNearestFontToDesignHeightInPixels(iFont,fontSpec));
       
   505 	iGc->UseFont(iFont);
       
   506 	TInt fontHeight=iFont->HeightInPixels();
       
   507 	iDrawRect.iTl.iY=(screenHeight-fontHeight)/2;
       
   508 	iDrawRect.iBr.iY=iDrawRect.iTl.iY+fontHeight;
       
   509 	iDrawHeight=iFont->AscentInPixels();
       
   510 	iCharWidth=iFont->CharWidthInPixels(iText[iFirstChar]);
       
   511 	iDrawRect.iBr.iX=Max(iDevice->SizeInPixels().iWidth,iDevice->SizeInPixels().iHeight);
       
   512 	iDrawRect.iTl.iX=iDrawRect.iBr.iX-iCharWidth;
       
   513 	}
       
   514 
       
   515 void CScrollingTextDrawer::SetBottomOfTest(TInt aBottom)
       
   516 	{
       
   517 	if (iDrawRect.iBr.iY>aBottom)
       
   518 		{
       
   519 		iDrawRect.iTl.iY-=iDrawRect.iBr.iY-aBottom;
       
   520 		iDrawRect.iBr.iY=aBottom;
       
   521 		}
       
   522 	}
       
   523 
       
   524 void CScrollingTextDrawer::Scroll()
       
   525 	{
       
   526 	iCharWidth=iFont->CharWidthInPixels(iText[iFirstChar]);
       
   527 	iDrawRect.iTl.iX-=iJump;
       
   528 	iGc->DrawText(iText.Mid(iFirstChar),iDrawRect,iDrawHeight);
       
   529 	iDevice->Update();
       
   530 	if (iDrawRect.iTl.iX<-iCharWidth)
       
   531 		{
       
   532 		if (++iFirstChar==iText.Length())
       
   533 			{
       
   534 			iFirstChar=0;
       
   535 			iDrawRect.iTl.iX=iDevice->SizeInPixels().iWidth;
       
   536 			}
       
   537 		else
       
   538 			iDrawRect.iTl.iX+=iCharWidth;
       
   539 		iCharWidth=iFont->CharWidthInPixels(iText[iFirstChar]);
       
   540 		}
       
   541 	}
       
   542 
       
   543 
       
   544 /*CScrollText*/
       
   545 
       
   546 TInt CScrollText::DrawText(TAny* aAnimation)
       
   547 	{
       
   548 	STATIC_CAST(CScrollText*,aAnimation)->ScrollText();
       
   549 	return(KErrNone);
       
   550 	}
       
   551 
       
   552 CScrollText* CScrollText::NewL(TInt aScreenNumber,TInt aId,CTWindowGroup& aParent,TInt aScrollJump,TBool aStart/*=EFalse*/)
       
   553 	{
       
   554 	CScrollText* self=new(ELeave) CScrollText(aId,aScrollJump,aScreenNumber);
       
   555 	CleanupStack::PushL(self);
       
   556 	self->ConstructL(aParent);
       
   557 	if (aStart)
       
   558 		self->StartL();
       
   559 	CleanupStack::Pop(self);
       
   560 	return self;
       
   561 	}
       
   562 
       
   563 CScrollText::~CScrollText()
       
   564 	{
       
   565 	delete iTimer;
       
   566 	delete iTextDraw;
       
   567 	iTextDraw=NULL;
       
   568 	delete iDrawer;
       
   569 	delete iWindow;
       
   570 	TheClient->Flush();
       
   571 	}
       
   572 
       
   573 void CScrollText::ConstructL(CTWindowGroup& aParent)
       
   574 	{
       
   575 	iWindow=new(ELeave) CTBlankWindow();
       
   576 	iWindow->ConstructL(aParent);
       
   577 	RWindowBase& win=*iWindow->BaseWin();
       
   578 	win.Activate();
       
   579 	iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,win,*this);
       
   580 	TheClient->Flush();
       
   581 	iTimer=CPeriodic::NewL(0);
       
   582 	}
       
   583 
       
   584 void CScrollText::StartL()
       
   585 	{
       
   586 	DoContinueL();
       
   587 	iDrawer->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   588 	if (!iTextDraw)
       
   589 		{
       
   590 		iTextDraw=CScrollingTextDrawer::NewL(iScreenNumber,iDrawer->ScreenDevice(),*iDrawer->Gc());
       
   591 		iTextDraw->SetScrollJump(iScrollJump);
       
   592 		}
       
   593 	}
       
   594 
       
   595 void CScrollText::ContinueL()
       
   596 	{
       
   597 	DoContinueL();
       
   598 	}
       
   599 
       
   600 void CScrollText::DoContinueL()
       
   601 	{
       
   602 	iTimer->Start(0,10000,TCallBack(CScrollText::DrawText,this));
       
   603 	
       
   604 		//0.01secs
       
   605 	iDrawer->StartL();
       
   606 	TRect bounding=iDrawer->DrawingRegion()->BoundingRect();
       
   607 #if defined(LOGGING)
       
   608 	_LIT(KBoundRect,"Continue Scroll Text  Rect=(%d,%d,%d,%d)");
       
   609 	LogMessageText.Zero();
       
   610 	LogMessageText.AppendFormat(KBoundRect,bounding.iTl.iX,bounding.iTl.iY,bounding.iBr.iX,bounding.iBr.iY);
       
   611 	TheClient->iWs.LogMessage(LogMessageText);
       
   612 	TheClient->Flush();
       
   613 #endif
       
   614 	TRect window=TRect(iWindow->BaseWin()->AbsPosition(),iWindow->Size());
       
   615 	if (!window.Contains(bounding.iTl) || !window.Contains(bounding.iBr-TPoint(1,1)))
       
   616 		AutoPanic(EAutoPanicTestFailed);
       
   617 	}
       
   618 
       
   619 void CScrollText::Stop()
       
   620 	{
       
   621 	iTimer->Cancel();
       
   622 	iDrawer->Cancel();
       
   623 	}
       
   624 
       
   625 void CScrollText::ScrollText()
       
   626 	{
       
   627 	iTextDraw->Scroll();
       
   628 	}
       
   629 
       
   630 void CScrollText::AbortNow(RDirectScreenAccess::TTerminationReasons aReason)
       
   631 	{
       
   632 	iTimer->Cancel();
       
   633 	if (!iCounting)
       
   634 		return;
       
   635 	if (iAbortCountDown>0)
       
   636 		--iAbortCountDown;
       
   637 	else
       
   638 		{
       
   639 		if (aReason==RDirectScreenAccess::ETerminateRegion)
       
   640 			{
       
   641 			User::After(1500000);		//1.5secs
       
   642 			iAbortCountDown=7;
       
   643 			}
       
   644 		}
       
   645 	}
       
   646 
       
   647 void CScrollText::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/)
       
   648 //This function is pure virtual and so cannot have an 'L' at the end of it's name
       
   649 	{
       
   650 	ContinueL();
       
   651 	}
       
   652 
       
   653 /*CWindowWithChild*/
       
   654 
       
   655 CWindowWithChild* CWindowWithChild::NewL(TInt aScreenNumber, CTWindowGroup& aParent,TBool aStart/*=EFalse*/)
       
   656 	{
       
   657 	CWindowWithChild* self=new(ELeave) CWindowWithChild(aScreenNumber);
       
   658 	CleanupStack::PushL(self);
       
   659 	self->ConstructL(aParent);
       
   660 	if (aStart)
       
   661 		self->StartL();
       
   662 	CleanupStack::Pop(self);
       
   663 	return self;
       
   664 	}
       
   665 
       
   666 CWindowWithChild::~CWindowWithChild()
       
   667 	{
       
   668 	delete iDrawer;
       
   669 	delete iChildWindow;
       
   670 	delete iWindow;
       
   671 	TheClient->Flush();
       
   672 	}
       
   673 
       
   674 void CWindowWithChild::ConstructL(CTWindowGroup& aParent)
       
   675 	{
       
   676 	iWindow=new(ELeave) CTBlankWindow();
       
   677 	iWindow->ConstructL(aParent);
       
   678 
       
   679 	iChildWindow = new(ELeave) CTWin();
       
   680 	iChildWindow->ConstructWin(*iWindow);
       
   681 	
       
   682 	iChildWindow->SetExt(TPoint(0,0), TSize(4,4));
       
   683 	RWindowBase& cwin=*iChildWindow->BaseWin();
       
   684 	cwin.Activate();
       
   685 
       
   686 	RWindowBase& win=*iWindow->BaseWin();
       
   687 	win.Activate();
       
   688 
       
   689 	iDrawer=CDirectScreenAccess::NewL(TheClient->iWs,*TheClient->iScreen,win,*this);
       
   690 	
       
   691 	TheClient->Flush();
       
   692 	}
       
   693 
       
   694 void CWindowWithChild::StartL()
       
   695 	{
       
   696 	DoContinueL();
       
   697 	}
       
   698 
       
   699 void CWindowWithChild::ContinueL()
       
   700 	{
       
   701 	DoContinueL();
       
   702 	}
       
   703 
       
   704 void CWindowWithChild::DoContinueL()
       
   705 	{
       
   706 	iDrawer->StartL();
       
   707 	iRunning = ETrue;
       
   708 	}
       
   709 
       
   710 void CWindowWithChild::Stop()
       
   711 	{
       
   712 	iDrawer->Cancel();
       
   713 	}
       
   714 
       
   715 void CWindowWithChild::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
       
   716 	{
       
   717 	iRunning = EFalse;
       
   718 	}
       
   719 
       
   720 void CWindowWithChild::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/)
       
   721 //This function is pure virtual and so cannot have an 'L' at the end of it's name
       
   722 	{
       
   723 	ContinueL();
       
   724 	}
       
   725 
       
   726 void CWindowWithChild::PerformCoverageCalls()
       
   727 	{
       
   728 	//add coverage to commands with no/partial coverage
       
   729 	RWindow& cwin=*iChildWindow->Win();	
       
   730 	TInt priority = 0;
       
   731 	
       
   732 	cwin.SetPointerCapturePriority(priority);
       
   733 	__ASSERT_ALWAYS(cwin.GetPointerCapturePriority()==priority, User::Invariant());
       
   734 	cwin.ClaimPointerGrab(EFalse);
       
   735 	cwin.EnableBackup(0);
       
   736 	__ASSERT_ALWAYS(cwin.PrevSibling()==0, User::Invariant());	
       
   737 	cwin.Invalidate(TRect(0, 0, 10, 10));
       
   738 	cwin.FadeBehind(ETrue);
       
   739 	TheClient->Flush();
       
   740 	// cover (empty) False condition in CWsWindow::SetFadeBehind
       
   741 	cwin.FadeBehind(ETrue);
       
   742 	TheClient->Flush();
       
   743 	}
       
   744 
       
   745 /*CWsBase*/
       
   746 
       
   747 void CWsBase::ConstructL(TInt aScreenNumber, TInt aHandle)
       
   748 	{
       
   749 	User::LeaveIfError(iWs.Connect());
       
   750 	iScrDev=new(ELeave) CWsScreenDevice(iWs);
       
   751 	User::LeaveIfError(iScrDev->Construct(aScreenNumber));
       
   752 	iGroup=RWindowGroup(iWs);
       
   753 	User::LeaveIfError(iGroup.Construct(aHandle,EFalse));
       
   754 	iGroup.SetOrdinalPosition(0,KMainTestBaseWindow);
       
   755 	}
       
   756 
       
   757 void CWsBase::CreateBlankWindowL(RBlankWindow& iWin,TInt aHandle)
       
   758 	{
       
   759 	iWin=RBlankWindow(iWs);
       
   760 	User::LeaveIfError(iWin.Construct(iGroup,aHandle));
       
   761 	}
       
   762 
       
   763 CWsBase::~CWsBase()
       
   764 	{
       
   765 	iGroup.Close();
       
   766 	delete iScrDev;
       
   767 	iWs.Close();
       
   768 	}
       
   769 
       
   770 
       
   771 /*CAnimating*/
       
   772 
       
   773 TInt CAnimating::StartLC(TAny* aScreenNumber)
       
   774 	{
       
   775 	CAnimating* self=new(ELeave) CAnimating();
       
   776 	CleanupStack::PushL(self);
       
   777 	self->ConstructL((TInt)aScreenNumber);
       
   778 	return KErrNone;
       
   779 	}
       
   780 
       
   781 void CAnimating::ConstructL(TInt aScreenNumber)
       
   782 	{
       
   783 	CWsBase::ConstructL(aScreenNumber,798);
       
   784 #if defined(LOGGING)
       
   785 	_LIT(KAnimate1,"Constructed CWsBase");
       
   786 	LogMessageText.Copy(KAnimate1);
       
   787 	iWs.LogMessage(LogMessageText);
       
   788 	iWs.Flush();
       
   789 #endif
       
   790 	iGroup.EnableReceiptOfFocus(EFalse);
       
   791 	CreateBlankWindowL(iWindow,799);
       
   792 	User::LeaveIfError(iWindow.SetRequiredDisplayMode(EGray16));
       
   793 	iWindow.Activate();
       
   794 #if defined(LOGGING)
       
   795 	_LIT(KAnimate2,"Set up Windows");
       
   796 	LogMessageText.Copy(KAnimate2);
       
   797 	iWs.LogMessage(LogMessageText);
       
   798 #endif
       
   799 	iWs.Flush();
       
   800 	TDisplayMode displayMode=CWsBase::iScrDev->DisplayMode();
       
   801 	if (displayMode<EGray16)
       
   802 		displayMode=EGray16;
       
   803 	iScrDev=CFbsScreenDevice::NewL(aScreenNumber,displayMode);
       
   804 	User::LeaveIfError(iScrDev->CreateContext(iGc));
       
   805 #if defined(LOGGING)
       
   806 	_LIT(KAnimate3,"Created Screen Device");
       
   807 	LogMessageText.Copy(KAnimate3);
       
   808 	iWs.LogMessage(LogMessageText);
       
   809 	iWs.Flush();
       
   810 #endif
       
   811 	iDirect=CDirectScreenAccessOld::NewL(iWs,*this);
       
   812 	iTimer=CPeriodic::NewL(0);
       
   813 	User::LeaveIfError(iControlSem.OpenGlobal(SemControl,EOwnerThread));		//Must be thread relative, since it won't get cleaned up when the thread is killed otherwise
       
   814 	User::LeaveIfError(iControlQueue.OpenGlobal(QueueControl,EOwnerThread));	//Must be thread relative, since it won't get cleaned up when the thread is killed otherwise
       
   815 	iSemCreated=ETrue;
       
   816 #if defined(LOGGING)
       
   817 	_LIT(KAnimate5,"Created Direct, Timer and Semaphore");
       
   818 	LogMessageText.Copy(KAnimate5);
       
   819 	iWs.LogMessage(LogMessageText);
       
   820 	iWs.Flush();
       
   821 #endif
       
   822 	iScrSize=iScrDev->SizeInPixels();
       
   823 	iGc->SetPenStyle(CGraphicsContext::ENullPen);
       
   824 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   825 	StartAnimatingL();
       
   826 #if defined(LOGGING)
       
   827 	_LIT(KAnimate6,"Started Animation");
       
   828 	LogMessageText.Copy(KAnimate6);
       
   829 	iWs.LogMessage(LogMessageText);
       
   830 	iWs.Flush();
       
   831 #endif
       
   832 	}
       
   833 
       
   834 CAnimating::~CAnimating()
       
   835 	//This function should never actually get run in practice
       
   836 	{
       
   837 	if (iSemCreated)
       
   838 		{
       
   839 		iControlSem.Close();
       
   840 		iControlQueue.Close();
       
   841 		}
       
   842 	if (iDrawingRegion)
       
   843 		iDrawingRegion->Destroy();
       
   844 	delete iTimer;
       
   845 	delete iDirect;
       
   846 	delete iGc;
       
   847 	delete iScrDev;
       
   848 	iWindow.Close();
       
   849 	}
       
   850 
       
   851 void CAnimating::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
       
   852 	{
       
   853 	iTimer->Cancel();
       
   854 	iControlSem.Signal();
       
   855 	TInt data = 2;
       
   856 	iControlQueue.Send(&data,sizeof(TInt));
       
   857 	User::After(10000000);		//10 secs
       
   858 	}
       
   859 
       
   860 TInt NextColor(TAny* aAnimation)
       
   861 	{
       
   862 	STATIC_CAST(CAnimating*,aAnimation)->DrawFrame();
       
   863 	return(KErrNone);
       
   864 	}
       
   865 
       
   866 void CAnimating::DrawFrame()
       
   867 	{
       
   868 	iColor=(iColor+3)%16;
       
   869 	iGc->SetBrushColor(TRgb::Gray16(iColor));
       
   870 	iGc->DrawRect(iScrSize);
       
   871 	iScrDev->Update();
       
   872 	if (iColor==2)
       
   873 		{
       
   874 		iControlSem.Signal();
       
   875 		TInt data = 1;
       
   876 		iControlQueue.Send(&data,sizeof(TInt));
       
   877 		}
       
   878 	}
       
   879 
       
   880 void CAnimating::StartAnimatingL()
       
   881 	{
       
   882 	iTimer->Start(0,150000,TCallBack(NextColor,this));		//0.15 secs
       
   883 
       
   884 	User::LeaveIfError(iDirect->Request(iDrawingRegion,iWindow));
       
   885 	iGc->SetClippingRegion(iDrawingRegion);
       
   886 	}
       
   887 
       
   888 
       
   889 /*CMoveWindow*/
       
   890 
       
   891 TInt CMoveWindow::StartLC(TAny* aScreenNumber)
       
   892 	{
       
   893 	CMoveWindow* self=new(ELeave) CMoveWindow();
       
   894 	CleanupStack::PushL(self);
       
   895 	self->ConstructL((TInt)aScreenNumber);
       
   896 	return KErrNone;
       
   897 	}
       
   898 
       
   899 TInt CMoveWindow::FlipChange(TAny* aMoveWin)
       
   900 	{
       
   901 	Cast(aMoveWin)->FlipChange();
       
   902 	return(KErrNone);
       
   903 	}
       
   904 
       
   905 TInt CMoveWindow::StateChange(TAny* aMoveWin)
       
   906 	{
       
   907 	Cast(aMoveWin)->StateChange();
       
   908 	return(KErrNone);
       
   909 	}
       
   910 
       
   911 CMoveWindow::~CMoveWindow()
       
   912 	{
       
   913 	delete iStateTimer;
       
   914 	delete iTimer;
       
   915 	iWindow.Close();
       
   916 	iBackUpWin.Close();
       
   917 	delete iGc;
       
   918 	}
       
   919 
       
   920 TInt MoveWin(TAny* aMoveWin)
       
   921 	{
       
   922 	STATIC_CAST(CMoveWindow*,aMoveWin)->MoveWindow();
       
   923 	return(KErrNone);
       
   924 	}
       
   925 
       
   926 void CMoveWindow::ConstructL(TInt aScreenNumber)
       
   927 	{
       
   928 	CWsBase::ConstructL(aScreenNumber,898);
       
   929 	iBounceArea=TRect(iScrDev->SizeInPixels());
       
   930 	iSize.iHeight=iBounceArea.iBr.iY/5;
       
   931 	iSize.iWidth=iBounceArea.iBr.iX/5;
       
   932 	iBounceArea.iTl.iX=iBounceArea.iBr.iX/6;
       
   933 	iBounceArea.iBr.iX=5*iBounceArea.iBr.iX/6;
       
   934 	iBounceArea.iTl.iY=iBounceArea.iBr.iY/4;
       
   935 	iBounceArea.iBr.iY=3*iBounceArea.iBr.iY/4;
       
   936 	iDelta=TSize(3,3);
       
   937 	iTl=iBounceArea.iTl;
       
   938 	CreateBlankWindowL(iWindow,899);
       
   939 	iWindow.SetExtent(iTl,iSize);
       
   940 	iWindow.SetShadowDisabled(ETrue);
       
   941 	iWindow.SetColor(TRgb::Gray4(2));
       
   942 	iWindow.Activate();
       
   943 	iBackUpWin=RBackedUpWindow(iWs);
       
   944 	User::LeaveIfError(iBackUpWin.Construct(iGroup,EGray4,698));
       
   945 	User::LeaveIfError(iBackUpWin.SetSizeErr(TSize(2,2)));
       
   946 	iGc=new(ELeave) CWindowGc(iScrDev);
       
   947 	User::LeaveIfError(iGc->Construct());
       
   948 	iDisplayMode=EGray4;
       
   949 	if (MoveInterval>TTimeIntervalMicroSeconds32(0))
       
   950 		CreateTimerL();
       
   951 	if (ModeInterval>TTimeIntervalMicroSeconds32(0))
       
   952 		{
       
   953 		iStateTimer=CPeriodic::NewL(0);
       
   954 		iStateTimer->Start(ModeInterval,ModeInterval,TCallBack(CMoveWindow::StateChange,this));
       
   955 		}
       
   956 	if (FlipInterval>TTimeIntervalMicroSeconds32(0))
       
   957 		{
       
   958 		iDevice=new(ELeave) CWsScreenDevice(iWs);
       
   959 		User::LeaveIfError(iDevice->Construct(aScreenNumber));
       
   960 		iNumOfModes=iDevice->NumScreenModes();
       
   961 		if (iNumOfModes>1)
       
   962 			{
       
   963 			iFlipTimer=CPeriodic::NewL(0);
       
   964 			iFlipTimer->Start(FlipInterval,FlipInterval,TCallBack(CMoveWindow::FlipChange,this));
       
   965 			}
       
   966 		}
       
   967 	iStateCountDown=0;
       
   968 	}
       
   969 
       
   970 void CMoveWindow::CreateTimerL()
       
   971 	{
       
   972 	iTimer=CPeriodic::NewL(0);
       
   973 	iTimer->Start(0,MoveInterval,TCallBack(MoveWin,this));
       
   974 
       
   975 	}
       
   976 
       
   977 void CMoveWindow::MoveWindow()
       
   978 	{
       
   979 	if (--iStateCountDown>=0)
       
   980 		{
       
   981 		if (iStateCountDown==2)
       
   982 			ToggleDisplayMode();
       
   983 		return;
       
   984 		}
       
   985 	TPoint iBr=iTl+iSize;
       
   986 	TSize iDeltaSize;
       
   987 	if ((iDelta.iHeight<0 && iTl.iY<=iBounceArea.iTl.iY) || (iDelta.iHeight>0 && iBr.iY>=iBounceArea.iBr.iY))
       
   988 		{
       
   989 		iDelta.iHeight=-iDelta.iHeight;
       
   990 		iDeltaSize.iWidth=2;
       
   991 		}
       
   992 	if ((iDelta.iWidth<0 && iTl.iX<=iBounceArea.iTl.iX) || (iDelta.iWidth>0 && iBr.iX>=iBounceArea.iBr.iX))
       
   993 		{
       
   994 		iDelta.iWidth=-iDelta.iWidth;
       
   995 		if (iDeltaSize.iWidth==0)
       
   996 			iDeltaSize.iHeight=2;
       
   997 		else
       
   998 			iDeltaSize.iWidth=0;
       
   999 		}
       
  1000 	iTl+=iDelta;
       
  1001 	iSize+=iDeltaSize;
       
  1002 	iWindow.SetExtent(iTl,iSize);
       
  1003 	iWs.Flush();
       
  1004 	}
       
  1005 
       
  1006 void CMoveWindow::StateChange()
       
  1007 	{
       
  1008 	if (ImmediateModeSwitch>1)
       
  1009 		{
       
  1010 		if (MoveInterval>TTimeIntervalMicroSeconds32(0) && iTimer==NULL)
       
  1011 			{
       
  1012 			TRAPD(err,CreateTimerL());
       
  1013 			if (err==KErrNone)
       
  1014 				ImmediateModeSwitch=ETrue;
       
  1015 			}
       
  1016 		}
       
  1017 	if (ImmediateModeSwitch || MoveInterval==TTimeIntervalMicroSeconds32(0))
       
  1018 		ToggleDisplayMode();
       
  1019 	else
       
  1020 		{
       
  1021 		if (iStateCountDown<-8)
       
  1022 			iStateCountDown=6;
       
  1023 		}
       
  1024 	}
       
  1025 
       
  1026 void CMoveWindow::ToggleDisplayMode()
       
  1027 	{
       
  1028 	if(iDisplayMode==EColor16MU)
       
  1029 		{
       
  1030 		return;		//Test probably doesn't work with mode EColor16MU
       
  1031 		}
       
  1032 	iDisplayMode=(iDisplayMode==EColor16M ? EGray4:EColor16M);
       
  1033 #if defined(LOGGING)
       
  1034 	TInt newMode=
       
  1035 #endif
       
  1036 				iWindow.SetRequiredDisplayMode(iDisplayMode);
       
  1037 	iGc->Activate(iBackUpWin);
       
  1038 	iBackUpWin.SetPosition(iDisplayMode==EColor16M ? TPoint(1,0):TPoint(0,1));
       
  1039 #if defined(LOGGING)
       
  1040 	TDisplayMode curentMode=iScrDev->DisplayMode();
       
  1041 	_LIT(KToggleMode,"Toggle Display Mode  Mode=%d Window=%d Actual=%d");
       
  1042 	LogMessageText.Zero();
       
  1043 	LogMessageText.AppendFormat(KToggleMode,(TInt&)iDisplayMode,newMode,(TInt&)curentMode);
       
  1044 	iWs.LogMessage(LogMessageText);
       
  1045 	//iWs.LogCommand(RWsSession::ELoggingStatusDump);
       
  1046 #endif
       
  1047 	iWs.Flush();
       
  1048 	iGc->Deactivate();
       
  1049 	}
       
  1050 
       
  1051 void CMoveWindow::FlipChange()
       
  1052 	{
       
  1053 	if (++iCurrentMode==2) //flip between modes 0 and 1
       
  1054 		iCurrentMode=0;
       
  1055 	iDevice->SetScreenMode(iCurrentMode);
       
  1056 	iWs.Flush();
       
  1057 	}
       
  1058 
       
  1059 //
       
  1060 // CBugFixColorAnimation
       
  1061 //
       
  1062 // This class is used for reproducing a defect found on 6.1: KAA-5J3BLW "Unnecessary Wserv's DSA abort".
       
  1063 // The problem was that a direct screen access client was getting an unnecessary abort notification
       
  1064 // when a new window (or window group) was created but not visible.
       
  1065 // This class will simulate the direct screen access client and it will check whether the first DSA abort
       
  1066 // is not caused by just creating a window.
       
  1067 
       
  1068 CBugFixColorAnimation* CBugFixColorAnimation::NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWindowGroup& aParent,TRect aExtent,TBool aStart)
       
  1069 	{
       
  1070 	CBugFixColorAnimation* self=new(ELeave) CBugFixColorAnimation(aScreenNumber, aId,aCallBack);
       
  1071 	CleanupStack::PushL(self);
       
  1072 	self->ConstructL(aParent,aExtent);
       
  1073 	if (aStart)
       
  1074 		{
       
  1075 		self->StartL();
       
  1076 		self->Started();
       
  1077 		}
       
  1078 	CleanupStack::Pop(self);
       
  1079 	return self;
       
  1080 	}
       
  1081 
       
  1082 CBugFixColorAnimation::CBugFixColorAnimation(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack)
       
  1083 	: CColorAnimation(aScreenNumber, aId, aCallBack)
       
  1084 	{
       
  1085 		iThreadParam.iScreenNumber = aScreenNumber;
       
  1086 	}
       
  1087 
       
  1088 CBugFixColorAnimation::~CBugFixColorAnimation()
       
  1089 	{
       
  1090 	iSem.Close();
       
  1091 	if(iThread)
       
  1092 		{
       
  1093 		TRequestStatus status;
       
  1094 		iThread->Logon(status);
       
  1095 		if (iThread->StillAlive())
       
  1096 			{
       
  1097  			iThread->Terminate(KErrNone);
       
  1098 			User::WaitForRequest(status);
       
  1099 			}
       
  1100 		delete iThread;
       
  1101 		}
       
  1102 	iTestFailed->Cancel();
       
  1103 	delete iTestFailed;
       
  1104 	}
       
  1105 
       
  1106 
       
  1107 LOCAL_D TInt TestFailed(TAny* aAnimation)
       
  1108 	{
       
  1109 	CBugFixColorAnimation* anim=reinterpret_cast<CBugFixColorAnimation*>(aAnimation);
       
  1110 	TRAP_IGNORE(
       
  1111 		anim->Stop();
       
  1112 		anim->CallBack().Fail();
       
  1113 		anim->FinishTest();
       
  1114 		);
       
  1115 	return KErrNone;
       
  1116 	}
       
  1117 
       
  1118 LOCAL_D TInt CreateNewWindowGroup(TAny* aParam)
       
  1119 	{
       
  1120 	TDirectThreadParam* param = (TDirectThreadParam*)aParam;
       
  1121 	TRect rect = param->iRect;
       
  1122 	TBool isInFront = param->iIsInFront;
       
  1123 	RWsSession ws;
       
  1124 	TInt error=ws.Connect();
       
  1125 
       
  1126 	CWsScreenDevice* screen = NULL;
       
  1127 	TRAP(error, screen = new (ELeave) CWsScreenDevice(ws));
       
  1128 	if (error!=KErrNone)
       
  1129 		{
       
  1130 		ws.Close();
       
  1131 		RThread::Rendezvous(error);
       
  1132 		return error;
       
  1133 		}
       
  1134 
       
  1135 	if ((error=screen->Construct(param->iScreenNumber))!=KErrNone)
       
  1136 		{
       
  1137 		delete screen;
       
  1138 		ws.Close();
       
  1139 		RThread::Rendezvous(error);
       
  1140 		return error;
       
  1141 		}
       
  1142 	RSemaphore sem;
       
  1143 	error = sem.OpenGlobal(KSem_DefectFix_KAA_5J3BLW_Name, EOwnerThread);
       
  1144 	if (error!=KErrNone)
       
  1145 	    {
       
  1146 	    ws.Close();
       
  1147 	    RThread::Rendezvous(error);
       
  1148 	    return error;
       
  1149 	    }
       
  1150 	
       
  1151 	RThread::Rendezvous(KErrNone);
       
  1152 
       
  1153 	// wait for the dsa to start before creating the new window group
       
  1154 	sem.Wait();
       
  1155 	sem.Close();
       
  1156 
       
  1157 	
       
  1158 	RWindowGroup group(ws);
       
  1159 	group.Construct(431,EFalse);
       
  1160 	if(isInFront)
       
  1161 		{
       
  1162 		group.SetOrdinalPosition(0,KAboveMainTestBaseWindow);
       
  1163 		}
       
  1164 	else
       
  1165 		{
       
  1166 		group.SetOrdinalPosition(2);
       
  1167 		}
       
  1168 	RWindow window(ws);
       
  1169 	error=window.Construct(group, 432);
       
  1170 	if (error==KErrNone)
       
  1171 		{
       
  1172 		window.SetExtentErr(rect.iTl, rect.Size());
       
  1173 		window.SetOrdinalPosition(0,0);
       
  1174 		ws.Flush();
       
  1175 		window.Activate();
       
  1176 		ws.Flush();
       
  1177 		if(!isInFront)
       
  1178 			{
       
  1179 			group.SetOrdinalPosition(-1);
       
  1180 			}
       
  1181 		ws.Flush();
       
  1182 		//Wait for wserv to render new window on top of the existing DSA region.
       
  1183 		ws.Finish(); 
       
  1184 		//Now the window has been rendered (and DSA should have been aborted).
       
  1185 		window.Close();
       
  1186 		}
       
  1187 
       
  1188 	group.Close();
       
  1189 	delete screen;
       
  1190 	ws.Close();
       
  1191 	return error;
       
  1192 	}
       
  1193 
       
  1194 void CBugFixColorAnimation::ConstructL(CTWindowGroup& aParent,TRect aExtent)
       
  1195 	{
       
  1196 	CColorAnimation::ConstructL(aParent, aExtent,KDrawingDsa);
       
  1197 	_LIT(ThreadName,"Create new Window");
       
  1198 	iAnimRect=aExtent;
       
  1199 	TInt error=iSem.CreateGlobal(KSem_DefectFix_KAA_5J3BLW_Name, 0);
       
  1200 	if (error==KErrNone)
       
  1201 	    {
       
  1202 	    iThreadParam.iRect = iAnimRect;
       
  1203 	    iThreadParam.iIsInFront = EFalse;
       
  1204 	    TThreadStartUp function=TThreadStartUp(CreateNewWindowGroup, &iThreadParam);
       
  1205 	    TRequestStatus status;
       
  1206 	    iThread=CProcess::NewThreadRendezvousL(ThreadName,&function, status);
       
  1207 	    User::WaitForRequest(status);
       
  1208 	    if (status != KErrNone)
       
  1209 	        {
       
  1210 	        RDebug::Printf("the request status is returned to be non KErrNone: %d", status.Int());
       
  1211 	        TestFailed(this);
       
  1212 	        }
       
  1213 		iTestFailed = CIdle::NewL(0);
       
  1214 	    }
       
  1215 	else
       
  1216 	    {
       
  1217 	    TestFailed(this);
       
  1218 	    }
       
  1219 	}
       
  1220 
       
  1221 void CBugFixColorAnimation::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
       
  1222 	{
       
  1223 	Stop();
       
  1224 	if (!iTestFailed->IsActive())
       
  1225 		{
       
  1226 		iTestFailed->Start(TCallBack(TestFailed,this));
       
  1227 		}
       
  1228 	}
       
  1229 
       
  1230 void CBugFixColorAnimation::Restart(RDirectScreenAccess::TTerminationReasons aReason)
       
  1231 	{
       
  1232 	AbortNow(aReason);
       
  1233 	}
       
  1234 
       
  1235 TInt CPanicDirect::DoTestOnNewSchedulerL(TInt aInt, TAny* aPtr)
       
  1236 	{	
       
  1237 	CActiveScheduler* activeScheduler=new(ELeave) CActiveScheduler;
       
  1238 	CActiveScheduler::Install(activeScheduler);
       
  1239 	CleanupStack::PushL(activeScheduler);
       
  1240 	DoTestNowL(aInt,aPtr);
       
  1241 	CleanupStack::PopAndDestroy(activeScheduler);
       
  1242 	return(EWsExitReasonBad);	//calls to this method currently all ignore the return code anyway.
       
  1243 	}
       
  1244 
       
  1245 TInt CPanicDirect::DoTestOnNewScheduler(TInt aInt, TAny* aPtr)
       
  1246 	{
       
  1247 	TInt rv=EWsExitReasonBad;	
       
  1248 	TRAP_IGNORE(rv=DoTestOnNewSchedulerL(aInt,aPtr));
       
  1249 	return(rv);	//calls to this method currently all ignore the return code anyway.
       
  1250  	}
       
  1251 
       
  1252 void CPanicDirect::DoTestNowL(TInt aInt, TAny* aPtr)
       
  1253 	{
       
  1254 	CPanicDirect* self=new(ELeave) CPanicDirect();
       
  1255 	CleanupStack::PushL(self);
       
  1256 	self->ConstructL((TInt)aPtr, aInt);
       
  1257 	self->TestL();
       
  1258 	CleanupStack::PopAndDestroy(self);
       
  1259 	}
       
  1260 
       
  1261 void CPanicDirect::ConstructL(TInt aScreenNumber, TInt aInt)
       
  1262 	{
       
  1263 	iScreenNumber = aScreenNumber;
       
  1264 
       
  1265 	User::LeaveIfError(iTimer.CreateLocal());
       
  1266 	User::LeaveIfError(iWs.Connect());
       
  1267 	iWsScrDev=new(ELeave) CWsScreenDevice(iWs);
       
  1268 	User::LeaveIfError(iWsScrDev->Construct(iScreenNumber));
       
  1269 
       
  1270 #if defined(LOGGING)
       
  1271 	_LIT(KPanicThead1,"PanicThread: Into ConstructL");
       
  1272 	LogMessageText.Copy(KPanicThead1);
       
  1273 	iWs.LogMessage(LogMessageText);
       
  1274 	iWs.Flush();
       
  1275 #endif
       
  1276 	iGroup=RWindowGroup(iWs);
       
  1277 	User::LeaveIfError(iGroup.Construct(2200+aInt,EFalse));
       
  1278 	iGroup.SetOrdinalPosition(0,KPanicTestOrdinalPriority);
       
  1279 	iBlankWin=RBlankWindow(iWs);
       
  1280 	User::LeaveIfError(iBlankWin.Construct(iGroup,2300+aInt));
       
  1281 	iBlankWin.Activate();
       
  1282 	iDirect=RDirectScreenAccess(iWs);
       
  1283 	User::LeaveIfError(iDirect.Construct());
       
  1284 	iDisplayMode=iWsScrDev->DisplayMode();
       
  1285 #if defined(LOGGING)
       
  1286 	_LIT(KPanicThead2,"PanicThread: Creating Screen Device, Mode=%d");
       
  1287 	LogMessageText.Format(KPanicThead2,iDisplayMode);
       
  1288 	iWs.LogMessage(LogMessageText);
       
  1289 	iWs.Flush();
       
  1290 #endif
       
  1291 	iScreenDevice=CFbsScreenDevice::NewL(aScreenNumber,iDisplayMode);
       
  1292 #if defined(LOGGING)
       
  1293 	_LIT(KPanicThead3,"PanicThread: Created Device");
       
  1294 	LogMessageText.Copy(KPanicThead3);
       
  1295 	iWs.LogMessage(LogMessageText);
       
  1296 	iWs.Flush();
       
  1297 #endif
       
  1298 	User::LeaveIfError(iScreenDevice->CreateContext(iGc));
       
  1299 #if defined(LOGGING)
       
  1300 	_LIT(KPanicThead4,"PanicThread: Created Context");
       
  1301 	LogMessageText.Copy(KPanicThead4);
       
  1302 	iWs.LogMessage(LogMessageText);
       
  1303 	iWs.Flush();
       
  1304 #endif
       
  1305 	iTextDraw=CScrollingTextDrawer::NewL(iScreenNumber,iScreenDevice,*iGc);
       
  1306 #if defined(LOGGING)
       
  1307 	_LIT(KPanicThead5,"PanicThread: Created ScrollDrawer");
       
  1308 	LogMessageText.Copy(KPanicThead5);
       
  1309 	iWs.LogMessage(LogMessageText);
       
  1310 	iWs.Flush();
       
  1311 #endif
       
  1312 	iTextDraw->SetScrollJump(4);
       
  1313 #if defined(LOGGING)
       
  1314 	_LIT(KCreatedDrawer,"PanicThread: CreatedDrawer");
       
  1315 	LogMessageText.Copy(KCreatedDrawer);
       
  1316 	iWs.LogMessage(LogMessageText);
       
  1317 	iWs.Flush();
       
  1318 #endif
       
  1319 	iTestNo=aInt;
       
  1320 	}
       
  1321 
       
  1322 CPanicDirect::~CPanicDirect()
       
  1323 	{
       
  1324 	iDirect.Close();
       
  1325 	delete iGc;
       
  1326 	delete iScreenDevice;
       
  1327 	delete iTextDraw;
       
  1328 	iBlankWin.Close();
       
  1329 	iGroup.Close();
       
  1330 	delete iWsScrDev;
       
  1331 	iWs.Close();
       
  1332 	if (iRegion)
       
  1333 		iRegion->Close();
       
  1334 	iTimer.Close();
       
  1335 	}
       
  1336 
       
  1337 void CPanicDirect::TestL()
       
  1338 	{
       
  1339 	if (iTestNo==2)
       
  1340 		{
       
  1341 		iDirect.Completed();
       
  1342 		return;
       
  1343 		}
       
  1344 	TInt err=iDirect.Request(iRegion,iDirectStatus,iBlankWin);
       
  1345 	if (err!=KErrNone || !iRegion)
       
  1346 		return;
       
  1347 	TRect screen(iScreenDevice->SizeInPixels());
       
  1348 	TRect bounding=iRegion->BoundingRect();
       
  1349 	if (!screen.Contains(bounding.iTl) || !screen.Contains(bounding.iBr-TPoint(1,1)))
       
  1350 		goto Cancel;
       
  1351 	iGc->SetClippingRegion(iRegion);
       
  1352 	iDrawingAllowed=ETrue;
       
  1353 	iTimer.After(iTimerStatus,50000);		//0.05secs
       
  1354 	FOREVER
       
  1355 		{
       
  1356 		User::WaitForRequest(iDirectStatus,iTimerStatus);
       
  1357 		if (iDirectStatus!=KRequestPending)
       
  1358 			iDrawingAllowed=EFalse;
       
  1359 		else if (iTimerStatus!=KRequestPending)
       
  1360 			{
       
  1361 			if (iDrawingAllowed)
       
  1362 				DoDrawingL();
       
  1363 			iTimer.After(iTimerStatus,50000);		//0.05secs
       
  1364 			}
       
  1365 		else
       
  1366 			{
       
  1367 	Cancel:
       
  1368 			iDirect.Cancel();
       
  1369 			return;
       
  1370 			}
       
  1371 		}
       
  1372 	}
       
  1373 
       
  1374 void CPanicDirect::DoDrawingL()
       
  1375 	{
       
  1376 	++iCount;
       
  1377 	iTextDraw->Scroll();
       
  1378 	if (iTestNo==1 && iCount==8)
       
  1379 		{
       
  1380 		iDirect.Request(iRegion,iDirectStatus,iBlankWin);
       
  1381 		return;
       
  1382 		}
       
  1383 	if (iTestNo==3 && iCount==12)
       
  1384 		{
       
  1385 		iDirect.Completed();
       
  1386 		iDirect.Completed();
       
  1387 		return;
       
  1388 		}
       
  1389 	if (iTestNo==4 && iCount==16)
       
  1390 		{
       
  1391 		iBlankWin.SetSize(TSize(20,25));
       
  1392 		delete iRegion;
       
  1393 		User::LeaveIfError(iDirect.Request(iRegion,iDirectStatus,iBlankWin));
       
  1394 		return;
       
  1395 		}
       
  1396 	if (iTestNo==5 && iCount==19)
       
  1397 		{
       
  1398 		iWs.Close();
       
  1399 		return;
       
  1400 		}
       
  1401 	}
       
  1402 
       
  1403 
       
  1404 /*CTDirect*/
       
  1405 
       
  1406 CTDirect::CTDirect(CTestStep* aStep):
       
  1407 	CTWsGraphicsBase(aStep)
       
  1408 	{
       
  1409 	iState = 0;
       
  1410 	iNextFrameFinished = ETrue;
       
  1411 	iPackagingFinished = EFalse;
       
  1412 	iTimerRunning = EFalse;
       
  1413 	}
       
  1414 
       
  1415 CTDirect::~CTDirect()
       
  1416 	{
       
  1417 	DeleteMoveWindow();
       
  1418 	DeleteScroll();
       
  1419 			
       
  1420 	delete iAnim;
       
  1421 	TheClient->WaitForRedrawsToFinish();
       
  1422 	delete iCallBackWin;
       
  1423 	// put focus back to current screen as this test changed the focus screen to primary screen
       
  1424 	TheClient->iWs.SetFocusScreen(iTest->iScreenNumber);
       
  1425 	}
       
  1426 
       
  1427 void CTDirect::ConstructL()
       
  1428 	{
       
  1429 	_LIT(KCTDirectConstructL,"AUTO  Construct Direct Test");
       
  1430 	LOG_MESSAGE(KCTDirectConstructL);
       
  1431 	FullScreenModeSize=TheClient->iScreen->SizeInPixels();
       
  1432 	iIsScalingSupported=CheckScalingSupportedOrNot();
       
  1433 	iNumOfCallBack=0;
       
  1434 	iCallBackWin=new(ELeave) CTBlankWindow;
       
  1435 	iCallBackWin->ConstructL(*TheClient->iGroup);
       
  1436 	User::LeaveIfError(iCallBackWin->BaseWin()->SetRequiredDisplayMode(EColor256));
       
  1437 	iCallBackWin->SetExt(TPoint(),TheClient->iScreen->SizeInPixels());
       
  1438 	iCallBackWin->SetVisible(EFalse);
       
  1439 	iCallBackWin->Activate();
       
  1440 	// the following line makes sure that a console object hidden outside of
       
  1441 	// screens range doesn't affect test results being on top of tested objects
       
  1442 	TheClient->iGroup->GroupWin()->SetOrdinalPosition(0, KMainTestBaseWindow);
       
  1443 	}
       
  1444 
       
  1445 void CTDirect::ConstrucBlankWindowL()
       
  1446 	{
       
  1447 	delete iWin;
       
  1448 	iWin=new(ELeave) CTBlankWindow;
       
  1449 	iWin->ConstructL(*TheClient->iGroup);
       
  1450 	iWin->BaseWin()->SetShadowDisabled(ETrue);
       
  1451 	iWin->BaseWin()->Activate();
       
  1452 	TheClient->Flush();
       
  1453 	}
       
  1454 
       
  1455 void CTDirect::InitialiseAnimationL()
       
  1456 	{
       
  1457 	ConstrucBlankWindowL();
       
  1458 	TInt colors,greys;
       
  1459 	TDisplayMode dispMode=TheClient->iWs.GetDefModeMaxNumColors(colors,greys);
       
  1460 	iScrDev=CFbsScreenDevice::NewL(iTest->iScreenNumber,dispMode);
       
  1461 	User::LeaveIfError(iScrDev->CreateContext(iGc));
       
  1462 	INFO_PRINTF1(_L(" Constructed Screen Device"));
       
  1463 	iScrSize=iScrDev->SizeInPixels();
       
  1464 	TFontSpec fontSpec(FontName,iScrSize.iHeight);
       
  1465 	fontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
       
  1466 	User::LeaveIfError(iScrDev->GetNearestFontToDesignHeightInPixels(iFont,fontSpec));
       
  1467 	iGc->UseFont(iFont);
       
  1468 	iFlags|=eFontSet;
       
  1469 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  1470 	TInt fontHeight=iFont->HeightInPixels();
       
  1471 	iDrawRect.iTl.iY=(iScrSize.iHeight-fontHeight)/2;
       
  1472 	iDrawRect.SetHeight(fontHeight);
       
  1473 	iDrawHeight=iFont->AscentInPixels();
       
  1474 	TSize winSize(25,20);
       
  1475 	iWin2=new(ELeave) CTBlankWindow;
       
  1476 	iWin2->ConstructL(*TheClient->iGroup);
       
  1477 	iWin2->SetExt(TPoint((iScrSize.iWidth-winSize.iWidth)/2,(iScrSize.iHeight-winSize.iHeight)/2),winSize);
       
  1478 	iWin2->SetColor(TRgb::Gray4(2));
       
  1479 	iWin2->BaseWin()->Activate();
       
  1480 	INFO_PRINTF1(_L(" Setup Window"));
       
  1481 	iScrDev->Update();
       
  1482 	TheClient->iWs.Finish();
       
  1483 	
       
  1484 	User::LeaveIfError(iControlSem.CreateGlobal(SemControl,0,KOwnerType));
       
  1485 	User::LeaveIfError(iControlQueue.CreateGlobal(QueueControl,1,sizeof(TInt),KOwnerType));
       
  1486 
       
  1487 	iFlags|=eDirectControlSem;
       
  1488 	User::LeaveIfError(iWinSem.CreateGlobal(SemNextOp,0,KOwnerType));
       
  1489 	iFlags|=eDirectWindowSem;
       
  1490 	iProcess=CProcess::NewTL(CProcess::eProcessDirectTest,iTest->iScreenNumber,&iThreadStatus);
       
  1491 	INFO_PRINTF1(_L(" Constructed Semaphores & Thread"));
       
  1492 	iControlSem.Wait();	
       
  1493 	
       
  1494 	iTimer=CPeriodic::NewL(iTest->EAutoTestPriority);
       
  1495 	iRestart=CIdle::NewL(iTest->EAutoTestPriority+5);
       
  1496 	iDirect=CDirectScreenAccessOld::NewL(TheClient->iWs,*this);
       
  1497 	}
       
  1498 
       
  1499 void CTDirect::DestroyAnimation()
       
  1500 	{
       
  1501 	ResetScreenSizeMode();
       
  1502 	if(iProcess && iProcess->StillAlive())
       
  1503 		{
       
  1504 		if (iFlags&eDirectControlSem)
       
  1505 			{
       
  1506 			iControlSem.Signal();
       
  1507 			TInt data = 3;
       
  1508 			iControlQueue.Send(&data,sizeof(TInt));
       
  1509 			}
       
  1510 		if (iFlags&eDirectWindowSem)
       
  1511 			iWinSem.Signal();
       
  1512 		}
       
  1513 	
       
  1514 	delete iTimer;
       
  1515 	iTimer=NULL;
       
  1516 	delete iRestart;
       
  1517 	iRestart=NULL;
       
  1518 	delete iDirect;
       
  1519 	iDirect=NULL;
       
  1520 	delete iChangeScreenModeTimer;
       
  1521 	iChangeScreenModeTimer=NULL;
       
  1522 	delete iScreenModeTimer;
       
  1523 	iScreenModeTimer=NULL;
       
  1524 	
       
  1525 	if (iFlags&eFontSet)
       
  1526 		{
       
  1527 		iGc->DiscardFont();
       
  1528 		iScrDev->ReleaseFont(iFont);
       
  1529 		}
       
  1530 	delete iGc;
       
  1531 	if (iDrawingRegion)
       
  1532 		iDrawingRegion->Destroy();
       
  1533 	delete iScrDev;
       
  1534 	delete iWin;
       
  1535 	delete iWin2;
       
  1536 	if (iProcess)
       
  1537 		{
       
  1538 		User::WaitForRequest(iThreadStatus);
       
  1539 		delete iProcess;
       
  1540 		iProcess = NULL;
       
  1541 		}
       
  1542 	if (iFlags&eDirectControlSem)
       
  1543 		{
       
  1544 		iControlSem.Close();
       
  1545 		iControlQueue.Close();
       
  1546 		}
       
  1547 	if (iFlags&eDirectWindowSem)
       
  1548 		iWinSem.Close();
       
  1549 	}
       
  1550 
       
  1551 void CTDirect::ResetScreenSizeMode()
       
  1552 	{
       
  1553 	if (iModeBackup!=ESizeEnforcementNone)
       
  1554 		{
       
  1555 		TheClient->iScreen->SetScreenModeEnforcement(ESizeEnforcementNone);
       
  1556 		iModeBackup=ESizeEnforcementNone;
       
  1557 		}
       
  1558 	TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationNormal);
       
  1559 	TheClient->iScreen->SetScreenMode(0);
       
  1560 	TPixelsAndRotation pixelsAndRotation;
       
  1561 	TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation);
       
  1562 	TheClient->iScreen->SetScreenSizeAndRotation(pixelsAndRotation);
       
  1563 	User::After(350000);		//0.35secs
       
  1564 	}
       
  1565 
       
  1566 void CTDirect::ScanTypeFacesL()
       
  1567 	{
       
  1568 	CFbsScreenDevice* scrdev=CFbsScreenDevice::NewL(iTest->iScreenNumber,EGray4);
       
  1569 	TTypefaceSupport typeFace;
       
  1570 	TInt numFaces=scrdev->NumTypefaces();
       
  1571 	TInt ii;
       
  1572 	for (ii=0;ii<numFaces;++ii)
       
  1573 		{
       
  1574 		scrdev->TypefaceSupport(typeFace,ii);
       
  1575 		}
       
  1576 	delete scrdev;
       
  1577 	}
       
  1578 
       
  1579 TInt RestartAnimation(TAny* aTest)
       
  1580 	{
       
  1581 	STATIC_CAST(CTDirect*,aTest)->Restart();
       
  1582 	return(KErrNone);
       
  1583 	}
       
  1584 
       
  1585 TInt NextFrame(TAny* aTest)
       
  1586 	{
       
  1587 	STATIC_CAST(CTDirect*,aTest)->DrawFrame();
       
  1588 	return(KErrNone);
       
  1589 	}
       
  1590 
       
  1591 void CTDirect::AbortNow(RDirectScreenAccess::TTerminationReasons aReason)
       
  1592 	{
       
  1593 	TEST(aReason==RDirectScreenAccess::ETerminateRegion);
       
  1594 	
       
  1595 	if (iDelay)
       
  1596 		User::After(2000000);		//2 secs
       
  1597 	if (iCancelNext)
       
  1598 		{
       
  1599 		iFrameNo=eDirectNumFrames;
       
  1600 		iTimer->Cancel();	
       
  1601 		iDirect->Cancel();
       
  1602 		TheClient->Flush();
       
  1603 		iNextFrameFinished = ETrue;
       
  1604 		iState++;
       
  1605 		return;
       
  1606 		}
       
  1607 	iRestart->Start(TCallBack(RestartAnimation,this));
       
  1608 	}
       
  1609 
       
  1610 TBool CTDirect::Restart()
       
  1611 	{
       
  1612 	StartDirect();
       
  1613 	return ETrue;
       
  1614 	}
       
  1615 
       
  1616 #pragma warning( disable : 4244 )	//conversion from 'int' to 'unsigned short', possible loss of data
       
  1617 TBool CTDirect::DrawFrame()
       
  1618 	{
       
  1619 	if (iFrameNo==eDirectNumFrames)
       
  1620 		{
       
  1621 		iState++;
       
  1622 		iTimer->Cancel();
       
  1623 		if (iFrameNo==eDirectNumFrames)
       
  1624 			iDirect->Cancel();
       
  1625 		iNextFrameFinished = ETrue;
       
  1626 		return EFalse;
       
  1627 		}
       
  1628 	_LIT(Text,"A0");
       
  1629 	TBuf<2> iString(Text);		//_LIT(Text,"ABCabc123");
       
  1630 	iString[0]+=iFrameNo;
       
  1631 	iString[1]+=iFrameNo;
       
  1632 	TInt textWidth=iFont->TextWidthInPixels(iString);
       
  1633 	TInt maxTextWidth=Max(textWidth,iLastTextWidth);
       
  1634 	iLastTextWidth=textWidth;
       
  1635 	if (iLastMaxTextWidth!=maxTextWidth)
       
  1636 		{
       
  1637 		iLastMaxTextWidth=maxTextWidth;
       
  1638 		iDrawRect.iTl.iX=(iScrSize.iWidth-iLastMaxTextWidth)/2;
       
  1639 		iDrawRect.SetWidth(iLastMaxTextWidth);
       
  1640 		}
       
  1641 	TInt colorOffset=iFrameNo%2;
       
  1642 	iGc->SetPenColor(TRgb::Gray4(colorOffset));
       
  1643 	iGc->DrawText(iString,iDrawRect,iDrawHeight,CGraphicsContext::ECenter);
       
  1644 	iGc->SetPenColor(TRgb::Gray4(1+colorOffset));
       
  1645 	iGc->DrawLine(TPoint(),iScrSize.AsPoint());
       
  1646 	iGc->DrawLine(TPoint(iScrSize.iWidth,0),TPoint(0,iScrSize.iHeight));
       
  1647 	iGc->DrawLine(TPoint(iScrSize.iWidth/2,0),TPoint(iScrSize.iWidth/2,iScrSize.iHeight));
       
  1648 	iGc->DrawLine(TPoint(0,iScrSize.iHeight/2),TPoint(iScrSize.iWidth,iScrSize.iHeight/2));
       
  1649 	iScrDev->Update();
       
  1650 	++iFrameNo;
       
  1651 	if (iFrameNo==iFrameToSignalAfter)
       
  1652 		SignalWindow();
       
  1653 	return ETrue;
       
  1654 	}
       
  1655 #pragma warning( default : 4244 )
       
  1656 
       
  1657 void CTDirect::SignalWindow()
       
  1658 	{
       
  1659 	switch(iState)
       
  1660 		{
       
  1661 	case 0:
       
  1662 		switch(iFrameNo)
       
  1663 			{
       
  1664 		case 0:
       
  1665 			iFrameToSignalAfter=0;
       
  1666 			}
       
  1667 		return;
       
  1668 	case 1:
       
  1669 	case 3:
       
  1670 		switch(iFrameNo)
       
  1671 			{
       
  1672 		case 0:
       
  1673 			iFrameToSignalAfter=3;
       
  1674 			iDelay=(iState==3);
       
  1675 			return;
       
  1676 		case 3:
       
  1677 			WinExt.SetSize(TSize(iScrSize.iWidth/2-5,iScrSize.iHeight/2+30));
       
  1678 			iFrameToSignalAfter=5;
       
  1679 			break;
       
  1680 		case 5:
       
  1681 			iFrameToSignalAfter=7;
       
  1682 			break;
       
  1683 		case 7:
       
  1684 			WinExt.SetSize(TSize(iScrSize.iWidth/2+30,iScrSize.iHeight/2-5));
       
  1685 			WinCol=1;
       
  1686 			iFrameToSignalAfter=8;
       
  1687 			break;
       
  1688 		case 8:
       
  1689 			iFrameToSignalAfter=0;
       
  1690 			iDelay=EFalse;
       
  1691 			break;
       
  1692 			}
       
  1693 		break;
       
  1694 	case 2:
       
  1695 		switch(iFrameNo)
       
  1696 			{
       
  1697 		case 0:
       
  1698 			iFrameToSignalAfter=2;
       
  1699 			return;
       
  1700 		case 2:
       
  1701 			WinExt.SetRect(TPoint(iScrSize.iWidth/2-15,iScrSize.iHeight/2-20),TSize(iScrSize.iWidth/3,iScrSize.iHeight/3));
       
  1702 			WinCol=2;
       
  1703 			iFrameToSignalAfter=5;
       
  1704 			break;
       
  1705 		case 5:
       
  1706 			iFrameToSignalAfter=6;
       
  1707 			break;
       
  1708 		case 6:
       
  1709 			WinExt.SetRect(TPoint(iScrSize.iWidth/2-50,iScrSize.iHeight/3),TSize(iScrSize.iWidth/4,iScrSize.iHeight/3));
       
  1710 			WinCol=3;
       
  1711 			iFrameToSignalAfter=8;
       
  1712 			break;
       
  1713 		case 8:
       
  1714 			iFrameToSignalAfter=0;
       
  1715 			break;
       
  1716 			}
       
  1717 		break;
       
  1718 	case 4:
       
  1719 		switch(iFrameNo)
       
  1720 			{
       
  1721 		case 0:
       
  1722 			iFrameToSignalAfter=3;
       
  1723 			return;
       
  1724 		case 3:
       
  1725 			iFrameToSignalAfter=6;
       
  1726 			iWin2->SetVisible(EFalse);
       
  1727 			TheClient->Flush();
       
  1728 			return;
       
  1729 		case 6:
       
  1730 			iFrameToSignalAfter=0;
       
  1731 			iWin2->SetVisible(ETrue);
       
  1732 			TheClient->Flush();
       
  1733 			return;
       
  1734 			}
       
  1735 		break;
       
  1736 	case 5:
       
  1737 		switch(iFrameNo)
       
  1738 			{
       
  1739 		case 0:
       
  1740 			iFrameToSignalAfter=6;
       
  1741 			return;
       
  1742 		case 6:
       
  1743 			iFrameToSignalAfter=0;
       
  1744 			WinExt.SetRect(10,10,20,20);
       
  1745 			iCancelNext=ETrue;
       
  1746 			break;
       
  1747 			}
       
  1748 		break;
       
  1749 	case 6:
       
  1750 		switch(iFrameNo)
       
  1751 			{
       
  1752 		case 0:
       
  1753 			iFrameToSignalAfter=7;
       
  1754 			iCancelNext=EFalse;
       
  1755 			return;
       
  1756 		case 7:
       
  1757 			iFrameToSignalAfter=0;
       
  1758 			delete iWin;
       
  1759 			TheClient->Flush();
       
  1760 			iWin=NULL;
       
  1761 			iWindowDead=ETrue;
       
  1762 			return;
       
  1763 			}
       
  1764 		break;
       
  1765 		}
       
  1766 #if defined(LOGGING)
       
  1767 	_LIT(KSignal,"Signaling Move Window");
       
  1768 	LogMessageText.Copy(KSignal);
       
  1769 	TheClient->iWs.LogMessage(LogMessageText);
       
  1770 	TheClient->Flush();
       
  1771 #endif
       
  1772 	iWinSem.Signal();
       
  1773 	}
       
  1774 
       
  1775 void CTDirect::StartDirect()
       
  1776 	{
       
  1777 	if (iWin==NULL)
       
  1778 		{
       
  1779 		TEST(iWindowDead);
       
  1780 		if (!iWindowDead)
       
  1781 			INFO_PRINTF3(_L("iWindowDead - Expected: %d, Actual: %d"), ETrue, iWindowDead);		
       
  1782 	
       
  1783 		iFrameNo=eDirectNumFrames;
       
  1784 		return;
       
  1785 		}
       
  1786 	TEST(!iWindowDead);
       
  1787 	if (iWindowDead)
       
  1788 		INFO_PRINTF3(_L("iWindowDead - Expected: %d, Actual: %d"), EFalse, iWindowDead);		
       
  1789 
       
  1790 	if (iDrawingRegion)
       
  1791 		iDrawingRegion->Destroy();
       
  1792 	TInt retVal = iDirect->Request(iDrawingRegion,*iWin->BaseWin());
       
  1793 	TEST(retVal==KErrNone);
       
  1794 	if (retVal!=KErrNone)
       
  1795 		INFO_PRINTF3(_L("iDirect->Request(iDrawingRegion,*iWin->BaseWin()) return value - Expected: %d, Actual: %d"), KErrNone, retVal);		
       
  1796 
       
  1797 	iGc->SetClippingRegion(iDrawingRegion);
       
  1798 	}
       
  1799 
       
  1800 void CTDirect::LogLeave(TInt aErr)
       
  1801 	{
       
  1802 	iTest->LogLeave(aErr);
       
  1803 	}
       
  1804 
       
  1805 void CTDirect::Fail()
       
  1806 	{
       
  1807 	TEST(EFalse);
       
  1808 	}
       
  1809 
       
  1810 void CTDirect::Finished(TInt aId)
       
  1811 	{
       
  1812 	//aId refers to the animation, it is not the test number
       
  1813 	_LIT(KCTDirectFinished,"Destroying animation number %d");
       
  1814 	LOG_MESSAGE2(KCTDirectFinished,aId);
       
  1815 	switch (aId)
       
  1816 		{
       
  1817 	case 10:
       
  1818 	case 11:
       
  1819 		ResetScreenSizeMode();
       
  1820 	case 9:
       
  1821 		iPackagingFinished = ETrue;
       
  1822 	case 8:
       
  1823 		DeleteMoveWindow();
       
  1824 		//iPackagingFinished = ETrue;
       
  1825 		if (iScroll)
       
  1826 			{
       
  1827 			DeleteScroll();
       
  1828 		#if defined(LOGGING)
       
  1829 			_LIT(KDeleteScroll,"Deleting Scroll Text  Id=%d  TimerActive=%d");
       
  1830 			LogMessageText.Zero();
       
  1831 			LogMessageText.AppendFormat(KDeleteScroll,aId,iAnim->IsTimerActive());
       
  1832 			TheClient->iWs.LogMessage(LogMessageText);
       
  1833 			TheClient->Flush();
       
  1834 		#endif
       
  1835 			}
       
  1836 		if (aId==8  && iAnim->IsTimerActive())
       
  1837 			return;
       
  1838 	case 1:
       
  1839 	case 12:
       
  1840 	case 25:	//case DSA using Region tracking Only (abort signal expceted)
       
  1841 	case 26:	//case DSA using Region tracking Only (abort signal not expceted)
       
  1842 		{
       
  1843 		iPackagingFinished = ETrue;
       
  1844 		delete iAnim;
       
  1845 		iAnim=NULL;
       
  1846 CHECKHANDLES:
       
  1847 		TInt numProcessHandles;
       
  1848 		TInt numThreadHandles;
       
  1849 		RThread().HandleCount(numProcessHandles,numThreadHandles);
       
  1850 		TEST(Abs(numThreadHandles-iNumThreadHandles)<2);
       
  1851 		if (Abs(numThreadHandles-iNumThreadHandles)>=2)
       
  1852 			INFO_PRINTF3(_L("Abs(numThreadHandles-iNumThreadHandles)<2 - Expected: %d or less, Actual: %d"), 2, Abs(numThreadHandles-iNumThreadHandles));		
       
  1853 		}
       
  1854 		break;
       
  1855 	case 16:
       
  1856 	case 15:	
       
  1857 		{		
       
  1858 		// Stop the animation and delete it, but make sure that you don't increment iState and call Rquest()
       
  1859 		// until this is the second call i.e. one of aId = 15 or aId = 16 has already been finished.
       
  1860 		TInt index = aId-15;
       
  1861 		iAnims[index]->Stop();
       
  1862 		delete iAnims[index];
       
  1863 		iAnims[index]=NULL;
       
  1864 		// This test creates two animations iAnims[0] and iAnims[1].
       
  1865 		// Use (index ^ 1 ) = Toggle the Index, to get the index of other animation.
       
  1866 		// If iAnims [ index ^ 1] is NULL then this is the second Call and test is finished.
       
  1867 		if (iAnims[index ^ 1] != NULL)
       
  1868 			{
       
  1869 			return;
       
  1870 			}
       
  1871 		iPackagingFinished = ETrue;
       
  1872 		goto CHECKHANDLES;
       
  1873 		}
       
  1874 	case 13:
       
  1875 		{
       
  1876 		iPackagingFinished = ETrue;
       
  1877 		delete iBlankTopClientWin1;
       
  1878 	//	delete iBlankTopClientWin2;
       
  1879 		TInt jj;
       
  1880 		for (jj=0;jj<4;++jj)
       
  1881 			iAnims[jj]->Stop();
       
  1882 		for (jj=0;jj<4;++jj)
       
  1883 			delete iAnims[jj];
       
  1884 		break;
       
  1885 		}
       
  1886 	case 14:
       
  1887 		{
       
  1888 		iPackagingFinished = ETrue;
       
  1889 		iAnims[0]->Stop();
       
  1890 		delete iAnims[0];
       
  1891 		if (iNumOfModes==iCurrentMode)
       
  1892 			{
       
  1893 			ResetScreenSizeMode();
       
  1894 			iCallBackWin->SetVisible(EFalse);
       
  1895 			break;
       
  1896 			}
       
  1897 		break;
       
  1898 		}
       
  1899 	case 18:
       
  1900 	case 17:
       
  1901 		{
       
  1902 		// Stop the animation and delete it, but make sure that you don't increment iState and call Rquest()
       
  1903 		// until this is the second call i.e. one of aId = 17 or aId = 18 has already been finished.
       
  1904 		TInt ii = 0;
       
  1905 		TBool finished = ETrue;
       
  1906 		if (aId == 17)
       
  1907 			{
       
  1908 			iAnims[0]->Stop();
       
  1909 			delete iAnims[0];
       
  1910 			iAnims[0] = NULL;
       
  1911 			for (ii=1;ii<=iNumAnimation;++ii)
       
  1912 				{
       
  1913 				 if (iAnims[ii])
       
  1914 				 	{
       
  1915 				 	finished = EFalse;
       
  1916 				 	break;
       
  1917 				 	}
       
  1918 				}
       
  1919 			}
       
  1920 		else // aId == 18
       
  1921 			{
       
  1922 			for (ii=1;ii<=iNumAnimation;++ii)
       
  1923 				{
       
  1924 				iAnims[ii]->Stop();
       
  1925 				delete iAnims[ii];
       
  1926 				iAnims[ii] = NULL;
       
  1927 				}
       
  1928 			if (iAnims[0])
       
  1929 			 	{
       
  1930 			 	finished = EFalse;
       
  1931 			 	}	
       
  1932 			}
       
  1933 		if (!finished)
       
  1934 			{
       
  1935 			return;
       
  1936 			}
       
  1937 		iPackagingFinished = ETrue;
       
  1938 		break;
       
  1939 		}
       
  1940 	case 19:
       
  1941 		{
       
  1942 		iPackagingFinished = ETrue;
       
  1943 		iAnims[0]->Stop();
       
  1944 		delete iAnims[0];
       
  1945 		break;
       
  1946 		}
       
  1947 	case 21:
       
  1948 	case 20:
       
  1949 		{	
       
  1950 		// Stop the animation and delete it, but make sure that you don't increment iState and call Rquest()
       
  1951 		// until this is the second call i.e. one of aId = 20 or aId = 21 has already been finished.
       
  1952 		TInt index = aId-20;
       
  1953 		iAnims[index]->Stop();
       
  1954 		delete iAnims[index];
       
  1955 		iAnims[index]=NULL;
       
  1956 		// This test creates two animations iAnims[0] and iAnims[1].
       
  1957 		// Use (index ^ 1 ) = Toggle the Index, to get the index of other animation.
       
  1958 		// If iAnims [ index ^ 1] is NULL then this is the second Call and test is finished.
       
  1959 		if (iAnims[index ^ 1] != NULL)
       
  1960 			{
       
  1961 			return;
       
  1962 			}
       
  1963 		DeleteMoveWindow();
       
  1964 		iPackagingFinished = ETrue;
       
  1965 		goto CHECKHANDLES;
       
  1966 		}		//unreachable line, no need for break
       
  1967 	case 24:
       
  1968 		iPackagingFinished = ETrue;
       
  1969 		iAnim->Stop();
       
  1970 		delete iAnim;
       
  1971 		iAnim=NULL;
       
  1972 		//don't want to increase state, so decrement, since it is incremented below
       
  1973 		//as part of processing normal completions.  This is to reenter the test
       
  1974 		//to call Fail() if required
       
  1975 		iState--;
       
  1976 		break;
       
  1977 	
       
  1978 	case 27:
       
  1979 	case 28:
       
  1980 	case 29:
       
  1981 	case 30:
       
  1982 	case 31:
       
  1983 	case 32:
       
  1984 		iAnims[aId-27]->Stop();
       
  1985 		delete iAnims[aId-27];
       
  1986 		iAnims[aId-27] = NULL;
       
  1987 		if(aId != 32)
       
  1988 			{
       
  1989 			return;
       
  1990 			}
       
  1991 		DeleteMoveWindow();
       
  1992 		iPackagingFinished = ETrue;
       
  1993 		break;
       
  1994 	default:
       
  1995 		iPackagingFinished = ETrue;
       
  1996 		TInt ii;
       
  1997 		for (ii=0;ii<6;++ii)
       
  1998 			iAnims[ii]->Stop();
       
  1999 		for (ii=0;ii<6;++ii)
       
  2000 			delete iAnims[ii];
       
  2001 		DeleteMoveWindow();
       
  2002 		break;
       
  2003 		}
       
  2004 #if defined(LOGGING)
       
  2005 	_LIT(KRequest,"Signal Start NextTest  Id=%d, State=%d(+1)");
       
  2006 	LogMessageText.Zero();
       
  2007 	LogMessageText.AppendFormat(KRequest,aId,iState);
       
  2008 	TheClient->iWs.LogMessage(LogMessageText);
       
  2009 	TheClient->Flush();
       
  2010 #endif
       
  2011 	iState++;
       
  2012 	}
       
  2013 
       
  2014 void CTDirect::DeleteMoveWindow()
       
  2015 	{
       
  2016 	if (iMoveWin)
       
  2017 		{
       
  2018 		TRequestStatus status;
       
  2019 		iMoveWin->Logon(status);
       
  2020 		if (iMoveWin->StillAlive())
       
  2021 			{
       
  2022 			iMoveWin->Terminate(KErrNone);
       
  2023 			User::WaitForRequest(status);
       
  2024 			}
       
  2025 		delete iMoveWin;
       
  2026 		iMoveWin=NULL;
       
  2027 		}
       
  2028 	}
       
  2029 
       
  2030 void CTDirect::DeleteScroll()
       
  2031 	{
       
  2032 	if (iScroll)
       
  2033 		{
       
  2034 		TheClient->iScreen->SetScreenMode(0);
       
  2035 		iScroll->Stop();
       
  2036 		delete iScroll;
       
  2037 		iScroll=NULL;
       
  2038 		}
       
  2039 	}
       
  2040 
       
  2041 TDisplayMode CTDirect::DisplayMode(TInt aId)
       
  2042 	{
       
  2043 	switch (aId)
       
  2044 		{
       
  2045 	case 1:
       
  2046 	case 13:
       
  2047 	case 15:
       
  2048 	case 16:
       
  2049 		return EColor16;
       
  2050 	case 2:
       
  2051 		return EGray16;
       
  2052 	case 3:
       
  2053 		return EColor16;
       
  2054 	case 4:
       
  2055 	case 14:
       
  2056 	case 17:
       
  2057 	case 18:
       
  2058 	case 19:
       
  2059 	case 24:
       
  2060 		return EColor256;
       
  2061 	case 5:
       
  2062 		return EGray256;
       
  2063 	case 6:
       
  2064 		return EColor4K;
       
  2065 	case 7:
       
  2066 		return EColor64K;
       
  2067 	case 8:
       
  2068 	case 9:
       
  2069 	case 10:
       
  2070 	case 11:
       
  2071 	case 12:
       
  2072 		{
       
  2073 		TInt colors,grays;
       
  2074 		/*TDisplayMode mode=*/TheClient->iWs.GetDefModeMaxNumColors(colors,grays);
       
  2075 		if (colors==0)
       
  2076 			return EGray4;
       
  2077 		return (aId==8? EGray16:EColor16);
       
  2078 		}
       
  2079 	default:;
       
  2080 		return TheClient->iScreen->DisplayMode();
       
  2081 		}
       
  2082 	}
       
  2083 
       
  2084 void CTDirect::Log(const TText8* aFile, TInt aLine, TInt aSeverity,const TDesC& aString)
       
  2085 	{
       
  2086 	Logger().LogExtra(((TText8*)aFile), aLine, aSeverity, aString) ;
       
  2087 	}
       
  2088 
       
  2089 TRgb CTDirect::BrushColorL(TInt aId,TInt& aColor,TBool& aFinished)
       
  2090 	{
       
  2091 	aFinished=EFalse;
       
  2092 	switch (aId)
       
  2093 		{
       
  2094 	case 1:
       
  2095 	case 13:
       
  2096 	case 14:
       
  2097 	case 15:
       
  2098 	case 16:
       
  2099 	case 17:
       
  2100 	case 18:
       
  2101 	case 19:
       
  2102 	case 20:
       
  2103 	case 21:
       
  2104 	case 27:
       
  2105 		aFinished=(aColor==20);
       
  2106 		return TRgb::Color16(27 + aColor++);
       
  2107 	case 28:
       
  2108 		aFinished=(aColor==17);
       
  2109 		return TRgb::Color16(28 + aColor++);
       
  2110 	case 29:
       
  2111 		aFinished=(aColor==15);
       
  2112 		return TRgb::Color16(29 + aColor++);
       
  2113 	case 8:
       
  2114 		if (aColor==15)
       
  2115 			{
       
  2116 			++iCycles;
       
  2117 			aFinished=(iCycles==5);
       
  2118 			}
       
  2119 		else if (!iScroll)
       
  2120 			aFinished=ETrue;
       
  2121 		else if (!iScroll->IsRunning())
       
  2122 			iScroll->ContinueL();
       
  2123 		{
       
  2124 	#if defined(LOGGING)
       
  2125 		if (aFinished || iScroll==NULL)
       
  2126 			{
       
  2127 			_LIT(KColor,"Col=%d Cycles=%d Fin=%d  iScroll=%d");
       
  2128 			LogMessageText.Zero();
       
  2129 			LogMessageText.AppendFormat(KColor,aColor,iCycles,aFinished,(TInt&)iScroll);
       
  2130 			TheClient->iWs.LogMessage(LogMessageText);
       
  2131 			TheClient->Flush();
       
  2132 			}
       
  2133 	#endif
       
  2134 		}
       
  2135 	case 2:
       
  2136 		if (aColor==16)
       
  2137 			aColor=0;
       
  2138 		return TRgb::Gray16(aColor++);
       
  2139 	case 9:
       
  2140 	case 10:
       
  2141 		aFinished=iCycles>3;
       
  2142 	case 11:
       
  2143 	case 3:
       
  2144 		if (aColor==16)
       
  2145 			{
       
  2146 			++iCycles;
       
  2147 			aColor=0;
       
  2148 			}
       
  2149 		return TRgb::Color16(aColor++);
       
  2150 	case 4:
       
  2151 		aFinished=(aColor==256);
       
  2152 		return TRgb::Color256(aColor++);
       
  2153 	case 5:
       
  2154 		if (aColor==256)
       
  2155 			aColor=0;
       
  2156 		return TRgb::Gray256(aColor++);
       
  2157 	case 6:
       
  2158 		aColor+=127;
       
  2159 		if (aColor>4095)
       
  2160 			aColor-=4096;
       
  2161 		return TRgb::Color4K(aColor);
       
  2162 	case 7:
       
  2163 		aColor+=211;
       
  2164 		if (aColor>65535)
       
  2165 			aColor-=65536;
       
  2166 		return TRgb::Color64K(aColor++);
       
  2167 	case 12:
       
  2168 		aFinished=2*(aColor>5);
       
  2169 		return TRgb::Color16(aColor++);
       
  2170 	case 24:
       
  2171 		iCycles++;
       
  2172 		if (iCycles==5)
       
  2173 			{
       
  2174 			aFinished=ETrue;
       
  2175 			CheckForTemporaryDeadlock();
       
  2176 			}
       
  2177 		return TRgb::Color16(aColor++);
       
  2178 	case 30:
       
  2179 		aFinished=(aColor==256);
       
  2180 		return TRgb::Color16(aColor++);
       
  2181 	case 31:
       
  2182 		aFinished=(aColor==100);
       
  2183 		return TRgb::Color16(aColor++);
       
  2184 	case 32:
       
  2185 		aFinished=(aColor==300);
       
  2186 		return TRgb::Color16(aColor++);
       
  2187 	default:;
       
  2188 		aFinished=ETrue;
       
  2189 		return TRgb::Gray2(1);		//White
       
  2190 		}
       
  2191 	}
       
  2192 
       
  2193 TInt CTDirect::TimerInterval(TInt aId)
       
  2194 	{
       
  2195 	switch (aId)
       
  2196 		{
       
  2197 	case 1:
       
  2198 	case 15:
       
  2199 	case 16:
       
  2200 	case 17:
       
  2201 	case 18:
       
  2202 	case 20:
       
  2203 	case 21:
       
  2204 		return 143200;
       
  2205 	case 27:	
       
  2206 		return 200000;
       
  2207 	case 28:
       
  2208 		return 180000;
       
  2209 	case 29:
       
  2210 		return 170000;
       
  2211 	case 30:
       
  2212 		return 200000;
       
  2213 	case 31:
       
  2214 		return 205000;
       
  2215 	case 32:
       
  2216 		return 300000;
       
  2217 	case 2:		
       
  2218 	case 25:
       
  2219 	case 26:
       
  2220 		return 234567;
       
  2221 	case 3:
       
  2222 		return 200000;
       
  2223 	case 4:
       
  2224 		return 11718;
       
  2225 	case 5:
       
  2226 		return 13719;
       
  2227 	case 6:
       
  2228 		return 14719;
       
  2229 	case 7:
       
  2230 		return 15719;
       
  2231 	case 8:
       
  2232 		return 275000;
       
  2233 	case 9:
       
  2234 		return 210000;
       
  2235 	case 10:
       
  2236 		return 110000;
       
  2237 	case 11:
       
  2238 		return 123456;
       
  2239 	case 12:
       
  2240 		return 10627;
       
  2241 	case 19:
       
  2242 		return 1000000;
       
  2243 	default:;
       
  2244 		return 1;
       
  2245 		}
       
  2246 	}
       
  2247 
       
  2248 void CTDirect::FailedReStart(TInt /*aId*/,TInt /*aReason*/)
       
  2249 	{
       
  2250 	Fail();
       
  2251 	}
       
  2252 
       
  2253 TInt CTDirect::SlowStopping(TInt aId,TInt aCount)
       
  2254 	{
       
  2255 	if (aId==8)
       
  2256 		return (aCount>1 ? CColorAnimation::eAbortAll : CColorAnimation::eStopNow);
       
  2257 	if (aId==9 || aId==10)
       
  2258 		return CColorAnimation::eStopNow;
       
  2259 	TInt ret=(2*aId-3==aCount%12);
       
  2260 	if (ret && aId==5)
       
  2261 		{
       
  2262 		++iCount;
       
  2263 		if (iCount==5)
       
  2264 			return CColorAnimation::eAbort;
       
  2265 		}
       
  2266 	return ret;
       
  2267 	}
       
  2268 
       
  2269 void CTDirect::ModeSwitch()
       
  2270 	{
       
  2271 	TRAPD(err,iAnim->ChangeModeL(EGray4));
       
  2272 	iWin2->SetSize(TSize(20,25));
       
  2273 	TheClient->Flush();
       
  2274 	if (err!=KErrNone)
       
  2275 		Fail();
       
  2276 	}
       
  2277 
       
  2278 TestState CTDirect::AnimateWindowL()
       
  2279 	{
       
  2280 //	if (!iTimer->IsActive())
       
  2281 	{
       
  2282 		
       
  2283 	
       
  2284 	iFrameNo=0;
       
  2285 	SignalWindow();
       
  2286 	
       
  2287 	
       
  2288 		iTimer->Start(0,200000,TCallBack(NextFrame,this));		//0.2 secs
       
  2289 
       
  2290 	StartDirect();
       
  2291 	TEST(iDrawingRegion->BoundingRect()==iScrSize);
       
  2292 	}
       
  2293 //	else
       
  2294 //	{
       
  2295 //		int i=0;
       
  2296 //	}
       
  2297 	return EWait;
       
  2298 	}
       
  2299 
       
  2300 TestState CTDirect::AnimationDiesL()
       
  2301 	{
       
  2302 	INFO_PRINTF1(_L("AUTO  Animation Dies "));
       
  2303 	_LIT(ThreadName,"AnimationDie");
       
  2304 	iFirstFunction=TThreadStartUp(CAnimating::StartLC,(TAny*)iTest->iScreenNumber);
       
  2305 	CProcess* thread=CProcess::NewThreadL(ThreadName,&iFirstFunction);
       
  2306 	CleanupStack::PushL(thread);
       
  2307 	thread->LeaveIfDied();
       
  2308 	INFO_PRINTF1(_L(" Constructed Thread"));
       
  2309 	iControlSem.Wait();
       
  2310 	RWindowGroup group(TheClient->iWs);
       
  2311 	group.Construct(431,EFalse);
       
  2312 	RBlankWindow win(TheClient->iWs);
       
  2313 	win.Construct(group,432);
       
  2314 	win.SetExtent(TPoint(12,34),TSize(56,78));
       
  2315 	win.Activate();
       
  2316 	INFO_PRINTF1(_L(" Constructed Windows"));
       
  2317 	iControlSem.Wait();
       
  2318 	User::After(1000000);		//1 sec
       
  2319 	TRequestStatus threadDied;
       
  2320 	thread->Logon(threadDied);
       
  2321 	thread->Terminate(KErrGeneral);
       
  2322 	INFO_PRINTF1(_L(" Waiting for Thread"));
       
  2323 	User::WaitForRequest(threadDied);
       
  2324 	CleanupStack::PopAndDestroy(thread);
       
  2325 	win.Close();
       
  2326 	group.Close();
       
  2327 	INFO_PRINTF1(_L(" Finished"));
       
  2328 	return ENext;
       
  2329 	}
       
  2330 
       
  2331 TestState CTDirect::PackagingClassL()
       
  2332 	{
       
  2333 	ConstrucBlankWindowL();
       
  2334 	TInt numProcessHandles;
       
  2335 	RThread().HandleCount(numProcessHandles,iNumThreadHandles);
       
  2336 	iAnim=CColorAnimation::NewL(iTest->iScreenNumber,1,*this,*TheClient->iGroup,TRect(10,10,630,230),ETrue);
       
  2337 	return EWait;
       
  2338 	}
       
  2339 
       
  2340 TestState CTDirect::MultipleL()
       
  2341 	{
       
  2342 	TSize scrSize=TheClient->iScreen->SizeInPixels();
       
  2343 	
       
  2344 	iFlags|=eMultiAnim;
       
  2345 	iAnims[0]=CColorAnimation::NewL(iTest->iScreenNumber,2,*this,*TheClient->iGroup,
       
  2346 									TRect(0,10,scrSize.iWidth/3+20,scrSize.iHeight/2-5),EFalse);
       
  2347 	iAnims[1]=CColorAnimation::NewL(iTest->iScreenNumber,3,*this,*TheClient->iGroup,
       
  2348 									TRect(10,scrSize.iHeight/2-20,scrSize.iWidth/3-5,scrSize.iHeight),EFalse);
       
  2349 	iAnims[3]=CColorAnimation::NewL(iTest->iScreenNumber,5,*this,*TheClient->iGroup,
       
  2350 									TRect(scrSize.iWidth/3-20,scrSize.iHeight/2+5,2*scrSize.iWidth/3+20,scrSize.iHeight-10),EFalse);
       
  2351 	iAnims[2]=CColorAnimation::NewL(iTest->iScreenNumber,4,*this,*TheClient->iGroup,
       
  2352 									TRect(scrSize.iWidth/3+5,0,2*scrSize.iWidth/3-5,scrSize.iHeight/2+20),EFalse);
       
  2353 	iAnims[4]=CColorAnimation::NewL(iTest->iScreenNumber,6,*this,*TheClient->iGroup,
       
  2354 									TRect(2*scrSize.iWidth/3-20,15,scrSize.iWidth,scrSize.iHeight/2+50),EFalse);
       
  2355 	iAnims[5]=CColorAnimation::NewL(iTest->iScreenNumber,7,*this,*TheClient->iGroup,
       
  2356 									TRect(2*scrSize.iWidth/3+5,-20,scrSize.iWidth-15,scrSize.iHeight+10),ETrue);
       
  2357 	TInt ii;
       
  2358 	for (ii=0;ii<5;++ii)
       
  2359 		iAnims[ii]->StartL();
       
  2360 	_LIT(ThreadName,"MoveWin");
       
  2361 	
       
  2362 	MoveInterval=100000;		//0.1 secs
       
  2363 	ModeInterval=1200000;		//1.2 sec
       
  2364 	ImmediateModeSwitch=EFalse;
       
  2365 	iFirstFunction=TThreadStartUp(CMoveWindow::StartLC,(TAny*)iTest->iScreenNumber);
       
  2366 	iMoveWin=CProcess::NewThreadL(ThreadName,&iFirstFunction);
       
  2367 	return EWait;
       
  2368 	}
       
  2369 
       
  2370 TestState CTDirect::MixDsaAndRegionTrackingOnlyL(TBool aWhoExitsLast)
       
  2371 	{
       
  2372 	TSize scrSize=TheClient->iScreen->SizeInPixels();
       
  2373 	
       
  2374 	iFlags|=eMultiAnim;
       
  2375 	TUint firstRegionTrackinOnlyDsa = (aWhoExitsLast == KRegionTrackingOnlyDsaExistLast ? 0 : 3);
       
  2376 	TUint firstDrawingDsa = (aWhoExitsLast == KDrawingDsaExistLast ? 0 : 3);
       
  2377 	
       
  2378 	//DSAs who use region tracking only
       
  2379 	iAnims[firstRegionTrackinOnlyDsa]=CColorAnimation::NewL(iTest->iScreenNumber,firstRegionTrackinOnlyDsa+27,*this,*TheClient->iGroup,
       
  2380 											TRect(10,scrSize.iHeight/2-20,scrSize.iWidth/3-5,scrSize.iHeight),EFalse,KRegionTrackingOnly);
       
  2381 	iAnims[firstRegionTrackinOnlyDsa+1]=CColorAnimation::NewL(iTest->iScreenNumber,firstRegionTrackinOnlyDsa+28,*this,*TheClient->iGroup,
       
  2382 											TRect(2*scrSize.iWidth/3-20,15,scrSize.iWidth,scrSize.iHeight/2+50),EFalse,KRegionTrackingOnly);
       
  2383 	iAnims[firstRegionTrackinOnlyDsa+2]=CColorAnimation::NewL(iTest->iScreenNumber,firstRegionTrackinOnlyDsa+29,*this,*TheClient->iGroup,
       
  2384 											TRect(2*scrSize.iWidth/3+5,-20,scrSize.iWidth-15,scrSize.iHeight+10),EFalse,KRegionTrackingOnly);
       
  2385 	
       
  2386 	//DSAs who actually draw
       
  2387 	iAnims[firstDrawingDsa]=CColorAnimation::NewL(iTest->iScreenNumber,firstDrawingDsa+27,*this,*TheClient->iGroup,
       
  2388 											TRect(0,10,scrSize.iWidth/3+20,scrSize.iHeight/2-5),EFalse,KDrawingDsa);
       
  2389 	iAnims[firstDrawingDsa+1]=CColorAnimation::NewL(iTest->iScreenNumber,firstDrawingDsa+28,*this,*TheClient->iGroup,
       
  2390 											TRect(scrSize.iWidth/3+5,0,2*scrSize.iWidth/3-5,scrSize.iHeight/2+20),EFalse,KDrawingDsa);
       
  2391 	iAnims[firstDrawingDsa+2]=CColorAnimation::NewL(iTest->iScreenNumber,firstDrawingDsa+29,*this,*TheClient->iGroup,
       
  2392 											TRect(scrSize.iWidth/3-20,scrSize.iHeight/2+5,2*scrSize.iWidth/3+20,scrSize.iHeight-10),EFalse,KDrawingDsa);
       
  2393 	
       
  2394 	TInt ii;
       
  2395 	for (ii=0;ii<6;++ii)
       
  2396 		{
       
  2397 		if(iAnims[ii])
       
  2398 			iAnims[ii]->StartL();
       
  2399 		}
       
  2400 		
       
  2401 	_LIT(ThreadName,"MoveWin");
       
  2402 	
       
  2403 	MoveInterval=100000;		//0.1 secs
       
  2404 	ModeInterval=1200000;		//1.2 secs
       
  2405 	ImmediateModeSwitch=EFalse;
       
  2406 	iFirstFunction=TThreadStartUp(CMoveWindow::StartLC,(TAny*)iTest->iScreenNumber);
       
  2407 	iMoveWin=CProcess::NewThreadL(ThreadName,&iFirstFunction);
       
  2408 	return EWait;
       
  2409 	}
       
  2410 
       
  2411 TestState CTDirect::TryDifferentSupportedModesL()
       
  2412 	{
       
  2413 	
       
  2414 	RWsSession session;
       
  2415 	User::LeaveIfError(session.Connect());
       
  2416 	CWsScreenDevice* device = new(ELeave) CWsScreenDevice(session);
       
  2417 	CleanupStack::PushL(device);
       
  2418 	User::LeaveIfError(device->Construct(iTest->iScreenNumber));
       
  2419 	TUint numOfModes=device->NumScreenModes();
       
  2420 	_LIT(KTryingCurrentMode,"Trying Mode = %d");
       
  2421 	for(TUint currentMode =0; currentMode < numOfModes; currentMode++)
       
  2422 		{
       
  2423 		LOG_MESSAGE2(KTryingCurrentMode,currentMode);
       
  2424 		device->SetScreenMode(currentMode);
       
  2425 		TRAPD(err,iAnims[0]=CColorAnimation::NewL(iTest->iScreenNumber,4,*this,*TheClient->iGroup,
       
  2426 										TRect(0,0,50,50),ETrue));
       
  2427 		if(err!=KErrNone)
       
  2428 			{
       
  2429 			TEST(EFalse);
       
  2430 			}
       
  2431 		else
       
  2432 			{
       
  2433 			User::After(2000000);
       
  2434 			iAnims[0]->Stop();
       
  2435 			delete iAnims[0];
       
  2436 			}
       
  2437 		}
       
  2438 	CleanupStack::PopAndDestroy(device);
       
  2439 	session.Close();
       
  2440 	iState++;
       
  2441 	return EWait;
       
  2442 	}
       
  2443 
       
  2444 
       
  2445 TestState CTDirect::FailCodesL()
       
  2446 	{
       
  2447  	__UHEAP_MARK;
       
  2448 	TRequestStatus status;
       
  2449 	RRegion region(TRect(0,0,10,10),1);
       
  2450 	RRegion* pRegion=&region;
       
  2451 	RDirectScreenAccess direct(TheClient->iWs);
       
  2452 	User::LeaveIfError(direct.Construct());
       
  2453 	RBlankWindow window(TheClient->iWs);
       
  2454 	User::LeaveIfError(window.Construct(*TheClient->iGroup->WinTreeNode(),1234));
       
  2455 	TInt err=direct.Request(pRegion,status,window);
       
  2456 	TEST(err==KErrNone);
       
  2457 	if (err!=KErrNone)
       
  2458 		INFO_PRINTF3(_L("direct.Request(pRegion,status,window) return value - Expected: %d, Actual: %d"), KErrNone, err);		
       
  2459 	TEST(pRegion!=NULL);
       
  2460 	if (pRegion==NULL)
       
  2461 		INFO_PRINTF3(_L("pRegion!=NULL - Expected: %d, Actual: %d"), 0, 0);		
       
  2462 	pRegion->Destroy();
       
  2463 	direct.Cancel();
       
  2464 	User::WaitForRequest(status);
       
  2465 	window.Activate();
       
  2466 	window.SetOrdinalPosition(-2);
       
  2467 	pRegion=&region;
       
  2468 	err=direct.Request(pRegion,status,window);
       
  2469 	TEST(err==KErrNone);
       
  2470 	if (err!=KErrNone)
       
  2471 		INFO_PRINTF3(_L("direct.Request(pRegion,status,window) return value - Expected: %d, Actual: %d"), KErrNone, err);		
       
  2472 	TEST(pRegion!=NULL);
       
  2473 	if (pRegion==NULL)
       
  2474 		INFO_PRINTF3(_L("pRegion!=NULL - Expected: %d, Actual: %d"), 0, 0);		
       
  2475 	pRegion->Destroy();
       
  2476 	direct.Cancel();
       
  2477 	User::WaitForRequest(status);
       
  2478 #if defined(__WINS__)
       
  2479 	// Loop over the allocations done.
       
  2480 	// There is one allocating of the rectangle list and
       
  2481 	// one of the region holding the list
       
  2482 	for (TInt rate = 1; rate <= 2; rate++)
       
  2483 		{
       
  2484 		window.SetOrdinalPosition(0);
       
  2485 		pRegion=&region;
       
  2486 		TheClient->Flush();
       
  2487 		__UHEAP_FAILNEXT(rate);
       
  2488 		err=direct.Request(pRegion,status,window);
       
  2489 		TEST(err==KErrNoMemory);
       
  2490 		if (err!=KErrNoMemory)
       
  2491 			INFO_PRINTF3(_L("direct.Request(pRegion,status,window) return value - Expected: %d, Actual: %d"), KErrNoMemory, err);		
       
  2492 
       
  2493 		TEST(pRegion==NULL);
       
  2494 		if (pRegion!=NULL)
       
  2495 			INFO_PRINTF3(_L("pRegion!=NULL - Expected: %d, Actual: %d"), 0, 0);		
       
  2496 		}
       
  2497 #endif
       
  2498 	window.Close();
       
  2499 	direct.Close();
       
  2500 	region.Close();
       
  2501 	__UHEAP_MARKEND;
       
  2502 	return ENext;
       
  2503 	}
       
  2504 
       
  2505 void CTDirect::ScrolingTextL(TInt aId,TRect aWinRect,TBool aStartThread,TInt aScreenMode/*=0*/)
       
  2506 	{
       
  2507 	INFO_PRINTF1(_L("AUTO  Construct ScrolingText "));
       
  2508 	INFO_PRINTF1(_L(" Constructed Window"));
       
  2509 	iCycles=0;
       
  2510 	TInt numProcessHandles;
       
  2511 	RThread().HandleCount(numProcessHandles,iNumThreadHandles);
       
  2512 	iAnim=CColorAnimation::NewL(iTest->iScreenNumber,aId,*this,*TheClient->iGroup,aWinRect,EFalse);
       
  2513 	iScroll=CScrollText::NewL(iTest->iScreenNumber,1,*TheClient->iGroup,5,EFalse);
       
  2514 	INFO_PRINTF1(_L(" Constructed Text Scroller & Animation"));
       
  2515 	iAnim->BringWindowToFront();
       
  2516 	if (aStartThread)
       
  2517 		{
       
  2518 		_LIT(ThreadName,"MoveWin");
       
  2519 		INFO_PRINTF1(_L(" About to constructed Thread"));
       
  2520 		iFirstFunction=TThreadStartUp(CMoveWindow::StartLC,(TAny*)iTest->iScreenNumber);
       
  2521 		__ASSERT_DEBUG(!iMoveWin,AutoPanic(EAutoPanicDirect));
       
  2522 		iMoveWin=CProcess::NewThreadL(ThreadName,&iFirstFunction);
       
  2523 		INFO_PRINTF1(_L(" Constructed Thread"));
       
  2524 		}
       
  2525 	if (aScreenMode>0)
       
  2526 		{
       
  2527 		TInt numScreenModes = TheClient->iScreen->NumScreenModes();
       
  2528 		if (aScreenMode < numScreenModes)
       
  2529 			TheClient->iScreen->SetScreenMode(aScreenMode);
       
  2530 		else
       
  2531 			LOG_MESSAGE(_L("WARNING: Failed to change screen mode"));
       
  2532 			// We have to run the test anyway to avoid things going wrong later
       
  2533 		}
       
  2534 	iAnim->StartOrPanic();
       
  2535 	iScroll->StartL();
       
  2536 	INFO_PRINTF1(_L(" Constructed/Started"));
       
  2537 #if defined(LOGGING)
       
  2538 	_LIT(KStarted,"Finished StartUp ScrollText");
       
  2539 	LogMessageText.Copy(KStarted);
       
  2540 	TheClient->iWs.LogMessage(LogMessageText);
       
  2541 	TheClient->Flush();
       
  2542 #endif
       
  2543 	}
       
  2544 
       
  2545 TestState CTDirect::ScrolingText1L()
       
  2546 	{
       
  2547 	MoveInterval=0;
       
  2548 	ModeInterval=1200000;		//1.2 sec
       
  2549 	ScrolingTextL(8,TRect(20,20,40,40),ETrue);
       
  2550 	return EWait;
       
  2551 	}
       
  2552 
       
  2553 TestState CTDirect::RClassL()
       
  2554 	{
       
  2555 #if defined(LOGGING)
       
  2556 	_LIT(KRClass,"Starting Panic test on RClass");
       
  2557 	LogMessageText.Zero();
       
  2558 	LogMessageText.AppendFormat(KRClass);
       
  2559 	TheClient->iWs.LogMessage(LogMessageText);
       
  2560 	TheClient->Flush();
       
  2561 #endif
       
  2562 	TEST(iTest->TestWsPanicL(CPanicDirect::DoTestOnNewScheduler,EWservPanicDirectMisuse,1,(TAny*)iTest->iScreenNumber));
       
  2563 #if defined(LOGGING)
       
  2564 	_LIT(KPanic1,"Done First Panic");
       
  2565 	LogMessageText.Zero();
       
  2566 	LogMessageText.AppendFormat(KPanic1);
       
  2567 	TheClient->iWs.LogMessage(LogMessageText);
       
  2568 	TheClient->Flush();
       
  2569 #endif
       
  2570 #if defined(__WINS__)
       
  2571 #if defined(LOGGING)
       
  2572 	_LIT(KPanic2,"Doing 2 debug panics");
       
  2573 	LogMessageText.Zero();
       
  2574 	LogMessageText.AppendFormat(KPanic2);
       
  2575 	TheClient->iWs.LogMessage(LogMessageText);
       
  2576 	TheClient->Flush();
       
  2577 #endif
       
  2578 	TEST(iTest->TestW32PanicL(CPanicDirect::DoTestOnNewScheduler,EW32PanicDirectMisuse,2,(TAny*)iTest->iScreenNumber));
       
  2579 	TEST(iTest->TestW32PanicL(CPanicDirect::DoTestOnNewScheduler,EW32PanicDirectMisuse,3,(TAny*)iTest->iScreenNumber));
       
  2580 #endif
       
  2581 #if defined(LOGGING)
       
  2582 	_LIT(KPanicTest,"Trying Panic %d");
       
  2583 	LogMessageText.Zero();
       
  2584 	LogMessageText.AppendFormat(KPanicTest,4);
       
  2585 	TheClient->iWs.LogMessage(LogMessageText);
       
  2586 	TheClient->Flush();
       
  2587 #endif
       
  2588 	TEST(iTest->TestWsPanicL(CPanicDirect::DoTestOnNewScheduler,EWservPanicDirectMisuse,4,(TAny*)iTest->iScreenNumber));
       
  2589 	TEST(iTest->TestW32PanicL(CPanicDirect::DoTestOnNewScheduler,EW32PanicDirectMisuse,5,(TAny*)iTest->iScreenNumber));
       
  2590 	return ENext;
       
  2591 	}
       
  2592 
       
  2593 TestState CTDirect::ScrolingText2L()
       
  2594 	{
       
  2595 	MoveInterval=81234;		//0.08 sec
       
  2596 	ModeInterval=140123;		//0.14 sec
       
  2597 	ImmediateModeSwitch=2;
       
  2598 	ScrolingTextL(9,TRect(15,25,45,35),ETrue);
       
  2599 	iScroll->SetCountDown(5);
       
  2600 	return EWait;
       
  2601 	}
       
  2602 
       
  2603 TestState CTDirect::ScrolingText3L()
       
  2604 	{
       
  2605 	iModeBackup=TheClient->iScreen->ScreenModeEnforcement();
       
  2606 	if (iModeBackup!=ESizeEnforcementNone)
       
  2607 		TheClient->iScreen->SetScreenModeEnforcement(ESizeEnforcementNone);
       
  2608 	MoveInterval=0;
       
  2609 	ModeInterval=0;
       
  2610 	FlipInterval=1200000;		//1.2 secs
       
  2611 	ScrolingTextL(10,TRect(25,30,35,45),ETrue,1);
       
  2612 	iScroll->SetBottomOfTest(80);		//So it can be seen in both screen modes
       
  2613 	return EWait;
       
  2614 	}
       
  2615 
       
  2616 TestState CTDirect::ScrolingText4L()
       
  2617 	{
       
  2618 	iModeBackup=TheClient->iScreen->ScreenModeEnforcement();
       
  2619 	if (iModeBackup!=ESizeEnforcementNone)
       
  2620 		TheClient->iScreen->SetScreenModeEnforcement(ESizeEnforcementNone);
       
  2621 	MoveInterval=876543;		//0.88 secs
       
  2622 	ModeInterval=2178900;		//2.18 secs
       
  2623 	FlipInterval=5000000;		//5 secs
       
  2624 	ScrolingTextL(11,TRect(30,40,55,65),ETrue);
       
  2625 	iScroll->SetBottomOfTest(80);		//So it can be seen in both screen modes
       
  2626 	return EWait;
       
  2627 	}
       
  2628 
       
  2629 void CTDirect::CreateAnimForScreenModeL(TInt aAnimIndex,CTWinBase& aParent,TRect aRect,TInt aId)
       
  2630 	{
       
  2631 	iAnims[aAnimIndex]=CColorAnimation::NewL(iTest->iScreenNumber,aId,*this,aParent,aRect,EFalse);
       
  2632 	iAnims[aAnimIndex]->StartL();
       
  2633 	iAnims[aAnimIndex]->BringWindowToFront();
       
  2634 	}
       
  2635 
       
  2636 void CTDirect::BlankTopClientWindowL(CTBlankWindow& aBlankWindow,TRect aRect)
       
  2637 	{
       
  2638 	aBlankWindow.ConstructExtLD(*TheClient->iGroup,aRect.iTl,aRect.Size());
       
  2639 	User::LeaveIfError(aBlankWindow.BaseWin()->SetRequiredDisplayMode(EColor256));
       
  2640 	aBlankWindow.BaseWin()->SetShadowDisabled(ETrue);
       
  2641 	aBlankWindow.Activate();
       
  2642 	}
       
  2643 
       
  2644 static TInt ChangeScreenModeL(TAny* aTest)
       
  2645 	{
       
  2646 	STATIC_CAST(CTDirect*,aTest)->ChangeToNextScreenModeL();
       
  2647 	return KErrNone;
       
  2648 	}
       
  2649 
       
  2650 void CTDirect::ChangeToNextScreenModeL()
       
  2651 	{
       
  2652 #if defined(LOGGING)
       
  2653 	_LIT(KChangeMode,"AUTO Screen Mode Pos Test2 CallBack");
       
  2654 	LogMessageText.Copy(KChangeMode);
       
  2655 	TheClient->LogMessage(LogMessageText);
       
  2656 	TheClient->iWs.LogCommand(RWsSession::ELoggingStatusDump);
       
  2657 #endif
       
  2658 	iNumOfModes=TheClient->iScreen->NumScreenModes();
       
  2659 	if (iCurrentMode<iNumOfModes)
       
  2660 		{
       
  2661 		TPixelsAndRotation pixelsAndRotation;
       
  2662 		SetScreenMode(iCurrentMode,pixelsAndRotation);
       
  2663 		TInt oldCurrentMode=iCurrentMode;
       
  2664 		CArrayFixFlat<TInt>* rotations=new(ELeave) CArrayFixFlat<TInt>(1);
       
  2665 		CleanupStack::PushL(rotations);
       
  2666 		User::LeaveIfError(TheClient->iScreen->GetRotationsList(iCurrentMode,rotations));
       
  2667 		TInt count=rotations->Count();
       
  2668 		TInt jj=0;
       
  2669 		if (count>1)
       
  2670 			{
       
  2671 			for (jj=0;jj<count;)
       
  2672 				{
       
  2673 				if ((*rotations)[jj++]==pixelsAndRotation.iRotation)
       
  2674 					{
       
  2675 					break;
       
  2676 					}
       
  2677 				}
       
  2678 			if (jj==count)
       
  2679 				{
       
  2680 				jj=0;
       
  2681 				}
       
  2682 			}
       
  2683 		if (jj==0)
       
  2684 			{
       
  2685 			iCurrentMode++;
       
  2686 			}
       
  2687 		TInt currentRotation=(*rotations)[jj];
       
  2688 		TheClient->iScreen->SetCurrentRotations(oldCurrentMode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation));
       
  2689 		CleanupStack::PopAndDestroy(rotations);
       
  2690 		TheClient->iScreen->GetScreenModeSizeAndRotation(oldCurrentMode,pixelsAndRotation);
       
  2691 		TInt screenWidth=pixelsAndRotation.iPixelSize.iWidth;
       
  2692 		TInt screenHeight=pixelsAndRotation.iPixelSize.iHeight;
       
  2693 		TPoint screenModeOrigin=TheClient->iScreen->GetScreenModeScaledOrigin(oldCurrentMode);
       
  2694 		TPoint point1(screenModeOrigin.iX,screenModeOrigin.iY+(screenModeOrigin.iY+screenHeight)/2);
       
  2695 		TPoint point2(screenModeOrigin.iX+(screenModeOrigin.iX+screenWidth)/2,screenHeight+screenModeOrigin.iY);
       
  2696 		TRect rect0(point1,point2);
       
  2697 		TRect rect1(TPoint(0,0),rect0.Size());
       
  2698 		CreateAnimForScreenModeL(0,*TheClient->iGroup,rect1,14);
       
  2699 		TPoint pos=iAnims[0]->AbsoluteWindowPosition();
       
  2700 		TEST(pos==TPoint(0,0));
       
  2701 		}
       
  2702 	}
       
  2703 
       
  2704 TInt ChangeScreenScaleCallBack(TAny* aTest)
       
  2705 	{
       
  2706 	static_cast<CTDirect*>(aTest)->ChangeScreenScale();
       
  2707 	return KErrNone;
       
  2708 	}
       
  2709 
       
  2710 void CTDirect::ChangeScreenScale()
       
  2711 	{
       
  2712 	if (!iNumOfCallBack)
       
  2713 		{
       
  2714 		iCurrentMode=TheClient->iScreen->CurrentScreenMode();
       
  2715 		iModeData=TheClient->iScreen->GetCurrentScreenModeAttributes();
       
  2716 		iModeData.iScreenScale.SetSize(1,1);
       
  2717 		}
       
  2718 	TSizeMode testMode=iModeData;
       
  2719 	if (!iNumOfCallBack)
       
  2720 		{
       
  2721 		testMode.iScreenScale.SetSize(2,2);
       
  2722 		}
       
  2723 	else if (iNumOfCallBack==1)
       
  2724 		{
       
  2725 		testMode.iScreenScale.SetSize(3,2);
       
  2726 		}
       
  2727 	else if (iNumOfCallBack==2)
       
  2728 		{
       
  2729 		testMode.iScreenScale.SetSize(2,3);
       
  2730 		}
       
  2731 	TheClient->iScreen->SetCurrentScreenModeAttributes(testMode);
       
  2732 	TheClient->iScreen->SetAppScreenMode(iCurrentMode);
       
  2733 	TheClient->iScreen->SetScreenMode(iCurrentMode);
       
  2734 	if (iNumOfCallBack==2)
       
  2735 		{
       
  2736 		iScreenModeTimer->Cancel();
       
  2737 		delete iScreenModeTimer;
       
  2738 		iScreenModeTimer=NULL;
       
  2739 		}
       
  2740 	iNumOfCallBack++;
       
  2741 	}
       
  2742 
       
  2743 /*
       
  2744  * Creates a DSA for screen mode 0. After DSA has displayd 2 or 3 frames screen mode
       
  2745  * scale is changed with a timer. The DSA aborts and restarts once again
       
  2746  * and completes itself in different screen mode.
       
  2747  */
       
  2748 TestState CTDirect::ScreenModeTestForScalingL()
       
  2749 	{
       
  2750 	CreateAnimForScreenModeL(0,*TheClient->iGroup,TRect(TSize(10,10)),19);
       
  2751 	iScreenModeTimer=CPeriodic::NewL(0);
       
  2752 	MoveInterval=2000000;
       
  2753 	iScreenModeTimer->Start(1000,MoveInterval,TCallBack(ChangeScreenScaleCallBack,this));
       
  2754 	return EWait;
       
  2755 	}
       
  2756 
       
  2757 /*
       
  2758  * Creates a DSA for screen mode 0, tests API AbsoluteWindowPosition()
       
  2759  * Then sets screen mode to last(test) screen mode, here it does the same thing as
       
  2760  * done for screenmode 0, but with diffrerent scale (2,2) (2,3) (3,2) (3,3) and
       
  2761  * with different origin (20,30) (30,20) (20,20).
       
  2762  * Lastly copy back the test screen mode values.
       
  2763  */
       
  2764 TestState CTDirect::ScreenModeScalingTestL()
       
  2765 	{
       
  2766 #if defined(LOGGING)
       
  2767 INFO_PRINTF1("AUTO  ScreenModeScalingTest ");
       
  2768 #else
       
  2769 //	DisabledStartLogText();
       
  2770 #endif
       
  2771 INFO_PRINTF1(_L(" Switch to mode 0"));
       
  2772 	iModeData.iScreenScale.iWidth=1;
       
  2773 	iModeData.iScreenScale.iHeight=1;
       
  2774 	TheClient->iScreen->SetCurrentScreenModeAttributes(iModeData);
       
  2775 	TheClient->iScreen->SetAppScreenMode(0);
       
  2776 	TheClient->iScreen->SetScreenMode(0);
       
  2777 	iCurrentMode=0;
       
  2778 INFO_PRINTF1(_L(" Get Parameters"));
       
  2779 	iCurrentScreenModeOrigin=TheClient->iScreen->GetDefaultScreenModeOrigin();
       
  2780 	iCurrentScreenModeScale=TheClient->iScreen->GetCurrentScreenModeScale();
       
  2781 	Copy2ndHalfOfScreen=(iCurrentScreenModeOrigin.iX>FullScreenModeSize.iWidth/2? 1 : 0);
       
  2782 	TRect testWinRect(PhysicalToLogical(TPoint(),iCurrentScreenModeScale),
       
  2783 					  PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth :
       
  2784 	                                                                  FullScreenModeSize.iWidth/2),
       
  2785 										       FullScreenModeSize.iHeight)-
       
  2786 										iCurrentScreenModeOrigin,iCurrentScreenModeScale)
       
  2787 					 );
       
  2788 	testWinRect.Shrink(10,10);
       
  2789 INFO_PRINTF1(_L(" Create Animation"));
       
  2790 	CreateAnimForScreenModeL(0,*TheClient->iGroup,testWinRect,17);
       
  2791 	TPoint pos0=iAnims[0]->AbsoluteWindowPosition();
       
  2792 	TEST(pos0==TPoint(10,10));
       
  2793 
       
  2794 	TInt numOfModes=TheClient->iScreen->NumScreenModes();
       
  2795 	iCurrentMode=numOfModes-1;
       
  2796 INFO_PRINTF1(_L(" Switch to Last Mode"));
       
  2797 	TheClient->iScreen->SetAppScreenMode(iCurrentMode);
       
  2798 	TheClient->iScreen->SetScreenMode(iCurrentMode);
       
  2799 	TSizeMode storeModeData=TheClient->iScreen->GetCurrentScreenModeAttributes();
       
  2800 	TSizeMode testMode=storeModeData;
       
  2801 	iNumAnimation=0;
       
  2802 	for (TInt xScale=2;xScale<4;xScale++)
       
  2803 		{
       
  2804 INFO_PRINTF1(_L(" New X-Scale"));
       
  2805 		for (TInt yScale=2;yScale<4;yScale++)
       
  2806 			{
       
  2807 INFO_PRINTF1(_L(" New Y-Scale"));
       
  2808 			testMode.iScreenScale=TSize(xScale,yScale);
       
  2809 			TestDifferentOriginAndScaleL(testMode,TPoint(20,20));
       
  2810 			TestDifferentOriginAndScaleL(testMode,TPoint(20,30));
       
  2811 			TestDifferentOriginAndScaleL(testMode,TPoint(30,20));
       
  2812 			}
       
  2813 		}
       
  2814 	TheClient->iScreen->SetScreenMode(iCurrentMode);
       
  2815 	TheClient->iScreen->SetCurrentScreenModeAttributes(storeModeData);
       
  2816 INFO_PRINTF1(_L(" Set To Mode 0"));
       
  2817 	TheClient->iScreen->SetAppScreenMode(0);
       
  2818 	TheClient->iScreen->SetScreenMode(0);
       
  2819 	return EWait;
       
  2820 	}
       
  2821 
       
  2822 void CTDirect::TestDifferentOriginAndScaleL(TSizeMode &aMode,TPoint aOrigin)
       
  2823 	{
       
  2824 	aMode.iOrigin=aOrigin;
       
  2825 	TheClient->iScreen->SetCurrentScreenModeAttributes(aMode);
       
  2826 	TheClient->iScreen->SetAppScreenMode(iCurrentMode);
       
  2827 	TheClient->iScreen->SetScreenMode(iCurrentMode);
       
  2828 	iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode);
       
  2829 	iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode);
       
  2830 	Copy2ndHalfOfScreen=(iCurrentScreenModeOrigin.iX>FullScreenModeSize.iWidth/2? 1 : 0);
       
  2831 	TRect testWinRect(PhysicalToLogical(TPoint(),iCurrentScreenModeScale),
       
  2832 					  PhysicalToLogical(TPoint((Copy2ndHalfOfScreen ? FullScreenModeSize.iWidth
       
  2833 																	: FullScreenModeSize.iWidth/2),
       
  2834 											   FullScreenModeSize.iHeight)
       
  2835 										-iCurrentScreenModeOrigin,iCurrentScreenModeScale)
       
  2836 					 );
       
  2837 	testWinRect.Shrink(10,10);
       
  2838 	++iNumAnimation;
       
  2839 	CreateAnimForScreenModeL(iNumAnimation,*TheClient->iGroup,testWinRect,18);
       
  2840 	TPoint pos0=iAnims[iNumAnimation]->AbsoluteWindowPosition();
       
  2841 	TEST(pos0==TPoint(10,10));
       
  2842 	}
       
  2843 
       
  2844 //REQUIREMENT: CR PHAR-5SJGAM, PREQ673
       
  2845 //Tests that DSA works correctly in screen modes with non-zero screen mode origin.
       
  2846 TestState CTDirect::DSAWithScreenModeOffset1L()
       
  2847 	{
       
  2848 	TPoint screenModeTwoOrigin=TheClient->iScreen->GetScreenModeScaledOrigin(2);
       
  2849 	TPixelsAndRotation pixelsAndRotation;
       
  2850 	TheClient->iScreen->GetScreenModeSizeAndRotation(2,pixelsAndRotation);
       
  2851 	if(pixelsAndRotation.iRotation != CFbsBitGc::EGraphicsOrientationNormal)
       
  2852 		{
       
  2853 		TheClient->iScreen->SetCurrentRotations(2, CFbsBitGc::EGraphicsOrientationNormal);
       
  2854 		}
       
  2855 	TheClient->iScreen->GetScreenModeSizeAndRotation(2,pixelsAndRotation);
       
  2856 	//check that the current rotation is normal
       
  2857 	__ASSERT_DEBUG(pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationNormal,AutoPanic(EAutoPanicDirect));
       
  2858 	TInt screenWidthMode2=pixelsAndRotation.iPixelSize.iWidth;
       
  2859 	TInt screenHeightMode2=pixelsAndRotation.iPixelSize.iHeight;
       
  2860 	TPoint point1(screenModeTwoOrigin.iX,screenModeTwoOrigin.iY+(screenModeTwoOrigin.iY+screenHeightMode2)/2);
       
  2861 	TPoint point2(screenModeTwoOrigin.iX+(screenModeTwoOrigin.iX+screenWidthMode2)/2,screenHeightMode2+screenModeTwoOrigin.iY);
       
  2862 	TPoint point3(screenModeTwoOrigin.iX+screenWidthMode2,screenModeTwoOrigin.iY+screenHeightMode2);
       
  2863 
       
  2864 	SetScreenMode(0,pixelsAndRotation);
       
  2865 	TRect rect0(point1,point2);
       
  2866 	CreateAnimForScreenModeL(0,*TheClient->iGroup,rect0,13);
       
  2867 	TPoint pos0=iAnims[0]->AbsoluteWindowPosition();
       
  2868 	TEST(pos0==point1);
       
  2869 
       
  2870 	SetScreenMode(2,pixelsAndRotation);
       
  2871 	TRect rect1(TPoint(0,0),rect0.Size());
       
  2872 	CreateAnimForScreenModeL(1,*TheClient->iGroup,rect1,13);
       
  2873 	TPoint pos1=iAnims[1]->AbsoluteWindowPosition();
       
  2874 	TEST(pos1==rect1.iTl);
       
  2875 
       
  2876 	SetScreenMode(0,pixelsAndRotation);
       
  2877 	iBlankTopClientWin1=new(ELeave) CTBlankWindow();
       
  2878 //	TInt ordpos = iBlankTopClientWin1->BaseWin()->OrdinalPosition();
       
  2879 	TRect rect2(TPoint(point2.iX,point1.iY),point3);
       
  2880 	BlankTopClientWindowL(*iBlankTopClientWin1,rect2);
       
  2881 	TInt x=rect2.Size().iWidth/4;
       
  2882 	TPoint animWinPt(x,0);
       
  2883 	rect2.Shrink(x,0);
       
  2884 	CreateAnimForScreenModeL(2,*iBlankTopClientWin1,TRect(animWinPt,rect2.Size()),13);
       
  2885 	TPoint pos2=iAnims[2]->AbsoluteWindowPosition();
       
  2886 	TEST(pos2==rect2.iTl);
       
  2887 
       
  2888 	SetScreenMode(2,pixelsAndRotation);
       
  2889 	iBlankTopClientWin2=new(ELeave) CTBlankWindow();
       
  2890 //	ordpos = iBlankTopClientWin2->BaseWin()->OrdinalPosition();
       
  2891 	TPoint tl(rect1.iBr.iX,0);
       
  2892 	TRect rect3(tl,TPoint(screenWidthMode2,rect1.iBr.iY));
       
  2893 	BlankTopClientWindowL(*iBlankTopClientWin2,rect3);
       
  2894 	x=rect3.Size().iWidth/4;
       
  2895 	animWinPt=TPoint(x,0);
       
  2896 	rect3.Shrink(x,0);
       
  2897 	CreateAnimForScreenModeL(3,*iBlankTopClientWin2,TRect(animWinPt,rect3.Size()),13);
       
  2898 	TPoint pos3=iAnims[3]->AbsoluteWindowPosition();
       
  2899 	TEST(pos3==(animWinPt+tl));
       
  2900 
       
  2901 	SetScreenMode(0,pixelsAndRotation);
       
  2902 	return EWait;
       
  2903 	}
       
  2904 
       
  2905 //REQUIREMENT: CR PHAR-5SJGAM, PREQ673
       
  2906 //Tests that DSA works correctly in screen modes with non-zero screen mode origin and different rotations
       
  2907 TestState CTDirect::DSAWithScreenModeOffset2L()
       
  2908 	{
       
  2909 	iCurrentMode=0;
       
  2910 	TTimeIntervalMicroSeconds32 timeBetweenScreenModeChange=3200000;
       
  2911 	iCallBackWin->WinTreeNode()->SetOrdinalPosition(0);
       
  2912 	iCallBackWin->SetVisible(ETrue);		//Used to forsce screen into Color256 so that it will rotate
       
  2913 	iChangeScreenModeTimer=CPeriodic::NewL(0);
       
  2914 	iChangeScreenModeTimer->Start(0,timeBetweenScreenModeChange,TCallBack(ChangeScreenModeL,this));
       
  2915 	return EWait;
       
  2916 	}
       
  2917 
       
  2918 void CTDirect::SetScreenMode(TInt aMode,TPixelsAndRotation& aPixelsAndRotation)
       
  2919 	{
       
  2920 	TheClient->iScreen->SetScreenMode(aMode);
       
  2921 	TheClient->iScreen->SetScreenModeEnforcement(ESizeEnforcementNone);
       
  2922 	TheClient->iScreen->GetDefaultScreenSizeAndRotation(aPixelsAndRotation);
       
  2923 	TheClient->iScreen->SetScreenSizeAndRotation(aPixelsAndRotation);
       
  2924 	TheClient->Flush();
       
  2925 	}
       
  2926 
       
  2927 TestState CTDirect::DefectFix_KAA_5J3BLW_L()
       
  2928 	{
       
  2929 	TInt numProcessHandles;
       
  2930 	RThread().HandleCount(numProcessHandles,iNumThreadHandles);
       
  2931 	const TSize screenSize(TheClient->iScreen->SizeInPixels());
       
  2932 	const TRect dsaRect(0,0,screenSize.iWidth>>2,screenSize.iHeight>>2);
       
  2933 	iAnim=CBugFixColorAnimation::NewL(iTest->iScreenNumber, 1, *this, *TheClient->iGroup, dsaRect,ETrue);
       
  2934 	return EWait;
       
  2935 	}
       
  2936 
       
  2937 TestState CTDirect::RegionTrackingOnlyNotificationsL(TUint aId)
       
  2938 	{
       
  2939 	TInt numProcessHandles;
       
  2940 	RThread().HandleCount(numProcessHandles,iNumThreadHandles);
       
  2941 	const TSize screenSize(TheClient->iScreen->SizeInPixels());
       
  2942 	const TRect dsaRect(0,0,screenSize.iWidth>>2,screenSize.iHeight>>2);
       
  2943 	TBool isWindowOpenedInFrontOfDsa = (aId == KRegionTrackingOnlyDsaWaitingForAbortSignal);
       
  2944 	iAnim=CRegionTrackingOnly::NewL(iTest->iScreenNumber, aId, *this, *TheClient->iGroup, dsaRect,ETrue,isWindowOpenedInFrontOfDsa);
       
  2945 	return EWait;
       
  2946 	}
       
  2947 
       
  2948 // Tests the new function of getting the window's absolute position
       
  2949 TestState CTDirect::WindowPoistionRelativeToScreenL()
       
  2950 	{
       
  2951 	//.. delete screen mode timer
       
  2952 	delete iChangeScreenModeTimer;
       
  2953 	iChangeScreenModeTimer=NULL;
       
  2954 
       
  2955 	TInt numProcessHandles;
       
  2956 	RThread().HandleCount(numProcessHandles,iNumThreadHandles);
       
  2957 	TSize screenSize(TheClient->iScreen->SizeInPixels());
       
  2958 	TRect rect(0,0,screenSize.iWidth>>1,screenSize.iHeight);
       
  2959 	rect.Shrink(10,10);
       
  2960 	// First animation is for showing that child window is within the visible part of the parent window and within the visible screen area
       
  2961 	iAnims[0]=new(ELeave) CColorAnimation(iTest->iScreenNumber,15,*this);
       
  2962 	iAnims[0]->ConstructL(*TheClient->iGroup,rect,KDrawingDsa,1);
       
  2963 	iAnims[0]->StartL(ETrue);
       
  2964 	// First animation is for showing that child window is to the side of visible part of parent window
       
  2965 	rect.Move(screenSize.iWidth>>1,0);
       
  2966 	iAnims[1]=new(ELeave) CColorAnimation(iTest->iScreenNumber,16,*this);
       
  2967 	iAnims[1]->ConstructL(*TheClient->iGroup,rect,KDrawingDsa,2);
       
  2968 	iAnims[1]->StartL(ETrue);
       
  2969 	return EWait;
       
  2970 	}
       
  2971 
       
  2972 TestState CTDirect::MultipleDSAsOnSameWindowL()
       
  2973 	{
       
  2974 	TInt numProcessHandles;
       
  2975 	RThread().HandleCount(numProcessHandles,iNumThreadHandles);
       
  2976 	iCallBackWin->SetVisible(ETrue);
       
  2977 	iCallBackWin->WinTreeNode()->SetOrdinalPosition(0);
       
  2978 	iAnims[0]=new(ELeave) CColorAnimation(iTest->iScreenNumber,20,*this);
       
  2979 	iAnims[0]->ConstructL(*TheClient->iGroup,TRect(),KDrawingDsa,0,1);
       
  2980 	iAnims[0]->StartL();
       
  2981 	iAnims[1]=new(ELeave) CColorAnimation(iTest->iScreenNumber,21,*this);
       
  2982 	iAnims[1]->ConstructL(*TheClient->iGroup,TRect(),KDrawingDsa,0,2);
       
  2983 	iAnims[1]->StartL();
       
  2984 	_LIT(ThreadName,"MoveWin");
       
  2985 	MoveInterval=100000;
       
  2986 	ModeInterval=0;
       
  2987 	FlipInterval=0;
       
  2988 	ImmediateModeSwitch=EFalse;
       
  2989 	iFirstFunction=TThreadStartUp(CMoveWindow::StartLC,(TAny*)iTest->iScreenNumber);
       
  2990 	iMoveWin=CProcess::NewThreadL(ThreadName,&iFirstFunction);
       
  2991 	return EWait;
       
  2992 	}
       
  2993 
       
  2994 TestState CTDirect::KillAnimationL()
       
  2995 	{
       
  2996 	TInt numProcessHandles;
       
  2997 	RThread().HandleCount(numProcessHandles,iNumThreadHandles);
       
  2998 	iAnim=CColorAnimation::NewL(iTest->iScreenNumber,12,*this,*TheClient->iGroup,TRect(15,15,625,225),ETrue);
       
  2999 	return EWait;
       
  3000 	}
       
  3001 
       
  3002 TestState CTDirect::TemporaryDeadlockL()
       
  3003 	{
       
  3004 
       
  3005 	if (iTestJustCompleted)
       
  3006 		{
       
  3007 			if (iTestJustFailed)
       
  3008 			{
       
  3009 			Fail();
       
  3010 			}
       
  3011 		iState++;
       
  3012 		return ENext;
       
  3013 		}
       
  3014 
       
  3015 	//make sure this code isn't called a second time
       
  3016 	__ASSERT_ALWAYS(iAnim==NULL,AutoPanic(EAutoPanicDirect));
       
  3017 
       
  3018 	TSize screenSize(TheClient->iScreen->SizeInPixels());
       
  3019 	TRect rect(0,0,screenSize.iWidth>>1,screenSize.iHeight);
       
  3020 	rect.Shrink(10,10);
       
  3021 	iAnim=new(ELeave) CColorAnimation(iTest->iScreenNumber,24,*this);
       
  3022 	iAnim->ConstructL(*TheClient->iGroup,rect,KDrawingDsa,1);
       
  3023 	iAnim->StartL(ETrue);
       
  3024 	return EWait;
       
  3025 	}
       
  3026 
       
  3027 void CTDirect::CheckForTemporaryDeadlock()
       
  3028 	{
       
  3029 
       
  3030 	TBool result=ETrue;
       
  3031 	TInt error;
       
  3032 
       
  3033 
       
  3034 	//Create a window for placing on top
       
  3035 	TTime beforeTime;
       
  3036 	beforeTime.HomeTime();
       
  3037 
       
  3038 	RWindow window(TheClient->iWs);
       
  3039 
       
  3040 	error=window.Construct(*TheClient->iGroup->GroupWin(), reinterpret_cast<TInt>(&window));
       
  3041 	if (error==KErrNone)
       
  3042 		{
       
  3043 		window.SetOrdinalPosition(0);
       
  3044 		window.SetExtent(TPoint(30,30),TSize(10,10));
       
  3045 		window.SetBackgroundColor(TRgb(255,0,255));
       
  3046 
       
  3047 		//make sure the basewin is towards the back
       
  3048 		iCallBackWin->BaseWin()->SetOrdinalPosition(5);
       
  3049 
       
  3050 		window.SetRequiredDisplayMode(EColor256);
       
  3051 		window.Activate();
       
  3052 		TheClient->iWs.Flush();
       
  3053 		//need code similar to below, but the status of the active object we
       
  3054 		//really want is too private
       
  3055 		//if (!iAnim->IsReadyToAbort())
       
  3056 		//	{
       
  3057 		//	result=EFalse;
       
  3058 		//	}
       
  3059 		window.Close();
       
  3060 		}
       
  3061 	else
       
  3062 		{
       
  3063 		result = EFalse;
       
  3064 		}
       
  3065 
       
  3066 	TTime afterTime;
       
  3067 	afterTime.HomeTime();
       
  3068 	TTimeIntervalMicroSeconds difference = afterTime.MicroSecondsFrom(beforeTime);
       
  3069 
       
  3070 	//make time difference 350ms, since the two timers to be checked are 400ms and 500ms
       
  3071 	if (difference>TTimeIntervalMicroSeconds(1000*350))
       
  3072 		{
       
  3073 		result=EFalse;
       
  3074 		}
       
  3075 
       
  3076 	iTestJustCompleted = ETrue;
       
  3077 	if (result==EFalse)
       
  3078 		{
       
  3079 		iTestJustFailed=ETrue;
       
  3080 		}
       
  3081 	}
       
  3082 
       
  3083 void CTDirect::RunTestCaseL(TInt /*aCurTestCase*/)
       
  3084 	{
       
  3085 	_LIT(Animation1,"Animating");
       
  3086 	_LIT(Animation2,"Animating Dies");
       
  3087 	_LIT(Animation3,"Packaging Class");
       
  3088 	_LIT(Animation4,"Many Animations");
       
  3089 	_LIT(Animation5,"Fail Codes");
       
  3090 	_LIT(Animation6,"Cancel The Other");
       
  3091 	_LIT(Animation7,"'R' Class API");
       
  3092 	_LIT(Animation8,"Switch Clear Type");
       
  3093 	_LIT(Animation9,"SizeMode Change");
       
  3094 	_LIT(Animation10,"Soak Testing");
       
  3095 	_LIT(Animation11,"Kill Animation");
       
  3096 	_LIT(Animation12,"Defect-Fix: KAA-5J3BLW");
       
  3097 	_LIT(Animation13,"Screen Mode Positioning DSA Test 1");
       
  3098 	_LIT(Animation14,"Screen Mode Positioning DSA Test 2");
       
  3099 	_LIT(Animation15,"Position Relative to Screen");
       
  3100 	_LIT(Animation16,"Screen mode Scaling DSA Test 1");
       
  3101 	_LIT(Animation17,"Screen mode Scaling DSA Test 2");
       
  3102 	_LIT(Animation18,"Multiple DSAs on same window");
       
  3103 	_LIT(Animation19,"DSA and windows temporary deadlock");
       
  3104 	_LIT(Animation25,"RegionTrackingOnly DSA, window opened in front");
       
  3105 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
       
  3106 	_LIT(Animation26,"RegionTrackingOnly DSA, window opened behind");
       
  3107 	_LIT(Animation27,"Mixed DSAs, RegionTrackingOnly DSA last to exit");
       
  3108 	_LIT(Animation28,"Mixed DSAs, drawing DSA last to exit");
       
  3109 	_LIT(Animation29,"Trying all the screen supported modes");
       
  3110 #endif
       
  3111 	TestState ret=ENext;
       
  3112 
       
  3113 	if (iTimerRunning && !iPackagingFinished)
       
  3114 		{
       
  3115 		// Prevent test harness from repeatedly running the test case too quickly.
       
  3116 		User::After(SHORT_DELAY);
       
  3117 		}
       
  3118 
       
  3119 	//if (iState==0) iState=18;
       
  3120 	iTest->iState=iState;
       
  3121 	((CTDirectStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
       
  3122 	switch(iState)
       
  3123 		{
       
  3124 /**
       
  3125 @SYMTestCaseID		GRAPHICS-WSERV-0158
       
  3126 
       
  3127 @SYMDEF             DEF081259
       
  3128 
       
  3129 @SYMTestCaseDesc    Create seven seperate animations and run them to completion
       
  3130 
       
  3131 @SYMTestPriority    High
       
  3132 
       
  3133 @SYMTestStatus      Implemented
       
  3134 
       
  3135 @SYMTestActions     Create animations and start them running. Run until the animations finish.
       
  3136 
       
  3137 @SYMTestExpectedResults The animation run to completion without error
       
  3138 */
       
  3139 	case 0:
       
  3140 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158"));
       
  3141 		if (iNextFrameFinished)
       
  3142 			InitialiseAnimationL();
       
  3143 	case 1:
       
  3144 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158"));
       
  3145 	case 2:
       
  3146 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158"));
       
  3147 	case 3:
       
  3148 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158"));
       
  3149 	case 4:
       
  3150 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158"));
       
  3151 	case 5:
       
  3152 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158"));
       
  3153 	case 6:
       
  3154 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0158"));
       
  3155 		if (iNextFrameFinished)
       
  3156 			{
       
  3157 			iTest->LogSubTest(Animation1);
       
  3158 			ret=AnimateWindowL();
       
  3159 			iNextFrameFinished=EFalse;
       
  3160 			}
       
  3161 		else
       
  3162 			{
       
  3163 			// Prevent test harness from repeatedly running the test case too quickly.
       
  3164 			User::After(SHORT_DELAY);
       
  3165 			}
       
  3166 		break;
       
  3167 /**
       
  3168 @SYMTestCaseID		GRAPHICS-WSERV-0159
       
  3169 
       
  3170 @SYMDEF             DEF081259
       
  3171 
       
  3172 @SYMTestCaseDesc    Check animation dies correctly when run in a thread
       
  3173 
       
  3174 @SYMTestPriority    High
       
  3175 
       
  3176 @SYMTestStatus      Implemented
       
  3177 
       
  3178 @SYMTestActions     Create animation and run in from a thread that dies. Once the thread
       
  3179 					has died check the animation has been dealt with correctly.
       
  3180 
       
  3181 @SYMTestExpectedResults The animation dies correctly
       
  3182 */
       
  3183 	case 7:
       
  3184 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0159"));
       
  3185 		iTest->LogSubTest(Animation2);
       
  3186 		ret=AnimationDiesL();
       
  3187 		++iState;
       
  3188 		DestroyAnimation();
       
  3189 		break;
       
  3190 /**
       
  3191 @SYMTestCaseID		GRAPHICS-WSERV-0160
       
  3192 
       
  3193 @SYMDEF             DEF081259
       
  3194 
       
  3195 @SYMTestCaseDesc    Check animation runs correctly in blank window
       
  3196 
       
  3197 @SYMTestPriority    High
       
  3198 
       
  3199 @SYMTestStatus      Implemented
       
  3200 
       
  3201 @SYMTestActions     Create an animation and run it in a blank window
       
  3202 
       
  3203 @SYMTestExpectedResults The animation runs to completion without error
       
  3204 */
       
  3205 	case 8:
       
  3206 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0160"));
       
  3207 		if (!iTimerRunning)
       
  3208 			{
       
  3209 			iTest->LogSubTest(Animation3);
       
  3210 			ret=PackagingClassL();
       
  3211 			iTimerRunning = ETrue;
       
  3212 			}
       
  3213 		if (iPackagingFinished)
       
  3214 			{
       
  3215 			iPackagingFinished = EFalse;
       
  3216 			iTimerRunning = EFalse;
       
  3217 			}
       
  3218 		break;
       
  3219 /**
       
  3220 @SYMTestCaseID		GRAPHICS-WSERV-0161
       
  3221 
       
  3222 @SYMDEF             DEF081259
       
  3223 
       
  3224 @SYMTestCaseDesc    Check many animations can be run in the same window
       
  3225 
       
  3226 @SYMTestPriority    High
       
  3227 
       
  3228 @SYMTestStatus      Implemented
       
  3229 
       
  3230 @SYMTestActions     Create multiple animations in a window and run them all
       
  3231 					until completion
       
  3232 
       
  3233 @SYMTestExpectedResults The animations run without error
       
  3234 */
       
  3235 	case 9:
       
  3236 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0161"));
       
  3237 		if (!iTimerRunning)
       
  3238 			{
       
  3239 			iTest->LogSubTest(Animation4);
       
  3240 			ret=MultipleL();
       
  3241 			iTimerRunning = ETrue;
       
  3242 			}
       
  3243 		if (iPackagingFinished)
       
  3244 			{
       
  3245 			iPackagingFinished = EFalse;
       
  3246 			iTimerRunning = EFalse;
       
  3247 			}
       
  3248 		break;
       
  3249 /**
       
  3250 @SYMTestCaseID		GRAPHICS-WSERV-0162
       
  3251 
       
  3252 @SYMDEF             DEF081259
       
  3253 
       
  3254 @SYMTestCaseDesc    Direct screen access out of memory test
       
  3255 
       
  3256 @SYMTestPriority    High
       
  3257 
       
  3258 @SYMTestStatus      Implemented
       
  3259 
       
  3260 @SYMTestActions     Direct screen access out of memory test
       
  3261 
       
  3262 @SYMTestExpectedResults The out of memory error is handled correctly
       
  3263 */
       
  3264 	case 10:
       
  3265 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0162"));
       
  3266 		iTest->LogSubTest(Animation5);
       
  3267 		ret=FailCodesL();
       
  3268 		iState++;
       
  3269 		break;
       
  3270 /**
       
  3271 @SYMTestCaseID		GRAPHICS-WSERV-0163
       
  3272 
       
  3273 @SYMDEF             DEF081259
       
  3274 
       
  3275 @SYMTestCaseDesc    Two animations, one scrolling text
       
  3276 
       
  3277 @SYMTestPriority    High
       
  3278 
       
  3279 @SYMTestStatus      Implemented
       
  3280 
       
  3281 @SYMTestActions     Create two animations, one which scrolls text across the screen and
       
  3282 					run them to completion
       
  3283 
       
  3284 @SYMTestExpectedResults The animations run without error
       
  3285 */
       
  3286 	case 11:		
       
  3287 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0163"));
       
  3288 		if (!iTimerRunning)
       
  3289 			{
       
  3290 			iTest->LogSubTest(Animation6);
       
  3291 			ret=ScrolingText1L();
       
  3292 			iTimerRunning = ETrue;
       
  3293 			}
       
  3294 		if (iPackagingFinished)
       
  3295 			{
       
  3296 			iPackagingFinished = EFalse;
       
  3297 			iTimerRunning = EFalse;
       
  3298 			}
       
  3299 		break;
       
  3300 /**
       
  3301 @SYMTestCaseID		GRAPHICS-WSERV-0164
       
  3302 
       
  3303 @SYMDEF             DEF081259
       
  3304 
       
  3305 @SYMTestCaseDesc    Test direct screen access panic messages
       
  3306 
       
  3307 @SYMTestPriority    High
       
  3308 
       
  3309 @SYMTestStatus      Implemented
       
  3310 
       
  3311 @SYMTestActions     Call the direct screen access panic's and check they are handled
       
  3312 					correctly
       
  3313 
       
  3314 @SYMTestExpectedResults The panic's are handled correctly
       
  3315 */
       
  3316 	case 12:
       
  3317 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0164"));
       
  3318 		iTest->LogSubTest(Animation7);
       
  3319 		ret=RClassL();
       
  3320 		iTest->CloseAllPanicWindows();
       
  3321 		iState++;
       
  3322 		break;
       
  3323 /**
       
  3324 @SYMTestCaseID		GRAPHICS-WSERV-0165
       
  3325 
       
  3326 @SYMDEF             DEF081259
       
  3327 
       
  3328 @SYMTestCaseDesc    Two animations, one scrolling text
       
  3329 
       
  3330 @SYMTestPriority    High
       
  3331 
       
  3332 @SYMTestStatus      Implemented
       
  3333 
       
  3334 @SYMTestActions     Create two animations, one which scrolls text across the screen and
       
  3335 					run them to completion
       
  3336 
       
  3337 @SYMTestExpectedResults The animations run without error
       
  3338 */
       
  3339 	case 13:
       
  3340 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0165"));
       
  3341 		if (!iTimerRunning)
       
  3342 			{
       
  3343 			iTest->LogSubTest(Animation8);
       
  3344 			ret=ScrolingText2L();
       
  3345 			iTimerRunning = ETrue;
       
  3346 			}
       
  3347 		if (iPackagingFinished)
       
  3348 			{
       
  3349 			iPackagingFinished = EFalse;
       
  3350 			iTimerRunning = EFalse;
       
  3351 			}
       
  3352 		break;
       
  3353 /**
       
  3354 @SYMTestCaseID		GRAPHICS-WSERV-0166
       
  3355 
       
  3356 @SYMDEF             DEF081259
       
  3357 
       
  3358 @SYMTestCaseDesc    Two animations, one scrolling text. Change the screen mode an run.
       
  3359 
       
  3360 @SYMTestPriority    High
       
  3361 
       
  3362 @SYMTestStatus      Implemented
       
  3363 
       
  3364 @SYMTestActions     Create two animations, one which scrolls text across the screen and
       
  3365 					run them to completion while changing the screen mode
       
  3366 
       
  3367 @SYMTestExpectedResults The animations run without error
       
  3368 */
       
  3369 	
       
  3370 	case 14:
       
  3371 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0166"));
       
  3372 		if (!iTimerRunning)
       
  3373 			{
       
  3374 			iTest->LogSubTest(Animation9);
       
  3375 			ret=ScrolingText3L();
       
  3376 			if (ret == ENext)
       
  3377 				iPackagingFinished = ETrue;
       
  3378 			else
       
  3379 				iTimerRunning = ETrue;
       
  3380 			}
       
  3381 		if (iPackagingFinished)
       
  3382 			{
       
  3383 			iPackagingFinished = EFalse;
       
  3384 			iTimerRunning = EFalse;
       
  3385 			FlipInterval = 0; // Stops the tests (erroneously) flipping for the rest of the run
       
  3386 			}
       
  3387 		break;
       
  3388 /**
       
  3389 @SYMTestCaseID		GRAPHICS-WSERV-0167
       
  3390 
       
  3391 @SYMDEF             DEF081259
       
  3392 
       
  3393 @SYMTestCaseDesc    Start an animation then kill it
       
  3394 
       
  3395 @SYMTestPriority    High
       
  3396 
       
  3397 @SYMTestStatus      Implemented
       
  3398 
       
  3399 @SYMTestActions     Start an animation running then kill it. Check the animation dies correctly
       
  3400 
       
  3401 @SYMTestExpectedResults The animations dies correctly
       
  3402 */
       
  3403 	case 15:
       
  3404 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0167"));
       
  3405 		if (!iTimerRunning)
       
  3406 			{
       
  3407 			iTest->LogSubTest(Animation11);
       
  3408 			ret=KillAnimationL();
       
  3409 			iTimerRunning = ETrue;
       
  3410 			}
       
  3411 		if (iPackagingFinished)
       
  3412 			{
       
  3413 			iPackagingFinished = EFalse;
       
  3414 			iTimerRunning = EFalse;
       
  3415 			}
       
  3416 		break;
       
  3417 	case 16:
       
  3418 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0167"));
       
  3419 		iTest->LogSubTest(Animation10);		//This test is designed to be left running for at least several hours
       
  3420 		//ret=ScrolingText4L();
       
  3421 		iState++;
       
  3422 		break;
       
  3423 /**
       
  3424 @SYMTestCaseID		GRAPHICS-WSERV-0168
       
  3425 
       
  3426 @SYMDEF             DEF081259
       
  3427 
       
  3428 @SYMTestCaseDesc    CBugFixColorAnimation
       
  3429 
       
  3430 @SYMTestPriority    High
       
  3431 
       
  3432 @SYMTestStatus      Implemented
       
  3433 
       
  3434 @SYMTestActions     This class is used for reproducing a defect found on 6.1: KAA-5J3BLW "Unnecessary Wserv's DSA abort".
       
  3435 					The problem was that a direct screen access client was getting an unnecessary abort notification
       
  3436 					when a new window (or window group) was created but not visible.
       
  3437 					This class will simulate the direct screen access client and it will check whether the first DSA abort
       
  3438 					is not caused by just creating a window.
       
  3439 
       
  3440 @SYMTestExpectedResults Abort is not caused when creatung a window
       
  3441 */	
       
  3442 	case 17:
       
  3443 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0168"));
       
  3444 		if (!iTimerRunning)
       
  3445 			{
       
  3446 			iTest->LogSubTest(Animation12);
       
  3447 			ret=DefectFix_KAA_5J3BLW_L();
       
  3448 			iTimerRunning = ETrue;
       
  3449 			}
       
  3450 		if (iPackagingFinished)
       
  3451 			{
       
  3452 			iPackagingFinished = EFalse;
       
  3453 			iTimerRunning = EFalse;
       
  3454 			}
       
  3455 		break;
       
  3456 /**
       
  3457 @SYMTestCaseID		GRAPHICS-WSERV-0169
       
  3458 
       
  3459 @SYMDEF             DEF081259
       
  3460 
       
  3461 @SYMTestCaseDesc    Direct screen access in screen modes with non-zero screen mode origin
       
  3462 
       
  3463 @SYMTestPriority    High
       
  3464 
       
  3465 @SYMTestStatus      Implemented
       
  3466 
       
  3467 @SYMTestActions     Tests that DSA works correctly in screen modes with non-zero screen mode origin
       
  3468 
       
  3469 @SYMTestExpectedResults The DSA works correctly
       
  3470 */
       
  3471 	case 18:
       
  3472 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0169"));
       
  3473 		if (!CheckNonZeroOriginsSupportedOrNot())
       
  3474 			{
       
  3475 			INFO_PRINTF1(_L("Non Zero Origins not supported\n"));
       
  3476 			iState++;
       
  3477 			}
       
  3478 		else
       
  3479 			{
       
  3480 			if (!iTimerRunning)
       
  3481 				{
       
  3482 				iTest->LogSubTest(Animation13);
       
  3483 				ret=DSAWithScreenModeOffset1L();
       
  3484 				iTimerRunning = ETrue;
       
  3485 				}
       
  3486 			if (iPackagingFinished)
       
  3487 				{
       
  3488 				iPackagingFinished = EFalse;
       
  3489 				iTimerRunning = EFalse;
       
  3490 				}
       
  3491 			}
       
  3492 		break;
       
  3493 /**
       
  3494 @SYMTestCaseID		GRAPHICS-WSERV-0170
       
  3495 
       
  3496 @SYMDEF             DEF081259
       
  3497 
       
  3498 @SYMTestCaseDesc    Direct screen access in screen modes with non-zero screen mode origin
       
  3499 
       
  3500 @SYMTestPriority    High
       
  3501 
       
  3502 @SYMTestStatus      Implemented
       
  3503 
       
  3504 @SYMTestActions     Tests that DSA works correctly in screen modes with non-zero screen mode origin and different rotations
       
  3505 
       
  3506 @SYMTestExpectedResults The DSA works correctly
       
  3507 */
       
  3508 	case 19:
       
  3509 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0170"));
       
  3510 		if (!CheckNonZeroOriginsSupportedOrNot())
       
  3511 			{
       
  3512 			INFO_PRINTF1(_L("Non Zero Origins not supported\n"));
       
  3513 			iState++;
       
  3514 			}
       
  3515 		else
       
  3516 			{
       
  3517 			if (!iTimerRunning)
       
  3518 				{
       
  3519 				iTest->LogSubTest(Animation14);
       
  3520 				ret=DSAWithScreenModeOffset2L();
       
  3521 				iTimerRunning = ETrue;
       
  3522 				}
       
  3523 			if (iPackagingFinished)
       
  3524 				{
       
  3525 				iPackagingFinished = EFalse;
       
  3526 				iTimerRunning = EFalse;
       
  3527 				}
       
  3528 			}
       
  3529 		break;
       
  3530 /**
       
  3531 @SYMTestCaseID		GRAPHICS-WSERV-0171
       
  3532 
       
  3533 @SYMDEF             DEF081259
       
  3534 
       
  3535 @SYMTestCaseDesc    Window absolute position
       
  3536 
       
  3537 @SYMTestPriority    High
       
  3538 
       
  3539 @SYMTestStatus      Implemented
       
  3540 
       
  3541 @SYMTestActions     Tests the new function of getting the window's absolute position
       
  3542 
       
  3543 @SYMTestExpectedResults Function works correctly
       
  3544 */
       
  3545 	case 20:
       
  3546 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0171"));
       
  3547 		if (!iTimerRunning)
       
  3548 			{
       
  3549 			iTest->LogSubTest(Animation15);
       
  3550 			ret=WindowPoistionRelativeToScreenL();
       
  3551 			iTimerRunning = ETrue;
       
  3552 			}
       
  3553 		if (iPackagingFinished)
       
  3554 			{
       
  3555 			iPackagingFinished = EFalse;
       
  3556 			iTimerRunning = EFalse;
       
  3557 			}
       
  3558 		break;
       
  3559 /**
       
  3560 @SYMTestCaseID		GRAPHICS-WSERV-0172
       
  3561 
       
  3562 @SYMDEF             DEF081259
       
  3563 
       
  3564 @SYMTestCaseDesc    Test direct screen access restart
       
  3565 
       
  3566 @SYMTestPriority    High
       
  3567 
       
  3568 @SYMTestStatus      Implemented
       
  3569 
       
  3570 @SYMTestActions     Creates a DSA for screen mode 0. After DSA has displayed 2 or 3 frames screen mode
       
  3571  					scale is changed with a timer. The DSA aborts and restarts once again
       
  3572  					and completes itself in different screen mode.
       
  3573 
       
  3574 @SYMTestExpectedResults DSA restarts and completes correctly
       
  3575 */
       
  3576 	case 21:
       
  3577 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0172"));
       
  3578 		if (iIsScalingSupported)
       
  3579 			{
       
  3580 			if (!iTimerRunning)
       
  3581 				{
       
  3582 				iTest->LogSubTest(Animation16);
       
  3583 				ret=ScreenModeTestForScalingL();
       
  3584 				iTimerRunning = ETrue;
       
  3585 				}
       
  3586 			if (iPackagingFinished)
       
  3587 				{
       
  3588 				iPackagingFinished = EFalse;
       
  3589 				iTimerRunning = EFalse;
       
  3590 				}
       
  3591 			break;
       
  3592 			}
       
  3593 		iState++;
       
  3594 		break;
       
  3595 /**
       
  3596 @SYMTestCaseID		GRAPHICS-WSERV-0173
       
  3597 
       
  3598 @SYMDEF             DEF081259
       
  3599 
       
  3600 @SYMTestCaseDesc    Test direct screen access scaling
       
  3601 
       
  3602 @SYMTestPriority    High
       
  3603 
       
  3604 @SYMTestStatus      Implemented
       
  3605 
       
  3606 @SYMTestActions     Creates a DSA for screen mode 0, tests API AbsoluteWindowPosition()
       
  3607  					Then sets screen mode to last(test) screen mode, here it does the same thing as
       
  3608  					done for screenmode 0, but with diffrerent scale (2,2) (2,3) (3,2) (3,3) and
       
  3609  					with different origin (20,30) (30,20) (20,20).
       
  3610  					Lastly copy back the test screen mode values.
       
  3611 
       
  3612 @SYMTestExpectedResults DSA scales correctly
       
  3613 */
       
  3614 	case 22:
       
  3615 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0173"));
       
  3616 		if (iIsScalingSupported)
       
  3617 			{
       
  3618 			if (!iTimerRunning)
       
  3619 				{
       
  3620 				iTest->LogSubTest(Animation17);
       
  3621 				ret=ScreenModeScalingTestL();
       
  3622 				iTimerRunning = ETrue;
       
  3623 				}
       
  3624 			if (iPackagingFinished)
       
  3625 				{
       
  3626 				iPackagingFinished = EFalse;
       
  3627 				iTimerRunning = EFalse;
       
  3628 				}
       
  3629 			break;
       
  3630 			}
       
  3631 		iState++;
       
  3632 		break;
       
  3633 /**
       
  3634 @SYMTestCaseID		GRAPHICS-WSERV-0174
       
  3635 
       
  3636 @SYMDEF             DEF081259
       
  3637 
       
  3638 @SYMTestCaseDesc    Test multiple direct screen access elements on the same window 
       
  3639 
       
  3640 @SYMTestPriority    High
       
  3641 
       
  3642 @SYMTestStatus      Implemented
       
  3643 
       
  3644 @SYMTestActions     Create a number of direct screen access elements on the same window and
       
  3645 					check that they work correctly
       
  3646 
       
  3647 @SYMTestExpectedResults DSAs work correctly
       
  3648 */
       
  3649 	case 23:
       
  3650 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0174"));
       
  3651 		if (iIsScalingSupported)
       
  3652 			{
       
  3653 			if (!iTimerRunning)
       
  3654 				{
       
  3655 				iTest->LogSubTest(Animation18);
       
  3656 				ret=MultipleDSAsOnSameWindowL();
       
  3657 				iTimerRunning = ETrue;
       
  3658 				}
       
  3659 			if (iPackagingFinished)
       
  3660 				{
       
  3661 				iPackagingFinished = EFalse;
       
  3662 				iTimerRunning = EFalse;
       
  3663 				}	
       
  3664 			break;
       
  3665 			}
       
  3666 		iState++;
       
  3667 		break;
       
  3668 /**
       
  3669 @SYMTestCaseID		GRAPHICS-WSERV-0175
       
  3670 
       
  3671 @SYMDEF             DEF081259
       
  3672 
       
  3673 @SYMTestCaseDesc    Create a temporary deadlock on a DSA and resolve it 
       
  3674 
       
  3675 @SYMTestPriority    High
       
  3676 
       
  3677 @SYMTestStatus      Implemented
       
  3678 
       
  3679 @SYMTestActions     Resolve a temporary deadlock on a DSA
       
  3680 
       
  3681 @SYMTestExpectedResults DSA resolves the deadlock
       
  3682 */
       
  3683 	case 24:
       
  3684 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0175"));
       
  3685 		if (!iTimerRunning)
       
  3686 			{
       
  3687 			iTest->LogSubTest(Animation19);
       
  3688 			ret=TemporaryDeadlockL();//for INC072887 - removing a 0.5s delay in wserv.
       
  3689 			iTimerRunning = ETrue;
       
  3690 			}
       
  3691 		if (iPackagingFinished)
       
  3692 			{
       
  3693 			iPackagingFinished = EFalse;
       
  3694 			iTimerRunning = EFalse;
       
  3695 			iState++;
       
  3696 			}
       
  3697 		break;
       
  3698 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
       
  3699 	case 25:
       
  3700 /**
       
  3701 @SYMTestCaseID		GRAPHICS-WSERV-0533
       
  3702 */
       
  3703 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0533"));
       
  3704 		if (!iTimerRunning)
       
  3705 			{
       
  3706 			FlipInterval=0;
       
  3707 			iTest->LogSubTest(Animation25);
       
  3708 			//Opens a window in front of a region tracking only DSA
       
  3709 			ret=RegionTrackingOnlyNotificationsL(KRegionTrackingOnlyDsaWaitingForAbortSignal);
       
  3710 			iTimerRunning = ETrue;
       
  3711 			}
       
  3712 		if (iPackagingFinished)
       
  3713 			{
       
  3714 			iPackagingFinished = EFalse;
       
  3715 			iTimerRunning = EFalse;
       
  3716 			}
       
  3717 		break;
       
  3718 	case 26:
       
  3719 /**
       
  3720 @SYMTestCaseID		GRAPHICS-WSERV-0534
       
  3721 */
       
  3722 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0534"));
       
  3723 		if (!iTimerRunning)
       
  3724 			{
       
  3725 			iTest->LogSubTest(Animation26);
       
  3726 			//Opens a window behind a region tracking only DSA
       
  3727 			ret=RegionTrackingOnlyNotificationsL(KRegionTrackingOnlyDsaNoAbortSignal);
       
  3728 			iTimerRunning = ETrue;
       
  3729 			}
       
  3730 		if (iPackagingFinished)
       
  3731 			{
       
  3732 			iPackagingFinished = EFalse;
       
  3733 			iTimerRunning = EFalse;
       
  3734 			}
       
  3735 		break;
       
  3736 	case 27:
       
  3737 /**
       
  3738 @SYMTestCaseID		GRAPHICS-WSERV-0535
       
  3739 */
       
  3740 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0535"));
       
  3741 		if (!iTimerRunning)
       
  3742 			{
       
  3743 			iTest->LogSubTest(Animation27);
       
  3744 			ret=MixDsaAndRegionTrackingOnlyL(KRegionTrackingOnlyDsaExistLast);
       
  3745 			iTimerRunning = ETrue;
       
  3746 			}
       
  3747 		if (iPackagingFinished)
       
  3748 			{
       
  3749 			iPackagingFinished = EFalse;
       
  3750 			iTimerRunning = EFalse;
       
  3751 			}
       
  3752 		break;
       
  3753 	case 28:
       
  3754 /**
       
  3755 @SYMTestCaseID		GRAPHICS-WSERV-0536
       
  3756 */
       
  3757 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0536"));
       
  3758 		if (!iTimerRunning)
       
  3759 			{
       
  3760 			iTest->LogSubTest(Animation28);
       
  3761 			ret=MixDsaAndRegionTrackingOnlyL(KDrawingDsaExistLast);
       
  3762 			iTimerRunning = ETrue;
       
  3763 			}
       
  3764 		if (iPackagingFinished)
       
  3765 			{
       
  3766 			iPackagingFinished = EFalse;
       
  3767 			iTimerRunning = EFalse;
       
  3768 			}
       
  3769 		break;
       
  3770 	case 29:
       
  3771 /**
       
  3772 @SYMTestCaseID		GRAPHICS-WSERV-0537
       
  3773 */
       
  3774 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0537"));
       
  3775 		if (!iTimerRunning)
       
  3776 			{
       
  3777 			iTest->LogSubTest(Animation29);
       
  3778 			ret=TryDifferentSupportedModesL();
       
  3779 			iTimerRunning = ETrue;
       
  3780 			}
       
  3781 		if (iPackagingFinished)
       
  3782 			{
       
  3783 			iPackagingFinished = EFalse;
       
  3784 			iTimerRunning = EFalse;
       
  3785 			}
       
  3786 		break;
       
  3787 #else
       
  3788 //NON NGA negative test for RegionTrackingOnly DSA
       
  3789 	case 25:
       
  3790 /**
       
  3791 @SYMTestCaseID		GRAPHICS-WSERV-0575
       
  3792 */
       
  3793 		((CTDirectStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0575"));
       
  3794 		if (!iTimerRunning)
       
  3795 			{
       
  3796 			FlipInterval=0;
       
  3797 			iTest->LogSubTest(Animation25);
       
  3798 			CColorAnimation* temp = NULL;
       
  3799 			//Attempt to create a RegionTrackingOnly DSA in non NGA code
       
  3800 			TRAPD(err,temp = CColorAnimation::NewL(iTest->iScreenNumber,1,*this,*TheClient->iGroup,TRect(10,10,630,230),ETrue,KRegionTrackingOnly));
       
  3801 			if(err!=KErrNotSupported)
       
  3802 				{
       
  3803 				_LIT(KCTDirectNonNgaError,"Attempt to creat a RegionTrackingOnly DSA did not return KErrNotSupported on non-NGA");
       
  3804 				LOG_MESSAGE(KCTDirectNonNgaError);
       
  3805 				if(temp)
       
  3806 					{
       
  3807 					delete temp;
       
  3808 					}
       
  3809 				Fail();
       
  3810 				}
       
  3811 			else
       
  3812 				{
       
  3813 				_LIT(KCTDirectNonNgaSuccess,"RegionTrackingOnly DSA not supported on non-NGA as expected");
       
  3814 				LOG_MESSAGE(KCTDirectNonNgaSuccess);
       
  3815 				}
       
  3816 			iState++;
       
  3817 			}
       
  3818 		break;
       
  3819 #endif
       
  3820 	default:
       
  3821 		((CTDirectStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
  3822 		((CTDirectStep*)iStep)->CloseTMSGraphicsStep();
       
  3823 		TestComplete();
       
  3824 		break;
       
  3825 		}
       
  3826 	((CTDirectStep*)iStep)->RecordTestResultL();
       
  3827 	}
       
  3828 
       
  3829 CRegionTrackingOnly* CRegionTrackingOnly::NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWindowGroup& aParent,TRect aExtent,TBool aStart,TBool aOpenWindowInFrontDsa)
       
  3830 	{
       
  3831 	CRegionTrackingOnly* self=new(ELeave) CRegionTrackingOnly(aScreenNumber, aId,aCallBack);
       
  3832 	CleanupStack::PushL(self);
       
  3833 	self->ConstructL(aParent,aExtent,aOpenWindowInFrontDsa);
       
  3834 	if (aStart)
       
  3835 		{
       
  3836 		self->StartL();
       
  3837 		self->Started();
       
  3838 		}
       
  3839 	CleanupStack::Pop(self);
       
  3840 	return self;
       
  3841 	}
       
  3842 
       
  3843 CRegionTrackingOnly::CRegionTrackingOnly(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack)
       
  3844 	: CColorAnimation(aScreenNumber, aId, aCallBack)
       
  3845 	{
       
  3846 	iThreadParam.iScreenNumber = aScreenNumber;
       
  3847 	}
       
  3848 
       
  3849 void CRegionTrackingOnly::ConstructL(CTWindowGroup& aParent,TRect aExtent,TBool aOpenWindowInFrontDsa)
       
  3850 	{
       
  3851 	iExpectedToAbort = aOpenWindowInFrontDsa; 
       
  3852 	CColorAnimation::ConstructL(aParent, aExtent, KRegionTrackingOnly);
       
  3853 	_LIT(ThreadName,"Create new Window");
       
  3854 	
       
  3855     TInt error=iSem.CreateGlobal(KSem_DefectFix_KAA_5J3BLW_Name, 0);
       
  3856     if (error==KErrNone)
       
  3857         {
       
  3858         iAnimRect=aExtent;
       
  3859         iThreadParam.iRect = iAnimRect;
       
  3860         iThreadParam.iIsInFront = aOpenWindowInFrontDsa;
       
  3861         TThreadStartUp function=TThreadStartUp(CreateNewWindowGroup, &iThreadParam);
       
  3862         TRequestStatus status;
       
  3863         iThread=CProcess::NewThreadRendezvousL(ThreadName,&function,status);
       
  3864         User::WaitForRequest(status);
       
  3865         if (status != KErrNone)
       
  3866             {
       
  3867             RDebug::Printf("the request status is returned to be non KErrNone: %d", status.Int());
       
  3868             TestFailed(this);
       
  3869             }
       
  3870         }
       
  3871     else
       
  3872         {
       
  3873         TestFailed(this);
       
  3874         }
       
  3875 	}
       
  3876 
       
  3877 TBool CColorAnimation::TestGcAndScreenDeviceValues()
       
  3878 	{
       
  3879 	TBool succeeded = ETrue;
       
  3880 	_LIT(KErrorLogGraphicContext,"GraphicsContext not NULL when using the region tracking feature only");
       
  3881 	_LIT(KErrorLogScreenDevice,"ScreenDevice not NULL when using the region tracking feature only");
       
  3882 	if(iRegionTrackingOnly && iDrawer->Gc() != NULL)
       
  3883 		{
       
  3884 		CallBack().Log((TText8*)__FILE__,__LINE__, ESevrErr,KErrorLogGraphicContext);
       
  3885 		succeeded = EFalse;
       
  3886 		}
       
  3887 	if(iRegionTrackingOnly && iDrawer->ScreenDevice() != NULL)
       
  3888 		{
       
  3889 		CallBack().Log((TText8*)__FILE__,__LINE__, ESevrErr,KErrorLogScreenDevice);
       
  3890 		succeeded = EFalse;
       
  3891 		}
       
  3892 	return succeeded;
       
  3893 	}
       
  3894 
       
  3895 void CRegionTrackingOnly::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
       
  3896 	{
       
  3897 	Stop();
       
  3898 	}
       
  3899 
       
  3900 void CRegionTrackingOnly::Restart(RDirectScreenAccess::TTerminationReasons/* aReason*/)
       
  3901 	{
       
  3902 	if(!TestGcAndScreenDeviceValues())
       
  3903 		{
       
  3904 		CallBack().Fail();
       
  3905 		}
       
  3906 	if (iExpectedToAbort)
       
  3907 		{
       
  3908 		_LIT(KExpected,"DSA got an abort signal as expected");
       
  3909 		CallBack().Log((TText8*)__FILE__,__LINE__,ESevrInfo,KExpected);
       
  3910 		}
       
  3911 	else
       
  3912 		{
       
  3913 		_LIT(KError,"DSA got an abort signal even though the window was opened behind it");
       
  3914 		CallBack().Log((TText8*)__FILE__,__LINE__,ESevrErr,KError);
       
  3915 		CallBack().Fail();
       
  3916 		}
       
  3917 	FinishTest();
       
  3918 	}
       
  3919 
       
  3920 CRegionTrackingOnly::~CRegionTrackingOnly()
       
  3921 	{
       
  3922 	iSem.Close();
       
  3923 	if(iThread)
       
  3924 		{
       
  3925 		TRequestStatus status;
       
  3926 		iThread->Logon(status);
       
  3927 		if (iThread->StillAlive())
       
  3928 			{
       
  3929  			iThread->Terminate(KErrNone);
       
  3930 			User::WaitForRequest(status);
       
  3931 			}
       
  3932 		delete iThread;
       
  3933 		}
       
  3934 	}
       
  3935 
       
  3936 __WS_CONSTRUCT_STEP__(Direct)