sl@0
|
1 |
// Copyright (c) 1998-2010 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 <s32cont.h>
|
sl@0
|
17 |
#include <s32page.h>
|
sl@0
|
18 |
#include <s32mem.h>
|
sl@0
|
19 |
#include <e32test.h>
|
sl@0
|
20 |
#include "U32STD.H"
|
sl@0
|
21 |
|
sl@0
|
22 |
const TInt KTestCleanupStack=0x20;
|
sl@0
|
23 |
|
sl@0
|
24 |
LOCAL_D CTrapCleanup* TheTrapCleanup;
|
sl@0
|
25 |
LOCAL_D RTest test(_L("t_storset"));
|
sl@0
|
26 |
|
sl@0
|
27 |
/**
|
sl@0
|
28 |
@SYMTestCaseID SYSLIB-STORE-CT-1121
|
sl@0
|
29 |
@SYMTestCaseDesc TPagedSet class functionality test
|
sl@0
|
30 |
@SYMTestPriority High
|
sl@0
|
31 |
@SYMTestActions Tests insert/delete/contains without duplicates.
|
sl@0
|
32 |
Tests for emptying the set
|
sl@0
|
33 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
34 |
@SYMREQ REQ0000
|
sl@0
|
35 |
*/
|
sl@0
|
36 |
LOCAL_C void test1L()
|
sl@0
|
37 |
{
|
sl@0
|
38 |
test.Start(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1121 Insertion & Deletion "));
|
sl@0
|
39 |
|
sl@0
|
40 |
const TInt KEntryCount=200;
|
sl@0
|
41 |
TPagedSet<TInt32> set;
|
sl@0
|
42 |
set.Connect(CMemPagePool::NewLC());
|
sl@0
|
43 |
//IsIntact() and IsDirty() test
|
sl@0
|
44 |
TBool rc = set.IsIntact();
|
sl@0
|
45 |
test(rc);
|
sl@0
|
46 |
rc = set.IsDirty();
|
sl@0
|
47 |
test(!rc);
|
sl@0
|
48 |
set.MarkDirty();
|
sl@0
|
49 |
rc = set.IsDirty();
|
sl@0
|
50 |
test(rc);
|
sl@0
|
51 |
//IsBroken() test
|
sl@0
|
52 |
rc = set.IsBroken();
|
sl@0
|
53 |
test(!rc);
|
sl@0
|
54 |
set.MarkBroken();
|
sl@0
|
55 |
rc = set.IsBroken();
|
sl@0
|
56 |
test(!rc);//Empty tree - cannot be marked as broken
|
sl@0
|
57 |
TInt yy = 10;
|
sl@0
|
58 |
set.InsertL(yy);
|
sl@0
|
59 |
set.MarkBroken();
|
sl@0
|
60 |
rc = set.IsBroken();
|
sl@0
|
61 |
test(rc);
|
sl@0
|
62 |
set.RepairL();
|
sl@0
|
63 |
rc = set.IsBroken();
|
sl@0
|
64 |
test(!rc);
|
sl@0
|
65 |
set.ClearL();
|
sl@0
|
66 |
rc = set.IsBroken();
|
sl@0
|
67 |
test(!rc);
|
sl@0
|
68 |
|
sl@0
|
69 |
TInt32 it=0;
|
sl@0
|
70 |
//* test(set.InsertL(it));
|
sl@0
|
71 |
set.InsertL(it);
|
sl@0
|
72 |
test(set.Count()==1);
|
sl@0
|
73 |
//* test(!set.InsertL(it));
|
sl@0
|
74 |
test(set.Count()==1);
|
sl@0
|
75 |
test(set.ContainsL(it));
|
sl@0
|
76 |
//* test(set.DeleteL(it));
|
sl@0
|
77 |
set.DeleteL(it);
|
sl@0
|
78 |
test(set.Count()==0);
|
sl@0
|
79 |
//* test(!set.DeleteL(it));
|
sl@0
|
80 |
//* test(set.Count()==0);
|
sl@0
|
81 |
test(!set.ContainsL(it));
|
sl@0
|
82 |
|
sl@0
|
83 |
//* test.Next(_L("Duplicates"));
|
sl@0
|
84 |
TInt ii;
|
sl@0
|
85 |
//* for (ii=0;ii<KEntryCount;++ii)
|
sl@0
|
86 |
//* test(set.InsertL(it,EAllowDuplicates));
|
sl@0
|
87 |
//* test(set.Count()==KEntryCount);
|
sl@0
|
88 |
//* test(set.ContainsL(it));
|
sl@0
|
89 |
//* test(!set.InsertL(it));
|
sl@0
|
90 |
//* for (ii=0;ii<KEntryCount;++ii)
|
sl@0
|
91 |
//* test(set.DeleteL(it));
|
sl@0
|
92 |
//* test(!set.ContainsL(it));
|
sl@0
|
93 |
//* test(!set.DeleteL(it));
|
sl@0
|
94 |
//* test(set.Count()==0);
|
sl@0
|
95 |
|
sl@0
|
96 |
test.Next(_L("No duplicates"));
|
sl@0
|
97 |
for (ii=0;ii<KEntryCount;++ii)
|
sl@0
|
98 |
{
|
sl@0
|
99 |
it=ii;
|
sl@0
|
100 |
//* test(set.InsertL(it));
|
sl@0
|
101 |
set.InsertL(it);
|
sl@0
|
102 |
}
|
sl@0
|
103 |
for (ii=0;ii<KEntryCount;++ii)
|
sl@0
|
104 |
{
|
sl@0
|
105 |
it=ii;
|
sl@0
|
106 |
//* test(!set.InsertL(it));
|
sl@0
|
107 |
test(set.ContainsL(it));
|
sl@0
|
108 |
}
|
sl@0
|
109 |
test(set.Count()==KEntryCount);
|
sl@0
|
110 |
|
sl@0
|
111 |
test.Next(_L("Empty the set"));
|
sl@0
|
112 |
set.ClearL();
|
sl@0
|
113 |
test(set.Count()==0);
|
sl@0
|
114 |
for (ii=0;ii<KEntryCount;++ii)
|
sl@0
|
115 |
{
|
sl@0
|
116 |
it=ii;
|
sl@0
|
117 |
test(!set.ContainsL(it));
|
sl@0
|
118 |
}
|
sl@0
|
119 |
|
sl@0
|
120 |
test.End();
|
sl@0
|
121 |
CleanupStack::PopAndDestroy();
|
sl@0
|
122 |
}
|
sl@0
|
123 |
/**
|
sl@0
|
124 |
@SYMTestCaseID SYSLIB-STORE-CT-1122
|
sl@0
|
125 |
@SYMTestCaseDesc TPagedSet class functionality test with large (10000) set of TUint32.
|
sl@0
|
126 |
@SYMTestPriority High
|
sl@0
|
127 |
@SYMTestActions Insert,delete,contains,iteration operations test
|
sl@0
|
128 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
129 |
@SYMREQ REQ0000
|
sl@0
|
130 |
*/
|
sl@0
|
131 |
LOCAL_C void test2L()
|
sl@0
|
132 |
{
|
sl@0
|
133 |
const TInt KEntryCount=10000;
|
sl@0
|
134 |
|
sl@0
|
135 |
TPagedSet<TUint32> set;
|
sl@0
|
136 |
//* set.Connect(CMemPagePool::NewLC(),TBtree::EQosFastest);
|
sl@0
|
137 |
set.Connect(CMemPagePool::NewLC());
|
sl@0
|
138 |
|
sl@0
|
139 |
test.Start(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1122 Add items "));
|
sl@0
|
140 |
TUint32 jj=0;
|
sl@0
|
141 |
TInt32 ii;
|
sl@0
|
142 |
for (ii=KEntryCount;ii>0;--ii)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
jj=(jj+17)%KEntryCount;
|
sl@0
|
145 |
//* test(set.InsertL(jj));
|
sl@0
|
146 |
set.InsertL(jj);
|
sl@0
|
147 |
}
|
sl@0
|
148 |
test(set.Count()==KEntryCount);
|
sl@0
|
149 |
|
sl@0
|
150 |
test.Next(_L("Check contents"));
|
sl@0
|
151 |
for (ii=0;ii<KEntryCount;++ii)
|
sl@0
|
152 |
test(set.ContainsL(ii));
|
sl@0
|
153 |
|
sl@0
|
154 |
test.Next(_L("Iterate over items"));
|
sl@0
|
155 |
TUint8 *checkMap=(TUint8*)User::AllocLC(KEntryCount);
|
sl@0
|
156 |
Mem::FillZ(checkMap,KEntryCount);
|
sl@0
|
157 |
TPagedSetIter<TUint32> iter(set);
|
sl@0
|
158 |
if (iter.ResetL())
|
sl@0
|
159 |
{
|
sl@0
|
160 |
do
|
sl@0
|
161 |
{
|
sl@0
|
162 |
TUint32 data1 = iter.AtL();
|
sl@0
|
163 |
++checkMap[data1];
|
sl@0
|
164 |
TUint32 data2;
|
sl@0
|
165 |
iter.ExtractAtL(data2);
|
sl@0
|
166 |
test(data1 == data2);
|
sl@0
|
167 |
}while(iter.NextL());
|
sl@0
|
168 |
}
|
sl@0
|
169 |
for (ii=0;ii<KEntryCount;++ii)
|
sl@0
|
170 |
test(checkMap[ii]==1);
|
sl@0
|
171 |
CleanupStack::PopAndDestroy();
|
sl@0
|
172 |
|
sl@0
|
173 |
test.Next(_L("Delete items"));
|
sl@0
|
174 |
jj=0;
|
sl@0
|
175 |
for (ii=KEntryCount;ii>KEntryCount/2;--ii)
|
sl@0
|
176 |
{
|
sl@0
|
177 |
jj=(jj+17)%KEntryCount;
|
sl@0
|
178 |
//* test(set.DeleteL(jj));
|
sl@0
|
179 |
set.DeleteL(jj);
|
sl@0
|
180 |
}
|
sl@0
|
181 |
test(set.Count()==KEntryCount/2);
|
sl@0
|
182 |
|
sl@0
|
183 |
test.Next(_L("Check contents"));
|
sl@0
|
184 |
for (;ii>0;--ii)
|
sl@0
|
185 |
{
|
sl@0
|
186 |
jj=(jj+17)%KEntryCount;
|
sl@0
|
187 |
test(set.ContainsL(jj));
|
sl@0
|
188 |
}
|
sl@0
|
189 |
jj=0;
|
sl@0
|
190 |
for (ii=KEntryCount;ii>KEntryCount/2;--ii)
|
sl@0
|
191 |
{
|
sl@0
|
192 |
jj=(jj+17)%KEntryCount;
|
sl@0
|
193 |
test(!set.ContainsL(jj));
|
sl@0
|
194 |
}
|
sl@0
|
195 |
|
sl@0
|
196 |
test.Next(_L("Delete items"));
|
sl@0
|
197 |
for (;ii>1;--ii)
|
sl@0
|
198 |
{
|
sl@0
|
199 |
jj=(jj+17)%KEntryCount;
|
sl@0
|
200 |
//* test(set.DeleteL(jj));
|
sl@0
|
201 |
set.DeleteL(jj);
|
sl@0
|
202 |
}
|
sl@0
|
203 |
test(set.Count()==1);
|
sl@0
|
204 |
|
sl@0
|
205 |
test.Next(_L("Check contents"));
|
sl@0
|
206 |
jj=(jj+17)%KEntryCount;
|
sl@0
|
207 |
TPagedSetBiIter<TUint32> biter(set);
|
sl@0
|
208 |
test(biter.FirstL());
|
sl@0
|
209 |
test(biter.AtL()==jj);
|
sl@0
|
210 |
TUint32 data;
|
sl@0
|
211 |
biter.ExtractAtL(data);
|
sl@0
|
212 |
test(data == jj);
|
sl@0
|
213 |
test(!biter.NextL());
|
sl@0
|
214 |
test(biter.LastL());
|
sl@0
|
215 |
test(biter.AtL()==jj);
|
sl@0
|
216 |
test(!biter.PreviousL());
|
sl@0
|
217 |
TPagedSetRIter<TUint32> riter(set);
|
sl@0
|
218 |
test(riter.ResetL());
|
sl@0
|
219 |
test(riter.AtL()==jj);
|
sl@0
|
220 |
riter.ExtractAtL(data);
|
sl@0
|
221 |
test(data == jj);
|
sl@0
|
222 |
test(!riter.NextL());
|
sl@0
|
223 |
|
sl@0
|
224 |
//* test(set.DeleteL(jj));
|
sl@0
|
225 |
set.DeleteL(jj);
|
sl@0
|
226 |
test(!iter.ResetL());
|
sl@0
|
227 |
test(set.Count()==0);
|
sl@0
|
228 |
|
sl@0
|
229 |
test.End();
|
sl@0
|
230 |
|
sl@0
|
231 |
CleanupStack::PopAndDestroy();
|
sl@0
|
232 |
}
|
sl@0
|
233 |
/**
|
sl@0
|
234 |
@SYMTestCaseID SYSLIB-STORE-CT-1123
|
sl@0
|
235 |
@SYMTestCaseDesc Stream set out test
|
sl@0
|
236 |
@SYMTestPriority High
|
sl@0
|
237 |
@SYMTestActions Build set and stream out
|
sl@0
|
238 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
239 |
@SYMREQ REQ0000
|
sl@0
|
240 |
*/
|
sl@0
|
241 |
LOCAL_C void test3aL(RWriteStream& aStream,MPagePool *aPool,TInt aCount)
|
sl@0
|
242 |
{
|
sl@0
|
243 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1123 "));
|
sl@0
|
244 |
TPagedSet<TInt32> set;
|
sl@0
|
245 |
//* set.Connect(aPool,TBtree::EQosFastest);
|
sl@0
|
246 |
set.Connect(aPool);
|
sl@0
|
247 |
|
sl@0
|
248 |
for (TInt ii=0;ii<aCount;ii++)
|
sl@0
|
249 |
{
|
sl@0
|
250 |
TInt32 it=ii;
|
sl@0
|
251 |
//* test(set.InsertL(it));
|
sl@0
|
252 |
set.InsertL(it);
|
sl@0
|
253 |
}
|
sl@0
|
254 |
aStream<<set.Token();
|
sl@0
|
255 |
}
|
sl@0
|
256 |
/**
|
sl@0
|
257 |
@SYMTestCaseID SYSLIB-STORE-CT-1124
|
sl@0
|
258 |
@SYMTestCaseDesc Stream in and set test
|
sl@0
|
259 |
@SYMTestPriority High
|
sl@0
|
260 |
@SYMTestActions Read a token from a stream,create and a pagedset.Tests for emptying the set.
|
sl@0
|
261 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
262 |
@SYMREQ REQ0000
|
sl@0
|
263 |
*/
|
sl@0
|
264 |
LOCAL_C void test3bL(RReadStream& aStream,MPagePool *aPool,TInt aCount)
|
sl@0
|
265 |
{
|
sl@0
|
266 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1124 "));
|
sl@0
|
267 |
TPagedSetToken token;
|
sl@0
|
268 |
aStream>>token;
|
sl@0
|
269 |
TPagedSet<TInt32> set(token);
|
sl@0
|
270 |
//* set.Connect(aPool,TBtree::EQosFastest);
|
sl@0
|
271 |
set.Connect(aPool);
|
sl@0
|
272 |
|
sl@0
|
273 |
test(set.Count()==aCount);
|
sl@0
|
274 |
for (TInt ii=0;ii<aCount;ii++)
|
sl@0
|
275 |
{
|
sl@0
|
276 |
TInt32 it=ii;
|
sl@0
|
277 |
//* test(set.DeleteL(it));
|
sl@0
|
278 |
set.DeleteL(it);
|
sl@0
|
279 |
}
|
sl@0
|
280 |
test(set.Count()==0);
|
sl@0
|
281 |
}
|
sl@0
|
282 |
|
sl@0
|
283 |
/**
|
sl@0
|
284 |
@SYMTestCaseID SYSLIB-STORE-CT-1125
|
sl@0
|
285 |
@SYMTestCaseDesc Streaming sets test
|
sl@0
|
286 |
@SYMTestPriority High
|
sl@0
|
287 |
@SYMTestActions Tests for token streaming operations on pagedsets.
|
sl@0
|
288 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
289 |
@SYMREQ REQ0000
|
sl@0
|
290 |
*/
|
sl@0
|
291 |
LOCAL_C void test3L()
|
sl@0
|
292 |
{
|
sl@0
|
293 |
const TInt KEntryCount=1000;
|
sl@0
|
294 |
MPagePool *pool=CMemPagePool::NewLC();
|
sl@0
|
295 |
TUint8 stream[0x40];
|
sl@0
|
296 |
test.Start(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1125 Build set and stream out "));
|
sl@0
|
297 |
RMemWriteStream out(stream,sizeof(stream));
|
sl@0
|
298 |
test3aL(out,pool,KEntryCount);
|
sl@0
|
299 |
test.Next(_L("Stream in and test set "));
|
sl@0
|
300 |
RMemReadStream in(stream,sizeof(stream));
|
sl@0
|
301 |
test3bL(in,pool,KEntryCount);
|
sl@0
|
302 |
test.End();
|
sl@0
|
303 |
CleanupStack::PopAndDestroy();
|
sl@0
|
304 |
}
|
sl@0
|
305 |
|
sl@0
|
306 |
class CPersistentStoreHelper: public CPersistentStore
|
sl@0
|
307 |
{
|
sl@0
|
308 |
virtual MStreamBuf* DoReadL(TStreamId /*anId*/) const
|
sl@0
|
309 |
{
|
sl@0
|
310 |
return NULL;
|
sl@0
|
311 |
}
|
sl@0
|
312 |
virtual MStreamBuf* DoCreateL(TStreamId& /*anId*/)
|
sl@0
|
313 |
{
|
sl@0
|
314 |
return NULL;
|
sl@0
|
315 |
}
|
sl@0
|
316 |
void Help()
|
sl@0
|
317 |
{
|
sl@0
|
318 |
//just do nothing
|
sl@0
|
319 |
return;
|
sl@0
|
320 |
}
|
sl@0
|
321 |
};
|
sl@0
|
322 |
|
sl@0
|
323 |
/**
|
sl@0
|
324 |
@SYMTestCaseID PDS-STORE-CT-4015
|
sl@0
|
325 |
@SYMTestCaseDesc Test untested APIs of TPagedMultiset and TPagedSetToken
|
sl@0
|
326 |
@SYMTestPriority High
|
sl@0
|
327 |
@SYMTestActions Test possibility of adding duplicates into TPagedMultiset. Calling empy constructor TPagedSetToken.
|
sl@0
|
328 |
Test RepairL();
|
sl@0
|
329 |
@SYMTestExpectedResults Insterting duplicates should be possible and should not fail. After adding KEntryCount
|
sl@0
|
330 |
identical elements Count() should equal KEntryCount. Constructor should create valid object.
|
sl@0
|
331 |
RepairL function can't be runned now, because it has a problem inside that cause KERN-EXEC: 3.
|
sl@0
|
332 |
@SYMDEF DEF135804
|
sl@0
|
333 |
*/
|
sl@0
|
334 |
LOCAL_C void test4L()
|
sl@0
|
335 |
{
|
sl@0
|
336 |
const TInt KEntryCount=200;
|
sl@0
|
337 |
|
sl@0
|
338 |
test.Start(_L(" @SYMTestCaseID:PDS-STORE-CT-4015 Test untested APIs "));
|
sl@0
|
339 |
|
sl@0
|
340 |
TInt32 it=0;
|
sl@0
|
341 |
TPagedMultiset<TInt32> set;
|
sl@0
|
342 |
set.Connect(CMemPagePool::NewLC());
|
sl@0
|
343 |
test.Next(_L("Duplicates"));
|
sl@0
|
344 |
TInt ii, err;
|
sl@0
|
345 |
for (ii=0;ii<KEntryCount;++ii)
|
sl@0
|
346 |
{
|
sl@0
|
347 |
TRAP(err, set.InsertL(it));
|
sl@0
|
348 |
test(err==KErrNone);
|
sl@0
|
349 |
}
|
sl@0
|
350 |
test(set.Count()==KEntryCount);
|
sl@0
|
351 |
TBool rc = set.IsEmpty();
|
sl@0
|
352 |
test(!rc);
|
sl@0
|
353 |
set.MarkDirty();
|
sl@0
|
354 |
set.MarkCurrent();
|
sl@0
|
355 |
TRAP(err, set.ContainsL(it));
|
sl@0
|
356 |
test(err==KErrNone);
|
sl@0
|
357 |
TRAP(err, set.InsertL(it));
|
sl@0
|
358 |
test(err==KErrNone);
|
sl@0
|
359 |
|
sl@0
|
360 |
for (ii=0;ii<KEntryCount;++ii)
|
sl@0
|
361 |
{
|
sl@0
|
362 |
TRAP(err, set.DeleteL(it));
|
sl@0
|
363 |
test(err==KErrNone);
|
sl@0
|
364 |
}
|
sl@0
|
365 |
|
sl@0
|
366 |
TRAP(err, set.ContainsL(it));
|
sl@0
|
367 |
test(err==KErrNone);
|
sl@0
|
368 |
TRAP(err, set.DeleteL(it));
|
sl@0
|
369 |
test(err==KErrNone);
|
sl@0
|
370 |
test(set.Count()==0);
|
sl@0
|
371 |
|
sl@0
|
372 |
test.Next(_L("Calling MPagePool::Delete"));
|
sl@0
|
373 |
CMemPagePool* mpp = CMemPagePool::NewLC();
|
sl@0
|
374 |
const TPageAbandonFunction& nopFunc = mpp->AcquireL();
|
sl@0
|
375 |
test(&nopFunc != NULL);
|
sl@0
|
376 |
TAny* any = mpp->AllocL();
|
sl@0
|
377 |
TPageRef pref;
|
sl@0
|
378 |
pref = mpp->AssignL(any, EPageReclaimable);
|
sl@0
|
379 |
mpp->MPagePool::Delete(pref);
|
sl@0
|
380 |
CleanupStack::PopAndDestroy();
|
sl@0
|
381 |
|
sl@0
|
382 |
test.Next(_L("CPersistentStore DoSetRootL"));
|
sl@0
|
383 |
CPersistentStoreHelper* ps = new (ELeave) CPersistentStoreHelper();
|
sl@0
|
384 |
CleanupStack::PushL(ps);
|
sl@0
|
385 |
ps->SetRootL(KNullStreamId);
|
sl@0
|
386 |
CleanupStack::PopAndDestroy();
|
sl@0
|
387 |
|
sl@0
|
388 |
test.Next(_L("HDirectStoreBuf::DoSeekL calls"));
|
sl@0
|
389 |
HBufC8* buf = HBufC8::NewLC(1024);
|
sl@0
|
390 |
RDesWriteStream wts;
|
sl@0
|
391 |
|
sl@0
|
392 |
TPtr8 ptr(buf->Des());
|
sl@0
|
393 |
wts.Open(ptr);
|
sl@0
|
394 |
TStreamId id(5);
|
sl@0
|
395 |
wts << id;
|
sl@0
|
396 |
wts.CommitL();
|
sl@0
|
397 |
wts.Close();
|
sl@0
|
398 |
buf->Des().Append(_L8("Ala ma kota a kot ma futro. Futro jest dobre by chronic przed zimnem."));
|
sl@0
|
399 |
RDesReadStream rts;
|
sl@0
|
400 |
ptr.Set(buf->Des());
|
sl@0
|
401 |
rts.Open(ptr);
|
sl@0
|
402 |
|
sl@0
|
403 |
CEmbeddedStore* estor = CEmbeddedStore::FromLC(rts);
|
sl@0
|
404 |
RStoreReadStream rstream;
|
sl@0
|
405 |
rstream.OpenL(*estor, id);
|
sl@0
|
406 |
TStreamPos pos = rstream.Source()->SeekL(MStreamBuf::ERead, 5);
|
sl@0
|
407 |
test(pos.Offset() == 5);
|
sl@0
|
408 |
rts.Close();
|
sl@0
|
409 |
rstream.Close();
|
sl@0
|
410 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
411 |
|
sl@0
|
412 |
test.Next(_L("Calling TEmpty Constructor"));
|
sl@0
|
413 |
TPagedSetToken set2(TBtreeToken::EEmpty);
|
sl@0
|
414 |
test( set2.Count() == 0);
|
sl@0
|
415 |
|
sl@0
|
416 |
test.Next(_L("Set function"));
|
sl@0
|
417 |
set.Set(set2);
|
sl@0
|
418 |
const TPagedSetToken& pst = set.Token();
|
sl@0
|
419 |
test(pst.Count() == set2.Count());
|
sl@0
|
420 |
|
sl@0
|
421 |
test.End();
|
sl@0
|
422 |
CleanupStack::PopAndDestroy();
|
sl@0
|
423 |
}
|
sl@0
|
424 |
|
sl@0
|
425 |
/**
|
sl@0
|
426 |
@SYMTestCaseID PDS-STORE-CT-4065
|
sl@0
|
427 |
@SYMTestCaseDesc TStreamPos tests.
|
sl@0
|
428 |
@SYMTestActions Tests operations provided by TStreamPos class.
|
sl@0
|
429 |
@SYMTestPriority High
|
sl@0
|
430 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
431 |
*/
|
sl@0
|
432 |
void StreamPosTest()
|
sl@0
|
433 |
{
|
sl@0
|
434 |
TStreamPos pos1;
|
sl@0
|
435 |
TStreamPos pos2(5);
|
sl@0
|
436 |
pos1 = pos2;
|
sl@0
|
437 |
test(pos1 == pos2);
|
sl@0
|
438 |
|
sl@0
|
439 |
pos1 = 5 + pos2;
|
sl@0
|
440 |
test(pos1 > pos2);
|
sl@0
|
441 |
test(pos2 < pos1);
|
sl@0
|
442 |
test(pos2 <= pos1);
|
sl@0
|
443 |
test(pos1 != pos2);
|
sl@0
|
444 |
pos1 = pos1 - 5;
|
sl@0
|
445 |
test(pos1 == pos2);
|
sl@0
|
446 |
|
sl@0
|
447 |
pos2 += 0;
|
sl@0
|
448 |
test(pos1 == pos2);
|
sl@0
|
449 |
pos2 -= 0;
|
sl@0
|
450 |
test(pos1 == pos2);
|
sl@0
|
451 |
}
|
sl@0
|
452 |
|
sl@0
|
453 |
struct TTestEntry
|
sl@0
|
454 |
{
|
sl@0
|
455 |
inline TTestEntry() :
|
sl@0
|
456 |
iKey(-1),
|
sl@0
|
457 |
iData(-1)
|
sl@0
|
458 |
{
|
sl@0
|
459 |
}
|
sl@0
|
460 |
inline TTestEntry(TInt aKey, TInt aData) :
|
sl@0
|
461 |
iKey(aKey),
|
sl@0
|
462 |
iData(aData)
|
sl@0
|
463 |
{
|
sl@0
|
464 |
}
|
sl@0
|
465 |
TInt iKey;
|
sl@0
|
466 |
TInt iData;
|
sl@0
|
467 |
};
|
sl@0
|
468 |
|
sl@0
|
469 |
/**
|
sl@0
|
470 |
@SYMTestCaseID PDS-STORE-CT-4066
|
sl@0
|
471 |
@SYMTestCaseDesc TBtreeFix tests.
|
sl@0
|
472 |
@SYMTestActions Tests operations provided by TBtreeFix class.
|
sl@0
|
473 |
@SYMTestPriority High
|
sl@0
|
474 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
475 |
*/
|
sl@0
|
476 |
void BTreeFixTestL()
|
sl@0
|
477 |
{
|
sl@0
|
478 |
CMemPagePool* pool = CMemPagePool::NewLC();
|
sl@0
|
479 |
|
sl@0
|
480 |
TBtreeToken token(TBtreeToken::EEmpty);
|
sl@0
|
481 |
TBool rc = token.IsEmpty();
|
sl@0
|
482 |
test(rc);
|
sl@0
|
483 |
rc = token.IsIntact();
|
sl@0
|
484 |
test(rc);
|
sl@0
|
485 |
|
sl@0
|
486 |
TBtreeFix<TTestEntry, TInt> bentry(token, EBtreeSecure);
|
sl@0
|
487 |
TBtreeKey bkey(sizeof(TInt));
|
sl@0
|
488 |
bentry.Connect(pool, &bkey);
|
sl@0
|
489 |
|
sl@0
|
490 |
TBtreePos bpos;
|
sl@0
|
491 |
rc = bentry.FindL(bpos, 1);
|
sl@0
|
492 |
test(!rc);
|
sl@0
|
493 |
rc = bentry.InsertL(bpos, TTestEntry(1, 101));
|
sl@0
|
494 |
test(rc);
|
sl@0
|
495 |
rc = bentry.FindL(bpos, 1);
|
sl@0
|
496 |
test(rc);
|
sl@0
|
497 |
TTestEntry entry1 = bentry.AtL(bpos);
|
sl@0
|
498 |
test(entry1.iKey == 1 && entry1.iData == 101);
|
sl@0
|
499 |
const void* key = bkey.Key(&entry1);
|
sl@0
|
500 |
TInt keyVal = *((const TInt*)key);
|
sl@0
|
501 |
test.Printf(_L("keyVal=%d\n"), keyVal);
|
sl@0
|
502 |
|
sl@0
|
503 |
rc = bentry.InsertL(bpos, TTestEntry(3, 103));
|
sl@0
|
504 |
test(rc);
|
sl@0
|
505 |
rc = bentry.InsertL(bpos, TTestEntry(2, 102));
|
sl@0
|
506 |
test(rc);
|
sl@0
|
507 |
|
sl@0
|
508 |
rc = bentry.FindL(bpos, 2);
|
sl@0
|
509 |
test(rc);
|
sl@0
|
510 |
TTestEntry entry2;
|
sl@0
|
511 |
bentry.ExtractAtL(bpos, entry2);
|
sl@0
|
512 |
test(entry2.iKey == 2 && entry2.iData == 102);
|
sl@0
|
513 |
|
sl@0
|
514 |
rc = bentry.FindL(bpos, 3);
|
sl@0
|
515 |
test(rc);
|
sl@0
|
516 |
TTestEntry entry3;
|
sl@0
|
517 |
bentry.ExtractAtL(bpos, entry3);
|
sl@0
|
518 |
test(entry3.iKey == 3 && entry3.iData == 103);
|
sl@0
|
519 |
|
sl@0
|
520 |
//==============================================
|
sl@0
|
521 |
|
sl@0
|
522 |
TBtreeMark bmark;
|
sl@0
|
523 |
if(bentry.ResetL(bmark))
|
sl@0
|
524 |
{
|
sl@0
|
525 |
do
|
sl@0
|
526 |
{
|
sl@0
|
527 |
TTestEntry entry = bentry.AtL(bmark);
|
sl@0
|
528 |
test.Printf(_L("AtL(): entry.iKey=%d, entry.iData=%d\n"), entry.iKey, entry.iData);
|
sl@0
|
529 |
bentry.ExtractAtL(bmark, entry);
|
sl@0
|
530 |
test.Printf(_L("ExtractAtL(): entry.iKey=%d, entry.iData=%d\n"), entry.iKey, entry.iData);
|
sl@0
|
531 |
}while(bentry.NextL(bmark));
|
sl@0
|
532 |
}
|
sl@0
|
533 |
|
sl@0
|
534 |
rc = bentry.NextL(bmark);
|
sl@0
|
535 |
test(!rc);
|
sl@0
|
536 |
|
sl@0
|
537 |
//==============================================
|
sl@0
|
538 |
|
sl@0
|
539 |
rc = bentry.DeleteL(2);
|
sl@0
|
540 |
test(rc);
|
sl@0
|
541 |
rc = bentry.FindL(bpos, 2);
|
sl@0
|
542 |
test(!rc);
|
sl@0
|
543 |
rc = bentry.FindL(bpos, 3);
|
sl@0
|
544 |
test(rc);
|
sl@0
|
545 |
TRAPD(err, bentry.DeleteAtL(bpos));
|
sl@0
|
546 |
test(err == KErrNone);
|
sl@0
|
547 |
rc = bentry.FindL(bpos, 3);
|
sl@0
|
548 |
test(!rc);
|
sl@0
|
549 |
|
sl@0
|
550 |
bentry.MarkDirty();
|
sl@0
|
551 |
rc = bentry.IsDirty();
|
sl@0
|
552 |
test(rc);
|
sl@0
|
553 |
bentry.MarkCurrent();
|
sl@0
|
554 |
rc = bentry.IsDirty();
|
sl@0
|
555 |
test(!rc);
|
sl@0
|
556 |
|
sl@0
|
557 |
bentry.ClearL();
|
sl@0
|
558 |
CleanupStack::PopAndDestroy(pool);
|
sl@0
|
559 |
}
|
sl@0
|
560 |
|
sl@0
|
561 |
LOCAL_C void doMainL()
|
sl@0
|
562 |
{
|
sl@0
|
563 |
test.Start(_L("Basic operations"));
|
sl@0
|
564 |
test1L();
|
sl@0
|
565 |
test.Next(_L("Large set TUint32"));
|
sl@0
|
566 |
test2L();
|
sl@0
|
567 |
test.Next(_L("Tokens and streaming"));
|
sl@0
|
568 |
test3L();
|
sl@0
|
569 |
test.Next(_L("Forgotten API"));
|
sl@0
|
570 |
test4L();
|
sl@0
|
571 |
test.Next(_L("@SYMTestCaseID:PDS-STORE-CT-4065: TStreamPos test"));
|
sl@0
|
572 |
StreamPosTest();
|
sl@0
|
573 |
test.Next(_L("@SYMTestCaseID:PDS-STORE-CT-4066: TBtreeFix test"));
|
sl@0
|
574 |
BTreeFixTestL();
|
sl@0
|
575 |
test.End();
|
sl@0
|
576 |
}
|
sl@0
|
577 |
|
sl@0
|
578 |
LOCAL_C void setupCleanup()
|
sl@0
|
579 |
//
|
sl@0
|
580 |
// Initialise the cleanup stack.
|
sl@0
|
581 |
//
|
sl@0
|
582 |
{
|
sl@0
|
583 |
TheTrapCleanup=CTrapCleanup::New();
|
sl@0
|
584 |
test(TheTrapCleanup!=NULL);
|
sl@0
|
585 |
TRAPD(r,\
|
sl@0
|
586 |
{\
|
sl@0
|
587 |
for (TInt i=KTestCleanupStack;i>0;i--)\
|
sl@0
|
588 |
CleanupStack::PushL((TAny*)1);\
|
sl@0
|
589 |
test(r==KErrNone);\
|
sl@0
|
590 |
CleanupStack::Pop(KTestCleanupStack);\
|
sl@0
|
591 |
});
|
sl@0
|
592 |
test(r==KErrNone);
|
sl@0
|
593 |
}
|
sl@0
|
594 |
|
sl@0
|
595 |
GLDEF_C TInt E32Main()
|
sl@0
|
596 |
{
|
sl@0
|
597 |
test.Title();
|
sl@0
|
598 |
setupCleanup();
|
sl@0
|
599 |
__UHEAP_MARK;
|
sl@0
|
600 |
//
|
sl@0
|
601 |
TRAPD(r,doMainL());
|
sl@0
|
602 |
test(r==KErrNone);
|
sl@0
|
603 |
//
|
sl@0
|
604 |
__UHEAP_MARKEND;
|
sl@0
|
605 |
delete TheTrapCleanup;
|
sl@0
|
606 |
test.Close();
|
sl@0
|
607 |
return 0;
|
sl@0
|
608 |
}
|
sl@0
|
609 |
|