|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <s32mem.h> |
|
17 #include <e32test.h> |
|
18 #include <vprop.h> |
|
19 #include <versit.h> |
|
20 #include <vcal.h> |
|
21 #include <vcard.h> |
|
22 #include <f32file.h> |
|
23 #include <s32file.h> |
|
24 #include "testdata.h" |
|
25 |
|
26 // Type definitions |
|
27 #define UNUSED_VAR(a) a = a |
|
28 |
|
29 CConsoleBase* console; |
|
30 LOCAL_D RTest test(_L("TEST_SAVELOADBINOOM")); |
|
31 |
|
32 |
|
33 |
|
34 void doTestL() |
|
35 { |
|
36 console=Console::NewL(_L("TEST_SAVELOADBINOOM"),TSize(76,18)); |
|
37 CleanupStack::PushL(console); |
|
38 for (TInt ii=0;ii<10000;++ii) |
|
39 { |
|
40 CleanupStack::PushL(&ii); |
|
41 } |
|
42 CleanupStack::Pop(10000); |
|
43 |
|
44 RDesReadStream input1(vcardbinary); |
|
45 CParserVCard* vcard1 = CParserVCard::NewL(); |
|
46 CleanupStack::PushL(vcard1); |
|
47 vcard1->SetEntityNameL(_L("vcard")); |
|
48 vcard1->InternalizeL(input1); |
|
49 |
|
50 TInt ret=KErrNoMemory; |
|
51 TInt failAt=0; |
|
52 while (ret!=KErrNone) |
|
53 { |
|
54 failAt++; |
|
55 __UHEAP_SETFAIL(RHeap::EDeterministic,failAt); |
|
56 __UHEAP_MARK; |
|
57 TRAP(ret, vcard1->SaveBinaryValuesToFilesL(0,_L("c:\\"))); |
|
58 if (ret!=KErrNone) |
|
59 { |
|
60 __UHEAP_MARKEND; |
|
61 } |
|
62 __UHEAP_RESET; |
|
63 if (ret!=KErrNoMemory&&ret!=KErrNone) |
|
64 { |
|
65 test.Printf(_L("Non standard error: %d\n"),ret); |
|
66 test.Getch(); |
|
67 } |
|
68 test(ret==KErrNoMemory||ret==KErrNone); |
|
69 } |
|
70 |
|
71 while (ret!=KErrNone) |
|
72 { |
|
73 failAt++; |
|
74 __UHEAP_SETFAIL(RHeap::EDeterministic,failAt); |
|
75 __UHEAP_MARK; |
|
76 TRAP(ret, vcard1->LoadBinaryValuesFromFilesL()); |
|
77 if (ret!=KErrNone) |
|
78 { |
|
79 __UHEAP_MARKEND; |
|
80 } |
|
81 __UHEAP_RESET; |
|
82 if (ret!=KErrNoMemory&&ret!=KErrNone) |
|
83 { |
|
84 test.Printf(_L("Non standard error: %d\n"),ret); |
|
85 test.Getch(); |
|
86 } |
|
87 test(ret==KErrNoMemory||ret==KErrNone); |
|
88 } |
|
89 |
|
90 CleanupStack::PopAndDestroy(vcard1); |
|
91 |
|
92 RDesReadStream input2(vcardagent); |
|
93 CParserVCard* vcard2 = CParserVCard::NewL(); |
|
94 CleanupStack::PushL(vcard2); |
|
95 vcard2->SetEntityNameL(_L("vcard")); |
|
96 vcard2->InternalizeL(input2); |
|
97 RFs fs; |
|
98 fs.Connect(); |
|
99 CleanupClosePushL(fs); |
|
100 |
|
101 ret=KErrNoMemory; |
|
102 failAt=0; |
|
103 while (ret!=KErrNone) |
|
104 { |
|
105 failAt++; |
|
106 __UHEAP_SETFAIL(RHeap::EDeterministic,failAt); |
|
107 __UHEAP_MARK; |
|
108 TRAP(ret, vcard2->SaveBinaryValuesToFilesL(0,_L("c:\\"),fs)); |
|
109 if (ret!=KErrNone) |
|
110 { |
|
111 __UHEAP_MARKEND; |
|
112 } |
|
113 __UHEAP_RESET; |
|
114 if (ret!=KErrNoMemory&&ret!=KErrNone) |
|
115 { |
|
116 test.Printf(_L("Non standard error: %d\n"),ret); |
|
117 test.Getch(); |
|
118 } |
|
119 test(ret==KErrNoMemory||ret==KErrNone); |
|
120 } |
|
121 |
|
122 while (ret!=KErrNone) |
|
123 { |
|
124 failAt++; |
|
125 __UHEAP_SETFAIL(RHeap::EDeterministic,failAt); |
|
126 __UHEAP_MARK; |
|
127 TRAP(ret, vcard2->LoadBinaryValuesFromFilesL(fs)); |
|
128 if (ret!=KErrNone) |
|
129 { |
|
130 __UHEAP_MARKEND; |
|
131 } |
|
132 __UHEAP_RESET; |
|
133 if (ret!=KErrNoMemory&&ret!=KErrNone) |
|
134 { |
|
135 test.Printf(_L("Non standard error: %d\n"),ret); |
|
136 test.Getch(); |
|
137 } |
|
138 test(ret==KErrNoMemory||ret==KErrNone); |
|
139 } |
|
140 |
|
141 CleanupStack::PopAndDestroy(&fs); |
|
142 CleanupStack::PopAndDestroy(vcard2); |
|
143 CleanupStack::PopAndDestroy(console); |
|
144 } |
|
145 |
|
146 /** |
|
147 @SYMTestCaseID PIM-TESTSAVELOADBINOOM-0001 |
|
148 */ |
|
149 TInt E32Main() |
|
150 { |
|
151 __UHEAP_MARK; |
|
152 test.Start(_L("@SYMTestCaseID PIM-TESTSAVELOADBINOOM-0001 TEST_SAVELOADBINOOM")); |
|
153 test.Title(); |
|
154 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
155 TRAPD(error,doTestL()); |
|
156 UNUSED_VAR(error); //Used to supress build warnings |
|
157 |
|
158 ASSERT(error == KErrNone); |
|
159 delete cleanup; |
|
160 test.End(); |
|
161 test.Close(); |
|
162 __UHEAP_MARKEND; |
|
163 return (KErrNone); |
|
164 } |