|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ExifLibTest |
|
15 * |
|
16 */ |
|
17 #include "ExifLibTestInc.h" |
|
18 |
|
19 // Test cases modified for no jpeg parsing and no tag validity checking options |
|
20 |
|
21 // Exif.Read.201 |
|
22 // Instantiate an Exif reader with valid Exif image |
|
23 // Created Exif reader instance is returned. |
|
24 void CExifReadTest::ExifRead201L() |
|
25 { |
|
26 HBufC8* exif = TUtils::ReadFileL(iFs, KFullExif, 65536); |
|
27 CleanupStack::PushL(exif); |
|
28 CExifRead* read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking ); |
|
29 if(!read) |
|
30 User::Leave(KErrGeneral); |
|
31 delete read; |
|
32 CleanupStack::PopAndDestroy(exif); |
|
33 } |
|
34 |
|
35 // Exif.Read.202 |
|
36 // Try to instantiate an Exif reader with invalid/corrupted Exif image |
|
37 // Leaves with proper error code or doesn't detect the error |
|
38 void CExifReadTest::ExifRead202L() |
|
39 { |
|
40 // Various invalid/ corrupted Exif images |
|
41 HBufC8* exif = TUtils::ReadFileL(iFs, KInvalidExif1, 65536); |
|
42 CleanupStack::PushL(exif); |
|
43 CExifRead* read = 0; |
|
44 TRAPD( error, read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking) ); |
|
45 if ( error ) // jpeg error detected |
|
46 { |
|
47 if ( ( error != KErrCorrupt ) || ( read ) ) |
|
48 { |
|
49 if ( read ) |
|
50 { |
|
51 delete read; |
|
52 } |
|
53 if ( error ) |
|
54 { |
|
55 User::Leave( error ); |
|
56 } |
|
57 User::Leave(KErrGeneral); |
|
58 } |
|
59 } |
|
60 else if( read ) |
|
61 { |
|
62 CleanupStack::PushL(read); |
|
63 TUtils::GetAllTagsTestL( read, KInvalidExif1 ); |
|
64 CleanupStack::Pop(read); |
|
65 } |
|
66 else |
|
67 { |
|
68 RDebug::Print(_L("CExifReadTest::ExifRead202L(): KInvalidExif1 return no buffer")); |
|
69 } |
|
70 delete read; |
|
71 read = 0; |
|
72 CleanupStack::PopAndDestroy(exif); |
|
73 |
|
74 exif = TUtils::ReadFileL(iFs, KInvalidExif2, 65536); |
|
75 CleanupStack::PushL(exif); |
|
76 TRAP( error, read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking) ); |
|
77 if ( error ) // jpeg error detected |
|
78 { |
|
79 if ( ( error != KErrCorrupt ) || ( read ) ) |
|
80 { |
|
81 if ( read ) |
|
82 { |
|
83 delete read; |
|
84 } |
|
85 if ( error ) |
|
86 { |
|
87 User::Leave( error ); |
|
88 } |
|
89 User::Leave(KErrGeneral); |
|
90 } |
|
91 } |
|
92 else if( read ) |
|
93 { |
|
94 CleanupStack::PushL(read); |
|
95 TUtils::GetAllTagsTestL( read, KInvalidExif2 ); |
|
96 CleanupStack::Pop(read); |
|
97 } |
|
98 else |
|
99 { |
|
100 RDebug::Print(_L("CExifReadTest::ExifRead202L(): KInvalidExif2 return no buffer")); |
|
101 } |
|
102 |
|
103 delete read; |
|
104 read = 0; |
|
105 CleanupStack::PopAndDestroy(exif); |
|
106 |
|
107 exif = TUtils::CreateDummyBufL(120000); |
|
108 CleanupStack::PushL(exif); |
|
109 TRAP( error, read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking) ); |
|
110 if ( ( error != KErrCorrupt ) || ( read ) ) |
|
111 { |
|
112 if ( read ) |
|
113 { |
|
114 delete read; |
|
115 } |
|
116 if ( error ) |
|
117 { |
|
118 User::Leave( error ); |
|
119 } |
|
120 User::Leave(KErrGeneral); |
|
121 } |
|
122 CleanupStack::PopAndDestroy(exif); |
|
123 |
|
124 exif = TUtils::ReadFileL(iFs, KInvalidExif3, 65536); |
|
125 CleanupStack::PushL(exif); |
|
126 TRAP( error, read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking) ); |
|
127 if ( error ) // jpeg error detected |
|
128 { |
|
129 if ( ( error != KErrCorrupt ) || ( read ) ) |
|
130 { |
|
131 if ( read ) |
|
132 { |
|
133 delete read; |
|
134 } |
|
135 if ( error ) |
|
136 { |
|
137 User::Leave( error ); |
|
138 } |
|
139 User::Leave(KErrGeneral); |
|
140 } |
|
141 } |
|
142 else if( read ) |
|
143 { |
|
144 CleanupStack::PushL(read); |
|
145 TUtils::GetAllTagsTestL( read, KInvalidExif3 ); |
|
146 CleanupStack::Pop(read); |
|
147 } |
|
148 else |
|
149 { |
|
150 RDebug::Print(_L("CExifReadTest::ExifRead202L(): KInvalidExif3 return no buffer")); |
|
151 } |
|
152 |
|
153 delete read; |
|
154 read = 0; |
|
155 CleanupStack::PopAndDestroy(exif); |
|
156 |
|
157 exif = TUtils::ReadFileL(iFs, KInvalidExif4, 65536); |
|
158 CleanupStack::PushL(exif); |
|
159 TRAP( error, read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking) ); |
|
160 if ( error ) // jpeg error detected |
|
161 { |
|
162 if ( ( error != KErrCorrupt ) || ( read ) ) |
|
163 { |
|
164 if ( read ) |
|
165 { |
|
166 delete read; |
|
167 } |
|
168 if ( error ) |
|
169 { |
|
170 User::Leave( error ); |
|
171 } |
|
172 User::Leave(KErrGeneral); |
|
173 } |
|
174 } |
|
175 else if( read ) |
|
176 { |
|
177 CleanupStack::PushL(read); |
|
178 TUtils::GetAllTagsTestL( read, KInvalidExif4 ); |
|
179 CleanupStack::Pop(read); |
|
180 } |
|
181 else |
|
182 { |
|
183 RDebug::Print(_L("CExifReadTest::ExifRead202L(): KInvalidExif4 return no buffer")); |
|
184 } |
|
185 delete read; |
|
186 read = 0; |
|
187 CleanupStack::PopAndDestroy(exif); |
|
188 |
|
189 exif = TUtils::ReadFileL(iFs, KInvalidExif5, 65536); |
|
190 CleanupStack::PushL(exif); |
|
191 TRAP( error, read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking) ); |
|
192 if ( error ) // jpeg error detected |
|
193 { |
|
194 if ( ( error != KErrCorrupt ) || ( read ) ) |
|
195 { |
|
196 if ( read ) |
|
197 { |
|
198 delete read; |
|
199 } |
|
200 if ( error ) |
|
201 { |
|
202 User::Leave( error ); |
|
203 } |
|
204 User::Leave(KErrGeneral); |
|
205 } |
|
206 } |
|
207 else if( read ) |
|
208 { |
|
209 CleanupStack::PushL(read); |
|
210 TUtils::GetAllTagsTestL( read, KInvalidExif5 ); |
|
211 CleanupStack::Pop(read); |
|
212 } |
|
213 else |
|
214 { |
|
215 RDebug::Print(_L("CExifReadTest::ExifRead202L(): KInvalidExif5 return no buffer")); |
|
216 } |
|
217 delete read; |
|
218 read = 0; |
|
219 CleanupStack::PopAndDestroy(exif); |
|
220 |
|
221 exif = TUtils::ReadFileL(iFs, KInvalidExif7, 65536); |
|
222 CleanupStack::PushL(exif); |
|
223 TRAP( error, read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking) ); |
|
224 if ( error ) // jpeg error detected |
|
225 { |
|
226 if ( ( error != KErrCorrupt ) || ( read ) ) |
|
227 { |
|
228 if ( read ) |
|
229 { |
|
230 delete read; |
|
231 } |
|
232 if ( error ) |
|
233 { |
|
234 User::Leave( error ); |
|
235 } |
|
236 User::Leave(KErrGeneral); |
|
237 } |
|
238 } |
|
239 else if( read ) |
|
240 { |
|
241 CleanupStack::PushL(read); |
|
242 TUtils::GetAllTagsTestL( read, KInvalidExif7 ); |
|
243 CleanupStack::Pop(read); |
|
244 } |
|
245 else |
|
246 { |
|
247 RDebug::Print(_L("CExifReadTest::ExifRead202L(): KInvalidExif7 return no buffer")); |
|
248 } |
|
249 delete read; |
|
250 read = 0; |
|
251 CleanupStack::PopAndDestroy(exif); |
|
252 |
|
253 exif = TUtils::ReadFileL(iFs, KInvalidExif8, 65536); |
|
254 CleanupStack::PushL(exif); |
|
255 TRAP( error, read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking) ); |
|
256 if ( error ) // jpeg error detected |
|
257 { |
|
258 if ( ( error != KErrCorrupt ) || ( read ) ) |
|
259 { |
|
260 if ( read ) |
|
261 { |
|
262 delete read; |
|
263 } |
|
264 if ( error ) |
|
265 { |
|
266 User::Leave( error ); |
|
267 } |
|
268 User::Leave(KErrGeneral); |
|
269 } |
|
270 } |
|
271 else if( read ) |
|
272 { |
|
273 CleanupStack::PushL(read); |
|
274 TUtils::GetAllTagsTestL( read, KInvalidExif8 ); |
|
275 CleanupStack::Pop(read); |
|
276 } |
|
277 else |
|
278 { |
|
279 RDebug::Print(_L("CExifReadTest::ExifRead202L(): KInvalidExif8 return no buffer")); |
|
280 } |
|
281 delete read; |
|
282 read = 0; |
|
283 CleanupStack::PopAndDestroy(exif); |
|
284 |
|
285 exif = TUtils::ReadFileL(iFs, KInvalidExif9, 65536); |
|
286 CleanupStack::PushL(exif); |
|
287 TRAP( error, read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking) ); |
|
288 if ( error ) // jpeg error detected |
|
289 { |
|
290 if ( ( error != KErrCorrupt ) || ( read ) ) |
|
291 { |
|
292 if ( read ) |
|
293 { |
|
294 delete read; |
|
295 } |
|
296 if ( error ) |
|
297 { |
|
298 User::Leave( error ); |
|
299 } |
|
300 User::Leave(KErrGeneral); |
|
301 } |
|
302 } |
|
303 else if( read ) |
|
304 { |
|
305 CleanupStack::PushL(read); |
|
306 TUtils::GetAllTagsTestL( read, KInvalidExif9 ); |
|
307 CleanupStack::Pop(read); |
|
308 } |
|
309 else |
|
310 { |
|
311 RDebug::Print(_L("CExifReadTest::ExifRead202L(): KInvalidExif9 return no buffer")); |
|
312 } |
|
313 delete read; |
|
314 read = 0; |
|
315 CleanupStack::PopAndDestroy(exif); |
|
316 |
|
317 exif = TUtils::ReadFileL(iFs, KInvalidExif10, 65536); |
|
318 CleanupStack::PushL(exif); |
|
319 TRAP( error, read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking) ); |
|
320 if ( error ) // jpeg error detected |
|
321 { |
|
322 if ( ( error != KErrCorrupt ) || ( read ) ) |
|
323 { |
|
324 if ( read ) |
|
325 { |
|
326 delete read; |
|
327 } |
|
328 if ( error ) |
|
329 { |
|
330 User::Leave( error ); |
|
331 } |
|
332 User::Leave(KErrGeneral); |
|
333 } |
|
334 } |
|
335 else if( read ) |
|
336 { |
|
337 CleanupStack::PushL(read); |
|
338 TUtils::GetAllTagsTestL( read, KInvalidExif10 ); |
|
339 CleanupStack::Pop(read); |
|
340 } |
|
341 else |
|
342 { |
|
343 RDebug::Print(_L("CExifReadTest::ExifRead202L(): KInvalidExif10 return no buffer")); |
|
344 } |
|
345 delete read; |
|
346 read = 0; |
|
347 CleanupStack::PopAndDestroy(exif); |
|
348 |
|
349 exif = TUtils::ReadFileL(iFs, KInvalidExif11, 65536); |
|
350 CleanupStack::PushL(exif); |
|
351 TRAP( error, read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking) ); |
|
352 if ( error ) // jpeg error detected |
|
353 { |
|
354 if ( ( error != KErrCorrupt ) || ( read ) ) |
|
355 { |
|
356 if ( read ) |
|
357 { |
|
358 delete read; |
|
359 } |
|
360 if ( error ) |
|
361 { |
|
362 User::Leave( error ); |
|
363 } |
|
364 User::Leave(KErrGeneral); |
|
365 } |
|
366 } |
|
367 else if( read ) |
|
368 { |
|
369 CleanupStack::PushL(read); |
|
370 TUtils::GetAllTagsTestL( read, KInvalidExif11 ); |
|
371 CleanupStack::Pop(read); |
|
372 } |
|
373 else |
|
374 { |
|
375 RDebug::Print(_L("CExifReadTest::ExifRead202L(): KInvalidExif11 return no buffer")); |
|
376 } |
|
377 delete read; |
|
378 read = 0; |
|
379 CleanupStack::PopAndDestroy(exif); |
|
380 |
|
381 exif = TUtils::ReadFileL(iFs, KInvalidExif12, 65536); |
|
382 CleanupStack::PushL(exif); |
|
383 TRAP( error, read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking) ); |
|
384 if ( error ) // jpeg error detected |
|
385 { |
|
386 if ( ( error != KErrCorrupt ) || ( read ) ) |
|
387 { |
|
388 if ( read ) |
|
389 { |
|
390 delete read; |
|
391 } |
|
392 if ( error ) |
|
393 { |
|
394 User::Leave( error ); |
|
395 } |
|
396 User::Leave(KErrGeneral); |
|
397 } |
|
398 } |
|
399 else if( read ) |
|
400 { |
|
401 CleanupStack::PushL(read); |
|
402 TUtils::GetAllTagsTestL( read, KInvalidExif12 ); |
|
403 CleanupStack::Pop(read); |
|
404 } |
|
405 else |
|
406 { |
|
407 RDebug::Print(_L("CExifReadTest::ExifRead202L(): KInvalidExif12 return no buffer")); |
|
408 } |
|
409 delete read; |
|
410 read = 0; |
|
411 CleanupStack::PopAndDestroy(exif); |
|
412 |
|
413 exif = TUtils::ReadFileL(iFs, KInvalidExif13, 65536); |
|
414 CleanupStack::PushL(exif); |
|
415 TRAP( error, read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking) ); |
|
416 if ( error ) // jpeg error detected |
|
417 { |
|
418 if ( ( error != KErrCorrupt ) || ( read ) ) |
|
419 { |
|
420 if ( read ) |
|
421 { |
|
422 delete read; |
|
423 } |
|
424 if ( error ) |
|
425 { |
|
426 User::Leave( error ); |
|
427 } |
|
428 User::Leave(KErrGeneral); |
|
429 } |
|
430 } |
|
431 else if( read ) |
|
432 { |
|
433 CleanupStack::PushL(read); |
|
434 TUtils::GetAllTagsTestL( read, KInvalidExif13 ); |
|
435 CleanupStack::Pop(read); |
|
436 } |
|
437 else |
|
438 { |
|
439 RDebug::Print(_L("CExifReadTest::ExifRead202L(): KInvalidExif13 return no buffer")); |
|
440 } |
|
441 delete read; |
|
442 read = 0; |
|
443 CleanupStack::PopAndDestroy(exif); |
|
444 |
|
445 /* Supported, but uncompressed thumbnail is skipped */ |
|
446 exif = TUtils::ReadFileL(iFs, KNotSupportedExif1, 65536); |
|
447 CleanupStack::PushL(exif); |
|
448 TRAP( error, read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking) ); |
|
449 if ( ( error != KErrNone ) || ( !read ) ) |
|
450 { |
|
451 if ( read ) |
|
452 { |
|
453 delete read; |
|
454 } |
|
455 if ( error ) |
|
456 { |
|
457 User::Leave( error ); |
|
458 } |
|
459 User::Leave(KErrGeneral); |
|
460 } |
|
461 else if( read ) |
|
462 { |
|
463 CleanupStack::PushL(read); |
|
464 TUtils::GetAllTagsTestL( read, KNotSupportedExif1 ); |
|
465 CleanupStack::Pop(read); |
|
466 } |
|
467 else |
|
468 { |
|
469 RDebug::Print(_L("CExifReadTest::ExifRead202L(): KNotSupportedExif1 return no buffer")); |
|
470 } |
|
471 delete read; |
|
472 read = 0; |
|
473 CleanupStack::PopAndDestroy(exif); |
|
474 |
|
475 /* Supported, but unsupported (uncompressed) thumbnail is skipped */ |
|
476 exif = TUtils::ReadFileL(iFs, KNotSupportedExif2, 65536); |
|
477 CleanupStack::PushL(exif); |
|
478 TRAP( error, read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking) ); |
|
479 if ( ( error != KErrNone ) || ( !read ) ) |
|
480 { |
|
481 if ( read ) |
|
482 { |
|
483 delete read; |
|
484 } |
|
485 if ( error ) |
|
486 { |
|
487 User::Leave( error ); |
|
488 } |
|
489 User::Leave(KErrGeneral); |
|
490 } |
|
491 else if( read ) |
|
492 { |
|
493 CleanupStack::PushL(read); |
|
494 TUtils::GetAllTagsTestL( read, KNotSupportedExif2 ); |
|
495 CleanupStack::Pop(read); |
|
496 } |
|
497 else |
|
498 { |
|
499 RDebug::Print(_L("CExifReadTest::ExifRead202L(): KNotSupportedExif2 return no buffer")); |
|
500 } |
|
501 delete read; |
|
502 read = 0; |
|
503 CleanupStack::PopAndDestroy(exif); |
|
504 |
|
505 // Corrupted over 64k tag data |
|
506 exif = TUtils::ReadFileL(iFs, KInvalidExif14, 65536); |
|
507 CleanupStack::PushL(exif); |
|
508 TRAP( error, read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking) ); |
|
509 if ( error ) // jpeg error detected |
|
510 { |
|
511 if ( ( error != KErrCorrupt ) || ( read ) ) |
|
512 { |
|
513 if ( read ) |
|
514 { |
|
515 delete read; |
|
516 } |
|
517 if ( error ) |
|
518 { |
|
519 User::Leave( error ); |
|
520 } |
|
521 User::Leave(KErrGeneral); |
|
522 } |
|
523 } |
|
524 else if( read ) |
|
525 { |
|
526 CleanupStack::PushL(read); |
|
527 TUtils::GetAllTagsTestL( read, KInvalidExif14 ); |
|
528 CleanupStack::Pop(read); |
|
529 } |
|
530 else |
|
531 { |
|
532 RDebug::Print(_L("CExifReadTest::ExifRead202L(): KInvalidExif14 return no buffer")); |
|
533 } |
|
534 delete read; |
|
535 read = 0; |
|
536 CleanupStack::PopAndDestroy(exif); |
|
537 } |
|
538 |
|
539 |
|
540 // Exif.Read.203 |
|
541 // Retrieve a tag existing in the specified IFD from Exif data. |
|
542 // The requested tag instance (unmodifiable / const) is returned. |
|
543 void CExifReadTest::ExifRead203L() |
|
544 { |
|
545 // For each IFD. |
|
546 HBufC8* exif = TUtils::ReadFileL(iFs, KFullExif, 65536); |
|
547 CleanupStack::PushL(exif); |
|
548 CExifRead* read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking); |
|
549 CleanupStack::PushL(read); |
|
550 |
|
551 const CExifTag* tag = read->GetTagL(EIfd0, KIdXResolution); |
|
552 if(!tag) |
|
553 User::Leave(KErrGeneral); |
|
554 |
|
555 tag = read->GetTagL(EIfdExif, KIdColorSpace); |
|
556 if(!tag) |
|
557 User::Leave(KErrGeneral); |
|
558 |
|
559 tag = read->GetTagL(EIfd1, KIdCompression); |
|
560 if(!tag) |
|
561 User::Leave(KErrGeneral); |
|
562 |
|
563 tag = read->GetTagL(EIfdIntOp, 1); |
|
564 if(!tag) |
|
565 User::Leave(KErrGeneral); |
|
566 |
|
567 tag = read->GetTagL(EIfdGps, KIdGpsVersion); |
|
568 if(!tag) |
|
569 User::Leave(KErrGeneral); |
|
570 |
|
571 CleanupStack::PopAndDestroy(read); |
|
572 CleanupStack::PopAndDestroy(exif); |
|
573 } |
|
574 |
|
575 |
|
576 // Exif.Read.204 |
|
577 // Try to retrieve a tag which doesn't exist in the Exif data. |
|
578 // Leaves with proper error code. |
|
579 void CExifReadTest::ExifRead204L() |
|
580 { |
|
581 HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif, 65536); |
|
582 CleanupStack::PushL(exif); |
|
583 CExifRead* read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking); |
|
584 CleanupStack::PushL(read); |
|
585 |
|
586 const CExifTag* tag = NULL; |
|
587 // IFD exists but tag doesn't exist, |
|
588 TRAPD(error, tag = read->GetTagL(EIfd0, KIdArtist)); |
|
589 if(error != KErrNotFound) |
|
590 { |
|
591 if(error) |
|
592 User::Leave(error); |
|
593 else |
|
594 User::Leave(KErrGeneral); |
|
595 } |
|
596 |
|
597 // IFD doesn't exist |
|
598 TRAP(error, tag = read->GetTagL(EIfdGps, KIdGpsVersion)); |
|
599 if(error != KErrNotFound) |
|
600 { |
|
601 if(error) |
|
602 User::Leave(error); |
|
603 else |
|
604 User::Leave(KErrGeneral); |
|
605 } |
|
606 |
|
607 CleanupStack::PopAndDestroy(read); |
|
608 CleanupStack::PopAndDestroy(exif); |
|
609 } |
|
610 |
|
611 |
|
612 // Exif.Read.205 |
|
613 // Try to retrieve a tag with invalid parameters. |
|
614 // Leaves with proper error code. |
|
615 void CExifReadTest::ExifRead205L() |
|
616 { |
|
617 HBufC8* exif = TUtils::ReadFileL(iFs, KFullExif, 65536); |
|
618 CleanupStack::PushL(exif); |
|
619 CExifRead* read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking); |
|
620 CleanupStack::PushL(read); |
|
621 |
|
622 const CExifTag* tag; |
|
623 // Tag ID is invalid |
|
624 TRAPD(error, tag = read->GetTagL(EIfdExif, 200)); |
|
625 if(error != KErrNotSupported) |
|
626 { |
|
627 if(error) |
|
628 User::Leave(error); |
|
629 else |
|
630 User::Leave(KErrGeneral); |
|
631 } |
|
632 |
|
633 // Tag cannot exist in the specified IFD. |
|
634 TRAP(error, tag = read->GetTagL(EIfdGps, KIdImageDescription)); |
|
635 if(error != KErrNotSupported) |
|
636 { |
|
637 if(error) |
|
638 User::Leave(error); |
|
639 else |
|
640 User::Leave(KErrGeneral); |
|
641 } |
|
642 |
|
643 CleanupStack::PopAndDestroy(read); |
|
644 CleanupStack::PopAndDestroy(exif); |
|
645 } |
|
646 |
|
647 |
|
648 // Exif.Read.206 |
|
649 // Retrieve the IDs of tags from an IFD in Exif data. |
|
650 // Returns the tag IDs and the number of IDs |
|
651 void CExifReadTest::ExifRead206L() |
|
652 { |
|
653 // For each IFD. |
|
654 HBufC8* exif = TUtils::ReadFileL(iFs, KFullExif, 65536); |
|
655 CleanupStack::PushL(exif); |
|
656 CExifRead* read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking); |
|
657 CleanupStack::PushL(read); |
|
658 |
|
659 TInt no = 0; |
|
660 TUint16* tags = read->GetTagIdsL(EIfd0, no); |
|
661 if((!tags) || (no != 14)) |
|
662 { |
|
663 if(tags) |
|
664 delete tags; |
|
665 User::Leave(KErrGeneral); |
|
666 } |
|
667 delete tags; |
|
668 tags = 0; |
|
669 |
|
670 tags = read->GetTagIdsL(EIfdExif, no); |
|
671 if((!tags) || (no != 41)) |
|
672 { |
|
673 if(tags) |
|
674 delete tags; |
|
675 User::Leave(KErrGeneral); |
|
676 } |
|
677 delete tags; |
|
678 tags = 0; |
|
679 |
|
680 tags = read->GetTagIdsL(EIfd1, no); |
|
681 if((!tags) || (no != 6)) |
|
682 { |
|
683 if(tags) |
|
684 delete tags; |
|
685 User::Leave(KErrGeneral); |
|
686 } |
|
687 delete tags; |
|
688 tags = 0; |
|
689 |
|
690 tags = read->GetTagIdsL(EIfdIntOp, no); |
|
691 if((!tags) || (no != 4)) |
|
692 { |
|
693 if(tags) |
|
694 delete tags; |
|
695 User::Leave(KErrGeneral); |
|
696 } |
|
697 delete tags; |
|
698 tags = 0; |
|
699 |
|
700 tags = read->GetTagIdsL(EIfdGps, no); |
|
701 if((!tags) || (no != 4)) |
|
702 { |
|
703 if(tags) |
|
704 delete tags; |
|
705 User::Leave(KErrGeneral); |
|
706 } |
|
707 delete tags; |
|
708 tags = 0; |
|
709 |
|
710 CleanupStack::PopAndDestroy(read); |
|
711 CleanupStack::PopAndDestroy(exif); |
|
712 } |
|
713 |
|
714 |
|
715 // Exif.Read.207 |
|
716 // Try to retrieve the IDs of tags from an IFD, which doesn't exist in Exif data. |
|
717 // Leaves with proper error code. |
|
718 void CExifReadTest::ExifRead207L() |
|
719 { |
|
720 HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif, 65536); |
|
721 CleanupStack::PushL(exif); |
|
722 CExifRead* read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking); |
|
723 CleanupStack::PushL(read); |
|
724 |
|
725 TInt no = 0; |
|
726 TUint16* tags = NULL; |
|
727 TRAPD(error, tags = read->GetTagIdsL(EIfdGps, no)); |
|
728 if(tags) |
|
729 delete tags; |
|
730 if(error != KErrNotFound) |
|
731 { |
|
732 if(error) |
|
733 User::Leave(error); |
|
734 else |
|
735 User::Leave(KErrGeneral); |
|
736 } |
|
737 CleanupStack::PopAndDestroy(read); |
|
738 CleanupStack::PopAndDestroy(exif); |
|
739 } |
|
740 |
|
741 |
|
742 // Exif.Read.208 |
|
743 // Retrieve the types of IFDs included in Exif data. |
|
744 // Returns the IFD types and the number of IFDs. |
|
745 void CExifReadTest::ExifRead208L() |
|
746 { |
|
747 HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif, 65536); |
|
748 CleanupStack::PushL(exif); |
|
749 CExifRead* read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking); |
|
750 CleanupStack::PushL(read); |
|
751 |
|
752 TInt no = 0; |
|
753 TExifIfdType* ifds = read->GetIfdTypesL(no); |
|
754 if((!ifds) && (no != 4)) |
|
755 { |
|
756 if(ifds) |
|
757 delete ifds; |
|
758 User::Leave(KErrGeneral); |
|
759 } |
|
760 delete ifds; |
|
761 CleanupStack::PopAndDestroy(read); |
|
762 CleanupStack::PopAndDestroy(exif); |
|
763 } |
|
764 |
|
765 |
|
766 // Exif.Read.209 |
|
767 // Retrieve a copy of existing Exif thumbnail image from Exif data. |
|
768 // Returns the Exif thumbnail image. |
|
769 void CExifReadTest::ExifRead209L() |
|
770 { |
|
771 HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif, 65536); |
|
772 CleanupStack::PushL(exif); |
|
773 CExifRead* read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking); |
|
774 CleanupStack::PushL(read); |
|
775 |
|
776 HBufC8* thumbnail = read->GetThumbnailL(); |
|
777 if(!thumbnail) |
|
778 User::Leave(KErrGeneral); |
|
779 |
|
780 delete thumbnail; |
|
781 CleanupStack::PopAndDestroy(read); |
|
782 CleanupStack::PopAndDestroy(exif); |
|
783 } |
|
784 |
|
785 |
|
786 // Exif.Read.210 |
|
787 // Try to retrieve a copy of Exif thumbnail image from Exif data that doesn't contain compressed Exif thumbnail image. |
|
788 // Leaves with proper error code. |
|
789 void CExifReadTest::ExifRead210L() |
|
790 { |
|
791 HBufC8* exif = TUtils::ReadFileL(iFs, KNoThumbnail, 65536); |
|
792 CleanupStack::PushL(exif); |
|
793 CExifRead* read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking); |
|
794 CleanupStack::PushL(read); |
|
795 |
|
796 HBufC8* thumbnail = NULL; |
|
797 TRAPD(error, thumbnail = read->GetThumbnailL()); |
|
798 if(thumbnail) |
|
799 delete thumbnail; |
|
800 if(error != KErrNotFound) |
|
801 { |
|
802 if(error) |
|
803 User::Leave(error); |
|
804 else |
|
805 User::Leave(KErrGeneral); |
|
806 } |
|
807 CleanupStack::PopAndDestroy(read); |
|
808 CleanupStack::PopAndDestroy(exif); |
|
809 } |
|
810 |
|
811 |
|
812 // Exif.Read.211 |
|
813 // Check if an IFD exists in Exif data. |
|
814 // Returns ETrue if specified IFD exists, EFalse otherwise. |
|
815 void CExifReadTest::ExifRead211L() |
|
816 { |
|
817 // For each IFD |
|
818 HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif, 65536); |
|
819 CleanupStack::PushL(exif); |
|
820 CExifRead* read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking); |
|
821 CleanupStack::PushL(read); |
|
822 |
|
823 // IFD exists, |
|
824 if(!read->IfdExists(EIfd0)) |
|
825 User::Leave(KErrGeneral); |
|
826 if(!read->IfdExists(EIfdExif)) |
|
827 User::Leave(KErrGeneral); |
|
828 if(!read->IfdExists(EIfd1)) |
|
829 User::Leave(KErrGeneral); |
|
830 if(!read->IfdExists(EIfdIntOp)) |
|
831 User::Leave(KErrGeneral); |
|
832 // IFD doesn't exist. |
|
833 if(read->IfdExists(EIfdGps)) |
|
834 User::Leave(KErrGeneral); |
|
835 |
|
836 CleanupStack::PopAndDestroy(read); |
|
837 CleanupStack::PopAndDestroy(exif); |
|
838 } |
|
839 |
|
840 |
|
841 // Exif.Read.212 |
|
842 // Check if a tag exists in the specified IFD of Exif data. |
|
843 // Returns ETrue if tag exists in the specified IFD, EFalse otherwise. |
|
844 void CExifReadTest::ExifRead212L() |
|
845 { |
|
846 // For each IFD; |
|
847 HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif, 65536); |
|
848 CleanupStack::PushL(exif); |
|
849 CExifRead* read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking); |
|
850 CleanupStack::PushL(read); |
|
851 |
|
852 // Tag exists in IFD, |
|
853 if(!read->TagExists(KIdXResolution, EIfd0)) |
|
854 User::Leave(KErrGeneral); |
|
855 if(!read->TagExists(KIdComponentsConfiguration, EIfdExif)) |
|
856 User::Leave(KErrGeneral); |
|
857 if(!read->TagExists(1, EIfdIntOp)) |
|
858 User::Leave(KErrGeneral); |
|
859 // IFD exists but tag doesn't exist, |
|
860 if(read->TagExists(KIdCopyright, EIfd1)) |
|
861 User::Leave(KErrGeneral); |
|
862 // IFD doesn't exist |
|
863 if(read->TagExists(KIdGpsVersion, EIfdGps)) |
|
864 User::Leave(KErrGeneral); |
|
865 |
|
866 CleanupStack::PopAndDestroy(read); |
|
867 CleanupStack::PopAndDestroy(exif); |
|
868 } |
|
869 |
|
870 |
|
871 // Exif.Read.213 |
|
872 // Retrieve specific data using Get functions. |
|
873 // Returns the requested data. |
|
874 void CExifReadTest::ExifRead213L() |
|
875 { |
|
876 HBufC8* exif = TUtils::ReadFileL(iFs, KFullExif, 65536); |
|
877 CleanupStack::PushL(exif); |
|
878 CExifRead* read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking); |
|
879 CleanupStack::PushL(read); |
|
880 |
|
881 // For some Get functions. |
|
882 HBufC8* data = read->GetImageDescriptionL(); |
|
883 if(!data) |
|
884 User::Leave(KErrGeneral); |
|
885 delete data; |
|
886 data = 0; |
|
887 |
|
888 data = read->GetMakeL(); |
|
889 if(!data) |
|
890 User::Leave(KErrGeneral); |
|
891 delete data; |
|
892 data = 0; |
|
893 |
|
894 data = read->GetDateTimeOriginalL(); |
|
895 if(!data) |
|
896 User::Leave(KErrGeneral); |
|
897 delete data; |
|
898 data = 0; |
|
899 |
|
900 data = read->GetTransferFunctionL(); |
|
901 if(!data) |
|
902 User::Leave(KErrGeneral); |
|
903 delete data; |
|
904 data = 0; |
|
905 |
|
906 data = read->GetRelatedSoundFileL(); |
|
907 if(!data) |
|
908 User::Leave(KErrGeneral); |
|
909 delete data; |
|
910 data = 0; |
|
911 |
|
912 data = read->GetModelL(); |
|
913 if(!data) |
|
914 User::Leave(KErrGeneral); |
|
915 delete data; |
|
916 data = 0; |
|
917 |
|
918 data = read->GetMakerNoteL(); |
|
919 if(!data) |
|
920 User::Leave(KErrGeneral); |
|
921 delete data; |
|
922 data = 0; |
|
923 |
|
924 data = read->GetIsoSpeedRatingsL(); |
|
925 if(!data) |
|
926 User::Leave(KErrGeneral); |
|
927 delete data; |
|
928 data = 0; |
|
929 |
|
930 data = read->GetDateTimeDigitizedL(); |
|
931 if(!data) |
|
932 User::Leave(KErrGeneral); |
|
933 delete data; |
|
934 data = 0; |
|
935 |
|
936 data = read->GetCopyrightL(); |
|
937 if(!data) |
|
938 User::Leave(KErrGeneral); |
|
939 delete data; |
|
940 data = 0; |
|
941 |
|
942 |
|
943 TUint16 uInt16 = 0; |
|
944 TUint32 uInt32 = 0; |
|
945 TUint32 uInt32i = 0; |
|
946 TInt32 int32 = 0; |
|
947 TInt32 int32i = 0; |
|
948 TInt8 int8 = 0; |
|
949 TUint8 a1 = 0; |
|
950 TUint8 a2 = 0; |
|
951 TUint8 a3 = 0; |
|
952 TUint8 a4 = 0; |
|
953 |
|
954 User::LeaveIfError(read->GetExposureTime(uInt32, uInt32i)); |
|
955 if((uInt32 != 0) || (uInt32i != 0)) |
|
956 User::Leave(KErrGeneral); |
|
957 User::LeaveIfError(read->GetShutterSpeedValue(int32, int32i)); |
|
958 if((int32 != 0x00087383) || (int32i != 0x00010000)) |
|
959 User::Leave(KErrGeneral); |
|
960 User::LeaveIfError(read->GetBrightnessValue(int32, int32i)); |
|
961 if((int32 != 0) || (int32i != 1)) |
|
962 User::Leave(KErrGeneral); |
|
963 User::LeaveIfError(read->GetCustomRendered(uInt16)); |
|
964 if(uInt16 != 0) |
|
965 User::Leave(KErrGeneral); |
|
966 User::LeaveIfError(read->GetGainControl(uInt16)); |
|
967 if(uInt16 != 0) |
|
968 User::Leave(KErrGeneral); |
|
969 User::LeaveIfError(read->GetGpsVersion(uInt32)); |
|
970 if(uInt32 != 0x00000202) |
|
971 User::Leave(KErrGeneral); |
|
972 User::LeaveIfError(read->GetComponentsConfiguration(a1, a2, a3, a4)); |
|
973 if((a1 != 1) || (a2 != 2) || (a3 != 3 ) || (a4 != 0)) |
|
974 User::Leave(KErrGeneral); |
|
975 User::LeaveIfError(read->GetOrientation(uInt16)); |
|
976 if(uInt16 != 1) |
|
977 User::Leave(KErrGeneral); |
|
978 User::LeaveIfError(read->GetXResolution(uInt32, uInt32i)); |
|
979 if((uInt32 != 180) || (uInt32i != 1)) |
|
980 User::Leave(KErrGeneral); |
|
981 User::LeaveIfError(read->GetExifIfdPointer(uInt32)); |
|
982 if(uInt32 != 1798) |
|
983 User::Leave(KErrGeneral); |
|
984 User::LeaveIfError(read->GetFileSource(int8)); |
|
985 if(int8 != 3) |
|
986 User::Leave(KErrGeneral); |
|
987 User::LeaveIfError(read->GetSharpness(uInt16)); |
|
988 if(uInt16 != 0) |
|
989 User::Leave(KErrGeneral); |
|
990 User::LeaveIfError(read->GetExifVersion(uInt32)); |
|
991 if(uInt32 != 0x30323230) |
|
992 User::Leave(KErrGeneral); |
|
993 User::LeaveIfError(read->GetThumbnailXResolution(uInt32, uInt32i)); |
|
994 if((uInt32 != 180) || (uInt32i != 1)) |
|
995 User::Leave(KErrGeneral); |
|
996 User::LeaveIfError(read->GetThumbnailCompression(uInt16)); |
|
997 if(uInt16 != 6) |
|
998 User::Leave(KErrGeneral); |
|
999 User::LeaveIfError(read->GetJpegInterchangeFormat(uInt32)); |
|
1000 if(uInt32 != 2814) |
|
1001 User::Leave(KErrGeneral); |
|
1002 User::LeaveIfError(read->GetWhiteBalance(uInt16)); |
|
1003 if(uInt16 != 0) |
|
1004 User::Leave(KErrGeneral); |
|
1005 User::LeaveIfError(read->GetSceneCaptureType(uInt16)); |
|
1006 if(uInt16 != 0) |
|
1007 User::Leave(KErrGeneral); |
|
1008 User::LeaveIfError(read->GetSaturation(uInt16)); |
|
1009 if(uInt16 != 0) |
|
1010 User::Leave(KErrGeneral); |
|
1011 User::LeaveIfError(read->GetMeteringMode(uInt16)); |
|
1012 if(uInt16 != 2) |
|
1013 User::Leave(KErrGeneral); |
|
1014 User::LeaveIfError(read->GetJpegInterchangeFormatLength(uInt32)); |
|
1015 if(uInt32 != 5342) |
|
1016 User::Leave(KErrGeneral); |
|
1017 User::LeaveIfError(read->GetInteroperabilityIfdPointer(uInt32)); |
|
1018 if(uInt32 != 2666) |
|
1019 User::Leave(KErrGeneral); |
|
1020 User::LeaveIfError(read->GetGpsInfoIfdPointer(uInt32)); |
|
1021 if(uInt32 != 2612) |
|
1022 User::Leave(KErrGeneral); |
|
1023 User::LeaveIfError(read->GetFlashPixVersion(uInt32)); |
|
1024 if(uInt32 != 0x30303130) |
|
1025 User::Leave(KErrGeneral); |
|
1026 User::LeaveIfError(read->GetExposureProgram(uInt16)); |
|
1027 if(uInt16 != 0) |
|
1028 User::Leave(KErrGeneral); |
|
1029 User::LeaveIfError(read->GetExposureMode(uInt16)); |
|
1030 if(uInt16 != 0) |
|
1031 User::Leave(KErrGeneral); |
|
1032 User::LeaveIfError(read->GetExposureBiasValue(int32, int32i)); |
|
1033 if((int32 != 0) || (int32i != 3)) |
|
1034 User::Leave(KErrGeneral); |
|
1035 User::LeaveIfError(read->GetContrast(uInt16)); |
|
1036 if(uInt16 != 0) |
|
1037 User::Leave(KErrGeneral); |
|
1038 User::LeaveIfError(read->GetApertureValue(uInt32, uInt32i)); |
|
1039 if((uInt32 != 262144) || (uInt32i != 65536)) |
|
1040 User::Leave(KErrGeneral); |
|
1041 |
|
1042 |
|
1043 CleanupStack::PopAndDestroy(read); |
|
1044 CleanupStack::PopAndDestroy(exif); |
|
1045 } |
|
1046 |
|
1047 |
|
1048 // Exif.Read.214 |
|
1049 // Try to retrieve specific data that is not present in the Exif data using Get functions. |
|
1050 // Leaves with or returns proper error code. |
|
1051 void CExifReadTest::ExifRead214L() |
|
1052 { |
|
1053 HBufC8* exif = TUtils::ReadFileL(iFs, KNoThumbnail, 65536); |
|
1054 CleanupStack::PushL(exif); |
|
1055 CExifRead* read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking); |
|
1056 CleanupStack::PushL(read); |
|
1057 |
|
1058 // For some Get functions. |
|
1059 HBufC8* data = NULL; |
|
1060 TRAPD(error, data = read->GetSoftwareL()); |
|
1061 if(data) |
|
1062 delete data; |
|
1063 data = 0; |
|
1064 if(error != KErrNotFound) |
|
1065 { |
|
1066 if(error) |
|
1067 User::Leave(error); |
|
1068 else |
|
1069 User::Leave(KErrGeneral); |
|
1070 } |
|
1071 TRAP(error, data = read->GetUserCommentL()); |
|
1072 if(data) |
|
1073 delete data; |
|
1074 data = 0; |
|
1075 if(error != KErrNotFound) |
|
1076 { |
|
1077 if(error) |
|
1078 User::Leave(error); |
|
1079 else |
|
1080 User::Leave(KErrGeneral); |
|
1081 } |
|
1082 |
|
1083 TUint16 uInt16 = 0; |
|
1084 TUint32 uInt32 = 0; |
|
1085 TUint32 uInt32i = 0; |
|
1086 TInt8 int8 = 0; |
|
1087 error = read->GetLightSource(uInt16); |
|
1088 if(error != KErrNotFound) |
|
1089 { |
|
1090 if(error) |
|
1091 User::Leave(error); |
|
1092 else |
|
1093 User::Leave(KErrGeneral); |
|
1094 } |
|
1095 error = read->GetFileSource(int8); |
|
1096 if(error != KErrNotFound) |
|
1097 { |
|
1098 if(error) |
|
1099 User::Leave(error); |
|
1100 else |
|
1101 User::Leave(KErrGeneral); |
|
1102 } |
|
1103 error = read->GetDigitalZoomRatio(uInt32, uInt32i); |
|
1104 if(error != KErrNotFound) |
|
1105 { |
|
1106 if(error) |
|
1107 User::Leave(error); |
|
1108 else |
|
1109 User::Leave(KErrGeneral); |
|
1110 } |
|
1111 error = read->GetThumbnailCompression(uInt16); |
|
1112 if(error != KErrNotFound) |
|
1113 { |
|
1114 if(error) |
|
1115 User::Leave(error); |
|
1116 else |
|
1117 User::Leave(KErrGeneral); |
|
1118 } |
|
1119 error = read->GetJpegInterchangeFormat(uInt32); |
|
1120 if(error != KErrNotFound) |
|
1121 { |
|
1122 if(error) |
|
1123 User::Leave(error); |
|
1124 else |
|
1125 User::Leave(KErrGeneral); |
|
1126 } |
|
1127 |
|
1128 CleanupStack::PopAndDestroy(read); |
|
1129 CleanupStack::PopAndDestroy(exif); |
|
1130 } |
|
1131 |
|
1132 // Exif.Read.216 |
|
1133 // Retrieve the Exif APP1 segment. |
|
1134 // Returns the whole Exif APP1 segment. |
|
1135 void CExifReadTest::ExifRead216L() |
|
1136 { |
|
1137 |
|
1138 HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif, 65536); |
|
1139 CleanupStack::PushL(exif); |
|
1140 CExifRead* read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking); |
|
1141 CleanupStack::PushL(read); |
|
1142 |
|
1143 HBufC8* appSegment = read->GetExifAppSegmentL(); |
|
1144 CleanupStack::PushL( appSegment ); |
|
1145 if ( appSegment->Length() != 12670 ) |
|
1146 { |
|
1147 User::Leave( KErrGeneral ); |
|
1148 } |
|
1149 if ( *appSegment->Ptr() != 0xff ) |
|
1150 { |
|
1151 User::Leave( KErrGeneral ); |
|
1152 } |
|
1153 if ( *( appSegment->Ptr() + appSegment->Length() - 1 ) != 0xd9 ) |
|
1154 { |
|
1155 User::Leave( KErrGeneral ); |
|
1156 } |
|
1157 CleanupStack::PopAndDestroy( appSegment ); |
|
1158 |
|
1159 CleanupStack::PopAndDestroy(read); |
|
1160 CleanupStack::PopAndDestroy(exif); |
|
1161 |
|
1162 exif = TUtils::ReadFileL(iFs, KFullExif, 65536); |
|
1163 CleanupStack::PushL(exif); |
|
1164 read = CExifRead::NewL(*exif, CExifRead::ENoJpeg | CExifRead::ENoTagChecking); |
|
1165 CleanupStack::PushL(read); |
|
1166 |
|
1167 appSegment = read->GetExifAppSegmentL(); |
|
1168 CleanupStack::PushL( appSegment ); |
|
1169 if ( appSegment->Length() != 8166 ) |
|
1170 { |
|
1171 User::Leave( KErrGeneral ); |
|
1172 } |
|
1173 if ( *appSegment->Ptr() != 0xff ) |
|
1174 { |
|
1175 User::Leave( KErrGeneral ); |
|
1176 } |
|
1177 if ( *( appSegment->Ptr() + appSegment->Length() - 1 ) != 0xd9 ) |
|
1178 { |
|
1179 User::Leave( KErrGeneral ); |
|
1180 } |
|
1181 CleanupStack::PopAndDestroy( appSegment ); |
|
1182 |
|
1183 CleanupStack::PopAndDestroy(read); |
|
1184 CleanupStack::PopAndDestroy(exif); |
|
1185 } |
|
1186 |
|
1187 // Exif.Read.215 |
|
1188 // Test the behavior of the previous test cases in OOM situations. |
|
1189 // Successfully operates or leaves with OOM error, without any memory leaks. |
|
1190 void CExifReadTest::ExifRead215L() |
|
1191 { |
|
1192 // OOM in EXIF.READ.201- EXIF.READ.216 |
|
1193 TInt error = KErrGeneral; |
|
1194 TInt i = 0; |
|
1195 |
|
1196 RDebug::Print(_L("ExifRead201L() memory test")); |
|
1197 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1198 for(i = 1; i < 500; i++) |
|
1199 #else |
|
1200 for(i = 1; i < 10; i++) |
|
1201 #endif |
|
1202 { |
|
1203 __UHEAP_MARK; |
|
1204 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1205 __UHEAP_SETFAIL( RHeap::EFailNext, i ); |
|
1206 #else |
|
1207 __UHEAP_SETFAIL( RHeap::ERandom, i ); |
|
1208 #endif |
|
1209 TRAP(error, ExifRead201L()); |
|
1210 if(error) |
|
1211 { |
|
1212 if(error != KErrNoMemory) |
|
1213 { |
|
1214 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1215 RDebug::Print((_L("ExifRead215L() TRAP error=%d")),error); |
|
1216 User::Leave(KErrGeneral); |
|
1217 } |
|
1218 } |
|
1219 else |
|
1220 { |
|
1221 __UHEAP_MARKEND; |
|
1222 break; |
|
1223 } |
|
1224 __UHEAP_MARKEND; |
|
1225 } |
|
1226 |
|
1227 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1228 RDebug::Print(_L("ExifRead102L() memory test")); |
|
1229 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1230 for(i = 1; i < 500; i++) |
|
1231 #else |
|
1232 for(i = 1; i < 10; i++) |
|
1233 #endif |
|
1234 { |
|
1235 // RDebug::Print((_L("ExifRead102L() memory test i=%d")),i); |
|
1236 __UHEAP_MARK; |
|
1237 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1238 __UHEAP_SETFAIL( RHeap::EFailNext, i ); |
|
1239 #else |
|
1240 __UHEAP_SETFAIL( RHeap::ERandom, i ); |
|
1241 #endif |
|
1242 TRAP(error, ExifRead102L()); |
|
1243 if(error) |
|
1244 { |
|
1245 if(error != KErrNoMemory) |
|
1246 { |
|
1247 RDebug::Print((_L("ExifRead215L() TRAP error=%d")),error); |
|
1248 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1249 User::Leave(KErrGeneral); |
|
1250 } |
|
1251 } |
|
1252 else |
|
1253 { |
|
1254 __UHEAP_MARKEND; |
|
1255 break; |
|
1256 } |
|
1257 __UHEAP_MARKEND; |
|
1258 } |
|
1259 |
|
1260 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1261 RDebug::Print(_L("ExifRead103L() memory test")); |
|
1262 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1263 for(i = 1; i < 500; i++) |
|
1264 #else |
|
1265 for(i = 1; i < 10; i++) |
|
1266 #endif |
|
1267 { |
|
1268 __UHEAP_MARK; |
|
1269 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1270 __UHEAP_SETFAIL( RHeap::EFailNext, i ); |
|
1271 #else |
|
1272 __UHEAP_SETFAIL( RHeap::ERandom, i ); |
|
1273 #endif |
|
1274 TRAP(error, ExifRead103L()); |
|
1275 if(error) |
|
1276 { |
|
1277 if(error != KErrNoMemory) |
|
1278 { |
|
1279 RDebug::Print((_L("ExifRead215L() TRAP error=%d")),error); |
|
1280 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1281 User::Leave(KErrGeneral); |
|
1282 } |
|
1283 } |
|
1284 else |
|
1285 { |
|
1286 __UHEAP_MARKEND; |
|
1287 break; |
|
1288 } |
|
1289 __UHEAP_MARKEND; |
|
1290 } |
|
1291 |
|
1292 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1293 RDebug::Print(_L("ExifRead104L() memory test")); |
|
1294 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1295 for(i = 1; i < 500; i++) |
|
1296 #else |
|
1297 for(i = 1; i < 10; i++) |
|
1298 #endif |
|
1299 { |
|
1300 __UHEAP_MARK; |
|
1301 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1302 __UHEAP_SETFAIL( RHeap::EFailNext, i ); |
|
1303 #else |
|
1304 __UHEAP_SETFAIL( RHeap::ERandom, i ); |
|
1305 #endif |
|
1306 TRAP(error, ExifRead104L()); |
|
1307 if(error) |
|
1308 { |
|
1309 if(error != KErrNoMemory) |
|
1310 { |
|
1311 RDebug::Print((_L("ExifRead215L() TRAP error=%d")),error); |
|
1312 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1313 User::Leave(KErrGeneral); |
|
1314 } |
|
1315 } |
|
1316 else |
|
1317 { |
|
1318 __UHEAP_MARKEND; |
|
1319 break; |
|
1320 } |
|
1321 __UHEAP_MARKEND; |
|
1322 } |
|
1323 |
|
1324 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1325 RDebug::Print(_L("ExifRead105L() memory test")); |
|
1326 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1327 for(i = 1; i < 500; i++) |
|
1328 #else |
|
1329 for(i = 1; i < 10; i++) |
|
1330 #endif |
|
1331 { |
|
1332 __UHEAP_MARK; |
|
1333 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1334 __UHEAP_SETFAIL( RHeap::EFailNext, i ); |
|
1335 #else |
|
1336 __UHEAP_SETFAIL( RHeap::ERandom, i ); |
|
1337 #endif |
|
1338 TRAP(error, ExifRead105L()); |
|
1339 if(error) |
|
1340 { |
|
1341 if(error != KErrNoMemory) |
|
1342 { |
|
1343 RDebug::Print((_L("ExifRead215L() TRAP error=%d")),error); |
|
1344 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1345 User::Leave(KErrGeneral); |
|
1346 } |
|
1347 } |
|
1348 else |
|
1349 { |
|
1350 __UHEAP_MARKEND; |
|
1351 break; |
|
1352 } |
|
1353 __UHEAP_MARKEND; |
|
1354 } |
|
1355 |
|
1356 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1357 RDebug::Print(_L("ExifRead106L() memory test")); |
|
1358 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1359 for(i = 1; i < 500; i++) |
|
1360 #else |
|
1361 for(i = 1; i < 10; i++) |
|
1362 #endif |
|
1363 { |
|
1364 __UHEAP_MARK; |
|
1365 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1366 __UHEAP_SETFAIL( RHeap::EFailNext, i ); |
|
1367 #else |
|
1368 __UHEAP_SETFAIL( RHeap::ERandom, i ); |
|
1369 #endif |
|
1370 TRAP(error, ExifRead106L()); |
|
1371 if(error) |
|
1372 { |
|
1373 if(error != KErrNoMemory) |
|
1374 { |
|
1375 RDebug::Print((_L("ExifRead215L() TRAP error=%d")),error); |
|
1376 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1377 User::Leave(KErrGeneral); |
|
1378 } |
|
1379 } |
|
1380 else |
|
1381 { |
|
1382 __UHEAP_MARKEND; |
|
1383 break; |
|
1384 } |
|
1385 __UHEAP_MARKEND; |
|
1386 } |
|
1387 |
|
1388 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1389 RDebug::Print(_L("ExifRead107L() memory test")); |
|
1390 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1391 for(i = 1; i < 500; i++) |
|
1392 #else |
|
1393 for(i = 1; i < 10; i++) |
|
1394 #endif |
|
1395 { |
|
1396 __UHEAP_MARK; |
|
1397 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1398 __UHEAP_SETFAIL( RHeap::EFailNext, i ); |
|
1399 #else |
|
1400 __UHEAP_SETFAIL( RHeap::ERandom, i ); |
|
1401 #endif |
|
1402 TRAP(error, ExifRead107L()); |
|
1403 if(error) |
|
1404 { |
|
1405 if(error != KErrNoMemory) |
|
1406 { |
|
1407 RDebug::Print((_L("ExifRead215L() TRAP error=%d")),error); |
|
1408 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1409 User::Leave(KErrGeneral); |
|
1410 } |
|
1411 } |
|
1412 else |
|
1413 { |
|
1414 __UHEAP_MARKEND; |
|
1415 break; |
|
1416 } |
|
1417 __UHEAP_MARKEND; |
|
1418 } |
|
1419 |
|
1420 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1421 RDebug::Print(_L("ExifRead108L() memory test")); |
|
1422 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1423 for(i = 1; i < 500; i++) |
|
1424 #else |
|
1425 for(i = 1; i < 10; i++) |
|
1426 #endif |
|
1427 { |
|
1428 __UHEAP_MARK; |
|
1429 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1430 __UHEAP_SETFAIL( RHeap::EFailNext, i ); |
|
1431 #else |
|
1432 __UHEAP_SETFAIL( RHeap::ERandom, i ); |
|
1433 #endif |
|
1434 TRAP(error, ExifRead108L()); |
|
1435 if(error) |
|
1436 { |
|
1437 if(error != KErrNoMemory) |
|
1438 { |
|
1439 RDebug::Print((_L("ExifRead215L() TRAP error=%d")),error); |
|
1440 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1441 User::Leave(KErrGeneral); |
|
1442 } |
|
1443 } |
|
1444 else |
|
1445 { |
|
1446 __UHEAP_MARKEND; |
|
1447 break; |
|
1448 } |
|
1449 __UHEAP_MARKEND; |
|
1450 } |
|
1451 |
|
1452 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1453 RDebug::Print(_L("ExifRead109L() memory test")); |
|
1454 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1455 for(i = 1; i < 500; i++) |
|
1456 #else |
|
1457 for(i = 1; i < 10; i++) |
|
1458 #endif |
|
1459 { |
|
1460 __UHEAP_MARK; |
|
1461 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1462 __UHEAP_SETFAIL( RHeap::EFailNext, i ); |
|
1463 #else |
|
1464 __UHEAP_SETFAIL( RHeap::ERandom, i ); |
|
1465 #endif |
|
1466 TRAP(error, ExifRead109L()); |
|
1467 if(error) |
|
1468 { |
|
1469 if(error != KErrNoMemory) |
|
1470 { |
|
1471 RDebug::Print((_L("ExifRead215L() TRAP error=%d")),error); |
|
1472 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1473 User::Leave(KErrGeneral); |
|
1474 } |
|
1475 } |
|
1476 else |
|
1477 { |
|
1478 __UHEAP_MARKEND; |
|
1479 break; |
|
1480 } |
|
1481 __UHEAP_MARKEND; |
|
1482 } |
|
1483 |
|
1484 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1485 RDebug::Print(_L("ExifRead210L() memory test")); |
|
1486 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1487 for(i = 1; i < 500; i++) |
|
1488 #else |
|
1489 for(i = 1; i < 10; i++) |
|
1490 #endif |
|
1491 { |
|
1492 __UHEAP_MARK; |
|
1493 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1494 __UHEAP_SETFAIL( RHeap::EFailNext, i ); |
|
1495 #else |
|
1496 __UHEAP_SETFAIL( RHeap::ERandom, i ); |
|
1497 #endif |
|
1498 TRAP(error, ExifRead210L()); |
|
1499 if(error) |
|
1500 { |
|
1501 if(error != KErrNoMemory) |
|
1502 { |
|
1503 RDebug::Print((_L("ExifRead215L() TRAP error=%d")),error); |
|
1504 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1505 User::Leave(KErrGeneral); |
|
1506 } |
|
1507 } |
|
1508 else |
|
1509 { |
|
1510 __UHEAP_MARKEND; |
|
1511 break; |
|
1512 } |
|
1513 __UHEAP_MARKEND; |
|
1514 } |
|
1515 |
|
1516 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1517 RDebug::Print(_L("ExifRead211L() memory test")); |
|
1518 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1519 for(i = 1; i < 500; i++) |
|
1520 #else |
|
1521 for(i = 1; i < 10; i++) |
|
1522 #endif |
|
1523 { |
|
1524 __UHEAP_MARK; |
|
1525 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1526 __UHEAP_SETFAIL( RHeap::EFailNext, i ); |
|
1527 #else |
|
1528 __UHEAP_SETFAIL( RHeap::ERandom, i ); |
|
1529 #endif |
|
1530 TRAP(error, ExifRead211L()); |
|
1531 if(error) |
|
1532 { |
|
1533 if(error != KErrNoMemory) |
|
1534 { |
|
1535 RDebug::Print((_L("ExifRead215L() TRAP error=%d")),error); |
|
1536 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1537 User::Leave(KErrGeneral); |
|
1538 } |
|
1539 } |
|
1540 else |
|
1541 { |
|
1542 __UHEAP_MARKEND; |
|
1543 break; |
|
1544 } |
|
1545 __UHEAP_MARKEND; |
|
1546 } |
|
1547 |
|
1548 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1549 RDebug::Print(_L("ExifRead212L() memory test")); |
|
1550 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1551 for(i = 1; i < 500; i++) |
|
1552 #else |
|
1553 for(i = 1; i < 10; i++) |
|
1554 #endif |
|
1555 { |
|
1556 __UHEAP_MARK; |
|
1557 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1558 __UHEAP_SETFAIL( RHeap::EFailNext, i ); |
|
1559 #else |
|
1560 __UHEAP_SETFAIL( RHeap::ERandom, i ); |
|
1561 #endif |
|
1562 TRAP(error, ExifRead212L()); |
|
1563 if(error) |
|
1564 { |
|
1565 if(error != KErrNoMemory) |
|
1566 { |
|
1567 RDebug::Print((_L("ExifRead215L() TRAP error=%d")),error); |
|
1568 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1569 User::Leave(KErrGeneral); |
|
1570 } |
|
1571 } |
|
1572 else |
|
1573 { |
|
1574 __UHEAP_MARKEND; |
|
1575 break; |
|
1576 } |
|
1577 __UHEAP_MARKEND; |
|
1578 } |
|
1579 |
|
1580 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1581 RDebug::Print(_L("ExifRead213L() memory test")); |
|
1582 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1583 for(i = 1; i < 500; i++) |
|
1584 #else |
|
1585 for(i = 1; i < 10; i++) |
|
1586 #endif |
|
1587 { |
|
1588 __UHEAP_MARK; |
|
1589 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1590 __UHEAP_SETFAIL( RHeap::EFailNext, i ); |
|
1591 #else |
|
1592 __UHEAP_SETFAIL( RHeap::ERandom, i ); |
|
1593 #endif |
|
1594 TRAP(error, ExifRead213L()); |
|
1595 if(error) |
|
1596 { |
|
1597 if(error != KErrNoMemory) |
|
1598 { |
|
1599 RDebug::Print((_L("ExifRead215L() TRAP error=%d")),error); |
|
1600 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1601 User::Leave(KErrGeneral); |
|
1602 } |
|
1603 } |
|
1604 else |
|
1605 { |
|
1606 __UHEAP_MARKEND; |
|
1607 break; |
|
1608 } |
|
1609 __UHEAP_MARKEND; |
|
1610 } |
|
1611 |
|
1612 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1613 RDebug::Print(_L("ExifRead214L() memory test")); |
|
1614 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1615 for(i = 1; i < 500; i++) |
|
1616 #else |
|
1617 for(i = 1; i < 10; i++) |
|
1618 #endif |
|
1619 { |
|
1620 __UHEAP_MARK; |
|
1621 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1622 __UHEAP_SETFAIL( RHeap::EFailNext, i ); |
|
1623 #else |
|
1624 __UHEAP_SETFAIL( RHeap::ERandom, i ); |
|
1625 #endif |
|
1626 TRAP(error, ExifRead214L()); |
|
1627 if(error) |
|
1628 { |
|
1629 if(error != KErrNoMemory) |
|
1630 { |
|
1631 RDebug::Print((_L("ExifRead215L() TRAP error=%d")),error); |
|
1632 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1633 User::Leave(KErrGeneral); |
|
1634 } |
|
1635 } |
|
1636 else |
|
1637 { |
|
1638 __UHEAP_MARKEND; |
|
1639 break; |
|
1640 } |
|
1641 __UHEAP_MARKEND; |
|
1642 } |
|
1643 |
|
1644 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1645 RDebug::Print(_L("ExifRead216L() memory test")); |
|
1646 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1647 for(i = 1; i < 500; i++) |
|
1648 #else |
|
1649 for(i = 1; i < 10; i++) |
|
1650 #endif |
|
1651 { |
|
1652 __UHEAP_MARK; |
|
1653 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
1654 __UHEAP_SETFAIL( RHeap::EFailNext, i ); |
|
1655 #else |
|
1656 __UHEAP_SETFAIL( RHeap::ERandom, i ); |
|
1657 #endif |
|
1658 TRAP(error, ExifRead216L()); |
|
1659 if(error) |
|
1660 { |
|
1661 if(error != KErrNoMemory) |
|
1662 { |
|
1663 RDebug::Print((_L("ExifRead215L() TRAP error=%d")),error); |
|
1664 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1665 User::Leave(KErrGeneral); |
|
1666 } |
|
1667 } |
|
1668 else |
|
1669 { |
|
1670 __UHEAP_MARKEND; |
|
1671 break; |
|
1672 } |
|
1673 __UHEAP_MARKEND; |
|
1674 } |
|
1675 |
|
1676 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
1677 } |
|
1678 |