|
1 // Copyright (c) 2007-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 // Contains implementation of CTestHttpBaseStep class |
|
15 // @internalAll |
|
16 // |
|
17 // |
|
18 |
|
19 // System Include |
|
20 // for StartC32() |
|
21 #include <c32comm.h> |
|
22 #include <e32base.h> |
|
23 #include <http.h> |
|
24 // User Include |
|
25 #include "testhttpbasestep.h" |
|
26 |
|
27 |
|
28 // PDD names for the physical device drivers that are loaded in wins or arm |
|
29 #if defined (__WINS__) |
|
30 #define PDD_NAME _L("ECDRV") |
|
31 #else |
|
32 #define PDD_NAME _L("EUART1") |
|
33 #define PDD2_NAME _L("EUART2") |
|
34 #define PDD3_NAME _L("EUART3") |
|
35 #define PDD4_NAME _L("EUART4") |
|
36 #endif |
|
37 |
|
38 #define LDD_NAME _L("ECOMM") |
|
39 |
|
40 |
|
41 // Loads the physical device drivers |
|
42 void CTestHttpBaseStep::InitCommsL() |
|
43 { |
|
44 TInt ret = User::LoadPhysicalDevice(PDD_NAME); |
|
45 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
46 |
|
47 #ifndef __WINS__ |
|
48 ret = User::LoadPhysicalDevice(PDD2_NAME); |
|
49 ret = User::LoadPhysicalDevice(PDD3_NAME); |
|
50 ret = User::LoadPhysicalDevice(PDD4_NAME); |
|
51 #endif |
|
52 |
|
53 ret = User::LoadLogicalDevice(LDD_NAME); |
|
54 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
55 ret = StartC32(); |
|
56 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
57 } |
|
58 |
|
59 |
|
60 /** |
|
61 Constructor: Sets the test step name. |
|
62 @internalTechnology |
|
63 @test |
|
64 */ |
|
65 CTestHttpBaseStep::CTestHttpBaseStep() |
|
66 { |
|
67 //Call base class method to set human readable name for test step |
|
68 SetTestStepName(KTestHttpBaseStep); |
|
69 } |
|
70 |
|
71 |
|
72 /** |
|
73 Destructor: Closes the iFileServ. |
|
74 @internalTechnology |
|
75 @test |
|
76 */ |
|
77 CTestHttpBaseStep::~CTestHttpBaseStep() |
|
78 { |
|
79 iFileServ.Close(); |
|
80 delete iSched; |
|
81 //CleanupStack::PopAndDestroy(); // iSched |
|
82 iSched = NULL; |
|
83 } |
|
84 |
|
85 |
|
86 /** |
|
87 Base class virtual doTestStepPreambleL(): |
|
88 Create and install the active scheduler and connect to iFileServ (RFs). |
|
89 @internalTechnology |
|
90 @test |
|
91 @param None |
|
92 @return EPass or EFail. |
|
93 */ |
|
94 TVerdict CTestHttpBaseStep::doTestStepPreambleL() |
|
95 { |
|
96 iSched = new(ELeave) CActiveScheduler; |
|
97 CActiveScheduler::Install(iSched); |
|
98 User::LeaveIfError(iFileServ.Connect()); |
|
99 return TestStepResult(); |
|
100 } // doTestPreambleL |
|
101 |
|
102 |
|
103 /** |
|
104 Base class pure virtual doTestStepL(): |
|
105 Tests the ebo support in http. |
|
106 @internalTechnology |
|
107 @test |
|
108 @param None |
|
109 @return EPass or EFail indicating the result of the test step. |
|
110 */ |
|
111 TVerdict CTestHttpBaseStep::doTestStepL() |
|
112 { |
|
113 __UHEAP_MARK; |
|
114 INFO_PRINTF1(_L("\n")); |
|
115 // Start C32 and initalize some device drivers. This is necessary when running a test console as these won't |
|
116 // have been started |
|
117 TRAPD(err,InitCommsL()); |
|
118 if (err != KErrNone) |
|
119 { |
|
120 ERR_PRINTF2(_L("Teststep Failed: Leave occured in CTestHttpBaseStep::InitCommsL: %D\n" |
|
121 ),err |
|
122 ); |
|
123 SetTestStepResult(EFail); |
|
124 } |
|
125 else |
|
126 { |
|
127 // Opening session |
|
128 iSess.OpenL(); |
|
129 // start the client |
|
130 TRAP(err,StartClientL()); |
|
131 if (err != KErrNone) |
|
132 { |
|
133 ERR_PRINTF2(_L("Teststep Failed: Leave occured in CTestHttpBaseStep::StartClientL: %D\n" |
|
134 ),err |
|
135 ); |
|
136 SetTestStepResult(EFail); |
|
137 } |
|
138 // Closing session |
|
139 iSess.Close(); |
|
140 } |
|
141 __UHEAP_MARKEND; |
|
142 |
|
143 INFO_PRINTF1(_L("\n")); |
|
144 return TestStepResult(); |
|
145 } // doTestStepL |
|
146 |
|
147 |
|
148 /** |
|
149 Sets the headers. |
|
150 @internalTechnology |
|
151 @test |
|
152 @param aHeaders Headers collection |
|
153 @param aHdrField Header field to be added |
|
154 @return aHdrValue Header value to be added |
|
155 */ |
|
156 void CTestHttpBaseStep::SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue) |
|
157 { |
|
158 RStringF valStr = iSess.StringPool().OpenFStringL(aHdrValue); |
|
159 THTTPHdrVal val(valStr); |
|
160 aHeaders.SetFieldL(iSess.StringPool().StringF(aHdrField,RHTTPSession::GetTable()), val); |
|
161 valStr.Close(); |
|
162 } |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |