|
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 * TTestKeywords 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 // ================= MEMBER FUNCTIONS ========================================= |
|
51 |
|
52 /* |
|
53 ------------------------------------------------------------------------------- |
|
54 |
|
55 Class: TTestKeywords |
|
56 |
|
57 Method: Keyword |
|
58 |
|
59 Description: Returns a string desrciptor corresponding to keyword number. |
|
60 |
|
61 Parameters: TInt aKeyword: in: keyword index. |
|
62 |
|
63 Return Values: TPtrC8: keyword descriptor |
|
64 |
|
65 Errors/Exceptions: None |
|
66 |
|
67 Status: Approved |
|
68 |
|
69 ------------------------------------------------------------------------------- |
|
70 */ |
|
71 TPtrC TTestKeywords::Keyword( TInt aKeyword ) |
|
72 { |
|
73 static TText* const keywords[] = |
|
74 { |
|
75 (TText*)L"title", |
|
76 (TText*)L"timeout", |
|
77 (TText*)L"priority", |
|
78 (TText*)L"create", |
|
79 (TText*)L"delete", |
|
80 (TText*)L"request", |
|
81 (TText*)L"wait", |
|
82 (TText*)L"release", |
|
83 (TText*)L"set", |
|
84 (TText*)L"unset", |
|
85 (TText*)L"print", |
|
86 (TText*)L"allownextresult", |
|
87 (TText*)L"waittestclass", |
|
88 (TText*)L"createkernel", |
|
89 (TText*)L"pause", |
|
90 (TText*)L"loop", |
|
91 (TText*)L"endloop", |
|
92 (TText*)L"oomignorefailure", |
|
93 (TText*)L"oomheapfailnext", |
|
94 (TText*)L"oomheapsetfail", |
|
95 (TText*)L"oomheaptonormal", |
|
96 (TText*)L"testinterference", |
|
97 (TText*)L"measurement", |
|
98 (TText*)L"allowerrorcodes", |
|
99 (TText*)L"bringtoforeground", |
|
100 (TText*)L"sendtobackground", |
|
101 (TText*)L"presskey", |
|
102 (TText*)L"typetext", |
|
103 (TText*)L"var", |
|
104 (TText*)L"callsub", |
|
105 (TText*)L"createx", |
|
106 (TText*)L"setresultdescription", |
|
107 (TText*)L"sendpointerevent", |
|
108 }; |
|
109 |
|
110 if( (TUint)aKeyword >= (sizeof( keywords )/sizeof(TText*)) ) |
|
111 { |
|
112 TPtrC null; |
|
113 return null; |
|
114 } |
|
115 |
|
116 TPtrC keyword( keywords[ aKeyword ] ); |
|
117 return keyword; |
|
118 |
|
119 } |
|
120 |
|
121 /* |
|
122 ------------------------------------------------------------------------------- |
|
123 |
|
124 Class: TTestKeywords |
|
125 |
|
126 Method: Priority |
|
127 |
|
128 Description: Returns a string desrciptor corresponding to priority |
|
129 keywords optional argument number. |
|
130 |
|
131 Parameters: TInt aArg: in: argument index. |
|
132 |
|
133 Return Values: TPtrC8: keyword descriptor |
|
134 |
|
135 Errors/Exceptions: None |
|
136 |
|
137 Status: Draft |
|
138 |
|
139 ------------------------------------------------------------------------------- |
|
140 */ |
|
141 TPtrC TTestKeywords::Priority( TInt aArg ) |
|
142 { |
|
143 static TText* const priority[] = |
|
144 { |
|
145 (TText*)L"high", |
|
146 (TText*)L"normal", |
|
147 (TText*)L"low", |
|
148 }; |
|
149 |
|
150 if( aArg >= (TInt)(sizeof( priority )/sizeof(TText*)) ) |
|
151 { |
|
152 TPtrC null; |
|
153 return null; |
|
154 } |
|
155 |
|
156 TPtrC arg( priority[ aArg ] ); |
|
157 return arg; |
|
158 |
|
159 } |
|
160 |
|
161 /* |
|
162 ------------------------------------------------------------------------------- |
|
163 |
|
164 Class: TTestKeywords |
|
165 |
|
166 Method: Parse |
|
167 |
|
168 Description: Returns a keyword enum corresponding to keyword |
|
169 string descriptor. |
|
170 |
|
171 Parameters: TPtrC aKeyword: in: keyword descriptor. |
|
172 KeywordFunc aFunc: in: Function pointer to keyword parser |
|
173 |
|
174 Return Values: TInt: keyword index |
|
175 |
|
176 Errors/Exceptions: None |
|
177 |
|
178 Status: Draft |
|
179 |
|
180 ------------------------------------------------------------------------------- |
|
181 */ |
|
182 TInt TTestKeywords::Parse( TDesC& aKeyword, KeywordFunc aFunc ) |
|
183 { |
|
184 TInt ind; |
|
185 for( ind = 0; aFunc( ind ).Length() > 0; ind++ ) |
|
186 { |
|
187 if( aFunc( ind ) == aKeyword ) |
|
188 { |
|
189 return ind; |
|
190 } |
|
191 } |
|
192 return KErrNotFound; |
|
193 }; |
|
194 |
|
195 // ================= OTHER EXPORTED FUNCTIONS ================================= |
|
196 // None |
|
197 |
|
198 // End of File |