748
|
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
|
872
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
748
|
5 |
// which accompanies this distribution, and is available
|
872
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
748
|
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 |
return TestStepResult();
|
|
77 |
}
|
|
78 |
|
|
79 |
|
|
80 |
/**
|
|
81 |
* @return - TVerdict
|
|
82 |
* Implementation of CTestStep base class virtual
|
|
83 |
* It is used for doing all after test treatment common to derived classes in here.
|
|
84 |
* Make it being able to leave
|
|
85 |
* The leave will be picked up by the framework.
|
|
86 |
*/
|
|
87 |
TVerdict CT_LbsNetSimStep::doTestStepPostambleL()
|
|
88 |
{
|
|
89 |
// Process some common post setting to test steps then set SetTestStepResult to EFail or Epass.
|
|
90 |
INFO_PRINTF1(_L(">>CT_LbsNetSimStep::doTestStepPostabmleL()"));
|
|
91 |
|
|
92 |
//SetTestStepResult(EPass); // or EFail
|
|
93 |
return TestStepResult();
|
|
94 |
}
|
|
95 |
|
|
96 |
|
|
97 |
/** Used to mark each callback that has fired.
|
|
98 |
*/
|
|
99 |
void CT_LbsNetSimStep::SetCallbackFlag(TLbsCallbackFlags aCallbackFlag)
|
|
100 |
{
|
|
101 |
// INFO_PRINTF2(_L("CT_LbsNetSimStep::SetCallbackFlag: setting callback flag 0x%x"), aCallbackFlag);
|
|
102 |
iCallbackFlags |= aCallbackFlag;
|
|
103 |
}
|
|
104 |
|
|
105 |
|
|
106 |
/** Used to determine which callback or callbacks have been fired.
|
|
107 |
*/
|
|
108 |
TBool CT_LbsNetSimStep::TestCallbackFlags(TLbsCallbackFlags aExpectedFlags)
|
|
109 |
{
|
|
110 |
if (iCallbackFlags == aExpectedFlags)
|
|
111 |
{
|
|
112 |
return ETrue;
|
|
113 |
}
|
|
114 |
return EFalse;
|
|
115 |
}
|
|
116 |
|
|
117 |
|
|
118 |
/** Keep alive timer callback.
|
|
119 |
|
|
120 |
Check the state machine to determine when to halt the test. Once all the callbacks
|
|
121 |
have been received the test can end.
|
|
122 |
|
|
123 |
We have to call async functions from here also, as the callbacks are executed in another thread.
|
|
124 |
*/
|
|
125 |
void CT_LbsNetSimStep::HandleTimerL(TInt aTimerId, const TTime& aTargetTime)
|
|
126 |
{
|
|
127 |
// Not used.
|
|
128 |
(void)aTimerId;
|
|
129 |
(void)aTargetTime;
|
|
130 |
|
|
131 |
if(KAbortTimerId == aTimerId)
|
|
132 |
{
|
|
133 |
INFO_PRINTF1(_L("Abort timer fired"));
|
|
134 |
iState = EAborted;
|
|
135 |
iKeepAliveTimer->Cancel();
|
|
136 |
CActiveScheduler::Stop();
|
|
137 |
}
|
|
138 |
else
|
|
139 |
{
|
|
140 |
// Check for test finish.
|
|
141 |
|
|
142 |
ASSERT(aTimerId == KKeepAliveTimerId);
|
|
143 |
// We stop test from here when in the correct state and, there should not be anything outstanding.
|
|
144 |
if (iState == EWaiting && TestCallbackFlags(iFlagsToHaltOn))
|
|
145 |
{
|
|
146 |
if(iExtendedTimerInterval.Int()) // we need an extended timer
|
|
147 |
{
|
|
148 |
INFO_PRINTF1(_L("Starting extended timer"));
|
|
149 |
iState = EExtendedWaiting;
|
|
150 |
iKeepAliveTimer->SetTimer(iExtendedTimerInterval);
|
|
151 |
}
|
|
152 |
else
|
|
153 |
{
|
|
154 |
iState = EDone;
|
|
155 |
iAbortTimer->Cancel(); // note: this is ok since it will do nothing if timer never started
|
|
156 |
CActiveScheduler::Stop();
|
|
157 |
}
|
|
158 |
}
|
|
159 |
// expected callbacks have all fired, but waiting for an extended period of time before stopping
|
|
160 |
else if(iState == EExtendedWaiting)
|
|
161 |
{
|
|
162 |
INFO_PRINTF1(_L("Extended timer fired"));
|
|
163 |
iState = EDone;
|
|
164 |
iAbortTimer->Cancel();
|
|
165 |
CActiveScheduler::Stop();
|
|
166 |
}
|
|
167 |
// Keep going, still waiting for callbacks.
|
|
168 |
else
|
|
169 |
{
|
|
170 |
TTimeIntervalMicroSeconds32 interval(KLbsKeepAlivePeriod);
|
|
171 |
|
|
172 |
iKeepAliveTimer->SetTimer(interval);
|
|
173 |
}
|
|
174 |
}
|
|
175 |
}
|
|
176 |
|
|
177 |
|
|
178 |
/** NetSim callbacks.
|
|
179 |
*/
|
|
180 |
void CT_LbsNetSimStep::Connected()
|
|
181 |
{
|
|
182 |
INFO_PRINTF1(_L("Got - NetSim Connect - Callback Event."));
|
|
183 |
|
|
184 |
SetCallbackFlag(KLbsCallback_NetSim_Got_Connect);
|
|
185 |
|
|
186 |
iState = EWaiting;
|
|
187 |
}
|
|
188 |
|
|
189 |
|
|
190 |
void CT_LbsNetSimStep::Disconnected()
|
|
191 |
{
|
|
192 |
INFO_PRINTF1(_L("Got - NetSim Notify Disconnected - Callback Event."));
|
|
193 |
}
|
|
194 |
|
|
195 |
|
|
196 |
void CT_LbsNetSimStep::NotifyRegisterLcsMoLr(const TDesC& aData)
|
|
197 |
{
|
|
198 |
(void)aData;
|
|
199 |
|
|
200 |
INFO_PRINTF1(_L("Got - NetSim Notify Register Lcs MoLr - Callback Event."));
|
|
201 |
SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyRegisterLcsMoLr);
|
|
202 |
}
|
|
203 |
|
|
204 |
|
|
205 |
void CT_LbsNetSimStep::NotifyReleaseLcsMoLr(TInt aReason)
|
|
206 |
{
|
|
207 |
(void)aReason;
|
|
208 |
|
|
209 |
INFO_PRINTF1(_L("Got - NetSim Notify Release Lcs MoLr - Callback Event."));
|
|
210 |
SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyReleaseLcsMoLr);
|
|
211 |
}
|
|
212 |
|
|
213 |
|
|
214 |
void CT_LbsNetSimStep::NotifyMeasurementControlLocation(const TPositionInfo& aPosition,
|
|
215 |
const RLbsAssistanceDataBuilderSet& aData,
|
|
216 |
const TLbsNetPosRequestQuality& aQuality)
|
|
217 |
{
|
|
218 |
(void)aPosition;
|
|
219 |
(void)aData;
|
|
220 |
(void)aQuality;
|
|
221 |
|
|
222 |
INFO_PRINTF1(_L("Got - NetSim Notify Measurement Control Location - Callback Event."));
|
|
223 |
SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyMeasurementControlLocation);
|
|
224 |
}
|
|
225 |
|
|
226 |
|
|
227 |
void CT_LbsNetSimStep::NotifyReleaseLcsLocationNotification(const CLbsNetworkProtocolBase::TLbsPrivacyResponse& aResult)
|
|
228 |
{
|
|
229 |
(void)aResult;
|
|
230 |
|
|
231 |
INFO_PRINTF1(_L("Got - NetSim Notify Release Lcs Location Notification - Callback Event."));
|
|
232 |
SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyReleaseLcsLocationNotification);
|
|
233 |
}
|
|
234 |
|
|
235 |
|
|
236 |
void CT_LbsNetSimStep::NotifyFacilityLcsMoLrResult(TInt aReason, const TPositionInfo& aPosition)
|
|
237 |
{
|
|
238 |
(void)aReason;
|
|
239 |
(void)aPosition;
|
|
240 |
|
|
241 |
INFO_PRINTF1(_L("Got - NetSim Notify Facility Lcs MoLr Result - Callback Event."));
|
|
242 |
SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyFacilityLcsMoLrResult);
|
|
243 |
}
|
|
244 |
|
|
245 |
|
|
246 |
void CT_LbsNetSimStep::NotifyMeasurementReportLocation(const TPositionInfo& aPosition)
|
|
247 |
{
|
|
248 |
(void)aPosition;
|
|
249 |
|
|
250 |
INFO_PRINTF1(_L("Got - Net Sim Notify Measurement Report - Callback Event."));
|
|
251 |
SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyMeasurementReportLocation);
|
|
252 |
}
|
|
253 |
|
|
254 |
|
|
255 |
void CT_LbsNetSimStep::NotifyMeasurementReportRequestMoreAssistanceData(const TLbsAssistanceDataGroup& aFilter)
|
|
256 |
{
|
|
257 |
(void)aFilter;
|
|
258 |
|
|
259 |
INFO_PRINTF1(_L("Got - Net Sim Notify Measurement Report Request More Assistance Data - Callback Event."));
|
|
260 |
SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyMeasurementReportRequestMoreAssistanceData);
|
|
261 |
}
|
|
262 |
|
|
263 |
|
|
264 |
void CT_LbsNetSimStep::NotifyMeasurementReportControlFailure(TInt aReason)
|
|
265 |
{
|
|
266 |
INFO_PRINTF2(_L("Got - Net Sim Notify Measurement Report Control Failure - Callback Event. Reason = %d"), aReason);
|
|
267 |
SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyMeasurementReportControlFailure);
|
|
268 |
}
|
|
269 |
|
|
270 |
void CT_LbsNetSimStep::NotifyError(MLbsNetSimTestObserver::EFunction aFunction, int aError)
|
|
271 |
{
|
|
272 |
INFO_PRINTF3(_L("Got - Net Sim Notify Error - Callback Event. Function = %d, Error = %d"), aFunction, aError);
|
|
273 |
SetCallbackFlag(KLbsCallback_NetSim_Got_NotifyError);
|
|
274 |
}
|
|
275 |
|
|
276 |
void CT_LbsNetSimStep::ProcessMeasurementControlLocationError(TInt aError)
|
|
277 |
{
|
|
278 |
INFO_PRINTF2(_L("Got - Net Sim Process Measurement Control Location Error - Callback Event. Reason = %d"), aError);
|
|
279 |
SetCallbackFlag(KLbsCallback_NetSim_Got_ProcessMeasurementControlLocationError);
|
|
280 |
}
|