|
1 // Copyright (c) 2002-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 // EtelPacketTest1_2.cpp |
|
15 // This contains EtelPacket TestCase Test 1.2 (RPacketContext functionality) |
|
16 // |
|
17 // |
|
18 |
|
19 // Symbian OS includes |
|
20 #include <e32base.h> |
|
21 |
|
22 #include <etelpckt.h> |
|
23 #include <pcktcs.h> |
|
24 |
|
25 #include "Te_EtelPacketTestStepBase.h" |
|
26 |
|
27 #include "testdef.h" |
|
28 |
|
29 #include "Te_EtelPacketTest1_2.h" |
|
30 #include "Te_etelpckt_defs.h" |
|
31 |
|
32 // constructor |
|
33 CEtelPacketTest1_2::CEtelPacketTest1_2() |
|
34 { |
|
35 // store the name of this test case |
|
36 SetTestStepName(_L("Context")); |
|
37 } |
|
38 |
|
39 // destructor |
|
40 CEtelPacketTest1_2::~CEtelPacketTest1_2() |
|
41 { |
|
42 } |
|
43 |
|
44 // do Test step 1.1 |
|
45 enum TVerdict CEtelPacketTest1_2::doTestStepL( void ) |
|
46 { |
|
47 RPhone phone; |
|
48 TInt ret=phone.Open(iTelServer,DPCKTTSY_PHONE_NAME); |
|
49 CHECKPOINT(ret,KErrNone,CHP_OPEN_PHONE); |
|
50 |
|
51 RPacketService gprs; |
|
52 ret=gprs.Open(phone); |
|
53 CHECKPOINT(ret,KErrNone,CHP_SRVS_CASE("A.1")); |
|
54 |
|
55 RPacketContext gprsContext; |
|
56 TName contextName; |
|
57 ret=gprsContext.OpenNewContext(gprs, contextName); |
|
58 CHECKPOINT(ret,KErrNone,CHP_CNTXT_CASE("B.1")); |
|
59 |
|
60 User::After(100000L); |
|
61 |
|
62 RPacketContext aContext; |
|
63 aContext.OpenExistingContext(gprs, contextName); |
|
64 CHECKPOINT(contextName, DPCKTTSY_CONTEXT_NAME, CHP_CNTXT_CASE("B.2")); |
|
65 |
|
66 aContext.Close(); |
|
67 TRequestStatus reqStatus; |
|
68 //Set configuration |
|
69 RPacketContext::TContextConfigGPRS contextConfig; |
|
70 CHECKPOINT(contextConfig.ExtensionId(),TPacketDataConfigBase::KConfigGPRS,CHP_CNTXT_CASE("B.4")); |
|
71 TPckg<RPacketContext::TContextConfigGPRS> contextConfigPckg(contextConfig); |
|
72 |
|
73 contextConfig.iAccessPointName = DPCKTTSY_ACCESS_POINT1; |
|
74 contextConfig.iAnonymousAccessReqd = DPCKTTSY_ANONYMOUS_ACCESS1; |
|
75 contextConfig.iPdpAddress = DPCKTTSY_PDP_ADDRESS1; |
|
76 contextConfig.iPdpCompression = DPCKTTSY_COMPRESSION1; |
|
77 contextConfig.iPdpType = DPCKTTSY_PDP_TYPE1; |
|
78 contextConfig.iUseEdge = DPCKTTSY_EGPRS_REQUIRED; |
|
79 contextConfig.iProtocolConfigOption.iAuthInfo.iUsername = DPCKTTSY_USER_NAME1; |
|
80 contextConfig.iProtocolConfigOption.iAuthInfo.iPassword = DPCKTTSY_PASSWORD1; |
|
81 contextConfig.iProtocolConfigOption.iAuthInfo.iProtocol = DPCKTTSY_PROTOCOL_TYPE1_0; |
|
82 contextConfig.iNWIContext = DPCKTTSY_NWICONTEXT_FALSE; |
|
83 |
|
84 gprsContext.SetConfig(reqStatus, contextConfigPckg); |
|
85 User::WaitForRequest(reqStatus); |
|
86 CHECKPOINT(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("B.4")); |
|
87 |
|
88 gprsContext.SetConfig(reqStatus, contextConfigPckg); |
|
89 gprsContext.CancelAsyncRequest(EPacketContextSetConfig); |
|
90 User::WaitForRequest(reqStatus); |
|
91 CHECKPOINT(reqStatus.Int(),KErrCancel,CHP_CNTXT_CASE("B.4")); |
|
92 |
|
93 //get context |
|
94 gprsContext.GetConfig(reqStatus,contextConfigPckg); |
|
95 User::WaitForRequest(reqStatus); |
|
96 CHECKPOINT(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("B.5")); |
|
97 CHECKPOINT_COMP_STR(contextConfig.iAccessPointName,DPCKTTSY_ACCESS_POINT2,CHP_CNTXT_CASE("B.5")); |
|
98 CHECKPOINT(contextConfig.iAnonymousAccessReqd,DPCKTTSY_ANONYMOUS_ACCESS2,CHP_CNTXT_CASE("B.5")); |
|
99 CHECKPOINT_COMP_STR(contextConfig.iPdpAddress,DPCKTTSY_PDP_ADDRESS2,CHP_CNTXT_CASE("B.5")); |
|
100 CHECKPOINT(contextConfig.iPdpCompression,DPCKTTSY_COMPRESSION2,CHP_CNTXT_CASE("B.5")); |
|
101 CHECKPOINT(contextConfig.iPdpType,DPCKTTSY_PDP_TYPE2,CHP_CNTXT_CASE("B.5")); |
|
102 CHECKPOINT_COMP_STR(contextConfig.iPdpAddress,DPCKTTSY_PDP_ADDRESS2,CHP_CNTXT_CASE("B.5")); |
|
103 CHECKPOINT(contextConfig.iUseEdge,DPCKTTSY_EGPRS_NOTREQUIRED,CHP_CNTXT_CASE("B.5")); // Added 12/07/02 - CR: BGIN5ADD6S |
|
104 CHECKPOINT_COMP_STR(contextConfig.iProtocolConfigOption.iAuthInfo.iUsername,DPCKTTSY_USER_NAME1,CHP_CNTXT_CASE("B.5")); |
|
105 CHECKPOINT_COMP_STR(contextConfig.iProtocolConfigOption.iAuthInfo.iPassword,DPCKTTSY_PASSWORD1,CHP_CNTXT_CASE("B.5")); |
|
106 CHECKPOINT_COMP_STR(contextConfig.iProtocolConfigOption.iAuthInfo.iProtocol,DPCKTTSY_PROTOCOL_TYPE1_0,CHP_CNTXT_CASE("B.5")); |
|
107 CHECKPOINT_COMP_STR(contextConfig.iNWIContext,DPCKTTSY_NWICONTEXT_TRUE,CHP_CNTXT_CASE("B.5")); |
|
108 |
|
109 gprsContext.GetConfig(reqStatus, contextConfigPckg); |
|
110 gprsContext.CancelAsyncRequest(EPacketContextGetConfig); |
|
111 User::WaitForRequest(reqStatus); |
|
112 CHECKPOINT(reqStatus.Int(),KErrCancel,CHP_CNTXT_CASE("B.5")); |
|
113 |
|
114 //notify config changed |
|
115 gprsContext.NotifyConfigChanged(reqStatus, contextConfigPckg); |
|
116 User::WaitForRequest(reqStatus); |
|
117 CHECKPOINT(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("B.6")); |
|
118 CHECKPOINT_COMP_STR(contextConfig.iAccessPointName,DPCKTTSY_ACCESS_POINT1,CHP_CNTXT_CASE("B.6")); |
|
119 CHECKPOINT(contextConfig.iAnonymousAccessReqd,DPCKTTSY_ANONYMOUS_ACCESS1,CHP_CNTXT_CASE("B.6")); |
|
120 CHECKPOINT_COMP_STR(contextConfig.iPdpAddress,DPCKTTSY_PDP_ADDRESS1,CHP_CNTXT_CASE("B.6")); |
|
121 CHECKPOINT(contextConfig.iPdpCompression,DPCKTTSY_COMPRESSION1,CHP_CNTXT_CASE("B.6")); |
|
122 CHECKPOINT(contextConfig.iPdpType,DPCKTTSY_PDP_TYPE1,CHP_CNTXT_CASE("B.6")); |
|
123 CHECKPOINT(contextConfig.iUseEdge,DPCKTTSY_EGPRS_REQUIRED,CHP_CNTXT_CASE("B.6")); |
|
124 CHECKPOINT_COMP_STR(contextConfig.iProtocolConfigOption.iAuthInfo.iUsername,DPCKTTSY_USER_NAME1,CHP_CNTXT_CASE("B.6")); |
|
125 CHECKPOINT_COMP_STR(contextConfig.iProtocolConfigOption.iAuthInfo.iPassword,DPCKTTSY_PASSWORD1,CHP_CNTXT_CASE("B.6")); |
|
126 CHECKPOINT(contextConfig.iProtocolConfigOption.iAuthInfo.iProtocol,DPCKTTSY_PROTOCOL_TYPE1_0,CHP_CNTXT_CASE("B.6")); |
|
127 CHECKPOINT_COMP_STR(contextConfig.iNWIContext,DPCKTTSY_NWICONTEXT_TRUE,CHP_CNTXT_CASE("B.6")); |
|
128 |
|
129 gprsContext.NotifyConfigChanged(reqStatus, contextConfigPckg); |
|
130 gprsContext.CancelAsyncRequest(EPacketContextNotifyConfigChanged); |
|
131 User::WaitForRequest(reqStatus); |
|
132 CHECKPOINT(reqStatus.Int(),KErrCancel,CHP_CNTXT_CASE("B.6")); |
|
133 |
|
134 // Activate |
|
135 gprsContext.Activate(reqStatus); |
|
136 User::WaitForRequest(reqStatus); |
|
137 CHECKPOINT(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("B.7")); |
|
138 |
|
139 gprsContext.Activate(reqStatus); |
|
140 gprsContext.CancelAsyncRequest(EPacketContextActivate); |
|
141 User::WaitForRequest(reqStatus); |
|
142 CHECKPOINT(reqStatus.Int(),KErrCancel,CHP_CNTXT_CASE("B.7")); |
|
143 // Deactivate |
|
144 gprsContext.Deactivate(reqStatus); |
|
145 gprsContext.CancelAsyncRequest(EPacketContextDeactivate); |
|
146 User::WaitForRequest(reqStatus); |
|
147 CHECKPOINT(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("B.8")); |
|
148 |
|
149 gprsContext.Deactivate(reqStatus); |
|
150 gprsContext.CancelAsyncRequest(EPacketContextDeactivate); |
|
151 User::WaitForRequest(reqStatus); |
|
152 CHECKPOINT(reqStatus.Int(),KErrCancel,CHP_CNTXT_CASE("B.8")); |
|
153 |
|
154 // Delete |
|
155 gprsContext.Delete(reqStatus); |
|
156 User::WaitForRequest(reqStatus); |
|
157 CHECKPOINT(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("B.9")); |
|
158 |
|
159 gprsContext.Delete(reqStatus); |
|
160 gprsContext.CancelAsyncRequest(EPacketContextDelete); |
|
161 User::WaitForRequest(reqStatus); |
|
162 CHECKPOINT(reqStatus.Int(),KErrCancel,CHP_CNTXT_CASE("B.9")); |
|
163 // Comm Port |
|
164 RCall::TCommPort dataPort; |
|
165 gprsContext.LoanCommPort(reqStatus, dataPort); |
|
166 User::WaitForRequest(reqStatus); |
|
167 CHECKPOINT(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("B.10")); |
|
168 CHECKPOINT_COMP_STR(dataPort.iCsy,DPCKTTSY_CSY,CHP_CNTXT_CASE("B.10")); |
|
169 CHECKPOINT_COMP_STR(dataPort.iPort,DPCKTTSY_PORT,CHP_CNTXT_CASE("B.10")); |
|
170 |
|
171 gprsContext.LoanCommPort(reqStatus, dataPort); |
|
172 gprsContext.CancelAsyncRequest(EPacketContextLoanCommPort); |
|
173 User::WaitForRequest(reqStatus); |
|
174 CHECKPOINT(reqStatus.Int(),KErrCancel,CHP_CNTXT_CASE("B.10")); |
|
175 //recover comm port |
|
176 gprsContext.RecoverCommPort(reqStatus); |
|
177 User::WaitForRequest(reqStatus); |
|
178 CHECKPOINT(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("B.11")); |
|
179 |
|
180 gprsContext.RecoverCommPort(reqStatus); |
|
181 gprsContext.CancelAsyncRequest(EPacketContextRecoverCommPort); |
|
182 User::WaitForRequest(reqStatus); |
|
183 CHECKPOINT(reqStatus.Int(),KErrCancel,CHP_CNTXT_CASE("B.11")); |
|
184 |
|
185 ExtendedTest1( reqStatus, gprsContext); |
|
186 |
|
187 gprs.Close(); |
|
188 phone.Close(); |
|
189 |
|
190 return TestStepResult(); |
|
191 } |
|
192 |
|
193 // some test code moved here to prevent stack overflow |
|
194 enum TVerdict CEtelPacketTest1_2::ExtendedTest1(TRequestStatus& reqStatus, RPacketContext& gprsContext) |
|
195 { |
|
196 // Context Status |
|
197 RPacketContext::TContextStatus contextStatus; |
|
198 CHECKPOINT(gprsContext.GetStatus(contextStatus),KErrNone,CHP_CNTXT_CASE("B.12")); |
|
199 CHECKPOINT(contextStatus,DPCKTTSY_CONTEXT_STATUS1,CHP_CNTXT_CASE("B.12")); |
|
200 // |
|
201 gprsContext.NotifyStatusChange(reqStatus, contextStatus); |
|
202 User::WaitForRequest(reqStatus); |
|
203 CHECKPOINT(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("B.13")); |
|
204 CHECKPOINT(contextStatus,DPCKTTSY_CONTEXT_STATUS2,CHP_CNTXT_CASE("B.13")); |
|
205 |
|
206 gprsContext.NotifyStatusChange(reqStatus, contextStatus); |
|
207 gprsContext.CancelAsyncRequest(EPacketContextNotifyStatusChange); |
|
208 User::WaitForRequest(reqStatus); |
|
209 CHECKPOINT(reqStatus.Int(),KErrCancel,CHP_CNTXT_CASE("B.13")); |
|
210 // Data Volume Transferred |
|
211 RPacketContext::TDataVolume volume; |
|
212 CHECKPOINT(gprsContext.GetDataVolumeTransferred(volume),KErrNone,CHP_CNTXT_CASE("B.14")); |
|
213 CHECKPOINT(volume.iBytesSent,DPCKTTSY_BYTES_SENT1,CHP_CNTXT_CASE("B.14")); |
|
214 CHECKPOINT(volume.iOverflowCounterSent,DPCKTTSY_OVERFLOW_COUNTER_SENT1,CHP_CNTXT_CASE("B.14")); |
|
215 CHECKPOINT(volume.iBytesReceived,DPCKTTSY_BYTES_RCVD1,CHP_CNTXT_CASE("B.14")); |
|
216 CHECKPOINT(volume.iOverflowCounterReceived,DPCKTTSY_OVERFLOW_COUNTER_RCVD1,CHP_CNTXT_CASE("B.14")); |
|
217 |
|
218 // Data Transferred |
|
219 TUint rcvdGranularity=DPCKTTSY_RCVD_GRANULARITY; |
|
220 TUint sentGranularity=DPCKTTSY_SENT_GRANULARITY; |
|
221 |
|
222 gprsContext.NotifyDataTransferred(reqStatus, volume, rcvdGranularity, sentGranularity); |
|
223 User::WaitForRequest(reqStatus); |
|
224 CHECKPOINT(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("B.15")); |
|
225 CHECKPOINT(volume.iBytesSent,DPCKTTSY_BYTES_SENT2,CHP_CNTXT_CASE("B.15")); |
|
226 CHECKPOINT(volume.iOverflowCounterSent,DPCKTTSY_OVERFLOW_COUNTER_SENT2,CHP_CNTXT_CASE("B.15")); |
|
227 CHECKPOINT(volume.iBytesReceived,DPCKTTSY_BYTES_RCVD2,CHP_CNTXT_CASE("B.15")); |
|
228 CHECKPOINT(volume.iOverflowCounterReceived,DPCKTTSY_OVERFLOW_COUNTER_RCVD2,CHP_CNTXT_CASE("B.15")); |
|
229 |
|
230 gprsContext.NotifyDataTransferred(reqStatus, volume, rcvdGranularity, sentGranularity); |
|
231 gprsContext.CancelAsyncRequest(EPacketContextNotifyDataTransferred); |
|
232 User::WaitForRequest(reqStatus); |
|
233 CHECKPOINT(reqStatus.Int(),KErrCancel,CHP_CNTXT_CASE("B.15")); |
|
234 |
|
235 //current connection speed |
|
236 TUint rate=0; |
|
237 gprsContext.GetConnectionSpeed(reqStatus,rate); |
|
238 User::WaitForRequest(reqStatus); |
|
239 CHECKPOINT(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("B.16")); |
|
240 CHECKPOINT(rate,DPCKTTSY_CONNECTION_RATE,CHP_CNTXT_CASE("B.16")); |
|
241 //speed change notification |
|
242 gprsContext.NotifyConnectionSpeedChange(reqStatus, rate); |
|
243 User::WaitForRequest(reqStatus); |
|
244 CHECKPOINT(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("B.17")); |
|
245 CHECKPOINT(rate,DPCKTTSY_CONNECTION_RATE,CHP_CNTXT_CASE("B.17")); |
|
246 |
|
247 gprsContext.NotifyConnectionSpeedChange(reqStatus, rate); |
|
248 gprsContext.CancelAsyncRequest(EPacketContextNotifyConnectionSpeedChange); |
|
249 User::WaitForRequest(reqStatus); |
|
250 CHECKPOINT(reqStatus.Int(),KErrCancel,CHP_CNTXT_CASE("B.17")); |
|
251 // Last Error Cause |
|
252 TInt error; |
|
253 CHECKPOINT(gprsContext.GetLastErrorCause(error),KErrNone,CHP_CNTXT_CASE("B.18")); |
|
254 CHECKPOINT(error,DPCKTTSY_LAST_ERROR_CAUSE,CHP_CNTXT_CASE("B.18")); |
|
255 |
|
256 // JoeF : 16-Nov-01 : Added the following test below. This tests a new API method recently added to the RPacketContext class |
|
257 // GetProfileName |
|
258 TName myQoSProfile; |
|
259 CHECKPOINT(gprsContext.GetProfileName(myQoSProfile), KErrNone, CHP_CNTXT_CASE("B.19")); |
|
260 CHECKPOINT_COMP_STR(myQoSProfile, DPCKTTSY_PROFILE_NAME, CHP_CNTXT_CASE("B.19")); |
|
261 |
|
262 // Change Request: NDOE-58VF4Q. Added asychronous request (and cancel) for the following |
|
263 // method: GetDataVolumeTransferred(). |
|
264 // Data Volume Transferred - Asynchronous variant |
|
265 RPacketContext::TDataVolume volume2; |
|
266 gprsContext.GetDataVolumeTransferred(reqStatus, volume2); |
|
267 User::WaitForRequest(reqStatus); |
|
268 |
|
269 CHECKPOINT(reqStatus.Int(), KErrNone, CHP_CNTXT_CASE("B.14B")); |
|
270 CHECKPOINT(volume2.iBytesSent,DPCKTTSY_BYTES_SENT3,CHP_CNTXT_CASE("B.14B")); |
|
271 CHECKPOINT(volume2.iOverflowCounterSent,DPCKTTSY_OVERFLOW_COUNTER_SENT3,CHP_CNTXT_CASE("B.14B")); |
|
272 CHECKPOINT(volume2.iBytesReceived,DPCKTTSY_BYTES_RCVD3,CHP_CNTXT_CASE("B.14B")); |
|
273 CHECKPOINT(volume2.iOverflowCounterReceived,DPCKTTSY_OVERFLOW_COUNTER_RCVD3,CHP_CNTXT_CASE("B.14B")); |
|
274 |
|
275 // Cancel Data Volume Transferred |
|
276 gprsContext.GetDataVolumeTransferred(reqStatus, volume2); |
|
277 gprsContext.CancelAsyncRequest(EPacketContextGetDataVolumeTransferred); |
|
278 User::WaitForRequest(reqStatus); |
|
279 CHECKPOINT(reqStatus.Int(),KErrCancel,CHP_CNTXT_CASE("B.14")); |
|
280 |
|
281 // End of RPacketContext tests |
|
282 gprsContext.Close(); |
|
283 |
|
284 |
|
285 |
|
286 return TestStepResult(); |
|
287 } |
|
288 |