1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file CTestConfig.cpp |
|
22 */ |
|
23 |
|
24 #include "tefunit.h" |
|
25 |
|
26 CTestConfig::CTestConfig() |
|
27 /** |
|
28 * Constructor |
|
29 */ |
|
30 { |
|
31 } |
|
32 |
|
33 CTestConfig::CTestConfig( CTestStep* aTestStep ) |
|
34 /** |
|
35 * Constructor |
|
36 * |
|
37 * @param aTestStep - Test step to use for the configuration access |
|
38 */ |
|
39 : iTestStep(aTestStep) |
|
40 { |
|
41 } |
|
42 |
|
43 CTestConfig::CTestConfig(const CTestConfig& aTestConfig ) |
|
44 /** |
|
45 * Constructor |
|
46 * |
|
47 * @param aTestConfig - Test config to copy |
|
48 */ |
|
49 { |
|
50 iTestStep = aTestConfig.iTestStep; |
|
51 } |
|
52 |
|
53 CTestConfig::~CTestConfig() |
|
54 /** |
|
55 * Destructor |
|
56 */ |
|
57 { |
|
58 } |
|
59 |
|
60 TBool CTestConfig::GetBool(const TDesC& aSectionName, const TDesC& aKey, TBool& aResult) const |
|
61 /** |
|
62 * GetBool |
|
63 * |
|
64 * @param aSectionName - Section name within the ini file |
|
65 * @param aKey - Key within the ini file |
|
66 * @param aResult - Retrieved boolean |
|
67 * @return - Call result |
|
68 */ |
|
69 { |
|
70 return iTestStep->GetBoolFromConfig( aSectionName, aKey, aResult ); |
|
71 } |
|
72 |
|
73 TBool CTestConfig::GetInt(const TDesC& aSectionName, const TDesC& aKey, TInt& aResult) const |
|
74 /** |
|
75 * GetInt |
|
76 * |
|
77 * @param aSectionName - Section name within the ini file |
|
78 * @param aKey - Key within the ini file |
|
79 * @param aResult - Retrieved int |
|
80 * @return - Call result |
|
81 */ |
|
82 { |
|
83 return iTestStep->GetIntFromConfig( aSectionName, aKey, aResult ); |
|
84 } |
|
85 TBool CTestConfig::GetInt(const TDesC& aSectionName, const TDesC& aKey, TInt64& aResult) const |
|
86 /** |
|
87 * GetInt |
|
88 * |
|
89 * @param aSectionName - Section name within the ini file |
|
90 * @param aKey - Key within the ini file |
|
91 * @param aResult - Retrieved int64 |
|
92 * @return - Call result |
|
93 */ |
|
94 { |
|
95 return iTestStep->GetIntFromConfig( aSectionName, aKey, aResult ); |
|
96 } |
|
97 |
|
98 TBool CTestConfig::GetInt(const TDesC& aKey, TInt64& aResult) const |
|
99 /** |
|
100 * GetInt |
|
101 * |
|
102 * @param aKey - Key within the ini file |
|
103 * @param aResult - Retrieved int64 |
|
104 * @return - Call result |
|
105 */ |
|
106 { |
|
107 TBool ret = EFalse; |
|
108 if( iTestStep->ConfigSection().Length() > 0 ) |
|
109 { |
|
110 ret = iTestStep->GetIntFromConfig( iTestStep->ConfigSection(), aKey, aResult ); |
|
111 } |
|
112 return ret; |
|
113 } |
|
114 |
|
115 TBool CTestConfig::WriteInt(const TDesC& aSectionName, const TDesC& aKey, TInt64& aValue) const |
|
116 /** |
|
117 * WriteInt |
|
118 * |
|
119 * @param aSectionName - Section name within the ini file |
|
120 * @param aKey - Key within the ini file |
|
121 * @param aValue - Written int64 |
|
122 * @return - Call result |
|
123 */ |
|
124 { |
|
125 return iTestStep->WriteIntToConfig( aSectionName, aKey, aValue ); |
|
126 } |
|
127 |
|
128 TBool CTestConfig::WriteInt(const TDesC& aKey, TInt64& aValue) const |
|
129 /** |
|
130 * WriteInt |
|
131 * |
|
132 * @param aKey - Key within the ini file |
|
133 * @param aValue - Written int |
|
134 * @return - Call result |
|
135 */ |
|
136 { |
|
137 TBool ret = EFalse; |
|
138 if( iTestStep->ConfigSection().Length() > 0 ) |
|
139 { |
|
140 ret = iTestStep->WriteIntToConfig( iTestStep->ConfigSection(), aKey, aValue ); |
|
141 } |
|
142 return ret; |
|
143 } |
|
144 TBool CTestConfig::GetHex(const TDesC& aSectionName, const TDesC& aKey, TInt& aResult) const |
|
145 /** |
|
146 * GetHex |
|
147 * |
|
148 * @param aSectionName - Section name within the ini file |
|
149 * @param aKey - Key within the ini file |
|
150 * @param aResult - Retrieved hex |
|
151 * @return - Call result |
|
152 */ |
|
153 { |
|
154 return iTestStep->GetHexFromConfig( aSectionName, aKey, aResult ); |
|
155 } |
|
156 |
|
157 TBool CTestConfig::GetString(const TDesC& aSectionName, const TDesC& aKey, TPtrC& aResult) const |
|
158 /** |
|
159 * GetString |
|
160 * |
|
161 * @param aSectionName - Section name within the ini file |
|
162 * @param aKey - Key within the ini file |
|
163 * @param aResult - Retrieved string |
|
164 * @return - Call result |
|
165 */ |
|
166 { |
|
167 return iTestStep->GetStringFromConfig( aSectionName, aKey, aResult ); |
|
168 } |
|
169 |
|
170 TBool CTestConfig::GetBool(const TDesC& aKey, TBool& aResult) const |
|
171 /** |
|
172 * GetBool |
|
173 * |
|
174 * @param aKey - Key within the ini file |
|
175 * @param aResult - Retrieved boolean from section passed in via the script |
|
176 * @return - Call result |
|
177 */ |
|
178 { |
|
179 TBool ret = EFalse; |
|
180 if( iTestStep->ConfigSection().Length() > 0 ) |
|
181 { |
|
182 ret = iTestStep->GetBoolFromConfig( iTestStep->ConfigSection(), aKey, aResult ); |
|
183 } |
|
184 return ret; |
|
185 } |
|
186 |
|
187 TBool CTestConfig::GetInt(const TDesC& aKey, TInt& aResult) const |
|
188 /** |
|
189 * GetInt |
|
190 * |
|
191 * @param aKey - Key within the ini file |
|
192 * @param aResult - Retrieved int |
|
193 * @return - Call result |
|
194 */ |
|
195 { |
|
196 TBool ret = EFalse; |
|
197 if( iTestStep->ConfigSection().Length() > 0 ) |
|
198 { |
|
199 ret = iTestStep->GetIntFromConfig( iTestStep->ConfigSection(), aKey, aResult ); |
|
200 } |
|
201 return ret; |
|
202 } |
|
203 |
|
204 TBool CTestConfig::GetHex(const TDesC& aKey, TInt& aResult) const |
|
205 /** |
|
206 * GetHex |
|
207 * |
|
208 * @param aKey - Key within the ini file |
|
209 * @param aResult - Retrieved hex |
|
210 * @return - Call result |
|
211 */ |
|
212 { |
|
213 TBool ret = EFalse; |
|
214 if( iTestStep->ConfigSection().Length() > 0 ) |
|
215 { |
|
216 ret = iTestStep->GetHexFromConfig( iTestStep->ConfigSection(), aKey, aResult ); |
|
217 } |
|
218 return ret; |
|
219 } |
|
220 |
|
221 TBool CTestConfig::GetString(const TDesC& aKey, TPtrC& aResult) const |
|
222 /** |
|
223 * GetString |
|
224 * |
|
225 * @param aKey - Key within the ini file |
|
226 * @param aResult - Retrieved string |
|
227 * @return - Call result |
|
228 */ |
|
229 { |
|
230 TBool ret = EFalse; |
|
231 if( iTestStep->ConfigSection().Length() > 0 ) |
|
232 { |
|
233 ret = iTestStep->GetStringFromConfig( iTestStep->ConfigSection(), aKey, aResult ); |
|
234 } |
|
235 return ret; |
|
236 } |
|
237 |
|
238 // Newly added functions for writing to ini file |
|
239 TBool CTestConfig::WriteBool(const TDesC& aSectionName, const TDesC& aKey, TBool& aValue) const |
|
240 /** |
|
241 * WriteBool |
|
242 * |
|
243 * @param aSectionName - Section name within the ini file |
|
244 * @param aKey - Key within the ini file |
|
245 * @param aValue - Written boolean |
|
246 * @return - Call result |
|
247 */ |
|
248 { |
|
249 return iTestStep->WriteBoolToConfig( aSectionName, aKey, aValue ); |
|
250 } |
|
251 |
|
252 TBool CTestConfig::WriteInt(const TDesC& aSectionName, const TDesC& aKey, TInt& aValue) const |
|
253 /** |
|
254 * WriteInt |
|
255 * |
|
256 * @param aSectionName - Section name within the ini file |
|
257 * @param aKey - Key within the ini file |
|
258 * @param aValue - Written int |
|
259 * @return - Call result |
|
260 */ |
|
261 { |
|
262 return iTestStep->WriteIntToConfig( aSectionName, aKey, aValue ); |
|
263 } |
|
264 |
|
265 TBool CTestConfig::WriteHex(const TDesC& aSectionName, const TDesC& aKey, TInt& aValue) const |
|
266 /** |
|
267 * WriteHex |
|
268 * |
|
269 * @param aSectionName - Section name within the ini file |
|
270 * @param aKey - Key within the ini file |
|
271 * @param aValue - Written hex |
|
272 * @return - Call result |
|
273 */ |
|
274 { |
|
275 return iTestStep->WriteHexToConfig( aSectionName, aKey, aValue ); |
|
276 } |
|
277 |
|
278 TBool CTestConfig::WriteString(const TDesC& aSectionName, const TDesC& aKey, TPtrC& aValue) const |
|
279 /** |
|
280 * WriteString |
|
281 * |
|
282 * @param aSectionName - Section name within the ini file |
|
283 * @param aKey - Key within the ini file |
|
284 * @param aValue - Written string |
|
285 * @return - Call result |
|
286 */ |
|
287 { |
|
288 return iTestStep->WriteStringToConfig( aSectionName, aKey, aValue ); |
|
289 } |
|
290 |
|
291 TBool CTestConfig::WriteBool(const TDesC& aKey, TBool& aValue) const |
|
292 /** |
|
293 * WriteBool |
|
294 * |
|
295 * @param aKey - Key within the ini file |
|
296 * @param aValue - Written boolean from section passed in via the script |
|
297 * @return - Call result |
|
298 */ |
|
299 { |
|
300 TBool ret = EFalse; |
|
301 if( iTestStep->ConfigSection().Length() > 0 ) |
|
302 { |
|
303 ret = iTestStep->WriteBoolToConfig( iTestStep->ConfigSection(), aKey, aValue ); |
|
304 } |
|
305 return ret; |
|
306 } |
|
307 |
|
308 TBool CTestConfig::WriteInt(const TDesC& aKey, TInt& aValue) const |
|
309 /** |
|
310 * WriteInt |
|
311 * |
|
312 * @param aKey - Key within the ini file |
|
313 * @param aValue - Written int |
|
314 * @return - Call result |
|
315 */ |
|
316 { |
|
317 TBool ret = EFalse; |
|
318 if( iTestStep->ConfigSection().Length() > 0 ) |
|
319 { |
|
320 ret = iTestStep->WriteIntToConfig( iTestStep->ConfigSection(), aKey, aValue ); |
|
321 } |
|
322 return ret; |
|
323 } |
|
324 |
|
325 TBool CTestConfig::WriteHex(const TDesC& aKey, TInt& aValue) const |
|
326 /** |
|
327 * WriteHex |
|
328 * |
|
329 * @param aKey - Key within the ini file |
|
330 * @param aValue - Written hex |
|
331 * @return - Call result |
|
332 */ |
|
333 { |
|
334 TBool ret = EFalse; |
|
335 if( iTestStep->ConfigSection().Length() > 0 ) |
|
336 { |
|
337 ret = iTestStep->WriteHexToConfig( iTestStep->ConfigSection(), aKey, aValue ); |
|
338 } |
|
339 return ret; |
|
340 } |
|
341 |
|
342 TBool CTestConfig::WriteString(const TDesC& aKey, TPtrC& aValue) const |
|
343 /** |
|
344 * WriteString |
|
345 * |
|
346 * @param aKey - Key within the ini file |
|
347 * @param aValue - Written string |
|
348 * @return - Call result |
|
349 */ |
|
350 { |
|
351 TBool ret = EFalse; |
|
352 if( iTestStep->ConfigSection().Length() > 0 ) |
|
353 { |
|
354 ret = iTestStep->WriteStringToConfig( iTestStep->ConfigSection(), aKey, aValue ); |
|
355 } |
|
356 return ret; |
|
357 } |
|