|
1 // Copyright (c) 2004-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 "get14.h" |
|
17 #include <http.h> |
|
18 #include "csrvaddrval.h" |
|
19 |
|
20 _LIT8(KWapTestUrl, "http://WapTestIP"); |
|
21 |
|
22 CHttpTestCaseGet14::CHttpTestCaseGet14(CScriptFile* aIniSettingsFile) |
|
23 : CHttpAcceptTestBase(), |
|
24 iIniSettingsFile(aIniSettingsFile) |
|
25 { |
|
26 } |
|
27 |
|
28 const TDesC& CHttpTestCaseGet14::TestName() |
|
29 { |
|
30 _LIT(KHeaderTestName,"Iteration 2 Get Test 14 "); |
|
31 return KHeaderTestName; |
|
32 } |
|
33 |
|
34 void CHttpTestCaseGet14::OpenTestTrans1L() |
|
35 { |
|
36 // Literals used in the function |
|
37 _LIT8(KUrlPath, "/http_tests/rc/401/private/index.html"); |
|
38 |
|
39 // Replace the host name in the URL |
|
40 HBufC8* newUrl8 = TSrvAddrVal::ReplaceHostNameL(KWapTestUrl(), iIniSettingsFile); |
|
41 CleanupStack::PushL(newUrl8); |
|
42 TPtr8 newUrlPtr8 = newUrl8->Des(); |
|
43 newUrlPtr8.Append(KUrlPath()); |
|
44 |
|
45 TUriParser8 testURI; |
|
46 testURI.Parse(newUrlPtr8); |
|
47 |
|
48 iTransaction1 = iSession.OpenTransactionL(testURI, *this, iMyStrP.StringF(HTTP::EGET,RHTTPSession::GetTable())); |
|
49 iOpenTransactionCount++; |
|
50 iEngine->Utils().LogIt(_L("Transaction Created in Session")); |
|
51 |
|
52 TSrvAddrVal::LogUsing8BitDesL(iEngine, newUrlPtr8); |
|
53 iEngine->Utils().LogIt(_L("Method:GET")); |
|
54 CleanupStack::PopAndDestroy(newUrl8); |
|
55 } |
|
56 |
|
57 void CHttpTestCaseGet14::OpenTestTrans2L() |
|
58 { |
|
59 // Literals used in the function |
|
60 _LIT8(KUrlPath, "/http_tests/rc/401/private/index2.html"); |
|
61 |
|
62 // Replace the host name in the URL |
|
63 HBufC8* newUrl8 = TSrvAddrVal::ReplaceHostNameL(KWapTestUrl(), iIniSettingsFile); |
|
64 CleanupStack::PushL(newUrl8); |
|
65 TPtr8 newUrlPtr8 = newUrl8->Des(); |
|
66 newUrlPtr8.Append(KUrlPath()); |
|
67 |
|
68 TUriParser8 testURI; |
|
69 testURI.Parse(newUrlPtr8); |
|
70 |
|
71 iTransaction2 = iSession.OpenTransactionL(testURI, *this, iMyStrP.StringF(HTTP::EGET,RHTTPSession::GetTable())); |
|
72 iOpenTransactionCount++; |
|
73 iEngine->Utils().LogIt(_L("Transaction Created in Session")); |
|
74 |
|
75 TSrvAddrVal::LogUsing8BitDesL(iEngine, newUrlPtr8); |
|
76 iEngine->Utils().LogIt(_L("Method:GET")); |
|
77 CleanupStack::PopAndDestroy(newUrl8); |
|
78 } |
|
79 |
|
80 void CHttpTestCaseGet14::CloseTestSession() |
|
81 { |
|
82 iTransaction1.Close(); |
|
83 iEngine->Utils().LogIt(_L("Transaction1 terminated\n")); |
|
84 iTransaction2.Close(); |
|
85 iEngine->Utils().LogIt(_L("Transaction2 terminated\n")); |
|
86 iSession.Close(); |
|
87 iEngine->Utils().LogIt(_L("Session terminated")); |
|
88 } |
|
89 |
|
90 |
|
91 TBool CHttpTestCaseGet14::GetCredentialsL(const TUriC8& aURI, RString aRealm, RStringF aAuthenticationType, RString& aUsername, RString& aPassword) |
|
92 { |
|
93 if(iCallsNum++) |
|
94 { |
|
95 iTestFail=1; |
|
96 iEngine->Utils().LogIt(_L("The test will fail: the credential haven't been kept(the GetCredential function has been called again)")); |
|
97 return EFalse; |
|
98 } |
|
99 iEngine->Utils().LogIt(_L("Supplying credentials")); |
|
100 iEngine->Utils().DumpData(aURI.UriDes()); |
|
101 iEngine->Utils().DumpData(aRealm.DesC()); |
|
102 iEngine->Utils().DumpData(aAuthenticationType.DesC()); |
|
103 _LIT8(KScooby, "scooby"); |
|
104 _LIT8(KDoo, "doo"); |
|
105 RStringPool p = aRealm.Pool(); |
|
106 aUsername = p.OpenStringL(KScooby); |
|
107 aPassword = p.OpenStringL(KDoo); |
|
108 return ETrue; |
|
109 } |
|
110 |
|
111 void CHttpTestCaseGet14::DoRunL() |
|
112 { |
|
113 OpenTestSessionL(); |
|
114 |
|
115 //Trans1 |
|
116 OpenTestTrans1L(); |
|
117 iTransaction1.SubmitL(); |
|
118 CActiveScheduler::Start(); |
|
119 |
|
120 //Trans2 |
|
121 OpenTestTrans2L(); |
|
122 iTransaction2.SubmitL(); |
|
123 CActiveScheduler::Start(); |
|
124 |
|
125 iTransaction1.Close(); |
|
126 iTransaction2.Close(); |
|
127 |
|
128 CloseTestSession(); |
|
129 if (iTestFail==1) |
|
130 { |
|
131 User::Leave(-1); |
|
132 } |
|
133 } |
|
134 |
|
135 void CHttpTestCaseGet14::OpenTestSessionL() |
|
136 { |
|
137 //open a default Session |
|
138 iSession.OpenL(); |
|
139 |
|
140 //Logs |
|
141 iEngine->Utils().LogIt(_L("Session Created(Iteration 2 Get Test 14)")); |
|
142 iEngine->Utils().LogIt(_L("Session parameters: Default")); |
|
143 |
|
144 InstallAuthenticationL(iSession); |
|
145 |
|
146 //Get the iSession'string pool handle; |
|
147 iMyStrP = iSession.StringPool(); |
|
148 } |