|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cpipeliningtestcase.h" |
|
20 |
|
21 //Helper function to convert TPtr to TInt |
|
22 //declared as extern as it is already defined in |
|
23 //CPipeliningTestCaseParams.cpp as a static function |
|
24 static TInt Ptr2Int(const TDesC8& aPtr) |
|
25 { |
|
26 TInt aInt; |
|
27 TLex8 aLex(aPtr); |
|
28 aLex.Val(aInt); |
|
29 return aInt; |
|
30 } |
|
31 |
|
32 CPipeliningTestCase* CPipeliningTestCase::NewL ( CPipeliningTestParams& aPipeliningTestParams) |
|
33 { |
|
34 CPipeliningTestCase* self = new (ELeave) CPipeliningTestCase(aTestUtils, aPipeliningTestParams); |
|
35 return self; |
|
36 } |
|
37 |
|
38 |
|
39 |
|
40 CPipeliningTestCase::CPipeliningTestCase(CHTTPTestUtils& aTestUtils, CPipeliningTestParams& aPipeliningTestParams) |
|
41 : iTestUtils(aTestUtils), iPipeliningTestParams(aPipeliningTestParams) |
|
42 { |
|
43 } |
|
44 |
|
45 |
|
46 |
|
47 CPipeliningTestCase::~CPipeliningTestCase() |
|
48 { |
|
49 } |
|
50 |
|
51 |
|
52 |
|
53 const TDesC& CPipeliningTestCase::TestCaseName() const |
|
54 { |
|
55 return iPipeliningTestParams.TestCaseName(); |
|
56 } |
|
57 |
|
58 |
|
59 |
|
60 TInt CPipeliningTestCase::TransactionCount(TInt aConnectionIndex) const |
|
61 { |
|
62 return iPipeliningTestParams.TransactionCount(aConnectionIndex); |
|
63 } |
|
64 |
|
65 |
|
66 |
|
67 TInt CPipeliningTestCase::TotalTransactionCount() const |
|
68 { |
|
69 return iPipeliningTestParams.TotalTransactionCount(); |
|
70 } |
|
71 |
|
72 |
|
73 |
|
74 TBool CPipeliningTestCase::BatchTransactions() const |
|
75 { |
|
76 return ETrue; |
|
77 } |
|
78 |
|
79 |
|
80 |
|
81 TInt CPipeliningTestCase::ConnectionCount() const |
|
82 { |
|
83 return iPipeliningTestParams.ConnectionCount(); |
|
84 } |
|
85 |
|
86 TInt CPipeliningTestCase::ErrorVal() const |
|
87 { |
|
88 return iPipeliningTestParams.Error(); |
|
89 } |
|
90 |
|
91 RHTTPTransaction CPipeliningTestCase::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient) |
|
92 { |
|
93 __ASSERT_ALWAYS( aIndex < iPipeliningTestParams.TotalTransactionCount(), User::Invariant()); |
|
94 |
|
95 if(iPipeliningTestParams.TestCaseName().Compare(_L("IOP TEST CASE 6")) == 0) |
|
96 { |
|
97 _LIT8(KTxtUri, "http://127.0.0.1"); |
|
98 TUriParser8 uri; |
|
99 uri.Parse(KTxtUri()); |
|
100 |
|
101 RStringF method = aSession.StringPool().StringF(HTTP::EPOST,RHTTPSession::GetTable()); |
|
102 RHTTPTransaction trans = aSession.OpenTransactionL(uri, aClient, method); |
|
103 RHTTPHeaders headers = trans.Request().GetHeaderCollection(); |
|
104 |
|
105 |
|
106 _LIT8(KTxtHeaderName0, "Expect"); |
|
107 _LIT8(KTxtHeaderValue0, "100-Continue"); |
|
108 RStringF headerStrName0 = aSession.StringPool().OpenFStringL(KTxtHeaderName0()); |
|
109 CleanupClosePushL(headerStrName0); |
|
110 RStringF headerStrValue0 = aSession.StringPool().OpenFStringL(KTxtHeaderValue0()); |
|
111 CleanupClosePushL(headerStrValue0); |
|
112 THTTPHdrVal headerValue0(headerStrValue0); |
|
113 headers.SetFieldL(headerStrName0, headerValue0); |
|
114 CleanupStack::PopAndDestroy(2, &headerStrName0); |
|
115 return trans; |
|
116 } |
|
117 |
|
118 else if((iPipeliningTestParams.TestCaseName().Compare(_L("Test Case INC078630")) == 0) || (iPipeliningTestParams.TestCaseName().Compare(_L("Performance Test Case 8")) == 0)) |
|
119 { |
|
120 |
|
121 _LIT8(KTxtUri, "Microsoft-Server-ActiveSync?DeviceId=Foo&DeviceType=9999&Cmd=Ping"); |
|
122 TUriParser8 uri; |
|
123 uri.Parse(KTxtUri()); |
|
124 |
|
125 |
|
126 RStringF method = aSession.StringPool().StringF(HTTP::EPOST,RHTTPSession::GetTable()); |
|
127 RHTTPTransaction trans = aSession.OpenTransactionL(uri, aClient, method); |
|
128 RHTTPHeaders headers = trans.Request().GetHeaderCollection(); |
|
129 |
|
130 |
|
131 _LIT8(KTxtHeaderName0, "Host"); |
|
132 _LIT8(KTxtHeaderValue0, "127.0.0.1"); |
|
133 RStringF headerStrName0 = aSession.StringPool().OpenFStringL(KTxtHeaderName0()); |
|
134 CleanupClosePushL(headerStrName0); |
|
135 RStringF headerStrValue0 = aSession.StringPool().OpenFStringL(KTxtHeaderValue0()); |
|
136 CleanupClosePushL(headerStrValue0); |
|
137 THTTPHdrVal headerValue0(headerStrValue0); |
|
138 headers.SetFieldL(headerStrName0, headerValue0); |
|
139 CleanupStack::PopAndDestroy(2, &headerStrName0); |
|
140 |
|
141 _LIT8(KTxtHeaderName, "Accept-Language"); |
|
142 _LIT8(KTxtHeaderValue, "en-us"); |
|
143 RStringF headerStrName = aSession.StringPool().OpenFStringL(KTxtHeaderName()); |
|
144 CleanupClosePushL(headerStrName); |
|
145 RStringF headerStrValue = aSession.StringPool().OpenFStringL(KTxtHeaderValue()); |
|
146 CleanupClosePushL(headerStrValue); |
|
147 THTTPHdrVal headerValue(headerStrValue); |
|
148 headers.SetFieldL(headerStrName, headerValue); |
|
149 CleanupStack::PopAndDestroy(2, &headerStrName); |
|
150 |
|
151 _LIT8(KTxtHeaderName1, "MS-ASProtocolVersion"); |
|
152 _LIT8(KTxtHeaderValue1, "2.5"); |
|
153 RStringF headerStrName1 = aSession.StringPool().OpenFStringL(KTxtHeaderName1()); |
|
154 CleanupClosePushL(headerStrName1); |
|
155 RStringF headerStrValue1 = aSession.StringPool().OpenFStringL(KTxtHeaderValue1()); |
|
156 CleanupClosePushL(headerStrValue1); |
|
157 THTTPHdrVal headerValue1(headerStrValue1); |
|
158 headers.SetFieldL(headerStrName1, headerValue1); |
|
159 CleanupStack::PopAndDestroy(2, &headerStrName1); |
|
160 |
|
161 return trans; |
|
162 |
|
163 } |
|
164 else if(iPipeliningTestParams.TestCaseName().Compare(_L("Performance Test Case 9")) == 0) |
|
165 { |
|
166 |
|
167 _LIT8(KTxtUri, "http://www.newlc.com/Symbian-OS-Error-Codes.html"); |
|
168 TUriParser8 uri; |
|
169 uri.Parse(KTxtUri()); |
|
170 |
|
171 |
|
172 RStringF method = aSession.StringPool().StringF(HTTP::EPOST,RHTTPSession::GetTable()); |
|
173 RHTTPTransaction trans = aSession.OpenTransactionL(uri, aClient, method); |
|
174 RHTTPHeaders headers = trans.Request().GetHeaderCollection(); |
|
175 |
|
176 _LIT8(KTxtHeaderName3, "Host"); |
|
177 _LIT8(KTxtHeaderValue3, "194.146.227.34"); |
|
178 RStringF headerStrName3 = aSession.StringPool().OpenFStringL(KTxtHeaderName3()); |
|
179 CleanupClosePushL(headerStrName3); |
|
180 RStringF headerStrValue3 = aSession.StringPool().OpenFStringL(KTxtHeaderValue3()); |
|
181 CleanupClosePushL(headerStrValue3); |
|
182 THTTPHdrVal headerValue3(headerStrValue3); |
|
183 headers.SetFieldL(headerStrName3, headerValue3); |
|
184 CleanupStack::PopAndDestroy(2, &headerStrName3); |
|
185 |
|
186 _LIT8(KTxtHeaderName1, "Content-Type"); |
|
187 _LIT8(KTxtHeaderValue1, "*/*"); |
|
188 RStringF headerStrName1 = aSession.StringPool().OpenFStringL(KTxtHeaderName1()); |
|
189 CleanupClosePushL(headerStrName1); |
|
190 RStringF headerStrValue1 = aSession.StringPool().OpenFStringL(KTxtHeaderValue1()); |
|
191 CleanupClosePushL(headerStrValue1); |
|
192 THTTPHdrVal headerValue1(headerStrValue1); |
|
193 headers.SetFieldL(headerStrName1, headerValue1); |
|
194 CleanupStack::PopAndDestroy(2, &headerStrName1); |
|
195 |
|
196 //Set the body data |
|
197 //The Content-Length will be set to 14 |
|
198 if (iFormEncoder) |
|
199 { |
|
200 delete iFormEncoder; |
|
201 iFormEncoder = NULL; |
|
202 } |
|
203 |
|
204 iFormEncoder = CHTTPFormEncoder::NewL(); |
|
205 TBuf8<256> name8; |
|
206 TBuf8<256> value8; |
|
207 _LIT(KName, "recherche"); |
|
208 _LIT(KValue, "asdf"); |
|
209 name8.Copy(KName); |
|
210 value8.Copy(KValue); |
|
211 iFormEncoder->AddFieldL(name8, value8); |
|
212 |
|
213 MHTTPDataSupplier* dataSupplier = this; |
|
214 dataSupplier = iFormEncoder; |
|
215 trans.Request().SetBody(*dataSupplier); |
|
216 |
|
217 return trans; |
|
218 |
|
219 } |
|
220 |
|
221 |
|
222 TInt transType = iPipeliningTestParams.TransactionSequenceArray(aIndex); |
|
223 |
|
224 // Check the transaction type to see if its a HTTP 1.0 transaction |
|
225 // if 1.0 transaction then |
|
226 // change the session properties for transaction 1 |
|
227 |
|
228 // Check the value for the TransactionList header in the ini file if it carries a value |
|
229 // other than 1 at the position described by aIndex for the particular test case |
|
230 if ( (transType != 1) && (aIndex == 0)) |
|
231 { |
|
232 TransInfo thisTransInfo = iPipeliningTestParams.TransactionType(transType); |
|
233 |
|
234 TInt valueForHttpHdr = thisTransInfo.TransHeaderTypeArr[EHttpHeader]; |
|
235 if (( valueForHttpHdr != (ENoHeader) ) ) |
|
236 { |
|
237 if ((thisTransInfo.TransHeaderInfoPtrArr[valueForHttpHdr])->Des().Compare(_L("1.0"))) |
|
238 { |
|
239 RHTTPConnectionInfo connInfo = aSession.ConnectionInfo(); |
|
240 RStringPool strPool = aSession.StringPool(); |
|
241 THTTPHdrVal http10( strPool.StringF( HTTP::EHttp10, RHTTPSession::GetTable() ) ); |
|
242 connInfo.SetPropertyL( strPool.StringF( HTTP::EHTTPVersion,RHTTPSession::GetTable() ), http10 ); |
|
243 } |
|
244 } |
|
245 } |
|
246 |
|
247 //Check the request method type |
|
248 RStringF method; |
|
249 if(iPipeliningTestParams.ReqMethod().Compare(_L("HEAD")) == 0) |
|
250 { |
|
251 method = aSession.StringPool().StringF(HTTP::EHEAD,RHTTPSession::GetTable()); |
|
252 } |
|
253 else if(iPipeliningTestParams.ReqMethod().Compare(_L("POST")) == 0) |
|
254 { |
|
255 method = aSession.StringPool().StringF(HTTP::EPOST,RHTTPSession::GetTable()); |
|
256 } |
|
257 else if(iPipeliningTestParams.ReqMethod().Compare(_L("GET")) == 0) |
|
258 { |
|
259 method = aSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable()); |
|
260 } |
|
261 else if(iPipeliningTestParams.ReqMethod().Compare(_L("OPTIONS")) == 0) |
|
262 { |
|
263 method = aSession.StringPool().StringF(HTTP::EOPTIONS,RHTTPSession::GetTable()); |
|
264 } |
|
265 TInt aTempIndex(0); |
|
266 TInt uriCount(iPipeliningTestParams.UriCount()); |
|
267 aTempIndex = (uriCount > 1) ? aIndex : (uriCount-1); |
|
268 |
|
269 TUriParser8 uri; |
|
270 uri.Parse(iPipeliningTestParams.UriL(aTempIndex)); |
|
271 |
|
272 if ((iPipeliningTestParams.BatchingEnabled() == 1) && (iBatchingBufferSizeSet == 1)) |
|
273 { |
|
274 TInt bufferSize = iPipeliningTestParams.BufferSize(); |
|
275 RHTTPConnectionInfo connInfo = aSession.ConnectionInfo(); |
|
276 connInfo.SetPropertyL(aSession.StringPool().StringF(HTTP::EBatchingBufferSize,RHTTPSession::GetTable()), bufferSize); |
|
277 } |
|
278 |
|
279 if( (iPipeliningTestParams.Error() == KErrCancel) && (iPipeliningTestParams.TransactionSequenceArray(aIndex) == 2 )) |
|
280 { |
|
281 iTransToCancel = aSession.OpenTransactionL(uri, aClient, method); |
|
282 return iTransToCancel; |
|
283 } |
|
284 |
|
285 // Check the value for the TransactionList header in the ini file if it carries a value |
|
286 // other than 1 at the position described by aIndex for the particular test case |
|
287 else if ( transType != 1 ) |
|
288 { |
|
289 //Get the transaction info |
|
290 TransInfo thisTransInfo = iPipeliningTestParams.TransactionType(transType); |
|
291 |
|
292 //Check if there is a Cancel transaction |
|
293 TInt valueForTransactionHdr = thisTransInfo.TransHeaderTypeArr[ETransactionHeader]; |
|
294 if (( valueForTransactionHdr != ENoHeader ) ) |
|
295 { |
|
296 if ((thisTransInfo.TransHeaderInfoPtrArr[valueForTransactionHdr])->Des().Compare(_L("Cancel"))) |
|
297 { |
|
298 iTransToCancel = aSession.OpenTransactionL(uri, aClient, method); |
|
299 return iTransToCancel; |
|
300 } |
|
301 } |
|
302 |
|
303 //Create a plain-vanilla transaction |
|
304 RHTTPTransaction trans = aSession.OpenTransactionL(uri, aClient, method); |
|
305 |
|
306 //Check if there is a connection header |
|
307 TInt valueForConnectionHdr = thisTransInfo.TransHeaderTypeArr[::EConnectionHeader]; |
|
308 if (( valueForConnectionHdr != ENoHeader ) ) |
|
309 { |
|
310 if ( ( thisTransInfo.TransHeaderInfoPtrArr[valueForConnectionHdr])->Des().Compare(_L("Close") ) ) |
|
311 { |
|
312 AddConnectionCloseHeaderL(trans); |
|
313 } |
|
314 } |
|
315 |
|
316 |
|
317 TInt valueForBatchingHdr = thisTransInfo.TransHeaderTypeArr[EBatchingHeader]; |
|
318 if (( valueForBatchingHdr != ENoHeader ) && (thisTransInfo.TransHeaderInfoPtrArr[valueForBatchingHdr])->Des().Compare(_L("True")) )//Transaction needs a large header |
|
319 { |
|
320 // Add a fairly large header |
|
321 |
|
322 RHTTPHeaders headers = trans.Request().GetHeaderCollection(); |
|
323 |
|
324 _LIT8(KTxtHeaderName, "This_Is_A_Long_Header_Name"); |
|
325 _LIT8(KTxtHeaderValue, "This_Is_A_Long_Header_Value_abcdefghijklmnopqrstuvwxyz1234567890"); |
|
326 RStringF headerStrName = aSession.StringPool().OpenFStringL(KTxtHeaderName()); |
|
327 CleanupClosePushL(headerStrName); |
|
328 RStringF headerStrValue = aSession.StringPool().OpenFStringL(KTxtHeaderValue()); |
|
329 CleanupClosePushL(headerStrValue); |
|
330 THTTPHdrVal headerValue(headerStrValue); |
|
331 headers.SetFieldL(headerStrName, headerValue); |
|
332 CleanupStack::PopAndDestroy(2, &headerStrName); |
|
333 |
|
334 } |
|
335 return trans; |
|
336 } |
|
337 |
|
338 return aSession.OpenTransactionL(uri, aClient, method); |
|
339 } |
|
340 |
|
341 |
|
342 TBool CPipeliningTestCase::GetNextDataPart(TPtrC8& /*aDataPart*/) |
|
343 { |
|
344 return 0; |
|
345 } |
|
346 |
|
347 void CPipeliningTestCase::ReleaseData() |
|
348 { |
|
349 |
|
350 } |
|
351 TInt CPipeliningTestCase::OverallDataSize() |
|
352 { |
|
353 return 0; |
|
354 } |
|
355 TInt CPipeliningTestCase::Reset() |
|
356 { |
|
357 return 0; |
|
358 } |
|
359 const TDesC8& CPipeliningTestCase::GetRawRequest(TInt aConnectionIndex, TInt aTransIndex) |
|
360 { |
|
361 __ASSERT_ALWAYS( (aTransIndex<iPipeliningTestParams.TotalTransactionCount()) && (aConnectionIndex < iPipeliningTestParams.ConnectionCount()), User::Invariant()); |
|
362 |
|
363 return iPipeliningTestParams.RawRequest(aConnectionIndex, aTransIndex); |
|
364 } |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 const TDesC8& CPipeliningTestCase::GetRawResponse(TInt aConnectionIndex, TInt aTransIndex) |
|
370 { |
|
371 __ASSERT_ALWAYS( (aTransIndex<iPipeliningTestParams.TotalTransactionCount()) && (aConnectionIndex < iPipeliningTestParams.ConnectionCount()), User::Invariant()); |
|
372 |
|
373 return iPipeliningTestParams.RawResponse(aConnectionIndex, aTransIndex); |
|
374 } |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 void CPipeliningTestCase::AddConnectionCloseHeaderL(RHTTPTransaction aTransaction) |
|
380 { |
|
381 RStringF name = aTransaction.Session().StringPool().StringF(HTTP::EConnection, RHTTPSession::GetTable()); |
|
382 THTTPHdrVal value = aTransaction.Session().StringPool().StringF(HTTP::EClose, RHTTPSession::GetTable()); |
|
383 |
|
384 aTransaction.Request().GetHeaderCollection().SetFieldL(name, value); |
|
385 } |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 TInt CPipeliningTestCase::RealExpectedConnectionCount() const |
|
391 { |
|
392 TInt numUris = iPipeliningTestParams.UriCount(); |
|
393 _LIT8(KTxtUri, "http://127.0.0.1"); |
|
394 //Check if the number of URIs in the ini file is more than one for the particular test case |
|
395 if ( numUris != 1) |
|
396 { |
|
397 TInt numLocalConnections = 0; |
|
398 TInt numExternalConnections = 0; |
|
399 for (TInt ii = 0; ii < numUris ; ++ ii) |
|
400 { |
|
401 TPtrC8 thisUri; |
|
402 TRAPD(err,thisUri.Set(iPipeliningTestParams.UriL(ii))); |
|
403 if(err != KErrArgument) |
|
404 { |
|
405 if (thisUri.Compare(KTxtUri) == 0) |
|
406 { |
|
407 ++numLocalConnections; |
|
408 } |
|
409 else |
|
410 { |
|
411 ++numExternalConnections; |
|
412 } |
|
413 } |
|
414 } |
|
415 |
|
416 TInt totalConnections = numLocalConnections + ((numExternalConnections != 0) ? 1:0); |
|
417 return totalConnections; |
|
418 } |
|
419 else |
|
420 { |
|
421 TPtrC8 firstUri; |
|
422 TRAPD(err,firstUri.Set(iPipeliningTestParams.UriL(0))); |
|
423 if(err != KErrArgument) |
|
424 { |
|
425 if (firstUri.Compare(KTxtUri) == 0) |
|
426 { |
|
427 return iPipeliningTestParams.ConnectionCount(); |
|
428 } |
|
429 else |
|
430 { |
|
431 return 1; |
|
432 } |
|
433 } |
|
434 } |
|
435 return 0; |
|
436 } |
|
437 |
|
438 |
|
439 TInt CPipeliningTestCase::ExpectedError(RHTTPTransaction aTrans) |
|
440 { |
|
441 if (iPipeliningTestParams.Error() == KErrCancel) |
|
442 { |
|
443 if(!iIsTransCancelled) |
|
444 { |
|
445 if(aTrans.Id() == 3) |
|
446 { |
|
447 iTransToCancel.Cancel(); |
|
448 iIsTransCancelled = ETrue; |
|
449 iPipeliningTestParams.DecreaseTotalTransactionCount(); |
|
450 } |
|
451 } |
|
452 |
|
453 if( iTransToCancel.Id() == aTrans.Id() ) |
|
454 { |
|
455 return KErrCancel; |
|
456 } |
|
457 } |
|
458 else if ( iPipeliningTestParams.Error() == KErrDisconnected) |
|
459 { |
|
460 return KErrDisconnected; |
|
461 } |
|
462 |
|
463 return KErrNone; |
|
464 } |
|
465 |
|
466 void CPipeliningTestCase::ProcessHeadersL(RHTTPTransaction aTrans) |
|
467 { |
|
468 |
|
469 _LIT(KTxtFailed, "**TEST FAILED**"); |
|
470 _LIT(KExpectedValue, "Expected Value: %S"); |
|
471 _LIT(KActualValue, "Actual Value: %S"); |
|
472 _LIT(KExpectedLength, "Expected Content Length: %d"); |
|
473 _LIT(KActualLength, "Actual Content Length: %d"); |
|
474 |
|
475 |
|
476 if ( iPipeliningTestParams.ProcessHeader() ) |
|
477 { |
|
478 TInt numHdrs = iPipeliningTestParams.NumHdrs(); |
|
479 |
|
480 for (TInt xx=0; xx < numHdrs; ++xx ) |
|
481 { |
|
482 //Check if the header to process is WWW-Authenticate |
|
483 if((iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("WWW-Authenticate"))) == 0) |
|
484 { |
|
485 RStringPool stringPool = aTrans.Session().StringPool(); |
|
486 RHTTPHeaders headers = aTrans.Response().GetHeaderCollection(); |
|
487 RStringF headerStr = stringPool.StringF(HTTP::EWWWAuthenticate, aTrans.Session().GetTable()); |
|
488 FieldCompareL(headers.FieldPartsL(headerStr), iPipeliningTestParams.NumberOfHeaderVals(xx)); |
|
489 FieldValueCompareL(headers, headers.FieldPartsL(headerStr), xx, headerStr); |
|
490 } |
|
491 |
|
492 //Check if the header to process is Upgrade |
|
493 else if ( (iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("Upgrade"))) == 0 ) |
|
494 { |
|
495 RStringPool stringPool = aTrans.Session().StringPool(); |
|
496 RHTTPHeaders headers = aTrans.Response().GetHeaderCollection(); |
|
497 RStringF headerStr = stringPool.StringF(HTTP::EUpgrade, aTrans.Session().GetTable()); |
|
498 FieldCompareL(headers.FieldPartsL(headerStr), iPipeliningTestParams.NumberOfHeaderVals(xx)); |
|
499 FieldValueCompareL(headers, headers.FieldPartsL(headerStr), xx, headerStr); |
|
500 } |
|
501 |
|
502 //Check if the header to process is Content-Language |
|
503 else if ( (iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("Content-Language"))) == 0 ) |
|
504 { |
|
505 RStringPool stringPool = aTrans.Session().StringPool(); |
|
506 RHTTPHeaders headers = aTrans.Response().GetHeaderCollection(); |
|
507 RStringF headerStr = stringPool.StringF(HTTP::EContentLanguage, aTrans.Session().GetTable()); |
|
508 FieldCompareL(headers.FieldPartsL(headerStr), iPipeliningTestParams.NumberOfHeaderVals(xx)); |
|
509 FieldValueCompareL(headers, headers.FieldPartsL(headerStr), xx, headerStr); |
|
510 } |
|
511 |
|
512 //Check if the header to process is Server |
|
513 else if ( (iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("Server"))) == 0 ) |
|
514 { |
|
515 RStringPool stringPool = aTrans.Session().StringPool(); |
|
516 RHTTPHeaders headers = aTrans.Response().GetHeaderCollection(); |
|
517 RStringF headerStr = stringPool.StringF(HTTP::EServer, aTrans.Session().GetTable()); |
|
518 FieldCompareL(headers.FieldPartsL(headerStr), iPipeliningTestParams.NumberOfHeaderVals(xx)); |
|
519 FieldValueCompareL(headers, headers.FieldPartsL(headerStr), xx, headerStr); |
|
520 } |
|
521 |
|
522 //Check if the header to process is Host |
|
523 else if ( (iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("Host"))) == 0 ) |
|
524 { |
|
525 RStringPool stringPool = aTrans.Session().StringPool(); |
|
526 RHTTPHeaders headers = aTrans.Request().GetHeaderCollection(); |
|
527 THTTPHdrVal hdrVal; |
|
528 TBuf<100> buf1, buf2; |
|
529 RStringF headerStr = stringPool.StringF(HTTP::EHost, aTrans.Session().GetTable()); |
|
530 FieldValueCompareL(headers, 1, xx, headerStr); |
|
531 } |
|
532 |
|
533 //Check if the header to process is Content-Length |
|
534 else if ( (iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("Content-Length"))) == 0 ) |
|
535 { |
|
536 RStringPool stringPool = aTrans.Session().StringPool(); |
|
537 RHTTPHeaders headers = aTrans.Response().GetHeaderCollection(); |
|
538 THTTPHdrVal hdrVal; |
|
539 |
|
540 //Check Content-Length header parameter is stored correctly |
|
541 RStringF headerStr = stringPool.StringF(HTTP::EContentLength, aTrans.Session().GetTable()); |
|
542 User::LeaveIfError(headers.GetField(headerStr,0,hdrVal)); |
|
543 |
|
544 FieldCompareL(headers.FieldPartsL(headerStr), iPipeliningTestParams.NumberOfHeaderVals(xx)); |
|
545 |
|
546 if (hdrVal.Int() != Ptr2Int(iPipeliningTestParams.HeaderVal(xx+1,1)) ) |
|
547 { |
|
548 iTestUtils.LogIt(KExpectedLength, hdrVal.Int()); |
|
549 iTestUtils.LogIt(KActualLength, Ptr2Int(iPipeliningTestParams.HeaderVal(xx + 1,1))); |
|
550 iTestUtils.LogIt(KTxtFailed); |
|
551 User::Leave(KErrArgument); |
|
552 } |
|
553 iTestUtils.LogIt(KExpectedLength, hdrVal.Int()); |
|
554 iTestUtils.LogIt(KActualLength, Ptr2Int(iPipeliningTestParams.HeaderVal(xx + 1,1))); |
|
555 } |
|
556 |
|
557 //Check if the header to process is Content-Type |
|
558 else if ( (iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("Content-Type"))) == 0 ) |
|
559 { |
|
560 RStringPool stringPool = aTrans.Session().StringPool(); |
|
561 RHTTPHeaders headers = aTrans.Response().GetHeaderCollection(); |
|
562 THTTPHdrVal hdrVal; |
|
563 TBuf<100> buf1, buf2; |
|
564 |
|
565 RStringF headerStr = stringPool.StringF(HTTP::EContentType, aTrans.Session().GetTable()); |
|
566 |
|
567 FieldCompareL(headers.FieldPartsL(headerStr), iPipeliningTestParams.NumberOfHeaderVals(xx)); |
|
568 |
|
569 for ( TInt mn =0; mn < headers.FieldPartsL(headerStr); ++mn) |
|
570 { |
|
571 User::LeaveIfError(headers.GetField(headerStr,mn,hdrVal)); |
|
572 TPtrC8 ptrValue1 ( hdrVal.StrF ().DesC() ); |
|
573 if (TInt mno = ptrValue1.Compare(iPipeliningTestParams.HeaderVal(xx+1,mn+1)) != 0) |
|
574 { |
|
575 buf1.Copy(ptrValue1); |
|
576 buf2.Copy(iPipeliningTestParams.HeaderVal(xx + 1,mn + 1)); |
|
577 iTestUtils.LogIt(KExpectedValue, &buf1); |
|
578 iTestUtils.LogIt(KActualValue, &buf2); |
|
579 iTestUtils.LogIt(KTxtFailed); |
|
580 User::Leave(KErrArgument); |
|
581 } |
|
582 buf1.Copy(ptrValue1); |
|
583 buf2.Copy(iPipeliningTestParams.HeaderVal(xx + 1,mn + 1)); |
|
584 iTestUtils.LogIt(KExpectedValue, &buf1); |
|
585 iTestUtils.LogIt(KActualValue, &buf2); |
|
586 |
|
587 /* |
|
588 RStringF param = stringPool.StringF(HTTP::ECharset, aTrans.Session().GetTable()); |
|
589 THTTPHdrVal paramval; |
|
590 User::LeaveIfError(headers.GetParam(headerStr, param, paramval, mn)); |
|
591 TPtrC8 paramval1(paramval.StrF().DesC()); |
|
592 TBuf<100> buf3; |
|
593 buf3.Copy(paramval1); |
|
594 _LIT(KTxtParam, "Parameter Charset= %S"); |
|
595 iTestUtils.LogIt(KTxtParam, &buf3); |
|
596 */ |
|
597 } |
|
598 } |
|
599 |
|
600 //Check if the header to process is Date |
|
601 else if ( (iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("Date"))) == 0 ) |
|
602 { |
|
603 RStringPool stringPool = aTrans.Session().StringPool(); |
|
604 RHTTPHeaders headers = aTrans.Response().GetHeaderCollection(); |
|
605 THTTPHdrVal hdrVal; |
|
606 |
|
607 RStringF headerStr = stringPool.StringF(HTTP::EDate, aTrans.Session().GetTable()); |
|
608 |
|
609 if( headers.FieldPartsL(headerStr) != iPipeliningTestParams.NumberOfHeaderVals(xx)) |
|
610 { |
|
611 User::Leave(KErrArgument); |
|
612 } |
|
613 |
|
614 for ( TInt mn =0; mn < headers.FieldPartsL(headerStr); ++mn) |
|
615 { |
|
616 User::LeaveIfError(headers.GetField(headerStr,mn,hdrVal)); |
|
617 TDateTime rdt = hdrVal.DateTime(); |
|
618 } |
|
619 } |
|
620 |
|
621 //Check if the header to process is MsgBody |
|
622 else if ( (iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("MsgBody"))) == 0 ) |
|
623 { |
|
624 RStringPool stringPool = aTrans.Session().StringPool(); |
|
625 THTTPHdrVal hdrval; |
|
626 |
|
627 if(aTrans.Response().HasBody()) |
|
628 { |
|
629 _LIT(KStrHasBody, "Response stream has a body"); |
|
630 iTestUtils.LogIt(KStrHasBody); |
|
631 } |
|
632 else |
|
633 { |
|
634 _LIT(KStrNoBody, "Response stream has no body"); |
|
635 iTestUtils.LogIt(KStrNoBody); |
|
636 } |
|
637 |
|
638 if ( iPipeliningTestParams.HeaderVal(xx+1, 1).Compare(_L8("Null")) == 0) |
|
639 { |
|
640 TBool hasBody = aTrans.Response().HasBody(); |
|
641 if ( hasBody ) |
|
642 { |
|
643 _LIT(KTxtExpectedMsg, "Expected message body: NULL"); |
|
644 iTestUtils.LogIt(KTxtExpectedMsg); |
|
645 iTestUtils.LogIt(KTxtFailed); |
|
646 User::Leave(KErrArgument); |
|
647 } |
|
648 else |
|
649 { |
|
650 _LIT(KTxtHasBody, "Message Body: NULL"); |
|
651 iTestUtils.LogIt(KTxtHasBody); |
|
652 } |
|
653 } |
|
654 } |
|
655 } |
|
656 } |
|
657 } |
|
658 |
|
659 TBool CPipeliningTestCase::EnableBatching() const |
|
660 { |
|
661 return iPipeliningTestParams.BatchingEnabled(); |
|
662 } |
|
663 |
|
664 /** |
|
665 Compares the number fields in the String pool with those provided in the ini file |
|
666 @param aStringPool |
|
667 The String Pool |
|
668 @param aIniFile |
|
669 The fields from the ini file |
|
670 @leave |
|
671 KErrArgument if the number of fields in the ini file do not match those from the string pool |
|
672 */ |
|
673 void CPipeliningTestCase::FieldCompareL(TInt aStringPool, TInt aIniFile) |
|
674 { |
|
675 |
|
676 _LIT(KExpectedFields, "Expected number of fields: %d"); |
|
677 _LIT(KActualFields, "Actual number of fields: %d"); |
|
678 _LIT(KTxtFailed, "**TEST FAILED**"); |
|
679 |
|
680 if( aStringPool != aIniFile) |
|
681 { |
|
682 iTestUtils.LogIt(KExpectedFields,aStringPool ); |
|
683 iTestUtils.LogIt(KActualFields, aIniFile); |
|
684 iTestUtils.LogIt(KTxtFailed); |
|
685 User::Leave(KErrArgument); |
|
686 } |
|
687 iTestUtils.LogIt(KExpectedFields,aStringPool); |
|
688 iTestUtils.LogIt(KActualFields, aIniFile); |
|
689 |
|
690 } |
|
691 |
|
692 /** |
|
693 Compares the values provided for each header in the ini file with those obtained from |
|
694 the string pool |
|
695 @param headers |
|
696 Collection of headers from the response/request |
|
697 @param xyz |
|
698 Number of fields/headers present in the string pool |
|
699 @param xx |
|
700 Index value the header that needs to be processed |
|
701 @param headerStr |
|
702 Holds the header name that is obtained from the string pool |
|
703 @leave |
|
704 KErrArgument if the field values do not match |
|
705 */ |
|
706 void CPipeliningTestCase::FieldValueCompareL(RHTTPHeaders headers, TInt xyz, TInt xx, RStringF headerStr) |
|
707 { |
|
708 |
|
709 _LIT(KTxtFailed, "**TEST FAILED**"); |
|
710 _LIT(KExpectedValue, "Expected Value: %S"); |
|
711 _LIT(KActualValue, "Actual Value: %S"); |
|
712 |
|
713 TBuf<100> buf1, buf2; |
|
714 THTTPHdrVal hdrVal; |
|
715 |
|
716 for ( TInt mn =0; mn < xyz; ++mn) |
|
717 { |
|
718 User::LeaveIfError(headers.GetField(headerStr,mn,hdrVal)); |
|
719 TPtrC8 ptrValue1 ( hdrVal.StrF ().DesC() ); |
|
720 if (TInt mno = ptrValue1.Compare(iPipeliningTestParams.HeaderVal(xx+1,mn+1)) != 0) |
|
721 { |
|
722 buf1.Copy(ptrValue1); |
|
723 buf2.Copy(iPipeliningTestParams.HeaderVal(xx + 1,mn + 1)); |
|
724 iTestUtils.LogIt(KExpectedValue, &buf1); |
|
725 iTestUtils.LogIt(KActualValue, &buf2); |
|
726 iTestUtils.LogIt(KTxtFailed); |
|
727 User::Leave(KErrArgument); |
|
728 } |
|
729 buf1.Copy(ptrValue1); |
|
730 buf2.Copy(iPipeliningTestParams.HeaderVal(xx + 1,mn + 1)); |
|
731 iTestUtils.LogIt(KExpectedValue, &buf1); |
|
732 iTestUtils.LogIt(KActualValue, &buf2); |
|
733 } |
|
734 } |
|
735 |
|
736 |
|
737 |
|
738 |
|
739 |
|
740 |
|
741 |