First public contribution.
1 // Copyright (c) 2001-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 "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.
16 #include "CUriAndAuthorityTest.h"
20 #include "UriAndAuthorityTestCommon.h"
21 #include <uriutilscommon.h>
23 #include "UriAndAuthorityTests.h"
24 #include "SipUriAndAuthorityTests.h"
26 CUriAndAuthorityTest* CUriAndAuthorityTest::NewLC(CIpuTestHarness* aTestHarness)
28 CUriAndAuthorityTest* self = new (ELeave) CUriAndAuthorityTest(aTestHarness);
29 CleanupStack::PushL(self);
34 CUriAndAuthorityTest* CUriAndAuthorityTest::NewL(CIpuTestHarness* aTestHarness)
36 CUriAndAuthorityTest* self = CUriAndAuthorityTest::NewLC(aTestHarness);
37 CleanupStack::Pop(self);
41 CUriAndAuthorityTest::CUriAndAuthorityTest(CIpuTestHarness* aTestHarness)
42 : iTestHarness(aTestHarness)
46 void CUriAndAuthorityTest::ConstructL()
50 CUriAndAuthorityTest::~CUriAndAuthorityTest()
54 void CUriAndAuthorityTest::DoTestsL()
56 // Test TUriParser Component Extraction
57 TestUriComponentExtractionL(KComps0, KScheme0, KUserInfo0, KHost0, KPort0, KPath0, KQuery0, KFragment0);
58 TestUriComponentExtractionL(KComps1, KScheme1, KUserInfo1, KHost1, KPort1, KPath1, KQuery1, KFragment1);
59 TestUriComponentExtractionL(KComps2, KScheme2, KUserInfo2, KHost2, KPort2, KPath2, KQuery2, KFragment2);
60 TestUriComponentExtractionL(KComps3, KScheme3, KUserInfo3, KHost3, KPort3, KPath3, KQuery3, KFragment3);
61 TestUriComponentExtractionL(KComps4, KScheme4, KUserInfo4, KHost4, KPort4, KPath4, KQuery4, KFragment4);
62 TestUriComponentExtractionL(KComps5, KScheme5, KUserInfo5, KHost5, KPort5, KPath5, KQuery5, KFragment5);
63 TestUriComponentExtractionL(KComps6, KScheme6, KUserInfo6, KHost6, KPort6, KPath6, KQuery6, KFragment6);
64 TestUriComponentExtractionL(KComps10, KScheme10, KUserInfo10, KHost10, KPort10, KPath10, KQuery10, KFragment10);
65 TestUriComponentExtractionL(KComps11, KScheme11, KUserInfo11, KHost11, KPort11, KPath11, KQuery11, KFragment11);
66 TestUriComponentExtractionL(KComps12, KScheme12, KUserInfo12, KHost12, KPort12, KPath12, KQuery12, KFragment12);
67 TestUriComponentExtractionL(KComps13, KScheme13, KUserInfo13, KHost13, KPort13, KPath13, KQuery13, KFragment13);
68 TestUriComponentExtractionL(KComps14, KScheme14, KUserInfo14, KHost14, KPort14, KPath14, KQuery14, KFragment14);
69 TestUriComponentExtractionL(KComps15, KScheme15, KUserInfo15, KHost15, KPort15, KPath15, KQuery15, KFragment15);
70 TestUriComponentExtractionL(KComps16, KScheme16, KUserInfo16, KHost16, KPort16, KPath16, KQuery16, KFragment16);
71 TestUriComponentExtractionL(KComps17, KScheme17, KUserInfo17, KHost17, KPort17, KPath17, KQuery17, KFragment17);
72 TestUriComponentExtractionL(KComps18, KScheme18, KUserInfo18, KHost18, KPort18, KPath18, KQuery18, KFragment18);
73 TestUriComponentExtractionL(KComps19, KScheme19, KUserInfo19, KHost19, KPort19, KPath19, KQuery19, KFragment19);
74 TestUriComponentExtractionL(KComps20, KScheme20, KUserInfo20, KHost20, KPort20, KPath20, KQuery20, KFragment20);
75 TestUriComponentExtractionL(KComps21, KScheme21, KUserInfo21, KHost21, KPort21, KPath21, KQuery21, KFragment21);
76 TestUriComponentExtractionL(KComps22, KScheme22, KUserInfo22, KHost22, KPort22, KPath22, KQuery22, KFragment22);
77 TestUriComponentExtractionL(KComps23, KScheme23, KUserInfo23, KHost23, KPort23, KPath23, KQuery23, KFragment23);
78 TestUriComponentExtractionL(KComps24, KScheme24, KUserInfo24, KHost24, KPort24, KPath24, KQuery24, KFragment24);
79 TestUriComponentExtractionL(KComps25, KScheme25, KUserInfo25, KHost25, KPort25, KPath25, KQuery25, KFragment25);
80 TestUriComponentExtractionL(KComps26, KScheme26, KUserInfo26, KHost26, KPort26, KPath26, KQuery26, KFragment26);
81 TestUriComponentExtractionL(KComps27, KScheme27, KUserInfo27, KHost27, KPort27, KPath27, KQuery27, KFragment27);
82 TestUriComponentExtractionL(KComps28, KScheme28, KUserInfo28, KHost28, KPort28, KPath28, KQuery28, KFragment28);
83 TestUriComponentExtractionL(KComps29, KScheme29, KUserInfo29, KHost29, KPort29, KPath29, KQuery29, KFragment29);
86 // IPv6 Test cases Section 2.9.1
87 TestUriComponentExtractionL(KComps30, KScheme30, KUserInfo30, KHost30, KPort30, KPath30, KQuery30, KFragment30);
88 TestUriComponentExtractionL(KComps31, KScheme31, KUserInfo31, KHost31, KPort31, KPath31, KQuery31, KFragment31);
89 TestUriComponentExtractionL(KComps32, KScheme32, KUserInfo32, KHost32, KPort32, KPath32, KQuery32, KFragment32);
90 TestUriComponentExtractionL(KComps33, KScheme33, KUserInfo33, KHost33, KPort33, KPath33, KQuery33, KFragment33);
91 TestUriComponentExtractionL(KComps34, KScheme34, KUserInfo34, KHost34, KPort34, KPath34, KQuery34, KFragment34);
92 TestUriComponentExtractionL(KComps35, KScheme35, KUserInfo35, KHost35, KPort35, KPath35, KQuery35, KFragment35);
93 TestUriComponentExtractionL(KComps36, KScheme36, KUserInfo36, KHost36, KPort36, KPath36, KQuery36, KFragment36);
95 TestAuthorityComponentExtractionL(KAuthority0, KUserInfo0, KHost0, KPort0);
96 TestAuthorityComponentExtractionL(KAuthority1, KUserInfo1, KHost1, KPort1);
97 TestAuthorityComponentExtractionL(KAuthority2, KUserInfo2, KHost2, KPort2);
98 TestAuthorityComponentExtractionL(KAuthority3, KUserInfo3, KHost3, KPort3);
99 TestAuthorityComponentExtractionL(KAuthority4, KUserInfo4, KHost4, KPort4);
100 TestAuthorityComponentExtractionL(KAuthority5, KUserInfo5, KHost5, KPort5);
101 TestAuthorityComponentExtractionL(KAuthority6, KUserInfo6, KHost6, KPort6);
102 TestAuthorityComponentExtractionL(KAuthority10, KUserInfo10, KHost10, KPort10);
103 TestAuthorityComponentExtractionL(KAuthority11, KUserInfo11, KHost11, KPort11);
104 TestAuthorityComponentExtractionL(KAuthority12, KUserInfo12, KHost12, KPort12);
105 TestAuthorityComponentExtractionL(KAuthority13, KUserInfo13, KHost13, KPort13);
106 TestAuthorityComponentExtractionL(KAuthority14, KUserInfo14, KHost14, KPort14);
107 TestAuthorityComponentExtractionL(KAuthority15, KUserInfo15, KHost15, KPort15);
108 TestAuthorityComponentExtractionL(KAuthority16, KUserInfo16, KHost16, KPort16);
109 TestAuthorityComponentExtractionL(KAuthority17, KUserInfo17, KHost17, KPort17);
110 TestAuthorityComponentExtractionL(KAuthority18, KUserInfo18, KHost18, KPort18);
111 TestAuthorityComponentExtractionL(KAuthority19, KUserInfo19, KHost19, KPort19);
112 TestAuthorityComponentExtractionL(KAuthority20, KUserInfo20, KHost20, KPort20);
113 TestAuthorityComponentExtractionL(KAuthority21, KUserInfo21, KHost21, KPort21);
114 TestAuthorityComponentExtractionL(KAuthority22, KUserInfo22, KHost22, KPort22);
115 TestAuthorityComponentExtractionL(KAuthority23, KUserInfo23, KHost23, KPort23);
116 TestAuthorityComponentExtractionL(KAuthority24, KUserInfo24, KHost24, KPort24);
117 TestAuthorityComponentExtractionL(KAuthority25, KUserInfo25, KHost25, KPort25);
118 TestAuthorityComponentExtractionL(KAuthority26, KUserInfo26, KHost26, KPort26);
119 TestAuthorityComponentExtractionL(KAuthority27, KUserInfo27, KHost27, KPort27);
120 TestAuthorityComponentExtractionL(KAuthority28, KUserInfo28, KHost28, KPort28);
121 TestAuthorityComponentExtractionL(KAuthority29, KUserInfo29, KHost29, KPort29);
124 TestAuthorityComponentExtractionL(KAuthority30, KUserInfo30, KHost30, KPort30);
125 TestAuthorityComponentExtractionL(KAuthority31, KUserInfo31, KHost31, KPort31);
126 TestAuthorityComponentExtractionL(KAuthority32, KUserInfo32, KHost32, KPort32);
127 TestAuthorityComponentExtractionL(KAuthority33, KUserInfo33, KHost33, KPort33);
128 TestAuthorityComponentExtractionL(KAuthority34, KUserInfo34, KHost34, KPort34);
129 TestAuthorityComponentExtractionL(KAuthority35, KUserInfo35, KHost35, KPort35);
130 TestAuthorityComponentExtractionL(KAuthority36, KUserInfo36, KHost36, KPort36);
132 TestResolveL(KBase,KRelative1,KResolved1);
133 TestResolveL(KBase,KRelative2,KResolved2);
134 TestResolveL(KBase,KRelative3,KResolved3);
135 TestResolveL(KBase,KRelative4,KResolved4);
136 TestResolveL(KBase,KRelative5,KResolved5);
137 TestResolveL(KBase,KRelative6,KResolved6);
138 TestResolveL(KBase,KRelative7,KResolved7);
139 TestResolveL(KBase,KRelative8,KResolved8);
140 TestResolveL(KBase,KRelative9,KResolved9);
141 TestResolveL(KBase,KRelative10,KResolved10);
142 TestResolveL(KBase,KRelative11,KResolved11);
143 TestResolveL(KBase,KRelative12,KResolved12);
144 TestResolveL(KBase,KRelative13,KResolved13);
145 TestResolveL(KBase,KRelative14,KResolved14);
146 TestResolveL(KBase,KRelative15,KResolved15);
147 TestResolveL(KBase,KRelative16,KResolved16);
148 TestResolveL(KBase,KRelative17,KResolved17);
149 TestResolveL(KBase,KRelative18,KResolved18);
150 TestResolveL(KBase,KRelative19,KResolved19);
151 TestResolveL(KBase,KRelative20,KResolved20);
152 TestResolveL(KBase,KRelative21,KResolved21);
153 TestResolveL(KBase,KRelative22,KResolved22);
155 TestResolveL(KBase,KRelative23,KResolved23);
156 TestResolveL(KBase,KRelative24,KResolved24);
157 TestResolveL(KBase,KRelative25,KResolved25);
158 TestResolveL(KBase,KRelative26,KResolved26);
159 TestResolveL(KBase,KRelative27,KResolved27);
160 TestResolveL(KBase,KRelative28,KResolved28);
161 TestResolveL(KBase,KRelative29,KResolved29);
162 TestResolveL(KBase,KRelative30,KResolved30);
164 TestResolveL(KBase,KRelative31,KResolved31);
165 TestResolveL(KBase,KRelative32,KResolved32);
166 TestResolveL(KBase,KRelative33,KResolved33);
167 TestResolveL(KBase,KRelative34,KResolved34);
168 TestResolveL(KBase,KRelative35,KResolved35);
169 TestResolveL(KBase,KRelative36,KResolved36);
171 TestResolveL(KBase,KRelative37,KResolved37);
172 TestResolveL(KBase,KRelative38,KResolved38);
173 TestResolveL(KBase,KRelative39,KResolved39);
174 TestResolveL(KBase,KRelative40,KResolved40);
176 TestResolveL(KBase,KRelative41,KResolved41);
178 TestResolveL(KBase,KRelative42,KResolved42);
180 iTestHarness->LogIt(_L("Next Test - Defect EDNMTAN-4H9K6A, CUrlWrap::ResolveL does not parse file Urls properly"));
181 TestResolveL(KBaseFile, KRelativeFile1, KResolvedFile1);
183 iTestHarness->LogIt(_L("Next Test - Defect EDNSTAR-4HTNB4, CUrlWrap::ResolveL panics with zero length aUrlBase"));
184 TestResolveL(KNullDesC, KRelativeFile1, KRelativeFile1);
186 iTestHarness->LogIt(_L("Next Test - Defect EDNPHAD-4J6EUY, CUrlWrap::ResolveL fails when the base and relative URLs both have fragments"));
187 TestResolveL(KBaseBug1, KRelativeBug1, KResolvedBug1);
188 TestResolveL(KBaseBug2, KRelativeBug2, KResolvedBug2);
189 TestResolveL(KBaseBug2, KRelativeBug3, KResolvedBug3);
191 iTestHarness->LogIt(_L("Next Test - Defect EDNFUDN-4JYFH7, CUrl overflow causes WINS crash during sub-doc fetch"));
192 TestResolveL(KBaseBug3, KRelativeBug4, KResolvedBug4);
194 TestUriCompareL(KUri_Compare0_a, KUri_Compare0_b, KUriMatchFlags0);
195 TestUriCompareL(KUri_Compare1_a, KUri_Compare1_b, KUriMatchFlags1);
197 // IPv6 Test cases for section 2.9.1.1.1
198 TestUriCompareL(KUri_Compare2_a, KUri_Compare2_b, KUriMatchFlags2);
199 // and section 2.9.1.1.2
200 TestUriCompareL(KUri_Compare3_a, KUri_Compare3_b, KUriMatchFlags3);
202 TestAuthorityCompareL(KAuth_Compare0_a, KAuth_Compare0_b, KAuthMatchFlags0);
203 TestAuthorityCompareL(KAuth_Compare1_a, KAuth_Compare1_b, KAuthMatchFlags1);
205 TestUriComponentPresenceL(KUri_Presence0, KUriPresenceFlags0);
206 TestUriComponentPresenceL(KUri_Presence1, KUriPresenceFlags1);
208 TestAuthorityComponentPresenceL(KAuthority_Presence0, KAuthorityPresenceFlags0);
209 TestAuthorityComponentPresenceL(KAuthority_Presence1, KAuthorityPresenceFlags1);
211 TestUriDesL(KUri_Des0);
213 TestAuthorityDesL(KAuthority_Des0);
215 TestUriSchemeValidiyL(KUri_SchemeValidation0, KUri_SchemeValidity0);
216 TestUriSchemeValidiyL(KUri_SchemeValidation1, KUri_SchemeValidity1);
218 TestUriWithoutFragmentL(KUri_WithoutFragment0, KUri_WithoutFragment_Result0);
219 TestUriWithoutFragmentL(KUri_WithoutFragment1, KUri_WithoutFragment_Result1);
221 TestUriSetComponentL(KUri_Scheme0, KUri_Host0, KUri_Userinfo0, KUri_Port0, KUri_Path0, KUri_Query0, KUri_Fragment0,
222 KUri_SchemeComp0, KUri_HostComp0, KUri_UserinfoComp0, KUri_PortComp0, KUri_PathComp0, KUri_QueryComp0, KUri_FragmentComp0);
224 TestUriRemoveComponentL(KUri_NoScheme0, KUri_NoHost0, KUri_NoUserinfo0, KUri_NoPort0, KUri_NoPath0,
225 KUri_NoQuery0, KUri_NoFragment0, KUri_Whole0);
227 // Same test as above, but with an IPv6 format host, section 2.9.1.4
228 // Apart from the IPv6 address, the component data from the previous test can be reused
229 TestUriSetComponentL(KUri_Scheme0, KUri_IPv6Host0, KUri_IPv6UserInfo0, KUri_IPv6Port0, KUri_IPv6Path0, KUri_IPv6Query0, KUri_IPv6Fragment0,
230 KUri_SchemeComp0, KUri_IPv6HostComp0, KUri_UserinfoComp0, KUri_PortComp0, KUri_PathComp0, KUri_QueryComp0, KUri_FragmentComp0);
232 TestUriRemoveComponentL(KUri_IPv6NoScheme0, KUri_IPv6NoHost0, KUri_IPv6NoUserinfo0, KUri_IPv6NoPort0, KUri_IPv6NoPath0,
233 KUri_IPv6NoQuery0, KUri_IPv6NoFragment0, KUri_IPv6Whole0);
235 TestAuthoritySetComponentL(KAuthority_Host0, KAuthority_Userinfo0, KAuthority_Port0,
236 KAuthority_HostComp0, KAuthority_UserinfoComp0, KAuthority_PortComp0);
238 TestAuthoritySetAndEscapeComponentL(KAuthorityEscaped_Host0, KAuthorityEscaped_Userinfo0, KAuthorityEscaped_Port0,
239 KAuthorityEscaped_HostComp0, KAuthorityEscaped_UserinfoComp0, KAuthorityEscaped_PortComp0);
241 TestAuthorityRemoveComponentL(KAuthority_NoHost0, KAuthority_NoUserinfo0, KAuthority_NoPort0, KAuthority_Whole0);
243 // Same tests as above but for IPv6, as per section 2.9.1.4
244 TestAuthoritySetComponentL(KAuthority_IPv6Host0, KAuthority_IPv6Userinfo0, KAuthority_IPv6Port0,
245 KAuthority_IPv6HostComp0, KAuthority_IPv6UserinfoComp0, KAuthority_IPv6PortComp0);
247 TestAuthorityRemoveComponentL(KAuthority_IPv6NoHost0, KAuthority_IPv6NoUserinfo0, KAuthority_IPv6NoPort0, KAuthority_IPv6Whole0);
256 void CUriAndAuthorityTest::TestUriComponentExtractionL(const TDesC16& aUri, const TDesC16& aScheme,
257 const TDesC16& aUserinfo, const TDesC16& aHost,
258 const TDesC16& aPort, const TDesC16& aPath,
259 const TDesC16& aQuery, const TDesC16& aFragment) const
261 iTestHarness->StartTestL(_L("Test TUriParser Component Extraction (deprecated 16-bit )"));
262 iTestHarness->LogIt(_L("Uri - %S"), &aUri);
264 TInt error = DoUriComponentExtraction<TUriParser16>(aUri, aScheme, aUserinfo, aHost, aPort, aPath, aQuery, aFragment);
266 //check for failed Sip test
267 if (KErrNotFound!=aPath.Find(_L(",")) && KErrNotFound!=aScheme.Find(_L("sIp")))
269 iTestHarness->LogIt(KCompsSipUriInvalidMess6);
272 iTestHarness->EndTest(error);
274 iTestHarness->StartTestL(_L("Test TUriParser Component Extraction"));
275 iTestHarness->LogIt(_L("Uri - %S"), &aUri);
278 TRAP( error , DoUriComponentExtractionL(aUri, aScheme, aUserinfo, aHost, aPort, aPath, aQuery, aFragment) )
280 //check for failed Sip test
281 if (aPath.Find(_L(","))!=KErrNotFound && aScheme.Find(_L("sIp")) != KErrNotFound)
283 iTestHarness->LogIt(KCompsSipUriInvalidMess6);
286 iTestHarness->EndTest(error);
289 HBufC8* uriBuf = HBufC8::NewLC(aUri.Length());
290 TPtr8 uri8Bit = uriBuf->Des();
293 HBufC8* schemeBuf = HBufC8::NewLC(aScheme.Length());
294 TPtr8 scheme8Bit = schemeBuf->Des();
295 scheme8Bit.Copy(aScheme);
297 HBufC8* userinfoBuf = HBufC8::NewLC(aUserinfo.Length());
298 TPtr8 userinfo8Bit = userinfoBuf->Des();
299 userinfo8Bit.Copy(aUserinfo);
301 HBufC8* hostBuf = HBufC8::NewLC(aHost.Length());
302 TPtr8 host8Bit = hostBuf->Des();
303 host8Bit.Copy(aHost);
305 HBufC8* portBuf = HBufC8::NewLC(aPort.Length());
306 TPtr8 port8Bit = portBuf->Des();
307 port8Bit.Copy(aPort);
309 HBufC8* pathBuf = HBufC8::NewLC(aPath.Length());
310 TPtr8 path8Bit = pathBuf->Des();
311 path8Bit.Copy(aPath);
313 HBufC8* queryBuf = HBufC8::NewLC(aQuery.Length());
314 TPtr8 query8Bit = queryBuf->Des();
315 query8Bit.Copy(aQuery);
317 HBufC8* fragmentBuf = HBufC8::NewLC(aFragment.Length());
318 TPtr8 fragment8Bit = fragmentBuf->Des();
319 fragment8Bit.Copy(aFragment);
321 iTestHarness->StartTestL(_L("Test TUriParser Component Extraction (8-bit)"));
322 iTestHarness->LogIt(_L("Uri - %S"), &aUri);
324 error = DoUriComponentExtraction<TUriParser8>(uri8Bit, scheme8Bit, userinfo8Bit, host8Bit, port8Bit, path8Bit, query8Bit, fragment8Bit);
326 //check for failed Sip test
327 if (aPath.Find(_L(","))!=KErrNotFound && aScheme.Find(_L("sIp"))!=KErrNotFound)
329 iTestHarness->LogIt(KCompsSipUriInvalidMess6);
332 iTestHarness->EndTest(error);
334 CleanupStack::PopAndDestroy(8, uriBuf); // uriBuf, schemeBuf, userinfoBuf, hostBuf, portBuf, pathBuf, queryBuf, fragmentBuf
337 void CUriAndAuthorityTest::TestResolveL(const TDesC& aBase, const TDesC& aReference, const TDesC& aExpected) const
339 iTestHarness->StartTestL(_L("Testing Resolving Functionality (16-bit)"));
340 iTestHarness->LogIt(_L("Test Resolving %S , %S -> %S"), &aBase, &aReference, &aExpected);
342 TInt error = DoTestResolve<TUriParser16, CUri16>(aBase, aReference, aExpected);
344 iTestHarness->EndTest(error);
347 HBufC8* baseBuf = HBufC8::NewLC(aBase.Length());
348 TPtr8 base8Bit = baseBuf->Des();
349 base8Bit.Copy(aBase);
351 HBufC8* refBuf = HBufC8::NewLC(aReference.Length());
352 TPtr8 ref8Bit = refBuf->Des();
353 ref8Bit.Copy(aReference);
355 HBufC8* expectedBuf = HBufC8::NewLC(aExpected.Length());
356 TPtr8 expected8Bit = expectedBuf->Des();
357 expected8Bit.Copy(aExpected);
359 iTestHarness->StartTestL(_L("Testing Resolving Functionality (8-bit)"));
361 //Abnormal examples below differs from RFC 2396 to the current implementation of
362 //RFC3986. So, the expected output for ResolveL for Uri8 is modified to support
363 //section 5.4.2 of RFC 3986.
365 if( aReference.Compare(KRelative23) == 0 ||
366 aReference.Compare(KRelative24) == 0 ||
367 aReference.Compare(KRelative25) == 0 ||
368 aReference.Compare(KRelative26) == 0 )
370 _LIT8(KRfc3986,"http://a/g");
371 expected8Bit.Copy(KRfc3986);
372 _LIT(KRfc3986Bit16,"http://a/g");
373 iTestHarness->LogIt(_L("Test Resolving as per RFC3986 %S , %S -> %S"), &aBase, &aReference, &KRfc3986Bit16);
377 iTestHarness->LogIt(_L("Test Resolving %S , %S -> %S"), &aBase, &aReference, &aExpected);
379 error = DoTestResolve<TUriParser8, CUri8>(base8Bit, ref8Bit, expected8Bit);
381 iTestHarness->EndTest(error);
383 CleanupStack::PopAndDestroy(3, baseBuf); // baseBuf, refBuf, expectedBuf
386 void CUriAndAuthorityTest::TestUriCompareL(const TDesC& aUri1, const TDesC& aUri2, TInt aMatchFlags) const
388 iTestHarness->StartTestL(_L("Test TUriC Component Compare (16-bit)"));
390 TInt error = DoUriCompare<TUriParser16>(aUri1, aUri2, aMatchFlags);
392 iTestHarness->EndTest(error);
395 HBufC8* uriBuf1 = HBufC8::NewLC(aUri1.Length());
396 TPtr8 uri8Bit1 = uriBuf1->Des();
397 uri8Bit1.Copy(aUri1);
399 HBufC8* uriBuf2 = HBufC8::NewLC(aUri2.Length());
400 TPtr8 uri8Bit2 = uriBuf2->Des();
401 uri8Bit2.Copy(aUri2);
403 iTestHarness->StartTestL(_L("Test TUriC Component Compare (8-bit)"));
405 error = DoUriCompare<TUriParser8>(uri8Bit1, uri8Bit2, aMatchFlags);
407 iTestHarness->EndTest(error);
409 CleanupStack::PopAndDestroy(2, uriBuf1); // uriBuf1, uriBuf2
412 void CUriAndAuthorityTest::TestUriComponentPresenceL(const TDesC& aUri, TInt aPresenceFlags) const
414 iTestHarness->StartTestL(_L("Test TUriC Component Presence (16-bit)"));
416 TInt error = DoUriComponentPresence<TUriParser16>(aUri, aPresenceFlags);
418 iTestHarness->EndTest(error);
421 HBufC8* uriBuf = HBufC8::NewLC(aUri.Length());
422 TPtr8 uri8Bit = uriBuf->Des();
425 iTestHarness->StartTestL(_L("Test TUriC Component Presence (8-bit)"));
427 error = DoUriComponentPresence<TUriParser8>(uri8Bit, aPresenceFlags);
429 iTestHarness->EndTest(error);
431 CleanupStack::PopAndDestroy(uriBuf); // uriBuf
434 void CUriAndAuthorityTest::TestUriDesL(const TDesC& aUri) const
436 iTestHarness->StartTestL(_L("Test TUriC UriDes() (16-bit deprecated)"));
438 TInt error = DoUriDes<TUriParser16>(aUri);
440 iTestHarness->EndTest(error);
442 iTestHarness->StartTestL(_L("Test TUriC UriDes() (16-bit)"));
444 TRAP( error , DoUriDesL(aUri) );
446 iTestHarness->EndTest(error);
449 HBufC8* uriBuf = HBufC8::NewLC(aUri.Length());
450 TPtr8 uri8Bit = uriBuf->Des();
453 iTestHarness->StartTestL(_L("Test TUriC UriDes() (8-bit)"));
455 error = DoUriDes<TUriParser8>(uri8Bit);
457 iTestHarness->EndTest(error);
459 CleanupStack::PopAndDestroy(uriBuf); // uriBuf
462 void CUriAndAuthorityTest::TestUriSchemeValidiyL(const TDesC& aUri, TBool aValidScheme) const
464 iTestHarness->StartTestL(_L("Test TUriC Scheme Validation (16-bit)"));
466 TInt error = DoUriSchemeValidation<TUriParser16>(aUri, aValidScheme);
468 iTestHarness->EndTest(error);
471 HBufC8* uriBuf = HBufC8::NewLC(aUri.Length());
472 TPtr8 uri8Bit = uriBuf->Des();
475 iTestHarness->StartTestL(_L("Test TUriC Scheme Validation (8-bit)"));
477 error = DoUriSchemeValidation<TUriParser8>(uri8Bit, aValidScheme);
479 iTestHarness->EndTest(error);
481 CleanupStack::PopAndDestroy(uriBuf); // uriBuf
484 void CUriAndAuthorityTest::TestUriWithoutFragmentL(const TDesC& aUri, const TDesC& aExpected)
486 iTestHarness->StartTestL(_L("Test TUriC Uri Without Fragment (16-bit)"));
488 TInt error = DoUriWithoutFragment<TUriParser16, TPtrC16>(aUri, aExpected);
490 iTestHarness->EndTest(error);
493 HBufC8* uriBuf = HBufC8::NewLC(aUri.Length());
494 TPtr8 uri8Bit = uriBuf->Des();
497 HBufC8* expectedBuf = HBufC8::NewLC(aExpected.Length());
498 TPtr8 expected8Bit = expectedBuf->Des();
499 expected8Bit.Copy(aExpected);
501 iTestHarness->StartTestL(_L("Test TUriC Uri Without Fragment (8-bit)"));
503 error = DoUriWithoutFragment<TUriParser8, TPtrC8>(uri8Bit, expected8Bit);
505 iTestHarness->EndTest(error);
507 CleanupStack::PopAndDestroy(2, uriBuf); // uriBuf, expectedBuf
510 void CUriAndAuthorityTest::TestUriSetComponentL(const TDesC& aUri_Scheme, const TDesC& aUri_Host, const TDesC& aUri_Userinfo,
511 const TDesC& aUri_Port, const TDesC& aUri_Path, const TDesC& aUri_Query,
512 const TDesC& aUri_Fragment, const TDesC& aScheme, const TDesC& aHost,
513 const TDesC& aUserinfo, const TDesC& aPort, const TDesC& aPath,
514 const TDesC& aQuery, const TDesC& aFragment) const
517 iTestHarness->StartTestL(_L("Test CUri SetComponentL (16-bit)"));
519 TInt error = DoUriConstruction<CUri16>(aUri_Scheme, aUri_Host, aUri_Userinfo, aUri_Port, aUri_Path,
520 aUri_Query, aUri_Fragment, aScheme, aHost, aUserinfo, aPort, aPath, aQuery, aFragment);
522 iTestHarness->EndTest(error);
525 HBufC8* uri_SchemeBuf = HBufC8::NewLC(aUri_Scheme.Length());
526 TPtr8 uri_Scheme8Bit = uri_SchemeBuf->Des();
527 uri_Scheme8Bit.Copy(aUri_Scheme);
529 HBufC8* uri_HostBuf = HBufC8::NewLC(aUri_Host.Length());
530 TPtr8 uri_Host8Bit = uri_HostBuf->Des();
531 uri_Host8Bit.Copy(aUri_Host);
533 HBufC8* uri_UserinfoBuf = HBufC8::NewLC(aUri_Userinfo.Length());
534 TPtr8 uri_Userinfo8Bit = uri_UserinfoBuf->Des();
535 uri_Userinfo8Bit.Copy(aUri_Userinfo);
537 HBufC8* uri_PortBuf = HBufC8::NewLC(aUri_Port.Length());
538 TPtr8 uri_Port8Bit = uri_PortBuf->Des();
539 uri_Port8Bit.Copy(aUri_Port);
541 HBufC8* uri_PathBuf = HBufC8::NewLC(aUri_Path.Length());
542 TPtr8 uri_Path8Bit = uri_PathBuf->Des();
543 uri_Path8Bit.Copy(aUri_Path);
545 HBufC8* uri_QueryBuf = HBufC8::NewLC(aUri_Query.Length());
546 TPtr8 uri_Query8Bit = uri_QueryBuf->Des();
547 uri_Query8Bit.Copy(aUri_Query);
549 HBufC8* uri_FragmentBuf = HBufC8::NewLC(aUri_Fragment.Length());
550 TPtr8 uri_Fragment8Bit = uri_FragmentBuf->Des();
551 uri_Fragment8Bit.Copy(aUri_Fragment);
553 // And the individual components
554 HBufC8* schemeBuf = HBufC8::NewLC(aScheme.Length());
555 TPtr8 scheme8Bit = schemeBuf->Des();
556 scheme8Bit.Copy(aScheme);
558 HBufC8* userinfoBuf = HBufC8::NewLC(aUserinfo.Length());
559 TPtr8 userinfo8Bit = userinfoBuf->Des();
560 userinfo8Bit.Copy(aUserinfo);
562 HBufC8* hostBuf = HBufC8::NewLC(aHost.Length());
563 TPtr8 host8Bit = hostBuf->Des();
564 host8Bit.Copy(aHost);
566 HBufC8* portBuf = HBufC8::NewLC(aPort.Length());
567 TPtr8 port8Bit = portBuf->Des();
568 port8Bit.Copy(aPort);
570 HBufC8* pathBuf = HBufC8::NewLC(aPath.Length());
571 TPtr8 path8Bit = pathBuf->Des();
572 path8Bit.Copy(aPath);
574 HBufC8* queryBuf = HBufC8::NewLC(aQuery.Length());
575 TPtr8 query8Bit = queryBuf->Des();
576 query8Bit.Copy(aQuery);
578 HBufC8* fragmentBuf = HBufC8::NewLC(aFragment.Length());
579 TPtr8 fragment8Bit = fragmentBuf->Des();
580 fragment8Bit.Copy(aFragment);
582 iTestHarness->StartTestL(_L("Test CUri SetComponentL (8-bit)"));
584 error = DoUriConstruction<CUri8>(uri_Scheme8Bit, uri_Host8Bit, uri_Userinfo8Bit, uri_Port8Bit, uri_Path8Bit,
585 uri_Query8Bit, uri_Fragment8Bit, scheme8Bit, host8Bit, userinfo8Bit, port8Bit, path8Bit, query8Bit, fragment8Bit);
587 iTestHarness->EndTest(error);
588 CleanupStack::PopAndDestroy(14, uri_SchemeBuf); // too many to list!
591 void CUriAndAuthorityTest::TestUriRemoveComponentL(const TDesC& aUri_NoScheme, const TDesC& aUri_NoHost, const TDesC& aUri_NoUserinfo,
592 const TDesC& aUri_NoPort, const TDesC& aUri_NoPath, const TDesC& aUri_NoQuery,
593 const TDesC& aUri_NoFragment, const TDesC& aUri_Whole) const
595 iTestHarness->StartTestL(_L("Test CUri RemoveComponentL (16-bit)"));
597 TInt error = DoUriDestruction<CUri16, TUriParser16>(aUri_NoScheme, aUri_NoHost, aUri_NoUserinfo, aUri_NoPort, aUri_NoPath,
598 aUri_NoQuery, aUri_NoFragment, aUri_Whole);
600 iTestHarness->EndTest(error);
603 HBufC8* uri_NoSchemeBuf = HBufC8::NewLC(aUri_NoScheme.Length());
604 TPtr8 uri_NoScheme8Bit = uri_NoSchemeBuf->Des();
605 uri_NoScheme8Bit.Copy(aUri_NoScheme);
607 HBufC8* uri_NoHostBuf = HBufC8::NewLC(aUri_NoHost.Length());
608 TPtr8 uri_NoHost8Bit = uri_NoHostBuf->Des();
609 uri_NoHost8Bit.Copy(aUri_NoHost);
611 HBufC8* uri_NoUserinfoBuf = HBufC8::NewLC(aUri_NoUserinfo.Length());
612 TPtr8 uri_NoUserinfo8Bit = uri_NoUserinfoBuf->Des();
613 uri_NoUserinfo8Bit.Copy(aUri_NoUserinfo);
615 HBufC8* uri_NoPortBuf = HBufC8::NewLC(aUri_NoPort.Length());
616 TPtr8 uri_NoPort8Bit = uri_NoPortBuf->Des();
617 uri_NoPort8Bit.Copy(aUri_NoPort);
619 HBufC8* uri_NoPathBuf = HBufC8::NewLC(aUri_NoPath.Length());
620 TPtr8 uri_NoPath8Bit = uri_NoPathBuf->Des();
621 uri_NoPath8Bit.Copy(aUri_NoPath);
623 HBufC8* uri_NoQueryBuf = HBufC8::NewLC(aUri_NoQuery.Length());
624 TPtr8 uri_NoQuery8Bit = uri_NoQueryBuf->Des();
625 uri_NoQuery8Bit.Copy(aUri_NoQuery);
627 HBufC8* uri_NoFragmentBuf = HBufC8::NewLC(aUri_NoFragment.Length());
628 TPtr8 uri_NoFragment8Bit = uri_NoFragmentBuf->Des();
629 uri_NoFragment8Bit.Copy(aUri_NoFragment);
631 HBufC8* uri_WholeBuf = HBufC8::NewLC(aUri_Whole.Length());
632 TPtr8 uri_Whole8Bit = uri_WholeBuf->Des();
633 uri_Whole8Bit.Copy(aUri_Whole);
635 iTestHarness->StartTestL(_L("Test CUri RemoveComponentL (8-bit)"));
637 error = DoUriDestruction<CUri8, TUriParser8>(uri_NoScheme8Bit, uri_NoHost8Bit, uri_NoUserinfo8Bit, uri_NoPort8Bit,
638 uri_NoPath8Bit, uri_NoQuery8Bit, uri_NoFragment8Bit, uri_Whole8Bit);
640 iTestHarness->EndTest(error);
641 CleanupStack::PopAndDestroy(8, uri_NoSchemeBuf); // too many to list!
650 void CUriAndAuthorityTest::TestAuthorityComponentExtractionL(const TDesC16& aAuthority, const TDesC16& aUserinfo,
651 const TDesC16& aHost, const TDesC16& aPort) const
653 iTestHarness->StartTestL(_L("Test TAuthority Component Extraction (deprecated 16-bit)"));
654 iTestHarness->LogIt(_L("Uri - %S"), &aAuthority);
656 TInt error = DoAuthorityComponentExtraction<TAuthorityParser16>(aAuthority, aUserinfo, aHost, aPort);
658 iTestHarness->EndTest(error);
660 iTestHarness->StartTestL(_L("Test TAuthority Component Extraction (16-bit)"));
661 iTestHarness->LogIt(_L("Uri - %S"), &aAuthority);
663 TRAP(error, DoAuthorityComponentExtractionL(aAuthority, aUserinfo, aHost, aPort) );
665 iTestHarness->EndTest(error);
668 HBufC8* authorityBuf = HBufC8::NewLC(aAuthority.Length());
669 TPtr8 authority8Bit = authorityBuf->Des();
670 authority8Bit.Copy(aAuthority);
672 HBufC8* userinfoBuf = HBufC8::NewLC(aUserinfo.Length());
673 TPtr8 userinfo8Bit = userinfoBuf->Des();
674 userinfo8Bit.Copy(aUserinfo);
676 HBufC8* hostBuf = HBufC8::NewLC(aHost.Length());
677 TPtr8 host8Bit = hostBuf->Des();
678 host8Bit.Copy(aHost);
680 HBufC8* portBuf = HBufC8::NewLC(aPort.Length());
681 TPtr8 port8Bit = portBuf->Des();
682 port8Bit.Copy(aPort);
684 iTestHarness->StartTestL(_L("Test TAuthority Component Extraction (8-bit)"));
685 iTestHarness->LogIt(_L("Uri - %S"), &aAuthority);
687 error = DoAuthorityComponentExtraction<TAuthorityParser8>(authority8Bit, userinfo8Bit, host8Bit, port8Bit);
689 iTestHarness->EndTest(error);
691 CleanupStack::PopAndDestroy(4, authorityBuf); // authorityBuf, userInfoBuf, hostBuf, portBuf
694 void CUriAndAuthorityTest::TestAuthorityCompareL(const TDesC& aAuthority1, const TDesC& aAuthority2, TInt aMatchFlags) const
696 iTestHarness->StartTestL(_L("Test TAuthorityC Component Compare (16-bit)"));
698 TInt error = DoAuthorityCompare<TAuthorityParser16>(aAuthority1, aAuthority2, aMatchFlags);
700 iTestHarness->EndTest(error);
703 HBufC8* authorityBuf1 = HBufC8::NewLC(aAuthority1.Length());
704 TPtr8 authority8Bit1 = authorityBuf1->Des();
705 authority8Bit1.Copy(aAuthority1);
707 HBufC8* authorityBuf2 = HBufC8::NewLC(aAuthority2.Length());
708 TPtr8 authority8Bit2 = authorityBuf2->Des();
709 authority8Bit2.Copy(aAuthority2);
711 iTestHarness->StartTestL(_L("Test TAuthorityC Component Compare (8-bit)"));
713 error = DoAuthorityCompare<TAuthorityParser8>(authority8Bit1, authority8Bit2, aMatchFlags);
715 iTestHarness->EndTest(error);
717 CleanupStack::PopAndDestroy(2, authorityBuf1); // authorityBuf1, authorityBuf2
720 void CUriAndAuthorityTest::TestAuthorityComponentPresenceL(const TDesC& aAuthority, TInt aPresenceFlags) const
722 iTestHarness->StartTestL(_L("Test TAuthorityC Component Presence (16-bit)"));
724 TInt error = DoAuthorityComponentPresence<TAuthorityParser16>(aAuthority, aPresenceFlags);
726 iTestHarness->EndTest(error);
729 HBufC8* authorityBuf = HBufC8::NewLC(aAuthority.Length());
730 TPtr8 authority8Bit = authorityBuf->Des();
731 authority8Bit.Copy(aAuthority);
733 iTestHarness->StartTestL(_L("Test TAuthorityC Component Presence (8-bit)"));
735 error = DoAuthorityComponentPresence<TAuthorityParser8>(authority8Bit, aPresenceFlags);
737 iTestHarness->EndTest(error);
739 CleanupStack::PopAndDestroy(authorityBuf); // authorityBuf
742 void CUriAndAuthorityTest::TestAuthorityDesL(const TDesC& aAuthority)
744 iTestHarness->StartTestL(_L("Test TAuthorityC AuthorityDes() (16-bit deprecated)"));
746 TInt error = DoAuthorityDes<TAuthorityParser16>(aAuthority);
748 iTestHarness->EndTest(error);
750 iTestHarness->StartTestL(_L("Test TAuthorityC AuthorityDes() (16-bit)"));
752 TRAP( error , DoAuthorityDesL(aAuthority) );
754 iTestHarness->EndTest(error);
757 HBufC8* authorityBuf = HBufC8::NewLC(aAuthority.Length());
758 TPtr8 authority8Bit = authorityBuf->Des();
759 authority8Bit.Copy(aAuthority);
761 iTestHarness->StartTestL(_L("Test TAuthorityC AuthorityDes() (8-bit)"));
763 error = DoAuthorityDes<TAuthorityParser8>(authority8Bit);
765 iTestHarness->EndTest(error);
767 CleanupStack::PopAndDestroy(authorityBuf); // authorityBuf
770 void CUriAndAuthorityTest::TestAuthoritySetComponentL(const TDesC& aAuthority_Host, const TDesC& aAuthority_Userinfo,
771 const TDesC& aAuthority_Port, const TDesC& aHost,
772 const TDesC& aUserinfo, const TDesC& aPort)
775 iTestHarness->StartTestL(_L("Test CAuthority SetComponentL (16-bit)"));
777 TInt error = DoAuthorityConstruction<CAuthority16>(aAuthority_Host, aAuthority_Userinfo, aAuthority_Port,
778 aHost, aUserinfo, aPort);
780 iTestHarness->EndTest(error);
783 HBufC8* authority_HostBuf = HBufC8::NewLC(aAuthority_Host.Length());
784 TPtr8 authority_Host8Bit = authority_HostBuf->Des();
785 authority_Host8Bit.Copy(aAuthority_Host);
787 HBufC8* authority_UserinfoBuf = HBufC8::NewLC(aAuthority_Userinfo.Length());
788 TPtr8 authority_Userinfo8Bit = authority_UserinfoBuf->Des();
789 authority_Userinfo8Bit.Copy(aAuthority_Userinfo);
791 HBufC8* authority_PortBuf = HBufC8::NewLC(aAuthority_Port.Length());
792 TPtr8 authority_Port8Bit = authority_PortBuf->Des();
793 authority_Port8Bit.Copy(aAuthority_Port);
795 // And the individual components
796 HBufC8* userinfoBuf = HBufC8::NewLC(aUserinfo.Length());
797 TPtr8 userinfo8Bit = userinfoBuf->Des();
798 userinfo8Bit.Copy(aUserinfo);
800 HBufC8* hostBuf = HBufC8::NewLC(aHost.Length());
801 TPtr8 host8Bit = hostBuf->Des();
802 host8Bit.Copy(aHost);
804 HBufC8* portBuf = HBufC8::NewLC(aPort.Length());
805 TPtr8 port8Bit = portBuf->Des();
806 port8Bit.Copy(aPort);
808 iTestHarness->StartTestL(_L("Test CAuthority SetComponentL (8-bit)"));
810 error = DoAuthorityConstruction<CAuthority8>(authority_Host8Bit, authority_Userinfo8Bit, authority_Port8Bit,
811 host8Bit, userinfo8Bit, port8Bit);
813 iTestHarness->EndTest(error);
814 CleanupStack::PopAndDestroy(6, authority_HostBuf); // too many to list!
817 void CUriAndAuthorityTest::TestAuthoritySetAndEscapeComponentL(const TDesC& aAuthority_Host, const TDesC& aAuthority_Userinfo,
818 const TDesC& aAuthority_Port, const TDesC& aHost,
819 const TDesC& aUserinfo, const TDesC& aPort) const
822 iTestHarness->StartTestL(_L("Test CAuthority SetAndEscapeComponentL (16-bit)"));
824 TInt error = DoAuthorityEscapedConstruction<CAuthority16>(aAuthority_Host, aAuthority_Userinfo, aAuthority_Port,
825 aHost, aUserinfo, aPort);
827 iTestHarness->EndTest(error);
830 HBufC8* authority_HostBuf = HBufC8::NewLC(aAuthority_Host.Length());
831 TPtr8 authority_Host8Bit = authority_HostBuf->Des();
832 authority_Host8Bit.Copy(aAuthority_Host);
834 HBufC8* authority_UserinfoBuf = HBufC8::NewLC(aAuthority_Userinfo.Length());
835 TPtr8 authority_Userinfo8Bit = authority_UserinfoBuf->Des();
836 authority_Userinfo8Bit.Copy(aAuthority_Userinfo);
838 HBufC8* authority_PortBuf = HBufC8::NewLC(aAuthority_Port.Length());
839 TPtr8 authority_Port8Bit = authority_PortBuf->Des();
840 authority_Port8Bit.Copy(aAuthority_Port);
842 // And the individual components
843 HBufC8* userinfoBuf = HBufC8::NewLC(aUserinfo.Length());
844 TPtr8 userinfo8Bit = userinfoBuf->Des();
845 userinfo8Bit.Copy(aUserinfo);
847 HBufC8* hostBuf = HBufC8::NewLC(aHost.Length());
848 TPtr8 host8Bit = hostBuf->Des();
849 host8Bit.Copy(aHost);
851 HBufC8* portBuf = HBufC8::NewLC(aPort.Length());
852 TPtr8 port8Bit = portBuf->Des();
853 port8Bit.Copy(aPort);
855 iTestHarness->StartTestL(_L("Test CAuthority SetAnsEscapeComponentL (8-bit)"));
857 error = DoAuthorityEscapedConstruction<CAuthority8>(authority_Host8Bit, authority_Userinfo8Bit, authority_Port8Bit,
858 host8Bit, userinfo8Bit, port8Bit);
860 iTestHarness->EndTest(error);
861 CleanupStack::PopAndDestroy(6, authority_HostBuf); // too many to list!
864 void CUriAndAuthorityTest::TestAuthorityRemoveComponentL(const TDesC& aAuthority_NoHost, const TDesC& aAuthority_NoUserinfo,
865 const TDesC& aAuthority_NoPort, const TDesC& aAuthority_Whole) const
867 iTestHarness->StartTestL(_L("Test CAuthority RemoveComponentL (16-bit)"));
869 TInt error = DoAuthorityDestruction<CAuthority16, TAuthorityParser16>(aAuthority_NoHost, aAuthority_NoUserinfo,
870 aAuthority_NoPort, aAuthority_Whole);
872 iTestHarness->EndTest(error);
875 HBufC8* authority_NoHostBuf = HBufC8::NewLC(aAuthority_NoHost.Length());
876 TPtr8 authority_NoHost8Bit = authority_NoHostBuf->Des();
877 authority_NoHost8Bit.Copy(aAuthority_NoHost);
879 HBufC8* authority_NoUserinfoBuf = HBufC8::NewLC(aAuthority_NoUserinfo.Length());
880 TPtr8 authority_NoUserinfo8Bit = authority_NoUserinfoBuf->Des();
881 authority_NoUserinfo8Bit.Copy(aAuthority_NoUserinfo);
883 HBufC8* authority_NoPortBuf = HBufC8::NewLC(aAuthority_NoPort.Length());
884 TPtr8 authority_NoPort8Bit = authority_NoPortBuf->Des();
885 authority_NoPort8Bit.Copy(aAuthority_NoPort);
887 HBufC8* authority_WholeBuf = HBufC8::NewLC(aAuthority_Whole.Length());
888 TPtr8 authority_Whole8Bit = authority_WholeBuf->Des();
889 authority_Whole8Bit.Copy(aAuthority_Whole);
891 iTestHarness->StartTestL(_L("Test CAuthority RemoveComponentL (8-bit)"));
893 error = DoAuthorityDestruction<CAuthority8, TAuthorityParser8>(authority_NoHost8Bit, authority_NoUserinfo8Bit,
894 authority_NoPort8Bit, authority_Whole8Bit);
896 iTestHarness->EndTest(error);
897 CleanupStack::PopAndDestroy(4, authority_NoHostBuf); // too many to list!
902 // Implementation of LOCAL functions
906 template<class TUriParserType, class TDesCType>
907 TInt DoUriComponentExtraction(const TDesCType& aUri, const TDesCType& aScheme,
908 const TDesCType& aUserinfo, const TDesCType& aHost,
909 const TDesCType& aPort, const TDesCType& aPath,
910 const TDesCType& aQuery, const TDesCType& aFragment)
912 TUriParserType uriParser;
913 TInt error = uriParser.Parse(aUri);
914 // Is this a valid Uri?
915 if( error == KUriUtilsErrInvalidUri )
921 if( TestComponent(uriParser, aScheme, EUriScheme) != 0 )
923 return KUriUtilsErrDifferentScheme;
926 if( TestComponent(uriParser, aUserinfo, EUriUserinfo) != 0 )
928 return KUriUtilsErrDifferentUserInfo;
931 if( TestComponent(uriParser, aHost, EUriHost) != 0 )
933 return KUriUtilsErrDifferentHost;
936 if( TestComponent(uriParser, aPort, EUriPort) != 0 )
938 return KUriUtilsErrDifferentPort;
941 if( TestComponent(uriParser, aPath, EUriPath) != 0)
943 return KUriUtilsErrDifferentPath;
946 if( TestComponent(uriParser, aQuery, EUriQuery) != 0 )
948 return KUriUtilsErrDifferentQuery;
951 if( TestComponent(uriParser, aFragment, EUriFragment) != 0 )
953 return KUriUtilsErrDifferentFragment;
959 /** create 8-bit URI from descriptor, compare components*/
960 void DoUriComponentExtractionL(const TDesC& aUri, const TDesC& aScheme,
961 const TDesC& aUserinfo, const TDesC& aHost,
962 const TDesC& aPort, const TDesC& aPath,
963 const TDesC& aQuery, const TDesC& aFragment)
965 CUri8* uri = UriUtils::CreateUriL(aUri);
966 CleanupStack::PushL(uri);
969 HBufC* text = uri->Uri().DisplayFormL(EUriScheme);
970 TInt error = ( text->Compare(aScheme) == 0 ) ? KErrNone : KUriUtilsErrDifferentScheme;
972 User::LeaveIfError(error);
975 text = uri->Uri().DisplayFormL(EUriUserinfo);
976 error = ( text->Compare(aUserinfo) == 0 ) ? KErrNone : KUriUtilsErrDifferentUserInfo;
978 User::LeaveIfError(error);
981 text = uri->Uri().DisplayFormL(EUriHost);
982 error = ( text->Compare(aHost) == 0 ) ? KErrNone : KUriUtilsErrDifferentHost;
984 User::LeaveIfError(error);
987 text = uri->Uri().DisplayFormL(EUriPort);
988 error = ( text->Compare(aPort) == 0 ) ? KErrNone : KUriUtilsErrDifferentPort;
990 User::LeaveIfError(error);
993 text = uri->Uri().DisplayFormL(EUriPath);
994 error = ( text->Compare(aPath) == 0 ) ? KErrNone : KUriUtilsErrDifferentPath;
996 User::LeaveIfError(error);
999 text = uri->Uri().DisplayFormL(EUriQuery);
1000 error = ( text->Compare(aQuery) == 0 ) ? KErrNone : KUriUtilsErrDifferentQuery;
1002 User::LeaveIfError(error);
1004 // Check fragment...
1005 text = uri->Uri().DisplayFormL(EUriFragment);
1006 error = ( text->Compare(aFragment) == 0 ) ? KErrNone : KUriUtilsErrDifferentFragment;
1008 User::LeaveIfError(error);
1009 CleanupStack::PopAndDestroy(uri);
1013 template<class TAuthorityParserType, class TDesCType>
1014 TInt DoAuthorityComponentExtraction(const TDesCType& aAuthority, const TDesCType& aUserInfo,
1015 const TDesCType& aHost, const TDesCType& aPort)
1017 TAuthorityParserType authorityParser;
1018 TInt error = authorityParser.Parse(aAuthority);
1020 // Check userinfo...
1021 if( TestComponent(authorityParser, aUserInfo, EAuthorityUserinfo) != 0 )
1023 return KUriUtilsErrDifferentUserInfo;
1026 if( TestComponent(authorityParser, aHost, EAuthorityHost) != 0 )
1028 return KUriUtilsErrDifferentHost;
1031 if( TestComponent(authorityParser, aPort, EAuthorityPort) != 0 )
1033 return KUriUtilsErrDifferentPort;
1038 /** create 8-bit Authority from descriptor, compare components*/
1039 void DoAuthorityComponentExtractionL(const TDesC& aAuthority, const TDesC& aUserInfo,
1040 const TDesC& aHost, const TDesC& aPort)
1042 CAuthority8* authority = UriUtils::CreateAuthorityL(aAuthority);
1043 CleanupStack::PushL(authority);
1045 // Check userinfo...
1046 HBufC* text = authority->Authority().DisplayFormL(EAuthorityUserinfo);
1047 TInt error = ( text->Compare(aUserInfo) == 0 ) ? KErrNone : KUriUtilsErrDifferentUserInfo;
1049 User::LeaveIfError(error);
1052 text = authority->Authority().DisplayFormL(EAuthorityHost);
1053 error = ( text->Compare(aHost) == 0 ) ? KErrNone : KUriUtilsErrDifferentHost;
1057 text = authority->Authority().DisplayFormL(EAuthorityPort);
1058 error = ( text->Compare(aPort) == 0 ) ? KErrNone : KUriUtilsErrDifferentPort;
1061 CleanupStack::PopAndDestroy(authority);
1064 template<class TParserType, class TDesCType, class TComponentType>
1065 TInt TestComponent(const TParserType& aParser, const TDesCType& aExpected, TComponentType aComponent)
1067 return aParser.Extract(aComponent).Compare(aExpected);
1070 template<class TUriParserType, class CUriType, class TDesCType>
1071 TInt DoTestResolve(const TDesCType& aBase, const TDesCType& aReference, const TDesCType& aExpected)
1073 TUriParserType baseUri;
1074 TInt error = baseUri.Parse(aBase);
1075 if ( error != KErrNone )
1079 TUriParserType refUri;
1080 error = refUri.Parse(aReference);
1081 if ( error != KErrNone )
1085 CUriType* resolvedUri = NULL;
1086 TRAP(error, resolvedUri = CUriType::ResolveL(baseUri, refUri));
1087 if( error != KErrNone )
1091 error = resolvedUri->Uri().UriDes().Compare(aExpected);
1097 template<class TUriParserType, class TDesCType>
1098 TInt DoUriCompare(const TDesCType& aUri1, const TDesCType& aUri2, TInt aMatchFlags)
1100 TUriParserType uri1;
1101 TInt error = uri1.Parse(aUri1);
1102 if( error == KUriUtilsErrInvalidUri )
1106 TUriParserType uri2;
1107 error = uri2.Parse(aUri2);
1108 if( error == KUriUtilsErrInvalidUri )
1112 // Test compare for fragment
1113 if( (error = TestCompare(uri1, uri2, EUriFragment, (aMatchFlags & EFragmentFlag))) != 0 )
1115 return KErrNotFound;
1117 // Test compare for query
1118 if( (error = TestCompare(uri1, uri2, EUriQuery, (aMatchFlags & EQueryFlag))) != 0 )
1120 return KErrNotFound;
1122 // Test compare for path
1123 if( (error = TestCompare(uri1, uri2, EUriPath, (aMatchFlags & EPathFlag))) != 0 )
1125 return KErrNotFound;
1127 // Test compare for port
1128 if( (error = TestCompare(uri1, uri2, EUriPort, (aMatchFlags & EPortFlag))) != 0 )
1130 return KErrNotFound;
1132 // Test compare for userinfo
1133 if( (error = TestCompare(uri1, uri2, EUriUserinfo, (aMatchFlags & EUserinfoFlag))) != 0 )
1135 return KErrNotFound;
1137 // Test compare for host
1138 if( (error = TestCompare(uri1, uri2, EUriHost, (aMatchFlags & EHostFlag))) != 0 )
1140 return KErrNotFound;
1142 // Test compare for scheme
1143 if( (error = TestCompare(uri1, uri2, EUriScheme, (aMatchFlags & ESchemeFlag))) != 0 )
1145 return KErrNotFound;
1150 template<class TAuthorityParserType, class TDesCType>
1151 TInt DoAuthorityCompare(const TDesCType& aAuthority1, const TDesCType& aAuthority2, TInt aMatchFlags)
1153 TAuthorityParserType auth1;
1154 TInt error = auth1.Parse(aAuthority1);
1155 TAuthorityParserType auth2;
1156 error = auth2.Parse(aAuthority2);
1157 // Test compare for userinfo
1158 if( (error = TestCompare(auth1, auth2, EAuthorityUserinfo, (aMatchFlags & EUserinfoFlag))) != 0 )
1160 return KErrNotFound;
1162 // Test compare for port
1163 if( (error = TestCompare(auth1, auth2, EAuthorityPort, (aMatchFlags & EPortFlag))) != 0 )
1165 return KErrNotFound;
1167 // Test compare for host
1168 if( (error = TestCompare(auth1, auth2, EAuthorityHost, (aMatchFlags & EHostFlag))) != 0 )
1170 return KErrNotFound;
1175 template<class TParserType, class TComponentType>
1176 TInt TestCompare(const TParserType& aData1, const TParserType& aData2, TComponentType aComponent, TBool aExpectedMatch)
1178 TInt error = aData1.Compare(aData2, aComponent);
1179 TBool match = error == 0;
1180 if( (!match && aExpectedMatch) | (match && !aExpectedMatch) )
1182 return KErrNotFound;
1187 template<class TUriParserType, class TDesCType>
1188 TInt DoUriComponentPresence(const TDesCType& aUri, TInt aPresenceFlags)
1191 TInt error = uri.Parse(aUri);
1192 if( error == KUriUtilsErrInvalidUri )
1196 // Test compare for scheme
1197 if( (error = TestPresence(uri, EUriScheme, (aPresenceFlags & ESchemeFlag))) != 0)
1199 return KErrNotFound;
1201 // Test compare for host
1202 if( (error = TestPresence(uri, EUriHost, (aPresenceFlags & EHostFlag))) != 0)
1204 return KErrNotFound;
1206 // Test compare for userinfo
1207 if( (error = TestPresence(uri, EUriUserinfo, (aPresenceFlags & EUserinfoFlag))) != 0)
1209 return KErrNotFound;
1211 // Test compare for port
1212 if( (error = TestPresence(uri, EUriPort, (aPresenceFlags & EPortFlag))) != 0)
1214 return KErrNotFound;
1216 // Test compare for path
1217 if( (error = TestPresence(uri, EUriPath, (aPresenceFlags & EPathFlag))) != 0)
1219 return KErrNotFound;
1221 // Test compare for query
1222 if( (error = TestPresence(uri, EUriQuery, (aPresenceFlags & EQueryFlag))) != 0)
1224 return KErrNotFound;
1226 // Test compare for fragment
1227 if( (error = TestPresence(uri, EUriFragment, (aPresenceFlags & EFragmentFlag))) != 0)
1229 return KErrNotFound;
1234 template<class TAuthorityParserType, class TDesCType>
1235 TInt DoAuthorityComponentPresence(const TDesCType& aAuthority, TInt aPresenceFlags)
1237 TAuthorityParserType authority;
1238 TInt error = authority.Parse(aAuthority);
1239 // Test compare for host
1240 if( (error = TestPresence(authority, EAuthorityHost, (aPresenceFlags & EHostFlag))) != 0)
1242 return KErrNotFound;
1244 // Test compare for userinfo
1245 if( (error = TestPresence(authority, EAuthorityUserinfo, (aPresenceFlags & EUserinfoFlag))) != 0)
1247 return KErrNotFound;
1249 // Test compare for port
1250 if( (error = TestPresence(authority, EAuthorityPort, (aPresenceFlags & EPortFlag))) != 0)
1252 return KErrNotFound;
1257 template<class TParserType, class TComponentType>
1258 TInt TestPresence(const TParserType& aData, TComponentType aComponent, TBool aExpectedPresence)
1260 TBool present = aData.IsPresent(aComponent);
1261 if( (!present && aExpectedPresence) | (present && !aExpectedPresence) )
1263 return KErrNotFound;
1268 template<class TUriParserType, class TDesCType>
1269 TInt DoUriDes(const TDesCType& aUri)
1272 TInt error = uri.Parse(aUri);
1273 if( error == KUriUtilsErrInvalidUri )
1277 if( uri.UriDes().Compare(aUri) != 0)
1279 return KErrNotFound;
1284 void DoUriDesL(const TDesC& aUri)
1286 CUri8* uri = UriUtils::CreateUriL(aUri);
1287 CleanupStack::PushL(uri);
1289 HBufC* text = uri->Uri().DisplayFormL();
1290 TInt error = ( text->Compare(aUri) == 0 ) ? KErrNone : KErrNotFound;
1292 User::LeaveIfError(error);
1293 CleanupStack::PopAndDestroy(uri);
1296 template<class TAuthorityParserType, class TDesCType>
1297 TInt DoAuthorityDes(const TDesCType& aAuthority)
1299 TAuthorityParserType authority;
1300 TInt error = authority.Parse(aAuthority);
1301 if( (error = authority.AuthorityDes().Compare(aAuthority)) != 0)
1303 return KErrNotFound;
1308 void DoAuthorityDesL(const TDesC& aAuthority)
1310 CAuthority8* authority = UriUtils::CreateAuthorityL(aAuthority);
1311 CleanupStack::PushL(authority);
1313 HBufC* text = authority->Authority().DisplayFormL();
1314 TInt error = ( text->Compare(aAuthority) == 0 ) ? KErrNone : KErrNotFound;
1316 User::LeaveIfError(error);
1318 CleanupStack::PopAndDestroy(authority);
1321 template<class TUriParserType, class TDesCType>
1322 TInt DoUriSchemeValidation(const TDesCType& aUri, TBool aValidScheme)
1325 TInt error = uri.Parse(aUri);
1326 if( error == KUriUtilsErrInvalidUri )
1330 TBool valid = uri.IsSchemeValid();
1331 if( (!valid && aValidScheme) | (valid && !aValidScheme) )
1333 return KErrNotFound;
1338 template<class TUriParserType, class TPtrCType, class TDesCType>
1339 TInt DoUriWithoutFragment(const TDesCType& aUri, const TDesCType& aExpected)
1342 TInt error = uri.Parse(aUri);
1343 if( error == KUriUtilsErrInvalidUri )
1347 TPtrCType uriWithoutFragment;
1348 uri.UriWithoutFragment(uriWithoutFragment);
1349 if( (error = uriWithoutFragment.Compare(aExpected)) != 0)
1351 return KErrNotFound;
1356 template<class CUriType, class TDesCType>
1357 TInt DoUriConstruction(const TDesCType& aUri_Scheme, const TDesCType& aUri_Host, const TDesCType& aUri_Userinfo,
1358 const TDesCType& aUri_Port, const TDesCType& aUri_Path, const TDesCType& aUri_Query,
1359 const TDesCType& aUri_Fragment, const TDesCType& aScheme, const TDesCType& aHost,
1360 const TDesCType& aUserinfo, const TDesCType& aPort, const TDesCType& aPath,
1361 const TDesCType& aQuery, const TDesCType& aFragment)
1363 // Create the CUriType object
1364 CUriType* uri = NULL;
1365 TRAPD(error, uri = CUriType::NewL());
1366 if( error != KErrNone )
1370 CleanupStack::PushL(uri);
1372 if( DoUriSetAndCompareComponent<CUriType>(uri, EUriScheme, aScheme, aUri_Scheme) != KErrNone )
1374 CleanupStack::PopAndDestroy(uri); // uri
1375 return KErrNotFound;
1379 if( DoUriSetAndCompareComponent<CUriType>(uri, EUriHost, aHost, aUri_Host) != KErrNone )
1381 CleanupStack::PopAndDestroy(uri); // uri
1382 return KErrNotFound;
1385 if( DoUriSetAndCompareComponent<CUriType>(uri, EUriUserinfo, aUserinfo, aUri_Userinfo) != KErrNone )
1387 CleanupStack::PopAndDestroy(uri); // uri
1388 return KErrNotFound;
1391 if( DoUriSetAndCompareComponent<CUriType>(uri, EUriPort, aPort, aUri_Port) != KErrNone )
1393 CleanupStack::PopAndDestroy(uri); // uri
1394 return KErrNotFound;
1397 if( DoUriSetAndCompareComponent<CUriType>(uri, EUriPath, aPath, aUri_Path) != KErrNone )
1399 CleanupStack::PopAndDestroy(uri); // uri
1400 return KErrNotFound;
1403 if( DoUriSetAndCompareComponent<CUriType>(uri, EUriQuery, aQuery, aUri_Query) != KErrNone )
1405 CleanupStack::PopAndDestroy(uri); // uri
1406 return KErrNotFound;
1409 if( DoUriSetAndCompareComponent<CUriType>(uri, EUriFragment, aFragment, aUri_Fragment) != KErrNone )
1411 CleanupStack::PopAndDestroy(uri); // uri
1412 return KErrNotFound;
1414 // Cleanup and return
1415 CleanupStack::PopAndDestroy(uri); // uri
1419 template<class CUriType, class TDesCType>
1420 TInt DoUriSetAndCompareComponent(CUriType* aUri, TUriComponent aComponent, const TDesCType& aData, const TDesCType& aExpected)
1422 TRAPD(error, aUri->SetComponentL(aData, aComponent));
1423 if( error != KErrNone )
1427 // Compare with expected
1428 if( aUri->Uri().UriDes().Compare(aExpected) != 0)
1430 return KErrNotFound;
1435 template<class CUriType, class TUriParserType, class TDesCType>
1436 TInt DoUriDestruction(const TDesCType& aUri_NoScheme, const TDesCType& aUri_NoHost, const TDesCType& aUri_NoUserinfo,
1437 const TDesCType& aUri_NoPort, const TDesCType& aUri_NoPath, const TDesCType& aUri_NoQuery,
1438 const TDesCType& aUri_NoFragment, const TDesCType& aUri_Whole)
1440 // Create a TUriC-derived objet from whole uri
1441 TUriParserType parser;
1442 TInt error = parser.Parse(aUri_Whole);
1443 if( error == KUriUtilsErrInvalidUri )
1447 // Create the CUriType object
1448 CUriType* uri = NULL;
1449 TRAP(error, uri = CUriType::NewL(parser));
1450 if( error != KErrNone )
1454 CleanupStack::PushL(uri);
1455 // Remove fragment...
1456 if( DoUriRemoveAndCompareComponent<CUriType>(uri, EUriFragment, aUri_NoFragment) != KErrNone )
1458 CleanupStack::PopAndDestroy(uri); // uri
1459 return KErrNotFound;
1462 if( DoUriRemoveAndCompareComponent<CUriType>(uri, EUriQuery, aUri_NoQuery) != KErrNone )
1464 CleanupStack::PopAndDestroy(uri); // uri
1465 return KErrNotFound;
1468 if( DoUriRemoveAndCompareComponent<CUriType>(uri, EUriPath, aUri_NoPath) != KErrNone )
1470 CleanupStack::PopAndDestroy(uri); // uri
1471 return KErrNotFound;
1474 if( DoUriRemoveAndCompareComponent<CUriType>(uri, EUriPort, aUri_NoPort) != KErrNone )
1476 CleanupStack::PopAndDestroy(uri); // uri
1477 return KErrNotFound;
1479 // Remove userinfo...
1480 if( DoUriRemoveAndCompareComponent<CUriType>(uri, EUriUserinfo, aUri_NoUserinfo) != KErrNone )
1482 CleanupStack::PopAndDestroy(uri); // uri
1483 return KErrNotFound;
1486 if( DoUriRemoveAndCompareComponent<CUriType>(uri, EUriHost, aUri_NoHost) != KErrNone )
1488 CleanupStack::PopAndDestroy(uri); // uri
1489 return KErrNotFound;
1492 if( DoUriRemoveAndCompareComponent<CUriType>(uri, EUriScheme, aUri_NoScheme) != KErrNone )
1494 CleanupStack::PopAndDestroy(uri); // uri
1495 return KErrNotFound;
1497 // Cleanup and return
1498 CleanupStack::PopAndDestroy(uri); // uri
1502 template<class CUriType, class TDesCType>
1503 TInt DoUriRemoveAndCompareComponent(CUriType* aUri, TUriComponent aComponent, const TDesCType& aExpected)
1505 TRAPD(error, aUri->RemoveComponentL(aComponent));
1506 if( error != KErrNone )
1510 // Compare with expected
1511 if( aUri->Uri().UriDes().Compare(aExpected) != 0)
1513 return KErrNotFound;
1518 template<class CAuthorityType, class TDesCType>
1519 TInt DoAuthorityConstruction(const TDesCType& aAuthority_Host, const TDesCType& aAuthority_Userinfo, const TDesCType& aAuthority_Port,
1520 const TDesCType& aHost, const TDesCType& aUserinfo, const TDesCType& aPort)
1522 // Create the CAuthorityType object
1523 CAuthorityType* authority = NULL;
1524 TRAPD(error, authority = CAuthorityType::NewL());
1525 if( error != KErrNone )
1529 CleanupStack::PushL(authority);
1531 if( DoAuthoritySetAndCompareComponent<CAuthorityType>(authority, EAuthorityHost, aHost, aAuthority_Host) != KErrNone )
1533 CleanupStack::PopAndDestroy(authority); // authority
1534 return KErrNotFound;
1537 if( DoAuthoritySetAndCompareComponent<CAuthorityType>(authority, EAuthorityUserinfo, aUserinfo, aAuthority_Userinfo) != KErrNone )
1539 CleanupStack::PopAndDestroy(authority); // authority
1540 return KErrNotFound;
1543 if( DoAuthoritySetAndCompareComponent<CAuthorityType>(authority, EAuthorityPort, aPort, aAuthority_Port) != KErrNone )
1545 CleanupStack::PopAndDestroy(authority); // authority
1546 return KErrNotFound;
1548 // Cleanup and return
1549 CleanupStack::PopAndDestroy(authority); // authority
1553 template<class CAuthorityType, class TDesCType>
1554 TInt DoAuthoritySetAndCompareComponent(CAuthorityType* aAuthority, TAuthorityComponent aComponent, const TDesCType& aData, const TDesCType& aExpected)
1556 TRAPD(error, aAuthority->SetComponentL(aData, aComponent));
1557 if( error != KErrNone )
1561 // Compare with expected
1562 if( aAuthority->Authority().AuthorityDes().Compare(aExpected) != 0)
1564 return KErrNotFound;
1569 template<class CAuthorityType, class TDesCType>
1570 TInt DoAuthorityEscapedConstruction(const TDesCType& aAuthority_Host, const TDesCType& aAuthority_Userinfo, const TDesCType& aAuthority_Port,
1571 const TDesCType& aHost, const TDesCType& aUserinfo, const TDesCType& aPort)
1573 // Create the CAuthorityType object
1574 CAuthorityType* authority = NULL;
1575 TRAPD(error, authority = CAuthorityType::NewL());
1576 if( error != KErrNone )
1580 CleanupStack::PushL(authority);
1582 if( DoAuthoritySetAndEscapeAndCompareComponent<CAuthorityType>(authority, EAuthorityHost, aHost, aAuthority_Host) != KErrNone )
1584 CleanupStack::PopAndDestroy(authority); // authority
1585 return KErrNotFound;
1588 if( DoAuthoritySetAndEscapeAndCompareComponent<CAuthorityType>(authority, EAuthorityUserinfo, aUserinfo, aAuthority_Userinfo) != KErrNone )
1590 CleanupStack::PopAndDestroy(authority); // authority
1591 return KErrNotFound;
1594 if( DoAuthoritySetAndEscapeAndCompareComponent<CAuthorityType>(authority, EAuthorityPort, aPort, aAuthority_Port) != KErrNone )
1596 CleanupStack::PopAndDestroy(authority); // authority
1597 return KErrNotFound;
1599 // Cleanup and return
1600 CleanupStack::PopAndDestroy(authority); // authority
1604 template<class CAuthorityType, class TDesCType>
1605 TInt DoAuthoritySetAndEscapeAndCompareComponent(CAuthorityType* aAuthority, TAuthorityComponent aComponent, const TDesCType& aData, const TDesCType& aExpected)
1607 TRAPD(error, aAuthority->SetAndEscapeComponentL(aData, aComponent));
1608 if( error != KErrNone )
1612 // Compare with expected
1613 if( aAuthority->Authority().AuthorityDes().Compare(aExpected) != 0)
1615 return KErrNotFound;
1620 template<class CAuthorityType, class TAuthorityParserType, class TDesCType>
1621 TInt DoAuthorityDestruction(const TDesCType& aAuthority_NoHost, const TDesCType& aAuthority_NoUserinfo,
1622 const TDesCType& aAuthority_NoPort, const TDesCType& aAuthority_Whole)
1624 // Create a TAuthorityC-derived objet from whole authority
1625 TAuthorityParserType parser;
1626 TInt error = parser.Parse(aAuthority_Whole);
1627 // Create the CAuthorityType object
1628 CAuthorityType* authority = NULL;
1629 TRAP(error, authority = CAuthorityType::NewL(parser));
1630 if( error != KErrNone )
1634 CleanupStack::PushL(authority);
1636 if( DoAuthorityRemoveAndCompareComponent<CAuthorityType>(authority, EAuthorityPort, aAuthority_NoPort) != KErrNone )
1638 CleanupStack::PopAndDestroy(authority); // authority
1639 return KErrNotFound;
1641 // Remove userinfo...
1642 if( DoAuthorityRemoveAndCompareComponent<CAuthorityType>(authority, EAuthorityUserinfo, aAuthority_NoUserinfo) != KErrNone )
1644 CleanupStack::PopAndDestroy(authority); // authority
1645 return KErrNotFound;
1648 if( DoAuthorityRemoveAndCompareComponent<CAuthorityType>(authority, EAuthorityHost, aAuthority_NoHost) != KErrNone )
1650 CleanupStack::PopAndDestroy(authority); // authority
1651 return KErrNotFound;
1653 // Cleanup and return
1654 CleanupStack::PopAndDestroy(authority); // authority
1658 template<class CAuthorityType, class TDesCType>
1659 TInt DoAuthorityRemoveAndCompareComponent(CAuthorityType* aAuthority, TAuthorityComponent aComponent, const TDesCType& aExpected)
1661 TRAPD(error, aAuthority->RemoveComponentL(aComponent));
1662 if( error != KErrNone )
1666 // Compare with expected
1667 if( aAuthority->Authority().AuthorityDes().Compare(aExpected) != 0)
1669 return KErrNotFound;