|
1 // Copyright (c) 2005-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 @file SimPsyFixedDataModeStep.cpp |
|
18 @internalTechnology |
|
19 */ |
|
20 #include "simpsyfixeddatamodestep.h" |
|
21 #include "te_lbssimulationpsysuitedefs.h" |
|
22 |
|
23 |
|
24 |
|
25 // A few useful macros |
|
26 #define MAX(x,y) ((x)<(y))?(y):(x) |
|
27 #define MIN(x,y) ((x)<(y))?(x):(y) |
|
28 |
|
29 GLREF_C TPositionModuleStatus ModuleStatus(); |
|
30 GLREF_C TPositionModuleStatus PrevModuleStatus(); |
|
31 |
|
32 // CONSTANTS |
|
33 _LIT(KSimEmptyFile, ""); |
|
34 |
|
35 const TInt32 KSimModuleId = 270498433; |
|
36 |
|
37 CSimPsyFixedDataModeStep::~CSimPsyFixedDataModeStep() |
|
38 /** |
|
39 * Destructor |
|
40 */ |
|
41 { |
|
42 delete iSimDataArray; |
|
43 iSimDataArray = NULL; |
|
44 |
|
45 #ifdef __CTC__ |
|
46 #pragma CTC APPEND |
|
47 #endif |
|
48 } |
|
49 |
|
50 CSimPsyFixedDataModeStep::CSimPsyFixedDataModeStep() |
|
51 /** |
|
52 * Constructor |
|
53 */ |
|
54 { |
|
55 // **MUST** call SetTestStepName in the constructor as the controlling |
|
56 // framework uses the test step name immediately following construction to set |
|
57 // up the step's unique logging ID. |
|
58 SetTestStepName(KSimPsyFixedDataModeStep); |
|
59 } |
|
60 |
|
61 TVerdict CSimPsyFixedDataModeStep::doTestStepPreambleL() |
|
62 /** |
|
63 * @return - TVerdict code |
|
64 * Override of base class virtual |
|
65 */ |
|
66 { |
|
67 // uncomment the following 3 lines if you have common pre setting to all the test steps in there |
|
68 CTe_LbsSimulationPSYSuiteStepBase::doTestStepPreambleL(); |
|
69 if (TestStepResult()!=EPass) |
|
70 return TestStepResult(); |
|
71 // process some pre setting to this test step then set SetTestStepResult to EFail or Epass. |
|
72 SetTestStepResult(EPass); |
|
73 TTime time; |
|
74 time.UniversalTime(); |
|
75 iSeed = time.Int64(); |
|
76 iSimDataArray = new (ELeave) CDesC8ArrayFlat(10); |
|
77 SetSimDataFileL(KSimEmptyFile); |
|
78 return TestStepResult(); |
|
79 } |
|
80 |
|
81 |
|
82 TVerdict CSimPsyFixedDataModeStep::doTestStepL() |
|
83 /** |
|
84 * @return - TVerdict code |
|
85 * Override of base class pure virtual |
|
86 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
87 * not leave. That being the case, the current test result value will be EPass. |
|
88 */ |
|
89 { |
|
90 if (TestStepResult()==EPass) |
|
91 { |
|
92 TInt test; |
|
93 if(!GetIntFromConfig(ConfigSection(),KTe_LbsSimulationPSYSuiteInt,test) |
|
94 ) |
|
95 { |
|
96 // Leave if there's any error. |
|
97 User::Leave(KErrNotFound); |
|
98 } |
|
99 SetTestStepResult(EPass); |
|
100 StartL(test); |
|
101 } |
|
102 return TestStepResult(); |
|
103 } |
|
104 |
|
105 |
|
106 |
|
107 TVerdict CSimPsyFixedDataModeStep::doTestStepPostambleL() |
|
108 /** |
|
109 * @return - TVerdict code |
|
110 * Override of base class virtual |
|
111 */ |
|
112 { |
|
113 // process something post setting to the test step |
|
114 // uncomment the following line if you have common post setting to all the test steps in there |
|
115 // CTe_LbsSimulationPSYSuiteStepBase::doTestStepPostambleL(); |
|
116 // uncomment the following line if you have post process or remove the following line if no post process |
|
117 // SetTestStepResult(EPass); // or EFail |
|
118 return TestStepResult(); |
|
119 } |
|
120 |
|
121 |
|
122 // ================= MEMBER FUNCTIONS ======================= |
|
123 |
|
124 // --------------------------------------------------------- |
|
125 // CSimPsyFixedDataModeStep::StartL |
|
126 // (other items were commented in a header). |
|
127 // --------------------------------------------------------- |
|
128 // |
|
129 void CSimPsyFixedDataModeStep::StartL(TInt aIndex) |
|
130 { |
|
131 switch (aIndex) |
|
132 { |
|
133 case 0: |
|
134 _LIT(KSingleTestName, "**** Single request test ****"); |
|
135 INFO_PRINTF1(KSingleTestName); |
|
136 TestSingleRequestL(); |
|
137 break; |
|
138 case 1: |
|
139 _LIT(KMultipleRequestsMemoryTestName, "**** Multiple requests memory leak test ****"); |
|
140 INFO_PRINTF1(KMultipleRequestsMemoryTestName); |
|
141 //TestMultipleRequestsL(20); |
|
142 HeapTestL(aIndex); |
|
143 break; |
|
144 default: break; |
|
145 } |
|
146 } |
|
147 |
|
148 |
|
149 void CSimPsyFixedDataModeStep::DoTestL(TInt aIndex) |
|
150 { |
|
151 switch (aIndex) |
|
152 { |
|
153 case 0: TestSingleRequestL(); break; |
|
154 case 1: TestMultipleRequestsL(20); break; |
|
155 default: break; |
|
156 } |
|
157 } |
|
158 // --------------------------------------------------------- |
|
159 // CSimPsyFixedDataModeStep::TestSingleRequestL |
|
160 // (other items were commented in a header). |
|
161 // --------------------------------------------------------- |
|
162 // |
|
163 void CSimPsyFixedDataModeStep::TestSingleRequestL() |
|
164 { |
|
165 SetSimDataFileL(KSimEmptyFile); |
|
166 CSimPsyMultiRequester* requester = CSimPsyMultiRequester::NewLC(); |
|
167 |
|
168 TInt status; |
|
169 TPositionInfo position; |
|
170 TTimeIntervalMicroSeconds requestTime; |
|
171 |
|
172 requester->MakeRequests(); |
|
173 requester->GetResult(status, position, requestTime); |
|
174 CheckRequestResultL(status, position); |
|
175 |
|
176 CleanupStack::PopAndDestroy(); // requester |
|
177 _LIT(KSingleTestName, "Ended: **** Single request test ****"); |
|
178 INFO_PRINTF1(KSingleTestName); |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------- |
|
182 // CSimPsyFixedDataModeStep::TestMultRequestsL |
|
183 // (other items were commented in a header). |
|
184 // --------------------------------------------------------- |
|
185 // |
|
186 void CSimPsyFixedDataModeStep::TestMultipleRequestsL(TInt aNumberOfRequests) |
|
187 { |
|
188 SetSimDataFileL(KSimEmptyFile); |
|
189 CSimPsyMultiRequester* requester = CSimPsyMultiRequester::NewLC(); |
|
190 |
|
191 TInt status; |
|
192 TPositionInfo position; |
|
193 TTimeIntervalMicroSeconds requestTime; |
|
194 |
|
195 for (TInt i = 0; i < aNumberOfRequests; i++) |
|
196 { |
|
197 requester->MakeRequests(); |
|
198 requester->GetResult(status, position, requestTime); |
|
199 CheckRequestResultL(status, position); |
|
200 } |
|
201 |
|
202 CleanupStack::PopAndDestroy(); // requester |
|
203 _LIT(KMultipleRequestsMemoryTestName, "Ended: **** Multiple requests memory leak test ****"); |
|
204 INFO_PRINTF1(KMultipleRequestsMemoryTestName); |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------- |
|
208 // CSimPsyFixedDataModeStep::CheckRequestResultL |
|
209 // (other items were commented in a header). |
|
210 // --------------------------------------------------------- |
|
211 // |
|
212 void CSimPsyFixedDataModeStep::CheckRequestResultL( |
|
213 TInt aStatus, TPositionInfo& aPosition) |
|
214 { |
|
215 if (aStatus != KErrNone) |
|
216 { |
|
217 User::Leave(aStatus); |
|
218 } |
|
219 |
|
220 TReal longitude = 0.0; |
|
221 TReal latitude = 0.0; |
|
222 TReal altitude = 0.0; |
|
223 TReal32 hacc = 0.0; |
|
224 TReal32 vacc = 0.0; |
|
225 |
|
226 TPosition position; |
|
227 aPosition.GetPosition(position); |
|
228 |
|
229 TBuf<100> buf; |
|
230 if (aPosition.ModuleId().iUid != KSimModuleId) |
|
231 { |
|
232 _LIT(KWrongUid, "Expected simulationpsy uid"); |
|
233 LogErrorAndFail(KWrongUid); |
|
234 } |
|
235 if (aPosition.UpdateType() != EPositionUpdateGeneral) |
|
236 { |
|
237 _LIT(KWrongUpType, "Expected Update Type General"); |
|
238 LogErrorAndFail(KWrongUpType); |
|
239 } |
|
240 |
|
241 if (position.VerticalAccuracy() != vacc) |
|
242 { |
|
243 _LIT(KVAcc, "Expected vacc %d."); |
|
244 buf.Format(KVAcc, vacc); |
|
245 LogErrorAndFail(buf); |
|
246 } |
|
247 if (position.HorizontalAccuracy() != hacc) |
|
248 { |
|
249 _LIT(KHAcc, "Expected hacc %d."); |
|
250 buf.Format(KHAcc, hacc); |
|
251 LogErrorAndFail(buf); |
|
252 } |
|
253 if (position.Latitude() != latitude) |
|
254 { |
|
255 _LIT(KLat, "Expected latitude %.4f."); |
|
256 buf.Format(KLat, latitude); |
|
257 LogErrorAndFail(buf); |
|
258 } |
|
259 if (position.Longitude() != longitude) |
|
260 { |
|
261 _LIT(KLong, "Expected longitude %.4f."); |
|
262 buf.Format(KLong, longitude); |
|
263 LogErrorAndFail(buf); |
|
264 } |
|
265 if(position.Altitude() != altitude) |
|
266 { |
|
267 _LIT(KLong, "Expected altitude %.4f."); |
|
268 buf.Format(KLong, altitude); |
|
269 LogErrorAndFail(buf); |
|
270 } |
|
271 } |
|
272 |
|
273 // --------------------------------------------------------- |
|
274 // CSimPsyFixedDataModeStep::SetSimDataFileL |
|
275 // (other items were commented in a header). |
|
276 // --------------------------------------------------------- |
|
277 // |
|
278 void CSimPsyFixedDataModeStep::SetSimDataFileL(const TDesC& aFileName) |
|
279 { |
|
280 // Third version of settings simulation psy file |
|
281 |
|
282 TFileName fileName = aFileName; |
|
283 CRepository* repository = CRepository::NewLC(KCRUidSimulationPSY); |
|
284 User::LeaveIfError(repository->Set(KCRKeySimPSYSimulationFile, fileName)); |
|
285 CleanupStack::PopAndDestroy(repository); |
|
286 } |
|
287 |
|
288 |
|
289 // End of File |