|
1 // Copyright (c) 1996-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 <s32file.h> |
|
17 #include <graphics/bitmapuid.h> |
|
18 #include "../sfbs/UTILS.H" |
|
19 #include "TFBS.H" |
|
20 #include "TALLOC.H" |
|
21 #include "../sfbs/fbsbitmapasyncstreamer.h" |
|
22 #include "fbsmessage.h" |
|
23 #include "fbsdefs.h" |
|
24 |
|
25 const TSize KLargeSize(4096 + 100, 1); |
|
26 const TSize KLargeSizeAlt(4096 + 200, 2); |
|
27 const TSize KSmallSize(10, 10); |
|
28 const TSize KSmallSizeAlt(20, 20); |
|
29 |
|
30 CTAlloc::CTAlloc(CTestStep* aStep): |
|
31 CTGraphicsBase(aStep), |
|
32 iFbs(NULL), |
|
33 iStore(NULL), |
|
34 iBitmap(NULL), |
|
35 iBitmap2(NULL) |
|
36 { |
|
37 INFO_PRINTF1(_L("Font/Bitmap Server Alloc Failure Recovery Testing")); |
|
38 } |
|
39 |
|
40 CTAlloc::~CTAlloc() |
|
41 { |
|
42 if (iShutdownFbs) |
|
43 { |
|
44 iFbs->SendCommand(EFbsMessShutdown); |
|
45 } |
|
46 iFbs->Disconnect(); |
|
47 |
|
48 delete iStore; |
|
49 } |
|
50 |
|
51 void CTAlloc::ConstructL() |
|
52 { |
|
53 iStore = CFbsTypefaceStore::NewL(NULL); |
|
54 |
|
55 if(RFbsSession::Connect()==KErrNone) |
|
56 { |
|
57 RFbsSession::Disconnect(); |
|
58 iShutdownFbs = EFalse; |
|
59 } |
|
60 else |
|
61 { |
|
62 FbsStartup(); |
|
63 iShutdownFbs = ETrue; |
|
64 } |
|
65 } |
|
66 |
|
67 void CTAlloc::RunTestCaseL(TInt aCurTestCase) |
|
68 { |
|
69 ((CTAllocStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
70 switch(aCurTestCase) |
|
71 { |
|
72 case 1: |
|
73 ((CTAllocStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0511")); |
|
74 Session(); |
|
75 break; |
|
76 case 2: |
|
77 { |
|
78 /** |
|
79 @SYMTestCaseID GRAPHICS-FBSERV-0611 |
|
80 */ |
|
81 ((CTAllocStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0611")); |
|
82 TInt ret = RFbsSession::Connect(); |
|
83 TEST2(ret, KErrNone); |
|
84 iFbs = RFbsSession::GetSession(); |
|
85 TEST(iFbs != NULL); |
|
86 } |
|
87 break; |
|
88 case 4: |
|
89 ((CTAllocStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0512")); |
|
90 BitmapsL(); |
|
91 break; |
|
92 case 5: |
|
93 ((CTAllocStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0514")); |
|
94 BitmapHandlerL(); |
|
95 break; |
|
96 case 6: |
|
97 ((CTAllocStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0513")); |
|
98 TypefaceStoreL(); |
|
99 break; |
|
100 case 7: |
|
101 ((CTAllocStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0515")); |
|
102 FontStoreL(); |
|
103 break; |
|
104 case 8: |
|
105 ((CTAllocStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
106 ((CTAllocStep*)iStep)->CloseTMSGraphicsStep(); |
|
107 TestComplete(); |
|
108 break; |
|
109 default: |
|
110 ((CTAllocStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
111 break; |
|
112 } |
|
113 ((CTAllocStep*)iStep)->RecordTestResultL(); |
|
114 } |
|
115 |
|
116 /** |
|
117 @SYMTestCaseID |
|
118 GRAPHICS-FBSERV-0511 |
|
119 |
|
120 @SYMTestCaseDesc |
|
121 Allocated sessions with the FbsServer and simulates memory allocation errors |
|
122 |
|
123 @SYMTestActions |
|
124 Checks the heap |
|
125 |
|
126 @SYMTestExpectedResults |
|
127 Test should pass |
|
128 */ |
|
129 void CTAlloc::Session() |
|
130 { |
|
131 INFO_PRINTF1(_L("RFbsSession::Connect()\r\n")); |
|
132 |
|
133 for (TInt count = 1; ; count++) |
|
134 { |
|
135 __UHEAP_FAILNEXT(count); |
|
136 __UHEAP_MARK; |
|
137 |
|
138 TInt ret = RFbsSession::Connect(); |
|
139 |
|
140 if (ret == KErrNoMemory) |
|
141 { |
|
142 __UHEAP_MARKEND; |
|
143 } |
|
144 else if (ret == KErrNone) |
|
145 { |
|
146 RFbsSession::Disconnect(); |
|
147 __UHEAP_MARKEND; |
|
148 break; |
|
149 } |
|
150 else |
|
151 { |
|
152 __UHEAP_MARKEND; |
|
153 TEST2(ret, KErrNone); |
|
154 } |
|
155 } |
|
156 |
|
157 __UHEAP_RESET; |
|
158 } |
|
159 |
|
160 /** |
|
161 @SYMTestCaseID |
|
162 GRAPHICS-FBSERV-0512 |
|
163 |
|
164 @SYMTestCaseDesc |
|
165 Creates bitmaps in different ways and checks if memory allocation succeeded |
|
166 |
|
167 @SYMTestActions |
|
168 Creates normal size bitmaps, large bitmaps, loads bitmaps, loads shared bitmaps, |
|
169 duplicated bitmaps, resizes bitmaps, compresses bitmaps, externalized bitmaps to write store, |
|
170 internalizes bitmaps back again from write store. All ways of creating bitmaps are tested |
|
171 against Out Of Memory error conditions |
|
172 |
|
173 @SYMTestExpectedResults |
|
174 Test should pass |
|
175 */ |
|
176 void CTAlloc::BitmapsL() |
|
177 { |
|
178 TInt heapMarkCheckFlag; |
|
179 if( !iStep->GetIntFromConfig(KDefaultSectionName, KFbsHeapMarkCheckFlag, heapMarkCheckFlag) ) |
|
180 { |
|
181 INFO_PRINTF1(_L("Error reading ini file")); |
|
182 User::Leave(KErrNotFound); |
|
183 } |
|
184 |
|
185 CFbsBitmap iBitmap; |
|
186 CFbsBitmap iBitmap2; |
|
187 |
|
188 iTestBitmapName = KTestBitmapOnZ; |
|
189 TInt ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL); |
|
190 TEST2(ret, KErrNone); |
|
191 |
|
192 ret = iBitmap.Create(KLargeSize,EColor256); // Expand server caches |
|
193 TEST2(ret, KErrNone); |
|
194 iBitmap.Reset(); |
|
195 |
|
196 TInt count; |
|
197 |
|
198 // Create bitmap |
|
199 INFO_PRINTF1(_L("CFbsBitmap::Create()\r\n")); |
|
200 for (count = 1; ; count++) |
|
201 { |
|
202 iFbs->SendCommand(EFbsMessDefaultAllocFail,count); |
|
203 if(heapMarkCheckFlag) |
|
204 { |
|
205 iFbs->SendCommand(EFbsMessDefaultMark); |
|
206 iFbs->SendCommand(EFbsMessUserMark); |
|
207 } |
|
208 ret = iBitmap.Create(KSmallSize,EColor256); |
|
209 |
|
210 if (ret == KErrNoMemory) |
|
211 { |
|
212 if(heapMarkCheckFlag) |
|
213 { |
|
214 iFbs->SendCommand(EFbsMessDefaultMark); |
|
215 iFbs->SendCommand(EFbsMessUserMark); |
|
216 } |
|
217 } |
|
218 else if (ret == KErrNone) |
|
219 { |
|
220 iBitmap.Reset(); |
|
221 if(heapMarkCheckFlag) |
|
222 { |
|
223 iFbs->SendCommand(EFbsMessDefaultMark); |
|
224 iFbs->SendCommand(EFbsMessUserMark); |
|
225 } |
|
226 break; |
|
227 } |
|
228 else |
|
229 TEST2(ret, KErrNone); |
|
230 } |
|
231 |
|
232 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
233 iFbs->SendCommand(EFbsMessUserAllocFail,0); |
|
234 TEST(iFbs->ResourceCount()==0); |
|
235 |
|
236 for (count = 1; ; count++) |
|
237 { |
|
238 iFbs->SendCommand(EFbsMessUserAllocFail,count); |
|
239 if(heapMarkCheckFlag) |
|
240 { |
|
241 iFbs->SendCommand(EFbsMessDefaultMark); |
|
242 iFbs->SendCommand(EFbsMessUserMark); |
|
243 } |
|
244 |
|
245 ret=iBitmap.Create(KSmallSize,EGray2); |
|
246 |
|
247 if (ret == KErrNoMemory) |
|
248 { |
|
249 if(heapMarkCheckFlag) |
|
250 { |
|
251 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
252 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
253 } |
|
254 } |
|
255 else if (ret == KErrNone) |
|
256 { |
|
257 iBitmap.Reset(); |
|
258 if(heapMarkCheckFlag) |
|
259 { |
|
260 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
261 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
262 } |
|
263 break; |
|
264 } |
|
265 else |
|
266 TEST2(ret, KErrNone); |
|
267 } |
|
268 |
|
269 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
270 iFbs->SendCommand(EFbsMessUserAllocFail,0); |
|
271 TEST(iFbs->ResourceCount()==0); |
|
272 |
|
273 // Create (large) |
|
274 for (count = 1; ; count++) |
|
275 { |
|
276 iFbs->SendCommand(EFbsMessDefaultAllocFail,count); |
|
277 if(heapMarkCheckFlag) |
|
278 { |
|
279 iFbs->SendCommand(EFbsMessDefaultMark); |
|
280 iFbs->SendCommand(EFbsMessUserMark); |
|
281 } |
|
282 |
|
283 ret = iBitmap.Create(KLargeSize,EColor256); |
|
284 |
|
285 if (ret == KErrNoMemory) |
|
286 { |
|
287 if(heapMarkCheckFlag) |
|
288 { |
|
289 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
290 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
291 } |
|
292 } |
|
293 else if (ret == KErrNone) |
|
294 { |
|
295 iBitmap.Reset(); |
|
296 if(heapMarkCheckFlag) |
|
297 { |
|
298 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
299 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
300 } |
|
301 break; |
|
302 } |
|
303 else |
|
304 TEST2(ret, KErrNone); |
|
305 } |
|
306 |
|
307 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
308 iFbs->SendCommand(EFbsMessUserAllocFail,0); |
|
309 TEST(iFbs->ResourceCount()==0); |
|
310 |
|
311 for (count = 1; ; count++) |
|
312 { |
|
313 iFbs->SendCommand(EFbsMessUserAllocFail,count); |
|
314 if(heapMarkCheckFlag) |
|
315 { |
|
316 iFbs->SendCommand(EFbsMessDefaultMark); |
|
317 iFbs->SendCommand(EFbsMessUserMark); |
|
318 } |
|
319 |
|
320 ret = iBitmap.Create(KLargeSize,EColor256); |
|
321 |
|
322 if (ret == KErrNoMemory) |
|
323 { |
|
324 if(heapMarkCheckFlag) |
|
325 { |
|
326 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
327 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
328 } |
|
329 } |
|
330 else if (ret == KErrNone) |
|
331 { |
|
332 iBitmap.Reset(); |
|
333 if(heapMarkCheckFlag) |
|
334 { |
|
335 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
336 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
337 } |
|
338 break; |
|
339 } |
|
340 else |
|
341 TEST2(ret, KErrNone); |
|
342 } |
|
343 |
|
344 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
345 iFbs->SendCommand(EFbsMessUserAllocFail,0); |
|
346 TEST(iFbs->ResourceCount()==0); |
|
347 |
|
348 // Load |
|
349 INFO_PRINTF1(_L("CFbsBitmap::Load()\r\n")); |
|
350 ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL); |
|
351 TEST2(ret, KErrNone); |
|
352 iBitmap.Reset(); |
|
353 for (count = 1; ; count++) |
|
354 { |
|
355 iFbs->SendCommand(EFbsMessDefaultAllocFail,count); |
|
356 if(heapMarkCheckFlag) |
|
357 { |
|
358 iFbs->SendCommand(EFbsMessDefaultMark); |
|
359 iFbs->SendCommand(EFbsMessUserMark); |
|
360 } |
|
361 |
|
362 ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL); |
|
363 |
|
364 if (ret == KErrNoMemory) |
|
365 { |
|
366 if(heapMarkCheckFlag) |
|
367 { |
|
368 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
369 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
370 } |
|
371 } |
|
372 else if (ret == KErrNone) |
|
373 { |
|
374 iBitmap.Reset(); |
|
375 if(heapMarkCheckFlag) |
|
376 { |
|
377 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
378 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
379 } |
|
380 break; |
|
381 } |
|
382 else |
|
383 TEST2(ret, KErrNone); |
|
384 } |
|
385 |
|
386 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
387 iFbs->SendCommand(EFbsMessUserAllocFail,0); |
|
388 TEST(iFbs->ResourceCount()==0); |
|
389 |
|
390 for (count = 1; ; count++) |
|
391 { |
|
392 iFbs->SendCommand(EFbsMessUserAllocFail,count); |
|
393 if(heapMarkCheckFlag) |
|
394 { |
|
395 iFbs->SendCommand(EFbsMessDefaultMark); |
|
396 iFbs->SendCommand(EFbsMessUserMark); |
|
397 } |
|
398 |
|
399 ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL); |
|
400 |
|
401 if (ret == KErrNoMemory) |
|
402 { |
|
403 if(heapMarkCheckFlag) |
|
404 { |
|
405 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
406 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
407 } |
|
408 } |
|
409 else if (ret == KErrNone) |
|
410 { |
|
411 iBitmap.Reset(); |
|
412 if(heapMarkCheckFlag) |
|
413 { |
|
414 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
415 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
416 } |
|
417 break; |
|
418 } |
|
419 else |
|
420 TEST2(ret, KErrNone); |
|
421 } |
|
422 |
|
423 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
424 iFbs->SendCommand(EFbsMessUserAllocFail,0); |
|
425 TEST(iFbs->ResourceCount()==0); |
|
426 |
|
427 // Load (shared) |
|
428 INFO_PRINTF1(_L("CFbsBitmap::Load() - shared \r\n")); |
|
429 |
|
430 // Do an initial load to ensure the StreamId cache does not get updated whilst OOM testing |
|
431 ret = iBitmap.Load(iTestBitmapName,ETfbs,ETrue); |
|
432 TEST2(ret, KErrNone); |
|
433 iBitmap.Reset(); |
|
434 |
|
435 for (count = 1; ; count++) |
|
436 { |
|
437 iFbs->SendCommand(EFbsMessDefaultAllocFail,count); |
|
438 if(heapMarkCheckFlag) |
|
439 { |
|
440 iFbs->SendCommand(EFbsMessDefaultMark); |
|
441 iFbs->SendCommand(EFbsMessUserMark); |
|
442 } |
|
443 |
|
444 ret = iBitmap.Load(iTestBitmapName,ETfbs,ETrue); |
|
445 |
|
446 if (ret == KErrNoMemory) |
|
447 { |
|
448 if(heapMarkCheckFlag) |
|
449 { |
|
450 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
451 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
452 } |
|
453 continue; |
|
454 } |
|
455 else if (ret != KErrNone) |
|
456 TEST2(ret, KErrNone); |
|
457 |
|
458 ret = iBitmap2.Load(iTestBitmapName,ETfbs,ETrue); |
|
459 |
|
460 if (ret == KErrNoMemory) |
|
461 { |
|
462 iBitmap.Reset(); |
|
463 if(heapMarkCheckFlag) |
|
464 { |
|
465 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
466 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
467 } |
|
468 continue; |
|
469 } |
|
470 else if (ret == KErrNone) |
|
471 { |
|
472 iBitmap.Reset(); |
|
473 iBitmap2.Reset(); |
|
474 if(heapMarkCheckFlag) |
|
475 { |
|
476 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
477 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
478 } |
|
479 break; |
|
480 } |
|
481 else |
|
482 TEST2(ret, KErrNone); |
|
483 } |
|
484 |
|
485 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
486 iFbs->SendCommand(EFbsMessUserAllocFail,0); |
|
487 TEST(iFbs->ResourceCount()==0); |
|
488 |
|
489 for (count = 1; ; count++) |
|
490 { |
|
491 iFbs->SendCommand(EFbsMessUserAllocFail,count); |
|
492 if(heapMarkCheckFlag) |
|
493 { |
|
494 iFbs->SendCommand(EFbsMessDefaultMark); |
|
495 iFbs->SendCommand(EFbsMessUserMark); |
|
496 } |
|
497 |
|
498 ret = iBitmap.Load(iTestBitmapName,ETfbs,ETrue); |
|
499 |
|
500 if (ret == KErrNoMemory) |
|
501 { |
|
502 if(heapMarkCheckFlag) |
|
503 { |
|
504 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
505 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
506 } |
|
507 continue; |
|
508 } |
|
509 else if (ret != KErrNone) |
|
510 TEST2(ret, KErrNone); |
|
511 |
|
512 ret = iBitmap2.Load(iTestBitmapName,ETfbs,ETrue); |
|
513 |
|
514 if (ret == KErrNoMemory) |
|
515 { |
|
516 iBitmap.Reset(); |
|
517 if(heapMarkCheckFlag) |
|
518 { |
|
519 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
520 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
521 } |
|
522 continue; |
|
523 } |
|
524 else if (ret == KErrNone) |
|
525 { |
|
526 iBitmap.Reset(); |
|
527 iBitmap2.Reset(); |
|
528 if(heapMarkCheckFlag) |
|
529 { |
|
530 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
531 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
532 } |
|
533 break; |
|
534 } |
|
535 else |
|
536 TEST2(ret, KErrNone); |
|
537 } |
|
538 |
|
539 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
540 iFbs->SendCommand(EFbsMessUserAllocFail,0); |
|
541 TEST(iFbs->ResourceCount()==0); |
|
542 |
|
543 |
|
544 // Duplicate |
|
545 CFbsBitmap bmpalt; |
|
546 ret = bmpalt.Create(KSmallSize,EColor256); |
|
547 TEST2(ret, KErrNone); |
|
548 |
|
549 INFO_PRINTF1(_L("CFbsBitmap::Duplicate()\r\n")); |
|
550 for (count = 1; ; count++) |
|
551 { |
|
552 iFbs->SendCommand(EFbsMessDefaultAllocFail,count); |
|
553 if(heapMarkCheckFlag) |
|
554 { |
|
555 iFbs->SendCommand(EFbsMessDefaultMark); |
|
556 iFbs->SendCommand(EFbsMessUserMark); |
|
557 } |
|
558 |
|
559 ret = iBitmap.Duplicate(bmpalt.Handle()); |
|
560 |
|
561 if (ret == KErrNoMemory) |
|
562 { |
|
563 if(heapMarkCheckFlag) |
|
564 { |
|
565 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
566 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
567 } |
|
568 } |
|
569 else if (ret == KErrNone) |
|
570 { |
|
571 iBitmap.Reset(); |
|
572 if(heapMarkCheckFlag) |
|
573 { |
|
574 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
575 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
576 } |
|
577 break; |
|
578 } |
|
579 else |
|
580 TEST2(ret, KErrNone); |
|
581 } |
|
582 |
|
583 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
584 iFbs->SendCommand(EFbsMessUserAllocFail,0); |
|
585 TEST(iFbs->ResourceCount()==1); |
|
586 ret = bmpalt.Create(KSmallSize,EColor256); |
|
587 TEST2(ret, KErrNone); |
|
588 |
|
589 for (count = 1; ; count++) |
|
590 { |
|
591 iFbs->SendCommand(EFbsMessUserAllocFail,count); |
|
592 if(heapMarkCheckFlag) |
|
593 { |
|
594 iFbs->SendCommand(EFbsMessDefaultMark); |
|
595 iFbs->SendCommand(EFbsMessUserMark); |
|
596 } |
|
597 |
|
598 ret = iBitmap.Duplicate(bmpalt.Handle()); |
|
599 |
|
600 if (ret == KErrNoMemory) |
|
601 { |
|
602 if(heapMarkCheckFlag) |
|
603 { |
|
604 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
605 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
606 } |
|
607 } |
|
608 else if (ret == KErrNone) |
|
609 { |
|
610 iBitmap.Reset(); |
|
611 if(heapMarkCheckFlag) |
|
612 { |
|
613 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
614 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
615 } |
|
616 break; |
|
617 } |
|
618 else |
|
619 TEST2(ret, KErrNone); |
|
620 } |
|
621 |
|
622 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
623 iFbs->SendCommand(EFbsMessUserAllocFail,0); |
|
624 bmpalt.Reset(); |
|
625 TEST(iFbs->ResourceCount()==0); |
|
626 |
|
627 // Resize |
|
628 // force fbserv to do a resize. This makes the pile to insert an index in it's array |
|
629 // If the array is empty when the tests below are run then the insert will look like a mem leak |
|
630 ret=iBitmap.Create(KLargeSize,EColor256); |
|
631 iBitmap.Resize(KLargeSizeAlt); |
|
632 iBitmap.Reset(); |
|
633 |
|
634 ret=iBitmap.Create(KSmallSize,EColor256); |
|
635 TEST2(ret, KErrNone); |
|
636 |
|
637 INFO_PRINTF1(_L("CFbsBitmap::Resize()\r\n")); |
|
638 for (count = 1; ; count++) |
|
639 { |
|
640 iFbs->SendCommand(EFbsMessDefaultAllocFail,count); |
|
641 if(heapMarkCheckFlag) |
|
642 { |
|
643 iFbs->SendCommand(EFbsMessDefaultMark); |
|
644 iFbs->SendCommand(EFbsMessUserMark); |
|
645 } |
|
646 |
|
647 ret = iBitmap.Resize(KSmallSizeAlt); |
|
648 |
|
649 if (ret == KErrNoMemory) |
|
650 { |
|
651 if(heapMarkCheckFlag) |
|
652 { |
|
653 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
654 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
655 } |
|
656 } |
|
657 else if (ret == KErrNone) |
|
658 { |
|
659 iBitmap.Reset(); |
|
660 if(heapMarkCheckFlag) |
|
661 { |
|
662 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
663 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
664 } |
|
665 break; |
|
666 } |
|
667 else |
|
668 TEST2(ret, KErrNone); |
|
669 } |
|
670 |
|
671 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
672 iFbs->SendCommand(EFbsMessUserAllocFail,0); |
|
673 TEST(iFbs->ResourceCount()==0); |
|
674 |
|
675 |
|
676 // force fbserv to do a resize. This makes the pile to insert an index in it's array |
|
677 // If the array is empty when the tests below are run then the insert will look like a mem leak |
|
678 ret=iBitmap.Create(KLargeSize,EColor256); |
|
679 iBitmap.Resize(KLargeSizeAlt); |
|
680 iBitmap.Reset(); |
|
681 |
|
682 ret=iBitmap.Create(KLargeSize,EColor256); |
|
683 TEST2(ret, KErrNone); |
|
684 |
|
685 for (count = 1; ; count++) |
|
686 { |
|
687 iFbs->SendCommand(EFbsMessUserAllocFail,count); |
|
688 if(heapMarkCheckFlag) |
|
689 { |
|
690 iFbs->SendCommand(EFbsMessDefaultMark); |
|
691 iFbs->SendCommand(EFbsMessUserMark); |
|
692 } |
|
693 |
|
694 ret = iBitmap.Resize(KLargeSizeAlt); |
|
695 |
|
696 if (ret == KErrNoMemory) |
|
697 { |
|
698 if(heapMarkCheckFlag) |
|
699 { |
|
700 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
701 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
702 } |
|
703 } |
|
704 else if (ret == KErrNone) |
|
705 { |
|
706 iBitmap.Reset(); |
|
707 if(heapMarkCheckFlag) |
|
708 { |
|
709 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
710 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
711 } |
|
712 break; |
|
713 } |
|
714 else |
|
715 TEST2(ret, KErrNone); |
|
716 } |
|
717 |
|
718 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
719 iFbs->SendCommand(EFbsMessUserAllocFail,0); |
|
720 TEST(iFbs->ResourceCount()==0); |
|
721 |
|
722 // Compress |
|
723 ret=iBitmap.Create(KSmallSize,EColor256); |
|
724 TEST2(ret, KErrNone); |
|
725 |
|
726 INFO_PRINTF1(_L("CFbsBitmap::Compress()\r\n")); |
|
727 for (count = 1; ; count++) |
|
728 { |
|
729 iFbs->SendCommand(EFbsMessDefaultAllocFail,count); |
|
730 if(heapMarkCheckFlag) |
|
731 { |
|
732 iFbs->SendCommand(EFbsMessDefaultMark); |
|
733 iFbs->SendCommand(EFbsMessUserMark); |
|
734 } |
|
735 |
|
736 ret = iBitmap.Compress(); |
|
737 |
|
738 if (ret == KErrNoMemory) |
|
739 { |
|
740 if(heapMarkCheckFlag) |
|
741 { |
|
742 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
743 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
744 } |
|
745 } |
|
746 else if (ret == KErrNone) |
|
747 { |
|
748 iBitmap.Reset(); |
|
749 if(heapMarkCheckFlag) |
|
750 { |
|
751 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
752 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
753 } |
|
754 break; |
|
755 } |
|
756 else |
|
757 TEST2(ret, KErrNone); |
|
758 } |
|
759 |
|
760 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
761 iFbs->SendCommand(EFbsMessUserAllocFail,0); |
|
762 TEST(iFbs->ResourceCount()==0); |
|
763 |
|
764 ret=iBitmap.Create(KLargeSize,EColor256); |
|
765 TEST2(ret, KErrNone); |
|
766 |
|
767 INFO_PRINTF1(_L("CFbsBitmap::Compress()\r\n")); |
|
768 for (count = 1; ; count++) |
|
769 { |
|
770 iFbs->SendCommand(EFbsMessDefaultAllocFail,count); |
|
771 if(heapMarkCheckFlag) |
|
772 { |
|
773 iFbs->SendCommand(EFbsMessDefaultMark); |
|
774 iFbs->SendCommand(EFbsMessUserMark); |
|
775 } |
|
776 |
|
777 ret = iBitmap.Compress(); |
|
778 |
|
779 if (ret == KErrNoMemory) |
|
780 { |
|
781 if(heapMarkCheckFlag) |
|
782 { |
|
783 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
784 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
785 } |
|
786 } |
|
787 else if (ret == KErrNone) |
|
788 { |
|
789 iBitmap.Reset(); |
|
790 if(heapMarkCheckFlag) |
|
791 { |
|
792 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
793 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
794 } |
|
795 break; |
|
796 } |
|
797 else |
|
798 TEST2(ret, KErrNone); |
|
799 } |
|
800 |
|
801 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
802 iFbs->SendCommand(EFbsMessUserAllocFail,0); |
|
803 TEST(iFbs->ResourceCount()==0); |
|
804 |
|
805 // WriteStore creation |
|
806 RFs fs; |
|
807 ret=fs.Connect(); |
|
808 TEST2(ret, KErrNone); |
|
809 CDirectFileStore* writestore=NULL; |
|
810 |
|
811 //Construct filename using the thread id to enable concurrent test runs. |
|
812 _LIT(KSbmFileName,"c:\\tall_"); |
|
813 TBuf<36> buf(KSbmFileName); |
|
814 TThreadId threadId = RThread().Id(); |
|
815 TUint64 id = threadId.Id(); |
|
816 TBuf<20> threadIdBuf; |
|
817 threadIdBuf.Num(id); |
|
818 buf.Append(threadIdBuf); |
|
819 buf.Append(_L(".sbm")); |
|
820 |
|
821 TRAP(ret,writestore=CDirectFileStore::ReplaceL(fs,buf,EFileStream|EFileWrite)); |
|
822 TEST2(ret, KErrNone); |
|
823 TUidType uidtype(KDirectFileStoreLayoutUid,KMultiBitmapFileImageUid); |
|
824 TRAP(ret,writestore->SetTypeL(uidtype)); |
|
825 TEST2(ret, KErrNone); |
|
826 |
|
827 RStoreWriteStream writestrm; |
|
828 TStreamId headerid(0); |
|
829 TRAP(ret,headerid=writestrm.CreateL(*writestore)); |
|
830 TEST2(ret, KErrNone); |
|
831 TRAP(ret,writestore->SetRootL(headerid)); |
|
832 TEST2(ret, KErrNone); |
|
833 |
|
834 // Externalize |
|
835 ret=iBitmap.Create(KSmallSize,EColor256); |
|
836 TEST2(ret, KErrNone); |
|
837 |
|
838 INFO_PRINTF1(_L("CFbsBitmap::ExternalizeL()\r\n")); |
|
839 for (count = 1; ; count++) |
|
840 { |
|
841 __UHEAP_SETFAIL(RHeap::EDeterministic,count); |
|
842 __UHEAP_MARK; |
|
843 |
|
844 TRAP(ret,iBitmap.ExternalizeL(writestrm)); |
|
845 |
|
846 if (ret == KErrNoMemory) |
|
847 { |
|
848 __UHEAP_MARKEND; |
|
849 } |
|
850 else if (ret == KErrNone) |
|
851 { |
|
852 iBitmap.Reset(); |
|
853 __UHEAP_MARKEND; |
|
854 break; |
|
855 } |
|
856 else |
|
857 { |
|
858 __UHEAP_MARKEND; |
|
859 TEST2(ret, KErrNone); |
|
860 } |
|
861 } |
|
862 |
|
863 __UHEAP_RESET; |
|
864 TEST(iFbs->ResourceCount()==0); |
|
865 |
|
866 // ExternalizeRectangle |
|
867 ret=iBitmap.Create(KSmallSize,EColor256); |
|
868 TEST2(ret, KErrNone); |
|
869 |
|
870 INFO_PRINTF1(_L("CFbsBitmap::ExternalizeRectangleL()\r\n")); |
|
871 for (count = 1; ; count++) |
|
872 { |
|
873 __UHEAP_SETFAIL(RHeap::EDeterministic,count); |
|
874 __UHEAP_MARK; |
|
875 |
|
876 TRAP(ret,iBitmap.ExternalizeRectangleL(writestrm,TRect(3,3,7,7))); |
|
877 |
|
878 if (ret == KErrNoMemory) |
|
879 { |
|
880 __UHEAP_MARKEND; |
|
881 } |
|
882 else if (ret == KErrNone) |
|
883 { |
|
884 __UHEAP_MARKEND; |
|
885 break; |
|
886 } |
|
887 else |
|
888 { |
|
889 __UHEAP_MARKEND; |
|
890 TEST2(ret, KErrNone); |
|
891 } |
|
892 } |
|
893 |
|
894 __UHEAP_RESET; |
|
895 writestrm.Close(); |
|
896 delete writestore; |
|
897 iBitmap.Reset(); |
|
898 TEST(iFbs->ResourceCount()==0); |
|
899 |
|
900 // Internalize |
|
901 INFO_PRINTF1(_L("CFbsBitmap::InternalizeL()\r\n")); |
|
902 for (count = 1; ; count++) |
|
903 { |
|
904 // ReadStore creation |
|
905 CDirectFileStore* readstore=NULL; |
|
906 TRAP(ret,readstore=CDirectFileStore::OpenL(fs,buf,EFileStream|EFileRead|EFileShareAny)); |
|
907 TEST2(ret, KErrNone); |
|
908 RStoreReadStream readstrm; |
|
909 headerid=readstore->Root(); |
|
910 TRAP(ret,readstrm.OpenL(*readstore,headerid)); |
|
911 TEST2(ret, KErrNone); |
|
912 |
|
913 iFbs->SendCommand(EFbsMessDefaultAllocFail,count); |
|
914 if(heapMarkCheckFlag) |
|
915 { |
|
916 iFbs->SendCommand(EFbsMessDefaultMark); |
|
917 iFbs->SendCommand(EFbsMessUserMark); |
|
918 } |
|
919 |
|
920 TRAP(ret,iBitmap.InternalizeL(readstrm)); |
|
921 |
|
922 readstrm.Close(); |
|
923 delete readstore; |
|
924 |
|
925 if (ret == KErrNoMemory) |
|
926 { |
|
927 if(heapMarkCheckFlag) |
|
928 { |
|
929 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
930 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
931 } |
|
932 } |
|
933 else if (ret == KErrNone) |
|
934 { |
|
935 iBitmap.Reset(); |
|
936 if(heapMarkCheckFlag) |
|
937 { |
|
938 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
939 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
940 } |
|
941 break; |
|
942 } |
|
943 else |
|
944 TEST2(ret, KErrNone); |
|
945 } |
|
946 |
|
947 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
948 iFbs->SendCommand(EFbsMessUserAllocFail,0); |
|
949 TEST(iFbs->ResourceCount()==0); |
|
950 |
|
951 for (count = 1; ; count++) |
|
952 { |
|
953 // ReadStore re-creation |
|
954 CDirectFileStore* readstore=NULL; |
|
955 // TRAP(ret,readstore=CDirectFileStore::OpenL(fs,_L("c:\\tall.sbm"),EFileStream|EFileRead|EFileShareAny)); |
|
956 TRAP(ret,readstore=CDirectFileStore::OpenL(fs,buf,EFileStream|EFileRead|EFileShareAny)); |
|
957 TEST2(ret, KErrNone); |
|
958 headerid=readstore->Root(); |
|
959 RStoreReadStream readstrm; |
|
960 TRAP(ret,readstrm.OpenL(*readstore,headerid)); |
|
961 TEST2(ret, KErrNone); |
|
962 |
|
963 iFbs->SendCommand(EFbsMessUserAllocFail,count); |
|
964 if(heapMarkCheckFlag) |
|
965 { |
|
966 iFbs->SendCommand(EFbsMessDefaultMark); |
|
967 iFbs->SendCommand(EFbsMessUserMark); |
|
968 } |
|
969 |
|
970 TRAP(ret,iBitmap.InternalizeL(readstrm)); |
|
971 |
|
972 readstrm.Close(); |
|
973 delete readstore; |
|
974 |
|
975 if (ret == KErrNoMemory) |
|
976 { |
|
977 if(heapMarkCheckFlag) |
|
978 { |
|
979 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
980 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
981 } |
|
982 } |
|
983 else if (ret == KErrNone) |
|
984 { |
|
985 iBitmap.Reset(); |
|
986 if(heapMarkCheckFlag) |
|
987 { |
|
988 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
989 iFbs->SendCommand(EFbsMessUserMarkEnd); |
|
990 } |
|
991 break; |
|
992 } |
|
993 else |
|
994 TEST2(ret, KErrNone); |
|
995 } |
|
996 |
|
997 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
998 iFbs->SendCommand(EFbsMessUserAllocFail,0); |
|
999 TEST(iFbs->ResourceCount()==0); |
|
1000 |
|
1001 fs.Delete(buf); |
|
1002 fs.Close(); |
|
1003 } |
|
1004 |
|
1005 /** |
|
1006 @SYMTestCaseID |
|
1007 GRAPHICS-FBSERV-0513 |
|
1008 |
|
1009 @SYMTestCaseDesc |
|
1010 Checks allocations of CFbsTypeFaceStore Objects OOM conditions |
|
1011 |
|
1012 @SYMTestActions |
|
1013 Uses different fonts and allocates CFbsTypeFaceStore objects |
|
1014 and checks them under Out Of Memory conditions |
|
1015 |
|
1016 @SYMTestExpectedResults |
|
1017 Test should pass |
|
1018 */ |
|
1019 void CTAlloc::TypefaceStoreL() |
|
1020 { |
|
1021 TInt count; |
|
1022 TInt ret; |
|
1023 CFbsTypefaceStore* tfs = NULL; |
|
1024 INFO_PRINTF1(_L("CFbsTypefaceStore::NewL()\r\n")); |
|
1025 |
|
1026 TInt heapMarkCheckFlag; |
|
1027 if( !iStep->GetIntFromConfig(KDefaultSectionName, KFbsHeapMarkCheckFlag, heapMarkCheckFlag) ) |
|
1028 { |
|
1029 INFO_PRINTF1(_L("Error reading ini file")); |
|
1030 User::Leave(KErrNotFound); |
|
1031 } |
|
1032 |
|
1033 // CFbsTypefaceStore::NewL() |
|
1034 for (count = 1; ; count++) |
|
1035 { |
|
1036 __UHEAP_SETFAIL(RHeap::EDeterministic,count); |
|
1037 __UHEAP_MARK; |
|
1038 |
|
1039 TRAP(ret,tfs=CFbsTypefaceStore::NewL(NULL)); |
|
1040 |
|
1041 if (ret == KErrNoMemory) |
|
1042 { |
|
1043 __UHEAP_MARKEND; |
|
1044 } |
|
1045 else if (ret == KErrNone) |
|
1046 { |
|
1047 delete tfs; |
|
1048 __UHEAP_MARKEND; |
|
1049 break; |
|
1050 } |
|
1051 else |
|
1052 { |
|
1053 __UHEAP_MARKEND; |
|
1054 TEST2(ret, KErrNone); |
|
1055 } |
|
1056 } |
|
1057 |
|
1058 __UHEAP_RESET; |
|
1059 |
|
1060 // CFbsTypefaceStore::SetFontNameAliasL() |
|
1061 _LIT(KFontNameAlias,"Fubar"); |
|
1062 TRAP(ret,tfs = CFbsTypefaceStore::NewL(NULL)); |
|
1063 TEST2(ret, KErrNone); |
|
1064 TRAP(ret, tfs->SetFontNameAliasL(_L("ExpandArray"),_L("DejaVu Serif Condensed"))); |
|
1065 TEST2(ret, KErrNone); |
|
1066 TRAP(ret, tfs->SetFontNameAliasL(_L("ExpandArray"),KNullDesC)); |
|
1067 TEST2(ret, KErrNone); |
|
1068 |
|
1069 for (count = 1; ; count++) |
|
1070 { |
|
1071 iFbs->SendCommand(EFbsMessDefaultAllocFail,count); |
|
1072 if(heapMarkCheckFlag) |
|
1073 { |
|
1074 iFbs->SendCommand(EFbsMessDefaultMark); |
|
1075 } |
|
1076 |
|
1077 TRAP(ret, tfs->SetFontNameAliasL(KFontNameAlias,_L("DejaVu Serif Condensed"))); |
|
1078 |
|
1079 if (ret == KErrNoMemory) |
|
1080 { |
|
1081 if(heapMarkCheckFlag) |
|
1082 { |
|
1083 iFbs->SendCommand(EFbsMessDefaultMarkEnd); |
|
1084 } |
|
1085 } |
|
1086 else if (ret == KErrNone) |
|
1087 { |
|
1088 if(heapMarkCheckFlag) |
|
1089 { |
|
1090 iFbs->SendCommand(EFbsMessDefaultMarkEnd,2); |
|
1091 } |
|
1092 break; |
|
1093 } |
|
1094 else |
|
1095 TEST2(ret, KErrNone); |
|
1096 } |
|
1097 |
|
1098 iFbs->SendCommand(EFbsMessDefaultAllocFail,0); |
|
1099 |
|
1100 // GetNearestFontToDesignHeightInTwips() |
|
1101 TFontSpec spec(_L("SwissA"),12); |
|
1102 CFont* font = NULL; |
|
1103 ret = tfs->GetNearestFontToDesignHeightInTwips(font,spec); |
|
1104 TEST2(ret, KErrNone); |
|
1105 tfs->ReleaseFont(font); |
|
1106 spec.iTypeface.iName = _L("DejaVu Serif Condensed"); |
|
1107 |
|
1108 for (count = 1; ; count++) |
|
1109 { |
|
1110 __UHEAP_SETFAIL(RHeap::EDeterministic,count); |
|
1111 __UHEAP_MARK; |
|
1112 |
|
1113 ret = tfs->GetNearestFontToDesignHeightInTwips(font,spec); |
|
1114 |
|
1115 if (ret == KErrNoMemory) |
|
1116 { |
|
1117 ASSERT(!font); |
|
1118 __UHEAP_MARKEND; |
|
1119 } |
|
1120 else if (ret == KErrNone) |
|
1121 { |
|
1122 ASSERT(font); |
|
1123 tfs->ReleaseFont(font); |
|
1124 __UHEAP_MARKEND; |
|
1125 break; |
|
1126 } |
|
1127 else |
|
1128 { |
|
1129 __UHEAP_MARKEND; |
|
1130 TEST2(ret, KErrNone); |
|
1131 } |
|
1132 } |
|
1133 |
|
1134 __UHEAP_RESET; |
|
1135 |
|
1136 // GetNearestFontToDesignHeightInTwips() with alias |
|
1137 spec.iTypeface.iName = KFontNameAlias; |
|
1138 TRAP(ret, tfs->SetFontNameAliasL(KFontNameAlias,_L("DejaVu Serif Condensed"))); |
|
1139 TEST2(ret, KErrNone); |
|
1140 |
|
1141 for (count = 1; ; count++) |
|
1142 { |
|
1143 __UHEAP_SETFAIL(RHeap::EDeterministic,count); |
|
1144 __UHEAP_MARK; |
|
1145 |
|
1146 ret = tfs->GetNearestFontToDesignHeightInTwips(font,spec); |
|
1147 |
|
1148 if (ret == KErrNoMemory) |
|
1149 { |
|
1150 ASSERT(!font); |
|
1151 __UHEAP_MARKEND; |
|
1152 } |
|
1153 else if (ret == KErrNone) |
|
1154 { |
|
1155 ASSERT(font); |
|
1156 tfs->ReleaseFont(font); |
|
1157 __UHEAP_MARKEND; |
|
1158 break; |
|
1159 } |
|
1160 else |
|
1161 { |
|
1162 __UHEAP_MARKEND; |
|
1163 TEST2(ret, KErrNone); |
|
1164 } |
|
1165 } |
|
1166 |
|
1167 __UHEAP_RESET; |
|
1168 TRAP(ret, tfs->SetFontNameAliasL(KFontNameAlias,KNullDesC)); |
|
1169 TEST2(ret, KErrNone); |
|
1170 delete tfs; |
|
1171 } |
|
1172 |
|
1173 /** |
|
1174 @SYMTestCaseID |
|
1175 GRAPHICS-FBSERV-0514 |
|
1176 |
|
1177 @SYMTestCaseDesc |
|
1178 Asynchronous loading and saving of bitmaps |
|
1179 |
|
1180 @SYMTestActions |
|
1181 Creates a loader for bitmaps and simulates Out Of Memory conditions |
|
1182 and then creates and saver and simulates Out Of Memory conditions |
|
1183 |
|
1184 @SYMTestExpectedResults |
|
1185 Test should pass |
|
1186 */ |
|
1187 void CTAlloc::BitmapHandlerL() |
|
1188 { |
|
1189 TInt ret=KErrNone; |
|
1190 CFbsBitmapAsyncStreamer* bmphandler=NULL; |
|
1191 |
|
1192 // Create loader |
|
1193 TInt count; |
|
1194 INFO_PRINTF1(_L("CFbsBitmapAsyncStreamer::NewL()\r\n")); |
|
1195 for (count = 1; ; count++) |
|
1196 { |
|
1197 __UHEAP_SETFAIL(RHeap::EDeterministic,count); |
|
1198 __UHEAP_MARK; |
|
1199 |
|
1200 TRAP(ret,bmphandler = CFbsBitmapAsyncStreamer::NewL(CFbsBitmapAsyncStreamer::ELoad)); |
|
1201 |
|
1202 if (ret == KErrNoMemory) |
|
1203 { |
|
1204 __UHEAP_MARKEND; |
|
1205 } |
|
1206 else if (ret == KErrNone) |
|
1207 { |
|
1208 delete bmphandler; |
|
1209 __UHEAP_MARKEND; |
|
1210 break; |
|
1211 } |
|
1212 else |
|
1213 { |
|
1214 __UHEAP_MARKEND; |
|
1215 TEST2(ret, KErrNone); |
|
1216 } |
|
1217 } |
|
1218 |
|
1219 __UHEAP_RESET; |
|
1220 TEST(iFbs->ResourceCount()==0); |
|
1221 |
|
1222 // Create saver |
|
1223 for (count = 1; ; count++) |
|
1224 { |
|
1225 __UHEAP_SETFAIL(RHeap::EDeterministic,count); |
|
1226 __UHEAP_MARK; |
|
1227 |
|
1228 TRAP(ret,bmphandler=CFbsBitmapAsyncStreamer::NewL(CFbsBitmapAsyncStreamer::ESave)); |
|
1229 |
|
1230 if (ret == KErrNoMemory) |
|
1231 { |
|
1232 __UHEAP_MARKEND; |
|
1233 } |
|
1234 else if (ret == KErrNone) |
|
1235 { |
|
1236 delete bmphandler; |
|
1237 __UHEAP_MARKEND; |
|
1238 break; |
|
1239 } |
|
1240 else |
|
1241 { |
|
1242 __UHEAP_MARKEND; |
|
1243 TEST2(ret, KErrNone); |
|
1244 } |
|
1245 } |
|
1246 |
|
1247 __UHEAP_RESET; |
|
1248 TEST(iFbs->ResourceCount()==0); |
|
1249 } |
|
1250 |
|
1251 /** |
|
1252 @SYMTestCaseID |
|
1253 GRAPHICS-FBSERV-0515 |
|
1254 |
|
1255 @SYMTestCaseDesc |
|
1256 Tests memory allocation of CFontStore object |
|
1257 |
|
1258 @SYMTestActions |
|
1259 CFontStore objects is created on the heap |
|
1260 |
|
1261 @SYMTestExpectedResults |
|
1262 Test should pass |
|
1263 */ |
|
1264 void CTAlloc::FontStoreL() |
|
1265 { |
|
1266 INFO_PRINTF1(_L("CFontStore::NewL()\r\n")); |
|
1267 |
|
1268 for (TInt count = 1; ; count++) |
|
1269 { |
|
1270 __UHEAP_SETFAIL(RHeap::EDeterministic,count); |
|
1271 __UHEAP_MARK; |
|
1272 |
|
1273 CFontStore* fs = NULL; |
|
1274 TRAPD(ret,fs = CFontStore::NewL(&User::Heap())); |
|
1275 |
|
1276 if (ret == KErrNoMemory) |
|
1277 { |
|
1278 __UHEAP_MARKEND; |
|
1279 } |
|
1280 else if (ret == KErrNone) |
|
1281 { |
|
1282 delete fs; |
|
1283 __UHEAP_MARKEND; |
|
1284 __UHEAP_SETFAIL(RHeap::ENone,count); |
|
1285 break; |
|
1286 } |
|
1287 else |
|
1288 { |
|
1289 __UHEAP_MARKEND; |
|
1290 TEST2(ret, KErrNone); |
|
1291 } |
|
1292 } |
|
1293 |
|
1294 } |
|
1295 |
|
1296 //-------------- |
|
1297 __CONSTRUCT_STEP__(Alloc) |
|
1298 |