sl@0: // Copyright (c) 1996-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_reg.cpp sl@0: // Overview: sl@0: // Test the machine configuration functions sl@0: // API Information: sl@0: // User::MachineConfiguration, User::SetMachineConfiguration sl@0: // Details: sl@0: // - Save machine configuration to different size descriptors and verify sl@0: // the results are as expected. sl@0: // - Set the machine configuration back to previous configurations, verify sl@0: // the results are 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: sl@0: LOCAL_D RTest test(_L("T_REG")); sl@0: sl@0: sl@0: LOCAL_C void testMachineConfiguration() sl@0: // sl@0: // Test the machine configuration functions sl@0: // sl@0: { sl@0: sl@0: test.Start(_L("Create test environment")); sl@0: // sl@0: test.Next(_L("Save machine configuration to tiny descriptor")); sl@0: TInt x=0; sl@0: TPtr8 mc11((TUint8*)&x,sizeof(x)); sl@0: test(User::MachineConfiguration(mc11,x)==KErrArgument); sl@0: test(x!=0); sl@0: test(x<10000); sl@0: // sl@0: test.Next(_L("Save machine configuration to just too small descriptor")); sl@0: TUint8* pMC1=(TUint8*)User::Alloc(x); sl@0: test(pMC1!=NULL); sl@0: TInt y; sl@0: TPtr8 mc12(pMC1,x-1); sl@0: test(User::MachineConfiguration(mc12,y)==KErrArgument); sl@0: test(y==x); sl@0: // sl@0: test.Next(_L("Save machine configuration properly")); sl@0: TPtr8 mc13(pMC1,x); sl@0: test(User::MachineConfiguration(mc13,y)==KErrNone); sl@0: test(y==x); sl@0: // sl@0: test.Next(_L("Save machine configuration to tiny descriptor")); sl@0: TInt z=0; sl@0: TPtr8 mc21((TUint8*)&z,sizeof(z)); sl@0: test(User::MachineConfiguration(mc21,z)==KErrArgument); sl@0: test(z!=0); sl@0: test(z<10000); sl@0: // sl@0: test.Next(_L("Save machine configuration to just too small descriptor")); sl@0: TUint8* pMC2=(TUint8*)User::Alloc(z); sl@0: test(pMC2!=NULL); sl@0: TPtr8 mc22(pMC2,z-1); sl@0: test(User::MachineConfiguration(mc22,y)==KErrArgument); sl@0: test(y==z); sl@0: // sl@0: test.Next(_L("Save machine configuration properly")); sl@0: TPtr8 mc23(pMC2,z); sl@0: test(User::MachineConfiguration(mc23,y)==KErrNone); sl@0: test(y==z); sl@0: // sl@0: // __KHEAP_MARK; // GLD 3/2/97 I don't know why the KHEAP checking is no longer working sl@0: test.Next(_L("Restore first configuration")); sl@0: test(User::SetMachineConfiguration(TPtrC8(pMC1,x))==KErrNone); sl@0: // __KHEAP_CHECK(0); sl@0: // sl@0: test.Next(_L("Restore second configuration")); sl@0: test(User::SetMachineConfiguration(TPtrC8(pMC2,z))==KErrNone); sl@0: // __KHEAP_MARKEND; sl@0: // sl@0: test.Next(_L("Tidy up")); sl@0: delete pMC1; sl@0: delete pMC2; sl@0: test.End(); sl@0: } sl@0: sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: // sl@0: // Test the registry functions. sl@0: // sl@0: { sl@0: sl@0: test.Title(); sl@0: // sl@0: test.Start(_L("Test Machine Configuration")); sl@0: testMachineConfiguration(); sl@0: // sl@0: test.End(); sl@0: return(KErrNone); sl@0: } sl@0: