fbs/fontandbitmapserver/tfbs/trfile.cpp
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2005-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 #include <f32file.h>
       
    17 #include <fbs.h>
       
    18 #include <bitdev.h>
       
    19 #include <bitstd.h>
       
    20 #include <graphics/gdi/gdiconsts.h>
       
    21 #include "../sfbs/UTILS.H"
       
    22 #include "trfile.h"
       
    23 #include "fbsmessage.h"
       
    24 #include "fbsdefs.h"
       
    25 
       
    26 // Define FBSTEST_SCREENSHOT to save the screen to a .mbm file
       
    27 //#define FBSTEST_SCREENSHOT
       
    28 
       
    29 const TInt KNumBitmap = 3;
       
    30 const TDisplayMode KDisplayMode = EColor64K;
       
    31 const TSize KLargeSize(128,128);
       
    32 const TSize KMidSize(64,64);
       
    33 const TSize KSmallSize(32,32);
       
    34 
       
    35 
       
    36 _LIT(KRamFile1,"c:\\rf1.mbm");
       
    37 _LIT(KRamFile2,"c:\\rf2.mbm");
       
    38 _LIT(KRamFile3,"c:\\rf3.mbm");
       
    39 _LIT(KRamFile4,"c:\\rf123.mbm");
       
    40 _LIT(KRomFile1,"z:\\system\\data\\rf1.mbm");
       
    41 _LIT(KRomFile2,"z:\\system\\data\\rf2.mbm");
       
    42 _LIT(KRomFile3,"z:\\system\\data\\rf3.mbm");
       
    43 _LIT(KRomFile4,"z:\\system\\data\\rf123.mbm");
       
    44 
       
    45 
       
    46 CTFile::CTFile(CTestStep* aStep):
       
    47 	CTGraphicsBase(aStep),
       
    48 	iFbs(NULL),
       
    49 	iSource(KNumBitmap)
       
    50 	{
       
    51 	}
       
    52 
       
    53 CTFile::~CTFile()
       
    54 	{
       
    55 	CleanUp();
       
    56 	if (iShutdownFbs)
       
    57 		iFbs->SendCommand(EFbsMessShutdown);
       
    58 	iFbs->Disconnect();
       
    59 	}
       
    60 	
       
    61 
       
    62 void CTFile::ConstructL()
       
    63 	{
       
    64 	if(RFbsSession::Connect()==KErrNone)
       
    65 		{
       
    66 		RFbsSession::Disconnect();
       
    67 		iShutdownFbs = EFalse;
       
    68 		}
       
    69 	else
       
    70 		{
       
    71 		FbsStartup();
       
    72 		iShutdownFbs = ETrue;
       
    73 		}
       
    74 
       
    75 	TInt ret = RFbsSession::Connect();
       
    76 	TEST(ret==KErrNone);
       
    77 	iFbs = RFbsSession::GetSession();
       
    78 	TEST(iFbs != NULL);
       
    79 
       
    80 	ret = iFs.Connect();
       
    81 	TEST(ret==KErrNone);
       
    82 	// required to allow file handle to be adopted by another process
       
    83 	iFs.ShareProtected();
       
    84 	
       
    85 	TUint32* romAddress = NULL;
       
    86 	if(!CFbsBitmap::IsFileInRom(KRomFile1, romAddress)) //any ROM bitmap
       
    87 		{
       
    88 		INFO_PRINTF2(_L("Skipping ROM bitmap tests since file \"%S\" is reported to not be a ROM bitmap."),
       
    89 				&KRomFile1);
       
    90 		INFO_PRINTF1(_L("This should only occur on non-XIP ROMs, e.g. NAND ROMs, where ROM bitmaps aren't supported."));
       
    91 		iSkipRomBitmapTests = ETrue;
       
    92 		}
       
    93 	}
       
    94 
       
    95 void CTFile::CleanUp()
       
    96 	{
       
    97 	const TBufC<32> names[KNumBitmap] =
       
    98 		{
       
    99 		(const TDesC&)KRamFile1,
       
   100 		(const TDesC&)KRamFile2,
       
   101 		(const TDesC&)KRamFile3
       
   102 		};
       
   103 	TInt i;
       
   104 	for (i=0; i<KNumBitmap; ++i)
       
   105 		{
       
   106 		delete iSource[i];
       
   107 		iFs.Delete(names[i]);
       
   108 		}
       
   109 	iSource.Close();
       
   110 	iFs.Delete(KRamFile4);
       
   111 	iFs.Close();	
       
   112 	}
       
   113 	
       
   114 void CTFile::RunTestCaseL(TInt aCurTestCase)
       
   115 	{
       
   116 	((CTFileStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
       
   117 	switch(aCurTestCase)
       
   118 		{
       
   119 	case 1:
       
   120 		((CTFileStep*)iStep)->SetTestStepID(_L("	GRAPHICS-FBSERV-0588"));
       
   121 		CreateL();
       
   122 		break;
       
   123 	case 2:
       
   124 		((CTFileStep*)iStep)->SetTestStepID(_L("	GRAPHICS-FBSERV-0589"));
       
   125 		SaveL();
       
   126 		break;
       
   127 	case 3:
       
   128 		((CTFileStep*)iStep)->SetTestStepID(_L("	GRAPHICS-FBSERV-0590"));
       
   129 		StoreL();
       
   130 		break;
       
   131 	case 4:
       
   132 		((CTFileStep*)iStep)->SetTestStepID(_L("	GRAPHICS-FBSERV-0591"));
       
   133 		LoadL();
       
   134 		break;
       
   135 	case 5:
       
   136 		((CTFileStep*)iStep)->SetTestStepID(_L("	GRAPHICS-FBSERV-0592"));
       
   137 		LoadAndCompressL();
       
   138 		break;
       
   139 	case 6:
       
   140 		((CTFileStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
   141 		((CTFileStep*)iStep)->CloseTMSGraphicsStep();
       
   142 		TestComplete();
       
   143 		break;
       
   144 		}
       
   145 	((CTFileStep*)iStep)->RecordTestResultL();
       
   146 	}
       
   147 
       
   148 
       
   149 /**
       
   150 	Draw union jack
       
   151 */
       
   152 void CTFile::Draw(CFbsBitGc* aGc, const TSize& aSize)
       
   153 	{
       
   154 	const TSize thick(aSize.iWidth/4,aSize.iWidth/4);
       
   155 	const TSize thin(thick.iWidth/2,thick.iWidth/2);
       
   156 	
       
   157 	// background
       
   158 	aGc->SetBrushColor(KRgbBlue);
       
   159 	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   160 	aGc->SetPenStyle(CGraphicsContext::ESolidPen);
       
   161 	aGc->DrawRect(aSize);
       
   162 
       
   163 	// corner to corner section
       
   164 	aGc->SetPenColor(KRgbWhite);
       
   165 	aGc->SetPenSize(thick);
       
   166 	aGc->DrawLine(TPoint(0,0),TPoint(aSize.iWidth,aSize.iHeight));
       
   167 	aGc->DrawLine(TPoint(aSize.iWidth,0),TPoint(0,aSize.iHeight));	
       
   168 	aGc->SetPenColor(KRgbRed);
       
   169 	aGc->SetPenSize(thin);
       
   170 	aGc->DrawLine(TPoint(0,0),TPoint(aSize.iWidth,aSize.iHeight));
       
   171 	aGc->DrawLine(TPoint(aSize.iWidth,0),TPoint(0,aSize.iHeight));	
       
   172 	
       
   173 	// cross section
       
   174 	aGc->SetPenColor(KRgbWhite);
       
   175 	aGc->SetPenSize(thick);
       
   176 	aGc->DrawLine(TPoint(aSize.iWidth/2,0),TPoint(aSize.iWidth/2,aSize.iHeight));	
       
   177 	aGc->DrawLine(TPoint(0,aSize.iHeight/2),TPoint(aSize.iWidth,aSize.iHeight/2));	
       
   178 	aGc->SetPenColor(KRgbRed);
       
   179 	aGc->SetPenSize(thin);
       
   180 	aGc->DrawLine(TPoint(aSize.iWidth/2,0),TPoint(aSize.iWidth/2,aSize.iHeight));	
       
   181 	aGc->DrawLine(TPoint(0,aSize.iHeight/2),TPoint(aSize.iWidth,aSize.iHeight/2));	
       
   182 	}
       
   183 
       
   184 /**
       
   185 
       
   186 */	
       
   187 /**
       
   188 	@SYMTestCaseID
       
   189 	GRAPHICS-FBSERV-0588
       
   190 
       
   191 	@SYMTestCaseDesc
       
   192 	Create various size bitmap for testing (original bitmaps) 
       
   193 	ie small (<4KB), mid (=4KB) and large (>4KB).
       
   194 	
       
   195 	@SYMTestActions	
       
   196 	
       
   197 	@SYMTestExpectedResults
       
   198 	Test should pass
       
   199 */
       
   200 void CTFile::CreateL()
       
   201 	{
       
   202 	const TSize sizes[KNumBitmap] = 
       
   203 		{
       
   204 		KSmallSize,
       
   205 		KMidSize,
       
   206 		KLargeSize
       
   207 		};
       
   208 	TInt i;
       
   209 	for (i=0; i<KNumBitmap; ++i)
       
   210 		{
       
   211 		CFbsBitmap* bmp = new(ELeave) CFbsBitmap;
       
   212 		CleanupStack::PushL(bmp);
       
   213 		User::LeaveIfError(bmp->Create(sizes[i],KDisplayMode));
       
   214 		
       
   215 		CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(bmp);
       
   216 		CleanupStack::PushL(dev);
       
   217 		
       
   218 		CFbsBitGc* gc;
       
   219 		User::LeaveIfError(dev->CreateContext(gc));
       
   220 		
       
   221 		Draw(gc,sizes[i]);
       
   222 		
       
   223 		delete gc;
       
   224 		CleanupStack::PopAndDestroy(dev);
       
   225 		
       
   226 		iSource.AppendL(bmp);
       
   227 		
       
   228 		CleanupStack::Pop(bmp);
       
   229 		}
       
   230 	}
       
   231 
       
   232 /**
       
   233 	@SYMTestCaseID
       
   234 	GRAPHICS-FBSERV-0589
       
   235 
       
   236 	@SYMTestCaseDesc
       
   237 	Save single bitmap to file using an opened file handle
       
   238 	
       
   239 	@SYMTestActions
       
   240 	Save original bitmap to file using file handle (saved bitmap)
       
   241 	Load saved bitmap using file name and compare against original
       
   242 	Leave saved bitmap files for next test (Load,LoadAndCompress)
       
   243 	
       
   244 	@SYMTestExpectedResults
       
   245 	Saved bitmap match original bitmap
       
   246 */
       
   247 void CTFile::SaveL()
       
   248 	{
       
   249 	const TBufC<32> names[KNumBitmap] =
       
   250 		{
       
   251 		(const TDesC&)KRamFile1,
       
   252 		(const TDesC&)KRamFile2,
       
   253 		(const TDesC&)KRamFile3
       
   254 		};
       
   255 		
       
   256 	INFO_PRINTF1(_L("Saving bitmap"));		
       
   257 	TInt i;
       
   258 	for (i=0; i<KNumBitmap; ++i)
       
   259 		{
       
   260 		RFile f;
       
   261 		TInt mode = EFileWrite;
       
   262 		TInt ret = f.Open(iFs,names[i],mode);
       
   263 		if (ret==KErrNotFound)
       
   264 			ret = f.Create(iFs,names[i],mode);
       
   265 		TEST(ret==KErrNone);
       
   266 		
       
   267 		TEST(iSource[i]->Save(f)==KErrNone);
       
   268 		f.Close();
       
   269 		
       
   270 		CFbsBitmap bmp;
       
   271 		TEST(bmp.Load(names[i])==KErrNone);
       
   272 		
       
   273 		CFbsBitmap* orig = iSource[i];
       
   274 		TSize size = orig->SizeInPixels();
       
   275 		TInt bytes = orig->ScanLineLength(size.iWidth,KDisplayMode)*size.iHeight;
       
   276 		orig->LockHeap();
       
   277 		bmp.LockHeap();
       
   278 		TEST(Mem::Compare((TUint8*)orig->DataAddress(),bytes,(TUint8*)bmp.DataAddress(),bytes)==0);
       
   279 		orig->UnlockHeap();
       
   280 		bmp.UnlockHeap();
       
   281 		}
       
   282 	}
       
   283 
       
   284 /**
       
   285 	@SYMTestCaseID
       
   286 	GRAPHICS-FBSERV-0590
       
   287 
       
   288 	@SYMTestCaseDesc
       
   289 	Save multi bitmaps to file using an opened file handle.
       
   290 	
       
   291 	@SYMTestActions
       
   292 	Save original bitmaps to file (saved bitmaps).
       
   293 	Load saved bitmaps and compare it against originals.
       
   294 	
       
   295 	@SYMTestExpectedResults
       
   296 	Saved bitmaps match original bitmaps
       
   297 */
       
   298 void CTFile::StoreL()
       
   299 	{
       
   300 	const TBufC<32> names[KNumBitmap] =
       
   301 		{
       
   302 		(const TDesC&)KRamFile1,
       
   303 		(const TDesC&)KRamFile2,
       
   304 		(const TDesC&)KRamFile3
       
   305 		};
       
   306 	INFO_PRINTF1(_L("Storing bitmaps"));
       
   307 	RFile f;
       
   308 	TInt mode = EFileWrite;
       
   309 	TInt ret = f.Open(iFs,KRamFile4,mode);
       
   310 	if (ret==KErrNotFound)
       
   311 		ret = f.Create(iFs,KRamFile4,mode);
       
   312 	TEST(ret==KErrNone);
       
   313 	
       
   314 	const TDesC* bmps[] = {&names[0],&names[1],&names[2]};
       
   315 	TInt32 ids[] = {0,0,0};
       
   316 	TRAP(ret,CFbsBitmap::StoreL(f,KNumBitmap,bmps,ids));
       
   317 	TEST(ret==KErrNone);
       
   318 	f.Close();
       
   319 	
       
   320 	TInt id;
       
   321 	for (id=0; id<KNumBitmap; ++id)
       
   322 		{
       
   323 		CFbsBitmap bmp;
       
   324 		TEST(bmp.Load(KRamFile4,id)==KErrNone);
       
   325 		
       
   326 		CFbsBitmap* orig = iSource[id];
       
   327 		TSize size = orig->SizeInPixels();
       
   328 		TInt bytes = orig->ScanLineLength(size.iWidth,KDisplayMode)*size.iHeight;
       
   329 		orig->LockHeap();
       
   330 		bmp.LockHeap();
       
   331 		TEST(Mem::Compare((TUint8*)orig->DataAddress(),bytes,(TUint8*)bmp.DataAddress(),bytes)==0);
       
   332 		orig->UnlockHeap();
       
   333 		bmp.UnlockHeap();
       
   334 		}
       
   335 	}
       
   336 
       
   337 /**
       
   338 	@SYMTestCaseID
       
   339 	GRAPHICS-FBSERV-0591
       
   340 
       
   341 	@SYMTestCaseDesc
       
   342 	Load bitmap from file using an opened file handle.
       
   343 	
       
   344 	@SYMTestActions
       
   345 	Load bitmap using file handle.
       
   346 	Compare loaded bitmaps against original.
       
   347 	
       
   348 	@SYMTestExpectedResults
       
   349 	Loaded bitmap match original
       
   350 */
       
   351 void CTFile::LoadL()
       
   352 	{
       
   353 	// Load single bitmap file
       
   354 	const TBufC<32> names[2*KNumBitmap] =
       
   355 		{
       
   356 		(const TDesC&)KRamFile1, //keep ram files at the top to make it easier to skip rom bitmaps
       
   357 		(const TDesC&)KRamFile2,
       
   358 		(const TDesC&)KRamFile3,
       
   359 		(const TDesC&)KRomFile1,
       
   360 		(const TDesC&)KRomFile2,
       
   361 		(const TDesC&)KRomFile3
       
   362 		};
       
   363 	INFO_PRINTF1(_L("Loading bitmaps"));
       
   364 	TInt i;
       
   365 	TInt maxIndex = (iSkipRomBitmapTests ? KNumBitmap - 1 : 2 * KNumBitmap - 1);
       
   366 	for (i=0; i <= maxIndex; ++i)
       
   367 		{
       
   368 		RFile f;
       
   369 		TInt mode = EFileShareReadersOnly;
       
   370 		TInt ret = f.Open(iFs,names[i],mode);
       
   371 		TEST(ret==KErrNone);
       
   372 		CFbsBitmap bmp;
       
   373 		TEST(bmp.Load(f)==KErrNone);
       
   374 		f.Close();
       
   375 		
       
   376 		CFbsBitmap* orig = iSource[i%KNumBitmap];
       
   377 		TSize size = orig->SizeInPixels();
       
   378 		TInt bytes = orig->ScanLineLength(size.iWidth,KDisplayMode)*size.iHeight;
       
   379 		orig->LockHeap();
       
   380 		bmp.LockHeap();
       
   381 		TEST(Mem::Compare((TUint8*)orig->DataAddress(),bytes,(TUint8*)bmp.DataAddress(),bytes)==0);
       
   382 		orig->UnlockHeap();
       
   383 		bmp.UnlockHeap();
       
   384 		}
       
   385 		
       
   386 	// Load multi bitmap file
       
   387 	const TBufC<32> mbm[] =
       
   388 		{
       
   389 		(const TDesC&)KRamFile4, //keep ram files at the top to make it easier to skip rom bitmaps
       
   390 		(const TDesC&)KRomFile4
       
   391 		};
       
   392 	maxIndex = (iSkipRomBitmapTests ? 0 : 1);
       
   393 	for (i=0; i <= maxIndex; ++i)
       
   394 		{
       
   395 		RFile f;
       
   396 		TInt mode = EFileShareReadersOnly;
       
   397 		TInt ret = f.Open(iFs,mbm[i],mode);
       
   398 		TEST(ret==KErrNone);
       
   399 		TInt id;
       
   400 		for (id=0; id<KNumBitmap; ++id)
       
   401 			{
       
   402 			CFbsBitmap bmp;
       
   403 			TEST(bmp.Load(f,id)==KErrNone);
       
   404 			
       
   405 			CFbsBitmap* orig = iSource[id];
       
   406 			TSize size = orig->SizeInPixels();
       
   407 			TInt bytes = orig->ScanLineLength(size.iWidth,KDisplayMode)*size.iHeight;
       
   408 			orig->LockHeap();
       
   409 			bmp.LockHeap();
       
   410 			TEST(Mem::Compare((TUint8*)orig->DataAddress(),bytes,(TUint8*)bmp.DataAddress(),bytes)==0);
       
   411 			orig->UnlockHeap();
       
   412 			bmp.UnlockHeap();
       
   413 			}
       
   414 		f.Close();
       
   415 		}
       
   416 	}
       
   417 
       
   418 /**
       
   419 	@SYMTestCaseID
       
   420 	GRAPHICS-FBSERV-0592
       
   421 
       
   422 	@SYMTestCaseDesc
       
   423 	Load and compress bitmap from file using an opened file handle.
       
   424 	
       
   425 	@SYMTestActions
       
   426 	Compress original bitmap.
       
   427 	Load and compress bitmap using file handle.
       
   428 	Blit loaded+compressed bitmaps and compressed original to screen.
       
   429 	Compare screen area.
       
   430 	
       
   431 	@SYMTestExpectedResults
       
   432 	LoadAndCompress ROM file return KErrAccessDenied.
       
   433 	Drawn bitmap on screen match.
       
   434 */
       
   435 void CTFile::LoadAndCompressL()
       
   436 	{
       
   437 	INFO_PRINTF1(_L("Loading and compressing bitmaps"));
       
   438 
       
   439 	RFile f;
       
   440 	TInt ret = KErrNone;
       
   441 	if(!iSkipRomBitmapTests)
       
   442 		{
       
   443 		// load and compress ROM file
       
   444 		ret = f.Open(iFs,KRomFile1,EFileShareReadersOnly);
       
   445 		TEST(ret==KErrNone);
       
   446 		CFbsBitmap bmp;
       
   447 		TEST(bmp.LoadAndCompress(f)==KErrAccessDenied);
       
   448 		f.Close();
       
   449 		}
       
   450 
       
   451 	// load single bitmap file
       
   452 	const TBufC<32> names[KNumBitmap] =
       
   453 		{
       
   454 		(const TDesC&)KRamFile1,
       
   455 		(const TDesC&)KRamFile2,
       
   456 		(const TDesC&)KRamFile3
       
   457 		};
       
   458 	TInt i;
       
   459 	for (i=0; i<KNumBitmap; ++i)
       
   460 		{
       
   461 		ret = f.Open(iFs,names[i],EFileShareReadersOnly);
       
   462 		TEST(ret==KErrNone);
       
   463 		CFbsBitmap bmp;
       
   464 		TEST(bmp.LoadAndCompress(f)==KErrNone);
       
   465 		f.Close();
       
   466 		TEST(bmp.IsCompressedInRAM());
       
   467 		
       
   468 		CFbsBitmap* orig = iSource[i];
       
   469 		TEST(orig->Compress()==KErrNone);
       
   470 		TEST(orig->IsCompressedInRAM());
       
   471 
       
   472 		TRAP(ret,BlitAndCompareL(orig,&bmp,orig->SizeInPixels()));
       
   473 		TEST(ret==KErrNone);
       
   474 		}
       
   475 	// Load multi bitmap KRamFile4
       
   476 	ret = f.Open(iFs,KRamFile4,EFileShareReadersOnly);
       
   477 	TEST(ret==KErrNone);
       
   478 	TInt id;
       
   479 	for (id=0; id<KNumBitmap; ++id)
       
   480 		{
       
   481 		CFbsBitmap bmp;
       
   482 		TEST(bmp.LoadAndCompress(f,id)==KErrNone);
       
   483 		TEST(bmp.IsCompressedInRAM());
       
   484 		
       
   485 		CFbsBitmap* orig = iSource[id];
       
   486 		TEST(orig->Compress()==KErrNone);
       
   487 		TEST(orig->IsCompressedInRAM());
       
   488 
       
   489 		TRAP(ret,BlitAndCompareL(orig,&bmp,orig->SizeInPixels()));
       
   490 		TEST(ret==KErrNone);
       
   491 		}
       
   492 	f.Close();
       
   493 	}
       
   494 
       
   495 /**
       
   496 	Blit two bitmap to screen device and compare if both match
       
   497 */
       
   498 void CTFile::BlitAndCompareL(CFbsBitmap* aBmpOrig,CFbsBitmap* aBmpTest,const TSize& aBmpSize)
       
   499 	{
       
   500 	CFbsScreenDevice* scd=NULL;
       
   501 	TRAPD(err,scd=CFbsScreenDevice::NewL(KDefaultScreenNo,KDisplayMode));
       
   502 	if (err!=KErrNone)
       
   503 		{
       
   504 		_LIT(KLog,"Failed to create screen device for mode %S  err=%d");
       
   505 		INFO_PRINTF3(KLog,&ColorModeName(KDisplayMode),err);
       
   506 		}
       
   507 	if (err==KErrNotSupported)
       
   508 		{
       
   509 		TRAPD(err,scd=CFbsScreenDevice::NewL(KDefaultScreenNo,EColor256));
       
   510 		if (err!=KErrNone)
       
   511 			{
       
   512 			_LIT(KLog,"Failed to create Color256 screen device  err=%d");
       
   513 			INFO_PRINTF2(KLog,err);
       
   514 			}
       
   515 		}
       
   516 	if (err==KErrNotSupported)
       
   517 		{
       
   518 		TRAPD(err,scd=CFbsScreenDevice::NewL(KDefaultScreenNo,EColor16MA));
       
   519 		if (err!=KErrNone)
       
   520 			{
       
   521 			_LIT(KLog,"Failed to create Color16MA screen device  err=%d");
       
   522 			INFO_PRINTF2(KLog,err);
       
   523 			}
       
   524 		}
       
   525 	if (err==KErrNotSupported)
       
   526 		{
       
   527 		TRAPD(err,scd=CFbsScreenDevice::NewL(KDefaultScreenNo,EColor16MAP));
       
   528 		if (err!=KErrNone)
       
   529 			{
       
   530 			_LIT(KLog,"Failed to create Color16MA screen device  err=%d");
       
   531 			INFO_PRINTF2(KLog,err);
       
   532 			}
       
   533 		}
       
   534 	_LIT(KLog,"Create screen device with mode %S");
       
   535 	INFO_PRINTF2(KLog,&ColorModeName(scd->DisplayMode()));
       
   536 	CleanupStack::PushL(scd);
       
   537 	scd->ChangeScreenDevice(NULL);
       
   538 	CFbsBitGc* sgc;
       
   539 	User::LeaveIfError(scd->CreateContext((CGraphicsContext*&)sgc)); 
       
   540 	CleanupStack::PushL(sgc);
       
   541 
       
   542 	TSize scrSize = scd->SizeInPixels();
       
   543 	TPoint left(0,0);
       
   544 	TPoint right(scrSize.iWidth/2,0);
       
   545 	TRect bmpRect(TPoint(0,0),aBmpSize);
       
   546 
       
   547 	// if bitmap width is greater than half screen width,
       
   548 	// try positioning right bitmap below original.
       
   549 	if (scrSize.iWidth < aBmpSize.iWidth*2)
       
   550 		{
       
   551 		if (scrSize.iHeight < aBmpSize.iHeight/2)
       
   552 			{
       
   553 			//That still doesn't work out, so restrict size of rect
       
   554 			// being blitted to half screen size.
       
   555 			INFO_PRINTF1(_L("Warning: the whole of the test images may not be compared"));
       
   556 			bmpRect = TRect(TPoint(0,0),TSize(scrSize.iWidth/2,aBmpSize.iHeight));
       
   557 			}
       
   558 		else
       
   559 			{
       
   560 			right = TPoint(0, scrSize.iHeight/2);
       
   561 			}
       
   562 		}
       
   563 	
       
   564 	sgc->BitBlt(left, aBmpOrig, bmpRect);
       
   565 	sgc->BitBlt(right, aBmpTest, bmpRect);
       
   566 	scd->Update();
       
   567 	
       
   568 #ifdef FBSTEST_SCREENSHOT
       
   569 	SaveScreenShotL(scd);
       
   570 #endif //FBSTEST_SCREENSHOT
       
   571 	
       
   572 	TBool match=scd->RectCompare(TRect(left,bmpRect.Size()),*scd,TRect(right,bmpRect.Size()));
       
   573 	if (!match)
       
   574 		{
       
   575 		_LIT(KLog,"Two areas of the screen don't match");
       
   576 		INFO_PRINTF1(KLog);
       
   577 		}
       
   578 	TEST(match);
       
   579 
       
   580 	CleanupStack::PopAndDestroy(2,scd);
       
   581 	}
       
   582 
       
   583 //--------------
       
   584 __CONSTRUCT_STEP__(File)