|
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 "cpipeliningtestengine.h" |
|
17 #include "cpipeliningtestserver.h" |
|
18 #include "cpipeliningtestclient.h" |
|
19 |
|
20 #include "CTestCase1.h" |
|
21 #include "CTestCase2.h" |
|
22 #include "CTestCase3.h" |
|
23 #include "CTestCase4.h" |
|
24 #include "CTestCase5.h" |
|
25 #include "CTestCase6.h" |
|
26 #include "CTestCase7.h" |
|
27 #include "CTestCase8.h" |
|
28 #include "CTestCase9.h" |
|
29 #include "CTestCase10.h" |
|
30 #include "CTestCase11.h" |
|
31 #include "CTestCase12.h" |
|
32 #include "CTestCase13.h" |
|
33 #include "CTestCase14.h" |
|
34 #include "CTestCase15.h" |
|
35 #include "CTestCase16.h" |
|
36 #include "CTestCase17.h" |
|
37 #include "CTestCase18.h" |
|
38 #include "CTestCase19.h" |
|
39 #include "CTestCase20.h" |
|
40 #include "CTestCase21.h" |
|
41 #include "CTestCase22.h" |
|
42 #include "CINC025140.h" |
|
43 #include "CINC036954.h" |
|
44 #include "CINC036384.h" |
|
45 #include "CINC037440.h" |
|
46 #include "CINC052596.h" |
|
47 #include "CINC077703.h" |
|
48 #include "CINC077703More.h" |
|
49 #include "CHeaderDecode.h" |
|
50 #include "cpipeliningconfigtest.h" |
|
51 #include "CINC078630.h" |
|
52 #include "CINC073400.h" |
|
53 #include "CINC077703New.h" |
|
54 #include "CPREQ1805.h" |
|
55 #include "CPREQ1805_Batching.h" |
|
56 #include "CRecvTimeOut.h" |
|
57 #include "ctestcase23.h" |
|
58 #include "ctestcase24.h" |
|
59 #include "ctestcase25.h" |
|
60 #include "ctestcase26.h" |
|
61 #include "ctestcasepipelinefallback.h" |
|
62 |
|
63 _LIT(KTestHttpPipeliningTestTitle, "HTTP Pipelining Unit Test Harness"); |
|
64 |
|
65 CPipeliningTestEngine* CPipeliningTestEngine::NewL() |
|
66 { |
|
67 CPipeliningTestEngine* self = new (ELeave) CPipeliningTestEngine(); |
|
68 CleanupStack::PushL(self); |
|
69 self->ConstructL(); |
|
70 CleanupStack::Pop(self); |
|
71 return self; |
|
72 } |
|
73 |
|
74 CPipeliningTestEngine::~CPipeliningTestEngine() |
|
75 { |
|
76 delete iTestServer; |
|
77 delete iTestUtils; |
|
78 } |
|
79 |
|
80 CPipeliningTestEngine::CPipeliningTestEngine() |
|
81 { |
|
82 } |
|
83 |
|
84 void CPipeliningTestEngine::ConstructL() |
|
85 { |
|
86 iTestUtils = CHTTPTestUtils::NewL(KTestHttpPipeliningTestTitle()); |
|
87 |
|
88 iTestUtils->InitCommsL(); |
|
89 |
|
90 iTestServer = CPipeliningTestServer::NewL(*iTestUtils, *this); |
|
91 iTestServer->StartServerL(); |
|
92 } |
|
93 |
|
94 void CPipeliningTestEngine::StartTests() |
|
95 { |
|
96 TRAPD(leaveErr, DoTestsL()); |
|
97 if(leaveErr!=KErrNone) |
|
98 { |
|
99 _LIT(KTxtLeave, "Engine - Caught a Leave. Leave Error: %d"); |
|
100 iTestUtils->LogIt(KTxtLeave(), leaveErr); |
|
101 } |
|
102 } |
|
103 |
|
104 void CPipeliningTestEngine::DoTestsL() |
|
105 { |
|
106 |
|
107 // Test Case 1 |
|
108 CTestCase1* testCase1 = CTestCase1::NewL(*iTestUtils); |
|
109 CleanupStack::PushL(testCase1); |
|
110 RunTestL(*testCase1); |
|
111 CleanupStack::PopAndDestroy(testCase1); |
|
112 |
|
113 // Test Case 2 |
|
114 CTestCase2* testCase2 = CTestCase2::NewL(*iTestUtils); |
|
115 CleanupStack::PushL(testCase2); |
|
116 RunTestL(*testCase2); |
|
117 CleanupStack::PopAndDestroy(testCase2); |
|
118 |
|
119 |
|
120 // Test Case 4 |
|
121 CTestCase4* testCase4 = CTestCase4::NewL(*iTestUtils); |
|
122 CleanupStack::PushL(testCase4); |
|
123 RunTestL(*testCase4); |
|
124 CleanupStack::PopAndDestroy(testCase4); |
|
125 |
|
126 // Test Case 5 |
|
127 CTestCase5* testCase5 = CTestCase5::NewL(*iTestUtils); |
|
128 CleanupStack::PushL(testCase5); |
|
129 RunTestL(*testCase5); |
|
130 CleanupStack::PopAndDestroy(testCase5); |
|
131 |
|
132 // Test Case 6 |
|
133 CTestCase6* testCase6 = CTestCase6::NewL(*iTestUtils); |
|
134 CleanupStack::PushL(testCase6); |
|
135 RunTestL(*testCase6); |
|
136 CleanupStack::PopAndDestroy(testCase6); |
|
137 |
|
138 // Test Case 7 |
|
139 CTestCase7* testCase7 = CTestCase7::NewL(*iTestUtils); |
|
140 CleanupStack::PushL(testCase7); |
|
141 RunTestL(*testCase7); |
|
142 CleanupStack::PopAndDestroy(testCase7); |
|
143 |
|
144 // Test Case 8 |
|
145 CTestCase8* testCase8 = CTestCase8::NewL(*iTestUtils); |
|
146 CleanupStack::PushL(testCase8); |
|
147 RunTestL(*testCase8); |
|
148 CleanupStack::PopAndDestroy(testCase8); |
|
149 |
|
150 // Test Case 9 |
|
151 CTestCase9* testCase9 = CTestCase9::NewL(*iTestUtils); |
|
152 CleanupStack::PushL(testCase9); |
|
153 RunTestL(*testCase9); |
|
154 CleanupStack::PopAndDestroy(testCase9); |
|
155 |
|
156 // Test Case 10 |
|
157 CTestCase10* testCase10 = CTestCase10::NewL(*iTestUtils); |
|
158 CleanupStack::PushL(testCase10); |
|
159 RunTestL(*testCase10); |
|
160 CleanupStack::PopAndDestroy(testCase10); |
|
161 |
|
162 // Test Case 11 |
|
163 CTestCase11* testCase11 = CTestCase11::NewL(*iTestUtils); |
|
164 CleanupStack::PushL(testCase11); |
|
165 RunTestL(*testCase11); |
|
166 CleanupStack::PopAndDestroy(testCase11); |
|
167 |
|
168 // Test Case 12 |
|
169 CTestCase12* testCase12 = CTestCase12::NewL(*iTestUtils); |
|
170 CleanupStack::PushL(testCase12); |
|
171 RunTestL(*testCase12); |
|
172 CleanupStack::PopAndDestroy(testCase12); |
|
173 |
|
174 // Test Case 13 |
|
175 CTestCase13* testCase13 = CTestCase13::NewL(*iTestUtils); |
|
176 CleanupStack::PushL(testCase13); |
|
177 RunTestL(*testCase13); |
|
178 CleanupStack::PopAndDestroy(testCase13); |
|
179 |
|
180 // Test Case 14 |
|
181 CTestCase14* testCase14 = CTestCase14::NewL(*iTestUtils); |
|
182 CleanupStack::PushL(testCase14); |
|
183 RunTestL(*testCase14); |
|
184 CleanupStack::PopAndDestroy(testCase14); |
|
185 |
|
186 // Test Case 15 |
|
187 CTestCase15* testCase15 = CTestCase15::NewL(*iTestUtils); |
|
188 CleanupStack::PushL(testCase15); |
|
189 RunTestL(*testCase15); |
|
190 CleanupStack::PopAndDestroy(testCase15); |
|
191 |
|
192 // Test Case 16 |
|
193 CTestCase16* testCase16 = CTestCase16::NewL(*iTestUtils); |
|
194 CleanupStack::PushL(testCase16); |
|
195 RunTestL(*testCase16); |
|
196 CleanupStack::PopAndDestroy(testCase16); |
|
197 |
|
198 // Test Case 17 |
|
199 CTestCase17* testCase17 = CTestCase17::NewL(*iTestUtils); |
|
200 CleanupStack::PushL(testCase17); |
|
201 RunTestL(*testCase17); |
|
202 CleanupStack::PopAndDestroy(testCase17); |
|
203 |
|
204 // Test Case 18 |
|
205 CTestCase18* testCase18 = CTestCase18::NewL(*iTestUtils); |
|
206 CleanupStack::PushL(testCase18); |
|
207 RunTestL(*testCase18); |
|
208 CleanupStack::PopAndDestroy(testCase18); |
|
209 |
|
210 // Test Case 19 |
|
211 CTestCase19* testCase19 = CTestCase19::NewL(*iTestUtils); |
|
212 CleanupStack::PushL(testCase19); |
|
213 RunTestL(*testCase19); |
|
214 CleanupStack::PopAndDestroy(testCase19); |
|
215 |
|
216 // Test Case 20 |
|
217 CTestCase20* testCase20 = CTestCase20::NewL(*iTestUtils); |
|
218 CleanupStack::PushL(testCase20); |
|
219 RunTestL(*testCase20); |
|
220 CleanupStack::PopAndDestroy(testCase20); |
|
221 |
|
222 // Test Case 21 |
|
223 CTestCase21* testCase21 = CTestCase21::NewL(*iTestUtils); |
|
224 CleanupStack::PushL(testCase21); |
|
225 RunTestL(*testCase21); |
|
226 CleanupStack::PopAndDestroy(testCase21); |
|
227 |
|
228 // Test Case 22 |
|
229 CTestCase22* testCase22 = CTestCase22::NewL(*iTestUtils); |
|
230 CleanupStack::PushL(testCase22); |
|
231 RunTestL(*testCase22); |
|
232 CleanupStack::PopAndDestroy(testCase22); |
|
233 |
|
234 // Test Case INC025140 |
|
235 CINC025140* inc025140 = CINC025140::NewL(*iTestUtils); |
|
236 CleanupStack::PushL(inc025140); |
|
237 RunTestL(*inc025140); |
|
238 CleanupStack::PopAndDestroy(inc025140); |
|
239 |
|
240 // Test Case INC036954 |
|
241 CINC036954* inc036954 = CINC036954::NewL(*iTestUtils); |
|
242 CleanupStack::PushL(inc036954); |
|
243 RunTestL(*inc036954); |
|
244 CleanupStack::PopAndDestroy(inc036954); |
|
245 |
|
246 // Test Case INC036384 |
|
247 CINC036384* inc036384 = CINC036384::NewL(*iTestUtils); |
|
248 CleanupStack::PushL(inc036384); |
|
249 RunTestL(*inc036384); |
|
250 CleanupStack::PopAndDestroy(inc036384); |
|
251 |
|
252 // Test Case INC037440 |
|
253 CINC037440* inc037440 = CINC037440::NewL(*iTestUtils); |
|
254 CleanupStack::PushL(inc037440); |
|
255 RunTestL(*inc037440); |
|
256 CleanupStack::PopAndDestroy(inc037440); |
|
257 |
|
258 // Test Case CINC052596 |
|
259 CINC052596* inc052596 = CINC052596::NewL(*iTestUtils); |
|
260 CleanupStack::PushL(inc052596); |
|
261 RunTestL(*inc052596); |
|
262 CleanupStack::PopAndDestroy(inc052596); |
|
263 |
|
264 // Test Case INC077703 |
|
265 CINC077703* inc077703 = CINC077703::NewL (*iTestUtils); |
|
266 CleanupStack::PushL ( inc077703 ); |
|
267 RunTestL ( *inc077703 ); |
|
268 CleanupStack::PopAndDestroy ( inc077703 ); |
|
269 |
|
270 // Test Case for Receive Timeout |
|
271 CRecvTimeOut* recvTimeOut = CRecvTimeOut::NewL (*iTestUtils); |
|
272 CleanupStack::PushL ( recvTimeOut ); |
|
273 RunTestL ( *recvTimeOut ); |
|
274 CleanupStack::PopAndDestroy ( recvTimeOut ); |
|
275 |
|
276 // Test Case INC077703More |
|
277 CINC077703More* inc077703More = CINC077703More::NewL (*iTestUtils); |
|
278 CleanupStack::PushL ( inc077703More ); |
|
279 RunTestL ( *inc077703More ); |
|
280 CleanupStack::PopAndDestroy ( inc077703More ); |
|
281 |
|
282 // Test Case CINC073400 |
|
283 CINC073400* inc073400 = CINC073400::NewL(*iTestUtils); |
|
284 CleanupStack::PushL(inc073400); |
|
285 RunTestL(*inc073400); |
|
286 CleanupStack::PopAndDestroy(inc073400); |
|
287 |
|
288 // Test Case CINC078630 |
|
289 CINC078630* inc078630 = CINC078630::NewL(*iTestUtils); |
|
290 CleanupStack::PushL(inc078630); |
|
291 RunTestL(*inc078630); |
|
292 CleanupStack::PopAndDestroy(inc078630); |
|
293 |
|
294 // Test Case INC077703New |
|
295 CINC077703New* inc077703New = CINC077703New::NewL (*iTestUtils); |
|
296 CleanupStack::PushL ( inc077703New ); |
|
297 RunTestL ( *inc077703New ); |
|
298 CleanupStack::PopAndDestroy ( inc077703New ); |
|
299 |
|
300 // Test Case 3 |
|
301 CTestCase3* testCase3 = CTestCase3::NewL(*iTestUtils); |
|
302 CleanupStack::PushL(testCase3); |
|
303 RunTestL(*testCase3); |
|
304 CleanupStack::PopAndDestroy(testCase3); |
|
305 |
|
306 // Test Case HeaderDecode |
|
307 CHeaderDecode* headerDecode = CHeaderDecode::NewL(*iTestUtils); |
|
308 CleanupStack::PushL(headerDecode); |
|
309 RunTestL(*headerDecode); |
|
310 CleanupStack::PopAndDestroy(headerDecode); |
|
311 |
|
312 // Test Case CPREQ1805Pipelining |
|
313 CPREQ1805* preq1805 = CPREQ1805::NewL(*iTestUtils); |
|
314 CleanupStack::PushL(preq1805); |
|
315 RunTestL(*preq1805); |
|
316 CleanupStack::PopAndDestroy(preq1805); |
|
317 |
|
318 // Test Case CPREQ1805Batching |
|
319 CPREQ1805Batching* preq1805Batching = CPREQ1805Batching::NewL(*iTestUtils); |
|
320 CleanupStack::PushL(preq1805Batching); |
|
321 RunTestL(*preq1805Batching); |
|
322 CleanupStack::PopAndDestroy(preq1805Batching); |
|
323 |
|
324 CTestCase23* testCase23 = CTestCase23::NewL(*iTestUtils); |
|
325 CleanupStack::PushL(testCase23); |
|
326 RunTestL(*testCase23); |
|
327 CleanupStack::PopAndDestroy(testCase23); |
|
328 |
|
329 CTestCase24* testCase24 = CTestCase24::NewL(*iTestUtils); |
|
330 CleanupStack::PushL(testCase24); |
|
331 RunTestL(*testCase24); |
|
332 CleanupStack::PopAndDestroy(testCase24); |
|
333 |
|
334 CTestCase25* testCase25 = CTestCase25::NewL(*iTestUtils); |
|
335 CleanupStack::PushL(testCase25); |
|
336 RunTestL(*testCase25); |
|
337 CleanupStack::PopAndDestroy(testCase25); |
|
338 |
|
339 CTestCase26* testCase26 = CTestCase26::NewL(*iTestUtils); |
|
340 CleanupStack::PushL(testCase26); |
|
341 RunTestL(*testCase26); |
|
342 CleanupStack::PopAndDestroy(testCase26); |
|
343 |
|
344 CTestCasePipelineFallback* pipelineFallback = CTestCasePipelineFallback::NewL(*iTestUtils); |
|
345 CleanupStack::PushL(pipelineFallback); |
|
346 RunTestL(*pipelineFallback); |
|
347 CleanupStack::PopAndDestroy(pipelineFallback); |
|
348 |
|
349 DoPipeliningConfigTestsL(); |
|
350 } |
|
351 |
|
352 void CPipeliningTestEngine::DoPipeliningConfigTestsL() |
|
353 /* A set of tests to config pipelining to restrict the number of transactions sent down one |
|
354 connection |
|
355 |
|
356 The same test class object is reused with settings being changed between each test. |
|
357 */ |
|
358 { |
|
359 _LIT(KPipeliningConfigTestName, "PipeliningConfig"); |
|
360 _LIT8(KUri1, "http://10.29.23.12/"); |
|
361 _LIT8(KUri2, "http://10.29.23.12/"); |
|
362 |
|
363 CPipeliningConfigTest* test = CPipeliningConfigTest::NewLC(KPipeliningConfigTestName); |
|
364 |
|
365 |
|
366 // 2 transactions to same location, with limit to only pipeline 1 at a time |
|
367 // 2 connections expected |
|
368 test->AddTransactionUrisL(KUri1, 2); |
|
369 test->SetMaxNumberTransactionsToPipeline(1); |
|
370 test->SetExpectedNumberConnections(2); |
|
371 RunTestL(*test); |
|
372 |
|
373 |
|
374 // 4 transactions to same location, with limit to pipeline upto 2 at a time |
|
375 // 2 connections expected |
|
376 test->AddTransactionUrisL(KUri1, 2); |
|
377 test->SetMaxNumberTransactionsToPipeline(2); |
|
378 RunTestL(*test); |
|
379 |
|
380 |
|
381 // 1 transaction to one location, 3 to another with limit to pipeline upto 2 at a time |
|
382 // 3 connections expected |
|
383 test->ClearTransactionUris(); |
|
384 test->AddTransactionUrisL(KUri2); |
|
385 test->AddTransactionUrisL(KUri1,3); |
|
386 test->SetExpectedNumberConnections(3); |
|
387 RunTestL(*test); |
|
388 |
|
389 |
|
390 // 4 transactions to same location, limit to only pipeline 1 at a time |
|
391 // Limit Transport Handlers to 3 |
|
392 // Expect 3 connections |
|
393 test->ClearTransactionUris(); |
|
394 test->AddTransactionUrisL(KUri1, 4); |
|
395 test->SetMaxNumberTransactionsToPipeline(1); |
|
396 test->SetMaxNumberTransportHandlers(3); |
|
397 RunTestL(*test); |
|
398 CleanupStack::PopAndDestroy(test); |
|
399 } |
|
400 |
|
401 |
|
402 void CPipeliningTestEngine::RunTestL(MPipeliningTestCase& aTestCase) |
|
403 { |
|
404 // Run a single test case |
|
405 iTestCase = &aTestCase; |
|
406 iTestFailed = EFalse; |
|
407 iTestUtils->StartTestL( aTestCase.TestCaseName() ); |
|
408 CPipeliningTestClient* testClient = CPipeliningTestClient::NewL(*iTestUtils, *this); |
|
409 CleanupStack::PushL(testClient); |
|
410 |
|
411 testClient->SetTestCase(&aTestCase); |
|
412 iTestServer->SetTestCase(&aTestCase); |
|
413 testClient->StartClientL(); |
|
414 |
|
415 CActiveScheduler::Start(); |
|
416 |
|
417 CleanupStack::PopAndDestroy(testClient); |
|
418 iTestServer->ResetServer(); |
|
419 |
|
420 iTestUtils->EndTest(iTestFailed); |
|
421 } |
|
422 |
|
423 void CPipeliningTestEngine::EndTest(TInt aError) |
|
424 { |
|
425 if( aError < KErrNone ) |
|
426 { |
|
427 iTestFailed = ETrue; |
|
428 _LIT(KTxtEndTestFail, "Engine - Test Failed. Completed with ErrorCode: %d"); |
|
429 iTestUtils->LogIt(KTxtEndTestFail(), aError); |
|
430 } |
|
431 else |
|
432 { |
|
433 __ASSERT_DEBUG( iTestCase!=NULL, User::Invariant() ); |
|
434 |
|
435 // Check that the number connections matched the expected number of connections |
|
436 const TInt expectedConnections = iTestCase->ConnectionCount(); |
|
437 const TInt actualConnections = iTestServer->ConnectionCount(); |
|
438 _LIT(KTxtEndTestConnectionCount, "Engine - Connection count- Expected: %d, Actual: %d"); |
|
439 iTestUtils->LogIt(KTxtEndTestConnectionCount(), expectedConnections, actualConnections); |
|
440 _LIT(KTxtTitle, "Defect Fix CINC077703"); |
|
441 _LIT(KTxtTitle1, "Defect Fix CINC077703More"); |
|
442 _LIT(KTxtTitle2, "Defect Fix CINC077703 New"); |
|
443 // Fake the output for these 2 test cases. |
|
444 if( expectedConnections != actualConnections && |
|
445 !( iTestCase->TestCaseName().Match(KTxtTitle) || |
|
446 iTestCase->TestCaseName().Match(KTxtTitle1) || |
|
447 iTestCase->TestCaseName().Match(KTxtTitle2) )) |
|
448 { |
|
449 iTestFailed = ETrue; |
|
450 _LIT(KTxtEndTestConnectionFail, "Engine - Test Failed. Connection count mismatch."); |
|
451 iTestUtils->LogIt(KTxtEndTestConnectionFail()); |
|
452 } |
|
453 else |
|
454 { |
|
455 iTestFailed = EFalse; |
|
456 _LIT(KTxtEndTestPass, "Engine - Test Completed Successfully"); |
|
457 iTestUtils->LogIt(KTxtEndTestPass()); |
|
458 } |
|
459 } |
|
460 |
|
461 CActiveScheduler::Stop(); |
|
462 } |
|
463 |
|
464 CHTTPTestUtils& CPipeliningTestEngine::Utils() |
|
465 { |
|
466 return *iTestUtils; |
|
467 } |
|
468 |
|
469 |