sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\system\t_cobj.cpp sl@0: // Overview: sl@0: // Test CObject, CObjectIx, CObjectCon, CObjectConIx classes sl@0: // API Information: sl@0: // CObject, CObjectIx, CObjectCon, CObjectConIx sl@0: // Details: sl@0: // - Test the CObjectIx class by adding and removing CObject objects sl@0: // in the same order, in reverse order and in random order. sl@0: // - Test adding many CObject objects to a CObjectConIx and test that sl@0: // the returned handle is as expected. sl@0: // - Perform a speed test on CObjectCon for both named and unnamed sl@0: // objects. sl@0: // - Check that the CObject, CObjectCon, CObjectIx and CObjectConIx methods sl@0: // are in the DLL by calling each one. sl@0: // - Test the CObject, CObjectCon, CObjectIx and CObjectConIx methods and sl@0: // verify the results are as expected. sl@0: // - Test all the objects together: create two containers, find objects by sl@0: // name in a variety of ways, delete objects and verify the results are sl@0: // as expected. sl@0: // Platforms/Drives/Compatibility: sl@0: // All. sl@0: // Assumptions/Requirement/Pre-requisites: sl@0: // Failures and causes: sl@0: // Base Port information: sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "../misc/prbs.h" sl@0: sl@0: struct TCObjectDump sl@0: { sl@0: TInt iAccessCount; sl@0: CObject* iOwner; sl@0: CObjectCon* iContainer; sl@0: HBufC* iName; sl@0: }; sl@0: sl@0: void CObject::__DbgTest(void* pCObjectDump) const sl@0: { sl@0: ((TCObjectDump*)pCObjectDump)->iAccessCount=iAccessCount; sl@0: ((TCObjectDump*)pCObjectDump)->iOwner=iOwner; sl@0: ((TCObjectDump*)pCObjectDump)->iContainer=iContainer; sl@0: ((TCObjectDump*)pCObjectDump)->iName=iName; sl@0: } sl@0: sl@0: LOCAL_D RTest test(_L("T_COBJ")); sl@0: LOCAL_D TName gName; sl@0: LOCAL_D TName gName1; sl@0: LOCAL_D TName gName2; sl@0: LOCAL_D TFullName gFullName; sl@0: LOCAL_D TFullName gFullName1; sl@0: LOCAL_D TFullName gFullName2; sl@0: sl@0: class RTestHeap : public RAllocator sl@0: { sl@0: public: sl@0: enum TOp {EOpNone=0, EOpAlloc=1, EOpFree=2, EOpReAlloc=3}; sl@0: sl@0: struct TOpInfo sl@0: { sl@0: TInt iOp; sl@0: TAny* iPtrArg; sl@0: TInt iIntArg; sl@0: TAny* iResult; sl@0: }; sl@0: public: sl@0: static RTestHeap* Install(); sl@0: void Uninstall(); sl@0: TInt GetLastOp(TOpInfo& aInfo); sl@0: virtual TAny* Alloc(TInt aSize); sl@0: virtual void Free(TAny* aPtr); sl@0: virtual TAny* ReAlloc(TAny* aPtr, TInt aSize, TInt aMode); sl@0: virtual TInt AllocLen(const TAny* aCell) const; sl@0: virtual TInt Compress(); sl@0: virtual void Reset(); sl@0: virtual TInt AllocSize(TInt& aTotalAllocSize) const; sl@0: virtual TInt Available(TInt& aBiggestBlock) const; sl@0: virtual TInt DebugFunction(TInt aFunc, TAny* a1, TAny* a2); sl@0: public: sl@0: RAllocator* iA; sl@0: TOpInfo iLastOp; sl@0: }; sl@0: sl@0: RTestHeap* RTestHeap::Install() sl@0: { sl@0: RTestHeap* p = new RTestHeap; sl@0: test(p!=0); sl@0: p->iA = &User::Heap(); sl@0: p->iLastOp.iOp = EOpNone; sl@0: User::SwitchHeap(p); sl@0: return p; sl@0: } sl@0: sl@0: void RTestHeap::Uninstall() sl@0: { sl@0: User::SwitchHeap(iA); sl@0: delete this; sl@0: } sl@0: sl@0: TInt RTestHeap::GetLastOp(RTestHeap::TOpInfo& aInfo) sl@0: { sl@0: memcpy(&aInfo, &iLastOp, sizeof(TOpInfo)); sl@0: iLastOp.iOp = EOpNone; sl@0: return (aInfo.iOp == EOpNone) ? KErrNotFound : KErrNone; sl@0: } sl@0: sl@0: TAny* RTestHeap::Alloc(TInt aSize) sl@0: { sl@0: TAny* p = iA->Alloc(aSize); sl@0: iLastOp.iOp = EOpAlloc; sl@0: iLastOp.iPtrArg = 0; sl@0: iLastOp.iIntArg = aSize; sl@0: iLastOp.iResult = p; sl@0: return p; sl@0: } sl@0: sl@0: void RTestHeap::Free(TAny* aPtr) sl@0: { sl@0: iLastOp.iOp = EOpFree; sl@0: iLastOp.iPtrArg = aPtr; sl@0: iLastOp.iIntArg = 0; sl@0: iLastOp.iResult = 0; sl@0: iA->Free(aPtr); sl@0: } sl@0: sl@0: TAny* RTestHeap::ReAlloc(TAny* aPtr, TInt aSize, TInt aMode=0) sl@0: { sl@0: TAny* p = iA->ReAlloc(aPtr,aSize,aMode); sl@0: iLastOp.iOp = EOpReAlloc; sl@0: iLastOp.iPtrArg = aPtr; sl@0: iLastOp.iIntArg = aSize; sl@0: iLastOp.iResult = p; sl@0: return p; sl@0: } sl@0: sl@0: TInt RTestHeap::AllocLen(const TAny* aCell) const sl@0: { sl@0: TInt l = iA->AllocLen(aCell); sl@0: return l; sl@0: } sl@0: sl@0: TInt RTestHeap::Compress() sl@0: { sl@0: TInt l = iA->Compress(); sl@0: return l; sl@0: } sl@0: sl@0: void RTestHeap::Reset() sl@0: { sl@0: iA->Reset(); sl@0: } sl@0: sl@0: TInt RTestHeap::AllocSize(TInt& aTotalAllocSize) const sl@0: { sl@0: TInt s; sl@0: TInt r = iA->AllocSize(s); sl@0: aTotalAllocSize = s; sl@0: return r; sl@0: } sl@0: sl@0: TInt RTestHeap::Available(TInt& aBiggestBlock) const sl@0: { sl@0: TInt s; sl@0: TInt r = iA->Available(s); sl@0: aBiggestBlock = s; sl@0: return r; sl@0: } sl@0: sl@0: TInt RTestHeap::DebugFunction(TInt aFunc, TAny* a1=NULL, TAny* a2=NULL) sl@0: { sl@0: TInt r = iA->DebugFunction(aFunc, a1, a2); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: class TestCObjects sl@0: { sl@0: public: sl@0: void Test1(void); sl@0: void Test2(void); sl@0: void Test3(void); sl@0: void Test4(void); sl@0: void Test5(void); sl@0: void Test6(void); sl@0: void Test7(void); sl@0: void Test8(void); sl@0: private: sl@0: static void GetObjName(TName& aDest,const CObject& aObj); sl@0: static void GetObjFullName(TFullName& aDest,const CObject& aObj); sl@0: }; sl@0: sl@0: sl@0: GLDEF_C void TestCObjects::Test1(void) sl@0: { sl@0: // Check CObject methods are in the DLL sl@0: CObject* pCObject=new CObject; sl@0: CObject* temp=new CObject; sl@0: sl@0: pCObject->Open(); sl@0: pCObject->Close(); sl@0: gName=pCObject->Name(); sl@0: TPtrC aDesR(_S("a name")); sl@0: pCObject->SetName(&aDesR); sl@0: pCObject->SetNameL(&aDesR); sl@0: gFullName=pCObject->FullName(); sl@0: pCObject->Owner(); sl@0: pCObject->SetOwner(temp); sl@0: pCObject->Close(); // deletes object when iAccessCount==0 sl@0: temp->Close(); sl@0: } sl@0: sl@0: GLDEF_C void TestCObjects::Test2(void) sl@0: { sl@0: // Check CObjectCon methods are in the DLL sl@0: CObjectCon* pCObjectCon=CObjectCon::NewL(); sl@0: CObject* pCObject=new CObject; sl@0: TInt aFindHandle=0; sl@0: sl@0: pCObjectCon->AddL(pCObject); sl@0: pCObjectCon->At(aFindHandle); sl@0: User::ValidateName(_L("a name")); sl@0: pCObjectCon->CheckUniqueFullName(pCObject, _L("a name")); sl@0: pCObjectCon->FindByName(aFindHandle, _L("a name"), gName); sl@0: pCObjectCon->FindByFullName(aFindHandle, _L("a Name"), gFullName); sl@0: pCObjectCon->UniqueID(); sl@0: pCObjectCon->Count(); sl@0: pCObjectCon->Remove(pCObject); sl@0: pCObject->Close(); sl@0: delete pCObjectCon; sl@0: } sl@0: sl@0: GLDEF_C void TestCObjects::Test3(void) sl@0: { sl@0: // Check the CObjectIx methods are in the DLL sl@0: CObjectIx* pCObjectIx=CObjectIx::NewL(); sl@0: pCObjectIx->Count(); sl@0: test(pCObjectIx->At(0)==NULL); sl@0: delete pCObjectIx; sl@0: pCObjectIx=CObjectIx::NewL(); sl@0: test(pCObjectIx->Count()==0); sl@0: CObjectConIx* pCObjectConIx=CObjectConIx::NewL(); sl@0: delete pCObjectConIx; sl@0: pCObjectConIx=CObjectConIx::NewL(); sl@0: CObjectCon* pCObjectCon=pCObjectConIx->CreateL(); sl@0: test(pCObjectCon->Count()==0); sl@0: CObject* pCObject= new CObject; sl@0: test(pCObject!=NULL); sl@0: sl@0: TInt find; sl@0: TName name; sl@0: TInt r=pCObjectCon->FindByName(find,_L("Name"),name); sl@0: test(r==KErrNotFound); sl@0: TFullName fullName; sl@0: r=pCObjectCon->FindByFullName(find,_L("Full Name"),fullName); sl@0: test(r==KErrNotFound); sl@0: sl@0: sl@0: pCObjectCon->AddL(pCObject); sl@0: test(pCObjectCon->Count()==1); sl@0: test(pCObjectIx->Count(pCObject)==0); sl@0: pCObjectIx->AddL(pCObject); sl@0: test(pCObjectIx->Count(pCObject)==1); sl@0: pCObjectIx->Count(); sl@0: pCObjectIx->At(0, 0); sl@0: pCObjectIx->At(0); sl@0: // pCObjectIx->Remove(0); sl@0: delete pCObjectIx; sl@0: delete pCObjectConIx; sl@0: // delete pCObjectCon; sl@0: // pCObject->Close(); sl@0: } sl@0: sl@0: GLDEF_C void TestCObjects::Test4(void) sl@0: { sl@0: // Check CObjectConIx methods are in the DLL sl@0: CObjectConIx* pCObjectConIx=CObjectConIx::NewL(); sl@0: CObjectCon* pCObjectCon=pCObjectConIx->CreateL(); sl@0: pCObjectConIx->Lookup(0); sl@0: pCObjectConIx->Remove(pCObjectCon); sl@0: delete pCObjectConIx; sl@0: } sl@0: sl@0: GLDEF_C void TestCObjects::Test5(void) sl@0: { sl@0: // Test the methods of the CObject class sl@0: TCObjectDump CObjectDump; sl@0: CObject* a=new CObject; sl@0: CObject* b=new CObject; sl@0: a->__DbgTest(&CObjectDump); sl@0: test(CObjectDump.iAccessCount==1 && CObjectDump.iOwner==NULL && CObjectDump.iContainer==NULL); sl@0: a->Open(); sl@0: a->__DbgTest(&CObjectDump); sl@0: test(CObjectDump.iAccessCount==2); sl@0: a->Close(); sl@0: a->__DbgTest(&CObjectDump); sl@0: test(CObjectDump.iAccessCount==1); sl@0: TPtrC aDesR(_L("aName")); sl@0: a->SetName(&aDesR); sl@0: gName=a->Name(); sl@0: test(gName==_L("aName")); sl@0: gFullName=a->FullName(); sl@0: test(gFullName==_L("aName")); sl@0: TPtrC aDesR2(_L("Owner")); sl@0: b->SetName(&aDesR2); sl@0: a->SetOwner(b); sl@0: test(a->Owner()==b); sl@0: gFullName=a->FullName(); sl@0: test(gFullName==_L("Owner::aName")); sl@0: a->Close(); // Calls the destructor via the call to delete sl@0: // To Do: set iContainer to something then call Close() sl@0: } sl@0: sl@0: sl@0: GLDEF_C void TestCObjects::Test6(void) sl@0: { sl@0: // Test the methods of CObjectCon sl@0: TCObjectDump dump1, dump2; sl@0: TInt aFindHandle=0; sl@0: CObject *pObj1=new CObject, sl@0: *pObj2=new CObject, sl@0: *pObj3=new CObject, sl@0: *temp; sl@0: CObjectCon* pCon=CObjectCon::NewL(); sl@0: sl@0: test(User::ValidateName(_L("xxx*xxx"))==KErrBadName); sl@0: test(User::ValidateName(_L("xxx?xxx"))==KErrBadName); sl@0: test(User::ValidateName(_L("xxx:xxx"))==KErrBadName); sl@0: test(User::ValidateName(_L("xxxxxxx"))==KErrNone); sl@0: sl@0: TPtrC name1(_S("Obj1")), name2(_S("Obj2")), name3(_S("Owner")); sl@0: pObj1->SetName(&name1); sl@0: pObj2->SetName(&name2); sl@0: pObj3->SetName(&name3); sl@0: sl@0: test(pCon->Count()==0); sl@0: pCon->AddL(pObj1); sl@0: test(pCon->Count()==1); sl@0: pCon->AddL(pObj2); sl@0: test(pCon->Count()==2); sl@0: sl@0: aFindHandle=0; sl@0: test(pCon->FindByName(aFindHandle, _L("xxx"), gName)==KErrNotFound); sl@0: aFindHandle=0; sl@0: GetObjName(gName1,*pObj1); sl@0: test(pCon->FindByName(aFindHandle, gName1, gName)==KErrNone); sl@0: test(aFindHandle==0); sl@0: aFindHandle=2; sl@0: GetObjName(gName1,*pObj1); sl@0: test(pCon->FindByName(aFindHandle, gName1, gName)==KErrNotFound); sl@0: aFindHandle=0; sl@0: GetObjName(gName1,*pObj2); sl@0: test(pCon->FindByName(aFindHandle, gName1, gName)==KErrNone); sl@0: test(aFindHandle==1); sl@0: sl@0: aFindHandle=0; sl@0: test(pCon->FindByFullName(aFindHandle, _L("xxx"), gFullName)==KErrNotFound); sl@0: aFindHandle=0; sl@0: GetObjName(gName1,*pObj1); sl@0: test(pCon->FindByFullName(aFindHandle, gName1, gFullName)==KErrNone); sl@0: test(aFindHandle==0); sl@0: GetObjName(gName1,*pObj2); sl@0: test(pCon->FindByFullName(aFindHandle, gName1, gFullName)==KErrNone); sl@0: test(aFindHandle==1); sl@0: sl@0: pObj1->SetOwner(pObj3); sl@0: pObj2->SetOwner(pObj3); sl@0: aFindHandle=0; sl@0: test(pCon->FindByFullName(aFindHandle, _L("xxx"), gFullName)==KErrNotFound); sl@0: aFindHandle=0; sl@0: GetObjFullName(gFullName1,*pObj1); sl@0: test(pCon->FindByFullName(aFindHandle, gFullName1, gFullName)==KErrNone); sl@0: test(aFindHandle==0); sl@0: GetObjFullName(gFullName1,*pObj2); sl@0: test(pCon->FindByFullName(aFindHandle, gFullName1, gFullName)==KErrNone); sl@0: test(aFindHandle==1); sl@0: sl@0: sl@0: test(pCon->CheckUniqueFullName(pObj3, _L("aname"))==KErrNone); sl@0: GetObjName(gName1,*pObj1); sl@0: test(pCon->CheckUniqueFullName(pObj3, gName1)==KErrAlreadyExists); sl@0: pCon->Remove(pObj1); sl@0: test(pCon->CheckUniqueFullName(pObj3, gName1)==KErrNone); sl@0: test(pCon->Count()==1); sl@0: pCon->AddL(pObj3); sl@0: test(pCon->Count()==2); sl@0: aFindHandle=0; sl@0: test(pCon->FindByName(aFindHandle, gName1, gName)==KErrNotFound); sl@0: aFindHandle=0; sl@0: GetObjFullName(gFullName1,*pObj1); sl@0: test(pCon->FindByFullName(aFindHandle, gFullName1, gFullName)==KErrNotFound); sl@0: aFindHandle=0; sl@0: GetObjName(gName1,*pObj2); sl@0: test(pCon->FindByName(aFindHandle, gName1, gName)==KErrNone); sl@0: test(aFindHandle==0); sl@0: GetObjFullName(gFullName1,*pObj2); sl@0: test(pCon->FindByFullName(aFindHandle, gFullName1, gFullName)==KErrNone); sl@0: test(aFindHandle==0); sl@0: GetObjName(gName1,*pObj3); sl@0: test(pCon->FindByName(aFindHandle, gName1, gName)==KErrNone); sl@0: test(aFindHandle==1); sl@0: aFindHandle=0; sl@0: test(pCon->FindByFullName(aFindHandle, _L("Owner"), gFullName)==KErrNone); sl@0: test(aFindHandle==1); sl@0: sl@0: sl@0: pObj2->__DbgTest(&dump1); sl@0: temp=pCon->At(0); sl@0: temp->__DbgTest(&dump2); sl@0: test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner && sl@0: dump1.iName==dump2.iName &&dump1.iContainer==dump2.iContainer); sl@0: pObj3->__DbgTest(&dump1); sl@0: temp=pCon->At(1); sl@0: temp->__DbgTest(&dump2); sl@0: test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner && sl@0: dump1.iName==dump2.iName &&dump1.iContainer==dump2.iContainer); sl@0: sl@0: pCon->Remove(pObj2); sl@0: pCon->Remove(pObj3); sl@0: test(pCon->Count()==0); sl@0: delete pCon; sl@0: sl@0: // Test expansion and shrinking sl@0: __UHEAP_MARK; sl@0: pCon=CObjectCon::NewL(); sl@0: CObject** obj = new CObject*[2048]; sl@0: test(obj!=0); sl@0: TInt i; sl@0: for (i=0; i<2048; ++i) sl@0: { sl@0: obj[i] = new CObject; sl@0: test(obj[i] != 0); sl@0: } sl@0: sl@0: RTestHeap* h = RTestHeap::Install(); sl@0: sl@0: const TInt xov_values[] = {0,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048}; sl@0: const TInt xov2_values[] = {1472, 960, 704, 448, 320, 192, 128, 96, 64, 48, 32, 24, 16, 12, 8, 6, 0}; sl@0: const TInt* xov_ptr = xov_values; sl@0: const TInt* xov2_ptr = xov2_values; sl@0: TInt sz = 0; sl@0: TInt xov = 0; sl@0: TAny* ptr = 0; sl@0: for (i=1; i<=2048; ++i) sl@0: { sl@0: pCon->AddL(obj[i-1]); sl@0: test(pCon->Count()==i); sl@0: RTestHeap::TOpInfo opi; sl@0: TInt r = h->GetLastOp(opi); sl@0: if (i*4 <= sz) sl@0: { sl@0: test(r==KErrNotFound); sl@0: continue; sl@0: } sl@0: test(r==KErrNone); sl@0: test.Printf(_L("Realloc at %d -> %d\n"), i, opi.iIntArg); sl@0: test(i-1 == xov); sl@0: test(opi.iOp == RTestHeap::EOpReAlloc); sl@0: test(opi.iPtrArg == ptr); sl@0: // recalc xov sl@0: xov = *++xov_ptr; sl@0: test(opi.iIntArg == xov*4); sl@0: sz = xov*4; sl@0: test(opi.iResult != 0); sl@0: ptr = opi.iResult; sl@0: } sl@0: sl@0: xov = *xov2_ptr; sl@0: for (i=2047; i>=0; --i) sl@0: { sl@0: pCon->Remove(obj[i]); sl@0: test(pCon->Count()==i); sl@0: RTestHeap::TOpInfo opi; sl@0: TInt r = h->GetLastOp(opi); sl@0: if (i>xov) sl@0: { sl@0: test(r==KErrNotFound); sl@0: continue; sl@0: } sl@0: test(r==KErrNone); sl@0: test.Printf(_L("Realloc at %d -> %d\n"), i, opi.iIntArg); sl@0: test(i == xov); sl@0: if (i==0) sl@0: { sl@0: test(opi.iOp == RTestHeap::EOpReAlloc || opi.iOp == RTestHeap::EOpFree); sl@0: } sl@0: else sl@0: { sl@0: test(opi.iOp = RTestHeap::EOpReAlloc); sl@0: test(opi.iResult == ptr); sl@0: } sl@0: test(opi.iPtrArg == ptr); sl@0: // recalc xov sl@0: xov = *++xov2_ptr; sl@0: sz = *--xov_ptr; sl@0: test(opi.iIntArg == sz*4); sl@0: } sl@0: sl@0: delete pCon; sl@0: for (i=0; i<2048; ++i) sl@0: obj[i]->Close(); sl@0: delete[] obj; sl@0: h->Uninstall(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: sl@0: sl@0: GLDEF_C void TestCObjects::Test7(void) sl@0: { sl@0: // Test the methods of CObjectIx sl@0: sl@0: // Before an object can be added to a ConIx it first has to be added to a container because the sl@0: // CObjectIx::Add method references theObject->iContainer->iName. But theObject->iContainer field sl@0: // is only set (within the CObjectCon::Add method) IF the container has first been created by the sl@0: // CObjectConIx::Create method, otherwise it is NULL and adding it to a CObjectIx will fail. sl@0: CObjectIx *pIx=CObjectIx::NewL(); sl@0: CObjectConIx *pConIx=CObjectConIx::NewL(); sl@0: CObjectCon *pCon1=pConIx->CreateL(), sl@0: *pCon2=pConIx->CreateL(); sl@0: CObject *pObj1=new CObject, sl@0: *pObj2=new CObject, sl@0: *pObj3=new CObject, sl@0: *temp; sl@0: TInt aHandle1, aHandle2, aHandle3; sl@0: TCObjectDump dump1, dump2; sl@0: TPtrC name1(_S("Obj1")), name2(_S("Obj2")), name3(_S("Obj3")); sl@0: sl@0: // Create two containers with Obj1 and Obj2 in the first and Obj3 in the second sl@0: pObj1->SetName(&name1); sl@0: pObj2->SetName(&name2); sl@0: pObj3->SetName(&name3); sl@0: pCon1->AddL(pObj1); sl@0: pCon1->AddL(pObj2); sl@0: pCon2->AddL(pObj3); sl@0: aHandle1=pIx->AddL(pObj1); sl@0: aHandle2=pIx->AddL(pObj2); sl@0: aHandle3=pIx->AddL(pObj3); sl@0: // At(TInt aHandle) sl@0: pObj1->__DbgTest(&dump1); sl@0: temp=pIx->At(aHandle1); sl@0: temp->__DbgTest(&dump2); sl@0: test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner && sl@0: dump1.iContainer==dump2.iContainer && dump1.iName==dump2.iName); sl@0: pObj2->__DbgTest(&dump1); sl@0: temp=pIx->At(aHandle2); sl@0: temp->__DbgTest(&dump2); sl@0: test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner && sl@0: dump1.iContainer==dump2.iContainer && dump1.iName==dump2.iName); sl@0: pObj3->__DbgTest(&dump1); sl@0: temp=pIx->At(aHandle3); sl@0: temp->__DbgTest(&dump2); sl@0: test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner && sl@0: dump1.iContainer==dump2.iContainer && dump1.iName==dump2.iName); sl@0: // At(TInt aHandle, TInt aUniqueID); sl@0: pObj1->__DbgTest(&dump1); sl@0: temp=pIx->At(aHandle1, 1); sl@0: temp->__DbgTest(&dump2); sl@0: test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner && sl@0: dump1.iContainer==dump2.iContainer && dump1.iName==dump2.iName); sl@0: pObj2->__DbgTest(&dump1); sl@0: temp=pIx->At(aHandle2, 1); sl@0: temp->__DbgTest(&dump2); sl@0: test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner && sl@0: dump1.iContainer==dump2.iContainer && dump1.iName==dump2.iName); sl@0: pObj3->__DbgTest(&dump1); sl@0: temp=pIx->At(aHandle3, 2); sl@0: temp->__DbgTest(&dump2); sl@0: test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner && sl@0: dump1.iContainer==dump2.iContainer && dump1.iName==dump2.iName); sl@0: // Remove(Tint aHandle) sl@0: pIx->Remove(aHandle2); sl@0: pObj1->__DbgTest(&dump1); sl@0: temp=pIx->At(aHandle1); sl@0: temp->__DbgTest(&dump2); sl@0: test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner && sl@0: dump1.iContainer==dump2.iContainer && dump1.iName==dump2.iName); sl@0: pObj3->__DbgTest(&dump1); sl@0: temp=pIx->At(aHandle3); sl@0: temp->__DbgTest(&dump2); sl@0: test(dump1.iAccessCount==dump2.iAccessCount && dump1.iOwner==dump2.iOwner && sl@0: dump1.iContainer==dump2.iContainer && dump1.iName==dump2.iName); sl@0: pIx->Remove(aHandle1); sl@0: pIx->Remove(aHandle3); sl@0: // pIx->Remove(aHandle3); this will cause a crash sl@0: sl@0: // Removing an object from a CObjectIx calls the objects close method hence in this case sl@0: // deleting it sl@0: //delete pCon1; // The destructor for a container deletes its contained objects sl@0: //delete pCon2; sl@0: delete pConIx; // The CObjectConIx destructor deletes its containers sl@0: delete pIx; // The CObjectIx destructor calls close on all its objects sl@0: } sl@0: sl@0: GLDEF_C void TestCObjects::Test8(void) sl@0: { sl@0: // Test all objects together sl@0: CObjectIx *pIx=CObjectIx::NewL(); sl@0: CObjectConIx *pConIx=CObjectConIx::NewL(); sl@0: CObjectCon *pCon1=pConIx->CreateL(), sl@0: *pCon2=pConIx->CreateL(); sl@0: CObject *pObj1=new CObject, sl@0: *pObj2=new CObject, sl@0: *pObj3=new CObject, sl@0: *pObj4=new CObject, sl@0: *pObj5=new CObject, sl@0: *temp; sl@0: TInt tempHandle; sl@0: TPtrC name1(_S("Obj1")), name2(_S("Obj2")), name3(_S("Obj3")), name4(_S("Obj4")), name5(_S("Obj5")); sl@0: sl@0: // Create two containers with Obj1,Obj2, Obj3 in the first and Obj4 and Obj5 in the second sl@0: // Obj1 owns Obj2 which owns Obj3 sl@0: pObj1->SetName(&name1); sl@0: pObj2->SetName(&name2); sl@0: pObj2->SetOwner(pObj1); sl@0: pObj3->SetName(&name3); sl@0: pObj3->SetOwner(pObj2); sl@0: pObj4->SetName(&name4); sl@0: pObj5->SetName(&name5); sl@0: pCon1->AddL(pObj1); sl@0: pCon1->AddL(pObj2); sl@0: pCon1->AddL(pObj3); sl@0: pCon2->AddL(pObj4); sl@0: pCon2->AddL(pObj5); sl@0: pIx->AddL(pObj1); sl@0: pIx->AddL(pObj2); sl@0: pIx->AddL(pObj3); sl@0: pIx->AddL(pObj4); sl@0: pIx->AddL(pObj5); sl@0: sl@0: sl@0: tempHandle=0; sl@0: GetObjName(gName1,*pObj1); sl@0: pCon1->FindByName(tempHandle, gName1, gName); sl@0: temp=pCon1->At(tempHandle); sl@0: GetObjName(gName2,*temp); sl@0: test(gName2==gName1); sl@0: tempHandle=0; sl@0: GetObjFullName(gFullName1,*pObj1); sl@0: pCon1->FindByFullName(tempHandle, gFullName1, gFullName); sl@0: temp=pCon1->At(tempHandle); sl@0: GetObjName(gName2,*temp); sl@0: test(gName2==gName1); sl@0: sl@0: tempHandle=0; sl@0: GetObjName(gName1,*pObj2); sl@0: pCon1->FindByName(tempHandle, gName1, gName); sl@0: temp=pCon1->At(tempHandle); sl@0: GetObjName(gName2,*temp); sl@0: test(gName2==gName1); sl@0: tempHandle=0; sl@0: GetObjFullName(gFullName1,*pObj2); sl@0: pCon1->FindByFullName(tempHandle, gFullName1, gFullName); sl@0: temp=pCon1->At(tempHandle); sl@0: GetObjName(gName2,*temp); sl@0: test(gName2==gName1); sl@0: sl@0: tempHandle=0; sl@0: GetObjName(gName1,*pObj3); sl@0: pCon1->FindByName(tempHandle, gName1, gName); sl@0: temp=pCon1->At(tempHandle); sl@0: GetObjName(gName2,*temp); sl@0: test(gName2==gName1); sl@0: tempHandle=0; sl@0: GetObjFullName(gFullName1,*pObj3); sl@0: pCon1->FindByFullName(tempHandle, gFullName1, gFullName); sl@0: temp=pCon1->At(tempHandle); sl@0: GetObjName(gName2,*temp); sl@0: test(gName2==gName1); sl@0: sl@0: tempHandle=0; sl@0: GetObjName(gName1,*pObj4); sl@0: pCon2->FindByName(tempHandle, gName1, gName); sl@0: temp=pCon2->At(tempHandle); sl@0: GetObjName(gName2,*temp); sl@0: test(gName2==gName1); sl@0: tempHandle=0; sl@0: GetObjFullName(gFullName1,*pObj4); sl@0: pCon2->FindByFullName(tempHandle, gFullName1, gFullName); sl@0: temp=pCon2->At(tempHandle); sl@0: GetObjName(gName2,*temp); sl@0: test(gName1==gName2); sl@0: sl@0: tempHandle=0; sl@0: GetObjName(gName1,*pObj5); sl@0: pCon2->FindByName(tempHandle, gName1, gName); sl@0: temp=pCon2->At(tempHandle); sl@0: GetObjName(gName2,*temp); sl@0: test(gName2==gName1); sl@0: tempHandle=0; sl@0: GetObjFullName(gFullName1,*pObj5); sl@0: pCon2->FindByFullName(tempHandle, gFullName1, gFullName); sl@0: temp=pCon2->At(tempHandle); sl@0: GetObjName(gName2,*temp); sl@0: test(gName2==gName1); sl@0: sl@0: sl@0: tempHandle=0; sl@0: test(pCon1->FindByName(tempHandle, _L("*1"), gName)==KErrNone); sl@0: GetObjName(gName1,*pObj1); sl@0: test(gName==gName1); sl@0: tempHandle=0; sl@0: test(pCon1->FindByFullName(tempHandle, _L("*::*"), gFullName)==KErrNone); sl@0: GetObjFullName(gFullName1,*pObj2); sl@0: test(gFullName==gFullName1); sl@0: GetObjName(gName1,*pObj3); sl@0: for(tempHandle=0;gName!=gName1;pCon1->FindByName(tempHandle, _L("????"),gName)) {}; sl@0: test(gName==gName1); sl@0: sl@0: sl@0: pObj1->Close(); // Deletes it and removes it from its container sl@0: pObj3->Close(); sl@0: tempHandle=0; sl@0: test(pCon1->FindByName(tempHandle, _L("Obj1"), gName)==KErrNotFound); sl@0: tempHandle=0; sl@0: test(pCon1->FindByName(tempHandle, _L("Obj3"), gName)==KErrNotFound); sl@0: tempHandle=0; sl@0: GetObjName(gName1,*pObj2); sl@0: test(pCon1->FindByName(tempHandle, gName1, gName)==KErrNone); sl@0: test(gName==gName1); sl@0: tempHandle=0; sl@0: //CObject* x=new CObject; sl@0: //x->SetName(_L("xxxx")); sl@0: //pCon1->FindByFullName(tempHandle, pObj2->FullName(), aFullName); sl@0: // FullName is set to Xxxx::Obj2 sl@0: sl@0: } sl@0: sl@0: GLDEF_C void TestCObjects::GetObjName(TName& aDest,const CObject& aObj) sl@0: // sl@0: // Utility function to reduce stack usage in functions, and so get rid of __chkstk errors sl@0: // sl@0: { sl@0: aDest=aObj.Name(); sl@0: } sl@0: sl@0: GLDEF_C void TestCObjects::GetObjFullName(TFullName& aDest,const CObject& aObj) sl@0: // sl@0: // Utility function to reduce stack usage in functions, and so get rid of __chkstk errors sl@0: // sl@0: { sl@0: aDest=aObj.FullName(); sl@0: } sl@0: sl@0: void testHandles() sl@0: sl@0: { sl@0: sl@0: CObjectConIx* myConIx=CObjectConIx::NewL(); sl@0: CObjectCon* myCon= myConIx->CreateL(); sl@0: CObjectIx* myIx=CObjectIx::NewL(); sl@0: test(myCon->UniqueID()!=0); sl@0: sl@0: for (TInt i=0;i<0x4006; i++) sl@0: { sl@0: CObject* myObj=new CObject; sl@0: myCon->AddL(myObj); sl@0: TInt handle=myIx->AddL(myObj); sl@0: if ((handle&0xffff0000)==0x3fff0000) sl@0: test.Printf(_L("Created biggest handle\n")); sl@0: test (handle!=0); sl@0: myIx->Remove(handle); sl@0: } sl@0: delete myIx; sl@0: delete myConIx; sl@0: } sl@0: sl@0: void testSpeed() sl@0: sl@0: { sl@0: sl@0: const TInt numObjects=0x600; sl@0: CObjectConIx* myConIx=CObjectConIx::NewL(); sl@0: CObjectCon* myCon= myConIx->CreateL(); sl@0: // CObjectIx* myIx=CObjectIx::NewL(); sl@0: TTime start; sl@0: TTime end; sl@0: TInt64 diff; sl@0: TInt i; sl@0: sl@0: start.HomeTime(); sl@0: for (i=0;iSetName(&name); sl@0: myCon->AddL(myObj); sl@0: } sl@0: end.HomeTime(); sl@0: diff=(end.Int64()-start.Int64())/100000; sl@0: test.Printf(_L("Time for 0x%08x named objects = %d tenths of secs\n"),numObjects,I64INT(diff)); sl@0: sl@0: // If run as a manual test (when enhancements to RTEST arrive) sl@0: // test.Printf(_L("Press a key to continue with these spammy tests\n")); sl@0: // test.Getch(); sl@0: sl@0: const TInt numObjects2=0x600; sl@0: // CObjectConIx* myConIx2=CObjectConIx::NewL(); sl@0: CObjectCon* myCon2= myConIx->CreateL(); sl@0: // CObjectIx* myIx2=CObjectIx::NewL(); sl@0: sl@0: start.HomeTime(); sl@0: for (i=0;iAddL(myObj); sl@0: } sl@0: end.HomeTime(); sl@0: diff=(end.Int64()-start.Int64())/100000; sl@0: test.Printf(_L("Time for 0x%08x unnamed objects = %d tenths of secs\n"),numObjects2,I64INT(diff)); sl@0: sl@0: sl@0: // If run as a manual test (when enhancements to RTEST arrive) sl@0: // test.Printf(_L("Press a key to continue with these spammy tests\n")); sl@0: // test.Getch(); sl@0: sl@0: // delete myIx; sl@0: // delete myConIx; sl@0: } sl@0: sl@0: sl@0: sl@0: const TInt KObjectIndexMask=0x7fff; sl@0: sl@0: //Tests CObjectIx class sl@0: class TestCObjectIx sl@0: { sl@0: public: sl@0: void StartL(void); sl@0: ~TestCObjectIx(); sl@0: private: sl@0: void Test1(TInt aSize); sl@0: void Test2(TInt aSize); sl@0: void Test3(TInt aSize, TBool aPerformanceTest); sl@0: inline TInt Index(TInt aHandle) {return(aHandle&KObjectIndexMask);} sl@0: sl@0: private: sl@0: struct COBjAndHandle sl@0: { sl@0: CObject* iObject; sl@0: TInt iHandle; sl@0: }; sl@0: sl@0: CObjectConIx* iMyConIx; sl@0: CObjectCon* iMyCon; sl@0: CObjectIx* iMyIx; sl@0: TUint iSeed[2]; sl@0: COBjAndHandle* iObjAndHandle; sl@0: }; sl@0: sl@0: const TInt KMaxTestObjects = (1<<11); sl@0: sl@0: //Runs all tests (methods) of the class sl@0: void TestCObjectIx::StartL(void) sl@0: { sl@0: TInt i; sl@0: iMyConIx=CObjectConIx::NewL(); sl@0: iMyCon= iMyConIx->CreateL(); sl@0: iObjAndHandle = (COBjAndHandle*) User::AllocL(KMaxTestObjects * sizeof(COBjAndHandle)); sl@0: sl@0: test.Title(); sl@0: test.Start(_L("Test CObjectIx")); sl@0: sl@0: test.Next(_L("Add and remove objects in the same order...")); sl@0: TUint32 startTime = User::NTickCount(); sl@0: for (i=1;i<2000;i=i+10) Test1(i); sl@0: test.Printf(_L("...done in %d msec\n"), User::NTickCount()-startTime); sl@0: sl@0: test.Next(_L("Add and remove objects in the reverse order...")); sl@0: startTime = User::NTickCount(); sl@0: for (i=1;i<2000;i=i+10) Test2(i); sl@0: test.Printf(_L("...done in %d msec\n"), User::NTickCount()-startTime); sl@0: sl@0: test.Next(_L("Add and remove objects in random order...")); sl@0: iSeed[0]=User::TickCount(); sl@0: test.Printf(_L("The initial seed for the random function is: S0=%xh S1=%xh\n"), iSeed[0], iSeed[1]); sl@0: for (i=2;i<=KMaxTestObjects/2; i<<=1) sl@0: Test3(i-1, EFalse); sl@0: sl@0: test.Next(_L("Add and remove objects in random order - performance test...")); sl@0: iSeed[0]=0; sl@0: iSeed[1]=1; sl@0: startTime = User::NTickCount(); sl@0: for (i=2;i<=KMaxTestObjects; i<<=1) sl@0: Test3(i-1, ETrue); sl@0: test.Printf(_L("...done in %d msec\n"), User::NTickCount()-startTime); sl@0: test.Printf(_L("CAUTION: Test changed in May 2005. Comparison of timings with those before then are not valid.\n")); sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: TestCObjectIx::~TestCObjectIx() sl@0: { sl@0: delete iMyConIx; sl@0: delete [] iObjAndHandle; sl@0: } sl@0: sl@0: //Adds a number of CObjects to CObjectIx, then removes them in the same order. sl@0: void TestCObjectIx::Test1(TInt aSize) sl@0: { sl@0: TInt i; sl@0: iMyIx=CObjectIx::NewL(); sl@0: sl@0: for (i=0; iAddL(iObjAndHandle[i].iObject); sl@0: iObjAndHandle[i].iHandle = iMyIx->AddL(iObjAndHandle[i].iObject); sl@0: } sl@0: sl@0: for (i=0; iRemove(iObjAndHandle[i].iHandle); sl@0: sl@0: delete iMyIx; sl@0: iMyIx=0; sl@0: } sl@0: sl@0: sl@0: //Adds a number of CObjects to CObjectIx, then removes them in the reverse order. sl@0: void TestCObjectIx::Test2(TInt aSize) sl@0: { sl@0: TInt i; sl@0: iMyIx=CObjectIx::NewL(); sl@0: sl@0: for (i=0; iAddL(iObjAndHandle[i].iObject); sl@0: iObjAndHandle[i].iHandle = iMyIx->AddL(iObjAndHandle[i].iObject); sl@0: } sl@0: sl@0: for (i=aSize-1; i>=aSize; i--) //Remove sl@0: iMyIx->Remove(iObjAndHandle[i].iHandle); sl@0: sl@0: delete iMyIx; sl@0: iMyIx=0; sl@0: } sl@0: sl@0: sl@0: //Adds and removes random number of CObjects to/from CObjectIx. sl@0: void TestCObjectIx::Test3(TInt aSize, TBool aPerformanceTest) sl@0: { sl@0: TInt index, x; sl@0: if(!aPerformanceTest) sl@0: test.Printf(_L("Testing size %d.The seeds are: S0=%xh S1=%xh\n"), aSize, iSeed[0], iSeed[1]); sl@0: sl@0: //---Create & init the objects we need sl@0: for (x=0; xActiveCount()+1); sl@0: //test.Printf(_L("Adding %d objects\n"), toAdd ); sl@0: while (toAdd--) sl@0: { sl@0: index=Random(iSeed)%aSize; sl@0: while (iObjAndHandle[index].iObject) //Find the next NULL pointer sl@0: { ++index; if(index>=aSize) index=0; } sl@0: if( (iObjAndHandle[index].iObject = new CObject) == NULL) User::Leave(KErrNoMemory); sl@0: iMyCon->AddL(iObjAndHandle[index].iObject); sl@0: iObjAndHandle[index].iHandle = iMyIx->AddL(iObjAndHandle[index].iObject); sl@0: //test.Printf(_L("%d(%d) "), index,iObjAndHandle[index].iHandle & 0x7fff ); sl@0: } sl@0: //test.Printf(_L("\n")); sl@0: sl@0: sl@0: //---Remove the random number of objects (in random order)--- sl@0: TInt toRemove=Random(iSeed)%(iMyIx->ActiveCount()+1); sl@0: //test.Printf(_L("Removing %d objects: "), toRemove ); sl@0: while (toRemove--) sl@0: { sl@0: index=Random(iSeed)%aSize; sl@0: while (!iObjAndHandle[index].iObject) //Find the next non-NULL pointer sl@0: { ++index; if(index>=aSize) index=0; } sl@0: //test.Printf(_L("%d(%d) "), index,iObjAndHandle[index].iHandle & 0x7fff ); sl@0: iMyIx->Remove(iObjAndHandle[index].iHandle); sl@0: iObjAndHandle[index].iObject=NULL; sl@0: } sl@0: //test.Printf(_L("\n")); sl@0: sl@0: sl@0: //---Test data consistency--- sl@0: if(aPerformanceTest) continue; sl@0: sl@0: TInt objNum=0; sl@0: for (index=0;indexAt(iObjAndHandle[index].iHandle)); sl@0: //Test Count(CObject* aObject) method sl@0: test(1==iMyIx->Count(iObjAndHandle[index].iObject)); sl@0: //Test At(CObject* aObject) method sl@0: test(iObjAndHandle[index].iHandle==iMyIx->At(iObjAndHandle[index].iObject)); sl@0: //Test operator[](TInt index) method sl@0: test(iObjAndHandle[index].iObject==(*iMyIx)[Index(iObjAndHandle[index].iHandle)]); sl@0: } sl@0: } sl@0: sl@0: test (objNum==iMyIx->ActiveCount()); sl@0: //test.Printf(_L("%d objects in array\n"), objNum); sl@0: } sl@0: sl@0: delete iMyIx; sl@0: iMyIx=NULL; sl@0: } sl@0: sl@0: // Test that things work when the unique ID of the object container grows larger sl@0: // than 15 bits sl@0: void TestCObjectConIxL(void) sl@0: { sl@0: const TInt KCObjectConLimit = 65535; sl@0: _LIT(KAnyMatch, "*"); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: CObjectConIx* conIx = CObjectConIx::NewL(); sl@0: CObjectIx* ix = CObjectIx::NewL(); sl@0: TInt i; sl@0: sl@0: test.Next(_L("Test repeated add/remove of object containers")); sl@0: for (i = 0 ; i < KCObjectConLimit * 2 ; ++i) sl@0: { sl@0: CObjectCon* con = conIx->CreateL(); sl@0: CObject* obj = new (ELeave) CObject(); sl@0: con->AddL(obj); sl@0: sl@0: TInt handle = ix->AddL(obj); sl@0: test(ix->At(handle) == obj); sl@0: test(ix->At(handle, con->UniqueID()) == obj); sl@0: sl@0: TName name; sl@0: TInt findHandle = 0; sl@0: test(con->FindByName(findHandle, KAnyMatch, name) == KErrNone); sl@0: test(con->AtL(findHandle) == obj); sl@0: test(con->At(findHandle) == obj); sl@0: test(conIx->Lookup(findHandle) == con); sl@0: test(con->FindByName(findHandle, KAnyMatch, name) == KErrNotFound); sl@0: sl@0: TFullName fullName; sl@0: findHandle = 0; sl@0: test(con->FindByFullName(findHandle, KAnyMatch, fullName) == KErrNone); sl@0: test(con->AtL(findHandle) == obj); sl@0: test(con->At(findHandle) == obj); sl@0: test(conIx->Lookup(findHandle) == con); sl@0: test(con->FindByFullName(findHandle, KAnyMatch, fullName) == KErrNotFound); sl@0: sl@0: ix->Remove(handle); sl@0: conIx->Remove(con); sl@0: } sl@0: sl@0: test.Next(_L("Test adding maximum possible number of object containers")); sl@0: RPointerArray cons; sl@0: for (i = 0 ; i < KCObjectConLimit ; ++i) sl@0: { sl@0: CObjectCon* con = conIx->CreateL(); sl@0: cons.AppendL(con); sl@0: } sl@0: TRAPD(err, conIx->CreateL()); sl@0: test(err == KErrOverflow); sl@0: sl@0: test.Next(_L("Test unique IDs are really unique after ID value has wrapped")); sl@0: for (i = 100 ; i < KCObjectConLimit ; ++i) sl@0: { sl@0: CObjectCon* con = cons[i]; sl@0: conIx->Remove(con); sl@0: } sl@0: for (i = 100 ; i < 200 ; ++i) sl@0: { sl@0: CObjectCon* con = conIx->CreateL(); sl@0: cons[i] = con; sl@0: } sl@0: for (i = 0 ; i < 200 ; ++i) sl@0: { sl@0: TName name; sl@0: TInt findHandle = 0; sl@0: CObjectCon* con = cons[i]; sl@0: sl@0: CObject* obj = new (ELeave) CObject(); sl@0: con->AddL(obj); sl@0: sl@0: test(con->FindByName(findHandle, KAnyMatch, name) == KErrNone); sl@0: test(conIx->Lookup(findHandle) == con); sl@0: sl@0: obj->Close(); sl@0: } sl@0: for (i = 0 ; i < 200 ; ++i) sl@0: { sl@0: CObjectCon* con = cons[i]; sl@0: conIx->Remove(con); sl@0: } sl@0: cons.Close(); sl@0: sl@0: delete ix; sl@0: delete conIx; sl@0: sl@0: __UHEAP_MARKEND; sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: sl@0: CTrapCleanup* trapHandler=CTrapCleanup::New(); sl@0: test(trapHandler!=NULL); sl@0: sl@0: test.Title(); sl@0: test.Start(_L("TEST METHODS ARE IN THE DLL")); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: TestCObjectIx* TCobjectIx = new TestCObjectIx; sl@0: TRAPD(ret, TCobjectIx->StartL()); sl@0: test(KErrNone == ret); sl@0: delete TCobjectIx; sl@0: sl@0: __UHEAP_MARKEND; sl@0: sl@0: test.Next(_L("Generate lots of handles")); sl@0: testHandles(); sl@0: sl@0: test.Next(_L("Test CObjectCon is fast enough")); sl@0: testSpeed(); sl@0: sl@0: TestCObjects T; sl@0: test.Next(_L("CObject methods")); sl@0: T.Test1(); sl@0: test.Next(_L("CObjectCon methods")); sl@0: T.Test2(); sl@0: test.Next(_L("CObjectIx methods")); sl@0: T.Test3(); sl@0: test.Next(_L("CObjectConIx methods")); sl@0: T.Test4(); sl@0: test.Next(_L("TEST THE METHODS")); sl@0: test.Next(_L("CObject")); sl@0: T.Test5(); sl@0: test.Next(_L("CObjectCon")); sl@0: T.Test6(); sl@0: test.Next(_L("CObjectIx")); sl@0: T.Test7(); sl@0: sl@0: ////////////////////////////// sl@0: // PROPER TESTING STARTS HERE sl@0: ////////////////////////////// sl@0: test.Next(_L("All objects")); sl@0: T.Test8(); sl@0: sl@0: test.Next(_L("CObjectConIx")); sl@0: TRAPD(err, TestCObjectConIxL()); sl@0: if (err != KErrNone) sl@0: test.Printf(_L("TestCObjectConIxL left with %d\n"), err); sl@0: test(err == KErrNone); sl@0: sl@0: test.End(); sl@0: sl@0: delete trapHandler; sl@0: return(KErrNone); sl@0: }