748
|
1 |
// Copyright (c) 2008-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 |
// This is the class implementation for the Notify Position Update Tests
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include "ctlbsclientstep_reset_assistance.h"
|
|
19 |
|
|
20 |
#include <lbs.h>
|
|
21 |
#include <lbssatellite.h>
|
|
22 |
|
|
23 |
#include "tlbsutils.h"
|
|
24 |
#include "ctlbsasyncwaiter.h"
|
|
25 |
|
|
26 |
|
|
27 |
const TTimeIntervalMicroSeconds KModuleTimeout = 6000000;//makes test module time out(which should be more than the Maxtime in lbsprofile.ini)
|
|
28 |
|
|
29 |
const TInt KNumberOfRequests = 10; // the number of requests to do to be near the average
|
|
30 |
|
|
31 |
const TInt KWaitTimeForCoolDown = 10 * 1000 * 1000; // how long to wait to make sure the integration module gets turned off
|
|
32 |
|
|
33 |
/**
|
|
34 |
* Sets a Requestor for now - TODO will be removed with new location server
|
|
35 |
*/
|
|
36 |
void CT_LbsClientStep_ResetAssistance::TempSetRequestorL()
|
|
37 |
{
|
|
38 |
User::LeaveIfError(iPositioner.SetRequestor( CRequestor::ERequestorService,
|
|
39 |
CRequestor::EFormatApplication,
|
|
40 |
_L("Tom Tom")));
|
|
41 |
}
|
|
42 |
|
|
43 |
|
|
44 |
/**
|
|
45 |
* Destructor
|
|
46 |
*/
|
|
47 |
CT_LbsClientStep_ResetAssistance::~CT_LbsClientStep_ResetAssistance()
|
|
48 |
{
|
|
49 |
delete iLbsAdmin;
|
|
50 |
}
|
|
51 |
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Constructor
|
|
55 |
*/
|
|
56 |
CT_LbsClientStep_ResetAssistance::CT_LbsClientStep_ResetAssistance(CT_LbsClientServer& aParent) : CT_LbsClientStep(aParent),iLbsAdmin(NULL),iRequestedAssData(FALSE), iReceivedAssData(FALSE)
|
|
57 |
{
|
|
58 |
|
|
59 |
SetTestStepName(KLbsClientStep_ResetAssistance);
|
|
60 |
}
|
|
61 |
|
|
62 |
|
|
63 |
/**
|
|
64 |
Static Constructor
|
|
65 |
*/
|
|
66 |
CT_LbsClientStep_ResetAssistance* CT_LbsClientStep_ResetAssistance::New(CT_LbsClientServer& aParent)
|
|
67 |
{
|
|
68 |
|
|
69 |
// Note the lack of ELeave.
|
|
70 |
// This means that having insufficient memory will return NULL;
|
|
71 |
|
|
72 |
CT_LbsClientStep_ResetAssistance* testStep = new CT_LbsClientStep_ResetAssistance(aParent);
|
|
73 |
if (testStep)
|
|
74 |
{
|
|
75 |
TInt err = KErrNone;
|
|
76 |
|
|
77 |
TRAP(err, testStep->ConstructL());
|
|
78 |
if (err)
|
|
79 |
{
|
|
80 |
delete testStep;
|
|
81 |
testStep = NULL;
|
|
82 |
}
|
|
83 |
}
|
|
84 |
return testStep;
|
|
85 |
}
|
|
86 |
|
|
87 |
|
|
88 |
void CT_LbsClientStep_ResetAssistance::ConstructL()
|
|
89 |
{
|
|
90 |
// create the admin
|
|
91 |
iLbsAdmin = CLbsAdmin::NewL();
|
|
92 |
|
|
93 |
}
|
|
94 |
|
|
95 |
//from MT_NotifyPosUpdateObserver:
|
|
96 |
/**
|
|
97 |
* Callback - called when NotifyPositionUpdate request completes
|
|
98 |
*/
|
|
99 |
|
|
100 |
void CT_LbsClientStep_ResetAssistance::NotifyPositionUpdateCallback(TRequestStatus& aStatus)
|
|
101 |
{
|
|
102 |
TInt err = aStatus.Int();
|
|
103 |
if (KErrCancel != err)
|
|
104 |
{
|
|
105 |
SetTestStepResult(EFail); // the request always gets cancelled (see test 0122)
|
|
106 |
}
|
|
107 |
CActiveScheduler::Stop();
|
|
108 |
}
|
|
109 |
|
|
110 |
/**
|
|
111 |
* @return - TVerdict code
|
|
112 |
* Override of base class pure virtual
|
|
113 |
* Our implementation only gets called if the base class doTestStepPreambleL() did
|
|
114 |
* not leave. That being the case, the current test result value will be EPass.
|
|
115 |
*/
|
|
116 |
TVerdict CT_LbsClientStep_ResetAssistance::doTestStepL()
|
|
117 |
{
|
|
118 |
// Generic test step used to test the LBS Client Notify position update API.
|
|
119 |
INFO_PRINTF1(_L(">>CT_LbsClientStep_ResetAssistance::doTestStepL()"));
|
|
120 |
|
|
121 |
if (TestStepResult()==EPass)
|
|
122 |
{
|
|
123 |
TInt err = KErrNone;
|
|
124 |
|
|
125 |
iParent.iSharedData->iTestModuleInUse = EFalse;
|
|
126 |
|
|
127 |
// Connect to self locate server.
|
|
128 |
err = iServer.Connect();
|
|
129 |
User::LeaveIfError(err);
|
|
130 |
CleanupClosePushL(iServer);
|
|
131 |
|
|
132 |
// Setup netsim.
|
|
133 |
User::LeaveIfError(OpenNetSim());
|
|
134 |
|
|
135 |
TTimeIntervalMicroSeconds resetRequestTime;
|
|
136 |
resetRequestTime = DoRequests(EFalse, ETrue);
|
|
137 |
INFO_PRINTF2(_L("Requests from warm with reset assistance data took on average %d miliseconds to complete."), (resetRequestTime.Int64()/KNumberOfRequests)/1000);
|
|
138 |
|
|
139 |
|
|
140 |
TTimeIntervalMicroSeconds coldRequestTime;
|
|
141 |
coldRequestTime = DoRequests(ETrue, EFalse);
|
|
142 |
INFO_PRINTF2(_L("Requests from cold took on average %d miliseconds to complete."), (coldRequestTime.Int64()/KNumberOfRequests)/1000);
|
|
143 |
|
|
144 |
TTimeIntervalMicroSeconds warmRequestTime;
|
|
145 |
warmRequestTime = DoRequests(EFalse, EFalse);
|
|
146 |
INFO_PRINTF2(_L("Requests from warm took on average %d miliseconds to complete."), (warmRequestTime.Int64()/KNumberOfRequests)/1000);
|
|
147 |
|
|
148 |
INFO_PRINTF2(_L("Requests from warm with reset assistance data took on average %d miliseconds to complete."), (resetRequestTime.Int64()/KNumberOfRequests)/1000);
|
|
149 |
INFO_PRINTF2(_L("Requests from cold took on average %d miliseconds to complete."), (coldRequestTime.Int64()/KNumberOfRequests)/1000);
|
|
150 |
/* if(warmRequestTime >= resetRequestTime/2 || resetRequestTime < (coldRequestTime*3)/4)
|
|
151 |
{
|
|
152 |
INFO_PRINTF1(_L("Reseting assistance data didn't fit into the right time frame"));
|
|
153 |
SetTestStepResult(EFail);
|
|
154 |
}
|
|
155 |
*/
|
|
156 |
CloseNetSim();
|
|
157 |
|
|
158 |
// All done, clean up.
|
|
159 |
CleanupStack::PopAndDestroy(&iServer);
|
|
160 |
}
|
|
161 |
|
|
162 |
INFO_PRINTF1(_L("<<CT_LbsClientStep_ResetAssistance::doTestStepL()"));
|
|
163 |
|
|
164 |
return TestStepResult();
|
|
165 |
}
|
|
166 |
|
|
167 |
TInt64 CT_LbsClientStep_ResetAssistance::DoRequests(TBool aCold, TBool aReset)
|
|
168 |
{
|
|
169 |
if(!aCold)
|
|
170 |
{
|
|
171 |
// *** Warming up module
|
|
172 |
// Open positioner.
|
|
173 |
TInt err = iPositioner.Open(iServer);
|
|
174 |
User::LeaveIfError(err);
|
|
175 |
CleanupClosePushL(iPositioner);
|
|
176 |
|
|
177 |
// Request notify for the expected reference position.
|
|
178 |
TPositionInfo actualRefPosInfo;
|
|
179 |
err = DoNotifyUpdateL(actualRefPosInfo);
|
|
180 |
if (KErrNone != err)
|
|
181 |
{
|
|
182 |
INFO_PRINTF2(_L("Failed test, reference position request returned err %d."), err);
|
|
183 |
SetTestStepResult(EFail);
|
|
184 |
}
|
|
185 |
|
|
186 |
TPositionInfo posInfo;
|
|
187 |
// Get the actual position
|
|
188 |
err = DoNotifyUpdateL(posInfo);
|
|
189 |
if (KErrNone != err)
|
|
190 |
{
|
|
191 |
INFO_PRINTF2(_L("Failed test, position request returned err %d."), err);
|
|
192 |
SetTestStepResult(EFail);
|
|
193 |
}
|
|
194 |
}
|
|
195 |
|
|
196 |
TTimeIntervalMicroSeconds requestTime;
|
|
197 |
requestTime = 0;
|
|
198 |
// *** Doing the repeated requests with reset assistance data in between if it's requested so
|
|
199 |
for(TInt count = 0; count < KNumberOfRequests; ++count)
|
|
200 |
{
|
|
201 |
if(aReset)
|
|
202 |
{
|
|
203 |
SendResetAssistanceData(0xFFFFFFFF);
|
|
204 |
}
|
|
205 |
|
|
206 |
if(aCold)
|
|
207 |
{
|
|
208 |
// Open positioner.
|
|
209 |
TInt err = iPositioner.Open(iServer);
|
|
210 |
User::LeaveIfError(err);
|
|
211 |
CleanupClosePushL(iPositioner);
|
|
212 |
}
|
|
213 |
|
|
214 |
TTime startTime;
|
|
215 |
startTime.UniversalTime(); // start the clock
|
|
216 |
|
|
217 |
if(aCold)
|
|
218 |
{
|
|
219 |
// Request notify for the expected reference position.
|
|
220 |
TPositionInfo actualRefPosInfo;
|
|
221 |
TInt err = DoNotifyUpdateL(actualRefPosInfo);
|
|
222 |
if (KErrNone != err)
|
|
223 |
{
|
|
224 |
INFO_PRINTF2(_L("Failed test, reference position request returned err %d."), err);
|
|
225 |
SetTestStepResult(EFail);
|
|
226 |
}
|
|
227 |
}
|
|
228 |
TPositionInfo posInfo;
|
|
229 |
// Get the actual position
|
|
230 |
TInt err = DoNotifyUpdateL(posInfo);
|
|
231 |
if (KErrNone != err)
|
|
232 |
{
|
|
233 |
INFO_PRINTF2(_L("Failed test, position request returned err %d."), err);
|
|
234 |
SetTestStepResult(EFail);
|
|
235 |
}
|
|
236 |
|
|
237 |
TTime endTime;
|
|
238 |
endTime.UniversalTime(); // stop the clock
|
|
239 |
TTimeIntervalMicroSeconds interval;
|
|
240 |
interval = endTime.MicroSecondsFrom(startTime);
|
|
241 |
INFO_PRINTF2(_L("Request took %d microseconds to complete."), interval.Int64());
|
|
242 |
requestTime = requestTime.Int64() + interval.Int64();
|
|
243 |
|
|
244 |
if(aCold)
|
|
245 |
{
|
|
246 |
CleanupStack::PopAndDestroy(&iPositioner);
|
|
247 |
User::After(KWaitTimeForCoolDown);
|
|
248 |
}
|
|
249 |
}
|
|
250 |
|
|
251 |
if(!aCold)
|
|
252 |
{
|
|
253 |
// Cleanup.
|
|
254 |
CleanupStack::PopAndDestroy(&iPositioner);
|
|
255 |
User::After(KWaitTimeForCoolDown);
|
|
256 |
}
|
|
257 |
return requestTime.Int64();
|
|
258 |
}
|