|
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 // Example CTestStep derived implementation |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file GenericInfoStep.cpp |
|
20 @internalTechnology |
|
21 */ |
|
22 #include "genericinfostep.h" |
|
23 #include "te_lbsapisuitedefs.h" |
|
24 |
|
25 #include "lcfsbucommondefinitions.h" |
|
26 |
|
27 #include <lbs.h> |
|
28 #include <lbssatellite.h> |
|
29 |
|
30 CGenericInfoStep::~CGenericInfoStep() |
|
31 /** |
|
32 * Destructor |
|
33 */ |
|
34 { |
|
35 } |
|
36 |
|
37 CGenericInfoStep::CGenericInfoStep() |
|
38 /** |
|
39 * Constructor |
|
40 */ |
|
41 { |
|
42 // **MUST** call SetTestStepName in the constructor as the controlling |
|
43 // framework uses the test step name immediately following construction to set |
|
44 // up the step's unique logging ID. |
|
45 SetTestStepName(KGenericInfoStep); |
|
46 } |
|
47 |
|
48 TVerdict CGenericInfoStep::doTestStepPreambleL() |
|
49 /** |
|
50 * @return - TVerdict code |
|
51 * Override of base class virtual |
|
52 */ |
|
53 { |
|
54 CTe_LbsApiSuiteStepBase::doTestStepPreambleL(); |
|
55 if (TestStepResult()!=EPass) |
|
56 return TestStepResult(); |
|
57 // process some pre setting to this test step then set SetTestStepResult to EFail or Epass. |
|
58 SetTestStepResult(EPass); |
|
59 return TestStepResult(); |
|
60 } |
|
61 |
|
62 |
|
63 TVerdict CGenericInfoStep::doTestStepL() |
|
64 /** |
|
65 * @return - TVerdict code |
|
66 * Override of base class pure virtual |
|
67 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
68 * not leave. That being the case, the current test result value will be EPass. |
|
69 */ |
|
70 { |
|
71 if (TestStepResult()==EPass) |
|
72 { |
|
73 TInt test; |
|
74 if(!GetIntFromConfig(ConfigSection(),KTe_LbsApiSuiteInt,test) |
|
75 ) |
|
76 { |
|
77 // Leave if there's any error. |
|
78 User::Leave(KErrNotFound); |
|
79 } |
|
80 SetTestStepResult(EPass); |
|
81 StartL(test); |
|
82 } |
|
83 return TestStepResult(); |
|
84 } |
|
85 |
|
86 |
|
87 |
|
88 TVerdict CGenericInfoStep::doTestStepPostambleL() |
|
89 /** |
|
90 * @return - TVerdict code |
|
91 * Override of base class virtual |
|
92 */ |
|
93 { |
|
94 // process something post setting to the test step |
|
95 // uncomment the following line if you have common post setting to all the test steps in there |
|
96 // CTe_LbsApiSuiteStepBase::doTestStepPostambleL(); |
|
97 // uncomment the following line if you have post process or remove the following line if no post process |
|
98 // SetTestStepResult(EPass); // or EFail |
|
99 return TestStepResult(); |
|
100 } |
|
101 |
|
102 |
|
103 void CGenericInfoStep::StartL (TInt aIndex) |
|
104 { |
|
105 switch (aIndex) |
|
106 { |
|
107 case 0: |
|
108 HPositionGenericInfo_ConstructionL (); |
|
109 break; |
|
110 case 1: |
|
111 HPositionGenericInfo_Construction2L (); |
|
112 break; |
|
113 case 2: |
|
114 HPositionGenericInfo_RequestingL (); |
|
115 break; |
|
116 case 3: |
|
117 HPositionGenericInfo_Requesting2L (); |
|
118 break; |
|
119 case 4: |
|
120 HPositionGenericInfo_GetL (); |
|
121 break; |
|
122 case 5: |
|
123 HPositionGenericInfo_GoodL (); |
|
124 break; |
|
125 case 6: |
|
126 HPositionGenericInfo_MismatchedL (); |
|
127 break; |
|
128 case 7: |
|
129 HPositionGenericInfo_HBufCL (); |
|
130 break; |
|
131 case 8: |
|
132 HPositionGenericInfo_BufferL (); |
|
133 break; |
|
134 case 9: |
|
135 HPositionGenericInfo_FieldsL (); |
|
136 break; |
|
137 case 10: |
|
138 HPositionGenericInfo_OverflowL (); |
|
139 break; |
|
140 case 11: |
|
141 HPositionGenericInfo_SetL (); |
|
142 break; |
|
143 default: |
|
144 break; |
|
145 |
|
146 } |
|
147 } |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 // |
|
153 // |
|
154 // HPositionGenericInfo |
|
155 // |
|
156 // Construction |
|
157 // |
|
158 // |
|
159 |
|
160 // 3.2.1. Construction |
|
161 void CGenericInfoStep::HPositionGenericInfo_ConstructionL() |
|
162 { |
|
163 DECLARE_ERROR_LOGGING; |
|
164 StandardPrepareL(); |
|
165 |
|
166 HPositionGenericInfo *genInfo, *genInfoL, *genInfoLC, *genInfoDef; |
|
167 const TInt KBufSize = 8; |
|
168 const TInt KMaxFields = 2; |
|
169 |
|
170 __UHEAP_MARK; |
|
171 |
|
172 genInfo = HPositionGenericInfo::New(KBufSize, KMaxFields); |
|
173 genInfoL = HPositionGenericInfo::NewL(KBufSize, KMaxFields); |
|
174 genInfoLC = HPositionGenericInfo::NewLC(KBufSize, KMaxFields); |
|
175 genInfoDef = HPositionGenericInfo::New(); |
|
176 |
|
177 __UHEAP_MARK; |
|
178 |
|
179 //check genInfo not NULL |
|
180 CHECK(genInfo); |
|
181 CHECK(genInfoL); |
|
182 CHECK(genInfoLC); |
|
183 CHECK(genInfoDef); |
|
184 |
|
185 // position class |
|
186 CHECK(genInfo->PositionClassType() == (EPositionInfoClass|EPositionGenericInfoClass)); |
|
187 CHECK(genInfo->PositionClassSize() >= sizeof(HPositionGenericInfo) + KBufSize + KMaxFields); |
|
188 |
|
189 CHECK(genInfoL->PositionClassType() == (EPositionInfoClass|EPositionGenericInfoClass)); |
|
190 CHECK(genInfoL->PositionClassSize() >= sizeof(HPositionGenericInfo) + KBufSize + KMaxFields); |
|
191 |
|
192 CHECK(genInfoLC->PositionClassType() == (EPositionInfoClass|EPositionGenericInfoClass)); |
|
193 CHECK(genInfoLC->PositionClassSize() >= sizeof(HPositionGenericInfo) + KBufSize + KMaxFields); |
|
194 |
|
195 CHECK(genInfoDef->PositionClassType() == (EPositionInfoClass|EPositionGenericInfoClass)); |
|
196 CHECK(genInfoDef->PositionClassSize() >= sizeof(HPositionGenericInfo) + KBufSize + KMaxFields); |
|
197 |
|
198 // sizes |
|
199 CHECK(genInfo->BufferSize() == KBufSize); |
|
200 CHECK(genInfo->MaxFields() == KMaxFields); |
|
201 |
|
202 CHECK(genInfoL->BufferSize() == KBufSize); |
|
203 CHECK(genInfoL->MaxFields() == KMaxFields); |
|
204 |
|
205 CHECK(genInfoLC->BufferSize() == KBufSize); |
|
206 CHECK(genInfoLC->MaxFields() == KMaxFields); |
|
207 |
|
208 CHECK(genInfoDef->BufferSize() == KPositionGenericInfoDefaultBufferSize); |
|
209 CHECK(genInfoDef->MaxFields() == KPositionGenericInfoDefaultMaxFields); |
|
210 CHECK_EQUAL_(KPositionGenericInfoDefaultBufferSize, genInfoDef->BufferSize()); |
|
211 CHECK_EQUAL_(KPositionGenericInfoDefaultMaxFields, genInfoDef->MaxFields()); |
|
212 |
|
213 // requested fields |
|
214 for(TUint16 i=EPositionFieldNone; i<EPositionFieldIdLast; i++) |
|
215 { |
|
216 CHECK(!genInfo->IsRequestedField(i)); |
|
217 CHECK(!genInfoL->IsRequestedField(i)); |
|
218 CHECK(!genInfoLC->IsRequestedField(i)); |
|
219 CHECK(!genInfoDef->IsRequestedField(i)); |
|
220 } |
|
221 // data fields |
|
222 for(TUint16 j=EPositionFieldNone; j<EPositionFieldIdLast; j++) |
|
223 { |
|
224 CHECK(!genInfo->IsFieldAvailable(j)); |
|
225 CHECK(!genInfoL->IsFieldAvailable(j)); |
|
226 CHECK(!genInfoLC->IsFieldAvailable(j)); |
|
227 CHECK(!genInfoDef->IsFieldAvailable(j)); |
|
228 } |
|
229 // field ids |
|
230 CHECK_EQUAL_(genInfo->FirstRequestedFieldId(), TPositionFieldId(EPositionFieldNone)); |
|
231 CHECK_EQUAL_(genInfoL->FirstRequestedFieldId(), TPositionFieldId(EPositionFieldNone)); |
|
232 CHECK_EQUAL_(genInfoLC->FirstRequestedFieldId(), TPositionFieldId(EPositionFieldNone)); |
|
233 CHECK_EQUAL_(genInfoDef->FirstRequestedFieldId(), TPositionFieldId(EPositionFieldNone)); |
|
234 for(TUint16 k = EPositionFieldNone; k < EPositionFieldIdLast; k++) |
|
235 { |
|
236 CHECK_EQUAL_(genInfo->NextRequestedFieldId(k), TPositionFieldId(EPositionFieldNone)); |
|
237 CHECK_EQUAL_(genInfoL->NextRequestedFieldId(k), TPositionFieldId(EPositionFieldNone)); |
|
238 CHECK_EQUAL_(genInfoLC->NextRequestedFieldId(k), TPositionFieldId(EPositionFieldNone)); |
|
239 CHECK_EQUAL_(genInfoDef->NextRequestedFieldId(k), TPositionFieldId(EPositionFieldNone)); |
|
240 } |
|
241 |
|
242 __UHEAP_MARKEND; |
|
243 |
|
244 delete genInfo; |
|
245 delete genInfoL; |
|
246 CleanupStack::PopAndDestroy(genInfoLC); |
|
247 delete genInfoDef; |
|
248 |
|
249 __UHEAP_MARKEND; |
|
250 |
|
251 StandardCleanup(); |
|
252 } |
|
253 |
|
254 |
|
255 // 3.2.2. NoMemory |
|
256 // see NoMemoryTests.cpp |
|
257 |
|
258 // 3.2.3 Invalid sizes |
|
259 struct THPGIdata |
|
260 { |
|
261 TInt defBufSize; |
|
262 TInt defMaxFields; |
|
263 }; |
|
264 |
|
265 TInt Construction_New_Invalid(TAny* aPtr) |
|
266 { |
|
267 THPGIdata& data = *(static_cast<THPGIdata*>(aPtr)); |
|
268 HPositionGenericInfo* posInfo = HPositionGenericInfo::New(data.defBufSize, data.defMaxFields); |
|
269 delete posInfo; |
|
270 return KErrGeneral; |
|
271 } |
|
272 |
|
273 |
|
274 TInt Construction_NewL_Invalid(TAny* aPtr) |
|
275 { |
|
276 THPGIdata& data = *(static_cast<THPGIdata*>(aPtr)); |
|
277 HPositionGenericInfo* posInfo = NULL; |
|
278 TInt err; |
|
279 TRAP(err, posInfo = HPositionGenericInfo::NewL(data.defBufSize, data.defMaxFields)); |
|
280 delete posInfo; |
|
281 return KErrGeneral; |
|
282 } |
|
283 |
|
284 |
|
285 TInt Construction_NewLC_Invalid(TAny* aPtr) |
|
286 { |
|
287 THPGIdata& data = *(static_cast<THPGIdata*>(aPtr)); |
|
288 TInt err; |
|
289 TRAP(err, |
|
290 HPositionGenericInfo* posInfo = HPositionGenericInfo::NewLC(data.defBufSize, data.defMaxFields); |
|
291 CleanupStack::PopAndDestroy(posInfo); |
|
292 ); |
|
293 return KErrGeneral; |
|
294 } |
|
295 |
|
296 #define TEST_CONSTRUCTION_NEW_INVALID(aPanicReason, aData) \ |
|
297 DO_PANIC_TEST_L_PTR(Construction_New_Invalid, KPosClientFault, \ |
|
298 aPanicReason, KDefaultTestTimeout, aData); |
|
299 |
|
300 #define TEST_CONSTRUCTION_NEWL_INVALID(aPanicReason, aData) \ |
|
301 DO_PANIC_TEST_L_PTR(Construction_NewL_Invalid, KPosClientFault, \ |
|
302 aPanicReason, KDefaultTestTimeout, aData); |
|
303 |
|
304 #define TEST_CONSTRUCTION_NEWLC_INVALID(aPanicReason, aData) \ |
|
305 DO_PANIC_TEST_L_PTR(Construction_NewLC_Invalid, KPosClientFault, \ |
|
306 aPanicReason, KDefaultTestTimeout, aData); |
|
307 |
|
308 void CGenericInfoStep::HPositionGenericInfo_Construction2L() |
|
309 { |
|
310 DECLARE_ERROR_LOGGING; |
|
311 StandardPrepareL(); |
|
312 |
|
313 THPGIdata data; |
|
314 |
|
315 // zero max fields |
|
316 data.defBufSize = 1; |
|
317 data.defMaxFields = 0; |
|
318 TEST_CONSTRUCTION_NEW_INVALID(EPositionGenericInfoZeroMaxFields, &data); |
|
319 TEST_CONSTRUCTION_NEWL_INVALID(EPositionGenericInfoZeroMaxFields, &data); |
|
320 TEST_CONSTRUCTION_NEWLC_INVALID(EPositionGenericInfoZeroMaxFields, &data); |
|
321 |
|
322 // negative max fields |
|
323 data.defBufSize = 1; |
|
324 data.defMaxFields = -1; |
|
325 TEST_CONSTRUCTION_NEW_INVALID(EPositionGenericInfoZeroMaxFields, &data); |
|
326 TEST_CONSTRUCTION_NEWL_INVALID(EPositionGenericInfoZeroMaxFields, &data); |
|
327 TEST_CONSTRUCTION_NEWLC_INVALID(EPositionGenericInfoZeroMaxFields, &data); |
|
328 |
|
329 // zero buffer |
|
330 data.defBufSize = 0; |
|
331 data.defMaxFields = 1; |
|
332 TEST_CONSTRUCTION_NEW_INVALID(EPositionGenericInfoZeroBufferSize, &data); |
|
333 TEST_CONSTRUCTION_NEWL_INVALID(EPositionGenericInfoZeroBufferSize, &data); |
|
334 TEST_CONSTRUCTION_NEWLC_INVALID(EPositionGenericInfoZeroBufferSize, &data); |
|
335 |
|
336 // negative buffer |
|
337 data.defBufSize = -1; |
|
338 data.defMaxFields = 1; |
|
339 TEST_CONSTRUCTION_NEW_INVALID(EPositionGenericInfoZeroBufferSize, &data); |
|
340 TEST_CONSTRUCTION_NEWL_INVALID(EPositionGenericInfoZeroBufferSize, &data); |
|
341 TEST_CONSTRUCTION_NEWLC_INVALID(EPositionGenericInfoZeroBufferSize, &data); |
|
342 |
|
343 StandardCleanup(); |
|
344 } |
|
345 |
|
346 |
|
347 // |
|
348 // |
|
349 // HPositionGenericInfo |
|
350 // |
|
351 // Requesting Fields |
|
352 // |
|
353 // |
|
354 |
|
355 // 3.3.1. Requesting Fields, ony-by-one |
|
356 void CGenericInfoStep::HPositionGenericInfo_RequestingL() |
|
357 { |
|
358 DECLARE_ERROR_LOGGING; |
|
359 StandardPrepareL(); |
|
360 |
|
361 __UHEAP_MARK; |
|
362 |
|
363 HPositionGenericInfo* genInfo = HPositionGenericInfo::NewL(); |
|
364 TUint maxField = genInfo->MaxFields(); |
|
365 |
|
366 __UHEAP_MARK; |
|
367 |
|
368 // request |
|
369 CHECK_EQUAL_(KErrNone, genInfo->SetRequestedField(TPositionFieldId(EPositionFieldNone-1))); // just very big value |
|
370 CHECK_EQUAL_(KErrArgument, genInfo->SetRequestedField(EPositionFieldNone)); |
|
371 CHECK_EQUAL_(EPositionFieldNone, genInfo->NextRequestedFieldId(TPositionFieldId(EPositionFieldNone-1))); |
|
372 |
|
373 TUint i = 0; |
|
374 for(i = EPositionFieldNone + 1; i < maxField; i++) // first is EPositionFieldNone-1 |
|
375 { |
|
376 CHECK_EQUAL_(KErrNone, genInfo->SetRequestedField(TPositionFieldId(i))); |
|
377 } |
|
378 CHECK_EQUAL_(KErrNone, genInfo->SetRequestedField(TPositionFieldId(i-1))); // double setting doesn't fail |
|
379 CHECK_EQUAL_(KErrOverflow, genInfo->SetRequestedField(TPositionFieldId(maxField + 1))); |
|
380 |
|
381 // check requested |
|
382 CHECK(genInfo->IsRequestedField(TPositionFieldId(EPositionFieldNone - 1))); |
|
383 CHECK(!genInfo->IsRequestedField(EPositionFieldNone)); |
|
384 for(i = EPositionFieldNone + 1; i < maxField; i++) // first is EPositionFieldNone-1 |
|
385 { |
|
386 CHECK(genInfo->IsRequestedField(TPositionFieldId(i))); |
|
387 } |
|
388 CHECK(!genInfo->IsRequestedField(TPositionFieldId(maxField + 1))); |
|
389 |
|
390 // enumerate requested fields |
|
391 TUint fieldsCount = 0; |
|
392 for(TPositionFieldId field = genInfo->FirstRequestedFieldId(); |
|
393 field > EPositionFieldNone; |
|
394 field = genInfo->NextRequestedFieldId(field)) |
|
395 { |
|
396 CHECK(genInfo->IsRequestedField(field)); |
|
397 fieldsCount++; |
|
398 } |
|
399 CHECK(fieldsCount == maxField); // check count here |
|
400 |
|
401 // clear all |
|
402 genInfo->ClearRequestedFields(); |
|
403 |
|
404 CHECK_EQUAL_(EPositionFieldNone, genInfo->FirstRequestedFieldId()); |
|
405 |
|
406 for(i = EPositionFieldNone + 1; i < maxField + 1; i++) |
|
407 { |
|
408 CHECK(!genInfo->IsRequestedField(TPositionFieldId(i))); |
|
409 CHECK_EQUAL_(EPositionFieldNone, genInfo->NextRequestedFieldId(TPositionFieldId(i))); |
|
410 } |
|
411 |
|
412 __UHEAP_MARKEND; |
|
413 |
|
414 delete genInfo; |
|
415 |
|
416 __UHEAP_MARKEND; |
|
417 |
|
418 StandardCleanup(); |
|
419 } |
|
420 |
|
421 |
|
422 // 3.3.2 Requesting Array of fields |
|
423 void CGenericInfoStep::HPositionGenericInfo_Requesting2L() |
|
424 { |
|
425 DECLARE_ERROR_LOGGING; |
|
426 StandardPrepareL(); |
|
427 |
|
428 __UHEAP_MARK; |
|
429 HPositionGenericInfo* genInfo = HPositionGenericInfo::NewL(); |
|
430 TUint maxField = genInfo->MaxFields(); |
|
431 __UHEAP_MARK; |
|
432 |
|
433 TPositionFieldId* fieldIds = new TPositionFieldId [maxField + 2]; |
|
434 TPositionFieldId fid = 0; |
|
435 for (fid = 0; fid <= maxField; fid++) |
|
436 { |
|
437 fieldIds[fid] = TPositionFieldId(fid + 1); |
|
438 }; |
|
439 fieldIds[maxField + 1] = EPositionFieldNone; // 1, 2, 3, 4, 5, ... 31,32,33,EPositionFieldNone |
|
440 |
|
441 CHECK_EQUAL_(KErrOverflow, genInfo->SetRequestedFields(fieldIds)); |
|
442 fieldIds[maxField] = EPositionFieldNone; // 32 is replaced with EPositionFieldNone |
|
443 // now it should work |
|
444 CHECK_EQUAL_(KErrNone, genInfo->SetRequestedFields(fieldIds)); |
|
445 |
|
446 // check requested |
|
447 CHECK(!genInfo->IsRequestedField(TPositionFieldId(EPositionFieldNone-1))); |
|
448 CHECK(!genInfo->IsRequestedField(EPositionFieldNone)); |
|
449 CHECK_EQUAL_(EPositionFieldNone, genInfo->NextRequestedFieldId(TPositionFieldId(EPositionFieldNone-1))); |
|
450 for(fid = EPositionFieldNone + 1; fid < maxField + 1; fid++) |
|
451 { |
|
452 CHECK(genInfo->IsRequestedField(fid)); |
|
453 } |
|
454 CHECK(!genInfo->IsRequestedField(TPositionFieldId(maxField + 1))); |
|
455 CHECK_EQUAL_(EPositionFieldNone, genInfo->NextRequestedFieldId(TPositionFieldId(maxField + 1))); |
|
456 |
|
457 // enumerate requested fields |
|
458 TUint fieldsCount = 0; |
|
459 for(TPositionFieldId field = genInfo->FirstRequestedFieldId(); |
|
460 field > EPositionFieldNone; |
|
461 field = genInfo->NextRequestedFieldId(field)) |
|
462 { |
|
463 CHECK(genInfo->IsRequestedField(field)); |
|
464 fieldsCount++; |
|
465 } |
|
466 CHECK(fieldsCount == maxField); // check count here |
|
467 |
|
468 // clear all |
|
469 genInfo->ClearRequestedFields(); |
|
470 |
|
471 CHECK_EQUAL_(EPositionFieldNone, genInfo->FirstRequestedFieldId()); |
|
472 |
|
473 for(fid = EPositionFieldNone + 1; fid < maxField + 1; fid++) |
|
474 { |
|
475 CHECK(!genInfo->IsRequestedField(fid)); |
|
476 CHECK_EQUAL_(EPositionFieldNone, genInfo->NextRequestedFieldId(fid)); |
|
477 } |
|
478 |
|
479 delete fieldIds; |
|
480 __UHEAP_MARKEND; |
|
481 delete genInfo; |
|
482 __UHEAP_MARKEND; |
|
483 |
|
484 StandardCleanup(); |
|
485 } |
|
486 |
|
487 |
|
488 // 3.3.3 NextRequestedField for unrequested |
|
489 // Implemented as part of 3.3.1 and 3.3.2 |
|
490 |
|
491 // |
|
492 // |
|
493 // HPositionGenericInfo |
|
494 // |
|
495 // Field Data |
|
496 // |
|
497 // |
|
498 |
|
499 |
|
500 // 3.4.1 Get/SetValue |
|
501 void CGenericInfoStep::HPositionGenericInfo_GetL() |
|
502 { |
|
503 DECLARE_ERROR_LOGGING; |
|
504 StandardPrepareL(); |
|
505 |
|
506 // SetData, Check data Availablity, Get, Check Data, Clear, |
|
507 // Check data unAvailability |
|
508 |
|
509 __UHEAP_MARK; |
|
510 |
|
511 HPositionGenericInfo* genInfo = HPositionGenericInfo::NewL(); |
|
512 |
|
513 const TUint8 testUint8 = 0x25; //Id == 1 |
|
514 const TUint16 testUint16 = 0x9811; //Id == 2 |
|
515 const TUint32 testUint32 = 0xDEADBEEF; //Id == 3 |
|
516 const TInt8 testInt8 = 23; //Id == 4 |
|
517 const TInt16 testInt16 = 3452; //Id == 5 |
|
518 const TInt32 testInt32 = 2345234; //Id == 6 |
|
519 const TInt64 testInt64(0x0EAEFACEBEEFFACELL); //Id == 7 |
|
520 const TReal32 testReal32 = TReal32(34.123); //Id == 8 |
|
521 const TReal64 testReal64 = 3425.1234; //Id == 9 |
|
522 const TTimeIntervalMicroSeconds testTimeInterval(TInt64(2345)); //Id == 10 |
|
523 const TTime testTime(TInt64(2345756)); //Id == 11 |
|
524 _LIT8(KEightBitDes, "Hello to all you lovely people."); //Id == 12 |
|
525 _LIT16(KUnicodeDes, "Who likes a bit of Heavy Metal?"); //Id == 13 |
|
526 |
|
527 // Add Data |
|
528 |
|
529 __UHEAP_MARK; |
|
530 |
|
531 CHECK_EQUAL_(KErrNone, genInfo->SetValue(1, testUint8)); |
|
532 CHECK_EQUAL_(KErrNone, genInfo->SetValue(2, testUint16)); |
|
533 CHECK_EQUAL_(KErrNone, genInfo->SetValue(3, testUint32)); |
|
534 CHECK_EQUAL_(KErrNone, genInfo->SetValue(4, testInt8)); |
|
535 CHECK_EQUAL_(KErrNone, genInfo->SetValue(5, testInt16)); |
|
536 CHECK_EQUAL_(KErrNone, genInfo->SetValue(6, testInt32)); |
|
537 CHECK_EQUAL_(KErrNone, genInfo->SetValue(7, testInt64)); |
|
538 CHECK_EQUAL_(KErrNone, genInfo->SetValue(8, testReal32)); |
|
539 CHECK_EQUAL_(KErrNone, genInfo->SetValue(9, testReal64)); |
|
540 CHECK_EQUAL_(KErrNone, genInfo->SetValue(10, testTimeInterval)); |
|
541 CHECK_EQUAL_(KErrNone, genInfo->SetValue(11, testTime)); |
|
542 CHECK_EQUAL_(KErrNone, genInfo->SetValue(12, KEightBitDes)); |
|
543 CHECK_EQUAL_(KErrNone, genInfo->SetValue(13, KUnicodeDes)); |
|
544 |
|
545 // check that set fields are available ... |
|
546 for(TUint16 i=1; i<14; i++) |
|
547 { |
|
548 CHECK(genInfo->IsFieldAvailable(i)); |
|
549 } |
|
550 // ... and unset are not |
|
551 for(TUint16 j=14; j<genInfo->MaxFields(); j++) |
|
552 { |
|
553 CHECK(!genInfo->IsFieldAvailable(j)); |
|
554 } |
|
555 |
|
556 TUint8 checkUint8; |
|
557 TUint16 checkUint16; |
|
558 TUint32 checkUint32; |
|
559 TInt8 checkInt8; |
|
560 TInt16 checkInt16; |
|
561 TInt32 checkInt32; |
|
562 TInt64 checkInt64; |
|
563 TReal32 checkReal32; |
|
564 TReal64 checkReal64; |
|
565 TTimeIntervalMicroSeconds checkTimeInterval; |
|
566 TTime checkTime; |
|
567 //Descriptors - test with TPrtC and TBuf objects. |
|
568 TPtrC8 ptr8; |
|
569 TBuf8<48> buf8; |
|
570 TPtrC16 ptr16; |
|
571 TBuf16<48> buf16; |
|
572 |
|
573 // Check that data is available in fact |
|
574 |
|
575 CHECK_EQUAL_(KErrNone, genInfo->GetValue(1, checkUint8)); |
|
576 CHECK_EQUAL_(KErrNone, genInfo->GetValue(2, checkUint16)); |
|
577 CHECK_EQUAL_(KErrNone, genInfo->GetValue(3, checkUint32)); |
|
578 CHECK_EQUAL_(KErrNone, genInfo->GetValue(4, checkInt8)); |
|
579 CHECK_EQUAL_(KErrNone, genInfo->GetValue(5, checkInt16)); |
|
580 CHECK_EQUAL_(KErrNone, genInfo->GetValue(6, checkInt32)); |
|
581 CHECK_EQUAL_(KErrNone, genInfo->GetValue(7, checkInt64)); |
|
582 CHECK_EQUAL_(KErrNone, genInfo->GetValue(8, checkReal32)); |
|
583 CHECK_EQUAL_(KErrNone, genInfo->GetValue(9, checkReal64)); |
|
584 CHECK_EQUAL_(KErrNone, genInfo->GetValue(10, checkTimeInterval)); |
|
585 CHECK_EQUAL_(KErrNone, genInfo->GetValue(11, checkTime)); |
|
586 CHECK_EQUAL_(KErrNone, genInfo->GetValue(12, ptr8)); |
|
587 CHECK_EQUAL_(KErrNone, genInfo->GetValue(12, buf8)); |
|
588 CHECK_EQUAL_(KErrNone, genInfo->GetValue(13, ptr16)); |
|
589 CHECK_EQUAL_(KErrNone, genInfo->GetValue(13, buf16)); |
|
590 |
|
591 // check data is returned correctly |
|
592 |
|
593 CHECK_EQUAL_(testUint8, checkUint8); |
|
594 CHECK_EQUAL_(testUint16, checkUint16); |
|
595 CHECK_EQUAL_(testUint32, checkUint32); |
|
596 CHECK_EQUAL_(testInt8, checkInt8); |
|
597 CHECK_EQUAL_(testInt16, checkInt16); |
|
598 CHECK_EQUAL_(testInt32, checkInt32); |
|
599 CHECK_EQUAL_(testInt64, checkInt64); |
|
600 CHECK_REAL_EQUAL(checkReal32, testReal32); |
|
601 CHECK_REAL_EQUAL(checkReal64, testReal64); |
|
602 CHECK(testTimeInterval == checkTimeInterval); |
|
603 CHECK(testTime == checkTime); |
|
604 CHECK(!ptr8.Compare(KEightBitDes)); |
|
605 CHECK(!buf8.Compare(KEightBitDes)); |
|
606 CHECK(!ptr16.Compare(KUnicodeDes)); |
|
607 CHECK(!buf16.Compare(KUnicodeDes)); |
|
608 |
|
609 //Do some checks for bad ids. |
|
610 CHECK_EQUAL_(KErrArgument, genInfo->SetValue(EPositionFieldNone, TUint8(1))); |
|
611 CHECK_EQUAL_(KErrArgument, genInfo->GetValue(EPositionFieldNone, checkInt8)); |
|
612 |
|
613 // Clear Data |
|
614 genInfo->ClearPositionData(); |
|
615 __UHEAP_MARKEND; |
|
616 |
|
617 // check that fields are not available any more |
|
618 for(TUint16 k=1; k<genInfo->MaxFields(); k++) |
|
619 { |
|
620 CHECK(!genInfo->IsFieldAvailable(k)); |
|
621 } |
|
622 |
|
623 // check that values are not available any more |
|
624 |
|
625 CHECK_EQUAL_(KErrNotFound, genInfo->GetValue(1, checkUint8)); |
|
626 CHECK_EQUAL_(KErrNotFound, genInfo->GetValue(2, checkUint16)); |
|
627 CHECK_EQUAL_(KErrNotFound, genInfo->GetValue(3, checkUint32)); |
|
628 CHECK_EQUAL_(KErrNotFound, genInfo->GetValue(4, checkInt8)); |
|
629 CHECK_EQUAL_(KErrNotFound, genInfo->GetValue(5, checkInt16)); |
|
630 CHECK_EQUAL_(KErrNotFound, genInfo->GetValue(6, checkInt32)); |
|
631 CHECK_EQUAL_(KErrNotFound, genInfo->GetValue(7, checkInt64)); |
|
632 CHECK_EQUAL_(KErrNotFound, genInfo->GetValue(8, checkReal32)); |
|
633 CHECK_EQUAL_(KErrNotFound, genInfo->GetValue(9, checkReal64)); |
|
634 CHECK_EQUAL_(KErrNotFound, genInfo->GetValue(10, checkTimeInterval)); |
|
635 CHECK_EQUAL_(KErrNotFound, genInfo->GetValue(11, checkTime)); |
|
636 CHECK_EQUAL_(KErrNotFound, genInfo->GetValue(12, ptr8)); |
|
637 CHECK_EQUAL_(KErrNotFound, genInfo->GetValue(12, buf8)); |
|
638 CHECK_EQUAL_(KErrNotFound, genInfo->GetValue(13, ptr16)); |
|
639 CHECK_EQUAL_(KErrNotFound, genInfo->GetValue(13, buf16)); |
|
640 |
|
641 delete genInfo; |
|
642 __UHEAP_MARKEND; |
|
643 |
|
644 StandardCleanup(); |
|
645 } |
|
646 |
|
647 |
|
648 // 3.4.2 Check Overflow doesn't harm existing data |
|
649 #define CHECK_GOOD_OVERFLOW(type, val1, val2) \ |
|
650 { \ |
|
651 __UHEAP_MARK; \ |
|
652 HPositionGenericInfo* genInfo = \ |
|
653 HPositionGenericInfo::NewL(sizeof(type)); \ |
|
654 __UHEAP_MARK; \ |
|
655 CHECK_EQUAL_(KErrNone, genInfo->SetValue(1, type(val1))); \ |
|
656 CHECK(genInfo->IsFieldAvailable(1)); \ |
|
657 CHECK_EQUAL_(KErrPositionBufferOverflow, genInfo->SetValue(2, type(val2)));\ |
|
658 CHECK(genInfo->IsFieldAvailable(1)); \ |
|
659 CHECK(!genInfo->IsFieldAvailable(2)); \ |
|
660 CHECK_EQUAL_(KErrNone, genInfo->SetValue(1, type(val2))); \ |
|
661 CHECK(genInfo->IsFieldAvailable(1)); \ |
|
662 type var; \ |
|
663 CHECK_EQUAL_(KErrNone, genInfo->GetValue(1, var)); \ |
|
664 CHECK(var == type(val2)); \ |
|
665 __UHEAP_MARKEND; \ |
|
666 delete genInfo; \ |
|
667 __UHEAP_MARKEND; \ |
|
668 } |
|
669 |
|
670 |
|
671 void CGenericInfoStep::HPositionGenericInfo_GoodL() |
|
672 { |
|
673 // we create a buffer with size precisely of size of tested |
|
674 // data type. |
|
675 // Then a value1 of this type is added to info. No error |
|
676 // Another value2 of same type is added - overflow. |
|
677 // check that value1 is available, value2 - is not |
|
678 // Reset field1 with value2, check it is available and correct |
|
679 |
|
680 DECLARE_ERROR_LOGGING; |
|
681 StandardPrepareL(); |
|
682 |
|
683 CHECK_GOOD_OVERFLOW(TInt8, 1, 2); |
|
684 CHECK_GOOD_OVERFLOW(TInt16, 1, 2); |
|
685 CHECK_GOOD_OVERFLOW(TInt32, 1, 2); |
|
686 CHECK_GOOD_OVERFLOW(TInt64, 1, 2); |
|
687 CHECK_GOOD_OVERFLOW(TUint8, 1, 2); |
|
688 CHECK_GOOD_OVERFLOW(TUint16, 1, 2); |
|
689 CHECK_GOOD_OVERFLOW(TUint32, 1, 2); |
|
690 CHECK_GOOD_OVERFLOW(TReal32, 1, 2); |
|
691 CHECK_GOOD_OVERFLOW(TReal64, 1, 2); |
|
692 CHECK_GOOD_OVERFLOW(TTime, 1, 2); |
|
693 CHECK_GOOD_OVERFLOW(TTimeIntervalMicroSeconds, 1, 2); |
|
694 |
|
695 // a bit different for descriptors |
|
696 // TBuf for descriptors |
|
697 TBufC8<1> buf81(_L8("1")); |
|
698 TBufC8<1> buf82(_L8("2")); |
|
699 TBufC16<1> buf161(_L16("1")); |
|
700 TBufC16<1> buf162(_L16("2")); |
|
701 |
|
702 //CHECK_GOOD_OVERFLOW(TDesC8, buf81, buf82); |
|
703 { |
|
704 __UHEAP_MARK; |
|
705 HPositionGenericInfo* genInfo = HPositionGenericInfo::NewL(sizeof(buf81)); |
|
706 __UHEAP_MARK; |
|
707 CHECK_EQUAL_(KErrNone, genInfo->SetValue(1, buf81)); |
|
708 CHECK(genInfo->IsFieldAvailable(1)); |
|
709 CHECK_EQUAL_(KErrPositionBufferOverflow, genInfo->SetValue(2, buf82)); |
|
710 CHECK(genInfo->IsFieldAvailable(1)); |
|
711 CHECK(!genInfo->IsFieldAvailable(2)); |
|
712 CHECK_EQUAL_(KErrNone, genInfo->SetValue(1, buf82)); |
|
713 CHECK(genInfo->IsFieldAvailable(1)); |
|
714 TBuf8<256> var; |
|
715 CHECK_EQUAL_(KErrNone, genInfo->GetValue(1, var)); |
|
716 CHECK(var == buf82); |
|
717 __UHEAP_MARKEND; |
|
718 delete genInfo; |
|
719 __UHEAP_MARKEND; |
|
720 } |
|
721 |
|
722 //CHECK_GOOD_OVERFLOW(TDesC16, buf161, buf162); |
|
723 { |
|
724 __UHEAP_MARK; |
|
725 HPositionGenericInfo* genInfo = HPositionGenericInfo::NewL(sizeof(buf161)); |
|
726 __UHEAP_MARK; |
|
727 CHECK_EQUAL_(KErrNone, genInfo->SetValue(1, buf161)); |
|
728 CHECK(genInfo->IsFieldAvailable(1)); |
|
729 CHECK_EQUAL_(KErrPositionBufferOverflow, genInfo->SetValue(2, buf162)); |
|
730 CHECK(genInfo->IsFieldAvailable(1)); |
|
731 CHECK(!genInfo->IsFieldAvailable(2)); |
|
732 CHECK_EQUAL_(KErrNone, genInfo->SetValue(1, buf162)); |
|
733 CHECK(genInfo->IsFieldAvailable(1)); |
|
734 TBuf16<256> var; |
|
735 CHECK_EQUAL_(KErrNone, genInfo->GetValue(1, var)); |
|
736 CHECK(var == buf162); |
|
737 __UHEAP_MARKEND; |
|
738 delete genInfo; |
|
739 __UHEAP_MARKEND; |
|
740 } |
|
741 |
|
742 StandardCleanup(); |
|
743 } |
|
744 |
|
745 |
|
746 // 3.4.3 Mismatched data types |
|
747 TInt Do_Mismatched_Data_Types1(TAny* /*aPtr*/) |
|
748 { |
|
749 HPositionGenericInfo* posInfo = HPositionGenericInfo::New(); |
|
750 if(posInfo==NULL) |
|
751 return KErrGeneral; //Failure will get picked up. |
|
752 if(posInfo->SetValue(1, TUint8(12))!=KErrNone) |
|
753 { |
|
754 delete posInfo; |
|
755 return KErrGeneral; |
|
756 } |
|
757 TBuf<10> buf; |
|
758 (void)posInfo->GetValue(1, buf); //This line should panic. We ignore error, since failure gets picked up. |
|
759 delete posInfo; |
|
760 return KErrGeneral; |
|
761 } |
|
762 |
|
763 |
|
764 void CGenericInfoStep::HPositionGenericInfo_MismatchedL() |
|
765 { |
|
766 DECLARE_ERROR_LOGGING; |
|
767 StandardPrepareL(); |
|
768 |
|
769 DO_PANIC_TEST_L(Do_Mismatched_Data_Types1, KPosClientFault, |
|
770 EPositionGenericInfoMismatchDataType, KDefaultTestTimeout); |
|
771 |
|
772 StandardCleanup(); |
|
773 } |
|
774 |
|
775 |
|
776 // 3.4.4 Test HBufC |
|
777 void CGenericInfoStep::HPositionGenericInfo_HBufCL() |
|
778 { |
|
779 DECLARE_ERROR_LOGGING; |
|
780 StandardPrepareL(); |
|
781 |
|
782 HBufC* hbuf = HBufC::NewL(256); |
|
783 const TBuf<20> bufdata(_L("HBufC")); |
|
784 *hbuf = (TDesC&)bufdata; |
|
785 |
|
786 __UHEAP_MARK; |
|
787 HPositionGenericInfo* genInfo = HPositionGenericInfo::NewL(sizeof(*hbuf) + hbuf->Size()); |
|
788 __UHEAP_MARK; |
|
789 |
|
790 CHECK_EQUAL_(KErrNone, genInfo->SetValue(1, *hbuf)); |
|
791 CHECK(genInfo->IsFieldAvailable(1)); |
|
792 CHECK_EQUAL_(KErrPositionBufferOverflow, genInfo->SetValue(2, *hbuf)); |
|
793 CHECK(genInfo->IsFieldAvailable(1)); |
|
794 CHECK(!genInfo->IsFieldAvailable(2)); |
|
795 |
|
796 TBuf<20> newbuf; |
|
797 // load again |
|
798 CHECK(KErrNone == genInfo->GetValue(1, newbuf)); |
|
799 CHECK(newbuf == bufdata); |
|
800 |
|
801 __UHEAP_MARKEND; |
|
802 delete genInfo; |
|
803 __UHEAP_MARKEND; |
|
804 |
|
805 delete hbuf; |
|
806 |
|
807 StandardCleanup(); |
|
808 } |
|
809 |
|
810 |
|
811 // 3.4.5 Buffer refill |
|
812 void CGenericInfoStep::HPositionGenericInfo_BufferL() |
|
813 { |
|
814 // Fill the buffer fully and refill it again, from last element to first one, |
|
815 // in both cases set values from one with lowest size to biggest |
|
816 // No overflow should be generated |
|
817 |
|
818 DECLARE_ERROR_LOGGING; |
|
819 StandardPrepareL(); |
|
820 |
|
821 const TInt8 int8 = 23; //Id == 1 |
|
822 const TUint8 uint8 = 0x25; //Id == 2 |
|
823 const TInt16 int16 = 3452; //Id == 3 |
|
824 const TUint16 uint16 = 0x9811; //Id == 4 |
|
825 const TInt32 int32 = 2345234; //Id == 5 |
|
826 const TUint32 uint32 = 0xDEADBEEF; //Id == 6 |
|
827 const TReal32 real32 = TReal32(34.123); //Id == 7 |
|
828 const TInt64 int64(0x0EAEFACEBEEFFACELL); //Id == 8 |
|
829 const TReal64 real64 = 3425.1234; //Id == 9 |
|
830 const TTimeIntervalMicroSeconds interval(TInt64(2345)); //Id == 10 |
|
831 const TTime time(TInt64(2345756)); //Id == 11 |
|
832 |
|
833 // calculate size |
|
834 TUint size = |
|
835 sizeof(int8) + sizeof(int16) + sizeof(int32) + sizeof(int64) + |
|
836 sizeof(uint8) + sizeof(uint16) + sizeof(uint32) + |
|
837 sizeof(real32) + sizeof(real64) + |
|
838 sizeof(time) + sizeof(interval); |
|
839 |
|
840 // create buffer |
|
841 __UHEAP_MARK; |
|
842 HPositionGenericInfo* genInfo = HPositionGenericInfo::NewL(size); |
|
843 __UHEAP_MARK; |
|
844 |
|
845 // fill with data. Note the sequence |
|
846 CHECK_EQUAL_(KErrNone, genInfo->SetValue(1, int8)); |
|
847 CHECK_EQUAL_(KErrNone, genInfo->SetValue(2, uint8)); |
|
848 CHECK_EQUAL_(KErrNone, genInfo->SetValue(3, int16)); |
|
849 CHECK_EQUAL_(KErrNone, genInfo->SetValue(4, uint16)); |
|
850 CHECK_EQUAL_(KErrNone, genInfo->SetValue(5, int32)); |
|
851 CHECK_EQUAL_(KErrNone, genInfo->SetValue(6, uint32)); |
|
852 CHECK_EQUAL_(KErrNone, genInfo->SetValue(7, real32)); |
|
853 CHECK_EQUAL_(KErrNone, genInfo->SetValue(8, int64)); |
|
854 CHECK_EQUAL_(KErrNone, genInfo->SetValue(9, real64)); |
|
855 CHECK_EQUAL_(KErrNone, genInfo->SetValue(10, interval)); |
|
856 CHECK_EQUAL_(KErrNone, genInfo->SetValue(11, time)); |
|
857 |
|
858 // check that there is no more space |
|
859 CHECK_EQUAL_(KErrPositionBufferOverflow, genInfo->SetValue(12, int8)); |
|
860 |
|
861 // check all are set |
|
862 for(TUint16 i = 1; i < 12; i++) |
|
863 { |
|
864 CHECK(genInfo->IsFieldAvailable(i)); |
|
865 } |
|
866 // check that 12th field is not really added |
|
867 CHECK(!genInfo->IsFieldAvailable(12)); |
|
868 |
|
869 // now fill in reverse sequence |
|
870 CHECK_EQUAL_(KErrNone, genInfo->SetValue(11, int8)); |
|
871 CHECK_EQUAL_(KErrNone, genInfo->SetValue(10, uint8)); |
|
872 CHECK_EQUAL_(KErrNone, genInfo->SetValue(9, int16)); |
|
873 CHECK_EQUAL_(KErrNone, genInfo->SetValue(8, uint16)); |
|
874 CHECK_EQUAL_(KErrNone, genInfo->SetValue(7, int32)); |
|
875 CHECK_EQUAL_(KErrNone, genInfo->SetValue(6, uint32)); |
|
876 CHECK_EQUAL_(KErrNone, genInfo->SetValue(5, real32)); |
|
877 CHECK_EQUAL_(KErrNone, genInfo->SetValue(4, int64)); |
|
878 CHECK_EQUAL_(KErrNone, genInfo->SetValue(3, real64)); |
|
879 CHECK_EQUAL_(KErrNone, genInfo->SetValue(2, interval)); |
|
880 CHECK_EQUAL_(KErrNone, genInfo->SetValue(1, time)); |
|
881 |
|
882 // check that there is no more space again |
|
883 CHECK_EQUAL_(KErrPositionBufferOverflow, genInfo->SetValue(12, int8)); |
|
884 |
|
885 // Note, that no Overflow error must be generated |
|
886 // because every time a field is replaced with value |
|
887 // that is of less or same size that is stored in the field!!! |
|
888 |
|
889 // check all are set |
|
890 for(TUint16 j = 1; j < 12; j++) |
|
891 { |
|
892 CHECK(genInfo->IsFieldAvailable(j)); |
|
893 } |
|
894 // except last one |
|
895 CHECK(!genInfo->IsFieldAvailable(12)); |
|
896 |
|
897 // read and check them |
|
898 TInt8 tint8; |
|
899 TUint8 tuint8; |
|
900 TInt16 tint16; |
|
901 TUint16 tuint16; |
|
902 TInt32 tint32; |
|
903 TUint32 tuint32; |
|
904 TReal32 treal32; |
|
905 TInt64 tint64; |
|
906 TReal64 treal64; |
|
907 TTimeIntervalMicroSeconds tinterval; |
|
908 TTime ttime; |
|
909 |
|
910 CHECK_EQUAL_(KErrNone, genInfo->GetValue(11, tint8)); |
|
911 CHECK_EQUAL_(KErrNone, genInfo->GetValue(10, tuint8)); |
|
912 CHECK_EQUAL_(KErrNone, genInfo->GetValue(9, tint16)); |
|
913 CHECK_EQUAL_(KErrNone, genInfo->GetValue(8, tuint16)); |
|
914 CHECK_EQUAL_(KErrNone, genInfo->GetValue(7, tint32)); |
|
915 CHECK_EQUAL_(KErrNone, genInfo->GetValue(6, tuint32)); |
|
916 CHECK_EQUAL_(KErrNone, genInfo->GetValue(5, treal32)); |
|
917 CHECK_EQUAL_(KErrNone, genInfo->GetValue(4, tint64)); |
|
918 CHECK_EQUAL_(KErrNone, genInfo->GetValue(3, treal64)); |
|
919 CHECK_EQUAL_(KErrNone, genInfo->GetValue(2, tinterval)); |
|
920 CHECK_EQUAL_(KErrNone, genInfo->GetValue(1, ttime)); |
|
921 |
|
922 CHECK_EQUAL_(tint8, int8); |
|
923 CHECK_EQUAL_(tuint8, uint8); |
|
924 CHECK_EQUAL_(tint16, int16); |
|
925 CHECK_EQUAL_(tuint16, uint16); |
|
926 CHECK_EQUAL_(tint32, int32); |
|
927 CHECK_EQUAL_(tuint32, uint32); |
|
928 CHECK_EQUAL_(treal32, real32); |
|
929 CHECK_EQUAL_(tint64, int64); |
|
930 CHECK_EQUAL_(treal64, real64); |
|
931 CHECK_EQUAL_(tinterval, interval); |
|
932 CHECK_EQUAL_(ttime, time); |
|
933 |
|
934 genInfo->ClearPositionData(); |
|
935 |
|
936 __UHEAP_MARKEND; |
|
937 delete genInfo; |
|
938 __UHEAP_MARKEND; |
|
939 |
|
940 StandardCleanup(); |
|
941 } |
|
942 |
|
943 |
|
944 // 3.4.6 Buffer refill 2 |
|
945 void CGenericInfoStep::HPositionGenericInfo_FieldsL() |
|
946 { |
|
947 // Allocate 8-byte buffer. Insert 1-byte value, 2-bytes value |
|
948 // and 4-bytes value. 1 byte remains free. |
|
949 // Replace second field (2-bytes) with 1-byte value. |
|
950 // No 2 bytes free. |
|
951 // Put 2-bytes value to the end of buffer. There is place certainly. |
|
952 // Will there right reallocation be done? Check availability and values |
|
953 |
|
954 DECLARE_ERROR_LOGGING; |
|
955 StandardPrepareL(); |
|
956 |
|
957 const TInt8 f8 = 1; //Id == 1 |
|
958 const TInt16 f16 = 2; //Id == 2 |
|
959 const TInt32 f32 = 3; //Id == 3 |
|
960 const TInt8 newf16 = 5; //Id == 2/2 |
|
961 const TInt16 f8_2 = 4; //Id == 4 |
|
962 |
|
963 // calculate size |
|
964 TUint size = sizeof(f8) + sizeof(f16) + sizeof(f32); // 7 bytes |
|
965 |
|
966 // create buffer |
|
967 __UHEAP_MARK; |
|
968 HPositionGenericInfo* genInfo = HPositionGenericInfo::NewL(size + 1); // 8 bytes |
|
969 __UHEAP_MARK; |
|
970 |
|
971 // fill with data. Note the sequence |
|
972 CHECK_EQUAL_(KErrNone, genInfo->SetValue(1, f8)); |
|
973 CHECK_EQUAL_(KErrNone, genInfo->SetValue(2, f16)); |
|
974 CHECK_EQUAL_(KErrNone, genInfo->SetValue(3, f32)); |
|
975 |
|
976 // check them |
|
977 CHECK(genInfo->IsFieldAvailable(1)); |
|
978 CHECK(genInfo->IsFieldAvailable(2)); |
|
979 CHECK(genInfo->IsFieldAvailable(3)); |
|
980 |
|
981 // replace second one |
|
982 CHECK_EQUAL_(KErrNone, genInfo->SetValue(2, newf16)); // 2 bytes free |
|
983 CHECK(genInfo->IsFieldAvailable(2)); |
|
984 |
|
985 // add 4th field |
|
986 CHECK_EQUAL_(KErrNone, genInfo->SetValue(4, f8_2)); // 0 bytes free |
|
987 CHECK(genInfo->IsFieldAvailable(4)); |
|
988 |
|
989 // 5th ? |
|
990 CHECK_EQUAL_(KErrPositionBufferOverflow, genInfo->SetValue(5, f8_2)); // should fail |
|
991 CHECK(!genInfo->IsFieldAvailable(5)); |
|
992 |
|
993 // check values |
|
994 TInt8 tf8 = 7; //Id == 1 |
|
995 TInt8 tf16 = 7; //Id == 2 |
|
996 TInt32 tf32 = 7; //Id == 3 |
|
997 TInt16 tf8_2 = 7; //Id == 4 |
|
998 |
|
999 CHECK_EQUAL_(KErrNone, genInfo->GetValue(1, tf8)); |
|
1000 CHECK_EQUAL_(KErrNone, genInfo->GetValue(2, tf16)); |
|
1001 CHECK_EQUAL_(KErrNone, genInfo->GetValue(3, tf32)); |
|
1002 CHECK_EQUAL_(KErrNone, genInfo->GetValue(4, tf8_2)); |
|
1003 |
|
1004 CHECK(tf8 == f8); |
|
1005 CHECK(tf16 == newf16); |
|
1006 CHECK(tf32 == f32); |
|
1007 CHECK(tf8_2 == f8_2); |
|
1008 |
|
1009 genInfo->ClearPositionData(); |
|
1010 |
|
1011 __UHEAP_MARKEND; |
|
1012 delete genInfo; |
|
1013 __UHEAP_MARKEND; |
|
1014 |
|
1015 // Here we do another test. Emulate situation |
|
1016 // when even compression doesn't help |
|
1017 // (the test is discovered after using CTC++) |
|
1018 |
|
1019 __UHEAP_MARK; |
|
1020 genInfo = HPositionGenericInfo::NewL(5); // 5 bytes |
|
1021 __UHEAP_MARK; |
|
1022 |
|
1023 // add fields |
|
1024 CHECK_EQUAL_(KErrNone, genInfo->SetValue(1, TUint8(1))); // values are equal to |
|
1025 CHECK_EQUAL_(KErrNone, genInfo->SetValue(2, TUint16(2))); // field indices |
|
1026 CHECK_EQUAL_(KErrNone, genInfo->SetValue(3, TUint8(3))); // one byte remains free |
|
1027 // check them |
|
1028 CHECK(genInfo->IsFieldAvailable(1)); |
|
1029 CHECK(genInfo->IsFieldAvailable(2)); |
|
1030 CHECK(genInfo->IsFieldAvailable(3)); |
|
1031 |
|
1032 // free one byte in the middle |
|
1033 CHECK_EQUAL_(KErrNone, genInfo->SetValue(2, TUint8(2))); |
|
1034 // now 2 bytes available |
|
1035 // add 4 bytes still |
|
1036 CHECK_EQUAL_(KErrPositionBufferOverflow, genInfo->SetValue(2, TUint32(4))); |
|
1037 |
|
1038 TUint8 testUint = 0; |
|
1039 // check all is ok still |
|
1040 // ... and other two fields |
|
1041 CHECK_EQUAL_(KErrNone, genInfo->GetValue(1, testUint)); |
|
1042 CHECK(testUint == 1); |
|
1043 CHECK_EQUAL_(KErrNone, genInfo->GetValue(3, testUint)); |
|
1044 CHECK(testUint == 3); |
|
1045 |
|
1046 genInfo->ClearPositionData(); |
|
1047 |
|
1048 __UHEAP_MARKEND; |
|
1049 delete genInfo; |
|
1050 __UHEAP_MARKEND; |
|
1051 |
|
1052 StandardCleanup(); |
|
1053 } |
|
1054 |
|
1055 // 3.4.7 Descriptors overflow |
|
1056 void CGenericInfoStep::HPositionGenericInfo_OverflowL() |
|
1057 { |
|
1058 DECLARE_ERROR_LOGGING; |
|
1059 StandardPrepareL(); |
|
1060 |
|
1061 HPositionGenericInfo* genInfo = HPositionGenericInfo::NewL(); |
|
1062 |
|
1063 // Byte |
|
1064 _LIT8(KBigNarrowDes, "The universe is estimated to be approx 13Gyr old"); |
|
1065 TBuf8<10> smallNarrowBuf; |
|
1066 smallNarrowBuf.SetLength(5); |
|
1067 |
|
1068 genInfo->SetValue(1, KBigNarrowDes); |
|
1069 |
|
1070 CHECK_EQUAL_(5, smallNarrowBuf.Length()); |
|
1071 CHECK_EQUAL_(KErrOverflow, genInfo->GetValue(1, smallNarrowBuf)); |
|
1072 CHECK_EQUAL_(0, smallNarrowBuf.Length()); |
|
1073 |
|
1074 // Unicode |
|
1075 _LIT16(KBigUnicodeDes, "There is a greater mass of ants than of humans on earth"); |
|
1076 TBuf16<10> smallUnicodeBuf; |
|
1077 smallUnicodeBuf.SetLength(5); |
|
1078 |
|
1079 genInfo->SetValue(1, KBigUnicodeDes); |
|
1080 |
|
1081 CHECK_EQUAL_(5, smallUnicodeBuf.Length()); |
|
1082 CHECK_EQUAL_(KErrOverflow, genInfo->GetValue(1, smallUnicodeBuf)); |
|
1083 CHECK_EQUAL_(0, smallUnicodeBuf.Length()); |
|
1084 |
|
1085 delete genInfo; |
|
1086 |
|
1087 StandardCleanup(); |
|
1088 } |
|
1089 |
|
1090 // 3.4.8 Set too many fields |
|
1091 void CGenericInfoStep::HPositionGenericInfo_SetL() |
|
1092 { |
|
1093 DECLARE_ERROR_LOGGING; |
|
1094 StandardPrepareL(); |
|
1095 |
|
1096 __UHEAP_MARK; |
|
1097 HPositionGenericInfo* genInfo = HPositionGenericInfo::NewL(0x40); |
|
1098 __UHEAP_MARK; |
|
1099 |
|
1100 for(TUint16 i = 1; i < genInfo->MaxFields() + 1; i++) |
|
1101 { |
|
1102 CHECK_EQUAL_(KErrNone, genInfo->SetValue(TPositionFieldId(i), TUint8(i))); |
|
1103 } |
|
1104 CHECK_EQUAL_(KErrOverflow, genInfo->SetValue( |
|
1105 TPositionFieldId(genInfo->MaxFields() + 1), TUint8(1))); // some value |
|
1106 |
|
1107 // Now check things are ok |
|
1108 for (TInt j = 2; j < genInfo->MaxFields() + 1; j++) |
|
1109 { |
|
1110 TUint8 testUint = 0; |
|
1111 CHECK_EQUAL_(KErrNone, genInfo->GetValue(TPositionFieldId(j), testUint)); |
|
1112 CHECK_EQUAL_(j, testUint); |
|
1113 } |
|
1114 |
|
1115 genInfo->ClearPositionData(); |
|
1116 __UHEAP_MARKEND; |
|
1117 delete genInfo; |
|
1118 __UHEAP_MARKEND; |
|
1119 |
|
1120 StandardCleanup(); |
|
1121 } |