|
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 "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 // |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include "ctlbsclientpostp76.h" |
|
21 #include <badesca.h> |
|
22 #include <lbs/epos_cposmodules.h> |
|
23 #include <lbs/epos_cposmoduleupdate.h> |
|
24 #include <lbs/epos_cposmoduleidlist.h> |
|
25 |
|
26 // CONSTANTS |
|
27 |
|
28 // ================= MEMBER FUNCTIONS ======================= |
|
29 |
|
30 // --------------------------------------------------------- |
|
31 // Constructor. |
|
32 // --------------------------------------------------------- |
|
33 CT_LbsClientPosTp76::CT_LbsClientPosTp76(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent) |
|
34 { |
|
35 _LIT(KTestName,"TP76 - Get module data"); |
|
36 SetTestStepName(KTestName); |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------- |
|
40 // Destructor. |
|
41 // --------------------------------------------------------- |
|
42 CT_LbsClientPosTp76::~CT_LbsClientPosTp76() |
|
43 { |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------- |
|
47 // CT_LbsClientPosTp76::StartL |
|
48 // |
|
49 // (other items were commented in a header). |
|
50 // --------------------------------------------------------- |
|
51 // |
|
52 void CT_LbsClientPosTp76::StartL() |
|
53 { |
|
54 // Open connection to Epos |
|
55 RPositionServer posServer; |
|
56 CleanupClosePushL(posServer); |
|
57 TInt err = posServer.Connect(); |
|
58 _LIT(KConnectError, "TP76. Unable to open connection to Epos, return code %d"); |
|
59 AssertTrueSecL(err == KErrNone, KConnectError, err); |
|
60 |
|
61 // Set priority for those psys that will be used in this tp. |
|
62 // The order will be testpsy1(externalgps),testpsy2,testpsy3 |
|
63 TUid uidPsy1 = iUidTestPsy1; |
|
64 TUid uidPsy2 = iUidTestPsy2; |
|
65 TUid uidPsy3 = iUidTestPsy3; |
|
66 |
|
67 SetupPsyL(uidPsy1); // will disable all except uidPsy1 |
|
68 |
|
69 CPosModules* db = CPosModules::OpenL(); |
|
70 CleanupStack::PushL(db); |
|
71 |
|
72 // Enable the PSY test psys |
|
73 CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC(); |
|
74 moduleUpdate -> SetUpdateAvailability(ETrue); |
|
75 db->SetModulePriorityL(uidPsy1, 0); |
|
76 db->SetModulePriorityL(uidPsy2, 1); |
|
77 db->SetModulePriorityL(uidPsy3, 1); |
|
78 db->UpdateModuleL(uidPsy1, *moduleUpdate); |
|
79 db->UpdateModuleL(uidPsy2, *moduleUpdate); |
|
80 db->UpdateModuleL(uidPsy3, *moduleUpdate); |
|
81 CleanupStack::PopAndDestroy(moduleUpdate); |
|
82 |
|
83 // Setup the PSY:s in the correct order |
|
84 CPosModuleIdList* prioList = db->ModuleIdListLC(); |
|
85 TInt numModules = prioList->Count(); |
|
86 TPositionModuleInfo modInfoPsy2; //used to comapre that the same result is returned. |
|
87 db -> GetModuleInfoL(uidPsy2, modInfoPsy2); |
|
88 CleanupStack::PopAndDestroy(2); // db, prioList |
|
89 |
|
90 // Get default positioning module info. (testpsy1 or externalgps) |
|
91 TPositionModuleInfo modInfo; |
|
92 TPositionModuleId defaultId; |
|
93 err = posServer.GetDefaultModuleId(defaultId); |
|
94 _LIT(KDefaultModuleId, "Not possible to get default module id"); |
|
95 AssertTrueSecL(err == KErrNone, KDefaultModuleId, err); |
|
96 // Check that the correct id was returned. |
|
97 if (defaultId != uidPsy1) |
|
98 { |
|
99 _LIT(KErrorWrongModule, "Default module was not returned in GetDefaultModuleId()"); |
|
100 LogErrorAndLeaveL(KErrorWrongModule); |
|
101 } |
|
102 |
|
103 // Get default module info by using the id returned. |
|
104 err = posServer.GetModuleInfoById(defaultId, modInfo); |
|
105 _LIT(KGetDefPosModInfoError, |
|
106 "TP76. Error occured at GetModuleInfoById, return code %d"); |
|
107 AssertTrueSecL(err == KErrNone, KGetDefPosModInfoError, err); |
|
108 // Check if the received psy is the right one |
|
109 _LIT(KIncorrectPsyError, |
|
110 "TP76. Incorrect PSY returned from Epos."); |
|
111 AssertTrueL(uidPsy1 == modInfo.ModuleId(), KIncorrectPsyError); |
|
112 //END TEST DEFAULT// |
|
113 |
|
114 // |
|
115 // TestGetModuleInfoById // |
|
116 // |
|
117 |
|
118 // Get info from specific psy (testpsy2) |
|
119 _LIT(KGetPosModInfoError, "Wrong data received from Epos"); |
|
120 err = posServer.GetModuleInfoById(uidPsy2, modInfo); |
|
121 AssertTrueSecL(err == 0, KGetPosModInfoError, err); |
|
122 AssertTrueL(modInfo.ModuleId() == uidPsy2, KGetPosModInfoError); |
|
123 CheckModuleInfoL(modInfoPsy2, modInfo); |
|
124 //END TEST GetModuleInfoById// |
|
125 |
|
126 // |
|
127 // Test GetModuleInfoByIndex // |
|
128 // |
|
129 |
|
130 // Get info from the testpsys (testpsy1, testpsy2, testpsy3) |
|
131 TPositionModuleId id1; |
|
132 TPositionModuleId id2; |
|
133 TPositionModuleId id3; |
|
134 TUint count; |
|
135 err = posServer.GetNumModules(count); |
|
136 _LIT(KNumPosModInfoError, |
|
137 "TP76. Error occured at GetNumModules error code returned, return code %d"); |
|
138 AssertTrueSecL(err == 0,KNumPosModInfoError,err); |
|
139 _LIT(KIncorrectNoOfModules, |
|
140 "TP76. Incorrect number of modules."); |
|
141 TUint no = (TUint) numModules; //Bad API implementation |
|
142 AssertTrueL(count == no, KIncorrectNoOfModules); |
|
143 |
|
144 err = posServer.GetModuleInfoByIndex(0, modInfo); |
|
145 AssertTrueSecL(err == KErrNone, KGetDefPosModInfoError, err); |
|
146 id1 = modInfo.ModuleId(); |
|
147 if (!(id1 == uidPsy1 || |
|
148 id1 == uidPsy2 || |
|
149 id1 == uidPsy3)) |
|
150 { |
|
151 LogErrorAndLeaveL(KGetPosModInfoError); |
|
152 } |
|
153 |
|
154 err = posServer.GetModuleInfoByIndex(1, modInfo); |
|
155 AssertTrueSecL(err == 0, KGetDefPosModInfoError, err); |
|
156 id2 = modInfo.ModuleId(); |
|
157 if (!(id2 == uidPsy1 || |
|
158 id2 == uidPsy2 || |
|
159 id2 == uidPsy3)) |
|
160 { |
|
161 LogErrorAndLeaveL(KGetPosModInfoError); |
|
162 } |
|
163 |
|
164 err = posServer.GetModuleInfoByIndex(2, modInfo); |
|
165 AssertTrueSecL(err == 0, KGetDefPosModInfoError, err); |
|
166 id3 = modInfo.ModuleId(); |
|
167 if (!(id3 == uidPsy1 || |
|
168 id3 == uidPsy2 || |
|
169 id3 == uidPsy3)) |
|
170 { |
|
171 LogErrorAndLeaveL(KGetPosModInfoError); |
|
172 } |
|
173 |
|
174 // Assuming that only 3 PSYs are installed |
|
175 err = posServer.GetModuleInfoByIndex(3, modInfo); |
|
176 AssertTrueSecL(err == 0, KGetDefPosModInfoError, err); |
|
177 |
|
178 // END TEST GetModuleInfoByIndex // |
|
179 |
|
180 CleanupStack::PopAndDestroy(); //posServer |
|
181 } |
|
182 |
|
183 // --------------------------------------------------------- |
|
184 // CT_LbsClientPosTp76::CheckModuleInfoL |
|
185 // |
|
186 // (other items were commented in a header). |
|
187 // --------------------------------------------------------- |
|
188 // |
|
189 void CT_LbsClientPosTp76::CheckModuleInfoL(const TPositionModuleInfo& dbInfo, |
|
190 const TPositionModuleInfo& clientInfo) |
|
191 { |
|
192 _LIT(KNotSame, "Module Info from settings is not the same as when read by GetModuleInfoById"); |
|
193 if (dbInfo.IsAvailable() != clientInfo.IsAvailable() || |
|
194 dbInfo.ModuleId() != clientInfo.ModuleId() || |
|
195 dbInfo.DeviceLocation() != clientInfo.DeviceLocation() || |
|
196 dbInfo.Capabilities() != clientInfo.Capabilities() || |
|
197 dbInfo.TechnologyType() != clientInfo.TechnologyType() || |
|
198 dbInfo.Version().iBuild != clientInfo.Version().iBuild || |
|
199 dbInfo.Version().iMajor != clientInfo.Version().iMajor || |
|
200 dbInfo.Version().iMinor != clientInfo.Version().iMinor || |
|
201 dbInfo.Version().Name() != clientInfo.Version().Name() || |
|
202 dbInfo.ClassesSupported(EPositionInfoFamily) != clientInfo.ClassesSupported(EPositionInfoFamily)) |
|
203 { |
|
204 LogErrorAndLeaveL(KNotSame); |
|
205 } |
|
206 TPositionQuality dbQuality; |
|
207 TPositionQuality clientQuality; |
|
208 dbInfo.GetPositionQuality(dbQuality); |
|
209 clientInfo.GetPositionQuality(clientQuality); |
|
210 if (dbQuality.TimeToFirstFix() != clientQuality.TimeToFirstFix() || |
|
211 dbQuality.TimeToNextFix() != clientQuality.TimeToNextFix() || |
|
212 dbQuality.HorizontalAccuracy() != clientQuality.HorizontalAccuracy() || |
|
213 dbQuality.VerticalAccuracy() != clientQuality.VerticalAccuracy() || |
|
214 dbQuality.CostIndicator() != clientQuality.CostIndicator() || |
|
215 dbQuality.PowerConsumption() != clientQuality.PowerConsumption() ) |
|
216 { |
|
217 LogErrorAndLeaveL(KNotSame); |
|
218 } |
|
219 |
|
220 |
|
221 TBuf<30> name1; |
|
222 TBuf<30> name2; |
|
223 dbInfo.GetModuleName(name1); |
|
224 clientInfo.GetModuleName(name2); |
|
225 if (name1 != name2) |
|
226 { |
|
227 LogErrorAndLeaveL(KNotSame); |
|
228 } |
|
229 } |
|
230 |
|
231 |
|
232 // --------------------------------------------------------- |
|
233 // CT_LbsClientPosTp76::AssertTrueL |
|
234 // |
|
235 // (other items were commented in a header). |
|
236 // --------------------------------------------------------- |
|
237 // |
|
238 void CT_LbsClientPosTp76::AssertTrueL(TBool aCondition, const TDesC& aErrorMsg) |
|
239 { |
|
240 if (!aCondition) |
|
241 { |
|
242 LogErrorAndLeaveL(aErrorMsg); |
|
243 } |
|
244 } |
|
245 |
|
246 |
|
247 // --------------------------------------------------------- |
|
248 // CT_LbsClientPosTp76::AssertTrueSecL |
|
249 // |
|
250 // (other items were commented in a header). |
|
251 // --------------------------------------------------------- |
|
252 // |
|
253 void CT_LbsClientPosTp76::AssertTrueSecL(TBool aCondition, const TDesC& aErrorMsg, TInt aErrorCode) |
|
254 { |
|
255 if (!aCondition) |
|
256 { |
|
257 TBuf<100> buf; |
|
258 buf.Format(aErrorMsg, aErrorCode); |
|
259 LogErrorAndLeaveL(buf); |
|
260 } |
|
261 } |