|
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 CT_LbsClientStep.cpp |
|
15 // This is the class implementation for the LBS Client Test Step Base |
|
16 // |
|
17 // |
|
18 |
|
19 #include "ctlbsclientstep.h" |
|
20 |
|
21 #include <lbs/test/tlbsutils.h> |
|
22 #include <lbs/test/ctlbsasyncwaiter.h> |
|
23 |
|
24 |
|
25 #define REFPOS_LAT 52.2 |
|
26 #define REFPOS_LONG 0.2 |
|
27 #define REFPOS_ALT 10 |
|
28 #define REFPOS_HORZ_ACCURACY 100 |
|
29 #define REFPOS_VERT_ACCURACY 100 |
|
30 |
|
31 /** |
|
32 * @return - TVerdict |
|
33 * Implementation of CTestStep base class virtual |
|
34 * It is used for doing all initialisation common to derived classes in here. |
|
35 * Make it being able to leave if there are any errors here as there's no point in |
|
36 * trying to run a test step if anything fails. |
|
37 * The leave will be picked up by the framework. |
|
38 */ |
|
39 TVerdict CT_LbsClientStep::doTestStepPreambleL() |
|
40 { |
|
41 // Process some common pre setting to test steps then set SetTestStepResult to EFail or Epass. |
|
42 INFO_PRINTF1(_L(">>CT_LbsClientStep::doTestStepPreambleL()")); |
|
43 SetTestStepResult(EPass); |
|
44 |
|
45 _LIT(KExpectedApiBehaviour, "expected_api_behaviour"); |
|
46 TInt expectedApiBehaviour; |
|
47 if(GetIntFromConfig(ConfigSection(), KExpectedApiBehaviour, expectedApiBehaviour)) |
|
48 { |
|
49 iExpectedApiBehaviour = static_cast<TExpectedApiBehaviour>(expectedApiBehaviour);; |
|
50 } |
|
51 else |
|
52 { |
|
53 iExpectedApiBehaviour = EApiVariant1; |
|
54 } |
|
55 |
|
56 return TestStepResult(); |
|
57 } |
|
58 |
|
59 |
|
60 /** |
|
61 * @return - TVerdict |
|
62 * Implementation of CTestStep base class virtual |
|
63 * It is used for doing all after test treatment common to derived classes in here. |
|
64 * Make it being able to leave |
|
65 * The leave will be picked up by the framework. |
|
66 */ |
|
67 TVerdict CT_LbsClientStep::doTestStepPostambleL() |
|
68 { |
|
69 // Process some common post setting to test steps then set SetTestStepResult to EFail or Epass. |
|
70 INFO_PRINTF1(_L(">>CT_LbsClientStep::doTestStepPostabmleL()")); |
|
71 |
|
72 //SetTestStepResult(EPass); // or EFail |
|
73 return TestStepResult(); |
|
74 } |
|
75 |
|
76 |
|
77 CT_LbsClientStep::~CT_LbsClientStep() |
|
78 { |
|
79 } |
|
80 |
|
81 |
|
82 CT_LbsClientStep::CT_LbsClientStep(CT_LbsClientServer& aParent) : iParent(aParent) |
|
83 { |
|
84 } |
|
85 |
|
86 |
|
87 TInt CT_LbsClientStep::DoNotifyUpdateL(TPositionInfoBase& aPosInfo) |
|
88 { |
|
89 return GetLocationL(aPosInfo, EDoNotifyPosUpdate); |
|
90 } |
|
91 |
|
92 TInt CT_LbsClientStep::DoLastKnownPosL(TPositionInfoBase& aPosInfo) |
|
93 { |
|
94 return GetLocationL(aPosInfo, EDoLastKnownPos); |
|
95 } |
|
96 |
|
97 |
|
98 TInt CT_LbsClientStep::GetLocationL(TPositionInfoBase& aPosInfo, TUint32 aNotifyCallType) |
|
99 { |
|
100 // Use wrapper active object for the async call below. |
|
101 CT_LbsAsyncWaiter* waiter = CT_LbsAsyncWaiter::NewL(); |
|
102 CleanupStack::PushL(waiter); |
|
103 |
|
104 // Set requestor, note we use the same values as DUMMY_REQUESTOR so we don't have |
|
105 // to include the header file from the test server, to keep code generic when test pos server goes. |
|
106 |
|
107 // TODO: NOTE for the new server, there is no requirement to SetRequestor so we can |
|
108 // remove later. |
|
109 User::LeaveIfError(iPositioner.SetRequestor( CRequestor::ERequestorService, |
|
110 CRequestor::EFormatApplication, |
|
111 _L("Tom Tom"))); |
|
112 |
|
113 // Determine the position function to call and get the actual position |
|
114 if (EDoNotifyPosUpdate == aNotifyCallType) |
|
115 { |
|
116 iPositioner.NotifyPositionUpdate(aPosInfo, waiter->iStatus); |
|
117 } |
|
118 else if (EDoLastKnownPos == aNotifyCallType) |
|
119 { |
|
120 iPositioner.GetLastKnownPosition(aPosInfo, waiter->iStatus); |
|
121 } |
|
122 |
|
123 else |
|
124 User::LeaveIfError(KErrArgument); |
|
125 |
|
126 // Wait for and process the result. |
|
127 waiter->StartAndWait(); |
|
128 |
|
129 TInt err = waiter->Result(); |
|
130 if (KErrNone == err) |
|
131 { |
|
132 INFO_PRINTF1(_L("position obtained successfully")); |
|
133 |
|
134 const TPositionInfo& posInfo = reinterpret_cast<const TPositionInfo&>(aPosInfo); |
|
135 |
|
136 |
|
137 TPosition pos; |
|
138 posInfo.GetPosition(pos); |
|
139 TReal32 lat = pos.Latitude(); |
|
140 TReal32 lng = pos.Longitude(); |
|
141 TReal32 hac = pos.HorizontalAccuracy(); |
|
142 TReal vac = pos.VerticalAccuracy(); |
|
143 |
|
144 INFO_PRINTF2(_L("lat: %f"),lat); |
|
145 INFO_PRINTF2(_L("lng: %f"),lng); |
|
146 INFO_PRINTF2(_L("hac: %f"),hac); |
|
147 INFO_PRINTF2(_L("vac: %f"),vac); |
|
148 |
|
149 } |
|
150 else |
|
151 { |
|
152 INFO_PRINTF2(_L("position update failed with error %d"), err); |
|
153 } |
|
154 |
|
155 CleanupStack::PopAndDestroy(waiter); |
|
156 |
|
157 return err; |
|
158 } |
|
159 |
|
160 |
|
161 |
|
162 TInt CT_LbsClientStep::OpenNetSim() |
|
163 { |
|
164 // Connect to net sim. |
|
165 TInt err = iNetSim.ConnectL(NULL); |
|
166 if (err) |
|
167 { |
|
168 return err; |
|
169 } |
|
170 |
|
171 |
|
172 // Set the reference position, which also be used for any required verification. |
|
173 iRefPos.SetCoordinate(REFPOS_LAT, REFPOS_LONG, REFPOS_ALT); |
|
174 iRefPos.SetAccuracy(REFPOS_HORZ_ACCURACY, REFPOS_VERT_ACCURACY); |
|
175 iRefPos.SetCurrentTime(); |
|
176 |
|
177 if (!iNetSim.SetReferenceLocation(iRefPos)) |
|
178 { |
|
179 iNetSim.Close(); |
|
180 |
|
181 return KErrGeneral; |
|
182 } |
|
183 |
|
184 |
|
185 // Set plugin to use. |
|
186 TUid pluginUid; |
|
187 if(iParent.iSharedData->iTestModuleInUse) |
|
188 { |
|
189 pluginUid = TUid::Uid(KSimpleAssistanceDataProviderPluginUidValue); |
|
190 } |
|
191 else |
|
192 { |
|
193 pluginUid = TUid::Uid(KSuplAssistanceDataProviderPluginUidValue); |
|
194 } |
|
195 if (!iNetSim.SetAssistanceDataProvider(pluginUid)) |
|
196 { |
|
197 iNetSim.Close(); |
|
198 |
|
199 return KErrGeneral; |
|
200 } |
|
201 |
|
202 return err; |
|
203 } |
|
204 |
|
205 void CT_LbsClientStep::SendResetAssistanceData(TLbsAssistanceDataGroup aMask) |
|
206 { |
|
207 iNetSim.SendResetAssistanceData(aMask); |
|
208 } |
|
209 |
|
210 void CT_LbsClientStep::CloseNetSim() |
|
211 { |
|
212 iNetSim.Close(); |
|
213 } |
|
214 |
|
215 |