748
|
1 |
// Copyright (c) 2001-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 |
//
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
// INCLUDES
|
|
19 |
#include "ctlbsclientpostp189.h"
|
|
20 |
#include <EPos_CPosModules.h>
|
|
21 |
#include <EPos_CPosModuleUpdate.h>
|
|
22 |
|
|
23 |
// CONSTANTS
|
|
24 |
const TInt32 KUidNonExistingPsy = 0x01111111;
|
|
25 |
const TInt KMaxMessageSize = 200;
|
|
26 |
const TInt KNrOfDeviceStatusChanges = 8; // 9 since some are ignored
|
|
27 |
// ================= MEMBER FUNCTIONS =======================
|
|
28 |
|
|
29 |
// ---------------------------------------------------------
|
|
30 |
// Constructor.
|
|
31 |
// ---------------------------------------------------------
|
|
32 |
CT_LbsClientPosTp189::CT_LbsClientPosTp189(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent)
|
|
33 |
{
|
|
34 |
_LIT(KTestName, "Tp189 - Status Events");
|
|
35 |
SetTestStepName(KTestName);
|
|
36 |
}
|
|
37 |
|
|
38 |
// ---------------------------------------------------------
|
|
39 |
// Destructor.
|
|
40 |
// ---------------------------------------------------------
|
|
41 |
CT_LbsClientPosTp189::~CT_LbsClientPosTp189()
|
|
42 |
{
|
|
43 |
}
|
|
44 |
|
|
45 |
// ---------------------------------------------------------
|
|
46 |
// CT_LbsClientPosTp189::StartL
|
|
47 |
//
|
|
48 |
// (other items were commented in a header).
|
|
49 |
// ---------------------------------------------------------
|
|
50 |
//
|
|
51 |
void CT_LbsClientPosTp189::StartL()
|
|
52 |
{
|
|
53 |
_LIT(KDeviceStatusValues, "Device Status Values (Unknown = 0, Error = 1, Disabled = 2, Inactive = 3, Initialising = 4, StandBy = 5, Ready = 6, Active = 7)");
|
|
54 |
INFO_PRINTF1(KDeviceStatusValues);
|
|
55 |
_LIT(KDataQualityValue, "Data Quality Status (Unknown = 0, Loss = 1, Partial = 2, Normal = 3)");
|
|
56 |
INFO_PRINTF1(KDataQualityValue);
|
|
57 |
|
|
58 |
_LIT(KSetTestStatusPsy, "Setting up TestStatusPsy");
|
|
59 |
INFO_PRINTF1(KSetTestStatusPsy);
|
|
60 |
|
|
61 |
SetupPsyL(iUidTestStatusPsy);
|
|
62 |
|
|
63 |
TPositionModuleStatusEvent statusEvent2;
|
|
64 |
statusEvent2.SetRequestedEvents(TPositionModuleStatusEvent::EEventDeviceStatus);
|
|
65 |
TRequestStatus status2 = KErrNone;
|
|
66 |
RPositionServer client2;
|
|
67 |
CleanupClosePushL(client2);
|
|
68 |
TInt err = client2.Connect();
|
|
69 |
_LIT(KConnectError, "TP18 Unable to open connection to Epos, return code %d");
|
|
70 |
AssertTrueL(err == KErrNone, KConnectError, err);
|
|
71 |
|
|
72 |
// Synchronous request to start server.
|
|
73 |
ConnectL();
|
|
74 |
|
|
75 |
// 1. Request to be notified about Module Status Events.
|
|
76 |
TPositionModuleStatusEvent statusEvent;
|
|
77 |
TRequestStatus status = KErrNone;
|
|
78 |
|
|
79 |
// Open a subsession to PSY.1
|
|
80 |
_LIT(KOpenPSY, "Calling OpenPositionerByName");
|
|
81 |
INFO_PRINTF1(KOpenPSY);
|
|
82 |
err = OpenPositionerByName(iUidTestStatusPsy);
|
|
83 |
_LIT(KErrOpen, "1. Error when opening subsession to PSY , error code = %d");
|
|
84 |
AssertTrueL(err == KErrNone, KErrOpen, err);
|
|
85 |
|
|
86 |
|
|
87 |
for(TInt i = 0; i < (KNrOfDeviceStatusChanges - 1); i++) //Iterate through different device statuses. Skip first and last
|
|
88 |
{
|
|
89 |
RequestWaitAndLogEventL(TPositionModuleStatusEvent::EEventDeviceStatus);
|
|
90 |
}
|
|
91 |
|
|
92 |
RequestWaitAndLogEventL(TPositionModuleStatusEvent::EEventDataQualityStatus); //Test to be notified about data quality changes
|
|
93 |
|
|
94 |
// Renew request before proceeding
|
|
95 |
statusEvent.SetRequestedEvents(TPositionModuleStatusEvent::EEventDeviceStatus);
|
|
96 |
iPosServer.NotifyModuleStatusEvent(statusEvent, status, iUidTestStatusPsy);
|
|
97 |
|
|
98 |
// 2. Disable PSY1.
|
|
99 |
CPosModules* db = CPosModules::OpenL();
|
|
100 |
CleanupStack::PushL(db);
|
|
101 |
CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();
|
|
102 |
|
|
103 |
moduleUpdate->SetUpdateAvailability(EFalse);
|
|
104 |
db->UpdateModuleL(iUidTestStatusPsy, *moduleUpdate);
|
|
105 |
_LIT(KWaitStatus, "Waiting for status after UpdateModuleL1");
|
|
106 |
INFO_PRINTF1(KWaitStatus);
|
|
107 |
User::WaitForRequest(status);
|
|
108 |
|
|
109 |
_LIT(KWait, "Error when request completed, error code = %d");
|
|
110 |
iExpectedStatus.SetDeviceStatus(TPositionModuleStatus::EDeviceDisabled);
|
|
111 |
iExpectedStatus.SetDataQualityStatus(TPositionModuleStatus::EDataQualityNormal);
|
|
112 |
|
|
113 |
TPositionModuleStatus getStatus;
|
|
114 |
statusEvent.GetModuleStatus(getStatus);
|
|
115 |
|
|
116 |
if (iExpectedStatus.DeviceStatus() != getStatus.DeviceStatus() ||
|
|
117 |
iExpectedStatus.DataQualityStatus() != getStatus.DataQualityStatus())
|
|
118 |
{
|
|
119 |
TBuf<100> buf;
|
|
120 |
if (iExpectedStatus.DeviceStatus() != getStatus.DeviceStatus())
|
|
121 |
{
|
|
122 |
_LIT(KError, "Status is not correct, Status returned %d Status expected %d");
|
|
123 |
buf.Format(KError, getStatus.DeviceStatus(), iExpectedStatus.DeviceStatus());
|
|
124 |
LogErrorAndLeaveL(buf);
|
|
125 |
}
|
|
126 |
else
|
|
127 |
{
|
|
128 |
_LIT(KError , "Quality is not correct, Quality returned %d Quality expected");
|
|
129 |
buf.Format(KError, getStatus.DataQualityStatus(), iExpectedStatus.DataQualityStatus());
|
|
130 |
LogErrorAndLeaveL(KError);
|
|
131 |
}
|
|
132 |
}
|
|
133 |
|
|
134 |
// 3. Renew request
|
|
135 |
iPosServer.NotifyModuleStatusEvent(statusEvent, status, iUidTestStatusPsy);
|
|
136 |
_LIT(KNotifyModuleStatusEvent, "Called NotifyModuleStatusEvent");
|
|
137 |
INFO_PRINTF1(KNotifyModuleStatusEvent);
|
|
138 |
|
|
139 |
// 4. Enable PSY1
|
|
140 |
moduleUpdate->SetUpdateAvailability(ETrue);
|
|
141 |
db->UpdateModuleL(iUidTestStatusPsy, *moduleUpdate);
|
|
142 |
_LIT(KWaitUpdateModuleL2, "Waiting for status after UpdateModuleL2");
|
|
143 |
INFO_PRINTF1(KWaitUpdateModuleL2);
|
|
144 |
|
|
145 |
User::WaitForRequest(status);
|
|
146 |
AssertTrueL(status.Int() == KErrNone, KWait, status.Int());
|
|
147 |
|
|
148 |
// 5. Renew request
|
|
149 |
iPosServer.NotifyModuleStatusEvent(statusEvent, status, iUidTestStatusPsy);
|
|
150 |
client2.NotifyModuleStatusEvent(statusEvent2, status2, iUidMultiPsy);
|
|
151 |
|
|
152 |
// 7. Disable PSY1
|
|
153 |
_LIT(KDisable, "Disabling TestStatusPsy");
|
|
154 |
INFO_PRINTF1(KDisable);
|
|
155 |
moduleUpdate->SetUpdateAvailability(EFalse);
|
|
156 |
db->UpdateModuleL(iUidTestStatusPsy, *moduleUpdate);
|
|
157 |
|
|
158 |
// 9. Enable PSY2
|
|
159 |
_LIT(KEnable, "Enabling MultiPsy");
|
|
160 |
INFO_PRINTF1(KEnable);
|
|
161 |
moduleUpdate->SetUpdateAvailability(ETrue);
|
|
162 |
db->UpdateModuleL(iUidMultiPsy, *moduleUpdate);
|
|
163 |
|
|
164 |
_LIT(KStatus, "Waiting for status & status2");
|
|
165 |
INFO_PRINTF1(KStatus);
|
|
166 |
User::WaitForRequest(status, status2);
|
|
167 |
if (status == KRequestPending)
|
|
168 |
{
|
|
169 |
User::WaitForRequest(status);
|
|
170 |
}
|
|
171 |
else
|
|
172 |
{
|
|
173 |
User::WaitForRequest(status2);
|
|
174 |
}
|
|
175 |
|
|
176 |
|
|
177 |
AssertTrueL(status.Int() == KErrNone, KWait, status.Int());
|
|
178 |
AssertTrueL(status2.Int() == KErrNone, KWait, status2.Int());
|
|
179 |
|
|
180 |
// 10. Renew request for all PSYs
|
|
181 |
iPosServer.NotifyModuleStatusEvent(statusEvent, status, iUidTestStatusPsy);
|
|
182 |
|
|
183 |
// 11. Enable PSY1
|
|
184 |
moduleUpdate->SetUpdateAvailability(ETrue);
|
|
185 |
db->UpdateModuleL(iUidTestStatusPsy, *moduleUpdate);
|
|
186 |
_LIT(KWaitUpdateModuleL3, "Waiting for status after UpdateModuleL3");
|
|
187 |
INFO_PRINTF1(KWaitUpdateModuleL3);
|
|
188 |
|
|
189 |
User::WaitForRequest(status);
|
|
190 |
AssertTrueL(status.Int() == KErrNone, KWait, status.Int());
|
|
191 |
|
|
192 |
// Open a subsession to PSY.1
|
|
193 |
err = iPositioner2.Open(iPosServer, iUidTestStatusPsy);
|
|
194 |
_LIT(KErrOpenOther, "7. Error when opening subsession to PSY , error code = %d");
|
|
195 |
AssertTrueL(err == KErrNone, KErrOpenOther, err);
|
|
196 |
|
|
197 |
User::After(10000000); //wait for all psy event to timeout
|
|
198 |
// Renew request for all PSYs
|
|
199 |
iPosServer.NotifyModuleStatusEvent(statusEvent, status);
|
|
200 |
User::After(1000000);
|
|
201 |
// 14. Close subsession to PSY1. All events execept close event has happen
|
|
202 |
iPositioner2.Close();
|
|
203 |
_LIT(KStatusClose, "Waiting for status after Close");
|
|
204 |
INFO_PRINTF1(KStatusClose);
|
|
205 |
|
|
206 |
User::WaitForRequest(status);
|
|
207 |
err = status.Int();
|
|
208 |
_LIT(KStatusErr, "status: %d");
|
|
209 |
INFO_PRINTF2(KStatusErr, err);
|
|
210 |
AssertTrueL(err == KErrNone, KWait, err);
|
|
211 |
|
|
212 |
|
|
213 |
// 15. Renew request for PSY1
|
|
214 |
iPosServer.NotifyModuleStatusEvent(statusEvent, status, iUidTestStatusPsy);
|
|
215 |
|
|
216 |
User::After(600000);
|
|
217 |
// 16. Cancel request
|
|
218 |
TInt cancelErr = iPosServer.CancelRequest(EPositionServerNotifyModuleStatusEvent);
|
|
219 |
_LIT(KCancel, "7. Error canceling request, error code = %d");
|
|
220 |
AssertTrueL(cancelErr == KErrNone, KCancel, cancelErr);
|
|
221 |
_LIT(KStatusCancelRequest, "Waiting for status after CancelRequest");
|
|
222 |
INFO_PRINTF1(KStatusCancelRequest);
|
|
223 |
|
|
224 |
User::WaitForRequest(status);
|
|
225 |
AssertTrueL(status.Int() == KErrCancel, KCancel, status.Int());
|
|
226 |
|
|
227 |
// 17. Cancel request again
|
|
228 |
cancelErr = iPosServer.CancelRequest(EPositionServerNotifyModuleStatusEvent);
|
|
229 |
AssertTrueL(cancelErr == KErrNotFound, KCancel, cancelErr);
|
|
230 |
|
|
231 |
// 18. Request for non-existing PSY.
|
|
232 |
_LIT(KNonExistingPSY, "Request for non-existing PSY");
|
|
233 |
INFO_PRINTF1(KNonExistingPSY);
|
|
234 |
TUid aNonExistingUid;
|
|
235 |
aNonExistingUid.iUid = KUidNonExistingPsy;
|
|
236 |
iPosServer.NotifyModuleStatusEvent(statusEvent, status, aNonExistingUid);
|
|
237 |
_LIT(KStatusWaiting, "Waiting for status");
|
|
238 |
INFO_PRINTF1(KStatusWaiting);
|
|
239 |
|
|
240 |
User::WaitForRequest(status);
|
|
241 |
AssertTrueL(status.Int() == KErrNotFound, KWait, status.Int());
|
|
242 |
|
|
243 |
|
|
244 |
CleanupStack::PopAndDestroy(moduleUpdate);
|
|
245 |
CleanupStack::PopAndDestroy(db);
|
|
246 |
CleanupStack::PopAndDestroy(&client2);
|
|
247 |
|
|
248 |
_LIT(KClosePositioner, "Calling ClosePositioner");
|
|
249 |
INFO_PRINTF1(KClosePositioner);
|
|
250 |
ClosePositioner();
|
|
251 |
|
|
252 |
Disconnect();
|
|
253 |
}
|
|
254 |
|
|
255 |
// ---------------------------------------------------------
|
|
256 |
// CT_LbsClientPosTp189::CheckModuleStatus
|
|
257 |
//
|
|
258 |
// (other items were commented in a header).
|
|
259 |
// ---------------------------------------------------------
|
|
260 |
//
|
|
261 |
void CT_LbsClientPosTp189::RequestWaitAndLogEventL(const TInt aEventToListenFor)
|
|
262 |
{
|
|
263 |
TPositionModuleStatusEvent statusEvent;
|
|
264 |
TRequestStatus status = KErrNone;
|
|
265 |
|
|
266 |
if(aEventToListenFor == TPositionModuleStatusEvent::EEventDataQualityStatus)
|
|
267 |
{
|
|
268 |
statusEvent.SetRequestedEvents(TPositionModuleStatusEvent::EEventDataQualityStatus);
|
|
269 |
}
|
|
270 |
else
|
|
271 |
{
|
|
272 |
statusEvent.SetRequestedEvents(TPositionModuleStatusEvent::EEventDeviceStatus);
|
|
273 |
}
|
|
274 |
|
|
275 |
// Renew request
|
|
276 |
iPosServer.NotifyModuleStatusEvent(statusEvent, status, iUidTestStatusPsy);
|
|
277 |
|
|
278 |
User::WaitForRequest(status);
|
|
279 |
_LIT(KErrLoopOpen, "Error in loop when opening subsession to PSY , error code = %d");
|
|
280 |
AssertTrueL(status.Int() == KErrNone, KErrLoopOpen, status.Int());
|
|
281 |
|
|
282 |
// Get status information for PSY.
|
|
283 |
TPositionModuleStatus moduleStatus = TPositionModuleStatus();
|
|
284 |
TInt err = iPosServer.GetModuleStatus(moduleStatus, iUidTestStatusPsy);
|
|
285 |
_LIT(KGet, "Error when getting module status from PSY , error code = %d");
|
|
286 |
AssertTrueL(err == KErrNone, KGet, err);
|
|
287 |
CheckModuleStatusL(moduleStatus);
|
|
288 |
}
|
|
289 |
// ---------------------------------------------------------
|
|
290 |
// CT_LbsClientPosTp189::CheckModuleStatus
|
|
291 |
//
|
|
292 |
// (other items were commented in a header).
|
|
293 |
// ---------------------------------------------------------
|
|
294 |
//
|
|
295 |
void CT_LbsClientPosTp189::CheckModuleStatusL(const TPositionModuleStatus& aStatus , const TBool /*aCheckStatus*/)
|
|
296 |
{
|
|
297 |
TBuf<KMaxMessageSize> buf;
|
|
298 |
_LIT(KStatus,"Checking module status");
|
|
299 |
INFO_PRINTF1(KStatus);
|
|
300 |
_LIT(KErrBoundary, "The value on status/quaity is out of range");
|
|
301 |
|
|
302 |
_LIT(KDevSta, "Device Status = %d");
|
|
303 |
TInt status = aStatus.DeviceStatus();
|
|
304 |
buf.Format(KDevSta, status);
|
|
305 |
INFO_PRINTF1(buf);
|
|
306 |
buf.Zero();
|
|
307 |
//check that status value is not out of range
|
|
308 |
switch(status)
|
|
309 |
{
|
|
310 |
case TPositionModuleStatus::EDeviceUnknown:
|
|
311 |
case TPositionModuleStatus::EDeviceError:
|
|
312 |
case TPositionModuleStatus::EDeviceInitialising:
|
|
313 |
case TPositionModuleStatus::EDeviceStandBy:
|
|
314 |
case TPositionModuleStatus::EDeviceReady:
|
|
315 |
case TPositionModuleStatus::EDeviceActive:
|
|
316 |
case TPositionModuleStatus::EDeviceInactive: //the psy should not be able to report this
|
|
317 |
break;
|
|
318 |
case TPositionModuleStatus::EDeviceDisabled: //the psy should not be able to report this
|
|
319 |
default:
|
|
320 |
LogErrorAndLeaveL(KErrBoundary);
|
|
321 |
}
|
|
322 |
|
|
323 |
|
|
324 |
|
|
325 |
_LIT(KDatQual, "Data Quality Status = %d");
|
|
326 |
TInt quality = aStatus.DataQualityStatus();
|
|
327 |
buf.Format(KDatQual, quality);
|
|
328 |
INFO_PRINTF1(buf);
|
|
329 |
buf.Zero();
|
|
330 |
//check that qauality value is not out of range
|
|
331 |
switch(quality)
|
|
332 |
{
|
|
333 |
case TPositionModuleStatus::EDataQualityUnknown:
|
|
334 |
case TPositionModuleStatus::EDataQualityLoss:
|
|
335 |
case TPositionModuleStatus::EDataQualityPartial:
|
|
336 |
case TPositionModuleStatus::EDataQualityNormal:
|
|
337 |
break;
|
|
338 |
default:
|
|
339 |
LogErrorAndLeaveL(KErrBoundary);
|
|
340 |
}
|
|
341 |
}
|
|
342 |
|
|
343 |
// End of file
|