sl@0
|
1 |
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "CSipUriAndAuthorityTest.h"
|
sl@0
|
17 |
#include "CUriAndAuthorityTest.h"
|
sl@0
|
18 |
#include <uriutilscommon.h>
|
sl@0
|
19 |
#include "SipUriAndAuthorityTests.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
#include <e32base.h>
|
sl@0
|
22 |
#include <f32file.h>
|
sl@0
|
23 |
|
sl@0
|
24 |
CSipUriAndAuthorityTest* CSipUriAndAuthorityTest::NewLC(CIpuTestHarness* aTestHarness)
|
sl@0
|
25 |
{
|
sl@0
|
26 |
CSipUriAndAuthorityTest* self = new (ELeave) CSipUriAndAuthorityTest(aTestHarness);
|
sl@0
|
27 |
CleanupStack::PushL(self);
|
sl@0
|
28 |
self->ConstructL();
|
sl@0
|
29 |
return self;
|
sl@0
|
30 |
}
|
sl@0
|
31 |
|
sl@0
|
32 |
CSipUriAndAuthorityTest* CSipUriAndAuthorityTest::NewL(CIpuTestHarness* aTestHarness)
|
sl@0
|
33 |
{
|
sl@0
|
34 |
CSipUriAndAuthorityTest* self = CSipUriAndAuthorityTest::NewLC(aTestHarness);
|
sl@0
|
35 |
CleanupStack::Pop(self);
|
sl@0
|
36 |
return self;
|
sl@0
|
37 |
}
|
sl@0
|
38 |
|
sl@0
|
39 |
CSipUriAndAuthorityTest::CSipUriAndAuthorityTest(CIpuTestHarness* aTestHarness)
|
sl@0
|
40 |
: iTestHarness(aTestHarness)
|
sl@0
|
41 |
{
|
sl@0
|
42 |
}
|
sl@0
|
43 |
|
sl@0
|
44 |
void CSipUriAndAuthorityTest::ConstructL()
|
sl@0
|
45 |
{
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
CSipUriAndAuthorityTest::~CSipUriAndAuthorityTest()
|
sl@0
|
49 |
{
|
sl@0
|
50 |
}
|
sl@0
|
51 |
|
sl@0
|
52 |
//
|
sl@0
|
53 |
//
|
sl@0
|
54 |
// SIP Uri tests
|
sl@0
|
55 |
//
|
sl@0
|
56 |
//
|
sl@0
|
57 |
void CSipUriAndAuthorityTest::DoTestsL()
|
sl@0
|
58 |
{
|
sl@0
|
59 |
//allredy pushed
|
sl@0
|
60 |
CUriAndAuthorityTest* uriAndAuthorityTest = CUriAndAuthorityTest::NewLC(iTestHarness);
|
sl@0
|
61 |
|
sl@0
|
62 |
// Test Sips TUriParser Component Extraction
|
sl@0
|
63 |
uriAndAuthorityTest->TestUriComponentExtractionL(KCompsSip0, KSchemeSip0, KUserInfoSip0, KHostSip0, KPortSip0, KPathSip0, KQuerySip0, KFragmentSip0);
|
sl@0
|
64 |
uriAndAuthorityTest->TestUriComponentExtractionL(KCompsSip1, KSchemeSip1, KUserInfoSip1, KHostSip1, KPortSip1, KPathSip1, KQuerySip1, KFragmentSip1);
|
sl@0
|
65 |
uriAndAuthorityTest->TestUriComponentExtractionL(KCompsSip2, KSchemeSip2, KUserInfoSip2, KHostSip2, KPortSip2, KPathSip2, KQuerySip2, KFragmentSip2);
|
sl@0
|
66 |
uriAndAuthorityTest->TestUriComponentExtractionL(KCompsSip3, KSchemeSip3, KUserInfoSip3, KHostSip3, KPortSip3, KPathSip3, KQuerySip3, KFragmentSip3);
|
sl@0
|
67 |
uriAndAuthorityTest->TestUriComponentExtractionL(KCompsSip4, KSchemeSip4, KUserInfoSip4, KHostSip4, KPortSip4, KPathSip4, KQuerySip4, KFragmentSip4);
|
sl@0
|
68 |
uriAndAuthorityTest->TestUriComponentExtractionL(KCompsSip5, KSchemeSip5, KUserInfoSip5, KHostSip5, KPortSip5, KPathSip5, KQuerySip5, KFragmentSip5);
|
sl@0
|
69 |
|
sl@0
|
70 |
// Sip URI construction test
|
sl@0
|
71 |
uriAndAuthorityTest->TestUriSetComponentL(KSipUri_Scheme0, KSipUri_Host0, KSipUri_Userinfo0, KSipUri_Port0, KSipUri_Path0, KSipUri_Query0, KSipUri_Fragment0,
|
sl@0
|
72 |
KSipUri_SchemeComp0, KSipUri_HostComp0, KSipUri_UserinfoComp0, KSipUri_PortComp0, KSipUri_PathComp0, KSipUri_QueryComp0, KSipUri_FragmentComp0);
|
sl@0
|
73 |
|
sl@0
|
74 |
/** No Fragment part exist in Sip Uri's as per RFC3261
|
sl@0
|
75 |
// Sip URI destruction test
|
sl@0
|
76 |
uriAndAuthorityTest->TestUriRemoveComponentL(KSipUri_NoScheme0, KSipUri_NoHost0, KSipUri_NoUserinfo0, KSipUri_NoPort0, KSipUri_NoPath0,
|
sl@0
|
77 |
KSipUri_NoQuery0, KSipUri_NoFragment0, KSipUri_Whole0);
|
sl@0
|
78 |
*/
|
sl@0
|
79 |
// Same test as above, but with an IPv6 format host
|
sl@0
|
80 |
// Sip URI construction test
|
sl@0
|
81 |
uriAndAuthorityTest->TestUriSetComponentL(KSipUri_Scheme0, KSipUri_IPv6Host0, KSipUri_IPv6UserInfo0, KSipUri_IPv6Port0, KSipUri_IPv6Path0, KSipUri_IPv6Query0, KSipUri_IPv6Fragment0,
|
sl@0
|
82 |
KSipUri_SchemeComp0, KUri_IPv6HostComp, KSipUri_UserinfoComp0, KSipUri_PortComp0, KSipUri_PathComp0, KSipUri_QueryComp0, KSipUri_FragmentComp0);
|
sl@0
|
83 |
|
sl@0
|
84 |
/** No Fragment part exist in Sip Uri's as per RFC3261
|
sl@0
|
85 |
// Sip URI destruction test
|
sl@0
|
86 |
uriAndAuthorityTest->TestUriRemoveComponentL(KSipUri_IPv6NoScheme0, KSipUri_IPv6NoHost0, KSipUri_IPv6NoUserinfo0, KSipUri_IPv6NoPort0, KSipUri_IPv6NoPath0,
|
sl@0
|
87 |
KSipUri_IPv6NoQuery0, KSipUri_IPv6NoFragment0, KSipUri_IPv6Whole0);
|
sl@0
|
88 |
*/
|
sl@0
|
89 |
CleanupStack::PopAndDestroy(uriAndAuthorityTest);
|
sl@0
|
90 |
|
sl@0
|
91 |
//Sip URI validation
|
sl@0
|
92 |
TInt error=KErrNone;
|
sl@0
|
93 |
error=OpenSipURIFile();
|
sl@0
|
94 |
if (KErrNone!=error)
|
sl@0
|
95 |
{
|
sl@0
|
96 |
iTestHarness->StartTestL(_L("Test TUriParser Component "));
|
sl@0
|
97 |
SipLogError(error, KCompsSipUriFileSystemError);
|
sl@0
|
98 |
}
|
sl@0
|
99 |
else
|
sl@0
|
100 |
{
|
sl@0
|
101 |
error=SipUriValidationL();
|
sl@0
|
102 |
if (KErrNone!=error)
|
sl@0
|
103 |
{
|
sl@0
|
104 |
iTestHarness->StartTestL(_L("Test TUriParser Component Validation "));
|
sl@0
|
105 |
switch (error)
|
sl@0
|
106 |
{
|
sl@0
|
107 |
case KErrNotFound:
|
sl@0
|
108 |
{
|
sl@0
|
109 |
iTestHarness->LogIt(KCompsSipUriNoValidate);
|
sl@0
|
110 |
}
|
sl@0
|
111 |
break;
|
sl@0
|
112 |
case KErrBadName:
|
sl@0
|
113 |
{
|
sl@0
|
114 |
iTestHarness->LogIt(KCompsSipUriNoValidateData);
|
sl@0
|
115 |
}
|
sl@0
|
116 |
break;
|
sl@0
|
117 |
default:
|
sl@0
|
118 |
break;
|
sl@0
|
119 |
}
|
sl@0
|
120 |
iTestHarness->EndTest(KErrNone);
|
sl@0
|
121 |
}
|
sl@0
|
122 |
|
sl@0
|
123 |
if (iFoundEquivalence)
|
sl@0
|
124 |
{
|
sl@0
|
125 |
error=SipUriEquivalenceL();
|
sl@0
|
126 |
//No Sip URI Equivalence data
|
sl@0
|
127 |
if (KErrBadName==error)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
iTestHarness->StartTestL(_L("Test TUriParser Component Equivalence "));
|
sl@0
|
130 |
iTestHarness->LogIt(KCompsSipUriNoEquivalenceData);
|
sl@0
|
131 |
iTestHarness->EndTest(KErrNone);
|
sl@0
|
132 |
}
|
sl@0
|
133 |
}
|
sl@0
|
134 |
else
|
sl@0
|
135 |
{
|
sl@0
|
136 |
iTestHarness->StartTestL(_L("Test TUriParser Component Equivalence "));
|
sl@0
|
137 |
iTestHarness->LogIt(KCompsSipUriNoEquivalence);
|
sl@0
|
138 |
iTestHarness->EndTest(KErrNone);
|
sl@0
|
139 |
error=KErrNone;
|
sl@0
|
140 |
}
|
sl@0
|
141 |
iFsSession.Close();
|
sl@0
|
142 |
}
|
sl@0
|
143 |
}
|
sl@0
|
144 |
|
sl@0
|
145 |
//
|
sl@0
|
146 |
//
|
sl@0
|
147 |
// Open SIP Uri data file
|
sl@0
|
148 |
//
|
sl@0
|
149 |
//
|
sl@0
|
150 |
TInt CSipUriAndAuthorityTest::OpenSipURIFile()
|
sl@0
|
151 |
{
|
sl@0
|
152 |
RFile file;
|
sl@0
|
153 |
TInt error=KErrNone;
|
sl@0
|
154 |
|
sl@0
|
155 |
error = iFsSession.Connect();
|
sl@0
|
156 |
if (KErrNone!=error)
|
sl@0
|
157 |
{
|
sl@0
|
158 |
return error;
|
sl@0
|
159 |
}
|
sl@0
|
160 |
|
sl@0
|
161 |
error = file.Open(iFsSession, KCompsSipUriFileName, EFileRead);
|
sl@0
|
162 |
if (KErrNone!=error)
|
sl@0
|
163 |
{
|
sl@0
|
164 |
iFsSession.Close();
|
sl@0
|
165 |
return error;
|
sl@0
|
166 |
}
|
sl@0
|
167 |
|
sl@0
|
168 |
iTUriParserFile.Set(file);
|
sl@0
|
169 |
return error;
|
sl@0
|
170 |
}
|
sl@0
|
171 |
|
sl@0
|
172 |
//
|
sl@0
|
173 |
//
|
sl@0
|
174 |
// SIP Uri Logger
|
sl@0
|
175 |
//
|
sl@0
|
176 |
//
|
sl@0
|
177 |
void CSipUriAndAuthorityTest::SipLogError(TInt aError, const TDesC16& aSipUri) const
|
sl@0
|
178 |
{
|
sl@0
|
179 |
TBool wrongError=EFalse;
|
sl@0
|
180 |
|
sl@0
|
181 |
//compare the Equivalent SIP URI to look for the correct error, these SIP URIs must be in T_UriParserSipUri.txt
|
sl@0
|
182 |
//All equal
|
sl@0
|
183 |
if (0==aSipUri.Compare(KCompsSipUriEqual0) && KErrNone != aError
|
sl@0
|
184 |
|| 0==aSipUri.Compare(KCompsSipUriEqual1) && KErrNone != aError
|
sl@0
|
185 |
|| 0==aSipUri.Compare(KCompsSipUriEqual2) && KErrNone != aError)
|
sl@0
|
186 |
{
|
sl@0
|
187 |
iTestHarness->LogIt(KCompsSipUriValidMess0);
|
sl@0
|
188 |
wrongError=ETrue;
|
sl@0
|
189 |
}
|
sl@0
|
190 |
//All not equal
|
sl@0
|
191 |
if (0==aSipUri.Compare(KCompsSipUriNotEqual0) && KUriUtilsErrDifferentUserInfo == aError
|
sl@0
|
192 |
|| 0==aSipUri.Compare(KCompsSipUriNotEqual1) && KUriUtilsErrDifferentPath == aError
|
sl@0
|
193 |
|| 0==aSipUri.Compare(KCompsSipUriNotEqual2) && KUriUtilsErrDifferentPort == aError )
|
sl@0
|
194 |
{
|
sl@0
|
195 |
iTestHarness->LogIt(KCompsSipUriEqualMess1);
|
sl@0
|
196 |
}
|
sl@0
|
197 |
|
sl@0
|
198 |
//compare the SIP URIs to look for the correct error returned by CUri for validation
|
sl@0
|
199 |
if (0==aSipUri.Compare(KCompsSipUriNotEqual1) && KUriUtilsErrDifferentPath != aError )
|
sl@0
|
200 |
{
|
sl@0
|
201 |
iTestHarness->LogIt(KCompsSipUriInvalidMess9);
|
sl@0
|
202 |
wrongError=ETrue;
|
sl@0
|
203 |
}
|
sl@0
|
204 |
|
sl@0
|
205 |
|
sl@0
|
206 |
if (0==aSipUri.Compare(KCompsSipUriValid0) && KErrNone!= aError
|
sl@0
|
207 |
|| 0==aSipUri.Compare(KCompsSipUriValid1) && KErrNone!= aError)
|
sl@0
|
208 |
{
|
sl@0
|
209 |
iTestHarness->LogIt(KCompsSipUriValidMess0);
|
sl@0
|
210 |
wrongError=ETrue;
|
sl@0
|
211 |
}
|
sl@0
|
212 |
|
sl@0
|
213 |
if (0==aSipUri.Compare(KCompsSipUriInvalid0) && KErrNotSupported != aError)
|
sl@0
|
214 |
{
|
sl@0
|
215 |
iTestHarness->LogIt(KCompsSipUriInvalidMess0);
|
sl@0
|
216 |
wrongError=ETrue;
|
sl@0
|
217 |
}
|
sl@0
|
218 |
|
sl@0
|
219 |
if( 0==aSipUri.Compare(KCompsSipUriInvalid5) && KUriUtilsErrInvalidParam!= aError
|
sl@0
|
220 |
|| 0==aSipUri.Compare(KCompsSipUriInvalid6) && KUriUtilsErrInvalidParam!= aError)
|
sl@0
|
221 |
{
|
sl@0
|
222 |
iTestHarness->LogIt(KCompsSipUriInvalidMess1);
|
sl@0
|
223 |
wrongError=ETrue;
|
sl@0
|
224 |
}
|
sl@0
|
225 |
|
sl@0
|
226 |
if (0==aSipUri.Compare(KCompsSipUriInvalid3) && KUriUtilsErrInvalidHost!= aError)
|
sl@0
|
227 |
{
|
sl@0
|
228 |
iTestHarness->LogIt(KCompsSipUriInvalidMess2);
|
sl@0
|
229 |
wrongError=ETrue;
|
sl@0
|
230 |
}
|
sl@0
|
231 |
|
sl@0
|
232 |
if (0==aSipUri.Compare(KCompsSipUriInvalid2) && KUriUtilsErrInvalidHeaders != aError)
|
sl@0
|
233 |
{
|
sl@0
|
234 |
iTestHarness->LogIt(KCompsSipUriInvalidMess8);
|
sl@0
|
235 |
wrongError=ETrue;
|
sl@0
|
236 |
}
|
sl@0
|
237 |
|
sl@0
|
238 |
if (0==aSipUri.Compare(KCompsSipUriInvalid1) && KUriUtilsErrInvalidPort != aError
|
sl@0
|
239 |
|| 0==aSipUri.Compare(KCompsSipUriInvalid4) && KUriUtilsErrInvalidPort!= aError
|
sl@0
|
240 |
|| 0==aSipUri.Compare(KCompsSipUriNotEqual2) && KUriUtilsErrDifferentPort != aError)
|
sl@0
|
241 |
{
|
sl@0
|
242 |
iTestHarness->LogIt(KCompsSipUriInvalidMess3);
|
sl@0
|
243 |
wrongError=ETrue;
|
sl@0
|
244 |
}
|
sl@0
|
245 |
|
sl@0
|
246 |
if (0==aSipUri.Compare(KCompsSipUriInvalid7) && KUriUtilsErrInvalidUserInfo!= aError
|
sl@0
|
247 |
|| 0==aSipUri.Compare(KCompsSipUriNotEqual0) && KUriUtilsErrDifferentUserInfo != aError)
|
sl@0
|
248 |
{
|
sl@0
|
249 |
iTestHarness->LogIt(KCompsSipUriInvalidMess7);
|
sl@0
|
250 |
wrongError=ETrue;
|
sl@0
|
251 |
}
|
sl@0
|
252 |
|
sl@0
|
253 |
if (wrongError)
|
sl@0
|
254 |
{
|
sl@0
|
255 |
iTestHarness->LogIt(KCompsSipUriInvalidMess5);
|
sl@0
|
256 |
}
|
sl@0
|
257 |
|
sl@0
|
258 |
LogErrorMessage(aSipUri, aError);
|
sl@0
|
259 |
|
sl@0
|
260 |
if (wrongError)
|
sl@0
|
261 |
{
|
sl@0
|
262 |
iTestHarness->EndTest(aError);
|
sl@0
|
263 |
}
|
sl@0
|
264 |
else
|
sl@0
|
265 |
{
|
sl@0
|
266 |
iTestHarness->EndTest(KErrNone);
|
sl@0
|
267 |
}
|
sl@0
|
268 |
}
|
sl@0
|
269 |
|
sl@0
|
270 |
//
|
sl@0
|
271 |
//
|
sl@0
|
272 |
// SIP Uri Validation Test
|
sl@0
|
273 |
//
|
sl@0
|
274 |
//
|
sl@0
|
275 |
TInt CSipUriAndAuthorityTest::SipUriValidationL()
|
sl@0
|
276 |
{
|
sl@0
|
277 |
TBuf<256> data;
|
sl@0
|
278 |
TInt error=KErrNone;
|
sl@0
|
279 |
iFoundEquivalence=EFalse;
|
sl@0
|
280 |
|
sl@0
|
281 |
//read the Valid section name in
|
sl@0
|
282 |
error=iTUriParserFile.Read(data);
|
sl@0
|
283 |
while(0!=data.Compare(KCompsSipUriValidate) && KErrNone==error)
|
sl@0
|
284 |
{
|
sl@0
|
285 |
if (0==data.Compare(KCompsSipUriEquivalence))
|
sl@0
|
286 |
{
|
sl@0
|
287 |
iFoundEquivalence=ETrue;
|
sl@0
|
288 |
break;
|
sl@0
|
289 |
}
|
sl@0
|
290 |
data.Zero();
|
sl@0
|
291 |
error=iTUriParserFile.Read(data);
|
sl@0
|
292 |
}
|
sl@0
|
293 |
|
sl@0
|
294 |
//No Validate Section, KErrEof
|
sl@0
|
295 |
if (0!=data.Compare(KCompsSipUriValidate))
|
sl@0
|
296 |
{
|
sl@0
|
297 |
return KErrNotFound;
|
sl@0
|
298 |
}
|
sl@0
|
299 |
|
sl@0
|
300 |
//get the validation Data
|
sl@0
|
301 |
error=iTUriParserFile.Read(data);
|
sl@0
|
302 |
|
sl@0
|
303 |
//no data
|
sl@0
|
304 |
if (KErrEof==error)
|
sl@0
|
305 |
{
|
sl@0
|
306 |
return KErrBadName;
|
sl@0
|
307 |
}
|
sl@0
|
308 |
|
sl@0
|
309 |
//found Equivalence
|
sl@0
|
310 |
if (0==data.Compare(KCompsSipUriEquivalence))
|
sl@0
|
311 |
{
|
sl@0
|
312 |
iFoundEquivalence=ETrue;
|
sl@0
|
313 |
return KErrBadName;
|
sl@0
|
314 |
}
|
sl@0
|
315 |
|
sl@0
|
316 |
while (KErrNone==error)
|
sl@0
|
317 |
{
|
sl@0
|
318 |
//check for comments
|
sl@0
|
319 |
while(data.Left(2)==(KCompsSipUriComment))
|
sl@0
|
320 |
{
|
sl@0
|
321 |
data.Zero();
|
sl@0
|
322 |
iTUriParserFile.Read(data);
|
sl@0
|
323 |
}
|
sl@0
|
324 |
if (0==data.Compare(KCompsSipUriEquivalence))
|
sl@0
|
325 |
{
|
sl@0
|
326 |
iFoundEquivalence=ETrue;
|
sl@0
|
327 |
break;
|
sl@0
|
328 |
}
|
sl@0
|
329 |
|
sl@0
|
330 |
//validate the 16 bit Sip URI first
|
sl@0
|
331 |
iTestHarness->StartTestL(_L("Test TUriParser Component Validation (16-bit SIP URI)"));
|
sl@0
|
332 |
iTestHarness->LogIt(_L("Uri - %S"), &data);
|
sl@0
|
333 |
error = DoSipUriValidation <TUriParser16>(data);
|
sl@0
|
334 |
SipLogError(error, data);
|
sl@0
|
335 |
|
sl@0
|
336 |
// Make 8-bit copies and validate this SIP URI
|
sl@0
|
337 |
HBufC8* uriBuf = HBufC8::NewLC(data.Length());
|
sl@0
|
338 |
TPtr8 uri8Bit = uriBuf->Des();
|
sl@0
|
339 |
uri8Bit.Copy(data);
|
sl@0
|
340 |
|
sl@0
|
341 |
iTestHarness->StartTestL(_L("Test TUriParser Component Validation (8-bit SIP URI)"));
|
sl@0
|
342 |
iTestHarness->LogIt(_L("Uri - %S"), &data);
|
sl@0
|
343 |
error = DoSipUriValidation <TUriParser8>(uri8Bit);
|
sl@0
|
344 |
SipLogError(error, data);
|
sl@0
|
345 |
|
sl@0
|
346 |
data.Zero();
|
sl@0
|
347 |
CleanupStack::PopAndDestroy(1, uriBuf);// uriBuf
|
sl@0
|
348 |
|
sl@0
|
349 |
error=iTUriParserFile.Read(data);
|
sl@0
|
350 |
}
|
sl@0
|
351 |
return KErrNone;
|
sl@0
|
352 |
}
|
sl@0
|
353 |
|
sl@0
|
354 |
//
|
sl@0
|
355 |
//
|
sl@0
|
356 |
// SIP Uri Equivalence Test
|
sl@0
|
357 |
//
|
sl@0
|
358 |
//
|
sl@0
|
359 |
TInt CSipUriAndAuthorityTest::SipUriEquivalenceL()
|
sl@0
|
360 |
{
|
sl@0
|
361 |
TBuf<256> valueA;
|
sl@0
|
362 |
TBuf<256> valueB;
|
sl@0
|
363 |
TBool sipUriError=EFalse;
|
sl@0
|
364 |
TInt errorA=KErrNone;
|
sl@0
|
365 |
TInt errorB=KErrNone;
|
sl@0
|
366 |
TInt error=KErrNone;
|
sl@0
|
367 |
|
sl@0
|
368 |
//get the Equivalence Data
|
sl@0
|
369 |
errorA=iTUriParserFile.Read(valueA);
|
sl@0
|
370 |
while(valueA.Left(2)==(KCompsSipUriComment) && KErrNone==errorA)
|
sl@0
|
371 |
{
|
sl@0
|
372 |
valueA.Zero();
|
sl@0
|
373 |
errorA=iTUriParserFile.Read(valueA);
|
sl@0
|
374 |
}
|
sl@0
|
375 |
|
sl@0
|
376 |
errorB=iTUriParserFile.Read(valueB);
|
sl@0
|
377 |
//no Equivalence Data
|
sl@0
|
378 |
if (KErrEof==errorA || KErrEof==errorB)
|
sl@0
|
379 |
{
|
sl@0
|
380 |
return KErrBadName;
|
sl@0
|
381 |
}
|
sl@0
|
382 |
|
sl@0
|
383 |
//read the Equivalence Sip URI
|
sl@0
|
384 |
while (KErrNone==errorA && KErrNone==errorB)
|
sl@0
|
385 |
{
|
sl@0
|
386 |
//check for comments
|
sl@0
|
387 |
while(valueA.Left(2)==(KCompsSipUriComment))
|
sl@0
|
388 |
{
|
sl@0
|
389 |
valueA.Zero();
|
sl@0
|
390 |
errorA=iTUriParserFile.Read(valueA);
|
sl@0
|
391 |
}
|
sl@0
|
392 |
while(valueB.Left(2)==(KCompsSipUriComment))
|
sl@0
|
393 |
{
|
sl@0
|
394 |
valueB.Zero();
|
sl@0
|
395 |
errorB=iTUriParserFile.Read(valueB);
|
sl@0
|
396 |
}
|
sl@0
|
397 |
|
sl@0
|
398 |
//validate the 16 bit Sip URI first
|
sl@0
|
399 |
iTestHarness->StartTestL(_L("Test TUriParser Component Equivalence (16-bit SIP)"));
|
sl@0
|
400 |
iTestHarness->LogIt(_L("Uri - %S"), &valueA);
|
sl@0
|
401 |
iTestHarness->LogIt(_L("Uri - %S"), &valueB);
|
sl@0
|
402 |
|
sl@0
|
403 |
error= DoSipUriEquivalence<TUriParser16>(valueA, valueB, sipUriError);
|
sl@0
|
404 |
//check for parsing errors on both Sip URIs
|
sl@0
|
405 |
if (KErrBadSipUriA==sipUriError)
|
sl@0
|
406 |
{
|
sl@0
|
407 |
SipLogError(error, valueA);
|
sl@0
|
408 |
}
|
sl@0
|
409 |
if (KErrBadSipUriB==sipUriError)
|
sl@0
|
410 |
{
|
sl@0
|
411 |
SipLogError(error, valueB);
|
sl@0
|
412 |
}
|
sl@0
|
413 |
SipLogError(error, valueA);
|
sl@0
|
414 |
|
sl@0
|
415 |
// Make 8-bit copies and validate this SIP URI
|
sl@0
|
416 |
HBufC8* uriBufA = HBufC8::NewLC(valueA.Length());
|
sl@0
|
417 |
TPtr8 uri8BitA = uriBufA->Des();
|
sl@0
|
418 |
uri8BitA.Copy(valueA);
|
sl@0
|
419 |
|
sl@0
|
420 |
HBufC8* uriBufB = HBufC8::NewLC(valueB.Length());
|
sl@0
|
421 |
TPtr8 uri8BitB = uriBufB->Des();
|
sl@0
|
422 |
uri8BitB.Copy(valueB);
|
sl@0
|
423 |
|
sl@0
|
424 |
iTestHarness->StartTestL(_L("Test TUriParser Component Equivalence (8-bit SIP)"));
|
sl@0
|
425 |
iTestHarness->LogIt(_L("Uri - %S"), &valueA);
|
sl@0
|
426 |
iTestHarness->LogIt(_L("Uri - %S"), &valueB);
|
sl@0
|
427 |
error = DoSipUriEquivalence<TUriParser8>(uri8BitA, uri8BitB, sipUriError);
|
sl@0
|
428 |
//check for parsing errors on both Sip URIs
|
sl@0
|
429 |
if (KErrBadSipUriA==sipUriError)
|
sl@0
|
430 |
{
|
sl@0
|
431 |
SipLogError(error, valueA);
|
sl@0
|
432 |
}
|
sl@0
|
433 |
if (KErrBadSipUriA==sipUriError)
|
sl@0
|
434 |
{
|
sl@0
|
435 |
SipLogError(error, valueB);
|
sl@0
|
436 |
}
|
sl@0
|
437 |
SipLogError(error, valueA);
|
sl@0
|
438 |
|
sl@0
|
439 |
CleanupStack::PopAndDestroy(2, uriBufA);// uriBufA, uriBufB
|
sl@0
|
440 |
|
sl@0
|
441 |
errorA=iTUriParserFile.Read(valueA);
|
sl@0
|
442 |
errorB=iTUriParserFile.Read(valueB);
|
sl@0
|
443 |
}
|
sl@0
|
444 |
return KErrNone;
|
sl@0
|
445 |
}
|
sl@0
|
446 |
|
sl@0
|
447 |
//
|
sl@0
|
448 |
//
|
sl@0
|
449 |
// SIP Uri Logger
|
sl@0
|
450 |
//
|
sl@0
|
451 |
//
|
sl@0
|
452 |
void CSipUriAndAuthorityTest::LogErrorMessage(const TDesC16& aSipUri, const TInt aError)const
|
sl@0
|
453 |
{
|
sl@0
|
454 |
switch (aError)
|
sl@0
|
455 |
{
|
sl@0
|
456 |
case KErrNotFound:
|
sl@0
|
457 |
iTestHarness->LogIt(aSipUri);
|
sl@0
|
458 |
break;
|
sl@0
|
459 |
|
sl@0
|
460 |
case KErrNotSupported:
|
sl@0
|
461 |
iTestHarness->LogIt(_L("Not Supported"));
|
sl@0
|
462 |
break;
|
sl@0
|
463 |
|
sl@0
|
464 |
case KUriUtilsErrInvalidScheme:
|
sl@0
|
465 |
case KUriUtilsErrDifferentScheme:
|
sl@0
|
466 |
iTestHarness->LogIt(_L("Invalid Scheme"));
|
sl@0
|
467 |
break;
|
sl@0
|
468 |
|
sl@0
|
469 |
case KUriUtilsErrInvalidUserInfo:
|
sl@0
|
470 |
case KUriUtilsErrDifferentUserInfo:
|
sl@0
|
471 |
iTestHarness->LogIt(_L("Invalid UserInfo"));
|
sl@0
|
472 |
break;
|
sl@0
|
473 |
|
sl@0
|
474 |
case KUriUtilsErrInvalidHost:
|
sl@0
|
475 |
case KUriUtilsErrDifferentHost:
|
sl@0
|
476 |
iTestHarness->LogIt(_L("Invalid Host"));
|
sl@0
|
477 |
break;
|
sl@0
|
478 |
|
sl@0
|
479 |
case KUriUtilsErrInvalidPort:
|
sl@0
|
480 |
case KUriUtilsErrDifferentPort:
|
sl@0
|
481 |
iTestHarness->LogIt(_L("Invalid Port"));
|
sl@0
|
482 |
break;
|
sl@0
|
483 |
|
sl@0
|
484 |
case KUriUtilsErrInvalidPath:
|
sl@0
|
485 |
case KUriUtilsErrDifferentPath:
|
sl@0
|
486 |
iTestHarness->LogIt(_L("Invalid Path"));
|
sl@0
|
487 |
break;
|
sl@0
|
488 |
|
sl@0
|
489 |
case KUriUtilsErrInvalidParam:
|
sl@0
|
490 |
iTestHarness->LogIt(_L("Invalid Parameter"));
|
sl@0
|
491 |
break;
|
sl@0
|
492 |
|
sl@0
|
493 |
case KUriUtilsErrInvalidQuery:
|
sl@0
|
494 |
case KUriUtilsErrDifferentQuery:
|
sl@0
|
495 |
iTestHarness->LogIt(_L("Invalid Query"));
|
sl@0
|
496 |
break;
|
sl@0
|
497 |
|
sl@0
|
498 |
case KUriUtilsErrInvalidHeaders:
|
sl@0
|
499 |
iTestHarness->LogIt(_L("Invalid Headers"));
|
sl@0
|
500 |
break;
|
sl@0
|
501 |
|
sl@0
|
502 |
case KUriUtilsErrInvalidFragment:
|
sl@0
|
503 |
case KUriUtilsErrDifferentFragment:
|
sl@0
|
504 |
iTestHarness->LogIt(_L("Invalid Fragment"));
|
sl@0
|
505 |
break;
|
sl@0
|
506 |
|
sl@0
|
507 |
default:
|
sl@0
|
508 |
break;
|
sl@0
|
509 |
}
|
sl@0
|
510 |
|
sl@0
|
511 |
//log correct message for equivalence
|
sl@0
|
512 |
if (iFoundEquivalence && KErrNone==aError)
|
sl@0
|
513 |
{
|
sl@0
|
514 |
iTestHarness->LogIt(KCompsSipUriEqualMess0);
|
sl@0
|
515 |
}
|
sl@0
|
516 |
else if (iFoundEquivalence && KErrNone!=aError)
|
sl@0
|
517 |
{
|
sl@0
|
518 |
iTestHarness->LogIt(KCompsSipUriEqualMess1);
|
sl@0
|
519 |
}
|
sl@0
|
520 |
}
|
sl@0
|
521 |
|
sl@0
|
522 |
//
|
sl@0
|
523 |
//
|
sl@0
|
524 |
// Implementation of LOCAL functions
|
sl@0
|
525 |
//
|
sl@0
|
526 |
//
|
sl@0
|
527 |
|
sl@0
|
528 |
template<class TUriParserType, class TDesCType>
|
sl@0
|
529 |
TInt DoSipUriValidation(const TDesCType& aSipUri)
|
sl@0
|
530 |
{
|
sl@0
|
531 |
TUriParserType uriParser;
|
sl@0
|
532 |
TInt error = uriParser.Parse(aSipUri);
|
sl@0
|
533 |
// Is this a valid SIP Uri?
|
sl@0
|
534 |
if( KUriUtilsErrInvalidUri == error)
|
sl@0
|
535 |
{
|
sl@0
|
536 |
return error;
|
sl@0
|
537 |
}
|
sl@0
|
538 |
|
sl@0
|
539 |
//Validate the Sip URI
|
sl@0
|
540 |
return(uriParser.Validate());
|
sl@0
|
541 |
}
|
sl@0
|
542 |
|
sl@0
|
543 |
template<class TUriParserType, class TDesCType>
|
sl@0
|
544 |
TInt DoSipUriEquivalence(const TDesCType& aSipUriA, const TDesCType& aSipUriB, TInt &aSipUriError)
|
sl@0
|
545 |
{
|
sl@0
|
546 |
TUriParserType uriParserA;
|
sl@0
|
547 |
TUriParserType uriParserB;
|
sl@0
|
548 |
|
sl@0
|
549 |
TBool errorA = uriParserA.Parse(aSipUriA);
|
sl@0
|
550 |
// Is this a valid SIP Uri?
|
sl@0
|
551 |
if( KUriUtilsErrInvalidUri == errorA)
|
sl@0
|
552 |
{
|
sl@0
|
553 |
aSipUriError=KErrBadSipUriA;
|
sl@0
|
554 |
return errorA;
|
sl@0
|
555 |
}
|
sl@0
|
556 |
|
sl@0
|
557 |
TBool errorB = uriParserB.Parse(aSipUriB);
|
sl@0
|
558 |
// Is this a valid SIP Uri?
|
sl@0
|
559 |
if( KUriUtilsErrInvalidUri == errorB)
|
sl@0
|
560 |
{
|
sl@0
|
561 |
aSipUriError=KErrBadSipUriB;
|
sl@0
|
562 |
return errorB;
|
sl@0
|
563 |
}
|
sl@0
|
564 |
|
sl@0
|
565 |
return(uriParserA.Equivalent(uriParserB));
|
sl@0
|
566 |
}
|
sl@0
|
567 |
|
sl@0
|
568 |
//End of file
|