os/graphics/fbs/fontandbitmapserver/tfbs/TStreamIdCache.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
// Epoc includes
sl@0
    17
#include "../inc/FBSMBMC.H"
sl@0
    18
#include "../sfbs/UTILS.H"
sl@0
    19
#include "TStreamIdCache.h"
sl@0
    20
#include "fbsmessage.h"
sl@0
    21
#include "fbsdefs.h"
sl@0
    22
sl@0
    23
//Eikon has 78 bitmaps inside the mbm file(id 0-77)
sl@0
    24
_LIT(KMbmFileEikon, "z:\\System\\Data\\tfbs_file4.mbm");
sl@0
    25
_LIT(KMbmFileEikon2, "z:\\System\\Data\\tfbs_file4a.mbm");
sl@0
    26
_LIT(KMbmFileEikon3, "z:\\System\\Data\\tfbs_file4b.mbm");
sl@0
    27
_LIT(KMbmFileEikon4, "z:\\System\\Data\\tfbs_file4c.mbm");
sl@0
    28
_LIT(KMbmFileEikon5, "z:\\System\\Data\\tfbs_file4d.mbm");
sl@0
    29
//Lafcurs has 28 bitmaps inside the mbm file(id 0-27)
sl@0
    30
_LIT(KMbmFileLafcurs, "z:\\System\\Data\\tfbs_file2.mbm");
sl@0
    31
//Resource file containing mbm file
sl@0
    32
_LIT(KMbmFileTFBSRSC, "z:\\System\\Data\\tfbs_rsc.rsc");
sl@0
    33
_LIT(KRscFileHeader, "z:\\system\\data\\RscHeader3.bin");
sl@0
    34
_LIT(KRscFileData, "z:\\system\\data\\DummyRscFile3.rsc");
sl@0
    35
sl@0
    36
// File with two 1x1 px mbm files: first is black, second is white. white mbm at 72 bytes into file
sl@0
    37
#define WHITE_OFFSET 72
sl@0
    38
_LIT(KBlackAndWhite, "z:\\system\\data\\blackandwhite.mbm");
sl@0
    39
sl@0
    40
// ============================================================================
sl@0
    41
sl@0
    42
//Default Constructor
sl@0
    43
CTStreamIdCache::CTStreamIdCache(CTestStep* aStep):
sl@0
    44
	CTGraphicsBase(aStep),
sl@0
    45
	iFbs(NULL)
sl@0
    46
	{
sl@0
    47
	}
sl@0
    48
sl@0
    49
CTStreamIdCache::~CTStreamIdCache()
sl@0
    50
	{
sl@0
    51
	if(iShutdownFbs)
sl@0
    52
		RFbsSession::GetSession()->SendCommand(EFbsMessShutdown);
sl@0
    53
	RFbsSession::Disconnect();
sl@0
    54
	iFs.Close();
sl@0
    55
	}
sl@0
    56
sl@0
    57
void CTStreamIdCache::ConstructL()
sl@0
    58
	{
sl@0
    59
	if(RFbsSession::Connect()==KErrNone)
sl@0
    60
		{
sl@0
    61
		iShutdownFbs = EFalse;
sl@0
    62
		}
sl@0
    63
	else
sl@0
    64
		{
sl@0
    65
		FbsStartup();
sl@0
    66
		RFbsSession::Connect();
sl@0
    67
		iShutdownFbs = ETrue;
sl@0
    68
		}
sl@0
    69
sl@0
    70
	iFs.Connect();
sl@0
    71
sl@0
    72
	iFbs = RFbsSession::GetSession();
sl@0
    73
	iSessionHandle = iFbs->SessionHandle();
sl@0
    74
	ExpandCleanupStackL();
sl@0
    75
	
sl@0
    76
	INFO_PRINTF1(_L("FBS Bitmap StreamId cache testing"));
sl@0
    77
	}
sl@0
    78
	
sl@0
    79
void CTStreamIdCache::RunTestCaseL(TInt aCurTestCase)
sl@0
    80
	{
sl@0
    81
	((CTStreamIdCacheStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
sl@0
    82
	switch(aCurTestCase)
sl@0
    83
		{
sl@0
    84
	case 1:
sl@0
    85
		((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0577"));
sl@0
    86
		TestStreamIdCacheEntry();
sl@0
    87
		break;
sl@0
    88
	case 2:
sl@0
    89
		((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0578"));
sl@0
    90
		TestProcessingBitmapStream();
sl@0
    91
		break;
sl@0
    92
	case 3:
sl@0
    93
		((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0580"));
sl@0
    94
		TestReplacingFile();
sl@0
    95
		break;
sl@0
    96
	case 4:
sl@0
    97
		((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0579"));
sl@0
    98
		TestComparingStreams();
sl@0
    99
		break;
sl@0
   100
	case 5:
sl@0
   101
		((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0581"));
sl@0
   102
		TestInvalidArgument();
sl@0
   103
		break;
sl@0
   104
	case 6:
sl@0
   105
		((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0582"));
sl@0
   106
		TestOOMCondition();
sl@0
   107
		break;
sl@0
   108
	case 7:
sl@0
   109
		((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0583"));
sl@0
   110
		TestPerformance();
sl@0
   111
		break;
sl@0
   112
	case 8:
sl@0
   113
		((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0584"));
sl@0
   114
		TestLoadAtOffset();
sl@0
   115
		break;
sl@0
   116
	case 9:
sl@0
   117
		((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0509"));
sl@0
   118
		TestSessionClose();
sl@0
   119
		break;
sl@0
   120
	case 10:
sl@0
   121
		((CTStreamIdCacheStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
   122
		((CTStreamIdCacheStep*)iStep)->CloseTMSGraphicsStep();
sl@0
   123
		TestComplete();
sl@0
   124
		break;
sl@0
   125
		}
sl@0
   126
	((CTStreamIdCacheStep*)iStep)->RecordTestResultL();
sl@0
   127
	}
sl@0
   128
	
sl@0
   129
//This function is here to measure the offset in the rsc file
sl@0
   130
TInt CTStreamIdCache::FileSizeL(const TDesC& aFileName)
sl@0
   131
	{
sl@0
   132
	RFile file;
sl@0
   133
	User::LeaveIfError(file.Open(iFs, aFileName, EFileRead));
sl@0
   134
	CleanupClosePushL(file);
sl@0
   135
	TInt size = 0;
sl@0
   136
	User::LeaveIfError(file.Size(size));
sl@0
   137
	CleanupStack::PopAndDestroy(&file);
sl@0
   138
	return size;
sl@0
   139
	}
sl@0
   140
sl@0
   141
void CTStreamIdCache::ExpandCleanupStackL()
sl@0
   142
	{
sl@0
   143
	TInt count=0;
sl@0
   144
	for(;count<10;count++)
sl@0
   145
		CleanupStack::PushL((TUint32*)0x1);
sl@0
   146
	CleanupStack::Pop(count);
sl@0
   147
	}
sl@0
   148
sl@0
   149
/**
sl@0
   150
	@SYMTestCaseID
sl@0
   151
	GRAPHICS-FBSERV-0577
sl@0
   152
sl@0
   153
	@SYMTestCaseDesc
sl@0
   154
	Tests the API functionality of the class  ensuring 
sl@0
   155
	the internal states are correct during the construction 
sl@0
   156
	and other operation.
sl@0
   157
sl@0
   158
	@SYMTestActions
sl@0
   159
	Tests the API on a defaultly built element object.
sl@0
   160
	
sl@0
   161
	@SYMTestExpectedResults
sl@0
   162
	Test should pass
sl@0
   163
*/
sl@0
   164
void CTStreamIdCache::TestStreamIdCacheEntry()
sl@0
   165
	{
sl@0
   166
	INFO_PRINTF1(_L("Test of CFbTopStreamIdCache API"));
sl@0
   167
sl@0
   168
	// Test the API on a defaultly built element object
sl@0
   169
		
sl@0
   170
		CFbTopStreamIdCache* mbmcache=new CFbTopStreamIdCache(20,30,1);
sl@0
   171
		TEST(mbmcache->iEntries.Count() == 0);
sl@0
   172
		TEST(mbmcache->iMaxCacheFilestores == 1);
sl@0
   173
		TEST(mbmcache->iBackwardCacheSize ==30);
sl@0
   174
		TEST(mbmcache->iForwardCacheSize ==20);
sl@0
   175
		
sl@0
   176
		delete mbmcache;
sl@0
   177
sl@0
   178
	}
sl@0
   179
sl@0
   180
/**
sl@0
   181
	@SYMTestCaseID
sl@0
   182
	GRAPHICS-FBSERV-0578
sl@0
   183
sl@0
   184
	@SYMTestCaseDesc
sl@0
   185
	Tests the loading of a bitmap from an mbm file using 
sl@0
   186
	the cache and the content of the cache after the loading 
sl@0
   187
	i.e. how many stream ids are stored, the last bitmap file 
sl@0
   188
	name, the last id, the cache forward and backward size.
sl@0
   189
sl@0
   190
	@SYMTestActions
sl@0
   191
	Tests the GetStreamIdL method. Loads eikon.mbm with 78
sl@0
   192
	bitmap files. Tests loading some rsc file which contains offset.
sl@0
   193
	Tests the flushing.
sl@0
   194
	
sl@0
   195
	@SYMTestExpectedResults
sl@0
   196
	Test should pass
sl@0
   197
*/
sl@0
   198
void CTStreamIdCache::TestProcessingBitmapStream()
sl@0
   199
	{
sl@0
   200
	TInt ret;
sl@0
   201
sl@0
   202
	INFO_PRINTF1(_L("Test loading a bitmap file and processing the stream id"));
sl@0
   203
sl@0
   204
	//Testing the GetStreamIdL method
sl@0
   205
	CFbTopStreamIdCache* mbmcacheptr = new CFbTopStreamIdCache(30,30,1);
sl@0
   206
	CFbTopStreamIdCache& mbmcache = *mbmcacheptr;
sl@0
   207
	INFO_PRINTF1(_L("Loading eikon.mbm with 78 bitmap files"));
sl@0
   208
	//Loading eikon.mbm with 78 bitmap files
sl@0
   209
	RFile file;
sl@0
   210
	ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   211
	TEST(ret==KErrNone);
sl@0
   212
	TRAP(ret,mbmcache.GetStreamIdL(file,KMbmFileEikon,50,0,iSessionHandle));
sl@0
   213
	TEST(ret==KErrNone);
sl@0
   214
	//the cache only stores 30 ids before 50 + max of 30 after(including 50)
sl@0
   215
	//but in this case the bitmap only has 78 bitmaps so it only stores 28 after
sl@0
   216
	TEST(mbmcache.iEntries.Count() == 1);
sl@0
   217
	TEST(mbmcache.iEntries[0]->iStreamIdCount==58);
sl@0
   218
	TEST(mbmcache.iEntries[0]->iLastId==50);
sl@0
   219
	TEST(mbmcache.iForwardCacheSize==30);
sl@0
   220
	TEST(mbmcache.iBackwardCacheSize==30);
sl@0
   221
	TEST(mbmcache.iEntries[0]->iFilename.CompareF(KMbmFileEikon)==0);
sl@0
   222
	TEST(mbmcache.iEntries[0]->iFilestore!=NULL);
sl@0
   223
sl@0
   224
	//Test loading some rsc file which contains offset
sl@0
   225
	TInt mbm_offset = FileSizeL(KRscFileHeader) + FileSizeL(KRscFileData);
sl@0
   226
	ret=file.Open(iFs,KMbmFileTFBSRSC,EFileShareReadersOnly);
sl@0
   227
	TEST(ret==KErrNone);
sl@0
   228
	TRAP(ret,mbmcache.GetStreamIdL(file,KMbmFileTFBSRSC,0,mbm_offset,iSessionHandle));
sl@0
   229
	TEST(ret==KErrNone);
sl@0
   230
	TEST(mbmcache.iEntries.Count() == 1);
sl@0
   231
	TEST(mbmcache.iEntries[0]->iLastId==0);
sl@0
   232
	TEST(mbmcache.iEntries[0]->iStreamIdCount==2);
sl@0
   233
	TEST(mbmcache.iEntries[0]->iFilename.CompareF(KMbmFileTFBSRSC)==0);
sl@0
   234
sl@0
   235
	// Test the flushing
sl@0
   236
	mbmcache.FlushCache();
sl@0
   237
	TEST(mbmcache.iEntries.Count() == 0);
sl@0
   238
	TEST(mbmcache.iMaxCacheFilestores == 1);
sl@0
   239
	TEST(mbmcache.iBackwardCacheSize == 30);
sl@0
   240
	TEST(mbmcache.iForwardCacheSize == 30);
sl@0
   241
sl@0
   242
	delete mbmcacheptr;
sl@0
   243
	}
sl@0
   244
sl@0
   245
/**
sl@0
   246
	@SYMTestCaseID
sl@0
   247
	GRAPHICS-FBSERV-0579
sl@0
   248
sl@0
   249
	@SYMTestCaseDesc
sl@0
   250
	Tests the correct functionality of the cache storing the stream ids. 
sl@0
   251
	Three different caches are used to load the same mbm file but the 
sl@0
   252
	bitmap id to be loaded are different however the bitmap ids are chosen in 
sl@0
   253
	such a way that these three caches will store some common bitmap id. 
sl@0
   254
	We then accessed the cache content and check that these three caches 
sl@0
   255
	will give the same stream id values for that common bitmap id.
sl@0
   256
sl@0
   257
	@SYMTestActions
sl@0
   258
		
sl@0
   259
	@SYMTestExpectedResults
sl@0
   260
	Test should pass
sl@0
   261
*/
sl@0
   262
void CTStreamIdCache::TestComparingStreams()
sl@0
   263
	{
sl@0
   264
	TInt ret;
sl@0
   265
sl@0
   266
	INFO_PRINTF1(_L("Test comparing the stream ids from three different caches"));
sl@0
   267
sl@0
   268
	CFbTopStreamIdCache* cache1=new CFbTopStreamIdCache(30,30,1);
sl@0
   269
	CFbTopStreamIdCache* cache2=new CFbTopStreamIdCache(10,30,1);
sl@0
   270
	CFbTopStreamIdCache* cache3=new CFbTopStreamIdCache(25,5,1);
sl@0
   271
sl@0
   272
	//CACHE1 Loading this will fill up the streams with ids from 0-55
sl@0
   273
	RFile file;
sl@0
   274
	ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   275
	TEST(ret==KErrNone);
sl@0
   276
	TRAP(ret,cache1->GetStreamIdL(file,KMbmFileEikon,25,0,iSessionHandle));
sl@0
   277
	TEST(ret==KErrNone);
sl@0
   278
	TEST(cache1->iEntries.Count() == 1);
sl@0
   279
	TEST(cache1->iEntries[0]->iStreamIdCount==55);
sl@0
   280
	TEST(cache1->iEntries[0]->iLastId==25);
sl@0
   281
	//now storing the actual TStreamId for bitmap id 26 for future comparison
sl@0
   282
	//stream id for bitmapid=26 will be @ the 26th position inside the array
sl@0
   283
	TStreamId id25_26=cache1->iEntries[0]->iStreamIdCache[26];
sl@0
   284
sl@0
   285
	delete cache1;	
sl@0
   286
	
sl@0
   287
	
sl@0
   288
	//CACHE2 Loading this will fill up the streams with ids from 36-65
sl@0
   289
	ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   290
	TEST(ret==KErrNone);
sl@0
   291
	TRAP(ret,cache2->GetStreamIdL(file,KMbmFileEikon,56,0,iSessionHandle));
sl@0
   292
	TEST(ret==KErrNone);
sl@0
   293
	TEST(cache2->iEntries.Count() == 1);
sl@0
   294
	TEST(cache2->iEntries[0]->iStreamIdCount==40);
sl@0
   295
	TEST(cache2->iEntries[0]->iLastId==56);
sl@0
   296
	//stream id for bitmapid=26 will be @ the 0th position inside the array
sl@0
   297
	TStreamId id56_26=cache2->iEntries[0]->iStreamIdCache[0];
sl@0
   298
	TEST(id25_26.Value()==id56_26.Value());
sl@0
   299
	
sl@0
   300
	delete cache2;
sl@0
   301
sl@0
   302
	//CACHE3 Loading this will fill up the streams with ids from 1-30
sl@0
   303
	ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   304
	TEST(ret==KErrNone);
sl@0
   305
	TRAP(ret,cache3->GetStreamIdL(file,KMbmFileEikon,6,0,iSessionHandle));
sl@0
   306
	TEST(ret==KErrNone);
sl@0
   307
	TEST(cache3->iEntries.Count() == 1);
sl@0
   308
	TEST(cache3->iEntries[0]->iStreamIdCount==30);
sl@0
   309
	TEST(cache3->iEntries[0]->iLastId==6);
sl@0
   310
	TStreamId id6_26=cache3->iEntries[0]->iStreamIdCache[25];
sl@0
   311
	TEST(id25_26.Value()==id6_26.Value());
sl@0
   312
sl@0
   313
	delete cache3;
sl@0
   314
	}
sl@0
   315
sl@0
   316
/**
sl@0
   317
	@SYMTestCaseID
sl@0
   318
	GRAPHICS-FBSERV-0580
sl@0
   319
sl@0
   320
	@SYMTestCaseDesc
sl@0
   321
	Tests the functionality of the cache when it has already
sl@0
   322
	stored some existing bitmap ids The cache is loaded with a 
sl@0
   323
	different mbm file and the cache content is examined to make 
sl@0
   324
	sure it has the correct new data.
sl@0
   325
	
sl@0
   326
	@SYMTestActions
sl@0
   327
	
sl@0
   328
	@SYMTestExpectedResults
sl@0
   329
	Test should pass
sl@0
   330
*/
sl@0
   331
void CTStreamIdCache::TestReplacingFile()
sl@0
   332
	{
sl@0
   333
	TInt ret;
sl@0
   334
sl@0
   335
	INFO_PRINTF1(_L("Test loading a file different from previous stored in cache"));
sl@0
   336
sl@0
   337
	CFbTopStreamIdCache* cache1ptr = new CFbTopStreamIdCache(30,30,1);
sl@0
   338
	CFbTopStreamIdCache& cache1 = *cache1ptr;
sl@0
   339
	RFile file;
sl@0
   340
	ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   341
	TEST(ret==KErrNone);
sl@0
   342
	TRAP(ret,cache1.GetStreamIdL(file,KMbmFileEikon,25,0,iSessionHandle));
sl@0
   343
	TEST(ret==KErrNone);
sl@0
   344
	TEST(cache1.iEntries.Count() == 1);
sl@0
   345
	TEST(cache1.iEntries[0]->iStreamIdCount==55);
sl@0
   346
	TEST(cache1.iEntries[0]->iLastId==25);
sl@0
   347
	TEST(cache1.iEntries[0]->iFilename.Compare(KMbmFileEikon)==0);
sl@0
   348
sl@0
   349
	//Now trying to load an entirely different bitmap file
sl@0
   350
	//and check to ensure the cache has reflushed itself
sl@0
   351
	//and load itself with new stuff
sl@0
   352
	ret=file.Open(iFs,KMbmFileLafcurs,EFileShareReadersOnly);
sl@0
   353
	TEST(ret==KErrNone);
sl@0
   354
	TRAP(ret,cache1.GetStreamIdL(file,KMbmFileLafcurs,12,0,iSessionHandle));
sl@0
   355
	TEST(ret==KErrNone);
sl@0
   356
	TEST(cache1.iEntries.Count() == 1);
sl@0
   357
	TEST(cache1.iEntries[0]->iStreamIdCount==28);
sl@0
   358
	TEST(cache1.iEntries[0]->iLastId==12);
sl@0
   359
	TEST(cache1.iEntries[0]->iFilename.Compare(KMbmFileLafcurs)==0);
sl@0
   360
sl@0
   361
	delete cache1ptr;
sl@0
   362
	}
sl@0
   363
sl@0
   364
/**
sl@0
   365
	@SYMTestCaseID
sl@0
   366
	GRAPHICS-FBSERV-0581
sl@0
   367
sl@0
   368
	@SYMTestCaseDesc
sl@0
   369
	Tests the error values that would be returned by
sl@0
   370
	the cache when supplied with invalid arguments such 
sl@0
   371
	as bad file name  negative bitmap ids, out of range 
sl@0
   372
	bitmap ids, and invalid file offset.
sl@0
   373
sl@0
   374
	@SYMDEF INC047122 INC046632
sl@0
   375
sl@0
   376
	@SYMTestActions
sl@0
   377
	Creates an FbTopStreamIdCache object. Tests to ensure the cache 
sl@0
   378
	can deal with non error cases immediately after error cases.
sl@0
   379
	Passing an in bound bitmap id. Passing an out of bound bitmap id.
sl@0
   380
	Passing an in bound bitmap id. Passing an out of bound bitmap id.
sl@0
   381
	Passing an in bound bitmap id. Passing negative bitmap id.
sl@0
   382
	Passing an invalid file name. Passing an invalid file offset.
sl@0
   383
		
sl@0
   384
	@SYMTestExpectedResults
sl@0
   385
	Test should pass
sl@0
   386
*/
sl@0
   387
void CTStreamIdCache::TestInvalidArgument()
sl@0
   388
	{
sl@0
   389
	
sl@0
   390
	TInt ret;
sl@0
   391
sl@0
   392
	INFO_PRINTF1(_L("Test loading a file bitmap with invalid argument"));
sl@0
   393
sl@0
   394
	CFbTopStreamIdCache* cache1ptr = new CFbTopStreamIdCache(30,30,1);
sl@0
   395
	CFbTopStreamIdCache& cache1 = *cache1ptr;
sl@0
   396
	//Eikon mbm only can accept ids from 0-77
sl@0
   397
sl@0
   398
	//The following sequence of 4 tests ensures the cache can deal with
sl@0
   399
	//non error cases immediately after error cases.
sl@0
   400
sl@0
   401
	//Passing an in bound bitmap id
sl@0
   402
	RFile file;
sl@0
   403
	ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   404
	TEST(ret==KErrNone);
sl@0
   405
	TRAP(ret,cache1.GetStreamIdL(file,KMbmFileEikon,0,0,iSessionHandle));
sl@0
   406
	TEST(ret==KErrNone);
sl@0
   407
sl@0
   408
	//Passing an out of bound bitmap id
sl@0
   409
	ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   410
	TEST(ret==KErrNone);
sl@0
   411
	TRAP(ret,cache1.GetStreamIdL(file,KMbmFileEikon,78,0,iSessionHandle));
sl@0
   412
	TEST(ret==KErrEof);
sl@0
   413
sl@0
   414
	//Passing an in bound bitmap id
sl@0
   415
	ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   416
	TEST(ret==KErrNone);
sl@0
   417
	TRAP(ret,cache1.GetStreamIdL(file,KMbmFileEikon,74,0,iSessionHandle));
sl@0
   418
	TEST(ret==KErrNone);
sl@0
   419
	
sl@0
   420
	//Passing an out of bound bitmap id
sl@0
   421
	ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   422
	TEST(ret==KErrNone);
sl@0
   423
	TRAP(ret,cache1.GetStreamIdL(file,KMbmFileEikon,78,0,iSessionHandle));
sl@0
   424
	TEST(ret==KErrEof);
sl@0
   425
	
sl@0
   426
	//Passing an in bound bitmap id
sl@0
   427
	ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   428
	TEST(ret==KErrNone);
sl@0
   429
	TRAP(ret,cache1.GetStreamIdL(file,KMbmFileEikon,77,0,iSessionHandle));
sl@0
   430
   	TEST(ret==KErrNone);
sl@0
   431
sl@0
   432
sl@0
   433
	//Passing negative bitmap id
sl@0
   434
	ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   435
	TEST(ret==KErrNone);
sl@0
   436
	TRAP(ret,cache1.GetStreamIdL(file,KMbmFileEikon,-1,0,iSessionHandle));
sl@0
   437
	TEST(ret==KErrEof);
sl@0
   438
sl@0
   439
	//Passing an invalid file name
sl@0
   440
	ret=file.Open(iFs,_L("invalid.mbm"),EFileShareReadersOnly);
sl@0
   441
	cache1.FlushCache();
sl@0
   442
	TEST((ret==KErrNotFound)||(ret==KErrPathNotFound));
sl@0
   443
sl@0
   444
	//Passing an invalid file offset
sl@0
   445
	ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   446
	TEST(ret==KErrNone);
sl@0
   447
	TRAP(ret,cache1.GetStreamIdL(file,KMbmFileEikon,12,10,iSessionHandle));
sl@0
   448
	TEST(ret==KErrNotSupported);
sl@0
   449
	
sl@0
   450
	//Tests for INC047122 and INC046632
sl@0
   451
	TInt err(KErrNone);
sl@0
   452
	TInt id(0);
sl@0
   453
	for (; id<100; id++)
sl@0
   454
		{
sl@0
   455
		err=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   456
		TEST(err==KErrNone);
sl@0
   457
		TRAP(err,cache1.GetStreamIdL(file,KMbmFileEikon,id,0,iSessionHandle));
sl@0
   458
		if(err != KErrNone)
sl@0
   459
			break;
sl@0
   460
		}
sl@0
   461
	TEST(id==78);
sl@0
   462
	INFO_PRINTF2(_L("Starting from 0 the number of bitmaps in KMbmFileEikon is calculated to be %d\n\n"), id);
sl@0
   463
sl@0
   464
	delete cache1ptr;
sl@0
   465
sl@0
   466
	// New cache, start from Id 50
sl@0
   467
	CFbTopStreamIdCache* cache2ptr = new CFbTopStreamIdCache(30,30,1);
sl@0
   468
	CFbTopStreamIdCache& cache2 = *cache2ptr;
sl@0
   469
	for (id=50,	err=KErrNone; id<100; id++)
sl@0
   470
		{
sl@0
   471
		err=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   472
		TEST(err==KErrNone);
sl@0
   473
		TRAP(err,cache2.GetStreamIdL(file,KMbmFileEikon,id,0,iSessionHandle));
sl@0
   474
		if(err != KErrNone)
sl@0
   475
			break;
sl@0
   476
		}
sl@0
   477
	TEST(id==78);
sl@0
   478
	INFO_PRINTF2(_L("Starting from 50 the number of bitmaps in KMbmFileEikon is calculated to be %d\n\n"), id);
sl@0
   479
sl@0
   480
	delete cache2ptr;
sl@0
   481
	}
sl@0
   482
sl@0
   483
/**
sl@0
   484
	@SYMTestCaseID
sl@0
   485
	GRAPHICS-FBSERV-0582
sl@0
   486
sl@0
   487
	@SYMTestCaseDesc
sl@0
   488
	Tests the out of memory condition during memory 
sl@0
   489
	allocation inside the test function GetStreamIdL
sl@0
   490
	to ensure that there is no memory leaks.
sl@0
   491
sl@0
   492
	@SYMTestActions
sl@0
   493
	Tests the cache by opening a file and calls GetStreamIdL
sl@0
   494
	and checks the heap for memory leaks. Tests the cache
sl@0
   495
	for a cache hit. Test the cache for a cache miss.
sl@0
   496
	
sl@0
   497
	@SYMTestExpectedResults
sl@0
   498
	Test should pass
sl@0
   499
*/
sl@0
   500
void CTStreamIdCache::TestOOMCondition()
sl@0
   501
	{
sl@0
   502
	INFO_PRINTF1(_L("Test of CFbTopStreamIdCache OOM"));
sl@0
   503
	
sl@0
   504
	// Test a cache for the first time
sl@0
   505
	for (TInt count = 1; ; count++)
sl@0
   506
        {
sl@0
   507
        __UHEAP_MARK;
sl@0
   508
		CFbTopStreamIdCache* cache=new CFbTopStreamIdCache(30,30,1);
sl@0
   509
		
sl@0
   510
		__UHEAP_SETFAIL(RHeap::EDeterministic,count);
sl@0
   511
		RFile file;
sl@0
   512
		TInt ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   513
		TEST(ret==KErrNone);
sl@0
   514
		TRAP(ret,cache->GetStreamIdL(file,KMbmFileEikon,30,0,iSessionHandle));
sl@0
   515
		__UHEAP_RESET;
sl@0
   516
		
sl@0
   517
	    delete cache;
sl@0
   518
	    __UHEAP_MARKEND;
sl@0
   519
		
sl@0
   520
		if (ret==KErrNone)
sl@0
   521
			break;
sl@0
   522
		TEST(ret==KErrNoMemory);
sl@0
   523
		}
sl@0
   524
sl@0
   525
	// Test a cache hit
sl@0
   526
	for (TInt count = 1; ; count++)
sl@0
   527
        {
sl@0
   528
        __UHEAP_MARK;
sl@0
   529
		CFbTopStreamIdCache* cache=new CFbTopStreamIdCache(30,30,1);
sl@0
   530
		
sl@0
   531
		RFile file1;
sl@0
   532
		TInt ret=file1.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   533
		TEST(ret==KErrNone);
sl@0
   534
		TRAP(ret,cache->GetStreamIdL(file1,KMbmFileEikon,30,0,iSessionHandle));
sl@0
   535
		TEST(ret==KErrNone);		
sl@0
   536
sl@0
   537
		__UHEAP_SETFAIL(RHeap::EDeterministic,count);
sl@0
   538
		RFile file;
sl@0
   539
		ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   540
		TEST(ret==KErrNone);
sl@0
   541
		TRAP(ret,cache->GetStreamIdL(file,KMbmFileEikon,30,0,iSessionHandle));
sl@0
   542
		__UHEAP_RESET;
sl@0
   543
		
sl@0
   544
	    delete cache;
sl@0
   545
	   	__UHEAP_MARKEND;
sl@0
   546
	   	
sl@0
   547
		if (ret==KErrNone)
sl@0
   548
			break;
sl@0
   549
		TEST(ret==KErrNoMemory);
sl@0
   550
		}
sl@0
   551
sl@0
   552
	// Test a cache miss
sl@0
   553
	for (TInt count = 1; ; count++)
sl@0
   554
        {
sl@0
   555
        __UHEAP_MARK;
sl@0
   556
		CFbTopStreamIdCache* cache=new CFbTopStreamIdCache(30,30,1);
sl@0
   557
		
sl@0
   558
		RFile file1;
sl@0
   559
		TInt ret=file1.Open(iFs,KMbmFileLafcurs,EFileShareReadersOnly);
sl@0
   560
		TEST(ret==KErrNone);
sl@0
   561
		TRAP(ret,cache->GetStreamIdL(file1,KMbmFileLafcurs,0,0,iSessionHandle));
sl@0
   562
		TEST(ret==KErrNone);		
sl@0
   563
sl@0
   564
		__UHEAP_SETFAIL(RHeap::EDeterministic,count);
sl@0
   565
		RFile file;
sl@0
   566
		ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   567
		TEST(ret==KErrNone);
sl@0
   568
		TRAP(ret,cache->GetStreamIdL(file,KMbmFileEikon,30,0,iSessionHandle));
sl@0
   569
		__UHEAP_RESET;
sl@0
   570
		
sl@0
   571
	    delete cache;
sl@0
   572
	   	__UHEAP_MARKEND;
sl@0
   573
	   	
sl@0
   574
		if (ret==KErrNone)
sl@0
   575
			{
sl@0
   576
			__UHEAP_SETFAIL(RHeap::ENone,count);
sl@0
   577
			break;
sl@0
   578
			}
sl@0
   579
		TEST(ret==KErrNoMemory);
sl@0
   580
		}
sl@0
   581
	}
sl@0
   582
sl@0
   583
/**
sl@0
   584
	@SYMTestCaseID
sl@0
   585
	GRAPHICS-FBSERV-0583
sl@0
   586
sl@0
   587
	@SYMTestCaseDesc
sl@0
   588
	This test is used to measure the performance improvement 
sl@0
   589
	when the font bitmap server is using a cache to store the 
sl@0
   590
	stream ids.
sl@0
   591
sl@0
   592
	@SYMTestActions
sl@0
   593
	Starts the timing. Gets the current time. Creates a FbsBitmap
sl@0
   594
	on the heap. Simulates loading during boot time by loading
sl@0
   595
	bitmaps from ROM. Does forward testing before optimised duration.
sl@0
   596
	Retreives the current time and calculates the time taken by the tests.
sl@0
   597
	Does forward testing after optimised duration. Does backward testing
sl@0
   598
	before optimised duration. Does backward testing after optimised duration.
sl@0
   599
	
sl@0
   600
	@SYMTestExpectedResults
sl@0
   601
	Test should pass
sl@0
   602
*/
sl@0
   603
void CTStreamIdCache::TestPerformance()
sl@0
   604
	{
sl@0
   605
	//Start the timing
sl@0
   606
	TTime starttime;
sl@0
   607
	starttime.UniversalTime();
sl@0
   608
sl@0
   609
	CFbsBitmap* bitmap=new (ELeave) CFbsBitmap;
sl@0
   610
	TInt ret;
sl@0
   611
	//simulating loading during boottime
sl@0
   612
	TInt i,j;
sl@0
   613
	for (i=0;i<30;i++)
sl@0
   614
		{
sl@0
   615
		for (j=0;j<10;j++)
sl@0
   616
			{
sl@0
   617
			ret=bitmap->Load(KMbmFileEikon,j,EFalse);
sl@0
   618
			TEST(ret==KErrNone);
sl@0
   619
			}
sl@0
   620
		for (j=0;j<2;j++)
sl@0
   621
			{
sl@0
   622
			ret=bitmap->Load(_L("z:\\system\\data\\tfbs.mbm"),j,EFalse);
sl@0
   623
			TEST(ret==KErrNone);
sl@0
   624
			}
sl@0
   625
		for (j=0;j<28;j++)
sl@0
   626
			{
sl@0
   627
			ret=bitmap->Load(KMbmFileLafcurs,j,EFalse);
sl@0
   628
			TEST(ret==KErrNone);
sl@0
   629
			}
sl@0
   630
		for (j=71;j<73;j++)
sl@0
   631
			{
sl@0
   632
			ret=bitmap->Load(KMbmFileEikon,j,EFalse);
sl@0
   633
			TEST(ret==KErrNone);
sl@0
   634
			}
sl@0
   635
		for (j=0;j<2;j++)
sl@0
   636
			{
sl@0
   637
			ret=bitmap->Load(_L("z:\\system\\data\\tfbs.mbm"),j,EFalse);
sl@0
   638
			TEST(ret==KErrNone);
sl@0
   639
			}
sl@0
   640
		for (j=20;j<22;j++)
sl@0
   641
			{
sl@0
   642
			ret=bitmap->Load(KMbmFileLafcurs,j,EFalse);
sl@0
   643
			TEST(ret==KErrNone);
sl@0
   644
			}
sl@0
   645
		}
sl@0
   646
	
sl@0
   647
	TTime endtime;
sl@0
   648
	endtime.UniversalTime();
sl@0
   649
	INFO_PRINTF1(_L("Forward Testing Before optimised duration= 3515625 microseconds \n"));
sl@0
   650
	TTimeIntervalMicroSeconds difftime=endtime.MicroSecondsFrom(starttime);
sl@0
   651
	INFO_PRINTF2(_L("Forward Testing After optimised duration=%Ld  microseconds\n\n"),difftime.Int64());
sl@0
   652
sl@0
   653
	starttime.UniversalTime();
sl@0
   654
	for (i=0;i<30;i++)
sl@0
   655
		{
sl@0
   656
		for (j=10;j>=0;j--)
sl@0
   657
			{
sl@0
   658
			ret=bitmap->Load(KMbmFileEikon,j,EFalse);
sl@0
   659
			TEST(ret==KErrNone);
sl@0
   660
			}
sl@0
   661
		for (j=1;j>=0;j--)
sl@0
   662
			{
sl@0
   663
			ret=bitmap->Load(_L("z:\\system\\data\\tfbs.mbm"),j,EFalse);
sl@0
   664
			TEST(ret==KErrNone);
sl@0
   665
			}
sl@0
   666
		for (j=27;j>=0;j--)
sl@0
   667
			{
sl@0
   668
			ret=bitmap->Load(KMbmFileLafcurs,j,EFalse);
sl@0
   669
			TEST(ret==KErrNone);
sl@0
   670
			}
sl@0
   671
		for (j=73;j>=72;j--)
sl@0
   672
			{
sl@0
   673
			ret=bitmap->Load(KMbmFileEikon,j,EFalse);
sl@0
   674
			TEST(ret==KErrNone);
sl@0
   675
			}
sl@0
   676
		for (j=1;j>=0;j--)
sl@0
   677
			{
sl@0
   678
			ret=bitmap->Load(_L("z:\\system\\data\\tfbs.mbm"),j,EFalse);
sl@0
   679
			TEST(ret==KErrNone);
sl@0
   680
			}
sl@0
   681
		for (j=22;j>=20;j--)
sl@0
   682
			{
sl@0
   683
			ret=bitmap->Load(KMbmFileLafcurs,j,EFalse);
sl@0
   684
			TEST(ret==KErrNone);
sl@0
   685
			}
sl@0
   686
		}	
sl@0
   687
	endtime.UniversalTime();
sl@0
   688
	difftime=endtime.MicroSecondsFrom(starttime);
sl@0
   689
	INFO_PRINTF1(_L("Backward Testing Before optimised duration= 3515625 microseconds \n"));
sl@0
   690
	INFO_PRINTF2(_L("Backward Testing After optimised duration=%Ld  microseconds\n\n"),difftime.Int64());
sl@0
   691
sl@0
   692
	starttime.UniversalTime();
sl@0
   693
	for (i=0;i<30;i++)
sl@0
   694
		{
sl@0
   695
		for (j=40;j<70;j++)
sl@0
   696
			{
sl@0
   697
			ret=bitmap->Load(KMbmFileEikon,j,EFalse);
sl@0
   698
			TEST(ret==KErrNone);
sl@0
   699
			ret=bitmap->Load(KMbmFileEikon2,j,EFalse);
sl@0
   700
			TEST(ret==KErrNone);
sl@0
   701
			ret=bitmap->Load(KMbmFileEikon3,j,EFalse);
sl@0
   702
			TEST(ret==KErrNone);
sl@0
   703
			ret=bitmap->Load(KMbmFileEikon4,j,EFalse);
sl@0
   704
			TEST(ret==KErrNone);
sl@0
   705
			ret=bitmap->Load(KMbmFileEikon5,j,EFalse);
sl@0
   706
			TEST(ret==KErrNone);
sl@0
   707
			}
sl@0
   708
		}
sl@0
   709
	endtime.UniversalTime();
sl@0
   710
	difftime=endtime.MicroSecondsFrom(starttime);
sl@0
   711
	INFO_PRINTF1(_L("Multiple File Testing Before optimised duration= ? microseconds \n"));
sl@0
   712
	INFO_PRINTF2(_L("Multiple File Testing After optimised duration=%Ld  microseconds\n\n"),difftime.Int64());
sl@0
   713
sl@0
   714
	starttime.UniversalTime();
sl@0
   715
	for (i=0;i<30;i++)
sl@0
   716
		{
sl@0
   717
		for (j=0;j<30;j++)
sl@0
   718
			{
sl@0
   719
			ret=bitmap->Load(KMbmFileEikon,j,EFalse);
sl@0
   720
			TEST(ret==KErrNone);
sl@0
   721
			}
sl@0
   722
		for (j=40;j<70;j++)
sl@0
   723
			{
sl@0
   724
			ret=bitmap->Load(KMbmFileEikon,j,EFalse);
sl@0
   725
			TEST(ret==KErrNone);
sl@0
   726
			}
sl@0
   727
		}
sl@0
   728
	endtime.UniversalTime();
sl@0
   729
	difftime=endtime.MicroSecondsFrom(starttime);
sl@0
   730
	INFO_PRINTF1(_L("Single File Testing Before optimised duration= ? microseconds \n"));
sl@0
   731
	INFO_PRINTF2(_L("Single File Testing After optimised duration=%Ld  microseconds\n\n"),difftime.Int64());
sl@0
   732
sl@0
   733
	bitmap->Reset();
sl@0
   734
	delete bitmap;
sl@0
   735
sl@0
   736
	}
sl@0
   737
sl@0
   738
/**
sl@0
   739
	@SYMTestCaseID
sl@0
   740
	GRAPHICS-FBSERV-0584
sl@0
   741
sl@0
   742
	@SYMTestCaseDesc
sl@0
   743
	Tests loading of bitmaps at an offset
sl@0
   744
	(Bitmap file section offset within the file).
sl@0
   745
sl@0
   746
	@SYMTestActions
sl@0
   747
	Creates an FbsBitmap object on the heap. Loads
sl@0
   748
	a monochrone bitmap with zero offset. Checks if
sl@0
   749
	loading completed successfully. Checks the pixel
sl@0
   750
	size. Gets a pixel. Checks if pixel is KRgbBlack. 
sl@0
   751
	
sl@0
   752
	@SYMTestExpectedResults
sl@0
   753
	Test should pass
sl@0
   754
*/
sl@0
   755
void CTStreamIdCache::TestLoadAtOffset()
sl@0
   756
	{
sl@0
   757
	CFbsBitmap* bitmap = NULL;
sl@0
   758
	TRAPD(ret, bitmap = new (ELeave) CFbsBitmap);
sl@0
   759
	TEST(ret==KErrNone);
sl@0
   760
	if(iStep->TestStepResult() != EPass)
sl@0
   761
		{
sl@0
   762
		return;
sl@0
   763
		}
sl@0
   764
	INFO_PRINTF1(_L("Testing repeated CFbsBitmap Load with different offsets"));
sl@0
   765
sl@0
   766
	do // use a do{}while(false) so we can break out of the test code and fall back to the cleanup code
sl@0
   767
		{
sl@0
   768
		ret = bitmap->Load(KBlackAndWhite, 0, EFalse, 0);
sl@0
   769
		TEST(ret==KErrNone);
sl@0
   770
		if(iStep->TestStepResult() != EPass)
sl@0
   771
			{
sl@0
   772
			INFO_PRINTF1(_L("TestLoadAtOffset: Failed to load first mbm"));
sl@0
   773
			break;
sl@0
   774
			}
sl@0
   775
sl@0
   776
		TEST( bitmap->SizeInPixels() == TSize(1,1) && bitmap->IsMonochrome() );
sl@0
   777
		if(iStep->TestStepResult() == EPass)
sl@0
   778
			{
sl@0
   779
			TRgb colour;
sl@0
   780
			bitmap->GetPixel(colour, TPoint(0,0));
sl@0
   781
			TEST( colour == KRgbBlack );
sl@0
   782
			}
sl@0
   783
sl@0
   784
		if(iStep->TestStepResult() != EPass)
sl@0
   785
			{
sl@0
   786
			INFO_PRINTF1(_L("TestLoadAtOffset: First mbm loaded incorrectly"));
sl@0
   787
			break;
sl@0
   788
			}
sl@0
   789
sl@0
   790
		ret = bitmap->Load(KBlackAndWhite, 0, EFalse, WHITE_OFFSET);
sl@0
   791
		TEST(ret==KErrNone);
sl@0
   792
		if(iStep->TestStepResult() != EPass)
sl@0
   793
			{
sl@0
   794
			INFO_PRINTF1(_L("TestLoadAtOffset: Failed to load second mbm"));
sl@0
   795
			break;
sl@0
   796
			}
sl@0
   797
sl@0
   798
		TEST( bitmap->SizeInPixels() == TSize(1,1) && bitmap->IsMonochrome() );
sl@0
   799
		if(iStep->TestStepResult() == EPass)
sl@0
   800
			{
sl@0
   801
			TRgb colour;
sl@0
   802
			bitmap->GetPixel(colour, TPoint(0,0));
sl@0
   803
			TEST( colour == KRgbWhite );
sl@0
   804
			}
sl@0
   805
sl@0
   806
		if(iStep->TestStepResult() != EPass)
sl@0
   807
			{
sl@0
   808
			INFO_PRINTF1(_L("TestLoadAtOffset: Second mbm loaded incorrectly"));
sl@0
   809
			break;
sl@0
   810
			}
sl@0
   811
		} while( EFalse );
sl@0
   812
sl@0
   813
	bitmap->Reset();
sl@0
   814
	delete bitmap;
sl@0
   815
	}
sl@0
   816
	
sl@0
   817
/**
sl@0
   818
@SYMTestCaseID			GRAPHICS-FBSERV-0509
sl@0
   819
sl@0
   820
@SYMDEF					DEF104261
sl@0
   821
sl@0
   822
@SYMTestCaseDesc		Tests file store cleanup for corresponding fbs session
sl@0
   823
sl@0
   824
@SYMTestPriority		Medium
sl@0
   825
sl@0
   826
@SYMTestStatus			Implemented
sl@0
   827
sl@0
   828
@SYMTestActions			1. Create a file store object from file stream cache using current session handle
sl@0
   829
						2. Create new file store object using some dummy session handle
sl@0
   830
						3. Check two file store object belongs to the corresponding dummy session handle.
sl@0
   831
						4. Close file store and check 
sl@0
   832
								- if corresponing session's handle file store used to close.
sl@0
   833
								- if we send wrong session handle none of the file store should close
sl@0
   834
								- if we haven't send any session handle close all the file store object irrespective of the session handle
sl@0
   835
sl@0
   836
@SYMTestExpectedResults	1. File store should close only for the corresponding session, while disconnecting the session
sl@0
   837
						2. By flushing cache should close all file stores and reset cache entries, irrespective of the session
sl@0
   838
*/
sl@0
   839
void CTStreamIdCache::TestSessionClose()
sl@0
   840
	{
sl@0
   841
	TInt ret;
sl@0
   842
sl@0
   843
	INFO_PRINTF1(_L("Test file store clean up"));
sl@0
   844
sl@0
   845
	CFbTopStreamIdCache* mbmcacheptr = new CFbTopStreamIdCache(30,30,2);
sl@0
   846
	CFbTopStreamIdCache& mbmcache = *mbmcacheptr;
sl@0
   847
	RFile file1;
sl@0
   848
	ret=file1.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
sl@0
   849
	TEST(ret==KErrNone);
sl@0
   850
	RFile file2;
sl@0
   851
	ret=file2.Open(iFs,KMbmFileLafcurs,EFileShareReadersOnly);
sl@0
   852
	TEST(ret==KErrNone);
sl@0
   853
sl@0
   854
	//Create a file store with dummy session handle 1
sl@0
   855
	TRAP(ret,mbmcache.GetStreamIdL(file1,KMbmFileEikon,50,0,1));
sl@0
   856
	TEST(ret==KErrNone);
sl@0
   857
	//Create a file store with dummy session handle 2
sl@0
   858
	TRAP(ret,mbmcache.GetStreamIdL(file2,KMbmFileLafcurs,12,0,2));
sl@0
   859
	TEST(ret==KErrNone);
sl@0
   860
	TEST(mbmcache.iEntries.Count() == 2);
sl@0
   861
	
sl@0
   862
	TEST(2==mbmcache.iEntries[0]->SessionHandle());
sl@0
   863
	TEST(1==mbmcache.iEntries[1]->SessionHandle());
sl@0
   864
	TEST(mbmcache.iEntries[0]->iFilestore!=NULL);
sl@0
   865
	TEST(mbmcache.iEntries[1]->iFilestore!=NULL);
sl@0
   866
sl@0
   867
	mbmcache.CloseFileStores(1);
sl@0
   868
	TEST(mbmcache.iEntries.Count() == 2);
sl@0
   869
	TEST(mbmcache.iEntries[0]->iFilestore!=NULL);
sl@0
   870
	TEST(mbmcache.iEntries[1]->iFilestore==NULL);
sl@0
   871
	TEST(2==mbmcache.iEntries[0]->SessionHandle());
sl@0
   872
	TEST(0==mbmcache.iEntries[1]->SessionHandle());
sl@0
   873
sl@0
   874
	//All File stores should deleted
sl@0
   875
	mbmcache.CloseFileStores(0);
sl@0
   876
	TEST(mbmcache.iEntries.Count() == 2);
sl@0
   877
	TEST(mbmcache.iEntries[0]->iFilestore==NULL);
sl@0
   878
	TEST(mbmcache.iEntries[1]->iFilestore==NULL);
sl@0
   879
	TEST(0==mbmcache.iEntries[0]->SessionHandle());
sl@0
   880
	TEST(0==mbmcache.iEntries[1]->SessionHandle());
sl@0
   881
sl@0
   882
	// Should remove all the file store objects and reset the cache entries.
sl@0
   883
	mbmcache.FlushCache();
sl@0
   884
	TEST(mbmcache.iEntries.Count() == 0);
sl@0
   885
	
sl@0
   886
	delete mbmcacheptr;
sl@0
   887
	}
sl@0
   888
sl@0
   889
	
sl@0
   890
//--------------
sl@0
   891
__CONSTRUCT_STEP__(StreamIdCache)
sl@0
   892
sl@0
   893
sl@0
   894
void CTStreamIdCacheStep::TestSetupL()
sl@0
   895
	{
sl@0
   896
	// Leaking thread handles
sl@0
   897
	iThread.HandleCount(iStartProcessHandleCount, iStartThreadHandleCount);
sl@0
   898
	}
sl@0
   899
	
sl@0
   900
void CTStreamIdCacheStep::TestClose()
sl@0
   901
	{
sl@0
   902
	// Check for open handles
sl@0
   903
	iThread.HandleCount(iEndProcessHandleCount, iEndThreadHandleCount);
sl@0
   904
	if(iStartThreadHandleCount != iEndThreadHandleCount)
sl@0
   905
		{__DEBUGGER()}							// Oops leaked some handles
sl@0
   906
	}