fbs/fontandbitmapserver/tfbs/TBITMAP.CPP
changeset 0 5d03bc08d59c
child 11 fed1595b188e
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code
       
    20 */
       
    21 
       
    22 #include <e32math.h>
       
    23 #include <s32file.h>
       
    24 #include <bautils.h>
       
    25 #include <hal.h>
       
    26 #include <test/tefunit.h>
       
    27 #include <graphics/bitmapuid.h>
       
    28 #include "../sfbs/UTILS.H"
       
    29 #include "TBitmap.h"
       
    30 #include "../sfbs/fbsbitmapasyncstreamer.h"
       
    31 #include "fbsmessage.h"
       
    32 
       
    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
       
    37 #endif
       
    38 // End of Symbian modification
       
    39 
       
    40 
       
    41 
       
    42 //
       
    43 //
       
    44 //Globals
       
    45 //LOCAL_D RTest	TheTest(_L("Test Bitmap"));
       
    46 LOCAL_D RFs		TheFs;
       
    47 const TUint8	KCheckValue = 0x69;//pixel value used in the tests
       
    48 
       
    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");
       
    58 
       
    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");
       
    63 
       
    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");
       
    68 
       
    69 _LIT(KRamBitmapOnZ, "z:\\system\\data\\16RAM2.mbm");
       
    70 _LIT(KRamBitmap, "c:\\16RAM2.mbm");
       
    71 _LIT(KRamBitmap2, "c:\\16RAM3.mbm");
       
    72 
       
    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");
       
    83 
       
    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");
       
    94 
       
    95 _LIT(KRomBitmap,"z:\\system\\data\\tfbs.rbm");
       
    96 
       
    97 //
       
    98 //
       
    99 //Create/Destroy test environment global functions
       
   100 
       
   101 //Delete "aFullName" file.
       
   102 LOCAL_C void DeleteDataFile(const TDesC& aFullName)
       
   103 	{
       
   104 	RFs fsSession;
       
   105 	TInt err = fsSession.Connect();
       
   106 	if(err == KErrNone)
       
   107 		{
       
   108 		TEntry entry;
       
   109 		if(fsSession.Entry(aFullName, entry) == KErrNone)
       
   110 			{
       
   111 			RDebug::Print(_L("Deleting \"%S\" file.\n"), &aFullName);
       
   112 			err = fsSession.SetAtt(aFullName, 0, KEntryAttReadOnly);
       
   113 			if(err != KErrNone) 
       
   114 				{
       
   115 				RDebug::Print(_L("Error %d changing \"%S\" file attributes.\n"), err, &aFullName);
       
   116 				}
       
   117 			err = fsSession.Delete(aFullName);
       
   118 			if(err != KErrNone) 
       
   119 				{
       
   120 				RDebug::Print(_L("Error %d deleting \"%S\" file.\n"), err, &aFullName);
       
   121 				}
       
   122 			}
       
   123 		fsSession.Close();
       
   124 		}
       
   125 	else
       
   126 		{
       
   127 		RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName);
       
   128 		}
       
   129 	}
       
   130 
       
   131 //Copy test bitmaps from Z: to C: drive. RFs::Connect() had to be called already 
       
   132 //on "TheFs" object.
       
   133 LOCAL_C void CopyFilesOnC()
       
   134 	{
       
   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);
       
   155 	}
       
   156 
       
   157 //Delete data files used by the test
       
   158 LOCAL_C void DeleteFilesFromC()
       
   159 	{
       
   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);
       
   180 	}
       
   181 
       
   182 //
       
   183 //
       
   184 
       
   185 void CTBitmap::DeleteScanLineBuffer()
       
   186 	{
       
   187 	RFbsSession* fbs = RFbsSession::GetSession();
       
   188 	delete fbs->iScanLineBuffer;
       
   189 	fbs->iScanLineBuffer = NULL;
       
   190 	}
       
   191 
       
   192 CTBitmap::CTBitmap(CTestStep* aStep):
       
   193 	CTGraphicsBase(aStep),
       
   194 	iBmpHandler(NULL),
       
   195 	iBitmap(NULL),
       
   196 	iAs(NULL)
       
   197 	{
       
   198 	__ASSERT_DEBUG(CActiveScheduler::Current(), User::Invariant());
       
   199 	CFbsBitmap bmp;
       
   200 	iTestBitmapName = KTestBitmapOnZ;
       
   201 	TInt ret=bmp.Load(iTestBitmapName,ETfbs,NULL);
       
   202 	TEST2(ret, KErrNone);
       
   203 	bmp.Reset();
       
   204 
       
   205 	ret = iFs.Connect();
       
   206 	TEST2(ret, KErrNone);
       
   207 
       
   208 	// Expand session scanline buffer cache to avoid spurious alloc heavens later on
       
   209 	const TInt bufferSize = 1024;
       
   210 
       
   211 	ret = bmp.Create(TSize(bufferSize,1),EColor256);
       
   212 	TEST2(ret, KErrNone);
       
   213 
       
   214 	ret = bmp.Compress();
       
   215 	TEST2(ret, KErrNone);
       
   216 
       
   217 	TUint8* buffer = new TUint8[bufferSize];
       
   218 	TEST(buffer != NULL);
       
   219 
       
   220 	TPtr8 scanline(buffer,bufferSize,bufferSize);
       
   221 	bmp.GetScanLine(scanline,TPoint(0,0),bufferSize,EColor256);
       
   222 	delete [] buffer;
       
   223 	bmp.Reset();
       
   224 	
       
   225 	TUint32* romAddress = NULL;
       
   226 	if(!CFbsBitmap::IsFileInRom(KRomBitmap, romAddress)) //any ROM bitmap
       
   227 		{
       
   228 		INFO_PRINTF2(_L("Skipping ROM bitmap tests since file \"%S\" is reported to not be a ROM bitmap."),
       
   229 				&KRomBitmap);
       
   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;
       
   232 		}
       
   233 	}
       
   234 
       
   235 CTBitmap::~CTBitmap()
       
   236 	{
       
   237 	iFs.Close();
       
   238 	}
       
   239 
       
   240 void CTBitmap::RunTestCaseL(TInt aCurTestCase)
       
   241     {
       
   242     ((CTBitmapStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
       
   243 	switch(aCurTestCase)
       
   244 		{
       
   245 	case 1:		
       
   246 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0550"));
       
   247 		TwoComprLines();
       
   248 		break;
       
   249 	case 2:
       
   250 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0517"));
       
   251 	// they are fast hence at the beginning
       
   252 		CheckScanlineL();
       
   253 		break;
       
   254 	case 3:
       
   255 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0534"));
       
   256 		Compress();
       
   257 		break;
       
   258 	case 4:
       
   259 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0518"));
       
   260 		StreamBitmap();
       
   261 		break;
       
   262 	case 5:
       
   263 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0519"));
       
   264 		StreamRectangle();
       
   265 		break;
       
   266 	case 6:
       
   267 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0523"));
       
   268 		LoadInSegments();
       
   269 		break;
       
   270 	case 7:
       
   271 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0524"));
       
   272 		SaveInSegments();
       
   273 		break;
       
   274 	case 8:
       
   275 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0525"));
       
   276 		MonoDetect();
       
   277 		break;
       
   278 	case 9:
       
   279 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0526"));
       
   280 		ChunkPileL();
       
   281 		break;
       
   282 	case 10:
       
   283 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0527"));
       
   284 		LargeBitmaps();
       
   285 		break;
       
   286 	case 12:
       
   287 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0528"));
       
   288 		HugeBitmaps();
       
   289 		break;
       
   290 	case 13:
       
   291 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0529"));
       
   292 		Resize();
       
   293 		break;
       
   294 	case 14:
       
   295 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0520"));
       
   296 		GetScanline();
       
   297 		break;
       
   298 	case 15:
       
   299 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0521"));
       
   300 		SetScanline();
       
   301 		break;
       
   302 	case 16:
       
   303 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0522"));
       
   304 		StretchScanline();
       
   305 		break;
       
   306 	case 17:
       
   307 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0530"));
       
   308 		BitmapUtil();
       
   309 		break;
       
   310 	case 18:
       
   311 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0531"));
       
   312 		InvalidBitmap();
       
   313 		break;
       
   314 	case 19:
       
   315 		((CTBitmapStep*)iStep)->SetTestStepID(_L(" GRAPHICS-FBSERV-0533"));
       
   316 		SaveAndLoadFast();
       
   317 		break;
       
   318 	case 20:
       
   319 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0532"));
       
   320 		SaveAndLoad();
       
   321 		break;
       
   322 	case 21:
       
   323 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0535"));
       
   324 		Color256BitmapUtil();
       
   325 		break;
       
   326 	case 22:
       
   327 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0536"));
       
   328 		HardwareBitmaps();
       
   329 		break;
       
   330 	case 23:
       
   331 		((CTBitmapStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
   332 	//	BitmapTiming(); 
       
   333 		break;
       
   334 	case 24:
       
   335 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0537"));
       
   336 		INC036062L();
       
   337 		break;
       
   338 	case 25:
       
   339 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0538"));
       
   340 		PerformanceTest_INC036062L();
       
   341 		break;
       
   342 	case 26:
       
   343 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0539"));
       
   344 		INC037474L();
       
   345 		break;
       
   346 	case 27:
       
   347 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0540"));
       
   348 		DEF038286L();
       
   349 		break;
       
   350 	case 28:
       
   351 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0541"));
       
   352 		DEF038286_2L();
       
   353 		break;
       
   354 	case 29:
       
   355 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0542"));
       
   356 		MonohromeL();
       
   357 		break;
       
   358 	case 30:
       
   359 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0543"));
       
   360 		GetVerticalScanLineL();
       
   361 		break;
       
   362 	case 31:
       
   363 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0544"));
       
   364 		GetVerticalScanLinePerformanceL();
       
   365 		break;
       
   366 	case 32:
       
   367 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0545"));
       
   368 		DEF071843_16MAL();
       
   369 		((CTBitmapStep*)iStep)->RecordTestResultL();
       
   370 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0546"));	
       
   371 		DEF071843_16MUL();
       
   372 		((CTBitmapStep*)iStep)->RecordTestResultL();
       
   373 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0547"));
       
   374 		DEF071843_16ML();
       
   375 #ifdef _DEBUG
       
   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	
       
   380 		DEF095361_16MAL();
       
   381 #endif		
       
   382 		break;
       
   383 	case 33:
       
   384 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0548"));
       
   385 		DEF074623_16MAL();
       
   386 		break;
       
   387 	case 34:
       
   388 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0551"));
       
   389 		TestPaletteCompressionL();
       
   390 		break;
       
   391 	case 35:
       
   392 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0552"));
       
   393 		TestSynchronousBackgroundPaletteCompressionL();
       
   394 		break;
       
   395 	case 36:
       
   396 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0553"));
       
   397 		TestAsynchronousBackgroundPaletteCompressionL();
       
   398 		break;
       
   399 	case 37:
       
   400 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0501"));
       
   401 		GetAllBitmapsIdsL();
       
   402 		break;
       
   403 	case 38:
       
   404 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0554"));
       
   405 		CheckBadBmp();
       
   406 		break; 
       
   407 	case 39:
       
   408 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0516"));
       
   409 		CheckSetDisplayModeL();
       
   410 		break; 	
       
   411 	case 40:
       
   412 /**
       
   413 	@SYMTestCaseID GRAPHICS-FBSERV-0619
       
   414 */
       
   415 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0619"));
       
   416 		MultiThreadedTestsL();
       
   417 		break;
       
   418 	case 41:
       
   419 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0612"));
       
   420 		TestBgCompressL();
       
   421 		break;
       
   422 	case 42:
       
   423 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0613"));
       
   424 		TestBgCompressInUseL();
       
   425 		break;
       
   426 	case 43:
       
   427 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0614"));
       
   428 		TestDisconnectWithBitmapL();
       
   429 		break;
       
   430 	case 44:
       
   431 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0617"));
       
   432 		TestTouchedAndVolatileL();
       
   433 		break;
       
   434 	case 45:
       
   435 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0618"));
       
   436 		TestBitmapWhiteFillL();
       
   437 		break;
       
   438 	case 46:
       
   439 		((CTBitmapStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
   440 		((CTBitmapStep*)iStep)->CloseTMSGraphicsStep();
       
   441 		TestComplete();
       
   442 		break;
       
   443 	default:
       
   444 		((CTBitmapStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
   445 		break;
       
   446 		}
       
   447 		
       
   448 	((CTBitmapStep*)iStep)->RecordTestResultL();
       
   449     }
       
   450    
       
   451 /**
       
   452 	@SYMTestCaseID
       
   453 	GRAPHICS-FBSERV-0516
       
   454 
       
   455 	@SYMTestCaseDesc
       
   456 	Checks that the display mode can be set 
       
   457 	to various modes, including EColor16MAP
       
   458 	
       
   459 	@SYMTestActions
       
   460 	
       
   461 	@SYMTestExpectedResults
       
   462 	Test should pass
       
   463 */  
       
   464 void CTBitmap::CheckSetDisplayModeL()
       
   465 	{
       
   466 	INFO_PRINTF1(_L("Check SetDisplayMode EColor16MAP"));
       
   467 
       
   468 	CFbsBitmap bmp;
       
   469 	User::LeaveIfError(bmp.Create(TSize(4,4),EColor16MA));
       
   470 	TInt ret=bmp.SetDisplayMode(EColor16MAP);
       
   471 	TEST(ret==KErrNone);
       
   472 	bmp.Reset();
       
   473 
       
   474 	User::LeaveIfError(bmp.Create(TSize(4,4),EColor16MU));
       
   475 	ret=bmp.SetDisplayMode(EColor16MAP);
       
   476 	TEST(ret==KErrNone);
       
   477 	bmp.Reset();
       
   478 
       
   479 	User::LeaveIfError(bmp.Create(TSize(4,4),EColor64K));
       
   480 	ret=bmp.SetDisplayMode(EColor16MAP);
       
   481 	TEST(ret==KErrArgument);
       
   482 	bmp.Reset();
       
   483 
       
   484 	User::LeaveIfError(bmp.Create(TSize(4,4),EColor16MAP));
       
   485 	ret=bmp.SetDisplayMode(EColor16MAP);
       
   486 	TEST(ret==KErrNone);
       
   487 
       
   488 	ret=bmp.SetDisplayMode(EColor16MU);
       
   489 	TEST(ret==KErrNone);
       
   490 	bmp.Reset();
       
   491 	
       
   492 	}    
       
   493 
       
   494 /**
       
   495 	@SYMTestCaseID
       
   496 	GRAPHICS-FBSERV-0517
       
   497 
       
   498 	@SYMTestCaseDesc
       
   499 	Compares a pixel retrieved with GetPixel and GetScanLine
       
   500 
       
   501 	@SYMTestActions
       
   502 	Zero fills a buffer which has an uneven length of bytes and
       
   503 	gets a pixel from a point which should coincide with
       
   504 	that of a point retrieved with scan line
       
   505 		
       
   506 	@SYMTestExpectedResults
       
   507 	Test should pass
       
   508 */
       
   509 void CTBitmap::CheckScanlineL()
       
   510 	{
       
   511 	INFO_PRINTF1(_L("Scanline sanity check"));
       
   512 
       
   513 	CFbsBitmap bmp;
       
   514 	User::LeaveIfError(bmp.Create(TSize(32,1),EGray2));
       
   515 
       
   516 	// try using a buffer that isn't a whole number of words long. 
       
   517 	TUint8 buffer[3];
       
   518 	Mem::FillZ(buffer,3);
       
   519 	TPtr8 scanline(buffer,3,3);
       
   520 	bmp.GetScanLine(scanline,TPoint(0,0),24,EGray2);
       
   521 
       
   522 	TRgb pixel(KRgbRed);
       
   523 	bmp.GetPixel(pixel,TPoint(0,0));
       
   524 
       
   525 	// getscanline and getpixel should agree
       
   526 	TEST(TRgb::Gray2(buffer[0] & 0x01) == pixel);
       
   527 
       
   528 	bmp.Reset();
       
   529 
       
   530 	
       
   531 	}
       
   532 
       
   533 /**
       
   534 	@SYMTestCaseID
       
   535 	GRAPHICS-FBSERV-0518
       
   536 
       
   537 	@SYMTestCaseDesc
       
   538 	Streams different bitmap size of different colour depth.
       
   539 
       
   540 	@SYMTestActions
       
   541 
       
   542 	
       
   543 	@SYMTestExpectedResults
       
   544 	Test should pass
       
   545 */
       
   546 void CTBitmap::StreamBitmap()
       
   547 	{
       
   548 	INFO_PRINTF1(_L("Test Bitmap Streaming"));
       
   549 
       
   550 	DoStreamBitmapSizes(EGray2);
       
   551 	DoStreamBitmapSizes(EGray4);
       
   552 	DoStreamBitmapSizes(EGray16);
       
   553 	DoStreamBitmapSizes(EGray256);
       
   554 	DoStreamBitmapSizes(EColor16);
       
   555 	DoStreamBitmapSizes(EColor256);
       
   556 	DoStreamBitmapSizes(EColor4K);
       
   557 	DoStreamBitmapSizes(EColor64K);
       
   558 	DoStreamBitmapSizes(EColor16M);
       
   559 	DoStreamBitmapSizes(EColor16MU);
       
   560 	DoStreamBitmapSizes(EColor16MAP);
       
   561 	}
       
   562 
       
   563 void CTBitmap::DoStreamBitmapSizes(TDisplayMode aDispMode)
       
   564 	{
       
   565 	const TSize smallStreamBitmapSize(32,10);
       
   566 	const TSize largeStreamBitmapSize(256,256);
       
   567 	const TSize oddStreamBitmapSize(31,2);
       
   568 
       
   569 	DoStreamBitmap(smallStreamBitmapSize,aDispMode,ETrue);
       
   570 	DoStreamBitmap(smallStreamBitmapSize,aDispMode,EFalse);
       
   571 	DoStreamBitmap(largeStreamBitmapSize,aDispMode,ETrue);
       
   572 	DoStreamBitmap(largeStreamBitmapSize,aDispMode,EFalse);
       
   573 	DoStreamBitmap(oddStreamBitmapSize,aDispMode,ETrue);
       
   574 	DoStreamBitmap(oddStreamBitmapSize,aDispMode,EFalse);
       
   575 	}
       
   576 
       
   577 void CTBitmap::DoStreamBitmap(const TSize& aSize,TDisplayMode aDispMode,TBool aBlank)
       
   578 	{
       
   579 	__UHEAP_MARK;
       
   580 
       
   581 	CFbsBitmapEx bmp;
       
   582 	TInt ret = bmp.Create(aSize,aDispMode);
       
   583 	TEST2(ret, KErrNone);
       
   584 
       
   585 	if (aBlank)
       
   586 		BlankBitmap(bmp);
       
   587 	else
       
   588 		FillBitmap(bmp);
       
   589 
       
   590 	CDirectFileStore* writestore=NULL;
       
   591 
       
   592 	TRAP(ret,writestore=CDirectFileStore::ReplaceL(iFs,KTempFilename,EFileStream|EFileWrite));
       
   593 	TEST2(ret, KErrNone);
       
   594 
       
   595 	TUidType uidtype(KDirectFileStoreLayoutUid,KMultiBitmapFileImageUid);
       
   596 
       
   597 	TRAP(ret,writestore->SetTypeL(uidtype));
       
   598 	TEST2(ret, KErrNone);
       
   599 
       
   600 	RStoreWriteStream writestrm;
       
   601 	TStreamId headerid(0);
       
   602 
       
   603 	TRAP(ret,headerid=writestrm.CreateL(*writestore));
       
   604 	TEST2(ret, KErrNone);
       
   605 
       
   606 	TRAP(ret,writestore->SetRootL(headerid));
       
   607 	TEST2(ret, KErrNone);
       
   608 
       
   609 	TRAP(ret,bmp.ExternalizeL(writestrm));
       
   610 	TEST2(ret, KErrNone);
       
   611 
       
   612 	writestrm.Close();
       
   613 	delete writestore;
       
   614 
       
   615 	CFbsBitmapEx bmpst;
       
   616 	CDirectFileStore* readstore=NULL;
       
   617 
       
   618 	TRAP(ret,readstore=CDirectFileStore::OpenL(iFs,KTempFilename,EFileStream|EFileRead));
       
   619 	TEST2(ret, KErrNone);
       
   620 
       
   621 	RStoreReadStream readstrm;
       
   622 	headerid=readstore->Root();
       
   623 
       
   624 	TRAP(ret,readstrm.OpenL(*readstore,headerid));
       
   625 	TEST2(ret, KErrNone);
       
   626 
       
   627 	TRAP(ret,bmpst.InternalizeL(readstrm));
       
   628 	TEST2(ret, KErrNone);
       
   629 
       
   630 	readstrm.Close();
       
   631 	delete readstore;
       
   632 
       
   633 	CompareBitmaps(bmp,bmpst,EColor16M);
       
   634 
       
   635 	iFs.Delete(KTempFilename);
       
   636 	bmp.Reset();
       
   637 	bmpst.Reset();
       
   638 	User::Heap().Check();
       
   639 	__UHEAP_MARKEND;
       
   640 	}
       
   641 
       
   642 /**
       
   643 	@SYMTestCaseID
       
   644 	GRAPHICS-FBSERV-0519
       
   645 
       
   646 	@SYMTestCaseDesc
       
   647 	Streams bitmap rectangles of different colour depth
       
   648 	to file store and reads them back again.
       
   649 
       
   650 	@SYMTestActions
       
   651 	Bitmap rectangles are externalized to file store and
       
   652 	read back again. ScanLine is used and compared to GetPixel
       
   653 	from the bitmap read back from file store.
       
   654 	
       
   655 	@SYMTestExpectedResults
       
   656 	Test should pass
       
   657 */
       
   658 void CTBitmap::StreamRectangle()
       
   659 	{
       
   660 	INFO_PRINTF1(_L("Test Rectangle Streaming"));
       
   661 
       
   662 	DoStreamRectangle(EGray2,ETrue);
       
   663 	DoStreamRectangle(EGray2,EFalse);
       
   664 	DoStreamRectangle(EGray4,ETrue);
       
   665 	DoStreamRectangle(EGray4,EFalse);
       
   666 	DoStreamRectangle(EGray16,ETrue);
       
   667 	DoStreamRectangle(EGray16,EFalse);
       
   668 	DoStreamRectangle(EGray256,ETrue);
       
   669 	DoStreamRectangle(EGray256,EFalse);
       
   670 	DoStreamRectangle(EColor16,ETrue);
       
   671 	DoStreamRectangle(EColor16,EFalse);
       
   672 	DoStreamRectangle(EColor256,ETrue);
       
   673 	DoStreamRectangle(EColor256,EFalse);
       
   674 	DoStreamRectangle(EColor4K,ETrue);
       
   675 	DoStreamRectangle(EColor4K,EFalse);
       
   676 	DoStreamRectangle(EColor64K,ETrue);
       
   677 	DoStreamRectangle(EColor64K,EFalse);
       
   678 	DoStreamRectangle(EColor16M,ETrue);
       
   679 	DoStreamRectangle(EColor16M,EFalse);
       
   680 	DoStreamRectangle(EColor16MU,ETrue);
       
   681 	DoStreamRectangle(EColor16MU,EFalse);
       
   682 	DoStreamRectangle(EColor16MAP,ETrue);
       
   683 	DoStreamRectangle(EColor16MAP,EFalse);
       
   684 	}
       
   685 
       
   686 void CTBitmap::DoStreamRectangle(TDisplayMode aDispMode,TBool aBlank)
       
   687 	{
       
   688 	__UHEAP_MARK;
       
   689 	CFbsBitmapEx bmp;
       
   690 	TInt ret = bmp.Create(TSize(160,80),aDispMode);
       
   691 	TEST2(ret, KErrNone);
       
   692 
       
   693 	if (aBlank)
       
   694 		BlankBitmap(bmp);
       
   695 	else
       
   696 		FillBitmap(bmp);
       
   697 
       
   698 	CDirectFileStore* writestore=NULL;
       
   699 	TRAP(ret,writestore=CDirectFileStore::ReplaceL(iFs,KTempFilename,EFileStream|EFileWrite));
       
   700 	TEST2(ret, KErrNone);
       
   701 
       
   702 	TUidType uidtype(KDirectFileStoreLayoutUid,KMultiBitmapFileImageUid);
       
   703 	TRAP(ret,writestore->SetTypeL(uidtype));
       
   704 	TEST2(ret, KErrNone);
       
   705 
       
   706 	RStoreWriteStream writestrm;
       
   707 	TStreamId headerid(0);
       
   708 	TRAP(ret,headerid=writestrm.CreateL(*writestore));
       
   709 	TEST2(ret, KErrNone);
       
   710 
       
   711 	TRAP(ret,writestore->SetRootL(headerid));
       
   712 	TEST2(ret, KErrNone);
       
   713 
       
   714 	TRAP(ret,bmp.ExternalizeRectangleL(writestrm,TRect(40,20,120,60)));
       
   715 	TEST2(ret, KErrNone);
       
   716 
       
   717 	writestrm.Close();
       
   718 	delete writestore;
       
   719 
       
   720 	CFbsBitmapEx bmpst;
       
   721 	CDirectFileStore* readstore=NULL;
       
   722 	TRAP(ret,readstore=CDirectFileStore::OpenL(iFs,KTempFilename,EFileStream|EFileRead));
       
   723 	TEST2(ret, KErrNone);
       
   724 
       
   725 	RStoreReadStream readstrm;
       
   726 	headerid=readstore->Root();
       
   727 	TRAP(ret,readstrm.OpenL(*readstore,headerid));
       
   728 	TEST2(ret, KErrNone);
       
   729 
       
   730 	TRAP(ret,bmpst.InternalizeL(readstrm));
       
   731 	TEST2(ret, KErrNone);
       
   732 
       
   733 	readstrm.Close();
       
   734 	delete readstore;
       
   735 
       
   736 	TInt scanLineLength = CFbsBitmap::ScanLineLength(80,aDispMode);
       
   737 	TUint8* buffer = new TUint8[scanLineLength];
       
   738 	TUint8* bufferst = new TUint8[scanLineLength];
       
   739 	Mem::FillZ(buffer,scanLineLength);
       
   740 	Mem::FillZ(bufferst,scanLineLength);
       
   741 	TPtr8 scanline(buffer,scanLineLength,scanLineLength);
       
   742 	TPtr8 scanlinest(bufferst,scanLineLength,scanLineLength);
       
   743 
       
   744 	for(TInt yy=0;yy<40;yy++)
       
   745 		{
       
   746 		bmp.GetScanLine(scanline,TPoint(40,yy+20),80,aDispMode);
       
   747 		bmpst.GetScanLine(scanlinest,TPoint(0,yy),80,aDispMode);
       
   748 		
       
   749 		if(aDispMode != EColor16MU)
       
   750 			{
       
   751 			TInt memRet = Mem::Compare(buffer,scanLineLength,bufferst,scanLineLength);
       
   752 			TEST(memRet == 0);
       
   753 			}
       
   754 		else
       
   755 			{
       
   756 			TInt pixelsToCompare = scanLineLength / 4;
       
   757 			TUint8* bufferCur = buffer;
       
   758 			TUint8* bufferstCur = bufferst;
       
   759 			
       
   760 			//top byte is unused, and would be more accurate to ignore it
       
   761 			for(TInt ii = 0; ii < pixelsToCompare; ii++)
       
   762 				{
       
   763 				TInt memRet = Mem::Compare(bufferCur,3,bufferstCur,3);
       
   764 				TEST(memRet == 0);
       
   765 				bufferCur += 4;
       
   766 				bufferstCur += 4;
       
   767 				}
       
   768 			}	
       
   769 		}
       
   770 	delete [] bufferst;
       
   771 	delete [] buffer;
       
   772 
       
   773 	iFs.Delete(KTempFilename);
       
   774 	bmp.Reset();
       
   775 	bmpst.Reset();
       
   776 	User::Heap().Check();
       
   777 	__UHEAP_MARKEND;
       
   778 	}
       
   779 
       
   780 /**
       
   781 	@SYMTestCaseID
       
   782 	GRAPHICS-FBSERV-0520
       
   783 
       
   784 	@SYMTestCaseDesc
       
   785 	Calls GetScanLine for different screen modes with
       
   786 	the bitmap compressed and uncompressed and checks
       
   787 	if the pixels are correct.
       
   788 
       
   789 	@SYMTestActions
       
   790 
       
   791 	@SYMTestExpectedResults
       
   792 	Test should pass
       
   793 */
       
   794 void CTBitmap::GetScanline()
       
   795 	{
       
   796 	INFO_PRINTF1(_L("Test GetScanline"));
       
   797 
       
   798 	const TSize size1(257,5);
       
   799 	const TSize size2(33,17);
       
   800 
       
   801 	INFO_PRINTF1(_L("EGray2"));
       
   802 	DoGetScanline(size1,EGray2);
       
   803 	DoGetScanline(size2,EGray2);
       
   804 	DoGetScanlineAlt(EGray2);
       
   805 
       
   806 	INFO_PRINTF1(_L(" EGray4"));
       
   807 	DoGetScanline(size1,EGray4);
       
   808 	DoGetScanline(size2,EGray4);
       
   809 	DoGetScanlineAlt(EGray4);
       
   810 
       
   811 	INFO_PRINTF1(_L(" EGray16"));
       
   812 	DoGetScanline(size1,EGray16);
       
   813 	DoGetScanline(size2,EGray16);
       
   814 	DoGetScanlineAlt(EGray16);
       
   815 
       
   816 	INFO_PRINTF1(_L(" EGray256"));
       
   817 	DoGetScanline(size1,EGray256);
       
   818 	DoGetScanline(size2,EGray256);
       
   819 	DoGetScanlineAlt(EGray256);
       
   820 
       
   821 	INFO_PRINTF1(_L(" EColor16"));
       
   822 	DoGetScanline(size1,EColor16);
       
   823 	DoGetScanline(size2,EColor16);
       
   824 	DoGetScanlineAlt(EColor16);
       
   825 
       
   826 	INFO_PRINTF1(_L(" EColor256"));
       
   827 	DoGetScanline(size1,EColor256);
       
   828 	DoGetScanline(size2,EColor256);
       
   829 	DoGetScanlineAlt(EColor256);
       
   830 
       
   831 	INFO_PRINTF1(_L(" EColor4K"));
       
   832 	DoGetScanline(size1,EColor4K);
       
   833 	DoGetScanline(size2,EColor4K);
       
   834 	DoGetScanlineAlt(EColor4K);
       
   835 
       
   836 	INFO_PRINTF1(_L(" EColor64K"));
       
   837 	DoGetScanline(size1,EColor64K);
       
   838 	DoGetScanline(size2,EColor64K);
       
   839 	DoGetScanlineAlt(EColor64K);
       
   840 
       
   841 	INFO_PRINTF1(_L(" EColor16M"));
       
   842 	DoGetScanline(size1,EColor16M);
       
   843 	DoGetScanline(size2,EColor16M);
       
   844 	DoGetScanlineAlt(EColor16M);
       
   845 
       
   846 	INFO_PRINTF1(_L(" EColor16MA"));
       
   847 	DoGetScanline(size1,EColor16MA);
       
   848 	DoGetScanline(size2,EColor16MA);
       
   849 	DoGetScanlineAlt(EColor16MA);
       
   850 
       
   851 	INFO_PRINTF1(_L(" EColor16MU"));
       
   852 	DoGetScanline(size1,EColor16MU);
       
   853 	DoGetScanline(size2,EColor16MU);
       
   854 	DoGetScanlineAlt(EColor16MU);
       
   855 
       
   856 	INFO_PRINTF1(_L(" EColor16MAP"));
       
   857 	DoGetScanline(size1,EColor16MAP);
       
   858 	DoGetScanline(size2,EColor16MAP);
       
   859 	DoGetScanlineAlt(EColor16MAP);
       
   860 
       
   861 	INFO_PRINTF1(_L("\n"));
       
   862 	}
       
   863 
       
   864 void CTBitmap::DoGetScanline(const TSize& aSize,TDisplayMode aDispMode)
       
   865 	{
       
   866 	__UHEAP_MARK;
       
   867 	CFbsBitmapEx bmp;
       
   868 	TInt ret = bmp.Create(aSize,aDispMode);
       
   869 	TEST2(ret, KErrNone);
       
   870 	FillBitmap(bmp);
       
   871 
       
   872 	DoGetScanlineCheck1(bmp, bmp, aSize, aDispMode);
       
   873 	DoGetScanlineCheck2(bmp, bmp, aSize, aDispMode);
       
   874 	DoGetScanlineCheck3(bmp, aDispMode);
       
   875 
       
   876 	ret = bmp.Create(aSize,aDispMode);
       
   877 	TEST2(ret, KErrNone);
       
   878 
       
   879 	StripeBitmap(bmp);
       
   880 	CFbsBitmapEx ref;
       
   881 	ret = ref.Create(aSize,aDispMode);
       
   882 	TEST2(ret, KErrNone);
       
   883 
       
   884 	CopyBitmap(ref, bmp);
       
   885 	ret = bmp.Compress();
       
   886 	TEST2(ret, KErrNone);
       
   887 
       
   888 	DoGetScanlineCheck1(bmp, ref, aSize, aDispMode);
       
   889 
       
   890 	ref.Reset();
       
   891 	bmp.Reset();
       
   892 	User::Heap().Check();
       
   893 	__UHEAP_MARKEND;
       
   894 	}
       
   895 
       
   896 void CTBitmap::DoGetScanlineCheck1(CFbsBitmap& aBitmap,CFbsBitmap& aReference,const TSize& aSize,TDisplayMode aDispMode)
       
   897 	{
       
   898 	TInt byteWidth = CFbsBitmap::ScanLineLength(aSize.iWidth,aDispMode);
       
   899 	TUint8* buffer = new TUint8[byteWidth + 1];
       
   900 	buffer[byteWidth] = KCheckValue;
       
   901 	TPtr8 scanline(buffer,byteWidth,byteWidth);
       
   902 
       
   903 	for(TInt xStart = 0; xStart <= 33; xStart++)
       
   904 		{
       
   905 		for (TInt xLength = 1; xLength <= 33; xLength++)
       
   906 			{
       
   907 			TInt xEnd = xStart + xLength;
       
   908 			if (xEnd <= aSize.iWidth)
       
   909 				{
       
   910 				aBitmap.GetScanLine(scanline,TPoint(xStart,0),xLength,aDispMode);
       
   911 				for(TInt xx = xStart; xx < xEnd; xx++)
       
   912 					{
       
   913 					TRgb color;
       
   914 					aReference.GetPixel(color,TPoint(xx,0));
       
   915 					TRgb bufferColor = ExtractRgb(buffer,xx - xStart,aDispMode);
       
   916 					TEST(bufferColor == color);
       
   917 					}
       
   918 				}
       
   919 			}
       
   920 		}
       
   921 
       
   922 	for(TInt yy = 0; yy < aSize.iHeight; yy++)
       
   923 		{
       
   924 		aBitmap.GetScanLine(scanline,TPoint(0,yy),aSize.iWidth,aDispMode);
       
   925 		for(TInt xx = 0; xx < aSize.iWidth; xx++)
       
   926 			{
       
   927 			TRgb color;
       
   928 			aReference.GetPixel(color,TPoint(xx,yy));
       
   929 			TRgb bufferColor = ExtractRgb(buffer,xx,aDispMode);
       
   930 			TEST(bufferColor == color);
       
   931 			}
       
   932 		}
       
   933 
       
   934 	TEST(buffer[byteWidth] == KCheckValue);
       
   935 	delete [] buffer;
       
   936 	}
       
   937 
       
   938 void CTBitmap::DoGetScanlineCheck2(CFbsBitmap& aBitmap,CFbsBitmap& aReference,const TSize& aSize,TDisplayMode aDispMode)
       
   939 	{
       
   940 	TInt byteHeight = CFbsBitmap::ScanLineLength(aSize.iHeight,ERgb);
       
   941 	TUint8* buffer = new TUint8[byteHeight];
       
   942 	TPtr8 scanline(buffer,byteHeight,byteHeight);
       
   943 
       
   944 	TInt xx;
       
   945 	for(xx = 0; xx < aSize.iWidth; xx++)
       
   946 		{
       
   947 		aBitmap.GetVerticalScanLine(scanline,xx,aDispMode);
       
   948 		for(TInt yy = 0; yy < aSize.iHeight; yy++)
       
   949 			{
       
   950 			TRgb color;
       
   951 			aReference.GetPixel(color,TPoint(xx,yy));
       
   952 			TRgb bufferColor = ExtractRgb(buffer,yy,aDispMode);
       
   953 			TEST(bufferColor == color);
       
   954 			}
       
   955 		}
       
   956 
       
   957 	for(xx = 0; xx < aSize.iWidth; xx++)
       
   958 		{
       
   959 		aBitmap.GetVerticalScanLine(scanline,xx,ERgb);
       
   960 		for(TInt yy = 0; yy < aSize.iHeight; yy++)
       
   961 			{
       
   962 			TRgb color;
       
   963 			aReference.GetPixel(color,TPoint(xx,yy));
       
   964 			TRgb bufferColor = ExtractRgb(buffer,yy,ERgb);
       
   965 			TEST(bufferColor == color);
       
   966 			}
       
   967 		}
       
   968 
       
   969 	delete [] buffer;
       
   970 	}
       
   971 
       
   972 void CTBitmap::DoGetScanlineCheck3(CFbsBitmap& aBitmap,TDisplayMode aDispMode)
       
   973 	{
       
   974 	TUint32 wordline=0xffffffff;
       
   975 	TPtr8 scanline((TUint8*)&wordline,4,4);
       
   976 	aBitmap.Create(TSize(31,1),aDispMode);
       
   977 	aBitmap.LockHeap();
       
   978 	Mem::Fill(aBitmap.DataAddress(),CFbsBitmap::ScanLineLength(31,aDispMode),0xff);
       
   979 	aBitmap.UnlockHeap();
       
   980 	aBitmap.SetScanLine(scanline,0);
       
   981 	TUint32 expected=0;
       
   982 
       
   983 	for(TInt zz=1;zz<31;zz++)
       
   984 		{
       
   985 		expected|=1<<(zz-1);
       
   986 		wordline=0;
       
   987 		aBitmap.GetScanLine(scanline,TPoint(0,0),zz,EGray2);
       
   988 		TUint32 actual=wordline&expected;
       
   989 		TEST(actual==expected);
       
   990 		}
       
   991 	}
       
   992 
       
   993 /* this function calls CheckScanLine with various screen modes, and with the bitmap
       
   994    compressed, and not compressed
       
   995  */
       
   996 void CTBitmap::DoGetScanlineAlt(TDisplayMode aDispMode)
       
   997 	{
       
   998 	__UHEAP_MARK;
       
   999 
       
  1000 	CFbsBitmapEx bmp;
       
  1001 	TInt ret = bmp.Create(TSize(256,3),aDispMode);
       
  1002 	TEST2(ret, KErrNone);
       
  1003 
       
  1004 	FillBitmap(bmp);
       
  1005 
       
  1006 	CheckScanLine(bmp,bmp,EGray2);
       
  1007 	CheckScanLine(bmp,bmp,EGray4);
       
  1008 	CheckScanLine(bmp,bmp,EGray16);
       
  1009 	CheckScanLine(bmp,bmp,EGray256);
       
  1010 	CheckScanLine(bmp,bmp,EColor16);
       
  1011 	CheckScanLine(bmp,bmp,EColor256);
       
  1012 	CheckScanLine(bmp,bmp,EColor4K);
       
  1013 	CheckScanLine(bmp,bmp,EColor64K);
       
  1014 	CheckScanLine(bmp,bmp,EColor16M);
       
  1015 	CheckScanLine(bmp,bmp,ERgb);
       
  1016 	CheckScanLine(bmp,bmp,EColor16MU);
       
  1017 	CheckScanLine(bmp,bmp,EColor16MAP);
       
  1018 
       
  1019 	CFbsBitmapEx ref;
       
  1020 	ret = ref.Create(bmp.SizeInPixels(),aDispMode);
       
  1021 	TEST2(ret, KErrNone);
       
  1022 	CopyBitmap(ref,bmp);
       
  1023 	bmp.Compress();
       
  1024 
       
  1025 	CheckScanLine(bmp,ref,EGray2);
       
  1026 	CheckScanLine(bmp,ref,EGray4);
       
  1027 	CheckScanLine(bmp,ref,EGray16);
       
  1028 	CheckScanLine(bmp,ref,EGray256);
       
  1029 	CheckScanLine(bmp,ref,EColor16);
       
  1030 	CheckScanLine(bmp,ref,EColor256);
       
  1031 	CheckScanLine(bmp,ref,EColor4K);
       
  1032 	CheckScanLine(bmp,ref,EColor64K);
       
  1033 	CheckScanLine(bmp,ref,EColor16M);
       
  1034 	CheckScanLine(bmp,ref,ERgb);
       
  1035 	CheckScanLine(bmp,ref,EColor16MU);
       
  1036 	CheckScanLine(bmp,ref,EColor16MAP);
       
  1037 
       
  1038 	User::Heap().Check();
       
  1039 	__UHEAP_MARKEND;
       
  1040 	}
       
  1041 
       
  1042 void CTBitmap::CheckScanLine(CFbsBitmapEx& aBitmap,CFbsBitmapEx& aReference,TDisplayMode aDispMode)
       
  1043 	{
       
  1044 	const TSize bmpSize(aBitmap.SizeInPixels());
       
  1045 	TInt byteWidth = CFbsBitmap::ScanLineLength(bmpSize.iWidth,aDispMode);
       
  1046 	TUint8* buffer = new TUint8[byteWidth + 1];
       
  1047 	buffer[byteWidth] = KCheckValue;
       
  1048 	TPtr8 scanLine(buffer,byteWidth,byteWidth);
       
  1049 
       
  1050 	aBitmap.GetScanLine(scanLine,TPoint(0,1),bmpSize.iWidth,aDispMode);
       
  1051 
       
  1052 	for(TInt xx = 0; xx < bmpSize.iWidth; xx++)
       
  1053 		{
       
  1054 		TRgb color;
       
  1055 		aReference.GetPixel(color,TPoint(xx,1));
       
  1056 		TRgb bufferColor = ExtractRgb(buffer,xx,aDispMode);
       
  1057 		switch (aDispMode)
       
  1058 			{
       
  1059 		case EGray2:
       
  1060 			if (color.Gray4() == 0 || color.Gray4() == 3) // doesn't check in great detail because dithering occurs
       
  1061 				TEST(bufferColor.Gray2() == color.Gray2());
       
  1062 			break;
       
  1063 		case EGray4:
       
  1064 			if (aBitmap.DisplayMode() != EGray16) // doesn't check EGray16 because dithering occurs
       
  1065 				TEST(bufferColor.Gray4() == color.Gray4());
       
  1066 			break;
       
  1067 		case EGray16:
       
  1068 			TEST(bufferColor.Gray16() == color.Gray16());
       
  1069 			break;
       
  1070 		case EGray256:
       
  1071 			TEST(bufferColor.Gray256() == color.Gray256());
       
  1072 			break;
       
  1073 		case EColor16:
       
  1074 			TEST(bufferColor.Color16() == color.Color16());
       
  1075 			break;
       
  1076 		case EColor256:
       
  1077 			TEST(bufferColor.Color256() == color.Color256());
       
  1078 			break;
       
  1079 		case EColor4K:
       
  1080 			TEST(bufferColor.Color4K() == color.Color4K());
       
  1081 			break;
       
  1082 		case EColor64K:
       
  1083 			TEST(bufferColor.Color64K() == color.Color64K());
       
  1084 			break;
       
  1085 		case EColor16M:
       
  1086 			TEST(bufferColor.Color16M() == color.Color16M());
       
  1087 			break;
       
  1088 		case ERgb:
       
  1089 			TEST(bufferColor == color);
       
  1090 			break;
       
  1091 		case EColor16MU:
       
  1092 			if (aReference.DisplayMode()==EColor16MAP || aReference.DisplayMode()==EColor16MA)
       
  1093 				color.SetAlpha(0xff);
       
  1094 			CompareColourLikeness(bufferColor, color);			
       
  1095 			break;
       
  1096 		case EColor16MAP:
       
  1097 			//Compare the TRgb values.  For an exact match to work the comparison would
       
  1098 			//need to be done in PMA space.
       
  1099 			color.SetInternal(color.Color16MAP());
       
  1100 			bufferColor.SetInternal(bufferColor.Color16MAP());
       
  1101 			CompareColourLikeness(bufferColor, color);			
       
  1102 			break;	
       
  1103 		default:
       
  1104 			break;
       
  1105 			};
       
  1106 		}
       
  1107 
       
  1108 	TEST(buffer[byteWidth] == KCheckValue);
       
  1109 	delete [] buffer;
       
  1110 	}
       
  1111 
       
  1112 /**
       
  1113 Compares two TRgbs and tests if they are similar colour.
       
  1114 This is required because there may be some rounding errors when converting bitmaps from one display mode to another
       
  1115 or due to alpha blending calculations.
       
  1116 
       
  1117 @param aSrc is the source colour
       
  1118 @param aDest is the destination colour
       
  1119 @param aDifference use this value for colour difference.  Value of 0 use KColourDifference;
       
  1120 */
       
  1121 void CTBitmap::CompareColourLikeness(const TRgb& aSrc, const TRgb& aDest, TInt aDifference)
       
  1122 	{
       
  1123 	const TInt KColourDifference = 2;	// Acceptable difference to check for
       
  1124 	TInt diff;
       
  1125 	
       
  1126 	if (aDifference==0)
       
  1127 		diff=KColourDifference;
       
  1128 	else
       
  1129 		diff=aDifference;
       
  1130 	
       
  1131 	TInt redDiff = Abs(aSrc.Red() - aDest.Red());
       
  1132 	TInt greenDiff = Abs(aSrc.Green() - aDest.Green());	
       
  1133 	TInt blueDiff = Abs(aSrc.Blue() - aDest.Blue());	
       
  1134 	TInt alphaDiff = Abs(aSrc.Alpha() - aDest.Alpha());	
       
  1135 	
       
  1136 	// Test each channel
       
  1137 	TEST(redDiff <= diff);
       
  1138 	TEST(greenDiff <= diff);
       
  1139 	TEST(blueDiff <= diff);
       
  1140 	TEST(alphaDiff <= diff);
       
  1141 	
       
  1142 	// the code below is useful for a breakpoint, to inspect the differences, in case of failure
       
  1143 /**	
       
  1144 	if ((redDiff > diff)||(greenDiff > diff)||(blueDiff > diff)||(alphaDiff > diff))
       
  1145 		TInt temp=1;
       
  1146 */
       
  1147 	}
       
  1148 
       
  1149 /**
       
  1150 	@SYMTestCaseID
       
  1151 	GRAPHICS-FBSERV-0521
       
  1152 
       
  1153 	@SYMTestCaseDesc
       
  1154 	Sets a scanline of random values into
       
  1155 	bitmaps of different color depths
       
  1156 
       
  1157 	@SYMTestActions
       
  1158 	
       
  1159 	@SYMTestExpectedResults
       
  1160 	Test should pass
       
  1161 */
       
  1162 void CTBitmap::SetScanline()
       
  1163 	{
       
  1164 	INFO_PRINTF1(_L("Test SetScanline"));
       
  1165 
       
  1166 	DoSetScanline(EGray2);
       
  1167 	DoSetScanline(EGray4);
       
  1168 	DoSetScanline(EGray16);
       
  1169 	DoSetScanline(EGray256);
       
  1170 	DoSetScanline(EColor16);
       
  1171 	DoSetScanline(EColor256);
       
  1172 	DoSetScanline(EColor4K);
       
  1173 	DoSetScanline(EColor64K);
       
  1174 	DoSetScanline(EColor16M);
       
  1175 	DoSetScanline(EColor16MU);
       
  1176 	DoSetScanline(EColor16MAP);
       
  1177 	}
       
  1178 
       
  1179 void CTBitmap::DoSetScanline(TDisplayMode aDispMode)
       
  1180 	{
       
  1181 	__UHEAP_MARK;
       
  1182 	CFbsBitmap bmp;
       
  1183 
       
  1184 	TInt ret = bmp.Create(TSize(256,2),aDispMode);
       
  1185 	TEST2(ret, KErrNone);
       
  1186 
       
  1187 	TInt scanLineLength = CFbsBitmap::ScanLineLength(256,aDispMode);
       
  1188 	TUint8* buffer = new TUint8[scanLineLength];
       
  1189 	TEST(buffer != NULL);
       
  1190 	TPtr8 scanline(buffer,scanLineLength,scanLineLength);
       
  1191 
       
  1192 	TUint8* bufptr = buffer;
       
  1193 	TInt64 seed = bmp.Handle();
       
  1194 	for(TInt count = 0; count < scanLineLength; count++)
       
  1195 		*bufptr++ = (TUint8)Math::Rand(seed);
       
  1196 
       
  1197 	bmp.SetScanLine(scanline,0);
       
  1198 	bmp.SetScanLine(scanline,1);
       
  1199 
       
  1200 	bmp.LockHeap();
       
  1201 	TUint8* data = (TUint8*)bmp.DataAddress();
       
  1202 	bmp.UnlockHeap();
       
  1203 	ret = Mem::Compare(buffer,scanLineLength,data,scanLineLength);
       
  1204 	TEST(ret == 0);
       
  1205 
       
  1206 	data += scanLineLength;
       
  1207 	ret = Mem::Compare(buffer,scanLineLength,data,scanLineLength);
       
  1208 	TEST(ret == 0);
       
  1209 
       
  1210 	delete [] buffer;
       
  1211 	bmp.Reset();
       
  1212 	User::Heap().Check();
       
  1213 	__UHEAP_MARKEND;
       
  1214 	}
       
  1215 
       
  1216 /**
       
  1217 	@SYMTestCaseID
       
  1218 	GRAPHICS-FBSERV-0522
       
  1219 
       
  1220 	@SYMTestCaseDesc
       
  1221 	Stretches a scan line to make it
       
  1222 	double as long for different colour depths
       
  1223 	tested on both small and large bitmaps.
       
  1224 
       
  1225 	@SYMTestActions
       
  1226 
       
  1227 	@SYMTestExpectedResults
       
  1228 	Test should pass
       
  1229 */
       
  1230 void CTBitmap::StretchScanline()
       
  1231 	{
       
  1232 	INFO_PRINTF1(_L("Test StretchScanline"));
       
  1233 
       
  1234 	const TSize smallBitmapSize(226,2);
       
  1235 	const TSize largeBitmapSize(1026,40);
       
  1236 
       
  1237 	INFO_PRINTF1(_L("EGray2"));
       
  1238 	DoStretchScanline(smallBitmapSize,EGray2);
       
  1239 	DoStretchScanline(largeBitmapSize,EGray2);
       
  1240 
       
  1241 	INFO_PRINTF1(_L(" EGray4"));
       
  1242 	DoStretchScanline(smallBitmapSize,EGray4);
       
  1243 	DoStretchScanline(largeBitmapSize,EGray4);
       
  1244 
       
  1245 	INFO_PRINTF1(_L(" EGray16"));
       
  1246 	DoStretchScanline(smallBitmapSize,EGray16);
       
  1247 	DoStretchScanline(largeBitmapSize,EGray16);
       
  1248 
       
  1249 	INFO_PRINTF1(_L(" EGray256"));
       
  1250 	DoStretchScanline(smallBitmapSize,EGray256);
       
  1251 	DoStretchScanline(largeBitmapSize,EGray256);
       
  1252 
       
  1253 	INFO_PRINTF1(_L(" EColor16"));
       
  1254 	DoStretchScanline(smallBitmapSize,EColor16);
       
  1255 	DoStretchScanline(largeBitmapSize,EColor16);
       
  1256 
       
  1257 	INFO_PRINTF1(_L(" EColor256"));
       
  1258 	DoStretchScanline(smallBitmapSize,EColor256);
       
  1259 	DoStretchScanline(largeBitmapSize,EColor256);
       
  1260 
       
  1261 	INFO_PRINTF1(_L(" EColor4K"));
       
  1262 	DoStretchScanline(smallBitmapSize,EColor4K);
       
  1263 	DoStretchScanline(largeBitmapSize,EColor4K);
       
  1264 
       
  1265 	INFO_PRINTF1(_L(" EColor64K"));
       
  1266 	DoStretchScanline(smallBitmapSize,EColor64K);
       
  1267 	DoStretchScanline(largeBitmapSize,EColor64K);
       
  1268 
       
  1269 	INFO_PRINTF1(_L(" EColor16M"));
       
  1270 	DoStretchScanline(smallBitmapSize,EColor16M);
       
  1271 	DoStretchScanline(largeBitmapSize,EColor16M);
       
  1272 
       
  1273 	INFO_PRINTF1(_L(" EColor16MU"));
       
  1274 	DoStretchScanline(smallBitmapSize,EColor16MU);
       
  1275 	DoStretchScanline(largeBitmapSize,EColor16MU);
       
  1276 	
       
  1277 	INFO_PRINTF1(_L(" EColor16MA"));
       
  1278 	DoStretchScanline(smallBitmapSize,EColor16MA);
       
  1279 	DoStretchScanline(largeBitmapSize,EColor16MA);
       
  1280 
       
  1281 	INFO_PRINTF1(_L(" EColor16MAP"));
       
  1282 	DoStretchScanline(smallBitmapSize,EColor16MAP);
       
  1283 	DoStretchScanline(largeBitmapSize,EColor16MAP);
       
  1284 	
       
  1285 	DoStretchScanline(smallBitmapSize,EColor16MAP,EColor16M, ETrue);
       
  1286 	DoStretchScanline(largeBitmapSize,EColor16MAP,EColor16M, ETrue);
       
  1287 	DoStretchScanline(smallBitmapSize,EColor16MAP,EColor16MU, ETrue);
       
  1288 	DoStretchScanline(largeBitmapSize,EColor16MAP,EColor16MU, ETrue);
       
  1289 	DoStretchScanline(smallBitmapSize,EColor16MAP,EColor16MA, ETrue);
       
  1290 	DoStretchScanline(largeBitmapSize,EColor16MAP,EColor16MA, ETrue);
       
  1291 	DoStretchScanline(smallBitmapSize,EColor16MAP,EColor64K, ETrue);
       
  1292 	DoStretchScanline(largeBitmapSize,EColor16MAP,EColor64K, ETrue);
       
  1293 	DoStretchScanline(smallBitmapSize,EColor16MAP,EColor4K, ETrue);
       
  1294 	DoStretchScanline(largeBitmapSize,EColor16MAP,EColor4K, ETrue);
       
  1295 	DoStretchScanline(smallBitmapSize,EColor16MAP,EColor256, ETrue);
       
  1296 	DoStretchScanline(largeBitmapSize,EColor16MAP,EColor256, ETrue);
       
  1297 	
       
  1298 	DoStretchScanline(smallBitmapSize,EColor16M,EColor16MAP, ETrue);
       
  1299 	DoStretchScanline(largeBitmapSize,EColor16M,EColor16MAP, ETrue);
       
  1300 	DoStretchScanline(smallBitmapSize,EColor16MU,EColor16MAP, ETrue);
       
  1301 	DoStretchScanline(largeBitmapSize,EColor16MU,EColor16MAP, ETrue);
       
  1302 	DoStretchScanline(smallBitmapSize,EColor16MA,EColor16MAP, ETrue);
       
  1303 	DoStretchScanline(largeBitmapSize,EColor16MA,EColor16MAP, ETrue);
       
  1304 	DoStretchScanline(smallBitmapSize,EColor64K,EColor16MAP, ETrue);
       
  1305 	DoStretchScanline(largeBitmapSize,EColor64K,EColor16MAP, ETrue);
       
  1306 	DoStretchScanline(smallBitmapSize,EColor4K,EColor16MAP, ETrue);
       
  1307 	DoStretchScanline(largeBitmapSize,EColor4K,EColor16MAP, ETrue);
       
  1308 	DoStretchScanline(smallBitmapSize,EColor256,EColor16MAP, ETrue);
       
  1309 	DoStretchScanline(largeBitmapSize,EColor256,EColor16MAP, ETrue);
       
  1310 	
       
  1311 	DoStretchScanline(smallBitmapSize,EColor16MU,EColor16M, ETrue);
       
  1312 	DoStretchScanline(largeBitmapSize,EColor16MU,EColor16M, ETrue);
       
  1313 	
       
  1314 	INFO_PRINTF1(_L("\n"));
       
  1315 	}
       
  1316 
       
  1317 void CTBitmap::DoStretchScanline(const TSize& aSize,TDisplayMode aDispMode)
       
  1318 	{
       
  1319 	DoStretchScanline(aSize,aDispMode,aDispMode, EFalse);
       
  1320 	}
       
  1321 
       
  1322 /* this function is used to determine an acceptable colour difference based on the screen mode 
       
  1323    and the alpha value.  This is because when converting from PMA to non pre-multiplied, there
       
  1324    can be large errors, especially if alpha is small.
       
  1325  */	
       
  1326 TInt CTBitmap::ColorDifference(TDisplayMode aMode, TInt aAlpha)
       
  1327 	{
       
  1328 	switch (aMode)
       
  1329 		{
       
  1330 	case EGray2:// Monochrome display mode (1 bpp)
       
  1331 		return 0xff>>1;
       
  1332 	case EGray4:// Four grayscales display mode (2 bpp)
       
  1333 		return 0xff>>2;
       
  1334 	case EGray16:// 16 grayscales display mode (4 bpp)
       
  1335 		return 0xff>>2;
       
  1336 	case EGray256:// 256 grayscales display mode (8 bpp)
       
  1337 		return 0xff>>2;
       
  1338 	case EColor16:// Low colour EGA 16 colour display mode (4 bpp)
       
  1339 		return 0xff>>2;
       
  1340 	case EColor256: // 256 colour display mode (8 bpp)
       
  1341 		return 0xff>>2;
       
  1342 	case EColor64K: // 64,000 colour display mode (16 bpp) 
       
  1343 		return 0xff>>5;
       
  1344 	case EColor16M: // True colour display mode (24 bpp)
       
  1345 		return 0xff>>5;
       
  1346 	case EColor4K: // 4096 colour display (12 bpp).
       
  1347 		return 0xff>>4;
       
  1348 	case EColor16MU:// True colour display mode (32 bpp, but top byte is unused and unspecified)
       
  1349 		return 0xff>>5;
       
  1350 	case EColor16MA:// Display mode with alpha (24bpp colour plus 8bpp alpha)
       
  1351 		return 0xff>>6;
       
  1352 	case EColor16MAP:// Pre-multiplied Alpha display mode (24bpp color multiplied with the alpha channel value, plus 8bpp alpha)
       
  1353 		if (aAlpha==0xff)
       
  1354 			return 0xff>>4;
       
  1355 		else
       
  1356 			//make inaccuracy a function of alpha since the colour will the premultiplied, and then
       
  1357 			//unpremultiplied.  For small alpha this can be quite large.
       
  1358 			if (aAlpha==0)
       
  1359 				return 0xff;
       
  1360 			else
       
  1361 				return Max(0xff>>4,Min(0xff,(0xff/aAlpha)+0xf));//value corrected by trial and error, with minimum of 15.
       
  1362 		}
       
  1363 	return 0xff>>7;	
       
  1364 	}
       
  1365 
       
  1366 void CTBitmap::DoStretchScanline(const TSize& aSize,TDisplayMode aSrcMode,TDisplayMode aDstMode, TBool aUseCompareLikeness)
       
  1367 	{
       
  1368 	__UHEAP_MARK;
       
  1369 	CFbsBitmapEx bmp;
       
  1370 	CBitwiseBitmap* bmpadd=NULL;
       
  1371 
       
  1372 	TInt ret = bmp.Create(aSize,aSrcMode);
       
  1373 	TEST2(ret, KErrNone);
       
  1374 
       
  1375 	FillBitmap(bmp);
       
  1376 	bmpadd = bmp.BitmapAddress();
       
  1377 	bmp.LockHeap();
       
  1378 	TUint32* base = bmp.DataAddress();
       
  1379 	bmp.UnlockHeap();
       
  1380 
       
  1381 	TInt scanLineLength = CFbsBitmap::ScanLineLength(aSize.iWidth,aSrcMode);
       
  1382 	TInt scanLineDestLength = CFbsBitmap::ScanLineLength(aSize.iWidth,aDstMode)*2;
       
  1383 	TUint8* buffer = new TUint8[scanLineLength];
       
  1384 	TUint8* doubleBuffer = new TUint8[scanLineDestLength];
       
  1385 	TPtr8 scanline(buffer,scanLineLength,scanLineLength);
       
  1386 	TPtr8 doubleScanline(doubleBuffer,scanLineDestLength,scanLineDestLength);
       
  1387 
       
  1388 	TInt yy;
       
  1389 	for(yy = 0; yy < aSize.iHeight; yy++)
       
  1390 		{
       
  1391 		bmp.GetScanLine(scanline,TPoint(0,yy),aSize.iWidth,aSrcMode);
       
  1392 		bmpadd->StretchScanLine(doubleScanline,TPoint(0,yy),0,aSize.iWidth * 2,aSize.iWidth * 2,0,aSize.iWidth,TPoint(0,0),aDstMode,base);
       
  1393 		for(TInt xx = 0; xx < aSize.iWidth; xx++)
       
  1394 			{
       
  1395 			TRgb scanlineColor = ExtractRgb(buffer,xx,aSrcMode);
       
  1396 			TRgb firstStretchColor = ExtractRgb(doubleBuffer,xx * 2,aDstMode);
       
  1397 			TRgb secondStretchColor = ExtractRgb(doubleBuffer,(xx * 2) + 1,aDstMode);
       
  1398 			TRgb reportedColor;
       
  1399 			bmpadd->GetPixel(reportedColor,TPoint(xx,yy),base,NULL);
       
  1400 			if (!aUseCompareLikeness)
       
  1401 				{
       
  1402 				TEST(scanlineColor == firstStretchColor);
       
  1403 				TEST(firstStretchColor == secondStretchColor);
       
  1404 				TEST(secondStretchColor == reportedColor);
       
  1405 				}
       
  1406 			else
       
  1407 				{
       
  1408 				if (aDstMode==EColor16M||aDstMode==EColor16MU||aDstMode==EColor64K||aDstMode==EColor4K||aDstMode==EColor256)
       
  1409 					{
       
  1410 					//there is no alpha in the destination
       
  1411 					scanlineColor.SetAlpha(0xff);
       
  1412 					reportedColor.SetAlpha(0xff);	
       
  1413 					}	
       
  1414 				CompareColourLikeness(scanlineColor, firstStretchColor, ColorDifference(aDstMode,scanlineColor.Alpha()));
       
  1415 				CompareColourLikeness(firstStretchColor, secondStretchColor,ColorDifference(aDstMode,scanlineColor.Alpha()));
       
  1416 				CompareColourLikeness(secondStretchColor, reportedColor,ColorDifference(aDstMode,scanlineColor.Alpha()));
       
  1417 				}
       
  1418 			}
       
  1419 		}
       
  1420 
       
  1421 	for(yy = 0; yy < aSize.iHeight; yy++)
       
  1422 		{
       
  1423 		bmp.GetScanLine(scanline,TPoint(0,yy),aSize.iWidth,aSrcMode);
       
  1424 		bmpadd->StretchScanLine(doubleScanline,TPoint(0,yy),0,aSize.iWidth / 2,aSize.iWidth / 2,0,aSize.iWidth,TPoint(0,0),aDstMode,base);
       
  1425 		for(TInt xx = 0; xx < aSize.iWidth; xx += 2)
       
  1426 			{
       
  1427 			TRgb scanlineColor = ExtractRgb(buffer,xx,aSrcMode);
       
  1428 			TRgb compressColor = ExtractRgb(doubleBuffer,xx / 2,aDstMode);
       
  1429 			TRgb reportedColor;
       
  1430 			bmpadd->GetPixel(reportedColor,TPoint(xx,yy),base,NULL);
       
  1431 			if (!aUseCompareLikeness)
       
  1432 				{
       
  1433 				TEST(scanlineColor == compressColor);
       
  1434 				TEST(compressColor == reportedColor);
       
  1435 				}
       
  1436 			else
       
  1437 				{
       
  1438 				if (aDstMode==EColor16M||aDstMode==EColor16MU||aDstMode==EColor64K||aDstMode==EColor4K||aDstMode==EColor256)
       
  1439 					{
       
  1440 					//there is no alpha in the destination
       
  1441 					scanlineColor.SetAlpha(0xff);
       
  1442 					reportedColor.SetAlpha(0xff);	
       
  1443 					}
       
  1444 				CompareColourLikeness(scanlineColor, compressColor,ColorDifference(aDstMode,scanlineColor.Alpha()));
       
  1445 				CompareColourLikeness(compressColor, reportedColor,ColorDifference(aDstMode,scanlineColor.Alpha()));
       
  1446 				}
       
  1447 			}
       
  1448 		}
       
  1449 
       
  1450 	delete [] buffer;
       
  1451 	delete [] doubleBuffer;
       
  1452 	buffer = NULL;
       
  1453 	doubleBuffer = NULL;
       
  1454 
       
  1455 	TInt rgbScanLineLength = aSize.iWidth * sizeof(TRgb) * 2;
       
  1456 	TUint8* rgbBuffer = new TUint8[rgbScanLineLength];
       
  1457 	TPtr8 rgbScanline(rgbBuffer,rgbScanLineLength,rgbScanLineLength);
       
  1458 
       
  1459 	for(yy = 0; yy < aSize.iHeight; yy++)
       
  1460 		{
       
  1461 		bmpadd->StretchScanLine(rgbScanline,TPoint(0,yy),0,aSize.iWidth * 2,aSize.iWidth * 2,0,aSize.iWidth,TPoint(0,0),ERgb,base);
       
  1462 		for(TInt xx = 0; xx < aSize.iWidth; xx++)
       
  1463 			{
       
  1464 			TRgb firstStretchColor = ExtractRgb(rgbBuffer,xx * 2,ERgb);
       
  1465 			TRgb secondStretchColor = ExtractRgb(rgbBuffer,(xx * 2) + 1,ERgb);
       
  1466 			TRgb reportedColor;
       
  1467 			bmpadd->GetPixel(reportedColor,TPoint(xx,yy),base,NULL);
       
  1468 			if (!aUseCompareLikeness)
       
  1469 				{
       
  1470 				TEST(firstStretchColor == secondStretchColor);
       
  1471 				TEST(secondStretchColor == reportedColor);
       
  1472 				}
       
  1473 			else
       
  1474 				{
       
  1475 				CompareColourLikeness(firstStretchColor, secondStretchColor);
       
  1476 				CompareColourLikeness(secondStretchColor, reportedColor);
       
  1477 				}
       
  1478 			}
       
  1479 		}
       
  1480 
       
  1481 	for(yy = 0; yy < aSize.iHeight; yy++)
       
  1482 		{
       
  1483 		bmpadd->StretchScanLine(rgbScanline,TPoint(0,yy),0,aSize.iWidth / 2,aSize.iWidth / 2,0,aSize.iWidth,TPoint(0,0),ERgb,base);
       
  1484 		for(TInt xx = 0; xx < aSize.iWidth; xx += 2)
       
  1485 			{
       
  1486 			TRgb compressColor = ExtractRgb(rgbBuffer,xx / 2,ERgb);
       
  1487 			TRgb reportedColor;
       
  1488 			bmpadd->GetPixel(reportedColor,TPoint(xx,yy),base,NULL);
       
  1489 			if (!aUseCompareLikeness)
       
  1490 				{
       
  1491 				TEST(compressColor == reportedColor);
       
  1492 				}
       
  1493 			else
       
  1494 				{
       
  1495 				CompareColourLikeness(compressColor, reportedColor);
       
  1496 				}
       
  1497 			}
       
  1498 		}
       
  1499 
       
  1500 	delete [] rgbBuffer;
       
  1501 	rgbBuffer = NULL;
       
  1502 
       
  1503 	bmp.Reset();
       
  1504 	User::Heap().Check();
       
  1505 	DeleteScanLineBuffer();
       
  1506 	__UHEAP_MARKEND;
       
  1507 	}
       
  1508 
       
  1509 TRgb CTBitmap::ExtractRgb(TUint8* aBuffer,TInt aPixelOffset,TDisplayMode aDispMode)
       
  1510 	{
       
  1511 	switch (aDispMode)
       
  1512 		{
       
  1513 	case EGray2:
       
  1514 		{
       
  1515 		TUint8 byte = *(aBuffer + (aPixelOffset >> 3));
       
  1516 		if (byte & (1 << (aPixelOffset & 7)))
       
  1517 			return KRgbWhite;
       
  1518 		return KRgbBlack;
       
  1519 		}
       
  1520 	case EGray4:
       
  1521 		{
       
  1522 		TUint8 byte = *(aBuffer + (aPixelOffset >> 2));
       
  1523 		byte >>= ((aPixelOffset & 3) << 1);
       
  1524 		return TRgb::Gray4(byte & 3);
       
  1525 		}
       
  1526 	case EGray16:
       
  1527 		{
       
  1528 		TUint8 byte = *(aBuffer + (aPixelOffset >> 1));
       
  1529 		if (aPixelOffset & 1)
       
  1530 			byte >>= 4;
       
  1531 		return TRgb::Gray16(byte & 0xf);
       
  1532 		}
       
  1533 	case EGray256:
       
  1534 		return TRgb::Gray256(*(aBuffer + aPixelOffset));
       
  1535 	case EColor16:
       
  1536 		{
       
  1537 		TUint8 byte = *(aBuffer + (aPixelOffset >> 1));
       
  1538 		if (aPixelOffset & 1)
       
  1539 			byte >>= 4;
       
  1540 		return TRgb::Color16(byte & 0xf);
       
  1541 		}
       
  1542 	case EColor256:
       
  1543 		return TRgb::Color256(*(aBuffer + aPixelOffset));
       
  1544 	case EColor4K:
       
  1545 		{
       
  1546 		TUint16 doubleByte = *(((TUint16*)aBuffer) + aPixelOffset);
       
  1547 		return TRgb::Color4K(doubleByte & 0xfff);
       
  1548 		}
       
  1549 	case EColor64K:
       
  1550 		{
       
  1551 		TUint16 doubleByte = *(((TUint16*)aBuffer) + aPixelOffset);
       
  1552 		return TRgb::Color64K(doubleByte);
       
  1553 		}
       
  1554 	case EColor16M:
       
  1555 		{
       
  1556 		aBuffer += aPixelOffset * 3;
       
  1557 		TInt value = *aBuffer++;
       
  1558 		value |= *aBuffer++ << 8;
       
  1559 		value |= *aBuffer << 16;
       
  1560 		return TRgb::Color16M(value);
       
  1561 		}
       
  1562 	case ERgb:
       
  1563 		return *(((TRgb*)aBuffer) + aPixelOffset);
       
  1564 	case EColor16MU:
       
  1565 		{
       
  1566 		return TRgb::Color16MU(*(((TUint32*)aBuffer) + aPixelOffset));
       
  1567 		}
       
  1568 	case EColor16MA:
       
  1569 		{
       
  1570 		return TRgb::Color16MA(*(((TUint32*)aBuffer) + aPixelOffset));
       
  1571 		}	
       
  1572 	case EColor16MAP:
       
  1573 		{
       
  1574 		return TRgb::_Color16MAP(*(((TUint32*)aBuffer) + aPixelOffset));
       
  1575 		}	
       
  1576 	default:
       
  1577 		break;
       
  1578 		};
       
  1579 	return KRgbBlack;
       
  1580 	}
       
  1581 	
       
  1582 /**
       
  1583 	@SYMTestCaseID
       
  1584 	GRAPHICS-FBSERV-0523
       
  1585 
       
  1586 	@SYMTestCaseDesc
       
  1587 	Streams a bitmap in segments and compares it
       
  1588 	to an expected bitmap
       
  1589 	
       
  1590 	@SYMTestActions
       
  1591 	
       
  1592 	@SYMTestExpectedResults
       
  1593 	Test should pass
       
  1594 */
       
  1595 void CTBitmap::LoadInSegments()
       
  1596 	{
       
  1597 	INFO_PRINTF1(_L("Test Segmented Loading"));
       
  1598 
       
  1599 	__UHEAP_MARK;
       
  1600 	CFbsBitmapEx bmp;
       
  1601 	TInt ret=bmp.Load(iTestBitmapName,ETfbs,NULL);
       
  1602 	TEST2(ret, KErrNone);
       
  1603 	CFbsBitmapAsyncStreamer* bmploader=NULL;
       
  1604 	TRAP(ret,bmploader=CFbsBitmapAsyncStreamer::NewL(CFbsBitmapAsyncStreamer::ELoad));
       
  1605 	TEST2(ret, KErrNone);
       
  1606 	TInt slines=0;
       
  1607 	ret=bmploader->Load(iTestBitmapName,ETfbs,slines);
       
  1608 	TEST2(ret, KErrNone);
       
  1609 	TEST(slines>0);
       
  1610 	CFbsBitmap* newbmp=NULL;
       
  1611 	TBool done=EFalse;
       
  1612 	do	{
       
  1613 		TEST(newbmp==NULL);
       
  1614 		TRAP(ret,done=bmploader->LoadScanLinesL(slines/10,newbmp));
       
  1615 		TEST2(ret, KErrNone);
       
  1616 		}
       
  1617 	while(!done);
       
  1618 
       
  1619 	TEST(newbmp!=NULL);
       
  1620 	CompareBitmaps(bmp,(CFbsBitmapEx&)*newbmp,EColor16M);
       
  1621 	delete bmploader;
       
  1622 	delete newbmp;
       
  1623 
       
  1624 	TRAP(ret,iBmpHandler=CFbsBitmapAsyncStreamer::NewL(CFbsBitmapAsyncStreamer::ELoad));
       
  1625 	TEST2(ret, KErrNone);
       
  1626 	ret=iBmpHandler->Load(iTestBitmapName,ETfbs,slines);
       
  1627 	TEST2(ret, KErrNone);
       
  1628 	TEST(slines>0);
       
  1629 	CIdle* idleobj=CIdle::New(-20);
       
  1630 	TEST(idleobj!=NULL);
       
  1631 	TCallBack callback(BmpLoadCallBack,this);
       
  1632 	idleobj->Start(callback);
       
  1633 	
       
  1634 	CActiveScheduler* as = CActiveScheduler::Current();
       
  1635 	__ASSERT_DEBUG(as, User::Invariant());
       
  1636 	
       
  1637 	TRAP(ret,as->Start());
       
  1638 	TEST2(ret, KErrNone);
       
  1639 	
       
  1640 	CompareBitmaps(bmp,(CFbsBitmapEx&)*iBitmap,EColor16M);
       
  1641 
       
  1642 	delete iBmpHandler;
       
  1643 	delete iBitmap;
       
  1644 	bmp.Reset();
       
  1645 	delete idleobj;
       
  1646 	User::Heap().Check();
       
  1647 	__UHEAP_MARKEND;
       
  1648 
       
  1649 	
       
  1650 	}
       
  1651 
       
  1652 TInt CTBitmap::BmpLoadCallBack(TAny* aPtr)
       
  1653 	{
       
  1654 	CTBitmap* tbmp=(CTBitmap*)aPtr;
       
  1655 	tbmp->INFO_PRINTF1(_L("*"));
       
  1656 	TBool done=EFalse;
       
  1657 	TRAPD(ret,done=tbmp->iBmpHandler->LoadScanLinesL(10,tbmp->iBitmap));
       
  1658 	tbmp->TEST2(ret, KErrNone);
       
  1659 	if(done)
       
  1660 		{
       
  1661 		tbmp->TEST(tbmp->iBitmap!=NULL);
       
  1662 		CActiveScheduler::Stop();
       
  1663 		}
       
  1664 	else 
       
  1665 		{
       
  1666 		tbmp->TEST(tbmp->iBitmap==NULL);
       
  1667 		}
       
  1668 	return(ETrue);
       
  1669 	}
       
  1670 	
       
  1671 /**
       
  1672 	@SYMTestCaseID
       
  1673 	GRAPHICS-FBSERV-0524
       
  1674 
       
  1675 	@SYMTestCaseDesc
       
  1676 	A bitmap is saved in segments and then read back from file store
       
  1677 	and compared to an expected bitmap
       
  1678 
       
  1679 	@SYMTestActions
       
  1680 	
       
  1681 	@SYMTestExpectedResults
       
  1682 	Test should pass
       
  1683 */	
       
  1684 void CTBitmap::SaveInSegments()
       
  1685 	{
       
  1686 	INFO_PRINTF1(_L("Test Segmented Saving"));
       
  1687 
       
  1688 	__UHEAP_MARK;
       
  1689 	CFbsBitmapEx bmp;
       
  1690 	TInt ret=bmp.Load(iTestBitmapName,ETfbs,NULL);
       
  1691 	TEST2(ret, KErrNone);
       
  1692 	CFbsBitmapAsyncStreamer* bmpsaver=NULL;
       
  1693 	TRAP(ret,bmpsaver=CFbsBitmapAsyncStreamer::NewL(CFbsBitmapAsyncStreamer::ESave));
       
  1694 	TEST2(ret, KErrNone);
       
  1695 	TInt slines=0;
       
  1696 	TInt32 id;
       
  1697 	ret=bmpsaver->Save(KTempFilename,&bmp,id,slines);
       
  1698 	TEST2(ret, KErrNone);
       
  1699 	TEST(id==0);
       
  1700 	TEST(slines>0);
       
  1701 	TBool done=EFalse;
       
  1702 	do	{
       
  1703 		TRAP(ret,done=bmpsaver->SaveScanLinesL(slines/10));
       
  1704 		TEST2(ret, KErrNone);
       
  1705 		}
       
  1706 	while(!done);
       
  1707 	delete bmpsaver;
       
  1708 	CFbsBitmapEx bmp2;
       
  1709 	ret=bmp2.Load(KTempFilename,id,NULL);
       
  1710 	TEST2(ret, KErrNone);
       
  1711 	TUint8 buffer[40];
       
  1712 	TUint8 bufferst[40];
       
  1713 	TPtr8 scanline(&buffer[0],40,40);
       
  1714 	TPtr8 scanlinest(&bufferst[0],40,40);
       
  1715 	TInt yy=0;
       
  1716 	for(;yy<80;yy++)
       
  1717 		{
       
  1718 		bmp.GetScanLine(scanline,TPoint(0,yy),160,EGray4);
       
  1719 		bmp2.GetScanLine(scanlinest,TPoint(0,yy),160,EGray4);
       
  1720 		for(TInt count=0;count<40;count++)
       
  1721 			TEST(buffer[count]==bufferst[count]);
       
  1722 		}
       
  1723 	bmp2.Reset();
       
  1724 	iFs.Delete(KTempFilename);
       
  1725 
       
  1726 	CActiveScheduler* as = CActiveScheduler::Current();
       
  1727 	__ASSERT_DEBUG(as, User::Invariant());
       
  1728 
       
  1729 	TRAP(ret,iBmpHandler=CFbsBitmapAsyncStreamer::NewL(CFbsBitmapAsyncStreamer::ESave));
       
  1730 	TEST2(ret, KErrNone);
       
  1731 	ret=iBmpHandler->Save(KTempFilename,&bmp,id,slines);
       
  1732 	TEST2(ret, KErrNone);
       
  1733 	TEST(id==0);
       
  1734 	TEST(slines>0);
       
  1735 	CIdle* idleobj=CIdle::New(-20);
       
  1736 	TEST(idleobj!=NULL);
       
  1737 	TCallBack callback(BmpSaveCallBack,this);
       
  1738 	idleobj->Start(callback);
       
  1739 	TRAP(ret,as->Start());
       
  1740 	TEST2(ret, KErrNone);
       
  1741 	delete iBmpHandler;
       
  1742 	ret=bmp2.Load(KTempFilename,id,NULL);
       
  1743 	TEST2(ret, KErrNone);
       
  1744 	for(yy=0;yy<80;yy++)
       
  1745 		{
       
  1746 		bmp.GetScanLine(scanline,TPoint(0,yy),160,EGray4);
       
  1747 		bmp2.GetScanLine(scanlinest,TPoint(0,yy),160,EGray4);
       
  1748 		for(TInt count=0;count<40;count++)
       
  1749 			TEST(buffer[count]==bufferst[count]);
       
  1750 		}
       
  1751 	bmp.Reset();
       
  1752 	delete idleobj;
       
  1753 	iFs.Delete(KTempFilename);
       
  1754 	User::Heap().Check();
       
  1755 	__UHEAP_MARKEND;
       
  1756 
       
  1757 	INFO_PRINTF1(_L("\r\n"));
       
  1758 	
       
  1759 	}
       
  1760 
       
  1761 TInt CTBitmap::BmpSaveCallBack(TAny* aPtr)
       
  1762 	{
       
  1763 	CTBitmap* tbmp=(CTBitmap*)aPtr;
       
  1764 	tbmp->INFO_PRINTF1(_L("*"));
       
  1765 	TBool done=EFalse;
       
  1766 	TRAPD(ret,done=tbmp->iBmpHandler->SaveScanLinesL(10));
       
  1767 	tbmp->TEST2(ret, KErrNone);
       
  1768 	if(done) 
       
  1769 		{
       
  1770 		CActiveScheduler::Stop();
       
  1771 		}
       
  1772 	return(ETrue);
       
  1773 	}
       
  1774 
       
  1775 /**
       
  1776 	@SYMTestCaseID
       
  1777 	GRAPHICS-FBSERV-0525
       
  1778 
       
  1779 	@SYMTestCaseDesc
       
  1780 	Tests if a bitmap is monochrone for different
       
  1781 	color depths
       
  1782 
       
  1783 	@SYMTestActions
       
  1784 	
       
  1785 	@SYMTestExpectedResults
       
  1786 	Test should pass
       
  1787 */
       
  1788 void CTBitmap::MonoDetect()
       
  1789 	{
       
  1790 	INFO_PRINTF1(_L("Test Mono Detection"));
       
  1791 
       
  1792 	DoMonoDetect(EGray2);
       
  1793 	DoMonoDetect(EGray4);
       
  1794 	DoMonoDetect(EGray16);
       
  1795 	DoMonoDetect(EGray256);
       
  1796 	DoMonoDetect(EColor16);
       
  1797 	DoMonoDetect(EColor256);
       
  1798 	DoMonoDetect(EColor4K);
       
  1799 	DoMonoDetect(EColor64K);
       
  1800 	DoMonoDetect(EColor16M);
       
  1801 	DoMonoDetect(EColor16MU);
       
  1802 	DoMonoDetect(EColor16MAP);
       
  1803 	}
       
  1804 
       
  1805 void CTBitmap::DoMonoDetect(TDisplayMode aDisplayMode)
       
  1806 	{
       
  1807 	CFbsBitmapEx bmp;
       
  1808 	TInt ret = bmp.Create(TSize(100,3),aDisplayMode);
       
  1809 	TEST2(ret, KErrNone);
       
  1810 
       
  1811 	CBitwiseBitmap* bmpadd = bmp.BitmapAddress();
       
  1812 	bmp.LockHeap();
       
  1813 	TUint32* base = bmp.DataAddress();
       
  1814 	bmp.UnlockHeap();
       
  1815 	TUint32* data = bmpadd->ScanLineAddress(base,1);
       
  1816 
       
  1817 	if(aDisplayMode == EColor16M)
       
  1818 		{
       
  1819 		*(data+1) = 0x0000FFFF;
       
  1820 		*(data+2) = 0xFFFFFF00;
       
  1821 		//Pixel at (data + 1). Bytes (3) and (2) are part of the pixel at (data) addr.
       
  1822 		//LSB                        MSB
       
  1823 		//3        2        1        0
       
  1824 		//FF       FF       00       00  
       
  1825 		//Pixel at (data + 2). Byte (3) is part of the pixel at (data + 1) addr.
       
  1826 		//LSB                        MSB
       
  1827 		//3        2        1        0
       
  1828 		//00       FF       FF       FF
       
  1829 		}
       
  1830 	else
       
  1831 		{
       
  1832 		*(data+1) = 0;
       
  1833 		}
       
  1834 	TBool mono = bmp.IsMonochrome();
       
  1835 	TEST(mono);
       
  1836 
       
  1837 	*(data+1) = 0x1234abcd;
       
  1838 	mono = bmp.IsMonochrome();
       
  1839 	if (aDisplayMode == EGray2)
       
  1840 		TEST(mono);
       
  1841 	else
       
  1842 		TEST(!mono);
       
  1843 
       
  1844 	if(aDisplayMode == EColor16M)
       
  1845 		{
       
  1846 		*(data+1) = 0xffffffff;
       
  1847 		*(data+2) = 0xffffffff;
       
  1848 		}
       
  1849 	else
       
  1850 		{
       
  1851 		*(data+1) = 0xffffffff;
       
  1852 		}
       
  1853 	mono=bmp.IsMonochrome();
       
  1854 	TEST(mono);
       
  1855 
       
  1856 	bmp.Reset();
       
  1857 	}
       
  1858 
       
  1859 
       
  1860 #if defined(__WINS__)
       
  1861 // these are patchable constants defined in fbscli.dll but on the emulator
       
  1862 // it's not possible to import them so they are re-defined here
       
  1863 const TInt KFbServLargeChunkGrowByShifter = 1;
       
  1864 const TInt KFbServLargeChunkSizeShifter = 2;
       
  1865 const TInt KFbServLargeChunkMinPhysicalSize = 0x4000;
       
  1866 #elif defined(__X86GCC__)
       
  1867 IMPORT_D extern const TInt KFbServLargeChunkGrowByShifter;
       
  1868 IMPORT_D extern const TInt KFbServLargeChunkSizeShifter;
       
  1869 IMPORT_D extern const TInt KFbServLargeChunkMinPhysicalSize;
       
  1870 #endif
       
  1871 
       
  1872 /**
       
  1873 	@SYMTestCaseID
       
  1874 	GRAPHICS-FBSERV-0526
       
  1875 
       
  1876 	@SYMTestCaseDesc
       
  1877 	Allocates different sized chunks of memory
       
  1878 	in a loop and frees them
       
  1879 
       
  1880 	@SYMTestActions
       
  1881 	
       
  1882 	@SYMTestExpectedResults
       
  1883 	Test should pass
       
  1884 */
       
  1885 void CTBitmap::ChunkPileL()
       
  1886 	{
       
  1887 	INFO_PRINTF1(_L("Test Chunk Pile"));
       
  1888 
       
  1889 	TInt virtualSize = 0x4000000;
       
  1890 	RChunk chunk;
       
  1891 	TInt ret = chunk.CreateDisconnectedGlobal(_L("TFbsLargeChunk"), 0, 0, virtualSize);
       
  1892 	TEST2(ret, KErrNone);
       
  1893 	CleanupClosePushL(chunk);
       
  1894 	TInt pageSize = 0;
       
  1895 	HAL::Get(HAL::EMemoryPageSize, pageSize);
       
  1896 	TEST(pageSize == 4096);
       
  1897 	TUint8* chunkSmallBase = chunk.Base() + pageSize;
       
  1898 	TUint8* chunkLargeBase = chunk.Base() + (virtualSize >> KFbServLargeChunkSizeShifter);
       
  1899 
       
  1900 	CChunkPile* cp=NULL;
       
  1901 	TRAP(ret, cp = CChunkPile::NewL(chunk));
       
  1902 	TEST2(ret, KErrNone);
       
  1903 	TEST(cp!=NULL);
       
  1904 	CleanupStack::PushL(cp);
       
  1905 	TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
       
  1906 
       
  1907 	TUint8* chunkalloc[16];
       
  1908 	TInt size[16];
       
  1909 	for (TInt i = 0; i < 64; ++i)
       
  1910 		{
       
  1911 		chunkalloc[0] = cp->Alloc(size[0] = 512);
       
  1912 		TEST(chunkalloc[0] == chunkSmallBase);
       
  1913 		chunkalloc[1] = cp->Alloc(size[1] = 8);
       
  1914 		TEST(chunkalloc[1] == chunkalloc[0] + size[0]);
       
  1915 		chunkalloc[2] = cp->Alloc(size[2] = 128);
       
  1916 		TEST(chunkalloc[2] == chunkalloc[1] + size[1]);
       
  1917 		chunkalloc[3] = cp->Alloc(size[3] = 372);
       
  1918 		TEST(chunkalloc[3] == chunkalloc[2] + size[2]);
       
  1919 		chunkalloc[4] = cp->Alloc(size[4] = 256);
       
  1920 		TEST(chunkalloc[4] == chunkalloc[3] + size[3]);
       
  1921 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
       
  1922 		// now we should have [0], [1], [2], [3], [4]
       
  1923 
       
  1924 		cp->Free(chunkalloc[2]);
       
  1925 		cp->Free(chunkalloc[3]);
       
  1926 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
       
  1927 		chunkalloc[5] = cp->Alloc(size[5] = size[2] + size[3]);
       
  1928 		TEST(chunkalloc[5] == chunkalloc[2]);
       
  1929 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
       
  1930 		// now we should have [0], [1], [5], [4]
       
  1931 
       
  1932 		chunkalloc[6] = cp->Alloc(size[6] = 4);
       
  1933 		TEST(chunkalloc[6] == chunkalloc[4] + size[4]);
       
  1934 		chunkalloc[7] = cp->Alloc(size[7] = 1024);
       
  1935 		TEST(chunkalloc[7] == chunkalloc[6] + size[6]);
       
  1936 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
       
  1937 		cp->Free(chunkalloc[7]);
       
  1938 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
       
  1939 		// now we should have [0], [1], [5], [4], [6]
       
  1940 
       
  1941 		cp->Free(chunkalloc[1]);
       
  1942 		cp->Free(chunkalloc[0]);
       
  1943 		cp->Free(chunkalloc[4]);
       
  1944 		cp->Free(chunkalloc[5]);
       
  1945 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
       
  1946 		chunkalloc[8] = cp->Alloc(size[8] = size[0] + size[1] + size[4] + size[5] - 32);
       
  1947 		TEST(chunkalloc[8] == chunkalloc[0]);
       
  1948 		chunkalloc[9] = cp->Alloc(size[9] = 32);
       
  1949 		TEST(chunkalloc[9] == chunkalloc[8] + size[8]);
       
  1950 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
       
  1951 		// now we should have [8], [9], [6]
       
  1952 
       
  1953 		chunkalloc[10] = cp->Alloc(size[10] = KFbServLargeChunkMinPhysicalSize - size[6] - size[8] - size[9]);
       
  1954 		TEST(chunkalloc[10] == chunkalloc[6] + size[6]);
       
  1955 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
       
  1956 		chunkalloc[11] = cp->Alloc(size[11] = 16);
       
  1957 		TEST(chunkalloc[11] == chunkalloc[10] + size[10]);
       
  1958 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + (pageSize << KFbServLargeChunkGrowByShifter));
       
  1959 		chunkalloc[12] = cp->Alloc(size[12] = ((pageSize << KFbServLargeChunkGrowByShifter) - 16) / 2);
       
  1960 		TEST(chunkalloc[12] == chunkalloc[11] + size[11]);
       
  1961 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + (pageSize << KFbServLargeChunkGrowByShifter));
       
  1962 		chunkalloc[13] = cp->Alloc(size[13] = size[12]);
       
  1963 		TEST(chunkalloc[13] == chunkalloc[12] + size[12]);
       
  1964 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + (pageSize << KFbServLargeChunkGrowByShifter));
       
  1965 		chunkalloc[14] = cp->Alloc(size[14] = pageSize << KFbServLargeChunkGrowByShifter);
       
  1966 		TEST(chunkalloc[14] == chunkalloc[13] + size[13]);
       
  1967 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + 2 * (pageSize << KFbServLargeChunkGrowByShifter));
       
  1968 		chunkalloc[15] = cp->Alloc(size[15] = (pageSize << KFbServLargeChunkGrowByShifter) + 4);
       
  1969 		TEST(chunkalloc[15] == chunkalloc[14] + size[14]);
       
  1970 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + 4 * (pageSize << KFbServLargeChunkGrowByShifter));
       
  1971 		// now we should have [8], [9], [6], [10], [11], [12], [13], [14], [15]
       
  1972 
       
  1973 		cp->Free(chunkalloc[15]);
       
  1974 		cp->Free(chunkalloc[14]);
       
  1975 		cp->Free(chunkalloc[13]);
       
  1976 		cp->Free(chunkalloc[12]);
       
  1977 		cp->Free(chunkalloc[11]);
       
  1978 		cp->Free(chunkalloc[10]);
       
  1979 		cp->Free(chunkalloc[9]);
       
  1980 		cp->Free(chunkalloc[8]);
       
  1981 		cp->Free(chunkalloc[6]);
       
  1982 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
       
  1983 
       
  1984 		TEST(cp->Alloc(virtualSize) == NULL);
       
  1985 
       
  1986 		TInt largeSize = 4 * pageSize;
       
  1987 		chunkalloc[0] = cp->Alloc(size[0] = 2 * largeSize);
       
  1988 		TEST(chunkalloc[0] == chunkLargeBase);
       
  1989 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[0]);
       
  1990 		chunkalloc[1] = cp->Alloc(2 * largeSize + 1);
       
  1991 		size[1] = 2 * largeSize + pageSize;
       
  1992 		TEST(chunkalloc[1] == chunkalloc[0] + size[0]);
       
  1993 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[0] + size[1]);
       
  1994 		chunkalloc[2] = cp->Alloc(size[2] = 3 * largeSize + pageSize);
       
  1995 		TEST(chunkalloc[2] == chunkalloc[1] + size[1]);
       
  1996 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[0] + size[1] + size[2]);
       
  1997 		// now we should have [0], [1], [2]
       
  1998 
       
  1999 		cp->Free(chunkalloc[1]);
       
  2000 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[0] + size[2]);
       
  2001 		chunkalloc[3] = cp->Alloc(largeSize + 1);
       
  2002 		size[3] = largeSize + pageSize;
       
  2003 		TEST(chunkalloc[3] == chunkalloc[1]);
       
  2004 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[0] + size[2] + size[3]);
       
  2005 		chunkalloc[4] = cp->Alloc(size[4] = largeSize);
       
  2006 		TEST(chunkalloc[4] == chunkalloc[3] + size[3]);
       
  2007 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[0] + size[2] + size[3] + size[4]);
       
  2008 		chunkalloc[5] = cp->Alloc(size[5] = 64 * largeSize);
       
  2009 		TEST(chunkalloc[5] == chunkalloc[2] + size[2]);
       
  2010 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[0] + size[2] + size[3] + size[4] + size[5]);
       
  2011 		// now we should have [0], [3], [4], [2], [5]
       
  2012 
       
  2013 		cp->Free(chunkalloc[0]);
       
  2014 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[2] + size[3] + size[4] + size[5]);
       
  2015 		cp->Free(chunkalloc[2]);
       
  2016 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[3] + size[4] + size[5]);
       
  2017 		cp->Free(chunkalloc[3]);
       
  2018 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[4] + size[5]);
       
  2019 		cp->Free(chunkalloc[4]);
       
  2020 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize + size[5]);
       
  2021 		cp->Free(chunkalloc[5]);
       
  2022 		TEST(chunk.Size() == KFbServLargeChunkMinPhysicalSize);
       
  2023 		}
       
  2024 
       
  2025 	CleanupStack::PopAndDestroy(2, &chunk); // cp, chunk
       
  2026 	}
       
  2027 
       
  2028 /**
       
  2029 	@SYMTestCaseID
       
  2030 	GRAPHICS-FBSERV-0527
       
  2031 
       
  2032 	@SYMTestCaseDesc
       
  2033 	Creates large bitmaps of different colour depth. 
       
  2034 
       
  2035 	@SYMTestActions
       
  2036 	The bitmaps allocated are too big so
       
  2037 	the allocation should fail.
       
  2038 	
       
  2039 	@SYMTestExpectedResults
       
  2040 	KErrNoMemory when allocating the bitmaps. 
       
  2041 */
       
  2042 void CTBitmap::LargeBitmaps()
       
  2043 	{
       
  2044 	INFO_PRINTF1(_L("Test Large Bitmaps"));
       
  2045 
       
  2046 	TMemoryInfoV1Buf membuf;
       
  2047 	UserHal::MemoryInfo(membuf);
       
  2048 	const TReal maxmem = membuf().iTotalRamInBytes;
       
  2049 
       
  2050 	TReal realSize = 0;
       
  2051 	TInt ret = Math::Sqrt(realSize,maxmem);
       
  2052 	TEST2(ret, KErrNone);
       
  2053 	TInt32 size = 0;
       
  2054 	ret = Math::Int(size,realSize);
       
  2055 	TEST2(ret, KErrNone);
       
  2056 
       
  2057 	DoLargeBitmaps(TSize(size * 8,size),EGray2);
       
  2058 	DoLargeBitmaps(TSize(size * 4,size),EGray4);
       
  2059 	DoLargeBitmaps(TSize(size * 2,size),EGray16);
       
  2060 	DoLargeBitmaps(TSize(size,size),EGray256);
       
  2061 	DoLargeBitmaps(TSize(size * 2,size),EColor16);
       
  2062 	DoLargeBitmaps(TSize(size,size),EColor256);
       
  2063 	DoLargeBitmaps(TSize(size / 2,size),EColor4K);
       
  2064 	DoLargeBitmaps(TSize(size / 2,size),EColor64K);
       
  2065 	DoLargeBitmaps(TSize(size / 3,size),EColor16M);
       
  2066 	DoLargeBitmaps(TSize(size / 4,size),EColor16MU);
       
  2067 	DoLargeBitmaps(TSize(size / 4,size),EColor16MAP);
       
  2068 	}
       
  2069 
       
  2070 void CTBitmap::DoLargeBitmaps(const TSize& aSize,TDisplayMode aDisplayMode)
       
  2071 	{
       
  2072 	CFbsBitmapEx bmp1;
       
  2073 	TInt ret = bmp1.Create(aSize,aDisplayMode);
       
  2074 	TEST2(ret, KErrNoMemory);
       
  2075 	}
       
  2076 
       
  2077 /**
       
  2078 	@SYMTestCaseID
       
  2079 	GRAPHICS-FBSERV-0528
       
  2080 
       
  2081 	@SYMTestCaseDesc
       
  2082 	Check error handling for bitmaps above pixel and byte size limits
       
  2083 
       
  2084 	@SYMTestActions
       
  2085 	
       
  2086 	@SYMTestExpectedResults
       
  2087 	Test should pass
       
  2088 */
       
  2089 void CTBitmap::HugeBitmaps()
       
  2090 	{
       
  2091 	// Check error handling for bitmaps above pixel and byte size limits
       
  2092 	INFO_PRINTF1(_L("Test Huge Bitmaps"));
       
  2093 
       
  2094 	const TInt KLargePixelSize = 50000;
       
  2095 
       
  2096 	DoHugeBitmaps(TSize(KLargePixelSize * 8,KLargePixelSize),EGray2);
       
  2097 	DoHugeBitmaps(TSize(KLargePixelSize * 4,KLargePixelSize),EGray4);
       
  2098 	DoHugeBitmaps(TSize(KLargePixelSize * 2,KLargePixelSize),EGray16);
       
  2099 	DoHugeBitmaps(TSize(KLargePixelSize,KLargePixelSize),EGray256);
       
  2100 	DoHugeBitmaps(TSize(KLargePixelSize * 2,KLargePixelSize),EColor16);
       
  2101 	DoHugeBitmaps(TSize(KLargePixelSize,KLargePixelSize),EColor256);
       
  2102 	DoHugeBitmaps(TSize(KLargePixelSize / 2,KLargePixelSize),EColor4K);
       
  2103 	DoHugeBitmaps(TSize(KLargePixelSize / 2,KLargePixelSize),EColor64K);
       
  2104 	DoHugeBitmaps(TSize(KLargePixelSize / 3,KLargePixelSize),EColor16M);
       
  2105 	DoHugeBitmaps(TSize(KLargePixelSize / 4,KLargePixelSize),EColor16MU);
       
  2106 	DoHugeBitmaps(TSize(KLargePixelSize / 4,KLargePixelSize),EColor16MAP);
       
  2107 	}
       
  2108 
       
  2109 void CTBitmap::DoHugeBitmaps(const TSize& aSize,TDisplayMode aDisplayMode)
       
  2110 	{
       
  2111 	const TInt KMaxPixelSize = KMaxTInt / 4 + 1;
       
  2112 
       
  2113 	CFbsBitmap bmp;
       
  2114 
       
  2115 	TInt ret = bmp.Create(TSize(aSize.iWidth / 2,aSize.iHeight / 2),aDisplayMode);
       
  2116 	TEST2(ret, KErrNoMemory);
       
  2117 
       
  2118 	ret = bmp.Create(aSize,aDisplayMode);
       
  2119 	TEST2(ret, KErrTooBig);
       
  2120 
       
  2121 	ret = bmp.Create(TSize(1,KMaxPixelSize),aDisplayMode);
       
  2122 	TEST2(ret, KErrTooBig);
       
  2123 
       
  2124 	ret = bmp.Create(TSize(KMaxPixelSize,1),aDisplayMode);
       
  2125 	TEST2(ret, KErrTooBig);
       
  2126 
       
  2127 	ret = bmp.Create(TSize(KMaxPixelSize,KMaxPixelSize),aDisplayMode);
       
  2128 	TEST2(ret, KErrTooBig);
       
  2129 
       
  2130 	ret = bmp.Create(TSize(KMaxTInt,KMaxTInt),aDisplayMode);
       
  2131 	TEST2(ret, KErrTooBig);
       
  2132 
       
  2133 
       
  2134 	ret = bmp.Create(TSize(1,1),aDisplayMode);
       
  2135 	TEST2(ret, KErrNone);
       
  2136 
       
  2137 	ret = bmp.Resize(TSize(aSize.iWidth / 2,aSize.iHeight / 2));
       
  2138 	TEST2(ret, KErrNoMemory);
       
  2139 
       
  2140 	ret = bmp.Resize(aSize);
       
  2141 	TEST2(ret, KErrTooBig);
       
  2142 
       
  2143 	ret = bmp.Resize(TSize(1,KMaxPixelSize));
       
  2144 	TEST2(ret, KErrTooBig);
       
  2145 
       
  2146 	ret = bmp.Resize(TSize(KMaxPixelSize,1));
       
  2147 	TEST2(ret, KErrTooBig);
       
  2148 
       
  2149 	ret = bmp.Resize(TSize(KMaxPixelSize,KMaxPixelSize));
       
  2150 	TEST2(ret, KErrTooBig);
       
  2151 
       
  2152 	ret = bmp.Resize(TSize(KMaxTInt,KMaxTInt));
       
  2153 	TEST2(ret, KErrTooBig);
       
  2154 
       
  2155 	bmp.Reset();
       
  2156 	}
       
  2157 
       
  2158 /**
       
  2159 	@SYMTestCaseID
       
  2160 	GRAPHICS-FBSERV-0529
       
  2161 
       
  2162 	@SYMTestCaseDesc
       
  2163 	Resizes a bitmap to a larger size and
       
  2164 	checks if the new bitmap is as expected
       
  2165 	
       
  2166 	@SYMTestActions
       
  2167 	
       
  2168 	@SYMTestExpectedResults
       
  2169 	Test should pass
       
  2170 */
       
  2171 void CTBitmap::Resize()
       
  2172 	{
       
  2173 	INFO_PRINTF1(_L("Test Resizing"));
       
  2174 
       
  2175 	DoResize(EGray2);
       
  2176 	DoResize(EGray4);
       
  2177 	DoResize(EGray16);
       
  2178 	DoResize(EGray256);
       
  2179 	DoResize(EColor16);
       
  2180 	DoResize(EColor256);
       
  2181 	DoResize(EColor4K);
       
  2182 	DoResize(EColor64K);
       
  2183 	DoResize(EColor16M);
       
  2184 	DoResize(EColor16MU);
       
  2185 	DoResize(EColor16MAP);
       
  2186 	}
       
  2187 
       
  2188 void CTBitmap::DoResize(TDisplayMode aDispMode)
       
  2189 	{
       
  2190 	const TSize KBitmapOriginalSize(256,24);
       
  2191 	const TSize KBitmapLargeSize(288,32);
       
  2192 	const TSize KBitmapSmallSize(1,1);
       
  2193 
       
  2194 	CFbsBitmapEx bmp;
       
  2195 	TInt ret = bmp.Create(KBitmapOriginalSize,aDispMode);
       
  2196 	TEST2(ret, KErrNone);
       
  2197 	bmp.SetSizeInTwips(KBitmapOriginalSize);
       
  2198 	TEST(bmp.SizeInPixels() == KBitmapOriginalSize);
       
  2199 	TEST(bmp.SizeInTwips() == KBitmapOriginalSize);
       
  2200 
       
  2201 	CBitwiseBitmap* bb = bmp.BitmapAddress();
       
  2202 	bmp.LockHeap();
       
  2203 	TUint32* base = bmp.DataAddress();
       
  2204 	bmp.UnlockHeap();
       
  2205 
       
  2206 	TInt scanLineLength = CFbsBitmap::ScanLineLength(256,aDispMode);
       
  2207 	TInt blockStart = scanLineLength / 4;
       
  2208 	TInt blockLength = scanLineLength / 2;
       
  2209 
       
  2210 	TInt row;
       
  2211 	for(row = 8; row < 16; row++)
       
  2212 		{
       
  2213 		TUint8* bmpadd = (TUint8*)bb->ScanLineAddress(base,row);
       
  2214 		Mem::FillZ(bmpadd + blockStart,blockLength);
       
  2215 		}
       
  2216 
       
  2217 	ret = bmp.Resize(KBitmapLargeSize);
       
  2218 	TEST2(ret, KErrNone);
       
  2219 	TEST(bmp.SizeInPixels() == KBitmapLargeSize);
       
  2220 	TEST(bmp.SizeInTwips() == KBitmapLargeSize);
       
  2221 	bb = bmp.BitmapAddress();
       
  2222 	bmp.LockHeap();
       
  2223 	base = bmp.DataAddress();
       
  2224 	bmp.UnlockHeap();
       
  2225 	scanLineLength = CFbsBitmap::ScanLineLength(288,aDispMode);
       
  2226 
       
  2227 	for(row = 0; row < 8; row++)
       
  2228 		{
       
  2229 		TUint8* bmpadd=(TUint8*)bb->ScanLineAddress(base,row);
       
  2230 		CheckWhite(bmpadd,scanLineLength,aDispMode);
       
  2231 		}
       
  2232 
       
  2233 	for(row = 16; row < 32; row++)
       
  2234 		{
       
  2235 		TUint8* bmpadd=(TUint8*)bb->ScanLineAddress(base,row);
       
  2236 		CheckWhite(bmpadd,scanLineLength,aDispMode);
       
  2237 		}
       
  2238 
       
  2239 	for(row = 8; row < 16; row++)
       
  2240 		{
       
  2241 		TUint8* bmpadd=(TUint8*)bb->ScanLineAddress(base,row);
       
  2242 		CheckWhite(bmpadd,blockStart,aDispMode);
       
  2243 
       
  2244 		TUint8* ptr = bmpadd + blockStart;
       
  2245 		TUint8* ptrLimit = ptr + blockLength;
       
  2246 		while (ptr < ptrLimit)
       
  2247 			TEST(*ptr++ == 0);
       
  2248 
       
  2249 		CheckWhite(ptr,scanLineLength - blockStart - blockLength,aDispMode);
       
  2250 		}
       
  2251 
       
  2252 	ret = bmp.Resize(KBitmapSmallSize);
       
  2253 	TEST2(ret, KErrNone);
       
  2254 	TEST(bmp.SizeInPixels() == KBitmapSmallSize);
       
  2255 	TEST(bmp.SizeInTwips() == KBitmapSmallSize);
       
  2256 
       
  2257 	ret = bmp.Resize(KBitmapOriginalSize);
       
  2258 	TEST2(ret, KErrNone);
       
  2259 	TEST(bmp.SizeInPixels() == KBitmapOriginalSize);
       
  2260 	TEST(bmp.SizeInTwips() == KBitmapOriginalSize);
       
  2261 
       
  2262 	bmp.Reset();
       
  2263 	}
       
  2264 
       
  2265 void CTBitmap::CheckWhite(TUint8* aData,TInt aDataLength,TDisplayMode aDispMode)
       
  2266 	{
       
  2267 	TUint8* dataLimit = aData + aDataLength;
       
  2268 
       
  2269 	if (aDispMode != EColor4K)
       
  2270 		{
       
  2271 		while (aData < dataLimit)
       
  2272 			TEST(*aData++ == 0xff);
       
  2273 		}
       
  2274 	else
       
  2275 		{
       
  2276 		while (aData < dataLimit)
       
  2277 			{
       
  2278 			TEST(*aData == 0xff || *aData == 0x0f);
       
  2279 			aData++;
       
  2280 			}
       
  2281 		}
       
  2282 	}
       
  2283 
       
  2284 /**
       
  2285 	@SYMTestCaseID
       
  2286 	GRAPHICS-FBSERV-0530
       
  2287 
       
  2288 	@SYMTestCaseDesc
       
  2289 	Creates BitmapUtil objects and sets the
       
  2290 	current position to different positions
       
  2291 	and retrieves and sets the pixels in these
       
  2292 	and compares it to another Bitmap Util object
       
  2293 	
       
  2294 	@SYMTestActions
       
  2295 
       
  2296 	@SYMTestExpectedResults
       
  2297 	Test should pass
       
  2298 */
       
  2299 void CTBitmap::BitmapUtil()
       
  2300 	{
       
  2301 	INFO_PRINTF1(_L("Test Bitmap Util"));
       
  2302 
       
  2303 	TSize bmpUtilSize1(256,4);
       
  2304 	TSize bmpUtilSize2(256,1);
       
  2305 	TSize bmpUtilSize3(256,256);
       
  2306 	TSize bmpUtilSize4(1024,1024);
       
  2307 
       
  2308 	INFO_PRINTF1(_L("256x4.. "));
       
  2309 	DoBitmapUtil(bmpUtilSize1,EGray2);
       
  2310 	DoBitmapUtil(bmpUtilSize1,EGray4);
       
  2311 	DoBitmapUtil(bmpUtilSize1,EGray16);
       
  2312 	DoBitmapUtil(bmpUtilSize1,EGray256);
       
  2313 	DoBitmapUtil(bmpUtilSize1,EColor16);
       
  2314 	DoBitmapUtil(bmpUtilSize1,EColor256);
       
  2315 	DoBitmapUtil(bmpUtilSize1,EColor4K);
       
  2316 	DoBitmapUtil(bmpUtilSize1,EColor64K);
       
  2317 	DoBitmapUtil(bmpUtilSize1,EColor16M);
       
  2318 	DoBitmapUtil(bmpUtilSize1,EColor16MU);
       
  2319 	DoBitmapUtil(bmpUtilSize1,EColor16MAP);
       
  2320 
       
  2321 	INFO_PRINTF1(_L("256x1.. "));
       
  2322 	DoBitmapUtil(bmpUtilSize2,EGray2);
       
  2323 	DoBitmapUtil(bmpUtilSize2,EGray4);
       
  2324 	DoBitmapUtil(bmpUtilSize2,EGray16);
       
  2325 	DoBitmapUtil(bmpUtilSize2,EGray256);
       
  2326 	DoBitmapUtil(bmpUtilSize2,EColor16);
       
  2327 	DoBitmapUtil(bmpUtilSize2,EColor256);
       
  2328 	DoBitmapUtil(bmpUtilSize2,EColor4K);
       
  2329 	DoBitmapUtil(bmpUtilSize2,EColor64K);
       
  2330 	DoBitmapUtil(bmpUtilSize2,EColor16M);
       
  2331 	DoBitmapUtil(bmpUtilSize2,EColor16MU);
       
  2332 	DoBitmapUtil(bmpUtilSize2,EColor16MAP);
       
  2333 
       
  2334 	INFO_PRINTF1(_L("256x256..\n"));
       
  2335 	DoBitmapUtil(bmpUtilSize3,EGray2);
       
  2336 	DoBitmapUtil(bmpUtilSize3,EGray4);
       
  2337 	DoBitmapUtil(bmpUtilSize3,EGray16);
       
  2338 	DoBitmapUtil(bmpUtilSize3,EGray256);
       
  2339 	DoBitmapUtil(bmpUtilSize3,EColor16);
       
  2340 	DoBitmapUtil(bmpUtilSize3,EColor256);
       
  2341 	DoBitmapUtil(bmpUtilSize3,EColor4K);
       
  2342 	DoBitmapUtil(bmpUtilSize3,EColor64K);
       
  2343 	DoBitmapUtil(bmpUtilSize3,EColor16M);
       
  2344 	DoBitmapUtil(bmpUtilSize3,EColor16MU);
       
  2345 	DoBitmapUtil(bmpUtilSize3,EColor16MAP);
       
  2346 		
       
  2347     INFO_PRINTF1(_L("Testing wastage bytes in 16M scanlines...\n"));
       
  2348 	bmpUtilSize1.SetSize(5,13);
       
  2349 	bmpUtilSize2.SetSize(6,14);
       
  2350 	bmpUtilSize3.SetSize(7,15);
       
  2351 	bmpUtilSize4.SetSize(8,16);
       
  2352 	DoBitmapUtil(bmpUtilSize1,EColor16M);
       
  2353 	DoBitmapUtil(bmpUtilSize2,EColor16M);
       
  2354 	DoBitmapUtil(bmpUtilSize3,EColor16M);
       
  2355 	DoBitmapUtil(bmpUtilSize4,EColor16M);
       
  2356 
       
  2357     /*
       
  2358 	 * Test code commented out as it results in test case failure. 
       
  2359 	 * Problem recorded in defect DEF001233.
       
  2360 	 *
       
  2361 	INFO_PRINTF1(_L("Testing wastage bits in Gray16 scanlines...\n\n"));
       
  2362 	bmpUtilSize1.SetSize(4,13);
       
  2363 	bmpUtilSize2.SetSize(5,14);
       
  2364 	bmpUtilSize3.SetSize(6,15);
       
  2365 	bmpUtilSize4.SetSize(7,16);
       
  2366 	DoBitmapUtil(bmpUtilSize1,EGray16);
       
  2367 	DoBitmapUtil(bmpUtilSize2,EGray16);
       
  2368 	DoBitmapUtil(bmpUtilSize3,EGray16);
       
  2369 	DoBitmapUtil(bmpUtilSize4,EGray16);
       
  2370 	 */
       
  2371 	}
       
  2372 
       
  2373 void CTBitmap::DoBitmapUtil(const TSize& aSize,TDisplayMode aDispMode)
       
  2374 	{
       
  2375 	const TPoint startPoint(aSize.iWidth / 3,aSize.iHeight / 3);
       
  2376 	const TPoint zeroPoint(0,0);
       
  2377 
       
  2378 	CFbsBitmapEx bmp1;
       
  2379 	TInt ret=bmp1.Create(aSize,aDispMode);
       
  2380 	TEST2(ret, KErrNone);
       
  2381 	FillBitmap(bmp1);
       
  2382 
       
  2383 
       
  2384 	const TInt numPixels = ((aSize.iWidth + 31) & ~0x1f) * aSize.iHeight;
       
  2385 	TInt count1;
       
  2386 	CFbsBitmapEx bmp2;
       
  2387 
       
  2388 	ret=bmp2.Create(aSize,aDispMode);
       
  2389 	TEST2(ret, KErrNone);
       
  2390 
       
  2391 	TBitmapUtil util1(&bmp1);
       
  2392 	util1.Begin(zeroPoint);
       
  2393 	TBitmapUtil util2(&bmp2);
       
  2394 	util2.Begin(zeroPoint,util1);
       
  2395 
       
  2396 	TPoint currentPosition;
       
  2397 	for (currentPosition.iY = 0; currentPosition.iY < aSize.iHeight; currentPosition.iY++)
       
  2398 		for (currentPosition.iX = 0; currentPosition.iX < aSize.iWidth; currentPosition.iX++)
       
  2399 			{
       
  2400 			util1.SetPos(currentPosition);
       
  2401 			util2.SetPos(currentPosition);
       
  2402 			TUint32 pixelData = util1.GetPixel();
       
  2403 			util2.SetPixel(pixelData);
       
  2404 			}
       
  2405 	util1.End();
       
  2406 	util2.End();
       
  2407 	CompareBitmaps(bmp1,bmp2,EColor16M);
       
  2408 	bmp2.Reset();
       
  2409 
       
  2410 	ret=bmp2.Create(aSize,aDispMode);
       
  2411 	TEST2(ret, KErrNone);
       
  2412 	util1.Begin(startPoint);
       
  2413 	util2.Begin(startPoint,util1);
       
  2414 	for (count1 = 0; count1 < numPixels; count1++)
       
  2415 		{
       
  2416 		util2.SetPixel(util1);
       
  2417 		util1.IncXPos();
       
  2418 		util2.IncXPos();
       
  2419 		}
       
  2420 	util1.End();
       
  2421 	util2.End();
       
  2422 	CompareBitmaps(bmp1,bmp2,EColor16M);
       
  2423 	bmp2.Reset();
       
  2424 
       
  2425 	ret=bmp2.Create(aSize,aDispMode);
       
  2426 	TEST2(ret, KErrNone);
       
  2427 	util1.Begin(zeroPoint);
       
  2428 	util2.Begin(zeroPoint,util1);
       
  2429 	for (currentPosition.iX = 0; currentPosition.iX < aSize.iWidth; currentPosition.iX++)
       
  2430 		{
       
  2431 		for (currentPosition.iY = 0; currentPosition.iY < aSize.iHeight; currentPosition.iY++)
       
  2432 			{
       
  2433 			util2.SetPixel(util1);
       
  2434 			util1.IncYPos();
       
  2435 			util2.IncYPos();
       
  2436 			}
       
  2437 		util1.IncXPos();
       
  2438 		util2.IncXPos();
       
  2439 		}
       
  2440 	util1.End();
       
  2441 	util2.End();
       
  2442 	CompareBitmaps(bmp1,bmp2,EColor16M);
       
  2443 	bmp2.Reset();
       
  2444 
       
  2445 	ret=bmp2.Create(aSize,aDispMode);
       
  2446 	TEST2(ret, KErrNone);
       
  2447 	util1.Begin(startPoint);
       
  2448 	util2.Begin(startPoint,util1);
       
  2449 	for (count1 = 0; count1 < numPixels; count1++)
       
  2450 		{
       
  2451 		util2.SetPixel(util1);
       
  2452 		util1.DecXPos();
       
  2453 		util2.DecXPos();
       
  2454 		}
       
  2455 	util1.End();
       
  2456 	util2.End();
       
  2457 	CompareBitmaps(bmp1,bmp2,EColor16M);
       
  2458 	bmp2.Reset();
       
  2459 
       
  2460 	ret=bmp2.Create(aSize,aDispMode);
       
  2461 	TEST2(ret, KErrNone);
       
  2462 	util1.Begin(zeroPoint);
       
  2463 	util2.Begin(zeroPoint,util1);
       
  2464 	for (currentPosition.iX = 0; currentPosition.iX < aSize.iWidth; currentPosition.iX++)
       
  2465 		{
       
  2466 		for (currentPosition.iY = 0; currentPosition.iY < aSize.iHeight; currentPosition.iY++)
       
  2467 			{
       
  2468 			util2.SetPixel(util1);
       
  2469 			util1.DecYPos();
       
  2470 			util2.DecYPos();
       
  2471 			}
       
  2472 		util1.DecXPos();
       
  2473 		util2.DecXPos();
       
  2474 		}
       
  2475 	util1.End();
       
  2476 	util2.End();
       
  2477 	CompareBitmaps(bmp1,bmp2,EColor16M);
       
  2478 	bmp2.Reset();
       
  2479 
       
  2480 	bmp1.Reset();
       
  2481 	}
       
  2482 
       
  2483 void CTBitmap::BitmapTiming()
       
  2484 	{
       
  2485 	INFO_PRINTF1(_L("Test Timing"));
       
  2486 
       
  2487 	CFbsBitmap bmp;
       
  2488 	TInt ret=bmp.Load(iTestBitmapName,ETfbs,NULL);
       
  2489 	TEST2(ret, KErrNone);
       
  2490 
       
  2491 	CDirectFileStore* writestore=NULL;
       
  2492 	TRAP(ret,writestore=CDirectFileStore::ReplaceL(iFs,KTempFilename,EFileStream|EFileWrite));
       
  2493 	TEST2(ret, KErrNone);
       
  2494 	TUidType uidtype(KDirectFileStoreLayoutUid,KMultiBitmapFileImageUid);
       
  2495 	TRAP(ret,writestore->SetTypeL(uidtype));
       
  2496 	TEST2(ret, KErrNone);
       
  2497 	RStoreWriteStream writestrm;
       
  2498 	TStreamId headerid(0);
       
  2499 	TRAP(ret,headerid=writestrm.CreateL(*writestore));
       
  2500 	TEST2(ret, KErrNone);
       
  2501 	TRAP(ret,writestore->SetRootL(headerid));
       
  2502 	TEST2(ret, KErrNone);
       
  2503 	INFO_PRINTF1(_L("Save time: "));
       
  2504 	TUint startTime=User::TickCount();
       
  2505 	for(TInt count=0;count<5000;count++)
       
  2506 		{
       
  2507 		TRAP(ret,bmp.ExternalizeL(writestrm));
       
  2508 		if(ret) break;
       
  2509 		}
       
  2510 	TUint stopTime=User::TickCount();
       
  2511 	TEST2(ret, KErrNone);
       
  2512 	writestrm.Close();
       
  2513 	delete writestore;
       
  2514 	INFO_PRINTF2(_L("%d ticks\r\n"),stopTime-startTime);
       
  2515 
       
  2516 	CDirectFileStore* readstore=NULL;
       
  2517 	TRAP(ret,readstore=CDirectFileStore::OpenL(iFs,KTempFilename,EFileStream|EFileRead));
       
  2518 	TEST2(ret, KErrNone);
       
  2519 	RStoreReadStream readstrm;
       
  2520 	headerid=readstore->Root();
       
  2521 	INFO_PRINTF1(_L("Load time: "));
       
  2522 	startTime=User::TickCount();
       
  2523 	for(TInt count2=0;count2<5000;count2++)
       
  2524 		{
       
  2525 		TRAP(ret,readstrm.OpenL(*readstore,headerid));
       
  2526 		if(ret) break;
       
  2527 		TRAP(ret,bmp.InternalizeL(readstrm));
       
  2528 		if(ret) break;
       
  2529 		readstrm.Close();
       
  2530 		}
       
  2531 	stopTime=User::TickCount();
       
  2532 	TEST2(ret, KErrNone);
       
  2533 	delete readstore;
       
  2534 	INFO_PRINTF2(_L("%d ticks\r\n"),stopTime-startTime);
       
  2535 
       
  2536 	bmp.Reset();
       
  2537 	iFs.Delete(KTempFilename);
       
  2538 
       
  2539 	
       
  2540 	}
       
  2541 
       
  2542 /**
       
  2543 	@SYMTestCaseID
       
  2544 	GRAPHICS-FBSERV-0531
       
  2545 
       
  2546 	@SYMTestCaseDesc
       
  2547 	Tries to load non existing bitmaps from the
       
  2548 	Z-drive.
       
  2549 
       
  2550 	@SYMTestActions
       
  2551 
       
  2552 	@SYMTestExpectedResults
       
  2553 	Test should pass
       
  2554 */
       
  2555 void CTBitmap::InvalidBitmap()
       
  2556 	{
       
  2557 	INFO_PRINTF1(_L("Test Invalid Bitmap"));
       
  2558 
       
  2559 	__UHEAP_MARK;
       
  2560 	CFbsBitmapEx bmp;
       
  2561 
       
  2562 	TInt ret=bmp.Load(_L("z:\\tfbsx.mbm"),ETfbs,NULL);
       
  2563 	TEST2(ret, KErrNotFound);
       
  2564 	ret=bmp.Load(_L("z:\\tfbs.xbm"),ETfbs,NULL);
       
  2565 	TEST2(ret, KErrNotFound);
       
  2566 	ret=bmp.Load(iTestBitmapName,999,NULL);
       
  2567 	TEST2(ret, KErrEof);
       
  2568 	ret=bmp.Load(iTestBitmapName,-1,NULL);
       
  2569 	TEST2(ret, KErrEof);
       
  2570 
       
  2571 	bmp.Reset();
       
  2572 	User::Heap().Check();
       
  2573 	__UHEAP_MARKEND;
       
  2574 
       
  2575 	
       
  2576 	}
       
  2577 
       
  2578 /**
       
  2579 	@SYMTestCaseID
       
  2580 	GRAPHICS-FBSERV-0532
       
  2581 
       
  2582 	@SYMTestCaseDesc
       
  2583 	Creates bitmaps and saves them to the C-drive
       
  2584 	and loads them back again and compares them to
       
  2585 	the original bitmaps. 
       
  2586 
       
  2587 	@SYMTestActions
       
  2588 	The test uses different colour depths and sizes
       
  2589 	of the bitmaps. The sizes of the bitmaps are
       
  2590 	large.
       
  2591 
       
  2592 	@SYMTestExpectedResults
       
  2593 	Test should pass
       
  2594 */
       
  2595 void CTBitmap::SaveAndLoad()
       
  2596 	{
       
  2597 	INFO_PRINTF1(_L("Test Save/Load Bitmap"));
       
  2598 
       
  2599 	const TInt sizes[] = { 1,2,3,4,5,7,8,9,15,16,17,31,32,33,100 };
       
  2600 	const TInt numSizes = sizeof(sizes) / sizeof(TInt);
       
  2601 	TSize size;
       
  2602 
       
  2603 	for (TInt widthIndex = 0; widthIndex < numSizes; widthIndex++)
       
  2604 		{
       
  2605 		INFO_PRINTF3(_L("Index %d/%d\r"), widthIndex + 1, numSizes);
       
  2606 		size.iWidth = sizes[widthIndex];
       
  2607 
       
  2608 		for (TInt heightIndex = 0; heightIndex < numSizes; heightIndex++)
       
  2609 			{
       
  2610 			size.iHeight = sizes[heightIndex];
       
  2611 
       
  2612 			DoSaveAndLoad(size,EGray2,EFalse);
       
  2613 			DoSaveAndLoad(size,EGray2,ETrue);
       
  2614 			DoSaveAndLoad(size,EGray4,EFalse);
       
  2615 			DoSaveAndLoad(size,EGray4,ETrue);
       
  2616 			DoSaveAndLoad(size,EGray16,EFalse);
       
  2617 			DoSaveAndLoad(size,EGray16,ETrue);
       
  2618 			DoSaveAndLoad(size,EGray256,EFalse);
       
  2619 			DoSaveAndLoad(size,EGray256,ETrue);
       
  2620 			DoSaveAndLoad(size,EColor16,EFalse);
       
  2621 			DoSaveAndLoad(size,EColor16,ETrue);
       
  2622 			DoSaveAndLoad(size,EColor256,EFalse);
       
  2623 			DoSaveAndLoad(size,EColor256,ETrue);
       
  2624 			DoSaveAndLoad(size,EColor4K,EFalse);
       
  2625 			DoSaveAndLoad(size,EColor4K,ETrue);
       
  2626 			DoSaveAndLoad(size,EColor64K,EFalse);
       
  2627 			DoSaveAndLoad(size,EColor64K,ETrue);
       
  2628 			DoSaveAndLoad(size,EColor16M,EFalse);
       
  2629 			DoSaveAndLoad(size,EColor16M,ETrue);
       
  2630 			DoSaveAndLoad(size,EColor16MU,EFalse);
       
  2631 			DoSaveAndLoad(size,EColor16MU,ETrue);
       
  2632 			DoSaveAndLoad(size,EColor16MAP,EFalse);
       
  2633 			DoSaveAndLoad(size,EColor16MAP,ETrue);
       
  2634 			}
       
  2635 		}
       
  2636 
       
  2637 	INFO_PRINTF1(_L("\r\n"));
       
  2638 	
       
  2639 	}
       
  2640 
       
  2641 /**
       
  2642 	@SYMTestCaseID
       
  2643 	GRAPHICS-FBSERV-0533
       
  2644 
       
  2645 	@SYMTestCaseDesc
       
  2646 	Creates bitmaps and saves them to the C-drive
       
  2647 	and loads them back again and compares them to
       
  2648 	the original bitmaps. 
       
  2649 
       
  2650 	@SYMTestActions
       
  2651 	The test uses different colour depths and sizes
       
  2652 	of the bitmaps. The sizes of the bitmaps are
       
  2653 	small.
       
  2654 
       
  2655 	@SYMTestExpectedResults
       
  2656 	Test should pass
       
  2657 */
       
  2658 void CTBitmap::SaveAndLoadFast()
       
  2659 	{
       
  2660 	INFO_PRINTF1(_L("Test Save/Load Fast Bitmap"));
       
  2661 
       
  2662 	// Keep this array small as the test time increases with n^2
       
  2663 	// This way we can put in bigger sizes...
       
  2664 	const TInt sizes[] = { 501, 107, 213 };
       
  2665 	const TInt numSizes = sizeof(sizes) / sizeof(TInt);
       
  2666 	TSize size;
       
  2667 
       
  2668 	for (TInt widthIndex = 0; widthIndex < numSizes; widthIndex++)
       
  2669 		{
       
  2670 		INFO_PRINTF3(_L("Index %d/%d\r"), widthIndex + 1, numSizes);
       
  2671 		size.iWidth = sizes[widthIndex];
       
  2672 
       
  2673 		for (TInt heightIndex = 0; heightIndex < numSizes; heightIndex++)
       
  2674 			{
       
  2675 			size.iHeight = sizes[heightIndex];
       
  2676 
       
  2677 			DoSaveAndLoad(size,EGray2,EFalse);
       
  2678 			DoSaveAndLoad(size,EGray2,ETrue);
       
  2679 			DoSaveAndLoad(size,EGray4,EFalse);
       
  2680 			DoSaveAndLoad(size,EGray4,ETrue);
       
  2681 			DoSaveAndLoad(size,EGray16,EFalse);
       
  2682 			DoSaveAndLoad(size,EGray16,ETrue);
       
  2683 			DoSaveAndLoad(size,EGray256,EFalse);
       
  2684 			DoSaveAndLoad(size,EGray256,ETrue);
       
  2685 			DoSaveAndLoad(size,EColor16,EFalse);
       
  2686 			DoSaveAndLoad(size,EColor16,ETrue);
       
  2687 			DoSaveAndLoad(size,EColor256,EFalse);
       
  2688 			DoSaveAndLoad(size,EColor256,ETrue);
       
  2689 			DoSaveAndLoad(size,EColor4K,EFalse);
       
  2690 			DoSaveAndLoad(size,EColor4K,ETrue);
       
  2691 			DoSaveAndLoad(size,EColor64K,EFalse);
       
  2692 			DoSaveAndLoad(size,EColor64K,ETrue);
       
  2693 			DoSaveAndLoad(size,EColor16M,EFalse);
       
  2694 			DoSaveAndLoad(size,EColor16M,ETrue);
       
  2695 			DoSaveAndLoad(size,EColor16MU,EFalse);
       
  2696 			DoSaveAndLoad(size,EColor16MU,ETrue);
       
  2697 			DoSaveAndLoad(size,EColor16MAP,EFalse);
       
  2698 			DoSaveAndLoad(size,EColor16MAP,ETrue);
       
  2699 			}
       
  2700 		}
       
  2701 
       
  2702 	INFO_PRINTF1(_L("\r\n"));
       
  2703 	
       
  2704 	}
       
  2705 
       
  2706 
       
  2707 void CTBitmap::DoSaveAndLoad(const TSize& aSize,TDisplayMode aDispMode,TBool aBlank)
       
  2708 	{
       
  2709 	CFbsBitmapEx bmp1;
       
  2710 	bmp1.Create(aSize,aDispMode);
       
  2711 
       
  2712 	if (aBlank)
       
  2713 		BlankBitmap(bmp1);
       
  2714 	else
       
  2715 		FillBitmap(bmp1);
       
  2716 
       
  2717 	TInt ret = bmp1.Save(KTempFilename);
       
  2718 	TEST2(ret, KErrNone);
       
  2719 
       
  2720 	CFbsBitmapEx bmp2;
       
  2721 	ret = bmp2.Load(KTempFilename);
       
  2722 	TEST2(ret, KErrNone);
       
  2723 
       
  2724 	CompareBitmaps(bmp1,bmp2,EColor16M);
       
  2725 
       
  2726 	ret = bmp2.Compress();
       
  2727 	TEST2(ret, KErrNone);
       
  2728 
       
  2729 	CompareBitmaps(bmp1,bmp2,EColor16M);
       
  2730 
       
  2731 	iFs.Delete(KTempFilename);
       
  2732 	}
       
  2733 
       
  2734 /**
       
  2735 	@SYMTestCaseID
       
  2736 	GRAPHICS-FBSERV-0534
       
  2737 
       
  2738 	@SYMTestCaseDesc
       
  2739 	Compresses bitmaps to ROM and RAM
       
  2740 
       
  2741 	@SYMTestActions
       
  2742 	Tries to compress a bitmap in ROM and expects it to fail. 
       
  2743 	Compresses a bitmap in RAM and expect it to succeed. 
       
  2744 	Compression tested when executed in the background.
       
  2745 	
       
  2746 	@SYMTestExpectedResults
       
  2747 	Test should pass
       
  2748 */
       
  2749 void CTBitmap::Compress()
       
  2750 	{
       
  2751 	INFO_PRINTF1(_L("Test Compression"));
       
  2752 
       
  2753 	CFbsBitmap bmp;
       
  2754 	RFbsSession* fbs = RFbsSession::GetSession();
       
  2755 	TRequestStatus rs;
       
  2756 
       
  2757 	if(!iSkipRomBitmapTests)
       
  2758 		{
       
  2759 		INFO_PRINTF1(_L("check compressing of ROM files causes error"));
       
  2760 
       
  2761 		TInt ret=bmp.Load(KRomBitmap,ETfbs,NULL);
       
  2762 		TEST2(ret, KErrNone);
       
  2763 
       
  2764 		ret = bmp.Compress();
       
  2765 		TEST2(ret, KErrAccessDenied); //cannot compress bitmaps in ROM
       
  2766 
       
  2767 		ret = bmp.CompressInBackground();
       
  2768 		TEST2(ret, KErrAccessDenied); //cannot compress bitmaps in ROM
       
  2769 
       
  2770 		bmp.CompressInBackground(rs);
       
  2771 		User::WaitForRequest(rs);
       
  2772 		TEST2(rs.Int(), KErrAccessDenied); //cannot compress bitmaps in ROM
       
  2773 
       
  2774 		ret = bmp.Save(KTempFilename);
       
  2775 		TEST2(ret, KErrNone);
       
  2776 		bmp.Reset();
       
  2777 
       
  2778 		ret = bmp.Load(KTempFilename);
       
  2779 		TEST2(ret, KErrNone);
       
  2780 
       
  2781 		ret = bmp.Compress();
       
  2782 		TEST2(ret, KErrNone);
       
  2783 		TEST(bmp.IsCompressedInRAM());
       
  2784 		bmp.Reset();
       
  2785 
       
  2786 
       
  2787 		ret = bmp.Load(KTempFilename);
       
  2788 		TEST2(ret, KErrNone);
       
  2789 
       
  2790 		ret = bmp.CompressInBackground();
       
  2791 		TEST2(ret, KErrNone);
       
  2792 
       
  2793 		fbs->SendCommand(EFbsCompress, 0); // force background compression to execute
       
  2794 
       
  2795 		TEST(bmp.IsCompressedInRAM());
       
  2796 		bmp.Reset();
       
  2797 
       
  2798 
       
  2799 		ret = bmp.Load(KTempFilename);
       
  2800 		TEST2(ret, KErrNone);
       
  2801 
       
  2802 		bmp.CompressInBackground(rs);
       
  2803 		User::WaitForRequest(rs); // wait until background compression is finished
       
  2804 		TEST2(rs.Int(), KErrNone);
       
  2805 
       
  2806 		TEST(bmp.IsCompressedInRAM());
       
  2807 		bmp.Reset();
       
  2808 
       
  2809 
       
  2810 		iFs.Delete(KTempFilename);
       
  2811 
       
  2812 		}
       
  2813 
       
  2814 	INFO_PRINTF1(_L("check compressing of RAM files is OK"));
       
  2815 	
       
  2816 		{
       
  2817 		TInt ret=bmp.Load(KTestBitmapOnC,ETfbs,NULL);
       
  2818 		if(ret != KErrNone)
       
  2819 			{
       
  2820 			INFO_PRINTF1(_L("Could not load "));
       
  2821 			INFO_PRINTF1(KTestBitmapOnC);
       
  2822 			INFO_PRINTF1(_L(" Ensure is it copied over and rerun test\n"));
       
  2823 			User::Panic(_L(""), ret);
       
  2824 			}
       
  2825 		
       
  2826 		ret = bmp.Compress();
       
  2827 		TEST2(ret, KErrNone);
       
  2828 
       
  2829 		TEST(bmp.IsCompressedInRAM());
       
  2830 			
       
  2831 		ret = bmp.Save(KTempFilename);
       
  2832 		TEST2(ret, KErrNone);
       
  2833 		bmp.Reset();
       
  2834 
       
  2835 
       
  2836 		ret = bmp.Load(KTempFilename);
       
  2837 		TEST2(ret, KErrNone);
       
  2838 
       
  2839 		ret = bmp.Compress();
       
  2840 		TEST2(ret, KErrNone);
       
  2841 
       
  2842 		TEST(bmp.IsCompressedInRAM());
       
  2843 		bmp.Reset();
       
  2844 
       
  2845 
       
  2846 		ret = bmp.Load(KTempFilename);
       
  2847 		TEST2(ret, KErrNone);
       
  2848 
       
  2849 		ret = bmp.CompressInBackground();
       
  2850 		TEST2(ret, KErrNone);
       
  2851 
       
  2852 		fbs->SendCommand(EFbsCompress, 0); // force background compression to execute
       
  2853 
       
  2854 		TEST(bmp.IsCompressedInRAM());
       
  2855 		bmp.Reset();
       
  2856 
       
  2857 
       
  2858 		ret = bmp.Load(KTempFilename);
       
  2859 		TEST2(ret, KErrNone);
       
  2860 
       
  2861 		bmp.CompressInBackground(rs);
       
  2862 		fbs->SendCommand(EFbsCompress, 0); // force background compression to execute
       
  2863 		User::WaitForRequest(rs);
       
  2864 		TEST2(rs.Int(), KErrNone);
       
  2865 
       
  2866 		TEST(bmp.IsCompressedInRAM());
       
  2867 		bmp.Reset();
       
  2868 
       
  2869 		iFs.Delete(KTempFilename);
       
  2870 		}
       
  2871 
       
  2872 		
       
  2873 		INFO_PRINTF1(_L("check compressing a created bitmap"));
       
  2874 		{
       
  2875 		INFO_PRINTF1(_L("1\r\n"));
       
  2876 		CFbsBitmapEx bitmap;
       
  2877 		TInt ret=bitmap.Create(TSize(200,200),EColor256);
       
  2878 		TEST2(ret, KErrNone);
       
  2879 		
       
  2880 		INFO_PRINTF1(_L("2\r\n"));
       
  2881 		BlankBitmap(bitmap);
       
  2882 		
       
  2883 		ret = bitmap.Compress();
       
  2884 		TEST2(ret, KErrNone);
       
  2885 		
       
  2886 		INFO_PRINTF1(_L("3\r\n"));
       
  2887 		
       
  2888 		TEST(bitmap.IsCompressedInRAM());
       
  2889 		}
       
  2890 	
       
  2891 	}
       
  2892 
       
  2893 void CTBitmap::BlankBitmap(CFbsBitmapEx& aBitmap)
       
  2894 	{
       
  2895 	TSize size = aBitmap.SizeInPixels();
       
  2896 	TInt dataLength = CFbsBitmap::ScanLineLength(size.iWidth,aBitmap.DisplayMode()) * size.iHeight;
       
  2897 	aBitmap.LockHeap();
       
  2898 	Mem::FillZ((TUint8*)aBitmap.DataAddress(),dataLength);
       
  2899 	aBitmap.UnlockHeap();
       
  2900 	}
       
  2901 
       
  2902 void CTBitmap::FillBitmap(CFbsBitmapEx& aBitmap)
       
  2903 	{
       
  2904 	TSize size = aBitmap.SizeInPixels();
       
  2905 	TInt dataLength = CFbsBitmap::ScanLineLength(size.iWidth,aBitmap.DisplayMode()) * size.iHeight;
       
  2906 
       
  2907 	aBitmap.LockHeap();
       
  2908 	TUint8* bmpBits = (TUint8*)aBitmap.DataAddress();
       
  2909 	aBitmap.UnlockHeap();
       
  2910 	TUint8* bmpBitsLimit = bmpBits + dataLength;
       
  2911 	TInt64 seed = aBitmap.Handle();
       
  2912 
       
  2913 	switch (aBitmap.DisplayMode())
       
  2914 		{
       
  2915 		case EColor4K:
       
  2916 			Mem::FillZ(bmpBits,dataLength);
       
  2917 
       
  2918 			while (bmpBits < bmpBitsLimit)
       
  2919 				{
       
  2920 				*bmpBits++ = (TUint8)Math::Rand(seed);
       
  2921 				*bmpBits++ = (TUint8)(Math::Rand(seed) & 0x0f);
       
  2922 				}	
       
  2923 			break;
       
  2924 		case EColor16MAP:
       
  2925 			while (bmpBits < bmpBitsLimit)
       
  2926 				{
       
  2927 				TUint32 alpha = (TUint8)Math::Rand(seed);
       
  2928 				TUint32 red = 	(TUint8)Math::Rand(seed);
       
  2929 				TUint32 green = (TUint8)Math::Rand(seed);
       
  2930 				TUint32 blue =  (TUint8)Math::Rand(seed);
       
  2931 				red = ((red * alpha)/255)&0xff;
       
  2932 				green  = ((green * alpha)/255)&0xff;
       
  2933 				blue = ((blue * alpha)/255)&0xff;
       
  2934 				*(TUint32*)bmpBits = (alpha<<24)|(red<<16)|(green<<8)|blue;
       
  2935 				bmpBits+=4;
       
  2936 				}
       
  2937 			break;
       
  2938 		default:
       
  2939 			while (bmpBits < bmpBitsLimit)
       
  2940 				*bmpBits++ = (TUint8)Math::Rand(seed);
       
  2941 			break;	
       
  2942 		}	
       
  2943 	}
       
  2944 
       
  2945 void CTBitmap::StripeBitmap(CFbsBitmapEx& aBitmap) // Compression friendly bitmap filling
       
  2946 	{
       
  2947 	TSize size = aBitmap.SizeInPixels();
       
  2948 	TInt dataLength = CFbsBitmap::ScanLineLength(size.iWidth,aBitmap.DisplayMode()) * size.iHeight;
       
  2949 
       
  2950 	aBitmap.LockHeap();
       
  2951 	TUint8* bmpBits = (TUint8*)aBitmap.DataAddress();
       
  2952 	aBitmap.UnlockHeap();
       
  2953 	TUint8* bmpBitsLimit = bmpBits + dataLength;
       
  2954 	TInt64 seed = aBitmap.Handle();
       
  2955 
       
  2956 	if (aBitmap.DisplayMode() != EColor4K)
       
  2957 		{
       
  2958 		while (bmpBits < bmpBitsLimit)
       
  2959 			{
       
  2960 			TUint8* tempBmpBitsLimit = Min(bmpBitsLimit, bmpBits + (TUint8)Math::Rand(seed));
       
  2961 			while (bmpBits < tempBmpBitsLimit)
       
  2962 				*bmpBits++ = 0;
       
  2963 			tempBmpBitsLimit = Min(bmpBitsLimit, bmpBits + (TUint8)Math::Rand(seed));
       
  2964 			while (bmpBits < tempBmpBitsLimit)
       
  2965 				*bmpBits++ = 0xff;
       
  2966 			}
       
  2967 		}
       
  2968 	else
       
  2969 		{
       
  2970 		Mem::FillZ(bmpBits,dataLength);
       
  2971 
       
  2972 		while (bmpBits < bmpBitsLimit)
       
  2973 			{
       
  2974 			TUint8* tempBmpBitsLimit = Min(bmpBitsLimit, bmpBits + (TUint8)(Math::Rand(seed) * 2));
       
  2975 			while (bmpBits < tempBmpBitsLimit)
       
  2976 				{
       
  2977 				*bmpBits++ = 0;
       
  2978 				*bmpBits++ = 0;
       
  2979 				}
       
  2980 			tempBmpBitsLimit = Min(bmpBitsLimit, bmpBits + (TUint8)Math::Rand(seed));
       
  2981 			while (bmpBits < tempBmpBitsLimit)
       
  2982 				{
       
  2983 				*bmpBits++ = 0xff;
       
  2984 				*bmpBits++ = 0x0f;
       
  2985 				}
       
  2986 			}		
       
  2987 		}
       
  2988 	}
       
  2989 
       
  2990 void CTBitmap::CompareBitmaps(CFbsBitmapEx& aBmp1,CFbsBitmapEx& aBmp2,TDisplayMode aDispMode)
       
  2991 	{
       
  2992 	// We will compare bitmaps that we draw beginning at four different offsets into the bitmap
       
  2993 	const TInt KTestBitmapOrigins = 4;
       
  2994 	const TSize bmpSize = aBmp1.SizeInPixels();
       
  2995 	TEST(bmpSize == aBmp2.SizeInPixels());
       
  2996 	TInt originIndex = 0;
       
  2997 	
       
  2998 	// Call DoCompareBitmaps() for four different origins
       
  2999 	for(TInt ii=0;ii<KTestBitmapOrigins;ii++)
       
  3000 		{
       
  3001 		TInt xCoord = originIndex*(bmpSize.iWidth/4);
       
  3002 		TInt yCoord = originIndex*(bmpSize.iHeight/4);
       
  3003 		DoCompareBitmaps(aBmp1,aBmp2,aDispMode,TPoint(xCoord, yCoord), bmpSize);
       
  3004 		originIndex++;
       
  3005 		}
       
  3006 	}
       
  3007 	
       
  3008 void CTBitmap::DoCompareBitmaps(CFbsBitmapEx& aBmp1,CFbsBitmapEx& aBmp2,TDisplayMode aDispMode, TPoint aLineOrigin, TSize aBmpSize)
       
  3009 	{
       
  3010 	// Compares two bitmaps line by line
       
  3011 	const TInt KBitmapWidth = aBmpSize.iWidth;
       
  3012 	const TInt KStartRow = aLineOrigin.iY;
       
  3013 	const TInt KBitmapHeight = aBmpSize.iHeight;
       
  3014 	
       
  3015 	HBufC8* buf1 = HBufC8::NewMax(KBitmapWidth * 4);
       
  3016 	HBufC8* buf2 = HBufC8::NewMax(KBitmapWidth * 4);
       
  3017 	TEST(buf1 && buf2);
       
  3018 
       
  3019 	TPtr8 des1(buf1->Des());
       
  3020 	TPtr8 des2(buf2->Des());
       
  3021 	
       
  3022 	for (TInt row = KStartRow; row < KBitmapHeight; row++) 
       
  3023 		{
       
  3024 		aBmp1.GetScanLine(des1,aLineOrigin,KBitmapWidth,aDispMode); 
       
  3025 		aBmp2.GetScanLine(des2,aLineOrigin,KBitmapWidth,aDispMode);
       
  3026 
       
  3027 		const TInt ret = des1.Compare(des2);
       
  3028 		if (ret!=0)
       
  3029 			{
       
  3030 			 INFO_PRINTF2(_L("Bitmap comparison failed, row %d differernt!\n"), row);
       
  3031 			 aBmp1.Save(KFail1Filename);
       
  3032 			 aBmp2.Save(KFail2Filename);
       
  3033 			}
       
  3034 		TEST(ret == 0);
       
  3035 		}
       
  3036 
       
  3037 	delete buf1;
       
  3038 	delete buf2;
       
  3039 	}
       
  3040 
       
  3041 void CTBitmap::CopyBitmap(CFbsBitmapEx& aBmp1,const CFbsBitmapEx& aBmp2)
       
  3042 	{
       
  3043 	TSize bmp1size = aBmp1.SizeInPixels();
       
  3044 	TSize bmp2size = aBmp2.SizeInPixels();
       
  3045 	TInt bmp1dataLength = CFbsBitmap::ScanLineLength(bmp1size.iWidth,aBmp1.DisplayMode()) * bmp1size.iHeight;
       
  3046 	TInt bmp2dataLength = CFbsBitmap::ScanLineLength(bmp2size.iWidth,aBmp2.DisplayMode()) * bmp2size.iHeight;
       
  3047 	TEST(bmp1dataLength == bmp2dataLength);
       
  3048 	aBmp1.LockHeap();
       
  3049 	TUint32* bmp1Bits = aBmp1.DataAddress();
       
  3050 	aBmp1.UnlockHeap();
       
  3051 	aBmp2.LockHeap();
       
  3052 	TUint32* bmp2Bits = aBmp2.DataAddress();
       
  3053 	aBmp2.UnlockHeap();
       
  3054 	Mem::Copy((TUint8*)bmp1Bits,(TUint8*)bmp2Bits,bmp1dataLength);
       
  3055 	}
       
  3056 
       
  3057 
       
  3058 /**
       
  3059 	@SYMTestCaseID
       
  3060 	GRAPHICS-FBSERV-0535
       
  3061 
       
  3062 	@SYMTestCaseDesc
       
  3063 	Loads and copies bitmaps and does a
       
  3064 	fuzzy compare on the bitmaps using 
       
  3065 	scan lines
       
  3066 
       
  3067 	@SYMTestActions
       
  3068 
       
  3069 	@SYMTestExpectedResults
       
  3070 	Test should pass
       
  3071 */
       
  3072 void CTBitmap::Color256BitmapUtil()
       
  3073 	{
       
  3074 	INFO_PRINTF1(_L("Test CFbsColor256BitmapUtil"));
       
  3075 
       
  3076 	CFbsBitmapEx bmpRefDitherFs;
       
  3077 	TInt ret=bmpRefDitherFs.Load(_L("z:\\system\\data\\8bitDitherFS.mbm"));
       
  3078 	TEST2(ret, KErrNone);
       
  3079 
       
  3080 	CFbsBitmapEx bmpRefNoDither;
       
  3081 	ret=bmpRefNoDither.Load(_L("z:\\system\\data\\8bitNoDither.mbm"));
       
  3082 	TEST2(ret, KErrNone);
       
  3083 
       
  3084 	TSize size = bmpRefNoDither.SizeInPixels();
       
  3085 
       
  3086 	CFbsColor256BitmapUtil* util = NULL;
       
  3087 	TRAP(ret, util=CFbsColor256BitmapUtil::NewL(NULL));
       
  3088 	TEST2(ret, KErrNone);
       
  3089 
       
  3090 	CFbsBitmapEx bmp2;
       
  3091 	ret = bmp2.Create(size,EColor256);
       
  3092 	TEST2(ret, KErrNone);
       
  3093 
       
  3094 	CFbsBitmapEx bmp1;
       
  3095 
       
  3096 	INFO_PRINTF1(_L("EColor256 "));
       
  3097 
       
  3098 	ret = util->CopyBitmap(&bmp2,&bmpRefNoDither,CFbsColor256BitmapUtil::ENoDither);
       
  3099 	TEST2(ret, KErrNone);
       
  3100 	CompareBitmaps(bmpRefNoDither,bmp2,EColor16M);
       
  3101 	ret = util->CopyBitmap(&bmp2,&bmpRefDitherFs,CFbsColor256BitmapUtil::EFloydSteinberg);
       
  3102 	TEST2(ret, KErrNone);
       
  3103 	CompareBitmaps(bmpRefDitherFs,bmp2,EColor16M);
       
  3104 
       
  3105 	INFO_PRINTF1(_L("EColor4K "));
       
  3106 
       
  3107 	ret=bmp1.Load(_L("z:\\system\\data\\12bit.mbm"));
       
  3108 	TEST2(ret, KErrNone);
       
  3109 	ret = util->CopyBitmap(&bmp2,&bmp1,CFbsColor256BitmapUtil::ENoDither);
       
  3110 	TEST2(ret, KErrNone);
       
  3111 	CompareBitmaps(bmpRefNoDither,bmp2,EColor16M);
       
  3112 	ret = util->CopyBitmap(&bmp2,&bmp1,CFbsColor256BitmapUtil::EFloydSteinberg);
       
  3113 	TEST2(ret, KErrNone);
       
  3114 	FuzzyCompareBitmapsColor256(bmpRefNoDither,bmp2,23);
       
  3115 
       
  3116 	INFO_PRINTF1(_L("EColor64K "));
       
  3117 
       
  3118 	ret=bmp1.Load(_L("z:\\system\\data\\16bit.mbm"));
       
  3119 	TEST2(ret, KErrNone);
       
  3120 	ret = util->CopyBitmap(&bmp2,&bmp1,CFbsColor256BitmapUtil::ENoDither);
       
  3121 	TEST2(ret, KErrNone);
       
  3122 	CompareBitmaps(bmpRefNoDither,bmp2,EColor16M);
       
  3123 	ret = util->CopyBitmap(&bmp2,&bmp1,CFbsColor256BitmapUtil::EFloydSteinberg);
       
  3124 	TEST2(ret, KErrNone);
       
  3125 	FuzzyCompareBitmapsColor256(bmpRefNoDither,bmp2,28);
       
  3126 
       
  3127 	INFO_PRINTF1(_L("EColor16M\r\n"));
       
  3128 
       
  3129 	ret=bmp1.Load(_L("z:\\system\\data\\24bit.mbm"));
       
  3130 	TEST2(ret, KErrNone);
       
  3131 	ret = util->CopyBitmap(&bmp2,&bmp1,CFbsColor256BitmapUtil::ENoDither);
       
  3132 	TEST2(ret, KErrNone);
       
  3133 	CompareBitmaps(bmpRefNoDither,bmp2,EColor16M);
       
  3134 	ret = util->CopyBitmap(&bmp2,&bmp1,CFbsColor256BitmapUtil::EFloydSteinberg);
       
  3135 	TEST2(ret, KErrNone);
       
  3136 	FuzzyCompareBitmapsColor256(bmpRefNoDither,bmp2,32);
       
  3137 
       
  3138 	INFO_PRINTF1(_L("EColor16MU\r\n"));
       
  3139 
       
  3140 	ret=bmp1.Load(_L("z:\\system\\data\\32bit.mbm"));
       
  3141 	TEST2(ret, KErrNone);
       
  3142 	ret = util->CopyBitmap(&bmp2,&bmp1,CFbsColor256BitmapUtil::ENoDither);
       
  3143 	TEST2(ret, KErrNone);
       
  3144 	CompareBitmaps(bmpRefNoDither,bmp2,EColor16M);
       
  3145 	ret = util->CopyBitmap(&bmp2,&bmp1,CFbsColor256BitmapUtil::EFloydSteinberg);
       
  3146 	TEST2(ret, KErrNone);
       
  3147 	FuzzyCompareBitmapsColor256(bmpRefNoDither,bmp2,32);
       
  3148 	
       
  3149 	CFbsBitmapEx bmp3;
       
  3150 	ret = bmp3.Create(size,EColor16MAP);
       
  3151 	TEST2(ret, KErrNone);
       
  3152 	CopyBitmap(bmp3,bmp1);
       
  3153 	TEST2(ret, KErrNone);
       
  3154 	ret = util->CopyBitmap(&bmp2,&bmp3,CFbsColor256BitmapUtil::ENoDither);
       
  3155 	TEST2(ret, KErrNone);
       
  3156 	//Do not compare bitmaps since there is no reference EColor16MAP image
       
  3157 	//CompareBitmaps(bmpRefNoDither,bmp2,EColor16M); - testing ensures that
       
  3158 	//copying succeeds, not accuracy
       
  3159 	ret = util->CopyBitmap(&bmp2,&bmp3,CFbsColor256BitmapUtil::EFloydSteinberg);
       
  3160 	TEST2(ret, KErrNone);
       
  3161 	//Do not compare bitmaps since there is no reference EColor16MAP image
       
  3162 	//FuzzyCompareBitmapsColor256(bmpRefNoDither,bmp2,32); - testing ensures that
       
  3163 	//copying succeeds, not accuracy
       
  3164 	bmp3.Reset();	
       
  3165 
       
  3166 //	bmp2.Save(_L("c:\\8bitSaved.mbm"));
       
  3167 
       
  3168 	bmp1.Reset();
       
  3169 	bmp2.Reset();
       
  3170 	bmpRefNoDither.Reset();
       
  3171 	bmpRefDitherFs.Reset();
       
  3172 	delete util;
       
  3173 
       
  3174 	
       
  3175 	}
       
  3176 
       
  3177 void CTBitmap::FuzzyCompareBitmapsColor256(CFbsBitmapEx& aBmp1,CFbsBitmapEx& aBmp2,TUint aDifLimit)
       
  3178 	{
       
  3179 	TSize bmp1size = aBmp1.SizeInPixels();
       
  3180 	TSize bmp2size = aBmp2.SizeInPixels();
       
  3181 	TInt bmp1dataLength = CFbsBitmap::ScanLineLength(bmp1size.iWidth,aBmp1.DisplayMode()) * bmp1size.iHeight;
       
  3182 	TInt bmp2dataLength = CFbsBitmap::ScanLineLength(bmp2size.iWidth,aBmp2.DisplayMode()) * bmp2size.iHeight;
       
  3183 	TEST(bmp1dataLength == bmp2dataLength);
       
  3184 	aBmp1.LockHeap();
       
  3185 	TUint8* bmp1Bits = (TUint8*)aBmp1.DataAddress();
       
  3186 	aBmp1.UnlockHeap();
       
  3187 	aBmp2.LockHeap();
       
  3188 	TUint8* bmp2Bits = (TUint8*)aBmp2.DataAddress();
       
  3189 	aBmp2.UnlockHeap();
       
  3190 
       
  3191 	TUint totalDifference = 0;
       
  3192 	TUint difference = 0;
       
  3193 	while(bmp1dataLength--)
       
  3194 		{
       
  3195 		difference = TRgb::Color256((TUint)*(bmp1Bits++)).Difference(TRgb::Color256((TUint)*(bmp2Bits++)));
       
  3196 		totalDifference+=difference;
       
  3197 		}
       
  3198 	TUint avDif = totalDifference/bmp2dataLength;
       
  3199 	TEST(avDif<=aDifLimit);
       
  3200 	}
       
  3201 
       
  3202 /**
       
  3203 	@SYMTestCaseID
       
  3204 	GRAPHICS-FBSERV-0536
       
  3205 
       
  3206 	@SYMTestCaseDesc
       
  3207 	Creates a hardware bitmap with a size and 
       
  3208 	display mode for different display modes. 
       
  3209 
       
  3210 	@SYMTestActions
       
  3211 	It checks some bitmap attributes, bitmapHandle,
       
  3212 	if it is a large bitmap and if the bitmap is in ROM.
       
  3213 	Creates a 'normal' bitmap with the same size as the 
       
  3214 	hardware one. Checks it can write to the hardware 
       
  3215 	bitmap. Checks reuse of a CFbsBitmap for mixture of 
       
  3216 	hardware and normal bitmaps works.
       
  3217 
       
  3218 	@SYMTestExpectedResults
       
  3219 	Test should pass
       
  3220 */
       
  3221 void CTBitmap::HardwareBitmaps()
       
  3222 	{
       
  3223 	static const TDisplayMode modes[] =
       
  3224 		{
       
  3225 		EGray2,
       
  3226 		EGray4,
       
  3227 		EGray16,
       
  3228 		EGray256,
       
  3229 		EColor16,
       
  3230 		EColor256,
       
  3231 		EColor64K,
       
  3232 		EColor16M,
       
  3233 		EColor16MU,
       
  3234 		EColor4K,
       
  3235 		EColor16MAP,
       
  3236 		ENone
       
  3237 		};
       
  3238 
       
  3239 	INFO_PRINTF1(_L("Test Hardware Bitmaps"));
       
  3240 
       
  3241 	CFbsBitmapEx bitmap1;
       
  3242 	// Large bitmap threshold increased from 4K to 64K
       
  3243 	TSize size(300,300);
       
  3244 	TDisplayMode displayMode;
       
  3245 
       
  3246 	// Try and find a display mode that hardware bitmaps support
       
  3247 	TInt ret = KErrNotSupported;
       
  3248 	TInt i=0;
       
  3249 	while((displayMode=modes[i])!=ENone)
       
  3250 		{
       
  3251 		ret = bitmap1.CreateHardwareBitmap(size,displayMode,TUid::Uid(0));
       
  3252 		if(ret!=KErrNotSupported)
       
  3253 			{
       
  3254 			TEST2(ret, KErrNone);
       
  3255 			break;
       
  3256 			}
       
  3257 		i++;
       
  3258 		}
       
  3259 
       
  3260 	if(ret==KErrNotSupported)
       
  3261 		{
       
  3262 		// Hardware bitmaps not supported on this device
       
  3263 		WARN_PRINTF1(_L("...Not Supported"));
       
  3264 		return;
       
  3265 		}
       
  3266 
       
  3267 	// Check some bitmap attributes
       
  3268 	TEST(bitmap1.HardwareBitmapHandle()!=NULL);
       
  3269 	TEST(!bitmap1.IsLargeBitmap());
       
  3270 	TEST(!bitmap1.IsRomBitmap());
       
  3271 
       
  3272 	// Create a 'normal' bitmap the same size as the hardware one
       
  3273 	CFbsBitmapEx bitmap2;
       
  3274 	ret = bitmap2.Create(size,displayMode);
       
  3275 	TEST2(ret, KErrNone);
       
  3276 	TEST(bitmap2.HardwareBitmapHandle()==NULL);
       
  3277 	TEST(bitmap2.IsLargeBitmap());
       
  3278 
       
  3279 	// Check we can write to the hardware bitmap OK
       
  3280 	FillBitmap(bitmap1);
       
  3281 	CopyBitmap(bitmap1,bitmap2);
       
  3282 	CompareBitmaps(bitmap1,bitmap2,EColor16M);
       
  3283 
       
  3284 	// Discard hardware bitmap
       
  3285 	bitmap1.Reset();
       
  3286 
       
  3287 	// Check reuse of a CFbsBitmap for mixture of hardware and normal bitmaps works
       
  3288 	ret = bitmap2.CreateHardwareBitmap(size,displayMode,TUid::Uid(0));
       
  3289 	TEST2(ret, KErrNone);
       
  3290 	ret = bitmap2.Create(TSize(10,10),displayMode);
       
  3291 	TEST2(ret, KErrNone);
       
  3292 	ret = bitmap2.CreateHardwareBitmap(size,displayMode,TUid::Uid(0));
       
  3293 	TEST2(ret, KErrNone);
       
  3294 	ret = bitmap2.Create(size,displayMode);
       
  3295 	TEST2(ret, KErrNone);
       
  3296 	}
       
  3297 
       
  3298 /**
       
  3299 	@SYMTestCaseID
       
  3300 	GRAPHICS-FBSERV-0537
       
  3301 
       
  3302 	@SYMTestCaseDesc
       
  3303 	GetScanLine test
       
  3304 	
       
  3305 	@SYMDEF INC036062
       
  3306 
       
  3307 	@SYMTestActions
       
  3308 	For each possible display mode it creates a test bitmap
       
  3309 	and initialize it with the data from the gray bitmap.
       
  3310 	Then for each possible display mode it calls GetScanLine 
       
  3311 	on the gray and	test bitmaps and compares the lines.
       
  3312 		
       
  3313 	@SYMTestExpectedResults
       
  3314 	Test should pass
       
  3315 */
       
  3316 void CTBitmap::INC036062L()
       
  3317 //INC036062  -  Optimise masked bitblit for 1 bit greyscale mask case 
       
  3318 	{
       
  3319 	INFO_PRINTF1(_L("INC036062"));
       
  3320 	TDisplayMode displayMode[] = 
       
  3321 		{
       
  3322 		EGray2, EGray4, EGray16, EGray256, EColor16, EColor256, 
       
  3323 		EColor64K, EColor16M, EColor4K, EColor16MU, EColor16MAP
       
  3324 		};
       
  3325 	//Two EGray2 test bitmaps with sizes (11, 11) and (121, 121).
       
  3326 	TSize size[] = 
       
  3327 		{
       
  3328 		TSize(11, 11), TSize(121, 121)
       
  3329 		};
       
  3330 	//Masks for for the last scanline byte (probably partially initialized)
       
  3331 	TUint8 mask[sizeof(size)/sizeof(size[0])][sizeof(displayMode)/sizeof(displayMode[0])] = 
       
  3332 		{
       
  3333 		//EGray2 EGray4 EGray16 EGray256 EColor16 EColor256 EColor64K EColor16M EColor4K EColor16MU
       
  3334 		{0x07,   0x3F,  0x0F,   0xFF,    0x0F,    0xFF,     0xFF,     0xFF,     0x0F,    0xFF},
       
  3335 		{0x01,   0x03,  0x0F,   0xFF,    0x0F,    0xFF,     0xFF,     0xFF,     0x0F,    0xFF}
       
  3336 		};
       
  3337 	for(TInt i=0;i<TInt(sizeof(size)/sizeof(size[0]));i++)
       
  3338 		{
       
  3339 		//Create EGray2 bitmap
       
  3340 		CFbsBitmap* bmp = CreateBitmapLC(size[i], EGray2);
       
  3341 		//GetScanLine test - for each possible display mode: create a test bitmap
       
  3342 		//and initialize it with the data from the gray bitmap.
       
  3343 		//After that: for each possible display mode - call GetScanLine on the gray and
       
  3344 		//test bitmaps and compare the lines.
       
  3345 		for(TInt m=0;m<TInt(sizeof(displayMode)/sizeof(displayMode[0]));m++)
       
  3346 			{
       
  3347 			HBufC8* row1 = HBufC8::NewLC(1000);
       
  3348 			TPtr8 prow1 = row1->Des();
       
  3349 			HBufC8* row2 = HBufC8::NewLC(1000);
       
  3350 			TPtr8 prow2 = row2->Des();
       
  3351 			//Create test bitmap
       
  3352 			CFbsBitmap* tbmp = CreateBitmapLC(size[i], displayMode[m], bmp);
       
  3353 			//Check test bitmap
       
  3354 			for(TInt m2=0;m2<TInt(sizeof(displayMode)/sizeof(displayMode[0]));m2++)
       
  3355 				{
       
  3356 				for(TInt y=0;y<size[i].iHeight;y++)
       
  3357 					{
       
  3358 					bmp->GetScanLine(prow1, TPoint(0, y), size[i].iWidth, displayMode[m2]);
       
  3359 					tbmp->GetScanLine(prow2, TPoint(0, y), size[i].iWidth, displayMode[m2]);
       
  3360 					TInt len = prow1.Length();
       
  3361 					TEST(len == prow2.Length());
       
  3362 					TEST(len > 0);
       
  3363 					TUint8 b1 = prow1[len - 1];
       
  3364 					TUint8 b2 = prow2[len - 1];
       
  3365 					if(mask[i][m2] != 0xFF)
       
  3366 						{//Not all bits from the last byte are used.
       
  3367 						TEST((b1 & mask[i][m2]) == (b2 & mask[i][m2]));
       
  3368 						prow1.SetLength(len - 1);
       
  3369 						prow2.SetLength(len - 1);
       
  3370 						}
       
  3371 					TEST(prow1 == prow2);
       
  3372 					}//end of - for(TInt y=0;y<size[i].iHeight;y++)
       
  3373 				}//end of - for(TInt m2=0;m2<(sizeof(displayMode)/sizeof(displayMode[0]));m2++)
       
  3374 			CleanupStack::PopAndDestroy(tbmp);
       
  3375 			CleanupStack::PopAndDestroy(row2);
       
  3376 			CleanupStack::PopAndDestroy(row1);
       
  3377 			}//end of - for(TInt m=0;m<(sizeof(displayMode)/sizeof(displayMode[0]));m++)
       
  3378 		CleanupStack::PopAndDestroy(bmp);
       
  3379 		}//end of - for(TInt i=0;i<(sizeof(size)/sizeof(size[0]));i++)
       
  3380 	}
       
  3381 
       
  3382 /**
       
  3383 	@SYMTestCaseID
       
  3384 	GRAPHICS-FBSERV-0538
       
  3385 
       
  3386 	@SYMTestCaseDesc
       
  3387 	Performance test of INC036062 (GetScanLine test)
       
  3388 
       
  3389 	@SYMDEF INC036062
       
  3390 
       
  3391 	@SYMTestActions
       
  3392 		
       
  3393 	@SYMTestExpectedResults
       
  3394 	Test should pass
       
  3395 */
       
  3396 void CTBitmap::PerformanceTest_INC036062L()
       
  3397 //INC036062  -  Optimise masked bitblit for 1 bit greyscale mask case 
       
  3398 	{
       
  3399 	INFO_PRINTF1(_L("INC036062-Performance Test"));
       
  3400 	TSize size(143, 143);
       
  3401 	//Create EGray2 bitmap
       
  3402 	CFbsBitmap* bmpGray2 = CreateBitmapLC(size, EGray2);
       
  3403 	//Create EColor64 bitmap
       
  3404 	CFbsBitmap* bmpEColor64 = CreateBitmapLC(size, EColor64K);
       
  3405 	//Performance test
       
  3406 	TDisplayMode displayMode[] = 
       
  3407 		{
       
  3408 		EGray2, EGray4, EGray16, EGray256, EColor16, EColor256, 
       
  3409 		EColor64K, EColor16M, EColor4K, EColor16MU, EColor16MAP
       
  3410 		};
       
  3411 	TInt i;
       
  3412 	HBufC8* row = HBufC8::NewLC(1000);
       
  3413 	TPtr8 prow = row->Des();
       
  3414 	for(TInt m=0;m<TInt(sizeof(displayMode)/sizeof(displayMode[0]));m++)
       
  3415 		{
       
  3416 		TUint time[2] = {0, 0};
       
  3417 		CFbsBitmap* pbmp[2] = {bmpGray2, bmpEColor64};
       
  3418 		for(TInt j=0;j<2;j++)
       
  3419 			{
       
  3420 			time[j] = User::TickCount();
       
  3421 			for(i=0;i<200;i++)
       
  3422 				{
       
  3423 				for(TInt y=0;y<size.iHeight;y++)
       
  3424 					{
       
  3425 					pbmp[j]->GetScanLine(prow, TPoint(0, y), size.iWidth, displayMode[m]);
       
  3426 					}
       
  3427 				}
       
  3428 			time[j] = User::TickCount() - time[j];
       
  3429 			}
       
  3430 		//"Time+" - time with optimized GetScanLine for EGray2 bitmaps
       
  3431 		//"Time-" - time with GetScanLine for all bitmaps which colour is not EGray2.
       
  3432 		INFO_PRINTF4(_L("GetScanLine. Mode=%d, Time+ =%d, Time- =%d\r\n"), displayMode[m], time[0], time[1]);
       
  3433 		}
       
  3434 	CleanupStack::PopAndDestroy(row);
       
  3435 	CleanupStack::PopAndDestroy(bmpEColor64);
       
  3436 	CleanupStack::PopAndDestroy(bmpGray2);
       
  3437 	}
       
  3438 
       
  3439 CFbsBitmap* CTBitmap::CreateBitmapLC(const TSize& aSize, TDisplayMode aMode)
       
  3440 	{
       
  3441 	CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
       
  3442 	CleanupStack::PushL(bmp);
       
  3443 	User::LeaveIfError(bmp->Create(aSize, aMode));
       
  3444 	//Initialize the bitmap
       
  3445 	TBitmapUtil bmpUtil(bmp);
       
  3446 	bmpUtil.Begin(TPoint(0, 0));
       
  3447 	for(TInt y=0;y<aSize.iHeight;bmpUtil.IncYPos(),y++)
       
  3448 		{
       
  3449 		for(TInt x=0;x<aSize.iWidth;bmpUtil.IncXPos(),x++)
       
  3450 			{
       
  3451 			TUint32 color = 0;
       
  3452 			switch(aMode)
       
  3453 				{
       
  3454 				case EGray2:
       
  3455 					color = Math::Random() % 2;
       
  3456 					break;
       
  3457 				case EColor64K:
       
  3458 					color = Math::Random() % 0x10000;
       
  3459 					break;
       
  3460 				case EColor16MA:
       
  3461 					color = Math::Random();
       
  3462 					break;
       
  3463 				default:
       
  3464 					break;
       
  3465 				}
       
  3466 			bmpUtil.SetPixel(color);
       
  3467 			}
       
  3468 		}
       
  3469 	bmpUtil.End();
       
  3470 	return bmp;
       
  3471 	}
       
  3472 
       
  3473 CFbsBitmap* CTBitmap::CreateBitmapLC(const TSize& aSize, TDisplayMode aMode, const CFbsBitmap* aSrcBmp)
       
  3474 	{
       
  3475 	CFbsBitmap* tbmp = new (ELeave) CFbsBitmap;
       
  3476 	CleanupStack::PushL(tbmp);
       
  3477 	User::LeaveIfError(tbmp->Create(aSize, aMode));
       
  3478 	//Initialize test bitmap
       
  3479 	HBufC8* row = HBufC8::NewLC(1000);
       
  3480 	TPtr8 prow = row->Des();
       
  3481 	for(TInt y=0;y<aSize.iHeight;y++)
       
  3482 		{
       
  3483 		aSrcBmp->GetScanLine(prow, TPoint(0, y), aSize.iWidth, aMode);
       
  3484 		tbmp->SetScanLine(prow, y);
       
  3485 		}
       
  3486 	CleanupStack::PopAndDestroy(row);
       
  3487 	return tbmp;
       
  3488 	}
       
  3489 
       
  3490 /**
       
  3491 	@SYMTestCaseID
       
  3492 	GRAPHICS-FBSERV-0539
       
  3493 
       
  3494 	@SYMTestCaseDesc
       
  3495 	Loads bitmaps from ROM and RAM
       
  3496 	and does a GetScanLine on the bitmaps
       
  3497 	and measures the time it takes to do
       
  3498 	the GetScanLine.
       
  3499 	
       
  3500 	@SYMDEF INC037474
       
  3501 	
       
  3502 	@SYMTestActions
       
  3503 	
       
  3504 	@SYMTestExpectedResults
       
  3505 	Test should pass
       
  3506 */
       
  3507 void CTBitmap::INC037474L()
       
  3508 //INC037474 - SS66 - CBitwiseBitmap::GenerateLineFromCompressedSixteenBitData() is very slow
       
  3509 	{
       
  3510 	TPtrC bmpFile[] =
       
  3511 		{
       
  3512 		KBmpCompr12(),
       
  3513 		KBmpCompr16(),
       
  3514 		KBmpCompr24(),
       
  3515 		KBmpCCompr12(),
       
  3516 		KBmpCCompr16(),
       
  3517 		KBmpCCompr24()
       
  3518 		};
       
  3519 	TPtrC tt[] = {_L("rom"), _L("rom"), _L("rom"), _L("ram"), _L("ram"), _L("ram")};
       
  3520 	TBool inRam[] = {EFalse, EFalse, EFalse, ETrue, ETrue, ETrue};
       
  3521 	TInt bpp[] = {12, 16, 24, 12, 16, 24};
       
  3522 	TDisplayMode targetMode[] = {EColor4K, EColor64K, EColor16M, EColor4K, EColor64K, EColor16M};
       
  3523 	const TInt KMaxScanLineLen = 800;
       
  3524 	TBuf8<KMaxScanLineLen> scanLineBuf;
       
  3525 	for(TInt i=0;i<TInt(sizeof(bmpFile)/sizeof(bmpFile[0]));i++)
       
  3526 		{
       
  3527 		if(iSkipRomBitmapTests && !inRam[i])
       
  3528 			continue;
       
  3529 		
       
  3530 		CFbsBitmap* bmp = LoadBitmapLC(bmpFile[i]);
       
  3531 		if(inRam[i])
       
  3532 			{
       
  3533 			User::LeaveIfError(bmp->Compress());
       
  3534 			}
       
  3535 		//
       
  3536 		TDesC& des = tt[i];
       
  3537 		INFO_PRINTF3(_L("%d bpp %S compressed bitmap, GetScanLine test\r\n"), bpp[i], &des);
       
  3538 		TSize size = bmp->SizeInPixels();
       
  3539 		TEST(TInt(size.iWidth * sizeof(TInt16)) <= KMaxScanLineLen);
       
  3540 		TUint timeStart = User::TickCount();
       
  3541 		enum {KTestTimes = 15};//Greater KTestTimes values make the test is too slow!
       
  3542 		for(TInt j=0;j<KTestTimes;j++) 
       
  3543 			{
       
  3544 			TPoint startPixel(0, 0);
       
  3545 			for(TInt k=0;k<size.iHeight;k++)
       
  3546 				{
       
  3547 				startPixel.iY = k;
       
  3548 				bmp->GetScanLine(scanLineBuf, startPixel, size.iWidth, targetMode[i]);
       
  3549 				}
       
  3550 			}
       
  3551 		TUint timeEnd = User::TickCount();
       
  3552 		INFO_PRINTF4(_L("%d bpp %S compressed bitmap, time = %d\r\n"), bpp[i], &des, timeEnd - timeStart);
       
  3553 		//
       
  3554 		CleanupStack::PopAndDestroy(bmp);
       
  3555 		}
       
  3556 	}
       
  3557 
       
  3558 CFbsBitmap* CTBitmap::LoadBitmapLC(const TDesC& aFileName)
       
  3559 	{
       
  3560 	CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
       
  3561 	CleanupStack::PushL(bmp);
       
  3562 	const TInt err = bmp->Load(aFileName, 0);
       
  3563 	TEST(err == KErrNone);
       
  3564 	User::LeaveIfError(err);
       
  3565 	return bmp;
       
  3566 	}
       
  3567 
       
  3568 /**
       
  3569 	@SYMTestCaseID
       
  3570 	GRAPHICS-FBSERV-0540
       
  3571 
       
  3572 	@SYMTestCaseDesc
       
  3573 	Test to verify defect DEF038286.
       
  3574 	
       
  3575 	@SYMDEF DEF038286
       
  3576 
       
  3577 	@SYMTestActions
       
  3578 	Initialized a test bitmap, compresses it
       
  3579 	and performs a GetScanLine on the compressed
       
  3580 	bitmap. Checks the color value against an
       
  3581 	expected value.
       
  3582 	
       
  3583 	@SYMTestExpectedResults
       
  3584 	Test should pass
       
  3585 */
       
  3586 void CTBitmap::DEF038286L()
       
  3587 //DEF038286 - CBitwiseBitmap::GenerateLineFromCompressedSixteenBitData returns wrong clr value	
       
  3588 	{
       
  3589 	INFO_PRINTF1(_L("DEF038286 fix test"));
       
  3590 	//Create test bitmap
       
  3591 	CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
       
  3592 	CleanupStack::PushL(bmp);
       
  3593 	const TInt width = 16;
       
  3594 	const TSize size(width, 1);
       
  3595 	User::LeaveIfError(bmp->Create(size, EColor64K));
       
  3596 	//Test bitmap data
       
  3597 	TUint8 colorVal[width * 2] = 
       
  3598 	//	 0          1          2          3          4          5          6          7
       
  3599 		{0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
       
  3600 	//	 8          9          10         11         12         13         14         15
       
  3601 	     0x00,0x00, 0x00,0x00, 0x00,0x00, 0xFF,0xFF, 0xFF,0xFF, 0xFF,0xFF, 0xFF,0xFF, 0xFF,0xFF};
       
  3602 	//Initialize test bitmap
       
  3603 	TPtr8 ptr(colorVal, width * 2, width * 2);
       
  3604 	bmp->SetScanLine(ptr, 0);
       
  3605 	//Compress test bitmap
       
  3606 	User::LeaveIfError(bmp->Compress());
       
  3607 	//Check the test data
       
  3608 	TUint8 colorVal2[width * 2];
       
  3609 	TPtr8 ptr2(colorVal2, width * 2, width * 2);
       
  3610 	//test 1
       
  3611 	colorVal2[0] = colorVal2[1] = colorVal2[2] = colorVal2[3] = 0x12;
       
  3612 	bmp->GetScanLine(ptr2, TPoint(10, 0), 2, EColor64K);
       
  3613 	TEST(colorVal2[0] == colorVal[10 * 2] && colorVal2[1] == colorVal[10 * 2 + 1] &&
       
  3614 		  colorVal2[2] == colorVal[11 * 2] && colorVal2[3] == colorVal[11 * 2 + 1]);
       
  3615 	//test 2
       
  3616 	colorVal2[0] = colorVal2[1] = colorVal2[2] = colorVal2[3] = 0x12;
       
  3617 	bmp->GetScanLine(ptr2, TPoint(10, 0), 1, EColor64K);
       
  3618 	TEST(colorVal2[0] == colorVal[10 * 2] && colorVal2[1] == colorVal[10 * 2 + 1]);
       
  3619 	//test 3
       
  3620 	colorVal2[0] = colorVal2[1] = colorVal2[2] = colorVal2[3] = 0x12;
       
  3621 	bmp->GetScanLine(ptr2, TPoint(11, 0), 1, EColor64K);
       
  3622 	TEST(colorVal2[0] == colorVal[11 * 2] && colorVal2[1] == colorVal[11 * 2 + 1]);
       
  3623 
       
  3624 	//Destroy test bitmap and data
       
  3625 	CleanupStack::PopAndDestroy(bmp);
       
  3626 	}
       
  3627 
       
  3628 /**
       
  3629 	@SYMTestCaseID
       
  3630 	GRAPHICS-FBSERV-0541
       
  3631 
       
  3632 	@SYMTestCaseDesc
       
  3633 	Test to verify defect DEF038286.
       
  3634 	
       
  3635 	@SYMDEF DEF038286
       
  3636 
       
  3637 	@SYMTestActions
       
  3638 	Initialized a test bitmap, compresses it
       
  3639 	and performs a GetScanLine on the compressed
       
  3640 	bitmap. Checks the colour value against an
       
  3641 	expected value.
       
  3642 	
       
  3643 	@SYMTestExpectedResults
       
  3644 	Test should pass
       
  3645 */
       
  3646 void CTBitmap::DEF038286_2L()
       
  3647 //DEF038286 - CBitwiseBitmap::GenerateLineFromCompressedSixteenBitData returns wrong clr value
       
  3648 //24 bpp bitmap test
       
  3649 	{
       
  3650 	INFO_PRINTF1(_L("DEF038286 fix test. 24 bpp bitmap."));
       
  3651 	//Create test bitmap
       
  3652 	CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
       
  3653 	CleanupStack::PushL(bmp);
       
  3654 	const TInt width = 16;
       
  3655 	const TSize size(width, 1);
       
  3656 	User::LeaveIfError(bmp->Create(size, EColor16M));
       
  3657 	//Test bitmap data
       
  3658 	TUint8 colorVal[width * 3] = 
       
  3659 	//	 0               1               2               3               4               5               6			     7
       
  3660 		{0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,
       
  3661 	//	 8               9               10              11              12              13              14              15
       
  3662 	     0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF};
       
  3663 	//Initialize test bitmap
       
  3664 	TPtr8 ptr(colorVal, width * 3, width * 3);
       
  3665 	bmp->SetScanLine(ptr, 0);
       
  3666 	//Compress test bitmap
       
  3667 	User::LeaveIfError(bmp->Compress());
       
  3668 	//Check the test data
       
  3669 	TUint8 colorVal2[width * 3];
       
  3670 	TPtr8 ptr2(colorVal2, width * 3, width * 3);
       
  3671 	//test 1
       
  3672 	colorVal2[0] = colorVal2[1] = colorVal2[2] = colorVal2[3] = colorVal2[4] = colorVal2[5] = 0x12;
       
  3673 	bmp->GetScanLine(ptr2, TPoint(10, 0), 2, EColor16M);
       
  3674 	TEST(colorVal2[0] == colorVal[10 * 3] && colorVal2[1] == colorVal[10 * 3 + 1] && colorVal2[2] == colorVal[10 * 3 + 2] &&
       
  3675 		  colorVal2[3] == colorVal[11 * 3] && colorVal2[4] == colorVal[11 * 3 + 1] && colorVal2[5] == colorVal[11 * 3 + 2]);
       
  3676 	//test 2
       
  3677 	colorVal2[0] = colorVal2[1] = colorVal2[2] = colorVal2[3] = colorVal2[4] = colorVal2[5] = 0x12;
       
  3678 	bmp->GetScanLine(ptr2, TPoint(10, 0), 1, EColor16M);
       
  3679 	TEST(colorVal2[0] == colorVal[10 * 3] && colorVal2[1] == colorVal[10 * 3 + 1] && colorVal2[2] == colorVal[10 * 3 + 2]);
       
  3680 	//test 3
       
  3681 	colorVal2[0] = colorVal2[1] = colorVal2[2] = colorVal2[3] = colorVal2[4] = colorVal2[5] = 0x12;
       
  3682 	bmp->GetScanLine(ptr2, TPoint(11, 0), 1, EColor16M);
       
  3683 	TEST(colorVal2[0] == colorVal[11 * 3] && colorVal2[1] == colorVal[11 * 3 + 1] && colorVal2[2] == colorVal[11 * 3 + 2]);
       
  3684 
       
  3685 	//Destroy test bitmap and data
       
  3686 	CleanupStack::PopAndDestroy(bmp);
       
  3687 	}
       
  3688 
       
  3689 /**
       
  3690 	@SYMTestCaseID
       
  3691 	GRAPHICS-FBSERV-0542
       
  3692 
       
  3693 	@SYMTestCaseDesc
       
  3694 	Tests the function CFbsBitmap::IsMonochrome()
       
  3695 
       
  3696 	@SYMTestActions
       
  3697 	Loads uncompressed bitmaps and checks
       
  3698 	them if they are monochrome
       
  3699 	
       
  3700 	@SYMTestExpectedResults
       
  3701 	Test should pass
       
  3702 */
       
  3703 void CTBitmap::MonohromeL()
       
  3704 	{
       
  3705 	INFO_PRINTF1(_L("Monohrome bitmaps"));
       
  3706 	TPtrC bitmap_ram[] = 
       
  3707 		{
       
  3708 		KMono_M1(),
       
  3709 		KMono_M2(),
       
  3710 		KMono_M4(),
       
  3711 		KMono_M8(),
       
  3712 		KMono_C4(),
       
  3713 		KMono_C8(),
       
  3714 		KMono_C12(),
       
  3715 		KMono_C16(),
       
  3716 		KMono_C24(),
       
  3717 		KMono_C32()
       
  3718 		};
       
  3719 	TInt i;
       
  3720 	//Check monohrome bitmaps
       
  3721 	//1 bpp bitmap is always monochrome
       
  3722 	for(i=0;i<TInt(sizeof(bitmap_ram)/sizeof(bitmap_ram[0]));i++)
       
  3723 		{
       
  3724 		CFbsBitmap* uncompressedBitmap = NULL;
       
  3725 		LoadAndNotCompressBitmapLC(uncompressedBitmap, bitmap_ram[i]);
       
  3726 		TEST(!uncompressedBitmap->IsCompressedInRAM());
       
  3727 		TBool monochrome = uncompressedBitmap->IsMonochrome();
       
  3728 		TEST(monochrome);
       
  3729 		CleanupStack::PopAndDestroy(uncompressedBitmap);
       
  3730 		}
       
  3731 	//Modify monohrome bitmaps and check them
       
  3732 	//1 bpp bitmap is always monochrome
       
  3733 	for(i=0;i<TInt(sizeof(bitmap_ram)/sizeof(bitmap_ram[0]));i++)
       
  3734 		{
       
  3735 		CFbsBitmap* uncompressedBitmap = NULL;
       
  3736 		LoadAndNotCompressBitmapLC(uncompressedBitmap, bitmap_ram[i]);
       
  3737 		TEST(!uncompressedBitmap->IsCompressedInRAM());
       
  3738 		//Change something into the bitmap data
       
  3739 		uncompressedBitmap->LockHeap(ETrue);
       
  3740 		TUint32* data = uncompressedBitmap->DataAddress();
       
  3741 		*data = 0x12345678;
       
  3742 		uncompressedBitmap->UnlockHeap(ETrue);
       
  3743 		//Check the bitmap
       
  3744 		TBool monochrome = uncompressedBitmap->IsMonochrome();
       
  3745 		TEST(i > 0 ? !monochrome : monochrome);
       
  3746 		CleanupStack::PopAndDestroy(uncompressedBitmap);
       
  3747 		}
       
  3748 	}
       
  3749 
       
  3750 /**
       
  3751 	@SYMTestCaseID
       
  3752 	GRAPHICS-FBSERV-0543
       
  3753 
       
  3754 	@SYMTestCaseDesc
       
  3755 	Tests the function CFbsBitmap::GetVerticalScanLine
       
  3756 
       
  3757 	@SYMTestActions
       
  3758 	Gets the bitmap's vertical scanline starting at 
       
  3759 	a specified x co-ordinate.
       
  3760 	
       
  3761 	@SYMTestExpectedResults
       
  3762 	Test should pass
       
  3763 */
       
  3764 void CTBitmap::GetVerticalScanLineL()
       
  3765 	{
       
  3766 	INFO_PRINTF1(_L("GetVerticalScanLine()"));
       
  3767 	TDisplayMode displayMode[] = 
       
  3768 		{
       
  3769 		EGray2,
       
  3770 		EGray4,
       
  3771 		EGray16,
       
  3772 		EGray256,
       
  3773 		EColor16,
       
  3774 		EColor256,
       
  3775 		EColor64K,
       
  3776 		EColor16M,
       
  3777 		ERgb,
       
  3778 		EColor4K,
       
  3779 		EColor16MU,
       
  3780 		EColor16MAP,
       
  3781 		};
       
  3782 	CFbsBitmap* uncompressedBitmap = NULL;
       
  3783 	LoadAndNotCompressBitmapLC(uncompressedBitmap, KRamBitmap2);
       
  3784 	TEST(!uncompressedBitmap->IsCompressedInRAM());
       
  3785 	TSize sizeInPixels = uncompressedBitmap->SizeInPixels();
       
  3786 	HBufC8* vertScanLine = HBufC8::NewLC(sizeInPixels.iHeight * 4);
       
  3787 	TPtr8 p = vertScanLine->Des();
       
  3788 	TDes8& des = p;
       
  3789 	for(TInt i=0;i<TInt(sizeof(displayMode)/sizeof(displayMode[0]));i++)
       
  3790 		{
       
  3791 		TBuf<80> buf;
       
  3792 		buf.Format(_L("--mode=%d\r\n"), displayMode[i]);
       
  3793 		INFO_PRINTF1(buf);
       
  3794 		for(TInt j=0;j<sizeInPixels.iWidth;j++)
       
  3795 			{
       
  3796 			uncompressedBitmap->GetVerticalScanLine(des, j, displayMode[i]);
       
  3797 			}
       
  3798 		}
       
  3799 	CleanupStack::PopAndDestroy(vertScanLine);
       
  3800 	CleanupStack::PopAndDestroy(uncompressedBitmap);
       
  3801 	}
       
  3802 
       
  3803 /**
       
  3804 	@SYMTestCaseID
       
  3805 	GRAPHICS-FBSERV-0544
       
  3806 	
       
  3807 	@SYMTestCaseDesc
       
  3808 	Tests the performance of the function 
       
  3809 	CFbsBitmap::GetVerticalScanLine
       
  3810 
       
  3811 	@SYMTestActions
       
  3812 	Gets the bitmap's vertical scanline starting at 
       
  3813 	a specified x co-ordinate and measures the time
       
  3814 	it takes.
       
  3815 	
       
  3816 	@SYMTestExpectedResults
       
  3817 	Test should pass
       
  3818 */
       
  3819 void CTBitmap::GetVerticalScanLinePerformanceL()
       
  3820 	{
       
  3821 	INFO_PRINTF1(_L("GetVerticalScanLine() performance"));
       
  3822 	TDisplayMode displayMode[] = 
       
  3823 		{
       
  3824 		EGray2,
       
  3825 		EGray4,
       
  3826 		EGray16,
       
  3827 		EGray256,
       
  3828 		EColor16,
       
  3829 		EColor256,
       
  3830 		EColor64K,
       
  3831 		EColor16M,
       
  3832 		ERgb,
       
  3833 		EColor4K,
       
  3834 		EColor16MU,
       
  3835 		EColor16MAP
       
  3836 		};
       
  3837 	CFbsBitmap* uncompressedBitmap = NULL;
       
  3838 	LoadAndNotCompressBitmapLC(uncompressedBitmap, KRamBitmap2);
       
  3839 	TEST(!uncompressedBitmap->IsCompressedInRAM());
       
  3840 	TSize sizeInPixels = uncompressedBitmap->SizeInPixels();
       
  3841 	HBufC8* vertScanLine = HBufC8::NewLC(sizeInPixels.iHeight * 4);
       
  3842 	TPtr8 p = vertScanLine->Des();
       
  3843 	TDes8& des = p;
       
  3844 	TUint time;
       
  3845 	for(TInt i=0;i<TInt(sizeof(displayMode)/sizeof(displayMode[0]));i++)
       
  3846 		{
       
  3847 		time = User::TickCount();
       
  3848 		for(TInt j=0;j<sizeInPixels.iWidth;j++)
       
  3849 			{
       
  3850 			uncompressedBitmap->GetVerticalScanLine(des, j, displayMode[i]);
       
  3851 			}
       
  3852 		INFO_PRINTF3(_L("Vert. line. Mode=%d, Time=%d\r\n"), displayMode[i], User::TickCount() - time);
       
  3853 		}
       
  3854 	CleanupStack::PopAndDestroy(vertScanLine);
       
  3855 	CleanupStack::PopAndDestroy(uncompressedBitmap);
       
  3856 	}
       
  3857 
       
  3858 /**
       
  3859 	@SYMTestCaseID
       
  3860 	GRAPHICS-FBSERV-0545
       
  3861 
       
  3862 	@SYMTestCaseDesc
       
  3863 	Test to verify defect DEF071843
       
  3864 	
       
  3865 	@SYMDEF DEF071843
       
  3866 	
       
  3867 	@SYMTestActions
       
  3868 	Creates a test bitmap. Initializes it 
       
  3869 	with test data using SetScanLine. Saves 
       
  3870 	bitmap and then reloads it and compares 
       
  3871 	it against expected bitmap.
       
  3872 	
       
  3873 	@SYMTestExpectedResults
       
  3874 	Test should pass
       
  3875 */
       
  3876 void CTBitmap::DEF071843_16MAL()
       
  3877 	{
       
  3878 	INFO_PRINTF1(_L("DEF071843 fix test. Saving and loading 16MA 32bpp bitmap."));
       
  3879 	// Create test bitmap
       
  3880 	CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
       
  3881 	CleanupStack::PushL(bmp);
       
  3882 	const TInt width = 12;
       
  3883 	const TSize size(width, 8);
       
  3884 	User::LeaveIfError(bmp->Create(size, EColor16MA));
       
  3885 
       
  3886 	//Test bitmap data - 8 rows of 12 pixels each containing various run lengths
       
  3887 	TUint8 colorVal0[width * 4] =  // runs: 12
       
  3888 	//	 0         1         2         3         4         5         6         7         8         9         10        11
       
  3889 		{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};
       
  3890 	TUint8 colorVal1[width * 4] =  // runs: 1 1 1 1 1 1 1 1 1 1 1 1
       
  3891 	//	 0         1         2         3         4         5         6         7         8         9         10        11
       
  3892 		{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};
       
  3893 	TUint8 colorVal2[width * 4] =  // runs: 1 1 2 1 1 3 1 1 1
       
  3894 	//	 0         1         2         3         4         5         6         7         8         9         10        11
       
  3895 		{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};
       
  3896 	TUint8 colorVal3[width * 4] =   // runs: 1 2 1 3 1 4
       
  3897 	//	 0         1         2         3         4         5         6         7         8         9         10        11
       
  3898 		{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};
       
  3899 	TUint8 colorVal4[width * 4] =   // runs: 2 1 2 2 2 3
       
  3900 	//	 0         1         2         3         4         5         6         7         8         9         10        11
       
  3901 		{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};
       
  3902 	TUint8 colorVal5[width * 4] =   // runs: 3 1 3 2 3
       
  3903 	//	 0         1         2         3         4         5         6         7         8         9         10        11
       
  3904 		{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};
       
  3905 	TUint8 colorVal6[width * 4] =   // runs: 4 1 1 1 1 4
       
  3906 	//	 0         1         2         3         4         5         6         7         8         9         10        11
       
  3907 		{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};
       
  3908 	TUint8 colorVal7[width * 4] =   // runs: 1 1 1 1 4 1 1 1 1
       
  3909 	//	 0         1         2         3         4         5         6         7         8         9         10        11
       
  3910 		{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};
       
  3911 
       
  3912 	//Initialize test bitmap
       
  3913 	TPtr8 line0(colorVal0, width * 4, width * 4);
       
  3914 	bmp->SetScanLine(line0, 0);
       
  3915 	TPtr8 line1(colorVal1, width * 4, width * 4);
       
  3916 	bmp->SetScanLine(line1, 1);
       
  3917 	TPtr8 line2(colorVal2, width * 4, width * 4);
       
  3918 	bmp->SetScanLine(line2, 2);
       
  3919 	TPtr8 line3(colorVal3, width * 4, width * 4);
       
  3920 	bmp->SetScanLine(line3, 3);
       
  3921 	TPtr8 line4(colorVal4, width * 4, width * 4);
       
  3922 	bmp->SetScanLine(line4, 4);
       
  3923 	TPtr8 line5(colorVal5, width * 4, width * 4);
       
  3924 	bmp->SetScanLine(line5, 5);
       
  3925 	TPtr8 line6(colorVal6, width * 4, width * 4);
       
  3926 	bmp->SetScanLine(line6, 6);
       
  3927 	TPtr8 line7(colorVal7, width * 4, width * 4);
       
  3928 	bmp->SetScanLine(line7, 7);
       
  3929 
       
  3930 	// Save bitmap then reload and compare
       
  3931 	_LIT(KTest16MABmpFile, "c:\\test16ma.mbm");
       
  3932 	bmp->Save(KTest16MABmpFile);	
       
  3933 	//
       
  3934 	CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
       
  3935 	CleanupStack::PushL(bmp2);
       
  3936 	TInt err = bmp2->Load(KTest16MABmpFile);
       
  3937 	TEST2(err, KErrNone);
       
  3938 	//
       
  3939 	CompareBitmaps((CFbsBitmapEx&)*bmp, (CFbsBitmapEx&)*bmp2,EColor16MA);
       
  3940 	
       
  3941 	// Destroy test bitmaps
       
  3942 	CleanupStack::PopAndDestroy(2, bmp); // bmp2
       
  3943 	}
       
  3944 
       
  3945 /**
       
  3946 	@SYMTestCaseID
       
  3947 	GRAPHICS-FBSERV-0546
       
  3948 
       
  3949 	@SYMTestCaseDesc
       
  3950 	Test to verify defect DEF071843
       
  3951 	
       
  3952 	@SYMDEF DEF071843
       
  3953 	
       
  3954 	@SYMTestActions
       
  3955 	Creates a test bitmap. Initializes it 
       
  3956 	with test data using SetScanLine. Saves 
       
  3957 	bitmap and then reloads it and compares 
       
  3958 	it against expected bitmap.
       
  3959 	
       
  3960 	@SYMTestExpectedResults
       
  3961 	Test should pass
       
  3962 */
       
  3963 void CTBitmap::DEF071843_16MUL()
       
  3964 	{
       
  3965 	INFO_PRINTF1(_L("DEF071843 fix test. Compression improvements for 16MU 32bpp bitmap."));
       
  3966 	// Create test bitmap
       
  3967 	CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
       
  3968 	CleanupStack::PushL(bmp);
       
  3969 	const TInt width = 12;
       
  3970 	const TSize size(width, 8);
       
  3971 	User::LeaveIfError(bmp->Create(size, EColor16MU));
       
  3972 
       
  3973 	//Test bitmap data - 8 rows of 12 pixels each containing various run lengths
       
  3974 	//Format is b,g,r,a where a (alpha) is unused, hence 255.
       
  3975 	TUint8 colorVal0[width * 4] =  // runs: 12
       
  3976 	//	 0           1           2           3           4           5           6           7           8           9           10          11
       
  3977 		{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};
       
  3978 	TUint8 colorVal1[width * 4] =  // runs: 1 1 1 1 1 1 1 1 1 1 1 1
       
  3979 	//	 0           1           2           3           4           5           6           7           8           9           10          11
       
  3980 		{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};
       
  3981 	TUint8 colorVal2[width * 4] =  // runs: 1 1 2 1 1 3 1 1 1
       
  3982 	//	 0           1           2           3           4           5           6           7           8           9           10          11
       
  3983 		{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};
       
  3984 	TUint8 colorVal3[width * 4] =   // runs: 1 2 1 3 1 4
       
  3985 	//	 0           1           2           3           4           5           6           7           8           9           10          11
       
  3986 		{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};
       
  3987 	TUint8 colorVal4[width * 4] =   // runs: 2 1 2 2 2 3
       
  3988 	//	 0           1           2           3           4           5           6           7           8           9           10          11
       
  3989 		{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};
       
  3990 	TUint8 colorVal5[width * 4] =   // runs: 3 1 3 2 3
       
  3991 	//	 0           1           2           3           4           5           6           7           8           9           10          11
       
  3992 		{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};
       
  3993 	TUint8 colorVal6[width * 4] =   // runs: 4 1 1 1 1 4
       
  3994 	//	 0           1           2           3           4           5           6           7           8           9           10          11
       
  3995 		{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};
       
  3996 	TUint8 colorVal7[width * 4] =   // runs: 1 1 1 1 4 1 1 1 1
       
  3997 	//	 0           1           2           3           4           5           6           7           8           9           10          11
       
  3998 		{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};
       
  3999 
       
  4000 	//Initialize test bitmap
       
  4001 	TPtr8 line0(colorVal0, width * 4, width * 4);
       
  4002 	bmp->SetScanLine(line0, 0);
       
  4003 	TPtr8 line1(colorVal1, width * 4, width * 4);
       
  4004 	bmp->SetScanLine(line1, 1);
       
  4005 	TPtr8 line2(colorVal2, width * 4, width * 4);
       
  4006 	bmp->SetScanLine(line2, 2);
       
  4007 	TPtr8 line3(colorVal3, width * 4, width * 4);
       
  4008 	bmp->SetScanLine(line3, 3);
       
  4009 	TPtr8 line4(colorVal4, width * 4, width * 4);
       
  4010 	bmp->SetScanLine(line4, 4);
       
  4011 	TPtr8 line5(colorVal5, width * 4, width * 4);
       
  4012 	bmp->SetScanLine(line5, 5);
       
  4013 	TPtr8 line6(colorVal6, width * 4, width * 4);
       
  4014 	bmp->SetScanLine(line6, 6);
       
  4015 	TPtr8 line7(colorVal7, width * 4, width * 4);
       
  4016 	bmp->SetScanLine(line7, 7);
       
  4017 
       
  4018 	// Save bitmap then reload and compare
       
  4019 	_LIT(KTest16MUBmpFile, "c:\\test16mu.mbm");
       
  4020 	bmp->Save(KTest16MUBmpFile);	
       
  4021 	//
       
  4022 	CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
       
  4023 	CleanupStack::PushL(bmp2);
       
  4024 	TInt err = bmp2->Load(KTest16MUBmpFile);
       
  4025 	TEST2(err, KErrNone);
       
  4026 	//
       
  4027 	CompareBitmaps((CFbsBitmapEx&)*bmp, (CFbsBitmapEx&)*bmp2, EColor16MU);
       
  4028 	
       
  4029 	// Destroy test bitmaps
       
  4030 	CleanupStack::PopAndDestroy(2, bmp); // bmp2
       
  4031 	}
       
  4032 
       
  4033 /**
       
  4034 	@SYMTestCaseID
       
  4035 	GRAPHICS-FBSERV-0547
       
  4036 
       
  4037 	@SYMTestCaseDesc
       
  4038 	Test to verify defect DEF071843
       
  4039 	
       
  4040 	@SYMDEF DEF071843
       
  4041 	
       
  4042 	@SYMTestActions
       
  4043 	Creates a test bitmap. Initializes it 
       
  4044 	with test data using SetScanLine. Saves 
       
  4045 	bitmap and then reloads it and compares 
       
  4046 	it against expected bitmap.
       
  4047 	
       
  4048 	@SYMTestExpectedResults
       
  4049 	Test should pass
       
  4050 */
       
  4051 void CTBitmap::DEF071843_16ML()
       
  4052 	{
       
  4053 	INFO_PRINTF1(_L("DEF071843 fix test. Compression improvements for 16M 24bpp bitmap."));
       
  4054 	// Create test bitmap
       
  4055 	CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
       
  4056 	CleanupStack::PushL(bmp);
       
  4057 	const TInt width = 12;
       
  4058 	const TSize size(width, 8);
       
  4059 	User::LeaveIfError(bmp->Create(size, EColor16M));
       
  4060 
       
  4061 	//Test bitmap data - 8 rows of 12 pixels each containing various run lengths
       
  4062 	TUint8 colorVal0[width * 3] =  // runs: 12
       
  4063 	//	 0       1       2       3       4       5       6       7       8       9       10      11
       
  4064 		{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};
       
  4065 	TUint8 colorVal1[width * 3] =  // runs: 1 1 1 1 1 1 1 1 1 1 1 1
       
  4066 	//	 0       1       2       3       4       5       6       7       8       9       10      11
       
  4067 		{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};
       
  4068 	TUint8 colorVal2[width * 3] =  // runs: 1 1 2 1 1 3 1 1 1
       
  4069 	//	 0       1       2       3       4       5       6       7       8       9       10      11
       
  4070 		{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};
       
  4071 	TUint8 colorVal3[width * 3] =   // runs: 1 2 1 3 1 4
       
  4072 	//	 0       1       2       3       4       5       6       7       8       9       10      11
       
  4073 		{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};
       
  4074 	TUint8 colorVal4[width * 3] =   // runs: 2 1 2 2 2 3
       
  4075 	//	 0       1       2       3       4       5       6       7       8       9       10      11
       
  4076 		{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};
       
  4077 	TUint8 colorVal5[width * 3] =   // runs: 3 1 3 2 3
       
  4078 	//	 0       1       2       3       4       5       6       7       8       9       10      11
       
  4079 		{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};
       
  4080 	TUint8 colorVal6[width * 3] =   // runs: 4 1 1 1 1 4
       
  4081 	//	 0       1       2       3       4       5       6       7       8       9       10      11
       
  4082 		{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};
       
  4083 	TUint8 colorVal7[width * 3] =   // runs: 1 1 1 1 4 1 1 1 1
       
  4084 	//	 0       1       2       3       4       5       6       7       8       9       10      11
       
  4085 		{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};
       
  4086 
       
  4087 	//Initialize test bitmap
       
  4088 	TPtr8 line0(colorVal0, width * 3, width * 3);
       
  4089 	bmp->SetScanLine(line0, 0);
       
  4090 	TPtr8 line1(colorVal1, width * 3, width * 3);
       
  4091 	bmp->SetScanLine(line1, 1);
       
  4092 	TPtr8 line2(colorVal2, width * 3, width * 3);
       
  4093 	bmp->SetScanLine(line2, 2);
       
  4094 	TPtr8 line3(colorVal3, width * 3, width * 3);
       
  4095 	bmp->SetScanLine(line3, 3);
       
  4096 	TPtr8 line4(colorVal4, width * 3, width * 3);
       
  4097 	bmp->SetScanLine(line4, 4);
       
  4098 	TPtr8 line5(colorVal5, width * 3, width * 3);
       
  4099 	bmp->SetScanLine(line5, 5);
       
  4100 	TPtr8 line6(colorVal6, width * 3, width * 3);
       
  4101 	bmp->SetScanLine(line6, 6);
       
  4102 	TPtr8 line7(colorVal7, width * 3, width * 3);
       
  4103 	bmp->SetScanLine(line7, 7);
       
  4104 
       
  4105 	// Save bitmap then reload and compare
       
  4106 	_LIT(KTest16MBmpFile, "c:\\test16m.mbm");
       
  4107 	bmp->Save(KTest16MBmpFile);	
       
  4108 	//
       
  4109 	CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
       
  4110 	CleanupStack::PushL(bmp2);
       
  4111 	TInt err = bmp2->Load(KTest16MBmpFile);
       
  4112 	TEST2(err, KErrNone);
       
  4113 	//
       
  4114 	CompareBitmaps((CFbsBitmapEx&)*bmp, (CFbsBitmapEx&)*bmp2, EColor16M);
       
  4115 	
       
  4116 	// Destroy test bitmaps
       
  4117 	CleanupStack::PopAndDestroy(2, bmp); // bmp2
       
  4118 	}
       
  4119 	
       
  4120 /**
       
  4121 	@SYMTestCaseID
       
  4122 	GRAPHICS-FBSERV-0548
       
  4123 
       
  4124 	@SYMTestCaseDesc
       
  4125 	Test to verify defect DEF074623 (Alpha bit)
       
  4126 
       
  4127 	@SYMDEF DEF074623
       
  4128 
       
  4129 	@SYMTestActions
       
  4130 	
       
  4131 	@SYMTestExpectedResults
       
  4132 	Test should pass
       
  4133 */
       
  4134 void CTBitmap::DEF074623_16MAL()
       
  4135 	{
       
  4136 	INFO_PRINTF1(_L("DEF074623 fix test For Alpha Bit."));
       
  4137 	// Create test bitmap
       
  4138 	CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
       
  4139 	CleanupStack::PushL(bmp);
       
  4140 	const TInt iBitmapWidth = 10;
       
  4141 	const TInt iBitmapHeight = 10;
       
  4142 
       
  4143 	
       
  4144 	TInt rowIndex;
       
  4145 	TInt colIndex;
       
  4146 	TSize rectSize(iBitmapWidth,iBitmapHeight);
       
  4147 	TRect srcRect(0,0,iBitmapWidth,iBitmapHeight);
       
  4148 	User::LeaveIfError(bmp->Create(rectSize, EColor16MU));
       
  4149 	srcRect.SetSize(rectSize);
       
  4150 	TBitmapUtil bmpUtil(bmp);
       
  4151 	bmpUtil.Begin(TPoint(0,0));
       
  4152 	for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex)
       
  4153 		{
       
  4154 		TInt red=0;
       
  4155 		TInt blue=255;
       
  4156 		TInt green=0;
       
  4157 		bmpUtil.SetPos(TPoint(0,rowIndex));
       
  4158 		for (colIndex=0;colIndex<iBitmapWidth;++colIndex)
       
  4159 			{
       
  4160 			TRgb rgb(red,green,blue);
       
  4161 			bmpUtil.SetPixel(rgb.Color16MA());
       
  4162 			}
       
  4163 		bmpUtil.IncXPos();
       
  4164 		red-=10;
       
  4165 		blue+=10;
       
  4166 		green-=10;
       
  4167 		if(red <= 0)
       
  4168 			{
       
  4169 			red+=255;
       
  4170 			}
       
  4171 		if(blue >= 255)
       
  4172 			{
       
  4173 			blue-=255;
       
  4174 			}
       
  4175 		if(green <= 0)
       
  4176 			{
       
  4177 			green+=255;
       
  4178 			}
       
  4179 		}
       
  4180 	bmpUtil.End();
       
  4181 	
       
  4182 	bmp->SetDisplayMode(EColor16MA);
       
  4183 	
       
  4184 	for(TInt yy = 0; yy < iBitmapHeight; yy++)
       
  4185 		{
       
  4186 		
       
  4187 		for(TInt xx = 0; xx < iBitmapWidth; xx++)
       
  4188 			{
       
  4189 			TRgb bmpcol;
       
  4190 			bmp->GetPixel(bmpcol,TPoint(xx,yy));
       
  4191 			TEST(bmpcol.Alpha() == 255);
       
  4192 			}
       
  4193 		}
       
  4194 		
       
  4195 	CleanupStack::PopAndDestroy(bmp);	
       
  4196 
       
  4197 	}
       
  4198 	
       
  4199 #ifdef _DEBUG
       
  4200 /**
       
  4201 	@SYMTestCaseID
       
  4202 	GRAPHICS-FBSERV-0549
       
  4203 
       
  4204 	@SYMTestCaseDesc
       
  4205 	Test to verify defect DEF095361
       
  4206 	
       
  4207 	@SYMDEF DEF095361
       
  4208 	
       
  4209 	@SYMTestActions
       
  4210 	Creates a test bitmap. Initializes it 
       
  4211 	with test data using SetScanLine. Compresses
       
  4212 	the bitmap. Saves bitmap and then reloads it 
       
  4213 	and compares it against expected bitmap.
       
  4214 	Simulates heap allocation failure of memory.
       
  4215 	
       
  4216 	@SYMTestExpectedResults
       
  4217 	Test should pass
       
  4218 */
       
  4219 void CTBitmap::DEF095361_16MAL()
       
  4220 	{
       
  4221 	INFO_PRINTF1(_L("DEF095361 fix test. Compressing, Saving and loading 16MA 32bpp bitmap."));
       
  4222 	// Create test bitmap
       
  4223 	CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
       
  4224 	CleanupStack::PushL(bmp);
       
  4225 	const TInt width = 12;
       
  4226 	const TSize size(width, 8);
       
  4227 	User::LeaveIfError(bmp->Create(size, EColor16MA));
       
  4228 
       
  4229 	//Test bitmap data - 8 rows of 12 pixels each containing various run lengths
       
  4230 	TUint8 colorVal0[width * 4] =  // runs: 12
       
  4231 	//	 0         1         2         3         4         5         6         7         8         9         10        11
       
  4232 		{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};
       
  4233 	TUint8 colorVal1[width * 4] =  // runs: 1 1 1 1 1 1 1 1 1 1 1 1
       
  4234 	//	 0         1         2         3         4         5         6         7         8         9         10        11
       
  4235 		{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};
       
  4236 	TUint8 colorVal2[width * 4] =  // runs: 1 1 2 1 1 3 1 1 1
       
  4237 	//	 0         1         2         3         4         5         6         7         8         9         10        11
       
  4238 		{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};
       
  4239 	TUint8 colorVal3[width * 4] =   // runs: 1 2 1 3 1 4
       
  4240 	//	 0         1         2         3         4         5         6         7         8         9         10        11
       
  4241 		{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};
       
  4242 	TUint8 colorVal4[width * 4] =   // runs: 2 1 2 2 2 3
       
  4243 	//	 0         1         2         3         4         5         6         7         8         9         10        11
       
  4244 		{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};
       
  4245 	TUint8 colorVal5[width * 4] =   // runs: 3 1 3 2 3
       
  4246 	//	 0         1         2         3         4         5         6         7         8         9         10        11
       
  4247 		{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};
       
  4248 	TUint8 colorVal6[width * 4] =   // runs: 4 1 1 1 1 4
       
  4249 	//	 0         1         2         3         4         5         6         7         8         9         10        11
       
  4250 		{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};
       
  4251 	TUint8 colorVal7[width * 4] =   // runs: 1 1 1 1 4 1 1 1 1
       
  4252 	//	 0         1         2         3         4         5         6         7         8         9         10        11
       
  4253 		{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};
       
  4254 
       
  4255 	//Initialize test bitmap
       
  4256 	TPtr8 line0(colorVal0, width * 4, width * 4);
       
  4257 	bmp->SetScanLine(line0, 0);
       
  4258 	TPtr8 line1(colorVal1, width * 4, width * 4);
       
  4259 	bmp->SetScanLine(line1, 1);
       
  4260 	TPtr8 line2(colorVal2, width * 4, width * 4);
       
  4261 	bmp->SetScanLine(line2, 2);
       
  4262 	TPtr8 line3(colorVal3, width * 4, width * 4);
       
  4263 	bmp->SetScanLine(line3, 3);
       
  4264 	TPtr8 line4(colorVal4, width * 4, width * 4);
       
  4265 	bmp->SetScanLine(line4, 4);
       
  4266 	TPtr8 line5(colorVal5, width * 4, width * 4);
       
  4267 	bmp->SetScanLine(line5, 5);
       
  4268 	TPtr8 line6(colorVal6, width * 4, width * 4);
       
  4269 	bmp->SetScanLine(line6, 6);
       
  4270 	TPtr8 line7(colorVal7, width * 4, width * 4);
       
  4271 	bmp->SetScanLine(line7, 7);
       
  4272 
       
  4273 	//Compress bitmap using RLE Compression
       
  4274 	bmp->Compress(ERLECompression);
       
  4275  
       
  4276 	// Save bitmap then reload and compare
       
  4277 	_LIT(KTest16MABmpFile, "c:\\testDEF095361_16ma.mbm");
       
  4278 	bmp->Save(KTest16MABmpFile);	
       
  4279 	//
       
  4280 	CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
       
  4281 	CleanupStack::PushL(bmp2);
       
  4282 	
       
  4283 	RFbsSession* fbs = RFbsSession::GetSession();
       
  4284 	
       
  4285 	TInt count;
       
  4286 	for (count = 1; ; count++)
       
  4287 		{
       
  4288 		fbs->SendCommand(EFbsMessDefaultAllocFail,count);
       
  4289 
       
  4290 		TInt ret = bmp2->Load(KTest16MABmpFile, 0, EFalse);
       
  4291 
       
  4292 		if (ret == KErrNoMemory)
       
  4293 			{
       
  4294 				// Do Nothing
       
  4295 			}
       
  4296 		else if (ret == KErrNone)
       
  4297 			{
       
  4298 			break;
       
  4299 			}
       
  4300 		else 
       
  4301 			TEST2(ret, KErrNone);
       
  4302 		}
       
  4303 
       
  4304 	fbs->SendCommand(EFbsMessDefaultAllocFail,0);
       
  4305 	
       
  4306 	//
       
  4307 	CompareBitmaps((CFbsBitmapEx&)*bmp, (CFbsBitmapEx&)*bmp2,EColor16MA);
       
  4308 	
       
  4309 	// Destroy test bitmaps
       
  4310 	CleanupStack::PopAndDestroy(2, bmp); // bmp2
       
  4311 	}
       
  4312 #endif
       
  4313 void CTBitmap::LoadAndCompressBitmapLC(CFbsBitmap*& aBmp, const TDesC& aBmpFile)
       
  4314 	{
       
  4315 	aBmp = new (ELeave) CFbsBitmap;
       
  4316 	CleanupStack::PushL(aBmp);
       
  4317 	TInt err = aBmp->Load(aBmpFile);
       
  4318 	TEST2(err, KErrNone);
       
  4319 	err = aBmp->Compress();
       
  4320 	TEST2(err, KErrNone);
       
  4321 	TEST(aBmp->IsCompressedInRAM());
       
  4322 	}
       
  4323 
       
  4324 /**
       
  4325 	@SYMTestCaseID
       
  4326 	GRAPHICS-FBSERV-0550
       
  4327 
       
  4328 	@SYMTestCaseDesc
       
  4329 	Compresses a bitmap containing two lines
       
  4330 
       
  4331 	@SYMTestActions
       
  4332 	Creates a test bitmap with two lines. Compresses it (16 bpp)
       
  4333 	and checks if compressed successfully
       
  4334 	
       
  4335 	@SYMTestExpectedResults
       
  4336 	Test should pass
       
  4337 */
       
  4338 
       
  4339 void CTBitmap::TwoComprLines()
       
  4340 	{
       
  4341 	INFO_PRINTF1(_L("16 bpp compressed bitmap - 2 lines"));
       
  4342 	//Create test bitmap
       
  4343 	CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
       
  4344 	CleanupStack::PushL(bmp);
       
  4345 	const TInt width = 3;
       
  4346 	const TSize size(width, 2);
       
  4347 	User::LeaveIfError(bmp->Create(size, EColor64K));
       
  4348 	//Test bitmap data
       
  4349 	TUint8 colorVal[width * 2] = 
       
  4350 	//	 0          1          2        
       
  4351 		{0x13,0x13, 0x13,0x13, 0x13,0x13};
       
  4352 	//Initialize test bitmap
       
  4353 	TPtr8 ptr(colorVal, width * 2, width * 2);
       
  4354 	bmp->SetScanLine(ptr, 0);
       
  4355 	bmp->SetScanLine(ptr, 1);
       
  4356 	//Compress test bitmap
       
  4357 	User::LeaveIfError(bmp->Compress());
       
  4358 	//Check the test data
       
  4359 	TUint8 colorVal2[width * 2];
       
  4360 	TPtr8 ptr2(colorVal2, width * 2, width * 2);
       
  4361 	//test 1
       
  4362 	bmp->GetScanLine(ptr2, TPoint(0, 0), 3, EColor64K);
       
  4363 	TEST(ptr2 == ptr);
       
  4364 	bmp->GetScanLine(ptr2, TPoint(0, 1), 3, EColor64K);
       
  4365 	TEST(ptr2 == ptr);
       
  4366 	//Destroy test bitmap and data
       
  4367 	CleanupStack::PopAndDestroy(bmp);
       
  4368 	}
       
  4369 
       
  4370 void CTBitmap::LoadAndNotCompressBitmapLC(CFbsBitmap*& aBmp, const TDesC& aBmpFile)
       
  4371 	{
       
  4372 	aBmp = new (ELeave) CFbsBitmap;
       
  4373 	CleanupStack::PushL(aBmp);
       
  4374 	TInt err = aBmp->Load(aBmpFile);
       
  4375 	TEST2(err, KErrNone);
       
  4376 	}
       
  4377 
       
  4378 /**
       
  4379 	@SYMTestCaseID
       
  4380 	GRAPHICS-FBSERV-0551
       
  4381 
       
  4382 	@SYMTestCaseDesc
       
  4383 	The test verifies the 
       
  4384 	CFbsBitmap::Compress((TBitmapfileCompressionScheme aScheme) API.
       
  4385 	It loads bitmaps from ROM & saves (temporarily) to C-drive. 
       
  4386 	Then it loads from C-drive into a new bitmap.
       
  4387 
       
  4388 	@SYMTestActions
       
  4389 	
       
  4390 	@SYMTestExpectedResults
       
  4391 	Test should pass
       
  4392 */
       
  4393 void CTBitmap::TestPaletteCompressionL()
       
  4394 	{
       
  4395 	INFO_PRINTF1(_L("Test Palette Compression"));
       
  4396 	_LIT(KmbmFileInRom, "z:\\system\\data\\24bitskin.mbm");
       
  4397 	RFbsSession* fbs = RFbsSession::GetSession();
       
  4398 	//create bitmap
       
  4399 	CFbsBitmap* fbsCompressed = new(ELeave) CFbsBitmap;
       
  4400 	CFbsBitmap* fbsUnCompressed = new(ELeave) CFbsBitmap;
       
  4401 	CleanupStack::PushL(fbsCompressed);
       
  4402 	CleanupStack::PushL(fbsUnCompressed);
       
  4403 	TEST2(fbsUnCompressed->Load(KmbmFileInRom, 0, EFalse), KErrNone);
       
  4404 	fbsUnCompressed->Save(KTempFilename);
       
  4405 	//load bitmap
       
  4406 	TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
       
  4407 	//compress bitmap (force foreground compression)
       
  4408 	fbsCompressed->Compress(EPaletteCompression);
       
  4409 	fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
       
  4410 	//test that palette compression occurred
       
  4411 	TEST(fbsCompressed->Header().iCompression == EGenericPaletteCompression);
       
  4412 	//compare with original
       
  4413 	INFO_PRINTF1(_L("Compare Palette Compressed bmp with original"));
       
  4414 	CompareBitmaps((CFbsBitmapEx&)*fbsCompressed, (CFbsBitmapEx&)*fbsUnCompressed, EColor16M);
       
  4415 	CleanupStack::PopAndDestroy(2);
       
  4416 	iFs.Delete(KTempFilename);
       
  4417 
       
  4418 	//Test that the RLE option works.
       
  4419 	//------------------------------------
       
  4420 	//create bitmap
       
  4421 	fbsCompressed = new(ELeave) CFbsBitmap ;
       
  4422 	fbsUnCompressed = new(ELeave) CFbsBitmap ;
       
  4423 	CleanupStack::PushL(fbsCompressed);
       
  4424 	CleanupStack::PushL(fbsUnCompressed);
       
  4425 	TEST2(fbsUnCompressed->Load(KmbmFileInRom, 0, EFalse), KErrNone);
       
  4426 	fbsUnCompressed->Save(KTempFilename);
       
  4427 	//load bitmap
       
  4428 	TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
       
  4429 	//compress bitmap (force foreground compression)
       
  4430 	fbsCompressed->Compress(ERLECompression);
       
  4431 	fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
       
  4432 	//test that RLE compression occurred
       
  4433 	TEST(fbsCompressed->Header().iCompression == ETwentyFourBitRLECompression);
       
  4434 	CleanupStack::PopAndDestroy(2);
       
  4435 	iFs.Delete(KTempFilename);
       
  4436 
       
  4437 	//Test that unsuitable bitmaps are not palette compressed (too many colours).
       
  4438 	//----------------------------------------------------------------------------------------
       
  4439 	_LIT(KmbmMultiColourMBMInRom, "z:\\system\\data\\24bit.mbm");
       
  4440 	//create bitmap
       
  4441 	fbsCompressed = new(ELeave) CFbsBitmap;
       
  4442 	fbsUnCompressed = new(ELeave) CFbsBitmap;
       
  4443 	CleanupStack::PushL(fbsCompressed);
       
  4444 	CleanupStack::PushL(fbsUnCompressed);
       
  4445 	TEST2(fbsUnCompressed->Load(KmbmMultiColourMBMInRom, 0, EFalse), KErrNone);
       
  4446 	fbsUnCompressed->Save(KTempFilename);
       
  4447 	//load bitmap
       
  4448 	TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
       
  4449 	//compress bitmap (force foreground compression)
       
  4450 	fbsCompressed->Compress(EPaletteCompression);
       
  4451 	fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
       
  4452 	//test that palette compression occurred
       
  4453 	TEST(fbsCompressed->Header().iCompression != EGenericPaletteCompression);
       
  4454 	CleanupStack::PopAndDestroy(2);
       
  4455 	iFs.Delete(KTempFilename);
       
  4456 	
       
  4457 	//Test that unsuitable bitmaps are not palette compressed (too few BPP)
       
  4458 	//---------------------------------------------------------------------------------
       
  4459 	//create bitmap
       
  4460 	fbsCompressed = new(ELeave) CFbsBitmap ;
       
  4461 	fbsUnCompressed = new(ELeave) CFbsBitmap ;
       
  4462 	CleanupStack::PushL(fbsCompressed);
       
  4463 	CleanupStack::PushL(fbsUnCompressed);
       
  4464 	TEST2(fbsUnCompressed->Load(KmbmMultiColourMBMInRom, 0, EFalse), KErrNone);
       
  4465 	fbsUnCompressed->Save(KTempFilename);
       
  4466 	//load bitmap
       
  4467 	TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
       
  4468 	//compress bitmap (force foreground compression)
       
  4469 	fbsCompressed->Compress(EPaletteCompression);
       
  4470 	fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
       
  4471 	//test that palette compression occurred
       
  4472 	TEST(fbsCompressed->Header().iCompression != EGenericPaletteCompression);
       
  4473 	CleanupStack::PopAndDestroy(2);
       
  4474 	iFs.Delete(KTempFilename);
       
  4475 
       
  4476 	
       
  4477 	// Test that 12bitmap cannot pallete compress but will fall back to RLE
       
  4478 	// --------------------------------------------------------------------
       
  4479 	_LIT(Kmbm12BitMBMInRom, "z:\\system\\data\\file.mbm");
       
  4480 	fbsCompressed = new(ELeave) CFbsBitmap ;
       
  4481 	fbsUnCompressed = new(ELeave) CFbsBitmap ;
       
  4482 	CleanupStack::PushL(fbsCompressed);
       
  4483 	CleanupStack::PushL(fbsUnCompressed);
       
  4484 	TEST2(fbsUnCompressed->Load(Kmbm12BitMBMInRom, 0, EFalse), KErrNone);
       
  4485 	fbsUnCompressed->Save(KTempFilename);
       
  4486 	//load bitmap
       
  4487 	TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
       
  4488 	//compress bitmap (force foreground compression)
       
  4489 	fbsCompressed->Compress(EPaletteCompressionWithRLEFallback);
       
  4490 	fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
       
  4491 	TBitmapfileCompression comp = fbsCompressed->Header().iCompression;
       
  4492 	//test that palette compression occurred
       
  4493 	TEST(fbsCompressed->Header().iCompression != EGenericPaletteCompression);
       
  4494 	CleanupStack::PopAndDestroy(2);
       
  4495 	iFs.Delete(KTempFilename);
       
  4496 	
       
  4497 
       
  4498 	// Test that multi colour bitmap cannot pallete compress but will fall back to RLE
       
  4499 	// -------------------------------------------------------------------------------
       
  4500 	fbsCompressed = new(ELeave) CFbsBitmap ;
       
  4501 	fbsUnCompressed = new(ELeave) CFbsBitmap ;
       
  4502 	CleanupStack::PushL(fbsCompressed);
       
  4503 	CleanupStack::PushL(fbsUnCompressed);
       
  4504 	TEST2(fbsUnCompressed->Load(KmbmMultiColourMBMInRom, 0, EFalse), KErrNone);
       
  4505 	fbsUnCompressed->Save(KTempFilename);
       
  4506 	//load bitmap
       
  4507 	TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
       
  4508 	//compress bitmap (force foreground compression)
       
  4509 	fbsCompressed->Compress(EPaletteCompressionWithRLEFallback);
       
  4510 	fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
       
  4511 	comp = fbsCompressed->Header().iCompression;
       
  4512 	//test that palette compression occurred
       
  4513 	TEST(fbsCompressed->Header().iCompression != EGenericPaletteCompression);
       
  4514 	CleanupStack::PopAndDestroy(2);
       
  4515 	iFs.Delete(KTempFilename);
       
  4516 	
       
  4517 	
       
  4518 	
       
  4519 	//Test various BPP & bitmap widths
       
  4520 	//----------------------------------------
       
  4521 	INFO_PRINTF1(_L("Test assorted BPP & colour counts"));
       
  4522 	_LIT(Kmbm16NarrowFileInRom, "z:\\system\\data\\16bitskin.mbm");
       
  4523 	TestAssortedBPPandColourDepthL(Kmbm16NarrowFileInRom, fbs);
       
  4524 	_LIT(Kmbm24bit6colFileInRom, "z:\\system\\data\\24bit6col.mbm");
       
  4525 	TestAssortedBPPandColourDepthL(Kmbm24bit6colFileInRom, fbs);
       
  4526 	_LIT(Kmbm24bit2colFileInRom, "z:\\system\\data\\24bit2col.mbm");
       
  4527 	TestAssortedBPPandColourDepthL(Kmbm24bit2colFileInRom, fbs);
       
  4528 	_LIT(Kmbm24bit3colFileInRom, "z:\\system\\data\\24bit3col.mbm");
       
  4529 	TestAssortedBPPandColourDepthL(Kmbm24bit3colFileInRom, fbs);
       
  4530 	_LIT(Kmbm24bit20colFileInRom, "z:\\system\\data\\24bit20col.mbm");
       
  4531 	TestAssortedBPPandColourDepthL(Kmbm24bit20colFileInRom, fbs);
       
  4532 	_LIT(Kmbm16bit6colFileInRom, "z:\\system\\data\\16bit6col.mbm");
       
  4533 	TestAssortedBPPandColourDepthL(Kmbm16bit6colFileInRom, fbs);
       
  4534 	_LIT(Kmbm16bit2colFileInRom, "z:\\system\\data\\16bit2col.mbm");
       
  4535 	TestAssortedBPPandColourDepthL(Kmbm16bit2colFileInRom, fbs);
       
  4536 	_LIT(Kmbm16bit3colFileInRom, "z:\\system\\data\\16bit3col.mbm");
       
  4537 	TestAssortedBPPandColourDepthL(Kmbm16bit3colFileInRom, fbs);
       
  4538 	_LIT(Kmbm16bit20colFileInRom, "z:\\system\\data\\16bit20col.mbm");
       
  4539 	TestAssortedBPPandColourDepthL(Kmbm16bit20colFileInRom, fbs);
       
  4540 	_LIT(Kmbm32BitSkinFileInRom, "z:\\system\\data\\32bitskin.mbm");
       
  4541 	TestAssortedBPPandColourDepthL(Kmbm32BitSkinFileInRom, fbs);
       
  4542 	_LIT(Kmbm32bit6colFileInRom, "z:\\system\\data\\32bit6col.mbm");
       
  4543 	TestAssortedBPPandColourDepthL(Kmbm32bit6colFileInRom, fbs);
       
  4544 	_LIT(Kmbm32bit2colFileInRom, "z:\\system\\data\\32bit2col.mbm");
       
  4545 	TestAssortedBPPandColourDepthL(Kmbm32bit2colFileInRom, fbs);
       
  4546 	_LIT(Kmbm32bit3colFileInRom, "z:\\system\\data\\32bit3col.mbm");
       
  4547 	TestAssortedBPPandColourDepthL(Kmbm32bit3colFileInRom, fbs);
       
  4548 	_LIT(Kmbm32bit20colFileInRom, "z:\\system\\data\\32bit20col.mbm");
       
  4549 	TestAssortedBPPandColourDepthL(Kmbm32bit20colFileInRom, fbs);
       
  4550 	INFO_PRINTF1(_L("Test Palette Compression - COMPLETE"));
       
  4551 	}
       
  4552 
       
  4553 void CTBitmap::TestAssortedBPPandColourDepthL(const TDesC& aFilename, RFbsSession* aFbs)
       
  4554 	{
       
  4555 	//create bitmap
       
  4556 	CFbsBitmap* fbsCompressed = new (ELeave) CFbsBitmap ;
       
  4557 	CFbsBitmap* fbsUnCompressed = new (ELeave) CFbsBitmap ;
       
  4558 	CleanupStack::PushL(fbsCompressed);
       
  4559 	CleanupStack::PushL(fbsUnCompressed);
       
  4560 	TEST2(fbsUnCompressed->Load(aFilename, 0, EFalse), KErrNone);
       
  4561 	fbsUnCompressed->Save(KTempFilename);
       
  4562 	//load bitmap
       
  4563 	TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
       
  4564 	//compress bitmap (force foreground compression)
       
  4565 	fbsCompressed->Compress(EPaletteCompression);
       
  4566 	aFbs->SendCommand(EFbsCompress, 0); //force background compression to execute
       
  4567 	//test that palette compression occurred
       
  4568 	TEST(fbsCompressed->Header().iCompression == EGenericPaletteCompression);
       
  4569 	//compare with original
       
  4570 	INFO_PRINTF1(_L("Compare Palette Compressed bmp with original"));
       
  4571 	CompareBitmaps((CFbsBitmapEx&)*fbsCompressed, (CFbsBitmapEx&)*fbsUnCompressed, EColor16M);
       
  4572 	CleanupStack::PopAndDestroy(2);
       
  4573 	iFs.Delete(KTempFilename);
       
  4574 	}
       
  4575 	
       
  4576 /**
       
  4577 	@SYMTestCaseID
       
  4578 	GRAPHICS-FBSERV-0552
       
  4579 
       
  4580 	@SYMTestCaseDesc
       
  4581 	The test verifies the 
       
  4582 	CFbsBitmap::CompressInBackground((TBitmapfileCompressionScheme aScheme)
       
  4583 	API. It loads bitmaps from ROM & saves (temporarily) to C-drive. 
       
  4584 	Then it loads from C-drive into a new bitmap.
       
  4585 
       
  4586 	@SYMTestActions
       
  4587 	
       
  4588 	@SYMTestExpectedResults
       
  4589 	Test should pass
       
  4590 */
       
  4591 void CTBitmap::TestSynchronousBackgroundPaletteCompressionL()
       
  4592 	{
       
  4593 	INFO_PRINTF1(_L("Test Background Palette Compression"));
       
  4594 	_LIT(KmbmFileInRom, "z:\\system\\data\\24bitskin.mbm");
       
  4595 	RFbsSession* fbs = RFbsSession::GetSession();
       
  4596 	//create bitmap
       
  4597 	CFbsBitmap* fbsCompressed = new(ELeave) CFbsBitmap ;
       
  4598 	CFbsBitmap* fbsUnCompressed = new(ELeave) CFbsBitmap ;
       
  4599 	CleanupStack::PushL(fbsCompressed);
       
  4600 	CleanupStack::PushL(fbsUnCompressed);
       
  4601 	TEST2(fbsUnCompressed->Load(KmbmFileInRom, 0, EFalse), KErrNone);
       
  4602 	fbsUnCompressed->Save(KTempFilename);
       
  4603 	//load bitmap
       
  4604 	TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
       
  4605 	//compress bitmap (force immediate compression)
       
  4606 	fbsCompressed->CompressInBackground(EPaletteCompression);
       
  4607 	fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
       
  4608 	//test that palette compression occurred
       
  4609 	TEST(fbsCompressed->Header().iCompression == EGenericPaletteCompression);
       
  4610 	//compare with original
       
  4611 	INFO_PRINTF1(_L("Compare Palette Compressed bmp with original"));
       
  4612 	CompareBitmaps((CFbsBitmapEx&)*fbsCompressed, (CFbsBitmapEx&)*fbsUnCompressed, EColor16M);
       
  4613 	CleanupStack::PopAndDestroy(2);
       
  4614 	iFs.Delete(KTempFilename);
       
  4615 	
       
  4616 	//Test that the RLE option works.
       
  4617 	//------------------------------------
       
  4618 	//create bitmap
       
  4619 	fbsCompressed = new(ELeave) CFbsBitmap ;
       
  4620 	fbsUnCompressed = new(ELeave) CFbsBitmap ;
       
  4621 	CleanupStack::PushL(fbsCompressed);
       
  4622 	CleanupStack::PushL(fbsUnCompressed);
       
  4623 	TEST2(fbsUnCompressed->Load(KmbmFileInRom, 0, EFalse), KErrNone);
       
  4624 	fbsUnCompressed->Save(KTempFilename);
       
  4625 	//load bitmap
       
  4626 	TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
       
  4627 	//compress bitmap (force immediate compression)
       
  4628 	fbsCompressed->CompressInBackground(ERLECompression);
       
  4629 	fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
       
  4630 	//test that RLE compression occurred
       
  4631 	TEST(fbsCompressed->Header().iCompression == ETwentyFourBitRLECompression);
       
  4632 	CleanupStack::PopAndDestroy(2);
       
  4633 	iFs.Delete(KTempFilename);
       
  4634 
       
  4635 	//Test that unsuitable bitmaps are not palette compressed (too many colours).
       
  4636 	//----------------------------------------------------------------------------------------
       
  4637 	_LIT(KmbmMultiColourMBMInRom, "z:\\system\\data\\24bit.mbm");
       
  4638 	//create bitmap
       
  4639 	fbsCompressed = new(ELeave) CFbsBitmap ;
       
  4640 	fbsUnCompressed = new(ELeave) CFbsBitmap ;
       
  4641 	CleanupStack::PushL(fbsCompressed);
       
  4642 	CleanupStack::PushL(fbsUnCompressed);
       
  4643 	TEST2(fbsUnCompressed->Load(KmbmMultiColourMBMInRom, 0, EFalse), KErrNone);
       
  4644 	fbsUnCompressed->Save(KTempFilename);
       
  4645 	//load bitmap
       
  4646 	TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
       
  4647 	//compress bitmap (force immediate compression)
       
  4648 	fbsCompressed->CompressInBackground(EPaletteCompression);
       
  4649 	fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
       
  4650 	//test that palette compression occurred
       
  4651 	TEST(fbsCompressed->Header().iCompression != EGenericPaletteCompression);
       
  4652 	CleanupStack::PopAndDestroy(2);
       
  4653 	iFs.Delete(KTempFilename);
       
  4654 	
       
  4655 	//Test that unsuitable bitmaps are not palette compressed (too few BPP)
       
  4656 	//---------------------------------------------------------------------------------
       
  4657 	//create bitmap
       
  4658 	fbsCompressed = new(ELeave) CFbsBitmap ;
       
  4659 	fbsUnCompressed = new(ELeave) CFbsBitmap ;
       
  4660 	CleanupStack::PushL(fbsCompressed);
       
  4661 	CleanupStack::PushL(fbsUnCompressed);
       
  4662 	TEST2(fbsUnCompressed->Load(KmbmMultiColourMBMInRom, 0, EFalse), KErrNone);
       
  4663 	fbsUnCompressed->Save(KTempFilename);
       
  4664 	//load bitmap
       
  4665 	TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
       
  4666 	//compress bitmap (force immediate compression)
       
  4667 	fbsCompressed->CompressInBackground(EPaletteCompression);
       
  4668 	fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
       
  4669 	//test that palette compression occurred
       
  4670 	TEST(fbsCompressed->Header().iCompression != EGenericPaletteCompression);
       
  4671 	CleanupStack::PopAndDestroy(2);
       
  4672 	iFs.Delete(KTempFilename);
       
  4673 	INFO_PRINTF1(_L("Test Background Palette Compression - COMPLETE"));
       
  4674 	}
       
  4675 	
       
  4676 /**
       
  4677 	@SYMTestCaseID
       
  4678 	GRAPHICS-FBSERV-0553
       
  4679 
       
  4680 	@SYMTestCaseDesc
       
  4681 	The test verifies the 
       
  4682 	CFbsBitmap::CompressInBackground(TRequestStatus& aRequestStatus, TBitmapfileCompressionScheme aScheme)
       
  4683 	API. It loads bitmaps from ROM & saves (temporarily) to C-drive. 
       
  4684 	Then it loads from C-drive into a new bitmap.
       
  4685 
       
  4686 	@SYMTestActions
       
  4687 	
       
  4688 	@SYMTestExpectedResults
       
  4689 	Test should pass
       
  4690 */	
       
  4691 void CTBitmap::TestAsynchronousBackgroundPaletteCompressionL()
       
  4692 	{
       
  4693 	INFO_PRINTF1(_L("Test Asynch background Palette Compression"));
       
  4694 	TRequestStatus status ;
       
  4695 	_LIT(KmbmFileInRom, "z:\\system\\data\\24bitskin.mbm");
       
  4696 	RFbsSession* fbs = RFbsSession::GetSession();
       
  4697 	//create bitmap
       
  4698 	CFbsBitmap* fbsCompressed = new(ELeave) CFbsBitmap ;
       
  4699 	CFbsBitmap* fbsUnCompressed = new(ELeave) CFbsBitmap ;
       
  4700 	CleanupStack::PushL(fbsCompressed);
       
  4701 	CleanupStack::PushL(fbsUnCompressed);
       
  4702 	TEST2(fbsUnCompressed->Load(KmbmFileInRom, 0, EFalse), KErrNone);
       
  4703 	fbsUnCompressed->Save(KTempFilename);
       
  4704 	//load bitmap
       
  4705 	TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
       
  4706 	//compress bitmap (force immediate compression)
       
  4707 	fbsCompressed->CompressInBackground(status, EPaletteCompression);
       
  4708 	fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
       
  4709 	User::WaitForRequest(status);
       
  4710 	TEST2(status.Int(), KErrNone);
       
  4711 	//test that palette compression occurred
       
  4712 	TEST(fbsCompressed->Header().iCompression == EGenericPaletteCompression);
       
  4713 	//compare with original
       
  4714 	INFO_PRINTF1(_L("Compare Palette Compressed bmp with original"));
       
  4715 	CompareBitmaps((CFbsBitmapEx&)*fbsCompressed, (CFbsBitmapEx&)*fbsUnCompressed, EColor16M);
       
  4716 	CleanupStack::PopAndDestroy(2);
       
  4717 	iFs.Delete(KTempFilename);
       
  4718 	
       
  4719 	//Test that the RLE option works.
       
  4720 	//------------------------------------
       
  4721 	//create bitmap
       
  4722 	fbsCompressed = new (ELeave) CFbsBitmap ;
       
  4723 	fbsUnCompressed = new (ELeave) CFbsBitmap ;
       
  4724 	CleanupStack::PushL(fbsCompressed);
       
  4725 	CleanupStack::PushL(fbsUnCompressed);
       
  4726 	TEST2(fbsUnCompressed->Load(KmbmFileInRom, 0, EFalse), KErrNone);
       
  4727 	fbsUnCompressed->Save(KTempFilename);
       
  4728 	//load bitmap
       
  4729 	TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
       
  4730 	//compress bitmap (force immediate compression)
       
  4731 	fbsCompressed->CompressInBackground(status, ERLECompression);
       
  4732 	fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
       
  4733 	User::WaitForRequest(status);
       
  4734 	TEST2(status.Int(), KErrNone);
       
  4735 	//test that RLE compression occurred
       
  4736 	TEST(fbsCompressed->Header().iCompression == ETwentyFourBitRLECompression);
       
  4737 	CleanupStack::PopAndDestroy(2);
       
  4738 	iFs.Delete(KTempFilename);
       
  4739 
       
  4740 	//Test that unsuitable bitmaps are not palette compressed (too many colours).
       
  4741 	//----------------------------------------------------------------------------------------
       
  4742 	_LIT(KmbmMultiColourMBMInRom, "z:\\system\\data\\24bit.mbm");
       
  4743 	//create bitmap
       
  4744 	fbsCompressed = new (ELeave) CFbsBitmap ;
       
  4745 	fbsUnCompressed = new (ELeave) CFbsBitmap ;
       
  4746 	CleanupStack::PushL(fbsCompressed);
       
  4747 	CleanupStack::PushL(fbsUnCompressed);
       
  4748 	TEST2(fbsUnCompressed->Load(KmbmMultiColourMBMInRom, 0, EFalse), KErrNone);
       
  4749 	fbsUnCompressed->Save(KTempFilename);
       
  4750 	//load bitmap
       
  4751 	TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
       
  4752 	//compress bitmap (force immediate compression)
       
  4753 	fbsCompressed->CompressInBackground(status, EPaletteCompression);
       
  4754 	fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
       
  4755 	User::WaitForRequest(status);
       
  4756 	TEST2(status.Int(), KErrNotSupported);
       
  4757 	//test that palette compression occurred
       
  4758 	TEST(fbsCompressed->Header().iCompression != EGenericPaletteCompression);
       
  4759 	CleanupStack::PopAndDestroy(2);
       
  4760 	iFs.Delete(KTempFilename);
       
  4761 	
       
  4762 	//Test that unsuitable bitmaps are not palette compressed (too few BPP)
       
  4763 	//---------------------------------------------------------------------------------
       
  4764 	//create bitmap
       
  4765 	fbsCompressed = new(ELeave) CFbsBitmap ;
       
  4766 	fbsUnCompressed = new(ELeave) CFbsBitmap ;
       
  4767 	CleanupStack::PushL(fbsCompressed);
       
  4768 	CleanupStack::PushL(fbsUnCompressed);
       
  4769 	TEST2(fbsUnCompressed->Load(KmbmMultiColourMBMInRom, 0, EFalse), KErrNone);
       
  4770 	fbsUnCompressed->Save(KTempFilename);
       
  4771 	//load bitmap
       
  4772 	TEST2(fbsCompressed->Load(KTempFilename, 0, EFalse), KErrNone);
       
  4773 	//compress bitmap (force immediate compression)
       
  4774 	fbsCompressed->CompressInBackground(status, EPaletteCompression);
       
  4775 	fbs->SendCommand(EFbsCompress, 0); //force background compression to execute
       
  4776 	User::WaitForRequest(status);
       
  4777 	TEST2(status.Int(), KErrNotSupported);
       
  4778 	//test that palette compression occurred
       
  4779 	TEST(fbsCompressed->Header().iCompression != EGenericPaletteCompression);
       
  4780 	CleanupStack::PopAndDestroy(2);
       
  4781 	iFs.Delete(KTempFilename);
       
  4782 	INFO_PRINTF1(_L("Test Asynch background Palette Compressio - COMPLETE"));
       
  4783 	}
       
  4784 
       
  4785 /**
       
  4786 @SYMTestCaseID GRAPHICS-FBSERV-0501
       
  4787 
       
  4788 @SYMTestType UT
       
  4789 
       
  4790 @SYMTestPriority Medium
       
  4791 
       
  4792 @SYMCR DKRN-6QGJPT
       
  4793 
       
  4794 @SYMTestCaseDesc Get all bitmap handles before and after loading a bitmap. 
       
  4795 
       
  4796 @SYMTestActions
       
  4797 1) Get all bitmap handles and store number of bitmaps obtained
       
  4798 2) Load a new bitmap
       
  4799 3) Get all bitmap handles and store number of bitmaps obtained
       
  4800 
       
  4801 @SYMTestExpectedResults
       
  4802 The number of bitmap handles retrieved after loading the bitmap should be one more than prior to loading the bitmap.
       
  4803 */
       
  4804 void CTBitmap::GetAllBitmapsIdsL()
       
  4805 	{
       
  4806 	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
       
  4807 	CleanupStack::PushL(bitmap);
       
  4808 	
       
  4809 	RArray <TInt> bitmapHandleArray;
       
  4810 	CleanupClosePushL(bitmapHandleArray);
       
  4811 	
       
  4812 	// Get current number of bitmap handles
       
  4813 	User::LeaveIfError(bitmap->GetAllBitmapHandles(bitmapHandleArray));
       
  4814 	const TInt numBitmapHandles = bitmapHandleArray.Count();
       
  4815 	
       
  4816 	// Load another bitmap
       
  4817 	CFbsBitmap* bmp = LoadBitmapLC(KRc_Ram8);
       
  4818 	
       
  4819 	// Get current number of bitmap handles
       
  4820 	User::LeaveIfError(bitmap->GetAllBitmapHandles(bitmapHandleArray));
       
  4821 	const TInt newNumBitmapHandles = bitmapHandleArray.Count();
       
  4822 	TEST(numBitmapHandles == newNumBitmapHandles - 1);	// Ensure there is one more bitmap handle from the bitmap we just added
       
  4823 	
       
  4824 	const TInt handle = bmp->Handle();
       
  4825 	
       
  4826 	TInt foundHandle = 0;
       
  4827 	for (TInt count = newNumBitmapHandles-1; count>=0; --count)
       
  4828 		{
       
  4829 		if (handle == bitmapHandleArray[count])
       
  4830 			{
       
  4831 			foundHandle++;
       
  4832 			}
       
  4833 		}
       
  4834 	TEST(foundHandle==1);	// Ensure only one instance of this handle is found in the array
       
  4835 	CleanupStack::PopAndDestroy(3, bitmap);	// bmp, bitmapHandleArray, bitmap	
       
  4836 	}
       
  4837 
       
  4838 /**
       
  4839 	@SYMTestCaseID
       
  4840 	GRAPHICS-FBSERV-0554
       
  4841 
       
  4842 	@SYMTestCaseDesc
       
  4843 	Test Code For Corrupted MBM File.
       
  4844 	
       
  4845 	@SYMTestActions
       
  4846 	Loads a specific bitmap from a multi-bitmap 
       
  4847 	file from ROM and tests if it is corrupted.
       
  4848 	
       
  4849 	@SYMTestExpectedResults
       
  4850 	Test should pass
       
  4851 */
       
  4852 void CTBitmap::CheckBadBmp()
       
  4853 {
       
  4854 	INFO_PRINTF1(_L("MalformedBmp"));
       
  4855 	_LIT(KmalmbmFile0, "z:\\system\\data\\00_grbmap.mbm");
       
  4856 	_LIT(KmalmbmFile1, "z:\\system\\data\\01_totalstramsize!.mbm");
       
  4857 	_LIT(KmalmbmFile2, "z:\\system\\data\\02_headersize.mbm");
       
  4858 	_LIT(KmalmbmFile3, "z:\\system\\data\\03_width!.mbm");
       
  4859 	_LIT(KmalmbmFile4, "z:\\system\\data\\04_height!.mbm");
       
  4860 	_LIT(KmalmbmFile5, "z:\\system\\data\\05_bitsperpixel.mbm");
       
  4861 	_LIT(KmalmbmFile6, "z:\\system\\data\\bad_bmpsize.mbm");
       
  4862 	_LIT(KmalmbmFile7, "z:\\system\\data\\bad_colormode.mbm");
       
  4863 	_LIT(KmalmbmFile8, "z:\\system\\data\\bad_compression.mbm");
       
  4864 	_LIT(KmalmbmFile9, "z:\\system\\data\\bad_paletteentries.mbm"); 
       
  4865 
       
  4866 	CFbsBitmap* fbsmalBmp = new(ELeave) CFbsBitmap;
       
  4867 	CleanupStack::PushL(fbsmalBmp);
       
  4868 
       
  4869 	//load bitmap
       
  4870 	TEST2(fbsmalBmp->Load(KmalmbmFile0, 0, EFalse), KErrNone);
       
  4871 	TEST2(fbsmalBmp->Load(KmalmbmFile1, 0, EFalse), KErrCorrupt);
       
  4872 	TEST2(fbsmalBmp->Load(KmalmbmFile2, 0, EFalse), KErrCorrupt);
       
  4873 	TEST2(fbsmalBmp->Load(KmalmbmFile3, 0, EFalse), KErrCorrupt);
       
  4874 	TEST2(fbsmalBmp->Load(KmalmbmFile4, 0, EFalse), KErrCorrupt);
       
  4875 	TEST2(fbsmalBmp->Load(KmalmbmFile5, 0, EFalse), KErrNotSupported);
       
  4876 	TEST2(fbsmalBmp->Load(KmalmbmFile6, 0, EFalse), KErrCorrupt);
       
  4877 	TEST2(fbsmalBmp->Load(KmalmbmFile7, 0, EFalse), KErrCorrupt);
       
  4878 	TEST2(fbsmalBmp->Load(KmalmbmFile8, 0, EFalse), KErrCorrupt);
       
  4879 	TEST2(fbsmalBmp->Load(KmalmbmFile9, 0, EFalse), KErrNotSupported);
       
  4880 
       
  4881 	CleanupStack::PopAndDestroy(fbsmalBmp);
       
  4882 }
       
  4883 
       
  4884 /**
       
  4885 @SYMTestCaseID			GRAPHICS-FBSERV-0613
       
  4886 
       
  4887 @SYMDEF					PDEF111181
       
  4888 
       
  4889 @SYMTestCaseDesc		Test the return code of operations on bitmaps in the background compression queue
       
  4890 
       
  4891 @SYMTestPriority		Critical
       
  4892 
       
  4893 @SYMTestType			UT
       
  4894 
       
  4895 @SYMTestStatus			Implemented
       
  4896 
       
  4897 @SYMTestActions			1. Creates a bitmap
       
  4898 						2. Calls CompressInBackground()
       
  4899 						3. Call Resize
       
  4900 						4. Waits until compression is finished
       
  4901 
       
  4902 @SYMTestExpectedResults The call to resize should return with KErrInUse since the compression is in progress
       
  4903 */
       
  4904 
       
  4905 void CTBitmap::TestBgCompressInUseL()
       
  4906 	{
       
  4907 	INFO_PRINTF1(_L("Test the return code of operations on bitmaps in the background compression queue"));
       
  4908 	
       
  4909 	CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
       
  4910 	CleanupStack::PushL(bmp);
       
  4911 
       
  4912 	TInt ret = bmp->Create(TSize(256, 256), EGray256); // create a solid grey bitmap
       
  4913 	TEST2 (ret,KErrNone);
       
  4914 	TRequestStatus status;
       
  4915 	bmp->CompressInBackground(status);
       
  4916 	TInt resizeRet = bmp->Resize(TSize(512,512));
       
  4917 	
       
  4918 	TEST2 (resizeRet,KErrInUse);
       
  4919 	User::WaitForRequest(status);
       
  4920 	TEST2 (status.Int(), KErrNone);
       
  4921 	CleanupStack::PopAndDestroy(bmp);
       
  4922 	}
       
  4923 
       
  4924 
       
  4925 //------------------------------------------------------------------------------
       
  4926 
       
  4927 LOCAL_D const TInt KTestBitmapWidth = 256; // this affects BitmapCheckCompressed()
       
  4928 LOCAL_D const TInt KTestBitmapHeight = 256;
       
  4929 LOCAL_D const TInt KTestBitmapResizeHeight = 512;
       
  4930 LOCAL_D const TInt KMaxRLERunLength = 127;
       
  4931 
       
  4932 LOCAL_C void SetBitmapDataWithVerticalGradient(TUint8* aDataPtr)
       
  4933 	{
       
  4934 	for (TInt y = 0; y < KTestBitmapHeight; ++y)
       
  4935 		for (TInt x = 0; x < KTestBitmapWidth; ++x)
       
  4936 			*aDataPtr++ = y;
       
  4937 	}
       
  4938 
       
  4939 LOCAL_C TBool BitmapDataCheckVerticalGradient(const TUint8* aDataPtr)
       
  4940 	{
       
  4941 	for (TInt y = 0; y < KTestBitmapHeight; ++y)
       
  4942 		for (TInt x = 0; x < KTestBitmapWidth; ++x)
       
  4943 			if (*aDataPtr++ != y)
       
  4944 				return EFalse;
       
  4945 	return ETrue;
       
  4946 	}
       
  4947 
       
  4948 LOCAL_C void SetBitmapDataWithHorizontalGradient(TUint8* aDataPtr)
       
  4949 	{
       
  4950 	for (TInt y = 0; y < KTestBitmapHeight; ++y)
       
  4951 		for (TInt x = 0; x < KTestBitmapWidth; ++x)
       
  4952 			*aDataPtr++ = x;
       
  4953 	}
       
  4954 
       
  4955 LOCAL_C TBool BitmapDataCheckHorizontalGradient(const TUint8* aDataPtr)
       
  4956 	{
       
  4957 	for (TInt y = 0; y < KTestBitmapHeight; ++y)
       
  4958 		for (TInt x = 0; x < KTestBitmapWidth; ++x)
       
  4959 			if (*aDataPtr++ != x)
       
  4960 				return EFalse;
       
  4961 	return ETrue;
       
  4962 	}
       
  4963 
       
  4964 LOCAL_C TInt ResizeTestBitmap(CFbsBitmap* aBitmap)
       
  4965 	{
       
  4966 	return aBitmap->Resize(TSize(KTestBitmapWidth, KTestBitmapResizeHeight));
       
  4967 	}
       
  4968 
       
  4969 LOCAL_C TBool BitmapCheckResized(const CFbsBitmap* aBitmap)
       
  4970 	{
       
  4971 	if (aBitmap->SizeInPixels() != TSize(KTestBitmapWidth, KTestBitmapResizeHeight))
       
  4972 		return EFalse;
       
  4973 	TUint8* dataPtr = (TUint8*)aBitmap->DataAddress();
       
  4974 	for (TInt y = 0; y < KTestBitmapHeight; ++y)
       
  4975 		for (TInt x = 0; x < KTestBitmapWidth; ++x)
       
  4976 			if (*dataPtr++ != y)
       
  4977 				return EFalse;
       
  4978 	for (TInt y = KTestBitmapHeight; y < KTestBitmapResizeHeight; ++y)
       
  4979 		for (TInt x = 0; x < KTestBitmapWidth; ++x)
       
  4980 			if (*dataPtr++ != 0xFF)
       
  4981 				return EFalse;
       
  4982 	return ETrue;
       
  4983 	}
       
  4984 
       
  4985 LOCAL_C TInt CompressTestBitmap(CFbsBitmap* aBitmap)
       
  4986 	{
       
  4987 	return aBitmap->Compress();
       
  4988 	}
       
  4989 
       
  4990 LOCAL_C TBool BitmapCheckCompressed(const CFbsBitmap* aBitmap)
       
  4991 	{
       
  4992 	if (aBitmap->SizeInPixels() != TSize(KTestBitmapWidth, KTestBitmapHeight))
       
  4993 		return EFalse;
       
  4994 	// check RLE compression on vertical gradient
       
  4995 	TUint8* dataPtr = (TUint8*)aBitmap->DataAddress();
       
  4996 	for (TInt y = 0; y < KTestBitmapHeight - 1; ++y)
       
  4997 		{
       
  4998 		// this works when the width of the bitmap is 256, or twice the maximum encodable run length, which is 128
       
  4999 		if (*dataPtr++ != KMaxRLERunLength)
       
  5000 			return EFalse;
       
  5001 		if (*dataPtr++ != y)
       
  5002 			return EFalse;
       
  5003 		if (*dataPtr++ != KMaxRLERunLength)
       
  5004 			return EFalse;
       
  5005 		if (*dataPtr++ != y)
       
  5006 			return EFalse;
       
  5007 		}
       
  5008 	return ETrue;
       
  5009 	}
       
  5010 
       
  5011 struct TTestThreadParams
       
  5012 	{
       
  5013 	TInt iBitmapHandle;
       
  5014 	TInt (*iBitmapFunction)(CFbsBitmap*); // operation to perform on the bitmap
       
  5015 	TBool (*iCheckFunction)(const CFbsBitmap*); // check that the operation was successfully performed
       
  5016 	};
       
  5017 
       
  5018 LOCAL_C void AlternateTestThreadL(const TTestThreadParams& aParams)
       
  5019 	{
       
  5020 	RFbsSession* fbs = RFbsSession::GetSession();
       
  5021 	if (fbs->ResourceCount() != 0)
       
  5022 		User::Leave(KErrGeneral);
       
  5023 	CFbsBitmap* bmp = new(ELeave) CFbsBitmap;
       
  5024 	CleanupStack::PushL(bmp);
       
  5025 	User::LeaveIfError(bmp->Duplicate(aParams.iBitmapHandle));
       
  5026 	if (fbs->ResourceCount() != 1)
       
  5027 		User::Leave(KErrGeneral);
       
  5028 	if (!BitmapDataCheckVerticalGradient((TUint8*)bmp->DataAddress()))
       
  5029 		User::Leave(KErrGeneral);
       
  5030 	User::LeaveIfError((*aParams.iBitmapFunction)(bmp));
       
  5031 	if (fbs->ResourceCount() != 1)
       
  5032 		User::Leave(KErrGeneral);
       
  5033 	if (aParams.iCheckFunction != NULL && !(*aParams.iCheckFunction)(bmp))
       
  5034 		User::Leave(KErrGeneral);
       
  5035 	CleanupStack::PopAndDestroy(bmp);
       
  5036 	if (fbs->ResourceCount() != 0)
       
  5037 		User::Leave(KErrGeneral);
       
  5038 	}
       
  5039 
       
  5040 LOCAL_C TInt AlternateTestThread(TAny* aParams)
       
  5041 	{
       
  5042 	__UHEAP_MARK;
       
  5043 	TInt ret = RFbsSession::Connect();
       
  5044 	if (ret != KErrNone)
       
  5045 		return ret;
       
  5046 	CTrapCleanup* cleanupStack = CTrapCleanup::New();
       
  5047 	if (cleanupStack == NULL)
       
  5048 		return KErrNoMemory;
       
  5049 	TRAP(ret, AlternateTestThreadL(*static_cast<TTestThreadParams*>(aParams)));
       
  5050 	delete cleanupStack;
       
  5051 	RFbsSession::Disconnect();
       
  5052 	__UHEAP_MARKEND;
       
  5053 	return ret;
       
  5054 	}
       
  5055 
       
  5056 void CTBitmap::MultiThreadedTestsL()
       
  5057 	{
       
  5058 	((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0503"));
       
  5059 	MultiThreadedResizeTestL();
       
  5060 	((CTBitmapStep*)iStep)->RecordTestResultL();
       
  5061 	((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0504"));
       
  5062 	MultiThreadedCompressTestL();
       
  5063 #ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP
       
  5064 	((CTBitmapStep*)iStep)->RecordTestResultL();
       
  5065 	((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0505"));
       
  5066 	MultiThreadedLockHeapTestL();
       
  5067 #endif
       
  5068 	}
       
  5069 
       
  5070 /**
       
  5071 @SYMTestCaseID			GRAPHICS-FBSERV-0503
       
  5072 
       
  5073 @SYMDEF					DEF090812
       
  5074 
       
  5075 @SYMTestCaseDesc		Tests behaviour of CFbsBitmap::DataAddress() and CFbsBitmap::Resize() when called concurrently by different threads
       
  5076 
       
  5077 @SYMTestPriority		High
       
  5078 
       
  5079 @SYMTestType			UT
       
  5080 
       
  5081 @SYMTestStatus			Implemented
       
  5082 
       
  5083 @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
       
  5084 						2. The 2nd thread will resize the same bitmap and exit
       
  5085 						3. The 1st thread will manipulate the bitmap data using the stored pointer and then re-fetch the bitmap data
       
  5086 
       
  5087 @SYMTestExpectedResults	The 1st thread should be able both to manipulate the old bitmap data and check the resized bitmap data
       
  5088 */
       
  5089 void CTBitmap::MultiThreadedResizeTestL()
       
  5090 	{
       
  5091 	INFO_PRINTF1(_L("Test Resize() with Multiple Threads"));
       
  5092 	DoMultiThreadedTestL(_L("AlternateResizeThread"), ResizeTestBitmap, BitmapCheckResized);
       
  5093 	}
       
  5094 
       
  5095 /**
       
  5096 @SYMTestCaseID			GRAPHICS-FBSERV-0504
       
  5097 
       
  5098 @SYMDEF					DEF090812
       
  5099 
       
  5100 @SYMTestCaseDesc		Tests behaviour of CFbsBitmap::DataAddress() and CFbsBitmap::Compress() when called concurrently by different threads
       
  5101 
       
  5102 @SYMTestPriority		High
       
  5103 
       
  5104 @SYMTestType			UT
       
  5105 
       
  5106 @SYMTestStatus			Implemented
       
  5107 
       
  5108 @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
       
  5109 						2. The 2nd thread will compress the same bitmap and exit
       
  5110 						3. The 1st thread will manipulate the bitmap data using the stored pointer and then re-fetch the bitmap data
       
  5111 
       
  5112 @SYMTestExpectedResults	The 1st thread should be able both to manipulate the old bitmap data and check the compressed bitmap data
       
  5113 */
       
  5114 void CTBitmap::MultiThreadedCompressTestL()
       
  5115 	{
       
  5116 	INFO_PRINTF1(_L("Test Compress() with Multiple Threads"));
       
  5117 	DoMultiThreadedTestL(_L("AlternateCompressThread"), CompressTestBitmap, BitmapCheckCompressed);
       
  5118 	}
       
  5119 
       
  5120 void CTBitmap::DoMultiThreadedTestL(const TDesC& aThreadName, TInt (*aBitmapFunction)(CFbsBitmap*), TBool (*aCheckFunction)(const CFbsBitmap*))
       
  5121 	{
       
  5122 	CFbsBitmap* bmp = new CFbsBitmap;
       
  5123 	ASSERT_NOT_NULL(bmp);
       
  5124 	CleanupStack::PushL(bmp);
       
  5125 	TInt ret = bmp->Create(TSize(KTestBitmapWidth, KTestBitmapHeight), EGray256);
       
  5126 	ASSERT_EQUALS(ret, KErrNone);
       
  5127 	TUint8* dataPtr = (TUint8*)bmp->DataAddress();
       
  5128 	SetBitmapDataWithVerticalGradient(dataPtr);
       
  5129 	TTestThreadParams params;
       
  5130 	params.iBitmapHandle = bmp->Handle();
       
  5131 	params.iBitmapFunction = aBitmapFunction;
       
  5132 	params.iCheckFunction = aCheckFunction;
       
  5133 	RThread thread;
       
  5134 	ret = thread.Create(aThreadName, AlternateTestThread, KDefaultStackSize, 0x2000, 0x2000, &params);
       
  5135 	ASSERT_EQUALS(ret, KErrNone);
       
  5136 	TRequestStatus status;
       
  5137 	thread.Logon(status);
       
  5138 	thread.Resume();
       
  5139 	User::WaitForRequest(status);
       
  5140 	TExitType exitType = thread.ExitType();
       
  5141 	TInt exitReason = thread.ExitReason();
       
  5142 	TEST(exitType == EExitKill);
       
  5143 	TEST(exitReason == KErrNone);
       
  5144 	thread.Close();
       
  5145 	TEST(BitmapDataCheckVerticalGradient(dataPtr));
       
  5146 	SetBitmapDataWithHorizontalGradient(dataPtr);
       
  5147 	TEST(BitmapDataCheckHorizontalGradient(dataPtr));
       
  5148 	TEST((*aCheckFunction)(bmp));
       
  5149 	CleanupStack::PopAndDestroy(bmp);
       
  5150 	User::Heap().Check();
       
  5151 	}
       
  5152 
       
  5153 #ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP
       
  5154 _LIT(KFBSERVClientPanicCategory, "FBSCLI");
       
  5155 
       
  5156 LOCAL_C TInt LockHeapTestBitmap(CFbsBitmap* aBitmap)
       
  5157 	{
       
  5158 	aBitmap->LockHeap();
       
  5159 	return KErrNone;
       
  5160 	}
       
  5161 
       
  5162 /**
       
  5163 @SYMTestCaseID			GRAPHICS-FBSERV-0505
       
  5164 
       
  5165 @SYMDEF					DEF090812
       
  5166 
       
  5167 @SYMTestCaseDesc		Tests behaviour of CFbsBitmap::LockHeap() when called concurrently by different threads
       
  5168 
       
  5169 @SYMTestPriority		High
       
  5170 
       
  5171 @SYMTestType			UT
       
  5172 
       
  5173 @SYMTestStatus			Implemented
       
  5174 
       
  5175 @SYMTestActions			1. The 1st thread will create a bitmap, call LockHeap() on it, launch the 2nd thread and then wait for it to terminate
       
  5176 						2. The 2nd thread will also call LockHeap() on the same bitmap
       
  5177 						3. The 1st thread will check that the 2nd thread has panicked
       
  5178 
       
  5179 @SYMTestExpectedResults	Panic FBSCLI 22
       
  5180 */
       
  5181 void CTBitmap::MultiThreadedLockHeapTestL()
       
  5182 	{
       
  5183 	INFO_PRINTF1(_L("Test LockHeap() Panic with Multiple Threads"));
       
  5184 	CFbsBitmap* bmp = new CFbsBitmap;
       
  5185 	ASSERT_NOT_NULL(bmp);
       
  5186 	CleanupStack::PushL(bmp);
       
  5187 	TInt ret = bmp->Create(TSize(KTestBitmapWidth, KTestBitmapHeight), EGray256);
       
  5188 	ASSERT_EQUALS(ret, KErrNone);
       
  5189 	SetBitmapDataWithVerticalGradient((TUint8*)bmp->DataAddress());
       
  5190 	bmp->LockHeap();
       
  5191 	TTestThreadParams params;
       
  5192 	params.iBitmapHandle = bmp->Handle();
       
  5193 	params.iBitmapFunction = LockHeapTestBitmap;
       
  5194 	params.iCheckFunction = NULL;
       
  5195 	RThread thread;
       
  5196 	ret = thread.Create(_L("AlternateLockHeapThread"), AlternateTestThread, KDefaultStackSize, 0x2000, 0x2000, &params);
       
  5197 	ASSERT_EQUALS(ret, KErrNone);
       
  5198 	TRequestStatus status;
       
  5199 	thread.Logon(status);
       
  5200 	thread.Resume();
       
  5201 	User::WaitForRequest(status);
       
  5202 	TExitType exitType = thread.ExitType();
       
  5203 	TExitCategoryName exitCategory = thread.ExitCategory();
       
  5204 	TInt exitReason = thread.ExitReason();
       
  5205 	TEST(exitType == EExitPanic);
       
  5206 	TEST(exitCategory == KFBSERVClientPanicCategory);
       
  5207 	TEST(exitReason == EFbsPanicBadHeapLock);
       
  5208 	thread.Close();
       
  5209 	CleanupStack::PopAndDestroy(bmp);
       
  5210 	User::Heap().Check();
       
  5211 	}
       
  5212 #endif
       
  5213 
       
  5214 //--------------
       
  5215 
       
  5216 class CStopTestBgCompress: public CAsyncOneShot
       
  5217 	{
       
  5218 public:
       
  5219 	CStopTestBgCompress(): CAsyncOneShot(CActive::EPriorityIdle - 1) {} // priority must be less than CFbsSessionHelper
       
  5220 	void RunL() { CActiveScheduler::Stop(); }
       
  5221 	};
       
  5222 
       
  5223 LOCAL_C TInt TestBgCompressThread(TAny* /*aParams*/)
       
  5224 	{
       
  5225 	const TInt KBmpSize = 0x100000 + sizeof(SEpocBitmapHeader);
       
  5226 	// assuming run-length encoding every scan line gets compressed into 8 runs of 128 bytes each
       
  5227 	// 2 bytes per encoded run results in 16 bytes per scan line so the compressed bitmap is large (>16K)
       
  5228 	// a few bytes added at the end for the compression bookmark are rounded up to a page
       
  5229 	const TInt KBmpCompressedSize = 0x5000;
       
  5230 	TInt ret = KErrNone;
       
  5231 	__UHEAP_MARK;
       
  5232 	CTrapCleanup* trap = CTrapCleanup::New();
       
  5233 	TRequestStatus status;
       
  5234 	if (trap == NULL)
       
  5235 		{
       
  5236 		ret = KErrNoMemory;
       
  5237 		goto exitNoTrap;
       
  5238 		}
       
  5239 	CActiveScheduler* scheduler = new CActiveScheduler;
       
  5240 	if (scheduler == NULL)
       
  5241 		{
       
  5242 		ret = KErrNoMemory;
       
  5243 		goto exitNoScheduler;
       
  5244 		}
       
  5245 	CActiveScheduler::Install(scheduler);
       
  5246 	CStopTestBgCompress* stop = new CStopTestBgCompress;
       
  5247 	if (stop == NULL)
       
  5248 		{
       
  5249 		ret = KErrNoMemory;
       
  5250 		goto exitNoStop;
       
  5251 		}
       
  5252 	ret = RFbsSession::Connect();
       
  5253 	if (ret != KErrNone)
       
  5254 		goto exitNoFbs;
       
  5255 	CFbsBitmapEx* bmp = new CFbsBitmapEx;
       
  5256 	if (bmp == NULL)
       
  5257 		{
       
  5258 		ret = KErrNoMemory;
       
  5259 		goto exitNoBmp;
       
  5260 		}
       
  5261 	CFbsBitmapEx* bmp2 = new CFbsBitmapEx;
       
  5262 	if (bmp2 == NULL)
       
  5263 		{
       
  5264 		ret = KErrNoMemory;
       
  5265 		goto exitNoBmp2;
       
  5266 		}
       
  5267 	ret = bmp->Create(TSize(1024, 1024), EGray256); // create a solid white bitmap
       
  5268 	if (ret != KErrNone)
       
  5269 		goto exitAll;
       
  5270 	ret = bmp2->Duplicate(bmp->Handle()); // duplicate the bitmap handle
       
  5271 	if (ret != KErrNone)
       
  5272 		goto exitAll;
       
  5273 	bmp->CompressInBackground(status);
       
  5274 	User::WaitForRequest(status);
       
  5275 	if (status != KErrNone)
       
  5276 		{
       
  5277 		ret = status.Int();
       
  5278 		goto exitAll;
       
  5279 		}
       
  5280 	if (bmp->BitmapAddress()->Header().iBitmapSize != KBmpSize || bmp->BitmapAddress() != bmp2->BitmapAddress())
       
  5281 		{
       
  5282 		ret = KErrGeneral;
       
  5283 		goto exitAll;
       
  5284 		}
       
  5285 	stop->Call();
       
  5286 	CActiveScheduler::Start(); // now CFbsSessionHelper should clean both bmp and bmp2 and free the dirty bitmap data
       
  5287 	if (!bmp->BitmapAddress()->IsCompressedInRAM() || bmp->BitmapAddress()->Header().iBitmapSize > KBmpCompressedSize || bmp->BitmapAddress() != bmp2->BitmapAddress())
       
  5288 		ret = KErrGeneral;
       
  5289 exitAll:
       
  5290 	delete bmp2;
       
  5291 exitNoBmp2:
       
  5292 	delete bmp;
       
  5293 exitNoBmp:
       
  5294 	RFbsSession::Disconnect();
       
  5295 exitNoFbs:
       
  5296 	delete stop;
       
  5297 exitNoStop:
       
  5298 	delete scheduler;
       
  5299 exitNoScheduler:
       
  5300 	delete trap;
       
  5301 exitNoTrap:
       
  5302 	__UHEAP_MARKEND;
       
  5303 	return ret;
       
  5304 	}
       
  5305 
       
  5306 /**
       
  5307 @SYMTestCaseID			GRAPHICS-FBSERV-0612
       
  5308 
       
  5309 @SYMDEF					INC109293
       
  5310 
       
  5311 @SYMTestCaseDesc		Tests memory usage with CFbsBitmap::CompressInBackground()
       
  5312 
       
  5313 @SYMTestPriority		High
       
  5314 
       
  5315 @SYMTestType			UT
       
  5316 
       
  5317 @SYMTestStatus			Implemented
       
  5318 
       
  5319 @SYMTestActions			1. Creates a bitmap
       
  5320 						2. Calls CompressInBackground()
       
  5321 						3. Waits until compression is finished
       
  5322 						4. Gives the active scheduler the chance to run the session's helper
       
  5323 
       
  5324 @SYMTestExpectedResults	Efficient use of memory
       
  5325 */
       
  5326 void CTBitmap::TestBgCompressL()
       
  5327 	{
       
  5328 	INFO_PRINTF1(_L("Test memory usage with CFbsBitmap::CompressInBackground()"));
       
  5329 	RThread thread;
       
  5330 	TInt ret = thread.Create(_L("TestBgCompressThread"), TestBgCompressThread, KDefaultStackSize, 0x2000, 0x2000, NULL);
       
  5331 	ASSERT_EQUALS(ret, KErrNone);
       
  5332 	TRequestStatus status;
       
  5333 	thread.Logon(status);
       
  5334 	thread.Resume();
       
  5335 	User::WaitForRequest(status);
       
  5336 	TExitType exitType = thread.ExitType();
       
  5337 	TInt exitReason = thread.ExitReason();
       
  5338 	TEST(exitType == EExitKill);
       
  5339 	TEST(exitReason == KErrNone);
       
  5340 	if (exitType != EExitKill || exitReason != KErrNone)
       
  5341 		{
       
  5342 		INFO_PRINTF3(_L("Exit Type = %d, Exit Reason = %d"), TInt(exitType), exitReason);
       
  5343 		}
       
  5344 	thread.Close();
       
  5345 	}
       
  5346 
       
  5347 /**
       
  5348 @SYMTestCaseID			GRAPHICS-FBSERV-0618
       
  5349 
       
  5350 @SYMDEF					DEF123068
       
  5351 
       
  5352 @SYMTestCaseDesc		Tests that small and large bitmaps are white-filled upon creation.
       
  5353 
       
  5354 @SYMTestPriority		High
       
  5355 
       
  5356 @SYMTestType			UT
       
  5357 
       
  5358 @SYMTestStatus			Implemented
       
  5359 
       
  5360 @SYMTestActions			1. Create a small bitmap
       
  5361 						2. Create a large bitmap
       
  5362 
       
  5363 @SYMTestExpectedResults	Both bitmaps are filled with white
       
  5364 */
       
  5365 void CTBitmap::TestBitmapWhiteFillL()
       
  5366 	{
       
  5367 	INFO_PRINTF1(_L("Test white fill of CFbsBitmap upon creation."));
       
  5368 	const TDisplayMode KDispMode = EColor16MAP;
       
  5369 	RPointerArray<CFbsBitmap> bmpArray;
       
  5370 	const TSize KBitmapSmallSize(4,4);
       
  5371 	const TSize KBitmapLargeSize(200,200);
       
  5372 	
       
  5373 	// Create small CFbsBitmap
       
  5374 	CFbsBitmap* bmp = new (ELeave) CFbsBitmap;;
       
  5375 	TInt ret = bmp->Create(KBitmapSmallSize,KDispMode);
       
  5376 	TEST2(ret, KErrNone);
       
  5377 	bmpArray.AppendL(bmp);
       
  5378 	// Create large CFbsBitmap
       
  5379 	bmp = new (ELeave) CFbsBitmap;;
       
  5380 	ret = bmp->Create(KBitmapLargeSize,KDispMode);
       
  5381 	TEST2(ret, KErrNone);
       
  5382 	bmpArray.AppendL(bmp);
       
  5383 	// Create small hardware bitmap
       
  5384 	bmp = new (ELeave) CFbsBitmap;;
       
  5385 	ret = bmp->CreateHardwareBitmap(KBitmapSmallSize, KDispMode, KNullUid);
       
  5386 	if (ret == KErrNotSupported)
       
  5387 		{
       
  5388 		INFO_PRINTF1(_L("WhiteFill test skipped for small hardware bitmaps as they are not supported"));
       
  5389 		delete bmp;
       
  5390 		}
       
  5391 	else
       
  5392 		{
       
  5393 		TEST2(ret, KErrNone);
       
  5394 		bmpArray.AppendL(bmp);
       
  5395 		}
       
  5396 	// Create large hardware bitmap
       
  5397 	bmp = new (ELeave) CFbsBitmap;;
       
  5398 	ret = bmp->CreateHardwareBitmap(KBitmapLargeSize, KDispMode, KNullUid);
       
  5399 	if (ret == KErrNotSupported)
       
  5400 		{
       
  5401 		INFO_PRINTF1(_L("WhiteFill test skipped for large hardware bitmaps as they are not supported"));
       
  5402 		delete bmp;
       
  5403 		}
       
  5404 	else
       
  5405 		{
       
  5406 		TEST2(ret, KErrNone);
       
  5407 		bmpArray.AppendL(bmp);
       
  5408 		}
       
  5409 	
       
  5410 	for (TInt ii = 0; ii < bmpArray.Count(); ++ii)
       
  5411 		{
       
  5412 		bmp = bmpArray[ii];
       
  5413 		bmp->BeginDataAccess();
       
  5414 		TUint32* base = bmp->DataAddress();
       
  5415 		TSize size = bmp->SizeInPixels();
       
  5416 		TInt scanLineLength = CFbsBitmap::ScanLineLength(size.iWidth,KDispMode);
       
  5417 		TInt dataLength = scanLineLength * size.iHeight;
       
  5418 		CheckWhite((TUint8*)base,dataLength,KDispMode);
       
  5419 		bmp->EndDataAccess(ETrue);
       
  5420 		delete bmp;
       
  5421 		}
       
  5422 	bmpArray.Close();
       
  5423 	}
       
  5424 
       
  5425 //--------------
       
  5426 
       
  5427 // The code for regression test case GRAPHICS-FBSERV-0614 must be in a separate thread
       
  5428 // because it has to call RFbsSession::Disconnect() and without the fix it panics.
       
  5429 LOCAL_C TInt TestDisconnectWithBitmapThread(TAny* /*aParams*/)
       
  5430 	{
       
  5431 	CTrapCleanup* trap = CTrapCleanup::New();
       
  5432 	if (trap == NULL)
       
  5433 		return KErrNoMemory;
       
  5434 	CActiveScheduler* scheduler = new CActiveScheduler;
       
  5435 	if (scheduler == NULL)
       
  5436 		{
       
  5437 		delete trap;
       
  5438 		return KErrNoMemory;
       
  5439 		}
       
  5440 	CActiveScheduler::Install(scheduler);
       
  5441 	TInt ret = RFbsSession::Connect();
       
  5442 	if (ret != KErrNone)
       
  5443 		{
       
  5444 		delete scheduler;
       
  5445 		delete trap;
       
  5446 		return ret;
       
  5447 		}
       
  5448 	CFbsBitmap* bmp = new CFbsBitmap;
       
  5449 	if (bmp == NULL)
       
  5450 		{
       
  5451 		RFbsSession::Disconnect();
       
  5452 		delete scheduler;
       
  5453 		delete trap;
       
  5454 		return KErrNoMemory;
       
  5455 		}
       
  5456 	ret = bmp->Create(TSize(256, 256), EGray256); // create a solid white bitmap
       
  5457 	if (ret != KErrNone)
       
  5458 		{
       
  5459 		RFbsSession::Disconnect();
       
  5460 		delete scheduler;
       
  5461 		delete trap;
       
  5462 		return ret;
       
  5463 		}
       
  5464 	RFbsSession::Disconnect();
       
  5465 	delete scheduler;
       
  5466 	delete trap;
       
  5467 	return ret;
       
  5468 	}
       
  5469 
       
  5470 /**
       
  5471 @SYMTestCaseID			GRAPHICS-FBSERV-0614
       
  5472 
       
  5473 @SYMDEF					INC113118
       
  5474 
       
  5475 @SYMTestCaseDesc		Tests behaviour when RFbsSession::Disconnect() is called and there is a CFbsBitmap not yet deleted
       
  5476 
       
  5477 @SYMTestPriority		High
       
  5478 
       
  5479 @SYMTestType			UT
       
  5480 
       
  5481 @SYMTestStatus			Implemented
       
  5482 
       
  5483 @SYMTestActions			1. Creates and installs an active scheduler so that CFbsSessionHelper can be activated
       
  5484 						2. Calls RFbsSession::Connect()
       
  5485 						3. Creates a bitmap
       
  5486 						4. Calls RFbsSession::Disconnect()
       
  5487 
       
  5488 @SYMTestExpectedResults	The bitmap should be destroyed automatically and no panics should occur
       
  5489 */
       
  5490 void CTBitmap::TestDisconnectWithBitmapL()
       
  5491 	{
       
  5492 	INFO_PRINTF1(_L("Test RFbsSession::Disconnect() with a CFbsBitmap not yet deleted"));
       
  5493 	RThread thread;
       
  5494 	TInt ret = thread.Create(_L("TestDisconnectWithBitmapThread"), TestDisconnectWithBitmapThread, KDefaultStackSize, 0x2000, 0x2000, NULL);
       
  5495 	ASSERT_EQUALS(ret, KErrNone);
       
  5496 	TRequestStatus status;
       
  5497 	thread.Logon(status);
       
  5498 	thread.Resume();
       
  5499 	User::WaitForRequest(status);
       
  5500 	TExitType exitType = thread.ExitType();
       
  5501 	TInt exitReason = thread.ExitReason();
       
  5502 	TEST(exitType == EExitKill);
       
  5503 	TEST(exitReason == KErrNone);
       
  5504 	thread.Close();
       
  5505 	}
       
  5506 
       
  5507 /**
       
  5508 @SYMTestCaseID			GRAPHICS-FBSERV-0617
       
  5509 
       
  5510 @SYMPREQ				PREQ39
       
  5511 
       
  5512 @SYMTestCaseDesc		Test that bitmaps have been touched when data changes.
       
  5513 						Test that bitmaps become volatile when DataAddress is called outside of 
       
  5514 						calls to  BeginDataAccess()	and EndDataAccess().
       
  5515 
       
  5516 @SYMTestStatus			Implemented
       
  5517 
       
  5518 @SYMTestPriority		High
       
  5519 
       
  5520 @SYMTestActions			Create a bitmap.
       
  5521 						Call each public API.
       
  5522 						Check that the touch count increases when the bitmap data has been modified.
       
  5523 						Check whether bitmap is volatile.
       
  5524 @SYMTestExpectedResults	Touch count only increases for the following functions:
       
  5525 	 						Resize,
       
  5526 	 						SetDisplayMode,
       
  5527 	 						SetScanLine,
       
  5528 	 						InternalizeL,
       
  5529 	 						SwapWidthAndHeight,
       
  5530 	 						DataAddress() called inside a Begin() and End(EFalse) pairing.
       
  5531 	 					Bitmap is volatile only when DataAddress() called outside
       
  5532 	 					a Begin() and End(EFalse) pairing.
       
  5533 */
       
  5534 void CTBitmap::TestTouchedAndVolatileL()
       
  5535 	{
       
  5536 	INFO_PRINTF1(_L("Test bitmaps become touched or volatile when data changes."));
       
  5537 	CFbsBitmap* bmp = new CFbsBitmap;
       
  5538 	TEST(bmp != NULL);
       
  5539 	TInt touchCount = 0;
       
  5540 	TInt newTouchCount = 0;
       
  5541 	CleanupStack::PushL(bmp);
       
  5542 	
       
  5543 	// Resize
       
  5544 	User::LeaveIfError(bmp->Create(TSize(4,4),EColor16MA));
       
  5545 	touchCount = bmp->TouchCount();
       
  5546 	TInt ret = bmp->Resize(TSize(5,5));
       
  5547 	TEST(ret == KErrNone);
       
  5548 	newTouchCount = bmp->TouchCount();
       
  5549 	TEST(newTouchCount == touchCount+1);
       
  5550 	TEST(!bmp->IsVolatile());
       
  5551 	touchCount = bmp->TouchCount();
       
  5552 	ret = bmp->Resize(TSize(3,3));
       
  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 	bmp->Reset();
       
  5564 
       
  5565 	// SetDisplayMode
       
  5566 	User::LeaveIfError(bmp->Create(TSize(4,4),EColor16MA));
       
  5567 	touchCount = bmp->TouchCount();
       
  5568 	ret = bmp->SetDisplayMode(EColor16MAP);
       
  5569 	TEST(ret == KErrNone);
       
  5570 	newTouchCount = bmp->TouchCount();
       
  5571 	TEST(newTouchCount == touchCount+1);
       
  5572 	TEST(!bmp->IsVolatile());
       
  5573 	bmp->Reset();
       
  5574 
       
  5575 	// SetScanLine
       
  5576 	TInt scanLineLength = CFbsBitmap::ScanLineLength(256,EColor16MA);
       
  5577 	TUint8* buffer = new TUint8[scanLineLength];
       
  5578 	TEST(buffer != NULL);
       
  5579 	TPtr8 scanline(buffer,scanLineLength,scanLineLength);
       
  5580 	User::LeaveIfError(bmp->Create(TSize(4,4),EColor16MA));
       
  5581 	touchCount = bmp->TouchCount();
       
  5582 	bmp->SetScanLine(scanline, 1);
       
  5583 	newTouchCount = bmp->TouchCount();
       
  5584 	TEST(newTouchCount == touchCount+1);
       
  5585 	TEST(!bmp->IsVolatile());
       
  5586 	delete[] buffer;
       
  5587 	bmp->Reset();
       
  5588 
       
  5589 	// SwapWidthAndHeight
       
  5590 	User::LeaveIfError(bmp->Create(TSize(4,6),EColor16MA));
       
  5591 	touchCount = bmp->TouchCount();
       
  5592 	ret = bmp->SwapWidthAndHeight();
       
  5593 	TEST(ret == KErrNone);
       
  5594 	newTouchCount = bmp->TouchCount();
       
  5595 	TEST(newTouchCount == touchCount+1);
       
  5596 	TEST(!bmp->IsVolatile());
       
  5597 	bmp->Reset();
       
  5598 
       
  5599 	// InternalizeL
       
  5600 	// Requires data to be externalised first
       
  5601 	User::LeaveIfError(bmp->Create(TSize(4,6),EColor16MA));
       
  5602 	touchCount = bmp->TouchCount();
       
  5603 	CDirectFileStore* writestore = CDirectFileStore::ReplaceL(iFs,KTempFilename,EFileStream|EFileWrite);
       
  5604 	TEST(writestore != NULL);
       
  5605 	TUidType uidtype(KDirectFileStoreLayoutUid,KMultiBitmapFileImageUid);
       
  5606 	writestore->SetTypeL(uidtype);
       
  5607 	RStoreWriteStream writestrm;
       
  5608 	TStreamId headerid(0);
       
  5609 	headerid = writestrm.CreateL(*writestore);
       
  5610 	writestore->SetRootL(headerid);
       
  5611 	bmp->ExternalizeL(writestrm);
       
  5612 	writestrm.Close();
       
  5613 	delete writestore;
       
  5614 	bmp->Reset();
       
  5615 	// Now internalise data to reset bitmap.
       
  5616 	CDirectFileStore* readstore = CDirectFileStore::OpenL(iFs,KTempFilename,EFileStream|EFileRead);
       
  5617 	RStoreReadStream readstrm;
       
  5618 	headerid = readstore->Root();
       
  5619 	readstrm.OpenL(*readstore,headerid);
       
  5620 	bmp->InternalizeL(readstrm);
       
  5621 	readstrm.Close();
       
  5622 	delete readstore;
       
  5623 	newTouchCount = bmp->TouchCount();
       
  5624 	TEST(newTouchCount == touchCount+1);
       
  5625 	TEST(!bmp->IsVolatile());
       
  5626 	bmp->Reset();
       
  5627 	
       
  5628 	
       
  5629 	// DataAddress
       
  5630 	// 1. Call as read-only (by passing ETrue into End())
       
  5631 	// Expect: touch count doesn't increase & bitmap not volatile
       
  5632 	User::LeaveIfError(bmp->Create(TSize(4,6),EColor16MA));
       
  5633 	touchCount = bmp->TouchCount();
       
  5634 	bmp->BeginDataAccess();
       
  5635 	bmp->DataAddress(); // ignore returned value for this test.
       
  5636 	bmp->EndDataAccess(ETrue);
       
  5637 	newTouchCount = bmp->TouchCount();
       
  5638 	TEST(newTouchCount == touchCount);
       
  5639 	TEST(!bmp->IsVolatile());
       
  5640 	// 2. Call as writeable  (by passing EFalse into End())
       
  5641 	// Expect: touch count increases & bitmap not volatile
       
  5642 	touchCount = newTouchCount;
       
  5643 	bmp->BeginDataAccess();
       
  5644 	bmp->DataAddress(); // ignore returned value for this test.
       
  5645 	bmp->EndDataAccess(EFalse);
       
  5646 	newTouchCount = bmp->TouchCount();
       
  5647 	TEST(newTouchCount == touchCount+1);
       
  5648 	TEST(!bmp->IsVolatile());
       
  5649 	// 3. Call without Begin/End pairing
       
  5650 	// Expect: bitmap is volatile
       
  5651 	bmp->DataAddress(); // ignore returned value for this test.
       
  5652 	TEST(bmp->IsVolatile());
       
  5653 	bmp->Reset();
       
  5654 
       
  5655 	CleanupStack::PopAndDestroy(bmp);
       
  5656 	}
       
  5657 
       
  5658 //--------------
       
  5659 __CONSTRUCT_STEP__(Bitmap)
       
  5660 
       
  5661 void CTBitmapStep::TestSetupL()
       
  5662 	{
       
  5663 	TheFs.Connect();
       
  5664 	::CopyFilesOnC();
       
  5665 	}
       
  5666 	
       
  5667 void CTBitmapStep::TestClose()
       
  5668 	{
       
  5669 	::DeleteFilesFromC();		//clean up data files used by this test - must be done before call to End() - DEF047652
       
  5670 	TheFs.Close();
       
  5671 	}
       
  5672