|
1 // Copyright (c) 2001-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 the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 // INCLUDES |
|
19 #include "ctlbsclientpostp178.h" |
|
20 #include <EPos_CPosModules.h> |
|
21 #include <EPos_CPosModuleUpdate.h> |
|
22 |
|
23 // CONSTANTS |
|
24 |
|
25 // ================= MEMBER FUNCTIONS ======================= |
|
26 |
|
27 // --------------------------------------------------------- |
|
28 // Constructor. |
|
29 // --------------------------------------------------------- |
|
30 CT_LbsClientPosTp178::CT_LbsClientPosTp178(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent) |
|
31 { |
|
32 _LIT(KTestName, "Tp178 - Request Timeout"); |
|
33 SetTestStepName(KTestName); |
|
34 } |
|
35 |
|
36 // --------------------------------------------------------- |
|
37 // Destructor. |
|
38 // --------------------------------------------------------- |
|
39 CT_LbsClientPosTp178::~CT_LbsClientPosTp178() |
|
40 { |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------- |
|
44 // CT_LbsClientPosTp178::CloseTest |
|
45 // Always called after the test, even if the test leaves |
|
46 // (other items were commented in a header). |
|
47 // --------------------------------------------------------- |
|
48 // |
|
49 void CT_LbsClientPosTp178::CloseTest() |
|
50 { |
|
51 ClosePositioner(); |
|
52 Disconnect(); |
|
53 } |
|
54 |
|
55 |
|
56 TInt Timeout178(TAny* /*aNothing*/) |
|
57 { |
|
58 CActiveScheduler::Stop(); |
|
59 return KErrNone; |
|
60 } |
|
61 |
|
62 void StartSchedulerForAWhile178L(TTimeIntervalMicroSeconds32 aTimeout) |
|
63 { |
|
64 CPeriodic* timer = CPeriodic::NewL(CActive::EPriorityStandard); |
|
65 CleanupStack::PushL(timer); |
|
66 timer->Start(aTimeout, aTimeout, TCallBack(Timeout178)); |
|
67 CActiveScheduler::Start(); |
|
68 CleanupStack::PopAndDestroy(timer); |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------- |
|
72 // CT_LbsClientPosTp178::StartL |
|
73 // |
|
74 // (other items were commented in a header). |
|
75 // --------------------------------------------------------- |
|
76 // |
|
77 void CT_LbsClientPosTp178::StartL() |
|
78 { |
|
79 _LIT(KServiceAccept, "SAAA"); |
|
80 |
|
81 SetupPsyL(iUidTestPsy3); |
|
82 |
|
83 RPositioner positioner; |
|
84 TPositionInfo info = TPositionInfo(); |
|
85 |
|
86 ConnectL(); |
|
87 |
|
88 User::LeaveIfError(positioner.Open(iPosServer,iUidTestPsy3)); |
|
89 CleanupClosePushL(positioner); |
|
90 |
|
91 TInt Err = positioner.SetRequestor(CRequestor::ERequestorService, |
|
92 CRequestor::EFormatApplication, KServiceAccept); |
|
93 |
|
94 TPositionUpdateOptions updateOptionsLong, updateOptionsShort; |
|
95 |
|
96 TTimeIntervalMicroSeconds longInterval(7000000); |
|
97 |
|
98 updateOptionsLong.SetUpdateTimeOut(longInterval); |
|
99 Err = positioner.SetUpdateOptions(updateOptionsLong); |
|
100 |
|
101 TTimeIntervalMicroSeconds shortInterval(2000000); |
|
102 updateOptionsShort.SetUpdateTimeOut(shortInterval); |
|
103 |
|
104 TPositionUpdateOptions theUpdateOptions; |
|
105 Err = positioner.GetUpdateOptions(theUpdateOptions); |
|
106 |
|
107 if (theUpdateOptions.UpdateTimeOut() != updateOptionsLong.UpdateTimeOut() || |
|
108 updateOptionsLong.UpdateTimeOut() != longInterval) |
|
109 { |
|
110 _LIT(KUpdateOptions, "The update option was not set correctly"); |
|
111 LogErrorAndLeaveL(KUpdateOptions); |
|
112 } |
|
113 |
|
114 _LIT(KDelayMsg, "The successfull requests was completed within %d microsecs."); |
|
115 _LIT(KCancelMsg, "The canceled requests was completed within %d microsecs."); |
|
116 |
|
117 TRequestStatus status; |
|
118 |
|
119 for (TInt i = 0; i < 10; i++) // makes 10 test inorder to get some statistic |
|
120 { |
|
121 |
|
122 positioner.SetUpdateOptions(updateOptionsLong); |
|
123 TTime requestStartTime; |
|
124 |
|
125 requestStartTime.UniversalTime(); |
|
126 positioner.NotifyPositionUpdate(info, status); |
|
127 User::WaitForRequest(status); |
|
128 TTime requestStopTime; |
|
129 requestStopTime.UniversalTime(); |
|
130 |
|
131 TTimeIntervalMicroSeconds durationMicro = requestStopTime.MicroSecondsFrom(requestStartTime); |
|
132 |
|
133 TInt duration = durationMicro.Int64(); |
|
134 |
|
135 TBuf<100> timeMsg; |
|
136 timeMsg.Format(KDelayMsg, duration); |
|
137 INFO_PRINTF1(timeMsg); |
|
138 |
|
139 //check error status |
|
140 if (status != KErrNone) |
|
141 { |
|
142 _LIT(KErrPositionRequest, "error code returned from NotifyPositionUpdate, error code = %d"); |
|
143 TBuf<100> buf; |
|
144 buf.Format(KErrPositionRequest, status.Int()); |
|
145 LogErrorAndLeaveL(buf); |
|
146 } |
|
147 |
|
148 |
|
149 TTimeIntervalMicroSeconds shortInterval(2000000); |
|
150 updateOptionsShort.SetUpdateTimeOut(shortInterval); |
|
151 |
|
152 positioner.SetUpdateOptions(updateOptionsShort); |
|
153 |
|
154 requestStartTime.UniversalTime(); |
|
155 positioner.NotifyPositionUpdate(info, status); |
|
156 User::WaitForRequest(status); |
|
157 requestStopTime.UniversalTime(); |
|
158 |
|
159 durationMicro = requestStopTime.MicroSecondsFrom(requestStartTime); |
|
160 |
|
161 duration = durationMicro.Int64(); |
|
162 |
|
163 #ifdef __WINS__ |
|
164 TTimeIntervalMicroSeconds winsFail(100000); |
|
165 durationMicro = TTimeIntervalMicroSeconds(durationMicro.Int64()+winsFail.Int64()); |
|
166 #endif |
|
167 |
|
168 timeMsg.Format(KCancelMsg, duration); |
|
169 INFO_PRINTF1(timeMsg); |
|
170 |
|
171 |
|
172 if (status != KErrTimedOut) |
|
173 { |
|
174 _LIT(KErrPositionRequest, "Request did not returned KErrTimedOut, status code = %d."); |
|
175 TBuf<100> buf; |
|
176 buf.Format(KErrPositionRequest, status.Int()); |
|
177 LogErrorAndLeaveL(buf); |
|
178 } |
|
179 |
|
180 //Check that the request was not aborted before the Interval |
|
181 //Remove this condition if a lot of data is needed in test log. |
|
182 if (durationMicro < shortInterval) |
|
183 { |
|
184 _LIT(KErrInterval, " The request was aborted before the set timed out "); |
|
185 LogErrorAndLeaveL(KErrInterval); |
|
186 } |
|
187 |
|
188 |
|
189 } // end for loop |
|
190 CleanupStack::PopAndDestroy(1); //positioner |
|
191 Disconnect(); |
|
192 |
|
193 // Do timeout test |
|
194 TestTimeoutL(); |
|
195 |
|
196 // Do cancel test |
|
197 TestCancelL(); |
|
198 |
|
199 // ESLI-5QRA7U just check that it is not possible to set a timeout that is less than |
|
200 // the update interval |
|
201 TestOptionL(); |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------- |
|
205 // CT_LbsClientPosTp178::TestTimeout |
|
206 // |
|
207 // (other items were commented in a header). |
|
208 // --------------------------------------------------------- |
|
209 // |
|
210 void CT_LbsClientPosTp178::TestTimeoutL() |
|
211 { |
|
212 _LIT(KSTART, "TestTimeout()"); |
|
213 _LIT(KEND, "TestTimeout() passed"); |
|
214 _LIT(KTIME, "Request took %d us"); |
|
215 |
|
216 // Setup verification stuff |
|
217 INFO_PRINTF1(KSTART); |
|
218 |
|
219 //TPrivDlgDiagnostics tmpdiag; |
|
220 TTime requestStartTime; |
|
221 TTime requestStopTime; |
|
222 TTimeIntervalMicroSeconds durationMicro; |
|
223 |
|
224 TBuf<100> buf; |
|
225 |
|
226 _LIT(KService, "SAAA"); |
|
227 TPositionUpdateOptions updateOptions; |
|
228 |
|
229 TTimeIntervalMicroSeconds longInterval(7000000); |
|
230 ConnectL(); |
|
231 SetupPsyL(iUidTestPsy3); |
|
232 |
|
233 OpenPositionerByName(iUidTestPsy3); |
|
234 updateOptions.SetUpdateTimeOut(longInterval); |
|
235 |
|
236 // Access protected member (iPositioner) here |
|
237 iPositioner.SetUpdateOptions(updateOptions); |
|
238 |
|
239 _LIT(KONE, "Perform first request, should NOT time out"); |
|
240 INFO_PRINTF1(KONE); |
|
241 |
|
242 requestStartTime.UniversalTime(); |
|
243 //Make one request to verify psy |
|
244 PerformRequestL(KService, CRequestor::ERequestorService, CRequestor::EFormatApplication); |
|
245 |
|
246 CheckRequestResultL(KErrNone); |
|
247 requestStopTime.UniversalTime(); |
|
248 |
|
249 durationMicro = requestStopTime.MicroSecondsFrom(requestStartTime); |
|
250 TInt duration = durationMicro.Int64(); |
|
251 |
|
252 buf.Format(KTIME, duration); |
|
253 INFO_PRINTF1(buf); |
|
254 |
|
255 ClosePositioner(); |
|
256 |
|
257 OpenPositionerByName(iUidTestPsy3); |
|
258 // ECancelButton means that the Automatised class should wait for a cancel call |
|
259 // before returning result |
|
260 |
|
261 updateOptions.SetUpdateTimeOut(longInterval); |
|
262 |
|
263 // Access protected (iPositioner) member here |
|
264 iPositioner.SetUpdateOptions(updateOptions); |
|
265 |
|
266 _LIT(KTWO, "Perform second request, should not time out"); |
|
267 INFO_PRINTF1(KTWO); |
|
268 |
|
269 //Make one request to verify psy |
|
270 TPositionInfo info = TPositionInfo(); |
|
271 requestStartTime.UniversalTime(); |
|
272 TInt err = PerformSyncRequest(KService, &info); |
|
273 requestStopTime.UniversalTime(); |
|
274 |
|
275 if (err != KErrNone) |
|
276 { |
|
277 _LIT(KError, "Wrong result from iStatus, should be KErrNone, was %d"); |
|
278 TBuf<100> buf; |
|
279 buf.Format(KError, err); |
|
280 LogErrorAndLeaveL(buf); |
|
281 } |
|
282 |
|
283 durationMicro = requestStopTime.MicroSecondsFrom(requestStartTime); |
|
284 duration = durationMicro.Int64(); |
|
285 |
|
286 buf.Format(KTIME, duration); |
|
287 INFO_PRINTF1(buf); |
|
288 |
|
289 ClosePositioner(); |
|
290 Disconnect(); |
|
291 |
|
292 INFO_PRINTF1(KEND); |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------- |
|
296 // CT_LbsClientPosTp178::TestCancel |
|
297 // |
|
298 // (other items were commented in a header). |
|
299 // --------------------------------------------------------- |
|
300 // |
|
301 void CT_LbsClientPosTp178::TestCancelL() |
|
302 { |
|
303 _LIT(KSTART, "TestCancel()"); |
|
304 _LIT(KEND, "TestCancel() passed"); |
|
305 |
|
306 // Setup verification stuff |
|
307 INFO_PRINTF1(KSTART); |
|
308 |
|
309 _LIT(KService, "SAAA"); |
|
310 ConnectL(); |
|
311 SetupPsyL(iUidTestPsy3); |
|
312 |
|
313 OpenPositionerByName(iUidTestPsy3); |
|
314 |
|
315 PerformRequestL(KService, CRequestor::ERequestorService, CRequestor::EFormatApplication); |
|
316 StartSchedulerForAWhile178L(2000000); |
|
317 iPositioner.CancelRequest(EPositionerNotifyPositionUpdate); |
|
318 CheckRequestResultL(KErrCancel); |
|
319 |
|
320 ClosePositioner(); |
|
321 Disconnect(); |
|
322 |
|
323 INFO_PRINTF1(KEND); |
|
324 } |
|
325 |
|
326 |
|
327 void CT_LbsClientPosTp178::TestOptionL() |
|
328 { |
|
329 SetupPsyL(iUidTestPsy3); |
|
330 |
|
331 RPositioner positioner; |
|
332 |
|
333 ConnectL(); |
|
334 |
|
335 User::LeaveIfError(positioner.Open(iPosServer,iUidTestPsy3)); |
|
336 CleanupClosePushL(positioner); |
|
337 |
|
338 _LIT(KKalle, "Kalle"); |
|
339 positioner.SetRequestor(CRequestor::ERequestorService, |
|
340 CRequestor::EFormatApplication, KKalle); |
|
341 |
|
342 TPositionUpdateOptions updateOptions; |
|
343 |
|
344 TTimeIntervalMicroSeconds timeoutInterval(4000000); |
|
345 TTimeIntervalMicroSeconds periodicInterval(7000000); |
|
346 |
|
347 updateOptions.SetUpdateTimeOut(timeoutInterval); |
|
348 updateOptions.SetUpdateInterval(periodicInterval); |
|
349 TInt err = positioner.SetUpdateOptions(updateOptions); |
|
350 if (err != KErrArgument) |
|
351 { |
|
352 _LIT(KErrArg, "Possible to set timout < update interval, error code = %d"); |
|
353 TBuf<100> buf; |
|
354 buf.Format(KErrArg, err); |
|
355 INFO_PRINTF1(buf); |
|
356 LogErrorAndLeaveL(buf); |
|
357 } |
|
358 |
|
359 //should never be runned; |
|
360 CleanupStack::PopAndDestroy(1); //positioner |
|
361 Disconnect(); |
|
362 } |
|
363 |
|
364 |
|
365 // End of File |
|
366 |