author | Johnson Ma <johnson.ma@nokia.com> |
Mon, 29 Mar 2010 14:46:27 +0800 | |
changeset 1 | bbd31066657e |
parent 0 | 3e07fef1e154 |
permissions | -rw-r--r-- |
0 | 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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include "ut_symbianunittestcommandlineparser.h" |
|
19 |
#include "symbianunittestcommandlineparser.h" |
|
20 |
#include <symbianunittestmacros.h> |
|
21 |
||
22 |
// --------------------------------------------------------------------------- |
|
23 |
// |
|
24 |
// --------------------------------------------------------------------------- |
|
25 |
// |
|
26 |
UT_CSymbianUnitTestCommandLineParser* UT_CSymbianUnitTestCommandLineParser::NewL() |
|
27 |
{ |
|
28 |
UT_CSymbianUnitTestCommandLineParser* self = |
|
29 |
UT_CSymbianUnitTestCommandLineParser::NewLC(); |
|
30 |
CleanupStack::Pop( self ); |
|
31 |
return self; |
|
32 |
} |
|
33 |
||
34 |
// --------------------------------------------------------------------------- |
|
35 |
// |
|
36 |
// --------------------------------------------------------------------------- |
|
37 |
// |
|
38 |
UT_CSymbianUnitTestCommandLineParser* UT_CSymbianUnitTestCommandLineParser::NewLC() |
|
39 |
{ |
|
40 |
UT_CSymbianUnitTestCommandLineParser* self = |
|
41 |
new( ELeave )UT_CSymbianUnitTestCommandLineParser(); |
|
42 |
CleanupStack::PushL( self ); |
|
43 |
self->ConstructL(); |
|
44 |
return self; |
|
45 |
} |
|
46 |
||
47 |
// --------------------------------------------------------------------------- |
|
48 |
// |
|
49 |
// --------------------------------------------------------------------------- |
|
50 |
// |
|
51 |
UT_CSymbianUnitTestCommandLineParser::UT_CSymbianUnitTestCommandLineParser() |
|
52 |
{ |
|
53 |
} |
|
54 |
||
55 |
// --------------------------------------------------------------------------- |
|
56 |
// |
|
57 |
// --------------------------------------------------------------------------- |
|
58 |
// |
|
59 |
void UT_CSymbianUnitTestCommandLineParser::ConstructL() |
|
60 |
{ |
|
61 |
BASE_CONSTRUCT |
|
62 |
||
1
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
63 |
DEFINE_TEST_CLASS( UT_CSymbianUnitTestCommandLineParser ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
64 |
|
0 | 65 |
ADD_SUT( UT_SetOutputFormatL ) |
66 |
ADD_SUT( UT_SetTestDllNamesL ) |
|
67 |
ADD_SUT( UT_FindArgumentL ) |
|
1
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
68 |
ADD_SUT( UT_SetTimeoutL ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
69 |
ADD_SUT( UT_SetTestCaseNamesL ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
70 |
//ADD_SUT( UT_TestCommandLineL ) |
0 | 71 |
} |
72 |
||
73 |
// --------------------------------------------------------------------------- |
|
74 |
// |
|
75 |
// --------------------------------------------------------------------------- |
|
76 |
// |
|
77 |
UT_CSymbianUnitTestCommandLineParser::~UT_CSymbianUnitTestCommandLineParser() |
|
78 |
{ |
|
79 |
} |
|
80 |
||
81 |
// ----------------------------------------------------------------------------- |
|
82 |
// |
|
83 |
// ----------------------------------------------------------------------------- |
|
84 |
// |
|
85 |
void UT_CSymbianUnitTestCommandLineParser::SetupL() |
|
86 |
{ |
|
87 |
iParser = CSymbianUnitTestCommandLineParser::NewL(); |
|
88 |
} |
|
89 |
||
90 |
// ----------------------------------------------------------------------------- |
|
91 |
// |
|
92 |
// ----------------------------------------------------------------------------- |
|
93 |
// |
|
94 |
void UT_CSymbianUnitTestCommandLineParser::Teardown() |
|
95 |
{ |
|
96 |
delete iParser; |
|
97 |
iParser = NULL; |
|
98 |
} |
|
99 |
||
100 |
// ----------------------------------------------------------------------------- |
|
101 |
// |
|
102 |
// ----------------------------------------------------------------------------- |
|
103 |
// |
|
104 |
void UT_CSymbianUnitTestCommandLineParser::UT_SetOutputFormatL() |
|
105 |
{ |
|
106 |
// Output format not found |
|
107 |
_LIT( KDefaultOutputFormat, "html" ); |
|
108 |
iParser->SetOutputFormatL(); |
|
109 |
SUT_ASSERT_EQUALS( KDefaultOutputFormat, iParser->OutputFormat() ) |
|
110 |
||
111 |
// Output format found, long form |
|
112 |
_LIT( KOutputFormatLong, "-output=xml" ); |
|
113 |
iParser->iArguments->Args().AppendL( KOutputFormatLong ); |
|
114 |
iParser->SetOutputFormatL(); |
|
115 |
SUT_ASSERT_EQUALS( _L( "xml" ), iParser->OutputFormat() ) |
|
116 |
||
117 |
// Output format found, short form |
|
118 |
_LIT( KOutputFormatShort, "-o=txt" ); |
|
119 |
iParser->iArguments->Args().Reset(); |
|
120 |
iParser->iArguments->Args().AppendL( KOutputFormatShort ); |
|
121 |
iParser->SetOutputFormatL(); |
|
122 |
SUT_ASSERT_EQUALS( _L( "txt" ), iParser->OutputFormat() ) |
|
123 |
} |
|
1
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
124 |
// ----------------------------------------------------------------------------- |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
125 |
// |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
126 |
// ----------------------------------------------------------------------------- |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
127 |
// |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
128 |
void UT_CSymbianUnitTestCommandLineParser::UT_SetTimeoutL() |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
129 |
{ |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
130 |
// Default timeout. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
131 |
iParser->iArguments->Args().Reset(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
132 |
iParser->SetTimeoutL(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
133 |
SUT_ASSERT_EQUALS( iParser->Timeout(), 30 ) |
0 | 134 |
|
1
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
135 |
// Set timeout=50, long form. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
136 |
_LIT( KTimeoutLong, "-timeout=50" ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
137 |
iParser->iArguments->Args().Reset(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
138 |
iParser->iArguments->Args().AppendL( KTimeoutLong ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
139 |
iParser->SetTimeoutL(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
140 |
SUT_ASSERT_EQUALS( iParser->Timeout(), 50 ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
141 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
142 |
// Set timeout=50, short form. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
143 |
_LIT( KTimeoutShort, "-to=20" ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
144 |
iParser->iArguments->Args().Reset(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
145 |
iParser->iArguments->Args().AppendL( KTimeoutShort ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
146 |
iParser->SetTimeoutL(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
147 |
SUT_ASSERT_EQUALS( iParser->Timeout(), 20 ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
148 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
149 |
// Set timeout to invalid value, long form. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
150 |
_LIT( KInvalidTimeoutLong, "-timeout=-50" ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
151 |
iParser->iArguments->Args().Reset(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
152 |
iParser->iArguments->Args().AppendL( KInvalidTimeoutLong ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
153 |
iParser->SetTimeoutL(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
154 |
SUT_ASSERT_EQUALS( iParser->Timeout(), 30 ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
155 |
} |
0 | 156 |
// ----------------------------------------------------------------------------- |
157 |
// |
|
158 |
// ----------------------------------------------------------------------------- |
|
159 |
// |
|
160 |
void UT_CSymbianUnitTestCommandLineParser::UT_SetTestDllNamesL() |
|
161 |
{ |
|
162 |
// Test DLL name not found |
|
163 |
iParser->SetTestDllNamesL(); |
|
164 |
SUT_ASSERT_EQUALS( 0, iParser->TestDllNames().MdcaCount() ) |
|
165 |
SUT_ASSERT( iParser->ShowHelp() ) |
|
166 |
||
167 |
// One test DLL name found |
|
168 |
_LIT( KOneTestDllName, "-tests=test1.dll" ); |
|
169 |
iParser->iArguments->Args().AppendL( KOneTestDllName ); |
|
170 |
iParser->SetTestDllNamesL(); |
|
171 |
SUT_ASSERT_EQUALS( 1, iParser->TestDllNames().MdcaCount() ) |
|
172 |
SUT_ASSERT_EQUALS( |
|
173 |
_L( "test1.dll" ), iParser->TestDllNames().MdcaPoint( 0 ) ) |
|
174 |
SUT_ASSERT( !iParser->ShowHelp() ) |
|
175 |
||
176 |
// Two test DLL names found |
|
177 |
_LIT( KTwoTestDllNames, "-tests=test1.dll,test2.dll" ); |
|
178 |
iParser->iArguments->Args().Reset(); |
|
179 |
iParser->iArguments->Args().AppendL( KTwoTestDllNames ); |
|
180 |
iParser->SetTestDllNamesL(); |
|
181 |
SUT_ASSERT_EQUALS( 2, iParser->TestDllNames().MdcaCount() ) |
|
182 |
SUT_ASSERT_EQUALS( |
|
183 |
_L( "test1.dll" ), iParser->TestDllNames().MdcaPoint( 0 ) ) |
|
184 |
SUT_ASSERT_EQUALS( |
|
185 |
_L( "test2.dll" ), iParser->TestDllNames().MdcaPoint( 1 ) ) |
|
186 |
SUT_ASSERT( !iParser->ShowHelp() ) |
|
187 |
||
188 |
// Two test DLL names found, short key name used |
|
189 |
_LIT( KTwoTestDllNamesWithShortForm, "-t=test3.dll,test4.dll" ); |
|
190 |
iParser->iArguments->Args().Reset(); |
|
191 |
iParser->iArguments->Args().AppendL( KTwoTestDllNamesWithShortForm ); |
|
192 |
iParser->SetTestDllNamesL(); |
|
193 |
SUT_ASSERT_EQUALS( 2, iParser->TestDllNames().MdcaCount() ) |
|
194 |
SUT_ASSERT_EQUALS( |
|
195 |
_L( "test3.dll" ), iParser->TestDllNames().MdcaPoint( 0 ) ) |
|
196 |
SUT_ASSERT_EQUALS( |
|
197 |
_L( "test4.dll" ), iParser->TestDllNames().MdcaPoint( 1 ) ) |
|
198 |
SUT_ASSERT( !iParser->ShowHelp() ) |
|
199 |
} |
|
200 |
||
1
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
201 |
// --------------------------------------------------------------------------- |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
202 |
// |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
203 |
// --------------------------------------------------------------------------- |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
204 |
// |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
205 |
void UT_CSymbianUnitTestCommandLineParser::UT_SetTestCaseNamesL() |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
206 |
{ |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
207 |
// Testcase Names, no name. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
208 |
iParser->SetTestCaseNamesL(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
209 |
SUT_ASSERT( !iParser->TestCaseNames().MdcaCount() ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
210 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
211 |
// One testcase name, long form. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
212 |
_LIT( KOneTestCaseNameLong, "-cases=case1" ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
213 |
iParser->iArguments->Args().Reset(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
214 |
iParser->iArguments->Args().AppendL( KOneTestCaseNameLong ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
215 |
iParser->SetTestCaseNamesL(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
216 |
SUT_ASSERT_EQUALS( 1, iParser->TestCaseNames().MdcaCount() ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
217 |
SUT_ASSERT_EQUALS( |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
218 |
_L( "case1" ), iParser->TestCaseNames().MdcaPoint( 0 ) ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
219 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
220 |
// One testcase name, short form. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
221 |
_LIT( KOneTestCaseNameShort, "-c=case2" ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
222 |
iParser->iArguments->Args().Reset(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
223 |
iParser->iArguments->Args().AppendL( KOneTestCaseNameShort ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
224 |
iParser->SetTestCaseNamesL(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
225 |
SUT_ASSERT_EQUALS( 1, iParser->TestCaseNames().MdcaCount() ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
226 |
SUT_ASSERT_EQUALS( |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
227 |
_L( "case2" ), iParser->TestCaseNames().MdcaPoint( 0 ) ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
228 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
229 |
// Two testcase names, long form. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
230 |
_LIT( KTwoTestCaseNameLong, "-cases=case3,case4" ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
231 |
iParser->iArguments->Args().Reset(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
232 |
iParser->iArguments->Args().AppendL( KTwoTestCaseNameLong ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
233 |
iParser->SetTestCaseNamesL(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
234 |
SUT_ASSERT_EQUALS( 2, iParser->TestCaseNames().MdcaCount() ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
235 |
SUT_ASSERT_EQUALS( |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
236 |
_L( "case3" ), iParser->TestCaseNames().MdcaPoint( 0 ) ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
237 |
SUT_ASSERT_EQUALS( |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
238 |
_L( "case4" ), iParser->TestCaseNames().MdcaPoint( 1 ) ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
239 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
240 |
// Two testcase names, short form. |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
241 |
_LIT( KTwoTestCaseNameShort, "-c=case5,case6" ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
242 |
iParser->iArguments->Args().Reset(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
243 |
iParser->iArguments->Args().AppendL( KTwoTestCaseNameShort ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
244 |
iParser->SetTestCaseNamesL(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
245 |
SUT_ASSERT_EQUALS( 2, iParser->TestCaseNames().MdcaCount() ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
246 |
SUT_ASSERT_EQUALS( |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
247 |
_L( "case5" ), iParser->TestCaseNames().MdcaPoint( 0 ) ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
248 |
SUT_ASSERT_EQUALS( |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
249 |
_L( "case6" ), iParser->TestCaseNames().MdcaPoint( 1 ) ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
250 |
} |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
251 |
|
0 | 252 |
// ----------------------------------------------------------------------------- |
253 |
// |
|
254 |
// ----------------------------------------------------------------------------- |
|
255 |
// |
|
256 |
void UT_CSymbianUnitTestCommandLineParser::UT_FindArgumentL() |
|
257 |
{ |
|
258 |
_LIT( KKey, "key" ); |
|
259 |
TPtrC value; |
|
260 |
||
261 |
// Argument not found |
|
262 |
SUT_ASSERT( !iParser->FindArgument( KKey, KNullDesC, value ) ) |
|
263 |
SUT_ASSERT_EQUALS( KNullDesC, value ) |
|
264 |
||
265 |
// Argument found, no equals sign |
|
266 |
_LIT( KOnlyKeyArgument, "key" ); |
|
267 |
iParser->iArguments->Args().AppendL( KOnlyKeyArgument ); |
|
268 |
SUT_ASSERT( iParser->FindArgument( KKey, KNullDesC, value ) ) |
|
269 |
SUT_ASSERT_EQUALS( KNullDesC, value ) |
|
270 |
||
271 |
// Argument found, equals sign as the first character |
|
272 |
_LIT( KKeyStartingWithEqualsSign, "=key" ); |
|
273 |
_LIT( KKeyStartingWithEqualsSignArgument, "=keysomething" ); |
|
274 |
iParser->iArguments->Args().Reset(); |
|
275 |
iParser->iArguments->Args().AppendL( KKeyStartingWithEqualsSignArgument ); |
|
276 |
SUT_ASSERT( |
|
277 |
iParser->FindArgument( KKeyStartingWithEqualsSign, KNullDesC, value ) ) |
|
278 |
SUT_ASSERT_EQUALS( KNullDesC, value ) |
|
279 |
||
280 |
// Argument found, equals sign as the last character |
|
281 |
_LIT( KKeyEndingWithEqualsSignArgument, "key=" ); |
|
282 |
iParser->iArguments->Args().Reset(); |
|
283 |
iParser->iArguments->Args().AppendL( KKeyEndingWithEqualsSignArgument ); |
|
284 |
SUT_ASSERT( iParser->FindArgument( KKey, KNullDesC, value ) ) |
|
285 |
SUT_ASSERT_EQUALS( KNullDesC, value ) |
|
286 |
||
287 |
// Argument found, equals sign as not the first and not the last |
|
288 |
_LIT( KValidArgument, "key=value" ); |
|
289 |
iParser->iArguments->Args().Reset(); |
|
290 |
iParser->iArguments->Args().AppendL( KValidArgument ); |
|
291 |
SUT_ASSERT( iParser->FindArgument( KKey, KNullDesC, value ) ) |
|
292 |
SUT_ASSERT_EQUALS( _L( "value" ), value ) |
|
293 |
||
294 |
// Short form of the argument found |
|
295 |
_LIT( KValidArgument2, "k=value2" ); |
|
296 |
iParser->iArguments->Args().Reset(); |
|
297 |
iParser->iArguments->Args().AppendL( KValidArgument2 ); |
|
298 |
_LIT( KShortKey, "k" ); |
|
299 |
SUT_ASSERT( iParser->FindArgument( KNullDesC, KShortKey, value ) ) |
|
300 |
SUT_ASSERT_EQUALS( _L( "value2" ), value ) |
|
301 |
} |
|
1
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
302 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
303 |
void UT_CSymbianUnitTestCommandLineParser::LaunchExample( TInt aType ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
304 |
{ |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
305 |
_LIT( KSymbianUnitTestFilename, "symbianunittest.exe" ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
306 |
_LIT( KSymbianUnitTestArgs, "-t=ut_racecar.dll -noprompt -output=" ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
307 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
308 |
const TInt KMaxArgLength( 255 ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
309 |
TBuf<KMaxArgLength> strArgs; |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
310 |
strArgs.Copy( KSymbianUnitTestArgs ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
311 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
312 |
switch( aType ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
313 |
{ |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
314 |
case 0: // html |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
315 |
strArgs.Append( _L("html") ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
316 |
break; |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
317 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
318 |
case 1: // xml |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
319 |
strArgs.Append( _L("xml") ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
320 |
break; |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
321 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
322 |
case 2: // txt |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
323 |
strArgs.Append( _L("txt") ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
324 |
break; |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
325 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
326 |
default: |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
327 |
//strArgs.Append( _L("html") ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
328 |
strArgs = strArgs.Left( 27 ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
329 |
} |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
330 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
331 |
RProcess proc; |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
332 |
proc.Create( KSymbianUnitTestFilename, strArgs ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
333 |
TRequestStatus status; |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
334 |
proc.Logon( status ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
335 |
proc.Resume(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
336 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
337 |
User::WaitForRequest( status ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
338 |
proc.Close(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
339 |
if ( KErrNone != status.Int() ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
340 |
{ |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
341 |
User::LeaveIfError( status.Int() ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
342 |
} |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
343 |
} |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
344 |
|
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
345 |
void UT_CSymbianUnitTestCommandLineParser::UT_TestCommandLineL() |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
346 |
{ |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
347 |
// set output = html, xml, txt, default; |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
348 |
for(TInt i=0; i<30; ++i) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
349 |
{ |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
350 |
LaunchExample(i); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
351 |
} |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
352 |
} |