|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "FbsRalc.h" |
|
17 #include "UTILS.H" |
|
18 #include "TRalc.h" |
|
19 #include "fbsmessage.h" |
|
20 #include "fbsdefs.h" |
|
21 |
|
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"); |
|
29 |
|
30 _LIT(KMbmFileLafcursLong, "z:\\siuhsiughighifhgidfhguifhguidhfguifhghlarglaghghghghghkrjghszkjg\\System\\Data\\tfbs_file2.mbm"); |
|
31 _LIT(KMbmFileShellLong, "z:\\siuhsiughighifhgidfhguifhguidhfguifhghlarglaghghghghghkrjghszkjg\\System\\Data\\tfbs_file1.mbm"); |
|
32 |
|
33 // ============================================================================ |
|
34 |
|
35 CTRalc::CTRalc(CTestStep* aStep): |
|
36 CTGraphicsBase(aStep), |
|
37 iHandle(0), |
|
38 iFbs(NULL), |
|
39 iResourceCount(0), |
|
40 iAllocs(0) |
|
41 { |
|
42 } |
|
43 |
|
44 CTRalc::~CTRalc() |
|
45 { |
|
46 if(iShutdownFbs) |
|
47 RFbsSession::GetSession()->SendCommand(EFbsMessShutdown); |
|
48 RFbsSession::Disconnect(); |
|
49 } |
|
50 |
|
51 void CTRalc::ConstructL() |
|
52 { |
|
53 if(RFbsSession::Connect()==KErrNone) |
|
54 { |
|
55 iShutdownFbs = EFalse; |
|
56 } |
|
57 else |
|
58 { |
|
59 FbsStartup(); |
|
60 RFbsSession::Connect(); |
|
61 iShutdownFbs = ETrue; |
|
62 } |
|
63 |
|
64 iFbs = RFbsSession::GetSession(); |
|
65 |
|
66 TRAPD(err,ExpandCleanupStackL()); |
|
67 if (err != KErrNone) |
|
68 User::Panic(_L("CleanupStack expansion failed"),err); |
|
69 |
|
70 INFO_PRINTF1(_L("FBS Client RALC testing")); |
|
71 } |
|
72 |
|
73 void CTRalc::ExpandCleanupStackL() |
|
74 { |
|
75 TInt count=0; |
|
76 for(;count<10;count++) |
|
77 CleanupStack::PushL((TUint32*)0x1); |
|
78 CleanupStack::Pop(count); |
|
79 } |
|
80 |
|
81 /** |
|
82 @SYMTestCaseID |
|
83 GRAPHICS-FBSERV-0604 |
|
84 |
|
85 @SYMTestCaseDesc |
|
86 Tests the creation of CFbsRalCacheEl objects. |
|
87 |
|
88 @SYMTestActions |
|
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. |
|
93 |
|
94 @SYMTestExpectedResults |
|
95 Test should pass |
|
96 */ |
|
97 void CTRalc::TestRALCEntryClass() |
|
98 { |
|
99 INFO_PRINTF1(_L("Test of CFbsRalCacheEl API")); |
|
100 |
|
101 // Test the API on a defaultly built element object |
|
102 { |
|
103 CFbsRalCacheEl elOne; |
|
104 TEST(elOne.iAddress == 0); |
|
105 TEST(elOne.iFilename == 0); |
|
106 |
|
107 // Test matching method |
|
108 TBool r1 = EFalse; |
|
109 r1 = elOne.MatchKey (KMbmFileEikon); |
|
110 TEST(r1 == EFalse); |
|
111 |
|
112 // Test destruction |
|
113 } |
|
114 |
|
115 // Test a New'd element object followed by delete |
|
116 { |
|
117 CFbsRalCacheEl *elTwo = 0; |
|
118 elTwo = CFbsRalCacheEl::New(KMbmFileTimew, (TAny*)0x58001000); |
|
119 TEST(elTwo != 0); |
|
120 TEST(elTwo->iFilename->CompareF(KMbmFileTimew) == 0); |
|
121 TEST(elTwo->iAddress == (TAny*)0x58001000); |
|
122 |
|
123 delete elTwo; |
|
124 } |
|
125 |
|
126 // Test a New'd element object followed by destroy & free |
|
127 { |
|
128 CFbsRalCacheEl *elThree = 0; |
|
129 elThree = CFbsRalCacheEl::New(KMbmFileLafcursLong, (TAny*)0x58002000); |
|
130 TEST(elThree != 0); |
|
131 TEST(elThree->iFilename->CompareF(KMbmFileLafcursLong) == 0); |
|
132 TEST(elThree->iAddress == (TAny*)0x58002000); |
|
133 |
|
134 elThree->~CFbsRalCacheEl(); |
|
135 TEST(elThree->iFilename == 0); |
|
136 CFbsRalCacheEl::FreeOnly(elThree); |
|
137 TEST(elThree == 0); |
|
138 } |
|
139 |
|
140 // Test matching of an element object |
|
141 { |
|
142 CFbsRalCacheEl *elFour = 0; |
|
143 elFour = CFbsRalCacheEl::New(KMbmFileTechview, (TAny*)0x58003000); |
|
144 TEST(elFour != 0); |
|
145 |
|
146 TBool r2 = EFalse; |
|
147 r2 = elFour->MatchKey (KMbmFileEikon); |
|
148 TEST(r2 == EFalse); |
|
149 |
|
150 r2 = elFour->MatchKey (KMbmFileTechview); |
|
151 TEST(r2); |
|
152 |
|
153 r2 = elFour->MatchKey(KMbmFileTechviewU); |
|
154 TEST(r2); |
|
155 |
|
156 delete elFour; |
|
157 } |
|
158 } |
|
159 |
|
160 /** |
|
161 @SYMTestCaseID |
|
162 GRAPHICS-FBSERV-0605 |
|
163 |
|
164 @SYMTestCaseDesc |
|
165 Tests the RALC Cache class. |
|
166 |
|
167 @SYMTestActions |
|
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. |
|
171 |
|
172 @SYMTestExpectedResults |
|
173 Test should pass |
|
174 */ |
|
175 void CTRalc::TestRALCCacheClass() |
|
176 { |
|
177 RFs fileServer; |
|
178 TInt ret; |
|
179 |
|
180 ret = fileServer.Connect(); |
|
181 TEST(ret==KErrNone); |
|
182 |
|
183 INFO_PRINTF1(_L("Test of CFbsRalCache API")); |
|
184 |
|
185 // Test the construction/destruction API |
|
186 { |
|
187 CFbsRalCache* cache1 = CFbsRalCache::New(0, fileServer); |
|
188 TEST(cache1 == 0); |
|
189 |
|
190 cache1 = CFbsRalCache::New(5, fileServer); |
|
191 TEST(cache1 != 0); |
|
192 TEST(cache1->Count() == 0); |
|
193 TEST(cache1->Length() == 5); |
|
194 |
|
195 delete cache1; |
|
196 } |
|
197 |
|
198 // Test the lookup facility of the cache with overflow |
|
199 { |
|
200 CFbsRalCache* cache2 = CFbsRalCache::New(2, fileServer); |
|
201 |
|
202 TAny* p1; |
|
203 p1 = cache2->Lookup(KMbmFileLafcurs); |
|
204 TEST(p1 != 0); |
|
205 TEST(cache2->Count() == 1); |
|
206 |
|
207 p1 = cache2->Lookup(KMbmFileShel); |
|
208 TEST(p1 == 0); |
|
209 TEST(cache2->Count() == 1); |
|
210 |
|
211 p1 = cache2->Lookup(KMbmFileShell); |
|
212 TEST(p1 != 0); |
|
213 TEST(cache2->Count() == 2); |
|
214 |
|
215 p1 = cache2->Lookup(KMbmFileEikon); |
|
216 TEST(p1 != 0); |
|
217 TEST(cache2->Count() == 2); |
|
218 |
|
219 delete cache2; |
|
220 } |
|
221 |
|
222 fileServer.Close(); |
|
223 } |
|
224 |
|
225 /** |
|
226 @SYMTestCaseID |
|
227 GRAPHICS-FBSERV-0606 |
|
228 |
|
229 @SYMTestCaseDesc |
|
230 Tests Out Of Memory conditions for the CFbsRalCache class. |
|
231 |
|
232 @SYMTestActions |
|
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 |
|
237 server handle. |
|
238 |
|
239 @SYMTestExpectedResults |
|
240 Test should pass |
|
241 */ |
|
242 void CTRalc::TestOOMCondition() |
|
243 { |
|
244 RFs fileServer; |
|
245 TInt ret; |
|
246 ret = fileServer.Connect(); |
|
247 TEST(ret==KErrNone); |
|
248 |
|
249 INFO_PRINTF1(_L("Test of CFbsRalCache and OOM")); |
|
250 |
|
251 for (TInt count = 1; ; count++) |
|
252 { |
|
253 __UHEAP_SETFAIL(RHeap::EDeterministic,count); |
|
254 __UHEAP_MARK; |
|
255 |
|
256 CFbsRalCache* cache = 0; |
|
257 cache = CFbsRalCache::New(4, fileServer); |
|
258 |
|
259 if (cache == 0) |
|
260 { |
|
261 __UHEAP_MARKEND; |
|
262 } |
|
263 else |
|
264 { |
|
265 delete cache; |
|
266 __UHEAP_MARKEND; |
|
267 __UHEAP_SETFAIL(RHeap::ENone,count); |
|
268 break; |
|
269 } |
|
270 } |
|
271 |
|
272 fileServer.Close(); |
|
273 } |
|
274 |
|
275 /** |
|
276 @SYMTestCaseID |
|
277 GRAPHICS-FBSERV-0607 |
|
278 |
|
279 @SYMTestCaseDesc |
|
280 Intended to measure performance of bitmap loading. |
|
281 |
|
282 @SYMTestActions |
|
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. |
|
286 |
|
287 @SYMTestExpectedResults |
|
288 No test result is given in the function. |
|
289 */ |
|
290 void CTRalc::MeasurePerformanceWith2() |
|
291 { |
|
292 TInt loopI; |
|
293 CFbsBitmap bitmap1; |
|
294 CFbsBitmap bitmap2; |
|
295 |
|
296 INFO_PRINTF1(_L("Performance Test with 2 Lookups")); |
|
297 |
|
298 for (loopI=0; loopI<2700; loopI++) |
|
299 bitmap1.Load(KMbmFileLafcurs, 0, EFalse); |
|
300 |
|
301 for (loopI=0; loopI<600; loopI++) |
|
302 bitmap2.Load(KMbmFileShell, 0, EFalse); |
|
303 |
|
304 /* RDebug::ProfileEnd(10); |
|
305 TProfile profile; |
|
306 RDebug::ProfileResult(&profile,10,1); |
|
307 RDebug::Print(_L("Performance test end %d.%d s\n"),profile.iTime/1000000,(profile.iTime/1000)%1000); */ |
|
308 } |
|
309 |
|
310 /** |
|
311 @SYMTestCaseID |
|
312 GRAPHICS-FBSERV-0609 |
|
313 |
|
314 @SYMTestCaseDesc |
|
315 Intended to measure performance of bitmap loading. |
|
316 |
|
317 @SYMTestActions |
|
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. |
|
321 |
|
322 @SYMTestExpectedResults |
|
323 No test result is given in the function. |
|
324 */ |
|
325 void CTRalc::MeasurePerformanceWith2Long() |
|
326 { |
|
327 TInt loopI; |
|
328 CFbsBitmap bitmap1; |
|
329 CFbsBitmap bitmap2; |
|
330 |
|
331 INFO_PRINTF1(_L("Performance Test with 2 LONG Lookups")); |
|
332 // RDebug::ProfileReset(10, 1); |
|
333 // RDebug::ProfileStart(10); |
|
334 |
|
335 for (loopI=0; loopI<2700; loopI++) |
|
336 (void)bitmap1.Load(KMbmFileLafcursLong, 0, EFalse); |
|
337 |
|
338 for (loopI=0; loopI<600; loopI++) |
|
339 (void)bitmap2.Load(KMbmFileShellLong, 0, EFalse); |
|
340 |
|
341 /* RDebug::ProfileEnd(10); |
|
342 TProfile profile; |
|
343 RDebug::ProfileResult(&profile,10,1); |
|
344 RDebug::Print(_L("Performance test end %d.%d s\n"),profile.iTime/1000000,(profile.iTime/1000)%1000); */ |
|
345 } |
|
346 |
|
347 /** |
|
348 @SYMTestCaseID |
|
349 GRAPHICS-FBSERV-0608 |
|
350 |
|
351 @SYMTestCaseDesc |
|
352 Intended to measure performance of bitmap loading. |
|
353 |
|
354 @SYMTestActions |
|
355 Creates five CFbsBitmap objects on the stack and |
|
356 loads different bitmap files in to the objects in a loop. |
|
357 |
|
358 @SYMTestExpectedResults |
|
359 No test result is given in the function. |
|
360 */ |
|
361 void CTRalc::MeasurePerformanceWith5() |
|
362 { |
|
363 TInt loopI; |
|
364 CFbsBitmap bitmap1; |
|
365 CFbsBitmap bitmap2; |
|
366 CFbsBitmap bitmap3; |
|
367 CFbsBitmap bitmap4; |
|
368 CFbsBitmap bitmap5; |
|
369 |
|
370 INFO_PRINTF1(_L("Performance Test with 5 Lookups")); |
|
371 // RDebug::ProfileReset(10, 1); |
|
372 // RDebug::ProfileStart(10); |
|
373 |
|
374 for (loopI=0; loopI<500; loopI++) |
|
375 bitmap1.Load(KMbmFileEikon, 0, EFalse); |
|
376 |
|
377 for (loopI=0; loopI<200; loopI++) |
|
378 bitmap2.Load(KMbmFileTechview, 0, EFalse); |
|
379 |
|
380 for (loopI=0; loopI<2700; loopI++) |
|
381 bitmap3.Load(KMbmFileLafcurs, 0, EFalse); |
|
382 |
|
383 for (loopI=0; loopI<600; loopI++) |
|
384 bitmap4.Load(KMbmFileShell, 0, EFalse); |
|
385 |
|
386 for (loopI=0; loopI<1100; loopI++) |
|
387 bitmap5.Load(KMbmFileTimew, 0, EFalse); |
|
388 |
|
389 /* RDebug::ProfileEnd(10); |
|
390 TProfile profile; |
|
391 RDebug::ProfileResult(&profile,10,1); |
|
392 RDebug::Print(_L("Performance test end %d.%d s\n"),profile.iTime/1000000,(profile.iTime/1000)%1000); */ |
|
393 } |
|
394 |
|
395 /** |
|
396 @SYMTestCaseID |
|
397 GRAPHICS-FBSERV-0610 |
|
398 |
|
399 @SYMTestCaseDesc |
|
400 Intended to measure performance of bitmap loading. |
|
401 |
|
402 @SYMTestActions |
|
403 Creates five CFbsBitmap objects on the stack and |
|
404 loads different bitmap files in to the objects in a loop. |
|
405 |
|
406 @SYMTestExpectedResults |
|
407 No test result is given in the function. |
|
408 */ |
|
409 void CTRalc::MeasurePerformanceWith23Mix() |
|
410 { |
|
411 TInt loopI; |
|
412 CFbsBitmap bitmap1; |
|
413 CFbsBitmap bitmap2; |
|
414 CFbsBitmap bitmap3; |
|
415 CFbsBitmap bitmap4; |
|
416 CFbsBitmap bitmap5; |
|
417 |
|
418 INFO_PRINTF1(_L("Performance Test with 2/3 Mix of Lookups")); |
|
419 // RDebug::ProfileReset(10, 1); |
|
420 // RDebug::ProfileStart(10); |
|
421 |
|
422 for (loopI=0; loopI<500; loopI++) |
|
423 bitmap1.Load(KMbmFileEikon, 0, EFalse); |
|
424 |
|
425 for (loopI=0; loopI<200; loopI++) |
|
426 bitmap2.Load(KMbmFileTechview, 0, EFalse); |
|
427 |
|
428 for (loopI=0; loopI<2700; loopI++) |
|
429 bitmap3.Load(KMbmFileLafcursLong, 0, EFalse); |
|
430 |
|
431 for (loopI=0; loopI<600; loopI++) |
|
432 bitmap4.Load(KMbmFileShellLong, 0, EFalse); |
|
433 |
|
434 for (loopI=0; loopI<1100; loopI++) |
|
435 bitmap5.Load(KMbmFileTimew, 0, EFalse); |
|
436 |
|
437 /* RDebug::ProfileEnd(10); |
|
438 TProfile profile; |
|
439 RDebug::ProfileResult(&profile,10,1); |
|
440 RDebug::Print(_L("Performance test end %d.%d s\n"),profile.iTime/1000000,(profile.iTime/1000)%1000);*/ |
|
441 } |
|
442 |
|
443 void CTRalc::RunTestCaseL(TInt aCurTestCase) |
|
444 { |
|
445 TUint32* romAddress = NULL; |
|
446 if(!CFbsBitmap::IsFileInRom(KMbmFileEikon, romAddress)) //check any rom bitmap |
|
447 { |
|
448 INFO_PRINTF2(_L("Skipping CFbsRalCache tests since file \"%S\" is reported to not be a ROM bitmap."), |
|
449 &KMbmFileEikon); |
|
450 INFO_PRINTF1(_L("This should only occur on non-XIP ROMs, e.g. NAND ROMs, where ROM bitmaps aren't supported.")); |
|
451 TestComplete(); |
|
452 } |
|
453 else |
|
454 { |
|
455 ((CTRalcStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
456 switch(aCurTestCase) |
|
457 { |
|
458 case 1: |
|
459 ((CTRalcStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0604")); |
|
460 TestRALCEntryClass(); |
|
461 break; |
|
462 case 2: |
|
463 ((CTRalcStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0605")); |
|
464 TestRALCCacheClass(); |
|
465 break; |
|
466 case 3: |
|
467 ((CTRalcStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0606")); |
|
468 TestOOMCondition(); |
|
469 break; |
|
470 case 4: |
|
471 ((CTRalcStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0607")); |
|
472 MeasurePerformanceWith2(); |
|
473 break; |
|
474 case 5: |
|
475 ((CTRalcStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0608")); |
|
476 MeasurePerformanceWith5(); |
|
477 break; |
|
478 case 6: |
|
479 ((CTRalcStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0609")); |
|
480 MeasurePerformanceWith2Long(); |
|
481 break; |
|
482 case 7: |
|
483 ((CTRalcStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0610")); |
|
484 MeasurePerformanceWith23Mix(); |
|
485 break; |
|
486 case 8: |
|
487 ((CTRalcStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
488 ((CTRalcStep*)iStep)->CloseTMSGraphicsStep(); |
|
489 TestComplete(); |
|
490 break; |
|
491 } |
|
492 ((CTRalcStep*)iStep)->RecordTestResultL(); |
|
493 } |
|
494 } |
|
495 |
|
496 //-------------- |
|
497 __CONSTRUCT_STEP__(Ralc) |
|
498 |
|
499 void CTRalcStep::TestSetupL() |
|
500 { |
|
501 // Leaking thread handles |
|
502 iThread.HandleCount(iStartProcessHandleCount, iStartThreadHandleCount); |
|
503 } |
|
504 |
|
505 void CTRalcStep::TestClose() |
|
506 { |
|
507 // Check for open handles |
|
508 iThread.HandleCount(iEndProcessHandleCount, iEndThreadHandleCount); |
|
509 if(iStartThreadHandleCount != iEndThreadHandleCount) |
|
510 {__DEBUGGER()} // Oops leaked some handles |
|
511 } |