sl@0
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// @internalComponent
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <e32std.h>
|
sl@0
|
19 |
#include <e32base.h>
|
sl@0
|
20 |
#include <e32test.h>
|
sl@0
|
21 |
#include <f32file.h>
|
sl@0
|
22 |
#include <bsul/inifile.h> // CIniDocument8, CIniDocument16
|
sl@0
|
23 |
|
sl@0
|
24 |
RTest test(_L("Ini File Parser and Generator"));
|
sl@0
|
25 |
|
sl@0
|
26 |
RFs TheRFs;
|
sl@0
|
27 |
|
sl@0
|
28 |
using namespace BSUL;
|
sl@0
|
29 |
#define UNUSED_VAR(a) a=a
|
sl@0
|
30 |
|
sl@0
|
31 |
_LIT(KIniFile16,"z:\\resource\\testconfig16.ini") ;
|
sl@0
|
32 |
|
sl@0
|
33 |
void LeaveIfNoMemory(TInt ret)
|
sl@0
|
34 |
{
|
sl@0
|
35 |
if (ret==KErrNoMemory)
|
sl@0
|
36 |
User::LeaveNoMemory();
|
sl@0
|
37 |
}
|
sl@0
|
38 |
|
sl@0
|
39 |
void CheckResources(RFs& aFs, TInt aOriginalHandleCount)
|
sl@0
|
40 |
{
|
sl@0
|
41 |
UNUSED_VAR(aOriginalHandleCount);
|
sl@0
|
42 |
//check we haven't leaked any handles
|
sl@0
|
43 |
TInt processHandleCount = 0;
|
sl@0
|
44 |
TInt threadHandleCount = 0;
|
sl@0
|
45 |
RThread().HandleCount(processHandleCount, threadHandleCount);
|
sl@0
|
46 |
test(threadHandleCount == aOriginalHandleCount);
|
sl@0
|
47 |
//check we haven't leaked any files
|
sl@0
|
48 |
aFs.ResourceCountMarkEnd();
|
sl@0
|
49 |
}
|
sl@0
|
50 |
|
sl@0
|
51 |
TBool CompareFilesL(RFs& aFs,const TDesC& aFileNameA,const TDesC& aFileNameB)
|
sl@0
|
52 |
{
|
sl@0
|
53 |
TBool filesAreSame=FALSE;
|
sl@0
|
54 |
RFile fileA;
|
sl@0
|
55 |
User::LeaveIfError(fileA.Open(aFs,aFileNameA,EFileShareReadersOrWriters ));
|
sl@0
|
56 |
CleanupClosePushL(fileA);
|
sl@0
|
57 |
RFile fileB;
|
sl@0
|
58 |
User::LeaveIfError(fileB.Open(aFs,aFileNameB,EFileShareReadersOrWriters ));
|
sl@0
|
59 |
CleanupClosePushL(fileB);
|
sl@0
|
60 |
|
sl@0
|
61 |
TInt filesizeA=0;
|
sl@0
|
62 |
TInt filesizeB=0;
|
sl@0
|
63 |
fileA.Size(filesizeA);
|
sl@0
|
64 |
fileB.Size(filesizeB);
|
sl@0
|
65 |
if ( filesizeA == filesizeB)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
HBufC8* aBufferPtrA=HBufC8::NewLC(filesizeA);
|
sl@0
|
68 |
HBufC8* aBufferPtrB=HBufC8::NewLC(filesizeB);
|
sl@0
|
69 |
TPtr8 asWriteableBufferA(aBufferPtrA->Des());
|
sl@0
|
70 |
User::LeaveIfError(fileA.Read(0,asWriteableBufferA,filesizeA));
|
sl@0
|
71 |
TPtr8 asWriteableBufferB(aBufferPtrB->Des());
|
sl@0
|
72 |
User::LeaveIfError(fileB.Read(0,asWriteableBufferB,filesizeB));
|
sl@0
|
73 |
if (asWriteableBufferA.Compare(asWriteableBufferB) == 0)
|
sl@0
|
74 |
{
|
sl@0
|
75 |
filesAreSame=TRUE;
|
sl@0
|
76 |
}
|
sl@0
|
77 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
78 |
}
|
sl@0
|
79 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
80 |
return filesAreSame;
|
sl@0
|
81 |
}
|
sl@0
|
82 |
|
sl@0
|
83 |
class CIniParser16Test :public CBase
|
sl@0
|
84 |
{
|
sl@0
|
85 |
typedef void (CIniParser16Test::*ClassFuncPtr8L) (void);
|
sl@0
|
86 |
|
sl@0
|
87 |
public:
|
sl@0
|
88 |
static CIniParser16Test* NewL();
|
sl@0
|
89 |
~CIniParser16Test()
|
sl@0
|
90 |
{
|
sl@0
|
91 |
if (iIniDocument)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
delete iIniDocument;
|
sl@0
|
94 |
iIniDocument=NULL;
|
sl@0
|
95 |
}
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
//heavy create and delete
|
sl@0
|
99 |
static void CreateDeleteTest1L();
|
sl@0
|
100 |
static void CreateDeleteOOMTestL();
|
sl@0
|
101 |
|
sl@0
|
102 |
//light
|
sl@0
|
103 |
static void CreateDeleteTest2L();
|
sl@0
|
104 |
static void CreateDeleteOOMTest2L();
|
sl@0
|
105 |
|
sl@0
|
106 |
//List of tests
|
sl@0
|
107 |
//heavy
|
sl@0
|
108 |
void DoTest1L();
|
sl@0
|
109 |
void DoTest2L();
|
sl@0
|
110 |
void DoTest3L();
|
sl@0
|
111 |
void DoTest4L();
|
sl@0
|
112 |
void DoTest5L();
|
sl@0
|
113 |
void DoTest6L();
|
sl@0
|
114 |
void DoTest7L();
|
sl@0
|
115 |
void DoTest8L();
|
sl@0
|
116 |
void DoTest9L();
|
sl@0
|
117 |
//light
|
sl@0
|
118 |
void DoTest10L();
|
sl@0
|
119 |
void DoTest11L();
|
sl@0
|
120 |
|
sl@0
|
121 |
//OOM consistency test
|
sl@0
|
122 |
void DoTest12L();
|
sl@0
|
123 |
|
sl@0
|
124 |
//class function utilities
|
sl@0
|
125 |
static void DoBasicTestL(ClassFuncPtr8L testFuncL, const TDesC& aTestDesc);
|
sl@0
|
126 |
static void DoOOMTestL(ClassFuncPtr8L testFuncL, const TDesC& aTestDesc);
|
sl@0
|
127 |
static void DoOOMWithConsistencyCheckTestL(ClassFuncPtr8L testFuncL, const TDesC& aTestDesc,const TBool aShouldBeSame);
|
sl@0
|
128 |
private:
|
sl@0
|
129 |
CIniParser16Test():iIniDocument(NULL){}
|
sl@0
|
130 |
CIniDocument16* iIniDocument;
|
sl@0
|
131 |
};
|
sl@0
|
132 |
|
sl@0
|
133 |
CIniParser16Test* CIniParser16Test::NewL()
|
sl@0
|
134 |
{
|
sl@0
|
135 |
CIniParser16Test* self=new (ELeave)CIniParser16Test();
|
sl@0
|
136 |
CleanupStack::PushL(self);
|
sl@0
|
137 |
self->iIniDocument=CIniDocument16::NewL(TheRFs,KIniFile16);
|
sl@0
|
138 |
CleanupStack::Pop();
|
sl@0
|
139 |
return self;
|
sl@0
|
140 |
}
|
sl@0
|
141 |
|
sl@0
|
142 |
void CIniParser16Test::DoBasicTestL(ClassFuncPtr8L testFuncL, const TDesC& aTestDesc)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
test.Next(aTestDesc);
|
sl@0
|
145 |
|
sl@0
|
146 |
__UHEAP_MARK;
|
sl@0
|
147 |
// find out the number of open handles
|
sl@0
|
148 |
TInt startProcessHandleCount;
|
sl@0
|
149 |
TInt startThreadHandleCount;
|
sl@0
|
150 |
RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
|
sl@0
|
151 |
|
sl@0
|
152 |
CIniParser16Test* iniTest=CIniParser16Test::NewL();
|
sl@0
|
153 |
|
sl@0
|
154 |
CleanupStack::PushL(iniTest);
|
sl@0
|
155 |
|
sl@0
|
156 |
(iniTest->*testFuncL)();
|
sl@0
|
157 |
|
sl@0
|
158 |
CleanupStack::PopAndDestroy();
|
sl@0
|
159 |
|
sl@0
|
160 |
// check that no handles have leaked
|
sl@0
|
161 |
TInt endProcessHandleCount;
|
sl@0
|
162 |
TInt endThreadHandleCount;
|
sl@0
|
163 |
RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
|
sl@0
|
164 |
|
sl@0
|
165 |
test(startProcessHandleCount == endProcessHandleCount);
|
sl@0
|
166 |
test(startThreadHandleCount == endThreadHandleCount);
|
sl@0
|
167 |
|
sl@0
|
168 |
__UHEAP_MARKEND;
|
sl@0
|
169 |
}
|
sl@0
|
170 |
|
sl@0
|
171 |
void CIniParser16Test::DoOOMTestL(ClassFuncPtr8L testFuncL, const TDesC& aTestDesc)
|
sl@0
|
172 |
{
|
sl@0
|
173 |
test.Next(aTestDesc);
|
sl@0
|
174 |
|
sl@0
|
175 |
TInt err;
|
sl@0
|
176 |
TInt tryCount = 0;
|
sl@0
|
177 |
do
|
sl@0
|
178 |
{
|
sl@0
|
179 |
__UHEAP_MARK;
|
sl@0
|
180 |
// find out the number of open handles
|
sl@0
|
181 |
TInt startProcessHandleCount;
|
sl@0
|
182 |
TInt startThreadHandleCount;
|
sl@0
|
183 |
RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
|
sl@0
|
184 |
|
sl@0
|
185 |
CIniParser16Test* iniTest=CIniParser16Test::NewL();
|
sl@0
|
186 |
CleanupStack::PushL(iniTest);
|
sl@0
|
187 |
|
sl@0
|
188 |
__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
|
sl@0
|
189 |
TRAP(err, (iniTest->*testFuncL)());
|
sl@0
|
190 |
__UHEAP_SETFAIL(RHeap::ENone, 0);
|
sl@0
|
191 |
|
sl@0
|
192 |
CleanupStack::PopAndDestroy(iniTest);
|
sl@0
|
193 |
iniTest=NULL;
|
sl@0
|
194 |
// check that no handles have leaked
|
sl@0
|
195 |
TInt endProcessHandleCount;
|
sl@0
|
196 |
TInt endThreadHandleCount;
|
sl@0
|
197 |
RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
|
sl@0
|
198 |
|
sl@0
|
199 |
test(startProcessHandleCount == endProcessHandleCount);
|
sl@0
|
200 |
test(startThreadHandleCount == endThreadHandleCount);
|
sl@0
|
201 |
|
sl@0
|
202 |
__UHEAP_MARKEND;
|
sl@0
|
203 |
} while(err == KErrNoMemory);
|
sl@0
|
204 |
|
sl@0
|
205 |
test(err==KErrNone);
|
sl@0
|
206 |
test.Printf(_L("- succeeded at heap failure rate of %i\n"), tryCount);
|
sl@0
|
207 |
}
|
sl@0
|
208 |
|
sl@0
|
209 |
void CIniParser16Test::CreateDeleteOOMTestL()
|
sl@0
|
210 |
{
|
sl@0
|
211 |
TInt err;
|
sl@0
|
212 |
TInt tryCount = 0;
|
sl@0
|
213 |
do
|
sl@0
|
214 |
{
|
sl@0
|
215 |
__UHEAP_MARK;
|
sl@0
|
216 |
|
sl@0
|
217 |
// find out the number of open handles
|
sl@0
|
218 |
TInt startProcessHandleCount;
|
sl@0
|
219 |
TInt startThreadHandleCount;
|
sl@0
|
220 |
RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
|
sl@0
|
221 |
|
sl@0
|
222 |
__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
|
sl@0
|
223 |
|
sl@0
|
224 |
CIniDocument16* ini=NULL;
|
sl@0
|
225 |
TRAP(err,ini=CIniDocument16::NewL(TheRFs,KIniFile16));
|
sl@0
|
226 |
|
sl@0
|
227 |
delete ini;
|
sl@0
|
228 |
|
sl@0
|
229 |
__UHEAP_SETFAIL(RHeap::ENone, 0);
|
sl@0
|
230 |
|
sl@0
|
231 |
// check that no handles have leaked
|
sl@0
|
232 |
TInt endProcessHandleCount;
|
sl@0
|
233 |
TInt endThreadHandleCount;
|
sl@0
|
234 |
RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
|
sl@0
|
235 |
test(startProcessHandleCount == endProcessHandleCount);
|
sl@0
|
236 |
test(startThreadHandleCount == endThreadHandleCount);
|
sl@0
|
237 |
|
sl@0
|
238 |
__UHEAP_MARKEND;
|
sl@0
|
239 |
} while(err == KErrNoMemory);
|
sl@0
|
240 |
|
sl@0
|
241 |
test(err==KErrNone);
|
sl@0
|
242 |
test.Printf(_L("- succeeded at heap failure rate of %i\n"), tryCount);
|
sl@0
|
243 |
}
|
sl@0
|
244 |
|
sl@0
|
245 |
void CIniParser16Test::DoOOMWithConsistencyCheckTestL(ClassFuncPtr8L testFuncL, const TDesC& aTestDesc, const TBool aShouldBeSame)
|
sl@0
|
246 |
{
|
sl@0
|
247 |
test.Next(aTestDesc);
|
sl@0
|
248 |
|
sl@0
|
249 |
// find out the number of open handles
|
sl@0
|
250 |
TInt startProcessHandleCount = 0;
|
sl@0
|
251 |
TInt startThreadHandleCount = 0;
|
sl@0
|
252 |
RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
|
sl@0
|
253 |
|
sl@0
|
254 |
//Compare the results against this instance.
|
sl@0
|
255 |
TInt err;
|
sl@0
|
256 |
CIniDocument16* referenceDoc=NULL;
|
sl@0
|
257 |
TRAP(err,referenceDoc=CIniDocument16::NewL(TheRFs,KIniFile16));
|
sl@0
|
258 |
User::LeaveIfError(err);
|
sl@0
|
259 |
CleanupStack::PushL(referenceDoc);
|
sl@0
|
260 |
|
sl@0
|
261 |
//Open a file and Externalise the reference oom to it.
|
sl@0
|
262 |
User::LeaveIfError(referenceDoc->Externalise(_L("c:\\initest\\oom_ref16.ini")));
|
sl@0
|
263 |
CIniParser16Test* iniTest=NULL;
|
sl@0
|
264 |
|
sl@0
|
265 |
for (TInt i = 1;;i++)
|
sl@0
|
266 |
{
|
sl@0
|
267 |
__UHEAP_FAILNEXT(i);
|
sl@0
|
268 |
__UHEAP_MARK;
|
sl@0
|
269 |
|
sl@0
|
270 |
TRAP(err, iniTest=CIniParser16Test::NewL());
|
sl@0
|
271 |
if (err != KErrNone)
|
sl@0
|
272 |
continue;
|
sl@0
|
273 |
|
sl@0
|
274 |
CleanupStack::PushL(iniTest);
|
sl@0
|
275 |
|
sl@0
|
276 |
TRAP(err, (iniTest->*testFuncL)());
|
sl@0
|
277 |
if (err != KErrNone)
|
sl@0
|
278 |
{
|
sl@0
|
279 |
test(iniTest->iIniDocument->CompareDocs(*referenceDoc));
|
sl@0
|
280 |
CleanupStack::PopAndDestroy(iniTest);
|
sl@0
|
281 |
__UHEAP_SETFAIL(RHeap::ENone, 0);
|
sl@0
|
282 |
__UHEAP_MARKEND;
|
sl@0
|
283 |
continue;
|
sl@0
|
284 |
}
|
sl@0
|
285 |
else
|
sl@0
|
286 |
{
|
sl@0
|
287 |
//Open a file and Externalise to it.
|
sl@0
|
288 |
TRAP(err, iniTest->iIniDocument->Externalise(_L("c:\\initest\\oom16.ini")));
|
sl@0
|
289 |
if (err != KErrNone)
|
sl@0
|
290 |
{
|
sl@0
|
291 |
CleanupStack::PopAndDestroy(iniTest);
|
sl@0
|
292 |
__UHEAP_SETFAIL(RHeap::ENone, 0);
|
sl@0
|
293 |
__UHEAP_MARKEND;
|
sl@0
|
294 |
continue;
|
sl@0
|
295 |
}
|
sl@0
|
296 |
else
|
sl@0
|
297 |
{
|
sl@0
|
298 |
TBool result=EFalse;
|
sl@0
|
299 |
TRAP(err, result=CompareFilesL(TheRFs,_L("c:\\initest\\oom_ref16.ini"), _L("c:\\initest\\oom16.ini")));
|
sl@0
|
300 |
if (err != KErrNone)
|
sl@0
|
301 |
{
|
sl@0
|
302 |
CleanupStack::PopAndDestroy(iniTest);
|
sl@0
|
303 |
__UHEAP_SETFAIL(RHeap::ENone, 0);
|
sl@0
|
304 |
__UHEAP_MARKEND;
|
sl@0
|
305 |
continue;
|
sl@0
|
306 |
}
|
sl@0
|
307 |
test(result == aShouldBeSame);
|
sl@0
|
308 |
}
|
sl@0
|
309 |
}
|
sl@0
|
310 |
CleanupStack::PopAndDestroy(iniTest);
|
sl@0
|
311 |
//check we haven't leaked any heap memory
|
sl@0
|
312 |
__UHEAP_MARKEND;
|
sl@0
|
313 |
CheckResources(TheRFs, startThreadHandleCount);
|
sl@0
|
314 |
|
sl@0
|
315 |
if (err != KErrNoMemory)
|
sl@0
|
316 |
{
|
sl@0
|
317 |
test(err == KErrNone);
|
sl@0
|
318 |
break; // we reach here if we are unable to create the OOM condition.
|
sl@0
|
319 |
}
|
sl@0
|
320 |
|
sl@0
|
321 |
__UHEAP_SETFAIL(RHeap::ENone, 0);
|
sl@0
|
322 |
}
|
sl@0
|
323 |
__UHEAP_RESET;
|
sl@0
|
324 |
CleanupStack::PopAndDestroy(referenceDoc);
|
sl@0
|
325 |
|
sl@0
|
326 |
test.Printf(_L("Completed consistency check."));
|
sl@0
|
327 |
}
|
sl@0
|
328 |
|
sl@0
|
329 |
void CIniParser16Test::CreateDeleteTest1L()
|
sl@0
|
330 |
{
|
sl@0
|
331 |
__UHEAP_MARK;
|
sl@0
|
332 |
|
sl@0
|
333 |
CIniDocument16* ini=NULL;
|
sl@0
|
334 |
//note only support 16 bit Little Endian ini file
|
sl@0
|
335 |
ini=CIniDocument16::NewL(TheRFs,KIniFile16);
|
sl@0
|
336 |
|
sl@0
|
337 |
delete ini;
|
sl@0
|
338 |
|
sl@0
|
339 |
__UHEAP_MARKEND;
|
sl@0
|
340 |
}
|
sl@0
|
341 |
|
sl@0
|
342 |
void CIniParser16Test::CreateDeleteOOMTest2L()
|
sl@0
|
343 |
{
|
sl@0
|
344 |
TInt err;
|
sl@0
|
345 |
TInt tryCount = 0;
|
sl@0
|
346 |
do
|
sl@0
|
347 |
{
|
sl@0
|
348 |
__UHEAP_MARK;
|
sl@0
|
349 |
|
sl@0
|
350 |
// find out the number of open handles
|
sl@0
|
351 |
TInt startProcessHandleCount;
|
sl@0
|
352 |
TInt startThreadHandleCount;
|
sl@0
|
353 |
RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
|
sl@0
|
354 |
|
sl@0
|
355 |
__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
|
sl@0
|
356 |
|
sl@0
|
357 |
CIniFile16* ini=NULL;
|
sl@0
|
358 |
TRAP(err,ini=CIniFile16::NewL(TheRFs,KIniFile16));
|
sl@0
|
359 |
|
sl@0
|
360 |
delete ini;
|
sl@0
|
361 |
|
sl@0
|
362 |
__UHEAP_SETFAIL(RHeap::ENone, 0);
|
sl@0
|
363 |
|
sl@0
|
364 |
// check that no handles have leaked
|
sl@0
|
365 |
TInt endProcessHandleCount;
|
sl@0
|
366 |
TInt endThreadHandleCount;
|
sl@0
|
367 |
RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
|
sl@0
|
368 |
test(startProcessHandleCount == endProcessHandleCount);
|
sl@0
|
369 |
test(startThreadHandleCount == endThreadHandleCount);
|
sl@0
|
370 |
|
sl@0
|
371 |
__UHEAP_MARKEND;
|
sl@0
|
372 |
} while(err == KErrNoMemory);
|
sl@0
|
373 |
|
sl@0
|
374 |
test(err==KErrNone);
|
sl@0
|
375 |
test.Printf(_L("- succeeded at heap failure rate of %i\n"), tryCount);
|
sl@0
|
376 |
}
|
sl@0
|
377 |
|
sl@0
|
378 |
|
sl@0
|
379 |
void CIniParser16Test::CreateDeleteTest2L()
|
sl@0
|
380 |
{
|
sl@0
|
381 |
__UHEAP_MARK;
|
sl@0
|
382 |
|
sl@0
|
383 |
CIniFile16* ini=NULL;
|
sl@0
|
384 |
//note only support 16 bit Little Endian ini file
|
sl@0
|
385 |
ini=CIniFile16::NewL(TheRFs,KIniFile16);
|
sl@0
|
386 |
|
sl@0
|
387 |
delete ini;
|
sl@0
|
388 |
|
sl@0
|
389 |
__UHEAP_MARKEND;
|
sl@0
|
390 |
}
|
sl@0
|
391 |
|
sl@0
|
392 |
|
sl@0
|
393 |
void CIniParser16Test::DoTest1L()
|
sl@0
|
394 |
{
|
sl@0
|
395 |
//Testing GetSectionList API
|
sl@0
|
396 |
RArray<TPtrC16> sectionNames;
|
sl@0
|
397 |
User::LeaveIfError(iIniDocument->GetSectionList(sectionNames));
|
sl@0
|
398 |
test(sectionNames.Count()==8);
|
sl@0
|
399 |
|
sl@0
|
400 |
//Testing the sectionNames in name order
|
sl@0
|
401 |
test(sectionNames[0].Compare(_L("1"))==0);
|
sl@0
|
402 |
test(sectionNames[1].Compare(_L("MAPPINGS"))==0);
|
sl@0
|
403 |
test(sectionNames[2].Compare(_L("MEDIA"))==0);
|
sl@0
|
404 |
test(sectionNames[3].Compare(_L("OUTPUT_CHANNELS"))==0);
|
sl@0
|
405 |
test(sectionNames[4].Compare(_L("SERVERS"))==0);
|
sl@0
|
406 |
test(sectionNames[5].Compare(_L("SWTRACER"))==0);
|
sl@0
|
407 |
test(sectionNames[6].Compare(_L("test_section"))==0);
|
sl@0
|
408 |
test(sectionNames[7].Compare(_L("test_twosection"))==0);
|
sl@0
|
409 |
sectionNames.Reset();
|
sl@0
|
410 |
}
|
sl@0
|
411 |
|
sl@0
|
412 |
void CIniParser16Test::DoTest2L()
|
sl@0
|
413 |
{
|
sl@0
|
414 |
//Test GetKeyValue API
|
sl@0
|
415 |
TPtrC16 value;
|
sl@0
|
416 |
User::LeaveIfError(iIniDocument->GetKeyValue(_L("MEDIA"),_L("RDebug"),value));
|
sl@0
|
417 |
test(value.Compare(_L("SwtRDebugPlugin.dll"))==0);
|
sl@0
|
418 |
User::LeaveIfError(iIniDocument->GetKeyValue(_L("OUTPUT_CHANNELS"),_L("1"),value));
|
sl@0
|
419 |
test(value.Compare(_L("RDebug"))==0);
|
sl@0
|
420 |
User::LeaveIfError(iIniDocument->GetKeyValue(_L("1"),_L("new_setting"),value));
|
sl@0
|
421 |
test(value.Compare(_L("value \\n value1\\t value2"))==0);
|
sl@0
|
422 |
|
sl@0
|
423 |
//unknown section
|
sl@0
|
424 |
TInt ret=KErrNone;
|
sl@0
|
425 |
ret=iIniDocument->GetKeyValue(_L("mySection"),_L("mykey"),value);
|
sl@0
|
426 |
LeaveIfNoMemory(ret);
|
sl@0
|
427 |
test(ret==KErrNotFound);
|
sl@0
|
428 |
//unknown key
|
sl@0
|
429 |
ret=iIniDocument->GetKeyValue(_L("MEDIA"),_L("mykey"),value);
|
sl@0
|
430 |
LeaveIfNoMemory(ret);
|
sl@0
|
431 |
test(ret==KErrNotFound);
|
sl@0
|
432 |
//empty value
|
sl@0
|
433 |
ret=iIniDocument->GetKeyValue(_L("SERVERS"),_L("SWTRACER"),value);
|
sl@0
|
434 |
LeaveIfNoMemory(ret);
|
sl@0
|
435 |
test(value.Length()==0);
|
sl@0
|
436 |
}
|
sl@0
|
437 |
|
sl@0
|
438 |
void CIniParser16Test::DoTest3L()
|
sl@0
|
439 |
{
|
sl@0
|
440 |
//Test AddSection API
|
sl@0
|
441 |
RArray<TPtrC16> sectionNames;
|
sl@0
|
442 |
CleanupClosePushL(sectionNames);
|
sl@0
|
443 |
User::LeaveIfError(iIniDocument->AddSection(_L("NEW-SECTION")));
|
sl@0
|
444 |
User::LeaveIfError(iIniDocument->GetSectionList(sectionNames));
|
sl@0
|
445 |
test(sectionNames.Count()==9);
|
sl@0
|
446 |
|
sl@0
|
447 |
//case sensitive
|
sl@0
|
448 |
User::LeaveIfError(iIniDocument->AddSection(_L("NeW-SECTION")));
|
sl@0
|
449 |
User::LeaveIfError(iIniDocument->GetSectionList(sectionNames));
|
sl@0
|
450 |
test(sectionNames.Count()==10);
|
sl@0
|
451 |
//adding existing section, no duplicate allowed
|
sl@0
|
452 |
TInt ret=iIniDocument->AddSection(_L("NEW-SECTION"));
|
sl@0
|
453 |
LeaveIfNoMemory(ret);
|
sl@0
|
454 |
test(ret==KErrAlreadyExists);
|
sl@0
|
455 |
CleanupStack::PopAndDestroy();
|
sl@0
|
456 |
}
|
sl@0
|
457 |
|
sl@0
|
458 |
void CIniParser16Test::DoTest4L()
|
sl@0
|
459 |
{
|
sl@0
|
460 |
//Test RemoveSection API
|
sl@0
|
461 |
RArray<TPtrC16> sectionNames;
|
sl@0
|
462 |
CleanupClosePushL(sectionNames);
|
sl@0
|
463 |
|
sl@0
|
464 |
//known section
|
sl@0
|
465 |
User::LeaveIfError(iIniDocument->RemoveSection(_L("SERVERS")));
|
sl@0
|
466 |
User::LeaveIfError(iIniDocument->GetSectionList(sectionNames));
|
sl@0
|
467 |
test(sectionNames.Count()==7);
|
sl@0
|
468 |
|
sl@0
|
469 |
//check key inside section is also deleted
|
sl@0
|
470 |
TPtrC16 value;
|
sl@0
|
471 |
TInt ret=iIniDocument->GetKeyValue(_L("SERVERS"),_L("SWTRACER"),value);
|
sl@0
|
472 |
LeaveIfNoMemory(ret);
|
sl@0
|
473 |
test(ret==KErrNotFound);
|
sl@0
|
474 |
|
sl@0
|
475 |
//unknown section
|
sl@0
|
476 |
ret=iIniDocument->RemoveSection(_L("AnySection"));
|
sl@0
|
477 |
LeaveIfNoMemory(ret);
|
sl@0
|
478 |
test(ret==KErrNotFound);
|
sl@0
|
479 |
|
sl@0
|
480 |
CleanupStack::PopAndDestroy();
|
sl@0
|
481 |
}
|
sl@0
|
482 |
|
sl@0
|
483 |
void CIniParser16Test::DoTest5L()
|
sl@0
|
484 |
{
|
sl@0
|
485 |
//Testing SetKey API
|
sl@0
|
486 |
TPtrC16 value;
|
sl@0
|
487 |
//Modifying existing value
|
sl@0
|
488 |
User::LeaveIfError(iIniDocument->SetKey(_L("MEDIA"),_L("RDebug"),_L("NewPlugin.dll")));
|
sl@0
|
489 |
User::LeaveIfError(iIniDocument->GetKeyValue(_L("MEDIA"),_L("RDebug"),value));
|
sl@0
|
490 |
test(value.Compare(_L("NewPlugin.dll"))==0);
|
sl@0
|
491 |
|
sl@0
|
492 |
//nonexist key should be created
|
sl@0
|
493 |
User::LeaveIfError(iIniDocument->SetKey(_L("MEDIA"),_L("newplug"),_L("")));
|
sl@0
|
494 |
User::LeaveIfError(iIniDocument->GetKeyValue(_L("MEDIA"),_L("newplug"),value));
|
sl@0
|
495 |
test(value.Compare(_L(""))==0);
|
sl@0
|
496 |
|
sl@0
|
497 |
//nonexist section should be created
|
sl@0
|
498 |
User::LeaveIfError(iIniDocument->SetKey(_L("unknown_section"),_L("unknown_key"),_L("unknown_value")));
|
sl@0
|
499 |
User::LeaveIfError(iIniDocument->GetKeyValue(_L("unknown_section"),_L("unknown_key"),value));
|
sl@0
|
500 |
test(value.Compare(_L("unknown_value"))==0);
|
sl@0
|
501 |
|
sl@0
|
502 |
//Testing Externalise to a New file
|
sl@0
|
503 |
User::LeaveIfError(iIniDocument->Externalise(_L("c:\\initest\\output16_1.ini")));
|
sl@0
|
504 |
|
sl@0
|
505 |
//Try opening the written ini file now to ensure no corruption in writing
|
sl@0
|
506 |
CIniDocument16* iniReRead=CIniDocument16::NewL(TheRFs,_L("c:\\initest\\output16_1.ini"));
|
sl@0
|
507 |
CleanupStack::PushL(iniReRead);
|
sl@0
|
508 |
User::LeaveIfError(iniReRead->GetKeyValue(_L("unknown_section"),_L("unknown_key"),value));
|
sl@0
|
509 |
test(value.Compare(_L("unknown_value"))==0);
|
sl@0
|
510 |
User::LeaveIfError(iniReRead->GetKeyValue(_L("MEDIA"),_L("newplug"),value));
|
sl@0
|
511 |
test(value.Compare(_L(""))==0);
|
sl@0
|
512 |
|
sl@0
|
513 |
CleanupStack::PopAndDestroy(iniReRead);
|
sl@0
|
514 |
}
|
sl@0
|
515 |
|
sl@0
|
516 |
void CIniParser16Test::DoTest6L()
|
sl@0
|
517 |
{
|
sl@0
|
518 |
//Testing RemoveKey API
|
sl@0
|
519 |
TPtrC16 value;
|
sl@0
|
520 |
//remove existing key
|
sl@0
|
521 |
User::LeaveIfError(iIniDocument->RemoveKey(_L("OUTPUT_CHANNELS"),_L("1")));
|
sl@0
|
522 |
TInt ret=iIniDocument->GetKeyValue(_L("OUTPUT_CHANNELS"),_L("1"),value);
|
sl@0
|
523 |
LeaveIfNoMemory(ret);
|
sl@0
|
524 |
test(ret==KErrNotFound);
|
sl@0
|
525 |
|
sl@0
|
526 |
//remove non-exist key
|
sl@0
|
527 |
ret=iIniDocument->RemoveKey(_L("OUTPUT_CHANNELS"),_L("1"));
|
sl@0
|
528 |
LeaveIfNoMemory(ret);
|
sl@0
|
529 |
test(ret==KErrNotFound);
|
sl@0
|
530 |
|
sl@0
|
531 |
//remove non-exist section
|
sl@0
|
532 |
ret=iIniDocument->RemoveKey(_L("Non-existSection"),_L("1"));
|
sl@0
|
533 |
LeaveIfNoMemory(ret);
|
sl@0
|
534 |
test(ret==KErrNotFound);
|
sl@0
|
535 |
}
|
sl@0
|
536 |
|
sl@0
|
537 |
void CIniParser16Test::DoTest7L()
|
sl@0
|
538 |
{
|
sl@0
|
539 |
//Testing iterator class
|
sl@0
|
540 |
CIniSecIter16* iIniSecIter=NULL;
|
sl@0
|
541 |
TInt ret=KErrNone;
|
sl@0
|
542 |
|
sl@0
|
543 |
//unknown section
|
sl@0
|
544 |
TRAP(ret,iIniSecIter=CIniSecIter16::NewL(_L("Unknown"),iIniDocument));
|
sl@0
|
545 |
LeaveIfNoMemory(ret);
|
sl@0
|
546 |
test(ret==KErrNotFound);
|
sl@0
|
547 |
|
sl@0
|
548 |
//null document
|
sl@0
|
549 |
TRAP(ret,iIniSecIter=CIniSecIter16::NewL(_L("Unknown"),NULL));
|
sl@0
|
550 |
LeaveIfNoMemory(ret);
|
sl@0
|
551 |
test(ret==KErrArgument);
|
sl@0
|
552 |
|
sl@0
|
553 |
//known section
|
sl@0
|
554 |
iIniSecIter=CIniSecIter16::NewL(_L("test_section"),iIniDocument);
|
sl@0
|
555 |
TPtrC16 key;
|
sl@0
|
556 |
TPtrC16 value;
|
sl@0
|
557 |
//test Next() and End();
|
sl@0
|
558 |
test(!iIniSecIter->End());
|
sl@0
|
559 |
test(iIniSecIter->Next(key,value));
|
sl@0
|
560 |
test(key.Compare(_L("key1"))==0);
|
sl@0
|
561 |
test(value.Compare(_L("value1"))==0);
|
sl@0
|
562 |
test(!iIniSecIter->End());
|
sl@0
|
563 |
test(iIniSecIter->Next(key,value));
|
sl@0
|
564 |
test(key.Compare(_L("key2"))==0);
|
sl@0
|
565 |
test(value.Compare(_L("value2"))==0);
|
sl@0
|
566 |
test(!iIniSecIter->End());
|
sl@0
|
567 |
test(iIniSecIter->Next(key,value));
|
sl@0
|
568 |
test(key.Compare(_L("key3"))==0);
|
sl@0
|
569 |
test(value.Compare(_L("value3"))==0);
|
sl@0
|
570 |
test(!iIniSecIter->End());
|
sl@0
|
571 |
test(iIniSecIter->Next(key,value));
|
sl@0
|
572 |
test(key.Compare(_L("key4"))==0);
|
sl@0
|
573 |
test(value.Compare(_L("value4"))==0);
|
sl@0
|
574 |
test(!iIniSecIter->End());
|
sl@0
|
575 |
test(iIniSecIter->Next(key,value));
|
sl@0
|
576 |
test(key.Compare(_L("key5"))==0);
|
sl@0
|
577 |
test(value.Compare(_L("value value value"))==0);
|
sl@0
|
578 |
test(iIniSecIter->End());
|
sl@0
|
579 |
test(iIniSecIter->Next(key,value)==EFalse);
|
sl@0
|
580 |
|
sl@0
|
581 |
//test Reset()
|
sl@0
|
582 |
iIniSecIter->Reset();
|
sl@0
|
583 |
test(!iIniSecIter->End());
|
sl@0
|
584 |
test(iIniSecIter->Next(key,value));
|
sl@0
|
585 |
test(key.Compare(_L("key1"))==0);
|
sl@0
|
586 |
test(value.Compare(_L("value1"))==0);
|
sl@0
|
587 |
|
sl@0
|
588 |
delete iIniSecIter;
|
sl@0
|
589 |
iIniSecIter=NULL;
|
sl@0
|
590 |
}
|
sl@0
|
591 |
|
sl@0
|
592 |
void CIniParser16Test::DoTest8L()
|
sl@0
|
593 |
{
|
sl@0
|
594 |
//Testing Externalise to ROM drive
|
sl@0
|
595 |
TInt ret=iIniDocument->Externalise(_L("z:\\output16.ini"));
|
sl@0
|
596 |
LeaveIfNoMemory(ret);
|
sl@0
|
597 |
test(ret==KErrAccessDenied);
|
sl@0
|
598 |
|
sl@0
|
599 |
//Testing Externalise to a New file
|
sl@0
|
600 |
User::LeaveIfError(iIniDocument->Externalise(_L("c:\\initest\\output16.ini")));
|
sl@0
|
601 |
|
sl@0
|
602 |
//Try opening the written ini file now to ensure no corruption in writing
|
sl@0
|
603 |
CIniDocument16* output=CIniDocument16::NewL(TheRFs,_L("c:\\initest\\output16.ini"));
|
sl@0
|
604 |
CleanupStack::PushL(output);
|
sl@0
|
605 |
User::LeaveIfError(output->SetKey(_L("Test"),_L("Test"),_L("Test")));
|
sl@0
|
606 |
|
sl@0
|
607 |
//Testing Externaliseing to the already exist file
|
sl@0
|
608 |
User::LeaveIfError(output->Externalise(_L("c:\\initest\\output16_1.ini")));
|
sl@0
|
609 |
CleanupStack::PopAndDestroy();
|
sl@0
|
610 |
|
sl@0
|
611 |
//Opening an empty file and Externaliseing an empty file
|
sl@0
|
612 |
output=CIniDocument16::NewL(TheRFs,_L("c:\\initest\\unknown16.ini"));
|
sl@0
|
613 |
CleanupStack::PushL(output);
|
sl@0
|
614 |
User::LeaveIfError(output->Externalise(_L("c:\\initest\\unknown16_1.ini")));
|
sl@0
|
615 |
CleanupStack::PopAndDestroy();
|
sl@0
|
616 |
|
sl@0
|
617 |
// Read it back in and find the additions put in above.
|
sl@0
|
618 |
CIniDocument16* iniReRead=NULL;
|
sl@0
|
619 |
iniReRead=CIniDocument16::NewL(TheRFs,_L("c:\\initest\\output16_1.ini"));
|
sl@0
|
620 |
CleanupStack::PushL(iniReRead);
|
sl@0
|
621 |
|
sl@0
|
622 |
TPtrC16 value;
|
sl@0
|
623 |
User::LeaveIfError(iniReRead->GetKeyValue(_L("Test"),_L("Test"),value));
|
sl@0
|
624 |
test(value.Compare(_L("Test"))==0);
|
sl@0
|
625 |
|
sl@0
|
626 |
CleanupStack::PopAndDestroy(iniReRead);
|
sl@0
|
627 |
}
|
sl@0
|
628 |
|
sl@0
|
629 |
void CIniParser16Test::DoTest9L()
|
sl@0
|
630 |
{
|
sl@0
|
631 |
//Test for no leakage when handling corrupt file
|
sl@0
|
632 |
CIniDocument16* ini=NULL;
|
sl@0
|
633 |
TRAPD(err,ini=CIniDocument16::NewL(TheRFs,_L("z:\\resource\\corruptconfig16.ini")));
|
sl@0
|
634 |
LeaveIfNoMemory(err);
|
sl@0
|
635 |
test(err==KErrCorrupt);
|
sl@0
|
636 |
delete ini;
|
sl@0
|
637 |
}
|
sl@0
|
638 |
|
sl@0
|
639 |
void CIniParser16Test::DoTest10L()
|
sl@0
|
640 |
{
|
sl@0
|
641 |
TPtrC16 value;
|
sl@0
|
642 |
//open existing ini file
|
sl@0
|
643 |
CIniFile16* ini=CIniFile16::NewL(TheRFs, _L16("z:\\resource\\testconfig16.ini"));
|
sl@0
|
644 |
CleanupStack::PushL(ini);
|
sl@0
|
645 |
|
sl@0
|
646 |
//mid section
|
sl@0
|
647 |
User::LeaveIfError(ini->FindVar(_L16("test_section"),_L16("key1"),value));
|
sl@0
|
648 |
test(value.Compare(_L16("value1"))==0);
|
sl@0
|
649 |
User::LeaveIfError(ini->FindVar(_L16("test_section"),_L16("key2"),value));
|
sl@0
|
650 |
test(value.Compare(_L16("value2"))==0);
|
sl@0
|
651 |
User::LeaveIfError(ini->FindVar(_L16("test_section"),_L16("key3"),value));
|
sl@0
|
652 |
test(value.Compare(_L16("value3"))==0);
|
sl@0
|
653 |
User::LeaveIfError(ini->FindVar(_L16("test_section"),_L16("key4"),value));
|
sl@0
|
654 |
test(value.Compare(_L16("value4"))==0);
|
sl@0
|
655 |
User::LeaveIfError(ini->FindVar(_L16("test_section"),_L16("key5"),value));
|
sl@0
|
656 |
test(value.Compare(_L16("value value value"))==0);
|
sl@0
|
657 |
|
sl@0
|
658 |
//first section
|
sl@0
|
659 |
User::LeaveIfError(ini->FindVar(_L16("SERVERS"),_L16("SWTRACER"),value));
|
sl@0
|
660 |
test(value.Compare(_L16(""))==0);
|
sl@0
|
661 |
|
sl@0
|
662 |
//last section
|
sl@0
|
663 |
User::LeaveIfError(ini->FindVar(_L16("1"),_L16("timestamps"),value));
|
sl@0
|
664 |
test(value.Compare(_L16("0"))==0);
|
sl@0
|
665 |
User::LeaveIfError(ini->FindVar(_L16("1"),_L16("setting"),value));
|
sl@0
|
666 |
test(value.Compare(_L16("value"))==0);
|
sl@0
|
667 |
|
sl@0
|
668 |
CleanupStack::PopAndDestroy();
|
sl@0
|
669 |
|
sl@0
|
670 |
//open a non existing file
|
sl@0
|
671 |
TInt ret=KErrNone;
|
sl@0
|
672 |
TRAP(ret,ini=CIniFile16::NewL(TheRFs,_L16("z:\\resource\\nonexist.ini")));
|
sl@0
|
673 |
LeaveIfNoMemory(ret);
|
sl@0
|
674 |
test(ret==KErrNotFound);
|
sl@0
|
675 |
|
sl@0
|
676 |
//open an empty ini file
|
sl@0
|
677 |
ini=CIniFile16::NewL(TheRFs,_L16("z:\\resource\\empty16.ini"));
|
sl@0
|
678 |
CleanupStack::PushL(ini);
|
sl@0
|
679 |
|
sl@0
|
680 |
ret=ini->FindVar(_L16("empty"),_L16("empty"),value);
|
sl@0
|
681 |
LeaveIfNoMemory(ret);
|
sl@0
|
682 |
test(ret==KErrNotFound);
|
sl@0
|
683 |
|
sl@0
|
684 |
CleanupStack::PopAndDestroy();
|
sl@0
|
685 |
}
|
sl@0
|
686 |
|
sl@0
|
687 |
void CIniParser16Test::DoTest11L()
|
sl@0
|
688 |
{
|
sl@0
|
689 |
TPtrC16 value;
|
sl@0
|
690 |
//open existing 8 bit ini file with 16 bit reader
|
sl@0
|
691 |
CIniFile16* ini;
|
sl@0
|
692 |
TInt err;
|
sl@0
|
693 |
TRAP(err,ini=CIniFile16::NewL(TheRFs,_L16("z:\\resource\\testconfig8.ini")));
|
sl@0
|
694 |
test(err==KErrCorrupt || err==KErrNoMemory);
|
sl@0
|
695 |
|
sl@0
|
696 |
//open existing 8 bit ini file, but allow conversion to 16 bits
|
sl@0
|
697 |
ini=CIniFile16::NewL(TheRFs,_L16("z:\\resource\\testconfig8.ini"),ETrue);
|
sl@0
|
698 |
CleanupStack::PushL(ini);
|
sl@0
|
699 |
|
sl@0
|
700 |
//mid section
|
sl@0
|
701 |
User::LeaveIfError(ini->FindVar(_L16("test_section"),_L16("key1"),value));
|
sl@0
|
702 |
test(value.Compare(_L16("value1"))==0);
|
sl@0
|
703 |
User::LeaveIfError(ini->FindVar(_L16("test_section"),_L16("key2"),value));
|
sl@0
|
704 |
test(value.Compare(_L16("value2"))==0);
|
sl@0
|
705 |
User::LeaveIfError(ini->FindVar(_L16("test_section"),_L16("key3"),value));
|
sl@0
|
706 |
test(value.Compare(_L16("value3"))==0);
|
sl@0
|
707 |
User::LeaveIfError(ini->FindVar(_L16("test_section"),_L16("key4"),value));
|
sl@0
|
708 |
test(value.Compare(_L16("value4"))==0);
|
sl@0
|
709 |
User::LeaveIfError(ini->FindVar(_L16("test_section"),_L16("key5"),value));
|
sl@0
|
710 |
test(value.Compare(_L16("value value value"))==0);
|
sl@0
|
711 |
|
sl@0
|
712 |
//first section
|
sl@0
|
713 |
User::LeaveIfError(ini->FindVar(_L16("SERVERS"),_L16("SWTRACER"),value));
|
sl@0
|
714 |
test(value.Compare(_L16(""))==0);
|
sl@0
|
715 |
|
sl@0
|
716 |
//last section
|
sl@0
|
717 |
User::LeaveIfError(ini->FindVar(_L16("1"),_L16("timestamps"),value));
|
sl@0
|
718 |
test(value.Compare(_L16("0"))==0);
|
sl@0
|
719 |
User::LeaveIfError(ini->FindVar(_L16("1"),_L16("setting"),value));
|
sl@0
|
720 |
test(value.Compare(_L16("value"))==0);
|
sl@0
|
721 |
|
sl@0
|
722 |
CleanupStack::PopAndDestroy();
|
sl@0
|
723 |
}
|
sl@0
|
724 |
|
sl@0
|
725 |
void CIniParser16Test::DoTest12L()
|
sl@0
|
726 |
{
|
sl@0
|
727 |
TPtrC16 value;
|
sl@0
|
728 |
// We are trying to invoke an OOM condition for a single operation to test that the operation is atomic.
|
sl@0
|
729 |
// Under that condition the object should be rolled back to the original state. The resulting document should be the same
|
sl@0
|
730 |
// as before the condition was invoked. If the test succeeded, a new section should be created at end
|
sl@0
|
731 |
// (which is nice but not the real focus of the test).
|
sl@0
|
732 |
User::LeaveIfError(iIniDocument->SetKey(_L16("unknown_section3"),_L16("unknown_key3"),_L16("unknown_value3")));
|
sl@0
|
733 |
}
|
sl@0
|
734 |
|
sl@0
|
735 |
static void DeleteFilesL()
|
sl@0
|
736 |
{
|
sl@0
|
737 |
CFileMan* fileman=CFileMan::NewL(TheRFs);
|
sl@0
|
738 |
|
sl@0
|
739 |
fileman->Delete(_L("c:\\initest\\*"));
|
sl@0
|
740 |
|
sl@0
|
741 |
delete fileman;
|
sl@0
|
742 |
}
|
sl@0
|
743 |
|
sl@0
|
744 |
/**
|
sl@0
|
745 |
@SYMTestCaseID SYSLIB-BAFL-CT-1559
|
sl@0
|
746 |
@SYMTestCaseDesc Test CIniParser16Test
|
sl@0
|
747 |
@SYMTestPriority High
|
sl@0
|
748 |
@SYMTestActions Perform component tests on CIniParser16Test (includes OOM)
|
sl@0
|
749 |
Testing all the exported apis.
|
sl@0
|
750 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
751 |
@SYMREQ PREQ505
|
sl@0
|
752 |
*/
|
sl@0
|
753 |
static void DoTestL()
|
sl@0
|
754 |
{
|
sl@0
|
755 |
TTime startTime(0), stopTime(0);
|
sl@0
|
756 |
TTimeIntervalMicroSeconds timeTaken;
|
sl@0
|
757 |
|
sl@0
|
758 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-1559 "));
|
sl@0
|
759 |
|
sl@0
|
760 |
DeleteFilesL();
|
sl@0
|
761 |
//16 bit basic testing
|
sl@0
|
762 |
CIniParser16Test::CreateDeleteTest1L();
|
sl@0
|
763 |
CIniParser16Test::DoBasicTestL(&CIniParser16Test::DoTest1L,_L("GetSectionList16"));
|
sl@0
|
764 |
CIniParser16Test::DoBasicTestL(&CIniParser16Test::DoTest2L,_L("GetKeyValue16"));
|
sl@0
|
765 |
CIniParser16Test::DoBasicTestL(&CIniParser16Test::DoTest3L,_L("AddSection16"));
|
sl@0
|
766 |
CIniParser16Test::DoBasicTestL(&CIniParser16Test::DoTest4L,_L("RemoveSection16"));
|
sl@0
|
767 |
CIniParser16Test::DoBasicTestL(&CIniParser16Test::DoTest5L,_L("SetKeyValue16"));
|
sl@0
|
768 |
CIniParser16Test::DoBasicTestL(&CIniParser16Test::DoTest6L,_L("RemoveKey16"));
|
sl@0
|
769 |
CIniParser16Test::DoBasicTestL(&CIniParser16Test::DoTest7L,_L("IniSecIter16"));
|
sl@0
|
770 |
CIniParser16Test::DoBasicTestL(&CIniParser16Test::DoTest8L,_L("Externalise16"));
|
sl@0
|
771 |
CIniParser16Test::DoBasicTestL(&CIniParser16Test::DoTest9L,_L("Corrupt file16"));
|
sl@0
|
772 |
//16 bit OOM testing
|
sl@0
|
773 |
CIniParser16Test::CreateDeleteOOMTestL();
|
sl@0
|
774 |
CIniParser16Test::DoOOMTestL(&CIniParser16Test::DoTest1L,_L("GetSectionList16-OOM"));
|
sl@0
|
775 |
CIniParser16Test::DoOOMTestL(&CIniParser16Test::DoTest2L,_L("GetKeyValue16-OOM"));
|
sl@0
|
776 |
CIniParser16Test::DoOOMTestL(&CIniParser16Test::DoTest3L,_L("AddSection16-OOM"));
|
sl@0
|
777 |
CIniParser16Test::DoOOMTestL(&CIniParser16Test::DoTest4L,_L("RemoveSection16-OOM"));
|
sl@0
|
778 |
CIniParser16Test::DoOOMTestL(&CIniParser16Test::DoTest5L,_L("SetKeyValue16-OOM"));
|
sl@0
|
779 |
CIniParser16Test::DoOOMTestL(&CIniParser16Test::DoTest6L,_L("RemoveKey16-OOM"));
|
sl@0
|
780 |
CIniParser16Test::DoOOMTestL(&CIniParser16Test::DoTest7L,_L("IniSecIter16-OOM"));
|
sl@0
|
781 |
CIniParser16Test::DoOOMTestL(&CIniParser16Test::DoTest8L,_L("Externalise16-OOM"));
|
sl@0
|
782 |
CIniParser16Test::DoOOMTestL(&CIniParser16Test::DoTest9L,_L("Corrupt file16-OOM"));
|
sl@0
|
783 |
|
sl@0
|
784 |
//16 bit light basic testing
|
sl@0
|
785 |
CIniParser16Test::CreateDeleteTest2L();
|
sl@0
|
786 |
CIniParser16Test::DoBasicTestL(&CIniParser16Test::DoTest10L,_L("Light FindVar16"));
|
sl@0
|
787 |
CIniParser16Test::DoBasicTestL(&CIniParser16Test::DoTest11L,_L("Load 16"));
|
sl@0
|
788 |
//16 bit light OOM testing
|
sl@0
|
789 |
CIniParser16Test::CreateDeleteOOMTest2L();
|
sl@0
|
790 |
CIniParser16Test::DoOOMTestL(&CIniParser16Test::DoTest10L,_L("Light FindVar-OOM16"));
|
sl@0
|
791 |
CIniParser16Test::DoOOMTestL(&CIniParser16Test::DoTest11L,_L("Load 16-OOM"));
|
sl@0
|
792 |
stopTime.UniversalTime();
|
sl@0
|
793 |
timeTaken = stopTime.MicroSecondsFrom(startTime);
|
sl@0
|
794 |
test.Printf(_L("Time taken for Heavy= %d microseconds\n"), timeTaken.Int64() );
|
sl@0
|
795 |
startTime.UniversalTime();
|
sl@0
|
796 |
// Consistency checks
|
sl@0
|
797 |
CIniParser16Test::DoOOMWithConsistencyCheckTestL(&CIniParser16Test::DoTest12L,_L("Consistency16-OOMC"), FALSE);
|
sl@0
|
798 |
|
sl@0
|
799 |
stopTime.UniversalTime();
|
sl@0
|
800 |
timeTaken = stopTime.MicroSecondsFrom(startTime);
|
sl@0
|
801 |
test.Printf(_L("Time taken for consistency checks= %d microseconds\n"), timeTaken.Int64() );
|
sl@0
|
802 |
}
|
sl@0
|
803 |
|
sl@0
|
804 |
GLDEF_C TInt E32Main()
|
sl@0
|
805 |
{
|
sl@0
|
806 |
__UHEAP_MARK;
|
sl@0
|
807 |
CTrapCleanup* trapCleanup=CTrapCleanup::New();
|
sl@0
|
808 |
test(TheRFs.Connect()==KErrNone);
|
sl@0
|
809 |
test.Start(_L("Ini File Parser Test"));
|
sl@0
|
810 |
|
sl@0
|
811 |
TRAPD(error, DoTestL());
|
sl@0
|
812 |
test(error == KErrNone);
|
sl@0
|
813 |
|
sl@0
|
814 |
|
sl@0
|
815 |
TheRFs.Close();
|
sl@0
|
816 |
test.End();
|
sl@0
|
817 |
test.Close();
|
sl@0
|
818 |
delete trapCleanup;
|
sl@0
|
819 |
__UHEAP_MARKEND;
|
sl@0
|
820 |
return error;
|
sl@0
|
821 |
}
|
sl@0
|
822 |
|