|
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 "CPipeliningConfigTest.h" |
|
17 #include <uri8.h> |
|
18 |
|
19 CPipeliningConfigTest* CPipeliningConfigTest::NewLC(const TDesC& aTestName) |
|
20 { |
|
21 CPipeliningConfigTest* me = new (ELeave) CPipeliningConfigTest(); |
|
22 CleanupStack::PushL(me); |
|
23 me->ConstructL(aTestName); |
|
24 return me; |
|
25 } |
|
26 |
|
27 CPipeliningConfigTest::CPipeliningConfigTest() |
|
28 { |
|
29 } |
|
30 |
|
31 void CPipeliningConfigTest::ConstructL(const TDesC& aTestName) |
|
32 { |
|
33 iTestName = aTestName.AllocL(); |
|
34 } |
|
35 |
|
36 CPipeliningConfigTest::~CPipeliningConfigTest() |
|
37 { |
|
38 iTransactionUris.ResetAndDestroy(); |
|
39 delete iTestName; |
|
40 } |
|
41 |
|
42 |
|
43 |
|
44 const TDesC& CPipeliningConfigTest::TestCaseName() const |
|
45 { |
|
46 return *iTestName; |
|
47 } |
|
48 |
|
49 |
|
50 TInt CPipeliningConfigTest::TotalTransactionCount() const |
|
51 { |
|
52 return iTransactionUris.Count(); |
|
53 } |
|
54 |
|
55 |
|
56 TInt CPipeliningConfigTest::TransactionCount(TInt /*aConnectionIndex*/) const |
|
57 { |
|
58 return 0; |
|
59 } |
|
60 |
|
61 |
|
62 RHTTPTransaction CPipeliningConfigTest::GetTransactionL(TInt aIndex, |
|
63 RHTTPSession aSession, |
|
64 MHTTPTransactionCallback& aClient) |
|
65 { |
|
66 |
|
67 if (aIndex >= iTransactionUris.Count()) |
|
68 { |
|
69 User::Invariant(); |
|
70 } |
|
71 |
|
72 CheckAndSetSessionSettingsL(aSession); |
|
73 |
|
74 RStringF method = aSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable()); |
|
75 TUriParser8 uri; |
|
76 uri.Parse(*(iTransactionUris[aIndex])); |
|
77 return aSession.OpenTransactionL(uri, aClient, method); |
|
78 } |
|
79 |
|
80 |
|
81 TBool CPipeliningConfigTest::BatchTransactions() const |
|
82 { |
|
83 return ETrue; |
|
84 } |
|
85 |
|
86 |
|
87 TInt CPipeliningConfigTest::ExpectedError(RHTTPTransaction /*aTrans*/) |
|
88 { |
|
89 return KErrNone; |
|
90 } |
|
91 |
|
92 |
|
93 const TDesC8& CPipeliningConfigTest::GetRawRequest(TInt /*aConnectionIndex*/, |
|
94 TInt /*aTransIndex*/) |
|
95 { |
|
96 User::Invariant(); |
|
97 return KNullDesC8(); |
|
98 } |
|
99 |
|
100 |
|
101 const TDesC8& CPipeliningConfigTest::GetRawResponse(TInt /*aConnectionIndex*/, |
|
102 TInt /*aTransIndex*/) |
|
103 { |
|
104 User::Invariant(); |
|
105 return KNullDesC8(); |
|
106 } |
|
107 |
|
108 |
|
109 TInt CPipeliningConfigTest::ConnectionCount() const |
|
110 { |
|
111 return 0; |
|
112 } |
|
113 |
|
114 TInt CPipeliningConfigTest::RealExpectedConnectionCount() const |
|
115 { |
|
116 return iExpectedNumberConnections; |
|
117 } |
|
118 |
|
119 |
|
120 TBool CPipeliningConfigTest::EnableBatching() const |
|
121 { |
|
122 return ETrue; |
|
123 } |
|
124 |
|
125 |
|
126 void CPipeliningConfigTest::ProcessHeadersL(RHTTPTransaction /*aTrans*/) |
|
127 { |
|
128 //do nothing |
|
129 } |
|
130 |
|
131 TInt CPipeliningConfigTest::ErrorVal() const |
|
132 { |
|
133 return 0; |
|
134 } |
|
135 |
|
136 void CPipeliningConfigTest::CheckAndSetSessionSettingsL(RHTTPSession aSession) |
|
137 { |
|
138 RStringPool stringPool = aSession.StringPool(); |
|
139 RHTTPConnectionInfo sessionSettings = aSession.ConnectionInfo(); |
|
140 |
|
141 if (iMaxNumberTransactionsToPipeline > 0) |
|
142 { |
|
143 RStringF maxToPipelineSetting = stringPool.StringF(HTTP::EMaxNumTransactionsToPipeline, |
|
144 aSession.GetTable()); |
|
145 THTTPHdrVal value; |
|
146 if (sessionSettings.Property(maxToPipelineSetting, value) == EFalse) |
|
147 { |
|
148 value.SetInt(iMaxNumberTransactionsToPipeline); |
|
149 sessionSettings.SetPropertyL(maxToPipelineSetting,value); |
|
150 } |
|
151 } |
|
152 |
|
153 |
|
154 if (iMaxNumberTransportHandlers > 0) |
|
155 { |
|
156 RStringF maxTransportHandlers = stringPool.StringF(HTTP::EMaxNumTransportHandlers, |
|
157 aSession.GetTable()); |
|
158 THTTPHdrVal value; |
|
159 if (sessionSettings.Property(maxTransportHandlers, value) == EFalse) |
|
160 { |
|
161 value.SetInt(iMaxNumberTransportHandlers); |
|
162 sessionSettings.SetPropertyL(maxTransportHandlers,value); |
|
163 } |
|
164 } |
|
165 } |
|
166 |
|
167 |
|
168 void CPipeliningConfigTest::SetMaxNumberTransactionsToPipeline(TInt aMaxNumberTransactionsToPipeline) |
|
169 { |
|
170 iMaxNumberTransactionsToPipeline = aMaxNumberTransactionsToPipeline; |
|
171 } |
|
172 |
|
173 |
|
174 void CPipeliningConfigTest::SetMaxNumberTransportHandlers(TInt aMaxNumberTransportHandlers) |
|
175 { |
|
176 iMaxNumberTransportHandlers = aMaxNumberTransportHandlers; |
|
177 } |
|
178 |
|
179 |
|
180 void CPipeliningConfigTest::AddTransactionUrisL(const TDesC8& aUri, TInt aRepeatNumber) |
|
181 { |
|
182 for ( TInt ii = 0; ii < aRepeatNumber; ++ii ) |
|
183 { |
|
184 HBufC8* uri = aUri.AllocLC(); |
|
185 User::LeaveIfError(iTransactionUris.Append(uri)); |
|
186 CleanupStack::Pop(uri); |
|
187 } |
|
188 } |
|
189 |
|
190 |
|
191 |
|
192 void CPipeliningConfigTest::ClearTransactionUris() |
|
193 { |
|
194 iTransactionUris.ResetAndDestroy(); |
|
195 } |
|
196 |
|
197 |
|
198 void CPipeliningConfigTest::SetExpectedNumberConnections(TInt aExpectedNumberConnections) |
|
199 { |
|
200 iExpectedNumberConnections = aExpectedNumberConnections; |
|
201 } |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |