|
1 // Copyright (c) 2004-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 // This file contains the test steps ICL positive testing for GT0210 MS3.4 File Handle APIs. |
|
15 // EPOC includes |
|
16 // |
|
17 // |
|
18 |
|
19 #include <testframework.h> |
|
20 #include <icl/icl_uids.hrh> |
|
21 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
22 #include <icl/icl_uids_const.hrh> |
|
23 #include <icl/icl_uids_def.hrh> |
|
24 #endif |
|
25 #include "TestPositiveConversionNew.h" |
|
26 |
|
27 #include "ICLFbsSessionTest.h" |
|
28 |
|
29 const TInt KMaxMimeLength = 256; |
|
30 |
|
31 /** |
|
32 * |
|
33 * |
|
34 * Class Constructor |
|
35 * |
|
36 */ |
|
37 CTestPositiveConversionNew::CTestPositiveConversionNew(const TDesC& aTestName) : |
|
38 CTestStepConversion(aTestName) |
|
39 { |
|
40 iHeapSize = 500000; |
|
41 } |
|
42 |
|
43 /** |
|
44 * |
|
45 * |
|
46 * NewL Method |
|
47 * |
|
48 */ |
|
49 CTestPositiveConversionNew *CTestPositiveConversionNew::NewL(const TDesC& aTestName) |
|
50 { |
|
51 CTestPositiveConversionNew* self = new(ELeave) CTestPositiveConversionNew(aTestName); |
|
52 return self; |
|
53 } |
|
54 |
|
55 |
|
56 /** |
|
57 * |
|
58 * |
|
59 * do the test step |
|
60 * |
|
61 */ |
|
62 TVerdict CTestPositiveConversionNew::DoTestStepL() |
|
63 { |
|
64 TVerdict currentVerdict = EPass; |
|
65 |
|
66 if( (iTestStepName.Compare(_L("MM-ICL-FRM-I-0701-CP")) == 0) || |
|
67 (iTestStepName.Compare(_L("MM-ICL-FRM-I-0702-CP")) == 0) || |
|
68 (iTestStepName.Compare(_L("MM-ICL-FRM-I-0703-CP")) == 0) || |
|
69 (iTestStepName.Compare(_L("MM-ICL-FRM-I-0704-CP")) == 0) ) |
|
70 { |
|
71 currentVerdict = Step0701_0704_CPL(); |
|
72 } |
|
73 else if( (iTestStepName.Compare(_L("MM-ICL-FRM-I-0705-CP")) == 0) || |
|
74 (iTestStepName.Compare(_L("MM-ICL-FRM-I-0706-CP")) == 0) || |
|
75 (iTestStepName.Compare(_L("MM-ICL-FRM-I-0707-CP")) == 0) || |
|
76 (iTestStepName.Compare(_L("MM-ICL-FRM-I-0708-CP")) == 0) ) |
|
77 { |
|
78 currentVerdict = Step0705_0708_CPL(); |
|
79 } |
|
80 else if ( (iTestStepName.Compare(_L("MM-ICL-FRM-I-0709-CP")) == 0) || |
|
81 (iTestStepName.Compare(_L("MM-ICL-FRM-I-0710-CP")) == 0) ) |
|
82 { |
|
83 currentVerdict = Step0709_0710_CPL(); |
|
84 } |
|
85 else if ( (iTestStepName.Compare(_L("MM-ICL-FRM-I-0711-CP")) == 0) || |
|
86 (iTestStepName.Compare(_L("MM-ICL-FRM-I-0712-CP")) == 0) ) |
|
87 { |
|
88 currentVerdict = Step0711_0712_CPL(); |
|
89 } |
|
90 |
|
91 return currentVerdict; |
|
92 } |
|
93 |
|
94 /** |
|
95 * |
|
96 * Read, decode and verify different graphic formats |
|
97 * |
|
98 * Step 0701_CP to 0704_CP |
|
99 * |
|
100 */ |
|
101 TVerdict CTestPositiveConversionNew::Step0701_0704_CPL() |
|
102 { |
|
103 TVerdict result = EFail; |
|
104 TInt theErr = KErrNone; |
|
105 TInt theErr1 = KErrNone; |
|
106 |
|
107 // dummy Hal call for heap balance on target |
|
108 if (DummyHalCall() != KErrNone) |
|
109 { |
|
110 return EInconclusive; |
|
111 } |
|
112 |
|
113 //__MM_HEAP_MARK; |
|
114 //[ Connect RFs ] |
|
115 User::LeaveIfError(iFs.Connect()); |
|
116 CleanupClosePushL(iFs); |
|
117 User::LeaveIfError(iFs.ShareProtected()); |
|
118 |
|
119 //[ Open the Source Image File using RFile ] |
|
120 TFileName theSourceFilename; |
|
121 Directory(EInput, theSourceFilename); |
|
122 theSourceFilename.Append(iFileNameSrc); |
|
123 |
|
124 INFO_PRINTF2(_L("Start : Open the file : %S by RFile"), &theSourceFilename); |
|
125 TInt theRes = iFile.Open(iFs, theSourceFilename, EFileWrite); |
|
126 User::LeaveIfError(theRes); |
|
127 CleanupClosePushL(iFile); |
|
128 INFO_PRINTF2(_L("End : Open the file : %S by RFile"), &theSourceFilename); |
|
129 |
|
130 //[ Connect to RFbsSession ] |
|
131 CICLFbsSessionTest* fbsSession = CICLFbsSessionTest::NewLC(); |
|
132 |
|
133 //[ Open the File for convert, using the 'FileNewL' APIs for each test step ] |
|
134 INFO_PRINTF2(_L("Start : Open the file : %S by CImageDecoder::FileNewL"), &theSourceFilename); |
|
135 if (iTestStepName.Compare(_L("MM-ICL-FRM-I-0701-CP")) == 0) |
|
136 { |
|
137 INFO_PRINTF1(_L("Read a JPEG,not specifying file type. Decode and verify JPEG.")); |
|
138 TRAP(theRes, iImageDecoder=CImageDecoder::FileNewL(iFile, EPlay)); |
|
139 } |
|
140 else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-0702-CP")) == 0) |
|
141 { |
|
142 INFO_PRINTF1(_L("Read a JPEG,specifying MIME type. Decode and verify JPEG.")); |
|
143 TBuf8<KMaxMimeLength> mimeType; |
|
144 ReadMimeTypeFromConfig(mimeType); |
|
145 TRAP(theRes, iImageDecoder=CImageDecoder::FileNewL(iFile, mimeType, EPlay)); |
|
146 } |
|
147 else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-0703-CP")) == 0) |
|
148 { |
|
149 INFO_PRINTF1(_L("Read a OTA, specifying image type. Decode and verify OTA.")); |
|
150 TRAP(theRes, iImageDecoder=CImageDecoder::FileNewL(iFile, EPlay, CImageDecoder::EOptionNone, iImageTypeUid, KNullUid, KNullUid)); |
|
151 } |
|
152 else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-0704-CP")) == 0) |
|
153 { |
|
154 INFO_PRINTF1(_L("Read a WBMP, specifying the Decoder UID. Decode and verify WBMP.")); |
|
155 TRAP(theRes, iImageDecoder=CImageDecoder::FileNewL(iFile, EPlay, CImageDecoder::EOptionNone, iImageTypeUid, KNullUid, TUid::Uid(KWBMPDecoderImplementationUidValue))); |
|
156 } |
|
157 User::LeaveIfError(theRes); |
|
158 CleanupStack::PushL(iImageDecoder); |
|
159 INFO_PRINTF2(_L("End : Open the file : %S by CImageDecoder::FileNewL"), &theSourceFilename); |
|
160 |
|
161 //[ Call the main Decode Test Method ] |
|
162 TRAP(theErr1, theErr = DecodeUsingDecoderL(iFileNameSrc)); |
|
163 |
|
164 //[ Delete and Close Local ImageDecoder and iFs ] |
|
165 CleanupStack::Pop(); |
|
166 delete iImageDecoder; |
|
167 iImageDecoder = NULL; |
|
168 |
|
169 //[ Delete and Close RFs, RFile and FbsSession] |
|
170 CleanupStack::PopAndDestroy(3); |
|
171 //__MM_HEAP_MARKEND; |
|
172 |
|
173 if(theErr1 != KErrNone) |
|
174 { |
|
175 theErr = theErr1; |
|
176 } |
|
177 if(theErr == KErrNone) |
|
178 { |
|
179 result = EPass; |
|
180 } |
|
181 else |
|
182 { |
|
183 INFO_PRINTF2(_L("Error : %d"), theErr); |
|
184 } |
|
185 |
|
186 return result; |
|
187 } |
|
188 |
|
189 /** |
|
190 * |
|
191 * Encode an image from bitmap to a file |
|
192 * |
|
193 * Step 0705_CP to 0708_CP |
|
194 * |
|
195 */ |
|
196 TVerdict CTestPositiveConversionNew::Step0705_0708_CPL() |
|
197 { |
|
198 TVerdict result = EFail ; |
|
199 TInt theErr = KErrNone; |
|
200 TInt theErr1 = KErrNone; |
|
201 TInt theRes = KErrNone; |
|
202 |
|
203 //__MM_HEAP_MARK; |
|
204 |
|
205 //[ Connect RFs ] |
|
206 User::LeaveIfError(iFs.Connect()); |
|
207 CleanupClosePushL(iFs); |
|
208 User::LeaveIfError(iFs.ShareProtected()); |
|
209 |
|
210 // [ Open the Destination File using RFile ] |
|
211 TFileName theDestinationFileName; |
|
212 TBuf<KLenBuffer> theExtension; |
|
213 |
|
214 Directory(EOutput, theDestinationFileName); |
|
215 theDestinationFileName.Append(iFileNameSrc.Left(iFileNameSrc.Length()-3)); |
|
216 GetImageExtension(iImageTypeUid, theExtension); |
|
217 theDestinationFileName.Append(theExtension); |
|
218 |
|
219 INFO_PRINTF2(_L("Start : Open the file : %S by RFile"), &theDestinationFileName); |
|
220 User::LeaveIfError(iFile.Replace(iFs, theDestinationFileName, EFileWrite)); |
|
221 CleanupClosePushL(iFile); |
|
222 INFO_PRINTF2(_L("End : Open the file : %S by RFile"), &theDestinationFileName); |
|
223 |
|
224 //[ Connect to RFbsSession ] |
|
225 CICLFbsSessionTest* fbsSession = CICLFbsSessionTest::NewLC(); |
|
226 |
|
227 //[ Open the File for convert, using the 'FileNewL' APIs for each test step ] |
|
228 INFO_PRINTF2(_L("Start : Open the file : %S by CImageEncoder::FileNewL"), &theDestinationFileName); |
|
229 if (iTestStepName.Compare(_L("MM-ICL-FRM-I-0705-CP")) == 0) |
|
230 { |
|
231 INFO_PRINTF1(_L("Encode an image from bitmap to a file, not specifying the file type.")); |
|
232 //Image type or encoder UID should be there, otherwise throws panic.. |
|
233 TRAP(theRes, iImageEncoder=CImageEncoder::FileNewL(iFile, CImageEncoder::EOptionNone, iImageTypeUid)); |
|
234 } |
|
235 else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-0706-CP")) == 0) |
|
236 { |
|
237 INFO_PRINTF1(_L("Encode an image from bitmap to a file, given the MIME Type")); |
|
238 TBuf8<KMaxMimeLength> mimeType; |
|
239 ReadMimeTypeFromConfig(mimeType); |
|
240 TRAP(theRes, iImageEncoder=CImageEncoder::FileNewL(iFile, mimeType)); |
|
241 } |
|
242 else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-0707-CP")) == 0) |
|
243 { |
|
244 INFO_PRINTF1(_L("Encode an image from bitmap to a file, given the Image Type")); |
|
245 TRAP(theRes, iImageEncoder=CImageEncoder::FileNewL(iFile, CImageEncoder::EOptionNone, iImageTypeUid, KNullUid, KNullUid)); |
|
246 } |
|
247 else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-0708-CP")) == 0) |
|
248 { |
|
249 INFO_PRINTF1(_L("Encode an image from bitmap to a file, given the Encoder UID.")); |
|
250 //The Image type has to be given for Decoder Implementation |
|
251 TRAP(theRes, iImageEncoder=CImageEncoder::FileNewL(iFile, CImageEncoder::EOptionNone, KNullUid, KNullUid, TUid::Uid(KJPGEncoderImplementationUidValue))); |
|
252 } |
|
253 User::LeaveIfError(theRes); |
|
254 |
|
255 INFO_PRINTF2(_L("End : Open the file : %S by CImageEncoder::FileNewL"), &theDestinationFileName); |
|
256 |
|
257 //[ Call the main Encode Test Method ] |
|
258 EncodeUsingEncoderL(iFileNameSrc); |
|
259 |
|
260 //[ Delete and Close ImageEncoder ] |
|
261 |
|
262 delete iImageEncoder; |
|
263 iImageEncoder = NULL; |
|
264 |
|
265 //[ Delete and Close RFs, RFile and fbsSession] |
|
266 CleanupStack::PopAndDestroy(3); |
|
267 |
|
268 //__MM_HEAP_MARKEND; |
|
269 |
|
270 if(theErr1 != KErrNone) |
|
271 { |
|
272 theErr = theErr1; |
|
273 } |
|
274 if(theErr == KErrNone) |
|
275 { |
|
276 result = EPass; |
|
277 } |
|
278 else |
|
279 { |
|
280 INFO_PRINTF2(_L("Error : %d"), theErr); |
|
281 } |
|
282 |
|
283 return result; |
|
284 } |
|
285 |
|
286 /** |
|
287 * |
|
288 * Alloc tests to Encode an image from bitmap to a file |
|
289 * |
|
290 * Step 0709_CP to 0710_CP |
|
291 * |
|
292 */ |
|
293 TVerdict CTestPositiveConversionNew::Step0709_0710_CPL() |
|
294 { |
|
295 //Traces |
|
296 if (iTestStepName.Compare(_L("MM-ICL-FRM-I-0709-CP")) == 0) |
|
297 { |
|
298 INFO_PRINTF1(_L("Alloc tests to Encode an image from bitmap to a file, specifying the MIME Type.")); |
|
299 } |
|
300 else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-0710-CP")) == 0) |
|
301 { |
|
302 INFO_PRINTF1(_L("Alloc tests to Encode an image from bitmap to a file, NOT specifying the MIME Type.")); |
|
303 } |
|
304 |
|
305 //Check for Alloc Test Support |
|
306 __UHEAP_SETFAIL(RHeap::EFailNext, 1); |
|
307 TAny *testAllocSupport = User::Alloc(1); |
|
308 if (testAllocSupport!=NULL) |
|
309 { |
|
310 delete testAllocSupport; |
|
311 testAllocSupport=NULL; |
|
312 INFO_PRINTF1(_L("This build does not support ALLOC testing")); |
|
313 return EInconclusive; |
|
314 } |
|
315 |
|
316 //Initialise Variables |
|
317 TVerdict iAllocTestStepResult=EPass; |
|
318 TInt err = KErrNone; |
|
319 TBool badResult = EFalse; |
|
320 |
|
321 //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<< |
|
322 INFO_PRINTF1(_L("Executing the Test Method call Outside the FOR LOOP.")); |
|
323 TRAP(err, iAllocTestStepResult = TestStep0709_0710_CPL()); |
|
324 if (err != KErrNone) |
|
325 { |
|
326 INFO_PRINTF2(_L("Encoding error, returned error code = %d"), err); |
|
327 User::Leave(err); |
|
328 } |
|
329 else |
|
330 { |
|
331 //Check the iAllocTestStepResult |
|
332 if (iAllocTestStepResult != EPass) |
|
333 { |
|
334 badResult = ETrue; |
|
335 } |
|
336 } |
|
337 |
|
338 TInt failCount = 1; |
|
339 TBool completed = EFalse; |
|
340 iAllocTestStepResult = EPass; // reinitialise |
|
341 TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging |
|
342 for(;;) |
|
343 { |
|
344 __UHEAP_SETFAIL(RHeap::EFailNext, failCount); |
|
345 __MM_HEAP_MARK; |
|
346 |
|
347 //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<< |
|
348 INFO_PRINTF2(_L("Executing the Test Method call #%d."), failCount); |
|
349 TRAP(err, iAllocTestStepResult = TestStep0709_0710_CPL()); |
|
350 |
|
351 completed = EFalse; |
|
352 if (err == KErrNone) |
|
353 { |
|
354 TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test |
|
355 if (testAlloc == NULL) |
|
356 { |
|
357 reachedEnd = ETrue; |
|
358 failCount -= 1; |
|
359 } |
|
360 else |
|
361 { |
|
362 User::Free(testAlloc); |
|
363 } |
|
364 |
|
365 //Check the iAllocTestStepResult |
|
366 if (iAllocTestStepResult != EPass) |
|
367 { |
|
368 badResult = ETrue; |
|
369 } |
|
370 |
|
371 completed = reachedEnd || badResult; |
|
372 } |
|
373 else if (err != KErrNoMemory) // bad error code |
|
374 { |
|
375 completed = ETrue; |
|
376 badResult = EFail; |
|
377 } |
|
378 |
|
379 __MM_HEAP_MARKEND; |
|
380 __UHEAP_SETFAIL(RHeap::ENone, 0); |
|
381 |
|
382 if (completed) |
|
383 { |
|
384 break; // exit loop |
|
385 } |
|
386 |
|
387 failCount++; |
|
388 } |
|
389 |
|
390 //failCount -= 1; // Failcount of 1 equates to 0 successful allocs, etc |
|
391 |
|
392 if (err != KErrNone || badResult) |
|
393 { |
|
394 if (badResult) |
|
395 { |
|
396 INFO_PRINTF3(_L(" Bad result with %d memory allocations tested. The Error returned is %d"), failCount, err); |
|
397 } |
|
398 else |
|
399 { |
|
400 INFO_PRINTF3(_L(" Error(%d) with %d memory allocations tested\n"), err, failCount); |
|
401 } |
|
402 iAllocTestStepResult = EFail; |
|
403 } |
|
404 else |
|
405 { |
|
406 INFO_PRINTF2(_L(" Completed OK with %d memory allocations tested\n"), failCount); |
|
407 iAllocTestStepResult = EPass; |
|
408 } |
|
409 return iAllocTestStepResult; |
|
410 } |
|
411 |
|
412 /** |
|
413 * |
|
414 * Alloc test main test step to Encode an image from bitmap to a file |
|
415 * |
|
416 * Step 0709_CP to 0710_CP |
|
417 * |
|
418 */ |
|
419 TVerdict CTestPositiveConversionNew::TestStep0709_0710_CPL() |
|
420 { |
|
421 TInt theRes = KErrNone; |
|
422 |
|
423 //__MM_HEAP_MARK; |
|
424 |
|
425 //[ Connect RFs ] |
|
426 User::LeaveIfError(iFs.Connect()); |
|
427 CleanupClosePushL(iFs); |
|
428 User::LeaveIfError(iFs.ShareProtected()); |
|
429 |
|
430 // [ Open the Destination File using RFile ] |
|
431 TFileName theDestinationFileName; |
|
432 TBuf<KLenBuffer> theExtension; |
|
433 |
|
434 Directory(EOutput, theDestinationFileName); |
|
435 theDestinationFileName.Append(iFileNameSrc.Left(iFileNameSrc.Length()-3)); |
|
436 GetImageExtension(iImageTypeUid, theExtension); |
|
437 theDestinationFileName.Append(theExtension); |
|
438 |
|
439 INFO_PRINTF2(_L("Start : Open the file : %S by RFile"), &theDestinationFileName); |
|
440 User::LeaveIfError(iFile.Replace(iFs, theDestinationFileName, EFileWrite)); |
|
441 CleanupClosePushL(iFile); |
|
442 INFO_PRINTF2(_L("End : Open the file : %S by RFile"), &theDestinationFileName); |
|
443 |
|
444 //[ Connect to RFbsSession ] |
|
445 CICLFbsSessionTest* fbsSession = CICLFbsSessionTest::NewLC(); |
|
446 |
|
447 //[ Open the File for convert, using the 'FileNewL' APIs for each test step ] |
|
448 INFO_PRINTF2(_L("Start : Open the file : %S by CImageEncoder::FileNewL"), &theDestinationFileName); |
|
449 if (iTestStepName.Compare(_L("MM-ICL-FRM-I-0709-CP")) == 0) |
|
450 { |
|
451 //INFO_PRINTF1(_L("Alloc tests to Encode an image from bitmap to a file, specifying the MIME Type.")); |
|
452 TBuf8<KMaxMimeLength> mimeType; |
|
453 ReadMimeTypeFromConfig(mimeType); |
|
454 TRAP(theRes, iImageEncoder=CImageEncoder::FileNewL(iFile, mimeType)); |
|
455 } |
|
456 else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-0710-CP")) == 0) |
|
457 { |
|
458 //INFO_PRINTF1(_L("Alloc tests to Encode an image from bitmap to a file, NOT specifying the MIME Type.")); |
|
459 //The Image type has to be given for Decoder Implementation |
|
460 TRAP(theRes, iImageEncoder=CImageEncoder::FileNewL(iFile, CImageEncoder::EOptionNone, KNullUid, KNullUid, TUid::Uid(KJPGEncoderImplementationUidValue))); |
|
461 } |
|
462 User::LeaveIfError(theRes); |
|
463 |
|
464 INFO_PRINTF2(_L("End : Open the file : %S by CImageEncoder::FileNewL"), &theDestinationFileName); |
|
465 |
|
466 //[ Call the main Encode Test Method ] |
|
467 TRAPD(err, EncodeUsingEncoderL(iFileNameSrc)); |
|
468 if (err != KErrNone) |
|
469 { |
|
470 delete iImageEncoder; |
|
471 iImageEncoder = NULL; |
|
472 |
|
473 User::Leave(err); |
|
474 } |
|
475 |
|
476 //[ Delete and Close ImageEncoder ] |
|
477 |
|
478 delete iImageEncoder; |
|
479 iImageEncoder = NULL; |
|
480 |
|
481 //[ Delete and Close RFs, RFile and fbsSession] |
|
482 CleanupStack::PopAndDestroy(3); |
|
483 |
|
484 //__MM_HEAP_MARKEND; |
|
485 |
|
486 return EPass; |
|
487 } |
|
488 |
|
489 |
|
490 |
|
491 /** |
|
492 * |
|
493 * Alloc tests to Read, decode and verify JPEG. |
|
494 * |
|
495 * Step 0711_CP to 0712_CP |
|
496 * |
|
497 */ |
|
498 TVerdict CTestPositiveConversionNew::Step0711_0712_CPL() |
|
499 { |
|
500 //Traces |
|
501 if (iTestStepName.Compare(_L("MM-ICL-FRM-I-0711-CP")) == 0) |
|
502 { |
|
503 INFO_PRINTF1(_L("Alloc tests to Read, decode and verify JPEG, specifying the MIME Type.")); |
|
504 } |
|
505 else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-0712-CP")) == 0) |
|
506 { |
|
507 INFO_PRINTF1(_L("Alloc tests to Read, decode and verify JPEG, NOT specifying the MIME Type.")); |
|
508 } |
|
509 |
|
510 //Check for Alloc Test Support |
|
511 __UHEAP_SETFAIL(RHeap::EFailNext, 1); |
|
512 TAny *testAllocSupport = User::Alloc(1); |
|
513 if (testAllocSupport!=NULL) |
|
514 { |
|
515 delete testAllocSupport; |
|
516 testAllocSupport=NULL; |
|
517 INFO_PRINTF1(_L("This build does not support ALLOC testing")); |
|
518 return EInconclusive; |
|
519 } |
|
520 |
|
521 //Initialise Variables |
|
522 TVerdict iAllocTestStepResult=EPass; |
|
523 TInt err = KErrNone; |
|
524 TBool badResult = EFalse; |
|
525 |
|
526 //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<< |
|
527 INFO_PRINTF1(_L("Executing the Test Method call Outside the FOR LOOP.")); |
|
528 TRAP(err, iAllocTestStepResult = TestStep0711_0712_CPL()); |
|
529 if (err != KErrNone) |
|
530 { |
|
531 INFO_PRINTF2(_L("Decoding error, returned error code = %d"), err); |
|
532 User::Leave(err); |
|
533 } |
|
534 else |
|
535 { |
|
536 //Check the iAllocTestStepResult |
|
537 if (iAllocTestStepResult != EPass) |
|
538 { |
|
539 badResult = ETrue; |
|
540 } |
|
541 } |
|
542 |
|
543 TInt failCount = 1; |
|
544 TBool completed = EFalse; |
|
545 iAllocTestStepResult = EPass; // reinitialise |
|
546 TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging |
|
547 for(;;) |
|
548 { |
|
549 __UHEAP_SETFAIL(RHeap::EFailNext, failCount); |
|
550 //__MM_HEAP_MARK; |
|
551 |
|
552 //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<< |
|
553 INFO_PRINTF2(_L("Executing the Test Method call #%d."), failCount); |
|
554 TRAP(err, iAllocTestStepResult = TestStep0711_0712_CPL()); |
|
555 |
|
556 completed = EFalse; |
|
557 if (err == KErrNone) |
|
558 { |
|
559 TAny *testAlloc = NULL; |
|
560 testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test |
|
561 if (testAlloc == NULL) |
|
562 { |
|
563 reachedEnd = ETrue; |
|
564 failCount -= 1; |
|
565 } |
|
566 else |
|
567 { |
|
568 User::Free(testAlloc); |
|
569 testAlloc=NULL; |
|
570 } |
|
571 |
|
572 //Check the iAllocTestStepResult |
|
573 if (iAllocTestStepResult != EPass) |
|
574 { |
|
575 badResult = ETrue; |
|
576 } |
|
577 |
|
578 completed = reachedEnd || badResult; |
|
579 } |
|
580 else if (err != KErrNoMemory) // bad error code |
|
581 { |
|
582 completed = ETrue; |
|
583 badResult = EFail; |
|
584 } |
|
585 |
|
586 //__MM_HEAP_MARKEND; |
|
587 __UHEAP_SETFAIL(RHeap::ENone, 0); |
|
588 |
|
589 if (completed) |
|
590 { |
|
591 break; // exit loop |
|
592 } |
|
593 |
|
594 failCount++; |
|
595 } |
|
596 |
|
597 //failCount -= 1; // Failcount of 1 equates to 0 successful allocs, etc |
|
598 |
|
599 if (err != KErrNone || badResult) |
|
600 { |
|
601 if (badResult) |
|
602 { |
|
603 INFO_PRINTF3(_L(" Bad result with %d memory allocations tested. The Error returned is %d"), failCount, err); |
|
604 } |
|
605 else |
|
606 { |
|
607 INFO_PRINTF3(_L(" Error(%d) with %d memory allocations tested\n"), err, failCount); |
|
608 } |
|
609 iAllocTestStepResult = EFail; |
|
610 } |
|
611 else |
|
612 { |
|
613 INFO_PRINTF2(_L(" Completed OK with %d memory allocations tested\n"), failCount); |
|
614 iAllocTestStepResult = EPass; |
|
615 } |
|
616 return iAllocTestStepResult; |
|
617 } |
|
618 |
|
619 /** |
|
620 * |
|
621 * Alloc test main test step to Read, decode and verify JPEG. |
|
622 * |
|
623 * Step 0711_CP to 0712_CP |
|
624 * |
|
625 */ |
|
626 TVerdict CTestPositiveConversionNew::TestStep0711_0712_CPL() |
|
627 { |
|
628 TInt theRes = KErrNone; |
|
629 |
|
630 // dummy Hal call for heap balance on target |
|
631 //if (DummyHalCall() != KErrNone) |
|
632 // return EInconclusive; |
|
633 |
|
634 //__MM_HEAP_MARK; |
|
635 //[ Connect RFs ] |
|
636 User::LeaveIfError(iFs.Connect()); |
|
637 CleanupClosePushL(iFs); |
|
638 User::LeaveIfError(iFs.ShareProtected()); |
|
639 |
|
640 //[ Open the Source Image File using RFile ] |
|
641 TFileName theSourceFilename; |
|
642 Directory(EInput, theSourceFilename); |
|
643 theSourceFilename.Append(iFileNameSrc); |
|
644 |
|
645 INFO_PRINTF2(_L("Start : Open the file : %S by RFile"), &theSourceFilename); |
|
646 theRes = iFile.Open(iFs, theSourceFilename, EFileWrite); |
|
647 User::LeaveIfError(theRes); |
|
648 CleanupClosePushL(iFile); |
|
649 INFO_PRINTF2(_L("End : Open the file : %S by RFile"), &theSourceFilename); |
|
650 |
|
651 //[ Connect to RFbsSession ] |
|
652 CICLFbsSessionTest* fbsSession = CICLFbsSessionTest::NewLC(); |
|
653 |
|
654 //[ Open the File for convert, using the 'FileNewL' APIs for each test step ] |
|
655 INFO_PRINTF2(_L("Start : Open the file : %S by CImageDecoder::FileNewL"), &theSourceFilename); |
|
656 if (iTestStepName.Compare(_L("MM-ICL-FRM-I-0711-CP")) == 0) |
|
657 { |
|
658 //INFO_PRINTF1(_L("Alloc tests to Read, decode and verify JPEG, specifying the MIME Type.")); |
|
659 TBuf8<KMaxMimeLength> mimeType; |
|
660 ReadMimeTypeFromConfig(mimeType); |
|
661 TRAP(theRes, iImageDecoder=CImageDecoder::FileNewL(iFile, mimeType, EPlay)); |
|
662 } |
|
663 else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-0712-CP")) == 0) |
|
664 { |
|
665 //INFO_PRINTF1(_L("Alloc tests to Read, decode and verify JPEG, NOT specifying the MIME Type.")); |
|
666 TRAP(theRes, iImageDecoder=CImageDecoder::FileNewL(iFile, EPlay, CImageDecoder::EOptionNone, iImageTypeUid, KNullUid, TUid::Uid(KJPGDecoderImplementationUidValue))); |
|
667 } |
|
668 User::LeaveIfError(theRes); |
|
669 CleanupStack::PushL(iImageDecoder); |
|
670 INFO_PRINTF2(_L("End : Open the file : %S by CImageDecoder::FileNewL"), &theSourceFilename); |
|
671 |
|
672 //[ Call the main Decode Test Method ] |
|
673 User::LeaveIfError(DecodeUsingDecoderL(iFileNameSrc)); |
|
674 |
|
675 //[ Delete and Close Local ImageDecoder ] |
|
676 CleanupStack::Pop(); |
|
677 delete iImageDecoder; |
|
678 iImageDecoder = NULL; |
|
679 |
|
680 //[ Delete and Close RFs, RFile and fbsSession] |
|
681 CleanupStack::PopAndDestroy(3); |
|
682 |
|
683 //__MM_HEAP_MARKEND; |
|
684 |
|
685 return EPass; |
|
686 } |
|
687 |