Update contrib.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\misc\t_uid.cpp
16 // Test handling of UIDs (Unique Identifiers).
18 // TUid, TUidType, TCheckedUid.
20 // - Assign some globally unique 32-bit numbers with specified values,
21 // get standard text form of the UID and check it is as expected.
22 // - Set the specified Uid type to be packaged and verify
23 // - validity of UID type.
24 // - Uid type contained is as expected.
25 // - component UIDs are same as specified UID.
26 // - the most derived UID is as expected.
27 // - Check the process' Uids are as expected.
28 // - Load the specified DLL, get Uid of DLL, name of this DLL's file,
29 // compare the name with a specified text and check it is as expected,
30 // verify the Uid is as expected.
31 // Platforms/Drives/Compatibility:
33 // Assumptions/Requirement/Pre-requisites:
34 // Failures and causes:
35 // Base Port information:
41 LOCAL_D RTest test(_L("T_UID"));
43 const TUid g1 = {0x10000001};
44 const TUid g11 = {0x10000001};
45 const TUid g2 = {0x10000002};
46 const TUid g22 = {0x10000002};
47 const TUid g3 = {0x10000003};
48 const TUid g33 = {0x10000003};
50 LOCAL_C void testUid()
56 test.Start(_L("All functions"));
60 TName a1Name = g1.Name();
61 TName a11Name = g11.Name();
62 TName a2Name = g2.Name();
63 TName a22Name = g22.Name();
64 test.Printf(_L("%S %S\n"),&a1Name,&a11Name);
65 test.Printf(_L("%S %S\n"),&a2Name,&a22Name);
69 LOCAL_C void testCheckedUid()
75 test.Start(_L("All functions"));
77 check1.Set(TUidType(g1));
78 test(check1.UidType().IsValid()==TRUE);
79 test(check1.UidType()[0]==g1);
80 test(check1.UidType()[1]==KNullUid);
81 test(check1.UidType()[2]==KNullUid);
82 test(check1.UidType().MostDerived()==g1);
83 test(check1.UidType().IsPresent(g1)==TRUE);
84 test(check1.UidType().IsPresent(g2)==FALSE);
85 test(check1.UidType().IsPresent(g3)==FALSE);
87 check2.Set(TUidType(g1,g2));
88 test(check2.UidType().IsValid()==TRUE);
89 test(check2.UidType()[0]==g1);
90 test(check2.UidType()[1]==g2);
91 test(check2.UidType()[2]==KNullUid);
92 test(check2.UidType().MostDerived()==g2);
93 test(check2.UidType().IsPresent(g1)==TRUE);
94 test(check2.UidType().IsPresent(g2)==TRUE);
95 test(check2.UidType().IsPresent(g3)==FALSE);
97 check3.Set(TUidType(g1,g2,g3));
98 test(check3.UidType().IsValid()==TRUE);
99 test(check3.UidType()[0]==g1);
100 test(check3.UidType()[1]==g2);
101 test(check3.UidType()[2]==g3);
102 test(check3.UidType().MostDerived()==g3);
103 test(check3.UidType().IsPresent(g1)==TRUE);
104 test(check3.UidType().IsPresent(g2)==TRUE);
105 test(check3.UidType().IsPresent(g3)==TRUE);
106 HBufC8* pH=check3.Des().Alloc();
107 TUidType t1(g3,check3.UidType()[1],check3.UidType()[2]);
109 test(check3.UidType().IsValid()==TRUE);
110 TUidType t2(g3,g1,check3.UidType()[2]);
112 test(check3.UidType().IsValid()==TRUE);
113 TUidType t3(g3,g1,g2);
115 test(check3.UidType().IsValid()==TRUE);
116 test(check3.UidType()[0]==g3);
117 test(check3.UidType()[1]==g1);
118 test(check3.UidType()[2]==g2);
119 test(check3.UidType().IsPresent(g1)==TRUE);
120 test(check3.UidType().IsPresent(g2)==TRUE);
121 test(check3.UidType().IsPresent(g3)==TRUE);
123 test(check3.UidType().IsValid()==TRUE);
124 test(check3.UidType()[0]==g1);
125 test(check3.UidType()[1]==g2);
126 test(check3.UidType()[2]==g3);
127 test(check3.UidType().IsPresent(g1)==TRUE);
128 test(check3.UidType().IsPresent(g2)==TRUE);
129 test(check3.UidType().IsPresent(g3)==TRUE);
130 TCheckedUid check4(*pH);
132 test(check4.UidType().IsValid()==TRUE);
133 test(check4.UidType()[0]==g1);
134 test(check4.UidType()[1]==g2);
135 test(check4.UidType()[2]==g3);
140 GLDEF_C TInt E32Main()
142 // Test Uid handling.
148 test.Start(_L("Uid tests"));
151 test.Next(_L("Checked Uid tests"));
154 test.Next(_L("Check this process's Uids"));
155 test(RProcess().Type()[1]==TUid::Uid(0x22222222));
156 test(RProcess().Type()[2]==TUid::Uid(0x33333333));
158 test.Next(_L("Load Uid DLL"));
160 TInt r=lib.Load(_L("T_DUID.DLL"));
162 test.Next(_L("Test FileName"));
163 test.Printf(lib.FileName());
164 test.Printf(_L("\n"));
166 #if defined(__WINS__)
167 if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
168 test(lib.FileName().CompareF(_L("Z:\\Sys\\Bin\\T_DUID.DLL"))==0);
170 test(lib.FileName().CompareF(_L("Z:\\System\\Bin\\T_DUID.DLL"))==0);
172 if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
173 test(lib.FileName().MatchF(_L("?:\\Sys\\Bin\\T_DUID.DLL"))!=KErrNotFound);
175 test(lib.FileName().MatchF(_L("?:\\System\\Bin\\T_DUID.DLL"))!=KErrNotFound);
177 test.Next(_L("Check DLL Uid"));
178 test(lib.Type()[1]==TUid::Uid(0x12345678));
179 test(lib.Type()[2]==TUid::Uid(0x87654321));