1 /* |
|
2 * Copyright (c) 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: This module contains the implementation of |
|
15 * TTCKeywords class member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "TestKeywords.h" |
|
22 |
|
23 // EXTERNAL DATA STRUCTURES |
|
24 // None |
|
25 |
|
26 // EXTERNAL FUNCTION PROTOTYPES |
|
27 // None |
|
28 |
|
29 // CONSTANTS |
|
30 // None |
|
31 |
|
32 // MACROS |
|
33 // None |
|
34 |
|
35 // LOCAL CONSTANTS AND MACROS |
|
36 // None |
|
37 |
|
38 // MODULE DATA STRUCTURES |
|
39 // None |
|
40 |
|
41 // LOCAL FUNCTION PROTOTYPES |
|
42 // None |
|
43 |
|
44 // FORWARD DECLARATIONS |
|
45 // None |
|
46 |
|
47 // ==================== LOCAL FUNCTIONS ======================================= |
|
48 // None |
|
49 |
|
50 |
|
51 // ================= MEMBER FUNCTIONS ========================================= |
|
52 |
|
53 /* |
|
54 ------------------------------------------------------------------------------- |
|
55 |
|
56 Class: TTCKeywords |
|
57 |
|
58 Method: Keyword |
|
59 |
|
60 Description: Returns a string desrciptor corresponding to keyword number. |
|
61 |
|
62 Parameters: TKeywords aKeyword: in: keyword index. |
|
63 |
|
64 Return Values: TPtrC8: keyword descriptor |
|
65 |
|
66 Errors/Exceptions: None |
|
67 |
|
68 Status: Approved |
|
69 |
|
70 ------------------------------------------------------------------------------- |
|
71 */ |
|
72 TPtrC TTCKeywords::Keyword( TInt aKeyword ) |
|
73 { |
|
74 static TText* const keywords[] = |
|
75 { |
|
76 (TText*)L"title", |
|
77 (TText*)L"run", |
|
78 (TText*)L"cancel", |
|
79 (TText*)L"pause", |
|
80 (TText*)L"resume", |
|
81 (TText*)L"complete", |
|
82 (TText*)L"request", |
|
83 (TText*)L"wait", |
|
84 (TText*)L"release", |
|
85 (TText*)L"set", |
|
86 (TText*)L"unset", |
|
87 (TText*)L"timeout", |
|
88 (TText*)L"priority", |
|
89 (TText*)L"print", |
|
90 (TText*)L"allocate", |
|
91 (TText*)L"free", |
|
92 (TText*)L"remote", |
|
93 (TText*)L"sendreceive", |
|
94 (TText*)L"canceliferror", |
|
95 (TText*)L"measurement", |
|
96 (TText*)L"loop", |
|
97 (TText*)L"endloop", |
|
98 (TText*)L"pausecombiner", |
|
99 }; |
|
100 |
|
101 if( (TUint)aKeyword >= (sizeof( keywords )/sizeof(TText*)) ) |
|
102 { |
|
103 TPtrC null; |
|
104 return null; |
|
105 } |
|
106 |
|
107 TPtrC keyword( keywords[ aKeyword ] ); |
|
108 return keyword; |
|
109 |
|
110 } |
|
111 |
|
112 /* |
|
113 ------------------------------------------------------------------------------- |
|
114 |
|
115 Class: TTCKeywords |
|
116 |
|
117 Method: RunOptArg |
|
118 |
|
119 Description: Returns a string desrciptor corresponding to run keyword |
|
120 optional argument number. |
|
121 |
|
122 Parameters: TRunOptArgs aArg: in: run keyword optional argument index |
|
123 |
|
124 Return Values: TPtrC8: argument descriptor |
|
125 |
|
126 Errors/Exceptions: None |
|
127 |
|
128 Status: Approved |
|
129 |
|
130 ------------------------------------------------------------------------------- |
|
131 */ |
|
132 TPtrC TTCKeywords::RunOptArg( TInt aArg ) |
|
133 { |
|
134 static TText* const runOptArgs[] = |
|
135 { |
|
136 (TText*)L"expect", |
|
137 (TText*)L"testid", |
|
138 (TText*)L"ini", |
|
139 (TText*)L"category", |
|
140 (TText*)L"timeout", |
|
141 (TText*)L"title", |
|
142 (TText*)L"args", |
|
143 }; |
|
144 |
|
145 if( aArg >= (TInt)(sizeof( runOptArgs )/sizeof(TText*)) ) |
|
146 { |
|
147 TPtrC null; |
|
148 return null; |
|
149 } |
|
150 |
|
151 TPtrC arg( runOptArgs[ aArg ] ); |
|
152 return arg; |
|
153 |
|
154 } |
|
155 |
|
156 /* |
|
157 ------------------------------------------------------------------------------- |
|
158 |
|
159 Class: TTCKeywords |
|
160 |
|
161 Method: PauseOptArg |
|
162 |
|
163 Description: Returns a string desrciptor corresponding to pause keyword |
|
164 optional argument number. |
|
165 |
|
166 Parameters: TPauseOptArgs aArg: in: argument index. |
|
167 |
|
168 Return Values: TPtrC8: argument descriptor |
|
169 |
|
170 Errors/Exceptions: None |
|
171 |
|
172 Status: Approved |
|
173 |
|
174 ------------------------------------------------------------------------------- |
|
175 */ |
|
176 TPtrC TTCKeywords::PauseOptArg( TInt aArg ) |
|
177 { |
|
178 static TText* const pauseOptArgs[] = |
|
179 { |
|
180 (TText*)L"time", |
|
181 }; |
|
182 |
|
183 if( aArg >= (TInt)(sizeof( pauseOptArgs )/sizeof(TText*)) ) |
|
184 { |
|
185 TPtrC null; |
|
186 return null; |
|
187 } |
|
188 |
|
189 TPtrC arg( pauseOptArgs[ aArg ] ); |
|
190 return arg; |
|
191 |
|
192 } |
|
193 |
|
194 /* |
|
195 ------------------------------------------------------------------------------- |
|
196 |
|
197 Class: TTCKeywords |
|
198 |
|
199 Method: EventOptArg |
|
200 |
|
201 Description: Returns a string desrciptor corresponding to event keywords |
|
202 optional argument number. |
|
203 |
|
204 Parameters: TEventOptArgs aArg: in: argument index. |
|
205 |
|
206 Return Values: TPtrC8: keyword descriptor |
|
207 |
|
208 Errors/Exceptions: None |
|
209 |
|
210 Status: Approved |
|
211 |
|
212 ------------------------------------------------------------------------------- |
|
213 */ |
|
214 TPtrC TTCKeywords::EventOptArg( TInt aArg ) |
|
215 { |
|
216 static TText* const optArgs[] = |
|
217 { |
|
218 (TText*)L"state", |
|
219 }; |
|
220 |
|
221 if( aArg >= (TInt)(sizeof( optArgs )/sizeof(TText*)) ) |
|
222 { |
|
223 TPtrC null; |
|
224 return null; |
|
225 } |
|
226 |
|
227 TPtrC arg( optArgs[ aArg ] ); |
|
228 return arg; |
|
229 |
|
230 } |
|
231 |
|
232 /* |
|
233 ------------------------------------------------------------------------------- |
|
234 |
|
235 Class: TTCKeywords |
|
236 |
|
237 Method: ResultCategory |
|
238 |
|
239 Description: Returns a string desrciptor corresponding to event keywords |
|
240 optional argument number. |
|
241 |
|
242 Parameters: TEventOptArgs aArg: in: argument index. |
|
243 |
|
244 Return Values: TPtrC8: keyword descriptor |
|
245 |
|
246 Errors/Exceptions: None |
|
247 |
|
248 Status: Approved |
|
249 |
|
250 ------------------------------------------------------------------------------- |
|
251 */ |
|
252 TPtrC TTCKeywords::Priority( TInt aArg ) |
|
253 { |
|
254 static TText* const priority[] = |
|
255 { |
|
256 (TText*)L"high", |
|
257 (TText*)L"normal", |
|
258 (TText*)L"low", |
|
259 }; |
|
260 |
|
261 if( aArg >= (TInt)(sizeof( priority )/sizeof(TText*)) ) |
|
262 { |
|
263 TPtrC null; |
|
264 return null; |
|
265 } |
|
266 |
|
267 TPtrC arg( priority[ aArg ] ); |
|
268 return arg; |
|
269 |
|
270 } |
|
271 |
|
272 /* |
|
273 ------------------------------------------------------------------------------- |
|
274 |
|
275 Class: TTCKeywords |
|
276 |
|
277 Method: Parse |
|
278 |
|
279 Description: Returns a keyword enum corresponding to keyword |
|
280 string descriptor. |
|
281 |
|
282 Parameters: TPtrC aKeyword: in: keyword descriptor. |
|
283 KeywordFunc aFunc: in: Function pointer to keyword parser |
|
284 |
|
285 Return Values: TInt: keyword index |
|
286 KErrNotFound: keyword not found |
|
287 |
|
288 Errors/Exceptions: None |
|
289 |
|
290 Status: Proposal |
|
291 |
|
292 ------------------------------------------------------------------------------- |
|
293 */ |
|
294 TInt TTCKeywords::Parse( TDesC& aKeyword, KeywordFunc aFunc ) |
|
295 { |
|
296 TInt ind; |
|
297 for( ind = 0; aFunc( ind ).Length() > 0; ind++ ) |
|
298 { |
|
299 if( aFunc( ind ) == aKeyword ) |
|
300 { |
|
301 return ind; |
|
302 } |
|
303 } |
|
304 return KErrNotFound; |
|
305 }; |
|
306 |
|
307 /* |
|
308 ------------------------------------------------------------------------------- |
|
309 |
|
310 Class: TTCKeywords |
|
311 |
|
312 Method: ResultCategory |
|
313 |
|
314 Description: Returns a string desrciptor corresponding to result |
|
315 category number. |
|
316 |
|
317 Parameters: TInt aArg: in: argument index. |
|
318 |
|
319 Return Values: TPtrC: keyword descriptor |
|
320 |
|
321 Errors/Exceptions: None |
|
322 |
|
323 Status: Proposal |
|
324 |
|
325 ------------------------------------------------------------------------------- |
|
326 */ |
|
327 TPtrC TTCKeywords::ResultCategory( TInt aArg ) |
|
328 { |
|
329 static TText* const category[] = |
|
330 { |
|
331 (TText*)L"ongoing", |
|
332 (TText*)L"normal", |
|
333 (TText*)L"cancelled", |
|
334 (TText*)L"errorfrommodule", |
|
335 (TText*)L"leave", |
|
336 (TText*)L"panic", |
|
337 (TText*)L"exception", |
|
338 (TText*)L"timeout", |
|
339 }; |
|
340 |
|
341 if( aArg >= (TInt)(sizeof( category )/sizeof(TText*)) ) |
|
342 { |
|
343 TPtrC null; |
|
344 return null; |
|
345 } |
|
346 |
|
347 TPtrC arg( category[ aArg ] ); |
|
348 return arg; |
|
349 |
|
350 } |
|
351 |
|
352 /* |
|
353 ------------------------------------------------------------------------------- |
|
354 |
|
355 Class: TTCKeywords |
|
356 |
|
357 Method: ResultCategory |
|
358 |
|
359 Description: Returns a string desrciptor corresponding to event keywords |
|
360 optional argument number. |
|
361 |
|
362 Parameters: TEventOptArgs aArg: in: argument index. |
|
363 |
|
364 Return Values: TPtrC8: keyword descriptor |
|
365 |
|
366 Errors/Exceptions: None |
|
367 |
|
368 Status: Proposal |
|
369 |
|
370 ------------------------------------------------------------------------------- |
|
371 */ |
|
372 TFullTestResult::TCaseExecutionResult |
|
373 TTCKeywords::GetResultCategory( TDesC& aCategory ) |
|
374 { |
|
375 |
|
376 TInt ind; |
|
377 for( ind = 0; ResultCategory( ind ).Length() > 0; ind++ ) |
|
378 { |
|
379 if( ResultCategory( ind ) == aCategory ) |
|
380 { |
|
381 switch( ind ) |
|
382 { |
|
383 case TFullTestResult::ECaseExecuted: |
|
384 case TFullTestResult::ECaseLeave: |
|
385 case TFullTestResult::ECasePanic: |
|
386 case TFullTestResult::ECaseException: |
|
387 case TFullTestResult::ECaseTimeout: |
|
388 return (TFullTestResult::TCaseExecutionResult)ind; |
|
389 default: |
|
390 break; |
|
391 } |
|
392 } |
|
393 } |
|
394 return TFullTestResult::ECaseOngoing; |
|
395 } |
|
396 |
|
397 // ================= OTHER EXPORTED FUNCTIONS ================================= |
|
398 // None |
|
399 |
|
400 // End of File |
|