Update contrib.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @internalComponent - Internal Symbian test code
26 #include <test/tefunit.h>
27 #include <graphics/bitmapuid.h>
28 #include "../sfbs/UTILS.H"
30 #include "../sfbs/fbsbitmapasyncstreamer.h"
31 #include "fbsmessage.h"
33 // Symbian modification to help reduce unnecessary warnings
34 #if (__ARMCC_VERSION >= 310000)
35 //turn off Warning: #546-D: transfer of control bypasses initialization of variable, which is unnecessary.
36 #pragma diag_suppress 546
38 // End of Symbian modification
45 //LOCAL_D RTest TheTest(_L("Test Bitmap"));
47 const TUint8 KCheckValue = 0x69;//pixel value used in the tests
49 _LIT(KBmpCompr12, "z:\\system\\data\\compr12.mbm");
50 _LIT(KBmpCompr16, "z:\\system\\data\\compr16.mbm");
51 _LIT(KBmpCompr24, "z:\\system\\data\\compr24.mbm");
52 _LIT(KBmpZCompr12, "z:\\system\\data\\racompr12.mbm");
53 _LIT(KBmpZCompr16, "z:\\system\\data\\racompr16.mbm");
54 _LIT(KBmpZCompr24, "z:\\system\\data\\racompr24.mbm");
55 _LIT(KBmpCCompr12, "c:\\racompr12.mbm");
56 _LIT(KBmpCCompr16, "c:\\racompr16.mbm");
57 _LIT(KBmpCCompr24, "c:\\racompr24.mbm");
59 _LIT(KRc_RamInRom8, "z:\\system\\data\\rc_ram8.mbm");
60 _LIT(KRc_RamInRom12, "z:\\system\\data\\rc_ram12.mbm");
61 _LIT(KRc_RamInRom16, "z:\\system\\data\\rc_ram16.mbm");
62 _LIT(KRc_RamInRom24, "z:\\system\\data\\rc_ram24.mbm");
64 _LIT(KRc_Ram8, "c:\\rc_ram8.mbm");
65 _LIT(KRc_Ram12, "c:\\rc_ram12.mbm");
66 _LIT(KRc_Ram16, "c:\\rc_ram16.mbm");
67 _LIT(KRc_Ram24, "c:\\rc_ram24.mbm");
69 _LIT(KRamBitmapOnZ, "z:\\system\\data\\16RAM2.mbm");
70 _LIT(KRamBitmap, "c:\\16RAM2.mbm");
71 _LIT(KRamBitmap2, "c:\\16RAM3.mbm");
73 _LIT(KMono_RamInRom_M1, "z:\\system\\data\\mono_m1.mbm");
74 _LIT(KMono_RamInRom_M2, "z:\\system\\data\\mono_m2.mbm");
75 _LIT(KMono_RamInRom_M4, "z:\\system\\data\\mono_m4.mbm");
76 _LIT(KMono_RamInRom_M8, "z:\\system\\data\\mono_m8.mbm");
77 _LIT(KMono_RamInRom_C4, "z:\\system\\data\\mono_c4.mbm");
78 _LIT(KMono_RamInRom_C8, "z:\\system\\data\\mono_c8.mbm");
79 _LIT(KMono_RamInRom_C12, "z:\\system\\data\\mono_c12.mbm");
80 _LIT(KMono_RamInRom_C16, "z:\\system\\data\\mono_c16.mbm");
81 _LIT(KMono_RamInRom_C24, "z:\\system\\data\\mono_c24.mbm");
82 _LIT(KMono_RamInRom_C32, "z:\\system\\data\\mono_c32.mbm");
84 _LIT(KMono_M1, "c:\\mono_m1.mbm");
85 _LIT(KMono_M2, "c:\\mono_m2.mbm");
86 _LIT(KMono_M4, "c:\\mono_m4.mbm");
87 _LIT(KMono_M8, "c:\\mono_m8.mbm");
88 _LIT(KMono_C4, "c:\\mono_c4.mbm");
89 _LIT(KMono_C8, "c:\\mono_c8.mbm");
90 _LIT(KMono_C12, "c:\\mono_c12.mbm");
91 _LIT(KMono_C16, "c:\\mono_c16.mbm");
92 _LIT(KMono_C24, "c:\\mono_c24.mbm");
93 _LIT(KMono_C32, "c:\\mono_c32.mbm");
95 _LIT(KRomBitmap,"z:\\system\\data\\tfbs.rbm");
99 //Create/Destroy test environment global functions
101 //Delete "aFullName" file.
102 LOCAL_C void DeleteDataFile(const TDesC& aFullName)
105 TInt err = fsSession.Connect();
109 if(fsSession.Entry(aFullName, entry) == KErrNone)
111 RDebug::Print(_L("Deleting \"%S\" file.\n"), &aFullName);
112 err = fsSession.SetAtt(aFullName, 0, KEntryAttReadOnly);
115 RDebug::Print(_L("Error %d changing \"%S\" file attributes.\n"), err, &aFullName);
117 err = fsSession.Delete(aFullName);
120 RDebug::Print(_L("Error %d deleting \"%S\" file.\n"), err, &aFullName);
127 RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName);
131 //Copy test bitmaps from Z: to C: drive. RFs::Connect() had to be called already
133 LOCAL_C void CopyFilesOnC()
135 BaflUtils::CopyFile(TheFs, KTestBitmapOnZ, KTestBitmapOnC);
136 BaflUtils::CopyFile(TheFs, KBmpZCompr12, KBmpCCompr12);
137 BaflUtils::CopyFile(TheFs, KBmpZCompr16, KBmpCCompr16);
138 BaflUtils::CopyFile(TheFs, KBmpZCompr24, KBmpCCompr24);
139 BaflUtils::CopyFile(TheFs, KRc_RamInRom8, KRc_Ram8);
140 BaflUtils::CopyFile(TheFs, KRc_RamInRom12, KRc_Ram12);
141 BaflUtils::CopyFile(TheFs, KRc_RamInRom16, KRc_Ram16);
142 BaflUtils::CopyFile(TheFs, KRc_RamInRom24, KRc_Ram24);
143 BaflUtils::CopyFile(TheFs, KRamBitmapOnZ, KRamBitmap);
144 BaflUtils::CopyFile(TheFs, KRamBitmapOnZ, KRamBitmap2);
145 BaflUtils::CopyFile(TheFs, KMono_RamInRom_M1, KMono_M1);
146 BaflUtils::CopyFile(TheFs, KMono_RamInRom_M2, KMono_M2);
147 BaflUtils::CopyFile(TheFs, KMono_RamInRom_M4, KMono_M4);
148 BaflUtils::CopyFile(TheFs, KMono_RamInRom_M8, KMono_M8);
149 BaflUtils::CopyFile(TheFs, KMono_RamInRom_C4, KMono_C4);
150 BaflUtils::CopyFile(TheFs, KMono_RamInRom_C8, KMono_C8);
151 BaflUtils::CopyFile(TheFs, KMono_RamInRom_C12, KMono_C12);
152 BaflUtils::CopyFile(TheFs, KMono_RamInRom_C16, KMono_C16);
153 BaflUtils::CopyFile(TheFs, KMono_RamInRom_C24, KMono_C24);
154 BaflUtils::CopyFile(TheFs, KMono_RamInRom_C32, KMono_C32);
157 //Delete data files used by the test
158 LOCAL_C void DeleteFilesFromC()
160 DeleteDataFile(KTestBitmapOnC);
161 DeleteDataFile(KBmpCCompr12);
162 DeleteDataFile(KBmpCCompr16);
163 DeleteDataFile(KBmpCCompr24);
164 DeleteDataFile(KRc_Ram8);
165 DeleteDataFile(KRc_Ram12);
166 DeleteDataFile(KRc_Ram16);
167 DeleteDataFile(KRc_Ram24);
168 DeleteDataFile(KRamBitmap);
169 DeleteDataFile(KRamBitmap2);
170 DeleteDataFile(KMono_M1);
171 DeleteDataFile(KMono_M2);
172 DeleteDataFile(KMono_M4);
173 DeleteDataFile(KMono_M8);
174 DeleteDataFile(KMono_C4);
175 DeleteDataFile(KMono_C8);
176 DeleteDataFile(KMono_C12);
177 DeleteDataFile(KMono_C16);
178 DeleteDataFile(KMono_C24);
179 DeleteDataFile(KMono_C32);
185 void CTBitmap::DeleteScanLineBuffer()
187 RFbsSession* fbs = RFbsSession::GetSession();
188 delete fbs->iScanLineBuffer;
189 fbs->iScanLineBuffer = NULL;
192 CTBitmap::CTBitmap(CTestStep* aStep):
193 CTGraphicsBase(aStep),
198 __ASSERT_DEBUG(CActiveScheduler::Current(), User::Invariant());
200 iTestBitmapName = KTestBitmapOnZ;
201 TInt ret=bmp.Load(iTestBitmapName,ETfbs,NULL);
202 TEST2(ret, KErrNone);
206 TEST2(ret, KErrNone);
208 // Expand session scanline buffer cache to avoid spurious alloc heavens later on
209 const TInt bufferSize = 1024;
211 ret = bmp.Create(TSize(bufferSize,1),EColor256);
212 TEST2(ret, KErrNone);
214 ret = bmp.Compress();
215 TEST2(ret, KErrNone);
217 TUint8* buffer = new TUint8[bufferSize];
218 TEST(buffer != NULL);
220 TPtr8 scanline(buffer,bufferSize,bufferSize);
221 bmp.GetScanLine(scanline,TPoint(0,0),bufferSize,EColor256);
225 TUint32* romAddress = NULL;
226 if(!CFbsBitmap::IsFileInRom(KRomBitmap, romAddress)) //any ROM bitmap
228 INFO_PRINTF2(_L("Skipping ROM bitmap tests since file \"%S\" is reported to not be a ROM bitmap."),
230 INFO_PRINTF1(_L("This should only occur on non-XIP ROMs, e.g. NAND ROMs, where ROM bitmaps aren't supported."));
231 iSkipRomBitmapTests = ETrue;
235 CTBitmap::~CTBitmap()
240 void CTBitmap::RunTestCaseL(TInt aCurTestCase)
242 ((CTBitmapStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
246 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0550"));
250 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0517"));
251 // they are fast hence at the beginning
255 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0534"));
259 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0518"));
263 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0519"));
267 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0523"));
271 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0524"));
275 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0525"));
279 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0526"));
283 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0527"));
287 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0528"));
291 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0529"));
295 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0520"));
299 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0521"));
303 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0522"));
307 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0530"));
311 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0531"));
315 ((CTBitmapStep*)iStep)->SetTestStepID(_L(" GRAPHICS-FBSERV-0533"));
319 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0532"));
323 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0535"));
324 Color256BitmapUtil();
327 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0536"));
331 ((CTBitmapStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
335 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0537"));
339 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0538"));
340 PerformanceTest_INC036062L();
343 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0539"));
347 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0540"));
351 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0541"));
355 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0542"));
359 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0543"));
360 GetVerticalScanLineL();
363 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0544"));
364 GetVerticalScanLinePerformanceL();
367 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0545"));
369 ((CTBitmapStep*)iStep)->RecordTestResultL();
370 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0546"));
372 ((CTBitmapStep*)iStep)->RecordTestResultL();
373 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0547"));
376 ((CTBitmapStep*)iStep)->RecordTestResultL();
377 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0549"));
378 //It uses Heap Allocation failure macro
379 //which is supported only for debug mode
384 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0548"));
388 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0551"));
389 TestPaletteCompressionL();
392 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0552"));
393 TestSynchronousBackgroundPaletteCompressionL();
396 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0553"));
397 TestAsynchronousBackgroundPaletteCompressionL();
400 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0501"));
404 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0554"));
408 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0516"));
409 CheckSetDisplayModeL();
413 @SYMTestCaseID GRAPHICS-FBSERV-0619
415 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0619"));
416 MultiThreadedTestsL();
419 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0612"));
423 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0613"));
424 TestBgCompressInUseL();
427 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0614"));
428 TestDisconnectWithBitmapL();
431 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0617"));
432 TestTouchedAndVolatileL();
435 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0618"));
436 TestBitmapWhiteFillL();
440 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0661"));
441 TestBitmapUtilWithUnsupportedBitmaps();
445 ((CTBitmapStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
446 ((CTBitmapStep*)iStep)->CloseTMSGraphicsStep();
450 ((CTBitmapStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
454 ((CTBitmapStep*)iStep)->RecordTestResultL();
462 Checks that the display mode can be set
463 to various modes, including EColor16MAP
467 @SYMTestExpectedResults
470 void CTBitmap::CheckSetDisplayModeL()
472 INFO_PRINTF1(_L("Check SetDisplayMode EColor16MAP"));
475 User::LeaveIfError(bmp.Create(TSize(4,4),EColor16MA));
476 TInt ret=bmp.SetDisplayMode(EColor16MAP);
480 User::LeaveIfError(bmp.Create(TSize(4,4),EColor16MU));
481 ret=bmp.SetDisplayMode(EColor16MAP);
485 User::LeaveIfError(bmp.Create(TSize(4,4),EColor64K));
486 ret=bmp.SetDisplayMode(EColor16MAP);
487 TEST(ret==KErrArgument);
490 User::LeaveIfError(bmp.Create(TSize(4,4),EColor16MAP));
491 ret=bmp.SetDisplayMode(EColor16MAP);
494 ret=bmp.SetDisplayMode(EColor16MU);
505 Compares a pixel retrieved with GetPixel and GetScanLine
508 Zero fills a buffer which has an uneven length of bytes and
509 gets a pixel from a point which should coincide with
510 that of a point retrieved with scan line
512 @SYMTestExpectedResults
515 void CTBitmap::CheckScanlineL()
517 INFO_PRINTF1(_L("Scanline sanity check"));
520 User::LeaveIfError(bmp.Create(TSize(32,1),EGray2));
522 // try using a buffer that isn't a whole number of words long.
524 Mem::FillZ(buffer,3);
525 TPtr8 scanline(buffer,3,3);
526 bmp.GetScanLine(scanline,TPoint(0,0),24,EGray2);
529 bmp.GetPixel(pixel,TPoint(0,0));
531 // getscanline and getpixel should agree
532 TEST(TRgb::Gray2(buffer[0] & 0x01) == pixel);
544 Streams different bitmap size of different colour depth.
549 @SYMTestExpectedResults
552 void CTBitmap::StreamBitmap()
554 INFO_PRINTF1(_L("Test Bitmap Streaming"));
556 DoStreamBitmapSizes(EGray2);
557 DoStreamBitmapSizes(EGray4);
558 DoStreamBitmapSizes(EGray16);
559 DoStreamBitmapSizes(EGray256);
560 DoStreamBitmapSizes(EColor16);
561 DoStreamBitmapSizes(EColor256);
562 DoStreamBitmapSizes(EColor4K);
563 DoStreamBitmapSizes(EColor64K);
564 DoStreamBitmapSizes(EColor16M);
565 DoStreamBitmapSizes(EColor16MU);
566 DoStreamBitmapSizes(EColor16MAP);
569 void CTBitmap::DoStreamBitmapSizes(TDisplayMode aDispMode)
571 const TSize smallStreamBitmapSize(32,10);
572 const TSize largeStreamBitmapSize(256,256);
573 const TSize oddStreamBitmapSize(31,2);
575 DoStreamBitmap(smallStreamBitmapSize,aDispMode,ETrue);
576 DoStreamBitmap(smallStreamBitmapSize,aDispMode,EFalse);
577 DoStreamBitmap(largeStreamBitmapSize,aDispMode,ETrue);
578 DoStreamBitmap(largeStreamBitmapSize,aDispMode,EFalse);
579 DoStreamBitmap(oddStreamBitmapSize,aDispMode,ETrue);
580 DoStreamBitmap(oddStreamBitmapSize,aDispMode,EFalse);
583 void CTBitmap::DoStreamBitmap(const TSize& aSize,TDisplayMode aDispMode,TBool aBlank)
588 TInt ret = bmp.Create(aSize,aDispMode);
589 TEST2(ret, KErrNone);
596 CDirectFileStore* writestore=NULL;
598 TRAP(ret,writestore=CDirectFileStore::ReplaceL(iFs,KTempFilename,EFileStream|EFileWrite));
599 TEST2(ret, KErrNone);
601 TUidType uidtype(KDirectFileStoreLayoutUid,KMultiBitmapFileImageUid);
603 TRAP(ret,writestore->SetTypeL(uidtype));
604 TEST2(ret, KErrNone);
606 RStoreWriteStream writestrm;
607 TStreamId headerid(0);
609 TRAP(ret,headerid=writestrm.CreateL(*writestore));
610 TEST2(ret, KErrNone);
612 TRAP(ret,writestore->SetRootL(headerid));
613 TEST2(ret, KErrNone);
615 TRAP(ret,bmp.ExternalizeL(writestrm));
616 TEST2(ret, KErrNone);
622 CDirectFileStore* readstore=NULL;
624 TRAP(ret,readstore=CDirectFileStore::OpenL(iFs,KTempFilename,EFileStream|EFileRead));
625 TEST2(ret, KErrNone);
627 RStoreReadStream readstrm;
628 headerid=readstore->Root();
630 TRAP(ret,readstrm.OpenL(*readstore,headerid));
631 TEST2(ret, KErrNone);
633 TRAP(ret,bmpst.InternalizeL(readstrm));
634 TEST2(ret, KErrNone);
639 CompareBitmaps(bmp,bmpst,EColor16M);
641 iFs.Delete(KTempFilename);
644 User::Heap().Check();
653 Streams bitmap rectangles of different colour depth
654 to file store and reads them back again.
657 Bitmap rectangles are externalized to file store and
658 read back again. ScanLine is used and compared to GetPixel
659 from the bitmap read back from file store.
661 @SYMTestExpectedResults
664 void CTBitmap::StreamRectangle()
666 INFO_PRINTF1(_L("Test Rectangle Streaming"));
668 DoStreamRectangle(EGray2,ETrue);
669 DoStreamRectangle(EGray2,EFalse);
670 DoStreamRectangle(EGray4,ETrue);
671 DoStreamRectangle(EGray4,EFalse);
672 DoStreamRectangle(EGray16,ETrue);
673 DoStreamRectangle(EGray16,EFalse);
674 DoStreamRectangle(EGray256,ETrue);
675 DoStreamRectangle(EGray256,EFalse);
676 DoStreamRectangle(EColor16,ETrue);
677 DoStreamRectangle(EColor16,EFalse);
678 DoStreamRectangle(EColor256,ETrue);
679 DoStreamRectangle(EColor256,EFalse);
680 DoStreamRectangle(EColor4K,ETrue);
681 DoStreamRectangle(EColor4K,EFalse);
682 DoStreamRectangle(EColor64K,ETrue);
683 DoStreamRectangle(EColor64K,EFalse);
684 DoStreamRectangle(EColor16M,ETrue);
685 DoStreamRectangle(EColor16M,EFalse);
686 DoStreamRectangle(EColor16MU,ETrue);
687 DoStreamRectangle(EColor16MU,EFalse);
688 DoStreamRectangle(EColor16MAP,ETrue);
689 DoStreamRectangle(EColor16MAP,EFalse);
692 void CTBitmap::DoStreamRectangle(TDisplayMode aDispMode,TBool aBlank)
696 TInt ret = bmp.Create(TSize(160,80),aDispMode);
697 TEST2(ret, KErrNone);
704 CDirectFileStore* writestore=NULL;
705 TRAP(ret,writestore=CDirectFileStore::ReplaceL(iFs,KTempFilename,EFileStream|EFileWrite));
706 TEST2(ret, KErrNone);
708 TUidType uidtype(KDirectFileStoreLayoutUid,KMultiBitmapFileImageUid);
709 TRAP(ret,writestore->SetTypeL(uidtype));
710 TEST2(ret, KErrNone);
712 RStoreWriteStream writestrm;
713 TStreamId headerid(0);
714 TRAP(ret,headerid=writestrm.CreateL(*writestore));
715 TEST2(ret, KErrNone);
717 TRAP(ret,writestore->SetRootL(headerid));
718 TEST2(ret, KErrNone);
720 TRAP(ret,bmp.ExternalizeRectangleL(writestrm,TRect(40,20,120,60)));
721 TEST2(ret, KErrNone);
727 CDirectFileStore* readstore=NULL;
728 TRAP(ret,readstore=CDirectFileStore::OpenL(iFs,KTempFilename,EFileStream|EFileRead));
729 TEST2(ret, KErrNone);
731 RStoreReadStream readstrm;
732 headerid=readstore->Root();
733 TRAP(ret,readstrm.OpenL(*readstore,headerid));
734 TEST2(ret, KErrNone);
736 TRAP(ret,bmpst.InternalizeL(readstrm));
737 TEST2(ret, KErrNone);
742 TInt scanLineLength = CFbsBitmap::ScanLineLength(80,aDispMode);
743 TUint8* buffer = new TUint8[scanLineLength];
744 TUint8* bufferst = new TUint8[scanLineLength];
745 Mem::FillZ(buffer,scanLineLength);
746 Mem::FillZ(bufferst,scanLineLength);
747 TPtr8 scanline(buffer,scanLineLength,scanLineLength);
748 TPtr8 scanlinest(bufferst,scanLineLength,scanLineLength);
750 for(TInt yy=0;yy<40;yy++)
752 bmp.GetScanLine(scanline,TPoint(40,yy+20),80,aDispMode);
753 bmpst.GetScanLine(scanlinest,TPoint(0,yy),80,aDispMode);
755 if(aDispMode != EColor16MU)
757 TInt memRet = Mem::Compare(buffer,scanLineLength,bufferst,scanLineLength);
762 TInt pixelsToCompare = scanLineLength / 4;
763 TUint8* bufferCur = buffer;
764 TUint8* bufferstCur = bufferst;
766 //top byte is unused, and would be more accurate to ignore it
767 for(TInt ii = 0; ii < pixelsToCompare; ii++)
769 TInt memRet = Mem::Compare(bufferCur,3,bufferstCur,3);
779 iFs.Delete(KTempFilename);
782 User::Heap().Check();
791 Calls GetScanLine for different screen modes with
792 the bitmap compressed and uncompressed and checks
793 if the pixels are correct.
797 @SYMTestExpectedResults
800 void CTBitmap::GetScanline()
802 INFO_PRINTF1(_L("Test GetScanline"));
804 const TSize size1(257,5);
805 const TSize size2(33,17);
807 INFO_PRINTF1(_L("EGray2"));
808 DoGetScanline(size1,EGray2);
809 DoGetScanline(size2,EGray2);
810 DoGetScanlineAlt(EGray2);
812 INFO_PRINTF1(_L(" EGray4"));
813 DoGetScanline(size1,EGray4);
814 DoGetScanline(size2,EGray4);
815 DoGetScanlineAlt(EGray4);
817 INFO_PRINTF1(_L(" EGray16"));
818 DoGetScanline(size1,EGray16);
819 DoGetScanline(size2,EGray16);
820 DoGetScanlineAlt(EGray16);
822 INFO_PRINTF1(_L(" EGray256"));
823 DoGetScanline(size1,EGray256);
824 DoGetScanline(size2,EGray256);
825 DoGetScanlineAlt(EGray256);
827 INFO_PRINTF1(_L(" EColor16"));
828 DoGetScanline(size1,EColor16);
829 DoGetScanline(size2,EColor16);
830 DoGetScanlineAlt(EColor16);
832 INFO_PRINTF1(_L(" EColor256"));
833 DoGetScanline(size1,EColor256);
834 DoGetScanline(size2,EColor256);
835 DoGetScanlineAlt(EColor256);
837 INFO_PRINTF1(_L(" EColor4K"));
838 DoGetScanline(size1,EColor4K);
839 DoGetScanline(size2,EColor4K);
840 DoGetScanlineAlt(EColor4K);
842 INFO_PRINTF1(_L(" EColor64K"));
843 DoGetScanline(size1,EColor64K);
844 DoGetScanline(size2,EColor64K);
845 DoGetScanlineAlt(EColor64K);
847 INFO_PRINTF1(_L(" EColor16M"));
848 DoGetScanline(size1,EColor16M);
849 DoGetScanline(size2,EColor16M);
850 DoGetScanlineAlt(EColor16M);
852 INFO_PRINTF1(_L(" EColor16MA"));
853 DoGetScanline(size1,EColor16MA);
854 DoGetScanline(size2,EColor16MA);
855 DoGetScanlineAlt(EColor16MA);
857 INFO_PRINTF1(_L(" EColor16MU"));
858 DoGetScanline(size1,EColor16MU);
859 DoGetScanline(size2,EColor16MU);
860 DoGetScanlineAlt(EColor16MU);
862 INFO_PRINTF1(_L(" EColor16MAP"));
863 DoGetScanline(size1,EColor16MAP);
864 DoGetScanline(size2,EColor16MAP);
865 DoGetScanlineAlt(EColor16MAP);
867 INFO_PRINTF1(_L("\n"));
870 void CTBitmap::DoGetScanline(const TSize& aSize,TDisplayMode aDispMode)
874 TInt ret = bmp.Create(aSize,aDispMode);
875 TEST2(ret, KErrNone);
878 DoGetScanlineCheck1(bmp, bmp, aSize, aDispMode);
879 DoGetScanlineCheck2(bmp, bmp, aSize, aDispMode);
880 DoGetScanlineCheck3(bmp, aDispMode);
882 ret = bmp.Create(aSize,aDispMode);
883 TEST2(ret, KErrNone);
887 ret = ref.Create(aSize,aDispMode);
888 TEST2(ret, KErrNone);
890 CopyBitmap(ref, bmp);
891 ret = bmp.Compress();
892 TEST2(ret, KErrNone);
894 DoGetScanlineCheck1(bmp, ref, aSize, aDispMode);
898 User::Heap().Check();
902 void CTBitmap::DoGetScanlineCheck1(CFbsBitmap& aBitmap,CFbsBitmap& aReference,const TSize& aSize,TDisplayMode aDispMode)
904 TInt byteWidth = CFbsBitmap::ScanLineLength(aSize.iWidth,aDispMode);
905 TUint8* buffer = new TUint8[byteWidth + 1];
906 buffer[byteWidth] = KCheckValue;
907 TPtr8 scanline(buffer,byteWidth,byteWidth);
909 for(TInt xStart = 0; xStart <= 33; xStart++)
911 for (TInt xLength = 1; xLength <= 33; xLength++)
913 TInt xEnd = xStart + xLength;
914 if (xEnd <= aSize.iWidth)
916 aBitmap.GetScanLine(scanline,TPoint(xStart,0),xLength,aDispMode);
917 for(TInt xx = xStart; xx < xEnd; xx++)
920 aReference.GetPixel(color,TPoint(xx,0));
921 TRgb bufferColor = ExtractRgb(buffer,xx - xStart,aDispMode);
922 TEST(bufferColor == color);
928 for(TInt yy = 0; yy < aSize.iHeight; yy++)
930 aBitmap.GetScanLine(scanline,TPoint(0,yy),aSize.iWidth,aDispMode);
931 for(TInt xx = 0; xx < aSize.iWidth; xx++)
934 aReference.GetPixel(color,TPoint(xx,yy));
935 TRgb bufferColor = ExtractRgb(buffer,xx,aDispMode);
936 TEST(bufferColor == color);
940 TEST(buffer[byteWidth] == KCheckValue);
944 void CTBitmap::DoGetScanlineCheck2(CFbsBitmap& aBitmap,CFbsBitmap& aReference,const TSize& aSize,TDisplayMode aDispMode)
946 TInt byteHeight = CFbsBitmap::ScanLineLength(aSize.iHeight,ERgb);
947 TUint8* buffer = new TUint8[byteHeight];
948 TPtr8 scanline(buffer,byteHeight,byteHeight);
951 for(xx = 0; xx < aSize.iWidth; xx++)
953 aBitmap.GetVerticalScanLine(scanline,xx,aDispMode);
954 for(TInt yy = 0; yy < aSize.iHeight; yy++)
957 aReference.GetPixel(color,TPoint(xx,yy));
958 TRgb bufferColor = ExtractRgb(buffer,yy,aDispMode);
959 TEST(bufferColor == color);
963 for(xx = 0; xx < aSize.iWidth; xx++)
965 aBitmap.GetVerticalScanLine(scanline,xx,ERgb);
966 for(TInt yy = 0; yy < aSize.iHeight; yy++)
969 aReference.GetPixel(color,TPoint(xx,yy));
970 TRgb bufferColor = ExtractRgb(buffer,yy,ERgb);
971 TEST(bufferColor == color);
978 void CTBitmap::DoGetScanlineCheck3(CFbsBitmap& aBitmap,TDisplayMode aDispMode)
980 TUint32 wordline=0xffffffff;
981 TPtr8 scanline((TUint8*)&wordline,4,4);
982 aBitmap.Create(TSize(31,1),aDispMode);
984 Mem::Fill(aBitmap.DataAddress(),CFbsBitmap::ScanLineLength(31,aDispMode),0xff);
985 aBitmap.UnlockHeap();
986 aBitmap.SetScanLine(scanline,0);
989 for(TInt zz=1;zz<31;zz++)
993 aBitmap.GetScanLine(scanline,TPoint(0,0),zz,EGray2);
994 TUint32 actual=wordline&expected;
995 TEST(actual==expected);
999 /* this function calls CheckScanLine with various screen modes, and with the bitmap
1000 compressed, and not compressed
1002 void CTBitmap::DoGetScanlineAlt(TDisplayMode aDispMode)
1007 TInt ret = bmp.Create(TSize(256,3),aDispMode);
1008 TEST2(ret, KErrNone);
1012 CheckScanLine(bmp,bmp,EGray2);
1013 CheckScanLine(bmp,bmp,EGray4);
1014 CheckScanLine(bmp,bmp,EGray16);
1015 CheckScanLine(bmp,bmp,EGray256);
1016 CheckScanLine(bmp,bmp,EColor16);
1017 CheckScanLine(bmp,bmp,EColor256);
1018 CheckScanLine(bmp,bmp,EColor4K);
1019 CheckScanLine(bmp,bmp,EColor64K);
1020 CheckScanLine(bmp,bmp,EColor16M);
1021 CheckScanLine(bmp,bmp,ERgb);
1022 CheckScanLine(bmp,bmp,EColor16MU);
1023 CheckScanLine(bmp,bmp,EColor16MAP);
1026 ret = ref.Create(bmp.SizeInPixels(),aDispMode);
1027 TEST2(ret, KErrNone);
1028 CopyBitmap(ref,bmp);
1031 CheckScanLine(bmp,ref,EGray2);
1032 CheckScanLine(bmp,ref,EGray4);
1033 CheckScanLine(bmp,ref,EGray16);
1034 CheckScanLine(bmp,ref,EGray256);
1035 CheckScanLine(bmp,ref,EColor16);
1036 CheckScanLine(bmp,ref,EColor256);
1037 CheckScanLine(bmp,ref,EColor4K);
1038 CheckScanLine(bmp,ref,EColor64K);
1039 CheckScanLine(bmp,ref,EColor16M);
1040 CheckScanLine(bmp,ref,ERgb);
1041 CheckScanLine(bmp,ref,EColor16MU);
1042 CheckScanLine(bmp,ref,EColor16MAP);
1044 User::Heap().Check();
1048 void CTBitmap::CheckScanLine(CFbsBitmapEx& aBitmap,CFbsBitmapEx& aReference,TDisplayMode aDispMode)
1050 const TSize bmpSize(aBitmap.SizeInPixels());
1051 TInt byteWidth = CFbsBitmap::ScanLineLength(bmpSize.iWidth,aDispMode);
1052 TUint8* buffer = new TUint8[byteWidth + 1];
1053 buffer[byteWidth] = KCheckValue;
1054 TPtr8 scanLine(buffer,byteWidth,byteWidth);
1056 aBitmap.GetScanLine(scanLine,TPoint(0,1),bmpSize.iWidth,aDispMode);
1058 for(TInt xx = 0; xx < bmpSize.iWidth; xx++)
1061 aReference.GetPixel(color,TPoint(xx,1));
1062 TRgb bufferColor = ExtractRgb(buffer,xx,aDispMode);
1066 if (color.Gray4() == 0 || color.Gray4() == 3) // doesn't check in great detail because dithering occurs
1067 TEST(bufferColor.Gray2() == color.Gray2());
1070 if (aBitmap.DisplayMode() != EGray16) // doesn't check EGray16 because dithering occurs
1071 TEST(bufferColor.Gray4() == color.Gray4());
1074 TEST(bufferColor.Gray16() == color.Gray16());
1077 TEST(bufferColor.Gray256() == color.Gray256());
1080 TEST(bufferColor.Color16() == color.Color16());
1083 TEST(bufferColor.Color256() == color.Color256());
1086 TEST(bufferColor.Color4K() == color.Color4K());
1089 TEST(bufferColor.Color64K() == color.Color64K());
1092 TEST(bufferColor.Color16M() == color.Color16M());
1095 TEST(bufferColor == color);
1098 if (aReference.DisplayMode()==EColor16MAP || aReference.DisplayMode()==EColor16MA)
1099 color.SetAlpha(0xff);
1100 CompareColourLikeness(bufferColor, color);
1103 //Compare the TRgb values. For an exact match to work the comparison would
1104 //need to be done in PMA space.
1105 color.SetInternal(color.Color16MAP());
1106 bufferColor.SetInternal(bufferColor.Color16MAP());
1107 CompareColourLikeness(bufferColor, color);
1114 TEST(buffer[byteWidth] == KCheckValue);
1119 Compares two TRgbs and tests if they are similar colour.
1120 This is required because there may be some rounding errors when converting bitmaps from one display mode to another
1121 or due to alpha blending calculations.
1123 @param aSrc is the source colour
1124 @param aDest is the destination colour
1125 @param aDifference use this value for colour difference. Value of 0 use KColourDifference;
1127 void CTBitmap::CompareColourLikeness(const TRgb& aSrc, const TRgb& aDest, TInt aDifference)
1129 const TInt KColourDifference = 2; // Acceptable difference to check for
1133 diff=KColourDifference;
1137 TInt redDiff = Abs(aSrc.Red() - aDest.Red());
1138 TInt greenDiff = Abs(aSrc.Green() - aDest.Green());
1139 TInt blueDiff = Abs(aSrc.Blue() - aDest.Blue());
1140 TInt alphaDiff = Abs(aSrc.Alpha() - aDest.Alpha());
1142 // Test each channel
1143 TEST(redDiff <= diff);
1144 TEST(greenDiff <= diff);
1145 TEST(blueDiff <= diff);
1146 TEST(alphaDiff <= diff);
1148 // the code below is useful for a breakpoint, to inspect the differences, in case of failure
1150 if ((redDiff > diff)||(greenDiff > diff)||(blueDiff > diff)||(alphaDiff > diff))
1157 GRAPHICS-FBSERV-0521
1160 Sets a scanline of random values into
1161 bitmaps of different color depths
1165 @SYMTestExpectedResults
1168 void CTBitmap::SetScanline()
1170 INFO_PRINTF1(_L("Test SetScanline"));
1172 DoSetScanline(EGray2);
1173 DoSetScanline(EGray4);
1174 DoSetScanline(EGray16);
1175 DoSetScanline(EGray256);
1176 DoSetScanline(EColor16);
1177 DoSetScanline(EColor256);
1178 DoSetScanline(EColor4K);
1179 DoSetScanline(EColor64K);
1180 DoSetScanline(EColor16M);
1181 DoSetScanline(EColor16MU);
1182 DoSetScanline(EColor16MAP);
1185 void CTBitmap::DoSetScanline(TDisplayMode aDispMode)
1190 TInt ret = bmp.Create(TSize(256,2),aDispMode);
1191 TEST2(ret, KErrNone);
1193 TInt scanLineLength = CFbsBitmap::ScanLineLength(256,aDispMode);
1194 TUint8* buffer = new TUint8[scanLineLength];
1195 TEST(buffer != NULL);
1196 TPtr8 scanline(buffer,scanLineLength,scanLineLength);
1198 TUint8* bufptr = buffer;
1199 TInt64 seed = bmp.Handle();
1200 for(TInt count = 0; count < scanLineLength; count++)
1201 *bufptr++ = (TUint8)Math::Rand(seed);
1203 bmp.SetScanLine(scanline,0);
1204 bmp.SetScanLine(scanline,1);
1207 TUint8* data = (TUint8*)bmp.DataAddress();
1209 ret = Mem::Compare(buffer,scanLineLength,data,scanLineLength);
1212 data += scanLineLength;
1213 ret = Mem::Compare(buffer,scanLineLength,data,scanLineLength);
1218 User::Heap().Check();
1224 GRAPHICS-FBSERV-0522
1227 Stretches a scan line to make it
1228 double as long for different colour depths
1229 tested on both small and large bitmaps.
1233 @SYMTestExpectedResults
1236 void CTBitmap::StretchScanline()
1238 INFO_PRINTF1(_L("Test StretchScanline"));
1240 const TSize smallBitmapSize(226,2);
1241 const TSize largeBitmapSize(1026,40);
1243 INFO_PRINTF1(_L("EGray2"));
1244 DoStretchScanline(smallBitmapSize,EGray2);
1245 DoStretchScanline(largeBitmapSize,EGray2);
1247 INFO_PRINTF1(_L(" EGray4"));
1248 DoStretchScanline(smallBitmapSize,EGray4);
1249 DoStretchScanline(largeBitmapSize,EGray4);
1251 INFO_PRINTF1(_L(" EGray16"));
1252 DoStretchScanline(smallBitmapSize,EGray16);
1253 DoStretchScanline(largeBitmapSize,EGray16);
1255 INFO_PRINTF1(_L(" EGray256"));
1256 DoStretchScanline(smallBitmapSize,EGray256);
1257 DoStretchScanline(largeBitmapSize,EGray256);
1259 INFO_PRINTF1(_L(" EColor16"));
1260 DoStretchScanline(smallBitmapSize,EColor16);
1261 DoStretchScanline(largeBitmapSize,EColor16);
1263 INFO_PRINTF1(_L(" EColor256"));
1264 DoStretchScanline(smallBitmapSize,EColor256);
1265 DoStretchScanline(largeBitmapSize,EColor256);
1267 INFO_PRINTF1(_L(" EColor4K"));
1268 DoStretchScanline(smallBitmapSize,EColor4K);
1269 DoStretchScanline(largeBitmapSize,EColor4K);
1271 INFO_PRINTF1(_L(" EColor64K"));
1272 DoStretchScanline(smallBitmapSize,EColor64K);
1273 DoStretchScanline(largeBitmapSize,EColor64K);
1275 INFO_PRINTF1(_L(" EColor16M"));
1276 DoStretchScanline(smallBitmapSize,EColor16M);
1277 DoStretchScanline(largeBitmapSize,EColor16M);
1279 INFO_PRINTF1(_L(" EColor16MU"));
1280 DoStretchScanline(smallBitmapSize,EColor16MU);
1281 DoStretchScanline(largeBitmapSize,EColor16MU);
1283 INFO_PRINTF1(_L(" EColor16MA"));
1284 DoStretchScanline(smallBitmapSize,EColor16MA);
1285 DoStretchScanline(largeBitmapSize,EColor16MA);
1287 INFO_PRINTF1(_L(" EColor16MAP"));
1288 DoStretchScanline(smallBitmapSize,EColor16MAP);
1289 DoStretchScanline(largeBitmapSize,EColor16MAP);
1291 DoStretchScanline(smallBitmapSize,EColor16MAP,EColor16M, ETrue);
1292 DoStretchScanline(largeBitmapSize,EColor16MAP,EColor16M, ETrue);
1293 DoStretchScanline(smallBitmapSize,EColor16MAP,EColor16MU, ETrue);
1294 DoStretchScanline(largeBitmapSize,EColor16MAP,EColor16MU, ETrue);
1295 DoStretchScanline(smallBitmapSize,EColor16MAP,EColor16MA, ETrue);
1296 DoStretchScanline(largeBitmapSize,EColor16MAP,EColor16MA, ETrue);
1297 DoStretchScanline(smallBitmapSize,EColor16MAP,EColor64K, ETrue);
1298 DoStretchScanline(largeBitmapSize,EColor16MAP,EColor64K, ETrue);
1299 DoStretchScanline(smallBitmapSize,EColor16MAP,EColor4K, ETrue);
1300 DoStretchScanline(largeBitmapSize,EColor16MAP,EColor4K, ETrue);
1301 DoStretchScanline(smallBitmapSize,EColor16MAP,EColor256, ETrue);
1302 DoStretchScanline(largeBitmapSize,EColor16MAP,EColor256, ETrue);
1304 DoStretchScanline(smallBitmapSize,EColor16M,EColor16MAP, ETrue);
1305 DoStretchScanline(largeBitmapSize,EColor16M,EColor16MAP, ETrue);
1306 DoStretchScanline(smallBitmapSize,EColor16MU,EColor16MAP, ETrue);
1307 DoStretchScanline(largeBitmapSize,EColor16MU,EColor16MAP, ETrue);
1308 DoStretchScanline(smallBitmapSize,EColor16MA,EColor16MAP, ETrue);
1309 DoStretchScanline(largeBitmapSize,EColor16MA,EColor16MAP, ETrue);
1310 DoStretchScanline(smallBitmapSize,EColor64K,EColor16MAP, ETrue);
1311 DoStretchScanline(largeBitmapSize,EColor64K,EColor16MAP, ETrue);
1312 DoStretchScanline(smallBitmapSize,EColor4K,EColor16MAP, ETrue);
1313 DoStretchScanline(largeBitmapSize,EColor4K,EColor16MAP, ETrue);
1314 DoStretchScanline(smallBitmapSize,EColor256,EColor16MAP, ETrue);
1315 DoStretchScanline(largeBitmapSize,EColor256,EColor16MAP, ETrue);
1317 DoStretchScanline(smallBitmapSize,EColor16MU,EColor16M, ETrue);
1318 DoStretchScanline(largeBitmapSize,EColor16MU,EColor16M, ETrue);
1320 INFO_PRINTF1(_L("\n"));
1323 void CTBitmap::DoStretchScanline(const TSize& aSize,TDisplayMode aDispMode)
1325 DoStretchScanline(aSize,aDispMode,aDispMode, EFalse);
1328 /* this function is used to determine an acceptable colour difference based on the screen mode
1329 and the alpha value. This is because when converting from PMA to non pre-multiplied, there
1330 can be large errors, especially if alpha is small.
1332 TInt CTBitmap::ColorDifference(TDisplayMode aMode, TInt aAlpha)
1336 case EGray2:// Monochrome display mode (1 bpp)
1338 case EGray4:// Four grayscales display mode (2 bpp)
1340 case EGray16:// 16 grayscales display mode (4 bpp)
1342 case EGray256:// 256 grayscales display mode (8 bpp)
1344 case EColor16:// Low colour EGA 16 colour display mode (4 bpp)
1346 case EColor256: // 256 colour display mode (8 bpp)
1348 case EColor64K: // 64,000 colour display mode (16 bpp)
1350 case EColor16M: // True colour display mode (24 bpp)
1352 case EColor4K: // 4096 colour display (12 bpp).
1354 case EColor16MU:// True colour display mode (32 bpp, but top byte is unused and unspecified)
1356 case EColor16MA:// Display mode with alpha (24bpp colour plus 8bpp alpha)
1358 case EColor16MAP:// Pre-multiplied Alpha display mode (24bpp color multiplied with the alpha channel value, plus 8bpp alpha)
1362 //make inaccuracy a function of alpha since the colour will the premultiplied, and then
1363 //unpremultiplied. For small alpha this can be quite large.
1367 return Max(0xff>>4,Min(0xff,(0xff/aAlpha)+0xf));//value corrected by trial and error, with minimum of 15.
1372 void CTBitmap::DoStretchScanline(const TSize& aSize,TDisplayMode aSrcMode,TDisplayMode aDstMode, TBool aUseCompareLikeness)
1376 CBitwiseBitmap* bmpadd=NULL;
1378 TInt ret = bmp.Create(aSize,aSrcMode);
1379 TEST2(ret, KErrNone);
1382 bmpadd = bmp.BitmapAddress();
1384 TUint32* base = bmp.DataAddress();
1387 TInt scanLineLength = CFbsBitmap::ScanLineLength(aSize.iWidth,aSrcMode);
1388 TInt scanLineDestLength = CFbsBitmap::ScanLineLength(aSize.iWidth,aDstMode)*2;
1389 TUint8* buffer = new TUint8[scanLineLength];
1390 TUint8* doubleBuffer = new TUint8[scanLineDestLength];
1391 TPtr8 scanline(buffer,scanLineLength,scanLineLength);
1392 TPtr8 doubleScanline(doubleBuffer,scanLineDestLength,scanLineDestLength);
1395 for(yy = 0; yy < aSize.iHeight; yy++)
1397 bmp.GetScanLine(scanline,TPoint(0,yy),aSize.iWidth,aSrcMode);
1398 bmpadd->StretchScanLine(doubleScanline,TPoint(0,yy),0,aSize.iWidth * 2,aSize.iWidth * 2,0,aSize.iWidth,TPoint(0,0),aDstMode,base);
1399 for(TInt xx = 0; xx < aSize.iWidth; xx++)
1401 TRgb scanlineColor = ExtractRgb(buffer,xx,aSrcMode);
1402 TRgb firstStretchColor = ExtractRgb(doubleBuffer,xx * 2,aDstMode);
1403 TRgb secondStretchColor = ExtractRgb(doubleBuffer,(xx * 2) + 1,aDstMode);
1405 bmpadd->GetPixel(reportedColor,TPoint(xx,yy),base,NULL);
1406 if (!aUseCompareLikeness)
1408 TEST(scanlineColor == firstStretchColor);
1409 TEST(firstStretchColor == secondStretchColor);
1410 TEST(secondStretchColor == reportedColor);
1414 if (aDstMode==EColor16M||aDstMode==EColor16MU||aDstMode==EColor64K||aDstMode==EColor4K||aDstMode==EColor256)
1416 //there is no alpha in the destination
1417 scanlineColor.SetAlpha(0xff);
1418 reportedColor.SetAlpha(0xff);
1420 CompareColourLikeness(scanlineColor, firstStretchColor, ColorDifference(aDstMode,scanlineColor.Alpha()));
1421 CompareColourLikeness(firstStretchColor, secondStretchColor,ColorDifference(aDstMode,scanlineColor.Alpha()));
1422 CompareColourLikeness(secondStretchColor, reportedColor,ColorDifference(aDstMode,scanlineColor.Alpha()));
1427 for(yy = 0; yy < aSize.iHeight; yy++)
1429 bmp.GetScanLine(scanline,TPoint(0,yy),aSize.iWidth,aSrcMode);
1430 bmpadd->StretchScanLine(doubleScanline,TPoint(0,yy),0,aSize.iWidth / 2,aSize.iWidth / 2,0,aSize.iWidth,TPoint(0,0),aDstMode,base);
1431 for(TInt xx = 0; xx < aSize.iWidth; xx += 2)
1433 TRgb scanlineColor = ExtractRgb(buffer,xx,aSrcMode);
1434 TRgb compressColor = ExtractRgb(doubleBuffer,xx / 2,aDstMode);
1436 bmpadd->GetPixel(reportedColor,TPoint(xx,yy),base,NULL);
1437 if (!aUseCompareLikeness)
1439 TEST(scanlineColor == compressColor);
1440 TEST(compressColor == reportedColor);
1444 if (aDstMode==EColor16M||aDstMode==EColor16MU||aDstMode==EColor64K||aDstMode==EColor4K||aDstMode==EColor256)
1446 //there is no alpha in the destination
1447 scanlineColor.SetAlpha(0xff);
1448 reportedColor.SetAlpha(0xff);
1450 CompareColourLikeness(scanlineColor, compressColor,ColorDifference(aDstMode,scanlineColor.Alpha()));
1451 CompareColourLikeness(compressColor, reportedColor,ColorDifference(aDstMode,scanlineColor.Alpha()));
1457 delete [] doubleBuffer;
1459 doubleBuffer = NULL;
1461 TInt rgbScanLineLength = aSize.iWidth * sizeof(TRgb) * 2;
1462 TUint8* rgbBuffer = new TUint8[rgbScanLineLength];
1463 TPtr8 rgbScanline(rgbBuffer,rgbScanLineLength,rgbScanLineLength);
1465 for(yy = 0; yy < aSize.iHeight; yy++)
1467 bmpadd->StretchScanLine(rgbScanline,TPoint(0,yy),0,aSize.iWidth * 2,aSize.iWidth * 2,0,aSize.iWidth,TPoint(0,0),ERgb,base);
1468 for(TInt xx = 0; xx < aSize.iWidth; xx++)
1470 TRgb firstStretchColor = ExtractRgb(rgbBuffer,xx * 2,ERgb);
1471 TRgb secondStretchColor = ExtractRgb(rgbBuffer,(xx * 2) + 1,ERgb);
1473 bmpadd->GetPixel(reportedColor,TPoint(xx,yy),base,NULL);
1474 if (!aUseCompareLikeness)
1476 TEST(firstStretchColor == secondStretchColor);
1477 TEST(secondStretchColor == reportedColor);
1481 CompareColourLikeness(firstStretchColor, secondStretchColor);
1482 CompareColourLikeness(secondStretchColor, reportedColor);
1487 for(yy = 0; yy < aSize.iHeight; yy++)
1489 bmpadd->StretchScanLine(rgbScanline,TPoint(0,yy),0,aSize.iWidth / 2,aSize.iWidth / 2,0,aSize.iWidth,TPoint(0,0),ERgb,base);
1490 for(TInt xx = 0; xx < aSize.iWidth; xx += 2)
1492 TRgb compressColor = ExtractRgb(rgbBuffer,xx / 2,ERgb);
1494 bmpadd->GetPixel(reportedColor,TPoint(xx,yy),base,NULL);
1495 if (!aUseCompareLikeness)
1497 TEST(compressColor == reportedColor);
1501 CompareColourLikeness(compressColor, reportedColor);
1506 delete [] rgbBuffer;
1510 User::Heap().Check();
1511 DeleteScanLineBuffer();
1515 TRgb CTBitmap::ExtractRgb(TUint8* aBuffer,TInt aPixelOffset,TDisplayMode aDispMode)
1521 TUint8 byte = *(aBuffer + (aPixelOffset >> 3));
1522 if (byte & (1 << (aPixelOffset & 7)))
1528 TUint8 byte = *(aBuffer + (aPixelOffset >> 2));
1529 byte >>= ((aPixelOffset & 3) << 1);
1530 return TRgb::Gray4(byte & 3);
1534 TUint8 byte = *(aBuffer + (aPixelOffset >> 1));
1535 if (aPixelOffset & 1)
1537 return TRgb::Gray16(byte & 0xf);
1540 return TRgb::Gray256(*(aBuffer + aPixelOffset));
1543 TUint8 byte = *(aBuffer + (aPixelOffset >> 1));
1544 if (aPixelOffset & 1)
1546 return TRgb::Color16(byte & 0xf);
1549 return TRgb::Color256(*(aBuffer + aPixelOffset));
1552 TUint16 doubleByte = *(((TUint16*)aBuffer) + aPixelOffset);
1553 return TRgb::Color4K(doubleByte & 0xfff);
1557 TUint16 doubleByte = *(((TUint16*)aBuffer) + aPixelOffset);
1558 return TRgb::Color64K(doubleByte);
1562 aBuffer += aPixelOffset * 3;
1563 TInt value = *aBuffer++;
1564 value |= *aBuffer++ << 8;
1565 value |= *aBuffer << 16;
1566 return TRgb::Color16M(value);
1569 return *(((TRgb*)aBuffer) + aPixelOffset);
1572 return TRgb::Color16MU(*(((TUint32*)aBuffer) + aPixelOffset));
1576 return TRgb::Color16MA(*(((TUint32*)aBuffer) + aPixelOffset));
1580 return TRgb::_Color16MAP(*(((TUint32*)aBuffer) + aPixelOffset));
1590 GRAPHICS-FBSERV-0523
1593 Streams a bitmap in segments and compares it
1594 to an expected bitmap
1598 @SYMTestExpectedResults
1601 void CTBitmap::LoadInSegments()
1603 INFO_PRINTF1(_L("Test Segmented Loading"));
1607 TInt ret=bmp.Load(iTestBitmapName,ETfbs,NULL);
1608 TEST2(ret, KErrNone);
1609 CFbsBitmapAsyncStreamer* bmploader=NULL;
1610 TRAP(ret,bmploader=CFbsBitmapAsyncStreamer::NewL(CFbsBitmapAsyncStreamer::ELoad));
1611 TEST2(ret, KErrNone);
1613 ret=bmploader->Load(iTestBitmapName,ETfbs,slines);
1614 TEST2(ret, KErrNone);
1616 CFbsBitmap* newbmp=NULL;
1620 TRAP(ret,done=bmploader->LoadScanLinesL(slines/10,newbmp));
1621 TEST2(ret, KErrNone);
1626 CompareBitmaps(bmp,(CFbsBitmapEx&)*newbmp,EColor16M);
1630 TRAP(ret,iBmpHandler=CFbsBitmapAsyncStreamer::NewL(CFbsBitmapAsyncStreamer::ELoad));
1631 TEST2(ret, KErrNone);
1632 ret=iBmpHandler->Load(iTestBitmapName,ETfbs,slines);
1633 TEST2(ret, KErrNone);
1635 CIdle* idleobj=CIdle::New(-20);
1636 TEST(idleobj!=NULL);
1637 TCallBack callback(BmpLoadCallBack,this);
1638 idleobj->Start(callback);
1640 CActiveScheduler* as = CActiveScheduler::Current();
1641 __ASSERT_DEBUG(as, User::Invariant());
1643 TRAP(ret,as->Start());
1644 TEST2(ret, KErrNone);
1646 CompareBitmaps(bmp,(CFbsBitmapEx&)*iBitmap,EColor16M);
1652 User::Heap().Check();
1658 TInt CTBitmap::BmpLoadCallBack(TAny* aPtr)
1660 CTBitmap* tbmp=(CTBitmap*)aPtr;
1661 tbmp->INFO_PRINTF1(_L("*"));
1663 TRAPD(ret,done=tbmp->iBmpHandler->LoadScanLinesL(10,tbmp->iBitmap));
1664 tbmp->TEST2(ret, KErrNone);
1667 tbmp->TEST(tbmp->iBitmap!=NULL);
1668 CActiveScheduler::Stop();
1672 tbmp->TEST(tbmp->iBitmap==NULL);
1679 GRAPHICS-FBSERV-0524
1682 A bitmap is saved in segments and then read back from file store
1683 and compared to an expected bitmap
1687 @SYMTestExpectedResults
1690 void CTBitmap::SaveInSegments()
1692 INFO_PRINTF1(_L("Test Segmented Saving"));
1696 TInt ret=bmp.Load(iTestBitmapName,ETfbs,NULL);
1697 TEST2(ret, KErrNone);
1698 CFbsBitmapAsyncStreamer* bmpsaver=NULL;
1699 TRAP(ret,bmpsaver=CFbsBitmapAsyncStreamer::NewL(CFbsBitmapAsyncStreamer::ESave));
1700 TEST2(ret, KErrNone);
1703 ret=bmpsaver->Save(KTempFilename,&bmp,id,slines);
1704 TEST2(ret, KErrNone);
1709 TRAP(ret,done=bmpsaver->SaveScanLinesL(slines/10));
1710 TEST2(ret, KErrNone);
1715 ret=bmp2.Load(KTempFilename,id,NULL);
1716 TEST2(ret, KErrNone);
1718 TUint8 bufferst[40];
1719 TPtr8 scanline(&buffer[0],40,40);
1720 TPtr8 scanlinest(&bufferst[0],40,40);
1724 bmp.GetScanLine(scanline,TPoint(0,yy),160,EGray4);
1725 bmp2.GetScanLine(scanlinest,TPoint(0,yy),160,EGray4);
1726 for(TInt count=0;count<40;count++)
1727 TEST(buffer[count]==bufferst[count]);
1730 iFs.Delete(KTempFilename);
1732 CActiveScheduler* as = CActiveScheduler::Current();
1733 __ASSERT_DEBUG(as, User::Invariant());
1735 TRAP(ret,iBmpHandler=CFbsBitmapAsyncStreamer::NewL(CFbsBitmapAsyncStreamer::ESave));
1736 TEST2(ret, KErrNone);
1737 ret=iBmpHandler->Save(KTempFilename,&bmp,id,slines);
1738 TEST2(ret, KErrNone);
1741 CIdle* idleobj=CIdle::New(-20);
1742 TEST(idleobj!=NULL);
1743 TCallBack callback(BmpSaveCallBack,this);
1744 idleobj->Start(callback);
1745 TRAP(ret,as->Start());
1746 TEST2(ret, KErrNone);
1748 ret=bmp2.Load(KTempFilename,id,NULL);
1749 TEST2(ret, KErrNone);
1750 for(yy=0;yy<80;yy++)
1752 bmp.GetScanLine(scanline,TPoint(0,yy),160,EGray4);
1753 bmp2.GetScanLine(scanlinest,TPoint(0,yy),160,EGray4);
1754 for(TInt count=0;count<40;count++)
1755 TEST(buffer[count]==bufferst[count]);
1759 iFs.Delete(KTempFilename);
1760 User::Heap().Check();
1763 INFO_PRINTF1(_L("\r\n"));
1767 TInt CTBitmap::BmpSaveCallBack(TAny* aPtr)
1769 CTBitmap* tbmp=(CTBitmap*)aPtr;
1770 tbmp->INFO_PRINTF1(_L("*"));
1772 TRAPD(ret,done=tbmp->iBmpHandler->SaveScanLinesL(10));
1773 tbmp->TEST2(ret, KErrNone);
1776 CActiveScheduler::Stop();
1783 GRAPHICS-FBSERV-0525
1786 Tests if a bitmap is monochrone for different
1791 @SYMTestExpectedResults
1794 void CTBitmap::MonoDetect()
1796 INFO_PRINTF1(_L("Test Mono Detection"));
1798 DoMonoDetect(EGray2);
1799 DoMonoDetect(EGray4);
1800 DoMonoDetect(EGray16);
1801 DoMonoDetect(EGray256);
1802 DoMonoDetect(EColor16);
1803 DoMonoDetect(EColor256);
1804 DoMonoDetect(EColor4K);
1805 DoMonoDetect(EColor64K);
1806 DoMonoDetect(EColor16M);
1807 DoMonoDetect(EColor16MU);
1808 DoMonoDetect(EColor16MAP);
1811 void CTBitmap::DoMonoDetect(TDisplayMode aDisplayMode)
1814 TInt ret = bmp.Create(TSize(100,3),aDisplayMode);
1815 TEST2(ret, KErrNone);
1817 CBitwiseBitmap* bmpadd = bmp.BitmapAddress();
1819 TUint32* base = bmp.DataAddress();
1821 TUint32* data = bmpadd->ScanLineAddress(base,1);
1823 if(aDisplayMode == EColor16M)
1825 *(data+1) = 0x0000FFFF;
1826 *(data+2) = 0xFFFFFF00;
1827 //Pixel at (data + 1). Bytes (3) and (2) are part of the pixel at (data) addr.
1831 //Pixel at (data + 2). Byte (3) is part of the pixel at (data + 1) addr.
1840 TBool mono = bmp.IsMonochrome();
1843 *(data+1) = 0x1234abcd;
1844 mono = bmp.IsMonochrome();
1845 if (aDisplayMode == EGray2)
1850 if(aDisplayMode == EColor16M)
1852 *(data+1) = 0xffffffff;
1853 *(data+2) = 0xffffffff;
1857 *(data+1) = 0xffffffff;
1859 mono=bmp.IsMonochrome();
1866 #if defined(__WINS__)
1867 // these are patchable constants defined in fbscli.dll but on the emulator
1868 // it's not possible to import them so they are re-defined here
1869 const TInt KFbServLargeChunkGrowByShifter = 1;
1870 const TInt KFbServLargeChunkSizeShifter = 2;
1871 const TInt KFbServLargeChunkMinPhysicalSize = 0x4000;
1872 #elif defined(__X86GCC__)
1873 IMPORT_D extern const TInt KFbServLargeChunkGrowByShifter;
1874 IMPORT_D extern const TInt KFbServLargeChunkSizeShifter;
1875 IMPORT_D extern const TInt KFbServLargeChunkMinPhysicalSize;
1880 GRAPHICS-FBSERV-0526
1883 Allocates different sized chunks of memory
1884 in a loop and frees them
1888 @SYMTestExpectedResults
1891 void CTBitmap::ChunkPileL()
1893 INFO_PRINTF1(_L("Test Chunk Pile"));
1895 TInt virtualSize = 0x4000000;
1897 TInt ret = chunk.CreateDisconnectedGlobal(_L("TFbsLargeChunk"), 0, 0, virtualSize);
1898 TEST2(ret, KErrNone);
1899 CleanupClosePushL(chunk);
1901 HAL::Get(HAL::EMemoryPageSize, pageSize);
1902 TEST(pageSize == 4096);
1903 TUint8* chunkSmallBase = chunk.Base() + pageSize;
1904 TUint8* chunkLargeBase = chunk.Base() + (virtualSize >> KFbServLargeChunkSizeShifter);
1906 CChunkPile* cp=NULL;
1907 TRAP(ret, cp = CChunkPile::NewL(chunk));
1908 TEST2(ret, KErrNone);
1910 CleanupStack::PushL(cp);
1911 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
1913 TUint8* chunkalloc[16];
1915 for (TInt i = 0; i < 64; ++i)
1917 chunkalloc[0] = cp->Alloc(size[0] = 512);
1918 TEST(chunkalloc[0] == chunkSmallBase);
1919 chunkalloc[1] = cp->Alloc(size[1] = 8);
1920 TEST(chunkalloc[1] == chunkalloc[0] + size[0]);
1921 chunkalloc[2] = cp->Alloc(size[2] = 128);
1922 TEST(chunkalloc[2] == chunkalloc[1] + size[1]);
1923 chunkalloc[3] = cp->Alloc(size[3] = 372);
1924 TEST(chunkalloc[3] == chunkalloc[2] + size[2]);
1925 chunkalloc[4] = cp->Alloc(size[4] = 256);
1926 TEST(chunkalloc[4] == chunkalloc[3] + size[3]);
1927 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
1928 // now we should have [0], [1], [2], [3], [4]
1930 cp->Free(chunkalloc[2]);
1931 cp->Free(chunkalloc[3]);
1932 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
1933 chunkalloc[5] = cp->Alloc(size[5] = size[2] + size[3]);
1934 TEST(chunkalloc[5] == chunkalloc[2]);
1935 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
1936 // now we should have [0], [1], [5], [4]
1938 chunkalloc[6] = cp->Alloc(size[6] = 4);
1939 TEST(chunkalloc[6] == chunkalloc[4] + size[4]);
1940 chunkalloc[7] = cp->Alloc(size[7] = 1024);
1941 TEST(chunkalloc[7] == chunkalloc[6] + size[6]);
1942 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
1943 cp->Free(chunkalloc[7]);
1944 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
1945 // now we should have [0], [1], [5], [4], [6]
1947 cp->Free(chunkalloc[1]);
1948 cp->Free(chunkalloc[0]);
1949 cp->Free(chunkalloc[4]);
1950 cp->Free(chunkalloc[5]);
1951 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
1952 chunkalloc[8] = cp->Alloc(size[8] = size[0] + size[1] + size[4] + size[5] - 32);
1953 TEST(chunkalloc[8] == chunkalloc[0]);
1954 chunkalloc[9] = cp->Alloc(size[9] = 32);
1955 TEST(chunkalloc[9] == chunkalloc[8] + size[8]);
1956 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
1957 // now we should have [8], [9], [6]
1959 chunkalloc[10] = cp->Alloc(size[10] = KFbServLargeChunkMinPhysicalSize - size[6] - size[8] - size[9]);
1960 TEST(chunkalloc[10] == chunkalloc[6] + size[6]);
1961 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
1962 chunkalloc[11] = cp->Alloc(size[11] = 16);
1963 TEST(chunkalloc[11] == chunkalloc[10] + size[10]);
1964 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + (pageSize << KFbServLargeChunkGrowByShifter));
1965 chunkalloc[12] = cp->Alloc(size[12] = ((pageSize << KFbServLargeChunkGrowByShifter) - 16) / 2);
1966 TEST(chunkalloc[12] == chunkalloc[11] + size[11]);
1967 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + (pageSize << KFbServLargeChunkGrowByShifter));
1968 chunkalloc[13] = cp->Alloc(size[13] = size[12]);
1969 TEST(chunkalloc[13] == chunkalloc[12] + size[12]);
1970 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + (pageSize << KFbServLargeChunkGrowByShifter));
1971 chunkalloc[14] = cp->Alloc(size[14] = pageSize << KFbServLargeChunkGrowByShifter);
1972 TEST(chunkalloc[14] == chunkalloc[13] + size[13]);
1973 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + 2 * (pageSize << KFbServLargeChunkGrowByShifter));
1974 chunkalloc[15] = cp->Alloc(size[15] = (pageSize << KFbServLargeChunkGrowByShifter) + 4);
1975 TEST(chunkalloc[15] == chunkalloc[14] + size[14]);
1976 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + 4 * (pageSize << KFbServLargeChunkGrowByShifter));
1977 // now we should have [8], [9], [6], [10], [11], [12], [13], [14], [15]
1979 cp->Free(chunkalloc[15]);
1980 cp->Free(chunkalloc[14]);
1981 cp->Free(chunkalloc[13]);
1982 cp->Free(chunkalloc[12]);
1983 cp->Free(chunkalloc[11]);
1984 cp->Free(chunkalloc[10]);
1985 cp->Free(chunkalloc[9]);
1986 cp->Free(chunkalloc[8]);
1987 cp->Free(chunkalloc[6]);
1988 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
1990 TEST(cp->Alloc(virtualSize) == NULL);
1992 TInt largeSize = 4 * pageSize;
1993 chunkalloc[0] = cp->Alloc(size[0] = 2 * largeSize);
1994 TEST(chunkalloc[0] == chunkLargeBase);
1995 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[0]);
1996 chunkalloc[1] = cp->Alloc(2 * largeSize + 1);
1997 size[1] = 2 * largeSize + pageSize;
1998 TEST(chunkalloc[1] == chunkalloc[0] + size[0]);
1999 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[0] + size[1]);
2000 chunkalloc[2] = cp->Alloc(size[2] = 3 * largeSize + pageSize);
2001 TEST(chunkalloc[2] == chunkalloc[1] + size[1]);
2002 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[0] + size[1] + size[2]);
2003 // now we should have [0], [1], [2]
2005 cp->Free(chunkalloc[1]);
2006 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[0] + size[2]);
2007 chunkalloc[3] = cp->Alloc(largeSize + 1);
2008 size[3] = largeSize + pageSize;
2009 TEST(chunkalloc[3] == chunkalloc[1]);
2010 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[0] + size[2] + size[3]);
2011 chunkalloc[4] = cp->Alloc(size[4] = largeSize);
2012 TEST(chunkalloc[4] == chunkalloc[3] + size[3]);
2013 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[0] + size[2] + size[3] + size[4]);
2014 chunkalloc[5] = cp->Alloc(size[5] = 64 * largeSize);
2015 TEST(chunkalloc[5] == chunkalloc[2] + size[2]);
2016 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[0] + size[2] + size[3] + size[4] + size[5]);
2017 // now we should have [0], [3], [4], [2], [5]
2019 cp->Free(chunkalloc[0]);
2020 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[2] + size[3] + size[4] + size[5]);
2021 cp->Free(chunkalloc[2]);
2022 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[3] + size[4] + size[5]);
2023 cp->Free(chunkalloc[3]);
2024 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[4] + size[5]);
2025 cp->Free(chunkalloc[4]);
2026 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[5]);
2027 cp->Free(chunkalloc[5]);
2028 TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
2031 CleanupStack::PopAndDestroy(2, &chunk); // cp, chunk
2036 GRAPHICS-FBSERV-0527
2039 Creates large bitmaps of different colour depth.
2042 The bitmaps allocated are too big so
2043 the allocation should fail.
2045 @SYMTestExpectedResults
2046 KErrNoMemory when allocating the bitmaps.
2048 void CTBitmap::LargeBitmaps()
2050 INFO_PRINTF1(_L("Test Large Bitmaps"));
2052 TMemoryInfoV1Buf membuf;
2053 UserHal::MemoryInfo(membuf);
2054 const TReal maxmem = membuf().iTotalRamInBytes;
2057 TInt ret = Math::Sqrt(realSize,maxmem);
2058 TEST2(ret, KErrNone);
2060 ret = Math::Int(size,realSize);
2061 TEST2(ret, KErrNone);
2063 DoLargeBitmaps(TSize(size * 8,size),EGray2);
2064 DoLargeBitmaps(TSize(size * 4,size),EGray4);
2065 DoLargeBitmaps(TSize(size * 2,size),EGray16);
2066 DoLargeBitmaps(TSize(size,size),EGray256);
2067 DoLargeBitmaps(TSize(size * 2,size),EColor16);
2068 DoLargeBitmaps(TSize(size,size),EColor256);
2069 DoLargeBitmaps(TSize(size / 2,size),EColor4K);
2070 DoLargeBitmaps(TSize(size / 2,size),EColor64K);
2071 DoLargeBitmaps(TSize(size / 3,size),EColor16M);
2072 DoLargeBitmaps(TSize(size / 4,size),EColor16MU);
2073 DoLargeBitmaps(TSize(size / 4,size),EColor16MAP);
2076 void CTBitmap::DoLargeBitmaps(const TSize& aSize,TDisplayMode aDisplayMode)
2079 TInt ret = bmp1.Create(aSize,aDisplayMode);
2080 TEST2(ret, KErrNoMemory);
2085 GRAPHICS-FBSERV-0528
2088 Check error handling for bitmaps above pixel and byte size limits
2092 @SYMTestExpectedResults
2095 void CTBitmap::HugeBitmaps()
2097 // Check error handling for bitmaps above pixel and byte size limits
2098 INFO_PRINTF1(_L("Test Huge Bitmaps"));
2100 const TInt KLargePixelSize = 50000;
2102 DoHugeBitmaps(TSize(KLargePixelSize * 8,KLargePixelSize),EGray2);
2103 DoHugeBitmaps(TSize(KLargePixelSize * 4,KLargePixelSize),EGray4);
2104 DoHugeBitmaps(TSize(KLargePixelSize * 2,KLargePixelSize),EGray16);
2105 DoHugeBitmaps(TSize(KLargePixelSize,KLargePixelSize),EGray256);
2106 DoHugeBitmaps(TSize(KLargePixelSize * 2,KLargePixelSize),EColor16);
2107 DoHugeBitmaps(TSize(KLargePixelSize,KLargePixelSize),EColor256);
2108 DoHugeBitmaps(TSize(KLargePixelSize / 2,KLargePixelSize),EColor4K);
2109 DoHugeBitmaps(TSize(KLargePixelSize / 2,KLargePixelSize),EColor64K);
2110 DoHugeBitmaps(TSize(KLargePixelSize / 3,KLargePixelSize),EColor16M);
2111 DoHugeBitmaps(TSize(KLargePixelSize / 4,KLargePixelSize),EColor16MU);
2112 DoHugeBitmaps(TSize(KLargePixelSize / 4,KLargePixelSize),EColor16MAP);
2115 void CTBitmap::DoHugeBitmaps(const TSize& aSize,TDisplayMode aDisplayMode)
2117 const TInt KMaxPixelSize = KMaxTInt / 4 + 1;
2121 TInt ret = bmp.Create(TSize(aSize.iWidth / 2,aSize.iHeight / 2),aDisplayMode);
2122 TEST2(ret, KErrNoMemory);
2124 ret = bmp.Create(aSize,aDisplayMode);
2125 TEST2(ret, KErrTooBig);
2127 ret = bmp.Create(TSize(1,KMaxPixelSize),aDisplayMode);
2128 TEST2(ret, KErrTooBig);
2130 ret = bmp.Create(TSize(KMaxPixelSize,1),aDisplayMode);
2131 TEST2(ret, KErrTooBig);
2133 ret = bmp.Create(TSize(KMaxPixelSize,KMaxPixelSize),aDisplayMode);
2134 TEST2(ret, KErrTooBig);
2136 ret = bmp.Create(TSize(KMaxTInt,KMaxTInt),aDisplayMode);
2137 TEST2(ret, KErrTooBig);
2140 ret = bmp.Create(TSize(1,1),aDisplayMode);
2141 TEST2(ret, KErrNone);
2143 ret = bmp.Resize(TSize(aSize.iWidth / 2,aSize.iHeight / 2));
2144 TEST2(ret, KErrNoMemory);
2146 ret = bmp.Resize(aSize);
2147 TEST2(ret, KErrTooBig);
2149 ret = bmp.Resize(TSize(1,KMaxPixelSize));
2150 TEST2(ret, KErrTooBig);
2152 ret = bmp.Resize(TSize(KMaxPixelSize,1));
2153 TEST2(ret, KErrTooBig);
2155 ret = bmp.Resize(TSize(KMaxPixelSize,KMaxPixelSize));
2156 TEST2(ret, KErrTooBig);
2158 ret = bmp.Resize(TSize(KMaxTInt,KMaxTInt));
2159 TEST2(ret, KErrTooBig);
2166 GRAPHICS-FBSERV-0529
2169 Resizes a bitmap to a larger size and
2170 checks if the new bitmap is as expected
2174 @SYMTestExpectedResults
2177 void CTBitmap::Resize()
2179 INFO_PRINTF1(_L("Test Resizing"));
2186 DoResize(EColor256);
2188 DoResize(EColor64K);
2189 DoResize(EColor16M);
2190 DoResize(EColor16MU);
2191 DoResize(EColor16MAP);
2194 void CTBitmap::DoResize(TDisplayMode aDispMode)
2196 const TSize KBitmapOriginalSize(256,24);
2197 const TSize KBitmapLargeSize(288,32);
2198 const TSize KBitmapSmallSize(1,1);
2201 TInt ret = bmp.Create(KBitmapOriginalSize,aDispMode);
2202 TEST2(ret, KErrNone);
2203 bmp.SetSizeInTwips(KBitmapOriginalSize);
2204 TEST(bmp.SizeInPixels() == KBitmapOriginalSize);
2205 TEST(bmp.SizeInTwips() == KBitmapOriginalSize);
2207 CBitwiseBitmap* bb = bmp.BitmapAddress();
2209 TUint32* base = bmp.DataAddress();
2212 TInt scanLineLength = CFbsBitmap::ScanLineLength(256,aDispMode);
2213 TInt blockStart = scanLineLength / 4;
2214 TInt blockLength = scanLineLength / 2;
2217 for(row = 8; row < 16; row++)
2219 TUint8* bmpadd = (TUint8*)bb->ScanLineAddress(base,row);
2220 Mem::FillZ(bmpadd + blockStart,blockLength);
2223 ret = bmp.Resize(KBitmapLargeSize);
2224 TEST2(ret, KErrNone);
2225 TEST(bmp.SizeInPixels() == KBitmapLargeSize);
2226 TEST(bmp.SizeInTwips() == KBitmapLargeSize);
2227 bb = bmp.BitmapAddress();
2229 base = bmp.DataAddress();
2231 scanLineLength = CFbsBitmap::ScanLineLength(288,aDispMode);
2233 for(row = 0; row < 8; row++)
2235 TUint8* bmpadd=(TUint8*)bb->ScanLineAddress(base,row);
2236 CheckWhite(bmpadd,scanLineLength,aDispMode);
2239 for(row = 16; row < 32; row++)
2241 TUint8* bmpadd=(TUint8*)bb->ScanLineAddress(base,row);
2242 CheckWhite(bmpadd,scanLineLength,aDispMode);
2245 for(row = 8; row < 16; row++)
2247 TUint8* bmpadd=(TUint8*)bb->ScanLineAddress(base,row);
2248 CheckWhite(bmpadd,blockStart,aDispMode);
2250 TUint8* ptr = bmpadd + blockStart;
2251 TUint8* ptrLimit = ptr + blockLength;
2252 while (ptr < ptrLimit)
2255 CheckWhite(ptr,scanLineLength - blockStart - blockLength,aDispMode);
2258 ret = bmp.Resize(KBitmapSmallSize);
2259 TEST2(ret, KErrNone);
2260 TEST(bmp.SizeInPixels() == KBitmapSmallSize);
2261 TEST(bmp.SizeInTwips() == KBitmapSmallSize);
2263 ret = bmp.Resize(KBitmapOriginalSize);
2264 TEST2(ret, KErrNone);
2265 TEST(bmp.SizeInPixels() == KBitmapOriginalSize);
2266 TEST(bmp.SizeInTwips() == KBitmapOriginalSize);
2271 void CTBitmap::CheckWhite(TUint8* aData,TInt aDataLength,TDisplayMode aDispMode)
2273 TUint8* dataLimit = aData + aDataLength;
2275 if (aDispMode != EColor4K)
2277 while (aData < dataLimit)
2278 TEST(*aData++ == 0xff);
2282 while (aData < dataLimit)
2284 TEST(*aData == 0xff || *aData == 0x0f);
2292 GRAPHICS-FBSERV-0530
2295 Creates BitmapUtil objects and sets the
2296 current position to different positions
2297 and retrieves and sets the pixels in these
2298 and compares it to another Bitmap Util object
2302 @SYMTestExpectedResults
2305 void CTBitmap::BitmapUtil()
2307 INFO_PRINTF1(_L("Test Bitmap Util"));
2309 TSize bmpUtilSize1(256,4);
2310 TSize bmpUtilSize2(256,1);
2311 TSize bmpUtilSize3(256,256);
2312 TSize bmpUtilSize4(1024,1024);
2314 INFO_PRINTF1(_L("256x4.. "));
2315 DoBitmapUtil(bmpUtilSize1,EGray2);
2316 DoBitmapUtil(bmpUtilSize1,EGray4);
2317 DoBitmapUtil(bmpUtilSize1,EGray16);
2318 DoBitmapUtil(bmpUtilSize1,EGray256);
2319 DoBitmapUtil(bmpUtilSize1,EColor16);
2320 DoBitmapUtil(bmpUtilSize1,EColor256);
2321 DoBitmapUtil(bmpUtilSize1,EColor4K);
2322 DoBitmapUtil(bmpUtilSize1,EColor64K);
2323 DoBitmapUtil(bmpUtilSize1,EColor16M);
2324 DoBitmapUtil(bmpUtilSize1,EColor16MU);
2325 DoBitmapUtil(bmpUtilSize1,EColor16MAP);
2327 INFO_PRINTF1(_L("256x1.. "));
2328 DoBitmapUtil(bmpUtilSize2,EGray2);
2329 DoBitmapUtil(bmpUtilSize2,EGray4);
2330 DoBitmapUtil(bmpUtilSize2,EGray16);
2331 DoBitmapUtil(bmpUtilSize2,EGray256);
2332 DoBitmapUtil(bmpUtilSize2,EColor16);
2333 DoBitmapUtil(bmpUtilSize2,EColor256);
2334 DoBitmapUtil(bmpUtilSize2,EColor4K);
2335 DoBitmapUtil(bmpUtilSize2,EColor64K);
2336 DoBitmapUtil(bmpUtilSize2,EColor16M);
2337 DoBitmapUtil(bmpUtilSize2,EColor16MU);
2338 DoBitmapUtil(bmpUtilSize2,EColor16MAP);
2340 INFO_PRINTF1(_L("256x256..\n"));
2341 DoBitmapUtil(bmpUtilSize3,EGray2);
2342 DoBitmapUtil(bmpUtilSize3,EGray4);
2343 DoBitmapUtil(bmpUtilSize3,EGray16);
2344 DoBitmapUtil(bmpUtilSize3,EGray256);
2345 DoBitmapUtil(bmpUtilSize3,EColor16);
2346 DoBitmapUtil(bmpUtilSize3,EColor256);
2347 DoBitmapUtil(bmpUtilSize3,EColor4K);
2348 DoBitmapUtil(bmpUtilSize3,EColor64K);
2349 DoBitmapUtil(bmpUtilSize3,EColor16M);
2350 DoBitmapUtil(bmpUtilSize3,EColor16MU);
2351 DoBitmapUtil(bmpUtilSize3,EColor16MAP);
2353 INFO_PRINTF1(_L("Testing wastage bytes in 16M scanlines...\n"));
2354 bmpUtilSize1.SetSize(5,13);
2355 bmpUtilSize2.SetSize(6,14);
2356 bmpUtilSize3.SetSize(7,15);
2357 bmpUtilSize4.SetSize(8,16);
2358 DoBitmapUtil(bmpUtilSize1,EColor16M);
2359 DoBitmapUtil(bmpUtilSize2,EColor16M);
2360 DoBitmapUtil(bmpUtilSize3,EColor16M);
2361 DoBitmapUtil(bmpUtilSize4,EColor16M);
2364 * Test code commented out as it results in test case failure.
2365 * Problem recorded in defect DEF001233.
2367 INFO_PRINTF1(_L("Testing wastage bits in Gray16 scanlines...\n\n"));
2368 bmpUtilSize1.SetSize(4,13);
2369 bmpUtilSize2.SetSize(5,14);
2370 bmpUtilSize3.SetSize(6,15);
2371 bmpUtilSize4.SetSize(7,16);
2372 DoBitmapUtil(bmpUtilSize1,EGray16);
2373 DoBitmapUtil(bmpUtilSize2,EGray16);
2374 DoBitmapUtil(bmpUtilSize3,EGray16);
2375 DoBitmapUtil(bmpUtilSize4,EGray16);
2379 void CTBitmap::DoBitmapUtil(const TSize& aSize,TDisplayMode aDispMode)
2381 const TPoint startPoint(aSize.iWidth / 3,aSize.iHeight / 3);
2382 const TPoint zeroPoint(0,0);
2385 TInt ret=bmp1.Create(aSize,aDispMode);
2386 TEST2(ret, KErrNone);
2390 const TInt numPixels = ((aSize.iWidth + 31) & ~0x1f) * aSize.iHeight;
2394 ret=bmp2.Create(aSize,aDispMode);
2395 TEST2(ret, KErrNone);
2397 TBitmapUtil util1(&bmp1);
2398 util1.Begin(zeroPoint);
2399 TBitmapUtil util2(&bmp2);
2400 util2.Begin(zeroPoint,util1);
2402 TPoint currentPosition;
2403 for (currentPosition.iY = 0; currentPosition.iY < aSize.iHeight; currentPosition.iY++)
2404 for (currentPosition.iX = 0; currentPosition.iX < aSize.iWidth; currentPosition.iX++)
2406 util1.SetPos(currentPosition);
2407 util2.SetPos(currentPosition);
2408 TUint32 pixelData = util1.GetPixel();
2409 util2.SetPixel(pixelData);
2413 CompareBitmaps(bmp1,bmp2,EColor16M);
2416 ret=bmp2.Create(aSize,aDispMode);
2417 TEST2(ret, KErrNone);
2418 util1.Begin(startPoint);
2419 util2.Begin(startPoint,util1);
2420 for (count1 = 0; count1 < numPixels; count1++)
2422 util2.SetPixel(util1);
2428 CompareBitmaps(bmp1,bmp2,EColor16M);
2431 ret=bmp2.Create(aSize,aDispMode);
2432 TEST2(ret, KErrNone);
2433 util1.Begin(zeroPoint);
2434 util2.Begin(zeroPoint,util1);
2435 for (currentPosition.iX = 0; currentPosition.iX < aSize.iWidth; currentPosition.iX++)
2437 for (currentPosition.iY = 0; currentPosition.iY < aSize.iHeight; currentPosition.iY++)
2439 util2.SetPixel(util1);
2448 CompareBitmaps(bmp1,bmp2,EColor16M);
2451 ret=bmp2.Create(aSize,aDispMode);
2452 TEST2(ret, KErrNone);
2453 util1.Begin(startPoint);
2454 util2.Begin(startPoint,util1);
2455 for (count1 = 0; count1 < numPixels; count1++)
2457 util2.SetPixel(util1);
2463 CompareBitmaps(bmp1,bmp2,EColor16M);
2466 ret=bmp2.Create(aSize,aDispMode);
2467 TEST2(ret, KErrNone);
2468 util1.Begin(zeroPoint);
2469 util2.Begin(zeroPoint,util1);
2470 for (currentPosition.iX = 0; currentPosition.iX < aSize.iWidth; currentPosition.iX++)
2472 for (currentPosition.iY = 0; currentPosition.iY < aSize.iHeight; currentPosition.iY++)
2474 util2.SetPixel(util1);
2483 CompareBitmaps(bmp1,bmp2,EColor16M);
2489 void CTBitmap::BitmapTiming()
2491 INFO_PRINTF1(_L("Test Timing"));
2494 TInt ret=bmp.Load(iTestBitmapName,ETfbs,NULL);
2495 TEST2(ret, KErrNone);
2497 CDirectFileStore* writestore=NULL;
2498 TRAP(ret,writestore=CDirectFileStore::ReplaceL(iFs,KTempFilename,EFileStream|EFileWrite));
2499 TEST2(ret, KErrNone);
2500 TUidType uidtype(KDirectFileStoreLayoutUid,KMultiBitmapFileImageUid);
2501 TRAP(ret,writestore->SetTypeL(uidtype));
2502 TEST2(ret, KErrNone);
2503 RStoreWriteStream writestrm;
2504 TStreamId headerid(0);
2505 TRAP(ret,headerid=writestrm.CreateL(*writestore));
2506 TEST2(ret, KErrNone);
2507 TRAP(ret,writestore->SetRootL(headerid));
2508 TEST2(ret, KErrNone);
2509 INFO_PRINTF1(_L("Save time: "));
2510 TUint startTime=User::TickCount();
2511 for(TInt count=0;count<5000;count++)
2513 TRAP(ret,bmp.ExternalizeL(writestrm));
2516 TUint stopTime=User::TickCount();
2517 TEST2(ret, KErrNone);
2520 INFO_PRINTF2(_L("%d ticks\r\n"),stopTime-startTime);
2522 CDirectFileStore* readstore=NULL;
2523 TRAP(ret,readstore=CDirectFileStore::OpenL(iFs,KTempFilename,EFileStream|EFileRead));
2524 TEST2(ret, KErrNone);
2525 RStoreReadStream readstrm;
2526 headerid=readstore->Root();
2527 INFO_PRINTF1(_L("Load time: "));
2528 startTime=User::TickCount();
2529 for(TInt count2=0;count2<5000;count2++)
2531 TRAP(ret,readstrm.OpenL(*readstore,headerid));
2533 TRAP(ret,bmp.InternalizeL(readstrm));
2537 stopTime=User::TickCount();
2538 TEST2(ret, KErrNone);
2540 INFO_PRINTF2(_L("%d ticks\r\n"),stopTime-startTime);
2543 iFs.Delete(KTempFilename);
2550 GRAPHICS-FBSERV-0531
2553 Tries to load non existing bitmaps from the
2558 @SYMTestExpectedResults
2561 void CTBitmap::InvalidBitmap()
2563 INFO_PRINTF1(_L("Test Invalid Bitmap"));
2568 TInt ret=bmp.Load(_L("z:\\tfbsx.mbm"),ETfbs,NULL);
2569 TEST2(ret, KErrNotFound);
2570 ret=bmp.Load(_L("z:\\tfbs.xbm"),ETfbs,NULL);
2571 TEST2(ret, KErrNotFound);
2572 ret=bmp.Load(iTestBitmapName,999,NULL);
2573 TEST2(ret, KErrEof);
2574 ret=bmp.Load(iTestBitmapName,-1,NULL);
2575 TEST2(ret, KErrEof);
2578 User::Heap().Check();
2586 GRAPHICS-FBSERV-0532
2589 Creates bitmaps and saves them to the C-drive
2590 and loads them back again and compares them to
2591 the original bitmaps.
2594 The test uses different colour depths and sizes
2595 of the bitmaps. The sizes of the bitmaps are
2598 @SYMTestExpectedResults
2601 void CTBitmap::SaveAndLoad()
2603 INFO_PRINTF1(_L("Test Save/Load Bitmap"));
2605 const TInt sizes[] = { 1,2,3,4,5,7,8,9,15,16,17,31,32,33,100 };
2606 const TInt numSizes = sizeof(sizes) / sizeof(TInt);
2609 for (TInt widthIndex = 0; widthIndex < numSizes; widthIndex++)
2611 INFO_PRINTF3(_L("Index %d/%d\r"), widthIndex + 1, numSizes);
2612 size.iWidth = sizes[widthIndex];
2614 for (TInt heightIndex = 0; heightIndex < numSizes; heightIndex++)
2616 size.iHeight = sizes[heightIndex];
2618 DoSaveAndLoad(size,EGray2,EFalse);
2619 DoSaveAndLoad(size,EGray2,ETrue);
2620 DoSaveAndLoad(size,EGray4,EFalse);
2621 DoSaveAndLoad(size,EGray4,ETrue);
2622 DoSaveAndLoad(size,EGray16,EFalse);
2623 DoSaveAndLoad(size,EGray16,ETrue);
2624 DoSaveAndLoad(size,EGray256,EFalse);
2625 DoSaveAndLoad(size,EGray256,ETrue);
2626 DoSaveAndLoad(size,EColor16,EFalse);
2627 DoSaveAndLoad(size,EColor16,ETrue);
2628 DoSaveAndLoad(size,EColor256,EFalse);
2629 DoSaveAndLoad(size,EColor256,ETrue);
2630 DoSaveAndLoad(size,EColor4K,EFalse);
2631 DoSaveAndLoad(size,EColor4K,ETrue);
2632 DoSaveAndLoad(size,EColor64K,EFalse);
2633 DoSaveAndLoad(size,EColor64K,ETrue);
2634 DoSaveAndLoad(size,EColor16M,EFalse);
2635 DoSaveAndLoad(size,EColor16M,ETrue);
2636 DoSaveAndLoad(size,EColor16MU,EFalse);
2637 DoSaveAndLoad(size,EColor16MU,ETrue);
2638 DoSaveAndLoad(size,EColor16MAP,EFalse);
2639 DoSaveAndLoad(size,EColor16MAP,ETrue);
2643 INFO_PRINTF1(_L("\r\n"));
2649 GRAPHICS-FBSERV-0533
2652 Creates bitmaps and saves them to the C-drive
2653 and loads them back again and compares them to
2654 the original bitmaps.
2657 The test uses different colour depths and sizes
2658 of the bitmaps. The sizes of the bitmaps are
2661 @SYMTestExpectedResults
2664 void CTBitmap::SaveAndLoadFast()
2666 INFO_PRINTF1(_L("Test Save/Load Fast Bitmap"));
2668 // Keep this array small as the test time increases with n^2
2669 // This way we can put in bigger sizes...
2670 const TInt sizes[] = { 501, 107, 213 };
2671 const TInt numSizes = sizeof(sizes) / sizeof(TInt);
2674 for (TInt widthIndex = 0; widthIndex < numSizes; widthIndex++)
2676 INFO_PRINTF3(_L("Index %d/%d\r"), widthIndex + 1, numSizes);
2677 size.iWidth = sizes[widthIndex];
2679 for (TInt heightIndex = 0; heightIndex < numSizes; heightIndex++)
2681 size.iHeight = sizes[heightIndex];
2683 DoSaveAndLoad(size,EGray2,EFalse);
2684 DoSaveAndLoad(size,EGray2,ETrue);
2685 DoSaveAndLoad(size,EGray4,EFalse);
2686 DoSaveAndLoad(size,EGray4,ETrue);
2687 DoSaveAndLoad(size,EGray16,EFalse);
2688 DoSaveAndLoad(size,EGray16,ETrue);
2689 DoSaveAndLoad(size,EGray256,EFalse);
2690 DoSaveAndLoad(size,EGray256,ETrue);
2691 DoSaveAndLoad(size,EColor16,EFalse);
2692 DoSaveAndLoad(size,EColor16,ETrue);
2693 DoSaveAndLoad(size,EColor256,EFalse);
2694 DoSaveAndLoad(size,EColor256,ETrue);
2695 DoSaveAndLoad(size,EColor4K,EFalse);
2696 DoSaveAndLoad(size,EColor4K,ETrue);
2697 DoSaveAndLoad(size,EColor64K,EFalse);
2698 DoSaveAndLoad(size,EColor64K,ETrue);
2699 DoSaveAndLoad(size,EColor16M,EFalse);
2700 DoSaveAndLoad(size,EColor16M,ETrue);
2701 DoSaveAndLoad(size,EColor16MU,EFalse);
2702 DoSaveAndLoad(size,EColor16MU,ETrue);
2703 DoSaveAndLoad(size,EColor16MAP,EFalse);
2704 DoSaveAndLoad(size,EColor16MAP,ETrue);
2708 INFO_PRINTF1(_L("\r\n"));
2713 void CTBitmap::DoSaveAndLoad(const TSize& aSize,TDisplayMode aDispMode,TBool aBlank)
2716 bmp1.Create(aSize,aDispMode);
2723 TInt ret = bmp1.Save(KTempFilename);
2724 TEST2(ret, KErrNone);
2727 ret = bmp2.Load(KTempFilename);
2728 TEST2(ret, KErrNone);
2730 CompareBitmaps(bmp1,bmp2,EColor16M);
2732 ret = bmp2.Compress();
2733 TEST2(ret, KErrNone);
2735 CompareBitmaps(bmp1,bmp2,EColor16M);
2737 iFs.Delete(KTempFilename);
2742 GRAPHICS-FBSERV-0534
2745 Compresses bitmaps to ROM and RAM
2748 Tries to compress a bitmap in ROM and expects it to fail.
2749 Compresses a bitmap in RAM and expect it to succeed.
2750 Compression tested when executed in the background.
2752 @SYMTestExpectedResults
2755 void CTBitmap::Compress()
2757 INFO_PRINTF1(_L("Test Compression"));
2760 RFbsSession* fbs = RFbsSession::GetSession();
2763 if(!iSkipRomBitmapTests)
2765 INFO_PRINTF1(_L("check compressing of ROM files causes error"));
2767 TInt ret=bmp.Load(KRomBitmap,ETfbs,NULL);
2768 TEST2(ret, KErrNone);
2770 ret = bmp.Compress();
2771 TEST2(ret, KErrAccessDenied); //cannot compress bitmaps in ROM
2773 ret = bmp.CompressInBackground();
2774 TEST2(ret, KErrAccessDenied); //cannot compress bitmaps in ROM
2776 bmp.CompressInBackground(rs);
2777 User::WaitForRequest(rs);
2778 TEST2(rs.Int(), KErrAccessDenied); //cannot compress bitmaps in ROM
2780 ret = bmp.Save(KTempFilename);
2781 TEST2(ret, KErrNone);
2784 ret = bmp.Load(KTempFilename);
2785 TEST2(ret, KErrNone);
2787 ret = bmp.Compress();
2788 TEST2(ret, KErrNone);
2789 TEST(bmp.IsCompressedInRAM());
2793 ret = bmp.Load(KTempFilename);
2794 TEST2(ret, KErrNone);
2796 ret = bmp.CompressInBackground();
2797 TEST2(ret, KErrNone);
2799 fbs->SendCommand(EFbsCompress, 0); // force background compression to execute
2801 TEST(bmp.IsCompressedInRAM());
2805 ret = bmp.Load(KTempFilename);
2806 TEST2(ret, KErrNone);
2808 bmp.CompressInBackground(rs);
2809 User::WaitForRequest(rs); // wait until background compression is finished
2810 TEST2(rs.Int(), KErrNone);
2812 TEST(bmp.IsCompressedInRAM());
2816 iFs.Delete(KTempFilename);
2820 INFO_PRINTF1(_L("check compressing of RAM files is OK"));
2823 TInt ret=bmp.Load(KTestBitmapOnC,ETfbs,NULL);
2826 INFO_PRINTF1(_L("Could not load "));
2827 INFO_PRINTF1(KTestBitmapOnC);
2828 INFO_PRINTF1(_L(" Ensure is it copied over and rerun test\n"));
2829 User::Panic(_L(""), ret);
2832 ret = bmp.Compress();
2833 TEST2(ret, KErrNone);
2835 TEST(bmp.IsCompressedInRAM());
2837 ret = bmp.Save(KTempFilename);
2838 TEST2(ret, KErrNone);
2842 ret = bmp.Load(KTempFilename);
2843 TEST2(ret, KErrNone);
2845 ret = bmp.Compress();
2846 TEST2(ret, KErrNone);
2848 TEST(bmp.IsCompressedInRAM());
2852 ret = bmp.Load(KTempFilename);
2853 TEST2(ret, KErrNone);
2855 ret = bmp.CompressInBackground();
2856 TEST2(ret, KErrNone);
2858 fbs->SendCommand(EFbsCompress, 0); // force background compression to execute
2860 TEST(bmp.IsCompressedInRAM());
2864 ret = bmp.Load(KTempFilename);
2865 TEST2(ret, KErrNone);
2867 bmp.CompressInBackground(rs);
2868 fbs->SendCommand(EFbsCompress, 0); // force background compression to execute
2869 User::WaitForRequest(rs);
2870 TEST2(rs.Int(), KErrNone);
2872 TEST(bmp.IsCompressedInRAM());
2875 iFs.Delete(KTempFilename);
2879 INFO_PRINTF1(_L("check compressing a created bitmap"));
2881 INFO_PRINTF1(_L("1\r\n"));
2882 CFbsBitmapEx bitmap;
2883 TInt ret=bitmap.Create(TSize(200,200),EColor256);
2884 TEST2(ret, KErrNone);
2886 INFO_PRINTF1(_L("2\r\n"));
2887 BlankBitmap(bitmap);
2889 ret = bitmap.Compress();
2890 TEST2(ret, KErrNone);
2892 INFO_PRINTF1(_L("3\r\n"));
2894 TEST(bitmap.IsCompressedInRAM());
2899 void CTBitmap::BlankBitmap(CFbsBitmapEx& aBitmap)
2901 TSize size = aBitmap.SizeInPixels();
2902 TInt dataLength = CFbsBitmap::ScanLineLength(size.iWidth,aBitmap.DisplayMode()) * size.iHeight;
2904 Mem::FillZ((TUint8*)aBitmap.DataAddress(),dataLength);
2905 aBitmap.UnlockHeap();
2908 void CTBitmap::FillBitmap(CFbsBitmapEx& aBitmap)
2910 TSize size = aBitmap.SizeInPixels();
2911 TInt dataLength = CFbsBitmap::ScanLineLength(size.iWidth,aBitmap.DisplayMode()) * size.iHeight;
2914 TUint8* bmpBits = (TUint8*)aBitmap.DataAddress();
2915 aBitmap.UnlockHeap();
2916 TUint8* bmpBitsLimit = bmpBits + dataLength;
2917 TInt64 seed = aBitmap.Handle();
2919 switch (aBitmap.DisplayMode())
2922 Mem::FillZ(bmpBits,dataLength);
2924 while (bmpBits < bmpBitsLimit)
2926 *bmpBits++ = (TUint8)Math::Rand(seed);
2927 *bmpBits++ = (TUint8)(Math::Rand(seed) & 0x0f);
2931 while (bmpBits < bmpBitsLimit)
2933 TUint32 alpha = (TUint8)Math::Rand(seed);
2934 TUint32 red = (TUint8)Math::Rand(seed);
2935 TUint32 green = (TUint8)Math::Rand(seed);
2936 TUint32 blue = (TUint8)Math::Rand(seed);
2937 red = ((red * alpha)/255)&0xff;
2938 green = ((green * alpha)/255)&0xff;
2939 blue = ((blue * alpha)/255)&0xff;
2940 *(TUint32*)bmpBits = (alpha<<24)|(red<<16)|(green<<8)|blue;
2945 while (bmpBits < bmpBitsLimit)
2946 *bmpBits++ = (TUint8)Math::Rand(seed);
2951 void CTBitmap::StripeBitmap(CFbsBitmapEx& aBitmap) // Compression friendly bitmap filling
2953 TSize size = aBitmap.SizeInPixels();
2954 TInt dataLength = CFbsBitmap::ScanLineLength(size.iWidth,aBitmap.DisplayMode()) * size.iHeight;
2957 TUint8* bmpBits = (TUint8*)aBitmap.DataAddress();
2958 aBitmap.UnlockHeap();
2959 TUint8* bmpBitsLimit = bmpBits + dataLength;
2960 TInt64 seed = aBitmap.Handle();
2962 if (aBitmap.DisplayMode() != EColor4K)
2964 while (bmpBits < bmpBitsLimit)
2966 TUint8* tempBmpBitsLimit = Min(bmpBitsLimit, bmpBits + (TUint8)Math::Rand(seed));
2967 while (bmpBits < tempBmpBitsLimit)
2969 tempBmpBitsLimit = Min(bmpBitsLimit, bmpBits + (TUint8)Math::Rand(seed));
2970 while (bmpBits < tempBmpBitsLimit)
2976 Mem::FillZ(bmpBits,dataLength);
2978 while (bmpBits < bmpBitsLimit)
2980 TUint8* tempBmpBitsLimit = Min(bmpBitsLimit, bmpBits + (TUint8)(Math::Rand(seed) * 2));
2981 while (bmpBits < tempBmpBitsLimit)
2986 tempBmpBitsLimit = Min(bmpBitsLimit, bmpBits + (TUint8)Math::Rand(seed));
2987 while (bmpBits < tempBmpBitsLimit)
2996 void CTBitmap::CompareBitmaps(CFbsBitmapEx& aBmp1,CFbsBitmapEx& aBmp2,TDisplayMode aDispMode)
2998 // We will compare bitmaps that we draw beginning at four different offsets into the bitmap
2999 const TInt KTestBitmapOrigins = 4;
3000 const TSize bmpSize = aBmp1.SizeInPixels();
3001 TEST(bmpSize == aBmp2.SizeInPixels());
3002 TInt originIndex = 0;
3004 // Call DoCompareBitmaps() for four different origins
3005 for(TInt ii=0;ii<KTestBitmapOrigins;ii++)
3007 TInt xCoord = originIndex*(bmpSize.iWidth/4);
3008 TInt yCoord = originIndex*(bmpSize.iHeight/4);
3009 DoCompareBitmaps(aBmp1,aBmp2,aDispMode,TPoint(xCoord, yCoord), bmpSize);
3014 void CTBitmap::DoCompareBitmaps(CFbsBitmapEx& aBmp1,CFbsBitmapEx& aBmp2,TDisplayMode aDispMode, TPoint aLineOrigin, TSize aBmpSize)
3016 // Compares two bitmaps line by line
3017 const TInt KBitmapWidth = aBmpSize.iWidth;
3018 const TInt KStartRow = aLineOrigin.iY;
3019 const TInt KBitmapHeight = aBmpSize.iHeight;
3021 HBufC8* buf1 = HBufC8::NewMax(KBitmapWidth * 4);
3022 HBufC8* buf2 = HBufC8::NewMax(KBitmapWidth * 4);
3025 TPtr8 des1(buf1->Des());
3026 TPtr8 des2(buf2->Des());
3028 for (TInt row = KStartRow; row < KBitmapHeight; row++)
3030 aBmp1.GetScanLine(des1,aLineOrigin,KBitmapWidth,aDispMode);
3031 aBmp2.GetScanLine(des2,aLineOrigin,KBitmapWidth,aDispMode);
3033 const TInt ret = des1.Compare(des2);
3036 INFO_PRINTF2(_L("Bitmap comparison failed, row %d differernt!\n"), row);
3037 aBmp1.Save(KFail1Filename);
3038 aBmp2.Save(KFail2Filename);
3047 void CTBitmap::CopyBitmap(CFbsBitmapEx& aBmp1,const CFbsBitmapEx& aBmp2)
3049 TSize bmp1size = aBmp1.SizeInPixels();
3050 TSize bmp2size = aBmp2.SizeInPixels();
3051 TInt bmp1dataLength = CFbsBitmap::ScanLineLength(bmp1size.iWidth,aBmp1.DisplayMode()) * bmp1size.iHeight;
3052 TInt bmp2dataLength = CFbsBitmap::ScanLineLength(bmp2size.iWidth,aBmp2.DisplayMode()) * bmp2size.iHeight;
3053 TEST(bmp1dataLength == bmp2dataLength);
3055 TUint32* bmp1Bits = aBmp1.DataAddress();
3058 TUint32* bmp2Bits = aBmp2.DataAddress();
3060 Mem::Copy((TUint8*)bmp1Bits,(TUint8*)bmp2Bits,bmp1dataLength);
3066 GRAPHICS-FBSERV-0535
3069 Loads and copies bitmaps and does a
3070 fuzzy compare on the bitmaps using
3075 @SYMTestExpectedResults
3078 void CTBitmap::Color256BitmapUtil()
3080 INFO_PRINTF1(_L("Test CFbsColor256BitmapUtil"));
3082 CFbsBitmapEx bmpRefDitherFs;
3083 TInt ret=bmpRefDitherFs.Load(_L("z:\\system\\data\\8bitDitherFS.mbm"));
3084 TEST2(ret, KErrNone);
3086 CFbsBitmapEx bmpRefNoDither;
3087 ret=bmpRefNoDither.Load(_L("z:\\system\\data\\8bitNoDither.mbm"));
3088 TEST2(ret, KErrNone);
3090 TSize size = bmpRefNoDither.SizeInPixels();
3092 CFbsColor256BitmapUtil* util = NULL;
3093 TRAP(ret, util=CFbsColor256BitmapUtil::NewL(NULL));
3094 TEST2(ret, KErrNone);
3097 ret = bmp2.Create(size,EColor256);
3098 TEST2(ret, KErrNone);
3102 INFO_PRINTF1(_L("EColor256 "));
3104 ret = util->CopyBitmap(&bmp2,&bmpRefNoDither,CFbsColor256BitmapUtil::ENoDither);
3105 TEST2(ret, KErrNone);
3106 CompareBitmaps(bmpRefNoDither,bmp2,EColor16M);
3107 ret = util->CopyBitmap(&bmp2,&bmpRefDitherFs,CFbsColor256BitmapUtil::EFloydSteinberg);
3108 TEST2(ret, KErrNone);
3109 CompareBitmaps(bmpRefDitherFs,bmp2,EColor16M);
3111 INFO_PRINTF1(_L("EColor4K "));
3113 ret=bmp1.Load(_L("z:\\system\\data\\12bit.mbm"));
3114 TEST2(ret, KErrNone);
3115 ret = util->CopyBitmap(&bmp2,&bmp1,CFbsColor256BitmapUtil::ENoDither);
3116 TEST2(ret, KErrNone);
3117 CompareBitmaps(bmpRefNoDither,bmp2,EColor16M);
3118 ret = util->CopyBitmap(&bmp2,&bmp1,CFbsColor256BitmapUtil::EFloydSteinberg);
3119 TEST2(ret, KErrNone);
3120 FuzzyCompareBitmapsColor256(bmpRefNoDither,bmp2,23);
3122 INFO_PRINTF1(_L("EColor64K "));
3124 ret=bmp1.Load(_L("z:\\system\\data\\16bit.mbm"));
3125 TEST2(ret, KErrNone);
3126 ret = util->CopyBitmap(&bmp2,&bmp1,CFbsColor256BitmapUtil::ENoDither);
3127 TEST2(ret, KErrNone);
3128 CompareBitmaps(bmpRefNoDither,bmp2,EColor16M);
3129 ret = util->CopyBitmap(&bmp2,&bmp1,CFbsColor256BitmapUtil::EFloydSteinberg);
3130 TEST2(ret, KErrNone);
3131 FuzzyCompareBitmapsColor256(bmpRefNoDither,bmp2,28);
3133 INFO_PRINTF1(_L("EColor16M\r\n"));
3135 ret=bmp1.Load(_L("z:\\system\\data\\24bit.mbm"));
3136 TEST2(ret, KErrNone);
3137 ret = util->CopyBitmap(&bmp2,&bmp1,CFbsColor256BitmapUtil::ENoDither);
3138 TEST2(ret, KErrNone);
3139 CompareBitmaps(bmpRefNoDither,bmp2,EColor16M);
3140 ret = util->CopyBitmap(&bmp2,&bmp1,CFbsColor256BitmapUtil::EFloydSteinberg);
3141 TEST2(ret, KErrNone);
3142 FuzzyCompareBitmapsColor256(bmpRefNoDither,bmp2,32);
3144 INFO_PRINTF1(_L("EColor16MU\r\n"));
3146 ret=bmp1.Load(_L("z:\\system\\data\\32bit.mbm"));
3147 TEST2(ret, KErrNone);
3148 ret = util->CopyBitmap(&bmp2,&bmp1,CFbsColor256BitmapUtil::ENoDither);
3149 TEST2(ret, KErrNone);
3150 CompareBitmaps(bmpRefNoDither,bmp2,EColor16M);
3151 ret = util->CopyBitmap(&bmp2,&bmp1,CFbsColor256BitmapUtil::EFloydSteinberg);
3152 TEST2(ret, KErrNone);
3153 FuzzyCompareBitmapsColor256(bmpRefNoDither,bmp2,32);
3156 ret = bmp3.Create(size,EColor16MAP);
3157 TEST2(ret, KErrNone);
3158 CopyBitmap(bmp3,bmp1);
3159 TEST2(ret, KErrNone);
3160 ret = util->CopyBitmap(&bmp2,&bmp3,CFbsColor256BitmapUtil::ENoDither);
3161 TEST2(ret, KErrNone);
3162 //Do not compare bitmaps since there is no reference EColor16MAP image
3163 //CompareBitmaps(bmpRefNoDither,bmp2,EColor16M); - testing ensures that
3164 //copying succeeds, not accuracy
3165 ret = util->CopyBitmap(&bmp2,&bmp3,CFbsColor256BitmapUtil::EFloydSteinberg);
3166 TEST2(ret, KErrNone);
3167 //Do not compare bitmaps since there is no reference EColor16MAP image
3168 //FuzzyCompareBitmapsColor256(bmpRefNoDither,bmp2,32); - testing ensures that
3169 //copying succeeds, not accuracy
3172 // bmp2.Save(_L("c:\\8bitSaved.mbm"));
3176 bmpRefNoDither.Reset();
3177 bmpRefDitherFs.Reset();
3183 void CTBitmap::FuzzyCompareBitmapsColor256(CFbsBitmapEx& aBmp1,CFbsBitmapEx& aBmp2,TUint aDifLimit)
3185 TSize bmp1size = aBmp1.SizeInPixels();
3186 TSize bmp2size = aBmp2.SizeInPixels();
3187 TInt bmp1dataLength = CFbsBitmap::ScanLineLength(bmp1size.iWidth,aBmp1.DisplayMode()) * bmp1size.iHeight;
3188 TInt bmp2dataLength = CFbsBitmap::ScanLineLength(bmp2size.iWidth,aBmp2.DisplayMode()) * bmp2size.iHeight;
3189 TEST(bmp1dataLength == bmp2dataLength);
3191 TUint8* bmp1Bits = (TUint8*)aBmp1.DataAddress();
3194 TUint8* bmp2Bits = (TUint8*)aBmp2.DataAddress();
3197 TUint totalDifference = 0;
3198 TUint difference = 0;
3199 while(bmp1dataLength--)
3201 difference = TRgb::Color256((TUint)*(bmp1Bits++)).Difference(TRgb::Color256((TUint)*(bmp2Bits++)));
3202 totalDifference+=difference;
3204 TUint avDif = totalDifference/bmp2dataLength;
3205 TEST(avDif<=aDifLimit);
3210 GRAPHICS-FBSERV-0536
3213 Creates a hardware bitmap with a size and
3214 display mode for different display modes.
3217 It checks some bitmap attributes, bitmapHandle,
3218 if it is a large bitmap and if the bitmap is in ROM.
3219 Creates a 'normal' bitmap with the same size as the
3220 hardware one. Checks it can write to the hardware
3221 bitmap. Checks reuse of a CFbsBitmap for mixture of
3222 hardware and normal bitmaps works.
3224 @SYMTestExpectedResults
3227 void CTBitmap::HardwareBitmaps()
3229 static const TDisplayMode modes[] =
3245 INFO_PRINTF1(_L("Test Hardware Bitmaps"));
3247 CFbsBitmapEx bitmap1;
3248 // Large bitmap threshold increased from 4K to 64K
3249 TSize size(300,300);
3250 TDisplayMode displayMode;
3252 // Try and find a display mode that hardware bitmaps support
3253 TInt ret = KErrNotSupported;
3255 while((displayMode=modes[i])!=ENone)
3257 ret = bitmap1.CreateHardwareBitmap(size,displayMode,TUid::Uid(0));
3258 if(ret!=KErrNotSupported)
3260 TEST2(ret, KErrNone);
3266 if(ret==KErrNotSupported)
3268 // Hardware bitmaps not supported on this device
3269 WARN_PRINTF1(_L("...Not Supported"));
3273 // Check some bitmap attributes
3274 TEST(bitmap1.HardwareBitmapHandle()!=NULL);
3275 TEST(!bitmap1.IsLargeBitmap());
3276 TEST(!bitmap1.IsRomBitmap());
3278 // Create a 'normal' bitmap the same size as the hardware one
3279 CFbsBitmapEx bitmap2;
3280 ret = bitmap2.Create(size,displayMode);
3281 TEST2(ret, KErrNone);
3282 TEST(bitmap2.HardwareBitmapHandle()==NULL);
3283 TEST(bitmap2.IsLargeBitmap());
3285 // Check we can write to the hardware bitmap OK
3286 FillBitmap(bitmap1);
3287 CopyBitmap(bitmap1,bitmap2);
3288 CompareBitmaps(bitmap1,bitmap2,EColor16M);
3290 // Discard hardware bitmap
3293 // Check reuse of a CFbsBitmap for mixture of hardware and normal bitmaps works
3294 ret = bitmap2.CreateHardwareBitmap(size,displayMode,TUid::Uid(0));
3295 TEST2(ret, KErrNone);
3296 ret = bitmap2.Create(TSize(10,10),displayMode);
3297 TEST2(ret, KErrNone);
3298 ret = bitmap2.CreateHardwareBitmap(size,displayMode,TUid::Uid(0));
3299 TEST2(ret, KErrNone);
3300 ret = bitmap2.Create(size,displayMode);
3301 TEST2(ret, KErrNone);
3306 GRAPHICS-FBSERV-0537
3314 For each possible display mode it creates a test bitmap
3315 and initialize it with the data from the gray bitmap.
3316 Then for each possible display mode it calls GetScanLine
3317 on the gray and test bitmaps and compares the lines.
3319 @SYMTestExpectedResults
3322 void CTBitmap::INC036062L()
3323 //INC036062 - Optimise masked bitblit for 1 bit greyscale mask case
3325 INFO_PRINTF1(_L("INC036062"));
3326 TDisplayMode displayMode[] =
3328 EGray2, EGray4, EGray16, EGray256, EColor16, EColor256,
3329 EColor64K, EColor16M, EColor4K, EColor16MU, EColor16MAP
3331 //Two EGray2 test bitmaps with sizes (11, 11) and (121, 121).
3334 TSize(11, 11), TSize(121, 121)
3336 //Masks for for the last scanline byte (probably partially initialized)
3337 TUint8 mask[sizeof(size)/sizeof(size[0])][sizeof(displayMode)/sizeof(displayMode[0])] =
3339 //EGray2 EGray4 EGray16 EGray256 EColor16 EColor256 EColor64K EColor16M EColor4K EColor16MU
3340 {0x07, 0x3F, 0x0F, 0xFF, 0x0F, 0xFF, 0xFF, 0xFF, 0x0F, 0xFF},
3341 {0x01, 0x03, 0x0F, 0xFF, 0x0F, 0xFF, 0xFF, 0xFF, 0x0F, 0xFF}
3343 for(TInt i=0;i<TInt(sizeof(size)/sizeof(size[0]));i++)
3345 //Create EGray2 bitmap
3346 CFbsBitmap* bmp = CreateBitmapLC(size[i], EGray2);
3347 //GetScanLine test - for each possible display mode: create a test bitmap
3348 //and initialize it with the data from the gray bitmap.
3349 //After that: for each possible display mode - call GetScanLine on the gray and
3350 //test bitmaps and compare the lines.
3351 for(TInt m=0;m<TInt(sizeof(displayMode)/sizeof(displayMode[0]));m++)
3353 HBufC8* row1 = HBufC8::NewLC(1000);
3354 TPtr8 prow1 = row1->Des();
3355 HBufC8* row2 = HBufC8::NewLC(1000);
3356 TPtr8 prow2 = row2->Des();
3357 //Create test bitmap
3358 CFbsBitmap* tbmp = CreateBitmapLC(size[i], displayMode[m], bmp);
3360 for(TInt m2=0;m2<TInt(sizeof(displayMode)/sizeof(displayMode[0]));m2++)
3362 for(TInt y=0;y<size[i].iHeight;y++)
3364 bmp->GetScanLine(prow1, TPoint(0, y), size[i].iWidth, displayMode[m2]);
3365 tbmp->GetScanLine(prow2, TPoint(0, y), size[i].iWidth, displayMode[m2]);
3366 TInt len = prow1.Length();
3367 TEST(len == prow2.Length());
3369 TUint8 b1 = prow1[len - 1];
3370 TUint8 b2 = prow2[len - 1];
3371 if(mask[i][m2] != 0xFF)
3372 {//Not all bits from the last byte are used.
3373 TEST((b1 & mask[i][m2]) == (b2 & mask[i][m2]));
3374 prow1.SetLength(len - 1);
3375 prow2.SetLength(len - 1);
3377 TEST(prow1 == prow2);
3378 }//end of - for(TInt y=0;y<size[i].iHeight;y++)
3379 }//end of - for(TInt m2=0;m2<(sizeof(displayMode)/sizeof(displayMode[0]));m2++)
3380 CleanupStack::PopAndDestroy(tbmp);
3381 CleanupStack::PopAndDestroy(row2);
3382 CleanupStack::PopAndDestroy(row1);
3383 }//end of - for(TInt m=0;m<(sizeof(displayMode)/sizeof(displayMode[0]));m++)
3384 CleanupStack::PopAndDestroy(bmp);
3385 }//end of - for(TInt i=0;i<(sizeof(size)/sizeof(size[0]));i++)
3390 GRAPHICS-FBSERV-0538
3393 Performance test of INC036062 (GetScanLine test)
3399 @SYMTestExpectedResults
3402 void CTBitmap::PerformanceTest_INC036062L()
3403 //INC036062 - Optimise masked bitblit for 1 bit greyscale mask case
3405 INFO_PRINTF1(_L("INC036062-Performance Test"));
3406 TSize size(143, 143);
3407 //Create EGray2 bitmap
3408 CFbsBitmap* bmpGray2 = CreateBitmapLC(size, EGray2);
3409 //Create EColor64 bitmap
3410 CFbsBitmap* bmpEColor64 = CreateBitmapLC(size, EColor64K);
3412 TDisplayMode displayMode[] =
3414 EGray2, EGray4, EGray16, EGray256, EColor16, EColor256,
3415 EColor64K, EColor16M, EColor4K, EColor16MU, EColor16MAP
3418 HBufC8* row = HBufC8::NewLC(1000);
3419 TPtr8 prow = row->Des();
3420 for(TInt m=0;m<TInt(sizeof(displayMode)/sizeof(displayMode[0]));m++)
3422 TUint time[2] = {0, 0};
3423 CFbsBitmap* pbmp[2] = {bmpGray2, bmpEColor64};
3424 for(TInt j=0;j<2;j++)
3426 time[j] = User::TickCount();
3429 for(TInt y=0;y<size.iHeight;y++)
3431 pbmp[j]->GetScanLine(prow, TPoint(0, y), size.iWidth, displayMode[m]);
3434 time[j] = User::TickCount() - time[j];
3436 //"Time+" - time with optimized GetScanLine for EGray2 bitmaps
3437 //"Time-" - time with GetScanLine for all bitmaps which colour is not EGray2.
3438 INFO_PRINTF4(_L("GetScanLine. Mode=%d, Time+ =%d, Time- =%d\r\n"), displayMode[m], time[0], time[1]);
3440 CleanupStack::PopAndDestroy(row);
3441 CleanupStack::PopAndDestroy(bmpEColor64);
3442 CleanupStack::PopAndDestroy(bmpGray2);
3445 CFbsBitmap* CTBitmap::CreateBitmapLC(const TSize& aSize, TDisplayMode aMode)
3447 CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
3448 CleanupStack::PushL(bmp);
3449 User::LeaveIfError(bmp->Create(aSize, aMode));
3450 //Initialize the bitmap
3451 TBitmapUtil bmpUtil(bmp);
3452 bmpUtil.Begin(TPoint(0, 0));
3453 for(TInt y=0;y<aSize.iHeight;bmpUtil.IncYPos(),y++)
3455 for(TInt x=0;x<aSize.iWidth;bmpUtil.IncXPos(),x++)
3461 color = Math::Random() % 2;
3464 color = Math::Random() % 0x10000;
3467 color = Math::Random();
3472 bmpUtil.SetPixel(color);
3479 CFbsBitmap* CTBitmap::CreateBitmapLC(const TSize& aSize, TDisplayMode aMode, const CFbsBitmap* aSrcBmp)
3481 CFbsBitmap* tbmp = new (ELeave) CFbsBitmap;
3482 CleanupStack::PushL(tbmp);
3483 User::LeaveIfError(tbmp->Create(aSize, aMode));
3484 //Initialize test bitmap
3485 HBufC8* row = HBufC8::NewLC(1000);
3486 TPtr8 prow = row->Des();
3487 for(TInt y=0;y<aSize.iHeight;y++)
3489 aSrcBmp->GetScanLine(prow, TPoint(0, y), aSize.iWidth, aMode);
3490 tbmp->SetScanLine(prow, y);
3492 CleanupStack::PopAndDestroy(row);
3498 GRAPHICS-FBSERV-0539
3501 Loads bitmaps from ROM and RAM
3502 and does a GetScanLine on the bitmaps
3503 and measures the time it takes to do
3510 @SYMTestExpectedResults
3513 void CTBitmap::INC037474L()
3514 //INC037474 - SS66 - CBitwiseBitmap::GenerateLineFromCompressedSixteenBitData() is very slow
3525 TPtrC tt[] = {_L("rom"), _L("rom"), _L("rom"), _L("ram"), _L("ram"), _L("ram")};
3526 TBool inRam[] = {EFalse, EFalse, EFalse, ETrue, ETrue, ETrue};
3527 TInt bpp[] = {12, 16, 24, 12, 16, 24};
3528 TDisplayMode targetMode[] = {EColor4K, EColor64K, EColor16M, EColor4K, EColor64K, EColor16M};
3529 const TInt KMaxScanLineLen = 800;
3530 TBuf8<KMaxScanLineLen> scanLineBuf;
3531 for(TInt i=0;i<TInt(sizeof(bmpFile)/sizeof(bmpFile[0]));i++)
3533 if(iSkipRomBitmapTests && !inRam[i])
3536 CFbsBitmap* bmp = LoadBitmapLC(bmpFile[i]);
3539 User::LeaveIfError(bmp->Compress());
3543 INFO_PRINTF3(_L("%d bpp %S compressed bitmap, GetScanLine test\r\n"), bpp[i], &des);
3544 TSize size = bmp->SizeInPixels();
3545 TEST(TInt(size.iWidth * sizeof(TInt16)) <= KMaxScanLineLen);
3546 TUint timeStart = User::TickCount();
3547 enum {KTestTimes = 15};//Greater KTestTimes values make the test is too slow!
3548 for(TInt j=0;j<KTestTimes;j++)
3550 TPoint startPixel(0, 0);
3551 for(TInt k=0;k<size.iHeight;k++)
3554 bmp->GetScanLine(scanLineBuf, startPixel, size.iWidth, targetMode[i]);
3557 TUint timeEnd = User::TickCount();
3558 INFO_PRINTF4(_L("%d bpp %S compressed bitmap, time = %d\r\n"), bpp[i], &des, timeEnd - timeStart);
3560 CleanupStack::PopAndDestroy(bmp);
3564 CFbsBitmap* CTBitmap::LoadBitmapLC(const TDesC& aFileName)
3566 CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
3567 CleanupStack::PushL(bmp);
3568 const TInt err = bmp->Load(aFileName, 0);
3569 TEST(err == KErrNone);
3570 User::LeaveIfError(err);
3576 GRAPHICS-FBSERV-0540
3579 Test to verify defect DEF038286.
3584 Initialized a test bitmap, compresses it
3585 and performs a GetScanLine on the compressed
3586 bitmap. Checks the color value against an
3589 @SYMTestExpectedResults
3592 void CTBitmap::DEF038286L()
3593 //DEF038286 - CBitwiseBitmap::GenerateLineFromCompressedSixteenBitData returns wrong clr value
3595 INFO_PRINTF1(_L("DEF038286 fix test"));
3596 //Create test bitmap
3597 CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
3598 CleanupStack::PushL(bmp);
3599 const TInt width = 16;
3600 const TSize size(width, 1);
3601 User::LeaveIfError(bmp->Create(size, EColor64K));
3603 TUint8 colorVal[width * 2] =
3605 {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
3606 // 8 9 10 11 12 13 14 15
3607 0x00,0x00, 0x00,0x00, 0x00,0x00, 0xFF,0xFF, 0xFF,0xFF, 0xFF,0xFF, 0xFF,0xFF, 0xFF,0xFF};
3608 //Initialize test bitmap
3609 TPtr8 ptr(colorVal, width * 2, width * 2);
3610 bmp->SetScanLine(ptr, 0);
3611 //Compress test bitmap
3612 User::LeaveIfError(bmp->Compress());
3613 //Check the test data
3614 TUint8 colorVal2[width * 2];
3615 TPtr8 ptr2(colorVal2, width * 2, width * 2);
3617 colorVal2[0] = colorVal2[1] = colorVal2[2] = colorVal2[3] = 0x12;
3618 bmp->GetScanLine(ptr2, TPoint(10, 0), 2, EColor64K);
3619 TEST(colorVal2[0] == colorVal[10 * 2] && colorVal2[1] == colorVal[10 * 2 + 1] &&
3620 colorVal2[2] == colorVal[11 * 2] && colorVal2[3] == colorVal[11 * 2 + 1]);
3622 colorVal2[0] = colorVal2[1] = colorVal2[2] = colorVal2[3] = 0x12;
3623 bmp->GetScanLine(ptr2, TPoint(10, 0), 1, EColor64K);
3624 TEST(colorVal2[0] == colorVal[10 * 2] && colorVal2[1] == colorVal[10 * 2 + 1]);
3626 colorVal2[0] = colorVal2[1] = colorVal2[2] = colorVal2[3] = 0x12;
3627 bmp->GetScanLine(ptr2, TPoint(11, 0), 1, EColor64K);
3628 TEST(colorVal2[0] == colorVal[11 * 2] && colorVal2[1] == colorVal[11 * 2 + 1]);
3630 //Destroy test bitmap and data
3631 CleanupStack::PopAndDestroy(bmp);
3636 GRAPHICS-FBSERV-0541
3639 Test to verify defect DEF038286.
3644 Initialized a test bitmap, compresses it
3645 and performs a GetScanLine on the compressed
3646 bitmap. Checks the colour value against an
3649 @SYMTestExpectedResults
3652 void CTBitmap::DEF038286_2L()
3653 //DEF038286 - CBitwiseBitmap::GenerateLineFromCompressedSixteenBitData returns wrong clr value
3654 //24 bpp bitmap test
3656 INFO_PRINTF1(_L("DEF038286 fix test. 24 bpp bitmap."));
3657 //Create test bitmap
3658 CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
3659 CleanupStack::PushL(bmp);
3660 const TInt width = 16;
3661 const TSize size(width, 1);
3662 User::LeaveIfError(bmp->Create(size, EColor16M));
3664 TUint8 colorVal[width * 3] =
3666 {0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,
3667 // 8 9 10 11 12 13 14 15
3668 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF};
3669 //Initialize test bitmap
3670 TPtr8 ptr(colorVal, width * 3, width * 3);
3671 bmp->SetScanLine(ptr, 0);
3672 //Compress test bitmap
3673 User::LeaveIfError(bmp->Compress());
3674 //Check the test data
3675 TUint8 colorVal2[width * 3];
3676 TPtr8 ptr2(colorVal2, width * 3, width * 3);
3678 colorVal2[0] = colorVal2[1] = colorVal2[2] = colorVal2[3] = colorVal2[4] = colorVal2[5] = 0x12;
3679 bmp->GetScanLine(ptr2, TPoint(10, 0), 2, EColor16M);
3680 TEST(colorVal2[0] == colorVal[10 * 3] && colorVal2[1] == colorVal[10 * 3 + 1] && colorVal2[2] == colorVal[10 * 3 + 2] &&
3681 colorVal2[3] == colorVal[11 * 3] && colorVal2[4] == colorVal[11 * 3 + 1] && colorVal2[5] == colorVal[11 * 3 + 2]);
3683 colorVal2[0] = colorVal2[1] = colorVal2[2] = colorVal2[3] = colorVal2[4] = colorVal2[5] = 0x12;
3684 bmp->GetScanLine(ptr2, TPoint(10, 0), 1, EColor16M);
3685 TEST(colorVal2[0] == colorVal[10 * 3] && colorVal2[1] == colorVal[10 * 3 + 1] && colorVal2[2] == colorVal[10 * 3 + 2]);
3687 colorVal2[0] = colorVal2[1] = colorVal2[2] = colorVal2[3] = colorVal2[4] = colorVal2[5] = 0x12;
3688 bmp->GetScanLine(ptr2, TPoint(11, 0), 1, EColor16M);
3689 TEST(colorVal2[0] == colorVal[11 * 3] && colorVal2[1] == colorVal[11 * 3 + 1] && colorVal2[2] == colorVal[11 * 3 + 2]);
3691 //Destroy test bitmap and data
3692 CleanupStack::PopAndDestroy(bmp);
3697 GRAPHICS-FBSERV-0542
3700 Tests the function CFbsBitmap::IsMonochrome()
3703 Loads uncompressed bitmaps and checks
3704 them if they are monochrome
3706 @SYMTestExpectedResults
3709 void CTBitmap::MonohromeL()
3711 INFO_PRINTF1(_L("Monohrome bitmaps"));
3712 TPtrC bitmap_ram[] =
3726 //Check monohrome bitmaps
3727 //1 bpp bitmap is always monochrome
3728 for(i=0;i<TInt(sizeof(bitmap_ram)/sizeof(bitmap_ram[0]));i++)
3730 CFbsBitmap* uncompressedBitmap = NULL;
3731 LoadAndNotCompressBitmapLC(uncompressedBitmap, bitmap_ram[i]);
3732 TEST(!uncompressedBitmap->IsCompressedInRAM());
3733 TBool monochrome = uncompressedBitmap->IsMonochrome();
3735 CleanupStack::PopAndDestroy(uncompressedBitmap);
3737 //Modify monohrome bitmaps and check them
3738 //1 bpp bitmap is always monochrome
3739 for(i=0;i<TInt(sizeof(bitmap_ram)/sizeof(bitmap_ram[0]));i++)
3741 CFbsBitmap* uncompressedBitmap = NULL;
3742 LoadAndNotCompressBitmapLC(uncompressedBitmap, bitmap_ram[i]);
3743 TEST(!uncompressedBitmap->IsCompressedInRAM());
3744 //Change something into the bitmap data
3745 uncompressedBitmap->LockHeap(ETrue);
3746 TUint32* data = uncompressedBitmap->DataAddress();
3748 uncompressedBitmap->UnlockHeap(ETrue);
3750 TBool monochrome = uncompressedBitmap->IsMonochrome();
3751 TEST(i > 0 ? !monochrome : monochrome);
3752 CleanupStack::PopAndDestroy(uncompressedBitmap);
3758 GRAPHICS-FBSERV-0543
3761 Tests the function CFbsBitmap::GetVerticalScanLine
3764 Gets the bitmap's vertical scanline starting at
3765 a specified x co-ordinate.
3767 @SYMTestExpectedResults
3770 void CTBitmap::GetVerticalScanLineL()
3772 INFO_PRINTF1(_L("GetVerticalScanLine()"));
3773 TDisplayMode displayMode[] =
3788 CFbsBitmap* uncompressedBitmap = NULL;
3789 LoadAndNotCompressBitmapLC(uncompressedBitmap, KRamBitmap2);
3790 TEST(!uncompressedBitmap->IsCompressedInRAM());
3791 TSize sizeInPixels = uncompressedBitmap->SizeInPixels();
3792 HBufC8* vertScanLine = HBufC8::NewLC(sizeInPixels.iHeight * 4);
3793 TPtr8 p = vertScanLine->Des();
3795 for(TInt i=0;i<TInt(sizeof(displayMode)/sizeof(displayMode[0]));i++)
3798 buf.Format(_L("--mode=%d\r\n"), displayMode[i]);
3800 for(TInt j=0;j<sizeInPixels.iWidth;j++)
3802 uncompressedBitmap->GetVerticalScanLine(des, j, displayMode[i]);
3805 CleanupStack::PopAndDestroy(vertScanLine);
3806 CleanupStack::PopAndDestroy(uncompressedBitmap);
3811 GRAPHICS-FBSERV-0544
3814 Tests the performance of the function
3815 CFbsBitmap::GetVerticalScanLine
3818 Gets the bitmap's vertical scanline starting at
3819 a specified x co-ordinate and measures the time
3822 @SYMTestExpectedResults
3825 void CTBitmap::GetVerticalScanLinePerformanceL()
3827 INFO_PRINTF1(_L("GetVerticalScanLine() performance"));
3828 TDisplayMode displayMode[] =
3843 CFbsBitmap* uncompressedBitmap = NULL;
3844 LoadAndNotCompressBitmapLC(uncompressedBitmap, KRamBitmap2);
3845 TEST(!uncompressedBitmap->IsCompressedInRAM());
3846 TSize sizeInPixels = uncompressedBitmap->SizeInPixels();
3847 HBufC8* vertScanLine = HBufC8::NewLC(sizeInPixels.iHeight * 4);
3848 TPtr8 p = vertScanLine->Des();
3851 for(TInt i=0;i<TInt(sizeof(displayMode)/sizeof(displayMode[0]));i++)
3853 time = User::TickCount();
3854 for(TInt j=0;j<sizeInPixels.iWidth;j++)
3856 uncompressedBitmap->GetVerticalScanLine(des, j, displayMode[i]);
3858 INFO_PRINTF3(_L("Vert. line. Mode=%d, Time=%d\r\n"), displayMode[i], User::TickCount() - time);
3860 CleanupStack::PopAndDestroy(vertScanLine);
3861 CleanupStack::PopAndDestroy(uncompressedBitmap);
3866 GRAPHICS-FBSERV-0545
3869 Test to verify defect DEF071843
3874 Creates a test bitmap. Initializes it
3875 with test data using SetScanLine. Saves
3876 bitmap and then reloads it and compares
3877 it against expected bitmap.
3879 @SYMTestExpectedResults
3882 void CTBitmap::DEF071843_16MAL()
3884 INFO_PRINTF1(_L("DEF071843 fix test. Saving and loading 16MA 32bpp bitmap."));
3885 // Create test bitmap
3886 CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
3887 CleanupStack::PushL(bmp);
3888 const TInt width = 12;
3889 const TSize size(width, 8);
3890 User::LeaveIfError(bmp->Create(size, EColor16MA));
3892 //Test bitmap data - 8 rows of 12 pixels each containing various run lengths
3893 TUint8 colorVal0[width * 4] = // runs: 12
3894 // 0 1 2 3 4 5 6 7 8 9 10 11
3895 {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
3896 TUint8 colorVal1[width * 4] = // runs: 1 1 1 1 1 1 1 1 1 1 1 1
3897 // 0 1 2 3 4 5 6 7 8 9 10 11
3898 {0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3, 4,4,4,4, 5,5,5,5, 6,6,6,6, 7,7,7,7, 8,8,8,8, 9,9,9,9, 10,10,10,10, 11,11,11,11};
3899 TUint8 colorVal2[width * 4] = // runs: 1 1 2 1 1 3 1 1 1
3900 // 0 1 2 3 4 5 6 7 8 9 10 11
3901 {0,0,0,0, 1,1,1,1, 2,2,2,2, 2,2,2,2, 3,3,3,3, 4,4,4,4, 5,5,5,5, 5,5,5,5, 5,5,5,5, 6,6,6,6, 7,7,7,7, 8,8,8,8};
3902 TUint8 colorVal3[width * 4] = // runs: 1 2 1 3 1 4
3903 // 0 1 2 3 4 5 6 7 8 9 10 11
3904 {0,0,0,0, 1,1,1,1, 1,1,1,1, 2,2,2,2, 3,3,3,3, 3,3,3,3, 3,3,3,3, 4,4,4,4, 5,5,5,5, 5,5,5,5, 5,5,5,5, 5,5,5,5};
3905 TUint8 colorVal4[width * 4] = // runs: 2 1 2 2 2 3
3906 // 0 1 2 3 4 5 6 7 8 9 10 11
3907 {0,0,0,0, 0,0,0,0, 1,1,1,1, 2,2,2,2, 2,2,2,2, 3,3,3,3, 3,3,3,3, 4,4,4,4, 4,4,4,4, 5,5,5,5, 5,5,5,5, 5,5,5,5};
3908 TUint8 colorVal5[width * 4] = // runs: 3 1 3 2 3
3909 // 0 1 2 3 4 5 6 7 8 9 10 11
3910 {0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,1, 2,2,2,2, 2,2,2,2, 2,2,2,2, 3,3,3,3, 3,3,3,3, 4,4,4,4, 4,4,4,4, 4,4,4,4};
3911 TUint8 colorVal6[width * 4] = // runs: 4 1 1 1 1 4
3912 // 0 1 2 3 4 5 6 7 8 9 10 11
3913 {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3, 4,4,4,4, 5,5,5,5, 5,5,5,5, 5,5,5,5, 5,5,5,5};
3914 TUint8 colorVal7[width * 4] = // runs: 1 1 1 1 4 1 1 1 1
3915 // 0 1 2 3 4 5 6 7 8 9 10 11
3916 {0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 5,5,5,5, 6,6,6,6, 7,7,7,7, 8,8,8,8};
3918 //Initialize test bitmap
3919 TPtr8 line0(colorVal0, width * 4, width * 4);
3920 bmp->SetScanLine(line0, 0);
3921 TPtr8 line1(colorVal1, width * 4, width * 4);
3922 bmp->SetScanLine(line1, 1);
3923 TPtr8 line2(colorVal2, width * 4, width * 4);
3924 bmp->SetScanLine(line2, 2);
3925 TPtr8 line3(colorVal3, width * 4, width * 4);
3926 bmp->SetScanLine(line3, 3);
3927 TPtr8 line4(colorVal4, width * 4, width * 4);
3928 bmp->SetScanLine(line4, 4);
3929 TPtr8 line5(colorVal5, width * 4, width * 4);
3930 bmp->SetScanLine(line5, 5);
3931 TPtr8 line6(colorVal6, width * 4, width * 4);
3932 bmp->SetScanLine(line6, 6);
3933 TPtr8 line7(colorVal7, width * 4, width * 4);
3934 bmp->SetScanLine(line7, 7);
3936 // Save bitmap then reload and compare
3937 _LIT(KTest16MABmpFile, "c:\\test16ma.mbm");
3938 bmp->Save(KTest16MABmpFile);
3940 CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
3941 CleanupStack::PushL(bmp2);
3942 TInt err = bmp2->Load(KTest16MABmpFile);
3943 TEST2(err, KErrNone);
3945 CompareBitmaps((CFbsBitmapEx&)*bmp, (CFbsBitmapEx&)*bmp2,EColor16MA);
3947 // Destroy test bitmaps
3948 CleanupStack::PopAndDestroy(2, bmp); // bmp2
3953 GRAPHICS-FBSERV-0546
3956 Test to verify defect DEF071843
3961 Creates a test bitmap. Initializes it
3962 with test data using SetScanLine. Saves
3963 bitmap and then reloads it and compares
3964 it against expected bitmap.
3966 @SYMTestExpectedResults
3969 void CTBitmap::DEF071843_16MUL()
3971 INFO_PRINTF1(_L("DEF071843 fix test. Compression improvements for 16MU 32bpp bitmap."));
3972 // Create test bitmap
3973 CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
3974 CleanupStack::PushL(bmp);
3975 const TInt width = 12;
3976 const TSize size(width, 8);
3977 User::LeaveIfError(bmp->Create(size, EColor16MU));
3979 //Test bitmap data - 8 rows of 12 pixels each containing various run lengths
3980 //Format is b,g,r,a where a (alpha) is unused, hence 255.
3981 TUint8 colorVal0[width * 4] = // runs: 12
3982 // 0 1 2 3 4 5 6 7 8 9 10 11
3983 {0,0,0,255, 0,0,0,255, 0,0,0,255, 0,0,0,255, 0,0,0,255, 0,0,0,255, 0,0,0,255, 0,0,0,255, 0,0,0,255, 0,0,0,255, 0,0,0,255, 0,0,0,255};
3984 TUint8 colorVal1[width * 4] = // runs: 1 1 1 1 1 1 1 1 1 1 1 1
3985 // 0 1 2 3 4 5 6 7 8 9 10 11
3986 {0,0,0,255, 1,1,1,255, 2,2,2,255, 3,3,3,255, 4,4,4,255, 5,5,5,255, 6,6,6,255, 7,7,7,255, 8,8,8,255, 9,9,9,255, 10,10,10,255, 11,11,11,255};
3987 TUint8 colorVal2[width * 4] = // runs: 1 1 2 1 1 3 1 1 1
3988 // 0 1 2 3 4 5 6 7 8 9 10 11
3989 {0,0,0,255, 1,1,1,255, 2,2,2,255, 2,2,2,255, 3,3,3,255, 4,4,4,255, 5,5,5,255, 5,5,5,255, 5,5,5,255, 6,6,6,255, 7,7,7,255, 8,8,8,255};
3990 TUint8 colorVal3[width * 4] = // runs: 1 2 1 3 1 4
3991 // 0 1 2 3 4 5 6 7 8 9 10 11
3992 {0,0,0,255, 1,1,1,255, 1,1,1,255, 2,2,2,255, 3,3,3,255, 3,3,3,255, 3,3,3,255, 4,4,4,255, 5,5,5,255, 5,5,5,255, 5,5,5,255, 5,5,5,255};
3993 TUint8 colorVal4[width * 4] = // runs: 2 1 2 2 2 3
3994 // 0 1 2 3 4 5 6 7 8 9 10 11
3995 {0,0,0,255, 0,0,0,255, 1,1,1,255, 2,2,2,255, 2,2,2,255, 3,3,3,255, 3,3,3,255, 4,4,4,255, 4,4,4,255, 5,5,5,255, 5,5,5,255, 5,5,5,255};
3996 TUint8 colorVal5[width * 4] = // runs: 3 1 3 2 3
3997 // 0 1 2 3 4 5 6 7 8 9 10 11
3998 {0,0,0,255, 0,0,0,255, 0,0,0,255, 1,1,1,255, 2,2,2,255, 2,2,2,255, 2,2,2,255, 3,3,3,255, 3,3,3,255, 4,4,4,255, 4,4,4,255, 4,4,4,255};
3999 TUint8 colorVal6[width * 4] = // runs: 4 1 1 1 1 4
4000 // 0 1 2 3 4 5 6 7 8 9 10 11
4001 {0,0,0,255, 0,0,0,255, 0,0,0,255, 0,0,0,255, 1,1,1,255, 2,2,2,255, 3,3,3,255, 4,4,4,255, 5,5,5,255, 5,5,5,255, 5,5,5,255, 5,5,5,255};
4002 TUint8 colorVal7[width * 4] = // runs: 1 1 1 1 4 1 1 1 1
4003 // 0 1 2 3 4 5 6 7 8 9 10 11
4004 {0,0,0,255, 1,1,1,255, 2,2,2,255, 3,3,3,255, 4,4,4,255, 4,4,4,255, 4,4,4,255, 4,4,4,255, 5,5,5,255, 6,6,6,255, 7,7,7,255, 8,8,8,255};
4006 //Initialize test bitmap
4007 TPtr8 line0(colorVal0, width * 4, width * 4);
4008 bmp->SetScanLine(line0, 0);
4009 TPtr8 line1(colorVal1, width * 4, width * 4);
4010 bmp->SetScanLine(line1, 1);
4011 TPtr8 line2(colorVal2, width * 4, width * 4);
4012 bmp->SetScanLine(line2, 2);
4013 TPtr8 line3(colorVal3, width * 4, width * 4);
4014 bmp->SetScanLine(line3, 3);
4015 TPtr8 line4(colorVal4, width * 4, width * 4);
4016 bmp->SetScanLine(line4, 4);
4017 TPtr8 line5(colorVal5, width * 4, width * 4);
4018 bmp->SetScanLine(line5, 5);
4019 TPtr8 line6(colorVal6, width * 4, width * 4);
4020 bmp->SetScanLine(line6, 6);
4021 TPtr8 line7(colorVal7, width * 4, width * 4);
4022 bmp->SetScanLine(line7, 7);
4024 // Save bitmap then reload and compare
4025 _LIT(KTest16MUBmpFile, "c:\\test16mu.mbm");
4026 bmp->Save(KTest16MUBmpFile);
4028 CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
4029 CleanupStack::PushL(bmp2);
4030 TInt err = bmp2->Load(KTest16MUBmpFile);
4031 TEST2(err, KErrNone);
4033 CompareBitmaps((CFbsBitmapEx&)*bmp, (CFbsBitmapEx&)*bmp2, EColor16MU);
4035 // Destroy test bitmaps
4036 CleanupStack::PopAndDestroy(2, bmp); // bmp2
4041 GRAPHICS-FBSERV-0547
4044 Test to verify defect DEF071843
4049 Creates a test bitmap. Initializes it
4050 with test data using SetScanLine. Saves
4051 bitmap and then reloads it and compares
4052 it against expected bitmap.
4054 @SYMTestExpectedResults
4057 void CTBitmap::DEF071843_16ML()
4059 INFO_PRINTF1(_L("DEF071843 fix test. Compression improvements for 16M 24bpp bitmap."));
4060 // Create test bitmap
4061 CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
4062 CleanupStack::PushL(bmp);
4063 const TInt width = 12;
4064 const TSize size(width, 8);
4065 User::LeaveIfError(bmp->Create(size, EColor16M));
4067 //Test bitmap data - 8 rows of 12 pixels each containing various run lengths
4068 TUint8 colorVal0[width * 3] = // runs: 12
4069 // 0 1 2 3 4 5 6 7 8 9 10 11
4070 {0,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0};
4071 TUint8 colorVal1[width * 3] = // runs: 1 1 1 1 1 1 1 1 1 1 1 1
4072 // 0 1 2 3 4 5 6 7 8 9 10 11
4073 {0,0,0, 1,1,1, 2,2,2, 3,3,3, 4,4,4, 5,5,5, 6,6,6, 7,7,7, 8,8,8, 9,9,9, 10,10,10, 11,11,11};
4074 TUint8 colorVal2[width * 3] = // runs: 1 1 2 1 1 3 1 1 1
4075 // 0 1 2 3 4 5 6 7 8 9 10 11
4076 {0,0,0, 1,1,1, 2,2,2, 2,2,2, 3,3,3, 4,4,4, 5,5,5, 5,5,5, 5,5,5, 6,6,6, 7,7,7, 8,8,8};
4077 TUint8 colorVal3[width * 3] = // runs: 1 2 1 3 1 4
4078 // 0 1 2 3 4 5 6 7 8 9 10 11
4079 {0,0,0, 1,1,1, 1,1,1, 2,2,2, 3,3,3, 3,3,3, 3,3,3, 4,4,4, 5,5,5, 5,5,5, 5,5,5, 5,5,5};
4080 TUint8 colorVal4[width * 3] = // runs: 2 1 2 2 2 3
4081 // 0 1 2 3 4 5 6 7 8 9 10 11
4082 {0,0,0, 0,0,0, 1,1,1, 2,2,2, 2,2,2, 3,3,3, 3,3,3, 4,4,4, 4,4,4, 5,5,5, 5,5,5, 5,5,5};
4083 TUint8 colorVal5[width * 3] = // runs: 3 1 3 2 3
4084 // 0 1 2 3 4 5 6 7 8 9 10 11
4085 {0,0,0, 0,0,0, 0,0,0, 1,1,1, 2,2,2, 2,2,2, 2,2,2, 3,3,3, 3,3,3, 4,4,4, 4,4,4, 4,4,4};
4086 TUint8 colorVal6[width * 3] = // runs: 4 1 1 1 1 4
4087 // 0 1 2 3 4 5 6 7 8 9 10 11
4088 {0,0,0, 0,0,0, 0,0,0, 0,0,0, 1,1,1, 2,2,2, 3,3,3, 4,4,4, 5,5,5, 5,5,5, 5,5,5, 5,5,5};
4089 TUint8 colorVal7[width * 3] = // runs: 1 1 1 1 4 1 1 1 1
4090 // 0 1 2 3 4 5 6 7 8 9 10 11
4091 {0,0,0, 1,1,1, 2,2,2, 3,3,3, 4,4,4, 4,4,4, 4,4,4, 4,4,4, 5,5,5, 6,6,6, 7,7,7, 8,8,8};
4093 //Initialize test bitmap
4094 TPtr8 line0(colorVal0, width * 3, width * 3);
4095 bmp->SetScanLine(line0, 0);
4096 TPtr8 line1(colorVal1, width * 3, width * 3);
4097 bmp->SetScanLine(line1, 1);
4098 TPtr8 line2(colorVal2, width * 3, width * 3);
4099 bmp->SetScanLine(line2, 2);
4100 TPtr8 line3(colorVal3, width * 3, width * 3);
4101 bmp->SetScanLine(line3, 3);
4102 TPtr8 line4(colorVal4, width * 3, width * 3);
4103 bmp->SetScanLine(line4, 4);
4104 TPtr8 line5(colorVal5, width * 3, width * 3);
4105 bmp->SetScanLine(line5, 5);
4106 TPtr8 line6(colorVal6, width * 3, width * 3);
4107 bmp->SetScanLine(line6, 6);
4108 TPtr8 line7(colorVal7, width * 3, width * 3);
4109 bmp->SetScanLine(line7, 7);
4111 // Save bitmap then reload and compare
4112 _LIT(KTest16MBmpFile, "c:\\test16m.mbm");
4113 bmp->Save(KTest16MBmpFile);
4115 CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
4116 CleanupStack::PushL(bmp2);
4117 TInt err = bmp2->Load(KTest16MBmpFile);
4118 TEST2(err, KErrNone);
4120 CompareBitmaps((CFbsBitmapEx&)*bmp, (CFbsBitmapEx&)*bmp2, EColor16M);
4122 // Destroy test bitmaps
4123 CleanupStack::PopAndDestroy(2, bmp); // bmp2
4128 GRAPHICS-FBSERV-0548
4131 Test to verify defect DEF074623 (Alpha bit)
4137 @SYMTestExpectedResults
4140 void CTBitmap::DEF074623_16MAL()
4142 INFO_PRINTF1(_L("DEF074623 fix test For Alpha Bit."));
4143 // Create test bitmap
4144 CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
4145 CleanupStack::PushL(bmp);
4146 const TInt iBitmapWidth = 10;
4147 const TInt iBitmapHeight = 10;
4152 TSize rectSize(iBitmapWidth,iBitmapHeight);
4153 TRect srcRect(0,0,iBitmapWidth,iBitmapHeight);
4154 User::LeaveIfError(bmp->Create(rectSize, EColor16MU));
4155 srcRect.SetSize(rectSize);
4156 TBitmapUtil bmpUtil(bmp);
4157 bmpUtil.Begin(TPoint(0,0));
4158 for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex)
4163 bmpUtil.SetPos(TPoint(0,rowIndex));
4164 for (colIndex=0;colIndex<iBitmapWidth;++colIndex)
4166 TRgb rgb(red,green,blue);
4167 bmpUtil.SetPixel(rgb.Color16MA());
4188 bmp->SetDisplayMode(EColor16MA);
4190 for(TInt yy = 0; yy < iBitmapHeight; yy++)
4193 for(TInt xx = 0; xx < iBitmapWidth; xx++)
4196 bmp->GetPixel(bmpcol,TPoint(xx,yy));
4197 TEST(bmpcol.Alpha() == 255);
4201 CleanupStack::PopAndDestroy(bmp);
4208 GRAPHICS-FBSERV-0549
4211 Test to verify defect DEF095361
4216 Creates a test bitmap. Initializes it
4217 with test data using SetScanLine. Compresses
4218 the bitmap. Saves bitmap and then reloads it
4219 and compares it against expected bitmap.
4220 Simulates heap allocation failure of memory.
4222 @SYMTestExpectedResults
4225 void CTBitmap::DEF095361_16MAL()
4227 INFO_PRINTF1(_L("DEF095361 fix test. Compressing, Saving and loading 16MA 32bpp bitmap."));
4228 // Create test bitmap
4229 CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
4230 CleanupStack::PushL(bmp);
4231 const TInt width = 12;
4232 const TSize size(width, 8);
4233 User::LeaveIfError(bmp->Create(size, EColor16MA));
4235 //Test bitmap data - 8 rows of 12 pixels each containing various run lengths
4236 TUint8 colorVal0[width * 4] = // runs: 12
4237 // 0 1 2 3 4 5 6 7 8 9 10 11
4238 {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
4239 TUint8 colorVal1[width * 4] = // runs: 1 1 1 1 1 1 1 1 1 1 1 1
4240 // 0 1 2 3 4 5 6 7 8 9 10 11
4241 {0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3, 4,4,4,4, 5,5,5,5, 6,6,6,6, 7,7,7,7, 8,8,8,8, 9,9,9,9, 10,10,10,10, 11,11,11,11};
4242 TUint8 colorVal2[width * 4] = // runs: 1 1 2 1 1 3 1 1 1
4243 // 0 1 2 3 4 5 6 7 8 9 10 11
4244 {0,0,0,0, 1,1,1,1, 2,2,2,2, 2,2,2,2, 3,3,3,3, 4,4,4,4, 5,5,5,5, 5,5,5,5, 5,5,5,5, 6,6,6,6, 7,7,7,7, 8,8,8,8};
4245 TUint8 colorVal3[width * 4] = // runs: 1 2 1 3 1 4
4246 // 0 1 2 3 4 5 6 7 8 9 10 11
4247 {0,0,0,0, 1,1,1,1, 1,1,1,1, 2,2,2,2, 3,3,3,3, 3,3,3,3, 3,3,3,3, 4,4,4,4, 5,5,5,5, 5,5,5,5, 5,5,5,5, 5,5,5,5};
4248 TUint8 colorVal4[width * 4] = // runs: 2 1 2 2 2 3
4249 // 0 1 2 3 4 5 6 7 8 9 10 11
4250 {0,0,0,0, 0,0,0,0, 1,1,1,1, 2,2,2,2, 2,2,2,2, 3,3,3,3, 3,3,3,3, 4,4,4,4, 4,4,4,4, 5,5,5,5, 5,5,5,5, 5,5,5,5};
4251 TUint8 colorVal5[width * 4] = // runs: 3 1 3 2 3
4252 // 0 1 2 3 4 5 6 7 8 9 10 11
4253 {0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,1, 2,2,2,2, 2,2,2,2, 2,2,2,2, 3,3,3,3, 3,3,3,3, 4,4,4,4, 4,4,4,4, 4,4,4,4};
4254 TUint8 colorVal6[width * 4] = // runs: 4 1 1 1 1 4
4255 // 0 1 2 3 4 5 6 7 8 9 10 11
4256 {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3, 4,4,4,4, 5,5,5,5, 5,5,5,5, 5,5,5,5, 5,5,5,5};
4257 TUint8 colorVal7[width * 4] = // runs: 1 1 1 1 4 1 1 1 1
4258 // 0 1 2 3 4 5 6 7 8 9 10 11
4259 {0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 5,5,5,5, 6,6,6,6, 7,7,7,7, 8,8,8,8};
4261 //Initialize test bitmap
4262 TPtr8 line0(colorVal0, width * 4, width * 4);
4263 bmp->SetScanLine(line0, 0);
4264 TPtr8 line1(colorVal1, width * 4, width * 4);
4265 bmp->SetScanLine(line1, 1);
4266 TPtr8 line2(colorVal2, width * 4, width * 4);
4267 bmp->SetScanLine(line2, 2);
4268 TPtr8 line3(colorVal3, width * 4, width * 4);
4269 bmp->SetScanLine(line3, 3);
4270 TPtr8 line4(colorVal4, width * 4, width * 4);
4271 bmp->SetScanLine(line4, 4);
4272 TPtr8 line5(colorVal5, width * 4, width * 4);
4273 bmp->SetScanLine(line5, 5);
4274 TPtr8 line6(colorVal6, width * 4, width * 4);
4275 bmp->SetScanLine(line6, 6);
4276 TPtr8 line7(colorVal7, width * 4, width * 4);
4277 bmp->SetScanLine(line7, 7);
4279 //Compress bitmap using RLE Compression
4280 bmp->Compress(ERLECompression);
4282 // Save bitmap then reload and compare
4283 _LIT(KTest16MABmpFile, "c:\\testDEF095361_16ma.mbm");
4284 bmp->Save(KTest16MABmpFile);
4286 CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
4287 CleanupStack::PushL(bmp2);
4289 RFbsSession* fbs = RFbsSession::GetSession();
4292 for (count = 1; ; count++)
4294 fbs->SendCommand(EFbsMessDefaultAllocFail,count);
4296 TInt ret = bmp2->Load(KTest16MABmpFile, 0, EFalse);
4298 if (ret == KErrNoMemory)
4302 else if (ret == KErrNone)
4307 TEST2(ret, KErrNone);
4310 fbs->SendCommand(EFbsMessDefaultAllocFail,0);
4313 CompareBitmaps((CFbsBitmapEx&)*bmp, (CFbsBitmapEx&)*bmp2,EColor16MA);
4315 // Destroy test bitmaps
4316 CleanupStack::PopAndDestroy(2, bmp); // bmp2
4319 void CTBitmap::LoadAndCompressBitmapLC(CFbsBitmap*& aBmp, const TDesC& aBmpFile)
4321 aBmp = new (ELeave) CFbsBitmap;
4322 CleanupStack::PushL(aBmp);
4323 TInt err = aBmp->Load(aBmpFile);
4324 TEST2(err, KErrNone);
4325 err = aBmp->Compress();
4326 TEST2(err, KErrNone);
4327 TEST(aBmp->IsCompressedInRAM());
4332 GRAPHICS-FBSERV-0550
4335 Compresses a bitmap containing two lines
4338 Creates a test bitmap with two lines. Compresses it (16 bpp)
4339 and checks if compressed successfully
4341 @SYMTestExpectedResults
4345 void CTBitmap::TwoComprLines()
4347 INFO_PRINTF1(_L("16 bpp compressed bitmap - 2 lines"));
4348 //Create test bitmap
4349 CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
4350 CleanupStack::PushL(bmp);
4351 const TInt width = 3;
4352 const TSize size(width, 2);
4353 User::LeaveIfError(bmp->Create(size, EColor64K));
4355 TUint8 colorVal[width * 2] =
4357 {0x13,0x13, 0x13,0x13, 0x13,0x13};
4358 //Initialize test bitmap
4359 TPtr8 ptr(colorVal, width * 2, width * 2);
4360 bmp->SetScanLine(ptr, 0);
4361 bmp->SetScanLine(ptr, 1);
4362 //Compress test bitmap
4363 User::LeaveIfError(bmp->Compress());
4364 //Check the test data
4365 TUint8 colorVal2[width * 2];
4366 TPtr8 ptr2(colorVal2, width * 2, width * 2);
4368 bmp->GetScanLine(ptr2, TPoint(0, 0), 3, EColor64K);
4370 bmp->GetScanLine(ptr2, TPoint(0, 1), 3, EColor64K);
4372 //Destroy test bitmap and data
4373 CleanupStack::PopAndDestroy(bmp);
4376 void CTBitmap::LoadAndNotCompressBitmapLC(CFbsBitmap*& aBmp, const TDesC& aBmpFile)
4378 aBmp = new (ELeave) CFbsBitmap;
4379 CleanupStack::PushL(aBmp);
4380 TInt err = aBmp->Load(aBmpFile);
4381 TEST2(err, KErrNone);
4386 GRAPHICS-FBSERV-0551
4389 The test verifies the
4390 CFbsBitmap::Compress((TBitmapfileCompressionScheme aScheme) API.
4391 It loads bitmaps from ROM & saves (temporarily) to C-drive.
4392 Then it loads from C-drive into a new bitmap.
4396 @SYMTestExpectedResults
4399 void CTBitmap::TestPaletteCompressionL()
4401 INFO_PRINTF1(_L("Test Palette Compression"));
4402 _LIT(KmbmFileInRom, "z:\\system\\data\\24bitskin.mbm");
4403 RFbsSession* fbs = RFbsSession::GetSession();
4405 CFbsBitmap* fbsCompressed = new(ELeave) CFbsBitmap;
4406 CFbsBitmap* fbsUnCompressed = new(ELeave) CFbsBitmap;
4407 CleanupStack::PushL(fbsCompressed);
4408 CleanupStack::PushL(fbsUnCompressed);
4409 TEST2(fbsUnCompressed->Load(KmbmFileInRom, 0, EFalse), KErrNone);
4410 fbsUnCompressed->Save(KTempFilename);
4412 TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
4413 //compress bitmap (force foreground compression)
4414 fbsCompressed->Compress(EPaletteCompression);
4415 fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
4416 //test that palette compression occurred
4417 TEST(fbsCompressed->Header().iCompression == EGenericPaletteCompression);
4418 //compare with original
4419 INFO_PRINTF1(_L("Compare Palette Compressed bmp with original"));
4420 CompareBitmaps((CFbsBitmapEx&)*fbsCompressed, (CFbsBitmapEx&)*fbsUnCompressed, EColor16M);
4421 CleanupStack::PopAndDestroy(2);
4422 iFs.Delete(KTempFilename);
4424 //Test that the RLE option works.
4425 //------------------------------------
4427 fbsCompressed = new(ELeave) CFbsBitmap ;
4428 fbsUnCompressed = new(ELeave) CFbsBitmap ;
4429 CleanupStack::PushL(fbsCompressed);
4430 CleanupStack::PushL(fbsUnCompressed);
4431 TEST2(fbsUnCompressed->Load(KmbmFileInRom, 0, EFalse), KErrNone);
4432 fbsUnCompressed->Save(KTempFilename);
4434 TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
4435 //compress bitmap (force foreground compression)
4436 fbsCompressed->Compress(ERLECompression);
4437 fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
4438 //test that RLE compression occurred
4439 TEST(fbsCompressed->Header().iCompression == ETwentyFourBitRLECompression);
4440 CleanupStack::PopAndDestroy(2);
4441 iFs.Delete(KTempFilename);
4443 //Test that unsuitable bitmaps are not palette compressed (too many colours).
4444 //----------------------------------------------------------------------------------------
4445 _LIT(KmbmMultiColourMBMInRom, "z:\\system\\data\\24bit.mbm");
4447 fbsCompressed = new(ELeave) CFbsBitmap;
4448 fbsUnCompressed = new(ELeave) CFbsBitmap;
4449 CleanupStack::PushL(fbsCompressed);
4450 CleanupStack::PushL(fbsUnCompressed);
4451 TEST2(fbsUnCompressed->Load(KmbmMultiColourMBMInRom, 0, EFalse), KErrNone);
4452 fbsUnCompressed->Save(KTempFilename);
4454 TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
4455 //compress bitmap (force foreground compression)
4456 fbsCompressed->Compress(EPaletteCompression);
4457 fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
4458 //test that palette compression occurred
4459 TEST(fbsCompressed->Header().iCompression != EGenericPaletteCompression);
4460 CleanupStack::PopAndDestroy(2);
4461 iFs.Delete(KTempFilename);
4463 //Test that unsuitable bitmaps are not palette compressed (too few BPP)
4464 //---------------------------------------------------------------------------------
4466 fbsCompressed = new(ELeave) CFbsBitmap ;
4467 fbsUnCompressed = new(ELeave) CFbsBitmap ;
4468 CleanupStack::PushL(fbsCompressed);
4469 CleanupStack::PushL(fbsUnCompressed);
4470 TEST2(fbsUnCompressed->Load(KmbmMultiColourMBMInRom, 0, EFalse), KErrNone);
4471 fbsUnCompressed->Save(KTempFilename);
4473 TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
4474 //compress bitmap (force foreground compression)
4475 fbsCompressed->Compress(EPaletteCompression);
4476 fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
4477 //test that palette compression occurred
4478 TEST(fbsCompressed->Header().iCompression != EGenericPaletteCompression);
4479 CleanupStack::PopAndDestroy(2);
4480 iFs.Delete(KTempFilename);
4483 // Test that 12bitmap cannot pallete compress but will fall back to RLE
4484 // --------------------------------------------------------------------
4485 _LIT(Kmbm12BitMBMInRom, "z:\\system\\data\\file.mbm");
4486 fbsCompressed = new(ELeave) CFbsBitmap ;
4487 fbsUnCompressed = new(ELeave) CFbsBitmap ;
4488 CleanupStack::PushL(fbsCompressed);
4489 CleanupStack::PushL(fbsUnCompressed);
4490 TEST2(fbsUnCompressed->Load(Kmbm12BitMBMInRom, 0, EFalse), KErrNone);
4491 fbsUnCompressed->Save(KTempFilename);
4493 TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
4494 //compress bitmap (force foreground compression)
4495 fbsCompressed->Compress(EPaletteCompressionWithRLEFallback);
4496 fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
4497 TBitmapfileCompression comp = fbsCompressed->Header().iCompression;
4498 //test that palette compression occurred
4499 TEST(fbsCompressed->Header().iCompression != EGenericPaletteCompression);
4500 CleanupStack::PopAndDestroy(2);
4501 iFs.Delete(KTempFilename);
4504 // Test that multi colour bitmap cannot pallete compress but will fall back to RLE
4505 // -------------------------------------------------------------------------------
4506 fbsCompressed = new(ELeave) CFbsBitmap ;
4507 fbsUnCompressed = new(ELeave) CFbsBitmap ;
4508 CleanupStack::PushL(fbsCompressed);
4509 CleanupStack::PushL(fbsUnCompressed);
4510 TEST2(fbsUnCompressed->Load(KmbmMultiColourMBMInRom, 0, EFalse), KErrNone);
4511 fbsUnCompressed->Save(KTempFilename);
4513 TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
4514 //compress bitmap (force foreground compression)
4515 fbsCompressed->Compress(EPaletteCompressionWithRLEFallback);
4516 fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
4517 comp = fbsCompressed->Header().iCompression;
4518 //test that palette compression occurred
4519 TEST(fbsCompressed->Header().iCompression != EGenericPaletteCompression);
4520 CleanupStack::PopAndDestroy(2);
4521 iFs.Delete(KTempFilename);
4525 //Test various BPP & bitmap widths
4526 //----------------------------------------
4527 INFO_PRINTF1(_L("Test assorted BPP & colour counts"));
4528 _LIT(Kmbm16NarrowFileInRom, "z:\\system\\data\\16bitskin.mbm");
4529 TestAssortedBPPandColourDepthL(Kmbm16NarrowFileInRom, fbs);
4530 _LIT(Kmbm24bit6colFileInRom, "z:\\system\\data\\24bit6col.mbm");
4531 TestAssortedBPPandColourDepthL(Kmbm24bit6colFileInRom, fbs);
4532 _LIT(Kmbm24bit2colFileInRom, "z:\\system\\data\\24bit2col.mbm");
4533 TestAssortedBPPandColourDepthL(Kmbm24bit2colFileInRom, fbs);
4534 _LIT(Kmbm24bit3colFileInRom, "z:\\system\\data\\24bit3col.mbm");
4535 TestAssortedBPPandColourDepthL(Kmbm24bit3colFileInRom, fbs);
4536 _LIT(Kmbm24bit20colFileInRom, "z:\\system\\data\\24bit20col.mbm");
4537 TestAssortedBPPandColourDepthL(Kmbm24bit20colFileInRom, fbs);
4538 _LIT(Kmbm16bit6colFileInRom, "z:\\system\\data\\16bit6col.mbm");
4539 TestAssortedBPPandColourDepthL(Kmbm16bit6colFileInRom, fbs);
4540 _LIT(Kmbm16bit2colFileInRom, "z:\\system\\data\\16bit2col.mbm");
4541 TestAssortedBPPandColourDepthL(Kmbm16bit2colFileInRom, fbs);
4542 _LIT(Kmbm16bit3colFileInRom, "z:\\system\\data\\16bit3col.mbm");
4543 TestAssortedBPPandColourDepthL(Kmbm16bit3colFileInRom, fbs);
4544 _LIT(Kmbm16bit20colFileInRom, "z:\\system\\data\\16bit20col.mbm");
4545 TestAssortedBPPandColourDepthL(Kmbm16bit20colFileInRom, fbs);
4546 _LIT(Kmbm32BitSkinFileInRom, "z:\\system\\data\\32bitskin.mbm");
4547 TestAssortedBPPandColourDepthL(Kmbm32BitSkinFileInRom, fbs);
4548 _LIT(Kmbm32bit6colFileInRom, "z:\\system\\data\\32bit6col.mbm");
4549 TestAssortedBPPandColourDepthL(Kmbm32bit6colFileInRom, fbs);
4550 _LIT(Kmbm32bit2colFileInRom, "z:\\system\\data\\32bit2col.mbm");
4551 TestAssortedBPPandColourDepthL(Kmbm32bit2colFileInRom, fbs);
4552 _LIT(Kmbm32bit3colFileInRom, "z:\\system\\data\\32bit3col.mbm");
4553 TestAssortedBPPandColourDepthL(Kmbm32bit3colFileInRom, fbs);
4554 _LIT(Kmbm32bit20colFileInRom, "z:\\system\\data\\32bit20col.mbm");
4555 TestAssortedBPPandColourDepthL(Kmbm32bit20colFileInRom, fbs);
4556 INFO_PRINTF1(_L("Test Palette Compression - COMPLETE"));
4559 void CTBitmap::TestAssortedBPPandColourDepthL(const TDesC& aFilename, RFbsSession* aFbs)
4562 CFbsBitmap* fbsCompressed = new (ELeave) CFbsBitmap ;
4563 CFbsBitmap* fbsUnCompressed = new (ELeave) CFbsBitmap ;
4564 CleanupStack::PushL(fbsCompressed);
4565 CleanupStack::PushL(fbsUnCompressed);
4566 TEST2(fbsUnCompressed->Load(aFilename, 0, EFalse), KErrNone);
4567 fbsUnCompressed->Save(KTempFilename);
4569 TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
4570 //compress bitmap (force foreground compression)
4571 fbsCompressed->Compress(EPaletteCompression);
4572 aFbs->SendCommand(EFbsCompress, 0); //force background compression to execute
4573 //test that palette compression occurred
4574 TEST(fbsCompressed->Header().iCompression == EGenericPaletteCompression);
4575 //compare with original
4576 INFO_PRINTF1(_L("Compare Palette Compressed bmp with original"));
4577 CompareBitmaps((CFbsBitmapEx&)*fbsCompressed, (CFbsBitmapEx&)*fbsUnCompressed, EColor16M);
4578 CleanupStack::PopAndDestroy(2);
4579 iFs.Delete(KTempFilename);
4584 GRAPHICS-FBSERV-0552
4587 The test verifies the
4588 CFbsBitmap::CompressInBackground((TBitmapfileCompressionScheme aScheme)
4589 API. It loads bitmaps from ROM & saves (temporarily) to C-drive.
4590 Then it loads from C-drive into a new bitmap.
4594 @SYMTestExpectedResults
4597 void CTBitmap::TestSynchronousBackgroundPaletteCompressionL()
4599 INFO_PRINTF1(_L("Test Background Palette Compression"));
4600 _LIT(KmbmFileInRom, "z:\\system\\data\\24bitskin.mbm");
4601 RFbsSession* fbs = RFbsSession::GetSession();
4603 CFbsBitmap* fbsCompressed = new(ELeave) CFbsBitmap ;
4604 CFbsBitmap* fbsUnCompressed = new(ELeave) CFbsBitmap ;
4605 CleanupStack::PushL(fbsCompressed);
4606 CleanupStack::PushL(fbsUnCompressed);
4607 TEST2(fbsUnCompressed->Load(KmbmFileInRom, 0, EFalse), KErrNone);
4608 fbsUnCompressed->Save(KTempFilename);
4610 TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
4611 //compress bitmap (force immediate compression)
4612 fbsCompressed->CompressInBackground(EPaletteCompression);
4613 fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
4614 //test that palette compression occurred
4615 TEST(fbsCompressed->Header().iCompression == EGenericPaletteCompression);
4616 //compare with original
4617 INFO_PRINTF1(_L("Compare Palette Compressed bmp with original"));
4618 CompareBitmaps((CFbsBitmapEx&)*fbsCompressed, (CFbsBitmapEx&)*fbsUnCompressed, EColor16M);
4619 CleanupStack::PopAndDestroy(2);
4620 iFs.Delete(KTempFilename);
4622 //Test that the RLE option works.
4623 //------------------------------------
4625 fbsCompressed = new(ELeave) CFbsBitmap ;
4626 fbsUnCompressed = new(ELeave) CFbsBitmap ;
4627 CleanupStack::PushL(fbsCompressed);
4628 CleanupStack::PushL(fbsUnCompressed);
4629 TEST2(fbsUnCompressed->Load(KmbmFileInRom, 0, EFalse), KErrNone);
4630 fbsUnCompressed->Save(KTempFilename);
4632 TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
4633 //compress bitmap (force immediate compression)
4634 fbsCompressed->CompressInBackground(ERLECompression);
4635 fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
4636 //test that RLE compression occurred
4637 TEST(fbsCompressed->Header().iCompression == ETwentyFourBitRLECompression);
4638 CleanupStack::PopAndDestroy(2);
4639 iFs.Delete(KTempFilename);
4641 //Test that unsuitable bitmaps are not palette compressed (too many colours).
4642 //----------------------------------------------------------------------------------------
4643 _LIT(KmbmMultiColourMBMInRom, "z:\\system\\data\\24bit.mbm");
4645 fbsCompressed = new(ELeave) CFbsBitmap ;
4646 fbsUnCompressed = new(ELeave) CFbsBitmap ;
4647 CleanupStack::PushL(fbsCompressed);
4648 CleanupStack::PushL(fbsUnCompressed);
4649 TEST2(fbsUnCompressed->Load(KmbmMultiColourMBMInRom, 0, EFalse), KErrNone);
4650 fbsUnCompressed->Save(KTempFilename);
4652 TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
4653 //compress bitmap (force immediate compression)
4654 fbsCompressed->CompressInBackground(EPaletteCompression);
4655 fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
4656 //test that palette compression occurred
4657 TEST(fbsCompressed->Header().iCompression != EGenericPaletteCompression);
4658 CleanupStack::PopAndDestroy(2);
4659 iFs.Delete(KTempFilename);
4661 //Test that unsuitable bitmaps are not palette compressed (too few BPP)
4662 //---------------------------------------------------------------------------------
4664 fbsCompressed = new(ELeave) CFbsBitmap ;
4665 fbsUnCompressed = new(ELeave) CFbsBitmap ;
4666 CleanupStack::PushL(fbsCompressed);
4667 CleanupStack::PushL(fbsUnCompressed);
4668 TEST2(fbsUnCompressed->Load(KmbmMultiColourMBMInRom, 0, EFalse), KErrNone);
4669 fbsUnCompressed->Save(KTempFilename);
4671 TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
4672 //compress bitmap (force immediate compression)
4673 fbsCompressed->CompressInBackground(EPaletteCompression);
4674 fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
4675 //test that palette compression occurred
4676 TEST(fbsCompressed->Header().iCompression != EGenericPaletteCompression);
4677 CleanupStack::PopAndDestroy(2);
4678 iFs.Delete(KTempFilename);
4679 INFO_PRINTF1(_L("Test Background Palette Compression - COMPLETE"));
4684 GRAPHICS-FBSERV-0553
4687 The test verifies the
4688 CFbsBitmap::CompressInBackground(TRequestStatus& aRequestStatus, TBitmapfileCompressionScheme aScheme)
4689 API. It loads bitmaps from ROM & saves (temporarily) to C-drive.
4690 Then it loads from C-drive into a new bitmap.
4694 @SYMTestExpectedResults
4697 void CTBitmap::TestAsynchronousBackgroundPaletteCompressionL()
4699 INFO_PRINTF1(_L("Test Asynch background Palette Compression"));
4700 TRequestStatus status ;
4701 _LIT(KmbmFileInRom, "z:\\system\\data\\24bitskin.mbm");
4702 RFbsSession* fbs = RFbsSession::GetSession();
4704 CFbsBitmap* fbsCompressed = new(ELeave) CFbsBitmap ;
4705 CFbsBitmap* fbsUnCompressed = new(ELeave) CFbsBitmap ;
4706 CleanupStack::PushL(fbsCompressed);
4707 CleanupStack::PushL(fbsUnCompressed);
4708 TEST2(fbsUnCompressed->Load(KmbmFileInRom, 0, EFalse), KErrNone);
4709 fbsUnCompressed->Save(KTempFilename);
4711 TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
4712 //compress bitmap (force immediate compression)
4713 fbsCompressed->CompressInBackground(status, EPaletteCompression);
4714 fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
4715 User::WaitForRequest(status);
4716 TEST2(status.Int(), KErrNone);
4717 //test that palette compression occurred
4718 TEST(fbsCompressed->Header().iCompression == EGenericPaletteCompression);
4719 //compare with original
4720 INFO_PRINTF1(_L("Compare Palette Compressed bmp with original"));
4721 CompareBitmaps((CFbsBitmapEx&)*fbsCompressed, (CFbsBitmapEx&)*fbsUnCompressed, EColor16M);
4722 CleanupStack::PopAndDestroy(2);
4723 iFs.Delete(KTempFilename);
4725 //Test that the RLE option works.
4726 //------------------------------------
4728 fbsCompressed = new (ELeave) CFbsBitmap ;
4729 fbsUnCompressed = new (ELeave) CFbsBitmap ;
4730 CleanupStack::PushL(fbsCompressed);
4731 CleanupStack::PushL(fbsUnCompressed);
4732 TEST2(fbsUnCompressed->Load(KmbmFileInRom, 0, EFalse), KErrNone);
4733 fbsUnCompressed->Save(KTempFilename);
4735 TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
4736 //compress bitmap (force immediate compression)
4737 fbsCompressed->CompressInBackground(status, ERLECompression);
4738 fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
4739 User::WaitForRequest(status);
4740 TEST2(status.Int(), KErrNone);
4741 //test that RLE compression occurred
4742 TEST(fbsCompressed->Header().iCompression == ETwentyFourBitRLECompression);
4743 CleanupStack::PopAndDestroy(2);
4744 iFs.Delete(KTempFilename);
4746 //Test that unsuitable bitmaps are not palette compressed (too many colours).
4747 //----------------------------------------------------------------------------------------
4748 _LIT(KmbmMultiColourMBMInRom, "z:\\system\\data\\24bit.mbm");
4750 fbsCompressed = new (ELeave) CFbsBitmap ;
4751 fbsUnCompressed = new (ELeave) CFbsBitmap ;
4752 CleanupStack::PushL(fbsCompressed);
4753 CleanupStack::PushL(fbsUnCompressed);
4754 TEST2(fbsUnCompressed->Load(KmbmMultiColourMBMInRom, 0, EFalse), KErrNone);
4755 fbsUnCompressed->Save(KTempFilename);
4757 TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
4758 //compress bitmap (force immediate compression)
4759 fbsCompressed->CompressInBackground(status, EPaletteCompression);
4760 fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
4761 User::WaitForRequest(status);
4762 TEST2(status.Int(), KErrNotSupported);
4763 //test that palette compression occurred
4764 TEST(fbsCompressed->Header().iCompression != EGenericPaletteCompression);
4765 CleanupStack::PopAndDestroy(2);
4766 iFs.Delete(KTempFilename);
4768 //Test that unsuitable bitmaps are not palette compressed (too few BPP)
4769 //---------------------------------------------------------------------------------
4771 fbsCompressed = new(ELeave) CFbsBitmap ;
4772 fbsUnCompressed = new(ELeave) CFbsBitmap ;
4773 CleanupStack::PushL(fbsCompressed);
4774 CleanupStack::PushL(fbsUnCompressed);
4775 TEST2(fbsUnCompressed->Load(KmbmMultiColourMBMInRom, 0, EFalse), KErrNone);
4776 fbsUnCompressed->Save(KTempFilename);
4778 TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
4779 //compress bitmap (force immediate compression)
4780 fbsCompressed->CompressInBackground(status, EPaletteCompression);
4781 fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
4782 User::WaitForRequest(status);
4783 TEST2(status.Int(), KErrNotSupported);
4784 //test that palette compression occurred
4785 TEST(fbsCompressed->Header().iCompression != EGenericPaletteCompression);
4786 CleanupStack::PopAndDestroy(2);
4787 iFs.Delete(KTempFilename);
4788 INFO_PRINTF1(_L("Test Asynch background Palette Compressio - COMPLETE"));
4792 @SYMTestCaseID GRAPHICS-FBSERV-0501
4796 @SYMTestPriority Medium
4800 @SYMTestCaseDesc Get all bitmap handles before and after loading a bitmap.
4803 1) Get all bitmap handles and store number of bitmaps obtained
4804 2) Load a new bitmap
4805 3) Get all bitmap handles and store number of bitmaps obtained
4807 @SYMTestExpectedResults
4808 The number of bitmap handles retrieved after loading the bitmap should be one more than prior to loading the bitmap.
4810 void CTBitmap::GetAllBitmapsIdsL()
4812 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
4813 CleanupStack::PushL(bitmap);
4815 RArray <TInt> bitmapHandleArray;
4816 CleanupClosePushL(bitmapHandleArray);
4818 // Get current number of bitmap handles
4819 User::LeaveIfError(bitmap->GetAllBitmapHandles(bitmapHandleArray));
4820 const TInt numBitmapHandles = bitmapHandleArray.Count();
4822 // Load another bitmap
4823 CFbsBitmap* bmp = LoadBitmapLC(KRc_Ram8);
4825 // Get current number of bitmap handles
4826 User::LeaveIfError(bitmap->GetAllBitmapHandles(bitmapHandleArray));
4827 const TInt newNumBitmapHandles = bitmapHandleArray.Count();
4828 TEST(numBitmapHandles == newNumBitmapHandles - 1); // Ensure there is one more bitmap handle from the bitmap we just added
4830 const TInt handle = bmp->Handle();
4832 TInt foundHandle = 0;
4833 for (TInt count = newNumBitmapHandles-1; count>=0; --count)
4835 if (handle == bitmapHandleArray[count])
4840 TEST(foundHandle==1); // Ensure only one instance of this handle is found in the array
4841 CleanupStack::PopAndDestroy(3, bitmap); // bmp, bitmapHandleArray, bitmap
4846 GRAPHICS-FBSERV-0554
4849 Test Code For Corrupted MBM File.
4852 Loads a specific bitmap from a multi-bitmap
4853 file from ROM and tests if it is corrupted.
4855 @SYMTestExpectedResults
4858 void CTBitmap::CheckBadBmp()
4860 INFO_PRINTF1(_L("MalformedBmp"));
4861 _LIT(KmalmbmFile0, "z:\\system\\data\\00_grbmap.mbm");
4862 _LIT(KmalmbmFile1, "z:\\system\\data\\01_totalstramsize!.mbm");
4863 _LIT(KmalmbmFile2, "z:\\system\\data\\02_headersize.mbm");
4864 _LIT(KmalmbmFile3, "z:\\system\\data\\03_width!.mbm");
4865 _LIT(KmalmbmFile4, "z:\\system\\data\\04_height!.mbm");
4866 _LIT(KmalmbmFile5, "z:\\system\\data\\05_bitsperpixel.mbm");
4867 _LIT(KmalmbmFile6, "z:\\system\\data\\bad_bmpsize.mbm");
4868 _LIT(KmalmbmFile7, "z:\\system\\data\\bad_colormode.mbm");
4869 _LIT(KmalmbmFile8, "z:\\system\\data\\bad_compression.mbm");
4870 _LIT(KmalmbmFile9, "z:\\system\\data\\bad_paletteentries.mbm");
4872 CFbsBitmap* fbsmalBmp = new(ELeave) CFbsBitmap;
4873 CleanupStack::PushL(fbsmalBmp);
4876 TEST2(fbsmalBmp->Load(KmalmbmFile0, 0, EFalse), KErrNone);
4877 TEST2(fbsmalBmp->Load(KmalmbmFile1, 0, EFalse), KErrCorrupt);
4878 TEST2(fbsmalBmp->Load(KmalmbmFile2, 0, EFalse), KErrCorrupt);
4879 TEST2(fbsmalBmp->Load(KmalmbmFile3, 0, EFalse), KErrCorrupt);
4880 TEST2(fbsmalBmp->Load(KmalmbmFile4, 0, EFalse), KErrCorrupt);
4881 TEST2(fbsmalBmp->Load(KmalmbmFile5, 0, EFalse), KErrNotSupported);
4882 TEST2(fbsmalBmp->Load(KmalmbmFile6, 0, EFalse), KErrCorrupt);
4883 TEST2(fbsmalBmp->Load(KmalmbmFile7, 0, EFalse), KErrCorrupt);
4884 TEST2(fbsmalBmp->Load(KmalmbmFile8, 0, EFalse), KErrCorrupt);
4885 TEST2(fbsmalBmp->Load(KmalmbmFile9, 0, EFalse), KErrNotSupported);
4887 CleanupStack::PopAndDestroy(fbsmalBmp);
4891 @SYMTestCaseID GRAPHICS-FBSERV-0613
4895 @SYMTestCaseDesc Test the return code of operations on bitmaps in the background compression queue
4897 @SYMTestPriority Critical
4901 @SYMTestStatus Implemented
4903 @SYMTestActions 1. Creates a bitmap
4904 2. Calls CompressInBackground()
4906 4. Waits until compression is finished
4908 @SYMTestExpectedResults The call to resize should return with KErrInUse since the compression is in progress
4911 void CTBitmap::TestBgCompressInUseL()
4913 INFO_PRINTF1(_L("Test the return code of operations on bitmaps in the background compression queue"));
4915 CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
4916 CleanupStack::PushL(bmp);
4918 TInt ret = bmp->Create(TSize(256, 256), EGray256); // create a solid grey bitmap
4919 TEST2 (ret,KErrNone);
4920 TRequestStatus status;
4921 bmp->CompressInBackground(status);
4922 TInt resizeRet = bmp->Resize(TSize(512,512));
4924 TEST2 (resizeRet,KErrInUse);
4925 User::WaitForRequest(status);
4926 TEST2 (status.Int(), KErrNone);
4927 CleanupStack::PopAndDestroy(bmp);
4931 //------------------------------------------------------------------------------
4933 LOCAL_D const TInt KTestBitmapWidth = 256; // this affects BitmapCheckCompressed()
4934 LOCAL_D const TInt KTestBitmapHeight = 256;
4935 LOCAL_D const TInt KTestBitmapResizeHeight = 512;
4936 LOCAL_D const TInt KMaxRLERunLength = 127;
4938 LOCAL_C void SetBitmapDataWithVerticalGradient(TUint8* aDataPtr)
4940 for (TInt y = 0; y < KTestBitmapHeight; ++y)
4941 for (TInt x = 0; x < KTestBitmapWidth; ++x)
4945 LOCAL_C TBool BitmapDataCheckVerticalGradient(const TUint8* aDataPtr)
4947 for (TInt y = 0; y < KTestBitmapHeight; ++y)
4948 for (TInt x = 0; x < KTestBitmapWidth; ++x)
4949 if (*aDataPtr++ != y)
4954 LOCAL_C void SetBitmapDataWithHorizontalGradient(TUint8* aDataPtr)
4956 for (TInt y = 0; y < KTestBitmapHeight; ++y)
4957 for (TInt x = 0; x < KTestBitmapWidth; ++x)
4961 LOCAL_C TBool BitmapDataCheckHorizontalGradient(const TUint8* aDataPtr)
4963 for (TInt y = 0; y < KTestBitmapHeight; ++y)
4964 for (TInt x = 0; x < KTestBitmapWidth; ++x)
4965 if (*aDataPtr++ != x)
4970 LOCAL_C TInt ResizeTestBitmap(CFbsBitmap* aBitmap)
4972 return aBitmap->Resize(TSize(KTestBitmapWidth, KTestBitmapResizeHeight));
4975 LOCAL_C TBool BitmapCheckResized(const CFbsBitmap* aBitmap)
4977 if (aBitmap->SizeInPixels() != TSize(KTestBitmapWidth, KTestBitmapResizeHeight))
4979 TUint8* dataPtr = (TUint8*)aBitmap->DataAddress();
4980 for (TInt y = 0; y < KTestBitmapHeight; ++y)
4981 for (TInt x = 0; x < KTestBitmapWidth; ++x)
4982 if (*dataPtr++ != y)
4984 for (TInt y = KTestBitmapHeight; y < KTestBitmapResizeHeight; ++y)
4985 for (TInt x = 0; x < KTestBitmapWidth; ++x)
4986 if (*dataPtr++ != 0xFF)
4991 LOCAL_C TInt CompressTestBitmap(CFbsBitmap* aBitmap)
4993 return aBitmap->Compress();
4996 LOCAL_C TBool BitmapCheckCompressed(const CFbsBitmap* aBitmap)
4998 if (aBitmap->SizeInPixels() != TSize(KTestBitmapWidth, KTestBitmapHeight))
5000 // check RLE compression on vertical gradient
5001 TUint8* dataPtr = (TUint8*)aBitmap->DataAddress();
5002 for (TInt y = 0; y < KTestBitmapHeight - 1; ++y)
5004 // this works when the width of the bitmap is 256, or twice the maximum encodable run length, which is 128
5005 if (*dataPtr++ != KMaxRLERunLength)
5007 if (*dataPtr++ != y)
5009 if (*dataPtr++ != KMaxRLERunLength)
5011 if (*dataPtr++ != y)
5017 struct TTestThreadParams
5020 TInt (*iBitmapFunction)(CFbsBitmap*); // operation to perform on the bitmap
5021 TBool (*iCheckFunction)(const CFbsBitmap*); // check that the operation was successfully performed
5024 LOCAL_C void AlternateTestThreadL(const TTestThreadParams& aParams)
5026 RFbsSession* fbs = RFbsSession::GetSession();
5027 if (fbs->ResourceCount() != 0)
5028 User::Leave(KErrGeneral);
5029 CFbsBitmap* bmp = new(ELeave) CFbsBitmap;
5030 CleanupStack::PushL(bmp);
5031 User::LeaveIfError(bmp->Duplicate(aParams.iBitmapHandle));
5032 if (fbs->ResourceCount() != 1)
5033 User::Leave(KErrGeneral);
5034 if (!BitmapDataCheckVerticalGradient((TUint8*)bmp->DataAddress()))
5035 User::Leave(KErrGeneral);
5036 User::LeaveIfError((*aParams.iBitmapFunction)(bmp));
5037 if (fbs->ResourceCount() != 1)
5038 User::Leave(KErrGeneral);
5039 if (aParams.iCheckFunction != NULL && !(*aParams.iCheckFunction)(bmp))
5040 User::Leave(KErrGeneral);
5041 CleanupStack::PopAndDestroy(bmp);
5042 if (fbs->ResourceCount() != 0)
5043 User::Leave(KErrGeneral);
5046 LOCAL_C TInt AlternateTestThread(TAny* aParams)
5049 TInt ret = RFbsSession::Connect();
5050 if (ret != KErrNone)
5052 CTrapCleanup* cleanupStack = CTrapCleanup::New();
5053 if (cleanupStack == NULL)
5054 return KErrNoMemory;
5055 TRAP(ret, AlternateTestThreadL(*static_cast<TTestThreadParams*>(aParams)));
5056 delete cleanupStack;
5057 RFbsSession::Disconnect();
5062 void CTBitmap::MultiThreadedTestsL()
5064 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0503"));
5065 MultiThreadedResizeTestL();
5066 ((CTBitmapStep*)iStep)->RecordTestResultL();
5067 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0504"));
5068 MultiThreadedCompressTestL();
5069 #ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP
5070 ((CTBitmapStep*)iStep)->RecordTestResultL();
5071 ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0505"));
5072 MultiThreadedLockHeapTestL();
5077 @SYMTestCaseID GRAPHICS-FBSERV-0503
5081 @SYMTestCaseDesc Tests behaviour of CFbsBitmap::DataAddress() and CFbsBitmap::Resize() when called concurrently by different threads
5083 @SYMTestPriority High
5087 @SYMTestStatus Implemented
5089 @SYMTestActions 1. The 1st thread will create a bitmap, store a pointer to the bitmap data, launch the 2nd thread and then wait for it to terminate
5090 2. The 2nd thread will resize the same bitmap and exit
5091 3. The 1st thread will manipulate the bitmap data using the stored pointer and then re-fetch the bitmap data
5093 @SYMTestExpectedResults The 1st thread should be able both to manipulate the old bitmap data and check the resized bitmap data
5095 void CTBitmap::MultiThreadedResizeTestL()
5097 INFO_PRINTF1(_L("Test Resize() with Multiple Threads"));
5098 DoMultiThreadedTestL(_L("AlternateResizeThread"), ResizeTestBitmap, BitmapCheckResized);
5102 @SYMTestCaseID GRAPHICS-FBSERV-0504
5106 @SYMTestCaseDesc Tests behaviour of CFbsBitmap::DataAddress() and CFbsBitmap::Compress() when called concurrently by different threads
5108 @SYMTestPriority High
5112 @SYMTestStatus Implemented
5114 @SYMTestActions 1. The 1st thread will create a bitmap, store a pointer to the bitmap data, launch the 2nd thread and then wait for it to terminate
5115 2. The 2nd thread will compress the same bitmap and exit
5116 3. The 1st thread will manipulate the bitmap data using the stored pointer and then re-fetch the bitmap data
5118 @SYMTestExpectedResults The 1st thread should be able both to manipulate the old bitmap data and check the compressed bitmap data
5120 void CTBitmap::MultiThreadedCompressTestL()
5122 INFO_PRINTF1(_L("Test Compress() with Multiple Threads"));
5123 DoMultiThreadedTestL(_L("AlternateCompressThread"), CompressTestBitmap, BitmapCheckCompressed);
5126 void CTBitmap::DoMultiThreadedTestL(const TDesC& aThreadName, TInt (*aBitmapFunction)(CFbsBitmap*), TBool (*aCheckFunction)(const CFbsBitmap*))
5128 CFbsBitmap* bmp = new CFbsBitmap;
5129 ASSERT_NOT_NULL(bmp);
5130 CleanupStack::PushL(bmp);
5131 TInt ret = bmp->Create(TSize(KTestBitmapWidth, KTestBitmapHeight), EGray256);
5132 ASSERT_EQUALS(ret, KErrNone);
5133 TUint8* dataPtr = (TUint8*)bmp->DataAddress();
5134 SetBitmapDataWithVerticalGradient(dataPtr);
5135 TTestThreadParams params;
5136 params.iBitmapHandle = bmp->Handle();
5137 params.iBitmapFunction = aBitmapFunction;
5138 params.iCheckFunction = aCheckFunction;
5140 ret = thread.Create(aThreadName, AlternateTestThread, KDefaultStackSize, 0x2000, 0x2000, ¶ms);
5141 ASSERT_EQUALS(ret, KErrNone);
5142 TRequestStatus status;
5143 thread.Logon(status);
5145 User::WaitForRequest(status);
5146 TExitType exitType = thread.ExitType();
5147 TInt exitReason = thread.ExitReason();
5148 TEST(exitType == EExitKill);
5149 TEST(exitReason == KErrNone);
5151 TEST(BitmapDataCheckVerticalGradient(dataPtr));
5152 SetBitmapDataWithHorizontalGradient(dataPtr);
5153 TEST(BitmapDataCheckHorizontalGradient(dataPtr));
5154 TEST((*aCheckFunction)(bmp));
5155 CleanupStack::PopAndDestroy(bmp);
5156 User::Heap().Check();
5159 #ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP
5160 _LIT(KFBSERVClientPanicCategory, "FBSCLI");
5162 LOCAL_C TInt LockHeapTestBitmap(CFbsBitmap* aBitmap)
5164 aBitmap->LockHeap();
5169 @SYMTestCaseID GRAPHICS-FBSERV-0505
5173 @SYMTestCaseDesc Tests behaviour of CFbsBitmap::LockHeap() when called concurrently by different threads
5175 @SYMTestPriority High
5179 @SYMTestStatus Implemented
5181 @SYMTestActions 1. The 1st thread will create a bitmap, call LockHeap() on it, launch the 2nd thread and then wait for it to terminate
5182 2. The 2nd thread will also call LockHeap() on the same bitmap
5183 3. The 1st thread will check that the 2nd thread has panicked
5185 @SYMTestExpectedResults Panic FBSCLI 22
5187 void CTBitmap::MultiThreadedLockHeapTestL()
5189 INFO_PRINTF1(_L("Test LockHeap() Panic with Multiple Threads"));
5190 CFbsBitmap* bmp = new CFbsBitmap;
5191 ASSERT_NOT_NULL(bmp);
5192 CleanupStack::PushL(bmp);
5193 TInt ret = bmp->Create(TSize(KTestBitmapWidth, KTestBitmapHeight), EGray256);
5194 ASSERT_EQUALS(ret, KErrNone);
5195 SetBitmapDataWithVerticalGradient((TUint8*)bmp->DataAddress());
5197 TTestThreadParams params;
5198 params.iBitmapHandle = bmp->Handle();
5199 params.iBitmapFunction = LockHeapTestBitmap;
5200 params.iCheckFunction = NULL;
5202 ret = thread.Create(_L("AlternateLockHeapThread"), AlternateTestThread, KDefaultStackSize, 0x2000, 0x2000, ¶ms);
5203 ASSERT_EQUALS(ret, KErrNone);
5204 TRequestStatus status;
5205 thread.Logon(status);
5207 User::WaitForRequest(status);
5208 TExitType exitType = thread.ExitType();
5209 TExitCategoryName exitCategory = thread.ExitCategory();
5210 TInt exitReason = thread.ExitReason();
5211 TEST(exitType == EExitPanic);
5212 TEST(exitCategory == KFBSERVClientPanicCategory);
5213 TEST(exitReason == EFbsPanicBadHeapLock);
5215 CleanupStack::PopAndDestroy(bmp);
5216 User::Heap().Check();
5222 class CStopTestBgCompress: public CAsyncOneShot
5225 CStopTestBgCompress(): CAsyncOneShot(CActive::EPriorityIdle - 1) {} // priority must be less than CFbsSessionHelper
5226 void RunL() { CActiveScheduler::Stop(); }
5229 LOCAL_C TInt TestBgCompressThread(TAny* /*aParams*/)
5231 const TInt KBmpSize = 0x100000 + sizeof(SEpocBitmapHeader);
5232 // assuming run-length encoding every scan line gets compressed into 8 runs of 128 bytes each
5233 // 2 bytes per encoded run results in 16 bytes per scan line so the compressed bitmap is large (>16K)
5234 // a few bytes added at the end for the compression bookmark are rounded up to a page
5235 const TInt KBmpCompressedSize = 0x5000;
5236 TInt ret = KErrNone;
5238 CTrapCleanup* trap = CTrapCleanup::New();
5239 TRequestStatus status;
5245 CActiveScheduler* scheduler = new CActiveScheduler;
5246 if (scheduler == NULL)
5249 goto exitNoScheduler;
5251 CActiveScheduler::Install(scheduler);
5252 CStopTestBgCompress* stop = new CStopTestBgCompress;
5258 ret = RFbsSession::Connect();
5259 if (ret != KErrNone)
5261 CFbsBitmapEx* bmp = new CFbsBitmapEx;
5267 CFbsBitmapEx* bmp2 = new CFbsBitmapEx;
5273 ret = bmp->Create(TSize(1024, 1024), EGray256); // create a solid white bitmap
5274 if (ret != KErrNone)
5276 ret = bmp2->Duplicate(bmp->Handle()); // duplicate the bitmap handle
5277 if (ret != KErrNone)
5279 bmp->CompressInBackground(status);
5280 User::WaitForRequest(status);
5281 if (status != KErrNone)
5286 if (bmp->BitmapAddress()->Header().iBitmapSize != KBmpSize || bmp->BitmapAddress() != bmp2->BitmapAddress())
5292 CActiveScheduler::Start(); // now CFbsSessionHelper should clean both bmp and bmp2 and free the dirty bitmap data
5293 if (!bmp->BitmapAddress()->IsCompressedInRAM() || bmp->BitmapAddress()->Header().iBitmapSize > KBmpCompressedSize || bmp->BitmapAddress() != bmp2->BitmapAddress())
5300 RFbsSession::Disconnect();
5313 @SYMTestCaseID GRAPHICS-FBSERV-0612
5317 @SYMTestCaseDesc Tests memory usage with CFbsBitmap::CompressInBackground()
5319 @SYMTestPriority High
5323 @SYMTestStatus Implemented
5325 @SYMTestActions 1. Creates a bitmap
5326 2. Calls CompressInBackground()
5327 3. Waits until compression is finished
5328 4. Gives the active scheduler the chance to run the session's helper
5330 @SYMTestExpectedResults Efficient use of memory
5332 void CTBitmap::TestBgCompressL()
5334 INFO_PRINTF1(_L("Test memory usage with CFbsBitmap::CompressInBackground()"));
5336 TInt ret = thread.Create(_L("TestBgCompressThread"), TestBgCompressThread, KDefaultStackSize, 0x2000, 0x2000, NULL);
5337 ASSERT_EQUALS(ret, KErrNone);
5338 TRequestStatus status;
5339 thread.Logon(status);
5341 User::WaitForRequest(status);
5342 TExitType exitType = thread.ExitType();
5343 TInt exitReason = thread.ExitReason();
5344 TEST(exitType == EExitKill);
5345 TEST(exitReason == KErrNone);
5346 if (exitType != EExitKill || exitReason != KErrNone)
5348 INFO_PRINTF3(_L("Exit Type = %d, Exit Reason = %d"), TInt(exitType), exitReason);
5354 @SYMTestCaseID GRAPHICS-FBSERV-0618
5358 @SYMTestCaseDesc Tests that small and large bitmaps are white-filled upon creation.
5360 @SYMTestPriority High
5364 @SYMTestStatus Implemented
5366 @SYMTestActions 1. Create a small bitmap
5367 2. Create a large bitmap
5369 @SYMTestExpectedResults Both bitmaps are filled with white
5371 void CTBitmap::TestBitmapWhiteFillL()
5373 INFO_PRINTF1(_L("Test white fill of CFbsBitmap upon creation."));
5374 const TDisplayMode KDispMode = EColor16MAP;
5375 RPointerArray<CFbsBitmap> bmpArray;
5376 const TSize KBitmapSmallSize(4,4);
5377 const TSize KBitmapLargeSize(200,200);
5379 // Create small CFbsBitmap
5380 CFbsBitmap* bmp = new (ELeave) CFbsBitmap;;
5381 TInt ret = bmp->Create(KBitmapSmallSize,KDispMode);
5382 TEST2(ret, KErrNone);
5383 bmpArray.AppendL(bmp);
5384 // Create large CFbsBitmap
5385 bmp = new (ELeave) CFbsBitmap;;
5386 ret = bmp->Create(KBitmapLargeSize,KDispMode);
5387 TEST2(ret, KErrNone);
5388 bmpArray.AppendL(bmp);
5389 // Create small hardware bitmap
5390 bmp = new (ELeave) CFbsBitmap;;
5391 ret = bmp->CreateHardwareBitmap(KBitmapSmallSize, KDispMode, KNullUid);
5392 if (ret == KErrNotSupported)
5394 INFO_PRINTF1(_L("WhiteFill test skipped for small hardware bitmaps as they are not supported"));
5399 TEST2(ret, KErrNone);
5400 bmpArray.AppendL(bmp);
5402 // Create large hardware bitmap
5403 bmp = new (ELeave) CFbsBitmap;;
5404 ret = bmp->CreateHardwareBitmap(KBitmapLargeSize, KDispMode, KNullUid);
5405 if (ret == KErrNotSupported)
5407 INFO_PRINTF1(_L("WhiteFill test skipped for large hardware bitmaps as they are not supported"));
5412 TEST2(ret, KErrNone);
5413 bmpArray.AppendL(bmp);
5416 for (TInt ii = 0; ii < bmpArray.Count(); ++ii)
5419 bmp->BeginDataAccess();
5420 TUint32* base = bmp->DataAddress();
5421 TSize size = bmp->SizeInPixels();
5422 TInt scanLineLength = CFbsBitmap::ScanLineLength(size.iWidth,KDispMode);
5423 TInt dataLength = scanLineLength * size.iHeight;
5424 CheckWhite((TUint8*)base,dataLength,KDispMode);
5425 bmp->EndDataAccess(ETrue);
5433 // The code for regression test case GRAPHICS-FBSERV-0614 must be in a separate thread
5434 // because it has to call RFbsSession::Disconnect() and without the fix it panics.
5435 LOCAL_C TInt TestDisconnectWithBitmapThread(TAny* /*aParams*/)
5437 CTrapCleanup* trap = CTrapCleanup::New();
5439 return KErrNoMemory;
5440 CActiveScheduler* scheduler = new CActiveScheduler;
5441 if (scheduler == NULL)
5444 return KErrNoMemory;
5446 CActiveScheduler::Install(scheduler);
5447 TInt ret = RFbsSession::Connect();
5448 if (ret != KErrNone)
5454 CFbsBitmap* bmp = new CFbsBitmap;
5457 RFbsSession::Disconnect();
5460 return KErrNoMemory;
5462 ret = bmp->Create(TSize(256, 256), EGray256); // create a solid white bitmap
5463 if (ret != KErrNone)
5465 RFbsSession::Disconnect();
5470 RFbsSession::Disconnect();
5477 @SYMTestCaseID GRAPHICS-FBSERV-0614
5481 @SYMTestCaseDesc Tests behaviour when RFbsSession::Disconnect() is called and there is a CFbsBitmap not yet deleted
5483 @SYMTestPriority High
5487 @SYMTestStatus Implemented
5489 @SYMTestActions 1. Creates and installs an active scheduler so that CFbsSessionHelper can be activated
5490 2. Calls RFbsSession::Connect()
5492 4. Calls RFbsSession::Disconnect()
5494 @SYMTestExpectedResults The bitmap should be destroyed automatically and no panics should occur
5496 void CTBitmap::TestDisconnectWithBitmapL()
5498 INFO_PRINTF1(_L("Test RFbsSession::Disconnect() with a CFbsBitmap not yet deleted"));
5500 TInt ret = thread.Create(_L("TestDisconnectWithBitmapThread"), TestDisconnectWithBitmapThread, KDefaultStackSize, 0x2000, 0x2000, NULL);
5501 ASSERT_EQUALS(ret, KErrNone);
5502 TRequestStatus status;
5503 thread.Logon(status);
5505 User::WaitForRequest(status);
5506 TExitType exitType = thread.ExitType();
5507 TInt exitReason = thread.ExitReason();
5508 TEST(exitType == EExitKill);
5509 TEST(exitReason == KErrNone);
5514 @SYMTestCaseID GRAPHICS-FBSERV-0617
5518 @SYMTestCaseDesc Test that bitmaps have been touched when data changes.
5519 Test that bitmaps become volatile when DataAddress is called outside of
5520 calls to BeginDataAccess() and EndDataAccess().
5522 @SYMTestStatus Implemented
5524 @SYMTestPriority High
5526 @SYMTestActions Create a bitmap.
5527 Call each public API.
5528 Check that the touch count increases when the bitmap data has been modified.
5529 Check whether bitmap is volatile.
5530 @SYMTestExpectedResults Touch count only increases for the following functions:
5536 DataAddress() called inside a Begin() and End(EFalse) pairing.
5537 Bitmap is volatile only when DataAddress() called outside
5538 a Begin() and End(EFalse) pairing.
5540 void CTBitmap::TestTouchedAndVolatileL()
5542 INFO_PRINTF1(_L("Test bitmaps become touched or volatile when data changes."));
5543 CFbsBitmap* bmp = new CFbsBitmap;
5545 TInt touchCount = 0;
5546 TInt newTouchCount = 0;
5547 CleanupStack::PushL(bmp);
5550 User::LeaveIfError(bmp->Create(TSize(4,4),EColor16MA));
5551 touchCount = bmp->TouchCount();
5552 TInt ret = bmp->Resize(TSize(5,5));
5553 TEST(ret == KErrNone);
5554 newTouchCount = bmp->TouchCount();
5555 TEST(newTouchCount == touchCount+1);
5556 TEST(!bmp->IsVolatile());
5557 touchCount = bmp->TouchCount();
5558 ret = bmp->Resize(TSize(3,3));
5559 TEST(ret == KErrNone);
5560 newTouchCount = bmp->TouchCount();
5561 TEST(newTouchCount == touchCount+1);
5562 TEST(!bmp->IsVolatile());
5563 touchCount = bmp->TouchCount();
5564 ret = bmp->Resize(TSize(3,3));
5565 TEST(ret == KErrNone);
5566 newTouchCount = bmp->TouchCount();
5567 TEST(newTouchCount == touchCount+1);
5568 TEST(!bmp->IsVolatile());
5572 User::LeaveIfError(bmp->Create(TSize(4,4),EColor16MA));
5573 touchCount = bmp->TouchCount();
5574 ret = bmp->SetDisplayMode(EColor16MAP);
5575 TEST(ret == KErrNone);
5576 newTouchCount = bmp->TouchCount();
5577 TEST(newTouchCount == touchCount+1);
5578 TEST(!bmp->IsVolatile());
5582 TInt scanLineLength = CFbsBitmap::ScanLineLength(256,EColor16MA);
5583 TUint8* buffer = new TUint8[scanLineLength];
5584 TEST(buffer != NULL);
5585 TPtr8 scanline(buffer,scanLineLength,scanLineLength);
5586 User::LeaveIfError(bmp->Create(TSize(4,4),EColor16MA));
5587 touchCount = bmp->TouchCount();
5588 bmp->SetScanLine(scanline, 1);
5589 newTouchCount = bmp->TouchCount();
5590 TEST(newTouchCount == touchCount+1);
5591 TEST(!bmp->IsVolatile());
5595 // SwapWidthAndHeight
5596 User::LeaveIfError(bmp->Create(TSize(4,6),EColor16MA));
5597 touchCount = bmp->TouchCount();
5598 ret = bmp->SwapWidthAndHeight();
5599 TEST(ret == KErrNone);
5600 newTouchCount = bmp->TouchCount();
5601 TEST(newTouchCount == touchCount+1);
5602 TEST(!bmp->IsVolatile());
5606 // Requires data to be externalised first
5607 User::LeaveIfError(bmp->Create(TSize(4,6),EColor16MA));
5608 touchCount = bmp->TouchCount();
5609 CDirectFileStore* writestore = CDirectFileStore::ReplaceL(iFs,KTempFilename,EFileStream|EFileWrite);
5610 TEST(writestore != NULL);
5611 TUidType uidtype(KDirectFileStoreLayoutUid,KMultiBitmapFileImageUid);
5612 writestore->SetTypeL(uidtype);
5613 RStoreWriteStream writestrm;
5614 TStreamId headerid(0);
5615 headerid = writestrm.CreateL(*writestore);
5616 writestore->SetRootL(headerid);
5617 bmp->ExternalizeL(writestrm);
5621 // Now internalise data to reset bitmap.
5622 CDirectFileStore* readstore = CDirectFileStore::OpenL(iFs,KTempFilename,EFileStream|EFileRead);
5623 RStoreReadStream readstrm;
5624 headerid = readstore->Root();
5625 readstrm.OpenL(*readstore,headerid);
5626 bmp->InternalizeL(readstrm);
5629 newTouchCount = bmp->TouchCount();
5630 TEST(newTouchCount == touchCount+1);
5631 TEST(!bmp->IsVolatile());
5636 // 1. Call as read-only (by passing ETrue into End())
5637 // Expect: touch count doesn't increase & bitmap not volatile
5638 User::LeaveIfError(bmp->Create(TSize(4,6),EColor16MA));
5639 touchCount = bmp->TouchCount();
5640 bmp->BeginDataAccess();
5641 bmp->DataAddress(); // ignore returned value for this test.
5642 bmp->EndDataAccess(ETrue);
5643 newTouchCount = bmp->TouchCount();
5644 TEST(newTouchCount == touchCount);
5645 TEST(!bmp->IsVolatile());
5646 // 2. Call as writeable (by passing EFalse into End())
5647 // Expect: touch count increases & bitmap not volatile
5648 touchCount = newTouchCount;
5649 bmp->BeginDataAccess();
5650 bmp->DataAddress(); // ignore returned value for this test.
5651 bmp->EndDataAccess(EFalse);
5652 newTouchCount = bmp->TouchCount();
5653 TEST(newTouchCount == touchCount+1);
5654 TEST(!bmp->IsVolatile());
5655 // 3. Call without Begin/End pairing
5656 // Expect: bitmap is volatile
5657 bmp->DataAddress(); // ignore returned value for this test.
5658 TEST(bmp->IsVolatile());
5661 CleanupStack::PopAndDestroy(bmp);
5666 * Creates an extended bitmap and it tries to use it with TBitmapUtil, which should cause a panic
5668 LOCAL_C void DoBitmapUtilWithExtendedBitmapThreadL()
5670 const TUint8 KTestData[] = "Extended bitmap test data 123456";
5671 const TInt KTestDataSize = sizeof(KTestData);
5672 const TSize KSizeInPixels = TSize(50,50);
5673 const TDisplayMode KDisplayMode = EColor64K;
5675 CFbsBitmap* bmp = new(ELeave)CFbsBitmap;
5676 CleanupStack::PushL(bmp);
5678 const TUid KUidTestExtendedBitmap = TUid::Uid(0xFFFFFFFF);
5679 User::LeaveIfError(bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize));
5681 TBitmapUtil util(bmp); // this will cause a panic
5683 CleanupStack::PopAndDestroy(bmp);
5687 * Creates a compressed bitmap and it tries to use it with TBitmapUtil, which should cause a panic
5689 LOCAL_C void DoBitmapUtilWithCompressedBitmapThreadL()
5691 CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
5692 CleanupStack::PushL(bmp);
5693 bmp->Load(KRamBitmap);
5694 User::LeaveIfError(bmp->Compress());
5695 if(!bmp->IsCompressedInRAM())
5697 User::Leave(KErrArgument);
5700 TBitmapUtil util(bmp); // this will cause a panic
5702 CleanupStack::PopAndDestroy(bmp);
5705 typedef void (*TFunctionPtr)();
5707 LOCAL_C TInt BitmapUtilWithUnsupportedBitmapThreadFunc(TAny* aFunctionPtr)
5709 TInt ret = RFbsSession::Connect();
5715 CTrapCleanup* trap = CTrapCleanup::New();
5718 RFbsSession::Disconnect();
5719 return KErrNoMemory;
5722 TRAP(ret, ((TFunctionPtr)aFunctionPtr)()); // this function can leave
5725 RFbsSession::Disconnect();
5730 * Creates a thread, and the test scenario for GRAPHICS-FBSERV-0661 is run in aThreadFunction, which
5731 * causes a panic. Checks if the thread has been terminated with panic with correct category and panic code.
5733 void CTBitmap::TestBitmapUtilWithUnsupportedBitmap(const TDesC& aThreadName, TAny* aFunctionPtr)
5736 TInt ret = thread.Create(aThreadName, BitmapUtilWithUnsupportedBitmapThreadFunc, KDefaultStackSize, 0x2000, 0x2000, aFunctionPtr);
5737 TEST(ret == KErrNone);
5738 TRequestStatus status;
5739 thread.Logon(status);
5741 User::WaitForRequest(status);
5742 TExitType exitType = thread.ExitType();
5743 TExitCategoryName exitCategory = thread.ExitCategory();
5744 TInt exitReason = thread.ExitReason();
5745 TEST(exitType == EExitPanic);
5746 TEST(exitCategory == KFBSERVClientPanicCategory);
5747 TEST(exitReason == EFbsPanicInvalidBitmapType);
5752 @SYMTestCaseID GRAPHICS-FBSERV-0661
5754 @SYMTestCaseDesc Test the use of TBitmapUtil with extended and compressed bitmaps.
5755 NOTE: this is a debug only test.
5757 @SYMTestStatus Implemented
5759 @SYMTestPriority High
5761 @SYMTestActions Create extended bitmap, and TBitmapUtil to process it.
5762 Create bitmap and compress it,and TBitmapUtil to process it.
5764 @SYMTestExpectedResults Panic FBSCLI 29
5766 void CTBitmap::TestBitmapUtilWithUnsupportedBitmaps()
5768 INFO_PRINTF1(_L("Test TBitmapUtil with unsupported bitmaps"));
5771 TestBitmapUtilWithUnsupportedBitmap(_L("BitmapUtilWithExtentedBitmapThread"), (TAny*)&DoBitmapUtilWithExtendedBitmapThreadL);
5773 // compressed bitmap
5774 TestBitmapUtilWithUnsupportedBitmap(_L("BitmapUtilWithCompressedBitmapThread"), (TAny*)&DoBitmapUtilWithCompressedBitmapThreadL);
5779 __CONSTRUCT_STEP__(Bitmap)
5781 void CTBitmapStep::TestSetupL()
5787 void CTBitmapStep::TestClose()
5789 ::DeleteFilesFromC(); //clean up data files used by this test - must be done before call to End() - DEF047652