First public contribution.
1 // Copyright (c) 2003-2010 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
20 #include <graphics/gdi/gdiconsts.h>
24 #include "fbsmessage.h"
26 //===================================================================
27 //In order to test multiple screens creation process on the Emulator,
28 //you have to extend your epoc.ini file with the following lines
32 //===================================================================
37 LOCAL_D RFs FServSession;
42 _LIT(KArchiveFileName, "C:\\FbsBitGcArchive.dat");
46 //Create/Destroy test environment global functions
48 //Delete "aFullName" file.
49 LOCAL_C void DeleteDataFile(const TDesC& aFullName)
52 TInt err = fsSession.Connect();
56 if(fsSession.Entry(aFullName, entry) == KErrNone)
58 RDebug::Print(_L("Deleting \"%S\" file.\n"), &aFullName);
59 err = fsSession.SetAtt(aFullName, 0, KEntryAttReadOnly);
62 RDebug::Print(_L("Error %d changing \"%S\" file attributes.\n"), err, &aFullName);
64 err = fsSession.Delete(aFullName);
67 RDebug::Print(_L("Error %d deleting \"%S\" file.\n"), err, &aFullName);
74 RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName);
79 CTDefect2::CTDefect2(CTestStep* aStep):
80 CTGraphicsBase(aStep),
90 CTDefect2::~CTDefect2()
94 DeleteGraphicsContext();
99 void CTDefect2::ConstructL()
101 User::LeaveIfError(::FServSession.Connect());
104 void CTDefect2::RunTestCaseL(TInt aCurTestCase)
106 ((CTDefect2Step*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
107 _LIT(KTest1,"SubTest %d: DEF039237");
108 _LIT(KTest2,"SubTest %d: DEF039331");
109 _LIT(KTest3,"SubTest %d: DEF039650");
110 _LIT(KTest4,"SubTest %d: CFbsBitmap::GetPixel() performance");
111 _LIT(KTest5,"SubTest %d: Rotate/Move text");
112 _LIT(KTest6,"SubTest %d: SwapWidthAndHeight");
113 _LIT(KTest8,"SubTest %d: Clear with non-zero origin");
114 _LIT(KTest9,"SubTest %d: DEF115395: DrawBitmap & DrawBitmapMasked with a sourceRect out of the Bitmap bounds");
115 _LIT(KTest10,"SubTest %d: INC119063: General test CopyRect rewrite for low color depth (8,4,2, pixels per byte)");
116 _LIT(KTest11,"SubTest %d: INC120917: Dirty Mask Bitmap not remapped in BitBltMasked");
117 _LIT(KTest12,"SubTest %d: Zero-sized brush pattern bitmaps");
118 _LIT(KTest13,"SubTest %d: CopyRect with non-trivial alpha");
119 _LIT(KTest14,"SubTest %d: INC119063: CopyRect reading past end of bitmap data at unallocated pages");
120 _LIT(KTest15,"SubTest %d: INC128813 : CFbsBitGc::InternalizeL handle duplicate fail testing");
121 _LIT(KTest16,"SubTest %d: DEF132331 : CFbsScreenDevice PixelsToTwips conversions faulty with large inputs");
122 _LIT(KTest17,"SubTest %d: DEF137103: CFbsBitmapDevice::SetBits() should check bitmap size");
126 ((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0066"));
127 INFO_PRINTF2(KTest1,aCurTestCase);
131 ((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0067"));
132 INFO_PRINTF2(KTest2,aCurTestCase);
136 ((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0068"));
137 INFO_PRINTF2(KTest3,aCurTestCase);
141 ((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0069"));
142 INFO_PRINTF2(KTest4,aCurTestCase);
143 GetPixelPerformance1L();
146 ((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0070"));
147 INFO_PRINTF2(KTest5,aCurTestCase);
151 ((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0071"));
152 INFO_PRINTF2(KTest6,aCurTestCase);
153 SwapWidthAndHeightL();
156 // Test case moved to tmultiscreens.cpp
159 ((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0073"));
160 INFO_PRINTF2(KTest8,aCurTestCase);
161 NonZeroOriginClearL();
164 ((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0097"));
165 INFO_PRINTF2(KTest9,aCurTestCase);
169 ((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0099"));
170 INFO_PRINTF2(KTest10,aCurTestCase);
174 ((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0101"));
175 INFO_PRINTF2(KTest11,aCurTestCase);
176 TestDirtyMaskBitmapL();
179 ((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0108"));
180 INFO_PRINTF2(KTest12,aCurTestCase);
181 ZeroSizedPatternBrushL();
184 ((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0113"));
185 INFO_PRINTF2(KTest13,aCurTestCase);
189 //Note: This test generates panic windows... you may need to put your test before it.
190 //They will be closed at the end of the test set, but they may get in the way of your next test, sorry.
191 ((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0098"));
192 INFO_PRINTF2(KTest14,aCurTestCase);
193 CopyRectReadOutsideBitmap();
196 ((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0110"));
197 INFO_PRINTF2(KTest15,aCurTestCase);
198 CFbsBitGcInternalizeLFailL();
201 ((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0111"));
202 INFO_PRINTF2(KTest16,aCurTestCase);
203 PixelsToTwipsConversionCheck();
206 ((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0112"));
207 INFO_PRINTF2(KTest17,aCurTestCase);
212 INFO_PRINTF1(_L("PDEF141192: test CFbsBitGc::DrawBitmapMasked()"));
213 INFO_PRINTF1(_L("Test Red Channel"));
214 TestMaskForSelectedValuesL(0);
215 INFO_PRINTF1(_L("Test Green Channel"));
216 TestMaskForSelectedValuesL(1);
217 INFO_PRINTF1(_L("Test Blue Channel"));
218 TestMaskForSelectedValuesL(2);
224 ((CTDefect2Step*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
225 ((CTDefect2Step*)iStep)->CloseTMSGraphicsStep();
229 ((CTDefect2Step*)iStep)->RecordTestResultL();
233 * @SYMTestCaseID GRAPHICS-BITGDI-0101
237 * @SYMTestCaseDesc If mask bitmap has been dirtied (by resize/compress)
238 * then bitbltmasked should not read old memory contents
240 * @SYMTestPriority Normal
242 * @SYMTestStatus Implemented
244 * @SYMTestActions Create image and mask bitmap with pattern and blit them for reference
245 * create duplicate handle
246 * resize the mask on duplicate
247 * verify that blit produces same result for same area on larger mask
249 * blit using duplicate handle and source
250 * blit using original handle and source
251 * in defect scenario these results are different (original same as reference)
252 * in fix scenario they should be same (different to reference)
253 * revalidate original handle reblit and verify now correct
255 * repeat above steps:
256 * (this proves duplicate change causes original flag, not just duplication)
257 * resize the mask on duplicate
258 * verify that blit produces same result for same area on larger mask
260 * blit using duplicate handle and source
261 * blit using original handle and source
262 * in defect scenario these results are different (original same as reference)
263 * in fix scenario they should be same (different to reference)
264 * revalidate original handle reblit and verify now correct
266 void CTDefect2::TestDirtyMaskBitmapL()
268 const TInt KWidth=120;
269 const TInt KHeight=50;
270 const TInt KBigger=50;
275 EStepDupDiffAfterRefill,
276 EStepOriginalDiffAfterRefill,
277 EStepOriginalDiffAfterRefillAndGetAddress,
278 EStepDupDiffAfterRefill2,
279 EStepOriginalDiffAfterRefill2,
284 CFbsBitmap* targetBmp=new(ELeave) CFbsBitmap();
285 CleanupStack::PushL(targetBmp);pushcount++;
286 User::LeaveIfError(targetBmp->Create(TSize(KWidth,KHeight*ENumSteps), EColor16MU));
287 CFbsBitmapDevice* bmpDevice=CFbsBitmapDevice::NewL(targetBmp);
288 CleanupStack::PushL(bmpDevice);pushcount++;
289 CBitmapContext* bmpContext;
290 User::LeaveIfError(bmpDevice->CreateBitmapContext(bmpContext));
291 CleanupStack::PushL(bmpContext);pushcount++;
292 bmpContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
293 bmpContext->SetBrushColor(KRgbRed);
296 //set up source and mask
297 CFbsBitmap* sourceBmp=new(ELeave) CFbsBitmap();
298 CleanupStack::PushL(sourceBmp);pushcount++;
299 User::LeaveIfError(sourceBmp->Create(TSize(KWidth,KHeight), EColor16MU));
300 TUint32* sourceData=sourceBmp->DataAddress();
301 TInt sourceLength=(sourceBmp->DataStride()>>2)*KHeight;
302 CFbsBitmap* maskBmp=new(ELeave) CFbsBitmap();
303 CleanupStack::PushL(maskBmp);pushcount++;
304 User::LeaveIfError(maskBmp->Create(TSize(KWidth,KHeight), EGray2));
305 TUint32* maskDataStart=maskBmp->DataAddress();
306 TInt maskLength=(maskBmp->DataStride()>>2)*KHeight;
308 TUint32* targetData=targetBmp->DataAddress();
309 TInt targetCopySize=((targetBmp->DataStride()+3)>>2)*KHeight;
311 TUint32 blueint=KRgbBlue.Color16MU();
312 for (TInt fillIndex=0;fillIndex<sourceLength;fillIndex++)
314 sourceData[fillIndex]=blueint;
316 TInt maskPattern=0x12345678;
317 for (TInt fillIndex=0;fillIndex<maskLength;fillIndex++)
319 maskDataStart[fillIndex]=maskPattern;
322 //Initial result of blit operation
323 bmpContext->BitBltMasked(TPoint(0,KHeight*EStepBefore),sourceBmp,TSize(KWidth,KHeight),maskBmp,EFalse);
325 //duplicate the mask handle
326 CFbsBitmap* maskBmpDup=new(ELeave) CFbsBitmap();
327 CleanupStack::PushL(maskBmpDup);pushcount++;
328 maskBmpDup->Duplicate(maskBmp->Handle());
329 TUint32* maskDataDup=maskBmpDup->DataAddress();
330 TEST(maskDataDup==maskDataStart); //not expected to fail
331 //resize duplicate handle bigger
332 maskBmpDup->Resize(TSize(KWidth+KBigger,KHeight));
333 maskDataDup=maskBmpDup->DataAddress();
334 TEST(maskDataDup!=maskDataStart); //not expected to fail
336 //At this point the duplicate handle is referencing a different address to the original handle.
337 //With the defect in place this remains uncorrected,
338 //and is demonstrated by comparing the output contents of blitting using each of the handles.
340 //verify that the resizing of the mask preserved the original mask data, so the resize has no effect on small area blit
341 bmpContext->BitBltMasked(TPoint(0,KHeight*EStepVerifyDupGrow),sourceBmp,TSize(KWidth,KHeight),maskBmpDup,EFalse);
343 //If this cmp fails: blit or resize is not working properly on the duplicate handle - not caused by this defect (very unexpected)
344 TEST(0==Mem::Compare((TUint8*)(targetData),targetCopySize*4,(TUint8*)(targetData+targetCopySize*EStepVerifyDupGrow),targetCopySize*4));
346 //Change the mask using the address in the duplicate handle
347 //As we want to fill the whole mask with a known pattern we need to recalculate the mask size.
348 TInt newMaskLength=(maskBmpDup->DataStride()>>2)*KHeight;
349 maskPattern=0xAAAAAAAA;
350 for (TInt fillIndex=0;fillIndex<newMaskLength;fillIndex++)
352 maskDataDup[fillIndex]=maskPattern;
355 //compare the results of blitting using this new mask using each of the two handles to the same mask
356 bmpContext->BitBltMasked(TPoint(0,KHeight*EStepDupDiffAfterRefill),sourceBmp,TSize(KWidth,KHeight),maskBmpDup,EFalse);
357 //This blit should not crash, even if the defect is present because the previous sized bitmap should not be released until all references have been updated.
359 bmpContext->BitBltMasked(TPoint(0,KHeight*EStepOriginalDiffAfterRefill),sourceBmp,TSize(KWidth,KHeight),maskBmp,EFalse);
361 //If this cmp fails: data change had no effect for duplicate handle (very unexpected)
362 TEST(0!=Mem::Compare((TUint8*)(targetData),targetCopySize*4,(TUint8*)(targetData+targetCopySize*EStepDupDiffAfterRefill),targetCopySize*4));
364 //Check that the result of both blits is the same.
365 //If this cmp fails: defect is demonstrated. This is the main defect demonstration test.
366 TEST(0==Mem::Compare((TUint8*)(targetData+targetCopySize*EStepDupDiffAfterRefill),targetCopySize*4,(TUint8*)(targetData+targetCopySize*EStepOriginalDiffAfterRefill),targetCopySize*4));
368 //This revalidates the original handle, hiding the defect
369 TUint32* maskDataRevalid=maskBmp->DataAddress();
370 TEST(maskDataDup==maskDataRevalid);
372 //This blit should not crash as the original handle has now been revalidated to point to allocated data.
373 bmpContext->BitBltMasked(TPoint(0,KHeight*EStepOriginalDiffAfterRefillAndGetAddress),sourceBmp,TSize(KWidth,KHeight),maskBmp,EFalse);
374 //If this cmp fails: original was not revalidated by DataAddress - content is not same as duplicate
375 TEST(0==Mem::Compare((TUint8*)(targetData+targetCopySize*EStepDupDiffAfterRefill),targetCopySize*4,(TUint8*)(targetData+targetCopySize*EStepOriginalDiffAfterRefillAndGetAddress),targetCopySize*4));
377 //Extra testing... do we handle situation where the duplicated handle is changed more than once?
379 //Basically repeats the test sequence above.
381 //Repeat the resize even bigger using duplicate handle
382 //resize duplicate handle bigger
383 maskBmpDup->Resize(TSize(KWidth+KBigger,KHeight+KBigger));
384 maskDataDup=maskBmpDup->DataAddress();
385 TEST(maskDataDup!=maskDataRevalid);
387 //Change the mask using the address in the duplicate handle
388 //As we want to fill the whole mask with a known pattern we need to recalculate the mask size.
389 newMaskLength=(maskBmpDup->DataStride()>>2)*(KHeight+KBigger);
390 maskPattern=0x55555555;
391 for (TInt fillIndex=0;fillIndex<newMaskLength;fillIndex++)
393 maskDataDup[fillIndex]=maskPattern;
396 //compare the results of blitting using this new mask using each of the two handles to the same mask
398 bmpContext->BitBltMasked(TPoint(0,KHeight*EStepDupDiffAfterRefill2),sourceBmp,TSize(KWidth,KHeight),maskBmpDup,EFalse);
399 //This blit should not crash, even if the defect is present because the previous sized bitmap should not be released until all references have been updated.
400 //If it does crash then this demonstrates the defect in that the original address is being used in error and has been freed and paged out
401 bmpContext->BitBltMasked(TPoint(0,KHeight*EStepOriginalDiffAfterRefill2),sourceBmp,TSize(KWidth,KHeight),maskBmp,EFalse);
403 //If this cmp fails: data change had no effect for duplicate handle (very unexpected)
404 TEST(0!=Mem::Compare((TUint8*)(targetData+targetCopySize*EStepDupDiffAfterRefill),targetCopySize*4,(TUint8*)(targetData+targetCopySize*EStepDupDiffAfterRefill2),targetCopySize*4));
406 //Check that the result of both blits is the same.
407 //If this cmp fails: defect is demonstrated. This is the main defect demonstration test.
408 TEST(0==Mem::Compare((TUint8*)(targetData+targetCopySize*EStepDupDiffAfterRefill2),targetCopySize*4,(TUint8*)(targetData+targetCopySize*EStepOriginalDiffAfterRefill2),targetCopySize*4));
411 CleanupStack::PopAndDestroy(pushcount,targetBmp);
415 * @SYMTestCaseID GRAPHICS-BITGDI-0097
419 * @SYMTestCaseDesc Robustness in the CFbsBitGc::DrawBitmap & CFbsBitGc::DrawBitmapMasked functions:
420 * when a sourceRect is used to capture only a part of the bitmap,
421 * we have to make sure that the sourceRect is not out of border of the image!
422 * (if it's the case, we just draw nothing)
424 * @SYMTestPriority Normal
426 * @SYMTestStatus Implemented
428 * @SYMTestActions We create a 8x8 KRgbRed Bitmap and 8x8 Mask (color TRgb(30, 30, 30))
429 * We try the 2 functions CFbsBitGc::DrawBitmap and CFbsBitGc::DrawBitmapMasked
430 * with a out of bounds source rectangle on a white output image.
431 * The output should stay all white.
434 void CTDefect2::DEF115395L()
436 const TSize size=TSize(8, 8);
437 const TPoint origin=TPoint(0, 0);
438 const TPoint vector=TPoint(2, 2);
439 const TRect destRect=TRect(origin, size);
440 const TRect srcRect=TRect(origin-vector, size);
441 const TBool invertMask=EFalse;
442 const TRgb maskColor=TRgb(30, 30, 30);
446 CFbsBitmap* myBmp=new(ELeave) CFbsBitmap();
447 CleanupStack::PushL(myBmp);
448 User::LeaveIfError(myBmp->Create(size, EColor16MU));
449 CFbsBitmapDevice* bmpDevice=CFbsBitmapDevice::NewL(myBmp);
450 CleanupStack::PushL(bmpDevice);
451 CBitmapContext* bmpContext;
452 User::LeaveIfError(bmpDevice->CreateBitmapContext(bmpContext));
453 CleanupStack::PushL(bmpContext);
454 bmpContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
455 bmpContext->SetBrushColor(KRgbRed);
457 CleanupStack::PopAndDestroy(2, bmpDevice); // bmpContext, bmpDevice
460 CFbsBitmap* myMaskBmp=new(ELeave) CFbsBitmap();
461 CleanupStack::PushL(myMaskBmp);
462 User::LeaveIfError(myMaskBmp->Create(size, EGray256));
463 bmpDevice = CFbsBitmapDevice::NewL(myMaskBmp);
464 CleanupStack::PushL(bmpDevice);
465 User::LeaveIfError(bmpDevice->CreateBitmapContext(bmpContext));
466 CleanupStack::PushL(bmpContext);
467 bmpContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
468 bmpContext->SetBrushColor(maskColor);
470 CleanupStack::PopAndDestroy(2, bmpDevice); // bmpContext, bmpDevice
473 CFbsBitmap* outputImg=new(ELeave) CFbsBitmap();
474 CleanupStack::PushL(outputImg);
475 User::LeaveIfError(outputImg->Create(size, EColor16MU));
476 bmpDevice = CFbsBitmapDevice::NewL(outputImg);
477 CleanupStack::PushL(bmpDevice);
478 User::LeaveIfError(bmpDevice->CreateBitmapContext(bmpContext));
479 CleanupStack::PushL(bmpContext);
480 bmpContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
481 bmpContext->SetBrushColor(KRgbWhite);
484 bmpContext->DrawBitmapMasked(destRect, myBmp, srcRect, myMaskBmp, invertMask);
487 for (ii=0;ii<=size.iWidth;ii++)
489 for (jj=0;jj<=size.iHeight;jj++)
491 outputImg->GetPixel(pixelColor, TPoint(ii,jj));
492 if (pixelColor!=KRgbWhite)
505 bmpContext->DrawBitmap(destRect, myBmp, srcRect);
506 for (ii=0;ii<=size.iWidth;ii++)
508 for (jj=0;jj<=size.iHeight;jj++)
510 outputImg->GetPixel(pixelColor, TPoint(ii,jj));
511 if (pixelColor!=KRgbWhite)
524 CleanupStack::PopAndDestroy(5);
528 @SYMDEF PDEF141192, INC140310
530 @SYMTestCaseDesc Test that the alpha merge method CFbsBitGc::DrawBitmapMasked() works accurately.
532 @SYMTestPriority normal
534 @SYMTestStatus Implemented
536 @SYMTestActions Create an alpha capable bitmap and throw sample values at the merge function
538 @SYMTestExpectedResults
539 1a) The merge resultant alpha values do not wrap through 256
540 1b) The merge resultant alpha values closely match an equivalent floating-point calculation
541 2a) The merge resultant colours do not wrap through 256
542 2b) The merge resultant colours do not exceed the resultant alpha if premultiplied output is expected
543 2c) The merge resultant colours closely match an equivalent floating-point calculation
544 2d) The other resultant colour values are not affected (stay black)
546 @param aChannelControl which channel is controlled (0=red, 1= green, 2=blue)
548 The input tested format is EColor64K, but could easily be changesd to test other formats.
549 The input mask is EGray256. If optimised internally, this could be changed to EGray16.
550 The tested output format is EColor16MAP. This should not be changed.
552 This test is an optimised version of CTDefect2::TestMaskForAllCombinationL(TInt aChannelControl)
554 void CTDefect2::TestMaskForSelectedValuesL(TInt aChannelControl)
556 const TSize size=TSize(1, 1);
559 CFbsBitmap* srcBmp=new(ELeave) CFbsBitmap();
560 CleanupStack::PushL(srcBmp);
561 User::LeaveIfError(srcBmp->Create(size, EColor64K));
562 CFbsBitmapDevice* sourceBmpDevice=CFbsBitmapDevice::NewL(srcBmp);
563 CleanupStack::PushL(sourceBmpDevice);
564 CBitmapContext* sourceBmpContext;
565 User::LeaveIfError(sourceBmpDevice->CreateBitmapContext(sourceBmpContext));
566 CleanupStack::PushL(sourceBmpContext);
567 sourceBmpContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
568 sourceBmpContext->Clear();
569 CleanupStack::PopAndDestroy(2, sourceBmpDevice); // sourceBmpContext, sourceBmpDevice
572 CFbsBitmap* maskBmp=new(ELeave) CFbsBitmap();
573 CleanupStack::PushL(maskBmp);
574 User::LeaveIfError(maskBmp->Create(size, EGray256));
575 CFbsBitmapDevice* maskBmpDevice=CFbsBitmapDevice::NewL(maskBmp);
576 CleanupStack::PushL(maskBmpDevice);
577 CBitmapContext* maskBmpContext;
578 User::LeaveIfError(maskBmpDevice->CreateBitmapContext(maskBmpContext));
579 CleanupStack::PushL(maskBmpContext);
580 maskBmpContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
581 maskBmpContext->Clear();
582 CleanupStack::PopAndDestroy(2, maskBmpDevice); // maskBmpContext, maskBmpDevice
585 CFbsBitmap* targetBmp=new(ELeave) CFbsBitmap();
586 CleanupStack::PushL(targetBmp);
587 User::LeaveIfError(targetBmp->Create(size, EColor16MAP));
588 CFbsBitmapDevice* targetBmpDevice=CFbsBitmapDevice::NewL(targetBmp);
589 CleanupStack::PushL(targetBmpDevice);
590 CBitmapContext* targetBmpContext;
591 User::LeaveIfError(targetBmpDevice->CreateBitmapContext(targetBmpContext));
592 CleanupStack::PushL(targetBmpContext);
593 targetBmpContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
594 targetBmpContext->Clear();
596 TSize screenSize = targetBmpDevice->SizeInPixels();
601 if (aChannelControl<1)
603 channelMask=0xFF0000;
607 if(aChannelControl==1)
609 channelMask=0x00FF00;
613 channelMask=0x0000FF;
616 channelMul=channelMask&0x01010101;
617 TInt previousTargetMask = -1;
618 const TInt otherMask=0xFFFFFF^channelMask;
620 for (TInt targetMask=0;targetMask<256;targetMask++)
622 //bkgrdChannel is background channel input value.
623 for (TInt targetChannel=0;targetChannel<=targetMask;targetChannel++)
625 if(targetChannel>(targetMask-10)) // Optimise the loop to test values specific for this defect
627 TInt failsPerPass=10;
629 //srcMask is the source mask/alpha
630 for (TInt srcMask=0;srcMask<256;srcMask++)
632 if((srcMask<=10)||(srcMask>=250)) // Optimise the loop to test values specific for this defect
635 if (aChannelControl == 1)
637 step = 255.0/63; // Only for blue channel for EColor64K source colour
643 TReal srcChannelReal = 0.0;
644 for (TInt srcChannel=0;srcChannel<256;srcChannel=(TInt)srcChannelReal)
646 if (targetMask != previousTargetMask)
648 //uncomment it to print log for each targetMask loop
649 //INFO_PRINTF2(_L("Processing source colours for targetMask=%i"),targetMask);
650 previousTargetMask = targetMask;
652 srcChannelReal += step;
654 //test blending of one-pixel bitmap
655 DoMaskTestL(srcChannel, srcMask, targetMask, targetChannel, aChannelControl, srcBmp, maskBmp, targetBmp, targetBmpContext);
658 TUint* readPixel = (TUint*)readBuffer.Ptr();
659 targetBmp->GetScanLine(readBuffer, TPoint(0, 0), 1, EColor16MAP);
661 //channelPixelValue is the channel pixel value as generated from the library code under test
662 TUint channelPixelValue=((*readPixel)&channelMask)/channelMul;
663 //alphaPixelValue is the alpha pixel value as generated from the library code under test
664 TUint alphaPixelValue = (*readPixel)>>24;
666 //check if channelPixelValue and alphaPixelValue match the expected ones
667 CheckValues(alphaPixelValue, channelPixelValue, failsPerPass, targetMask, targetChannel, srcMask, srcChannel, otherMask, readPixel);
672 { //note that this count may be out by 1...
673 INFO_PRINTF2(_L("Additional %i errors not reported in this pass."),-failsPerPass);
678 CleanupStack::PopAndDestroy(5);
681 void CTDefect2::CheckValues(TUint aAlphaPixelValue, TUint aChannelPixelValue, TInt& aFailsPerPass, TInt aTargetMask, TInt aTargetChannel, TInt aSrcMask, TInt aSrcChannel, TInt aOtherMask, TUint* aReadPixel)
683 const TReal KGross=1.95;
685 TReal alphaOutputValue;
686 //source multiplier factor for alpha that can then be used to optimise non-multiplied input calculations.
687 srcMultiplier=aSrcMask/255.0;
688 //destination/background multiplier factor for alpha that can then be used to optimise non-multiplied input calculations.
689 TReal destMultiplier=(aTargetMask/255.0)*(1.0-srcMultiplier);
690 //alphaOutputValue is a floating-point calculation of the alpha output value using 255.0 as the scaling factor.
691 alphaOutputValue=(srcMultiplier+destMultiplier)*255.0;
693 //alphaDiff is the difference in alpha between pixel and float calcuation, i.e. the error. This can be less than 1 level of brightness, i.e. insignificant.
695 alphaDiff=alphaOutputValue-aAlphaPixelValue;
696 if (alphaDiff>KGross || alphaDiff<-KGross)
698 if (--aFailsPerPass>0)
700 LogColourEvent(aTargetMask,aTargetChannel,aSrcMask,-1,alphaOutputValue,aAlphaPixelValue,alphaDiff,_L("Big Alpha error: expected %f, got %f"),ETrue);
703 //channelOutputValue is a floating-point calculation of the channel output value using 255.0 as the scaling factor.
704 TReal channelOutputValue=aSrcChannel*srcMultiplier;
705 channelOutputValue+=aTargetChannel*(1.0-srcMultiplier);
707 if (aChannelPixelValue>aAlphaPixelValue)
709 if (--aFailsPerPass>0)
711 LogColourEvent(aTargetMask,aTargetChannel,aSrcMask,aSrcChannel,aAlphaPixelValue,channelOutputValue,aChannelPixelValue,_L("Output multiplied colour exceeds alpha %f: expected %f got %f"),EFalse);
712 INFO_PRINTF1(_L("channelPixelValue>alphaPixelValue"));
716 if((aOtherMask&(*aReadPixel))!=0)
718 if (--aFailsPerPass>0)
720 LogColourEvent(aTargetMask,aTargetChannel,aSrcMask,aSrcChannel,aAlphaPixelValue,channelOutputValue,aChannelPixelValue,_L("Other colours damaged - NOT Zero"),EFalse);
724 //channelDiff is the difference in channel between pixel and float calcuation, i.e. the error. This can be less than 1 level of brightness, i.e. insignificant.
725 TReal channelDiff=channelOutputValue-aChannelPixelValue;
727 if (channelDiff>KGross || channelDiff<-KGross)
729 if (--aFailsPerPass>0)
731 LogColourEvent(aTargetMask,aTargetChannel,aSrcMask,aSrcChannel,channelOutputValue,aChannelPixelValue,channelDiff,_L("Big Colour error: expected %f, got %f"),EFalse);
737 Test of Blending function DrawBitmapMasked().
738 @param aSrcChannel source channel
739 @param aSrcMask source mask
740 @param aTargetMask target mask
741 @param aTargetChannel target channel
742 @param aChannelControl which channel is controlled (0=red, 1= green, 2=blue)
743 @param aSrcBmp source bitmap
744 @param aMaskBmp mask bitmap
745 @param aTargetBmp target bitmap
746 @param aTargetBmpContext gc for target bitmap
748 void CTDefect2::DoMaskTestL(TInt aSrcChannel, TInt aSrcMask, TInt aTargetMask, TInt aTargetChannel, TInt aChannelControl,
749 CFbsBitmap* aSrcBmp, CFbsBitmap* aMaskBmp, CFbsBitmap* aTargetBmp, CBitmapContext* aTargetBmpContext)
751 const TSize size=TSize(1, 1);
752 const TRect destRect=TRect(size);
753 const TRect srcRect=TRect(size);
755 const TInt scanLineLengthEColor16MAP = CFbsBitmap::ScanLineLength(1, EColor16MAP);
756 HBufC8* targetBuffer = HBufC8::NewL(scanLineLengthEColor16MAP);
757 CleanupStack::PushL(targetBuffer);
758 TPtr8 targetDes = targetBuffer->Des();
759 targetDes.SetLength(scanLineLengthEColor16MAP);
760 TUint32* targetP = (TUint32*)targetDes.Ptr();
761 TRgb targetColour(0, 0);
762 if (aChannelControl<1)
764 targetColour.SetRed(aTargetChannel);
768 if (aChannelControl==1)
770 targetColour.SetGreen(aTargetChannel);
774 targetColour.SetBlue(aTargetChannel);
777 targetColour.SetAlpha(aTargetMask);
778 *targetP = targetColour.Internal();
779 aTargetBmp->SetScanLine(targetDes, 0);
781 const TInt scanLineLengthEGray256 = CFbsBitmap::ScanLineLength(1, EGray256);
782 HBufC8* maskBuffer = HBufC8::NewL(scanLineLengthEGray256);
783 CleanupStack::PushL(maskBuffer);
784 TPtr8 maskDes = maskBuffer->Des();
785 maskDes.SetLength(scanLineLengthEGray256);
786 TUint8* maskP = (TUint8*)maskDes.Ptr();
788 aMaskBmp->SetScanLine(maskDes, 0);
790 const TInt scanLineLengthEColor64K = CFbsBitmap::ScanLineLength(1, EColor64K);
791 HBufC8* srcBuffer = HBufC8::NewL(scanLineLengthEColor64K);
792 CleanupStack::PushL(srcBuffer);
793 TPtr8 srcDes = srcBuffer->Des();
794 srcDes.SetLength(scanLineLengthEColor64K);
795 TUint16* srcP = (TUint16*)srcDes.Ptr();
797 if (aChannelControl<1)
799 srcColour.SetRed(aSrcChannel);
803 if (aChannelControl==1)
805 srcColour.SetGreen(aSrcChannel);
809 srcColour.SetBlue(aSrcChannel);
813 *srcP = srcColour.Color64K();
814 aSrcBmp->SetScanLine(srcDes, 0);
815 aTargetBmpContext->DrawBitmapMasked(destRect, aSrcBmp, srcRect, aMaskBmp, EFalse);
817 CleanupStack::PopAndDestroy(3);
821 @SYMDEF PDEF141192, INC140310
823 @SYMTestCaseDesc Test that the alpha merge method CFbsBitGc::DrawBitmapMasked() works accurately.
825 @SYMTestPriority normal
827 @SYMTestStatus Implemented
829 @SYMTestActions Create an alpha capable bitmap and throw sample values at the merge function
831 @SYMTestExpectedResults
832 1a) The merge resultant alpha values do not wrap through 256
833 1b) The merge resultant alpha values closely match an equivalent floating-point calculation
834 2a) The merge resultant colours do not wrap through 256
835 2b) The merge resultant colours do not exceed the resultant alpha if premultiplied output is expected
836 2c) The merge resultant colours closely match an equivalent floating-point calculation
837 2d) The other resultant colour values are not affected (stay black)
838 @param aChannelControl which channel is controlled (0=red, 1= green, 2=blue)
840 The input tested format is EColor64K, but could easily be changesd to test other formats.
841 The input mask is EGray256. If optimised internally, this could be changed to EGray16.
842 The tested output format is EColor16MAP. This should not be changed.
844 This test takes up to 40 minutes to run per channel control. Therefore, it is only kept for local reference, not scheduled for ONB.
845 An optimised version CTDefect2::TestMaskForSelectedValuesL(TInt aChannelControl) is run instead for selected combinations of channel and mask values.
847 void CTDefect2::TestMaskForAllCombinationL(TInt aChannelControl)
849 const TSize size=TSize(1, 1);
852 CFbsBitmap* srcBmp=new(ELeave) CFbsBitmap();
853 CleanupStack::PushL(srcBmp);
854 User::LeaveIfError(srcBmp->Create(size, EColor64K));
855 CFbsBitmapDevice* sourceBmpDevice=CFbsBitmapDevice::NewL(srcBmp);
856 CleanupStack::PushL(sourceBmpDevice);
857 CBitmapContext* sourceBmpContext;
858 User::LeaveIfError(sourceBmpDevice->CreateBitmapContext(sourceBmpContext));
859 CleanupStack::PushL(sourceBmpContext);
860 sourceBmpContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
861 sourceBmpContext->Clear();
862 CleanupStack::PopAndDestroy(2, sourceBmpDevice); // sourceBmpContext, sourceBmpDevice
865 CFbsBitmap* maskBmp=new(ELeave) CFbsBitmap();
866 CleanupStack::PushL(maskBmp);
867 User::LeaveIfError(maskBmp->Create(size, EGray256));
868 CFbsBitmapDevice* maskBmpDevice=CFbsBitmapDevice::NewL(maskBmp);
869 CleanupStack::PushL(maskBmpDevice);
870 CBitmapContext* maskBmpContext;
871 User::LeaveIfError(maskBmpDevice->CreateBitmapContext(maskBmpContext));
872 CleanupStack::PushL(maskBmpContext);
873 maskBmpContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
874 maskBmpContext->Clear();
875 CleanupStack::PopAndDestroy(2, maskBmpDevice); // maskBmpContext, maskBmpDevice
878 CFbsBitmap* targetBmp=new(ELeave) CFbsBitmap();
879 CleanupStack::PushL(targetBmp);
880 User::LeaveIfError(targetBmp->Create(size, EColor16MAP));
881 CFbsBitmapDevice* targetBmpDevice=CFbsBitmapDevice::NewL(targetBmp);
882 CleanupStack::PushL(targetBmpDevice);
883 CBitmapContext* targetBmpContext;
884 User::LeaveIfError(targetBmpDevice->CreateBitmapContext(targetBmpContext));
885 CleanupStack::PushL(targetBmpContext);
886 targetBmpContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
887 targetBmpContext->Clear();
889 TSize screenSize = targetBmpDevice->SizeInPixels();
894 if (aChannelControl<1)
896 channelMask=0xFF0000;
900 if(aChannelControl==1)
902 channelMask=0x00FF00;
906 channelMask=0x0000FF;
909 channelMul=channelMask&0x01010101;
910 TInt previousTargetMask = -1;
911 const TInt otherMask=0xFFFFFF^channelMask;
913 for (TInt targetMask=0;targetMask<256;targetMask++)
915 //bkgrdChannel is background channel input value.
916 for (TInt targetChannel=0;targetChannel<=targetMask;targetChannel++)
918 TInt failsPerPass=10;
920 //srcMask is the source mask/alpha
921 for (TInt srcMask=0;srcMask<256;srcMask++)
924 if (aChannelControl == 1)
926 step = 255.0/63; // Only for blue channel for EColor64K source colour
932 TReal srcChannelReal = 0.0;
934 for (TInt srcChannel=0;srcChannel<256;srcChannel=(TInt)srcChannelReal)
936 if (targetMask != previousTargetMask)
938 INFO_PRINTF2(_L("Processing source colours for targetMask=%i"),targetMask);
939 previousTargetMask = targetMask;
941 srcChannelReal += step;
943 //test blending of one-pixel bitmap
944 DoMaskTestL(srcChannel, srcMask, targetMask, targetChannel, aChannelControl, srcBmp, maskBmp, targetBmp, targetBmpContext);
947 TUint* readPixel = (TUint*)readBuffer.Ptr();
948 targetBmp->GetScanLine(readBuffer, TPoint(0, 0), 1, EColor16MAP);
950 //channelPixelValue is the channel pixel value as generated from the library code under test
951 TUint channelPixelValue=((*readPixel)&channelMask)/channelMul;
952 //alphaPixelValue is the alpha pixel value as generated from the library code under test
953 TUint alphaPixelValue = (*readPixel)>>24;
955 //check if channelPixelValue and alphaPixelValue match the expected ones
956 CheckValues(alphaPixelValue, channelPixelValue, failsPerPass, targetMask, targetChannel, srcMask, srcChannel, otherMask, readPixel);
959 { //note that this count may be out by 1...
960 INFO_PRINTF2(_L("Additional %i errors not reported in this pass."),-failsPerPass);
966 CleanupStack::PopAndDestroy(5);
970 This function is used to write to the log file
971 @param aNonPreMulDestPixColor non pre multiplied destination pixel colour
972 @param aPreMulSrcPixelColor pre multiplied source pixel colour
973 @param aNonPreMulSrcPixelColor non pre multiplied source pixel colour
974 @param aVal1 it contains the value of the first variable of the message to be displayed
975 @param aVal2 it contains the value of the second variable of the message to be displayed
976 @param aVal3 it contains the value of the third variable of the message to be displayed
977 @param aMsg it contains the message to be printed to the log file
978 @param aErr if true then the test case fails, if false test passes. log is printed in both the case. TEST does not abort, just reports test case failure
980 void CTDefect2::LogColourEvent(TInt aPreMulDestPixColor,TInt aNonPreMulDestPixColor,TInt aPreMulSrcPixelColor,TInt aNonPreMulSrcPixelColor,TReal aVal1,TReal aVal2,TReal aVal3,TRefByValue<const TDesC> aMsg,TBool aErr)
982 TEST(aErr==EFalse); // if aErr=True, then the previous test step failed.
983 INFO_PRINTF4(aMsg,aVal1,aVal2,aVal3);
984 if (aNonPreMulSrcPixelColor<0)
986 INFO_PRINTF4(_L("Processing source colours for MDest=%i, CDest=%i, MSrc=%i"),aPreMulDestPixColor,aNonPreMulDestPixColor,aPreMulSrcPixelColor);
990 INFO_PRINTF5(_L("Processing colour set MDest=%i, CDest=%i, MSrc=%i, CSrc=%i"),aPreMulDestPixColor,aNonPreMulDestPixColor,aPreMulSrcPixelColor,aNonPreMulSrcPixelColor);
994 class TFunctionThread
997 TFunctionThread():iExitHow(ENotStarted)
999 TInt LaunchThreadFunction(const TDesC& aName);
1001 static TInt TheThreadFunction(TAny*);
1002 virtual TInt ThreadFunctionL()=0;
1006 ERunning, //should never see this
1013 TInt iExitCode; //Currently don't store the panic category string.
1016 TInt TFunctionThread::LaunchThreadFunction(const TDesC& aName)
1019 TRequestStatus stat;
1021 KMinHeapSize=0x2000,
1022 KMaxHeapSize=0x200000
1024 TInt created=thrd.Create(aName,TheThreadFunction,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,this);
1025 if (created<KErrNone)
1030 thrd.SetPriority(EPriorityMuchMore);
1032 User::SetJustInTime(EFalse);
1034 User::WaitForRequest(stat);
1035 if ( iExitHow!=ENotStarted || iExitHow==ERunning )
1037 iExitCode=thrd.ExitReason();
1038 switch (thrd.ExitType())
1040 case EExitKill: iExitHow=EReturn; break;
1041 case EExitPanic: iExitHow=EPanic; break;
1042 case EExitTerminate: iExitHow=ETerminate; break;
1048 User::SetJustInTime(ETrue);
1052 TInt TFunctionThread::TheThreadFunction(TAny* aThis)
1054 TFunctionThread* thisThis=(TFunctionThread*)aThis;
1057 User::Panic(_L("NoThis"),0x1);
1059 TInt leaveErr = RFbsSession::Connect();
1060 if (leaveErr != KErrNone)
1062 thisThis->iExitHow = ELeave;
1063 thisThis->iExitCode = leaveErr;
1066 thisThis->iExitHow=thisThis->ERunning;
1067 CTrapCleanup* cleanup = CTrapCleanup::New();
1068 TInt returnErr=KErrNone;
1069 TRAP(leaveErr, returnErr = thisThis->ThreadFunctionL());
1072 thisThis->iExitHow=ELeave;
1073 thisThis->iExitCode=leaveErr;
1075 RFbsSession::Disconnect();
1080 thisThis->iExitHow=EReturn;
1081 thisThis->iExitCode=returnErr;
1083 RFbsSession::Disconnect();
1088 /** This thread verifies whether a range of memory is accessible
1089 The range is read sequentially until it panics, or the range is completed.
1090 It is useful to input a range of addresses where some are valid and some fail
1091 in order to demonstrate an edge against which an algorithm that performs illegal reads can subsequently be tested.
1092 The FailOffset() returned index indicates the offset from the start at which the memory access caused a panic.
1094 class TTestMemThread:public TFunctionThread
1097 TTestMemThread(TUint32* aStartAddress,TUint32* aEndAddress);
1100 virtual TInt ThreadFunctionL();
1102 TUint32* iStartAddress;
1103 TUint32* iEndAddress;
1104 volatile TUint32* iLastAddressTried;
1105 volatile TUint32 iCopyValueHere;
1109 TTestMemThread::TTestMemThread(TUint32* aStartAddress,TUint32* aEndAddress):
1110 iStartAddress(aStartAddress),
1111 iEndAddress(aEndAddress),
1112 iLastAddressTried(NULL)
1114 ASSERT(aStartAddress);
1115 ASSERT(aEndAddress);
1116 LaunchThreadFunction(_L("MemTest"));
1120 * Returns the number of successful memory reads before a panic occurred
1121 * Or various error codes if the test didn't run or didn't panic.
1124 TInt TTestMemThread::FailOffset()
1126 if (iExitHow==EReturn)
1128 return KErrCompletion;
1132 if (iExitHow==EPanic)
1134 if (iLastAddressTried)
1136 TInt retval=iLastAddressTried-iStartAddress;
1137 if (iEndAddress-iStartAddress<0)
1152 return KErrNotFound;
1157 return -iExitHow*100;
1162 * This thread function allows a test to verify that a particular address range
1163 * is actually inaccessable.
1164 * I.e. that attempting to read from the given address range causes a panic.
1166 TInt TTestMemThread::ThreadFunctionL()
1168 if (iStartAddress && iEndAddress)
1171 if (iStartAddress>iEndAddress)
1175 for (TUint32 volatile* tryAddress=iStartAddress;tryAddress!=iEndAddress;tryAddress+=delta)
1177 iLastAddressTried=tryAddress;
1178 iCopyValueHere=*tryAddress;
1182 return KErrArgument;
1185 /** This thread verifies the function of CopyRect
1186 A series of operations are performed on the given bitmap.
1187 If the operation panics the launcher is able to retrieve the parameters that caused the panic and report
1188 The FailOffset() returned index indicates the offset from the start at which the memory access caused a panic.
1190 class TTestCopyRectThread:public TFunctionThread
1193 TTestCopyRectThread(CFbsBitGc* aBitmapContext,TInt aStartX,TInt aStopX,TInt aY1,TInt aY2,TPoint aOffset);
1195 virtual TInt ThreadFunctionL();
1197 CFbsBitGc* iBitmapContext;
1204 volatile TInt iCurrX;
1205 volatile TInt iCurrWidth;
1209 TTestCopyRectThread::TTestCopyRectThread(CFbsBitGc* aBitmapContext,TInt aStartX,TInt aStopX,TInt aY1,TInt aY2,TPoint aOffset):
1210 iBitmapContext(aBitmapContext),
1217 LaunchThreadFunction(_L("CopyRectTest"));
1219 TInt TTestCopyRectThread::ThreadFunctionL()
1221 for (iCurrX=iStartX;iCurrX<iStopX;iCurrX++)
1223 for (iCurrWidth=iStopX-iCurrX;iCurrWidth>0;iCurrWidth--)
1225 iBitmapContext->CopyRect(iOffset,TRect(iCurrX,iY1,iCurrX+iCurrWidth,iY2));
1231 class CTestExecuteLogger;
1233 struct WrapCTestExecuteLogger
1235 WrapCTestExecuteLogger(): iLogger(NULL) {}
1236 WrapCTestExecuteLogger(CTestExecuteLogger&aLogger): iLogger(&aLogger) {}
1237 WrapCTestExecuteLogger(CTestExecuteLogger*aLogger): iLogger(aLogger) {}
1239 operator int() {return (iLogger!=NULL);}
1240 CTestExecuteLogger& operator()() { return *iLogger; }
1242 CTestExecuteLogger* iLogger;
1245 static const TInt KCopyTestHeight=20;
1246 static const TInt KCopyTestWidth=256; //should be some multiple of 32...
1247 /** Compares the pixels in the source rectangle and its copy.
1248 * The copy is at an offset from the source.
1249 * The compare is not complete as this was found to be too slow.
1250 * Instead only a few pixels on the left and right edges are compared.
1253 TBool CmpBitmapRectL(CFbsBitmap& aTestBitmap,TRect aSource,TPoint aTrgOffset,WrapCTestExecuteLogger Logger=NULL,TBool aExpectedPass=EFalse)
1255 //Comparing all the pixels in a large rectangle using GetPixel() is too slow.
1256 //So now, only a few pixels on the edges of the rectangle are compared,
1257 //and the ones in between are skipped.
1258 //Using any faster method to get the pixels is dubious
1259 //as it it may ultimately use GetLine, which is the method under test...
1260 const TInt processSize=6;
1261 TBool returnState=ETrue;
1262 TUint16 printcompareresultbuffers[KCopyTestHeight][2][processSize*2+1]={{{0}}};
1263 TInt resultRow=KCopyTestHeight-aSource.Height();
1264 TInt skipMiddleStart=aSource.iTl.iX+processSize;
1265 TInt skipMiddleEnd=aSource.iBr.iX-processSize-1;
1266 if (skipMiddleStart>=skipMiddleEnd)
1268 skipMiddleStart+=processSize+processSize; //make skip irrelivent
1270 //verify inputs valid
1271 TRect bitmapRect=aTestBitmap.SizeInPixels();
1272 TRect sourceRectIntersect=aSource;
1273 TRect targetRect=aSource;
1274 targetRect.Move(aTrgOffset);
1275 TRect targetRectIntersect=targetRect;
1276 targetRectIntersect.Intersection(bitmapRect);
1277 sourceRectIntersect.Intersection(bitmapRect);
1278 ASSERT(sourceRectIntersect==aSource);
1279 ASSERT(targetRectIntersect==targetRect);
1281 for (TInt sy=aSource.iTl.iY;sy<aSource.iBr.iY;sy++)
1284 for (TInt sx=aSource.iTl.iX;sx<aSource.iBr.iX;sx++)
1286 if (sx==skipMiddleStart)
1293 aTestBitmap.GetPixel(sourceColor,TPoint(sx,sy));
1295 aTestBitmap.GetPixel(targetColor,TPoint(sx,sy)+aTrgOffset);
1296 if (sourceColor!=targetColor)
1307 if (Logger&&resultRow>=0)
1309 printcompareresultbuffers[resultRow][0][resultCol]=L'@'+sourceColor.Color16();
1310 printcompareresultbuffers[resultRow][1][resultCol]=L'@'+targetColor.Color16();
1317 if (Logger && returnState!=aExpectedPass)
1319 INFO_PRINTF4(_L("Case: srcx=%i targx=%i width=%i result compare has failed! Content dump follows: [src] [trg] "),
1320 aSource.iTl.iX,targetRect.iTl.iX,aSource.Width());
1321 for (TInt row=(KCopyTestHeight-aSource.Height()>0)?KCopyTestHeight-aSource.Height():0;row<KCopyTestHeight;row++)
1323 INFO_PRINTF5(_L("Row: %2i %s %s (%s)"),
1324 row,printcompareresultbuffers[row][0],printcompareresultbuffers[row][1],
1325 Mem::Compare(printcompareresultbuffers[row][0],processSize*2,printcompareresultbuffers[row][1],processSize*2)
1335 * @SYMTestCaseID GRAPHICS-BITGDI-0099
1337 * @SYMDEF INC119063, pdef120353
1339 * @SYMTestCaseDesc CopyRect could read bytes past the end of the source bitmap
1340 * This is a general test of the rewrite of CopyRect
1341 * Note that this test says well within the boundaries of the bitmap,
1342 * and does not test the exception condition detected in the defect.
1343 * @SYMTestPriority Normal
1345 * @SYMTestStatus Implemented
1348 * Repeat the test for 4 affected bitmap resolutions: Gray2, Gray4, Gray16, Color16
1349 * Allocate a bitmap big enough to process the test
1351 * Fill the whole image with random data
1352 * Pixel compare the source rectangle wiith the target rectangle
1353 * - they should NOT be identical - very unlucky!
1354 * Pixel compare the left and right edge pixels outside the copy rect
1355 * - these should not be all identical - very unlucky!
1356 * Copyrect a region from the bottom half to the top half (not to edges)
1357 * Pixel compare the source rectangle wiith the target rectangle
1358 * - they should be identical - copy was successful
1359 * Pixel compare the left and right edge pixels outside the copy rect
1360 * - these should not be all identical - or too much was copied
1361 * Repeat for values of target x 0 to 32
1362 * Repeat for values of source x 0 to 32
1363 * Repeat for values of source/target width 1 to 96
1364 * Guess: 4x32x32x96 tests=400000 iterations
1366 void CTDefect2::ExerciseCopyRect()
1368 for (TInt mode=1;mode<EColorLast;mode++)
1370 CFbsBitmap testBitmap;
1372 //The exact dimensions of this bitmap are not important...
1373 //The width should ensure that the range of tests work (max 32+32+96=160 pixels)
1374 //The height should be enough to ensure there is enough variability in the random data
1375 //Note that the smallest data used in a uniqueness test is a 1-pixel-width column half the height of the image.
1376 //The whole height will be used if this is changed.
1377 if (testBitmap.Create(TSize(KCopyTestWidth,KCopyTestHeight*2),TDisplayMode(mode))<KErrNone)
1379 continue; //some mode numbers are bad!
1383 SEpocBitmapHeader header1 = testBitmap.Header();
1384 //We could run this test for other modes, but the defect and fix only applies to low bit depths
1385 if (header1.iBitsPerPixel>4)
1389 INFO_PRINTF3(_L("Bitmap color depth: %i bits. Color flag: %i"),header1.iBitsPerPixel,header1.iColor);
1392 TUint32* bitmapData=testBitmap.DataAddress();
1393 TUint32* pastBitmapData=bitmapData+((header1.iBitmapSize-header1.iStructSize)>>2);
1395 TInt splitHeight=header1.iSizeInPixels.iHeight/2;
1397 CFbsBitGc* bitmapContext = NULL;
1398 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(&testBitmap);
1399 CleanupStack::PushL(bitmapDevice);
1400 User::LeaveIfError(bitmapDevice->CreateContext(bitmapContext));
1401 CleanupStack::PushL(bitmapContext);
1402 TInt skippedCases=0;
1404 //These counts have been tweaked based on knowledge of the algorithm.
1405 //The target position is shifted in bits by up to 1 word (32 bits)
1406 //Bigger changes than this just change the target pointer and modulo the shift.
1407 //[I don't think that the target position influences the result, but it might]
1408 //The source position is shifted in bits by up to 1 word (32 bits)
1409 //Bigger changes than this just change the source pointer and modulo the shift.
1410 //The copy width is made up of a copy words element and a remainder bytes element.
1411 //The difference in shift element between source and target is used to shift the
1412 //source to a temporary buffer.
1413 //So the copy width element is also influenced by the source position and target position.
1414 //Testing 96 possible bit widths should exercise it for zero and non-zero word counts adequately.
1417 KTargXMax=32+32/header1.iBitsPerPixel,
1419 KSrcXMax=32+32/header1.iBitsPerPixel,
1421 KWidthMax=96/header1.iBitsPerPixel;
1422 for (TInt targx=KTargXMin;targx<KTargXMax;targx++)
1424 for (TInt srcx=KSrcXMin;srcx<KSrcXMax;srcx++)
1426 for (TInt width=KWidthMin;width<KWidthMax;width++)
1429 TInt offsetx=targx-srcx;
1430 //fill the buffer with random data
1431 TInt64 randomSeed=MAKE_TINT64(0xdeadbeef,0xbaadf00d);
1432 Math::Rand(randomSeed);
1435 while (--maxRetries>=0)
1437 for (TUint32* fillData=bitmapData;fillData!=pastBitmapData;fillData++)
1440 //Rand only sets 31 bits of the integer - no negative values - no top bit set!
1441 //This solution wastes some of the seed, but it should still produce valid results.
1442 TInt rnd=Math::Rand(randomSeed)^(Math::Rand(randomSeed)<<8);
1447 //verify that the data is different inside the copy area and outside each copy area
1448 if (TInt failCode= CmpBitmapRectL(testBitmap,TRect(srcx,splitHeight,srcx+width,splitHeight*2),TPoint(offsetx,-splitHeight))
1449 + 2*CmpBitmapRectL(testBitmap,TRect(srcx-1,splitHeight,srcx,splitHeight*2),TPoint(offsetx,-splitHeight))
1450 + 4*CmpBitmapRectL(testBitmap,TRect(srcx+width,splitHeight,srcx+width+1,splitHeight*2),TPoint(offsetx,-splitHeight))
1453 //OK.. need to find another pair of bits where the source and target columns are non-identical
1454 INFO_PRINTF5(_L("First random data failed... (code %i) Trying alternale columns: srcx=%i targx=%i width=%i"),failCode,srcx,targx,width);
1455 for (TInt tryOffSrc=0;tryOffSrc+srcx<KCopyTestWidth-(KWidthMax+1) && (colOffSrc==0&&colOffTrg==0);tryOffSrc+=32)
1456 for (TInt tryOffTrg=0;tryOffTrg+targx<KCopyTestWidth-(KWidthMax+1) && (colOffSrc==0&&colOffTrg==0);tryOffTrg+=32)
1458 TInt offsetx=(tryOffTrg+targx)-(tryOffSrc+srcx);
1459 TInt trysrcx=tryOffSrc+srcx;
1460 if ( CmpBitmapRectL(testBitmap,TRect(trysrcx,splitHeight,trysrcx+width,splitHeight*2),TPoint(offsetx,-splitHeight))
1461 | CmpBitmapRectL(testBitmap,TRect(trysrcx-1,splitHeight,trysrcx,splitHeight*2),TPoint(offsetx,-splitHeight))
1462 | CmpBitmapRectL(testBitmap,TRect(trysrcx+width,splitHeight,trysrcx+width+1,splitHeight*2),TPoint(offsetx,-splitHeight))
1468 colOffSrc=tryOffSrc;
1469 colOffTrg=tryOffTrg;
1472 if (colOffSrc||colOffTrg)
1474 offsetx=(colOffTrg+targx)-(colOffSrc+srcx);
1475 INFO_PRINTF4(_L("Found a safe equivalent column: srcx=%i targx=%i width=%i"),colOffSrc+srcx,colOffTrg+targx,width);
1479 INFO_PRINTF4(_L("Didn't find a safe column! Trying next random numbers"),srcx,targx,width);
1480 continue; //Try next random number...
1483 TInt trysrcx=colOffSrc+srcx;
1484 //Copy the region in question
1485 bitmapContext->CopyRect(TPoint(offsetx,-splitHeight), TRect(trysrcx,splitHeight,trysrcx+width,splitHeight*2));
1486 //verify the copied region is an exact match
1487 TBool copySame=CmpBitmapRectL(testBitmap,TRect(trysrcx,splitHeight,trysrcx+width,splitHeight*2),TPoint(offsetx,-splitHeight));
1488 //verify the area outside has not been copied
1489 TBool leftSame=CmpBitmapRectL(testBitmap,TRect(trysrcx-1,splitHeight,trysrcx,splitHeight*2),TPoint(offsetx,-splitHeight));
1490 TBool rightSame=CmpBitmapRectL(testBitmap,TRect(trysrcx+width,splitHeight,trysrcx+width+1,splitHeight*2),TPoint(offsetx,-splitHeight));
1491 if (!copySame||leftSame||rightSame)
1493 INFO_PRINTF4(_L("Case: srcx=%i targx=%i width=%i result compare has failed!"),srcx,targx,width);
1496 INFO_PRINTF1(_L("Copied data is not same as source data!"));
1500 INFO_PRINTF1(_L("Data to left of copy is now same as source data!"));
1504 INFO_PRINTF1(_L("Data to right of copy is now same as source data!"));
1508 break; //out of "try next random number" loop
1512 INFO_PRINTF4(_L("Case skipped TOO MANY TIMES because random data not unique: srcx=%i targx=%i width=%i."),srcx,targx,width);
1518 CleanupStack::PopAndDestroy(bitmapContext);
1519 CleanupStack::PopAndDestroy(bitmapDevice);
1524 INFO_PRINTF3(_L("%i / %i cases skipped because random picture data not unique enough! 10%% will cause test fail."),skippedCases,totalCases );
1525 TEST(skippedCases*10<totalCases);
1530 * @SYMTestCaseID GRAPHICS-BITGDI-0098
1532 * @SYMDEF INC119063, PDEF120353
1534 * @SYMTestCaseDesc CopyRect could previously read bytes past the end of the source bitmap
1535 * This would exception if the page is not mapped.
1536 * This particular image size allocation reproduces this exception.
1537 * Any changes to the allocation mechanism may mean the crash condition is not reproducable.
1538 * It is likely that it is changes to the allocator that have caused this defect to occur
1539 * in the first place.
1541 * @SYMTestPriority Normal
1543 * @SYMTestStatus Implemented
1545 * @SYMTestActions Create 768x1280 1 bit image, (also 384x1280x2bit and 192x1280x4bit ?)
1546 * In a seperate thread try to read past the end of the data.
1547 * If this panics then the test is valid.
1548 * Now, make a number of copyrect calls
1549 * that attempt to read data from near the end of the last scanline
1550 * Expected result: these reads should not exception.
1551 * Enhancement to improve reproducability:
1552 * Occasionally, the "next location" is addressable when the test is run in the overnight script
1553 * To address this, the test will recurse and repeat, forcing the image allocation to a different address if this occurs
1555 TBool CTDefect2::CopyRectReadOutsideBitmap(TInt aSingleMode /*=0*/,TInt aRetriesLeft /*=5*/)
1557 TBool testShouldUltimatelyFail=EFalse;
1558 TInt startMode=aSingleMode?aSingleMode:1;
1559 TInt stopMode=aSingleMode?aSingleMode+1:EColorLast;
1560 for (TInt mode=startMode;mode<stopMode;mode++)
1562 CFbsBitmap testBitmap;
1565 EMonoPixelsWidth=768,
1569 TInt guessPixels=EMonoPixelsWidth;
1570 TInt guessBytes=CFbsBitmap::ScanLineLength(guessPixels,TDisplayMode(mode));
1571 if (guessBytes<=0 || reinterpret_cast<TDisplayMode&>(mode)==ERgb)
1573 continue; //mode number not good.
1575 //want to generate a length of 768/8=96 bytes per scanline to repro the defect...
1576 while (guessBytes<EMonoBytesWidth)
1578 if (guessBytes<=EMonoBytesWidth/2)
1586 guessBytes=CFbsBitmap::ScanLineLength(guessPixels,TDisplayMode(mode));
1588 while (guessBytes>EMonoBytesWidth)
1590 if (guessBytes>=EMonoBytesWidth*2)
1598 guessBytes=CFbsBitmap::ScanLineLength(guessPixels,TDisplayMode(mode));
1601 if (testBitmap.Create(TSize(guessPixels,EMonoHeight),TDisplayMode(mode))<KErrNone)
1603 _LIT(KFail,"Failed to create bitmap for color depth: %S");
1604 INFO_PRINTF2(KFail,&ColorModeName(mode));
1607 testShouldUltimatelyFail=ETrue;
1609 continue; //some mode numbers are bad!
1612 SEpocBitmapHeader header1 = testBitmap.Header();
1614 TUint32* bitmapData=testBitmap.DataAddress();
1615 TUint32* pastBitmapData=bitmapData+((header1.iBitmapSize-header1.iStructSize)>>2);
1617 //The defect and fix only applies to low bit depths, but it is quick enough to run it for all color depths
1620 User::After(1000000); //Pause is in microseconds! //A small pause to try to get the bad operation completed
1621 INFO_PRINTF3(_L("Retry Bitmap: Address 0x%08x, past 0x%08x"),
1622 bitmapData,pastBitmapData );
1627 INFO_PRINTF7(_L("Bitmap: color depth: %i bits. Color mode= %i. Width=%i Height=%i Address 0x%08x, past 0x%08x"),
1628 header1.iBitsPerPixel,header1.iColor,
1629 header1.iSizeInPixels.iWidth,header1.iSizeInPixels.iHeight,
1630 bitmapData,pastBitmapData );
1632 TBool canGenerateDefectScenario=EFalse;
1635 //So now we hope that we have created a test bitmap on the bottom of a memory page,
1636 //as per the defect, but at different color depths as well.
1637 //Any number of factors could change the way this block is allocated and disguise the defect.
1638 //Equally, the next block of memory may be already mapped, and again the defect will not occurr.
1639 //There is no way to influence the result, so the next ting to do is to verify that an exception will occur.
1640 //Could assert that the address matches a 4K page, but I need to check if the page is mapped anyway!
1641 TTestMemThread memThread(pastBitmapData-2,pastBitmapData+2);
1642 TInt failAt=memThread.FailOffset();
1645 INFO_PRINTF2(_L(" Scenario invalid - error code generated by test thread! %i"),failAt);
1649 INFO_PRINTF1(_L(" Scenario invalid - didn't manage to read a safe location near the end of the bitmap!"));
1653 INFO_PRINTF1(_L(" Scenario invalid - managed to read right past the test location!"));
1657 INFO_PRINTF1(_L(" Verified that end address is bad memory"));
1658 canGenerateDefectScenario=ETrue;
1660 if (!canGenerateDefectScenario)
1662 if (!aRetriesLeft || !CopyRectReadOutsideBitmap(mode,aRetriesLeft-1)) //repeat attempt with nested bitmap alocation to new address
1664 //if this doesn't work out then the memory allocator is not like it was when the defect was raised!
1665 //so the test is no longer any good.
1666 //Can't return "Inconclusive" as other tests in the test set may reset the state.
1667 INFO_PRINTF2(_L("Error!!: Couldn't generate the defect scenario for the end address at 0x%08x."),(TInt)pastBitmapData);
1668 testShouldUltimatelyFail=ETrue;
1673 //These writes should succeed if the end of the bitmap is where it should be:
1674 //these colour values will be transferred in the copied data in the subsequent test
1675 //The test does not explicitly look for these patterns,
1676 //but they are useful to identify in the copied data if manually debugging.
1677 pastBitmapData[-2]=0xBAADF00D;
1678 pastBitmapData[-1]=0xdeadbeef;
1680 CFbsBitGc* bitmapContext = NULL;
1681 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(&testBitmap);
1682 CleanupStack::PushL(bitmapDevice);
1683 User::LeaveIfError(bitmapDevice->CreateContext(bitmapContext));
1684 CleanupStack::PushL(bitmapContext);
1685 //for the last scanline, try to copy various permutations of the last few pixels
1686 //note that there is no check to see if the "right" contents are copied, only that it doesn't abort.
1687 //In fact most of the bitmap is uninitialised...
1688 TTestCopyRectThread copythread(bitmapContext,guessPixels-64,guessPixels,EMonoHeight-5,EMonoHeight,TPoint(-5,-5));
1689 if (copythread.iExitHow!=copythread.EReturn)
1691 testShouldUltimatelyFail=ETrue;
1692 INFO_PRINTF7(_L("Error: (probably panic) when using CopyRect(TPoint(%i,%i),TRect(%i,%i,%i,%i)"),
1694 copythread.iCurrX,EMonoHeight-5, copythread.iCurrX+copythread.iCurrWidth,EMonoHeight);
1695 _LIT(KLog,"Thread Exit Reason %d, expected %d");
1696 INFO_PRINTF3(KLog,copythread.iExitHow,copythread.EReturn);
1699 CleanupStack::PopAndDestroy(bitmapContext);
1700 CleanupStack::PopAndDestroy(bitmapDevice);
1702 //For the purposes of verification, check that the memory location is still considered a valid scenario.
1703 //Again , the test is repeated nested if the scenario has become invalid
1704 TTestMemThread memThread2(pastBitmapData-2,pastBitmapData+2);
1705 TInt failAt=memThread2.FailOffset();
1706 canGenerateDefectScenario=EFalse;
1709 INFO_PRINTF2(_L(" After Test: Scenario invalid - error code generated by test thread! %i"),failAt);
1710 INFO_PRINTF1(_L("Warning: This may mean that bad copys may not have been detected??"));
1714 INFO_PRINTF1(_L(" After Test: Scenario invalid - didn't manage to read a safe location near the end of the bitmap!"));
1715 INFO_PRINTF1(_L("Warning: This may mean that bad copys may not have been detected??"));
1719 INFO_PRINTF1(_L(" After Test: Scenario invalid - managed to read right past the test location!"));
1720 INFO_PRINTF1(_L("Warning: This may mean that bad copys may not have been detected??"));
1724 INFO_PRINTF1(_L(" After Test: Verified that end address is still bad memory"));
1725 canGenerateDefectScenario=ETrue;
1727 if (!canGenerateDefectScenario)
1729 if (!aRetriesLeft || !CopyRectReadOutsideBitmap(mode,aRetriesLeft-1)) //repeat attempt with nested bitmap alocation to new address
1731 //if this doesn't work out then the memory allocator is not like it was when the defect was raised!
1732 //so the test is no longer any good.
1733 //Can't return "Inconclusive" as other tests in the test set may reset the state.
1734 INFO_PRINTF2(_L("Warning!!: Couldn't maintain the defect scenario for the end address at 0x%08x after retries."),(TInt)pastBitmapData);
1735 INFO_PRINTF1(_L("Test may have read from end of bitmap after it was made accessible."));
1736 //Ultimately, this refuses to stabilise on ONB scenario, so I won't have this retry of the test fail.
1745 TEST(!testShouldUltimatelyFail);
1747 return (!testShouldUltimatelyFail);
1751 @SYMTestCaseID GRAPHICS-BITGDI-0066
1755 @SYMTestCaseDesc Memory leak in CFbsScreenDevice (occurs on Lubbock, but not WINS)
1757 @SYMTestPriority normal
1759 @SYMTestStatus Implemented
1761 @SYMTestActions Creates a screen device in each colour mode
1763 @SYMTestExpectedResults Test should perform graphics operations succesfully.
1765 void CTDefect2::DEF039237L()
1768 const TInt KNumDisplayModes = 11;
1769 const TDisplayMode KDisplayMode[KNumDisplayModes] =
1770 { EGray2, EGray4, EGray16, EGray256, EColor16, EColor256,
1771 EColor4K, EColor64K, EColor16M, EColor16MA, EColor16MAP };
1773 CFbsScreenDevice* device = NULL;
1774 TInt err = KErrNotSupported;
1777 for (index=0; index<KNumDisplayModes && err==KErrNotSupported; ++index)
1779 ASSERT(device==NULL);
1780 TRAP(err,device = CFbsScreenDevice::NewL(KNullDesC,KDisplayMode[index]));
1785 _LIT(KLog,"Created device with color depth %S");
1786 INFO_PRINTF2(KLog,&ColorModeName(KDisplayMode[index]));
1790 _LIT(KLog,"Failed to create screen device, last color depth tried %S gave return value %d");
1791 INFO_PRINTF3(KLog,&ColorModeName(KDisplayMode[index]),err);
1794 User::LeaveIfError(err);
1802 @SYMTestCaseID GRAPHICS-BITGDI-0067
1806 @SYMTestCaseDesc bitgdi fails to deal correctly with screen orientation changes
1808 @SYMTestPriority normal
1810 @SYMTestStatus Implemented
1813 DEF039604 - CFbsBitGc::InternalizeL/ExternalizeL - comments, version number
1814 Default region externalization/internalization related code was removed, so
1815 I want to check that everything is OK calling
1816 CFbsBitGc::ExternalizeL()/CFbsBitGc::InternalizeL().
1817 The test may also fail in the future if somebody changes CFbsBitGc data members
1818 and fail to update ExternalizeL/InternalizeL methods.
1820 @SYMTestExpectedResults Test should perform graphics operations succesfully.
1822 void CTDefect2::DEF039331L()
1824 CreateScrDevAndContextL();
1826 //Make sure that the archive file does not exist.
1827 FServSession.Delete(KArchiveFileName);
1829 RFileWriteStream wrStream;
1830 ::CleanupClosePushL(wrStream);
1831 User::LeaveIfError(wrStream.Create(FServSession, KArchiveFileName, EFileWrite | EFileRead));
1833 iGc->ExternalizeL(wrStream);
1835 CleanupStack::PopAndDestroy();//wrStream
1837 RFileReadStream rdStream;
1838 ::CleanupClosePushL(rdStream);
1839 User::LeaveIfError(rdStream.Open(FServSession, KArchiveFileName, EFileRead));
1840 iGc->InternalizeL(rdStream);
1841 CleanupStack::PopAndDestroy();//rdStream
1845 @SYMTestCaseID GRAPHICS-BITGDI-0068
1849 @SYMTestCaseDesc CFbsDevice::RectCompare says don't match when they do
1851 @SYMTestPriority normal
1853 @SYMTestStatus Implemented
1855 @SYMTestActions Creates a bitmap, calls scanlinedata then checks that the scanline returns the correct amount of data
1857 @SYMTestExpectedResults Test should return correct number of bytes
1860 void CTDefect2::DEF039650L()
1862 enum {KHeight = 1};//Bitmaps height - in pixels
1863 TDisplayMode testMode[] = {EGray2, EGray4, EGray16, EColor16, EColor4K, EColor64K, EColor16M, EColor16MU, EColor256};//tested display modes
1864 const TInt pixelPerByte[] ={8, 4, 2, 2, 0, 0, 0, 0, 1};
1865 const TInt bytePerPixel[] ={0, 0, 0, 0, 2, 2, 3, 4, 0};
1866 const TInt bitmapWidth[] = {22, 7, 11, 11, 3, 3, 1, 1, 10};//bitmaps width
1867 const TUint8 KTestVal1 = 0xA3;//test value
1868 const TUint8 KTestVal2 = 0xF7;//test value
1869 TUint8 scanLineData[100];//100 should be enough for all possible modes which are tested
1870 for(TInt ii=0;ii<TInt(sizeof(testMode)/sizeof(testMode[0]));ii++)
1872 TSize size(bitmapWidth[ii], KHeight);//bitmap size - in pixels
1873 CreateBitmapL(size, testMode[ii]);
1874 //Initialize the bitmap scanline
1875 TInt scanLineLen = 0;
1876 if(pixelPerByte[ii])
1878 scanLineLen = bitmapWidth[ii] / pixelPerByte[ii] + (bitmapWidth[ii] % pixelPerByte[ii] ? 1 : 0);
1882 scanLineLen = bitmapWidth[ii] * bytePerPixel[ii];
1884 const TInt KAddBytes = 10;
1885 Mem::Fill(scanLineData, scanLineLen, KTestVal1);
1886 TPtr8 p(scanLineData, scanLineLen, scanLineLen + KAddBytes);
1887 iBitmap->SetScanLine(p, 0);
1888 //Create bitmap device (KWidth, KHeight) size
1889 DeleteBitmapDevice();
1890 iBmpDevice = CFbsBitmapDevice::NewL(iBitmap);
1891 //Fill the scanLineData with control values
1892 Mem::Fill(scanLineData, sizeof(scanLineData), KTestVal2);
1893 //GetScanLine test - check the KAddBytes bytes
1894 iBmpDevice->GetScanLine(p, TPoint(), bitmapWidth[ii], testMode[ii]);
1895 for(TInt jj=0;jj<KAddBytes;jj++)
1897 TEST(scanLineData[scanLineLen+jj] == KTestVal2);
1899 }//end of - for(TInt ii=0;ii<TInt(sizeof(testMode)/sizeof(testMode[0]));ii++)
1903 @SYMTestCaseID GRAPHICS-BITGDI-0069
1907 @SYMTestCaseDesc Tests the performance of getting and setting pixels in different display modes
1909 @SYMTestPriority normal
1911 @SYMTestStatus Implemented
1913 @SYMTestActions draws a number opf pixels to a bitmap then reads them back. Time is recorded
1915 @SYMTestExpectedResults Test should perform graphics operations succesfully.
1917 void CTDefect2::GetPixelPerformance1L()
1919 TDisplayMode mode[] = {EColor16MA, EColor16MAP, EColor256, EColor4K, EColor16M, EColor16MU, EColor64K,
1920 EGray256, EGray16, EGray4, EGray2, EColor16};
1921 _LIT(KLog,"Mode %S. Uncompressed bitmap. Time=%d");
1922 for(TInt ii=0;ii<TInt(sizeof(mode)/sizeof(mode[0]));ii++)
1925 enum {KWidth = 600, KHeight = 400};
1926 TSize size(KWidth, KHeight);
1927 CreateBitmapL(size, mode[ii]);
1928 TEST(!iBitmap->IsCompressedInRAM());
1930 TBitmapUtil bmpUtil(iBitmap);
1932 now.UniversalTime();
1933 TInt64 seed = now.Int64();
1934 bmpUtil.Begin(TPoint(0, 0));
1935 for(TInt j1=0;j1<KWidth;j1++)
1937 for(TInt j2=0;j2<KHeight;j2++)
1939 bmpUtil.SetPos(TPoint(j1, j2));
1940 bmpUtil.SetPixel(Math::Rand(seed));
1945 TUint time = User::TickCount();
1948 for(TInt jj=0;jj<size.iWidth;jj++)
1950 for(TInt kk=0;kk<size.iHeight;kk++)
1954 iBitmap->GetPixel(color, pt);
1957 time = User::TickCount() - time;
1958 INFO_PRINTF3(KLog,&ColorModeName(mode[ii]),time);
1961 }//end of - for(TInt ii=0;ii<TInt(sizeof(mode)/sizeof(mode[0]));ii++)
1965 @SYMTestCaseID GRAPHICS-BITGDI-0070
1969 @SYMTestCaseDesc Draws text to the screen device in different orientations
1971 @SYMTestPriority normal
1973 @SYMTestStatus Implemented
1975 @SYMTestActions Creates a screen device and gc, changes the gc orientation then draws some text to it
1977 @SYMTestExpectedResults Test should perform graphics operations succesfully.
1979 void CTDefect2::RotateMoveTextL()
1981 TInt err=CreateScrDevAndContext(EColor64K);
1983 err=CreateScrDevAndContext(EColor256);
1985 err=CreateScrDevAndContext(EColor16MA);
1987 err=CreateScrDevAndContext(EColor16MAP);
1988 TEST(err==KErrNone);
1989 DoRotateMoveTextL();
1992 void CTDefect2::DoRotateMoveTextL()
1994 __ASSERT_ALWAYS(iScrDev, User::Invariant());
1995 __ASSERT_ALWAYS(iGc, User::Invariant());
1999 const CFbsBitGc::TGraphicsOrientation KOrientation[] =
2001 CFbsBitGc::EGraphicsOrientationNormal,
2002 CFbsBitGc::EGraphicsOrientationRotated90,
2003 CFbsBitGc::EGraphicsOrientationRotated180,
2004 CFbsBitGc::EGraphicsOrientationRotated270
2007 for(TInt ii=0;ii<TInt(sizeof(KOrientation)/sizeof(KOrientation[0]));++ii)
2009 if(!iGc->SetOrientation(KOrientation[ii]))
2013 _LIT(KRotation,"===EOrientation%S===");
2014 INFO_PRINTF2(KRotation,&RotationName(KOrientation[ii]));
2016 TSize size = iScrDev->SizeInPixels();
2017 RDebug::Print(_L("Size: %d, %d\r\n"), size.iWidth, size.iHeight);
2018 for(TInt x=-40;x<(size.iWidth+30);x+=27)
2020 for(TInt y=-40;y<(size.iHeight+30);y+=23)
2023 iGc->SetPenStyle(CGraphicsContext::ESolidPen);
2024 iGc->SetPenColor(TRgb(0x00, 0x00, 0x00));
2025 iGc->SetPenSize(TSize(1, 1));
2027 iGc->DrawText(_L("Test text"), TPoint(x, y));
2033 iGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal);
2037 @SYMTestCaseID GRAPHICS-BITGDI-0071
2041 @SYMTestCaseDesc Swaps width and height of a bitmap
2043 @SYMTestPriority normal
2045 @SYMTestStatus Implemented
2047 @SYMTestActions Test to swap the width and height of a bitmap
2049 @SYMTestExpectedResults Test should perform graphics operations succesfully.
2051 void CTDefect2::SwapWidthAndHeightL()
2053 TDisplayMode testMode[] = {EColor4K, EColor64K, EColor16M, EColor16MU,
2054 EColor256, EColor16MA, EColor16MAP, EColor16, EGray16, EGray4, EGray2};//tested display modes
2055 _LIT(KLog,"Mode %S");
2056 for(TInt ii=0;ii<TInt(sizeof(testMode)/sizeof(testMode[0]));ii++)
2058 INFO_PRINTF2(KLog,&ColorModeName(testMode[ii]));
2059 TSize size(40, 12);//bitmap size - in pixels
2060 CreateBitmapL(size, testMode[ii]);//iBitmap - created
2061 //Create bitmap device
2062 DeleteBitmapDevice();
2063 iBmpDevice = CFbsBitmapDevice::NewL(iBitmap);
2064 TInt err = iBmpDevice->SwapWidthAndHeight();
2065 TEST(err == KErrNone);
2066 }//end of - for(TInt ii=0;ii<TInt(sizeof(testMode)/sizeof(testMode[0]));ii++)
2070 void CTDefect2::CreateScrDevAndContextL()
2072 DeleteGraphicsContext();
2073 DeleteScreenDevice();
2074 TDisplayMode mode[] = {EColor256, EColor4K, EColor16M, EColor16MU, EColor64K,
2075 EGray256, EGray16, EGray4, EGray2, EColor16, EColor16MA, EColor16MAP};
2077 TInt err = KErrNotSupported;
2078 for(ii=0;(ii<TInt(sizeof(mode)/sizeof(mode[0]))) && (err == KErrNotSupported);++ii)
2080 err = CreateScrDevAndContext(mode[ii]);
2082 TEST(err == KErrNone);
2085 TInt CTDefect2::CreateScrDevAndContext(TInt aScreenNo, TDisplayMode aDisplayMode)
2087 DeleteGraphicsContext();
2088 DeleteScreenDevice();
2089 TRAPD(err, iScrDev = CFbsScreenDevice::NewL(aScreenNo, aDisplayMode));
2092 TESTE( err == KErrNotSupported, err );
2095 TEST(err == KErrNone);
2096 TEST(iScrDev->ScreenNo() == aScreenNo);
2097 err = iScrDev->CreateContext((CGraphicsContext*&)iGc);
2102 TEST(err == KErrNone);
2103 iGc->SetUserDisplayMode(aDisplayMode);
2104 iScrDev->ChangeScreenDevice(NULL);
2105 iScrDev->SetAutoUpdate(EFalse);
2106 iSize = iScrDev->SizeInPixels();
2107 iCurrentMode = aDisplayMode;
2111 TInt CTDefect2::CreateScrDevAndContext(TDisplayMode aDisplayMode)
2113 return CreateScrDevAndContext(KDefaultScreenNo,aDisplayMode);
2116 void CTDefect2::DeleteScreenDevice()
2122 void CTDefect2::DeleteGraphicsContext()
2128 void CTDefect2::CreateBitmapL(const TSize& aSize, TDisplayMode aMode)
2131 iBitmap = new (ELeave) CFbsBitmap;
2132 User::LeaveIfError(iBitmap->Create(aSize, aMode));
2135 void CTDefect2::DeleteBitmap()
2145 void CTDefect2::DeleteBitmapDevice()
2151 void CTDefect2::CreateFontL()
2153 CFbsFont* font = NULL;
2154 TFontSpec fs(_L("Swiss"), 12);
2155 User::LeaveIfError(iScrDev->GetNearestFontToDesignHeightInPixels(font, fs));
2159 void CTDefect2::DestroyFont()
2168 @SYMTestCaseID GRAPHICS-BITGDI-0073
2172 @SYMTestCaseDesc Clear with non-zero origin
2174 @SYMTestPriority High
2176 @SYMTestStatus Implemented
2178 @SYMTestActions Creates a gc, setes its origin off (0,0) then clears it
2180 @SYMTestExpectedResults Test should perform graphics operations succesfully.
2182 void CTDefect2::NonZeroOriginClearL()
2184 TInt err=CreateScrDevAndContext(EColor64K);
2185 if (err==KErrNotSupported)
2186 err=CreateScrDevAndContext(EColor16MA);
2187 if (err==KErrNotSupported)
2188 err=CreateScrDevAndContext(EColor16MAP);
2191 _LIT(KLog,"Failed to create screen device, err=%d");
2192 INFO_PRINTF2(KLog,err);
2194 TRgb setColor(TRgb::Color64K(13897));
2195 iGc->SetBrushColor(setColor);
2196 iGc->SetOrigin(TPoint(100,100));
2200 //Check samples of the screen that it is the right color
2201 TSize size=iScrDev->SizeInPixels();
2205 for (x=0;x<size.iWidth;x+=10)
2207 for (y=0;y<size.iHeight;y+=10)
2210 iScrDev->GetPixel(gotColor, TPoint(x,y));
2211 TEST(gotColor==setColor);
2217 @SYMTestCaseID GRAPHICS-BITGDI-0108
2221 @SYMTestCaseDesc Use pattern brush bitmaps with zero widths or zero height or both
2223 @SYMTestPriority High
2225 @SYMTestStatus Implemented
2227 @SYMTestActions Creates 3 bitmaps:
2228 One with zero width, one with zero height, one width zero width and height.
2229 Each bitmap should automatically be cleared to white.
2230 Clear the screen to black.
2231 Set the GC to use patterned brush.
2232 In turn, set the brush pattern to be one of the bitmap and draw a rectangle.
2233 @SYMTestExpectedResults Each rectangle drawn should remain black as each pattern brush should not be used.
2235 void CTDefect2::ZeroSizedPatternBrushL()
2237 // Create a source bitmap with zero width
2238 CFbsBitmap* bmp1 = new (ELeave) CFbsBitmap();
2239 CleanupStack::PushL(bmp1);
2240 User::LeaveIfError(bmp1->Create(TSize(0,1), EColor16MU));
2242 // Create a source bitmap with zero height
2243 CFbsBitmap* bmp2 = new(ELeave) CFbsBitmap();
2244 CleanupStack::PushL(bmp2);
2245 User::LeaveIfError(bmp2->Create(TSize(1,0), EColor16MU));
2247 // Create a source bitmap with zero width and height
2248 CFbsBitmap* bmp3 = new (ELeave) CFbsBitmap();
2249 CleanupStack::PushL(bmp3);
2250 User::LeaveIfError(bmp3->Create(TSize(0,0), EColor16MU));
2252 //Create a screen device & gc
2253 CreateScrDevAndContextL();
2255 TRgb clearColor = KRgbBlack;
2256 iGc->SetBrushColor(clearColor);
2259 iGc->SetPenStyle(CGraphicsContext::ENullPen);
2260 iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
2261 TSize drawRectSize(10,3);
2262 // Draw a rectangle using each bitmap as a brush pattern
2263 // Each rectangle does not overlap
2264 iGc->UseBrushPattern(bmp1);
2265 iGc->DrawRect(TRect(TPoint(0,0),drawRectSize));
2267 iGc->UseBrushPattern(bmp2);
2268 iGc->DrawRect(TRect(TPoint(0,4),drawRectSize));
2270 iGc->UseBrushPattern(bmp3);
2271 iGc->DrawRect(TRect(TPoint(0,8),drawRectSize));
2274 // Bitmaps should be cleared to white when created, so if they are drawn
2275 // will show up different to cleared screen.
2276 for(TInt y=0; y<12; ++y)
2278 for(TInt x=0; x<10; ++x)
2281 iScrDev->GetPixel(pixelColor,TPoint(x,y));
2282 TEST(pixelColor==clearColor);
2285 CleanupStack::PopAndDestroy(3, bmp1);
2286 DeleteGraphicsContext();
2287 DeleteScreenDevice();
2291 @SYMTestCaseID GRAPHICS-BITGDI-0110
2293 @SYMDEF INC128813,PDEF129382
2295 @SYMTestCaseDesc Test CFbsBitGc::InternalizeL() when the font duplicate called from
2296 CFbsBitGc::Internalize:() fails.
2298 @SYMTestPriority Normal
2300 @SYMTestStatus Implemented (udeb/ debug versions only)
2302 @SYMTestActions Create and externalize a the CFbsBitGc*.
2303 Then send a message to the font and bitmap server to force
2304 CFbsBitGcFont::Duplicate() calls to fail.
2305 Internalize the CFbsBitGc*()
2306 Then send a message to the font and bitmap server to allow
2307 CFbsBitGcFont::Duplicate() calls to succeed.
2308 If the test runs to completion without any panics, then it has passed.
2310 void CTDefect2::CFbsBitGcInternalizeLFailL()
2312 // this code is based on test CTDefect2::DEF039331L();
2314 INFO_PRINTF1(_L("Cannot run CFbsBitGcInternalizeLFailL test because test needs udeb for fbserv"));
2318 CreateScrDevAndContextL();
2320 //Make sure that the archive file does not exist.
2321 FServSession.Delete(KArchiveFileName);
2323 CBufFlat* flatBuf = CBufFlat::NewL(256);
2324 CleanupStack::PushL(flatBuf);
2325 RBufWriteStream wrStream(*flatBuf);
2326 ::CleanupClosePushL(wrStream);
2330 iGc->ExternalizeL(wrStream);
2332 CleanupStack::PopAndDestroy();//wrStream
2334 RBufReadStream rdStream(*flatBuf);
2335 ::CleanupClosePushL(rdStream);
2337 RFbsSession::GetSession()->SendCommand(static_cast<TInt>(EFbsMessSetDuplicateFail),1);
2340 TRAP(ret, (void)(iGc->InternalizeL(rdStream)));
2341 INFO_PRINTF2(_L("CFbsBitGcInternalizeLFailL test returned %d: should have an error code"),ret);
2343 RFbsSession::GetSession()->SendCommand(static_cast<TInt>(EFbsMessSetDuplicateFail),0);
2345 //Without the fix there is a Kern-Exec3 panic.
2347 CleanupStack::PopAndDestroy(2,flatBuf);
2352 @SYMTestCaseID GRAPHICS-BITGDI-0111
2356 @SYMTestCaseDesc Compare output from CFbsScreenDevice::HorizontalPixelsToTwips() and
2357 VerticalPixelsToTwips() with the same methods in CWsScreenDevice with
2358 large input numbers.
2360 @SYMTestPriority Normal
2362 @SYMTestStatus Implemented
2364 @SYMTestActions Creates an instance of CWsScreenDevice (instance of CFbsScreenDevice already prepared for
2365 other tests). Call the pixels to twips and twips to pixels conversion methods on each with same
2366 number. Compare the resulting output.
2367 @SYMTestExpectedResults Outputs should be within a small tolerance.
2369 void CTDefect2::PixelsToTwipsConversionCheck()
2371 const TInt KHorizontalTestPixels=64000000;
2372 const TInt KVerticalTestPixels=24000000;
2373 const TReal32 KTolerance=0.10; // Percent difference permitted
2374 TInt cFbsScreenDeviceResult = 1;
2375 TInt cWsScreenDeviceResult = 1;
2376 TReal32 percentDifference = 0.0;
2377 CreateScrDevAndContextL();
2378 TBool testResult = EFalse;
2380 RWsSession wsSession;
2381 if (KErrNone == wsSession.Connect())
2383 CWsScreenDevice* wsScrDev = new (ELeave) CWsScreenDevice(wsSession);
2384 wsScrDev->Construct(0);
2386 // first compare results of the two class's HorizontalPixelsToTwips and pass
2387 // the test if they are within tolerance
2388 cFbsScreenDeviceResult = iScrDev->HorizontalPixelsToTwips(KHorizontalTestPixels);
2389 cWsScreenDeviceResult = wsScrDev->HorizontalPixelsToTwips(KHorizontalTestPixels);
2390 percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
2391 testResult = (percentDifference < KTolerance);
2394 _LIT(KHorizPixelsToTwipsDesc, "%d horizontal pixels converted to twips by screen device: FBS=%d, WS=%d");
2395 WARN_PRINTF4(KHorizPixelsToTwipsDesc, KHorizontalTestPixels, cFbsScreenDeviceResult, cWsScreenDeviceResult);
2399 // convert the CWsScreenDevice result back again using each class's HorizontalTwipsToPixels
2400 // and pass the test if these results are within tolerance
2401 TInt numTwipsToTest = cWsScreenDeviceResult;
2402 cFbsScreenDeviceResult = iScrDev->HorizontalTwipsToPixels(numTwipsToTest);
2403 cWsScreenDeviceResult = wsScrDev->HorizontalTwipsToPixels(numTwipsToTest);
2404 percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
2405 testResult = (percentDifference < KTolerance);
2408 _LIT(KHorizTwipsToPixelsDesc, "%d horizontal twips converted to pixels by screen device: FBS=%d, WS=%d");
2409 WARN_PRINTF4(KHorizTwipsToPixelsDesc, numTwipsToTest, cFbsScreenDeviceResult, cWsScreenDeviceResult);
2413 // next compare results of the two class's VerticalPixelsToTwips and pass the test
2414 // if they are within tolerance
2415 cFbsScreenDeviceResult = iScrDev->VerticalPixelsToTwips(KVerticalTestPixels);
2416 cWsScreenDeviceResult= wsScrDev->VerticalPixelsToTwips(KVerticalTestPixels);
2417 percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
2418 testResult = (percentDifference < KTolerance);
2421 _LIT(KVertPixelsToTwipsDesc, "%d vertical pixels converted to twips by screen device: FBS=%d, WS=%d");
2422 WARN_PRINTF4(KVertPixelsToTwipsDesc, KVerticalTestPixels, cFbsScreenDeviceResult, cWsScreenDeviceResult);
2426 // convert the CWsScreenDevice result back again using each class's VerticalTwipsToPixels
2427 // and pass the test if these results are within tolerance
2428 numTwipsToTest = cWsScreenDeviceResult;
2429 cFbsScreenDeviceResult = iScrDev->VerticalTwipsToPixels(numTwipsToTest);
2430 cWsScreenDeviceResult = wsScrDev->VerticalTwipsToPixels(numTwipsToTest);
2431 percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
2432 testResult = (percentDifference < KTolerance);
2435 _LIT(KVertTwipsToPixelsDesc, "%d vertical twips converted to pixels by screen device: FBS=%d, WS=%d");
2436 WARN_PRINTF4(KVertTwipsToPixelsDesc, numTwipsToTest, cFbsScreenDeviceResult, cWsScreenDeviceResult);
2445 iStep->SetTestStepResult(EFail);
2446 _LIT(KMessage,"ERROR: Test Failed");
2447 Logger().LogExtra((TText8*)__FILE__, __LINE__, ESevrErr,KMessage);
2452 @SYMTestCaseID GRAPHICS-BITGDI-0113
2456 @SYMTestCaseDesc Test CFbsBitGc::CopyRect() with non-trivial alpha channel
2458 @SYMTestPriority Normal
2460 @SYMTestStatus Implemented
2462 @SYMTestActions Create a 128 by 128 pixel bitmap with display mode EColor16MA.
2463 Fill the upper half of the bitmap with semi-transparent gray.
2464 Call CFbsBitGc::CopyRect() to copy the upper half to the lower half.
2465 Sample one pixel from both the upper and lower half of the bitmap.
2467 @SYMTestExpectedResults The two pixels should be the same. Without the fix the lower part
2468 would show a lighter shade of the gray.
2470 void CTDefect2::CopyRectAlphaL()
2472 TSize size = TSize(128, 128);
2474 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
2475 CleanupStack::PushL(bitmap);
2476 User::LeaveIfError(bitmap->Create(size, EColor16MA));
2478 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmap);
2479 CleanupStack::PushL(bitmapDevice);
2481 CFbsBitGc* bitmapContext = NULL;
2482 User::LeaveIfError(bitmapDevice->CreateContext(bitmapContext));
2483 CleanupStack::PushL(bitmapContext);
2485 bitmap->BeginDataAccess();
2486 Mem::Fill(bitmap->DataAddress(), 128 * 4 * 64, 0x80);
2487 bitmap->EndDataAccess();
2488 bitmapContext->CopyRect(TPoint(0, 64), TRect(0, 0, 128, 64));
2490 //sample a pixel from the lower part of the bitmap and it should be the same as the upper half
2491 TRgb pixelColorUpper;
2492 bitmap->GetPixel(pixelColorUpper, TPoint(2, 3));
2493 TRgb pixelColorLower;
2494 bitmap->GetPixel(pixelColorLower, TPoint(80, 90));
2495 TEST(pixelColorUpper == pixelColorLower);
2497 CleanupStack::PopAndDestroy(3, bitmap);
2502 class TTestSetBitsThread: public TFunctionThread
2505 TTestSetBitsThread(TDisplayMode aDisplayMode, TBool aVerticalResize, TBool aScaling);
2507 virtual TInt ThreadFunctionL();
2509 TDisplayMode iDisplayMode;
2510 TBool iVerticalResize;
2514 TTestSetBitsThread::TTestSetBitsThread(TDisplayMode aDisplayMode, TBool aVerticalResize, TBool aScaling)
2515 : iDisplayMode(aDisplayMode), iVerticalResize(aVerticalResize), iScaling(aScaling)
2517 TBuf<32> threadName;
2518 threadName.Format(_L("TestSetBits-%d-%d-%d"), TInt(aDisplayMode), TInt(aVerticalResize), TInt(aScaling));
2519 LaunchThreadFunction(threadName);
2522 TInt TTestSetBitsThread::ThreadFunctionL()
2524 CFbsBitmap* bmp = new(ELeave) CFbsBitmap;
2525 CleanupStack::PushL(bmp);
2526 User::LeaveIfError(bmp->Create(TSize(256, 256), iDisplayMode));
2527 CFbsBitmapDevice* bmpDev = CFbsBitmapDevice::NewL(bmp);
2528 CleanupStack::PushL(bmpDev);
2531 User::LeaveIfError(bmpDev->SetScalingFactor(TPoint(0, 0), 2, 2, 1, 1));
2533 if (iVerticalResize)
2535 User::LeaveIfError(bmp->Resize(TSize(256, 128)));
2539 User::LeaveIfError(bmp->Resize(TSize(128, 256)));
2541 bmpDev->DrawingBegin();
2542 bmpDev->DrawingEnd();
2543 CleanupStack::PopAndDestroy(2);
2548 @SYMTestCaseID GRAPHICS-BITGDI-0112
2552 @SYMTestCaseDesc Makes sure that CFbsBitmapDevice::SetBits() checks that the bitmap size is consistent.
2554 @SYMTestPriority Normal
2556 @SYMTestStatus Implemented
2558 @SYMTestActions 1. Creates a bitmap and an associated bitmap device.
2559 2. Resizes the bitmap directly.
2560 3. Calls DrawingBegin()/DrawingEnd() on the bitmap device.
2562 @SYMTestExpectedResults The call to DrawingBegin() should panic in debug builds.
2564 void CTDefect2::TestSetBitsL()
2567 for (TBool verticalResize = 0; verticalResize <= 1; ++verticalResize)
2569 for (TBool scaling = 0; scaling <= 1; ++scaling)
2571 TTestSetBitsThread testThread1(EGray2, verticalResize, scaling);
2572 TEST(testThread1.iExitHow == TFunctionThread::EPanic);
2573 TEST(testThread1.iExitCode == EBitgdiPanicInvalidBitmap);
2575 TTestSetBitsThread testThread2(EGray4, verticalResize, scaling);
2576 TEST(testThread2.iExitHow == TFunctionThread::EPanic);
2577 TEST(testThread2.iExitCode == EBitgdiPanicInvalidBitmap);
2579 TTestSetBitsThread testThread3(EGray16, verticalResize, scaling);
2580 TEST(testThread3.iExitHow == TFunctionThread::EPanic);
2581 TEST(testThread3.iExitCode == EBitgdiPanicInvalidBitmap);
2583 TTestSetBitsThread testThread4(EColor16, verticalResize, scaling);
2584 TEST(testThread4.iExitHow == TFunctionThread::EPanic);
2585 TEST(testThread4.iExitCode == EBitgdiPanicInvalidBitmap);
2587 TTestSetBitsThread testThread5(EGray256, verticalResize, scaling);
2588 TEST(testThread5.iExitHow == TFunctionThread::EPanic);
2589 TEST(testThread5.iExitCode == EBitgdiPanicInvalidBitmap);
2591 TTestSetBitsThread testThread6(EColor256, verticalResize, scaling);
2592 TEST(testThread6.iExitHow == TFunctionThread::EPanic);
2593 TEST(testThread6.iExitCode == EBitgdiPanicInvalidBitmap);
2595 TTestSetBitsThread testThread7(EColor4K, verticalResize, scaling);
2596 TEST(testThread7.iExitHow == TFunctionThread::EPanic);
2597 TEST(testThread7.iExitCode == EBitgdiPanicInvalidBitmap);
2599 TTestSetBitsThread testThread8(EColor64K, verticalResize, scaling);
2600 TEST(testThread8.iExitHow == TFunctionThread::EPanic);
2601 TEST(testThread8.iExitCode == EBitgdiPanicInvalidBitmap);
2603 TTestSetBitsThread testThread9(EColor16M, verticalResize, scaling);
2604 TEST(testThread9.iExitHow == TFunctionThread::EPanic);
2605 TEST(testThread9.iExitCode == EBitgdiPanicInvalidBitmap);
2607 TTestSetBitsThread testThread10(EColor16MU, verticalResize, scaling);
2608 TEST(testThread10.iExitHow == TFunctionThread::EPanic);
2609 TEST(testThread10.iExitCode == EBitgdiPanicInvalidBitmap);
2611 TTestSetBitsThread testThread11(EColor16MA, verticalResize, scaling);
2612 TEST(testThread11.iExitHow == TFunctionThread::EPanic);
2613 TEST(testThread11.iExitCode == EBitgdiPanicInvalidBitmap);
2615 TTestSetBitsThread testThread12(EColor16MAP, verticalResize, scaling);
2616 TEST(testThread12.iExitHow == TFunctionThread::EPanic);
2617 TEST(testThread12.iExitCode == EBitgdiPanicInvalidBitmap);
2621 WARN_PRINTF1(_L("Test skipped because it needs udeb build"));
2626 __CONSTRUCT_STEP__(Defect2)
2628 void CTDefect2Step::TestSetupL()
2632 void CTDefect2Step::TestClose()
2634 ::DeleteDataFile(KArchiveFileName);