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 "ctlbsclientpostp1.h"
|
|
20 |
#include <EPos_CPosModules.h>
|
|
21 |
#include <EPos_CPosModuleUpdate.h>
|
|
22 |
#include <EPos_CPosModuleIdList.h>
|
|
23 |
#include <LbsSatellite.h>
|
|
24 |
|
|
25 |
// CONSTANTS
|
|
26 |
|
|
27 |
// ================= MEMBER FUNCTIONS =======================
|
|
28 |
|
|
29 |
// ---------------------------------------------------------
|
|
30 |
// Constructor.
|
|
31 |
// ---------------------------------------------------------
|
|
32 |
CT_LbsClientPosTp1::CT_LbsClientPosTp1(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent)
|
|
33 |
{
|
|
34 |
_LIT(KTestName, "TP1 - Request location from default PSY");
|
|
35 |
SetTestStepName(KTestName);
|
|
36 |
}
|
|
37 |
|
|
38 |
// ---------------------------------------------------------
|
|
39 |
// Destructor.
|
|
40 |
// ---------------------------------------------------------
|
|
41 |
CT_LbsClientPosTp1::~CT_LbsClientPosTp1()
|
|
42 |
{
|
|
43 |
}
|
|
44 |
|
|
45 |
// ---------------------------------------------------------
|
|
46 |
// CT_LbsClientPosTp1::CloseTest
|
|
47 |
//
|
|
48 |
// (other items were commented in a header).
|
|
49 |
// ---------------------------------------------------------
|
|
50 |
//
|
|
51 |
void CT_LbsClientPosTp1::CloseTest()
|
|
52 |
{
|
|
53 |
ClosePositioner();
|
|
54 |
Disconnect();
|
|
55 |
}
|
|
56 |
|
|
57 |
// ---------------------------------------------------------
|
|
58 |
// CT_LbsClientPosTp1::StartL
|
|
59 |
//
|
|
60 |
// (other items were commented in a header).
|
|
61 |
// ---------------------------------------------------------
|
|
62 |
//
|
|
63 |
void CT_LbsClientPosTp1::StartL()
|
|
64 |
{
|
|
65 |
ConnectL();
|
|
66 |
|
|
67 |
CPosModules* db = CPosModules::OpenL();
|
|
68 |
CleanupStack::PushL(db);
|
|
69 |
|
|
70 |
SetupPsyL(iUidMultiPsy);
|
|
71 |
|
|
72 |
_LIT(KSetupPSY, "TP1: Has Setup Multi PSY");
|
|
73 |
INFO_PRINTF1(KSetupPSY);
|
|
74 |
|
|
75 |
//setting priority
|
|
76 |
TPositionModuleInfo moduleInfoHp;//Hp - high prio;
|
|
77 |
TPositionModuleInfo moduleInfoLp;//Lp - low prio;
|
|
78 |
|
|
79 |
CPosModuleIdList* prioList = db->ModuleIdListLC();
|
|
80 |
db->GetModuleInfoL(prioList->At(0), moduleInfoHp);
|
|
81 |
|
|
82 |
CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();
|
|
83 |
moduleUpdate->SetUpdateAvailability(ETrue);
|
|
84 |
|
|
85 |
if (iUidMultiPsy.iUid == moduleInfoHp.ModuleId().iUid)
|
|
86 |
{
|
|
87 |
// Case when Multi PSY has highest prio:
|
|
88 |
// Ensuring it is enabled
|
|
89 |
_LIT(KMultiHighest, "TP1: Case when Multi PSY has highest prio");
|
|
90 |
INFO_PRINTF1(KMultiHighest);
|
|
91 |
db->UpdateModuleL((*prioList)[0], *moduleUpdate);
|
|
92 |
}
|
|
93 |
else
|
|
94 |
{
|
|
95 |
// Case when Multi PSY has not highest prio:
|
|
96 |
//
|
|
97 |
_LIT(KMultiNotHighest, "TP1: Case when Multi PSY has NOT highest prio");
|
|
98 |
INFO_PRINTF1(KMultiNotHighest);
|
|
99 |
db->GetModuleInfoL(iUidMultiPsy, moduleInfoLp);
|
|
100 |
// Ensuring it is enabled
|
|
101 |
db->UpdateModuleL(iUidMultiPsy, *moduleUpdate);
|
|
102 |
|
|
103 |
TUint hp = db->PriorityL(moduleInfoHp.ModuleId());
|
|
104 |
TUint lp = db->PriorityL(moduleInfoLp.ModuleId());
|
|
105 |
|
|
106 |
// Changing prio of highest prio PSY and Multi PSY.
|
|
107 |
// Setting Multi PSY to highest prio
|
|
108 |
db->SetModulePriorityL(iUidMultiPsy, hp);
|
|
109 |
db->SetModulePriorityL((*prioList)[0], lp);
|
|
110 |
}
|
|
111 |
|
|
112 |
_LIT(KTestPSY1On, "TP1: Enabling Test PSY 1");
|
|
113 |
INFO_PRINTF1(KTestPSY1On);
|
|
114 |
db -> UpdateModuleL(iUidTestPsy1, *moduleUpdate);
|
|
115 |
_LIT(KTestPSY2On, "TP1: Enabling Test PSY 2");
|
|
116 |
INFO_PRINTF1(KTestPSY2On);
|
|
117 |
db -> UpdateModuleL(iUidTestPsy2, *moduleUpdate);
|
|
118 |
|
|
119 |
CleanupStack::PopAndDestroy(moduleUpdate);
|
|
120 |
CleanupStack::PopAndDestroy(2, db); // db, prioList
|
|
121 |
|
|
122 |
User::LeaveIfError(OpenPositioner());
|
|
123 |
|
|
124 |
// Request data from default psy should be Multi psy
|
|
125 |
_LIT(KService, "service");
|
|
126 |
TPositionInfo posInfo = TPositionInfo();
|
|
127 |
TInt err = PerformSyncRequest(KService, &posInfo);
|
|
128 |
if (err != KErrNone)
|
|
129 |
{
|
|
130 |
_LIT(KErrorRequest, "The request was not completed with KErrNone");
|
|
131 |
LogErrorAndLeaveL(KErrorRequest, err);
|
|
132 |
}
|
|
133 |
|
|
134 |
if (iUidMultiPsy.iUid != posInfo.ModuleId().iUid)
|
|
135 |
{
|
|
136 |
_LIT(KIncorrectPsyError, "TP1. Position from wrong PSY received");
|
|
137 |
LogErrorAndLeaveL(KIncorrectPsyError);
|
|
138 |
}
|
|
139 |
|
|
140 |
HPositionGenericInfo* genericInfo = HPositionGenericInfo::NewLC();
|
|
141 |
err = PerformSyncRequest(KService, &(*genericInfo));
|
|
142 |
if (err != KErrNone)
|
|
143 |
{
|
|
144 |
_LIT(KErrorRequest, "The request was not completed with KErrNone");
|
|
145 |
LogErrorAndLeaveL(KErrorRequest);
|
|
146 |
}
|
|
147 |
|
|
148 |
if (iUidMultiPsy.iUid != (genericInfo -> ModuleId()).iUid)
|
|
149 |
{
|
|
150 |
_LIT(KIncorrectPsyError,
|
|
151 |
"TP1. Position from wrong PSY received");
|
|
152 |
LogErrorAndLeaveL(KIncorrectPsyError);
|
|
153 |
}
|
|
154 |
|
|
155 |
TPositionCourseInfo courseInfo = TPositionCourseInfo();
|
|
156 |
err = PerformSyncRequest(KService, &courseInfo);
|
|
157 |
if (err != KErrNone)
|
|
158 |
{
|
|
159 |
_LIT(KErrorRequest, "Course info supported by default, but request failed");
|
|
160 |
LogErrorAndLeaveL(KErrorRequest);
|
|
161 |
}
|
|
162 |
|
|
163 |
TPositionSatelliteInfo satelliteInfo = TPositionSatelliteInfo();
|
|
164 |
err = PerformSyncRequest(KService, &satelliteInfo);
|
|
165 |
if (err != KErrNone)
|
|
166 |
{
|
|
167 |
_LIT(KErrorRequest, "Satellite info supported by default, but request failed");
|
|
168 |
LogErrorAndLeaveL(KErrorRequest);
|
|
169 |
}
|
|
170 |
|
|
171 |
//Changing the priority and verifiy that it still possilbe
|
|
172 |
//to request updated from a psy if basic position information
|
|
173 |
//is used and that it is not possilbe to request sat or cource
|
|
174 |
//any more.
|
|
175 |
SetupPsyL(iUidTestPsy2);
|
|
176 |
User::After(3000000);
|
|
177 |
|
|
178 |
// Request data from default psy should be test psy 2 now
|
|
179 |
err = PerformSyncRequest(KService, &posInfo);
|
|
180 |
if (err != KErrNone)
|
|
181 |
{
|
|
182 |
_LIT(KErrorRequest, "The request was not completed with KErrNone");
|
|
183 |
LogErrorAndLeaveL(KErrorRequest);
|
|
184 |
}
|
|
185 |
|
|
186 |
if (iUidTestPsy2.iUid != posInfo.ModuleId().iUid)
|
|
187 |
{
|
|
188 |
_LIT(KIncorrectPsyError,
|
|
189 |
"TP1. Position from wrong PSY received");
|
|
190 |
LogErrorAndLeaveL(KIncorrectPsyError);
|
|
191 |
}
|
|
192 |
|
|
193 |
err = PerformSyncRequest(KService, &(*genericInfo));
|
|
194 |
if (err != KErrNone)
|
|
195 |
{
|
|
196 |
_LIT(KErrorRequest, "The request was not completed with KErrNone");
|
|
197 |
LogErrorAndLeaveL(KErrorRequest);
|
|
198 |
}
|
|
199 |
|
|
200 |
if (iUidTestPsy2.iUid != (genericInfo -> ModuleId()).iUid)
|
|
201 |
{
|
|
202 |
_LIT(KIncorrectPsyError,
|
|
203 |
"TP1. Position from wrong PSY received");
|
|
204 |
LogErrorAndLeaveL(KIncorrectPsyError);
|
|
205 |
}
|
|
206 |
|
|
207 |
err = PerformSyncRequest(KService, &courseInfo);
|
|
208 |
if (err != KErrArgument)
|
|
209 |
{
|
|
210 |
_LIT(KErrorRequest, "Course info not supported by default, KErrArgument not returned");
|
|
211 |
LogErrorAndLeaveL(KErrorRequest);
|
|
212 |
}
|
|
213 |
|
|
214 |
|
|
215 |
err = PerformSyncRequest(KService, &satelliteInfo);
|
|
216 |
if (err != KErrArgument)
|
|
217 |
{
|
|
218 |
_LIT(KErrorRequest, "Satellite info not supported by default, KErrArgument not returned");
|
|
219 |
LogErrorAndLeaveL(KErrorRequest);
|
|
220 |
}
|
|
221 |
|
|
222 |
//check that it is possilbe to change the different
|
|
223 |
//type of class info during periodic request and
|
|
224 |
//that the periodic update will fail if the class
|
|
225 |
//type is incorrect.
|
|
226 |
TTimeIntervalMicroSeconds interval = TTimeIntervalMicroSeconds(1000000);
|
|
227 |
TPositionUpdateOptions posOption;
|
|
228 |
posOption.SetUpdateInterval(interval);
|
|
229 |
_LIT(KUpdateErr, "Error when setting update interval, %d");
|
|
230 |
err = iPositioner.SetUpdateOptions(posOption);
|
|
231 |
AssertTrueL(err == KErrNone, KUpdateErr, err);
|
|
232 |
|
|
233 |
_LIT(KErrPeriodic, "The periodic request did not return KErrNone, %d");
|
|
234 |
err = PerformSyncRequest(KService, &posInfo);
|
|
235 |
AssertTrueL(err == KErrNone , KErrPeriodic, err);
|
|
236 |
|
|
237 |
_LIT(KErrPeriodicArr, "The periodic request did not return KErrArgument, %d");
|
|
238 |
err = PerformSyncRequest(KService, &satelliteInfo);
|
|
239 |
AssertTrueL(err == KErrArgument , KErrPeriodicArr, err);
|
|
240 |
SetupPsyL(iUidMultiPsy);
|
|
241 |
User::After(3000000);
|
|
242 |
err = PerformSyncRequest(KService, &satelliteInfo);
|
|
243 |
AssertTrueL(err == KErrNone , KErrPeriodic, err);
|
|
244 |
|
|
245 |
CleanupStack::PopAndDestroy(genericInfo);
|
|
246 |
ClosePositioner();
|
|
247 |
Disconnect();
|
|
248 |
}
|
|
249 |
|
|
250 |
// ---------------------------------------------------------
|
|
251 |
// CT_LbsClientPosTp1::AssertTrueSecL
|
|
252 |
//
|
|
253 |
// (other items were commented in a header).
|
|
254 |
// ---------------------------------------------------------
|
|
255 |
//
|
|
256 |
void CT_LbsClientPosTp1::AssertTrueL(TBool aCondition, const TDesC& aErrorMsg, TInt aErrorCode)
|
|
257 |
{
|
|
258 |
if (!aCondition)
|
|
259 |
{
|
|
260 |
TBuf<100> buf;
|
|
261 |
buf.Format(aErrorMsg, aErrorCode);
|
|
262 |
LogErrorAndLeaveL(buf);
|
|
263 |
}
|
|
264 |
}
|
|
265 |
|