|
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 // Exif.Tag.001 |
|
20 // Duplicate an existing tag, and get related information of the tag. |
|
21 // Created tag instance is returned. |
|
22 void CExifTagTest::ExifTag001L() |
|
23 { |
|
24 HBufC8* exif = TUtils::ReadFileL(iFs, KFullExif); |
|
25 CleanupStack::PushL(exif); |
|
26 CExifRead* read = CExifRead::NewL(*exif); |
|
27 if(!read) |
|
28 User::Leave(KErrGeneral); |
|
29 CleanupStack::PushL(read); |
|
30 |
|
31 const CExifTag* tag = read->GetTagL(EIfd0, KIdImageDescription); |
|
32 CExifTag* copyTag = tag->DuplicateL(); |
|
33 if(!copyTag) |
|
34 User::Leave(KErrGeneral); |
|
35 CleanupStack::PushL(copyTag); |
|
36 |
|
37 if(copyTag->TagInfo().iId != KIdImageDescription) |
|
38 User::Leave(KErrGeneral); |
|
39 |
|
40 if(copyTag->TagInfo().iDataType != CExifTag::ETagAscii) |
|
41 User::Leave(KErrGeneral); |
|
42 |
|
43 if(copyTag->TagInfo().iDataCount != tag->TagInfo().iDataCount) |
|
44 User::Leave(KErrGeneral); |
|
45 |
|
46 if(copyTag->Data().Length() != tag->TagInfo().iDataCount) |
|
47 User::Leave(KErrGeneral); |
|
48 |
|
49 CleanupStack::PopAndDestroy(copyTag); |
|
50 CleanupStack::PopAndDestroy(read); |
|
51 CleanupStack::PopAndDestroy(exif); |
|
52 } |
|
53 |
|
54 |
|
55 // Exif.Tag.MEM.002 |
|
56 // Test the behavior of the previous test cases in OOM situations. |
|
57 // Successfully operates or leaves with OOM error, without any memory leaks. |
|
58 void CExifTagTest::ExifTag002L() |
|
59 { |
|
60 // EXIF.TAG.001 |
|
61 TInt error = KErrGeneral; |
|
62 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
63 for(TInt i = 1; i < 50 && error != KErrNone; i++) |
|
64 #else |
|
65 for(TInt i = 1; i < 10 && error != KErrNone; i++) |
|
66 #endif |
|
67 { |
|
68 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) ) |
|
69 __UHEAP_SETFAIL( RHeap::EFailNext, i ); |
|
70 #else |
|
71 __UHEAP_SETFAIL( RHeap::ERandom, i ); |
|
72 #endif |
|
73 TRAP(error, ExifTag001L()); |
|
74 if(error) |
|
75 { |
|
76 if(error != KErrNoMemory) |
|
77 { |
|
78 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
79 User::Leave(KErrGeneral); |
|
80 } |
|
81 } |
|
82 } |
|
83 __UHEAP_SETFAIL( RHeap::ENone, 0 ); |
|
84 } |