25 _LIT( KTestsKeyShort, "-t=" ); |
25 _LIT( KTestsKeyShort, "-t=" ); |
26 _LIT( KTestCasesKey, "-cases=" ); |
26 _LIT( KTestCasesKey, "-cases=" ); |
27 _LIT( KTestCasesKeyShort, "-c=" ); |
27 _LIT( KTestCasesKeyShort, "-c=" ); |
28 _LIT( KAllocKey, "-alloc" ); |
28 _LIT( KAllocKey, "-alloc" ); |
29 _LIT( KAllocKeyShort, "-a" ); |
29 _LIT( KAllocKeyShort, "-a" ); |
|
30 _LIT( KBackgroundKey, "-background" ); |
|
31 _LIT( KBackgroundKeyShort, "-b" ); |
30 _LIT( KOutputKey, "-output=" ); |
32 _LIT( KOutputKey, "-output=" ); |
31 _LIT( KOutputKeyShort, "-o=" ); |
33 _LIT( KOutputKeyShort, "-o=" ); |
32 _LIT( KNoPromptKey, "-noprompt" ); |
34 _LIT( KNoPromptKey, "-noprompt" ); |
33 _LIT( KTimeoutKey, "-timeout=" ); |
35 _LIT( KTimeoutKey, "-timeout=" ); |
34 _LIT( KTimeoutKeyShort, "-to=" ); |
36 _LIT( KTimeoutKeyShort, "-to=" ); |
65 // ----------------------------------------------------------------------------- |
67 // ----------------------------------------------------------------------------- |
66 // |
68 // |
67 // ----------------------------------------------------------------------------- |
69 // ----------------------------------------------------------------------------- |
68 // |
70 // |
69 CSymbianUnitTestCommandLineParser::CSymbianUnitTestCommandLineParser() |
71 CSymbianUnitTestCommandLineParser::CSymbianUnitTestCommandLineParser() |
|
72 : iBackground( EFalse ) |
70 { |
73 { |
71 } |
74 } |
72 |
75 |
73 // ----------------------------------------------------------------------------- |
76 // ----------------------------------------------------------------------------- |
74 // |
77 // |
79 iArguments = CCommandLineArguments::NewL(); |
82 iArguments = CCommandLineArguments::NewL(); |
80 TPtrC dummy; |
83 TPtrC dummy; |
81 iShowHelp = FindArgument( KHelpKey, KHelpKeyShort, dummy ); |
84 iShowHelp = FindArgument( KHelpKey, KHelpKeyShort, dummy ); |
82 iAllocFailureSimulation = FindArgument( KAllocKey, KAllocKeyShort, dummy ); |
85 iAllocFailureSimulation = FindArgument( KAllocKey, KAllocKeyShort, dummy ); |
83 iNoPrompt = FindArgument( KNoPromptKey, KNoPromptKey, dummy ); |
86 iNoPrompt = FindArgument( KNoPromptKey, KNoPromptKey, dummy ); |
|
87 iBackground = FindArgument( KBackgroundKey, KBackgroundKeyShort, dummy ); |
84 SetOutputFormatL(); |
88 SetOutputFormatL(); |
85 SetTimeoutL(); |
89 SetTimeoutL(); |
86 SetTestDllNamesL(); |
90 SetTestDllNamesL(); |
87 SetTestCaseNamesL(); |
91 SetTestCaseNamesL(); |
88 } |
92 } |
137 |
141 |
138 // ----------------------------------------------------------------------------- |
142 // ----------------------------------------------------------------------------- |
139 // |
143 // |
140 // ----------------------------------------------------------------------------- |
144 // ----------------------------------------------------------------------------- |
141 // |
145 // |
|
146 TBool CSymbianUnitTestCommandLineParser::Background() const |
|
147 { |
|
148 return iBackground; |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
142 const TDesC& CSymbianUnitTestCommandLineParser::OutputFileName() const |
155 const TDesC& CSymbianUnitTestCommandLineParser::OutputFileName() const |
143 { |
156 { |
144 return KOutputFileName; |
157 return KOutputFileName; |
145 } |
158 } |
146 |
159 |
178 // |
191 // |
179 void CSymbianUnitTestCommandLineParser::SetOutputFormatL() |
192 void CSymbianUnitTestCommandLineParser::SetOutputFormatL() |
180 { |
193 { |
181 HBufC* outputFormat = NULL; |
194 HBufC* outputFormat = NULL; |
182 TPtrC outputFormatPtr; |
195 TPtrC outputFormatPtr; |
183 if ( FindArgument( KOutputKey, KOutputKeyShort, outputFormatPtr ) ) |
196 TBool found = EFalse; |
|
197 found = FindArgument( KOutputKey, KOutputKeyShort, outputFormatPtr ); |
|
198 if ( found ) |
184 { |
199 { |
185 outputFormat = outputFormatPtr.AllocL(); |
200 outputFormat = outputFormatPtr.AllocL(); |
186 } |
201 } |
187 else |
202 else |
188 { |
203 { |
202 TPtrC timeoutPtr; |
217 TPtrC timeoutPtr; |
203 TBool hasTimeout = FindArgument( KTimeoutKey, KTimeoutKeyShort, timeoutPtr ); |
218 TBool hasTimeout = FindArgument( KTimeoutKey, KTimeoutKeyShort, timeoutPtr ); |
204 if ( hasTimeout) |
219 if ( hasTimeout) |
205 { |
220 { |
206 TLex timeoutLex(timeoutPtr); |
221 TLex timeoutLex(timeoutPtr); |
207 TInt timeout; |
222 TInt timeout; |
208 TInt ret = timeoutLex.Val(timeout); |
223 TInt ret = timeoutLex.Val(timeout); |
209 if (ret == KErrNone && timeout >= 0) |
224 hasTimeout = ( ret == KErrNone && timeout >= 0 ); |
210 { |
225 if ( hasTimeout ) |
211 iTimeout = timeout; |
226 { |
212 } |
227 iTimeout = timeout; |
|
228 } |
213 } |
229 } |
214 } |
230 } |
215 |
231 |
216 // ----------------------------------------------------------------------------- |
232 // ----------------------------------------------------------------------------- |
217 // |
233 // |
220 void CSymbianUnitTestCommandLineParser::SetTestDllNamesL() |
236 void CSymbianUnitTestCommandLineParser::SetTestDllNamesL() |
221 { |
237 { |
222 CDesCArray* testDllNames = new( ELeave )CDesCArrayFlat( 1 ); |
238 CDesCArray* testDllNames = new( ELeave )CDesCArrayFlat( 1 ); |
223 CleanupStack::PushL( testDllNames ); |
239 CleanupStack::PushL( testDllNames ); |
224 TPtrC testDllNamesPtr; |
240 TPtrC testDllNamesPtr; |
225 if ( FindArgument( KTestsKey, KTestsKeyShort, testDllNamesPtr ) ) |
241 TBool found = EFalse; |
|
242 found = FindArgument( KTestsKey, KTestsKeyShort, testDllNamesPtr ); |
|
243 if ( found ) |
226 { |
244 { |
227 TSymbianUnitTestDllNameParser parser; |
245 TSymbianUnitTestDllNameParser parser; |
228 parser.Parse( testDllNamesPtr ); |
246 parser.Parse( testDllNamesPtr ); |
229 TPtrC testDllNamePtr; |
247 TPtrC testDllNamePtr; |
230 while ( parser.GetNext( testDllNamePtr ) == KErrNone ) |
248 TBool hasNext = EFalse; |
|
249 hasNext = ( parser.GetNext( testDllNamePtr ) == KErrNone ); |
|
250 while ( hasNext ) |
231 { |
251 { |
232 testDllNames->AppendL( testDllNamePtr ); |
252 testDllNames->AppendL( testDllNamePtr ); |
|
253 hasNext = ( parser.GetNext( testDllNamePtr ) == KErrNone ); |
233 } |
254 } |
234 } |
255 } |
235 iShowHelp = ( testDllNames->Count() == 0 ); |
256 iShowHelp = ( testDllNames->Count() == 0 ); |
236 CleanupStack::Pop( testDllNames ); |
257 CleanupStack::Pop( testDllNames ); |
237 delete iTestDllNames; |
258 delete iTestDllNames; |
245 void CSymbianUnitTestCommandLineParser::SetTestCaseNamesL() |
266 void CSymbianUnitTestCommandLineParser::SetTestCaseNamesL() |
246 { |
267 { |
247 CDesCArray* testCaseNames = new( ELeave )CDesCArrayFlat( 1 ); |
268 CDesCArray* testCaseNames = new( ELeave )CDesCArrayFlat( 1 ); |
248 CleanupStack::PushL( testCaseNames ); |
269 CleanupStack::PushL( testCaseNames ); |
249 TPtrC testCaseNamesPtr; |
270 TPtrC testCaseNamesPtr; |
250 if ( FindArgument( KTestCasesKey, KTestCasesKeyShort, testCaseNamesPtr ) ) |
271 TBool found = EFalse; |
|
272 found = FindArgument( KTestCasesKey, KTestCasesKeyShort, testCaseNamesPtr ); |
|
273 if ( found ) |
251 { |
274 { |
252 //reuse the testdll parser here for case names |
275 //reuse the testdll parser here for case names |
253 TSymbianUnitTestDllNameParser parser; |
276 TSymbianUnitTestDllNameParser parser; |
254 parser.Parse( testCaseNamesPtr ); |
277 parser.Parse( testCaseNamesPtr ); |
255 TPtrC testCaseNamePtr; |
278 TPtrC testCaseNamePtr; |
256 while ( parser.GetNext( testCaseNamePtr ) == KErrNone ) |
279 TBool hasNext = EFalse; |
|
280 hasNext = ( parser.GetNext( testCaseNamePtr ) == KErrNone ); |
|
281 while ( hasNext ) |
257 { |
282 { |
258 testCaseNames->AppendL( testCaseNamePtr ); |
283 testCaseNames->AppendL( testCaseNamePtr ); |
|
284 hasNext = ( parser.GetNext( testCaseNamePtr ) == KErrNone ); |
259 } |
285 } |
260 } |
286 } |
261 CleanupStack::Pop( testCaseNames ); |
287 CleanupStack::Pop( testCaseNames ); |
262 delete iTestCaseNames; |
288 delete iTestCaseNames; |
263 iTestCaseNames = testCaseNames; |
289 iTestCaseNames = testCaseNames; |