First public contribution.
1 // Copyright (c) 1997-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include "../inc/FBSMBMC.H"
18 #include "../sfbs/UTILS.H"
19 #include "TStreamIdCache.h"
20 #include "fbsmessage.h"
23 //Eikon has 78 bitmaps inside the mbm file(id 0-77)
24 _LIT(KMbmFileEikon, "z:\\System\\Data\\tfbs_file4.mbm");
25 _LIT(KMbmFileEikon2, "z:\\System\\Data\\tfbs_file4a.mbm");
26 _LIT(KMbmFileEikon3, "z:\\System\\Data\\tfbs_file4b.mbm");
27 _LIT(KMbmFileEikon4, "z:\\System\\Data\\tfbs_file4c.mbm");
28 _LIT(KMbmFileEikon5, "z:\\System\\Data\\tfbs_file4d.mbm");
29 //Lafcurs has 28 bitmaps inside the mbm file(id 0-27)
30 _LIT(KMbmFileLafcurs, "z:\\System\\Data\\tfbs_file2.mbm");
31 //Resource file containing mbm file
32 _LIT(KMbmFileTFBSRSC, "z:\\System\\Data\\tfbs_rsc.rsc");
33 _LIT(KRscFileHeader, "z:\\system\\data\\RscHeader3.bin");
34 _LIT(KRscFileData, "z:\\system\\data\\DummyRscFile3.rsc");
36 // File with two 1x1 px mbm files: first is black, second is white. white mbm at 72 bytes into file
37 #define WHITE_OFFSET 72
38 _LIT(KBlackAndWhite, "z:\\system\\data\\blackandwhite.mbm");
40 // ============================================================================
43 CTStreamIdCache::CTStreamIdCache(CTestStep* aStep):
44 CTGraphicsBase(aStep),
49 CTStreamIdCache::~CTStreamIdCache()
52 RFbsSession::GetSession()->SendCommand(EFbsMessShutdown);
53 RFbsSession::Disconnect();
57 void CTStreamIdCache::ConstructL()
59 if(RFbsSession::Connect()==KErrNone)
61 iShutdownFbs = EFalse;
66 RFbsSession::Connect();
72 iFbs = RFbsSession::GetSession();
73 iSessionHandle = iFbs->SessionHandle();
74 ExpandCleanupStackL();
76 INFO_PRINTF1(_L("FBS Bitmap StreamId cache testing"));
79 void CTStreamIdCache::RunTestCaseL(TInt aCurTestCase)
81 ((CTStreamIdCacheStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
85 ((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0577"));
86 TestStreamIdCacheEntry();
89 ((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0578"));
90 TestProcessingBitmapStream();
93 ((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0580"));
97 ((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0579"));
98 TestComparingStreams();
101 ((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0581"));
102 TestInvalidArgument();
105 ((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0582"));
109 ((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0583"));
113 ((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0584"));
117 ((CTStreamIdCacheStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0509"));
121 ((CTStreamIdCacheStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
122 ((CTStreamIdCacheStep*)iStep)->CloseTMSGraphicsStep();
126 ((CTStreamIdCacheStep*)iStep)->RecordTestResultL();
129 //This function is here to measure the offset in the rsc file
130 TInt CTStreamIdCache::FileSizeL(const TDesC& aFileName)
133 User::LeaveIfError(file.Open(iFs, aFileName, EFileRead));
134 CleanupClosePushL(file);
136 User::LeaveIfError(file.Size(size));
137 CleanupStack::PopAndDestroy(&file);
141 void CTStreamIdCache::ExpandCleanupStackL()
144 for(;count<10;count++)
145 CleanupStack::PushL((TUint32*)0x1);
146 CleanupStack::Pop(count);
154 Tests the API functionality of the class ensuring
155 the internal states are correct during the construction
159 Tests the API on a defaultly built element object.
161 @SYMTestExpectedResults
164 void CTStreamIdCache::TestStreamIdCacheEntry()
166 INFO_PRINTF1(_L("Test of CFbTopStreamIdCache API"));
168 // Test the API on a defaultly built element object
170 CFbTopStreamIdCache* mbmcache=new CFbTopStreamIdCache(20,30,1);
171 TEST(mbmcache->iEntries.Count() == 0);
172 TEST(mbmcache->iMaxCacheFilestores == 1);
173 TEST(mbmcache->iBackwardCacheSize ==30);
174 TEST(mbmcache->iForwardCacheSize ==20);
185 Tests the loading of a bitmap from an mbm file using
186 the cache and the content of the cache after the loading
187 i.e. how many stream ids are stored, the last bitmap file
188 name, the last id, the cache forward and backward size.
191 Tests the GetStreamIdL method. Loads eikon.mbm with 78
192 bitmap files. Tests loading some rsc file which contains offset.
195 @SYMTestExpectedResults
198 void CTStreamIdCache::TestProcessingBitmapStream()
202 INFO_PRINTF1(_L("Test loading a bitmap file and processing the stream id"));
204 //Testing the GetStreamIdL method
205 CFbTopStreamIdCache* mbmcacheptr = new CFbTopStreamIdCache(30,30,1);
206 CFbTopStreamIdCache& mbmcache = *mbmcacheptr;
207 INFO_PRINTF1(_L("Loading eikon.mbm with 78 bitmap files"));
208 //Loading eikon.mbm with 78 bitmap files
210 ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
212 TRAP(ret,mbmcache.GetStreamIdL(file,KMbmFileEikon,50,0,iSessionHandle));
214 //the cache only stores 30 ids before 50 + max of 30 after(including 50)
215 //but in this case the bitmap only has 78 bitmaps so it only stores 28 after
216 TEST(mbmcache.iEntries.Count() == 1);
217 TEST(mbmcache.iEntries[0]->iStreamIdCount==58);
218 TEST(mbmcache.iEntries[0]->iLastId==50);
219 TEST(mbmcache.iForwardCacheSize==30);
220 TEST(mbmcache.iBackwardCacheSize==30);
221 TEST(mbmcache.iEntries[0]->iFilename.CompareF(KMbmFileEikon)==0);
222 TEST(mbmcache.iEntries[0]->iFilestore!=NULL);
224 //Test loading some rsc file which contains offset
225 TInt mbm_offset = FileSizeL(KRscFileHeader) + FileSizeL(KRscFileData);
226 ret=file.Open(iFs,KMbmFileTFBSRSC,EFileShareReadersOnly);
228 TRAP(ret,mbmcache.GetStreamIdL(file,KMbmFileTFBSRSC,0,mbm_offset,iSessionHandle));
230 TEST(mbmcache.iEntries.Count() == 1);
231 TEST(mbmcache.iEntries[0]->iLastId==0);
232 TEST(mbmcache.iEntries[0]->iStreamIdCount==2);
233 TEST(mbmcache.iEntries[0]->iFilename.CompareF(KMbmFileTFBSRSC)==0);
236 mbmcache.FlushCache();
237 TEST(mbmcache.iEntries.Count() == 0);
238 TEST(mbmcache.iMaxCacheFilestores == 1);
239 TEST(mbmcache.iBackwardCacheSize == 30);
240 TEST(mbmcache.iForwardCacheSize == 30);
250 Tests the correct functionality of the cache storing the stream ids.
251 Three different caches are used to load the same mbm file but the
252 bitmap id to be loaded are different however the bitmap ids are chosen in
253 such a way that these three caches will store some common bitmap id.
254 We then accessed the cache content and check that these three caches
255 will give the same stream id values for that common bitmap id.
259 @SYMTestExpectedResults
262 void CTStreamIdCache::TestComparingStreams()
266 INFO_PRINTF1(_L("Test comparing the stream ids from three different caches"));
268 CFbTopStreamIdCache* cache1=new CFbTopStreamIdCache(30,30,1);
269 CFbTopStreamIdCache* cache2=new CFbTopStreamIdCache(10,30,1);
270 CFbTopStreamIdCache* cache3=new CFbTopStreamIdCache(25,5,1);
272 //CACHE1 Loading this will fill up the streams with ids from 0-55
274 ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
276 TRAP(ret,cache1->GetStreamIdL(file,KMbmFileEikon,25,0,iSessionHandle));
278 TEST(cache1->iEntries.Count() == 1);
279 TEST(cache1->iEntries[0]->iStreamIdCount==55);
280 TEST(cache1->iEntries[0]->iLastId==25);
281 //now storing the actual TStreamId for bitmap id 26 for future comparison
282 //stream id for bitmapid=26 will be @ the 26th position inside the array
283 TStreamId id25_26=cache1->iEntries[0]->iStreamIdCache[26];
288 //CACHE2 Loading this will fill up the streams with ids from 36-65
289 ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
291 TRAP(ret,cache2->GetStreamIdL(file,KMbmFileEikon,56,0,iSessionHandle));
293 TEST(cache2->iEntries.Count() == 1);
294 TEST(cache2->iEntries[0]->iStreamIdCount==40);
295 TEST(cache2->iEntries[0]->iLastId==56);
296 //stream id for bitmapid=26 will be @ the 0th position inside the array
297 TStreamId id56_26=cache2->iEntries[0]->iStreamIdCache[0];
298 TEST(id25_26.Value()==id56_26.Value());
302 //CACHE3 Loading this will fill up the streams with ids from 1-30
303 ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
305 TRAP(ret,cache3->GetStreamIdL(file,KMbmFileEikon,6,0,iSessionHandle));
307 TEST(cache3->iEntries.Count() == 1);
308 TEST(cache3->iEntries[0]->iStreamIdCount==30);
309 TEST(cache3->iEntries[0]->iLastId==6);
310 TStreamId id6_26=cache3->iEntries[0]->iStreamIdCache[25];
311 TEST(id25_26.Value()==id6_26.Value());
321 Tests the functionality of the cache when it has already
322 stored some existing bitmap ids The cache is loaded with a
323 different mbm file and the cache content is examined to make
324 sure it has the correct new data.
328 @SYMTestExpectedResults
331 void CTStreamIdCache::TestReplacingFile()
335 INFO_PRINTF1(_L("Test loading a file different from previous stored in cache"));
337 CFbTopStreamIdCache* cache1ptr = new CFbTopStreamIdCache(30,30,1);
338 CFbTopStreamIdCache& cache1 = *cache1ptr;
340 ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
342 TRAP(ret,cache1.GetStreamIdL(file,KMbmFileEikon,25,0,iSessionHandle));
344 TEST(cache1.iEntries.Count() == 1);
345 TEST(cache1.iEntries[0]->iStreamIdCount==55);
346 TEST(cache1.iEntries[0]->iLastId==25);
347 TEST(cache1.iEntries[0]->iFilename.Compare(KMbmFileEikon)==0);
349 //Now trying to load an entirely different bitmap file
350 //and check to ensure the cache has reflushed itself
351 //and load itself with new stuff
352 ret=file.Open(iFs,KMbmFileLafcurs,EFileShareReadersOnly);
354 TRAP(ret,cache1.GetStreamIdL(file,KMbmFileLafcurs,12,0,iSessionHandle));
356 TEST(cache1.iEntries.Count() == 1);
357 TEST(cache1.iEntries[0]->iStreamIdCount==28);
358 TEST(cache1.iEntries[0]->iLastId==12);
359 TEST(cache1.iEntries[0]->iFilename.Compare(KMbmFileLafcurs)==0);
369 Tests the error values that would be returned by
370 the cache when supplied with invalid arguments such
371 as bad file name negative bitmap ids, out of range
372 bitmap ids, and invalid file offset.
374 @SYMDEF INC047122 INC046632
377 Creates an FbTopStreamIdCache object. Tests to ensure the cache
378 can deal with non error cases immediately after error cases.
379 Passing an in bound bitmap id. Passing an out of bound bitmap id.
380 Passing an in bound bitmap id. Passing an out of bound bitmap id.
381 Passing an in bound bitmap id. Passing negative bitmap id.
382 Passing an invalid file name. Passing an invalid file offset.
384 @SYMTestExpectedResults
387 void CTStreamIdCache::TestInvalidArgument()
392 INFO_PRINTF1(_L("Test loading a file bitmap with invalid argument"));
394 CFbTopStreamIdCache* cache1ptr = new CFbTopStreamIdCache(30,30,1);
395 CFbTopStreamIdCache& cache1 = *cache1ptr;
396 //Eikon mbm only can accept ids from 0-77
398 //The following sequence of 4 tests ensures the cache can deal with
399 //non error cases immediately after error cases.
401 //Passing an in bound bitmap id
403 ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
405 TRAP(ret,cache1.GetStreamIdL(file,KMbmFileEikon,0,0,iSessionHandle));
408 //Passing an out of bound bitmap id
409 ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
411 TRAP(ret,cache1.GetStreamIdL(file,KMbmFileEikon,78,0,iSessionHandle));
414 //Passing an in bound bitmap id
415 ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
417 TRAP(ret,cache1.GetStreamIdL(file,KMbmFileEikon,74,0,iSessionHandle));
420 //Passing an out of bound bitmap id
421 ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
423 TRAP(ret,cache1.GetStreamIdL(file,KMbmFileEikon,78,0,iSessionHandle));
426 //Passing an in bound bitmap id
427 ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
429 TRAP(ret,cache1.GetStreamIdL(file,KMbmFileEikon,77,0,iSessionHandle));
433 //Passing negative bitmap id
434 ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
436 TRAP(ret,cache1.GetStreamIdL(file,KMbmFileEikon,-1,0,iSessionHandle));
439 //Passing an invalid file name
440 ret=file.Open(iFs,_L("invalid.mbm"),EFileShareReadersOnly);
442 TEST((ret==KErrNotFound)||(ret==KErrPathNotFound));
444 //Passing an invalid file offset
445 ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
447 TRAP(ret,cache1.GetStreamIdL(file,KMbmFileEikon,12,10,iSessionHandle));
448 TEST(ret==KErrNotSupported);
450 //Tests for INC047122 and INC046632
455 err=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
457 TRAP(err,cache1.GetStreamIdL(file,KMbmFileEikon,id,0,iSessionHandle));
462 INFO_PRINTF2(_L("Starting from 0 the number of bitmaps in KMbmFileEikon is calculated to be %d\n\n"), id);
466 // New cache, start from Id 50
467 CFbTopStreamIdCache* cache2ptr = new CFbTopStreamIdCache(30,30,1);
468 CFbTopStreamIdCache& cache2 = *cache2ptr;
469 for (id=50, err=KErrNone; id<100; id++)
471 err=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
473 TRAP(err,cache2.GetStreamIdL(file,KMbmFileEikon,id,0,iSessionHandle));
478 INFO_PRINTF2(_L("Starting from 50 the number of bitmaps in KMbmFileEikon is calculated to be %d\n\n"), id);
488 Tests the out of memory condition during memory
489 allocation inside the test function GetStreamIdL
490 to ensure that there is no memory leaks.
493 Tests the cache by opening a file and calls GetStreamIdL
494 and checks the heap for memory leaks. Tests the cache
495 for a cache hit. Test the cache for a cache miss.
497 @SYMTestExpectedResults
500 void CTStreamIdCache::TestOOMCondition()
502 INFO_PRINTF1(_L("Test of CFbTopStreamIdCache OOM"));
504 // Test a cache for the first time
505 for (TInt count = 1; ; count++)
508 CFbTopStreamIdCache* cache=new CFbTopStreamIdCache(30,30,1);
510 __UHEAP_SETFAIL(RHeap::EDeterministic,count);
512 TInt ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
514 TRAP(ret,cache->GetStreamIdL(file,KMbmFileEikon,30,0,iSessionHandle));
522 TEST(ret==KErrNoMemory);
526 for (TInt count = 1; ; count++)
529 CFbTopStreamIdCache* cache=new CFbTopStreamIdCache(30,30,1);
532 TInt ret=file1.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
534 TRAP(ret,cache->GetStreamIdL(file1,KMbmFileEikon,30,0,iSessionHandle));
537 __UHEAP_SETFAIL(RHeap::EDeterministic,count);
539 ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
541 TRAP(ret,cache->GetStreamIdL(file,KMbmFileEikon,30,0,iSessionHandle));
549 TEST(ret==KErrNoMemory);
553 for (TInt count = 1; ; count++)
556 CFbTopStreamIdCache* cache=new CFbTopStreamIdCache(30,30,1);
559 TInt ret=file1.Open(iFs,KMbmFileLafcurs,EFileShareReadersOnly);
561 TRAP(ret,cache->GetStreamIdL(file1,KMbmFileLafcurs,0,0,iSessionHandle));
564 __UHEAP_SETFAIL(RHeap::EDeterministic,count);
566 ret=file.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
568 TRAP(ret,cache->GetStreamIdL(file,KMbmFileEikon,30,0,iSessionHandle));
576 __UHEAP_SETFAIL(RHeap::ENone,count);
579 TEST(ret==KErrNoMemory);
588 This test is used to measure the performance improvement
589 when the font bitmap server is using a cache to store the
593 Starts the timing. Gets the current time. Creates a FbsBitmap
594 on the heap. Simulates loading during boot time by loading
595 bitmaps from ROM. Does forward testing before optimised duration.
596 Retreives the current time and calculates the time taken by the tests.
597 Does forward testing after optimised duration. Does backward testing
598 before optimised duration. Does backward testing after optimised duration.
600 @SYMTestExpectedResults
603 void CTStreamIdCache::TestPerformance()
607 starttime.UniversalTime();
609 CFbsBitmap* bitmap=new (ELeave) CFbsBitmap;
611 //simulating loading during boottime
617 ret=bitmap->Load(KMbmFileEikon,j,EFalse);
622 ret=bitmap->Load(_L("z:\\system\\data\\tfbs.mbm"),j,EFalse);
627 ret=bitmap->Load(KMbmFileLafcurs,j,EFalse);
632 ret=bitmap->Load(KMbmFileEikon,j,EFalse);
637 ret=bitmap->Load(_L("z:\\system\\data\\tfbs.mbm"),j,EFalse);
642 ret=bitmap->Load(KMbmFileLafcurs,j,EFalse);
648 endtime.UniversalTime();
649 INFO_PRINTF1(_L("Forward Testing Before optimised duration= 3515625 microseconds \n"));
650 TTimeIntervalMicroSeconds difftime=endtime.MicroSecondsFrom(starttime);
651 INFO_PRINTF2(_L("Forward Testing After optimised duration=%Ld microseconds\n\n"),difftime.Int64());
653 starttime.UniversalTime();
658 ret=bitmap->Load(KMbmFileEikon,j,EFalse);
663 ret=bitmap->Load(_L("z:\\system\\data\\tfbs.mbm"),j,EFalse);
668 ret=bitmap->Load(KMbmFileLafcurs,j,EFalse);
673 ret=bitmap->Load(KMbmFileEikon,j,EFalse);
678 ret=bitmap->Load(_L("z:\\system\\data\\tfbs.mbm"),j,EFalse);
683 ret=bitmap->Load(KMbmFileLafcurs,j,EFalse);
687 endtime.UniversalTime();
688 difftime=endtime.MicroSecondsFrom(starttime);
689 INFO_PRINTF1(_L("Backward Testing Before optimised duration= 3515625 microseconds \n"));
690 INFO_PRINTF2(_L("Backward Testing After optimised duration=%Ld microseconds\n\n"),difftime.Int64());
692 starttime.UniversalTime();
697 ret=bitmap->Load(KMbmFileEikon,j,EFalse);
699 ret=bitmap->Load(KMbmFileEikon2,j,EFalse);
701 ret=bitmap->Load(KMbmFileEikon3,j,EFalse);
703 ret=bitmap->Load(KMbmFileEikon4,j,EFalse);
705 ret=bitmap->Load(KMbmFileEikon5,j,EFalse);
709 endtime.UniversalTime();
710 difftime=endtime.MicroSecondsFrom(starttime);
711 INFO_PRINTF1(_L("Multiple File Testing Before optimised duration= ? microseconds \n"));
712 INFO_PRINTF2(_L("Multiple File Testing After optimised duration=%Ld microseconds\n\n"),difftime.Int64());
714 starttime.UniversalTime();
719 ret=bitmap->Load(KMbmFileEikon,j,EFalse);
724 ret=bitmap->Load(KMbmFileEikon,j,EFalse);
728 endtime.UniversalTime();
729 difftime=endtime.MicroSecondsFrom(starttime);
730 INFO_PRINTF1(_L("Single File Testing Before optimised duration= ? microseconds \n"));
731 INFO_PRINTF2(_L("Single File Testing After optimised duration=%Ld microseconds\n\n"),difftime.Int64());
743 Tests loading of bitmaps at an offset
744 (Bitmap file section offset within the file).
747 Creates an FbsBitmap object on the heap. Loads
748 a monochrone bitmap with zero offset. Checks if
749 loading completed successfully. Checks the pixel
750 size. Gets a pixel. Checks if pixel is KRgbBlack.
752 @SYMTestExpectedResults
755 void CTStreamIdCache::TestLoadAtOffset()
757 CFbsBitmap* bitmap = NULL;
758 TRAPD(ret, bitmap = new (ELeave) CFbsBitmap);
760 if(iStep->TestStepResult() != EPass)
764 INFO_PRINTF1(_L("Testing repeated CFbsBitmap Load with different offsets"));
766 do // use a do{}while(false) so we can break out of the test code and fall back to the cleanup code
768 ret = bitmap->Load(KBlackAndWhite, 0, EFalse, 0);
770 if(iStep->TestStepResult() != EPass)
772 INFO_PRINTF1(_L("TestLoadAtOffset: Failed to load first mbm"));
776 TEST( bitmap->SizeInPixels() == TSize(1,1) && bitmap->IsMonochrome() );
777 if(iStep->TestStepResult() == EPass)
780 bitmap->GetPixel(colour, TPoint(0,0));
781 TEST( colour == KRgbBlack );
784 if(iStep->TestStepResult() != EPass)
786 INFO_PRINTF1(_L("TestLoadAtOffset: First mbm loaded incorrectly"));
790 ret = bitmap->Load(KBlackAndWhite, 0, EFalse, WHITE_OFFSET);
792 if(iStep->TestStepResult() != EPass)
794 INFO_PRINTF1(_L("TestLoadAtOffset: Failed to load second mbm"));
798 TEST( bitmap->SizeInPixels() == TSize(1,1) && bitmap->IsMonochrome() );
799 if(iStep->TestStepResult() == EPass)
802 bitmap->GetPixel(colour, TPoint(0,0));
803 TEST( colour == KRgbWhite );
806 if(iStep->TestStepResult() != EPass)
808 INFO_PRINTF1(_L("TestLoadAtOffset: Second mbm loaded incorrectly"));
818 @SYMTestCaseID GRAPHICS-FBSERV-0509
822 @SYMTestCaseDesc Tests file store cleanup for corresponding fbs session
824 @SYMTestPriority Medium
826 @SYMTestStatus Implemented
828 @SYMTestActions 1. Create a file store object from file stream cache using current session handle
829 2. Create new file store object using some dummy session handle
830 3. Check two file store object belongs to the corresponding dummy session handle.
831 4. Close file store and check
832 - if corresponing session's handle file store used to close.
833 - if we send wrong session handle none of the file store should close
834 - if we haven't send any session handle close all the file store object irrespective of the session handle
836 @SYMTestExpectedResults 1. File store should close only for the corresponding session, while disconnecting the session
837 2. By flushing cache should close all file stores and reset cache entries, irrespective of the session
839 void CTStreamIdCache::TestSessionClose()
843 INFO_PRINTF1(_L("Test file store clean up"));
845 CFbTopStreamIdCache* mbmcacheptr = new CFbTopStreamIdCache(30,30,2);
846 CFbTopStreamIdCache& mbmcache = *mbmcacheptr;
848 ret=file1.Open(iFs,KMbmFileEikon,EFileShareReadersOnly);
851 ret=file2.Open(iFs,KMbmFileLafcurs,EFileShareReadersOnly);
854 //Create a file store with dummy session handle 1
855 TRAP(ret,mbmcache.GetStreamIdL(file1,KMbmFileEikon,50,0,1));
857 //Create a file store with dummy session handle 2
858 TRAP(ret,mbmcache.GetStreamIdL(file2,KMbmFileLafcurs,12,0,2));
860 TEST(mbmcache.iEntries.Count() == 2);
862 TEST(2==mbmcache.iEntries[0]->SessionHandle());
863 TEST(1==mbmcache.iEntries[1]->SessionHandle());
864 TEST(mbmcache.iEntries[0]->iFilestore!=NULL);
865 TEST(mbmcache.iEntries[1]->iFilestore!=NULL);
867 mbmcache.CloseFileStores(1);
868 TEST(mbmcache.iEntries.Count() == 2);
869 TEST(mbmcache.iEntries[0]->iFilestore!=NULL);
870 TEST(mbmcache.iEntries[1]->iFilestore==NULL);
871 TEST(2==mbmcache.iEntries[0]->SessionHandle());
872 TEST(0==mbmcache.iEntries[1]->SessionHandle());
874 //All File stores should deleted
875 mbmcache.CloseFileStores(0);
876 TEST(mbmcache.iEntries.Count() == 2);
877 TEST(mbmcache.iEntries[0]->iFilestore==NULL);
878 TEST(mbmcache.iEntries[1]->iFilestore==NULL);
879 TEST(0==mbmcache.iEntries[0]->SessionHandle());
880 TEST(0==mbmcache.iEntries[1]->SessionHandle());
882 // Should remove all the file store objects and reset the cache entries.
883 mbmcache.FlushCache();
884 TEST(mbmcache.iEntries.Count() == 0);
891 __CONSTRUCT_STEP__(StreamIdCache)
894 void CTStreamIdCacheStep::TestSetupL()
896 // Leaking thread handles
897 iThread.HandleCount(iStartProcessHandleCount, iStartThreadHandleCount);
900 void CTStreamIdCacheStep::TestClose()
902 // Check for open handles
903 iThread.HandleCount(iEndProcessHandleCount, iEndThreadHandleCount);
904 if(iStartThreadHandleCount != iEndThreadHandleCount)
905 {__DEBUGGER()} // Oops leaked some handles