sl@0
|
1 |
// Copyright (c) 2008-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 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <f32file.h>
|
sl@0
|
17 |
#include "../../test/t_cenrep_helper.h"
|
sl@0
|
18 |
#include <e32test.h>
|
sl@0
|
19 |
|
sl@0
|
20 |
#ifdef __TOOLS2__
|
sl@0
|
21 |
#define CENREP_PC_TEST
|
sl@0
|
22 |
#endif
|
sl@0
|
23 |
|
sl@0
|
24 |
#ifdef CENREP_PC_TEST
|
sl@0
|
25 |
#include <x86tool/centralrepository.h>
|
sl@0
|
26 |
#else
|
sl@0
|
27 |
#include <centralrepository.h>
|
sl@0
|
28 |
#endif
|
sl@0
|
29 |
|
sl@0
|
30 |
_LIT( KCentralRepositoryServerName, "Centralrepositorysrv");
|
sl@0
|
31 |
|
sl@0
|
32 |
|
sl@0
|
33 |
//DEFINED IN THE TEST MAIN CPP
|
sl@0
|
34 |
extern void SetupEnv(const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode);
|
sl@0
|
35 |
extern void InitialiseLC(CRepository*& aRepository,TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode);
|
sl@0
|
36 |
extern RFs TheFs;
|
sl@0
|
37 |
extern RTest TheTest;
|
sl@0
|
38 |
|
sl@0
|
39 |
LOCAL_C void Check(TInt aValue, TInt aLine)
|
sl@0
|
40 |
{
|
sl@0
|
41 |
if(!aValue)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
TheTest(EFalse, aLine);
|
sl@0
|
44 |
}
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine)
|
sl@0
|
48 |
{
|
sl@0
|
49 |
if(aValue != aExpected)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
|
sl@0
|
52 |
TheTest(EFalse, aLine);
|
sl@0
|
53 |
}
|
sl@0
|
54 |
}
|
sl@0
|
55 |
|
sl@0
|
56 |
#define TEST(arg) ::Check((arg), __LINE__)
|
sl@0
|
57 |
#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
|
sl@0
|
58 |
|
sl@0
|
59 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
60 |
TInt CopyFile(const TDesC& aSource, const TDesC& aTarget)
|
sl@0
|
61 |
{
|
sl@0
|
62 |
RFile file;
|
sl@0
|
63 |
TInt ret=file.Open(TheFs,aSource,EFileRead);
|
sl@0
|
64 |
if (ret!=KErrNone)
|
sl@0
|
65 |
return ret;
|
sl@0
|
66 |
TInt fileSize;
|
sl@0
|
67 |
file.Size(fileSize);
|
sl@0
|
68 |
HBufC8* buf=HBufC8::New(fileSize);
|
sl@0
|
69 |
if (!buf)
|
sl@0
|
70 |
{
|
sl@0
|
71 |
file.Close();
|
sl@0
|
72 |
return KErrNoMemory;
|
sl@0
|
73 |
}
|
sl@0
|
74 |
TPtr8 mod(buf->Des());
|
sl@0
|
75 |
file.Read(mod);
|
sl@0
|
76 |
file.Close();
|
sl@0
|
77 |
ret=file.Replace(TheFs,aTarget,EFileWrite);
|
sl@0
|
78 |
if (ret==KErrNone)
|
sl@0
|
79 |
{
|
sl@0
|
80 |
file.Write(*buf);
|
sl@0
|
81 |
}
|
sl@0
|
82 |
file.Close();
|
sl@0
|
83 |
delete buf;
|
sl@0
|
84 |
return ret;
|
sl@0
|
85 |
}
|
sl@0
|
86 |
|
sl@0
|
87 |
void OomTest(void (*testFuncL)(CRepository* aRepository),TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode)
|
sl@0
|
88 |
{
|
sl@0
|
89 |
TInt error;
|
sl@0
|
90 |
TInt count = 0;
|
sl@0
|
91 |
|
sl@0
|
92 |
do
|
sl@0
|
93 |
{
|
sl@0
|
94 |
SetupEnv(aInFilePath,aOutFilePath,aTestMode);
|
sl@0
|
95 |
//for CRE testing we need to ensure we have a fresh copy of CRE(sourced from the TXT template)
|
sl@0
|
96 |
|
sl@0
|
97 |
__UHEAP_MARK;
|
sl@0
|
98 |
CRepository* repository=NULL;
|
sl@0
|
99 |
|
sl@0
|
100 |
#ifndef CENREP_PC_TEST
|
sl@0
|
101 |
//for CS testing, we want to kill server to start with fresh repos, otherwise might still use
|
sl@0
|
102 |
//cache version from previous test
|
sl@0
|
103 |
KillProcess(KCentralRepositoryServerName);
|
sl@0
|
104 |
#endif
|
sl@0
|
105 |
InitialiseLC(repository,aUid,aInFilePath,aOutFilePath,aTestMode);
|
sl@0
|
106 |
if (repository)
|
sl@0
|
107 |
CleanupStack::Pop();
|
sl@0
|
108 |
// This is supported by symuser but still have problem, so skiped
|
sl@0
|
109 |
// User::__DbgSetAllocFail(RHeap::EUser, RHeap::EDeterministic, ++count);
|
sl@0
|
110 |
|
sl@0
|
111 |
|
sl@0
|
112 |
// find out the number of open handles
|
sl@0
|
113 |
// TOOLS2 somehow not supporting RThread().HandleCount()?
|
sl@0
|
114 |
#ifndef __TOOLS2__
|
sl@0
|
115 |
TInt startProcessHandleCount;
|
sl@0
|
116 |
TInt startThreadHandleCount;
|
sl@0
|
117 |
RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
|
sl@0
|
118 |
#endif
|
sl@0
|
119 |
|
sl@0
|
120 |
TRAP(error, (testFuncL)(repository));
|
sl@0
|
121 |
|
sl@0
|
122 |
// check that no handles have leaked
|
sl@0
|
123 |
#ifndef __TOOLS2__
|
sl@0
|
124 |
TInt endProcessHandleCount;
|
sl@0
|
125 |
TInt endThreadHandleCount;
|
sl@0
|
126 |
RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
|
sl@0
|
127 |
|
sl@0
|
128 |
TEST2(endProcessHandleCount, startProcessHandleCount);
|
sl@0
|
129 |
TEST2(endThreadHandleCount, startThreadHandleCount);
|
sl@0
|
130 |
#endif
|
sl@0
|
131 |
// User::__DbgSetAllocFail(RHeap::EUser, RHeap::ENone, 1);
|
sl@0
|
132 |
|
sl@0
|
133 |
delete repository;
|
sl@0
|
134 |
|
sl@0
|
135 |
__UHEAP_MARKEND;
|
sl@0
|
136 |
|
sl@0
|
137 |
} while(error == KErrNoMemory);
|
sl@0
|
138 |
_LIT(KTestFailed, "Out of memory test failure on iteration %d\n");
|
sl@0
|
139 |
__ASSERT_ALWAYS(error==KErrNone, TheTest.Panic(error, KTestFailed, count));
|
sl@0
|
140 |
}
|
sl@0
|
141 |
|
sl@0
|
142 |
void ObjectCreateDeleteOOM(TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
// TInt count=0;
|
sl@0
|
145 |
TInt error=KErrNone;
|
sl@0
|
146 |
do
|
sl@0
|
147 |
{
|
sl@0
|
148 |
SetupEnv(aInFilePath,aOutFilePath,aTestMode);
|
sl@0
|
149 |
|
sl@0
|
150 |
__UHEAP_MARK;
|
sl@0
|
151 |
#ifndef __TOOLS2__
|
sl@0
|
152 |
TInt startProcessHandleCount;
|
sl@0
|
153 |
TInt startThreadHandleCount;
|
sl@0
|
154 |
RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
|
sl@0
|
155 |
#endif
|
sl@0
|
156 |
// This is supported by symuser but still has problems, so skipped.
|
sl@0
|
157 |
// User::__DbgSetAllocFail(RHeap::EUser, RHeap::EDeterministic, ++count);
|
sl@0
|
158 |
|
sl@0
|
159 |
CRepository* repository=NULL;
|
sl@0
|
160 |
|
sl@0
|
161 |
TRAP(error,InitialiseLC(repository,aUid,aInFilePath,aOutFilePath,aTestMode);CleanupStack::Pop());
|
sl@0
|
162 |
|
sl@0
|
163 |
delete repository;
|
sl@0
|
164 |
|
sl@0
|
165 |
// User::__DbgSetAllocFail(RHeap::EUser, RHeap::ENone, 1);
|
sl@0
|
166 |
|
sl@0
|
167 |
#ifndef __TOOLS2__
|
sl@0
|
168 |
// check that no handles have leaked
|
sl@0
|
169 |
TInt endProcessHandleCount;
|
sl@0
|
170 |
TInt endThreadHandleCount;
|
sl@0
|
171 |
RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
|
sl@0
|
172 |
|
sl@0
|
173 |
TEST2(endProcessHandleCount, startProcessHandleCount);
|
sl@0
|
174 |
TEST2(endThreadHandleCount, startThreadHandleCount);
|
sl@0
|
175 |
#endif
|
sl@0
|
176 |
|
sl@0
|
177 |
__UHEAP_MARKEND;
|
sl@0
|
178 |
} while(error == KErrNoMemory);
|
sl@0
|
179 |
}
|
sl@0
|
180 |
|
sl@0
|
181 |
void GetFunctionL(CRepository* aRepository)
|
sl@0
|
182 |
{
|
sl@0
|
183 |
//[GET]
|
sl@0
|
184 |
TInt intVal;
|
sl@0
|
185 |
TReal realVal;
|
sl@0
|
186 |
User::LeaveIfError(aRepository->Get(6,intVal));
|
sl@0
|
187 |
TEST(intVal==12);
|
sl@0
|
188 |
User::LeaveIfError(aRepository->Get(8,realVal));
|
sl@0
|
189 |
TEST(realVal==1.5);
|
sl@0
|
190 |
TBuf<255> stringVal;
|
sl@0
|
191 |
User::LeaveIfError(aRepository->Get(0x300,stringVal));
|
sl@0
|
192 |
TEST(stringVal.Compare(_L("Hello World"))==0);
|
sl@0
|
193 |
|
sl@0
|
194 |
TBuf<5> shortBuffer;
|
sl@0
|
195 |
TInt actualLength=0;
|
sl@0
|
196 |
TInt ret=aRepository->Get(0x300,shortBuffer,actualLength);
|
sl@0
|
197 |
TEST(ret==KErrOverflow);
|
sl@0
|
198 |
TEST(actualLength==11);
|
sl@0
|
199 |
TEST(shortBuffer.Compare(_L("Hello"))==0);
|
sl@0
|
200 |
|
sl@0
|
201 |
//[GETMETA]
|
sl@0
|
202 |
TUint32 metaValue;
|
sl@0
|
203 |
User::LeaveIfError(aRepository->GetMeta(2,metaValue));
|
sl@0
|
204 |
TEST(metaValue==0xa);
|
sl@0
|
205 |
//range based
|
sl@0
|
206 |
User::LeaveIfError(aRepository->GetMeta(0x204,metaValue));
|
sl@0
|
207 |
TEST(metaValue==0x20);
|
sl@0
|
208 |
//default based
|
sl@0
|
209 |
User::LeaveIfError(aRepository->GetMeta(0x10000,metaValue));
|
sl@0
|
210 |
TEST(metaValue==0x10);
|
sl@0
|
211 |
}
|
sl@0
|
212 |
|
sl@0
|
213 |
void FindFunctionL(CRepository* aRepository)
|
sl@0
|
214 |
{
|
sl@0
|
215 |
RArray<TUint32> keyList;
|
sl@0
|
216 |
CleanupClosePushL(keyList);
|
sl@0
|
217 |
//Find all settings
|
sl@0
|
218 |
TInt ret=aRepository->FindL(0xFFFFFFFF,0,keyList);
|
sl@0
|
219 |
User::LeaveIfError(ret);
|
sl@0
|
220 |
TEST(ret==KErrNone);
|
sl@0
|
221 |
TEST(keyList.Count()==33);
|
sl@0
|
222 |
keyList.Reset();
|
sl@0
|
223 |
//Find match EQ specific value
|
sl@0
|
224 |
ret=aRepository->FindEqL(0xFFFFFFFF,0,10,keyList);
|
sl@0
|
225 |
User::LeaveIfError(ret);
|
sl@0
|
226 |
TEST(ret==KErrNone);
|
sl@0
|
227 |
TEST(keyList.Count()==3);
|
sl@0
|
228 |
keyList.Reset();
|
sl@0
|
229 |
//Find match NEQ specific value
|
sl@0
|
230 |
ret=aRepository->FindNeqL(0xFFFFFFFF,0,10,keyList);
|
sl@0
|
231 |
TEST(ret==KErrNone);
|
sl@0
|
232 |
TEST(keyList.Count()==30);
|
sl@0
|
233 |
keyList.Reset();
|
sl@0
|
234 |
//Find using string matching instead
|
sl@0
|
235 |
_LIT(KString,"empty");
|
sl@0
|
236 |
ret=aRepository->FindEqL(0xFFFFFFFF,0,KString(),keyList);
|
sl@0
|
237 |
User::LeaveIfError(ret);
|
sl@0
|
238 |
TEST(ret==KErrNone);
|
sl@0
|
239 |
TEST(keyList.Count()==1);
|
sl@0
|
240 |
CleanupStack::PopAndDestroy();
|
sl@0
|
241 |
}
|
sl@0
|
242 |
|
sl@0
|
243 |
void SetFunctionL(CRepository* aRepository)
|
sl@0
|
244 |
{
|
sl@0
|
245 |
//[SET]
|
sl@0
|
246 |
//int
|
sl@0
|
247 |
TUint32 metaValue;
|
sl@0
|
248 |
TInt value;
|
sl@0
|
249 |
User::LeaveIfError(aRepository->Get(1,value));
|
sl@0
|
250 |
TEST(value==1);
|
sl@0
|
251 |
User::LeaveIfError(aRepository->Set(1,100));
|
sl@0
|
252 |
User::LeaveIfError(aRepository->Get(1,value));
|
sl@0
|
253 |
TEST(value==100) ;
|
sl@0
|
254 |
//real
|
sl@0
|
255 |
TReal realValue;
|
sl@0
|
256 |
User::LeaveIfError(aRepository->Get(2,realValue));
|
sl@0
|
257 |
TEST(realValue==2.732);
|
sl@0
|
258 |
TReal newrealValue(5.464);
|
sl@0
|
259 |
User::LeaveIfError(aRepository->Set(2,newrealValue));
|
sl@0
|
260 |
User::LeaveIfError(aRepository->Get(2,realValue));
|
sl@0
|
261 |
TEST(realValue==5.464);
|
sl@0
|
262 |
//string
|
sl@0
|
263 |
TBuf<255> stringValue;
|
sl@0
|
264 |
User::LeaveIfError(aRepository->Get(0x10000,stringValue));
|
sl@0
|
265 |
TEST(stringValue.Compare(_L("empty"))==0);
|
sl@0
|
266 |
User::LeaveIfError(aRepository->Set(0x10000,_L("full")));
|
sl@0
|
267 |
stringValue.Zero();
|
sl@0
|
268 |
User::LeaveIfError(aRepository->Get(0x10000,stringValue));
|
sl@0
|
269 |
TEST(stringValue.Compare(_L("full"))==0);
|
sl@0
|
270 |
|
sl@0
|
271 |
//use set to create new setting and also check the meta
|
sl@0
|
272 |
TInt newIntegerKeyValue=205;
|
sl@0
|
273 |
User::LeaveIfError(aRepository->Set(0x205,newIntegerKeyValue));
|
sl@0
|
274 |
User::LeaveIfError(aRepository->Get(0x205,value));
|
sl@0
|
275 |
TEST(value==205);
|
sl@0
|
276 |
User::LeaveIfError(aRepository->GetMeta(0x205,metaValue));
|
sl@0
|
277 |
//as the key 0x205 is within range, expect use of range meta
|
sl@0
|
278 |
TEST(metaValue==0x20);
|
sl@0
|
279 |
}
|
sl@0
|
280 |
|
sl@0
|
281 |
void CreateFunctionL(CRepository* aRepository)
|
sl@0
|
282 |
{
|
sl@0
|
283 |
TUint32 metaValue;
|
sl@0
|
284 |
TInt value=206;
|
sl@0
|
285 |
User::LeaveIfError(aRepository->Create(0x206,value));
|
sl@0
|
286 |
User::LeaveIfError(aRepository->Get(0x206,value));
|
sl@0
|
287 |
TEST(value==206);
|
sl@0
|
288 |
User::LeaveIfError(aRepository->GetMeta(0x206,metaValue));
|
sl@0
|
289 |
//within meta range
|
sl@0
|
290 |
TEST(metaValue==0x20);
|
sl@0
|
291 |
|
sl@0
|
292 |
TReal realValue=207.207;
|
sl@0
|
293 |
User::LeaveIfError(aRepository->Create(0x407,realValue));
|
sl@0
|
294 |
User::LeaveIfError(aRepository->Get(0x407,realValue));
|
sl@0
|
295 |
TEST(realValue==207.207);
|
sl@0
|
296 |
User::LeaveIfError(aRepository->GetMeta(0x407,metaValue));
|
sl@0
|
297 |
//default meta
|
sl@0
|
298 |
TEST(metaValue==0x10);
|
sl@0
|
299 |
|
sl@0
|
300 |
//create already existing setting
|
sl@0
|
301 |
TInt ret=aRepository->Create(1,value);
|
sl@0
|
302 |
TEST(ret==KErrAlreadyExists);
|
sl@0
|
303 |
}
|
sl@0
|
304 |
|
sl@0
|
305 |
void DeleteFunctionL(CRepository* aRepository)
|
sl@0
|
306 |
{
|
sl@0
|
307 |
//delete single
|
sl@0
|
308 |
TInt value;
|
sl@0
|
309 |
User::LeaveIfError(aRepository->Delete(6));
|
sl@0
|
310 |
TInt ret=aRepository->Get(6,value);
|
sl@0
|
311 |
TEST(ret==KErrNotFound);
|
sl@0
|
312 |
|
sl@0
|
313 |
//delete range
|
sl@0
|
314 |
RArray<TUint32> keyList;
|
sl@0
|
315 |
CleanupClosePushL(keyList);
|
sl@0
|
316 |
//make sure that the list of keys are there first
|
sl@0
|
317 |
ret=aRepository->FindL(0x03010000,0xFFFFF0FF,keyList);
|
sl@0
|
318 |
User::LeaveIfError(ret);
|
sl@0
|
319 |
TEST(keyList.Count()==5);
|
sl@0
|
320 |
TUint32 error;
|
sl@0
|
321 |
User::LeaveIfError(aRepository->Delete(0x03010000,0xFFFFF0FF,error));
|
sl@0
|
322 |
//check that key no longer exist
|
sl@0
|
323 |
keyList.Reset();
|
sl@0
|
324 |
ret=aRepository->FindL(0x03010000,0xFFFFF0FF,keyList);
|
sl@0
|
325 |
if (ret!=KErrNotFound)
|
sl@0
|
326 |
User::LeaveIfError(ret);
|
sl@0
|
327 |
TEST(ret==KErrNotFound);
|
sl@0
|
328 |
TEST(keyList.Count()==0);
|
sl@0
|
329 |
CleanupStack::PopAndDestroy();
|
sl@0
|
330 |
}
|
sl@0
|
331 |
|
sl@0
|
332 |
void MoveFunctionL(CRepository* aRepository)
|
sl@0
|
333 |
{
|
sl@0
|
334 |
RArray<TUint32> keyList;
|
sl@0
|
335 |
CleanupClosePushL(keyList);
|
sl@0
|
336 |
TUint32 errorKey;
|
sl@0
|
337 |
//check source key exists first
|
sl@0
|
338 |
keyList.Reset();
|
sl@0
|
339 |
TInt ret=aRepository->FindL(0x02010000,0xFFFFF0FF,keyList);
|
sl@0
|
340 |
User::LeaveIfError(ret);
|
sl@0
|
341 |
TEST(keyList.Count()==5);
|
sl@0
|
342 |
|
sl@0
|
343 |
User::LeaveIfError(aRepository->Move(0x02010000,0x06010000,0xFFFFF0FF,errorKey));
|
sl@0
|
344 |
|
sl@0
|
345 |
keyList.Reset();
|
sl@0
|
346 |
//check target now exists
|
sl@0
|
347 |
ret=aRepository->FindL(0x06010000,0xFFFFF0FF,keyList);
|
sl@0
|
348 |
User::LeaveIfError(ret);
|
sl@0
|
349 |
|
sl@0
|
350 |
TEST(keyList.Count()==5);
|
sl@0
|
351 |
//check source now deleted
|
sl@0
|
352 |
keyList.Reset();
|
sl@0
|
353 |
ret=aRepository->FindL(0x02010000,0xFFFFF0FF,keyList);
|
sl@0
|
354 |
TEST(ret==KErrNotFound);
|
sl@0
|
355 |
TEST2(keyList.Count(),0);
|
sl@0
|
356 |
|
sl@0
|
357 |
CleanupStack::PopAndDestroy();
|
sl@0
|
358 |
}
|
sl@0
|
359 |
|
sl@0
|
360 |
/**
|
sl@0
|
361 |
*/
|
sl@0
|
362 |
void BasicFunctionL(TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode)
|
sl@0
|
363 |
{
|
sl@0
|
364 |
//TEST SETUP
|
sl@0
|
365 |
SetupEnv(aInFilePath,aOutFilePath,aTestMode);
|
sl@0
|
366 |
|
sl@0
|
367 |
__UHEAP_MARK;
|
sl@0
|
368 |
CRepository* repository=NULL;
|
sl@0
|
369 |
|
sl@0
|
370 |
InitialiseLC(repository,aUid,aInFilePath,aOutFilePath,aTestMode);
|
sl@0
|
371 |
|
sl@0
|
372 |
#ifdef CENREP_PC_TEST
|
sl@0
|
373 |
//testing transaction
|
sl@0
|
374 |
TInt r= repository->StartTransaction(CRepository::EConcurrentReadWriteTransaction);
|
sl@0
|
375 |
TEST2(r, KErrNone);
|
sl@0
|
376 |
repository->CleanupCancelTransactionPushL();
|
sl@0
|
377 |
#endif
|
sl@0
|
378 |
|
sl@0
|
379 |
GetFunctionL(repository);
|
sl@0
|
380 |
FindFunctionL(repository);
|
sl@0
|
381 |
SetFunctionL(repository);
|
sl@0
|
382 |
CreateFunctionL(repository);
|
sl@0
|
383 |
DeleteFunctionL(repository);
|
sl@0
|
384 |
MoveFunctionL(repository);
|
sl@0
|
385 |
|
sl@0
|
386 |
#ifdef CENREP_PC_TEST
|
sl@0
|
387 |
CleanupStack::PopAndDestroy();
|
sl@0
|
388 |
#endif
|
sl@0
|
389 |
|
sl@0
|
390 |
CleanupStack::PopAndDestroy();
|
sl@0
|
391 |
|
sl@0
|
392 |
__UHEAP_MARKEND;
|
sl@0
|
393 |
}
|
sl@0
|
394 |
|
sl@0
|
395 |
void OomBasicFunction(TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode)
|
sl@0
|
396 |
{
|
sl@0
|
397 |
__UHEAP_MARK;
|
sl@0
|
398 |
|
sl@0
|
399 |
OomTest(GetFunctionL,aUid,aInFilePath,aOutFilePath,aTestMode);
|
sl@0
|
400 |
OomTest(FindFunctionL,aUid,aInFilePath,aOutFilePath,aTestMode);
|
sl@0
|
401 |
OomTest(SetFunctionL,aUid,aInFilePath,aOutFilePath,aTestMode);
|
sl@0
|
402 |
OomTest(CreateFunctionL,aUid,aInFilePath,aOutFilePath,aTestMode);
|
sl@0
|
403 |
OomTest(DeleteFunctionL,aUid,aInFilePath,aOutFilePath,aTestMode);
|
sl@0
|
404 |
OomTest(MoveFunctionL,aUid,aInFilePath,aOutFilePath,aTestMode);
|
sl@0
|
405 |
|
sl@0
|
406 |
__UHEAP_MARKEND;
|
sl@0
|
407 |
}
|
sl@0
|
408 |
|
sl@0
|
409 |
void DEF130394L(TUid aUid)
|
sl@0
|
410 |
{
|
sl@0
|
411 |
CRepository* repos=NULL;
|
sl@0
|
412 |
|
sl@0
|
413 |
repos = CRepository::NewL(aUid);
|
sl@0
|
414 |
|
sl@0
|
415 |
TInt err = repos->Create(1,1);
|
sl@0
|
416 |
TEST(err==KErrNone);
|
sl@0
|
417 |
|
sl@0
|
418 |
delete repos;
|
sl@0
|
419 |
|
sl@0
|
420 |
repos = CRepository::NewL(aUid);
|
sl@0
|
421 |
|
sl@0
|
422 |
err = repos->Create(1,1);
|
sl@0
|
423 |
TEST(err==KErrAlreadyExists);
|
sl@0
|
424 |
|
sl@0
|
425 |
delete repos;
|
sl@0
|
426 |
}
|
sl@0
|
427 |
|
sl@0
|
428 |
void DoFileCompL(const TDesC& aGenerated, const TDesC& aReference, TUint32& aCrcValue)
|
sl@0
|
429 |
{
|
sl@0
|
430 |
RFile genFile;
|
sl@0
|
431 |
RFile refFile;
|
sl@0
|
432 |
TInt err = genFile.Open(TheFs,aGenerated,EFileRead);
|
sl@0
|
433 |
User::LeaveIfError(err);
|
sl@0
|
434 |
err = refFile.Open(TheFs,aReference,EFileRead);
|
sl@0
|
435 |
User::LeaveIfError(err);
|
sl@0
|
436 |
|
sl@0
|
437 |
TInt sizeOfGen;
|
sl@0
|
438 |
genFile.Size(sizeOfGen);
|
sl@0
|
439 |
TInt sizeOfRef;
|
sl@0
|
440 |
refFile.Size(sizeOfRef);
|
sl@0
|
441 |
TEST(sizeOfGen == sizeOfRef);
|
sl@0
|
442 |
|
sl@0
|
443 |
TUint32 crcGen = 0;
|
sl@0
|
444 |
TUint32 crcRef = 0;
|
sl@0
|
445 |
|
sl@0
|
446 |
HBufC8* buf = HBufC8::New(sizeOfGen);
|
sl@0
|
447 |
if (!buf)
|
sl@0
|
448 |
{
|
sl@0
|
449 |
genFile.Close();
|
sl@0
|
450 |
refFile.Close();
|
sl@0
|
451 |
User::Leave(KErrNoMemory);
|
sl@0
|
452 |
}
|
sl@0
|
453 |
TPtr8 data(buf->Des());
|
sl@0
|
454 |
|
sl@0
|
455 |
err = genFile.Read(data);
|
sl@0
|
456 |
User::LeaveIfError(err);
|
sl@0
|
457 |
Mem::Crc32(crcGen, buf, sizeOfGen);
|
sl@0
|
458 |
err = refFile.Read(data);
|
sl@0
|
459 |
User::LeaveIfError(err);
|
sl@0
|
460 |
Mem::Crc32(crcRef, buf, sizeOfRef);
|
sl@0
|
461 |
|
sl@0
|
462 |
TEST(crcGen == crcRef);
|
sl@0
|
463 |
|
sl@0
|
464 |
aCrcValue = crcGen;
|
sl@0
|
465 |
|
sl@0
|
466 |
delete buf;
|
sl@0
|
467 |
genFile.Close();
|
sl@0
|
468 |
refFile.Close();
|
sl@0
|
469 |
|
sl@0
|
470 |
return;
|
sl@0
|
471 |
}
|
sl@0
|
472 |
|
sl@0
|
473 |
void DoCrcCompL(const TUint32& aCrcValue, const TDesC& aCrcRecord, TBool aCreOrTxt)
|
sl@0
|
474 |
{
|
sl@0
|
475 |
RFile file;
|
sl@0
|
476 |
TInt err = file.Open(TheFs, aCrcRecord, EFileRead);
|
sl@0
|
477 |
User::LeaveIfError(err);
|
sl@0
|
478 |
|
sl@0
|
479 |
TBuf8<100> buf;
|
sl@0
|
480 |
file.Read(buf);
|
sl@0
|
481 |
|
sl@0
|
482 |
TBuf8<1> breaker(_L8("-"));
|
sl@0
|
483 |
TInt pos = buf.Find(breaker);
|
sl@0
|
484 |
|
sl@0
|
485 |
TInt length = buf.Length();
|
sl@0
|
486 |
|
sl@0
|
487 |
const TPtrC8 crePtr = buf.Right(length - pos -1);
|
sl@0
|
488 |
const TPtrC8 txtPtr = buf.Left(pos);
|
sl@0
|
489 |
|
sl@0
|
490 |
TUint32 crc = 0;
|
sl@0
|
491 |
|
sl@0
|
492 |
if (aCreOrTxt)
|
sl@0
|
493 |
{
|
sl@0
|
494 |
TLex8 lex (crePtr);
|
sl@0
|
495 |
lex.Val(crc, EDecimal);
|
sl@0
|
496 |
}
|
sl@0
|
497 |
else
|
sl@0
|
498 |
{
|
sl@0
|
499 |
TLex8 lex (txtPtr);
|
sl@0
|
500 |
lex.Val(crc, EDecimal);
|
sl@0
|
501 |
}
|
sl@0
|
502 |
TEST2(crc, aCrcValue);
|
sl@0
|
503 |
file.Close();
|
sl@0
|
504 |
}
|
sl@0
|
505 |
|