sl@0: // Copyright (c) 1997-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_regram.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: sl@0: // sl@0: // This test takes forever to run and destroys the internal Ram drive. sl@0: // sl@0: sl@0: LOCAL_D RTest test(_L("T_REGRAM")); sl@0: sl@0: void deleteReg() sl@0: // sl@0: // Delete everything from the registry sl@0: // sl@0: { sl@0: TUid uid; sl@0: TRegistryIter riter; sl@0: riter.Reset(); sl@0: while (riter.Next(uid)==KErrNone) sl@0: { sl@0: TRegistryCategory cat(uid); sl@0: cat.DeleteAllItems(); sl@0: } sl@0: } sl@0: sl@0: TInt fillReg(const TDesC8 &aDes, TInt aEntries) sl@0: // sl@0: // Fill the registry with big nasty monsters sl@0: // returns the number of entries made. sl@0: // sl@0: { sl@0: TBuf8<0x100> buf=_L8(""); sl@0: TInt i; sl@0: for (i=0; i<8; i++) sl@0: buf.Append(_L8("Big_ nasty_ monster_ chasing_ me")); sl@0: sl@0: TUid uid; sl@0: uid=TUid::Uid(0x12345678); sl@0: TRegistryCategory cat(uid); sl@0: i=0; sl@0: TBuf8<0x20> item; sl@0: while (i item; sl@0: TInt i=aEntries-1; sl@0: while (i>=0) sl@0: { sl@0: item.Format(_L8("%S %08x"),&aDes,i); sl@0: TInt r=cat.DeleteItem(item); sl@0: if (r!=KErrNone) sl@0: break; sl@0: i--; sl@0: } sl@0: return aEntries-i-1; sl@0: } sl@0: sl@0: TInt testReg(const TDesC8 &aDes, TInt aEntries) sl@0: // sl@0: // Test the first aEntries entries are set correctly sl@0: // sl@0: { sl@0: TBuf8<0x100> buf=_L8(""); sl@0: TInt i; sl@0: for (i=0; i<8; i++) sl@0: buf.Append(_L8("Big_ nasty_ monster_ chasing_ me")); sl@0: sl@0: TUid uid; sl@0: uid=TUid::Uid(0x12345678); sl@0: TRegistryCategory cat(uid); sl@0: sl@0: TBuf8<0x20> item; sl@0: TBuf8<0x100> res; sl@0: i=0; sl@0: while (i infoPckg(info); sl@0: test(aRamDrive.Caps(infoPckg)==KErrNone); sl@0: TInt size=info.iSize.Low(); sl@0: TInt i; sl@0: TPckgBuf dataBuf; sl@0: TInt &data=dataBuf(); sl@0: for (i=0; i infoPckg(info); sl@0: test(aRamDrive.Caps(infoPckg)==KErrNone); sl@0: TInt size=info.iSize.Low(); sl@0: TInt i; sl@0: TPckgBuf dataBuf; sl@0: TInt &data=dataBuf(); sl@0: for (i=0; i infoPckg(info); sl@0: test(aRamDrive.Caps(infoPckg)==KErrNone); sl@0: TInt oldsize=info.iSize.Low(); sl@0: if (aSize>oldsize) sl@0: test(aRamDrive.Enlarge(aSize-oldsize)==KErrNone); sl@0: else sl@0: test(aRamDrive.ReduceSize(0,oldsize-aSize)==KErrNone); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main(void) sl@0: // sl@0: // Test the Ram Drive and the Registry sl@0: // sl@0: { sl@0: sl@0: test.Title(); sl@0: sl@0: test.Start(_L("Connect to the Local Drive")); sl@0: TBool changedFlag; sl@0: TBusLocalDrive ramDrive; sl@0: TInt r=ramDrive.Connect(0,changedFlag); sl@0: test(r==KErrNone); sl@0: sl@0: test.Next(_L("Test testing the ram drive")); sl@0: fillRamDrive(ramDrive); sl@0: testRamDrive(ramDrive); sl@0: sl@0: test.Next(_L("Simple grow test")); sl@0: fillRamDrive(ramDrive); sl@0: testGrow(); sl@0: testRamDrive(ramDrive); sl@0: test.Next(_L("Shrink")); sl@0: deleteReg(); sl@0: testRamDrive(ramDrive); sl@0: sl@0: { sl@0: deleteReg(); sl@0: test.Next(_L("Grow the registry a bit")); sl@0: TInt n=fillReg(_L8("Run Away"),40); sl@0: test.Next(_L("Test the content of the registry")); sl@0: TInt m=testReg(_L8("Run Away"),n); sl@0: test(n==m); sl@0: test.Next(_L("Shrink it a bit")); sl@0: m=shrinkReg(_L8("Run Away"),n); sl@0: test(n==m); sl@0: test.Next(_L("test ram drive")); sl@0: testRamDrive(ramDrive); sl@0: } sl@0: sl@0: /* test.Next(_L("Run the tests with the current ram drive size")); sl@0: fillRamDrive(ramDrive); sl@0: test1(); sl@0: testRamDrive(ramDrive);*/ sl@0: sl@0: test.Next(_L("Run the tests with no Ram Drive")); sl@0: setRamDriveSize(ramDrive, 0); sl@0: test1(); sl@0: sl@0: test.Next(_L("Run the tests with small ram drive")); sl@0: setRamDriveSize(ramDrive, 0x3000); sl@0: fillRamDrive(ramDrive); sl@0: test1(); sl@0: testRamDrive(ramDrive); sl@0: sl@0: test.Next(_L("Clear the registry")); sl@0: deleteReg(); sl@0: sl@0: /* test.Next(_L("Run the tests with a big ram drive")); sl@0: r=KErrGeneral; sl@0: while (r==KErrNone) sl@0: r=ramDrive.Enlarge(0x1000); sl@0: test.Printf(_L("%d"), r); sl@0: // test(r==KErrDiskFull); sl@0: r=ramDrive.ReduceSize(0, 0x2000); sl@0: test(r==KErrNone); sl@0: fillRamDrive(ramDrive); sl@0: test1(); sl@0: testRamDrive(ramDrive);*/ sl@0: sl@0: ramDrive.Disconnect(); sl@0: sl@0: test.End(); sl@0: return(KErrNone); sl@0: } sl@0: