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