os/graphics/fbs/fontandbitmapserver/tfbs/textendedbitmaplegacy.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/fbs/fontandbitmapserver/tfbs/textendedbitmaplegacy.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,830 @@
     1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "textendedbitmapcommon.h"
    1.20 +#include "textendedbitmaplegacy.h"
    1.21 +#include "tfbs.h"
    1.22 +#include <s32mem.h> 
    1.23 +#include <bautils.h>
    1.24 +
    1.25 +const TUint8 KTestData[]		= "Extended bitmap test data 123456";
    1.26 +const TInt KTestDataSize		= sizeof(KTestData);
    1.27 +const TInt KTestWidth 			= 50;
    1.28 +const TInt KTestHeight			= 50;
    1.29 +const TSize KSizeInPixels 		= TSize(KTestWidth,KTestHeight);
    1.30 +const TDisplayMode KDisplayMode	= EColor64K;
    1.31 +const TInt KBpp = 2; // 2 bpp for EColor64K
    1.32 +
    1.33 +// Test mbm files used by CTExtendedBitmapLegacy::TestApisThatCallResetL().
    1.34 +// These are used to check the operation of CFbsBitmap::Load() when used with
    1.35 +// extended bitmaps. 
    1.36 +_LIT(KRomBmpFilename, "z:\\system\\data\\rf1.mbm");
    1.37 +_LIT(KRamBitmapFilenameOnZ, "z:\\system\\data\\16RAM2.mbm");
    1.38 +_LIT(KRamBitmapFilename, "c:\\textendedbitmaplegacy_16RAM2.mbm");
    1.39 +
    1.40 +LOCAL_D RFs	TheFs;
    1.41 +
    1.42 +CTExtendedBitmapLegacy::CTExtendedBitmapLegacy(CTestStep* aStep):
    1.43 +	CTFbsBase(aStep, ETrue)
    1.44 +	{
    1.45 +	}
    1.46 +
    1.47 +CTExtendedBitmapLegacy::~CTExtendedBitmapLegacy()
    1.48 +	{	
    1.49 +	((CTExtendedBitmapLegacyStep*)iStep)->CloseTMSGraphicsStep();
    1.50 +	}
    1.51 +
    1.52 +void CTExtendedBitmapLegacy::RunFbsTestL(TInt aCurTestCase)
    1.53 +    {
    1.54 +    ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
    1.55 +	switch(aCurTestCase)
    1.56 +		{
    1.57 +	case 1:
    1.58 +		((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0030"));
    1.59 +		TestDuplicateL();
    1.60 +		break;
    1.61 +	case 2:
    1.62 +		((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0031"));
    1.63 +		TestAccessDeniedL();
    1.64 +		break;
    1.65 +	case 3:
    1.66 +		((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0032"));
    1.67 +		TestNotSupportedL();
    1.68 +		break;
    1.69 +	case 4:
    1.70 +		((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0033"));
    1.71 +		TestTwipsL();		
    1.72 +		break;
    1.73 +	case 5:
    1.74 +		((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0034"));
    1.75 +		TestGettersL();
    1.76 +		break;
    1.77 +	case 6:
    1.78 +		((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0035"));
    1.79 +		TestGetScanLineL();
    1.80 +		break;
    1.81 +	case 7:
    1.82 +		((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0036"));
    1.83 +		TestApisThatCallResetL();
    1.84 +		break;
    1.85 +	case 8:
    1.86 +		((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0037"));
    1.87 +		TestApisThatLeaveL();
    1.88 +		break;
    1.89 +	case 9:
    1.90 +		((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0038"));
    1.91 +		TestNotSupportedNoReturnL();
    1.92 +		break;
    1.93 +	case 10:
    1.94 +		((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0039"));
    1.95 +		TestGetPixelL();
    1.96 +		// Fall through as last test case
    1.97 +	default:
    1.98 +		SetLastTestCase();
    1.99 +		break;
   1.100 +		}
   1.101 +	((CTExtendedBitmapLegacyStep*)iStep)->RecordTestResultL();
   1.102 +    }
   1.103 +   
   1.104 +
   1.105 +/**
   1.106 +@SYMTestCaseID
   1.107 +	GRAPHICS-FBSERV-EXTENDEDBITMAP-0030
   1.108 +
   1.109 +@SYMTestCaseDesc
   1.110 +	Create an extended bitmap then duplicate it by calling CFbsBitmap::Duplicate()
   1.111 +
   1.112 +@SYMPREQ 
   1.113 +	PREQ2096
   1.114 +	
   1.115 +@SYMREQ
   1.116 +	REQ10847
   1.117 +
   1.118 +@SYMTestPriority  
   1.119 +	High
   1.120 +	
   1.121 +@SYMTestStatus 
   1.122 +	Implemented
   1.123 +	
   1.124 +@SYMTestActions
   1.125 +	Create an extended bitmap using test data and test Uid.
   1.126 +	Call Duplicate() on the extended bitmap.
   1.127 +	Retrieves and validates the bitmap size, display mode, Uid, data and data size.
   1.128 +		
   1.129 +@SYMTestExpectedResults
   1.130 +	Extended bitmap created and duplicated and information should match exactly.
   1.131 +*/
   1.132 +void CTExtendedBitmapLegacy::TestDuplicateL()
   1.133 +	{
   1.134 +	INFO_PRINTF1(_L("Duplicate - create a duplicate of an extended bitmap"));
   1.135 +	
   1.136 +	CFbsBitmap* bmp = new(ELeave) CFbsBitmap;
   1.137 +	CleanupStack::PushL(bmp);
   1.138 +	TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize);
   1.139 +	TESTNOERRORL(err);
   1.140 +		
   1.141 +	CFbsBitmap* duplicateBmp = new(ELeave) CFbsBitmap;
   1.142 +	CleanupStack::PushL(duplicateBmp);
   1.143 +	err = duplicateBmp->Duplicate(bmp->Handle());
   1.144 +	TESTNOERRORL(err);
   1.145 +	
   1.146 +	// check that the size, display mode etc are all correct
   1.147 +	TESTSIZEEQUALL(duplicateBmp->SizeInPixels(), KSizeInPixels);
   1.148 +	TESTEQUALL(duplicateBmp->DisplayMode(), KDisplayMode);
   1.149 +	TESTEQUALL(duplicateBmp->DisplayMode(), KDisplayMode);
   1.150 +	TESTEQUALL(duplicateBmp->ExtendedBitmapType(), KUidTestExtendedBitmap);
   1.151 +		
   1.152 +	duplicateBmp->BeginDataAccess();
   1.153 +			
   1.154 +	const TUint8* returnedDataAddress = reinterpret_cast<TUint8*>(duplicateBmp->DataAddress());
   1.155 +	TESTNOTEQUALL(returnedDataAddress, NULL);
   1.156 +	
   1.157 +	// compare the size of the data in the duplicate bitmap with the size of the original data, they should be the same
   1.158 +	TInt returnedDataSize = duplicateBmp->DataSize();
   1.159 +	TESTEQUALL(returnedDataSize, KTestDataSize);
   1.160 +	
   1.161 +	// compare the data returned from the duplicate bitmap with the original data, they should be the same
   1.162 +	TInt res = Mem::Compare(returnedDataAddress, returnedDataSize, KTestData, KTestDataSize);
   1.163 +	TESTEQUALL(res, 0);
   1.164 +	
   1.165 +	duplicateBmp->EndDataAccess(ETrue);	
   1.166 +	
   1.167 +	CleanupStack::PopAndDestroy(2, bmp);	
   1.168 +	}
   1.169 +
   1.170 +/**
   1.171 +@SYMTestCaseID
   1.172 +	GRAPHICS-FBSERV-EXTENDEDBITMAP-0031
   1.173 +
   1.174 +@SYMTestCaseDesc
   1.175 +	Test that all the legacy CFbsBitmap APIs (i.e. APIs that existed before PREQ2096)
   1.176 +	that should return KErrAccessDenied for an extended bitmap do so correctly.
   1.177 +
   1.178 +@SYMPREQ 
   1.179 +	PREQ2096
   1.180 +	
   1.181 +@SYMREQ
   1.182 +	REQ10847
   1.183 +	REQ10856
   1.184 +	REQ10857
   1.185 +	
   1.186 +@SYMTestPriority  
   1.187 +	High
   1.188 +	
   1.189 +@SYMTestStatus 
   1.190 +	Implemented
   1.191 +	
   1.192 +@SYMTestActions
   1.193 +	Create an extended bitmap using test data and test Uid.
   1.194 +	Call all the legacy APIs that should return KErrAccessDenied:
   1.195 +		- Resize()
   1.196 +		- Compress()
   1.197 +		- CompressInBackground()
   1.198 +		- SwapWidthAndHeight()		
   1.199 +		
   1.200 +@SYMTestExpectedResults
   1.201 +	The legacy APIs tested should all return KErrAccessDenied.
   1.202 +*/
   1.203 +void CTExtendedBitmapLegacy::TestAccessDeniedL()
   1.204 +	{
   1.205 +	INFO_PRINTF1(_L("AccessDenied - test legacy CFbsBitmap APIs that should return KErrAccessDenied when used with an extended bitmap"));
   1.206 +		
   1.207 +	CFbsBitmap* bmp = new(ELeave) CFbsBitmap;
   1.208 +	CleanupStack::PushL(bmp);
   1.209 +	TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize);
   1.210 +	TESTNOERRORL(err);
   1.211 +
   1.212 +	INFO_PRINTF1(_L("Resize()"));
   1.213 +	err = bmp->Resize(TSize(100,100));
   1.214 +	TESTEXPECTEDERRORL(err, KErrAccessDenied);
   1.215 +	
   1.216 +	// This covers both versions of Compress() as one calls the other
   1.217 +	INFO_PRINTF1(_L("Compress()"));
   1.218 +	err = bmp->Compress();
   1.219 +	TESTEXPECTEDERRORL(err, KErrAccessDenied);
   1.220 +	
   1.221 +	// This covers both synchronous versions of CompressInBackground() as one calls the other
   1.222 +	INFO_PRINTF1(_L("CompressInBackground()"));
   1.223 +	err = bmp->CompressInBackground();
   1.224 +	TESTEXPECTEDERRORL(err, KErrAccessDenied);
   1.225 +
   1.226 +	// This covers both asynchronous versions of CompressInBackground() as one calls the other
   1.227 +	INFO_PRINTF1(_L("CompressInBackground() (asynchronous)"));
   1.228 +	TRequestStatus requestStatus;
   1.229 +	bmp->CompressInBackground(requestStatus);
   1.230 +	User::WaitForRequest(requestStatus);
   1.231 +	TESTEXPECTEDERRORL(requestStatus.Int(), KErrAccessDenied);
   1.232 +	
   1.233 +	INFO_PRINTF1(_L("SwapWidthAndHeight()"));
   1.234 +	err = bmp->SwapWidthAndHeight();
   1.235 +	TESTEXPECTEDERRORL(err, KErrAccessDenied);	
   1.236 +
   1.237 +	CleanupStack::PopAndDestroy(bmp);
   1.238 +	}
   1.239 +
   1.240 +/**
   1.241 +@SYMTestCaseID
   1.242 +	GRAPHICS-FBSERV-EXTENDEDBITMAP-0032
   1.243 +
   1.244 +@SYMTestCaseDesc
   1.245 +	Test that all the legacy CFbsBitmap APIs (i.e. APIs that existted before PREQ2096)
   1.246 +	that should return KErrNotSupported for an extended bitmap do so correctly, or
   1.247 +	if they have no return value and are not supported that they return cleanly.
   1.248 +
   1.249 +@SYMPREQ 
   1.250 +	PREQ2096
   1.251 +
   1.252 +@SYMREQ
   1.253 +	REQ10847
   1.254 +	REQ10856
   1.255 +	REQ10857
   1.256 +	
   1.257 +@SYMTestPriority  
   1.258 +	High
   1.259 +	
   1.260 +@SYMTestStatus 
   1.261 +	Implemented
   1.262 +	
   1.263 +@SYMTestActions
   1.264 +	Create an extended bitmap using test data and test Uid.
   1.265 +	Call all the legacy APIs that should return KErrNotSupported:		
   1.266 +		- Save()
   1.267 +		- GetPalette()
   1.268 +		- SetDisplayMode()							
   1.269 +		
   1.270 +@SYMTestExpectedResults
   1.271 +	The legacy APIs tested should all return KErrNotSupported where they have return 
   1.272 +	values, they should not cause errors where they are not supported but don't return
   1.273 +	an error value.
   1.274 +*/
   1.275 +void CTExtendedBitmapLegacy::TestNotSupportedL()
   1.276 +	{
   1.277 +	INFO_PRINTF1(_L("NotSupported - test legacy CFbsBitmap APIs that are not supported when used with an extended bitmap"));
   1.278 +		
   1.279 +	CFbsBitmap* bmp = new(ELeave) CFbsBitmap;	
   1.280 +	CleanupStack::PushL(bmp);
   1.281 +	TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize);
   1.282 +	TESTNOERRORL(err);
   1.283 +	
   1.284 +	// Methods that should return KErrNotSupported
   1.285 +	INFO_PRINTF1(_L("Save() - filename"));
   1.286 +	_LIT(KFilename, "C:\\temp.mbm");
   1.287 +	TESTEXPECTEDERRORL(bmp->Save(KFilename), KErrNotSupported);	
   1.288 +	
   1.289 +	INFO_PRINTF1(_L("Save() - RFile"));
   1.290 +	RFile file;
   1.291 +	err = file.Open(TheFs, KFilename, EFileWrite);
   1.292 +	TESTNOERRORL(err);
   1.293 +	CleanupClosePushL(file);
   1.294 +	TESTEXPECTEDERRORL(bmp->Save(file), KErrNotSupported);
   1.295 +	CleanupStack::PopAndDestroy(&file);
   1.296 +	
   1.297 +	INFO_PRINTF1(_L("GetPalette()"));
   1.298 +	CPalette* palette;
   1.299 +	TESTEXPECTEDERRORL(bmp->GetPalette(palette), KErrNotSupported);				
   1.300 +	
   1.301 +	INFO_PRINTF1(_L("SetDisplayMode()"));
   1.302 +	err = bmp->SetDisplayMode(EColor16MU);
   1.303 +	TESTEXPECTEDERRORL(err, KErrNotSupported);
   1.304 +		
   1.305 +			
   1.306 +	CleanupStack::PopAndDestroy(bmp);
   1.307 +	}
   1.308 +
   1.309 +/**
   1.310 +@SYMTestCaseID
   1.311 +	GRAPHICS-FBSERV-EXTENDEDBITMAP-0033
   1.312 +
   1.313 +@SYMTestCaseDesc
   1.314 +	Test that all CFbsBitmap methods that mention Twips work correctly with extended bitmaps.
   1.315 +
   1.316 +@SYMPREQ 
   1.317 +	PREQ2096
   1.318 +	
   1.319 +@SYMREQ
   1.320 +	REQ10847
   1.321 +	REQ10857
   1.322 +	REQ10858
   1.323 +
   1.324 +@SYMTestPriority  
   1.325 +	High
   1.326 +	
   1.327 +@SYMTestStatus 
   1.328 +	Implemented
   1.329 +	
   1.330 +@SYMTestActions
   1.331 +	Create an extended bitmap using test data and test Uid.
   1.332 +	Call all the legacy APIs that mention Twips:
   1.333 +		- SetSizeInTwips()
   1.334 +		- SizeInTwips()
   1.335 +		- HorizontalPixelsToTwips()
   1.336 +		- HorizontalTwipsToPixels()		
   1.337 +		- VerticalPixelsToTwips()
   1.338 +		- VerticalTwipsToPixels()		
   1.339 +		
   1.340 +@SYMTestExpectedResults
   1.341 +	All methods should work correctly with extended bitmaps.
   1.342 +*/
   1.343 +void CTExtendedBitmapLegacy::TestTwipsL()
   1.344 +	{
   1.345 +	INFO_PRINTF1(_L("Twips - test legacy CFbsBitmap Twips APIs work correctly when used with an extended bitmap"));
   1.346 +	const TSize KSizeInTwips(20,30);
   1.347 +		
   1.348 +	CFbsBitmap* bmp = new(ELeave) CFbsBitmap;	
   1.349 +	CleanupStack::PushL(bmp);
   1.350 +	TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize);
   1.351 +	TESTNOERRORL(err);
   1.352 +		
   1.353 +	INFO_PRINTF1(_L("SetSizeInTwips()"));
   1.354 +	bmp->SetSizeInTwips(KSizeInTwips);
   1.355 +	
   1.356 +	INFO_PRINTF1(_L("SizeInTwips()"));
   1.357 +	TESTSIZEEQUALL(bmp->SizeInTwips(), KSizeInTwips);
   1.358 +	
   1.359 +	INFO_PRINTF1(_L("HorizontalPixelsToTwips()"));
   1.360 +	TESTEQUALL(bmp->HorizontalPixelsToTwips(KSizeInPixels.iWidth), KSizeInTwips.iWidth);
   1.361 +	
   1.362 +	INFO_PRINTF1(_L("HorizontalTwipsToPixels()"));
   1.363 +	TESTEQUALL(bmp->HorizontalTwipsToPixels(KSizeInTwips.iWidth), KSizeInPixels.iWidth);
   1.364 +	
   1.365 +	INFO_PRINTF1(_L("VerticalPixelsToTwips()"));
   1.366 +	TESTEQUALL(bmp->VerticalPixelsToTwips(KSizeInPixels.iHeight), KSizeInTwips.iHeight);
   1.367 +	
   1.368 +	INFO_PRINTF1(_L("VerticalTwipsToPixels()"));
   1.369 +	TESTEQUALL(bmp->VerticalTwipsToPixels(KSizeInTwips.iHeight), KSizeInPixels.iHeight);
   1.370 +	
   1.371 +	const TDisplayMode displayMode[] = {EColor256, EColor4K, EColor16M, EColor16MU, EColor64K, 
   1.372 +						   EGray256, EGray16, EGray4, EGray2, EColor16, EColor16MA, EColor16MAP};
   1.373 +	TInt ii = 0;
   1.374 +	err = KErrNotSupported;
   1.375 +	CFbsScreenDevice* scd = NULL;
   1.376 +	for(;(ii<TInt(sizeof(displayMode)/sizeof(displayMode[0]))) && (err == KErrNotSupported);++ii)
   1.377 +		{
   1.378 +		TRAP(err, scd = CFbsScreenDevice::NewL(_L("scdv"),displayMode[ii]));
   1.379 +		}
   1.380 +	if (err != KErrNone)
   1.381 +		{
   1.382 +		_LIT(KLog,"Failed to create screen device %S return value %d");
   1.383 +		INFO_PRINTF3(KLog,&ColorModeName(displayMode[ii]),err);
   1.384 +		}
   1.385 +	else
   1.386 +		{
   1.387 +		_LIT(KLog,"Created Screen Device with mode %S");
   1.388 +		INFO_PRINTF2(KLog,&ColorModeName(displayMode[ii]));
   1.389 +		}
   1.390 +	TESTNOERRORL(err);
   1.391 +	// The size of screen that this is tested on will be different depending on where it is 
   1.392 +	// tested, so just check that this does not cause an error, don't check the result
   1.393 +	INFO_PRINTF1(_L("SetSizeInTwips() (screen device)"));
   1.394 +	bmp->SetSizeInTwips(scd);
   1.395 +	
   1.396 +	delete scd;
   1.397 +	CleanupStack::PopAndDestroy(1, bmp);
   1.398 +	}
   1.399 +
   1.400 +/**
   1.401 +@SYMTestCaseID
   1.402 +	GRAPHICS-FBSERV-EXTENDEDBITMAP-0034
   1.403 +
   1.404 +@SYMTestCaseDesc
   1.405 +	Test the simple getter CFbsBitmap APIs such as Handle().
   1.406 +
   1.407 +@SYMPREQ 
   1.408 +	PREQ2096
   1.409 +	
   1.410 +@SYMREQ
   1.411 +	REQ10847
   1.412 +	REQ10857
   1.413 +	REQ10858
   1.414 +
   1.415 +@SYMTestPriority  
   1.416 +	High
   1.417 +	
   1.418 +@SYMTestStatus 
   1.419 +	Implemented
   1.420 +	
   1.421 +@SYMTestActions
   1.422 +	Create an extended bitmap using test data and test Uid.
   1.423 +	Call the following simple getter APIs:		
   1.424 +		- InitialDisplayMode()
   1.425 +		- IsRomBitmap()
   1.426 +		- Handle()		
   1.427 +		- Header()		
   1.428 +		- IsLargeBitmap()
   1.429 +		- DataStride()
   1.430 +		- HardwareBitmapHandle()		
   1.431 +		- SerialNumber()
   1.432 +		- IsCompressedInRAM()
   1.433 +		- GetAllBitmapHandles()
   1.434 +		
   1.435 +@SYMTestExpectedResults
   1.436 +	No errors should occur.
   1.437 +*/
   1.438 +void CTExtendedBitmapLegacy::TestGettersL()
   1.439 +	{
   1.440 +	INFO_PRINTF1(_L("Test simple getter APIs"));
   1.441 +
   1.442 +	CFbsBitmap* bmp = new(ELeave) CFbsBitmap;		
   1.443 +	CleanupStack::PushL(bmp);
   1.444 +	TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize);
   1.445 +	TESTNOERRORL(err);	
   1.446 +
   1.447 +	INFO_PRINTF1(_L("InitialDisplayMode()"));
   1.448 +	TESTEQUALL(bmp->InitialDisplayMode(), KDisplayMode);
   1.449 +		
   1.450 +	INFO_PRINTF1(_L("IsRomBitmap()"));
   1.451 +	TESTTRUEL(bmp->IsRomBitmap());
   1.452 +	
   1.453 +	INFO_PRINTF1(_L("Handle()"));
   1.454 +	TESTNOTEQUALL(bmp->Handle(), 0);
   1.455 +	
   1.456 +	INFO_PRINTF1(_L("Header()"));
   1.457 +	SEpocBitmapHeader header = bmp->Header();
   1.458 +	TESTSIZEEQUALL(header.iSizeInPixels, KSizeInPixels);
   1.459 +	TESTSIZEEQUALL(header.iSizeInTwips, TSize(0,0));
   1.460 +	TESTEQUALL(header.iBitsPerPixel, 16);
   1.461 +	TESTEQUALL(header.iColor, 1);
   1.462 +	TESTEQUALL(header.iPaletteEntries, 0);
   1.463 +	TESTEQUALL(header.iCompression, EProprietaryCompression);		
   1.464 +	
   1.465 +	INFO_PRINTF1(_L("IsLargeBitmap()"));
   1.466 +	TESTTRUEL(bmp->IsLargeBitmap());
   1.467 +	
   1.468 +	INFO_PRINTF1(_L("DataStride()"));
   1.469 +	TESTEQUALL(bmp->DataStride(), KSizeInPixels.iWidth*KBpp);
   1.470 +	
   1.471 +	INFO_PRINTF1(_L("HardwareBitmapHandle()"));
   1.472 +	TESTEQUALL(bmp->HardwareBitmapHandle(), 0);
   1.473 +	
   1.474 +	INFO_PRINTF1(_L("SerialNumber()"));
   1.475 +	TESTNOTEQUALL(bmp->SerialNumber(), 0);
   1.476 +	
   1.477 +	INFO_PRINTF1(_L("IsCompressedInRAM()"));
   1.478 +	TESTEQUALL(bmp->IsCompressedInRAM(), EFalse);
   1.479 +	
   1.480 +	// The touch count changes for a bitmap (not a ROM bitmap) when it is resized etc, it should not change
   1.481 +	// when Resize() is called on an extended bitmap 
   1.482 +	INFO_PRINTF1(_L("TouchCount()"));
   1.483 +	TESTEQUALL(bmp->TouchCount(), 0);
   1.484 +	bmp->Resize(TSize(100,100));
   1.485 +	TESTEQUALL(bmp->TouchCount(), 0);
   1.486 +	
   1.487 +	// Bitmaps (not ROM bitmaps) become volatile if DataAddress() is called outside BeginDataAccess() and EndDataAccess(),
   1.488 +	// should never be set for extended bitmaps
   1.489 +	INFO_PRINTF1(_L("IsVolatile()"));
   1.490 +	TESTEQUALL(bmp->IsVolatile(), EFalse);
   1.491 +	bmp->DataAddress();
   1.492 +	TESTEQUALL(bmp->IsVolatile(), EFalse);
   1.493 +	
   1.494 +	RArray<TInt> handles;
   1.495 +	CleanupClosePushL(handles);
   1.496 +	INFO_PRINTF1(_L("GetAllBitmapHandles()"));
   1.497 +	TESTNOERRORL(bmp->GetAllBitmapHandles(handles));
   1.498 +	TESTTRUEL(handles.Count() > 0);	
   1.499 +	
   1.500 +	CleanupStack::PopAndDestroy(2, bmp);
   1.501 +	}
   1.502 +
   1.503 +/**
   1.504 +@SYMTestCaseID
   1.505 +	GRAPHICS-FBSERV-EXTENDEDBITMAP-0035
   1.506 +
   1.507 +@SYMTestCaseDesc
   1.508 +	Test GetScanLine with extended bitmaps where no rasterizer is present.
   1.509 +
   1.510 +@SYMPREQ 
   1.511 +	PREQ2096
   1.512 +	
   1.513 +@SYMREQ
   1.514 +	REQ10847
   1.515 +	REQ10857
   1.516 +	REQ10858
   1.517 +
   1.518 +@SYMTestPriority  
   1.519 +	High
   1.520 +	
   1.521 +@SYMTestStatus 
   1.522 +	Implemented
   1.523 +	
   1.524 +@SYMTestActions
   1.525 +	Create an extended bitmap using test data and test Uid that is not supported by a rasterizer.
   1.526 +	Call GetScanLine().		
   1.527 +				
   1.528 +@SYMTestExpectedResults
   1.529 +	GetScanLine() should return a white scanline of the length requested, no errors should occur.
   1.530 +*/
   1.531 +void CTExtendedBitmapLegacy::TestGetScanLineL()
   1.532 +	{
   1.533 +	INFO_PRINTF1(_L("Test CFbsBitmap::GetScanLine() where there is no supported rasterizer for the passed extended bitmap Uid"));
   1.534 +
   1.535 +	CFbsBitmap* bmp = new(ELeave) CFbsBitmap;
   1.536 +	CleanupStack::PushL(bmp);
   1.537 +	TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize);
   1.538 +	TESTNOERRORL(err);
   1.539 +		
   1.540 +	const TInt KScanlineLength = KTestWidth*KBpp;
   1.541 +	TBuf8<KScanlineLength> buf; 
   1.542 +	bmp->GetScanLine(buf, TPoint(0,0), KTestWidth, KDisplayMode);
   1.543 +	TESTEQUALL(buf.Size(), KScanlineLength);
   1.544 +	
   1.545 +	// Check that the scanline has been set to white
   1.546 +	for (TInt i = 0; i < KScanlineLength; i++)
   1.547 +		{		
   1.548 +		TESTEQUALL(buf[i], 255);
   1.549 +		}
   1.550 +	
   1.551 +	CleanupStack::PopAndDestroy(bmp);
   1.552 +	}
   1.553 +
   1.554 +/**
   1.555 +@SYMTestCaseID
   1.556 +	GRAPHICS-FBSERV-EXTENDEDBITMAP-0036
   1.557 +
   1.558 +@SYMTestCaseDesc
   1.559 +	Test an extended bitmap with all of the CFbsBitmap APIs that call Reset().
   1.560 +
   1.561 +@SYMPREQ 
   1.562 +	PREQ2096
   1.563 +	
   1.564 +@SYMREQ
   1.565 +	REQ10847
   1.566 +
   1.567 +@SYMTestPriority  
   1.568 +	High
   1.569 +	
   1.570 +@SYMTestStatus 
   1.571 +	Implemented
   1.572 +	
   1.573 +@SYMTestActions
   1.574 +	For each API:
   1.575 +		- Create an extended bitmap using test data and test Uid that is not supported by a rasterizer.
   1.576 +		- Call the API.
   1.577 +	The following APIs are tested:		
   1.578 +		- Load()
   1.579 +		- LoadAndCompress()
   1.580 +		- Internalize()
   1.581 +		- SetRomBitmapL()
   1.582 +				
   1.583 +@SYMTestExpectedResults
   1.584 +	All APIs tested should complete with no errors, the resultant CFbsBitmap
   1.585 +	should not be an extended bitmap as it will have been reset.
   1.586 +*/
   1.587 +void CTExtendedBitmapLegacy::TestApisThatCallResetL()
   1.588 +	{
   1.589 +	INFO_PRINTF1(_L("Test CFbsBitmap APIs that Call Reset()"));
   1.590 +
   1.591 +	CFbsBitmap* bmp = new(ELeave) CFbsBitmap;
   1.592 +	CleanupStack::PushL(bmp);
   1.593 +	TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize);
   1.594 +	TESTNOERRORL(err);
   1.595 +	TESTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap);
   1.596 +
   1.597 +	INFO_PRINTF1(_L("Load()"));
   1.598 +	err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize);
   1.599 +	TESTNOERRORL(err);
   1.600 +	TESTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should be an extended bitmap again
   1.601 +	TESTNOERRORL(bmp->Load(KRamBitmapFilename));
   1.602 +	TESTNOTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should no longer be an extended bitmap
   1.603 +
   1.604 +	INFO_PRINTF1(_L("LoadAndCompress()"));
   1.605 +	err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize);
   1.606 +	TESTNOERRORL(err);
   1.607 +	TESTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should be an extended bitmap again
   1.608 +	TESTNOERRORL(bmp->LoadAndCompress(KRamBitmapFilename));
   1.609 +	TESTNOTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should no longer be an extended bitmap
   1.610 +
   1.611 +	INFO_PRINTF1(_L("InternalizeL()"));
   1.612 +	CBufFlat* buf = CBufFlat::NewL(512);
   1.613 +	CleanupStack::PushL(buf);
   1.614 +	RBufWriteStream writeStream(*buf,0);
   1.615 +	bmp->ExternalizeL(writeStream); // externalize a normal bitmap
   1.616 +	writeStream.Close();
   1.617 +	err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize);
   1.618 +	TESTNOERRORL(err);
   1.619 +	TESTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should be an extended bitmap again
   1.620 +	RBufReadStream readStream(*buf,0);
   1.621 +	bmp->InternalizeL(readStream);
   1.622 +	readStream.Close();
   1.623 +	TESTNOTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should no longer be an extended bitmap
   1.624 +	
   1.625 +	TUint32* romAddress = NULL;
   1.626 +	if(!CFbsBitmap::IsFileInRom(KRomBmpFilename, romAddress)) //check any rom bitmap
   1.627 +		{
   1.628 +		INFO_PRINTF2(_L("Skipping tests of ROM bitmaps since file \"%S\" is reported to not be a ROM bitmap."), &KRomBmpFilename);
   1.629 +		INFO_PRINTF1(_L("This should only occur on non-XIP ROMs, e.g. NAND ROMs, where ROM bitmaps aren't supported."));		
   1.630 +		}
   1.631 +	else
   1.632 +		{
   1.633 +		INFO_PRINTF1(_L("SetRomBitmapL()"));
   1.634 +		CFbsBitmapEx* romBitmap = new(ELeave) CFbsBitmapEx;
   1.635 +		CleanupStack::PushL(romBitmap);
   1.636 +		INFO_PRINTF2(_L("... attempting to load %S"), &KRomBmpFilename);
   1.637 +		err = romBitmap->Load(KRomBmpFilename);
   1.638 +		TESTNOERRORL(err);
   1.639 +		TInt size = 0;
   1.640 +		INFO_PRINTF1(_L("... calling SetRomBitmapL()"));
   1.641 +		bmp->SetRomBitmapL(romBitmap->BitmapAddress(), size);
   1.642 +		TESTNOTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should no longer be an extended bitmap
   1.643 +		TEST(bmp->SerialNumber() == -TInt64(static_cast<TUint32>(bmp->Handle()))); // A ROM bitmap's handle is its address pointer, its serial number is -ve the address pointer
   1.644 +		
   1.645 +		CleanupStack::PopAndDestroy(1, romBitmap);
   1.646 +		}
   1.647 +	
   1.648 +	CleanupStack::PopAndDestroy(2, bmp);
   1.649 +	}
   1.650 +
   1.651 +/**
   1.652 +@SYMTestCaseID
   1.653 +	GRAPHICS-FBSERV-EXTENDEDBITMAP-0037
   1.654 +
   1.655 +@SYMTestCaseDesc
   1.656 +	Test the CFbsBitmap APIs that should leave when called by an extended bitmap.
   1.657 +
   1.658 +@SYMPREQ 
   1.659 +	PREQ2096
   1.660 +	
   1.661 +@SYMREQ
   1.662 +	REQ10847
   1.663 +	REQ10856
   1.664 +	REQ10857
   1.665 +
   1.666 +@SYMTestPriority  
   1.667 +	High
   1.668 +	
   1.669 +@SYMTestStatus 
   1.670 +	Implemented
   1.671 +	
   1.672 +@SYMTestActions
   1.673 +	For each API:
   1.674 +		- Create an extended bitmap using test data and test Uid that is not supported by a rasterizer.
   1.675 +		- Call the API.
   1.676 +	The following APIs are tested:
   1.677 +		- ExternalizeL()
   1.678 +		- ExternalizeRectangleL()		
   1.679 +				
   1.680 +@SYMTestExpectedResults
   1.681 +	All APIs tested should leave with the error KErrNotSupported.
   1.682 +*/
   1.683 +void CTExtendedBitmapLegacy::TestApisThatLeaveL()
   1.684 +	{
   1.685 +	INFO_PRINTF1(_L("ApisThatLeave - test legacy CFbsBitmap APIs that leave when used with an extended bitmap"));
   1.686 +		
   1.687 +	CFbsBitmap* bmp = new(ELeave) CFbsBitmap;	
   1.688 +	CleanupStack::PushL(bmp);
   1.689 +	TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize);
   1.690 +	TESTNOERRORL(err);
   1.691 +	
   1.692 +	INFO_PRINTF1(_L("ExternalizeL()"));	
   1.693 +	CBufFlat* buf = CBufFlat::NewL(512);
   1.694 +	CleanupStack::PushL(buf);		
   1.695 +	RBufWriteStream writeStream(*buf,0);
   1.696 +	CleanupClosePushL(writeStream);
   1.697 +	TRAP(err, bmp->ExternalizeL(writeStream));
   1.698 +	TESTEXPECTEDERRORL(err, KErrNotSupported);	
   1.699 +		
   1.700 +	INFO_PRINTF1(_L("ExternalizeRectangleL()"));
   1.701 +	RBufWriteStream writeStream2(*buf,0);
   1.702 +	CleanupClosePushL(writeStream2);
   1.703 +	TRAP(err, bmp->ExternalizeRectangleL(writeStream2, TRect(10,10,100,100)));
   1.704 +	TESTEXPECTEDERRORL(err, KErrNotSupported);	
   1.705 +	
   1.706 +	CleanupStack::PopAndDestroy(4, bmp);
   1.707 +	}
   1.708 +
   1.709 +/**
   1.710 +@SYMTestCaseID
   1.711 +	GRAPHICS-FBSERV-EXTENDEDBITMAP-0038
   1.712 +
   1.713 +@SYMTestCaseDesc
   1.714 +	Test that APIs that do not return an error value or leave, yet are not supported
   1.715 +	for extended bitmaps, do not cause an error.
   1.716 +
   1.717 +@SYMPREQ 
   1.718 +	PREQ2096
   1.719 +	
   1.720 +@SYMREQ
   1.721 +	REQ10847
   1.722 +	REQ10856
   1.723 +	REQ10857
   1.724 +
   1.725 +@SYMTestPriority  
   1.726 +	High
   1.727 +	
   1.728 +@SYMTestStatus 
   1.729 +	Implemented
   1.730 +	
   1.731 +@SYMTestActions
   1.732 +	For each API:
   1.733 +		- Create an extended bitmap using test data and test Uid that is not supported by a rasterizer.
   1.734 +		- Call the API.
   1.735 +	The following APIs are tested:
   1.736 +		- PaletteAttributes()
   1.737 +		- SetPalette()		
   1.738 +				
   1.739 +@SYMTestExpectedResults
   1.740 +	All APIs tested should complete with no errors.
   1.741 +*/
   1.742 +void CTExtendedBitmapLegacy::TestNotSupportedNoReturnL()
   1.743 +	{
   1.744 +	INFO_PRINTF1(_L("NotSupportedNoReturn - test legacy CFbsBitmap APIs that are not supported when used with an extended bitmap but do not return errors"));
   1.745 +		
   1.746 +	CFbsBitmap* bmp = new(ELeave) CFbsBitmap;	
   1.747 +	CleanupStack::PushL(bmp);
   1.748 +	TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize);
   1.749 +	TESTNOERRORL(err);
   1.750 +	
   1.751 +	// Methods that are not supported and do not return errors values	
   1.752 +	INFO_PRINTF1(_L("PaletteAttributes()"));
   1.753 +	TBool modifiable;
   1.754 +	TInt numEntries;
   1.755 +	bmp->PaletteAttributes(modifiable, numEntries);
   1.756 +	
   1.757 +	INFO_PRINTF1(_L("SetPalette()"));	
   1.758 +	bmp->SetPalette(NULL);
   1.759 +	
   1.760 +	CleanupStack::PopAndDestroy(bmp);
   1.761 +	}
   1.762 +
   1.763 +/**
   1.764 +@SYMTestCaseID
   1.765 +	GRAPHICS-FBSERV-EXTENDEDBITMAP-0039
   1.766 +
   1.767 +@SYMTestCaseDesc
   1.768 +	Test GetPixel with extended bitmaps where no rasterizer is present 
   1.769 +	that supports the extended bitmap type.
   1.770 +
   1.771 +@SYMCR
   1.772 +	CR1804
   1.773 +
   1.774 +@SYMREQ
   1.775 +	REQ10858
   1.776 +
   1.777 +@SYMTestPriority
   1.778 +	High
   1.779 +
   1.780 +@SYMTestStatus
   1.781 +	Implemented
   1.782 +
   1.783 +@SYMTestActions
   1.784 +	Create an extended bitmap using test data and test Uid that is not supported by a rasterizer.
   1.785 +	Call GetPixel().
   1.786 +
   1.787 +@SYMTestExpectedResults
   1.788 +	GetPixel() should return white pixels at the points requested, no errors should occur.
   1.789 +*/
   1.790 +void CTExtendedBitmapLegacy::TestGetPixelL()
   1.791 +	{
   1.792 +	INFO_PRINTF1(_L("Test CFbsBitmap::GetPixel() where there is no supported rasterizer for the passed extended bitmap Uid"));
   1.793 +
   1.794 +	CFbsBitmap* bmp = new(ELeave) CFbsBitmap;
   1.795 +	CleanupStack::PushL(bmp);
   1.796 +	TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize);
   1.797 +	TESTNOERRORL(err);
   1.798 +
   1.799 +	// Check that the absence of a rasteriser causes legacy off-screen rendering to
   1.800 +	// treat the extended bitmap as if all pixels were white.
   1.801 +	TRgb color;
   1.802 +	for (TInt y = 0; y < KTestHeight; ++y)
   1.803 +		{
   1.804 +		for (TInt x = 0; x < KTestWidth; ++x)
   1.805 +			{
   1.806 +			bmp->GetPixel(color, TPoint(x,y));
   1.807 +			TESTTRUEL(color == KRgbWhite);
   1.808 +			}
   1.809 +		}
   1.810 +
   1.811 +	CleanupStack::PopAndDestroy(bmp);
   1.812 +	}
   1.813 +
   1.814 +__CONSTRUCT_STEP__(ExtendedBitmapLegacy)
   1.815 +
   1.816 +void CTExtendedBitmapLegacyStep::TestSetupL()
   1.817 +	{
   1.818 +	// Copy files needed by the tests to c:
   1.819 +	TheFs.Connect();
   1.820 +	TInt err = BaflUtils::CopyFile(TheFs, KRamBitmapFilenameOnZ, KRamBitmapFilename);
   1.821 +	if (err != KErrNone)
   1.822 +		{
   1.823 +		ERR_PRINTF2(_L("Error copying test mbm file from rom to ram: %d"), err);
   1.824 +		User::Leave(err);
   1.825 +		}
   1.826 +	}
   1.827 +	
   1.828 +void CTExtendedBitmapLegacyStep::TestClose()
   1.829 +	{
   1.830 +	// Delete files used by the tests from c:
   1.831 +	BaflUtils::DeleteFile(TheFs, KRamBitmapFilename);	
   1.832 +	TheFs.Close();
   1.833 +	}