Update contrib.
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.
19 #include "fbsmessage.h"
22 _LIT(KMbmFileEikon, "z:\\System\\Data\\tfbs_file4.mbm");
23 _LIT(KMbmFileTechview, "z:\\System\\Data\\tfbs_file5.mbm");
24 _LIT(KMbmFileTechviewU,"Z:\\SYSTEM\\DATA\\TFBS_FILE5.MBM");
25 _LIT(KMbmFileLafcurs, "z:\\System\\Data\\tfbs_file2.mbm");
26 _LIT(KMbmFileShell, "z:\\System\\Data\\tfbs_file1.mbm");
27 _LIT(KMbmFileShel, "z:\\System\\Data\\tfbs_file_.mbm");
28 _LIT(KMbmFileTimew, "z:\\System\\Data\\tfbs_file3.mbm");
30 _LIT(KMbmFileLafcursLong, "z:\\siuhsiughighifhgidfhguifhguidhfguifhghlarglaghghghghghkrjghszkjg\\System\\Data\\tfbs_file2.mbm");
31 _LIT(KMbmFileShellLong, "z:\\siuhsiughighifhgidfhguifhguidhfguifhghlarglaghghghghghkrjghszkjg\\System\\Data\\tfbs_file1.mbm");
33 // ============================================================================
35 CTRalc::CTRalc(CTestStep* aStep):
36 CTGraphicsBase(aStep),
47 RFbsSession::GetSession()->SendCommand(EFbsMessShutdown);
48 RFbsSession::Disconnect();
51 void CTRalc::ConstructL()
53 if(RFbsSession::Connect()==KErrNone)
55 iShutdownFbs = EFalse;
60 RFbsSession::Connect();
64 iFbs = RFbsSession::GetSession();
66 TRAPD(err,ExpandCleanupStackL());
68 User::Panic(_L("CleanupStack expansion failed"),err);
70 INFO_PRINTF1(_L("FBS Client RALC testing"));
73 void CTRalc::ExpandCleanupStackL()
76 for(;count<10;count++)
77 CleanupStack::PushL((TUint32*)0x1);
78 CleanupStack::Pop(count);
86 Tests the creation of CFbsRalCacheEl objects.
89 1. Test the API on a default built element object.
90 2. Test a New'd element object followed by delete.
91 3. Test a New'd element object followed by destroy & free.
92 4. Test matching of an element object.
94 @SYMTestExpectedResults
97 void CTRalc::TestRALCEntryClass()
99 INFO_PRINTF1(_L("Test of CFbsRalCacheEl API"));
101 // Test the API on a defaultly built element object
103 CFbsRalCacheEl elOne;
104 TEST(elOne.iAddress == 0);
105 TEST(elOne.iFilename == 0);
107 // Test matching method
109 r1 = elOne.MatchKey (KMbmFileEikon);
115 // Test a New'd element object followed by delete
117 CFbsRalCacheEl *elTwo = 0;
118 elTwo = CFbsRalCacheEl::New(KMbmFileTimew, (TAny*)0x58001000);
120 TEST(elTwo->iFilename->CompareF(KMbmFileTimew) == 0);
121 TEST(elTwo->iAddress == (TAny*)0x58001000);
126 // Test a New'd element object followed by destroy & free
128 CFbsRalCacheEl *elThree = 0;
129 elThree = CFbsRalCacheEl::New(KMbmFileLafcursLong, (TAny*)0x58002000);
131 TEST(elThree->iFilename->CompareF(KMbmFileLafcursLong) == 0);
132 TEST(elThree->iAddress == (TAny*)0x58002000);
134 elThree->~CFbsRalCacheEl();
135 TEST(elThree->iFilename == 0);
136 CFbsRalCacheEl::FreeOnly(elThree);
140 // Test matching of an element object
142 CFbsRalCacheEl *elFour = 0;
143 elFour = CFbsRalCacheEl::New(KMbmFileTechview, (TAny*)0x58003000);
147 r2 = elFour->MatchKey (KMbmFileEikon);
150 r2 = elFour->MatchKey (KMbmFileTechview);
153 r2 = elFour->MatchKey(KMbmFileTechviewU);
165 Tests the RALC Cache class.
168 Connect to the file server. Creates a CFbsRalCache
169 object on the heap. Deletes the object.
170 Test the lookup facility of the cache with overflow.
172 @SYMTestExpectedResults
175 void CTRalc::TestRALCCacheClass()
180 ret = fileServer.Connect();
183 INFO_PRINTF1(_L("Test of CFbsRalCache API"));
185 // Test the construction/destruction API
187 CFbsRalCache* cache1 = CFbsRalCache::New(0, fileServer);
190 cache1 = CFbsRalCache::New(5, fileServer);
192 TEST(cache1->Count() == 0);
193 TEST(cache1->Length() == 5);
198 // Test the lookup facility of the cache with overflow
200 CFbsRalCache* cache2 = CFbsRalCache::New(2, fileServer);
203 p1 = cache2->Lookup(KMbmFileLafcurs);
205 TEST(cache2->Count() == 1);
207 p1 = cache2->Lookup(KMbmFileShel);
209 TEST(cache2->Count() == 1);
211 p1 = cache2->Lookup(KMbmFileShell);
213 TEST(cache2->Count() == 2);
215 p1 = cache2->Lookup(KMbmFileEikon);
217 TEST(cache2->Count() == 2);
230 Tests Out Of Memory conditions for the CFbsRalCache class.
233 Connects to the file server. Sets a macro
234 that makes heap allocation fail after a certain
235 number of heap allocations. Creates a CFbsRalCache
236 object on the heap. Deletes the object. Closes the file
239 @SYMTestExpectedResults
242 void CTRalc::TestOOMCondition()
246 ret = fileServer.Connect();
249 INFO_PRINTF1(_L("Test of CFbsRalCache and OOM"));
251 for (TInt count = 1; ; count++)
253 __UHEAP_SETFAIL(RHeap::EDeterministic,count);
256 CFbsRalCache* cache = 0;
257 cache = CFbsRalCache::New(4, fileServer);
267 __UHEAP_SETFAIL(RHeap::ENone,count);
280 Intended to measure performance of bitmap loading.
283 Creates to CFbsBitmap objects on the stack and
284 loads a bitmap file in to objects in a loop.
285 Test case is not complete.
287 @SYMTestExpectedResults
288 No test result is given in the function.
290 void CTRalc::MeasurePerformanceWith2()
296 INFO_PRINTF1(_L("Performance Test with 2 Lookups"));
298 for (loopI=0; loopI<2700; loopI++)
299 bitmap1.Load(KMbmFileLafcurs, 0, EFalse);
301 for (loopI=0; loopI<600; loopI++)
302 bitmap2.Load(KMbmFileShell, 0, EFalse);
304 /* RDebug::ProfileEnd(10);
306 RDebug::ProfileResult(&profile,10,1);
307 RDebug::Print(_L("Performance test end %d.%d s\n"),profile.iTime/1000000,(profile.iTime/1000)%1000); */
315 Intended to measure performance of bitmap loading.
318 Creates to CFbsBitmap objects on the stack and
319 loads a bitmap file in to objects in a loop.
320 Test case is not complete.
322 @SYMTestExpectedResults
323 No test result is given in the function.
325 void CTRalc::MeasurePerformanceWith2Long()
331 INFO_PRINTF1(_L("Performance Test with 2 LONG Lookups"));
332 // RDebug::ProfileReset(10, 1);
333 // RDebug::ProfileStart(10);
335 for (loopI=0; loopI<2700; loopI++)
336 (void)bitmap1.Load(KMbmFileLafcursLong, 0, EFalse);
338 for (loopI=0; loopI<600; loopI++)
339 (void)bitmap2.Load(KMbmFileShellLong, 0, EFalse);
341 /* RDebug::ProfileEnd(10);
343 RDebug::ProfileResult(&profile,10,1);
344 RDebug::Print(_L("Performance test end %d.%d s\n"),profile.iTime/1000000,(profile.iTime/1000)%1000); */
352 Intended to measure performance of bitmap loading.
355 Creates five CFbsBitmap objects on the stack and
356 loads different bitmap files in to the objects in a loop.
358 @SYMTestExpectedResults
359 No test result is given in the function.
361 void CTRalc::MeasurePerformanceWith5()
370 INFO_PRINTF1(_L("Performance Test with 5 Lookups"));
371 // RDebug::ProfileReset(10, 1);
372 // RDebug::ProfileStart(10);
374 for (loopI=0; loopI<500; loopI++)
375 bitmap1.Load(KMbmFileEikon, 0, EFalse);
377 for (loopI=0; loopI<200; loopI++)
378 bitmap2.Load(KMbmFileTechview, 0, EFalse);
380 for (loopI=0; loopI<2700; loopI++)
381 bitmap3.Load(KMbmFileLafcurs, 0, EFalse);
383 for (loopI=0; loopI<600; loopI++)
384 bitmap4.Load(KMbmFileShell, 0, EFalse);
386 for (loopI=0; loopI<1100; loopI++)
387 bitmap5.Load(KMbmFileTimew, 0, EFalse);
389 /* RDebug::ProfileEnd(10);
391 RDebug::ProfileResult(&profile,10,1);
392 RDebug::Print(_L("Performance test end %d.%d s\n"),profile.iTime/1000000,(profile.iTime/1000)%1000); */
400 Intended to measure performance of bitmap loading.
403 Creates five CFbsBitmap objects on the stack and
404 loads different bitmap files in to the objects in a loop.
406 @SYMTestExpectedResults
407 No test result is given in the function.
409 void CTRalc::MeasurePerformanceWith23Mix()
418 INFO_PRINTF1(_L("Performance Test with 2/3 Mix of Lookups"));
419 // RDebug::ProfileReset(10, 1);
420 // RDebug::ProfileStart(10);
422 for (loopI=0; loopI<500; loopI++)
423 bitmap1.Load(KMbmFileEikon, 0, EFalse);
425 for (loopI=0; loopI<200; loopI++)
426 bitmap2.Load(KMbmFileTechview, 0, EFalse);
428 for (loopI=0; loopI<2700; loopI++)
429 bitmap3.Load(KMbmFileLafcursLong, 0, EFalse);
431 for (loopI=0; loopI<600; loopI++)
432 bitmap4.Load(KMbmFileShellLong, 0, EFalse);
434 for (loopI=0; loopI<1100; loopI++)
435 bitmap5.Load(KMbmFileTimew, 0, EFalse);
437 /* RDebug::ProfileEnd(10);
439 RDebug::ProfileResult(&profile,10,1);
440 RDebug::Print(_L("Performance test end %d.%d s\n"),profile.iTime/1000000,(profile.iTime/1000)%1000);*/
443 void CTRalc::RunTestCaseL(TInt aCurTestCase)
445 TUint32* romAddress = NULL;
446 if(!CFbsBitmap::IsFileInRom(KMbmFileEikon, romAddress)) //check any rom bitmap
448 INFO_PRINTF2(_L("Skipping CFbsRalCache tests since file \"%S\" is reported to not be a ROM bitmap."),
450 INFO_PRINTF1(_L("This should only occur on non-XIP ROMs, e.g. NAND ROMs, where ROM bitmaps aren't supported."));
455 ((CTRalcStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
459 ((CTRalcStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0604"));
460 TestRALCEntryClass();
463 ((CTRalcStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0605"));
464 TestRALCCacheClass();
467 ((CTRalcStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0606"));
471 ((CTRalcStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0607"));
472 MeasurePerformanceWith2();
475 ((CTRalcStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0608"));
476 MeasurePerformanceWith5();
479 ((CTRalcStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0609"));
480 MeasurePerformanceWith2Long();
483 ((CTRalcStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0610"));
484 MeasurePerformanceWith23Mix();
487 ((CTRalcStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
488 ((CTRalcStep*)iStep)->CloseTMSGraphicsStep();
492 ((CTRalcStep*)iStep)->RecordTestResultL();
497 __CONSTRUCT_STEP__(Ralc)
499 void CTRalcStep::TestSetupL()
501 // Leaking thread handles
502 iThread.HandleCount(iStartProcessHandleCount, iStartThreadHandleCount);
505 void CTRalcStep::TestClose()
507 // Check for open handles
508 iThread.HandleCount(iEndProcessHandleCount, iEndThreadHandleCount);
509 if(iStartThreadHandleCount != iEndThreadHandleCount)
510 {__DEBUGGER()} // Oops leaked some handles