36
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* @file ctlbsclientsteplastknownposareasources.cpp
|
|
16 |
* This is the class implementation for the Last Known Position Area Data Sources Tests
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
|
|
20 |
|
|
21 |
#include "ctlbsclientsteplastknownposareasources.h"
|
|
22 |
|
|
23 |
#include <lbs.h>
|
|
24 |
#include <lbssatellite.h>
|
|
25 |
|
|
26 |
#include <lbs/test/tlbsutils.h>
|
|
27 |
#include <lbs/test/ctlbsasyncwaiter.h>
|
|
28 |
|
|
29 |
#include <etel3rdparty.h>
|
|
30 |
#include <simtsy.h>
|
|
31 |
|
|
32 |
|
|
33 |
// constant definitions
|
|
34 |
_LIT(KLbsClientStepLastKnownPosAreaSources, "LbsClientStepLastKnownPosAreaSources");
|
|
35 |
|
|
36 |
/**
|
|
37 |
* Destructor
|
|
38 |
*/
|
|
39 |
CT_LbsClientStep_LastKnownPosAreaSources::~CT_LbsClientStep_LastKnownPosAreaSources()
|
|
40 |
{
|
|
41 |
}
|
|
42 |
|
|
43 |
|
|
44 |
/**
|
|
45 |
* Constructor
|
|
46 |
*/
|
|
47 |
CT_LbsClientStep_LastKnownPosAreaSources::CT_LbsClientStep_LastKnownPosAreaSources(CT_LbsClientServer& aParent) : CT_LbsClientStep(aParent)
|
|
48 |
{
|
|
49 |
SetTestStepName(KLbsClientStep_LastKnownPosAreaSources);
|
|
50 |
}
|
|
51 |
|
|
52 |
|
|
53 |
/**
|
|
54 |
Static Constructor
|
|
55 |
*/
|
|
56 |
CT_LbsClientStep_LastKnownPosAreaSources* CT_LbsClientStep_LastKnownPosAreaSources::New(CT_LbsClientServer& aParent)
|
|
57 |
{
|
|
58 |
// Note the lack of ELeave.
|
|
59 |
// This means that having insufficient memory will return NULL;
|
|
60 |
CT_LbsClientStep_LastKnownPosAreaSources* testStep = new CT_LbsClientStep_LastKnownPosAreaSources(aParent);
|
|
61 |
if (testStep)
|
|
62 |
{
|
|
63 |
TInt err = KErrNone;
|
|
64 |
TRAP(err, testStep->ConstructL());
|
|
65 |
if (err)
|
|
66 |
{
|
|
67 |
delete testStep;
|
|
68 |
testStep = NULL;
|
|
69 |
}
|
|
70 |
}
|
|
71 |
return testStep;
|
|
72 |
}
|
|
73 |
|
|
74 |
|
|
75 |
void CT_LbsClientStep_LastKnownPosAreaSources::ConstructL()
|
|
76 |
{
|
|
77 |
}
|
|
78 |
|
|
79 |
//from MT_NotifyPosUpdateObserver:
|
|
80 |
/**
|
|
81 |
* Callback - called when NotifyPositionUpdate request completes
|
|
82 |
*/
|
|
83 |
|
|
84 |
void CT_LbsClientStep_LastKnownPosAreaSources::NotifyPositionUpdateCallback(TRequestStatus& aStatus)
|
|
85 |
{
|
|
86 |
TInt err = aStatus.Int();
|
|
87 |
if (KErrCancel != err)
|
|
88 |
{
|
|
89 |
SetTestStepResult(EFail); // the request always gets cancelled (see test 0122)
|
|
90 |
}
|
|
91 |
CActiveScheduler::Stop();
|
|
92 |
}
|
|
93 |
|
|
94 |
/**
|
|
95 |
* @return - TVerdict code
|
|
96 |
* Override of base class pure virtual
|
|
97 |
* Our implementation only gets called if the base class doTestStepPreambleL() did
|
|
98 |
* not leave. That being the case, the current test result value will be EPass.
|
|
99 |
*/
|
|
100 |
TVerdict CT_LbsClientStep_LastKnownPosAreaSources::doTestStepL()
|
|
101 |
{
|
|
102 |
// Test step used to test the LBS Client Notify Position Area update API.
|
|
103 |
INFO_PRINTF1(_L(">>CT_LbsClientStep_LastKnownPosAreaSources::doTestStepL()"));
|
|
104 |
|
|
105 |
if (TestStepResult()==EPass)
|
|
106 |
{
|
|
107 |
// Connect to self locate server.
|
|
108 |
TInt err = iServer.Connect();
|
|
109 |
User::LeaveIfError(err);
|
|
110 |
CleanupClosePushL(iServer);
|
|
111 |
//RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr;
|
|
112 |
T_LbsUtils utils;
|
|
113 |
//utils.ResetAndDestroy_PosInfoArr(posInfoArr);
|
|
114 |
//TPositionModuleId modId;
|
|
115 |
//modId = utils.GetAGpsModuleIdL(iServer);
|
|
116 |
|
|
117 |
|
|
118 |
// Carry out actions.
|
|
119 |
TInt testCaseId;
|
|
120 |
if (GetIntFromConfig(ConfigSection(), KTestCaseId, testCaseId))
|
|
121 |
{
|
|
122 |
switch (testCaseId)
|
|
123 |
{
|
|
124 |
// Only Clear the database
|
|
125 |
case 1001:
|
|
126 |
{
|
|
127 |
TRequestStatus emptyStatus;
|
|
128 |
iServer.EmptyLastKnownPositionStore(emptyStatus);
|
|
129 |
User::WaitForRequest(emptyStatus);
|
|
130 |
break;
|
|
131 |
}
|
|
132 |
// Verify Position and match level
|
|
133 |
case 1:
|
|
134 |
case 2:
|
|
135 |
case 3:
|
|
136 |
case 4:
|
|
137 |
case 5:
|
|
138 |
{
|
|
139 |
User::LeaveIfError(iPositioner.Open(iServer));
|
|
140 |
CleanupClosePushL(iPositioner);
|
|
141 |
//1. LastKnown Pos Area
|
|
142 |
TPositionInfo posInfo;
|
|
143 |
TPositionAreaExtendedInfo matchLevel, expectedMatchLevel;
|
|
144 |
err = DoLastKnownPosAreaL(posInfo, matchLevel);
|
|
145 |
if (KErrNone != err)
|
|
146 |
{
|
|
147 |
ERR_PRINTF2(_L("Incorrect err %d returned"), err);
|
|
148 |
SetTestStepResult(EFail);
|
|
149 |
}
|
|
150 |
expectedMatchLevel.SetMobileCountryCodeMatch(ETrue);
|
|
151 |
expectedMatchLevel.SetMobileNetworkCodeMatch(ETrue);
|
|
152 |
expectedMatchLevel.SetLocationAreaCodeMatch(ETrue);
|
|
153 |
expectedMatchLevel.SetCellIdMatch(ETrue);
|
|
154 |
VerifyMatchLevel(expectedMatchLevel, matchLevel);
|
|
155 |
TPosition lhsPos;
|
|
156 |
// MOLR TA
|
|
157 |
if(testCaseId == 1)
|
|
158 |
{
|
|
159 |
lhsPos.SetAccuracy(10.0,10.0);
|
|
160 |
lhsPos.SetCoordinate(50.2454,0.1668,1.0);
|
|
161 |
}
|
|
162 |
// Cell
|
|
163 |
else if(testCaseId == 3)
|
|
164 |
{
|
|
165 |
lhsPos.SetAccuracy(2.0,3.0);
|
|
166 |
lhsPos.SetCoordinate(49.2,3.5,50.0);
|
|
167 |
}
|
|
168 |
// BT
|
|
169 |
else if(testCaseId == 5)
|
|
170 |
{
|
|
171 |
lhsPos.SetAccuracy(10.0,30.0);
|
|
172 |
lhsPos.SetCoordinate(61.448,23.855,0.0);
|
|
173 |
}
|
|
174 |
TPositionInfo lhsPosInfo;
|
|
175 |
lhsPosInfo.SetPosition(lhsPos);
|
|
176 |
if(!utils.Compare_PosInfo(lhsPosInfo, posInfo, T_LbsUtils::ERoughAccuracy))
|
|
177 |
{
|
|
178 |
ERR_PRINTF1(_L("Unexpected position returned"));
|
|
179 |
SetTestStepResult(EFail);
|
|
180 |
}
|
|
181 |
//2. Clear Database
|
|
182 |
TRequestStatus emptyStatus;
|
|
183 |
iServer.EmptyLastKnownPositionStore(emptyStatus);
|
|
184 |
User::WaitForRequest(emptyStatus);
|
|
185 |
CleanupStack::PopAndDestroy(&iPositioner);
|
|
186 |
break;
|
|
187 |
}
|
|
188 |
default:
|
|
189 |
User::Panic(KLbsClientStepLastKnownPosAreaSources, KErrUnknown);
|
|
190 |
}
|
|
191 |
}
|
|
192 |
// All done, clean up.
|
|
193 |
|
|
194 |
CleanupStack::PopAndDestroy(&iServer);
|
|
195 |
}
|
|
196 |
INFO_PRINTF1(_L("<<CT_LbsClientStep_LastKnownPosAreaSources::doTestStepL()"));
|
|
197 |
return TestStepResult();
|
|
198 |
}
|
|
199 |
|
|
200 |
|
|
201 |
void CT_LbsClientStep_LastKnownPosAreaSources::Validate(TPositionInfo& aExpectedPosition, TPositionInfo& aActualPosition,
|
|
202 |
TPositionAreaExtendedInfo& aActualArea, TBool aMccExpected, TBool aMncExpected, TBool aLacExpected, TBool aCidExpected)
|
|
203 |
{
|
|
204 |
TPositionAreaExtendedInfo expectedArea;
|
|
205 |
expectedArea.SetMobileCountryCodeMatch(aMccExpected);
|
|
206 |
expectedArea.SetMobileNetworkCodeMatch(aMncExpected);
|
|
207 |
expectedArea.SetLocationAreaCodeMatch(aLacExpected);
|
|
208 |
expectedArea.SetCellIdMatch(aCidExpected);
|
|
209 |
VerifyMatchLevel(expectedArea, aActualArea);
|
|
210 |
|
|
211 |
T_LbsUtils utils;
|
|
212 |
TBool equality = utils.Compare_PosInfo(aExpectedPosition, aActualPosition);
|
|
213 |
if(!equality)
|
|
214 |
{
|
|
215 |
ERR_PRINTF1(_L("Position does not match"));
|
|
216 |
SetTestStepResult(EFail);
|
|
217 |
}
|
|
218 |
}
|
|
219 |
|
|
220 |
|
|
221 |
TInt CT_LbsClientStep_LastKnownPosAreaSources::VerifyMatchLevel(TPositionAreaExtendedInfo& aExpected, TPositionAreaExtendedInfo& aActual)
|
|
222 |
{
|
|
223 |
TInt err = KErrNone;
|
|
224 |
if (!(aExpected.MobileCountryCodeMatch() == aActual.MobileCountryCodeMatch() &&
|
|
225 |
aExpected.MobileNetworkCodeMatch() == aActual.MobileNetworkCodeMatch() &&
|
|
226 |
aExpected.LocationAreaCodeMatch() == aActual.LocationAreaCodeMatch() &&
|
|
227 |
aExpected.CellIdMatch() == aActual.CellIdMatch()))
|
|
228 |
{
|
|
229 |
ERR_PRINTF1(_L("Incorrect Match level"));
|
|
230 |
ERR_PRINTF5(_L("Expected: MCC:%d, MNC:%d, LAC:%d, CID:%d"),
|
|
231 |
aExpected.MobileCountryCodeMatch(),
|
|
232 |
aExpected.MobileNetworkCodeMatch(),
|
|
233 |
aExpected.LocationAreaCodeMatch(),
|
|
234 |
aExpected.CellIdMatch());
|
|
235 |
ERR_PRINTF5(_L("Actual: MCC:%d, MNC:%d, LAC:%d, CID:%d"),
|
|
236 |
aActual.MobileCountryCodeMatch(),
|
|
237 |
aActual.MobileNetworkCodeMatch(),
|
|
238 |
aActual.LocationAreaCodeMatch(),
|
|
239 |
aActual.CellIdMatch());
|
|
240 |
SetTestStepResult(EFail);
|
|
241 |
err = KErrGeneral;
|
|
242 |
}
|
|
243 |
return err;
|
|
244 |
}
|
|
245 |
|
|
246 |
TInt CT_LbsClientStep_LastKnownPosAreaSources::DoLastKnownPosAreaL(TPositionInfoBase& aPosInfo, TPositionAreaExtendedInfo& aMatchLevel)
|
|
247 |
{
|
|
248 |
// Use wrapper active object for the async call below.
|
|
249 |
CT_LbsAsyncWaiter* waiter = CT_LbsAsyncWaiter::NewL();
|
|
250 |
CleanupStack::PushL(waiter);
|
|
251 |
User::LeaveIfError(iPositioner.SetRequestor(CRequestor::ERequestorService,
|
|
252 |
CRequestor::EFormatApplication,
|
|
253 |
_L("LbsClient LKPA Tests")));
|
|
254 |
iPositioner.GetLastKnownPositionArea(aPosInfo, aMatchLevel, waiter->iStatus);
|
|
255 |
// Wait for and process the result.
|
|
256 |
waiter->StartAndWait();
|
|
257 |
TInt err = waiter->Result();
|
|
258 |
if (KErrNone == err)
|
|
259 |
{
|
|
260 |
INFO_PRINTF1(_L("Last Known Pos Area position obtained successfully"));
|
|
261 |
}
|
|
262 |
else
|
|
263 |
{
|
|
264 |
INFO_PRINTF2(_L("Position update failed with error %d"), err);
|
|
265 |
}
|
|
266 |
CleanupStack::PopAndDestroy(waiter);
|
|
267 |
return err;
|
|
268 |
}
|