|
1 // Copyright (c) 2006-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 // @file ctlbsnetsimstep.cpp |
|
15 // This is the class implementation for the LBS Test Step Base |
|
16 // |
|
17 // |
|
18 |
|
19 #include "ctlbsnetsimstep.h" |
|
20 |
|
21 |
|
22 /** |
|
23 * Constructor |
|
24 */ |
|
25 CT_LbsNetSimStep::CT_LbsNetSimStep() : iState(EConnecting) |
|
26 { |
|
27 } |
|
28 |
|
29 |
|
30 /** |
|
31 * If parameter is supplied, it will cause the test to continue running for this period after all expected flags have been set |
|
32 */ |
|
33 void CT_LbsNetSimStep::ConstructL(TTimeIntervalMicroSeconds32 aHaltTimerInterval) |
|
34 { |
|
35 // Create the keep alive timer. |
|
36 iKeepAliveTimer = CT_LbsTimerUtils::NewL(this, KKeepAliveTimerId); |
|
37 // Create the abort timer. |
|
38 iAbortTimer = CT_LbsTimerUtils::NewL(this, KAbortTimerId); |
|
39 |
|
40 iExtendedTimerInterval = aHaltTimerInterval; |
|
41 } |
|
42 |
|
43 /** |
|
44 * Can be used to set the extended time interval if not known at construct time. |
|
45 * // This will cause the test to continue running for this period after all expected flags have been set |
|
46 */ |
|
47 void CT_LbsNetSimStep::SetExtendedTimerInterval(TTimeIntervalMicroSeconds32 aHaltTimerInterval) |
|
48 { |
|
49 iExtendedTimerInterval = aHaltTimerInterval; |
|
50 } |
|
51 |
|
52 |
|
53 CT_LbsNetSimStep::~CT_LbsNetSimStep() |
|
54 { |
|
55 iKeepAliveTimer->Cancel(); |
|
56 delete iKeepAliveTimer; |
|
57 iAbortTimer->Cancel(); |
|
58 delete iAbortTimer; |
|
59 |
|
60 } |
|
61 |
|
62 /** |
|
63 * @return - TVerdict |
|
64 * Implementation of CTestStep base class virtual |
|
65 * It is used for doing all initialisation common to derived classes in here. |
|
66 * Make it being able to leave if there are any errors here as there's no point in |
|
67 * trying to run a test step if anything fails. |
|
68 * The leave will be picked up by the framework. |
|
69 */ |
|
70 TVerdict CT_LbsNetSimStep::doTestStepPreambleL() |
|
71 { |
|
72 // Process some common pre setting to test steps then set SetTestStepResult to EFail or Epass. |
|
73 INFO_PRINTF1(_L(">>CT_LbsNetSimStep::doTestStepPreambleL()")); |
|
74 SetTestStepResult(EPass); |
|
75 |
|
76 _LIT(KExpectedApiBehaviour, "expected_api_behaviour"); |
|
77 TInt expectedApiBehaviour; |
|
78 if(GetIntFromConfig(ConfigSection(), KExpectedApiBehaviour, expectedApiBehaviour)) |
|
79 { |
|
80 iExpectedApiBehaviour = static_cast<TExpectedApiBehaviour>(expectedApiBehaviour);; |
|
81 } |
|
82 else |
|
83 { |
|
84 iExpectedApiBehaviour = EApiVariant1; |
|
85 } |
|
86 |
|
87 return TestStepResult(); |
|
88 } |
|
89 |
|
90 |
|
91 /** |
|
92 * @return - TVerdict |
|
93 * Implementation of CTestStep base class virtual |
|
94 * It is used for doing all after test treatment common to derived classes in here. |
|
95 * Make it being able to leave |
|
96 * The leave will be picked up by the framework. |
|
97 */ |
|
98 TVerdict CT_LbsNetSimStep::doTestStepPostambleL() |
|
99 { |
|
100 // Process some common post setting to test steps then set SetTestStepResult to EFail or Epass. |
|
101 INFO_PRINTF1(_L(">>CT_LbsNetSimStep::doTestStepPostabmleL()")); |
|
102 |
|
103 //SetTestStepResult(EPass); // or EFail |
|
104 return TestStepResult(); |
|
105 } |
|
106 |
|
107 |
|
108 /** Used to mark each callback that has fired. |
|
109 */ |
|
110 void CT_LbsNetSimStep::SetCallbackFlag(TLbsCallbackFlags aCallbackFlag) |
|
111 { |
|
112 // INFO_PRINTF2(_L("CT_LbsNetSimStep::SetCallbackFlag: setting callback flag 0x%x"), aCallbackFlag); |
|
113 iCallbackFlags |= aCallbackFlag; |
|
114 } |
|
115 |
|
116 |
|
117 /** Used to determine which callback or callbacks have been fired. |
|
118 */ |
|
119 TBool CT_LbsNetSimStep::TestCallbackFlags(TLbsCallbackFlags aExpectedFlags) |
|
120 { |
|
121 if (iCallbackFlags == aExpectedFlags) |
|
122 { |
|
123 return ETrue; |
|
124 } |
|
125 return EFalse; |
|
126 } |
|
127 |
|
128 |
|
129 /** Keep alive timer callback. |
|
130 |
|
131 Check the state machine to determine when to halt the test. Once all the callbacks |
|
132 have been received the test can end. |
|
133 |
|
134 We have to call async functions from here also, as the callbacks are executed in another thread. |
|
135 */ |
|
136 void CT_LbsNetSimStep::HandleTimerL(TInt aTimerId, const TTime& aTargetTime) |
|
137 { |
|
138 // Not used. |
|
139 (void)aTimerId; |
|
140 (void)aTargetTime; |
|
141 |
|
142 if(KAbortTimerId == aTimerId) |
|
143 { |
|
144 INFO_PRINTF1(_L("Abort timer fired")); |
|
145 iState = EAborted; |
|
146 iKeepAliveTimer->Cancel(); |
|
147 CActiveScheduler::Stop(); |
|
148 } |
|
149 else |
|
150 { |
|
151 // Check for test finish. |
|
152 |
|
153 ASSERT(aTimerId == KKeepAliveTimerId); |
|
154 // We stop test from here when in the correct state and, there should not be anything outstanding. |
|
155 if (iState == EWaiting && TestCallbackFlags(iFlagsToHaltOn)) |
|
156 { |
|
157 if(iExtendedTimerInterval.Int()) // we need an extended timer |
|
158 { |
|
159 INFO_PRINTF1(_L("Starting extended timer")); |
|
160 iState = EExtendedWaiting; |
|
161 iKeepAliveTimer->SetTimer(iExtendedTimerInterval); |
|
162 } |
|
163 else |
|
164 { |
|
165 iState = EDone; |
|
166 iAbortTimer->Cancel(); // note: this is ok since it will do nothing if timer never started |
|
167 CActiveScheduler::Stop(); |
|
168 } |
|
169 } |
|
170 // expected callbacks have all fired, but waiting for an extended period of time before stopping |
|
171 else if(iState == EExtendedWaiting) |
|
172 { |
|
173 INFO_PRINTF1(_L("Extended timer fired")); |
|
174 iState = EDone; |
|
175 iAbortTimer->Cancel(); |
|
176 CActiveScheduler::Stop(); |
|
177 } |
|
178 // Keep going, still waiting for callbacks. |
|
179 else |
|
180 { |
|
181 TTimeIntervalMicroSeconds32 interval(KLbsKeepAlivePeriod); |
|
182 |
|
183 iKeepAliveTimer->SetTimer(interval); |
|
184 } |
|
185 } |
|
186 } |
|
187 |
|
188 |
|
189 /** NetSim callbacks. |
|
190 */ |
|
191 void CT_LbsNetSimStep::Connected() |
|
192 { |
|
193 INFO_PRINTF1(_L("Got - NetSim Connect - Callback Event.")); |
|
194 |
|
195 SetCallbackFlag(KLbsCallback_NetSim_Got_Connect); |
|
196 |
|
197 iState = EWaiting; |
|
198 } |
|
199 |
|
200 |
|
201 void CT_LbsNetSimStep::Disconnected() |
|
202 { |
|
203 INFO_PRINTF1(_L("Got - NetSim Notify Disconnected - Callback Event.")); |
|
204 } |
|
205 |
|
206 |
|
207 void CT_LbsNetSimStep::NotifyRegisterLcsMoLr(const TDesC& aData) |
|
208 { |
|
209 (void)aData; |
|
210 |
|
211 INFO_PRINTF1(_L("Got - NetSim Notify Register Lcs MoLr - Callback Event.")); |
|
212 SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyRegisterLcsMoLr); |
|
213 } |
|
214 |
|
215 |
|
216 void CT_LbsNetSimStep::NotifyReleaseLcsMoLr(TInt aReason) |
|
217 { |
|
218 (void)aReason; |
|
219 |
|
220 INFO_PRINTF1(_L("Got - NetSim Notify Release Lcs MoLr - Callback Event.")); |
|
221 SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyReleaseLcsMoLr); |
|
222 } |
|
223 |
|
224 |
|
225 void CT_LbsNetSimStep::NotifyMeasurementControlLocation(const TPositionInfo& aPosition, |
|
226 const RLbsAssistanceDataBuilderSet& aData, |
|
227 const TLbsNetPosRequestQuality& aQuality) |
|
228 { |
|
229 (void)aPosition; |
|
230 (void)aData; |
|
231 (void)aQuality; |
|
232 |
|
233 INFO_PRINTF1(_L("Got - NetSim Notify Measurement Control Location - Callback Event.")); |
|
234 SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyMeasurementControlLocation); |
|
235 } |
|
236 |
|
237 |
|
238 void CT_LbsNetSimStep::NotifyReleaseLcsLocationNotification(const CLbsNetworkProtocolBase::TLbsPrivacyResponse& aResult) |
|
239 { |
|
240 (void)aResult; |
|
241 |
|
242 INFO_PRINTF1(_L("Got - NetSim Notify Release Lcs Location Notification - Callback Event.")); |
|
243 SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyReleaseLcsLocationNotification); |
|
244 } |
|
245 |
|
246 |
|
247 void CT_LbsNetSimStep::NotifyFacilityLcsMoLrResult(TInt aReason, const TPositionInfo& aPosition) |
|
248 { |
|
249 (void)aReason; |
|
250 (void)aPosition; |
|
251 |
|
252 INFO_PRINTF1(_L("Got - NetSim Notify Facility Lcs MoLr Result - Callback Event.")); |
|
253 SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyFacilityLcsMoLrResult); |
|
254 } |
|
255 |
|
256 |
|
257 void CT_LbsNetSimStep::NotifyMeasurementReportLocation(const TPositionInfo& aPosition) |
|
258 { |
|
259 (void)aPosition; |
|
260 |
|
261 INFO_PRINTF1(_L("Got - Net Sim Notify Measurement Report - Callback Event.")); |
|
262 SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyMeasurementReportLocation); |
|
263 } |
|
264 |
|
265 |
|
266 void CT_LbsNetSimStep::NotifyMeasurementReportRequestMoreAssistanceData(const TLbsAssistanceDataGroup& aFilter) |
|
267 { |
|
268 (void)aFilter; |
|
269 |
|
270 INFO_PRINTF1(_L("Got - Net Sim Notify Measurement Report Request More Assistance Data - Callback Event.")); |
|
271 SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyMeasurementReportRequestMoreAssistanceData); |
|
272 } |
|
273 |
|
274 |
|
275 void CT_LbsNetSimStep::NotifyMeasurementReportControlFailure(TInt aReason) |
|
276 { |
|
277 INFO_PRINTF2(_L("Got - Net Sim Notify Measurement Report Control Failure - Callback Event. Reason = %d"), aReason); |
|
278 SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyMeasurementReportControlFailure); |
|
279 } |
|
280 |
|
281 void CT_LbsNetSimStep::NotifyError(MLbsNetSimTestObserver::EFunction aFunction, int aError) |
|
282 { |
|
283 INFO_PRINTF3(_L("Got - Net Sim Notify Error - Callback Event. Function = %d, Error = %d"), aFunction, aError); |
|
284 SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyError); |
|
285 } |
|
286 |
|
287 void CT_LbsNetSimStep::ProcessMeasurementControlLocationError(TInt aError) |
|
288 { |
|
289 INFO_PRINTF2(_L("Got - Net Sim Process Measurement Control Location Error - Callback Event. Reason = %d"), aError); |
|
290 SetCallbackFlag(KLbsCallback_NetSim_Got_ProcessMeasurementControlLocationError); |
|
291 } |