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\misc\t_uid.cpp sl@0: // Overview: sl@0: // Test handling of UIDs (Unique Identifiers). sl@0: // API Information: sl@0: // TUid, TUidType, TCheckedUid. sl@0: // Details: sl@0: // - Assign some globally unique 32-bit numbers with specified values, sl@0: // get standard text form of the UID and check it is as expected. sl@0: // - Set the specified Uid type to be packaged and verify sl@0: // - validity of UID type. sl@0: // - Uid type contained is as expected. sl@0: // - component UIDs are same as specified UID. sl@0: // - the most derived UID is as expected. sl@0: // - Check the process' Uids are as expected. sl@0: // - Load the specified DLL, get Uid of DLL, name of this DLL's file, sl@0: // compare the name with a specified text and check it is as expected, sl@0: // verify the Uid is 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: sl@0: LOCAL_D RTest test(_L("T_UID")); sl@0: sl@0: const TUid g1 = {0x10000001}; sl@0: const TUid g11 = {0x10000001}; sl@0: const TUid g2 = {0x10000002}; sl@0: const TUid g22 = {0x10000002}; sl@0: const TUid g3 = {0x10000003}; sl@0: const TUid g33 = {0x10000003}; sl@0: sl@0: LOCAL_C void testUid() sl@0: // sl@0: // Test UIDs sl@0: // sl@0: { sl@0: sl@0: test.Start(_L("All functions")); sl@0: test(g1==g11); sl@0: test(g2==g22); sl@0: test(g1!=g2); sl@0: TName a1Name = g1.Name(); sl@0: TName a11Name = g11.Name(); sl@0: TName a2Name = g2.Name(); sl@0: TName a22Name = g22.Name(); sl@0: test.Printf(_L("%S %S\n"),&a1Name,&a11Name); sl@0: test.Printf(_L("%S %S\n"),&a2Name,&a22Name); sl@0: test.End(); sl@0: } sl@0: sl@0: LOCAL_C void testCheckedUid() sl@0: // sl@0: // Test checked UIDs sl@0: // sl@0: { sl@0: sl@0: test.Start(_L("All functions")); sl@0: TCheckedUid check1; sl@0: check1.Set(TUidType(g1)); sl@0: test(check1.UidType().IsValid()==TRUE); sl@0: test(check1.UidType()[0]==g1); sl@0: test(check1.UidType()[1]==KNullUid); sl@0: test(check1.UidType()[2]==KNullUid); sl@0: test(check1.UidType().MostDerived()==g1); sl@0: test(check1.UidType().IsPresent(g1)==TRUE); sl@0: test(check1.UidType().IsPresent(g2)==FALSE); sl@0: test(check1.UidType().IsPresent(g3)==FALSE); sl@0: TCheckedUid check2; sl@0: check2.Set(TUidType(g1,g2)); sl@0: test(check2.UidType().IsValid()==TRUE); sl@0: test(check2.UidType()[0]==g1); sl@0: test(check2.UidType()[1]==g2); sl@0: test(check2.UidType()[2]==KNullUid); sl@0: test(check2.UidType().MostDerived()==g2); sl@0: test(check2.UidType().IsPresent(g1)==TRUE); sl@0: test(check2.UidType().IsPresent(g2)==TRUE); sl@0: test(check2.UidType().IsPresent(g3)==FALSE); sl@0: TCheckedUid check3; sl@0: check3.Set(TUidType(g1,g2,g3)); sl@0: test(check3.UidType().IsValid()==TRUE); sl@0: test(check3.UidType()[0]==g1); sl@0: test(check3.UidType()[1]==g2); sl@0: test(check3.UidType()[2]==g3); sl@0: test(check3.UidType().MostDerived()==g3); sl@0: test(check3.UidType().IsPresent(g1)==TRUE); sl@0: test(check3.UidType().IsPresent(g2)==TRUE); sl@0: test(check3.UidType().IsPresent(g3)==TRUE); sl@0: HBufC8* pH=check3.Des().Alloc(); sl@0: TUidType t1(g3,check3.UidType()[1],check3.UidType()[2]); sl@0: check3=t1; sl@0: test(check3.UidType().IsValid()==TRUE); sl@0: TUidType t2(g3,g1,check3.UidType()[2]); sl@0: check3=t2; sl@0: test(check3.UidType().IsValid()==TRUE); sl@0: TUidType t3(g3,g1,g2); sl@0: check3=t3; sl@0: test(check3.UidType().IsValid()==TRUE); sl@0: test(check3.UidType()[0]==g3); sl@0: test(check3.UidType()[1]==g1); sl@0: test(check3.UidType()[2]==g2); sl@0: test(check3.UidType().IsPresent(g1)==TRUE); sl@0: test(check3.UidType().IsPresent(g2)==TRUE); sl@0: test(check3.UidType().IsPresent(g3)==TRUE); sl@0: check3.Set(*pH); sl@0: test(check3.UidType().IsValid()==TRUE); sl@0: test(check3.UidType()[0]==g1); sl@0: test(check3.UidType()[1]==g2); sl@0: test(check3.UidType()[2]==g3); sl@0: test(check3.UidType().IsPresent(g1)==TRUE); sl@0: test(check3.UidType().IsPresent(g2)==TRUE); sl@0: test(check3.UidType().IsPresent(g3)==TRUE); sl@0: TCheckedUid check4(*pH); sl@0: delete pH; sl@0: test(check4.UidType().IsValid()==TRUE); sl@0: test(check4.UidType()[0]==g1); sl@0: test(check4.UidType()[1]==g2); sl@0: test(check4.UidType()[2]==g3); sl@0: // sl@0: test.End(); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: // sl@0: // Test Uid handling. sl@0: // sl@0: { sl@0: sl@0: test.Title(); sl@0: // sl@0: test.Start(_L("Uid tests")); sl@0: testUid(); sl@0: // sl@0: test.Next(_L("Checked Uid tests")); sl@0: testCheckedUid(); sl@0: // sl@0: test.Next(_L("Check this process's Uids")); sl@0: test(RProcess().Type()[1]==TUid::Uid(0x22222222)); sl@0: test(RProcess().Type()[2]==TUid::Uid(0x33333333)); sl@0: sl@0: test.Next(_L("Load Uid DLL")); sl@0: RLibrary lib; sl@0: TInt r=lib.Load(_L("T_DUID.DLL")); sl@0: test(r==KErrNone); sl@0: test.Next(_L("Test FileName")); sl@0: test.Printf(lib.FileName()); sl@0: test.Printf(_L("\n")); sl@0: sl@0: #if defined(__WINS__) sl@0: if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)) sl@0: test(lib.FileName().CompareF(_L("Z:\\Sys\\Bin\\T_DUID.DLL"))==0); sl@0: else sl@0: test(lib.FileName().CompareF(_L("Z:\\System\\Bin\\T_DUID.DLL"))==0); sl@0: #else sl@0: if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)) sl@0: test(lib.FileName().MatchF(_L("?:\\Sys\\Bin\\T_DUID.DLL"))!=KErrNotFound); sl@0: else sl@0: test(lib.FileName().MatchF(_L("?:\\System\\Bin\\T_DUID.DLL"))!=KErrNotFound); sl@0: #endif sl@0: test.Next(_L("Check DLL Uid")); sl@0: test(lib.Type()[1]==TUid::Uid(0x12345678)); sl@0: test(lib.Type()[2]==TUid::Uid(0x87654321)); sl@0: lib.Close(); sl@0: test.End(); sl@0: return(KErrNone); sl@0: } sl@0: sl@0: sl@0: