|
1 // Copyright (c) 2007-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 // @file ctlbsclientstepignoreaccurracysetting.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include "ctlbsclientstepignoreaccurracysettingtracking.h" |
|
19 |
|
20 #include <lbs.h> |
|
21 #include <lbssatellite.h> |
|
22 |
|
23 #include "tlbsutils.h" |
|
24 #include "ctlbsasyncwaiter.h" |
|
25 |
|
26 _LIT(KUpdateArraySection, "update_array_section"); |
|
27 |
|
28 /** |
|
29 * Construction. |
|
30 */ |
|
31 CT_LbsClientStep_IgnoreAccuracySettingTracking* CT_LbsClientStep_IgnoreAccuracySettingTracking::New(CT_LbsClientServer& aParent) |
|
32 { |
|
33 // Note the lack of ELeave. |
|
34 // This means that having insufficient memory will return NULL; |
|
35 CT_LbsClientStep_IgnoreAccuracySettingTracking* testStep = new CT_LbsClientStep_IgnoreAccuracySettingTracking(aParent); |
|
36 if (testStep) |
|
37 { |
|
38 TInt err = KErrNone; |
|
39 |
|
40 TRAP(err, testStep->ConstructL()); |
|
41 if (err) |
|
42 { |
|
43 delete testStep; |
|
44 testStep = NULL; |
|
45 } |
|
46 } |
|
47 |
|
48 return testStep; |
|
49 } |
|
50 |
|
51 |
|
52 CT_LbsClientStep_IgnoreAccuracySettingTracking::CT_LbsClientStep_IgnoreAccuracySettingTracking(CT_LbsClientServer& aParent) |
|
53 : CT_LbsClientStep(aParent), iTestCaseId(0) |
|
54 { |
|
55 SetTestStepName(KLbsClientStep_IgnoreAccuracySettingTracking); |
|
56 } |
|
57 |
|
58 |
|
59 void CT_LbsClientStep_IgnoreAccuracySettingTracking::ConstructL() |
|
60 { |
|
61 // Connect server. |
|
62 User::LeaveIfError(iServer.Connect()); |
|
63 } |
|
64 |
|
65 |
|
66 /** |
|
67 * Destructor |
|
68 */ |
|
69 CT_LbsClientStep_IgnoreAccuracySettingTracking::~CT_LbsClientStep_IgnoreAccuracySettingTracking() |
|
70 { |
|
71 for(TInt index = 0; index < iExpectedUpdateArray.Count(); ++index) |
|
72 { |
|
73 delete iExpectedUpdateArray[index]; |
|
74 } |
|
75 iExpectedUpdateArray.Close(); |
|
76 iPositioner.Close(); |
|
77 iServer.Close(); |
|
78 } |
|
79 |
|
80 TVerdict CT_LbsClientStep_IgnoreAccuracySettingTracking::doTestStepPreambleL() |
|
81 { |
|
82 // Process some common pre setting to test steps then set SetTestStepResult to EFail or Epass. |
|
83 INFO_PRINTF1(_L(">>CT_LbsClientStep::doTestStepPreambleL()")); |
|
84 SetTestStepResult(EPass); |
|
85 |
|
86 if(GetIntFromConfig(ConfigSection(), KTestCaseId, iTestCaseId)) |
|
87 { |
|
88 switch(iTestCaseId) |
|
89 { |
|
90 case 112: // LBS-IGNORE-ACCURACY-ON-TRACKING-001 |
|
91 case 212: // LBS-IGNORE-ACCURACY-OFF-TRACKING-001 |
|
92 { // do nothing |
|
93 User::LeaveIfError(iPositioner.Open(iServer)); |
|
94 |
|
95 T_LbsUtils utils; |
|
96 TPtrC configFileName; |
|
97 _LIT(KUpdateOptionsFile, "pos_infos_file"); |
|
98 |
|
99 GetStringFromConfig(ConfigSection(), KUpdateOptionsFile, configFileName); |
|
100 |
|
101 TPositionUpdateOptions updateOpts; |
|
102 |
|
103 utils.GetConfigured_ModuleUpdateOptionsL(configFileName, ConfigSection(), updateOpts); |
|
104 iPositioner.SetUpdateOptions(updateOpts); |
|
105 |
|
106 TPtrC updateArraySection; |
|
107 GetStringFromConfig(ConfigSection(), KUpdateArraySection, updateArraySection); |
|
108 |
|
109 utils.GetConfigured_PosInfosL(configFileName, updateArraySection, iExpectedUpdateArray); |
|
110 |
|
111 break; |
|
112 } |
|
113 default: |
|
114 { |
|
115 SetTestStepResult(EFail); |
|
116 } |
|
117 } |
|
118 } |
|
119 else |
|
120 { |
|
121 SetTestStepResult(EFail); |
|
122 } |
|
123 |
|
124 return TestStepResult(); |
|
125 } |
|
126 |
|
127 /** |
|
128 * @return - TVerdict code |
|
129 * Override of base class pure virtual |
|
130 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
131 * not leave. That being the case, the current test result value will be EPass. |
|
132 */ |
|
133 TVerdict CT_LbsClientStep_IgnoreAccuracySettingTracking::doTestStepL() |
|
134 { |
|
135 // Generic test step used to test the LBS SetUpdateOptions API. |
|
136 INFO_PRINTF1(_L(">>CT_LbsClientStep_IgnoreAccuracySettingTracking::doTestStepL()")); |
|
137 |
|
138 if (TestStepResult()==EPass) |
|
139 { |
|
140 T_LbsUtils utils; |
|
141 TPositionInfo* posInfo = new(ELeave) TPositionInfo(); |
|
142 CleanupStack::PushL(posInfo); |
|
143 |
|
144 // Perfom test. |
|
145 TInt err = KErrNone; |
|
146 TPosition pos; |
|
147 TInt numOfPosInfos = 5; |
|
148 |
|
149 for(TInt updateIndex = 0 ; TestStepResult()==EPass && updateIndex < numOfPosInfos; |
|
150 ++updateIndex) |
|
151 { |
|
152 // Do request to position update. |
|
153 err = DoNotifyUpdateL(*posInfo); |
|
154 |
|
155 switch(iTestCaseId) |
|
156 { |
|
157 case 212: // LBS-IGNORE-ACCURACY-OFF-TRACKING-001 |
|
158 { |
|
159 switch(updateIndex) |
|
160 { |
|
161 case 0: |
|
162 case 1: |
|
163 case 3: |
|
164 { |
|
165 if(KPositionQualityLoss != err) |
|
166 { |
|
167 SetTestStepResult(EFail); |
|
168 } |
|
169 break; |
|
170 } |
|
171 case 2: |
|
172 case 4: |
|
173 { |
|
174 if(KErrNone != err) |
|
175 { |
|
176 SetTestStepResult(EFail); |
|
177 } |
|
178 break; |
|
179 } |
|
180 default: |
|
181 { |
|
182 SetTestStepResult(EFail); |
|
183 } |
|
184 } |
|
185 TPositionInfoBase* expectedPosition = |
|
186 static_cast<TPositionInfoBase*>(iExpectedUpdateArray[updateIndex]); |
|
187 if(!utils.Compare_PosInfo(*posInfo, *expectedPosition)) |
|
188 { |
|
189 SetTestStepResult(EFail); |
|
190 } |
|
191 break; |
|
192 } |
|
193 case 112: // LBS-IGNORE-ACCURACY-ON-TRACKING-001 |
|
194 { |
|
195 if(KErrNone != err) |
|
196 { |
|
197 SetTestStepResult(EFail); |
|
198 } |
|
199 TPositionInfoBase* expectedPosition = |
|
200 static_cast<TPositionInfoBase*>(iExpectedUpdateArray[updateIndex]); |
|
201 if(!utils.Compare_PosInfo(*posInfo, *expectedPosition)) |
|
202 { |
|
203 SetTestStepResult(EFail); |
|
204 } |
|
205 break; |
|
206 } |
|
207 default: |
|
208 { |
|
209 SetTestStepResult(EFail); |
|
210 } |
|
211 } |
|
212 } |
|
213 CleanupStack::PopAndDestroy(posInfo); |
|
214 } |
|
215 |
|
216 INFO_PRINTF1(_L("<<CT_LbsClientStep_IgnoreAccuracySettingTracking::doTestStepL()")); |
|
217 |
|
218 return TestStepResult(); |
|
219 } |