sl@0
|
1 |
// Copyright (c) 1995-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 the License "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 |
// e32test\system\t_cobj.cpp
|
sl@0
|
15 |
// Overview:
|
sl@0
|
16 |
// Test CObject, CObjectIx, CObjectCon, CObjectConIx classes
|
sl@0
|
17 |
// API Information:
|
sl@0
|
18 |
// CObject, CObjectIx, CObjectCon, CObjectConIx
|
sl@0
|
19 |
// Details:
|
sl@0
|
20 |
// - Test the CObjectIx class by adding and removing CObject objects
|
sl@0
|
21 |
// in the same order, in reverse order and in random order.
|
sl@0
|
22 |
// - Test adding many CObject objects to a CObjectConIx and test that
|
sl@0
|
23 |
// the returned handle is as expected.
|
sl@0
|
24 |
// - Perform a speed test on CObjectCon for both named and unnamed
|
sl@0
|
25 |
// objects.
|
sl@0
|
26 |
// - Check that the CObject, CObjectCon, CObjectIx and CObjectConIx methods
|
sl@0
|
27 |
// are in the DLL by calling each one.
|
sl@0
|
28 |
// - Test the CObject, CObjectCon, CObjectIx and CObjectConIx methods and
|
sl@0
|
29 |
// verify the results are as expected.
|
sl@0
|
30 |
// - Test all the objects together: create two containers, find objects by
|
sl@0
|
31 |
// name in a variety of ways, delete objects and verify the results are
|
sl@0
|
32 |
// as expected.
|
sl@0
|
33 |
// Platforms/Drives/Compatibility:
|
sl@0
|
34 |
// All.
|
sl@0
|
35 |
// Assumptions/Requirement/Pre-requisites:
|
sl@0
|
36 |
// Failures and causes:
|
sl@0
|
37 |
// Base Port information:
|
sl@0
|
38 |
//
|
sl@0
|
39 |
//
|
sl@0
|
40 |
|
sl@0
|
41 |
#include <e32std.h>
|
sl@0
|
42 |
#include <e32std_private.h>
|
sl@0
|
43 |
#include <e32base.h>
|
sl@0
|
44 |
#include <e32base_private.h>
|
sl@0
|
45 |
#include <e32test.h>
|
sl@0
|
46 |
#include <e32svr.h>
|
sl@0
|
47 |
#include <e32ver.h>
|
sl@0
|
48 |
#include "../misc/prbs.h"
|
sl@0
|
49 |
|
sl@0
|
50 |
struct TCObjectDump
|
sl@0
|
51 |
{
|
sl@0
|
52 |
TInt iAccessCount;
|
sl@0
|
53 |
CObject* iOwner;
|
sl@0
|
54 |
CObjectCon* iContainer;
|
sl@0
|
55 |
HBufC* iName;
|
sl@0
|
56 |
};
|
sl@0
|
57 |
|
sl@0
|
58 |
void CObject::__DbgTest(void* pCObjectDump) const
|
sl@0
|
59 |
{
|
sl@0
|
60 |
((TCObjectDump*)pCObjectDump)->iAccessCount=iAccessCount;
|
sl@0
|
61 |
((TCObjectDump*)pCObjectDump)->iOwner=iOwner;
|
sl@0
|
62 |
((TCObjectDump*)pCObjectDump)->iContainer=iContainer;
|
sl@0
|
63 |
((TCObjectDump*)pCObjectDump)->iName=iName;
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
LOCAL_D RTest test(_L("T_COBJ"));
|
sl@0
|
67 |
LOCAL_D TName gName;
|
sl@0
|
68 |
LOCAL_D TName gName1;
|
sl@0
|
69 |
LOCAL_D TName gName2;
|
sl@0
|
70 |
LOCAL_D TFullName gFullName;
|
sl@0
|
71 |
LOCAL_D TFullName gFullName1;
|
sl@0
|
72 |
LOCAL_D TFullName gFullName2;
|
sl@0
|
73 |
|
sl@0
|
74 |
class RTestHeap : public RAllocator
|
sl@0
|
75 |
{
|
sl@0
|
76 |
public:
|
sl@0
|
77 |
enum TOp {EOpNone=0, EOpAlloc=1, EOpFree=2, EOpReAlloc=3};
|
sl@0
|
78 |
|
sl@0
|
79 |
struct TOpInfo
|
sl@0
|
80 |
{
|
sl@0
|
81 |
TInt iOp;
|
sl@0
|
82 |
TAny* iPtrArg;
|
sl@0
|
83 |
TInt iIntArg;
|
sl@0
|
84 |
TAny* iResult;
|
sl@0
|
85 |
};
|
sl@0
|
86 |
public:
|
sl@0
|
87 |
static RTestHeap* Install();
|
sl@0
|
88 |
void Uninstall();
|
sl@0
|
89 |
TInt GetLastOp(TOpInfo& aInfo);
|
sl@0
|
90 |
virtual TAny* Alloc(TInt aSize);
|
sl@0
|
91 |
virtual void Free(TAny* aPtr);
|
sl@0
|
92 |
virtual TAny* ReAlloc(TAny* aPtr, TInt aSize, TInt aMode);
|
sl@0
|
93 |
virtual TInt AllocLen(const TAny* aCell) const;
|
sl@0
|
94 |
virtual TInt Compress();
|
sl@0
|
95 |
virtual void Reset();
|
sl@0
|
96 |
virtual TInt AllocSize(TInt& aTotalAllocSize) const;
|
sl@0
|
97 |
virtual TInt Available(TInt& aBiggestBlock) const;
|
sl@0
|
98 |
virtual TInt DebugFunction(TInt aFunc, TAny* a1, TAny* a2);
|
sl@0
|
99 |
public:
|
sl@0
|
100 |
RAllocator* iA;
|
sl@0
|
101 |
TOpInfo iLastOp;
|
sl@0
|
102 |
};
|
sl@0
|
103 |
|
sl@0
|
104 |
RTestHeap* RTestHeap::Install()
|
sl@0
|
105 |
{
|
sl@0
|
106 |
RTestHeap* p = new RTestHeap;
|
sl@0
|
107 |
test(p!=0);
|
sl@0
|
108 |
p->iA = &User::Heap();
|
sl@0
|
109 |
p->iLastOp.iOp = EOpNone;
|
sl@0
|
110 |
User::SwitchHeap(p);
|
sl@0
|
111 |
return p;
|
sl@0
|
112 |
}
|
sl@0
|
113 |
|
sl@0
|
114 |
void RTestHeap::Uninstall()
|
sl@0
|
115 |
{
|
sl@0
|
116 |
User::SwitchHeap(iA);
|
sl@0
|
117 |
delete this;
|
sl@0
|
118 |
}
|
sl@0
|
119 |
|
sl@0
|
120 |
TInt RTestHeap::GetLastOp(RTestHeap::TOpInfo& aInfo)
|
sl@0
|
121 |
{
|
sl@0
|
122 |
memcpy(&aInfo, &iLastOp, sizeof(TOpInfo));
|
sl@0
|
123 |
iLastOp.iOp = EOpNone;
|
sl@0
|
124 |
return (aInfo.iOp == EOpNone) ? KErrNotFound : KErrNone;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
TAny* RTestHeap::Alloc(TInt aSize)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
TAny* p = iA->Alloc(aSize);
|
sl@0
|
130 |
iLastOp.iOp = EOpAlloc;
|
sl@0
|
131 |
iLastOp.iPtrArg = 0;
|
sl@0
|
132 |
iLastOp.iIntArg = aSize;
|
sl@0
|
133 |
iLastOp.iResult = p;
|
sl@0
|
134 |
return p;
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
void RTestHeap::Free(TAny* aPtr)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
iLastOp.iOp = EOpFree;
|
sl@0
|
140 |
iLastOp.iPtrArg = aPtr;
|
sl@0
|
141 |
iLastOp.iIntArg = 0;
|
sl@0
|
142 |
iLastOp.iResult = 0;
|
sl@0
|
143 |
iA->Free(aPtr);
|
sl@0
|
144 |
}
|
sl@0
|
145 |
|
sl@0
|
146 |
TAny* RTestHeap::ReAlloc(TAny* aPtr, TInt aSize, TInt aMode=0)
|
sl@0
|
147 |
{
|
sl@0
|
148 |
TAny* p = iA->ReAlloc(aPtr,aSize,aMode);
|
sl@0
|
149 |
iLastOp.iOp = EOpReAlloc;
|
sl@0
|
150 |
iLastOp.iPtrArg = aPtr;
|
sl@0
|
151 |
iLastOp.iIntArg = aSize;
|
sl@0
|
152 |
iLastOp.iResult = p;
|
sl@0
|
153 |
return p;
|
sl@0
|
154 |
}
|
sl@0
|
155 |
|
sl@0
|
156 |
TInt RTestHeap::AllocLen(const TAny* aCell) const
|
sl@0
|
157 |
{
|
sl@0
|
158 |
TInt l = iA->AllocLen(aCell);
|
sl@0
|
159 |
return l;
|
sl@0
|
160 |
}
|
sl@0
|
161 |
|
sl@0
|
162 |
TInt RTestHeap::Compress()
|
sl@0
|
163 |
{
|
sl@0
|
164 |
TInt l = iA->Compress();
|
sl@0
|
165 |
return l;
|
sl@0
|
166 |
}
|
sl@0
|
167 |
|
sl@0
|
168 |
void RTestHeap::Reset()
|
sl@0
|
169 |
{
|
sl@0
|
170 |
iA->Reset();
|
sl@0
|
171 |
}
|
sl@0
|
172 |
|
sl@0
|
173 |
TInt RTestHeap::AllocSize(TInt& aTotalAllocSize) const
|
sl@0
|
174 |
{
|
sl@0
|
175 |
TInt s;
|
sl@0
|
176 |
TInt r = iA->AllocSize(s);
|
sl@0
|
177 |
aTotalAllocSize = s;
|
sl@0
|
178 |
return r;
|
sl@0
|
179 |
}
|
sl@0
|
180 |
|
sl@0
|
181 |
TInt RTestHeap::Available(TInt& aBiggestBlock) const
|
sl@0
|
182 |
{
|
sl@0
|
183 |
TInt s;
|
sl@0
|
184 |
TInt r = iA->Available(s);
|
sl@0
|
185 |
aBiggestBlock = s;
|
sl@0
|
186 |
return r;
|
sl@0
|
187 |
}
|
sl@0
|
188 |
|
sl@0
|
189 |
TInt RTestHeap::DebugFunction(TInt aFunc, TAny* a1=NULL, TAny* a2=NULL)
|
sl@0
|
190 |
{
|
sl@0
|
191 |
TInt r = iA->DebugFunction(aFunc, a1, a2);
|
sl@0
|
192 |
return r;
|
sl@0
|
193 |
}
|
sl@0
|
194 |
|
sl@0
|
195 |
|
sl@0
|
196 |
|
sl@0
|
197 |
|
sl@0
|
198 |
class TestCObjects
|
sl@0
|
199 |
{
|
sl@0
|
200 |
public:
|
sl@0
|
201 |
void Test1(void);
|
sl@0
|
202 |
void Test2(void);
|
sl@0
|
203 |
void Test3(void);
|
sl@0
|
204 |
void Test4(void);
|
sl@0
|
205 |
void Test5(void);
|
sl@0
|
206 |
void Test6(void);
|
sl@0
|
207 |
void Test7(void);
|
sl@0
|
208 |
void Test8(void);
|
sl@0
|
209 |
private:
|
sl@0
|
210 |
static void GetObjName(TName& aDest,const CObject& aObj);
|
sl@0
|
211 |
static void GetObjFullName(TFullName& aDest,const CObject& aObj);
|
sl@0
|
212 |
};
|
sl@0
|
213 |
|
sl@0
|
214 |
|
sl@0
|
215 |
GLDEF_C void TestCObjects::Test1(void)
|
sl@0
|
216 |
{
|
sl@0
|
217 |
// Check CObject methods are in the DLL
|
sl@0
|
218 |
CObject* pCObject=new CObject;
|
sl@0
|
219 |
CObject* temp=new CObject;
|
sl@0
|
220 |
|
sl@0
|
221 |
pCObject->Open();
|
sl@0
|
222 |
pCObject->Close();
|
sl@0
|
223 |
gName=pCObject->Name();
|
sl@0
|
224 |
TPtrC aDesR(_S("a name"));
|
sl@0
|
225 |
pCObject->SetName(&aDesR);
|
sl@0
|
226 |
pCObject->SetNameL(&aDesR);
|
sl@0
|
227 |
gFullName=pCObject->FullName();
|
sl@0
|
228 |
pCObject->Owner();
|
sl@0
|
229 |
pCObject->SetOwner(temp);
|
sl@0
|
230 |
pCObject->Close(); // deletes object when iAccessCount==0
|
sl@0
|
231 |
temp->Close();
|
sl@0
|
232 |
}
|
sl@0
|
233 |
|
sl@0
|
234 |
GLDEF_C void TestCObjects::Test2(void)
|
sl@0
|
235 |
{
|
sl@0
|
236 |
// Check CObjectCon methods are in the DLL
|
sl@0
|
237 |
CObjectCon* pCObjectCon=CObjectCon::NewL();
|
sl@0
|
238 |
CObject* pCObject=new CObject;
|
sl@0
|
239 |
TInt aFindHandle=0;
|
sl@0
|
240 |
|
sl@0
|
241 |
pCObjectCon->AddL(pCObject);
|
sl@0
|
242 |
pCObjectCon->At(aFindHandle);
|
sl@0
|
243 |
User::ValidateName(_L("a name"));
|
sl@0
|
244 |
pCObjectCon->CheckUniqueFullName(pCObject, _L("a name"));
|
sl@0
|
245 |
pCObjectCon->FindByName(aFindHandle, _L("a name"), gName);
|
sl@0
|
246 |
pCObjectCon->FindByFullName(aFindHandle, _L("a Name"), gFullName);
|
sl@0
|
247 |
pCObjectCon->UniqueID();
|
sl@0
|
248 |
pCObjectCon->Count();
|
sl@0
|
249 |
pCObjectCon->Remove(pCObject);
|
sl@0
|
250 |
pCObject->Close();
|
sl@0
|
251 |
delete pCObjectCon;
|
sl@0
|
252 |
}
|
sl@0
|
253 |
|
sl@0
|
254 |
GLDEF_C void TestCObjects::Test3(void)
|
sl@0
|
255 |
{
|
sl@0
|
256 |
// Check the CObjectIx methods are in the DLL
|
sl@0
|
257 |
CObjectIx* pCObjectIx=CObjectIx::NewL();
|
sl@0
|
258 |
pCObjectIx->Count();
|
sl@0
|
259 |
test(pCObjectIx->At(0)==NULL);
|
sl@0
|
260 |
delete pCObjectIx;
|
sl@0
|
261 |
pCObjectIx=CObjectIx::NewL();
|
sl@0
|
262 |
test(pCObjectIx->Count()==0);
|
sl@0
|
263 |
CObjectConIx* pCObjectConIx=CObjectConIx::NewL();
|
sl@0
|
264 |
delete pCObjectConIx;
|
sl@0
|
265 |
pCObjectConIx=CObjectConIx::NewL();
|
sl@0
|
266 |
CObjectCon* pCObjectCon=pCObjectConIx->CreateL();
|
sl@0
|
267 |
test(pCObjectCon->Count()==0);
|
sl@0
|
268 |
CObject* pCObject= new CObject;
|
sl@0
|
269 |
test(pCObject!=NULL);
|
sl@0
|
270 |
|
sl@0
|
271 |
TInt find;
|
sl@0
|
272 |
TName name;
|
sl@0
|
273 |
TInt r=pCObjectCon->FindByName(find,_L("Name"),name);
|
sl@0
|
274 |
test(r==KErrNotFound);
|
sl@0
|
275 |
TFullName fullName;
|
sl@0
|
276 |
r=pCObjectCon->FindByFullName(find,_L("Full Name"),fullName);
|
sl@0
|
277 |
test(r==KErrNotFound);
|
sl@0
|
278 |
|
sl@0
|
279 |
|
sl@0
|
280 |
pCObjectCon->AddL(pCObject);
|
sl@0
|
281 |
test(pCObjectCon->Count()==1);
|
sl@0
|
282 |
test(pCObjectIx->Count(pCObject)==0);
|
sl@0
|
283 |
pCObjectIx->AddL(pCObject);
|
sl@0
|
284 |
test(pCObjectIx->Count(pCObject)==1);
|
sl@0
|
285 |
pCObjectIx->Count();
|
sl@0
|
286 |
pCObjectIx->At(0, 0);
|
sl@0
|
287 |
pCObjectIx->At(0);
|
sl@0
|
288 |
// pCObjectIx->Remove(0);
|
sl@0
|
289 |
delete pCObjectIx;
|
sl@0
|
290 |
delete pCObjectConIx;
|
sl@0
|
291 |
// delete pCObjectCon;
|
sl@0
|
292 |
// pCObject->Close();
|
sl@0
|
293 |
}
|
sl@0
|
294 |
|
sl@0
|
295 |
GLDEF_C void TestCObjects::Test4(void)
|
sl@0
|
296 |
{
|
sl@0
|
297 |
// Check CObjectConIx methods are in the DLL
|
sl@0
|
298 |
CObjectConIx* pCObjectConIx=CObjectConIx::NewL();
|
sl@0
|
299 |
CObjectCon* pCObjectCon=pCObjectConIx->CreateL();
|
sl@0
|
300 |
pCObjectConIx->Lookup(0);
|
sl@0
|
301 |
pCObjectConIx->Remove(pCObjectCon);
|
sl@0
|
302 |
delete pCObjectConIx;
|
sl@0
|
303 |
}
|
sl@0
|
304 |
|
sl@0
|
305 |
GLDEF_C void TestCObjects::Test5(void)
|
sl@0
|
306 |
{
|
sl@0
|
307 |
// Test the methods of the CObject class
|
sl@0
|
308 |
TCObjectDump CObjectDump;
|
sl@0
|
309 |
CObject* a=new CObject;
|
sl@0
|
310 |
CObject* b=new CObject;
|
sl@0
|
311 |
a->__DbgTest(&CObjectDump);
|
sl@0
|
312 |
test(CObjectDump.iAccessCount==1 && CObjectDump.iOwner==NULL && CObjectDump.iContainer==NULL);
|
sl@0
|
313 |
a->Open();
|
sl@0
|
314 |
a->__DbgTest(&CObjectDump);
|
sl@0
|
315 |
test(CObjectDump.iAccessCount==2);
|
sl@0
|
316 |
a->Close();
|
sl@0
|
317 |
a->__DbgTest(&CObjectDump);
|
sl@0
|
318 |
test(CObjectDump.iAccessCount==1);
|
sl@0
|
319 |
TPtrC aDesR(_L("aName"));
|
sl@0
|
320 |
a->SetName(&aDesR);
|
sl@0
|
321 |
gName=a->Name();
|
sl@0
|
322 |
test(gName==_L("aName"));
|
sl@0
|
323 |
gFullName=a->FullName();
|
sl@0
|
324 |
test(gFullName==_L("aName"));
|
sl@0
|
325 |
TPtrC aDesR2(_L("Owner"));
|
sl@0
|
326 |
b->SetName(&aDesR2);
|
sl@0
|
327 |
a->SetOwner(b);
|
sl@0
|
328 |
test(a->Owner()==b);
|
sl@0
|
329 |
gFullName=a->FullName();
|
sl@0
|
330 |
test(gFullName==_L("Owner::aName"));
|
sl@0
|
331 |
a->Close(); // Calls the destructor via the call to delete
|
sl@0
|
332 |
// To Do: set iContainer to something then call Close()
|
sl@0
|
333 |
}
|
sl@0
|
334 |
|
sl@0
|
335 |
|
sl@0
|
336 |
GLDEF_C void TestCObjects::Test6(void)
|
sl@0
|
337 |
{
|
sl@0
|
338 |
// Test the methods of CObjectCon
|
sl@0
|
339 |
TCObjectDump dump1, dump2;
|
sl@0
|
340 |
TInt aFindHandle=0;
|
sl@0
|
341 |
CObject *pObj1=new CObject,
|
sl@0
|
342 |
*pObj2=new CObject,
|
sl@0
|
343 |
*pObj3=new CObject,
|
sl@0
|
344 |
*temp;
|
sl@0
|
345 |
CObjectCon* pCon=CObjectCon::NewL();
|
sl@0
|
346 |
|
sl@0
|
347 |
test(User::ValidateName(_L("xxx*xxx"))==KErrBadName);
|
sl@0
|
348 |
test(User::ValidateName(_L("xxx?xxx"))==KErrBadName);
|
sl@0
|
349 |
test(User::ValidateName(_L("xxx:xxx"))==KErrBadName);
|
sl@0
|
350 |
test(User::ValidateName(_L("xxxxxxx"))==KErrNone);
|
sl@0
|
351 |
|
sl@0
|
352 |
TPtrC name1(_S("Obj1")), name2(_S("Obj2")), name3(_S("Owner"));
|
sl@0
|
353 |
pObj1->SetName(&name1);
|
sl@0
|
354 |
pObj2->SetName(&name2);
|
sl@0
|
355 |
pObj3->SetName(&name3);
|
sl@0
|
356 |
|
sl@0
|
357 |
test(pCon->Count()==0);
|
sl@0
|
358 |
pCon->AddL(pObj1);
|
sl@0
|
359 |
test(pCon->Count()==1);
|
sl@0
|
360 |
pCon->AddL(pObj2);
|
sl@0
|
361 |
test(pCon->Count()==2);
|
sl@0
|
362 |
|
sl@0
|
363 |
aFindHandle=0;
|
sl@0
|
364 |
test(pCon->FindByName(aFindHandle, _L("xxx"), gName)==KErrNotFound);
|
sl@0
|
365 |
aFindHandle=0;
|
sl@0
|
366 |
GetObjName(gName1,*pObj1);
|
sl@0
|
367 |
test(pCon->FindByName(aFindHandle, gName1, gName)==KErrNone);
|
sl@0
|
368 |
test(aFindHandle==0);
|
sl@0
|
369 |
aFindHandle=2;
|
sl@0
|
370 |
GetObjName(gName1,*pObj1);
|
sl@0
|
371 |
test(pCon->FindByName(aFindHandle, gName1, gName)==KErrNotFound);
|
sl@0
|
372 |
aFindHandle=0;
|
sl@0
|
373 |
GetObjName(gName1,*pObj2);
|
sl@0
|
374 |
test(pCon->FindByName(aFindHandle, gName1, gName)==KErrNone);
|
sl@0
|
375 |
test(aFindHandle==1);
|
sl@0
|
376 |
|
sl@0
|
377 |
aFindHandle=0;
|
sl@0
|
378 |
test(pCon->FindByFullName(aFindHandle, _L("xxx"), gFullName)==KErrNotFound);
|
sl@0
|
379 |
aFindHandle=0;
|
sl@0
|
380 |
GetObjName(gName1,*pObj1);
|
sl@0
|
381 |
test(pCon->FindByFullName(aFindHandle, gName1, gFullName)==KErrNone);
|
sl@0
|
382 |
test(aFindHandle==0);
|
sl@0
|
383 |
GetObjName(gName1,*pObj2);
|
sl@0
|
384 |
test(pCon->FindByFullName(aFindHandle, gName1, gFullName)==KErrNone);
|
sl@0
|
385 |
test(aFindHandle==1);
|
sl@0
|
386 |
|
sl@0
|
387 |
pObj1->SetOwner(pObj3);
|
sl@0
|
388 |
pObj2->SetOwner(pObj3);
|
sl@0
|
389 |
aFindHandle=0;
|
sl@0
|
390 |
test(pCon->FindByFullName(aFindHandle, _L("xxx"), gFullName)==KErrNotFound);
|
sl@0
|
391 |
aFindHandle=0;
|
sl@0
|
392 |
GetObjFullName(gFullName1,*pObj1);
|
sl@0
|
393 |
test(pCon->FindByFullName(aFindHandle, gFullName1, gFullName)==KErrNone);
|
sl@0
|
394 |
test(aFindHandle==0);
|
sl@0
|
395 |
GetObjFullName(gFullName1,*pObj2);
|
sl@0
|
396 |
test(pCon->FindByFullName(aFindHandle, gFullName1, gFullName)==KErrNone);
|
sl@0
|
397 |
test(aFindHandle==1);
|
sl@0
|
398 |
|
sl@0
|
399 |
|
sl@0
|
400 |
test(pCon->CheckUniqueFullName(pObj3, _L("aname"))==KErrNone);
|
sl@0
|
401 |
GetObjName(gName1,*pObj1);
|
sl@0
|
402 |
test(pCon->CheckUniqueFullName(pObj3, gName1)==KErrAlreadyExists);
|
sl@0
|
403 |
pCon->Remove(pObj1);
|
sl@0
|
404 |
test(pCon->CheckUniqueFullName(pObj3, gName1)==KErrNone);
|
sl@0
|
405 |
test(pCon->Count()==1);
|
sl@0
|
406 |
pCon->AddL(pObj3);
|
sl@0
|
407 |
test(pCon->Count()==2);
|
sl@0
|
408 |
aFindHandle=0;
|
sl@0
|
409 |
test(pCon->FindByName(aFindHandle, gName1, gName)==KErrNotFound);
|
sl@0
|
410 |
aFindHandle=0;
|
sl@0
|
411 |
GetObjFullName(gFullName1,*pObj1);
|
sl@0
|
412 |
test(pCon->FindByFullName(aFindHandle, gFullName1, gFullName)==KErrNotFound);
|
sl@0
|
413 |
aFindHandle=0;
|
sl@0
|
414 |
GetObjName(gName1,*pObj2);
|
sl@0
|
415 |
test(pCon->FindByName(aFindHandle, gName1, gName)==KErrNone);
|
sl@0
|
416 |
test(aFindHandle==0);
|
sl@0
|
417 |
GetObjFullName(gFullName1,*pObj2);
|
sl@0
|
418 |
test(pCon->FindByFullName(aFindHandle, gFullName1, gFullName)==KErrNone);
|
sl@0
|
419 |
test(aFindHandle==0);
|
sl@0
|
420 |
GetObjName(gName1,*pObj3);
|
sl@0
|
421 |
test(pCon->FindByName(aFindHandle, gName1, gName)==KErrNone);
|
sl@0
|
422 |
test(aFindHandle==1);
|
sl@0
|
423 |
aFindHandle=0;
|
sl@0
|
424 |
test(pCon->FindByFullName(aFindHandle, _L("Owner"), gFullName)==KErrNone);
|
sl@0
|
425 |
test(aFindHandle==1);
|
sl@0
|
426 |
|
sl@0
|
427 |
|
sl@0
|
428 |
pObj2->__DbgTest(&dump1);
|
sl@0
|
429 |
temp=pCon->At(0);
|
sl@0
|
430 |
temp->__DbgTest(&dump2);
|
sl@0
|
431 |
test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner &&
|
sl@0
|
432 |
dump1.iName==dump2.iName &&dump1.iContainer==dump2.iContainer);
|
sl@0
|
433 |
pObj3->__DbgTest(&dump1);
|
sl@0
|
434 |
temp=pCon->At(1);
|
sl@0
|
435 |
temp->__DbgTest(&dump2);
|
sl@0
|
436 |
test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner &&
|
sl@0
|
437 |
dump1.iName==dump2.iName &&dump1.iContainer==dump2.iContainer);
|
sl@0
|
438 |
|
sl@0
|
439 |
pCon->Remove(pObj2);
|
sl@0
|
440 |
pCon->Remove(pObj3);
|
sl@0
|
441 |
test(pCon->Count()==0);
|
sl@0
|
442 |
delete pCon;
|
sl@0
|
443 |
|
sl@0
|
444 |
// Test expansion and shrinking
|
sl@0
|
445 |
__UHEAP_MARK;
|
sl@0
|
446 |
pCon=CObjectCon::NewL();
|
sl@0
|
447 |
CObject** obj = new CObject*[2048];
|
sl@0
|
448 |
test(obj!=0);
|
sl@0
|
449 |
TInt i;
|
sl@0
|
450 |
for (i=0; i<2048; ++i)
|
sl@0
|
451 |
{
|
sl@0
|
452 |
obj[i] = new CObject;
|
sl@0
|
453 |
test(obj[i] != 0);
|
sl@0
|
454 |
}
|
sl@0
|
455 |
|
sl@0
|
456 |
RTestHeap* h = RTestHeap::Install();
|
sl@0
|
457 |
|
sl@0
|
458 |
const TInt xov_values[] = {0,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048};
|
sl@0
|
459 |
const TInt xov2_values[] = {1472, 960, 704, 448, 320, 192, 128, 96, 64, 48, 32, 24, 16, 12, 8, 6, 0};
|
sl@0
|
460 |
const TInt* xov_ptr = xov_values;
|
sl@0
|
461 |
const TInt* xov2_ptr = xov2_values;
|
sl@0
|
462 |
TInt sz = 0;
|
sl@0
|
463 |
TInt xov = 0;
|
sl@0
|
464 |
TAny* ptr = 0;
|
sl@0
|
465 |
for (i=1; i<=2048; ++i)
|
sl@0
|
466 |
{
|
sl@0
|
467 |
pCon->AddL(obj[i-1]);
|
sl@0
|
468 |
test(pCon->Count()==i);
|
sl@0
|
469 |
RTestHeap::TOpInfo opi;
|
sl@0
|
470 |
TInt r = h->GetLastOp(opi);
|
sl@0
|
471 |
if (i*4 <= sz)
|
sl@0
|
472 |
{
|
sl@0
|
473 |
test(r==KErrNotFound);
|
sl@0
|
474 |
continue;
|
sl@0
|
475 |
}
|
sl@0
|
476 |
test(r==KErrNone);
|
sl@0
|
477 |
test.Printf(_L("Realloc at %d -> %d\n"), i, opi.iIntArg);
|
sl@0
|
478 |
test(i-1 == xov);
|
sl@0
|
479 |
test(opi.iOp == RTestHeap::EOpReAlloc);
|
sl@0
|
480 |
test(opi.iPtrArg == ptr);
|
sl@0
|
481 |
// recalc xov
|
sl@0
|
482 |
xov = *++xov_ptr;
|
sl@0
|
483 |
test(opi.iIntArg == xov*4);
|
sl@0
|
484 |
sz = xov*4;
|
sl@0
|
485 |
test(opi.iResult != 0);
|
sl@0
|
486 |
ptr = opi.iResult;
|
sl@0
|
487 |
}
|
sl@0
|
488 |
|
sl@0
|
489 |
xov = *xov2_ptr;
|
sl@0
|
490 |
for (i=2047; i>=0; --i)
|
sl@0
|
491 |
{
|
sl@0
|
492 |
pCon->Remove(obj[i]);
|
sl@0
|
493 |
test(pCon->Count()==i);
|
sl@0
|
494 |
RTestHeap::TOpInfo opi;
|
sl@0
|
495 |
TInt r = h->GetLastOp(opi);
|
sl@0
|
496 |
if (i>xov)
|
sl@0
|
497 |
{
|
sl@0
|
498 |
test(r==KErrNotFound);
|
sl@0
|
499 |
continue;
|
sl@0
|
500 |
}
|
sl@0
|
501 |
test(r==KErrNone);
|
sl@0
|
502 |
test.Printf(_L("Realloc at %d -> %d\n"), i, opi.iIntArg);
|
sl@0
|
503 |
test(i == xov);
|
sl@0
|
504 |
if (i==0)
|
sl@0
|
505 |
{
|
sl@0
|
506 |
test(opi.iOp == RTestHeap::EOpReAlloc || opi.iOp == RTestHeap::EOpFree);
|
sl@0
|
507 |
}
|
sl@0
|
508 |
else
|
sl@0
|
509 |
{
|
sl@0
|
510 |
test(opi.iOp = RTestHeap::EOpReAlloc);
|
sl@0
|
511 |
test(opi.iResult == ptr);
|
sl@0
|
512 |
}
|
sl@0
|
513 |
test(opi.iPtrArg == ptr);
|
sl@0
|
514 |
// recalc xov
|
sl@0
|
515 |
xov = *++xov2_ptr;
|
sl@0
|
516 |
sz = *--xov_ptr;
|
sl@0
|
517 |
test(opi.iIntArg == sz*4);
|
sl@0
|
518 |
}
|
sl@0
|
519 |
|
sl@0
|
520 |
delete pCon;
|
sl@0
|
521 |
for (i=0; i<2048; ++i)
|
sl@0
|
522 |
obj[i]->Close();
|
sl@0
|
523 |
delete[] obj;
|
sl@0
|
524 |
h->Uninstall();
|
sl@0
|
525 |
__UHEAP_MARKEND;
|
sl@0
|
526 |
}
|
sl@0
|
527 |
|
sl@0
|
528 |
|
sl@0
|
529 |
GLDEF_C void TestCObjects::Test7(void)
|
sl@0
|
530 |
{
|
sl@0
|
531 |
// Test the methods of CObjectIx
|
sl@0
|
532 |
|
sl@0
|
533 |
// Before an object can be added to a ConIx it first has to be added to a container because the
|
sl@0
|
534 |
// CObjectIx::Add method references theObject->iContainer->iName. But theObject->iContainer field
|
sl@0
|
535 |
// is only set (within the CObjectCon::Add method) IF the container has first been created by the
|
sl@0
|
536 |
// CObjectConIx::Create method, otherwise it is NULL and adding it to a CObjectIx will fail.
|
sl@0
|
537 |
CObjectIx *pIx=CObjectIx::NewL();
|
sl@0
|
538 |
CObjectConIx *pConIx=CObjectConIx::NewL();
|
sl@0
|
539 |
CObjectCon *pCon1=pConIx->CreateL(),
|
sl@0
|
540 |
*pCon2=pConIx->CreateL();
|
sl@0
|
541 |
CObject *pObj1=new CObject,
|
sl@0
|
542 |
*pObj2=new CObject,
|
sl@0
|
543 |
*pObj3=new CObject,
|
sl@0
|
544 |
*temp;
|
sl@0
|
545 |
TInt aHandle1, aHandle2, aHandle3;
|
sl@0
|
546 |
TCObjectDump dump1, dump2;
|
sl@0
|
547 |
TPtrC name1(_S("Obj1")), name2(_S("Obj2")), name3(_S("Obj3"));
|
sl@0
|
548 |
|
sl@0
|
549 |
// Create two containers with Obj1 and Obj2 in the first and Obj3 in the second
|
sl@0
|
550 |
pObj1->SetName(&name1);
|
sl@0
|
551 |
pObj2->SetName(&name2);
|
sl@0
|
552 |
pObj3->SetName(&name3);
|
sl@0
|
553 |
pCon1->AddL(pObj1);
|
sl@0
|
554 |
pCon1->AddL(pObj2);
|
sl@0
|
555 |
pCon2->AddL(pObj3);
|
sl@0
|
556 |
aHandle1=pIx->AddL(pObj1);
|
sl@0
|
557 |
aHandle2=pIx->AddL(pObj2);
|
sl@0
|
558 |
aHandle3=pIx->AddL(pObj3);
|
sl@0
|
559 |
// At(TInt aHandle)
|
sl@0
|
560 |
pObj1->__DbgTest(&dump1);
|
sl@0
|
561 |
temp=pIx->At(aHandle1);
|
sl@0
|
562 |
temp->__DbgTest(&dump2);
|
sl@0
|
563 |
test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner &&
|
sl@0
|
564 |
dump1.iContainer==dump2.iContainer && dump1.iName==dump2.iName);
|
sl@0
|
565 |
pObj2->__DbgTest(&dump1);
|
sl@0
|
566 |
temp=pIx->At(aHandle2);
|
sl@0
|
567 |
temp->__DbgTest(&dump2);
|
sl@0
|
568 |
test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner &&
|
sl@0
|
569 |
dump1.iContainer==dump2.iContainer && dump1.iName==dump2.iName);
|
sl@0
|
570 |
pObj3->__DbgTest(&dump1);
|
sl@0
|
571 |
temp=pIx->At(aHandle3);
|
sl@0
|
572 |
temp->__DbgTest(&dump2);
|
sl@0
|
573 |
test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner &&
|
sl@0
|
574 |
dump1.iContainer==dump2.iContainer && dump1.iName==dump2.iName);
|
sl@0
|
575 |
// At(TInt aHandle, TInt aUniqueID);
|
sl@0
|
576 |
pObj1->__DbgTest(&dump1);
|
sl@0
|
577 |
temp=pIx->At(aHandle1, 1);
|
sl@0
|
578 |
temp->__DbgTest(&dump2);
|
sl@0
|
579 |
test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner &&
|
sl@0
|
580 |
dump1.iContainer==dump2.iContainer && dump1.iName==dump2.iName);
|
sl@0
|
581 |
pObj2->__DbgTest(&dump1);
|
sl@0
|
582 |
temp=pIx->At(aHandle2, 1);
|
sl@0
|
583 |
temp->__DbgTest(&dump2);
|
sl@0
|
584 |
test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner &&
|
sl@0
|
585 |
dump1.iContainer==dump2.iContainer && dump1.iName==dump2.iName);
|
sl@0
|
586 |
pObj3->__DbgTest(&dump1);
|
sl@0
|
587 |
temp=pIx->At(aHandle3, 2);
|
sl@0
|
588 |
temp->__DbgTest(&dump2);
|
sl@0
|
589 |
test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner &&
|
sl@0
|
590 |
dump1.iContainer==dump2.iContainer && dump1.iName==dump2.iName);
|
sl@0
|
591 |
// Remove(Tint aHandle)
|
sl@0
|
592 |
pIx->Remove(aHandle2);
|
sl@0
|
593 |
pObj1->__DbgTest(&dump1);
|
sl@0
|
594 |
temp=pIx->At(aHandle1);
|
sl@0
|
595 |
temp->__DbgTest(&dump2);
|
sl@0
|
596 |
test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner &&
|
sl@0
|
597 |
dump1.iContainer==dump2.iContainer && dump1.iName==dump2.iName);
|
sl@0
|
598 |
pObj3->__DbgTest(&dump1);
|
sl@0
|
599 |
temp=pIx->At(aHandle3);
|
sl@0
|
600 |
temp->__DbgTest(&dump2);
|
sl@0
|
601 |
test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner &&
|
sl@0
|
602 |
dump1.iContainer==dump2.iContainer && dump1.iName==dump2.iName);
|
sl@0
|
603 |
pIx->Remove(aHandle1);
|
sl@0
|
604 |
pIx->Remove(aHandle3);
|
sl@0
|
605 |
// pIx->Remove(aHandle3); this will cause a crash
|
sl@0
|
606 |
|
sl@0
|
607 |
// Removing an object from a CObjectIx calls the objects close method hence in this case
|
sl@0
|
608 |
// deleting it
|
sl@0
|
609 |
//delete pCon1; // The destructor for a container deletes its contained objects
|
sl@0
|
610 |
//delete pCon2;
|
sl@0
|
611 |
delete pConIx; // The CObjectConIx destructor deletes its containers
|
sl@0
|
612 |
delete pIx; // The CObjectIx destructor calls close on all its objects
|
sl@0
|
613 |
}
|
sl@0
|
614 |
|
sl@0
|
615 |
GLDEF_C void TestCObjects::Test8(void)
|
sl@0
|
616 |
{
|
sl@0
|
617 |
// Test all objects together
|
sl@0
|
618 |
CObjectIx *pIx=CObjectIx::NewL();
|
sl@0
|
619 |
CObjectConIx *pConIx=CObjectConIx::NewL();
|
sl@0
|
620 |
CObjectCon *pCon1=pConIx->CreateL(),
|
sl@0
|
621 |
*pCon2=pConIx->CreateL();
|
sl@0
|
622 |
CObject *pObj1=new CObject,
|
sl@0
|
623 |
*pObj2=new CObject,
|
sl@0
|
624 |
*pObj3=new CObject,
|
sl@0
|
625 |
*pObj4=new CObject,
|
sl@0
|
626 |
*pObj5=new CObject,
|
sl@0
|
627 |
*temp;
|
sl@0
|
628 |
TInt tempHandle;
|
sl@0
|
629 |
TPtrC name1(_S("Obj1")), name2(_S("Obj2")), name3(_S("Obj3")), name4(_S("Obj4")), name5(_S("Obj5"));
|
sl@0
|
630 |
|
sl@0
|
631 |
// Create two containers with Obj1,Obj2, Obj3 in the first and Obj4 and Obj5 in the second
|
sl@0
|
632 |
// Obj1 owns Obj2 which owns Obj3
|
sl@0
|
633 |
pObj1->SetName(&name1);
|
sl@0
|
634 |
pObj2->SetName(&name2);
|
sl@0
|
635 |
pObj2->SetOwner(pObj1);
|
sl@0
|
636 |
pObj3->SetName(&name3);
|
sl@0
|
637 |
pObj3->SetOwner(pObj2);
|
sl@0
|
638 |
pObj4->SetName(&name4);
|
sl@0
|
639 |
pObj5->SetName(&name5);
|
sl@0
|
640 |
pCon1->AddL(pObj1);
|
sl@0
|
641 |
pCon1->AddL(pObj2);
|
sl@0
|
642 |
pCon1->AddL(pObj3);
|
sl@0
|
643 |
pCon2->AddL(pObj4);
|
sl@0
|
644 |
pCon2->AddL(pObj5);
|
sl@0
|
645 |
pIx->AddL(pObj1);
|
sl@0
|
646 |
pIx->AddL(pObj2);
|
sl@0
|
647 |
pIx->AddL(pObj3);
|
sl@0
|
648 |
pIx->AddL(pObj4);
|
sl@0
|
649 |
pIx->AddL(pObj5);
|
sl@0
|
650 |
|
sl@0
|
651 |
|
sl@0
|
652 |
tempHandle=0;
|
sl@0
|
653 |
GetObjName(gName1,*pObj1);
|
sl@0
|
654 |
pCon1->FindByName(tempHandle, gName1, gName);
|
sl@0
|
655 |
temp=pCon1->At(tempHandle);
|
sl@0
|
656 |
GetObjName(gName2,*temp);
|
sl@0
|
657 |
test(gName2==gName1);
|
sl@0
|
658 |
tempHandle=0;
|
sl@0
|
659 |
GetObjFullName(gFullName1,*pObj1);
|
sl@0
|
660 |
pCon1->FindByFullName(tempHandle, gFullName1, gFullName);
|
sl@0
|
661 |
temp=pCon1->At(tempHandle);
|
sl@0
|
662 |
GetObjName(gName2,*temp);
|
sl@0
|
663 |
test(gName2==gName1);
|
sl@0
|
664 |
|
sl@0
|
665 |
tempHandle=0;
|
sl@0
|
666 |
GetObjName(gName1,*pObj2);
|
sl@0
|
667 |
pCon1->FindByName(tempHandle, gName1, gName);
|
sl@0
|
668 |
temp=pCon1->At(tempHandle);
|
sl@0
|
669 |
GetObjName(gName2,*temp);
|
sl@0
|
670 |
test(gName2==gName1);
|
sl@0
|
671 |
tempHandle=0;
|
sl@0
|
672 |
GetObjFullName(gFullName1,*pObj2);
|
sl@0
|
673 |
pCon1->FindByFullName(tempHandle, gFullName1, gFullName);
|
sl@0
|
674 |
temp=pCon1->At(tempHandle);
|
sl@0
|
675 |
GetObjName(gName2,*temp);
|
sl@0
|
676 |
test(gName2==gName1);
|
sl@0
|
677 |
|
sl@0
|
678 |
tempHandle=0;
|
sl@0
|
679 |
GetObjName(gName1,*pObj3);
|
sl@0
|
680 |
pCon1->FindByName(tempHandle, gName1, gName);
|
sl@0
|
681 |
temp=pCon1->At(tempHandle);
|
sl@0
|
682 |
GetObjName(gName2,*temp);
|
sl@0
|
683 |
test(gName2==gName1);
|
sl@0
|
684 |
tempHandle=0;
|
sl@0
|
685 |
GetObjFullName(gFullName1,*pObj3);
|
sl@0
|
686 |
pCon1->FindByFullName(tempHandle, gFullName1, gFullName);
|
sl@0
|
687 |
temp=pCon1->At(tempHandle);
|
sl@0
|
688 |
GetObjName(gName2,*temp);
|
sl@0
|
689 |
test(gName2==gName1);
|
sl@0
|
690 |
|
sl@0
|
691 |
tempHandle=0;
|
sl@0
|
692 |
GetObjName(gName1,*pObj4);
|
sl@0
|
693 |
pCon2->FindByName(tempHandle, gName1, gName);
|
sl@0
|
694 |
temp=pCon2->At(tempHandle);
|
sl@0
|
695 |
GetObjName(gName2,*temp);
|
sl@0
|
696 |
test(gName2==gName1);
|
sl@0
|
697 |
tempHandle=0;
|
sl@0
|
698 |
GetObjFullName(gFullName1,*pObj4);
|
sl@0
|
699 |
pCon2->FindByFullName(tempHandle, gFullName1, gFullName);
|
sl@0
|
700 |
temp=pCon2->At(tempHandle);
|
sl@0
|
701 |
GetObjName(gName2,*temp);
|
sl@0
|
702 |
test(gName1==gName2);
|
sl@0
|
703 |
|
sl@0
|
704 |
tempHandle=0;
|
sl@0
|
705 |
GetObjName(gName1,*pObj5);
|
sl@0
|
706 |
pCon2->FindByName(tempHandle, gName1, gName);
|
sl@0
|
707 |
temp=pCon2->At(tempHandle);
|
sl@0
|
708 |
GetObjName(gName2,*temp);
|
sl@0
|
709 |
test(gName2==gName1);
|
sl@0
|
710 |
tempHandle=0;
|
sl@0
|
711 |
GetObjFullName(gFullName1,*pObj5);
|
sl@0
|
712 |
pCon2->FindByFullName(tempHandle, gFullName1, gFullName);
|
sl@0
|
713 |
temp=pCon2->At(tempHandle);
|
sl@0
|
714 |
GetObjName(gName2,*temp);
|
sl@0
|
715 |
test(gName2==gName1);
|
sl@0
|
716 |
|
sl@0
|
717 |
|
sl@0
|
718 |
tempHandle=0;
|
sl@0
|
719 |
test(pCon1->FindByName(tempHandle, _L("*1"), gName)==KErrNone);
|
sl@0
|
720 |
GetObjName(gName1,*pObj1);
|
sl@0
|
721 |
test(gName==gName1);
|
sl@0
|
722 |
tempHandle=0;
|
sl@0
|
723 |
test(pCon1->FindByFullName(tempHandle, _L("*::*"), gFullName)==KErrNone);
|
sl@0
|
724 |
GetObjFullName(gFullName1,*pObj2);
|
sl@0
|
725 |
test(gFullName==gFullName1);
|
sl@0
|
726 |
GetObjName(gName1,*pObj3);
|
sl@0
|
727 |
for(tempHandle=0;gName!=gName1;pCon1->FindByName(tempHandle, _L("????"),gName)) {};
|
sl@0
|
728 |
test(gName==gName1);
|
sl@0
|
729 |
|
sl@0
|
730 |
|
sl@0
|
731 |
pObj1->Close(); // Deletes it and removes it from its container
|
sl@0
|
732 |
pObj3->Close();
|
sl@0
|
733 |
tempHandle=0;
|
sl@0
|
734 |
test(pCon1->FindByName(tempHandle, _L("Obj1"), gName)==KErrNotFound);
|
sl@0
|
735 |
tempHandle=0;
|
sl@0
|
736 |
test(pCon1->FindByName(tempHandle, _L("Obj3"), gName)==KErrNotFound);
|
sl@0
|
737 |
tempHandle=0;
|
sl@0
|
738 |
GetObjName(gName1,*pObj2);
|
sl@0
|
739 |
test(pCon1->FindByName(tempHandle, gName1, gName)==KErrNone);
|
sl@0
|
740 |
test(gName==gName1);
|
sl@0
|
741 |
tempHandle=0;
|
sl@0
|
742 |
//CObject* x=new CObject;
|
sl@0
|
743 |
//x->SetName(_L("xxxx"));
|
sl@0
|
744 |
//pCon1->FindByFullName(tempHandle, pObj2->FullName(), aFullName);
|
sl@0
|
745 |
// FullName is set to Xxxx::Obj2
|
sl@0
|
746 |
|
sl@0
|
747 |
}
|
sl@0
|
748 |
|
sl@0
|
749 |
GLDEF_C void TestCObjects::GetObjName(TName& aDest,const CObject& aObj)
|
sl@0
|
750 |
//
|
sl@0
|
751 |
// Utility function to reduce stack usage in functions, and so get rid of __chkstk errors
|
sl@0
|
752 |
//
|
sl@0
|
753 |
{
|
sl@0
|
754 |
aDest=aObj.Name();
|
sl@0
|
755 |
}
|
sl@0
|
756 |
|
sl@0
|
757 |
GLDEF_C void TestCObjects::GetObjFullName(TFullName& aDest,const CObject& aObj)
|
sl@0
|
758 |
//
|
sl@0
|
759 |
// Utility function to reduce stack usage in functions, and so get rid of __chkstk errors
|
sl@0
|
760 |
//
|
sl@0
|
761 |
{
|
sl@0
|
762 |
aDest=aObj.FullName();
|
sl@0
|
763 |
}
|
sl@0
|
764 |
|
sl@0
|
765 |
void testHandles()
|
sl@0
|
766 |
|
sl@0
|
767 |
{
|
sl@0
|
768 |
|
sl@0
|
769 |
CObjectConIx* myConIx=CObjectConIx::NewL();
|
sl@0
|
770 |
CObjectCon* myCon= myConIx->CreateL();
|
sl@0
|
771 |
CObjectIx* myIx=CObjectIx::NewL();
|
sl@0
|
772 |
test(myCon->UniqueID()!=0);
|
sl@0
|
773 |
|
sl@0
|
774 |
for (TInt i=0;i<0x4006; i++)
|
sl@0
|
775 |
{
|
sl@0
|
776 |
CObject* myObj=new CObject;
|
sl@0
|
777 |
myCon->AddL(myObj);
|
sl@0
|
778 |
TInt handle=myIx->AddL(myObj);
|
sl@0
|
779 |
if ((handle&0xffff0000)==0x3fff0000)
|
sl@0
|
780 |
test.Printf(_L("Created biggest handle\n"));
|
sl@0
|
781 |
test (handle!=0);
|
sl@0
|
782 |
myIx->Remove(handle);
|
sl@0
|
783 |
}
|
sl@0
|
784 |
delete myIx;
|
sl@0
|
785 |
delete myConIx;
|
sl@0
|
786 |
}
|
sl@0
|
787 |
|
sl@0
|
788 |
void testSpeed()
|
sl@0
|
789 |
|
sl@0
|
790 |
{
|
sl@0
|
791 |
|
sl@0
|
792 |
const TInt numObjects=0x600;
|
sl@0
|
793 |
CObjectConIx* myConIx=CObjectConIx::NewL();
|
sl@0
|
794 |
CObjectCon* myCon= myConIx->CreateL();
|
sl@0
|
795 |
// CObjectIx* myIx=CObjectIx::NewL();
|
sl@0
|
796 |
TTime start;
|
sl@0
|
797 |
TTime end;
|
sl@0
|
798 |
TInt64 diff;
|
sl@0
|
799 |
TInt i;
|
sl@0
|
800 |
|
sl@0
|
801 |
start.HomeTime();
|
sl@0
|
802 |
for (i=0;i<numObjects; i++)
|
sl@0
|
803 |
{
|
sl@0
|
804 |
CObject* myObj=new CObject;
|
sl@0
|
805 |
TName name;
|
sl@0
|
806 |
name.Format(_L("CObject%d"),i);
|
sl@0
|
807 |
myObj->SetName(&name);
|
sl@0
|
808 |
myCon->AddL(myObj);
|
sl@0
|
809 |
}
|
sl@0
|
810 |
end.HomeTime();
|
sl@0
|
811 |
diff=(end.Int64()-start.Int64())/100000;
|
sl@0
|
812 |
test.Printf(_L("Time for 0x%08x named objects = %d tenths of secs\n"),numObjects,I64INT(diff));
|
sl@0
|
813 |
|
sl@0
|
814 |
// If run as a manual test (when enhancements to RTEST arrive)
|
sl@0
|
815 |
// test.Printf(_L("Press a key to continue with these spammy tests\n"));
|
sl@0
|
816 |
// test.Getch();
|
sl@0
|
817 |
|
sl@0
|
818 |
const TInt numObjects2=0x600;
|
sl@0
|
819 |
// CObjectConIx* myConIx2=CObjectConIx::NewL();
|
sl@0
|
820 |
CObjectCon* myCon2= myConIx->CreateL();
|
sl@0
|
821 |
// CObjectIx* myIx2=CObjectIx::NewL();
|
sl@0
|
822 |
|
sl@0
|
823 |
start.HomeTime();
|
sl@0
|
824 |
for (i=0;i<numObjects2; i++)
|
sl@0
|
825 |
{
|
sl@0
|
826 |
CObject* myObj=new CObject;
|
sl@0
|
827 |
TName name;
|
sl@0
|
828 |
name.Format(_L("CObject%d"),i);
|
sl@0
|
829 |
myCon2->AddL(myObj);
|
sl@0
|
830 |
}
|
sl@0
|
831 |
end.HomeTime();
|
sl@0
|
832 |
diff=(end.Int64()-start.Int64())/100000;
|
sl@0
|
833 |
test.Printf(_L("Time for 0x%08x unnamed objects = %d tenths of secs\n"),numObjects2,I64INT(diff));
|
sl@0
|
834 |
|
sl@0
|
835 |
|
sl@0
|
836 |
// If run as a manual test (when enhancements to RTEST arrive)
|
sl@0
|
837 |
// test.Printf(_L("Press a key to continue with these spammy tests\n"));
|
sl@0
|
838 |
// test.Getch();
|
sl@0
|
839 |
|
sl@0
|
840 |
// delete myIx;
|
sl@0
|
841 |
// delete myConIx;
|
sl@0
|
842 |
}
|
sl@0
|
843 |
|
sl@0
|
844 |
|
sl@0
|
845 |
|
sl@0
|
846 |
const TInt KObjectIndexMask=0x7fff;
|
sl@0
|
847 |
|
sl@0
|
848 |
//Tests CObjectIx class
|
sl@0
|
849 |
class TestCObjectIx
|
sl@0
|
850 |
{
|
sl@0
|
851 |
public:
|
sl@0
|
852 |
void StartL(void);
|
sl@0
|
853 |
~TestCObjectIx();
|
sl@0
|
854 |
private:
|
sl@0
|
855 |
void Test1(TInt aSize);
|
sl@0
|
856 |
void Test2(TInt aSize);
|
sl@0
|
857 |
void Test3(TInt aSize, TBool aPerformanceTest);
|
sl@0
|
858 |
inline TInt Index(TInt aHandle) {return(aHandle&KObjectIndexMask);}
|
sl@0
|
859 |
|
sl@0
|
860 |
private:
|
sl@0
|
861 |
struct COBjAndHandle
|
sl@0
|
862 |
{
|
sl@0
|
863 |
CObject* iObject;
|
sl@0
|
864 |
TInt iHandle;
|
sl@0
|
865 |
};
|
sl@0
|
866 |
|
sl@0
|
867 |
CObjectConIx* iMyConIx;
|
sl@0
|
868 |
CObjectCon* iMyCon;
|
sl@0
|
869 |
CObjectIx* iMyIx;
|
sl@0
|
870 |
TUint iSeed[2];
|
sl@0
|
871 |
COBjAndHandle* iObjAndHandle;
|
sl@0
|
872 |
};
|
sl@0
|
873 |
|
sl@0
|
874 |
const TInt KMaxTestObjects = (1<<11);
|
sl@0
|
875 |
|
sl@0
|
876 |
//Runs all tests (methods) of the class
|
sl@0
|
877 |
void TestCObjectIx::StartL(void)
|
sl@0
|
878 |
{
|
sl@0
|
879 |
TInt i;
|
sl@0
|
880 |
iMyConIx=CObjectConIx::NewL();
|
sl@0
|
881 |
iMyCon= iMyConIx->CreateL();
|
sl@0
|
882 |
iObjAndHandle = (COBjAndHandle*) User::AllocL(KMaxTestObjects * sizeof(COBjAndHandle));
|
sl@0
|
883 |
|
sl@0
|
884 |
test.Title();
|
sl@0
|
885 |
test.Start(_L("Test CObjectIx"));
|
sl@0
|
886 |
|
sl@0
|
887 |
test.Next(_L("Add and remove objects in the same order..."));
|
sl@0
|
888 |
TUint32 startTime = User::NTickCount();
|
sl@0
|
889 |
for (i=1;i<2000;i=i+10) Test1(i);
|
sl@0
|
890 |
test.Printf(_L("...done in %d msec\n"), User::NTickCount()-startTime);
|
sl@0
|
891 |
|
sl@0
|
892 |
test.Next(_L("Add and remove objects in the reverse order..."));
|
sl@0
|
893 |
startTime = User::NTickCount();
|
sl@0
|
894 |
for (i=1;i<2000;i=i+10) Test2(i);
|
sl@0
|
895 |
test.Printf(_L("...done in %d msec\n"), User::NTickCount()-startTime);
|
sl@0
|
896 |
|
sl@0
|
897 |
test.Next(_L("Add and remove objects in random order..."));
|
sl@0
|
898 |
iSeed[0]=User::TickCount();
|
sl@0
|
899 |
test.Printf(_L("The initial seed for the random function is: S0=%xh S1=%xh\n"), iSeed[0], iSeed[1]);
|
sl@0
|
900 |
for (i=2;i<=KMaxTestObjects/2; i<<=1)
|
sl@0
|
901 |
Test3(i-1, EFalse);
|
sl@0
|
902 |
|
sl@0
|
903 |
test.Next(_L("Add and remove objects in random order - performance test..."));
|
sl@0
|
904 |
iSeed[0]=0;
|
sl@0
|
905 |
iSeed[1]=1;
|
sl@0
|
906 |
startTime = User::NTickCount();
|
sl@0
|
907 |
for (i=2;i<=KMaxTestObjects; i<<=1)
|
sl@0
|
908 |
Test3(i-1, ETrue);
|
sl@0
|
909 |
test.Printf(_L("...done in %d msec\n"), User::NTickCount()-startTime);
|
sl@0
|
910 |
test.Printf(_L("CAUTION: Test changed in May 2005. Comparison of timings with those before then are not valid.\n"));
|
sl@0
|
911 |
|
sl@0
|
912 |
test.End();
|
sl@0
|
913 |
}
|
sl@0
|
914 |
|
sl@0
|
915 |
TestCObjectIx::~TestCObjectIx()
|
sl@0
|
916 |
{
|
sl@0
|
917 |
delete iMyConIx;
|
sl@0
|
918 |
delete [] iObjAndHandle;
|
sl@0
|
919 |
}
|
sl@0
|
920 |
|
sl@0
|
921 |
//Adds a number of CObjects to CObjectIx, then removes them in the same order.
|
sl@0
|
922 |
void TestCObjectIx::Test1(TInt aSize)
|
sl@0
|
923 |
{
|
sl@0
|
924 |
TInt i;
|
sl@0
|
925 |
iMyIx=CObjectIx::NewL();
|
sl@0
|
926 |
|
sl@0
|
927 |
for (i=0; i<aSize; i++) //Add
|
sl@0
|
928 |
{
|
sl@0
|
929 |
if( (iObjAndHandle[i].iObject = new CObject) == NULL) User::Leave(KErrNoMemory);
|
sl@0
|
930 |
iMyCon->AddL(iObjAndHandle[i].iObject);
|
sl@0
|
931 |
iObjAndHandle[i].iHandle = iMyIx->AddL(iObjAndHandle[i].iObject);
|
sl@0
|
932 |
}
|
sl@0
|
933 |
|
sl@0
|
934 |
for (i=0; i<aSize; i++) //Remove
|
sl@0
|
935 |
iMyIx->Remove(iObjAndHandle[i].iHandle);
|
sl@0
|
936 |
|
sl@0
|
937 |
delete iMyIx;
|
sl@0
|
938 |
iMyIx=0;
|
sl@0
|
939 |
}
|
sl@0
|
940 |
|
sl@0
|
941 |
|
sl@0
|
942 |
//Adds a number of CObjects to CObjectIx, then removes them in the reverse order.
|
sl@0
|
943 |
void TestCObjectIx::Test2(TInt aSize)
|
sl@0
|
944 |
{
|
sl@0
|
945 |
TInt i;
|
sl@0
|
946 |
iMyIx=CObjectIx::NewL();
|
sl@0
|
947 |
|
sl@0
|
948 |
for (i=0; i<aSize; i++) //Add
|
sl@0
|
949 |
{
|
sl@0
|
950 |
if( (iObjAndHandle[i].iObject = new CObject) == NULL) User::Leave(KErrNoMemory);
|
sl@0
|
951 |
iMyCon->AddL(iObjAndHandle[i].iObject);
|
sl@0
|
952 |
iObjAndHandle[i].iHandle = iMyIx->AddL(iObjAndHandle[i].iObject);
|
sl@0
|
953 |
}
|
sl@0
|
954 |
|
sl@0
|
955 |
for (i=aSize-1; i>=aSize; i--) //Remove
|
sl@0
|
956 |
iMyIx->Remove(iObjAndHandle[i].iHandle);
|
sl@0
|
957 |
|
sl@0
|
958 |
delete iMyIx;
|
sl@0
|
959 |
iMyIx=0;
|
sl@0
|
960 |
}
|
sl@0
|
961 |
|
sl@0
|
962 |
|
sl@0
|
963 |
//Adds and removes random number of CObjects to/from CObjectIx.
|
sl@0
|
964 |
void TestCObjectIx::Test3(TInt aSize, TBool aPerformanceTest)
|
sl@0
|
965 |
{
|
sl@0
|
966 |
TInt index, x;
|
sl@0
|
967 |
if(!aPerformanceTest)
|
sl@0
|
968 |
test.Printf(_L("Testing size %d.The seeds are: S0=%xh S1=%xh\n"), aSize, iSeed[0], iSeed[1]);
|
sl@0
|
969 |
|
sl@0
|
970 |
//---Create & init the objects we need
|
sl@0
|
971 |
for (x=0; x<aSize; x++) iObjAndHandle[x].iObject = NULL; //initialize the array
|
sl@0
|
972 |
iMyIx=CObjectIx::NewL();
|
sl@0
|
973 |
|
sl@0
|
974 |
for (x = 0; x<100; x++)
|
sl@0
|
975 |
{
|
sl@0
|
976 |
|
sl@0
|
977 |
//---Add the random number of objects (in random order)---
|
sl@0
|
978 |
TInt toAdd=Random(iSeed)%(aSize-iMyIx->ActiveCount()+1);
|
sl@0
|
979 |
//test.Printf(_L("Adding %d objects\n"), toAdd );
|
sl@0
|
980 |
while (toAdd--)
|
sl@0
|
981 |
{
|
sl@0
|
982 |
index=Random(iSeed)%aSize;
|
sl@0
|
983 |
while (iObjAndHandle[index].iObject) //Find the next NULL pointer
|
sl@0
|
984 |
{ ++index; if(index>=aSize) index=0; }
|
sl@0
|
985 |
if( (iObjAndHandle[index].iObject = new CObject) == NULL) User::Leave(KErrNoMemory);
|
sl@0
|
986 |
iMyCon->AddL(iObjAndHandle[index].iObject);
|
sl@0
|
987 |
iObjAndHandle[index].iHandle = iMyIx->AddL(iObjAndHandle[index].iObject);
|
sl@0
|
988 |
//test.Printf(_L("%d(%d) "), index,iObjAndHandle[index].iHandle & 0x7fff );
|
sl@0
|
989 |
}
|
sl@0
|
990 |
//test.Printf(_L("\n"));
|
sl@0
|
991 |
|
sl@0
|
992 |
|
sl@0
|
993 |
//---Remove the random number of objects (in random order)---
|
sl@0
|
994 |
TInt toRemove=Random(iSeed)%(iMyIx->ActiveCount()+1);
|
sl@0
|
995 |
//test.Printf(_L("Removing %d objects: "), toRemove );
|
sl@0
|
996 |
while (toRemove--)
|
sl@0
|
997 |
{
|
sl@0
|
998 |
index=Random(iSeed)%aSize;
|
sl@0
|
999 |
while (!iObjAndHandle[index].iObject) //Find the next non-NULL pointer
|
sl@0
|
1000 |
{ ++index; if(index>=aSize) index=0; }
|
sl@0
|
1001 |
//test.Printf(_L("%d(%d) "), index,iObjAndHandle[index].iHandle & 0x7fff );
|
sl@0
|
1002 |
iMyIx->Remove(iObjAndHandle[index].iHandle);
|
sl@0
|
1003 |
iObjAndHandle[index].iObject=NULL;
|
sl@0
|
1004 |
}
|
sl@0
|
1005 |
//test.Printf(_L("\n"));
|
sl@0
|
1006 |
|
sl@0
|
1007 |
|
sl@0
|
1008 |
//---Test data consistency---
|
sl@0
|
1009 |
if(aPerformanceTest) continue;
|
sl@0
|
1010 |
|
sl@0
|
1011 |
TInt objNum=0;
|
sl@0
|
1012 |
for (index=0;index<aSize;index++)
|
sl@0
|
1013 |
{
|
sl@0
|
1014 |
if (iObjAndHandle[index].iObject)
|
sl@0
|
1015 |
{
|
sl@0
|
1016 |
objNum++;
|
sl@0
|
1017 |
//Test At(TInt aHandle) method
|
sl@0
|
1018 |
test(iObjAndHandle[index].iObject == iMyIx->At(iObjAndHandle[index].iHandle));
|
sl@0
|
1019 |
//Test Count(CObject* aObject) method
|
sl@0
|
1020 |
test(1==iMyIx->Count(iObjAndHandle[index].iObject));
|
sl@0
|
1021 |
//Test At(CObject* aObject) method
|
sl@0
|
1022 |
test(iObjAndHandle[index].iHandle==iMyIx->At(iObjAndHandle[index].iObject));
|
sl@0
|
1023 |
//Test operator[](TInt index) method
|
sl@0
|
1024 |
test(iObjAndHandle[index].iObject==(*iMyIx)[Index(iObjAndHandle[index].iHandle)]);
|
sl@0
|
1025 |
}
|
sl@0
|
1026 |
}
|
sl@0
|
1027 |
|
sl@0
|
1028 |
test (objNum==iMyIx->ActiveCount());
|
sl@0
|
1029 |
//test.Printf(_L("%d objects in array\n"), objNum);
|
sl@0
|
1030 |
}
|
sl@0
|
1031 |
|
sl@0
|
1032 |
delete iMyIx;
|
sl@0
|
1033 |
iMyIx=NULL;
|
sl@0
|
1034 |
}
|
sl@0
|
1035 |
|
sl@0
|
1036 |
// Test that things work when the unique ID of the object container grows larger
|
sl@0
|
1037 |
// than 15 bits
|
sl@0
|
1038 |
void TestCObjectConIxL(void)
|
sl@0
|
1039 |
{
|
sl@0
|
1040 |
const TInt KCObjectConLimit = 65535;
|
sl@0
|
1041 |
_LIT(KAnyMatch, "*");
|
sl@0
|
1042 |
|
sl@0
|
1043 |
__UHEAP_MARK;
|
sl@0
|
1044 |
|
sl@0
|
1045 |
CObjectConIx* conIx = CObjectConIx::NewL();
|
sl@0
|
1046 |
CObjectIx* ix = CObjectIx::NewL();
|
sl@0
|
1047 |
TInt i;
|
sl@0
|
1048 |
|
sl@0
|
1049 |
test.Next(_L("Test repeated add/remove of object containers"));
|
sl@0
|
1050 |
for (i = 0 ; i < KCObjectConLimit * 2 ; ++i)
|
sl@0
|
1051 |
{
|
sl@0
|
1052 |
CObjectCon* con = conIx->CreateL();
|
sl@0
|
1053 |
CObject* obj = new (ELeave) CObject();
|
sl@0
|
1054 |
con->AddL(obj);
|
sl@0
|
1055 |
|
sl@0
|
1056 |
TInt handle = ix->AddL(obj);
|
sl@0
|
1057 |
test(ix->At(handle) == obj);
|
sl@0
|
1058 |
test(ix->At(handle, con->UniqueID()) == obj);
|
sl@0
|
1059 |
|
sl@0
|
1060 |
TName name;
|
sl@0
|
1061 |
TInt findHandle = 0;
|
sl@0
|
1062 |
test(con->FindByName(findHandle, KAnyMatch, name) == KErrNone);
|
sl@0
|
1063 |
test(con->AtL(findHandle) == obj);
|
sl@0
|
1064 |
test(con->At(findHandle) == obj);
|
sl@0
|
1065 |
test(conIx->Lookup(findHandle) == con);
|
sl@0
|
1066 |
test(con->FindByName(findHandle, KAnyMatch, name) == KErrNotFound);
|
sl@0
|
1067 |
|
sl@0
|
1068 |
TFullName fullName;
|
sl@0
|
1069 |
findHandle = 0;
|
sl@0
|
1070 |
test(con->FindByFullName(findHandle, KAnyMatch, fullName) == KErrNone);
|
sl@0
|
1071 |
test(con->AtL(findHandle) == obj);
|
sl@0
|
1072 |
test(con->At(findHandle) == obj);
|
sl@0
|
1073 |
test(conIx->Lookup(findHandle) == con);
|
sl@0
|
1074 |
test(con->FindByFullName(findHandle, KAnyMatch, fullName) == KErrNotFound);
|
sl@0
|
1075 |
|
sl@0
|
1076 |
ix->Remove(handle);
|
sl@0
|
1077 |
conIx->Remove(con);
|
sl@0
|
1078 |
}
|
sl@0
|
1079 |
|
sl@0
|
1080 |
test.Next(_L("Test adding maximum possible number of object containers"));
|
sl@0
|
1081 |
RPointerArray<CObjectCon> cons;
|
sl@0
|
1082 |
for (i = 0 ; i < KCObjectConLimit ; ++i)
|
sl@0
|
1083 |
{
|
sl@0
|
1084 |
CObjectCon* con = conIx->CreateL();
|
sl@0
|
1085 |
cons.AppendL(con);
|
sl@0
|
1086 |
}
|
sl@0
|
1087 |
TRAPD(err, conIx->CreateL());
|
sl@0
|
1088 |
test(err == KErrOverflow);
|
sl@0
|
1089 |
|
sl@0
|
1090 |
test.Next(_L("Test unique IDs are really unique after ID value has wrapped"));
|
sl@0
|
1091 |
for (i = 100 ; i < KCObjectConLimit ; ++i)
|
sl@0
|
1092 |
{
|
sl@0
|
1093 |
CObjectCon* con = cons[i];
|
sl@0
|
1094 |
conIx->Remove(con);
|
sl@0
|
1095 |
}
|
sl@0
|
1096 |
for (i = 100 ; i < 200 ; ++i)
|
sl@0
|
1097 |
{
|
sl@0
|
1098 |
CObjectCon* con = conIx->CreateL();
|
sl@0
|
1099 |
cons[i] = con;
|
sl@0
|
1100 |
}
|
sl@0
|
1101 |
for (i = 0 ; i < 200 ; ++i)
|
sl@0
|
1102 |
{
|
sl@0
|
1103 |
TName name;
|
sl@0
|
1104 |
TInt findHandle = 0;
|
sl@0
|
1105 |
CObjectCon* con = cons[i];
|
sl@0
|
1106 |
|
sl@0
|
1107 |
CObject* obj = new (ELeave) CObject();
|
sl@0
|
1108 |
con->AddL(obj);
|
sl@0
|
1109 |
|
sl@0
|
1110 |
test(con->FindByName(findHandle, KAnyMatch, name) == KErrNone);
|
sl@0
|
1111 |
test(conIx->Lookup(findHandle) == con);
|
sl@0
|
1112 |
|
sl@0
|
1113 |
obj->Close();
|
sl@0
|
1114 |
}
|
sl@0
|
1115 |
for (i = 0 ; i < 200 ; ++i)
|
sl@0
|
1116 |
{
|
sl@0
|
1117 |
CObjectCon* con = cons[i];
|
sl@0
|
1118 |
conIx->Remove(con);
|
sl@0
|
1119 |
}
|
sl@0
|
1120 |
cons.Close();
|
sl@0
|
1121 |
|
sl@0
|
1122 |
delete ix;
|
sl@0
|
1123 |
delete conIx;
|
sl@0
|
1124 |
|
sl@0
|
1125 |
__UHEAP_MARKEND;
|
sl@0
|
1126 |
}
|
sl@0
|
1127 |
|
sl@0
|
1128 |
GLDEF_C TInt E32Main()
|
sl@0
|
1129 |
{
|
sl@0
|
1130 |
|
sl@0
|
1131 |
CTrapCleanup* trapHandler=CTrapCleanup::New();
|
sl@0
|
1132 |
test(trapHandler!=NULL);
|
sl@0
|
1133 |
|
sl@0
|
1134 |
test.Title();
|
sl@0
|
1135 |
test.Start(_L("TEST METHODS ARE IN THE DLL"));
|
sl@0
|
1136 |
|
sl@0
|
1137 |
__UHEAP_MARK;
|
sl@0
|
1138 |
|
sl@0
|
1139 |
TestCObjectIx* TCobjectIx = new TestCObjectIx;
|
sl@0
|
1140 |
TRAPD(ret, TCobjectIx->StartL());
|
sl@0
|
1141 |
test(KErrNone == ret);
|
sl@0
|
1142 |
delete TCobjectIx;
|
sl@0
|
1143 |
|
sl@0
|
1144 |
__UHEAP_MARKEND;
|
sl@0
|
1145 |
|
sl@0
|
1146 |
test.Next(_L("Generate lots of handles"));
|
sl@0
|
1147 |
testHandles();
|
sl@0
|
1148 |
|
sl@0
|
1149 |
test.Next(_L("Test CObjectCon is fast enough"));
|
sl@0
|
1150 |
testSpeed();
|
sl@0
|
1151 |
|
sl@0
|
1152 |
TestCObjects T;
|
sl@0
|
1153 |
test.Next(_L("CObject methods"));
|
sl@0
|
1154 |
T.Test1();
|
sl@0
|
1155 |
test.Next(_L("CObjectCon methods"));
|
sl@0
|
1156 |
T.Test2();
|
sl@0
|
1157 |
test.Next(_L("CObjectIx methods"));
|
sl@0
|
1158 |
T.Test3();
|
sl@0
|
1159 |
test.Next(_L("CObjectConIx methods"));
|
sl@0
|
1160 |
T.Test4();
|
sl@0
|
1161 |
test.Next(_L("TEST THE METHODS"));
|
sl@0
|
1162 |
test.Next(_L("CObject"));
|
sl@0
|
1163 |
T.Test5();
|
sl@0
|
1164 |
test.Next(_L("CObjectCon"));
|
sl@0
|
1165 |
T.Test6();
|
sl@0
|
1166 |
test.Next(_L("CObjectIx"));
|
sl@0
|
1167 |
T.Test7();
|
sl@0
|
1168 |
|
sl@0
|
1169 |
//////////////////////////////
|
sl@0
|
1170 |
// PROPER TESTING STARTS HERE
|
sl@0
|
1171 |
//////////////////////////////
|
sl@0
|
1172 |
test.Next(_L("All objects"));
|
sl@0
|
1173 |
T.Test8();
|
sl@0
|
1174 |
|
sl@0
|
1175 |
test.Next(_L("CObjectConIx"));
|
sl@0
|
1176 |
TRAPD(err, TestCObjectConIxL());
|
sl@0
|
1177 |
if (err != KErrNone)
|
sl@0
|
1178 |
test.Printf(_L("TestCObjectConIxL left with %d\n"), err);
|
sl@0
|
1179 |
test(err == KErrNone);
|
sl@0
|
1180 |
|
sl@0
|
1181 |
test.End();
|
sl@0
|
1182 |
|
sl@0
|
1183 |
delete trapHandler;
|
sl@0
|
1184 |
return(KErrNone);
|
sl@0
|
1185 |
}
|