author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 17 Sep 2010 08:37:32 +0300 | |
changeset 60 | 9a7e3d5f461a |
parent 36 | b47902b73a93 |
permissions | -rw-r--r-- |
36 | 1 |
// Copyright (c) 2007-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 |
// This is the class implementation for the Module Information Tests |
|
15 |
// EPOC includes.sue |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
// LBS includes. |
|
20 |
#include <lbssatellite.h> |
|
21 |
#include <lbs/lbsnetprotocolbase.h> |
|
22 |
#include <lbs/lbsassistancedatabuilderset.h> |
|
23 |
#include <lbs/lbsloccommon.h> |
|
24 |
#include <lbs/lbsx3p.h> |
|
25 |
#include <lbs/lbsnetprotocolbase.h> |
|
26 |
#include <lbs/lbslocdatasourceclasstypes.h> |
|
27 |
#include <lbs/lbslocdatasourcegpsbase.h> |
|
28 |
#include <lbs/epos_cposmodules.h> |
|
29 |
#include <lbs/epos_cposmoduleupdate.h> |
|
30 |
#include <lbs/epos_cposmoduleidlist.h> |
|
31 |
#include <e32math.h> |
|
32 |
#include <e32property.h> |
|
33 |
#include "lbsnetinternalapi.h" |
|
34 |
#include "LbsInternalInterface.h" |
|
35 |
#include "LbsExtendModuleInfo.h" |
|
36 |
#include "lbsdevloggermacros.h" |
|
37 |
||
38 |
// LBS test includes. |
|
39 |
#include "ctlbsmolrtracking.h" |
|
40 |
#include <lbs/test/tlbsutils.h> |
|
41 |
#include "argutils.h" |
|
42 |
||
43 |
#include <lbs/test/activeyield.h> |
|
44 |
||
60
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
45 |
const TInt KSmallDelta = 800 * 1000; // 800 ms |
36 | 46 |
|
47 |
/** |
|
48 |
Static Constructor |
|
49 |
*/ |
|
50 |
CT_LbsMolrTracking* CT_LbsMolrTracking::New(CT_LbsHybridMOLRServer& aParent) |
|
51 |
{ |
|
52 |
// Note the lack of ELeave. |
|
53 |
// This means that having insufficient memory will return NULL; |
|
54 |
CT_LbsMolrTracking* testStep = new CT_LbsMolrTracking(aParent); |
|
55 |
if (testStep) |
|
56 |
{ |
|
57 |
TInt err = KErrNone; |
|
58 |
||
59 |
TRAP(err, testStep->ConstructL()); |
|
60 |
if (err) |
|
61 |
{ |
|
62 |
delete testStep; |
|
63 |
testStep = NULL; |
|
64 |
} |
|
65 |
} |
|
66 |
return testStep; |
|
67 |
} |
|
68 |
||
69 |
||
70 |
/** |
|
71 |
* Constructor |
|
72 |
*/ |
|
73 |
CT_LbsMolrTracking::CT_LbsMolrTracking(CT_LbsHybridMOLRServer& aParent) |
|
74 |
: CT_LbsHybridMOLRStep(aParent), |
|
75 |
iAdminGpsMode(CLbsAdmin::EGpsModeUnknown), |
|
76 |
iGPSModeNotSupported(EFalse), |
|
77 |
iSpecialTestMode(0) |
|
78 |
{ |
|
79 |
SetTestStepName(KLbsMolrTracking); |
|
80 |
} |
|
81 |
||
82 |
||
83 |
void CT_LbsMolrTracking::ConstructL() |
|
84 |
{ |
|
85 |
// Create the base class objects. |
|
86 |
CT_LbsHybridMOLRStep::ConstructL(); |
|
87 |
} |
|
88 |
||
89 |
/** |
|
90 |
* Destructor |
|
91 |
*/ |
|
92 |
CT_LbsMolrTracking::~CT_LbsMolrTracking() |
|
93 |
{ |
|
94 |
TRAP_IGNORE(doTestStepPostambleL()); |
|
95 |
} |
|
96 |
||
97 |
/** |
|
98 |
Things read from the ini file: |
|
99 |
- Network Method (1 - TB, 2 - TBTA, 3 - TA, 4 - TATB) |
|
100 |
- Planned Positions Originator (used in hybrid to decide where the position should |
|
101 |
come from. Same for all positions returned, 1 - Module, 2 - Network) |
|
102 |
- Could have checks for the module modes if wanted (optional, doesn't affect the test) |
|
103 |
-first argument one of: 1 - PTB, 2 - ATB, 3 - Autonomous, 4 - PTA, 5 - ATA |
|
104 |
-second and third argument can be 1 - Positions, 2 - Measurments |
|
105 |
- For each client the following information can be provided: |
|
106 |
- the starting delay, represented by two numbers: |
|
107 |
* the first one specifies after which network session to start - default is 0 |
|
108 |
* The second one specifies after which step in the network to start - default is 0; |
|
109 |
For a list of the network steps see ctlbsnetprotocol.h |
|
110 |
- the number of NPUDs, default is one NPUD. One NPUD means not tracking, more than |
|
111 |
that means the client is tracking |
|
112 |
- the positioner options: interval, max fix time, max age, partial accepted. |
|
113 |
Default all zero and partial not accepted |
|
114 |
- whether the client's NPUD request should be cancelled and at what stage |
|
115 |
Default to not cancelled |
|
116 |
The number of clients is determined from how many entries are that contain |
|
117 |
client details. If there are no entries one default client is used. The information |
|
118 |
missing from an entry will be assumed to be default. If either the tracking interval |
|
119 |
or the number of NPUDs is set to indicate no tracking then this client will not |
|
120 |
do any tracking. |
|
121 |
||
122 |
NOTE: The only way a client can do more NPUDs is if it's doing tracking |
|
123 |
NOTE: The Planned Position Originator has to be provided for all tests. Logic to |
|
124 |
work it out when not running in hybrid hasn't been provided in the test yet |
|
125 |
||
126 |
TODO: Add some position checking and make the network position change |
|
127 |
TODO: Add logic to deal with the max fix time bigger than the interval and positions coming in |
|
128 |
overlapping windows |
|
129 |
TODO: Sort out the PM returning a reference position in the right modes |
|
130 |
TODO: Checking of status changes for PM none <-> tracking |
|
131 |
||
132 |
Example of ini file entry: |
|
133 |
[TEST] |
|
134 |
agps_module_update_file = c:\testdata\configs\test.ini |
|
135 |
$update,3,0,NAN,NAN,NAN,NAN,NAN* |
|
136 |
$update,1,0,49.2,3.5,50,20,20* |
|
137 |
$update,1,0,NAN,NAN,NAN,NAN,NAN* |
|
138 |
$update,1,0,49.3,3.5,50,20,20* |
|
139 |
$update,1,0,NAN,NAN,NAN,NAN,NAN* |
|
140 |
$update,1,0,49.4,3.5,50,20,20* |
|
141 |
$update,1,0,NAN,NAN,NAN,NAN,NAN* |
|
142 |
$update,1,0,49.4,3.4,50,20,20* |
|
143 |
$update,1,0,NAN,NAN,NAN,NAN,NAN* |
|
144 |
$update,1,0,49.4,3.3,50,20,20* |
|
145 |
$update,1,0,NAN,NAN,NAN,NAN,NAN* |
|
146 |
$update,1,0,49.5,3.3,50,20,20* |
|
147 |
// The network will request TB |
|
148 |
NetworkMethod = 1 |
|
149 |
// It is expected that the module will return the position |
|
150 |
PositionOriginator = 1 |
|
151 |
// The module should be set to PTB and then not set again (this is optional - for additional checking) |
|
152 |
// PTB |
|
153 |
$modulemodes,1* |
|
154 |
// The client information |
|
155 |
// first client: session ID delay = 0, session step delay = 0, NPUDs = 4, interval = 10s, time out = 5s, max age = 0s, accept partial = false |
|
156 |
$clientdetails,0,0,4,10000000,5000000,0,false* |
|
157 |
// second client: session ID delay = 1, session step delay = 4, NPUDs = 3, interval = 8s, time out = 3s, max age = 0s, accept partial = false |
|
158 |
$clientdetails,1,4,3,8000000,3000000,0,false* |
|
159 |
// third client: session ID delay = 1, session step delay = 0, NPUDs = 1, interval = 0s, time out = 5s, max age = 0s, accept partial = false |
|
160 |
$clientdetails,1,0,1,0,5000000,0,false* |
|
161 |
// fourth client: session ID delay = 4, session step delay = 3, NPUDs = 1 (so no tracking) |
|
162 |
$clientdetails,4,3,1* |
|
163 |
// fifth client: session ID delay = 4, session step delay = 3, no tracking |
|
164 |
$clientdetails,4,3* |
|
165 |
// sixth client: no delay, no tracking (default client) |
|
166 |
$clientdetails* |
|
167 |
// seventh client: session ID delay = 0, session step delay = 0, NPUDs = 2, interval = 5s, time out = 5s, max age = 0s, accept partial = false, cancel = true, cancel session ID = 1, cancel session step = 3 |
|
168 |
$clientdetails,0,0,2,5000000,5000000,0,false,cancel,1,3* |
|
169 |
||
170 |
*/ |
|
171 |
TVerdict CT_LbsMolrTracking::doTestStepPreambleL() |
|
172 |
{ |
|
173 |
INFO_PRINTF1(_L(">>CT_LbsMolrTracking::doTestStepPreambleL()")); |
|
174 |
CT_LbsHybridMOLRStep::doTestStepPreambleL(); |
|
175 |
||
176 |
// Get the GPS mode set in the Admin |
|
177 |
CLbsAdmin* admin = CLbsAdmin::NewL(); |
|
178 |
CleanupStack::PushL(admin); |
|
179 |
||
180 |
TESTL(KErrNone == admin->Get(KLbsSettingRoamingGpsMode, iAdminGpsMode)); |
|
181 |
CleanupStack::PopAndDestroy(admin); |
|
182 |
||
183 |
// Set the test up so it expects that the GPS mode won't be supported if there is an incompatibility |
|
184 |
TPositionModuleInfoExtended::TDeviceGpsModeCapabilities deviceCapabilities; |
|
185 |
TInt err = LbsModuleInfo::GetDeviceCapabilities(KLbsGpsLocManagerUid, deviceCapabilities); |
|
186 |
||
187 |
if(!(deviceCapabilities & TPositionModuleInfoExtended::EDeviceGpsModeSimultaneousTATB) && !(deviceCapabilities & TPositionModuleInfoExtended::EDeviceGpsModeTerminalAssisted)) |
|
188 |
{ |
|
189 |
if(iAdminGpsMode == CLbsAdmin::EGpsPreferTerminalAssisted || |
|
190 |
iAdminGpsMode == CLbsAdmin::EGpsAlwaysTerminalAssisted) |
|
191 |
{ |
|
192 |
iGPSModeNotSupported = ETrue; |
|
193 |
} |
|
194 |
} |
|
195 |
if(!(deviceCapabilities & TPositionModuleInfoExtended::EDeviceGpsModeSimultaneousTATB) && !(deviceCapabilities & TPositionModuleInfoExtended::EDeviceGpsModeTerminalBased)) |
|
196 |
{ |
|
197 |
if(iAdminGpsMode == CLbsAdmin::EGpsPreferTerminalBased || |
|
198 |
iAdminGpsMode == CLbsAdmin::EGpsAlwaysTerminalBased || |
|
199 |
iAdminGpsMode == CLbsAdmin::EGpsAutonomous) |
|
200 |
{ |
|
201 |
iGPSModeNotSupported = ETrue; |
|
202 |
} |
|
203 |
} |
|
204 |
||
205 |
SetTestStepResult(EPass); |
|
206 |
T_LbsUtils utils; |
|
207 |
||
208 |
iNetworkProtocol = CT_LbsNetProtocol::NewL(*this, *this); |
|
209 |
// Get the Network Method |
|
210 |
_LIT(KNetworkMethod, "NetworkMethod"); |
|
211 |
TInt networkMethodInt; |
|
212 |
if(GetIntFromConfig(ConfigSection(), KNetworkMethod, networkMethodInt)) |
|
213 |
{ |
|
214 |
iNetworkProtocol->SetNetworkMethod(networkMethodInt); |
|
215 |
} |
|
216 |
else |
|
217 |
{ |
|
218 |
INFO_PRINTF1(_L("CT_LbsMolrTracking::doTestStepPreambleL() - FAILED: no network method configured")); |
|
219 |
TEST(EFalse); |
|
220 |
} |
|
221 |
||
222 |
// Get the position originator |
|
223 |
_LIT(KPositionOriginator, "PositionOriginator"); |
|
224 |
TInt positionOriginatorInt; |
|
225 |
if(GetIntFromConfig(ConfigSection(), KPositionOriginator, positionOriginatorInt)) |
|
226 |
{ |
|
227 |
iNetworkProtocol->SetPlannedPositionOriginator(positionOriginatorInt); |
|
228 |
} |
|
229 |
else |
|
230 |
{ |
|
231 |
INFO_PRINTF1(_L("CT_LbsMolrTracking::doTestStepPreambleL() - FAILED: no position originator configured")); |
|
232 |
TEST(EFalse); |
|
233 |
} |
|
234 |
||
235 |
// Get the SpecialTestModemode setting ... 0 means not in a LastKnownPosition mode |
|
236 |
_LIT(KLastKnownPosition, "SpecialTestMode"); |
|
237 |
TInt specialTestModeInt; |
|
238 |
if(GetIntFromConfig(ConfigSection(), KLastKnownPosition, specialTestModeInt)) |
|
239 |
{ |
|
240 |
iSpecialTestMode = specialTestModeInt; |
|
241 |
} |
|
242 |
else |
|
243 |
{ |
|
244 |
INFO_PRINTF1(_L("CT_LbsMolrTracking::doTestStepPreambleL() - no SpecialTestMode in .ini section - setting mode to disabled")); |
|
245 |
iSpecialTestMode =0; |
|
246 |
} |
|
247 |
||
248 |
TPtrC configFileName; |
|
249 |
_LIT(KUpdateOptionsFile, "agps_module_update_file"); |
|
250 |
TEST(GetStringFromConfig(ConfigSection(), KUpdateOptionsFile, configFileName)); |
|
251 |
RArray<TCTClientDetails> clientDetailsArray; |
|
252 |
CleanupClosePushL(clientDetailsArray); |
|
253 |
utils.GetConfigured_ClientDetailsL(configFileName, ConfigSection(), clientDetailsArray); |
|
254 |
||
255 |
||
256 |
for(TInt index = 1; index <= clientDetailsArray.Count(); ++index) |
|
257 |
{ |
|
258 |
CT_LbsTestActiveManager* clientTestManager = CT_LbsTestActiveManager::NewL(index, *this, CActive::EPriorityStandard, *this); |
|
259 |
iClientTestManagers.AppendL(clientTestManager); |
|
260 |
} |
|
261 |
||
262 |
for(TInt index = 0; index < clientDetailsArray.Count(); ++index) |
|
263 |
{ |
|
264 |
CT_ClientData* client = new(ELeave) CT_ClientData(clientDetailsArray[index].iSessionIdDelay, clientDetailsArray[index].iSessionStepDelay, clientDetailsArray[index].iCancelRequest, clientDetailsArray[index].iSessionIdCancel, clientDetailsArray[index].iSessionStepCancel, clientDetailsArray[index].iNumberOfNPUDs, |
|
265 |
clientDetailsArray[index].iUpdateOptions, clientDetailsArray[index].iPsyId, clientDetailsArray[index].iExpectedError); |
|
266 |
iClients.AppendL(client); |
|
267 |
} |
|
268 |
CleanupStack::PopAndDestroy(&clientDetailsArray); |
|
269 |
||
270 |
return TestStepResult(); |
|
271 |
} |
|
272 |
||
273 |
TVerdict CT_LbsMolrTracking::doTestStepPostambleL() |
|
274 |
{ |
|
275 |
INFO_PRINTF1(_L(">>CT_LbsMolrTracking::doTestStepPostambleL()")); |
|
276 |
iClients.ResetAndDestroy(); |
|
277 |
iClientTestManagers.ResetAndDestroy(); |
|
278 |
||
279 |
if(iNetworkProtocol) |
|
280 |
{ |
|
281 |
delete iNetworkProtocol; |
|
282 |
iNetworkProtocol = NULL; |
|
283 |
} |
|
284 |
||
285 |
iAdminGpsMode = CLbsAdmin::EGpsModeUnknown; |
|
286 |
CT_LbsHybridMOLRStep::doTestStepPostambleL(); |
|
287 |
return TestStepResult(); |
|
288 |
} |
|
289 |
||
290 |
TVerdict CT_LbsMolrTracking::doTestStepL() |
|
291 |
{ |
|
292 |
INFO_PRINTF1(_L("CT_LbsMolrTracking::doTestStepL()")); |
|
293 |
// Stop the test if the preamble failed |
|
294 |
TESTL(TestStepResult() == EPass); |
|
295 |
||
296 |
iNetworkProtocol->StartNetworkL(); |
|
297 |
||
298 |
CActiveScheduler::Start(); |
|
299 |
return TestStepResult(); |
|
300 |
} |
|
301 |
||
302 |
void CT_LbsMolrTracking::OnReadyL(TInt aObjectId) |
|
303 |
{ |
|
304 |
if(aObjectId > 0 && aObjectId <= iClients.Count()) |
|
305 |
{ |
|
306 |
DoClientStepL(aObjectId - 1); |
|
307 |
return; |
|
308 |
} |
|
309 |
||
310 |
User::Leave(KErrCorrupt); |
|
311 |
} |
|
312 |
||
313 |
void CT_LbsMolrTracking::OnTimedOutL(TInt aObjectId) |
|
314 |
{ |
|
315 |
INFO_PRINTF2(_L("Client number %d timed out waiting for a position"), aObjectId); |
|
316 |
User::Leave(KErrTimedOut); |
|
317 |
} |
|
318 |
||
319 |
void CT_LbsMolrTracking::OnGetLastKnownPositionL(TInt aObjectId, TInt32 aErr, const TPositionInfoBase& /*aPosInfo*/) |
|
320 |
{ |
|
321 |
INFO_PRINTF2(_L("CT_LbsMolrTracking::OnGetLastKnownPositionL() >> LKNP() complete with %d"), aErr); |
|
322 |
||
323 |
CT_ClientData& client = *(iClients[aObjectId-1]); |
|
324 |
||
325 |
TInt numberOfNPUDs = client.iNumberOfNPUDs; |
|
326 |
TInt positionsReceived = client.iPositionsReceived; |
|
327 |
||
328 |
if (iSpecialTestMode==1) |
|
329 |
{ |
|
330 |
INFO_PRINTF1(_L("CT_LbsMolrTracking::OnGetLastKnownPosition() - Special Test for FNP delivery")); |
|
331 |
INFO_PRINTF2(_L("Client number %d received a last known position"), aObjectId); |
|
332 |
INFO_PRINTF3(_L("Client now has %d of %d positions"), positionsReceived+1, numberOfNPUDs); |
|
333 |
||
334 |
INFO_PRINTF1(_L("CT_LbsMolrTracking::OnGetLastKnownPosition() - a network calculated FNP was correctly delivered")); |
|
335 |
||
336 |
} |
|
337 |
else |
|
338 |
{ |
|
339 |
INFO_PRINTF1(_L("CT_LbsMolrTracking::OnGetLastKnownPosition() - FAILED: not expecting this call")); |
|
340 |
TESTL(EFalse); // Shouldn't see this... |
|
341 |
} |
|
342 |
||
343 |
++client.iPositionsReceived; |
|
344 |
||
345 |
if(client.iPositionsReceived == client.iNumberOfNPUDs) |
|
346 |
{ // stop this client tracking and close connection to the server also check that all the other clients have received positions as expected |
|
347 |
iClientTestManagers[aObjectId-1]->Deactivate(); |
|
348 |
||
349 |
delete client.iWatcher; |
|
350 |
client.iWatcher = NULL; |
|
351 |
client.iPositioner.Close(); |
|
352 |
client.iServer.Close(); |
|
353 |
||
354 |
} |
|
355 |
else // re-issue the request |
|
356 |
{ |
|
357 |
iClientTestManagers[aObjectId-1]->StartL(0); |
|
358 |
} |
|
359 |
||
360 |
} |
|
361 |
||
362 |
void CT_LbsMolrTracking::OnNotifyPositionUpdateL(TInt aObjectId, TInt32 aErr, const TPositionInfoBase& aPosInfo) |
|
363 |
{ |
|
364 |
RDebug::Printf("LBSLog: LocSrv -> Client%d: Deliver Position, error = %d", aObjectId, aErr); |
|
365 |
INFO_PRINTF2(_L("CT_LbsMolrTracking::OnNotifyPositionUpdate() >> NPUD() complete with %d"), aErr); |
|
366 |
if(iGPSModeNotSupported) |
|
367 |
{ |
|
368 |
TESTL(aErr == KErrNotSupported); |
|
369 |
} |
|
370 |
else |
|
371 |
{ |
|
372 |
CT_ClientData& client = *(iClients[aObjectId-1]); |
|
373 |
TTime now; |
|
374 |
now.HomeTime(); |
|
375 |
||
376 |
if(client.iRequestCancelled) |
|
377 |
{ |
|
378 |
TESTL(aErr == KErrCancel); |
|
379 |
} |
|
380 |
else if(client.iExpectedError) |
|
381 |
{ |
|
382 |
TESTL(aErr == client.iExpectedError); |
|
383 |
} |
|
384 |
else |
|
385 |
{ |
|
386 |
TInt numberOfNPUDs = client.iNumberOfNPUDs; |
|
387 |
TInt positionsReceived = client.iPositionsReceived; |
|
388 |
||
389 |
INFO_PRINTF2(_L("Client number %d received a position"), aObjectId); |
|
390 |
INFO_PRINTF3(_L("Client now has %d of %d positions"), positionsReceived+1, numberOfNPUDs); |
|
391 |
||
392 |
if (iSpecialTestMode == 2) |
|
393 |
{ |
|
394 |
||
395 |
INFO_PRINTF1(_L("testing MaxAge feature")); |
|
396 |
const TPositionInfo* lastPosReturned = static_cast<const TPositionInfo*>(&aPosInfo); |
|
397 |
TPosition pos; |
|
398 |
lastPosReturned->GetPosition(pos); |
|
399 |
||
400 |
if (client.iPositionsReceived == 0) |
|
401 |
{ // if its the first one |
|
402 |
client.iTimeOfLastPosition = pos.Time(); |
|
403 |
} |
|
404 |
else |
|
405 |
{ |
|
406 |
if (client.iTimeOfLastPosition != pos.Time()) |
|
407 |
{ |
|
408 |
INFO_PRINTF1(_L("testing MaxAge feature - FAIL! position time was not same as previous")); |
|
409 |
TESTL(EFalse); |
|
410 |
} |
|
411 |
else |
|
412 |
{ |
|
413 |
INFO_PRINTF1(_L("testing MaxAge feature - PASS! position time was same as previous")); |
|
414 |
} |
|
415 |
client.iTimeOfLastPosition = pos.Time(); |
|
416 |
} |
|
417 |
} |
|
418 |
else if (iSpecialTestMode==3) // testing early complete behaviour when have multiple client requests |
|
419 |
{ |
|
420 |
if ( (aErr == KPositionEarlyComplete) || (aErr == KErrNone)) |
|
421 |
{ |
|
422 |
INFO_PRINTF2(_L("testing early complete behaviour got correct error%d"), aErr); |
|
423 |
} |
|
424 |
else |
|
425 |
{ |
|
426 |
INFO_PRINTF2(_L("testing early complete behaviour got error %d"), aErr); |
|
427 |
TESTL(EFalse); |
|
428 |
} |
|
429 |
} |
|
430 |
else |
|
431 |
{ |
|
432 |
// Normally it should be KErrNone |
|
433 |
TESTL(aErr == KErrNone); |
|
434 |
} |
|
435 |
||
436 |
// Verify position. |
|
437 |
//CT_ClientData& client = *(iClients[aObjectId-1]); |
|
438 |
||
439 |
TESTL(aPosInfo.PositionClassType() == EPositionInfoClass); |
|
440 |
if(iNetworkProtocol->PlannedPositionOriginator() == CT_LbsNetProtocol::EPositionOriginatorModule) |
|
441 |
{ |
|
442 |
if(client.iAutonomousPsy) |
|
443 |
{ |
|
444 |
INFO_PRINTF2(_L("Autonomous GPS client got position with techtype = %d"), aPosInfo.PositionMode()); |
|
445 |
TESTL( (aPosInfo.PositionMode() == (TPositionModuleInfo::ETechnologyTerminal)) || (aPosInfo.PositionMode() == (TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted))); |
|
446 |
} |
|
447 |
else |
|
448 |
{ |
|
449 |
TESTL(aPosInfo.PositionMode() == (TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted)); |
|
450 |
} |
|
451 |
} |
|
452 |
if(iNetworkProtocol->PlannedPositionOriginator() == CT_LbsNetProtocol::EPositionOriginatorNetwork) |
|
453 |
{ |
|
454 |
if (iSpecialTestMode==3) |
|
455 |
{ |
|
456 |
INFO_PRINTF1(_L("testing early complete behaviour - don't check tech type")); |
|
457 |
} |
|
458 |
else |
|
459 |
{ |
|
460 |
TESTL(aPosInfo.PositionMode() == (TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted)); |
|
461 |
} |
|
462 |
} |
|
463 |
||
464 |
if(iExpectedApiBehaviour == EApiVariant1) |
|
465 |
{ |
|
466 |
if(client.iPositionsReceived == 0) |
|
467 |
{ // record the time when a first position is received by the client |
|
468 |
client.iTimeOfInitialPosition.HomeTime(); |
|
469 |
} |
|
470 |
else |
|
471 |
{ // make sure that the position was received in the right window |
|
472 |
TTimeIntervalMicroSeconds interval = now.MicroSecondsFrom(client.iTimeOfInitialPosition); |
|
473 |
||
474 |
if (iSpecialTestMode==3) // testing early complete behaviour when have multiple client requests |
|
475 |
{ |
|
476 |
INFO_PRINTF1(_L("testing early complete behaviour - don't check arrival time")); |
|
477 |
||
478 |
} |
|
479 |
else |
|
480 |
{ |
|
481 |
if (client.iUpdateOptions.UpdateInterval().Int64()) |
|
482 |
{ // if tracking |
|
483 |
if(interval.Int64() < client.iUpdateOptions.UpdateInterval().Int64() * client.iPositionsReceived && |
|
484 |
interval.Int64()+KSmallDelta >= client.iUpdateOptions.UpdateInterval().Int64() * client.iPositionsReceived) |
|
485 |
{ // if the time is slightly before the window then allow for possible delays in the test framework |
|
486 |
interval = interval.Int64() + KSmallDelta; |
|
487 |
} |
|
488 |
if(interval.Int64() % client.iUpdateOptions.UpdateInterval().Int64() > client.iUpdateOptions.UpdateTimeOut().Int64() && |
|
489 |
(interval.Int64()-KSmallDelta) % client.iUpdateOptions.UpdateInterval().Int64() <= client.iUpdateOptions.UpdateTimeOut().Int64()) |
|
490 |
{ // if the time is slightly after the window then allow for possible delays in the test framework |
|
491 |
interval = interval.Int64() - KSmallDelta; |
|
492 |
} |
|
493 |
TESTL(interval.Int64() / client.iUpdateOptions.UpdateInterval().Int64() == client.iPositionsReceived); |
|
494 |
TESTL(interval.Int64() % client.iUpdateOptions.UpdateInterval().Int64() <= client.iUpdateOptions.UpdateTimeOut().Int64()); |
|
495 |
} |
|
496 |
} |
|
497 |
} |
|
498 |
} |
|
499 |
else |
|
500 |
{ // variant2 api behaviour |
|
501 |
if(client.iPositionsReceived > 0) // make sure that the position was received in the right window |
|
502 |
{ |
|
503 |
TTimeIntervalMicroSeconds interval = now.MicroSecondsFrom(client.iTimeOfPreviousPosition); |
|
504 |
if (iSpecialTestMode==3) // testing early complete behaviour when have multiple client requests |
|
505 |
{ |
|
506 |
INFO_PRINTF1(_L("testing early complete behaviour - don't check arrival time")); |
|
507 |
} |
|
508 |
else |
|
509 |
{ |
|
510 |
if (client.iUpdateOptions.UpdateInterval().Int64()) |
|
511 |
{ // if tracking |
|
512 |
if(interval.Int64() < client.iUpdateOptions.UpdateInterval().Int64() && |
|
513 |
interval.Int64()+KSmallDelta >= client.iUpdateOptions.UpdateInterval().Int64()) |
|
514 |
{ // if the time is slightly before the window then allow for possible delays in the test framework |
|
515 |
interval = interval.Int64() + KSmallDelta; |
|
516 |
} |
|
517 |
if(interval.Int64() - client.iUpdateOptions.UpdateInterval().Int64() > client.iUpdateOptions.UpdateTimeOut().Int64() && |
|
518 |
(interval.Int64()-KSmallDelta) - client.iUpdateOptions.UpdateInterval().Int64() <= client.iUpdateOptions.UpdateTimeOut().Int64()) |
|
519 |
{ // if the time is slightly after the window then allow for possible delays in the test framework |
|
520 |
interval = interval.Int64() - KSmallDelta; |
|
521 |
} |
|
522 |
TESTL(interval.Int64() >= client.iUpdateOptions.UpdateInterval().Int64()); |
|
523 |
TESTL(interval.Int64() - client.iUpdateOptions.UpdateInterval().Int64() <= client.iUpdateOptions.UpdateTimeOut().Int64()); |
|
524 |
} |
|
525 |
} |
|
526 |
} |
|
527 |
client.iTimeOfPreviousPosition.HomeTime(); |
|
528 |
} |
|
529 |
} |
|
530 |
||
531 |
++client.iPositionsReceived; |
|
532 |
||
533 |
if(client.iPositionsReceived == client.iNumberOfNPUDs) |
|
534 |
{ // stop this client tracking and close connection to the server also check that all the other clients have received positions as expected |
|
535 |
iClientTestManagers[aObjectId-1]->Deactivate(); |
|
536 |
||
537 |
delete client.iWatcher; |
|
538 |
client.iWatcher = NULL; |
|
539 |
client.iPositioner.Close(); |
|
540 |
client.iServer.Close(); |
|
541 |
||
542 |
TBool moreActiveClients(EFalse); |
|
543 |
||
544 |
if(iSpecialTestMode==3) // testing early complete behaviour when have multiple client requests |
|
545 |
{ |
|
546 |
INFO_PRINTF1(_L("testing early complete behaviour - don't check arrival times are in tracking windows")); |
|
547 |
} |
|
548 |
else |
|
549 |
{ |
|
550 |
for(TUint index = 0; index < iClients.Count(); ++index) |
|
551 |
{ // for each client check that the positions were received in the right window until now |
|
552 |
if(!iClientTestManagers[index]->IsDeactivated()) |
|
553 |
{ |
|
554 |
moreActiveClients = ETrue; |
|
555 |
CT_ClientData& clientToCheck = *(iClients[index]); |
|
556 |
if((!(clientToCheck.iRequestCancelled)) && (clientToCheck.iPositionsReceived > 0) && !(clientToCheck.iExpectedError)) |
|
557 |
{ |
|
558 |
if(iExpectedApiBehaviour == EApiVariant1) |
|
559 |
{ |
|
560 |
TTimeIntervalMicroSeconds interval = now.MicroSecondsFrom(clientToCheck.iTimeOfInitialPosition); |
|
561 |
if (client.iUpdateOptions.UpdateInterval().Int64()) |
|
562 |
{ |
|
563 |
||
564 |
TESTL(interval.Int64() / clientToCheck.iUpdateOptions.UpdateInterval().Int64() == clientToCheck.iPositionsReceived-1 || // either the client received all the positions already |
|
565 |
(interval.Int64() / clientToCheck.iUpdateOptions.UpdateInterval().Int64() == clientToCheck.iPositionsReceived && // or the window to receive a position is now and it's RunL didn't get called yet |
|
566 |
interval.Int64() % clientToCheck.iUpdateOptions.UpdateInterval().Int64() <= clientToCheck.iUpdateOptions.UpdateTimeOut().Int64())); |
|
567 |
} |
|
568 |
} |
|
569 |
else |
|
570 |
{ |
|
571 |
TTimeIntervalMicroSeconds interval = now.MicroSecondsFrom(clientToCheck.iTimeOfPreviousPosition); |
|
572 |
if (client.iUpdateOptions.UpdateInterval().Int64()) |
|
573 |
{ |
|
574 |
TESTL(interval.Int64() - clientToCheck.iUpdateOptions.UpdateInterval().Int64() - KSmallDelta <= |
|
575 |
clientToCheck.iUpdateOptions.UpdateTimeOut().Int64()); |
|
576 |
} |
|
577 |
} |
|
578 |
} |
|
579 |
} |
|
580 |
} |
|
581 |
} |
|
582 |
||
583 |
if(!moreActiveClients) |
|
584 |
{ // if all the clients finished then tell the network to close the session |
|
585 |
iNetworkProtocol->SignalClientsFinished(); |
|
586 |
} |
|
587 |
} |
|
588 |
else |
|
589 |
{ |
|
590 |
// re-issue the request |
|
591 |
iClientTestManagers[aObjectId-1]->StartL(0); |
|
592 |
} |
|
593 |
} |
|
594 |
} |
|
595 |
||
596 |
void CT_LbsMolrTracking::StopTest() |
|
597 |
{ |
|
598 |
CActiveScheduler::Stop(); |
|
599 |
} |
|
600 |
||
601 |
void CT_LbsMolrTracking::OnSignalNetworkStep(TInt aSessionId, TInt aSessionStep) |
|
602 |
{ |
|
603 |
for(TInt index = 0; index < iClientTestManagers.Count(); ++index) |
|
604 |
{ |
|
605 |
CT_ClientData& client = *iClients[index]; |
|
606 |
if(client.iInitialStep) |
|
607 |
{ |
|
608 |
if(aSessionId > client.iSessionIdDelay || |
|
609 |
(aSessionId == client.iSessionIdDelay && aSessionStep >= client.iSessionStepDelay)) |
|
610 |
{ |
|
611 |
iClientTestManagers[index]->StartL(0); |
|
612 |
} |
|
613 |
} |
|
614 |
if(client.iCancelRequest && !(client.iRequestCancelled)) |
|
615 |
{ |
|
616 |
INFO_PRINTF3(_L("Waiting to cancel. At network session %d, step %d"), aSessionId, aSessionStep); |
|
617 |
if(aSessionId > client.iSessionIdCancel || |
|
618 |
(aSessionId == client.iSessionIdCancel && aSessionStep >= client.iSessionStepCancel)) |
|
619 |
{ |
|
620 |
// cancel oustanding NPUD |
|
621 |
INFO_PRINTF3(_L("Cancelling Request for Client %d's NPUD %d"),index+1, client.iPositionsReceived+1); |
|
622 |
__ASSERT_DEBUG((client.iNumberOfNPUDs == client.iPositionsReceived + 1), User::Invariant()); |
|
623 |
RDebug::Printf("LBSLog: Client%d -> LocSrv : CancelRequest", index+1); |
|
624 |
client.iWatcher->CancelRequest(); |
|
625 |
client.iRequestCancelled = ETrue; |
|
626 |
} |
|
627 |
} |
|
628 |
} |
|
629 |
} |
|
630 |
||
631 |
void CT_LbsMolrTracking::DoClientStepL(TInt aIndex) |
|
632 |
{ |
|
633 |
CT_ClientData& client = *(iClients[aIndex]); |
|
634 |
const TInt KPosTimeOutDelay = 6 * 1000 * 1000; // this is so it leaves some space for delays due to other things in the test running |
|
635 |
TInt posTimeOut(KPosTimeOutDelay); |
|
636 |
||
637 |
TInt positionsReceived = client.iPositionsReceived; |
|
638 |
||
639 |
if(client.iInitialStep) |
|
640 |
{ |
|
641 |
TESTL(KErrNone == client.iServer.Connect()); |
|
642 |
TRequestStatus dbclear; |
|
643 |
client.iServer.EmptyLastKnownPositionStore(dbclear); |
|
644 |
User::WaitForRequest(dbclear); |
|
645 |
||
646 |
if(client.iPsyUid) // client wants a particular psy |
|
647 |
{ |
|
648 |
EnablePsy(client.iPsyUid); |
|
649 |
||
650 |
TPositionModuleInfo moduleInfo; |
|
651 |
||
652 |
client.iServer.GetModuleInfoById(TUid::Uid(client.iPsyUid), moduleInfo); |
|
653 |
||
654 |
if(moduleInfo.TechnologyType() == TPositionModuleInfo::ETechnologyTerminal) |
|
655 |
{ |
|
656 |
client.iAutonomousPsy = ETrue; |
|
657 |
} |
|
658 |
TESTL(KErrNone == client.iPositioner.Open(client.iServer, TUid::Uid(client.iPsyUid))); |
|
659 |
} |
|
660 |
else |
|
661 |
{ |
|
662 |
TESTL(KErrNone == client.iPositioner.Open(client.iServer)); |
|
663 |
} |
|
664 |
TPositionUpdateOptions updateOptions(client.iUpdateOptions); |
|
665 |
if(iExpectedApiBehaviour == EApiVariant2) |
|
666 |
{ // for variant 2 of the API behaviour the timeout is considered from the time of the NPUD, rather than from the target time |
|
667 |
updateOptions.SetUpdateTimeOut(updateOptions.UpdateTimeOut().Int64() + updateOptions.UpdateInterval().Int64()); |
|
668 |
} |
|
669 |
client.iPositioner.SetUpdateOptions(updateOptions); |
|
670 |
||
671 |
client.iWatcher = CPosServerWatcher::NewLC(client.iPositioner, *(iClientTestManagers[aIndex])); |
|
672 |
CleanupStack::Pop(client.iWatcher); |
|
673 |
client.iInitialStep = EFalse; |
|
674 |
posTimeOut += client.iUpdateOptions.UpdateTimeOut().Int64();; |
|
675 |
} |
|
676 |
else |
|
677 |
{ |
|
678 |
posTimeOut += client.iUpdateOptions.UpdateInterval().Int64() + client.iUpdateOptions.UpdateTimeOut().Int64(); |
|
679 |
} |
|
680 |
||
681 |
||
682 |
if ((iSpecialTestMode == 1) && (aIndex == 0) && (positionsReceived == 1)) |
|
683 |
{ |
|
684 |
INFO_PRINTF2(_L("Client number %d issuing LKNP request"), aIndex+1); |
|
685 |
client.iWatcher->IssueGetLastKnownPosition(); |
|
686 |
} |
|
687 |
else |
|
688 |
{ |
|
689 |
INFO_PRINTF2(_L("Client number %d issuing NPUD request"), aIndex+1); |
|
690 |
RDebug::Printf("LBSLog: Client%d -> LocSrv : NotifyPositionUpdate", aIndex+1); |
|
691 |
client.iWatcher->IssueNotifyPositionUpdate(); |
|
692 |
} |
|
693 |
||
694 |
||
695 |
if (iSpecialTestMode==3) |
|
696 |
{ |
|
697 |
if ((aIndex == 0) && (positionsReceived == 0)) // in this mode client 1 will immediately CompleteRequest the |
|
698 |
// NPUD. The test has contrived to have an ongoing MoLr |
|
699 |
// because client 2 has an outstanding NPUD that should not |
|
700 |
// be interfered with |
|
701 |
{ |
|
702 |
INFO_PRINTF1(_L("CompleteRequest!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")); |
|
703 |
client.iWatcher->CompleteRequest() ; |
|
704 |
} |
|
705 |
} |
|
706 |
iClientTestManagers[aIndex]->WaitForPosition(posTimeOut); |
|
707 |
} |
|
708 |
||
709 |
||
710 |
||
711 |
void CT_LbsMolrTracking::EnablePsy(TInt aPsyUid) |
|
712 |
{ |
|
713 |
CPosModules* db = CPosModules::OpenL(); |
|
714 |
CleanupStack::PushL(db); |
|
715 |
CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC(); |
|
716 |
||
717 |
CPosModuleIdList* prioList = db->ModuleIdListLC(); |
|
718 |
||
719 |
// Enable the PSY that came as an in parameter |
|
720 |
moduleUpdate->SetUpdateAvailability(ETrue); |
|
721 |
db->UpdateModuleL(TUid::Uid(aPsyUid), *moduleUpdate); |
|
722 |
||
723 |
CleanupStack::PopAndDestroy(prioList); |
|
724 |
CleanupStack::PopAndDestroy(moduleUpdate); |
|
725 |
CleanupStack::PopAndDestroy(db); |
|
726 |
} |