graphicsdeviceinterface/directgdi/test/tvgimagecache.cpp
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2007-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 "tvgimagecache.h"
       
    17 #include <graphics/directgdiengine.h>
       
    18 
       
    19 _LIT(KRomBitmap, "z:\\system\\data\\dgdi32bit.mbm");
       
    20 
       
    21 CTVgImageCache::CTVgImageCache()
       
    22 	{
       
    23 	SetTestStepName(KTDirectGdiVgImageCacheStep);
       
    24 	}
       
    25 
       
    26 CTVgImageCache::~CTVgImageCache()
       
    27 	{	
       
    28 	}
       
    29 
       
    30 /**
       
    31 @SYMTestCaseID
       
    32 	GRAPHICS-DIRECTGDI-VGIMAGECACHE-0001
       
    33 
       
    34 @SYMPREQ 
       
    35 	PREQ39
       
    36 
       
    37 @SYMREQ
       
    38 	REQ9195
       
    39 	REQ9201 
       
    40 	REQ9202 
       
    41 	REQ9222 
       
    42 	REQ9223 
       
    43 	REQ9236 
       
    44 	REQ9237
       
    45 
       
    46 @SYMTestCaseDesc
       
    47 	Test entries are added to the cache.
       
    48 
       
    49 @SYMTestStatus
       
    50 	Implemented
       
    51 
       
    52 @SYMTestPriority
       
    53 	High
       
    54 
       
    55 @SYMTestActions
       
    56 	1.	Create bitmaps and bitmap masks.  Blit them so that they are stored in the cache.
       
    57 		Check the VGImages created from the bitmaps are stored in the cache.
       
    58 	2.	Blit the bitmaps again in a different order.
       
    59 		Check the order that the bitmaps are stored in the cache.
       
    60 		
       
    61 @SYMTestExpectedResults
       
    62 	1.	There are entries for each bitmap and bitmap mask.
       
    63 	2.	The bitmaps are stored in the cache in order of most-recently used to least-recently used.
       
    64  */
       
    65 void CTVgImageCache::TestAddEntriesL()
       
    66 	{	
       
    67 	_LIT(KTestName, "Test Bitmaps Are Added To Cache"); 
       
    68 	if(!iRunningOomTests)
       
    69 		{
       
    70 		INFO_PRINTF1(KTestName);
       
    71 		}
       
    72 	CFbsBitmap* romBitmap = new(ELeave) CFbsBitmap;
       
    73 	TInt err = romBitmap->Load(KRomBitmap);
       
    74 	TESTNOERRORL(err);
       
    75 	CleanupStack::PushL(romBitmap);
       
    76 	
       
    77 	TSize bitmapSize(48,48);
       
    78 	TRect bitmapRect(TPoint(0,0), bitmapSize);
       
    79 	CFbsBitmap* bitmap1 = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat,  bitmapSize, TSize (20, 20));
       
    80 	TESTL(bitmap1 != NULL);
       
    81 	CleanupStack::PushL(bitmap1);
       
    82 	CFbsBitmap* bitmap2 = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, bitmapSize, TSize (10, 10));
       
    83 	TESTL(bitmap2 != NULL);
       
    84 	CleanupStack::PushL(bitmap2);
       
    85 	CFbsBitmap* bitmap3 = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, bitmapSize, TSize (8, 8));
       
    86 	TESTL(bitmap3 != NULL);
       
    87 	CleanupStack::PushL(bitmap3);
       
    88 	CFbsBitmap* mask1 = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, bitmapSize, TSize (4, 4));
       
    89 	TESTL(mask1 != NULL);
       
    90 	CleanupStack::PushL(mask1);
       
    91 	CFbsBitmap* mask2 = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, bitmapSize, TSize (2, 2));
       
    92 	TESTL(mask2 != NULL);
       
    93 	CleanupStack::PushL(mask2);
       
    94 
       
    95 	ResetGc();
       
    96 	CleanupStack::PushL(TCleanupItem(ResetCache, iVgImageCache));
       
    97 
       
    98 	iGc->BitBlt(TPoint(0,0), *romBitmap);		
       
    99 	iGc->DrawBitmap(bitmapRect, *bitmap1);
       
   100 	iGc->BitBltMasked(TPoint(0,0), *bitmap2, bitmapRect, *mask1, EFalse);
       
   101 	iGc->DrawBitmapMasked(bitmapRect, *bitmap3, bitmapRect, *mask2, EFalse);
       
   102 	
       
   103 	// Check bitmaps added
       
   104 	TInt numEntries = iVgImageCache->NumEntries();
       
   105 	TEST(numEntries == 6);
       
   106 	// The following tests must leave if they fail,
       
   107 	// otherwise a panic will occur in the ordered cache entry test
       
   108 	TESTL(iVgImageCache->IsInCache(romBitmap->SerialNumber()));
       
   109 	TESTL(iVgImageCache->IsInCache(bitmap1->SerialNumber()));
       
   110 	TESTL(iVgImageCache->IsInCache(bitmap2->SerialNumber()));
       
   111 	TESTL(iVgImageCache->IsInCache(bitmap3->SerialNumber()));
       
   112 	TESTL(iVgImageCache->IsInCache(mask1->SerialNumber()));
       
   113 	TESTL(iVgImageCache->IsInCache(mask2->SerialNumber()));
       
   114 	
       
   115 	//Blit a few more times and check order of items in cache
       
   116 	iGc->BitBlt(TPoint(0,0), *bitmap3);
       
   117 	iGc->BitBlt(TPoint(0,0), *bitmap1);
       
   118 	iGc->BitBlt(TPoint(0,0), *romBitmap);
       
   119 	iGc->BitBlt(TPoint(0,0), *mask2);
       
   120 	iGc->BitBlt(TPoint(0,0), *bitmap2);
       
   121 	
       
   122 	// Expect the most recently used to be at the head of the list
       
   123 	// i.e. bitmap2, mask2, romBitmap, bitmap1, bitmap3, mask1
       
   124 	TInt64* serialNumList = new TInt64[numEntries];
       
   125 	TESTL(serialNumList != NULL);
       
   126 	iVgImageCache->GetOrderedCacheEntries(*serialNumList,numEntries);
       
   127 	TEST(serialNumList[0] == bitmap2->SerialNumber());
       
   128 	TEST(serialNumList[1] == mask2->SerialNumber());
       
   129 	TEST(serialNumList[2] == romBitmap->SerialNumber());
       
   130 	TEST(serialNumList[3] == bitmap1->SerialNumber());
       
   131 	TEST(serialNumList[4] == bitmap3->SerialNumber());
       
   132 	TEST(serialNumList[5] == mask1->SerialNumber());
       
   133 	delete[] serialNumList;
       
   134 
       
   135 	CleanupStack::PopAndDestroy(7, romBitmap);
       
   136 	}
       
   137 
       
   138 /**
       
   139 @SYMTestCaseID
       
   140 	GRAPHICS-DIRECTGDI-VGIMAGECACHE-0002
       
   141 
       
   142 @SYMPREQ 
       
   143 	PREQ39
       
   144 
       
   145 @SYMREQ
       
   146 	REQ9195
       
   147 	REQ9201 
       
   148 	REQ9202 
       
   149 	REQ9222 
       
   150 	REQ9223 
       
   151 	REQ9236 
       
   152 	REQ9237
       
   153 
       
   154 @SYMTestCaseDesc
       
   155 	Test entries are added to the cache.
       
   156 
       
   157 @SYMTestStatus
       
   158 	Implemented
       
   159 
       
   160 @SYMTestPriority
       
   161 	High
       
   162 
       
   163 @SYMTestActions
       
   164 	Create a bitmap.  Blit it so that it is stored in the cache.
       
   165 	Check there is an entry for that bitmap in the cache.
       
   166 	Resize the bitmap (so that the bitmap's touch count is increased).
       
   167 	Blit the bitmap again.
       
   168 	Check the value of the touch count stored in the cache.
       
   169 	
       
   170 @SYMTestExpectedResults
       
   171 	Entry exists for bitmap and touch count value stored in cache
       
   172 	is same as the bitmap after it was resized.
       
   173 
       
   174  */
       
   175 void CTVgImageCache::TestBitmapResizedL()
       
   176 	{	
       
   177 	_LIT(KTestName, "Test That Images In Cache Are Updated When Associated Bitmap Is Resized"); 
       
   178 	if(!iRunningOomTests)
       
   179 		{
       
   180 		INFO_PRINTF1(KTestName);
       
   181 		}
       
   182 	TSize bitmapSize(48,48);
       
   183 	CFbsBitmap* bitmap = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat,  bitmapSize, TSize (8, 8));
       
   184 	TESTL(bitmap != NULL);
       
   185 
       
   186 	ResetGc();
       
   187 
       
   188 	iGc->BitBlt(TPoint(0,0), *bitmap);
       
   189 	TInt64 serialNumber = bitmap->SerialNumber();
       
   190 	// Check bitmaps added
       
   191 	TEST(iVgImageCache->IsInCache(serialNumber));
       
   192 	TInt oldTouchCount = iVgImageCache->TouchCount(serialNumber);
       
   193 	TEST(oldTouchCount == bitmap->TouchCount());
       
   194 	
       
   195 	//Resize bitmap
       
   196 	TESTNOERROR(bitmap->Resize(TSize(80,24)));
       
   197 	iGc->BitBlt(TPoint(0,0), *bitmap);
       
   198 	TEST(iVgImageCache->TouchCount(serialNumber) != oldTouchCount);
       
   199 	TEST(iVgImageCache->TouchCount(serialNumber) == bitmap->TouchCount());
       
   200 
       
   201 	delete bitmap;
       
   202 	iVgImageCache->ResetCache();
       
   203 	}
       
   204 
       
   205 
       
   206 /**
       
   207 @SYMTestCaseID
       
   208 	GRAPHICS-DIRECTGDI-VGIMAGECACHE-0003
       
   209 
       
   210 @SYMPREQ 
       
   211 	PREQ39
       
   212 
       
   213 @SYMREQ
       
   214 	REQ9195
       
   215 	REQ9201 
       
   216 	REQ9202 
       
   217 	REQ9222 
       
   218 	REQ9223 
       
   219 	REQ9236 
       
   220 	REQ9237
       
   221 
       
   222 @SYMTestCaseDesc
       
   223 	Test entries are added to the cache.
       
   224 
       
   225 @SYMTestStatus
       
   226 	Implemented
       
   227 
       
   228 @SYMTestPriority
       
   229 	High
       
   230 
       
   231 @SYMTestActions
       
   232 	Create a bitmap.  Blit it so that it is stored in the cache.
       
   233 	Check there is an entry for that bitmap in the cache.
       
   234 	Swap the width and height of the bitmap (so that the bitmap's touch count is increased).
       
   235 	Blit the bitmap again.
       
   236 	Check the value of the touch count stored in the cache.
       
   237 	
       
   238 @SYMTestExpectedResults
       
   239 	Entry exists for bitmap and touch count value stored in cache
       
   240 	is same as the bitmap after its width and height were swapped.
       
   241 
       
   242  */
       
   243 void CTVgImageCache::TestBitmapSwapWidthAndHeightL()
       
   244 	{	
       
   245 	_LIT(KTestName, "Test That Images In Cache Are Updated When Associated Bitmap Swaps Height and Width"); 
       
   246 	if(!iRunningOomTests)
       
   247 		{
       
   248 		INFO_PRINTF1(KTestName);
       
   249 		}
       
   250 	TSize bitmapSize(40,60);
       
   251 	CFbsBitmap* bitmap = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat,  bitmapSize, TSize (8, 8));
       
   252 	TESTL(bitmap != NULL);
       
   253 
       
   254 	ResetGc();
       
   255 	iVgImageCache->ResetCache();
       
   256 
       
   257 	iGc->BitBlt(TPoint(0,0), *bitmap);
       
   258 	// Check bitmap is added to cache
       
   259 	TEST(iVgImageCache->IsInCache(bitmap->SerialNumber()));
       
   260 	TInt oldTouchCount = bitmap->TouchCount();
       
   261 	TEST(oldTouchCount == iVgImageCache->TouchCount(bitmap->SerialNumber()));
       
   262 	
       
   263 	// Swap width & height of bitmap within a Begin/End bounds
       
   264 	// so that touch count increases
       
   265 	TESTNOERROR(bitmap->SwapWidthAndHeight());
       
   266 	TInt newTouchCount = bitmap->TouchCount();
       
   267 	iGc->BitBlt(TPoint(0,0), *bitmap);
       
   268 	// Check touch count is now different
       
   269 	TEST(newTouchCount != oldTouchCount);
       
   270 	// Expect cache to update entry for bitmap
       
   271 	TEST(iVgImageCache->TouchCount(bitmap->SerialNumber()) == newTouchCount);
       
   272 
       
   273 	delete bitmap;
       
   274 	iVgImageCache->ResetCache();
       
   275 	}
       
   276 
       
   277 /**
       
   278 @SYMTestCaseID
       
   279 	GRAPHICS-DIRECTGDI-VGIMAGECACHE-0004
       
   280 
       
   281 @SYMPREQ 
       
   282 	PREQ39
       
   283 
       
   284 @SYMREQ
       
   285 	REQ9195
       
   286 	REQ9201 
       
   287 	REQ9202 
       
   288 	REQ9222 
       
   289 	REQ9223 
       
   290 	REQ9236 
       
   291 	REQ9237
       
   292 
       
   293 @SYMTestCaseDesc
       
   294 	Test entries are not added to the cache for volatile bitmaps.
       
   295 
       
   296 @SYMTestStatus
       
   297 	Implemented
       
   298 
       
   299 @SYMTestPriority
       
   300 	High
       
   301 
       
   302 @SYMTestActions
       
   303 	Create Font Image Storage. In the cycle request Glyph Image entry for particular Glyph 
       
   304 	code and font ID. 
       
   305 	Delete Glyph Storage.
       
   306 	
       
   307 @SYMTestExpectedResults
       
   308 	No entry exists for the bitmap in the cache.
       
   309 
       
   310  */
       
   311 void CTVgImageCache::TestVolatileBitmapL()
       
   312 	{	
       
   313 	_LIT(KTestName, "Test That Volatile Bitmaps Are not Stored In Cache"); 
       
   314 	if(!iRunningOomTests)
       
   315 		{
       
   316 		INFO_PRINTF1(KTestName);
       
   317 		}
       
   318 	TSize bitmapSize(40,60);
       
   319 	CFbsBitmap* bitmap = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat,  bitmapSize, TSize (8, 8));
       
   320 	TESTL(bitmap != NULL);
       
   321 
       
   322 	ResetGc();
       
   323 	iVgImageCache->ResetCache();
       
   324 
       
   325 	// Make bitmap volatile
       
   326 	bitmap->DataAddress();
       
   327 	iGc->BitBlt(TPoint(0,0), *bitmap);
       
   328 	// Check bitmap is added to cache
       
   329 	TEST(!iVgImageCache->IsInCache(bitmap->SerialNumber()));
       
   330 
       
   331 	delete bitmap;
       
   332 	iVgImageCache->ResetCache();
       
   333 	}
       
   334 
       
   335 /**
       
   336 @SYMTestCaseID
       
   337 	GRAPHICS-DIRECTGDI-VGIMAGECACHE-0005
       
   338 
       
   339 @SYMPREQ 
       
   340 	PREQ39
       
   341 
       
   342 @SYMREQ
       
   343 	REQ9195
       
   344 	REQ9201 
       
   345 	REQ9202 
       
   346 	REQ9222 
       
   347 	REQ9223 
       
   348 	REQ9236 
       
   349 	REQ9237
       
   350 
       
   351 @SYMTestCaseDesc
       
   352 	Test least recently used entries are deleted  when the cache is full and a new entry is added to the cache.
       
   353 
       
   354 @SYMTestStatus
       
   355 	Implemented
       
   356 
       
   357 @SYMTestPriority
       
   358 	High
       
   359 
       
   360 @SYMTestActions
       
   361 	Fill the cache up (by blitting many different bitmaps).
       
   362 	Blit one more bitmap so that the cache has to delete an entry.
       
   363 	Get the driver's MDirectGdiDriverCacheSize extension interface.
       
   364 	Check that a new maximum cache size cannot be set that is smaller
       
   365 	than the existing cache size.
       
   366 	
       
   367 @SYMTestExpectedResults
       
   368 	An entry was deleted and that entry was the least recently used.
       
   369 	A cache size cannot be set that is smaller than the existing cache size.
       
   370  */
       
   371 void CTVgImageCache::TestFullCacheL()
       
   372 	{	
       
   373 	_LIT(KTestName, "Test Adding Image to Cache when Cache is Full"); 
       
   374 	if(!iRunningOomTests)
       
   375 		{
       
   376 		INFO_PRINTF1(KTestName);
       
   377 		}
       
   378 	
       
   379 	ResetGc();
       
   380 	iVgImageCache->ResetCache();
       
   381 	CleanupStack::PushL(TCleanupItem(ResetCache, iVgImageCache));
       
   382 	TInt maxCacheSize = iVgImageCache->MaxCacheSize();
       
   383 
       
   384 	TSize bitmapSize(200,200);
       
   385 	TInt dataStride = CFbsBitmap::ScanLineLength(bitmapSize.iWidth, TDisplayModeMapping::MapPixelFormatToDisplayMode(iTestParams.iSourcePixelFormat));
       
   386 	TInt imageSizeInBytes = bitmapSize.iHeight * dataStride;
       
   387 	TSize checksPerAxis(1,1);
       
   388 	// Create the first bitmap to be added to the cache.
       
   389 	// This is also be the bitmap to be removed from the cache when full.
       
   390 	CFbsBitmap* firstBitmap = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat,  bitmapSize, checksPerAxis);
       
   391 	TESTL(firstBitmap != NULL);
       
   392 	CleanupStack::PushL(firstBitmap);
       
   393 	iGc->BitBlt(TPoint(0,0), *firstBitmap);
       
   394 	TEST(iVgImageCache->IsInCache(firstBitmap->SerialNumber()));
       
   395 
       
   396 	// Fill the cache up.
       
   397 	while(imageSizeInBytes + iVgImageCache->CacheSizeInBytes() < maxCacheSize)
       
   398 		{
       
   399 		CFbsBitmap* bitmap = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat,  bitmapSize, checksPerAxis);
       
   400 		TESTL(bitmap != NULL);
       
   401 		iGc->BitBlt(TPoint(0,0), *bitmap);
       
   402 		delete bitmap;
       
   403 		}
       
   404 	
       
   405 	// Add one more entry to the cache
       
   406 	CFbsBitmap* bitmap = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat,  bitmapSize, checksPerAxis);
       
   407 	TESTL(bitmap != NULL);
       
   408 	TEST(!iVgImageCache->IsInCache(bitmap->SerialNumber()));
       
   409 	TEST(iVgImageCache->IsInCache(firstBitmap->SerialNumber()));
       
   410 	iGc->BitBlt(TPoint(0,0), *bitmap);
       
   411 	
       
   412 	// firstBitmap should now have been removed from the cache as it was the least recently used.
       
   413 	TEST(!iVgImageCache->IsInCache(firstBitmap->SerialNumber()));
       
   414 	// last bitmap should be in cache
       
   415 	TEST(iVgImageCache->IsInCache(bitmap->SerialNumber()));
       
   416 	
       
   417 	// get the driver's MDirectGdiDriverCacheSize extension interface and attempt
       
   418 	// to set the maximum cache size to be smaller than the existing cache size
       
   419 	CDirectGdiDriver* driver = CDirectGdiDriver::Static();
       
   420 	TESTL(driver != NULL);
       
   421 	MDirectGdiDriverCacheSize* driverCacheSize = NULL;
       
   422 	TInt res = driver->GetInterface(TUid::Uid(KDirectGdiDriverCacheSizeUid), (TAny*&)driverCacheSize);
       
   423 	TESTNOERRORL(res);
       
   424 	// save the original cache size
       
   425 	TInt originalCacheSize = driverCacheSize->MaxImageCacheSize();
       
   426 	// setting the cache size to a size smaller than the existing cache should fail
       
   427 	res = driverCacheSize->SetMaxImageCacheSize(iVgImageCache->CacheSizeInBytes()-1);
       
   428 	TEST(res == KErrArgument);	
       
   429 	// setting the cache size to the same size as the existing cache should pass
       
   430 	res = driverCacheSize->SetMaxImageCacheSize(iVgImageCache->CacheSizeInBytes());
       
   431 	TESTNOERROR(res);
       
   432 	TEST(iVgImageCache->CacheSizeInBytes() == driverCacheSize->MaxImageCacheSize());
       
   433 	// reset the original driver cache size
       
   434 	res = driverCacheSize->SetMaxImageCacheSize(originalCacheSize);
       
   435 	TESTNOERROR(res);
       
   436 
       
   437 	delete bitmap;
       
   438 	CleanupStack::PopAndDestroy(firstBitmap);
       
   439 	CleanupStack::PopAndDestroy(iVgImageCache);
       
   440 	}
       
   441 
       
   442 /**
       
   443 @SYMTestCaseID
       
   444 	GRAPHICS-DIRECTGDI-VGIMAGECACHE-0006
       
   445 
       
   446 @SYMPREQ 
       
   447 	PREQ39
       
   448 
       
   449 @SYMREQ
       
   450 	REQ9195
       
   451 	REQ9201 
       
   452 	REQ9202 
       
   453 	REQ9222 
       
   454 	REQ9223 
       
   455 	REQ9236 
       
   456 	REQ9237
       
   457 
       
   458 @SYMTestCaseDesc
       
   459 	Test adding a bitmap larger than maximum size of cache.
       
   460 
       
   461 @SYMTestStatus
       
   462 	Implemented
       
   463 
       
   464 @SYMTestPriority
       
   465 	High
       
   466 
       
   467 @SYMTestActions.
       
   468 	Blit a small bitmap which is added to the cache.
       
   469 	Blit a bitmap whose size in pixels is more than the maximum size of the cache.
       
   470 	
       
   471 @SYMTestExpectedResults
       
   472 	An entry for the large bitmap should not appear in the cache.
       
   473 	An entry for the small bitmap should appear in the cache.
       
   474 
       
   475  */
       
   476 void CTVgImageCache::TestImageLargerThanCacheL()
       
   477 	{	
       
   478 	_LIT(KTestName, "Test Adding Image Larger Than Cache"); 
       
   479 	if(!iRunningOomTests)
       
   480 		{
       
   481 		INFO_PRINTF1(KTestName);
       
   482 		}
       
   483 	
       
   484 	ResetGc();
       
   485 	iVgImageCache->ResetCache();
       
   486 	TInt maxCacheSize = iVgImageCache->MaxCacheSize();
       
   487 	
       
   488 	// Calculate height of bitmap whose width is 512 pixels so that the total size in bytes of the bitmap
       
   489 	// is the same as the maximum cache size.
       
   490 	TInt dataStride = CFbsBitmap::ScanLineLength(512, TDisplayModeMapping::MapPixelFormatToDisplayMode(iTestParams.iSourcePixelFormat));
       
   491 	TInt largeBitmapHeight = maxCacheSize / dataStride;
       
   492 	// Want bitmap with a larger size in bytes than cache,
       
   493 	// so create a bitmap with width of 550 pixels and largeBitmapHeight
       
   494 	TSize largeBitmapSize(550,largeBitmapHeight);
       
   495 
       
   496 	TSize smallBitmapSize(200,200);
       
   497 
       
   498 	TSize checksPerAxis(1,1);
       
   499 
       
   500 	// Create a small bitmap to be added to the cache.
       
   501 	CFbsBitmap* smallBitmap = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat,  smallBitmapSize, checksPerAxis);
       
   502 	TESTL(smallBitmap != NULL);
       
   503 	CleanupStack::PushL(smallBitmap);
       
   504 	// Create large bitmap which is too large to fit in cache
       
   505 	CFbsBitmap* largeBitmap = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat,  largeBitmapSize, checksPerAxis);
       
   506 	TESTL(largeBitmap != NULL);
       
   507 
       
   508 	// Add small bitmap to cache
       
   509 	iGc->BitBlt(TPoint(0,0), *smallBitmap);
       
   510 	TEST(iVgImageCache->IsInCache(smallBitmap->SerialNumber()));
       
   511 
       
   512 	// Blit large bitmap
       
   513 	iGc->BitBlt(TPoint(0,0), *largeBitmap);
       
   514 	TEST(!iVgImageCache->IsInCache(largeBitmap->SerialNumber()));
       
   515 	TEST(iVgImageCache->IsInCache(smallBitmap->SerialNumber()));
       
   516 
       
   517 	delete largeBitmap;
       
   518 	CleanupStack::PopAndDestroy(smallBitmap);
       
   519 	iVgImageCache->ResetCache();
       
   520 	}
       
   521 
       
   522 /**
       
   523 Override of base class virtual
       
   524 @leave Gets system wide error code
       
   525 @return - TVerdict code
       
   526 */
       
   527 TVerdict CTVgImageCache::doTestStepPreambleL()
       
   528 	{			
       
   529 	CTDirectGdiStepBase::doTestStepPreambleL();
       
   530 	return TestStepResult();
       
   531 	}
       
   532 	
       
   533 /** 
       
   534 Override of base class pure virtual
       
   535 Our implementation only gets called if the base class doTestStepPreambleL() did
       
   536 not leave. That being the case, the current test result value will be EPass.
       
   537 @leave Gets system wide error code
       
   538 @return TVerdict code
       
   539 */	
       
   540 TVerdict CTVgImageCache::doTestStepL()
       
   541 	{
       
   542 	if (iUseDirectGdi)
       
   543 		{
       
   544 		// Test independent of target pixel formats, so just use first.
       
   545 		iTestParams.iTargetPixelFormat = iTargetPixelFormatArray[0];
       
   546 		// Test needs a VG compatible source pixel format.
       
   547 		iTestParams.iSourcePixelFormat = EUidPixelFormatRGB_565;
       
   548 		SetTargetL(iTestParams.iTargetPixelFormat);
       
   549 		if (!iUseSwDirectGdi)
       
   550 			{
       
   551 			RunTestsL();
       
   552 			RunOomTestsL();
       
   553 			}
       
   554 		else
       
   555 			{
       
   556 			INFO_PRINTF1(_L("SW DirectGDI has no image cache to test!"));
       
   557 			}
       
   558 
       
   559 		}
       
   560 	else
       
   561 		{
       
   562 		INFO_PRINTF1(_L("BitGDI has no image cache to test!"));
       
   563 		}
       
   564 	return TestStepResult();
       
   565 	}
       
   566 
       
   567 /**
       
   568 Override of base class pure virtual
       
   569 Lists the tests to be run
       
   570 */
       
   571 void CTVgImageCache::RunTestsL()
       
   572 	{
       
   573 	SetTestStepID(_L("GRAPHICS-DIRECTGDI-VGIMAGECACHE-0001"));
       
   574 	TestAddEntriesL();
       
   575 	RecordTestResultL();
       
   576 	SetTestStepID(_L("GRAPHICS-DIRECTGDI-VGIMAGECACHE-0005"));
       
   577 	TestFullCacheL();
       
   578 	RecordTestResultL();
       
   579 	SetTestStepID(_L("GRAPHICS-DIRECTGDI-VGIMAGECACHE-0006"));
       
   580 	TestImageLargerThanCacheL();
       
   581 	RecordTestResultL();
       
   582 	SetTestStepID(_L("GRAPHICS-DIRECTGDI-VGIMAGECACHE-0002"));
       
   583 	TestBitmapResizedL();
       
   584 	RecordTestResultL();
       
   585 	SetTestStepID(_L("GRAPHICS-DIRECTGDI-VGIMAGECACHE-0003"));
       
   586 	TestBitmapSwapWidthAndHeightL();
       
   587 	RecordTestResultL();
       
   588 	SetTestStepID(_L("GRAPHICS-DIRECTGDI-VGIMAGECACHE-0004"));
       
   589 	TestVolatileBitmapL();
       
   590 	RecordTestResultL();
       
   591 	}