|
1 // Copyright (c) 2003-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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "CTestCase19.h" |
|
17 #include "httptestutils.h" |
|
18 |
|
19 const TInt KConn1TransCount = 3; |
|
20 const TInt KConn2TransCount = 1; |
|
21 const TInt KConn3TransCount = 1; |
|
22 const TInt KConnectionCount = 3; |
|
23 const TInt KBufferSize = 10; // Batching buffer size in bytes |
|
24 _LIT8(KTxtRawRequest, "GET / HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n"); |
|
25 _LIT8(KTxtRawResponse, "HTTP/1.1 200 Ok\r\nContent-Length: 6\r\n\r\nhello!"); |
|
26 _LIT8(KTxtRawResponseWithClose, "HTTP/1.1 200 Ok\r\nContent-Length: 6\r\nConnection: Close\r\n\r\nhello!"); |
|
27 |
|
28 CTestCase19* CTestCase19::NewL(CHTTPTestUtils& aTestUtils) |
|
29 { |
|
30 CTestCase19* self = new (ELeave) CTestCase19(aTestUtils); |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(); |
|
33 CleanupStack::Pop(self); |
|
34 return self; |
|
35 } |
|
36 |
|
37 CTestCase19::CTestCase19(CHTTPTestUtils& aTestUtils) |
|
38 : CBatchingTestCase(), iTestUtils(aTestUtils) |
|
39 { |
|
40 } |
|
41 |
|
42 void CTestCase19::ConstructL() |
|
43 { |
|
44 } |
|
45 |
|
46 CTestCase19::~CTestCase19() |
|
47 { |
|
48 } |
|
49 |
|
50 const TDesC& CTestCase19::TestCaseName() const |
|
51 { |
|
52 _LIT(KTxtTitle, "Test Case 19"); |
|
53 return KTxtTitle(); |
|
54 } |
|
55 |
|
56 TInt CTestCase19::TransactionCount(TInt aConnectionIndex) const |
|
57 { |
|
58 TInt transCount = 0; |
|
59 switch(aConnectionIndex) |
|
60 { |
|
61 case 0: |
|
62 { |
|
63 transCount = KConn1TransCount; |
|
64 } break; |
|
65 case 1: |
|
66 { |
|
67 transCount = KConn2TransCount; |
|
68 } break; |
|
69 case 2: |
|
70 { |
|
71 transCount = KConn3TransCount; |
|
72 } break; |
|
73 default: |
|
74 User::Invariant(); |
|
75 } |
|
76 |
|
77 return transCount; |
|
78 } |
|
79 |
|
80 TInt CTestCase19::TotalTransactionCount() const |
|
81 { |
|
82 return KConn1TransCount + KConn2TransCount + KConn3TransCount; |
|
83 } |
|
84 |
|
85 TInt CTestCase19::ConnectionCount() const |
|
86 { |
|
87 return KConnectionCount; |
|
88 } |
|
89 |
|
90 RHTTPTransaction CTestCase19::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient) |
|
91 { |
|
92 __ASSERT_ALWAYS(aIndex<TotalTransactionCount(), User::Invariant()); |
|
93 |
|
94 RStringF method = aSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable()); |
|
95 _LIT8(KTxtUri, "http://127.0.0.1"); |
|
96 TUriParser8 uri; |
|
97 uri.Parse(KTxtUri()); |
|
98 |
|
99 // Buffer size needs to be reduced in the session property before the first transaction. |
|
100 if( aIndex == 0 ) |
|
101 { |
|
102 RHTTPConnectionInfo connInfo = aSession.ConnectionInfo(); |
|
103 connInfo.SetPropertyL(aSession.StringPool().StringF(HTTP::EBatchingBufferSize,RHTTPSession::GetTable()), KBufferSize); |
|
104 } |
|
105 |
|
106 return aSession.OpenTransactionL(uri, aClient, method); |
|
107 } |
|
108 |
|
109 const TDesC8& CTestCase19::GetRawRequest(TInt aConnectionIndex, TInt aTransIndex) |
|
110 { |
|
111 __ASSERT_ALWAYS( (aTransIndex<TotalTransactionCount()) && (aConnectionIndex<KConnectionCount), User::Invariant()); |
|
112 |
|
113 return KTxtRawRequest(); |
|
114 } |
|
115 |
|
116 const TDesC8& CTestCase19::GetRawResponse(TInt aConnectionIndex, TInt aTransIndex) |
|
117 { |
|
118 __ASSERT_ALWAYS(aTransIndex<TotalTransactionCount(), User::Invariant()); |
|
119 |
|
120 if( aConnectionIndex==0 && aTransIndex==2 ) |
|
121 return KTxtRawResponseWithClose(); |
|
122 |
|
123 return KTxtRawResponse(); |
|
124 } |
|
125 |
|
126 |