53 |
53 |
54 // None |
54 // None |
55 |
55 |
56 // ================= MEMBER FUNCTIONS ========================================= |
56 // ================= MEMBER FUNCTIONS ========================================= |
57 |
57 |
|
58 /* |
|
59 ------------------------------------------------------------------------------- |
|
60 |
|
61 Class: CTestCasesList |
|
62 |
|
63 Method: NewL |
|
64 |
|
65 Description: Create new test cases list |
|
66 |
|
67 Parameters: const TDesC& aConfigFileName :in: Config file name |
|
68 |
|
69 Return Values: CTestCasesList* Pointer to new test cases list |
|
70 |
|
71 Errors/Exceptions: Leaves if memory allocation fails or ConstructL leaves. |
|
72 |
|
73 Status: Approved |
|
74 |
|
75 ------------------------------------------------------------------------------- |
|
76 */ |
|
77 CTestCasesList* CTestCasesList::NewL( const TDesC& aConfigFileName ) |
|
78 { |
|
79 CTestCasesList* self = new(ELeave)CTestCasesList; |
|
80 CleanupStack::PushL( self ); |
|
81 self->ConstructL( aConfigFileName ); |
|
82 CleanupStack::Pop( self ); |
|
83 return self; |
|
84 } |
|
85 |
|
86 /* |
|
87 ------------------------------------------------------------------------------- |
|
88 |
|
89 Class: CTestCasesList |
|
90 |
|
91 Method: ~CTestCasesList |
|
92 |
|
93 Description: Destructor |
|
94 |
|
95 Parameters: |
|
96 |
|
97 Return Values: |
|
98 |
|
99 Errors/Exceptions: |
|
100 |
|
101 Status: Approved |
|
102 |
|
103 ------------------------------------------------------------------------------- |
|
104 */ |
|
105 CTestCasesList::~CTestCasesList() |
|
106 { |
|
107 delete iConfigFileName; |
|
108 iConfigFileName = NULL; |
|
109 iTestCases.ResetAndDestroy(); |
|
110 iTestCases.Close(); |
|
111 } |
|
112 |
|
113 /* |
|
114 ------------------------------------------------------------------------------- |
|
115 |
|
116 Class: CTestCasesList |
|
117 |
|
118 Method: AppendTestCaseL |
|
119 |
|
120 Description: Appends test case. |
|
121 |
|
122 Parameters: const TDesC& aTestCaseTitle in: Test case title |
|
123 |
|
124 Return Values: |
|
125 |
|
126 Errors/Exceptions: Leaves if memory allocation fails |
|
127 |
|
128 Status: Approved |
|
129 |
|
130 ------------------------------------------------------------------------------- |
|
131 */ |
|
132 void CTestCasesList::AppendTestCaseL( const TDesC& aTestCaseTitle ) |
|
133 { |
|
134 HBufC* testCaseTitle = aTestCaseTitle.AllocL(); |
|
135 CleanupStack::PushL( testCaseTitle ); |
|
136 iTestCases.AppendL( testCaseTitle ); |
|
137 CleanupStack::Pop( testCaseTitle ); |
|
138 } |
|
139 |
|
140 /* |
|
141 ------------------------------------------------------------------------------- |
|
142 |
|
143 Class: CTestCasesList |
|
144 |
|
145 Method: GetTestCaseTitleL |
|
146 |
|
147 Description: Returns specified test case title |
|
148 |
|
149 Parameters: TInt aIndex: in: Requested test case index. |
|
150 |
|
151 Return Values: Test case title. |
|
152 |
|
153 Errors/Exceptions: Leaves if test case index is invalid |
|
154 |
|
155 Status: Approved |
|
156 |
|
157 ------------------------------------------------------------------------------- |
|
158 */ |
|
159 const TDesC& CTestCasesList::GetTestCaseTitleL( TInt aIndex ) const |
|
160 { |
|
161 if ( ( aIndex < 0 ) || ( aIndex >= iTestCases.Count() ) ) |
|
162 { |
|
163 User::Leave( KErrNotFound ); |
|
164 } |
|
165 return *iTestCases[ aIndex ]; |
|
166 } |
|
167 |
|
168 /* |
|
169 ------------------------------------------------------------------------------- |
|
170 |
|
171 Class: CTestCasesList |
|
172 |
|
173 Method: GetConfigFileName |
|
174 |
|
175 Description: Returns config file name |
|
176 |
|
177 Parameters: |
|
178 |
|
179 Return Values: Config file name. |
|
180 |
|
181 Errors/Exceptions: |
|
182 |
|
183 Status: Approved |
|
184 |
|
185 ------------------------------------------------------------------------------- |
|
186 */ |
|
187 const TDesC& CTestCasesList::GetConfigFileName() const |
|
188 { |
|
189 return *iConfigFileName; |
|
190 } |
|
191 |
|
192 /* |
|
193 ------------------------------------------------------------------------------- |
|
194 |
|
195 Class: CTestCasesList |
|
196 |
|
197 Method: Count |
|
198 |
|
199 Description: Returns count of test cases. |
|
200 |
|
201 Parameters: |
|
202 |
|
203 Return Values: Test cases count. |
|
204 |
|
205 Errors/Exceptions: |
|
206 |
|
207 Status: Approved |
|
208 |
|
209 ------------------------------------------------------------------------------- |
|
210 */ |
|
211 TInt CTestCasesList::Count() const |
|
212 { |
|
213 return iTestCases.Count(); |
|
214 } |
|
215 |
|
216 /* |
|
217 ------------------------------------------------------------------------------- |
|
218 |
|
219 Class: CTestCasesList |
|
220 |
|
221 Method: ResetAndDestroy |
|
222 |
|
223 Description: Resets list of test cases. |
|
224 |
|
225 Parameters: |
|
226 |
|
227 Return Values: |
|
228 |
|
229 Errors/Exceptions: |
|
230 |
|
231 Status: Approved |
|
232 |
|
233 ------------------------------------------------------------------------------- |
|
234 */ |
|
235 void CTestCasesList::ResetAndDestroy() |
|
236 { |
|
237 iTestCases.ResetAndDestroy(); |
|
238 } |
|
239 |
|
240 /* |
|
241 ------------------------------------------------------------------------------- |
|
242 |
|
243 Class: CTestCasesList |
|
244 |
|
245 Method: ~CTestCasesList |
|
246 |
|
247 Description: Destructor |
|
248 |
|
249 Parameters: |
|
250 |
|
251 Return Values: |
|
252 |
|
253 Errors/Exceptions: |
|
254 |
|
255 Status: Approved |
|
256 |
|
257 ------------------------------------------------------------------------------- |
|
258 */ |
|
259 CTestCasesList::CTestCasesList() |
|
260 { |
|
261 } |
|
262 |
|
263 /* |
|
264 ------------------------------------------------------------------------------- |
|
265 |
|
266 Class: CTestCasesList |
|
267 |
|
268 Method: ~CTestCasesList |
|
269 |
|
270 Description: Destructor |
|
271 |
|
272 Parameters: |
|
273 |
|
274 Return Values: |
|
275 |
|
276 Errors/Exceptions: |
|
277 |
|
278 Status: Approved |
|
279 |
|
280 ------------------------------------------------------------------------------- |
|
281 */ |
|
282 void CTestCasesList::ConstructL( const TDesC& aConfigFileName ) |
|
283 { |
|
284 iConfigFileName = aConfigFileName.AllocL(); |
|
285 } |
58 |
286 |
59 /* |
287 /* |
60 ------------------------------------------------------------------------------- |
288 ------------------------------------------------------------------------------- |
61 |
289 |
62 Class: CTestModule |
290 Class: CTestModule |
688 if( testCases == NULL ) |
916 if( testCases == NULL ) |
689 { |
917 { |
690 User::Leave( KErrGeneral ); |
918 User::Leave( KErrGeneral ); |
691 } |
919 } |
692 |
920 |
|
921 CTestCasesList* testCasesList = NULL; |
|
922 for ( TInt i = 0; i < iTestCaseTitlesMap.Count(); i++ ) |
|
923 { |
|
924 if ( iTestCaseTitlesMap[ i ]->GetConfigFileName() == config ) |
|
925 { |
|
926 testCasesList = iTestCaseTitlesMap[ i ]; |
|
927 break; |
|
928 } |
|
929 } |
|
930 if ( testCasesList == NULL ) |
|
931 { |
|
932 testCasesList = CTestCasesList::NewL( config ); |
|
933 CleanupStack::PushL( testCasesList ); |
|
934 iTestCaseTitlesMap.AppendL( testCasesList ); |
|
935 CleanupStack::Pop( testCasesList ); |
|
936 } |
|
937 |
693 // Store titles (for further use, i.e. when asked for title from the interface via CTestModuleIf->CTestThreadContainer->CTestModuleContainer) |
938 // Store titles (for further use, i.e. when asked for title from the interface via CTestModuleIf->CTestThreadContainer->CTestModuleContainer) |
694 iTestCaseTitles.ResetAndDestroy(); |
939 testCasesList->ResetAndDestroy(); |
695 TInt i; |
940 TInt i; |
696 for(i = 0; i < testCases->Count(); i++) |
941 for(i = 0; i < testCases->Count(); i++) |
697 { |
942 { |
698 //Handle situation when test cases are enumerated not as 0-based (testscripter, ...) |
943 //Handle situation when test cases are enumerated not as 0-based (testscripter, ...) |
699 if(i == 0 && (*testCases)[i]->iCaseNumber > 0) |
944 if(i == 0 && (*testCases)[i]->iCaseNumber > 0) |
700 { |
945 { |
701 iTestCaseTitles.Append(NULL); |
946 testCasesList->AppendTestCaseL( KNullDesC ); |
702 } |
947 } |
703 HBufC* title = (*testCases)[i]->iTitle.AllocL(); |
948 testCasesList->AppendTestCaseL( (*testCases)[i]->iTitle ); |
704 iTestCaseTitles.Append(title); |
|
705 } |
949 } |
706 |
950 |
707 TPckgBuf<TInt> countPckg( testCases->Count() ); |
951 TPckgBuf<TInt> countPckg( testCases->Count() ); |
708 TRAP( res, aMessage.WriteL( 1, countPckg ) ); |
952 TRAP( res, aMessage.WriteL( 1, countPckg ) ); |
709 if(res == KErrDied) |
953 if(res == KErrDied) |
1378 |
1622 |
1379 Status: Proposal |
1623 Status: Proposal |
1380 |
1624 |
1381 ------------------------------------------------------------------------------- |
1625 ------------------------------------------------------------------------------- |
1382 */ |
1626 */ |
1383 void CTestModule::GetTestCaseTitleL(TInt aTestCaseNumber, TDes& aTestCaseTitle) |
1627 void CTestModule::GetTestCaseTitleL(TInt aTestCaseNumber, const TDesC& aConfigFile,TDes& aTestCaseTitle) |
1384 { |
1628 { |
1385 RDebug::Print(_L("Trying to get test case title from module. Index=%d, count=%d"), aTestCaseNumber, iTestCaseTitles.Count()); |
1629 CTestCasesList* testCasesList = NULL; |
1386 aTestCaseTitle.Copy(*(iTestCaseTitles[aTestCaseNumber])); |
1630 for ( TInt i = 0; i < iTestCaseTitlesMap.Count(); i++ ) |
|
1631 { |
|
1632 if ( iTestCaseTitlesMap[ i ]->GetConfigFileName() == aConfigFile ) |
|
1633 { |
|
1634 testCasesList = iTestCaseTitlesMap[ i ]; |
|
1635 break; |
|
1636 } |
|
1637 } |
|
1638 if ( testCasesList == NULL ) |
|
1639 { |
|
1640 User::Leave( KErrNotFound ); |
|
1641 } |
|
1642 |
|
1643 RDebug::Print(_L("Trying to get test case title from module. Index=%d, count=%d"), aTestCaseNumber, testCasesList->Count() ); |
|
1644 |
|
1645 aTestCaseTitle.Copy( testCasesList->GetTestCaseTitleL( aTestCaseNumber ) ); |
1387 } |
1646 } |
1388 |
1647 |
1389 |
1648 |
1390 /* |
1649 /* |
1391 ------------------------------------------------------------------------------- |
1650 ------------------------------------------------------------------------------- |