1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TBACKUPW.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,953 @@
1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Test backed up windows
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @file
1.23 + @test
1.24 + @internalComponent - Internal Symbian test code
1.25 +*/
1.26 +
1.27 +#include "TBACKUPW.H"
1.28 +
1.29 +CTBackedUpWindow::CTBackedUpWindow(CTestStep* aStep):
1.30 + CTWsGraphicsBase(aStep)
1.31 + {
1.32 + }
1.33 +
1.34 +
1.35 +void CTBackedUpWindow::CheckWindow(CFbsBitmap *aBitmap)
1.36 + {
1.37 + TPoint oldPos=iBackedUpWindow.Position();
1.38 + iBackedUpWindow.SetPosition(TPoint(0,0));
1.39 +
1.40 + iCheckWindow.SetVisible(ETrue);
1.41 + iCheckWindow.SetPosition(iCheckPos);
1.42 +
1.43 + iCheckWindow.BeginRedraw();
1.44 + TheGc->Activate(iCheckWindow);
1.45 + TheGc->BitBlt(TPoint(0,0), aBitmap);
1.46 + TheGc->Deactivate();
1.47 + iCheckWindow.EndRedraw();
1.48 +
1.49 + TheClient->iWs.Flush();
1.50 + TheClient->WaitForRedrawsToFinish();
1.51 + TBool retVal = TheClient->iScreen->RectCompare(TRect(iSize),TRect(iCheckPos,iSize));
1.52 + TEST(retVal);
1.53 + if (!retVal)
1.54 + INFO_PRINTF3(_L("TheClient->iScreen->RectCompare(TRect(iSize),TRect(iCheckPos,iSize)) return value - Expected: %d , Actual: %d"), ETrue, retVal);
1.55 +
1.56 + iCheckWindow.SetVisible(EFalse);
1.57 + iBackedUpWindow.SetPosition(oldPos);
1.58 + }
1.59 +
1.60 +void CTBackedUpWindow::CheckWindow()
1.61 + {
1.62 + CheckWindow(&iBitmap);
1.63 + }
1.64 +
1.65 +void CTBackedUpWindow::Draw(TInt aDrawFunc, TAny *aParam)
1.66 + {
1.67 + TheGc->Activate(iBackedUpWindow);
1.68 + Draw(aDrawFunc, aParam, TheGc, iBitGc);
1.69 + TheGc->Deactivate();
1.70 + }
1.71 +
1.72 +void CTBackedUpWindow::DrawWithTwoGcsL()
1.73 + {
1.74 + RBlankWindow blank(TheClient->iWs);
1.75 + User::LeaveIfError(blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle));
1.76 + blank.Activate();
1.77 + CWindowGc *gc2;
1.78 + User::LeaveIfError(TheClient->iScreen->CreateContext(gc2));
1.79 + CleanupStack::PushL(gc2);
1.80 +
1.81 + CFbsFont *font1;
1.82 + TFontSpec fspec(KTestFontTypefaceName,200);
1.83 + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font1,fspec));
1.84 + CFbsFont *font2;
1.85 + TFontSpec fspec2(KTestFontTypefaceName,400);
1.86 + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font2,fspec2));
1.87 +
1.88 + gc2->Activate(iBackedUpWindow);
1.89 + gc2->UseFont(font2);
1.90 + TheGc->Activate(iBackedUpWindow);
1.91 + TheGc->UseFont(font1);
1.92 + _LIT(KText,"Testing123");
1.93 + TheGc->DrawText(KText,TPoint(20,20));
1.94 + gc2->DrawText(KText,TPoint(20,40));
1.95 + iBitGc->UseFont(font1);
1.96 + iBitGc->DrawText(KText,TPoint(20,20));
1.97 + iBitGc->UseFont(font2);
1.98 + iBitGc->DrawText(KText,TPoint(20,40));
1.99 + iBitGc->DiscardFont();
1.100 + TheGc->Deactivate();
1.101 + TheClient->iScreen->ReleaseFont(font2);
1.102 + TheClient->iScreen->ReleaseFont(font1);
1.103 + CleanupStack::PopAndDestroy();
1.104 + blank.Close();
1.105 + }
1.106 +
1.107 +void CTBackedUpWindow::Draw(TInt aDrawFunc, TAny *aParam, CBitmapContext *gc1, CBitmapContext *gc2) //DDD
1.108 + {
1.109 + CBitmapContext *gc;
1.110 + for(TInt mode=0;mode<2;mode++)
1.111 + {
1.112 + if (mode==0)
1.113 + gc=gc1;
1.114 + else
1.115 + gc=gc2;
1.116 + gc->Reset();
1.117 + switch(aDrawFunc)
1.118 + {
1.119 + case 0:
1.120 + gc->SetBrushColor(*((TRgb *)aParam));
1.121 + gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.122 + gc->SetPenStyle(CGraphicsContext::ENullPen);
1.123 + gc->DrawRect(TRect(iSize));
1.124 + break;
1.125 + case 1:
1.126 + {
1.127 + TSize half(iSize.iWidth/2,iSize.iHeight/2);
1.128 + gc->DrawEllipse(TRect(half));
1.129 + gc->DrawEllipse(TRect(TPoint(0,half.iHeight),half));
1.130 + TRect rect1(half);
1.131 + gc->SetOrigin(TPoint(half.iWidth,0));
1.132 + gc->SetClippingRect(rect1);
1.133 + gc->DrawEllipse(rect1);
1.134 + gc->SetOrigin(TPoint(half.iWidth,half.iHeight));
1.135 + gc->SetClippingRect(rect1);
1.136 + gc->DrawEllipse(rect1);
1.137 + gc->SetOrigin(TPoint(0,0));
1.138 + gc->CancelClippingRect();
1.139 + }
1.140 + break;
1.141 + case 2:
1.142 + {
1.143 + TInt param= *((TInt *)aParam);
1.144 + if (param&0x1)
1.145 + gc->DrawLine(TPoint(param+(param*27)%iSize.iWidth,0),
1.146 + TPoint(iSize.iWidth-((param<<1)+(param*19)%iSize.iWidth),iSize.iHeight));
1.147 + else
1.148 + gc->DrawLine(TPoint(0, (param<<1)+(param*7)%iSize.iHeight),
1.149 + TPoint(iSize.iWidth,param+(param*13)%iSize.iHeight));
1.150 + }
1.151 + break;
1.152 + case 3:
1.153 + {
1.154 + TPoint pos;
1.155 + for(;pos.iX<iSize.iWidth;pos.iX+=10)
1.156 + gc->DrawLine(pos,pos+TSize(0,iSize.iHeight));
1.157 + for(pos.iX=0;pos.iY<iSize.iHeight;pos.iY+=10)
1.158 + gc->DrawLine(pos,pos+TSize(iSize.iWidth,0));
1.159 + }
1.160 + break;
1.161 + }
1.162 + }
1.163 + }
1.164 +
1.165 +CTBackedUpWindow::~CTBackedUpWindow()
1.166 + {
1.167 + iBackedUpWindow.Close();
1.168 + iCheckWindow.Close();
1.169 + iOomFrontWindow.Close();
1.170 + delete iBitGc;
1.171 + delete iBitmapDevice;
1.172 + delete iTestBitmap;
1.173 + delete iMaskBitmap;
1.174 + }
1.175 +
1.176 +void CopyToGray4L(CFbsBitmap*& aDestBitmap,const CFbsBitmap& aSrcBitmap)
1.177 + {
1.178 + aDestBitmap=new(ELeave) CFbsBitmap();
1.179 + CleanupStack::PushL(aDestBitmap);
1.180 + User::LeaveIfError(aDestBitmap->Create(aSrcBitmap.SizeInPixels(),EGray4));
1.181 + CFbsBitmapDevice* device=CFbsBitmapDevice::NewL(aDestBitmap);
1.182 + CleanupStack::PushL(device);
1.183 + CFbsBitGc* gc;
1.184 + User::LeaveIfError(device->CreateContext(gc));
1.185 + gc->BitBlt(TPoint(),&aSrcBitmap);
1.186 + delete gc;
1.187 + CleanupStack::PopAndDestroy(device);
1.188 + CleanupStack::Pop(aDestBitmap);
1.189 + }
1.190 +
1.191 +void CTBackedUpWindow::ConstructL()
1.192 + {
1.193 + iBackedUpWindow=RBackedUpWindow(TheClient->iWs);
1.194 + iBackedUpWindow.Construct(*(TheClient->iGroup->GroupWin()),EGray4,ENullWsHandle);
1.195 + TSize size=TheClient->iScreen->SizeInTwips();
1.196 + iSize=TheClient->iScreen->SizeInPixels();
1.197 + iSize.iWidth>>=1;
1.198 + iSize.iHeight>>=1;
1.199 + size.iWidth>>=1;
1.200 + size.iHeight>>=1;
1.201 + size.iWidth-=1; //Modification to get the mapping factor the same as the screen
1.202 + size.iHeight-=1; //Ditto
1.203 + iWinPos.SetXY(iSize.iWidth>>1,iSize.iHeight>>1);
1.204 + User::LeaveIfError(iBackedUpWindow.SetExtentErr(iWinPos,iSize));
1.205 + iBackedUpWindow.Activate();
1.206 +
1.207 + iCheckPos.SetXY(iSize.iWidth,0);
1.208 + iCheckWindow=RWindow(TheClient->iWs);
1.209 + iCheckWindow.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle);
1.210 + iCheckWindow.SetSize(iSize);
1.211 + iCheckWindow.SetVisible(EFalse);
1.212 + iCheckWindow.Activate();
1.213 +
1.214 + TInt col,grey;
1.215 + TDisplayMode defMode=TheClient->iWs.GetDefModeMaxNumColors(col,grey);
1.216 + User::LeaveIfError(iBitmap.Create(iSize,defMode));
1.217 + iBitmap.SetSizeInTwips(size);
1.218 + iBitmapDevice=CFbsBitmapDevice::NewL(&iBitmap);
1.219 + User::LeaveIfError(iBitmapDevice->CreateContext(iBitGc));
1.220 +
1.221 + TRgb rgb(TRgb::Gray4(2));
1.222 + Draw(0,&rgb);
1.223 +
1.224 + iTestBitmap=new(ELeave) CFbsBitmap();
1.225 + User::LeaveIfError(iTestBitmap->Load(TEST_BITMAP_NAME,0));
1.226 + iTestBitmap->SetSizeInTwips(TSize(1500,750));
1.227 + iMaskBitmap=new(ELeave) CFbsBitmap();
1.228 + User::LeaveIfError(iMaskBitmap->Load(TEST_BITMAP_NAME,0));
1.229 + TDisplayMode defMode2=iMaskBitmap->DisplayMode();
1.230 + if (defMode>EGray4)
1.231 + {
1.232 + CFbsBitmap* bitmap=iTestBitmap;
1.233 + CopyToGray4L(iTestBitmap,*bitmap);
1.234 + delete bitmap;
1.235 + bitmap=iMaskBitmap;
1.236 + CopyToGray4L(iMaskBitmap,*bitmap);
1.237 + delete bitmap;
1.238 + }
1.239 + defMode2=iMaskBitmap->DisplayMode();
1.240 + defMode2=iMaskBitmap->DisplayMode();
1.241 + }
1.242 +
1.243 +void CTBackedUpWindow::InvisVis()
1.244 + {
1.245 + iBackedUpWindow.SetVisible(EFalse);
1.246 + TheClient->iWs.Flush();
1.247 + iBackedUpWindow.SetVisible(ETrue);
1.248 + TheClient->iWs.Flush();
1.249 + }
1.250 +
1.251 +void CTBackedUpWindow::WindowOnTop()
1.252 + {
1.253 + RBlankWindow blank(TheClient->iWs);
1.254 + blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle);
1.255 + blank.Activate();
1.256 + blank.Close();
1.257 + TheClient->iWs.Flush();
1.258 +
1.259 + TPoint pos;
1.260 + TInt sizeMode=0;
1.261 + TInt draw=13;
1.262 +
1.263 + for(pos.iX=-iSize.iWidth;pos.iX<iSize.iWidth;pos.iX+=50)
1.264 + for(pos.iY=-iSize.iHeight;pos.iY<iSize.iHeight;pos.iY+=50)
1.265 + {
1.266 + blank=RBlankWindow(TheClient->iWs);
1.267 + blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle);
1.268 + blank.SetColor(TRgb::Gray256(220));
1.269 + blank.SetShadowHeight(2);
1.270 + blank.SetExtent(pos+iWinPos,TSize((sizeMode&0x1)?iSize.iWidth>>1:iSize.iWidth<<1,(sizeMode&0x2)?iSize.iHeight>>1:iSize.iHeight<<1));
1.271 + sizeMode=(sizeMode+1)%4;
1.272 + blank.Activate();
1.273 + Draw(2,&draw);
1.274 + TheClient->iWs.Flush();
1.275 + draw++;
1.276 + blank.Close();
1.277 + }
1.278 + }
1.279 +
1.280 +void CTBackedUpWindow::Resize()
1.281 + {
1.282 + RBlankWindow blank(TheClient->iWs);
1.283 + blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle);
1.284 + blank.SetColor(TRgb::Gray256(128));
1.285 + blank.Activate();
1.286 + TInt xtop=(iSize.iWidth)-(iSize.iWidth>>2);
1.287 + TInt ytop=(iSize.iHeight)-(iSize.iHeight>>2);
1.288 + for(TInt winMode=0;winMode<3;winMode++)
1.289 + {
1.290 + switch(winMode)
1.291 + {
1.292 + case 0:
1.293 + blank.SetExtent(TPoint(0,ytop),TSize(iSize.iWidth,iSize.iHeight>>1));
1.294 + break;
1.295 + case 1:
1.296 + blank.SetExtent(TPoint(xtop,0),TSize(iSize.iWidth>>1,iSize.iHeight));
1.297 + break;
1.298 + case 2:
1.299 + blank.SetExtent(TPoint(xtop,ytop),TSize(iSize.iWidth>>1,iSize.iHeight>>1));
1.300 + break;
1.301 + }
1.302 + blank.SetShadowHeight(winMode);
1.303 + TPoint oldPos=iBackedUpWindow.Position();
1.304 + TPoint pos=oldPos;
1.305 + for(TUint i=0;i<sizeof(moveList)/sizeof(moveList[0]);i++)
1.306 + {
1.307 + pos+=moveList[i];
1.308 + iBackedUpWindow.SetPosition(pos);
1.309 + TheClient->iWs.Flush();
1.310 + }
1.311 + iBackedUpWindow.SetPosition(oldPos);
1.312 + }
1.313 + blank.Close();
1.314 + }
1.315 +
1.316 +void CTBackedUpWindow::ChildWindows()
1.317 + {
1.318 + TPoint pos;
1.319 + TInt sizeMode=0;
1.320 + TInt draw=13;
1.321 + RBlankWindow blank(TheClient->iWs);
1.322 + for(pos.iX=-(iSize.iWidth>>1);pos.iX<iSize.iWidth;pos.iX+=33)
1.323 + for(pos.iY=-(iSize.iHeight>>1);pos.iY<iSize.iHeight;pos.iY+=33)
1.324 + {
1.325 + blank.Construct(iBackedUpWindow,ENullWsHandle);
1.326 + blank.SetColor(TRgb::Gray256(220));
1.327 + blank.SetShadowHeight(2);
1.328 + blank.SetExtent(pos,TSize((sizeMode&0x1)?iSize.iWidth>>2:iSize.iWidth,(sizeMode&0x2)?iSize.iHeight>>2:iSize.iHeight));
1.329 + sizeMode=(sizeMode+1)%4;
1.330 + blank.Activate();
1.331 + Draw(2,&draw);
1.332 + TheClient->iWs.Flush();
1.333 + draw++;
1.334 + blank.Close();
1.335 + }
1.336 + }
1.337 +
1.338 +void CTBackedUpWindow::DupBitmapTestL()
1.339 + {
1.340 + INFO_PRINTF1(_L("AUTO Dup Bitmap Test "));
1.341 + CFbsBitmap *dup=new(ELeave) CFbsBitmap();
1.342 + dup->Duplicate(iBackedUpWindow.BitmapHandle());
1.343 + CheckWindow(dup);
1.344 + TRgb rgb(TRgb::Gray4(1));
1.345 + Draw(0,&rgb);
1.346 + CheckWindow(dup);
1.347 + INFO_PRINTF1(_L(" Done Window Drawing Test"));
1.348 +
1.349 + CFbsBitmapDevice *dupDevice=NULL;
1.350 + TRAPD(err,dupDevice=CFbsBitmapDevice::NewL(dup));
1.351 + CFbsBitGc *gc;
1.352 + if (err==KErrNone && dupDevice->CreateContext(gc)==KErrNone)
1.353 + {
1.354 + Draw(3,NULL,gc,iBitGc); // Draw directly to backup bitmap (and test bitmap)
1.355 + iBackedUpWindow.UpdateScreen();
1.356 + INFO_PRINTF1(_L(" First Bitmap Drawing"));
1.357 + CheckWindow();
1.358 + TRgb rgb(TRgb::Gray256(128));
1.359 + TInt col,grey;
1.360 + if (TheClient->iWs.GetDefModeMaxNumColors(col,grey)>EGray4)
1.361 + rgb=TRgb::Gray4(2);
1.362 + Draw(0,&rgb,gc,iBitGc);
1.363 + Draw(1,NULL,gc,iBitGc);
1.364 + iBackedUpWindow.UpdateScreen(TRegionFix<1>(TRect(iSize)));
1.365 + INFO_PRINTF1(_L(" Second Bitmap Drawing"));
1.366 + CheckWindow();
1.367 + delete gc;
1.368 + }
1.369 + delete dupDevice;
1.370 + delete dup;
1.371 + }
1.372 +
1.373 +void CTBackedUpWindow::UpdateBitmapTestL()
1.374 + {
1.375 + INFO_PRINTF1(_L("AUTO UpdateBitmap "));
1.376 + CheckWindow();
1.377 + CFbsBitmap *dup=new(ELeave) CFbsBitmap();
1.378 + dup->Duplicate(iBackedUpWindow.BitmapHandle());
1.379 + Draw(3,NULL);
1.380 + iBackedUpWindow.UpdateBackupBitmap();
1.381 + INFO_PRINTF1(_L(" First Drawing"));
1.382 + CheckWindow(dup);
1.383 + TRgb rgb;
1.384 + if (iSupState==0)
1.385 + rgb=TRgb::Gray256(128);
1.386 + else
1.387 + rgb=TRgb::Gray4(2);
1.388 + Draw(0,&rgb);
1.389 + Draw(1,NULL);
1.390 + iBackedUpWindow.UpdateBackupBitmap();
1.391 + INFO_PRINTF1(_L(" Second Drawing"));
1.392 + CheckWindow(dup);
1.393 + delete dup;
1.394 + }
1.395 +
1.396 +void CTBackedUpWindow::OOML()
1.397 + {
1.398 + iOomFrontWindow=RBlankWindow(TheClient->iWs);
1.399 + TSize size(iBackedUpWindow.Size());
1.400 + size.iWidth>>=1;
1.401 + size.iHeight>>=1;
1.402 + TPoint pos(size.iWidth*3/2,size.iHeight*3/2);
1.403 + iOomFrontWindow.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle);
1.404 + iOomFrontWindow.SetColor(TRgb(TRgb::Gray4(1)));
1.405 + iOomFrontWindow.SetExtent(pos,size);
1.406 + iOomFrontWindow.Activate();
1.407 + TheClient->iWs.Flush();
1.408 +
1.409 + TPoint buwPos=iBackedUpWindow.Position();
1.410 + TSize buwSize=iBackedUpWindow.Size();
1.411 + for(TInt count=0;count<100;count++)
1.412 + {
1.413 + iOomFrontWindow.SetVisible(ETrue);
1.414 + TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count);
1.415 + iBackedUpWindow.SetPosition(buwPos+TPoint(10,5));
1.416 + iBackedUpWindow.SetPosition(buwPos);
1.417 + iOomFrontWindow.SetSize(size+TSize(10,5));
1.418 + iOomFrontWindow.SetSize(size);
1.419 + iBackedUpWindow.SetSizeErr(buwSize+TSize(13,7));
1.420 + iBackedUpWindow.SetSizeErr(buwSize);
1.421 + iOomFrontWindow.SetVisible(EFalse);
1.422 + TheClient->iWs.HeapSetFail(RHeap::ENone,0);
1.423 + User::LeaveIfError(iBackedUpWindow.SetSizeErr(buwSize));
1.424 + TheClient->WaitForRedrawsToFinish();
1.425 + CheckWindow();
1.426 + }
1.427 +
1.428 + iOomFrontWindow.Close();
1.429 + }
1.430 +
1.431 +void CTBackedUpWindow::doGraphicFunctionsL(CBitmapContext *gc,TBool aExtraDrawBitMap)
1.432 + {
1.433 + TSize size=iBackedUpWindow.Size();
1.434 + CFbsFont *aFont;
1.435 + _LIT(KFontName,"Swiss");
1.436 + TFontSpec fspec(KFontName,190);
1.437 + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)aFont,fspec));
1.438 + CFbsBitmap* aBitmap=iTestBitmap;
1.439 + CFbsBitmap* aMaskBitmap=iMaskBitmap;
1.440 +
1.441 + #include "DLLDRAW.H" // Draws to a Gc called 'gc'
1.442 +
1.443 + TheClient->iScreen->ReleaseFont(aFont);
1.444 + }
1.445 +
1.446 +void CTBackedUpWindow::AllGraphicFunctionsL(RBlankWindow &aBlank,TBool aExtraDrawBitMap/*=ETrue*/)
1.447 + {
1.448 + aExtraDrawBitMap=EFalse; //Check out when bitblit scaling has changed again
1.449 + aBlank.SetVisible(ETrue);
1.450 + TheGc->Activate(iBackedUpWindow);
1.451 + TRAPD(err,doGraphicFunctionsL(TheGc,aExtraDrawBitMap));
1.452 + TheGc->Deactivate();
1.453 + User::LeaveIfError(err);
1.454 + iBitGc->Reset();
1.455 + iBitGc->SetUserDisplayMode(EGray4);
1.456 + doGraphicFunctionsL(iBitGc,aExtraDrawBitMap);
1.457 + aBlank.SetVisible(EFalse);
1.458 + CheckWindow();
1.459 + }
1.460 +
1.461 +void CTBackedUpWindow::AllGraphicFunctionsTestsL()
1.462 + {
1.463 + RBlankWindow blank(TheClient->iWs);
1.464 + TInt xtop=(iSize.iWidth)-(iSize.iWidth>>1);
1.465 + TInt ytop=(iSize.iHeight)-(iSize.iHeight>>1);
1.466 + blank.Construct(*(TheClient->iGroup->GroupWin()),ENullWsHandle);
1.467 + blank.SetColor(TRgb::Gray256(128));
1.468 + blank.Activate();
1.469 + blank.SetExtent(TPoint(0,ytop),TSize(iSize.iWidth,iSize.iHeight>>2));
1.470 + AllGraphicFunctionsL(blank);
1.471 + blank.SetExtent(TPoint(0,ytop+10),TSize(iSize.iWidth,iSize.iHeight>>2));
1.472 + AllGraphicFunctionsL(blank);
1.473 + blank.SetExtent(TPoint(xtop,ytop),TSize(iSize.iWidth>>1,iSize.iHeight));
1.474 + AllGraphicFunctionsL(blank,EFalse);
1.475 + blank.SetExtent(TPoint(xtop+(iSize.iWidth>>1),ytop),TSize(iSize.iWidth>>1,iSize.iHeight));
1.476 + AllGraphicFunctionsL(blank,EFalse);
1.477 + blank.SetExtent(TPoint(xtop+10,iSize.iHeight),TSize(iSize.iWidth,iSize.iHeight));
1.478 + AllGraphicFunctionsL(blank,EFalse);
1.479 + blank.SetExtent(TPoint(xtop,ytop),iSize);
1.480 + AllGraphicFunctionsL(blank,EFalse);
1.481 + blank.SetExtent(TPoint(0,0),TSize(0,0));
1.482 + AllGraphicFunctionsL(blank);
1.483 + blank.Close();
1.484 + }
1.485 +
1.486 +void CTBackedUpWindow::RunTestCaseL(TInt /*aCurTestCase*/)
1.487 + {
1.488 + switch(iSupState)
1.489 + {
1.490 + case 0:
1.491 + for (TInt iSubTest=0;iSubTest<KLastSubtest;iSubTest++)
1.492 + {
1.493 + DoSubTestL(iSubTest);
1.494 + }
1.495 + iBackedUpWindow.MaintainBackup(); //Putting this line here is a work around
1.496 + break;
1.497 + case 1:
1.498 + for (TInt iSubTest=0;iSubTest<KLastSubtest;iSubTest++)
1.499 + {
1.500 + DoSubTestL(iSubTest);
1.501 + }
1.502 + break;
1.503 + default:
1.504 + TestComplete();
1.505 + break;
1.506 + }
1.507 + iSupState++;
1.508 + }
1.509 +
1.510 +void CTBackedUpWindow::DoSubTestL(TInt iState)
1.511 + {
1.512 + _LIT(KTest0,"Simple draw");
1.513 + _LIT(KTest1,"Resizing");
1.514 + _LIT(KTest2,"Invisible/Visible");
1.515 + _LIT(KTest3,"Windows on top");
1.516 + _LIT(KTest4,"Child Windows");
1.517 + _LIT(KTest5,"OOM");
1.518 + _LIT(KTest6,"Update Bitmap");
1.519 + _LIT(KTest7,"Bitmap duplicate");
1.520 + _LIT(KTest8,"Two Graphic Contexts");
1.521 + _LIT(KTest9,"All Graphic Functions");
1.522 + _LIT(KTest10,"Reactivate");
1.523 + _LIT(KTest11,"DoDrawCommand");
1.524 +
1.525 + TRgb rgb1(255,255,255);
1.526 + TRgb rgb2(255,255,255);
1.527 + TRgb rgb3(255,255,255);
1.528 + TRgb rgb4(255,255,255);
1.529 + TRgb rgb5(255,255,255);
1.530 + TRgb rgb6(255,255,255);
1.531 + TRgb rgb7(255,255,255);
1.532 + TRgb color(TRgb::Gray4(2));
1.533 +
1.534 + iTest->iState=iState;
1.535 +((CTBackedUpWindowStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
1.536 + switch(iState)
1.537 + {
1.538 +/**
1.539 +@SYMTestCaseID GRAPHICS-WSERV-0202-0001
1.540 +
1.541 +@SYMDEF DEF081259
1.542 +
1.543 +@SYMTestCaseDesc Test drawing in a backed up window
1.544 +
1.545 +@SYMTestPriority High
1.546 +
1.547 +@SYMTestStatus Implemented
1.548 +
1.549 +@SYMTestActions Draw in a backed up window and a normal window and check
1.550 + the two drawings are the same
1.551 +
1.552 +@SYMTestExpectedResults The two drawings are exactly the same
1.553 +*/
1.554 + case 0:
1.555 + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0202-0001"));
1.556 + iTest->LogSubTest(KTest0);
1.557 + Draw(1,NULL);
1.558 + CheckWindow();
1.559 + break;
1.560 +/**
1.561 +@SYMTestCaseID GRAPHICS-WSERV-0202-0002
1.562 +
1.563 +@SYMDEF DEF081259
1.564 +
1.565 +@SYMTestCaseDesc Test drawing in a backed up window
1.566 +
1.567 +@SYMTestPriority High
1.568 +
1.569 +@SYMTestStatus Implemented
1.570 +
1.571 +@SYMTestActions Draw in a backed up window and a normal window and check
1.572 + the two drawings are the same
1.573 +
1.574 +@SYMTestExpectedResults The two drawings are exactly the same
1.575 +*/
1.576 + case 1:
1.577 + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0202-0002"));
1.578 + iTest->LogSubTest(KTest1);
1.579 + Draw(0,&rgb1);
1.580 + Draw(3,NULL);
1.581 + Resize();
1.582 + CheckWindow();
1.583 + break;
1.584 +/**
1.585 +@SYMTestCaseID GRAPHICS-WSERV-0203
1.586 +
1.587 +@SYMDEF DEF081259
1.588 +
1.589 +@SYMTestCaseDesc Test making a backed up window invisible
1.590 +
1.591 +@SYMTestPriority High
1.592 +
1.593 +@SYMTestStatus Implemented
1.594 +
1.595 +@SYMTestActions Draw in a backed up window and a normal window, make
1.596 + the backed up window invisible then visible and
1.597 + then check the two drawings are the same
1.598 +
1.599 +@SYMTestExpectedResults The two drawings are exactly the same
1.600 +*/
1.601 + case 2:
1.602 + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0203"));
1.603 + iTest->LogSubTest(KTest2);
1.604 + Draw(0,&rgb2);
1.605 + Draw(1,NULL);
1.606 + InvisVis();
1.607 + CheckWindow();
1.608 + break;
1.609 +/**
1.610 +@SYMTestCaseID GRAPHICS-WSERV-0204
1.611 +
1.612 +@SYMDEF DEF081259
1.613 +
1.614 +@SYMTestCaseDesc Test drawing in a backed up window and then placing a
1.615 + window on top of it
1.616 +
1.617 +@SYMTestPriority High
1.618 +
1.619 +@SYMTestStatus Implemented
1.620 +
1.621 +@SYMTestActions Draw in a backed up window and a normal window, then
1.622 + place a window on top of the backed up window and then
1.623 + check the two drawings are the same
1.624 +
1.625 +@SYMTestExpectedResults The two drawings are exactly the same
1.626 +*/
1.627 + case 3:
1.628 + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0204"));
1.629 + iTest->LogSubTest(KTest3);
1.630 + //TRgb rgb(220,220,220);
1.631 + Draw(0,&rgb3);
1.632 + Draw(1,NULL);
1.633 + WindowOnTop();
1.634 + CheckWindow();
1.635 + break;
1.636 +/**
1.637 +@SYMTestCaseID GRAPHICS-WSERV-0205
1.638 +
1.639 +@SYMDEF DEF081259
1.640 +
1.641 +@SYMTestCaseDesc Test drawing in a backed up window and then drawing in
1.642 + a child window
1.643 +
1.644 +@SYMTestPriority High
1.645 +
1.646 +@SYMTestStatus Implemented
1.647 +
1.648 +@SYMTestActions Draw in a backed up window and a normal window, then
1.649 + create and draw in a child window and then
1.650 + check the two original drawings are the same
1.651 +
1.652 +@SYMTestExpectedResults The two drawings are exactly the same
1.653 +*/
1.654 + case 4:
1.655 + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0205"));
1.656 + iTest->LogSubTest(KTest4);
1.657 + Draw(0,&rgb4);
1.658 + Draw(3,NULL);
1.659 + ChildWindows();
1.660 + CheckWindow();
1.661 + break;
1.662 +/**
1.663 +@SYMTestCaseID GRAPHICS-WSERV-0206
1.664 +
1.665 +@SYMDEF DEF081259
1.666 +
1.667 +@SYMTestCaseDesc Out of memeory test for backed up windows
1.668 +
1.669 +@SYMTestPriority High
1.670 +
1.671 +@SYMTestStatus Implemented
1.672 +
1.673 +@SYMTestActions Out of memeory test for backed up windows
1.674 +
1.675 +@SYMTestExpectedResults Backed up window responds correctly when out
1.676 + of memory
1.677 +*/
1.678 + case 5:
1.679 + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0206"));
1.680 + iTest->LogSubTest(KTest5);
1.681 + if (!iTest->IsFullRomL())
1.682 + {
1.683 + Draw(0,&rgb5);
1.684 + Draw(3,NULL);
1.685 + OOML();
1.686 + CheckWindow();
1.687 + }
1.688 + break;
1.689 +/**
1.690 +@SYMTestCaseID GRAPHICS-WSERV-0207
1.691 +
1.692 +@SYMDEF DEF081259
1.693 +
1.694 +@SYMTestCaseDesc Test updating a bitmap in a backed up window
1.695 +
1.696 +@SYMTestPriority High
1.697 +
1.698 +@SYMTestStatus Implemented
1.699 +
1.700 +@SYMTestActions Update a bitmap in a backed up window and a normal window
1.701 + and check the two bitmaps are the same
1.702 +
1.703 +@SYMTestExpectedResults The two bitmaps are exactly the same
1.704 +*/
1.705 + case 6:
1.706 + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0207"));
1.707 + iTest->LogSubTest(KTest6);
1.708 + Draw(0,&rgb6);
1.709 + Draw(1,NULL);
1.710 + UpdateBitmapTestL();
1.711 + break;
1.712 +/**
1.713 +@SYMTestCaseID GRAPHICS-WSERV-0208
1.714 +
1.715 +@SYMDEF DEF081259
1.716 +
1.717 +@SYMTestCaseDesc Test updating a duplicate bitmap in a backed up window
1.718 +
1.719 +@SYMTestPriority High
1.720 +
1.721 +@SYMTestStatus Implemented
1.722 +
1.723 +@SYMTestActions Update a duplicated bitmap in a backed up window and a normal window
1.724 + and check the two bitmaps are the same
1.725 +
1.726 +@SYMTestExpectedResults The two bitmaps are exactly the same
1.727 +*/
1.728 + case 7:
1.729 + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0208"));
1.730 + if (iSupState==0) //Will fail unless the window is fully backup.
1.731 + break;
1.732 + iTest->LogSubTest(KTest7);
1.733 + Draw(0,&rgb7);
1.734 + Draw(1,NULL);
1.735 + DupBitmapTestL();
1.736 + break;
1.737 +/**
1.738 +@SYMTestCaseID GRAPHICS-WSERV-0209
1.739 +
1.740 +@SYMDEF DEF081259
1.741 +
1.742 +@SYMTestCaseDesc Test drawing with two graphic contexts in a backed up window
1.743 +
1.744 +@SYMTestPriority High
1.745 +
1.746 +@SYMTestStatus Implemented
1.747 +
1.748 +@SYMTestActions Draw using two graphic contexts in a backed up window and a normal
1.749 + window and check the two drawings are the same
1.750 +
1.751 +@SYMTestExpectedResults The two drawings are exactly the same
1.752 +*/
1.753 + case 8:
1.754 + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0209"));
1.755 + iTest->LogSubTest(KTest8);
1.756 + Draw(0,&color);
1.757 + Draw(1,NULL);
1.758 + DrawWithTwoGcsL();
1.759 + CheckWindow();
1.760 + break;
1.761 +
1.762 +/**
1.763 +@SYMTestCaseID GRAPHICS-WSERV-0210
1.764 +
1.765 +@SYMDEF DEF081259
1.766 +
1.767 +@SYMTestCaseDesc Test drawing using all the graphic functions in a backed up window
1.768 +
1.769 +@SYMTestPriority High
1.770 +
1.771 +@SYMTestStatus Implemented
1.772 +
1.773 +@SYMTestActions Draw using all the graphic functions in a backed up window and a normal
1.774 + window and check the two drawings are the same
1.775 +
1.776 +@SYMTestExpectedResults The two drawings are exactly the same
1.777 +*/
1.778 + case 9:
1.779 + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0210"));
1.780 + iTest->LogSubTest(KTest9);
1.781 + if(TheClient->iScreen->SizeInPixels() == TSize(640,240))
1.782 + AllGraphicFunctionsTestsL();
1.783 + break;
1.784 +
1.785 + //A Coverage test, nothing spectacular just making the code
1.786 + //go into CWsGc::Reactivate
1.787 + case 10:
1.788 + {
1.789 +/**
1.790 +@SYMTestCaseID GRAPHICS-WSERV-0502
1.791 +*/
1.792 + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0502"));
1.793 + iTest->LogSubTest(KTest10);
1.794 + TheGc->Deactivate();
1.795 + RBackedUpWindow extentWindow;
1.796 + extentWindow=RBackedUpWindow(TheClient->iWs);
1.797 + extentWindow.Construct(*(TheClient->iGroup->GroupWin()),EGray4,ENullWsHandle);
1.798 + TheGc->Activate(extentWindow);
1.799 + TheClient->Flush();
1.800 + User::LeaveIfError(extentWindow.SetExtentErr(TPoint(2,2), TSize(4,4)));
1.801 + extentWindow.Activate();
1.802 + extentWindow.Close();
1.803 + TheGc->Deactivate();
1.804 + break;
1.805 + }
1.806 +
1.807 + //Coverage for various messages for CWsGc::DoDrawCommand
1.808 + case 11:
1.809 + {
1.810 +/**
1.811 +@SYMTestCaseID GRAPHICS-WSERV-0507
1.812 +*/
1.813 + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0507"));
1.814 + iTest->LogSubTest(KTest11);
1.815 + TheGc->Activate(iBackedUpWindow);
1.816 + TheGc->Reset();
1.817 + iBitGc->Reset();
1.818 + iBitGc->SetUserDisplayMode(EGray4);
1.819 +
1.820 + // EWsGcOpDrawWsGraphic
1.821 + TheGc->DrawWsGraphic(TWsGraphicId(0), TRect(0,0,10,10));
1.822 +
1.823 + //create a large junk buffer so that messages with Ptr suffix will be sent
1.824 + RBuf8 junkBuf8;
1.825 + RBuf junkBuf;
1.826 + junkBuf8.CreateMax(650); // a large enough buffer to sent as Ptr (this value used to crash the code before)
1.827 + junkBuf.CreateMax(650); // a large enough buffer to sent as Ptr
1.828 + for (int i=0; i<junkBuf.MaxLength()-1;i++)
1.829 + {
1.830 + junkBuf8[i] = 'A';
1.831 + junkBuf[i] = 'A';
1.832 + }
1.833 + junkBuf8[junkBuf8.MaxLength()-1] = '\0';
1.834 + junkBuf[junkBuf.MaxLength()-1] = '\0';
1.835 +
1.836 + // EWsGcOpDrawWsGraphicPtr
1.837 + TheGc->DrawWsGraphic(TWsGraphicId(0), TRect(0,0,10,10), junkBuf8);
1.838 +
1.839 + // Set font for drawing on screen
1.840 + CFbsFont *font1;
1.841 + TFontSpec fspec(KTestFontTypefaceName,200);
1.842 + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font1,fspec));
1.843 + TheGc->UseFont(font1);
1.844 + iBitGc->UseFont(font1);
1.845 +
1.846 + // EWsGcOpDrawTextPtr
1.847 + TheGc->DrawText(junkBuf, TPoint(0,0));
1.848 + iBitGc->DrawText(junkBuf, TPoint(0,0));
1.849 +
1.850 + // EWsGcOpDrawBoxText - unreachable 299-too lo, 300-too hi
1.851 +
1.852 + // EWsGcOpDrawBoxTextPtr
1.853 + TheGc->DrawText(junkBuf, TRect(0,0,10,10), 0, CGraphicsContext::ELeft, 0);
1.854 + iBitGc->DrawText(junkBuf, TRect(0,0,10,10), 0, CGraphicsContext::ELeft, 0);
1.855 +
1.856 + // EWsGcOpDrawTextVerticalPtr
1.857 + TheGc->DrawTextVertical(junkBuf, TPoint(0,0), ETrue);
1.858 + iBitGc->DrawTextVertical(junkBuf, TPoint(0,0), ETrue);
1.859 +
1.860 + // EWsGcOpDrawBoxTextVerticalPtr
1.861 + TheGc->DrawTextVertical(junkBuf, TRect(0,0,10,10), 0, ETrue, CGraphicsContext::ELeft, 0);
1.862 + iBitGc->DrawTextVertical(junkBuf, TRect(0,0,10,10), 0, ETrue, CGraphicsContext::ELeft, 0);
1.863 +
1.864 + // EWsGcOpMoveBy
1.865 + TheGc->MoveBy(TPoint(2,2));
1.866 + iBitGc->MoveBy(TPoint(2,2));
1.867 +
1.868 + // a bitmap for bitblt ops
1.869 + CWsBitmap bmp(TheClient->iWs);
1.870 + bmp.Create(TSize(16,16), iBackedUpWindow.DisplayMode());
1.871 +
1.872 + // EWsGcOpGdiWsBlt2
1.873 + TheGc->BitBlt(TPoint(0,0), &bmp);
1.874 + iBitGc->BitBlt(TPoint(0,0), &bmp);
1.875 +
1.876 + // EWsGcOpGdiWsBlt3
1.877 + TheGc->BitBlt(TPoint(0,0), &bmp, TRect(0,0,10,10));
1.878 + iBitGc->BitBlt(TPoint(0,0), &bmp, TRect(0,0,10,10));
1.879 +
1.880 + // EWsGcOpGdiWsBltMasked
1.881 + TheGc->BitBltMasked(TPoint(0,0), &bmp, TRect(0,0,10,10), &bmp, EFalse);
1.882 + iBitGc->BitBltMasked(TPoint(0,0), &bmp, TRect(0,0,10,10), &bmp, EFalse);
1.883 +
1.884 + // EWsGcOpGdiWsAlphaBlendBitmaps
1.885 + TheGc->AlphaBlendBitmaps(TPoint(0,0), &bmp, TRect(0,0,10,10), &bmp, TPoint(1,1));
1.886 + iBitGc->AlphaBlendBitmaps(TPoint(0,0), &bmp, TRect(0,0,10,10), &bmp, TPoint(1,1));
1.887 +
1.888 + // EWsGcOpWsDrawBitmapMasked
1.889 + TheGc->DrawBitmapMasked(TRect(0,0,10,10), &bmp, TRect(0,0,8,8), &bmp, ETrue);
1.890 + iBitGc->DrawBitmapMasked(TRect(0,0,10,10), &bmp, TRect(0,0,8,8), &bmp, ETrue);
1.891 +
1.892 + // EWsGcOpDrawBitmap
1.893 + TheGc->DrawBitmap(TPoint(0,0), &bmp);
1.894 + iBitGc->DrawBitmap(TPoint(0,0), &bmp);
1.895 +
1.896 + // EWsGcOpDrawBitmapMasked
1.897 + TheGc->DrawBitmapMasked(TRect(0,0,10,10), static_cast<const CFbsBitmap*>(&bmp),
1.898 + TRect(0,0,8,8), static_cast<const CFbsBitmap*>(&bmp),
1.899 + EFalse);
1.900 + iBitGc->DrawBitmapMasked(TRect(0,0,10,10), static_cast<const CFbsBitmap*>(&bmp),
1.901 + TRect(0,0,8,8), static_cast<const CFbsBitmap*>(&bmp),
1.902 + EFalse);
1.903 +
1.904 + // EWsGcOpDrawPolyLineContinued
1.905 + TheGc->DrawPolyLine(reinterpret_cast<const TPoint*>(junkBuf8.Ptr()),
1.906 + TInt(junkBuf8.Size()/sizeof(TPoint)));
1.907 + iBitGc->DrawPolyLine(reinterpret_cast<const TPoint*>(junkBuf8.Ptr()),
1.908 + TInt(junkBuf8.Size()/sizeof(TPoint)));
1.909 +
1.910 + // EWsGcOpCopyRect
1.911 + TheGc->CopyRect(TPoint(0,0), TRect(0,0,10,10));
1.912 + iBitGc->CopyRect(TPoint(0,0), TRect(0,0,10,10));
1.913 +
1.914 + //cleanup
1.915 + TheClient->Flush();
1.916 + TheGc->DiscardFont();
1.917 + iBitGc->DiscardFont();
1.918 + TheClient->iScreen->ReleaseFont(font1);
1.919 + junkBuf.Close();
1.920 + junkBuf8.Close();
1.921 + TheGc->Deactivate();
1.922 +
1.923 + CheckWindow();
1.924 +
1.925 + //the following have no client equivalent methods
1.926 + // EWsGcOpMapColorsLocal
1.927 + // EWsGcOpDrawPolyLineLocalBufLen
1.928 + // EWsGcOpDrawPolyLineLocal
1.929 + // EWsGcOpDrawPolygonLocalBufLen
1.930 + // EWsGcOpDrawPolygonLocal
1.931 + // EWsGcOpDrawBitmapLocal
1.932 + // EWsGcOpDrawBitmap2Local
1.933 + // EWsGcOpDrawBitmap3Local
1.934 + // EWsGcOpDrawBitmapMaskedLocal
1.935 + // EWsGcOpDrawTextPtr1
1.936 + // EWsGcOpDrawBoxTextPtr1
1.937 + // EWsGcOpDrawTextVerticalPtr1
1.938 + // EWsGcOpDrawBoxTextVerticalPtr1
1.939 + // EWsGcOpDrawTextLocal
1.940 + // EWsGcOpDrawBoxTextLocal
1.941 + // EWsGcOpGdiBlt2Local
1.942 + // EWsGcOpGdiBlt3Local
1.943 + // EWsGcOpGdiBltMaskedLocal
1.944 + ((CTBackedUpWindowStep*)iStep)->CloseTMSGraphicsStep();
1.945 + break;
1.946 + }
1.947 +
1.948 + default:
1.949 + ((CTBackedUpWindowStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1.950 + ((CTBackedUpWindowStep*)iStep)->CloseTMSGraphicsStep();
1.951 + break;
1.952 + }
1.953 + ((CTBackedUpWindowStep*)iStep)->RecordTestResultL();
1.954 + }
1.955 +
1.956 +__WS_CONSTRUCT_STEP__(BackedUpWindow)