|
1 // Copyright (c) 2005-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 "Te_SimPacketPenultimateContextTest.h" |
|
17 |
|
18 CSimPacketPenultimateContextTest::CSimPacketPenultimateContextTest() |
|
19 { |
|
20 SetTestStepName(_L("PenultimateContextTest")); |
|
21 } |
|
22 |
|
23 TVerdict CSimPacketPenultimateContextTest::doTestStepL() |
|
24 { |
|
25 INFO_PRINTF1(_L("BeginPacketPenultimateContextTest")); |
|
26 |
|
27 CreateConfigFileL(_L("c:\\config3.txt")); |
|
28 SetTestNumberL(6); |
|
29 |
|
30 TInt x=0; |
|
31 TInt ret = iPhone.Open(iTelServer,KPhoneName); |
|
32 INFO_PRINTF2(_L("Result: %d"),ret); |
|
33 TESTL(ret == KErrNone); |
|
34 INFO_PRINTF1(_L("Opened phone object")); |
|
35 TESTL(iPacketService.Open(iPhone)==KErrNone); |
|
36 INFO_PRINTF1(_L("Opened Packet object")); |
|
37 |
|
38 // test RPacketContext::OpenNewContext |
|
39 TName contextName; |
|
40 TName contextNameCompare; |
|
41 TESTL(iFirstPrimaryPacketContext.OpenNewContext(iPacketService, contextName)==KErrNone); |
|
42 contextNameCompare.Append(KSimPrimaryPacketContextName); |
|
43 contextNameCompare.AppendNum(1); |
|
44 TESTL(contextName.Compare(contextNameCompare)==KErrNone); |
|
45 INFO_PRINTF1(_L("Opened Context object")); |
|
46 |
|
47 TName anotherContextName; |
|
48 TName anotherContextNameCompare; |
|
49 TESTL(iSecondPrimaryPacketContext.OpenNewContext(iPacketService, anotherContextName)==KErrNone); |
|
50 anotherContextNameCompare.Append(KSimPrimaryPacketContextName); |
|
51 anotherContextNameCompare.AppendNum(2); |
|
52 TESTL(anotherContextName.Compare(anotherContextNameCompare)==KErrNone); |
|
53 INFO_PRINTF1(_L("Opened another Primary Context object")); |
|
54 |
|
55 // test RPacketContext::Activate - before calling InitialiseContext |
|
56 TRequestStatus reqStatus; |
|
57 StartNTRasSimulation(); |
|
58 iFirstPrimaryPacketContext.Activate(reqStatus); |
|
59 User::WaitForRequest(reqStatus); |
|
60 TESTL(reqStatus.Int()==KErrNone); |
|
61 INFO_PRINTF1(_L("Activate test passed")); |
|
62 |
|
63 // test RPacketContext::InitialiseContext |
|
64 RPacketContext::TDataChannelV2 channelV2; |
|
65 RPacketContext::TDataChannelV2Pckg channelV2pckg(channelV2); |
|
66 iFirstPrimaryPacketContext.InitialiseContext(reqStatus, channelV2pckg); |
|
67 User::WaitForRequest(reqStatus); |
|
68 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.41")); |
|
69 |
|
70 // test RPacketContext::OpenNewSecondaryContext |
|
71 TName aNewContextName; |
|
72 |
|
73 iPacketContext.OpenNewSecondaryContext(iPacketService, |
|
74 contextName, |
|
75 aNewContextName); |
|
76 |
|
77 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.29")); |
|
78 INFO_PRINTF1(_L("OpenNewSeondaryContext called successfully")); |
|
79 |
|
80 // test RPacketService::EnumerateNifs |
|
81 TInt count; |
|
82 iPacketService.EnumerateNifs(reqStatus, count); |
|
83 iPacketService.CancelAsyncRequest(EPacketEnumerateNifs); |
|
84 User::WaitForRequest(reqStatus); |
|
85 TESTL(count == 2); |
|
86 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.30")); |
|
87 INFO_PRINTF1(_L("EnumerateNifs tested successfully")); |
|
88 |
|
89 // test RPacketService::GetNifInfo |
|
90 TInt index = count-1; |
|
91 RPacketService::TNifInfoV2 nifInfoV2; |
|
92 RPacketService::TNifInfoV2Pckg nifInfoV2Pckg(nifInfoV2); |
|
93 |
|
94 iPacketService.GetNifInfo(reqStatus, index, nifInfoV2Pckg); |
|
95 iPacketService.CancelAsyncRequest(EPacketGetNifInfo); |
|
96 User::WaitForRequest(reqStatus); |
|
97 TESTL(nifInfoV2.iContextName.Compare(anotherContextName)==0); |
|
98 TESTL(nifInfoV2.iContextType == RPacketService::EUnspecified); |
|
99 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.31")); |
|
100 INFO_PRINTF1(_L("GetNifInfo Test Passed")); |
|
101 |
|
102 // test RPacketService::EnumerateContextsInNif |
|
103 iPacketService.EnumerateContextsInNif(reqStatus, nifInfoV2.iContextName, count); |
|
104 iPacketService.CancelAsyncRequest(EPacketEnumerateContextsInNif); |
|
105 User::WaitForRequest(reqStatus); |
|
106 TESTL(count == 1); |
|
107 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.32")); |
|
108 INFO_PRINTF1(_L("EnumerateContextsInNif Test Passed")); |
|
109 |
|
110 // test RPacketService::GetContextNameInNif |
|
111 index = count-1; |
|
112 iPacketService.GetContextNameInNif(reqStatus, nifInfoV2.iContextName, index, anotherContextNameCompare); |
|
113 iPacketService.CancelAsyncRequest(EPacketGetContextNameInNif); |
|
114 User::WaitForRequest(reqStatus); |
|
115 TESTL(anotherContextNameCompare.Compare(anotherContextName)==0); |
|
116 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.33")); |
|
117 |
|
118 INFO_PRINTF1(_L("GetContextNameInNif Test Passed")); |
|
119 |
|
120 // test RPacketService::GetCurrentReleaseMode |
|
121 RPacketService::TPacketReleaseMode releaseMode; |
|
122 iPacketService.GetCurrentReleaseMode(reqStatus, releaseMode); |
|
123 iPacketService.CancelAsyncRequest(EPacketGetCurrentReleaseMode); |
|
124 User::WaitForRequest(reqStatus); |
|
125 TESTL(releaseMode==5); |
|
126 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.34")); |
|
127 INFO_PRINTF1(_L("GetCurrentReleaseMode Test Passed")); |
|
128 |
|
129 // test RPacketService::NotifyReleaseModeChange |
|
130 iPacketService.NotifyReleaseModeChange(reqStatus, releaseMode); |
|
131 User::WaitForRequest(reqStatus); |
|
132 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.35")); |
|
133 INFO_PRINTF1(_L("NotifyReleaseModeChange Test Passed")); |
|
134 |
|
135 TUint8 addrArray[RPacketContext::KIPAddressSize] = {0,0,0,0, |
|
136 0,0,0,0, |
|
137 0,0,255,255, |
|
138 102,23,224,132}; |
|
139 TUint8 subArray[RPacketContext::KIPAddressSize] = {0,0,0,0, |
|
140 0,0,0,0, |
|
141 0,0,255,255, |
|
142 255,255,255,255}; |
|
143 RPacketContext::TPacketFilterV2 packetFilterV2; |
|
144 packetFilterV2.iId = 0; |
|
145 packetFilterV2.iEvaluationPrecedenceIndex = 1; |
|
146 |
|
147 for(x = 0; x<RPacketContext::KIPAddressSize; x++) |
|
148 { |
|
149 packetFilterV2.iSrcAddr[x] = addrArray[x]; |
|
150 packetFilterV2.iSrcAddrSubnetMask[x] = subArray[x]; |
|
151 } |
|
152 packetFilterV2.iProtocolNumberOrNextHeader = 1; |
|
153 packetFilterV2.iSrcPortMin = 0; |
|
154 packetFilterV2.iSrcPortMax = 1; |
|
155 packetFilterV2.iDestPortMin = 2; |
|
156 packetFilterV2.iDestPortMax = 0; |
|
157 packetFilterV2.iIPSecSPI = 0; |
|
158 packetFilterV2.iTOSorTrafficClass = 1; |
|
159 packetFilterV2.iFlowLabel = 2; |
|
160 //TFTfilter = 0, 1, 10.32.2.1, 10.32.5.5, 1, 0, 1, 2, 0, 0, 1, 2 - as in configuration file |
|
161 RPacketContext::TPacketFilterV2Pckg packetFilterV2pckg(packetFilterV2); |
|
162 |
|
163 // test RPacketContext::AddPacketFilter (V2) |
|
164 iFirstPrimaryPacketContext.AddPacketFilter(reqStatus, packetFilterV2pckg); |
|
165 User::WaitForRequest(reqStatus); |
|
166 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.38")); |
|
167 INFO_PRINTF1(_L("AddPacketFilter V2 Test Passed")); |
|
168 INFO_PRINTF1(_L("AddPacketFilter V2 Test Passed")); |
|
169 |
|
170 |
|
171 //Set up Source adress and Source address subnet Mask for V3 Packet Filter test |
|
172 RPacketContext::TPacketFilterV3 packetFilterV3(RPacketContext::EPacketFilterTypeOne); |
|
173 |
|
174 RPacketContext::TIPAddress srcAddr = {0,0,0,0, |
|
175 0,0,0,0, |
|
176 0,0,255,255, |
|
177 102,23,224,132}; |
|
178 |
|
179 RPacketContext::TIPAddress srcAddrSubnetMask = {0,0,0,0, |
|
180 0,0,0,0, |
|
181 0,0,255,255, |
|
182 255,255,255,255}; |
|
183 |
|
184 |
|
185 packetFilterV3.iId=V3_PCKT_FILTER_ID; |
|
186 packetFilterV3.iEvaluationPrecedenceIndex=V3_PCKT_FILTER_EVALUATION_PRECEDENCE_INDEX; |
|
187 packetFilterV3.SetSrcAddr(srcAddr); |
|
188 packetFilterV3.SetSrcAddrSubnetMask(srcAddrSubnetMask); |
|
189 packetFilterV3.SetProtocolNumberOrNextHeader(V3_PCKT_FILTER_PROTOCOLNUMBER_OR_NEXTHEADER); |
|
190 packetFilterV3.SetSrcPortMin(V3_PCKT_FILTER_MINIMUM_SOURCE_PORT_NUMBER); |
|
191 packetFilterV3.SetSrcPortMax(V3_PCKT_FILTER_MAXIMUM_SOURCE_PORT_NUMBER); |
|
192 packetFilterV3.SetDestPortMin(V3_PCKT_FILTER_MINIMUM_DESTINATION_PORT_NUMBER); |
|
193 packetFilterV3.SetDestPortMax(V3_PCKT_FILTER_MAXIMUM_DESTINATION_PORT_NUMBER); |
|
194 packetFilterV3.SetTOSorTrafficClass(V3_PCKT_FILTER_TYPE_OF_SERVICE_OR_TRAFFIC_CLASS); |
|
195 |
|
196 RPacketContext::TPacketFilterV3Pckg packetFilterV3pckg(packetFilterV3); |
|
197 |
|
198 // test RPacketContext::AddPacketFilter (V3) |
|
199 iFirstPrimaryPacketContext.AddPacketFilter(reqStatus, packetFilterV3pckg); |
|
200 User::WaitForRequest(reqStatus); |
|
201 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_IMS_CASE("P.12")); |
|
202 INFO_PRINTF1(_L("AddPacketFilter V3 Test Passed")); |
|
203 |
|
204 // test RPacketContext::EnumeratePacketFilters |
|
205 iFirstPrimaryPacketContext.EnumeratePacketFilters(reqStatus, count); |
|
206 User::WaitForRequest(reqStatus); |
|
207 TESTL(count == 2); |
|
208 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_IMS_CASE("P.13")); |
|
209 INFO_PRINTF1(_L("EnumeratePacketFilters Test Passed")); |
|
210 |
|
211 |
|
212 // test RPacketContext::GetPacketFilterInfo (V2) |
|
213 index = 0; |
|
214 iFirstPrimaryPacketContext.GetPacketFilterInfo(reqStatus, index, packetFilterV2pckg); |
|
215 User::WaitForRequest(reqStatus); |
|
216 TESTL(packetFilterV2.iId == 0); |
|
217 TESTL(packetFilterV2.iEvaluationPrecedenceIndex == 1); |
|
218 for(x = 0; x<RPacketContext::KIPAddressSize; x++) |
|
219 { |
|
220 TESTL(packetFilterV2.iSrcAddr[x] == addrArray[x]); |
|
221 TESTL(packetFilterV2.iSrcAddrSubnetMask[x] == subArray[x]); |
|
222 } |
|
223 TESTL(packetFilterV2.iProtocolNumberOrNextHeader == 1); |
|
224 TESTL(packetFilterV2.iSrcPortMin == 0); |
|
225 TESTL(packetFilterV2.iSrcPortMax == 1); |
|
226 TESTL(packetFilterV2.iDestPortMin == 2); |
|
227 TESTL(packetFilterV2.iDestPortMax == 0); |
|
228 TESTL(packetFilterV2.iIPSecSPI == 0); |
|
229 TESTL(packetFilterV2.iTOSorTrafficClass == 1); |
|
230 TESTL(packetFilterV2.iFlowLabel == 2); |
|
231 |
|
232 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.37")); |
|
233 |
|
234 //test RPacketContext::GetPacketFilterInfo (V3) |
|
235 index = 1; |
|
236 RPacketContext::TPacketFilterV3 packetFilterV3_2(RPacketContext::EPacketFilterTypeOne); |
|
237 RPacketContext::TPacketFilterV3Pckg packetFilterV3_2pckg(packetFilterV3_2); |
|
238 |
|
239 iFirstPrimaryPacketContext.GetPacketFilterInfo(reqStatus, index, packetFilterV3_2pckg); |
|
240 User::WaitForRequest(reqStatus); |
|
241 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_IMS_CASE("P.14")); |
|
242 |
|
243 TESTL(packetFilterV3_2.iId == V3_PCKT_FILTER_ID); |
|
244 TESTL(packetFilterV3_2.iEvaluationPrecedenceIndex == V3_PCKT_FILTER_EVALUATION_PRECEDENCE_INDEX); |
|
245 for(x = 0; x<RPacketContext::KIPAddressSize; x++) |
|
246 { |
|
247 TESTL(packetFilterV3_2.SrcAddr()[x] == srcAddr[x]); |
|
248 TESTL(packetFilterV3_2.SrcAddrSubnetMask()[x] == srcAddrSubnetMask[x]); |
|
249 } |
|
250 |
|
251 TESTL(packetFilterV3_2.IsPresent(RPacketContext::TPacketFilterV3::EPacketFilterDestPortMin)); |
|
252 TESTL((packetFilterV3_2.DestPortMin() == V3_PCKT_FILTER_MINIMUM_DESTINATION_PORT_NUMBER)); |
|
253 |
|
254 TESTL(packetFilterV3_2.IsPresent(RPacketContext::TPacketFilterV3::EPacketFilterDestPortMax)); |
|
255 TESTL((packetFilterV3_2.DestPortMax() == V3_PCKT_FILTER_MAXIMUM_DESTINATION_PORT_NUMBER)); |
|
256 |
|
257 TESTL(packetFilterV3_2.IsPresent(RPacketContext::TPacketFilterV3::EPacketFilterProtocolNumberOrNextHeader)); |
|
258 TESTL((packetFilterV3_2.ProtocolNumberOrNextHeader() == V3_PCKT_FILTER_PROTOCOLNUMBER_OR_NEXTHEADER)); |
|
259 |
|
260 TESTL(packetFilterV3_2.IsPresent(RPacketContext::TPacketFilterV3::EPacketFilterSrcPortMin)); |
|
261 TESTL((packetFilterV3_2.SrcPortMin() == V3_PCKT_FILTER_MINIMUM_SOURCE_PORT_NUMBER)); |
|
262 |
|
263 TESTL(packetFilterV3_2.IsPresent(RPacketContext::TPacketFilterV3::EPacketFilterSrcPortMax)); |
|
264 TESTL((packetFilterV3_2.SrcPortMax() == V3_PCKT_FILTER_MAXIMUM_SOURCE_PORT_NUMBER)); |
|
265 |
|
266 TESTL(packetFilterV3_2.IsPresent(RPacketContext::TPacketFilterV3::EPacketFilterTOSorTrafficClass)); |
|
267 TESTL((packetFilterV3_2.TOSorTrafficClass() == V3_PCKT_FILTER_TYPE_OF_SERVICE_OR_TRAFFIC_CLASS)); |
|
268 |
|
269 /* Because the Filter Type was One SPI will not be set and should be 0 */ |
|
270 TESTL(packetFilterV3_2.IsPresent(RPacketContext::TPacketFilterV3::EPacketFilterIPSecSPI) == EFalse); |
|
271 TESTL(packetFilterV3_2.IsPresent(RPacketContext::TPacketFilterV3::EPacketFilterFlowLabel) == EFalse); |
|
272 |
|
273 INFO_PRINTF1(_L("GetPacketFilterInfo Test Passed")); |
|
274 |
|
275 // test RPacketContext::ModifyActiveContext |
|
276 iFirstPrimaryPacketContext.ModifyActiveContext(reqStatus); |
|
277 User::WaitForRequest(reqStatus); |
|
278 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.40")); |
|
279 INFO_PRINTF1(_L("ModifyActiveContext Test Passed")); |
|
280 |
|
281 index = 0; |
|
282 RPacketService::TContextInfo contextInfo; |
|
283 iPacketService.GetContextInfo(reqStatus, index, contextInfo); |
|
284 iPacketService.CancelAsyncRequest(EPacketGetContextInfo); |
|
285 User::WaitForRequest(reqStatus); |
|
286 TESTL(reqStatus.Int()==KErrNone); |
|
287 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.6")); |
|
288 INFO_PRINTF1(_L("Get Info Test Passed")); |
|
289 |
|
290 // test RPacketContext::RemovePacketFilter |
|
291 iFirstPrimaryPacketContext.RemovePacketFilter(reqStatus, index); |
|
292 User::WaitForRequest(reqStatus); |
|
293 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.39")); |
|
294 INFO_PRINTF1(_L("RemovePacketFilter Test Passed")); |
|
295 |
|
296 // End of RPacketContext and RPacketService tests |
|
297 iPacketContext.Close(); |
|
298 iFirstPrimaryPacketContext.Close(); |
|
299 iSecondPrimaryPacketContext.Close(); |
|
300 iPacketService.Close(); |
|
301 iPhone.Close(); |
|
302 ASSERT(RThread().RequestCount()==0); |
|
303 |
|
304 return TestStepResult(); |
|
305 } |
|
306 |