|
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 "ctestcaselocalandremotehost.h" |
|
17 #include "httptestutils.h" |
|
18 |
|
19 const TInt KInternalTransCount = 3; |
|
20 CTestCaseLocalAndRemoteHost* CTestCaseLocalAndRemoteHost::NewL(CHTTPTestUtils& aTestUtils, MPipeliningTestObserver& aObserver) |
|
21 { |
|
22 CTestCaseLocalAndRemoteHost* self = new (ELeave) CTestCaseLocalAndRemoteHost(aTestUtils, aObserver); |
|
23 CleanupStack::PushL(self); |
|
24 self->ConstructL(); |
|
25 CleanupStack::Pop(); // self |
|
26 return self; |
|
27 } |
|
28 |
|
29 CTestCaseLocalAndRemoteHost::~CTestCaseLocalAndRemoteHost() |
|
30 { |
|
31 } |
|
32 |
|
33 |
|
34 void CTestCaseLocalAndRemoteHost::ConstructL() |
|
35 { |
|
36 CPipeliningTestClient::ConstructL(); |
|
37 } |
|
38 |
|
39 CTestCaseLocalAndRemoteHost::CTestCaseLocalAndRemoteHost(CHTTPTestUtils& aTestUtils, MPipeliningTestObserver& aObserver) |
|
40 : CPipeliningTestClient(aTestUtils, aObserver) |
|
41 { |
|
42 |
|
43 } |
|
44 |
|
45 RHTTPTransaction CTestCaseLocalAndRemoteHost::GetLocalTransactionL() |
|
46 { |
|
47 _LIT8(KTxtUri, "http://127.0.0.1"); |
|
48 TUriParser8 uri; |
|
49 uri.Parse(KTxtUri()); |
|
50 return iSession.OpenTransactionL(uri, *this); |
|
51 } |
|
52 |
|
53 RHTTPTransaction CTestCaseLocalAndRemoteHost::GetRemoteTransactionL() |
|
54 { |
|
55 _LIT8(KRemoteUri, "http://10.29.23.12/"); |
|
56 TUriParser8 uri; |
|
57 uri.Parse(KRemoteUri()); |
|
58 return iSession.OpenTransactionL(uri, *this); |
|
59 } |
|
60 |
|
61 void CTestCaseLocalAndRemoteHost::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent) |
|
62 { |
|
63 |
|
64 switch (aEvent.iStatus) |
|
65 { |
|
66 case THTTPEvent::EGotResponseHeaders: |
|
67 { |
|
68 _LIT(KTxtSuccessful, "EGotResponse headers: %d."); |
|
69 iTestUtils.LogIt(KTxtSuccessful, aTransaction.Id()); |
|
70 |
|
71 } break; |
|
72 case THTTPEvent::EGotResponseBodyData: |
|
73 { |
|
74 // Done with that bit of body data |
|
75 aTransaction.Response().Body()->ReleaseData(); |
|
76 } break; |
|
77 case THTTPEvent::EResponseComplete: |
|
78 { |
|
79 } break; |
|
80 case THTTPEvent::ESucceeded: |
|
81 { |
|
82 ++iCurrentTrans; |
|
83 TInt transId = aTransaction.Id(); |
|
84 aTransaction.Close(); |
|
85 _LIT(KTxtSuccessful, "Client - Transaction %d, completed successfully."); |
|
86 iTestUtils.LogIt(KTxtSuccessful, transId); |
|
87 |
|
88 if(KInternalTransCount == iCurrentTrans) |
|
89 { |
|
90 EndTestL(KErrNone); |
|
91 break; |
|
92 } |
|
93 if(iSentRemoteHostTrans == EFalse) |
|
94 { |
|
95 StartAndSetNetworkToHttp(); |
|
96 // Create and submit the transaction to remote host |
|
97 GetRemoteTransactionL().SubmitL(); |
|
98 iSentRemoteHostTrans = ETrue; |
|
99 } |
|
100 else |
|
101 { |
|
102 // Create and submit the transaction to local host |
|
103 GetLocalTransactionL().SubmitL(); |
|
104 } |
|
105 } break; |
|
106 case THTTPEvent::EFailed: |
|
107 { |
|
108 aTransaction.Close(); |
|
109 EndTestL(KErrNotFound); // We must not fail. If we fail we fail the test case as well. |
|
110 } break; |
|
111 default: |
|
112 { |
|
113 CPipeliningTestClient::MHFRunL(aTransaction, aEvent); |
|
114 } break; |
|
115 } |
|
116 } |
|
117 |
|
118 |