48 CBaseTestCase::CBaseTestCase(const TDesC& aTestCaseId,TBool aHostFlag, TBool aHostOnly) |
44 CBaseTestCase::CBaseTestCase(const TDesC& aTestCaseId,TBool aHostFlag, TBool aHostOnly) |
49 : CActive(EPriorityStandard), |
45 : CActive(EPriorityStandard), |
50 iHost(aHostFlag), |
46 iHost(aHostFlag), |
51 iHostOnly(aHostOnly) |
47 iHostOnly(aHostOnly) |
52 { |
48 { |
53 OstTraceFunctionEntryExt( CBASETESTCASE_CBASETESTCASE_ENTRY, this ); |
|
54 iTestCaseId.Copy(aTestCaseId); |
49 iTestCaseId.Copy(aTestCaseId); |
55 CActiveScheduler::Add(this); |
50 CActiveScheduler::Add(this); |
56 OstTraceFunctionExit1( CBASETESTCASE_CBASETESTCASE_EXIT, this ); |
|
57 } |
51 } |
58 |
52 |
59 void CBaseTestCase::BaseConstructL() |
53 void CBaseTestCase::BaseConstructL() |
60 { |
54 { |
61 OstTraceFunctionEntry1( CBASETESTCASE_BASECONSTRUCTL_ENTRY, this ); |
55 LOG_FUNC |
62 OstTrace0(TRACE_NORMAL, CBASETESTCASE_BASECONSTRUCTL, "Creating test case timer"); |
56 RDebug::Printf("Creating test case timer"); |
63 TInt err(iTimer.CreateLocal()); |
57 TInt err(iTimer.CreateLocal()); |
64 if(err == KErrNone) |
58 if(err == KErrNone) |
65 { |
59 { |
66 OstTrace0(TRACE_NORMAL, CBASETESTCASE_BASECONSTRUCTL_DUP01, "Test case timer created"); |
60 RDebug::Printf("Test case timer created"); |
67 } |
61 } |
68 else |
62 else |
69 { |
63 { |
70 OstTrace1(TRACE_NORMAL, CBASETESTCASE_BASECONSTRUCTL_DUP02, "<Error %d> Test case timer could not be created",err); |
64 RDebug::Printf("<Error %d> Test case timer could not be created",err); |
71 User::Leave(err); |
65 User::Leave(err); |
72 } |
66 } |
73 OstTraceFunctionExit1( CBASETESTCASE_BASECONSTRUCTL_EXIT, this ); |
|
74 } |
67 } |
75 |
68 |
76 void CBaseTestCase::TimeoutIn(TInt aTimeoutPeriod) |
69 void CBaseTestCase::TimeoutIn(TInt aTimeoutPeriod) |
77 { |
70 { |
78 OstTraceFunctionEntryExt( CBASETESTCASE_TIMEOUTIN_ENTRY, this ); |
71 LOG_FUNC |
79 |
72 |
80 CancelTimeout(); |
73 CancelTimeout(); |
81 iTimer.After(iStatus,aTimeoutPeriod*1000000); |
74 iTimer.After(iStatus,aTimeoutPeriod*1000000); |
82 SetActive(); |
75 SetActive(); |
83 OstTraceFunctionExit1( CBASETESTCASE_TIMEOUTIN_EXIT, this ); |
|
84 } |
76 } |
85 |
77 |
86 |
78 |
87 void CBaseTestCase::CancelTimeout() |
79 void CBaseTestCase::CancelTimeout() |
88 { |
80 { |
89 OstTraceFunctionEntry1( CBASETESTCASE_CANCELTIMEOUT_ENTRY, this ); |
|
90 iTimer.Cancel(); |
81 iTimer.Cancel(); |
91 OstTraceFunctionExit1( CBASETESTCASE_CANCELTIMEOUT_EXIT, this ); |
|
92 } |
82 } |
93 |
83 |
94 TInt CBaseTestCase::GenerateRefFile(const TDesC& aFileName) |
84 TInt CBaseTestCase::GenerateRefFile(const TDesC& aFileName) |
95 { |
85 { |
96 OstTraceFunctionEntryExt( CBASETESTCASE_GENERATEREFFILE_ENTRY, this ); |
86 |
97 |
87 LOG_FUNC |
98 TBuf<256> refTreeFullFileName(KGeneratedFilesPath); |
88 TBuf<256> refTreeFullFileName(KGeneratedFilesPath); |
99 refTreeFullFileName.Append(aFileName); |
89 refTreeFullFileName.Append(aFileName); |
100 refTreeFullFileName.Append(KExtensionFile); |
90 refTreeFullFileName.Append(KExtensionFile); |
101 |
91 |
102 RFile refFile; |
92 RFile refFile; |
103 TInt ret = KErrNone; |
93 TInt ret = KErrNone; |
104 ret = iFs.Connect(); |
94 ret = iFs.Connect(); |
105 if(ret!=KErrNone && ret!=KErrAlreadyExists) |
95 if(ret!=KErrNone && ret!=KErrAlreadyExists) |
106 // if already connected, ignore |
96 // if already connected, ignore |
107 { |
97 { |
108 OstTrace1(TRACE_NORMAL, CBASETESTCASE_GENERATEREFFILE, "iFs.Connect fails, ret = %d", ret); |
98 RDebug::Printf("iFs.Connect fails, ret = %d", ret); |
109 OstTraceFunctionExitExt( CBASETESTCASE_GENERATEREFFILE_EXIT, this, ret ); |
|
110 return ret; |
99 return ret; |
111 } |
100 } |
112 |
101 |
113 ret = iFs.Delete(refTreeFullFileName); |
102 ret = iFs.Delete(refTreeFullFileName); |
114 if(ret == KErrNone || ret == KErrNotFound) |
103 if(ret == KErrNone || ret == KErrNotFound) |
116 ret = refFile.Create(iFs,refTreeFullFileName,EFileShareAny|EFileWrite); |
105 ret = refFile.Create(iFs,refTreeFullFileName,EFileShareAny|EFileWrite); |
117 } |
106 } |
118 |
107 |
119 if(ret!=KErrNone) |
108 if(ret!=KErrNone) |
120 { |
109 { |
121 OstTrace1(TRACE_NORMAL, CBASETESTCASE_GENERATEREFFILE_DUP01, "refFile.Create fails, ret = %d", ret); |
110 RDebug::Printf("refFile.Create fails, ret = %d", ret); |
122 OstTraceFunctionExitExt( CBASETESTCASE_GENERATEREFFILE_EXIT_DUP01, this, ret ); |
|
123 return ret; |
111 return ret; |
124 } |
112 } |
125 |
113 |
126 refFile.Write(iTreeBuffer); |
114 refFile.Write(iTreeBuffer); |
127 refFile.Flush(); |
115 refFile.Flush(); |
128 refFile.Close(); |
116 refFile.Close(); |
129 |
117 |
130 OstTraceFunctionExitExt( CBASETESTCASE_GENERATEREFFILE_EXIT_DUP02, this, KErrNone ); |
|
131 return KErrNone; |
118 return KErrNone; |
132 } |
119 } |
133 |
120 |
134 TInt CBaseTestCase::CompareCurrentTreeToRef(const TDesC& aFileName, TBool& aIsIdentical) |
121 TInt CBaseTestCase::CompareCurrentTreeToRef(const TDesC& aFileName, TBool& aIsIdentical) |
135 { |
122 { |
136 OstTraceFunctionEntryExt( CBASETESTCASE_COMPARECURRENTTREETOREF_ENTRY, this ); |
123 |
137 |
124 LOG_FUNC |
138 TBuf<256> refTreeFullFileName(KRefPath); |
125 TBuf<256> refTreeFullFileName(KRefPath); |
139 refTreeFullFileName.Append(aFileName); |
126 refTreeFullFileName.Append(aFileName); |
140 refTreeFullFileName.Append(KExtensionFile); |
127 refTreeFullFileName.Append(KExtensionFile); |
141 |
128 |
142 TInt ret = KErrNone; |
129 TInt ret = KErrNone; |
143 ret = iFs.Connect(); |
130 ret = iFs.Connect(); |
144 if(ret!=KErrNone && ret!=KErrAlreadyExists) |
131 if(ret!=KErrNone && ret!=KErrAlreadyExists) |
145 // if already connected, ignore |
132 // if already connected, ignore |
146 { |
133 { |
147 OstTrace1(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF, "iFs.Connect fails, ret = %d", ret); |
134 RDebug::Printf("iFs.Connect fails, ret = %d", ret); |
148 OstTraceFunctionExitExt( CBASETESTCASE_COMPARECURRENTTREETOREF_EXIT, this, ret ); |
|
149 return ret; |
135 return ret; |
150 } |
136 } |
151 |
137 |
152 RFile refFile; |
138 RFile refFile; |
153 ret = refFile.Open(iFs,refTreeFullFileName,EFileShareAny|EFileRead); |
139 ret = refFile.Open(iFs,refTreeFullFileName,EFileShareAny|EFileRead); |
154 |
140 |
155 if(ret!=KErrNone) |
141 if(ret!=KErrNone) |
156 { |
142 { |
157 OstTraceExt1(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP01, "Reference File path: %S", refTreeFullFileName); |
143 RDebug::Printf("Reference File path: %S", &refTreeFullFileName); |
158 OstTrace1(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP02, "refFile.Open fails ret = %d", ret); |
144 RDebug::Printf("refFile.Open fails ret = %d", ret); |
159 OstTraceFunctionExitExt( CBASETESTCASE_COMPARECURRENTTREETOREF_EXIT_DUP01, this, ret ); |
|
160 return ret; |
145 return ret; |
161 } |
146 } |
162 |
147 |
163 TInt refFileSize; |
148 TInt refFileSize; |
164 refFile.Size(refFileSize); |
149 refFile.Size(refFileSize); |
165 |
150 |
166 // check size is identical |
151 // check size is identical |
167 if(refFileSize != iTreeBuffer.Size()) |
152 if(refFileSize != iTreeBuffer.Size()) |
168 { |
153 { |
169 OstTraceExt2(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP03, "sizes are NOT identical, refFileSize = %d, iTreeBuffer.Size() = %d ", refFileSize, iTreeBuffer.Size()); |
154 RDebug::Printf("sizes are NOT identical, refFileSize = %d, iTreeBuffer.Size() = %d ", refFileSize, iTreeBuffer.Size()); |
170 //return KErrGeneral; not an issue, \n encoded differently by perforce... x0D x0A. (x0A only in generated ref file) |
155 //return KErrGeneral; not an issue, \n encoded differently by perforce... x0D x0A. (x0A only in generated ref file) |
171 } |
156 } |
172 |
157 |
173 // read the file, and put it in a local buffer |
158 // read the file, and put it in a local buffer |
174 RBuf8 refBuf; |
159 RBuf8 refBuf; |
175 refBuf.CreateL(refFileSize); |
160 refBuf.CreateL(refFileSize); |
176 ret = refFile.Read(0, refBuf, refFileSize); |
161 ret = refFile.Read(0, refBuf, refFileSize); |
177 |
162 |
178 if(ret!=KErrNone) |
163 if(ret!=KErrNone) |
179 { |
164 { |
180 OstTrace1(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP04, "refFile.Read fails %d", ret); |
165 RDebug::Printf("refFile.Read fails %d", ret); |
181 OstTraceFunctionExitExt( CBASETESTCASE_COMPARECURRENTTREETOREF_EXIT_DUP02, this, ret ); |
|
182 return ret; |
166 return ret; |
183 } |
167 } |
184 |
168 |
185 // find occurences of \n now |
169 // find occurences of \n now |
186 RBuf8 copyRefBuf; |
170 RBuf8 copyRefBuf; |
203 } |
187 } |
204 copyRefBuf.AppendFormat(_L8("%c"), refBuf[iRefBuffer]); |
188 copyRefBuf.AppendFormat(_L8("%c"), refBuf[iRefBuffer]); |
205 } |
189 } |
206 refBuf.Close(); |
190 refBuf.Close(); |
207 |
191 |
208 OstTrace1(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP05, "copyRefBuf.Size %d", copyRefBuf.Size()); |
192 RDebug::Printf("copyRefBuf.Size %d", copyRefBuf.Size()); |
209 |
193 |
210 |
194 |
211 // check size is identical, should be identical now |
195 // check size is identical, should be identical now |
212 if(copyRefBuf.Size() != iTreeBuffer.Size()) |
196 if(copyRefBuf.Size() != iTreeBuffer.Size()) |
213 { |
197 { |
214 OstTraceExt2(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP06, "sizes are NOT identical, copyRefBuf.Size() = %d, iTreeBuffer.Size() = %d ", refFileSize, iTreeBuffer.Size()); |
198 RDebug::Printf("sizes are NOT identical, copyRefBuf.Size() = %d, iTreeBuffer.Size() = %d ", refFileSize, iTreeBuffer.Size()); |
215 OstTraceFunctionExitExt( CBASETESTCASE_COMPARECURRENTTREETOREF_EXIT_DUP03, this, KErrGeneral ); |
|
216 return KErrGeneral; |
199 return KErrGeneral; |
217 } |
200 } |
218 |
201 |
219 // now compare the 2 buffers |
202 // now compare the 2 buffers |
220 // Can only go as far as the smallest buffer |
203 // Can only go as far as the smallest buffer |
221 TInt bufferSizeToCheck = Min(copyRefBuf.Size(), iTreeBuffer.Size()); |
204 TInt bufferSizeToCheck = Min(copyRefBuf.Size(), iTreeBuffer.Size()); |
222 OstTrace1(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP07, "bufferSizeToCheck = %d", bufferSizeToCheck); |
205 RDebug::Print(_L("bufferSizeToCheck = %d"), bufferSizeToCheck); |
223 |
206 |
224 aIsIdentical = ETrue; |
207 aIsIdentical = ETrue; |
225 for(TInt iRefBuffer=0; iRefBuffer < bufferSizeToCheck; iRefBuffer++) |
208 for(TInt iRefBuffer=0; iRefBuffer < bufferSizeToCheck; iRefBuffer++) |
226 { |
209 { |
227 if(iTreeBuffer[iRefBuffer] != copyRefBuf[iRefBuffer]) |
210 if(iTreeBuffer[iRefBuffer] != copyRefBuf[iRefBuffer]) |
228 { |
211 { |
229 OstTrace1(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP08, "Failed buffer comparison at position %d", iRefBuffer); |
212 RDebug::Print(_L("Failed buffer comparison at position %d"), iRefBuffer); |
230 OstTraceExt4(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP09, "Missmatching chars (%d %d) (%c %c)", iTreeBuffer[iRefBuffer], copyRefBuf[iRefBuffer], iTreeBuffer[iRefBuffer], copyRefBuf[iRefBuffer]); |
213 RDebug::Print(_L("Missmatching chars (%d %d) (%c %c)"), iTreeBuffer[iRefBuffer], copyRefBuf[iRefBuffer], iTreeBuffer[iRefBuffer], copyRefBuf[iRefBuffer]); |
231 aIsIdentical = EFalse; |
214 aIsIdentical = EFalse; |
232 break; |
215 break; |
233 } |
216 } |
234 } |
217 } |
235 |
218 |
236 OstTrace1(TRACE_NORMAL, CBASETESTCASE_COMPARECURRENTTREETOREF_DUP10, "Finished Buffer comparison aIsIdentical=%d", aIsIdentical); |
219 RDebug::Print(_L("Finished Buffer comparison aIsIdentical=%d"), aIsIdentical); |
237 |
220 |
238 copyRefBuf.Close(); |
221 copyRefBuf.Close(); |
239 |
222 |
240 OstTraceFunctionExitExt( CBASETESTCASE_COMPARECURRENTTREETOREF_EXIT_DUP04, this, KErrNone ); |
|
241 return KErrNone; |
223 return KErrNone; |
242 } |
224 } |
243 |
225 |
244 CBaseTestCase::~CBaseTestCase() |
226 CBaseTestCase::~CBaseTestCase() |
245 { |
227 { |
246 OstTraceFunctionEntry1( CBASETESTCASE_CBASETESTCASE_ENTRY_DUP01, this ); |
228 LOG_FUNC |
247 Cancel(); |
229 Cancel(); |
248 iTimer.Close(); |
230 iTimer.Close(); |
249 iTreeBuffer.Close(); |
231 iTreeBuffer.Close(); |
250 iFs.Close(); |
232 iFs.Close(); |
251 OstTraceFunctionExit1( CBASETESTCASE_CBASETESTCASE_EXIT_DUP01, this ); |
|
252 } |
233 } |
253 |
234 |
254 void CBaseTestCase::SelfComplete() |
235 void CBaseTestCase::SelfComplete() |
255 { |
236 { |
256 OstTraceFunctionEntry1( CBASETESTCASE_SELFCOMPLETE_ENTRY, this ); |
|
257 SelfComplete(KErrNone); |
237 SelfComplete(KErrNone); |
258 OstTraceFunctionExit1( CBASETESTCASE_SELFCOMPLETE_EXIT, this ); |
|
259 } |
238 } |
260 |
239 |
261 void CBaseTestCase::SelfComplete(TInt aError) |
240 void CBaseTestCase::SelfComplete(TInt aError) |
262 { |
241 { |
263 OstTraceFunctionEntryExt( CBASETESTCASE_SELFCOMPLETE_ENTRY_DUP01, this ); |
|
264 TRequestStatus* s = &iStatus; |
242 TRequestStatus* s = &iStatus; |
265 iStatus = KRequestPending; |
243 iStatus = KRequestPending; |
266 User::RequestComplete(s,aError); |
244 User::RequestComplete(s,aError); |
267 SetActive(); |
245 SetActive(); |
268 OstTraceFunctionExit1( CBASETESTCASE_SELFCOMPLETE_EXIT_DUP01, this ); |
|
269 } |
246 } |
270 |
247 |
271 |
248 |
272 void CBaseTestCase::DoCancel() |
249 void CBaseTestCase::DoCancel() |
273 { |
250 { |
274 OstTraceFunctionEntry1( CBASETESTCASE_DOCANCEL_ENTRY, this ); |
251 LOG_FUNC |
275 iTimer.Cancel(); |
252 iTimer.Cancel(); |
276 if(iHost) |
253 if(iHost) |
277 { |
254 { |
278 HostDoCancel(); |
255 HostDoCancel(); |
279 } |
256 } |
280 else |
257 else |
281 { |
258 { |
282 DeviceDoCancel(); |
259 DeviceDoCancel(); |
283 } |
260 } |
284 OstTraceFunctionExit1( CBASETESTCASE_DOCANCEL_EXIT, this ); |
|
285 } |
261 } |
286 |
262 |
287 void CBaseTestCase::RunL() |
263 void CBaseTestCase::RunL() |
288 { |
264 { |
289 OstTraceFunctionEntry1( CBASETESTCASE_RUNL_ENTRY, this ); |
|
290 if(iHost) |
265 if(iHost) |
291 { |
266 { |
292 HostRunL(); |
267 HostRunL(); |
293 } |
268 } |
294 else |
269 else |
295 { |
270 { |
296 DeviceRunL(); |
271 DeviceRunL(); |
297 } |
272 } |
298 OstTraceFunctionExit1( CBASETESTCASE_RUNL_EXIT, this ); |
|
299 } |
273 } |
300 |
274 |
301 TInt CBaseTestCase::RunError(TInt aError) |
275 TInt CBaseTestCase::RunError(TInt aError) |
302 { |
276 { |
303 OstTraceFunctionEntryExt( CBASETESTCASE_RUNERROR_ENTRY, this ); |
277 LOG_FUNC |
304 OstTraceExt2(TRACE_NORMAL, CBASETESTCASE_RUNERROR, "Test case C%lS::RunL left with %d",iTestCaseId,aError); |
278 RDebug::Printf("Test case C%lS::RunL left with %d",&iTestCaseId,aError); |
305 iTestPolicy->SignalTestComplete(aError); |
279 iTestPolicy->SignalTestComplete(aError); |
306 OstTraceFunctionExitExt( CBASETESTCASE_RUNERROR_EXIT, this, KErrNone ); |
|
307 return KErrNone; |
280 return KErrNone; |
308 } |
281 } |
309 |
282 |
310 TDesC& CBaseTestCase::TestCaseId() |
283 TDesC& CBaseTestCase::TestCaseId() |
311 { |
284 { |
312 OstTraceFunctionEntry1( CBASETESTCASE_TESTCASEID_ENTRY, this ); |
|
313 OstTraceFunctionExitExt( CBASETESTCASE_TESTCASEID_EXIT, this, ( TUint )&( iTestCaseId ) ); |
|
314 return iTestCaseId; |
285 return iTestCaseId; |
315 } |
286 } |
316 |
287 |
317 |
288 |
318 TInt CBaseTestCase::TestResult() const |
289 TInt CBaseTestCase::TestResult() const |
319 { |
290 { |
320 OstTraceFunctionEntry1( CBASETESTCASE_TESTRESULT_ENTRY, this ); |
|
321 OstTraceFunctionExitExt( CBASETESTCASE_TESTRESULT_EXIT, this, iTestResult ); |
|
322 return iTestResult; |
291 return iTestResult; |
323 } |
292 } |
324 |
293 |
325 TBool CBaseTestCase::IsHostOnly() const |
294 TBool CBaseTestCase::IsHostOnly() const |
326 { |
295 { |
327 OstTraceFunctionEntry1( CBASETESTCASE_ISHOSTONLY_ENTRY, this ); |
|
328 OstTraceFunctionExitExt( CBASETESTCASE_ISHOSTONLY_EXIT, this, iHostOnly ); |
|
329 return iHostOnly; |
296 return iHostOnly; |
330 } |
297 } |
331 |
298 |
332 TBool CBaseTestCase::IsHost() const |
299 TBool CBaseTestCase::IsHost() const |
333 { |
300 { |
334 OstTraceFunctionEntry1( CBASETESTCASE_ISHOST_ENTRY, this ); |
|
335 OstTraceFunctionExitExt( CBASETESTCASE_ISHOST_EXIT, this, iHost ); |
|
336 return iHost; |
301 return iHost; |
337 } |
302 } |
338 |
303 |
339 void CBaseTestCase::PerformTestL() |
304 void CBaseTestCase::PerformTestL() |
340 { |
305 { |
341 OstTraceFunctionEntry1( CBASETESTCASE_PERFORMTESTL_ENTRY, this ); |
|
342 |
306 |
343 if(iHost) |
307 if(iHost) |
344 { |
308 { |
345 iTreeBuffer.CreateL(KTreeBufferSize); //32k |
309 iTreeBuffer.CreateL(KTreeBufferSize); //32k |
346 ExecuteHostTestCaseL(); |
310 ExecuteHostTestCaseL(); |
347 } |
311 } |
348 else |
312 else |
349 { |
313 { |
350 ExecuteDeviceTestCaseL(); |
314 ExecuteDeviceTestCaseL(); |
351 } |
315 } |
352 OstTraceFunctionExit1( CBASETESTCASE_PERFORMTESTL_EXIT, this ); |
|
353 } |
316 } |
354 |
317 |
355 void CBaseTestCase::SetTestPolicy(CBasicTestPolicy* aTestPolicy) |
318 void CBaseTestCase::SetTestPolicy(CBasicTestPolicy* aTestPolicy) |
356 { |
319 { |
357 OstTraceFunctionEntryExt( CBASETESTCASE_SETTESTPOLICY_ENTRY, this ); |
|
358 iTestPolicy = aTestPolicy; |
320 iTestPolicy = aTestPolicy; |
359 OstTraceFunctionExit1( CBASETESTCASE_SETTESTPOLICY_EXIT, this ); |
|
360 } |
321 } |
361 |
322 |
362 void CBaseTestCase::TestFailed(TInt aFailResult) |
323 void CBaseTestCase::TestFailed(TInt aFailResult) |
363 { |
324 { |
364 OstTraceFunctionEntryExt( CBASETESTCASE_TESTFAILED_ENTRY, this ); |
325 LOG_FUNC |
365 iTestResult = aFailResult; |
326 iTestResult = aFailResult; |
366 if(!iHostOnly) |
327 if(!iHostOnly) |
367 { |
328 { |
368 OstTrace0(TRACE_NORMAL, CBASETESTCASE_TESTFAILED, "CActiveScheduler::Stop CBaseTestCase::TestFailed"); |
329 RDebug::Printf("CActiveScheduler::Stop CBaseTestCase::TestFailed"); |
369 CActiveScheduler::Stop(); |
330 CActiveScheduler::Stop(); |
370 } |
331 } |
371 OstTraceFunctionExit1( CBASETESTCASE_TESTFAILED_EXIT, this ); |
|
372 } |
332 } |
373 |
333 |
374 void CBaseTestCase::TestPassed() |
334 void CBaseTestCase::TestPassed() |
375 { |
335 { |
376 OstTraceFunctionEntry1( CBASETESTCASE_TESTPASSED_ENTRY, this ); |
336 LOG_FUNC |
377 iTestResult = KErrNone; |
337 iTestResult = KErrNone; |
378 if(!iHostOnly) |
338 if(!iHostOnly) |
379 { |
339 { |
380 OstTrace0(TRACE_NORMAL, CBASETESTCASE_TESTPASSED, "CActiveScheduler::Stop CBaseTestCase::TestPassed"); |
340 RDebug::Printf("CActiveScheduler::Stop CBaseTestCase::TestPassed"); |
381 CActiveScheduler::Stop(); |
341 CActiveScheduler::Stop(); |
382 } |
342 } |
383 OstTraceFunctionExit1( CBASETESTCASE_TESTPASSED_EXIT, this ); |
|
384 } |
343 } |
385 |
344 |
386 CBasicTestPolicy& CBaseTestCase::TestPolicy() |
345 CBasicTestPolicy& CBaseTestCase::TestPolicy() |
387 { |
346 { |
388 OstTraceFunctionEntry1( CBASETESTCASE_TESTPOLICY_ENTRY, this ); |
|
389 OstTraceFunctionExit1( CBASETESTCASE_TESTPOLICY_EXIT, this ); |
|
390 return *iTestPolicy; |
347 return *iTestPolicy; |
391 } |
348 } |
392 |
349 |
393 |
350 |
394 /** |
351 /** |
411 one endpoint of the given type exists on the interface setting |
368 one endpoint of the given type exists on the interface setting |
412 */ |
369 */ |
413 TInt CBaseTestCase::GetEndpointAddress(RUsbInterface& aUsbInterface,TInt aInterfaceSetting, |
370 TInt CBaseTestCase::GetEndpointAddress(RUsbInterface& aUsbInterface,TInt aInterfaceSetting, |
414 TUint8 aTransferType,TUint8 aDirection,TUint8 aIndex,TInt& aEndpointAddress) |
371 TUint8 aTransferType,TUint8 aDirection,TUint8 aIndex,TInt& aEndpointAddress) |
415 { |
372 { |
416 OstTraceFunctionEntryExt( CBASETESTCASE_GETENDPOINTADDRESS_ENTRY_DUP01, this ); |
373 LOG_FUNC |
417 |
374 |
418 // Get the interface descriptor |
375 // Get the interface descriptor |
419 OstTrace0(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS, "Getting the interface descriptor for this alternate setting"); |
376 RDebug::Printf("Getting the interface descriptor for this alternate setting"); |
420 |
377 |
421 TUsbInterfaceDescriptor alternateInterfaceDescriptor; |
378 TUsbInterfaceDescriptor alternateInterfaceDescriptor; |
422 TInt err = aUsbInterface.GetAlternateInterfaceDescriptor(aInterfaceSetting, alternateInterfaceDescriptor); |
379 TInt err = aUsbInterface.GetAlternateInterfaceDescriptor(aInterfaceSetting, alternateInterfaceDescriptor); |
423 |
380 |
424 if(err) |
381 if(err) |
425 { |
382 { |
426 OstTraceExt2(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP01, "<Error %d> Unable to get alternate interface (%d) descriptor",err,aInterfaceSetting); |
383 RDebug::Printf("<Error %d> Unable to get alternate interface (%d) descriptor",err,aInterfaceSetting); |
427 OstTraceFunctionExitExt( CBASETESTCASE_GETENDPOINTADDRESS_EXIT, this, err ); |
|
428 return err; |
384 return err; |
429 } |
385 } |
430 |
386 |
431 // Parse the descriptor tree from the interface |
387 // Parse the descriptor tree from the interface |
432 OstTrace0(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP02, "Search the child descriptors for matching endpoint attributes"); |
388 RDebug::Printf("Search the child descriptors for matching endpoint attributes"); |
433 |
389 |
434 TUsbGenericDescriptor* descriptor = alternateInterfaceDescriptor.iFirstChild; |
390 TUsbGenericDescriptor* descriptor = alternateInterfaceDescriptor.iFirstChild; |
435 TUint8 indexCount = 0; |
391 TUint8 indexCount = 0; |
436 while(descriptor) |
392 while(descriptor) |
437 { |
393 { |
438 OstTrace0(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP03, "Check descriptor type for endpoint"); |
394 RDebug::Printf("Check descriptor type for endpoint"); |
439 |
395 |
440 // Cast the descriptor to an endpoint descriptor |
396 // Cast the descriptor to an endpoint descriptor |
441 TUsbEndpointDescriptor* endpoint = TUsbEndpointDescriptor::Cast(descriptor); |
397 TUsbEndpointDescriptor* endpoint = TUsbEndpointDescriptor::Cast(descriptor); |
442 |
398 |
443 if(endpoint) |
399 if(endpoint) |
444 { |
400 { |
445 OstTrace0(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP04, "Match attributes for transfer type"); |
401 RDebug::Printf("Match attributes for transfer type"); |
446 |
402 |
447 if( (endpoint->Attributes() & aTransferType) == aTransferType) |
403 if( (endpoint->Attributes() & aTransferType) == aTransferType) |
448 { |
404 { |
449 OstTrace0(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP05, "Match attributes for endpoint direction"); |
405 RDebug::Printf("Match attributes for endpoint direction"); |
450 |
406 |
451 if( (endpoint->EndpointAddress() & aDirection) == aDirection) |
407 if( (endpoint->EndpointAddress() & aDirection) == aDirection) |
452 { |
408 { |
453 if(indexCount==aIndex) |
409 if(indexCount==aIndex) |
454 { |
410 { |
455 aEndpointAddress = endpoint->EndpointAddress(); |
411 aEndpointAddress = endpoint->EndpointAddress(); |
456 OstTrace0(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP06, "Endpoint address found"); |
412 RDebug::Printf("Endpoint address found"); |
457 OstTraceFunctionExitExt( CBASETESTCASE_GETENDPOINTADDRESS_EXIT_DUP01, this, KErrNone ); |
|
458 return KErrNone; |
413 return KErrNone; |
459 } |
414 } |
460 else |
415 else |
461 { |
416 { |
462 indexCount++; |
417 indexCount++; |
498 //##==TBuf16<40> unicodeBuf; |
449 //##==TBuf16<40> unicodeBuf; |
499 TBuf8<40> unicodeBuf; |
450 TBuf8<40> unicodeBuf; |
500 unicodeBuf.Copy(buf); // Ideally this needs conversion to UNICODE |
451 unicodeBuf.Copy(buf); // Ideally this needs conversion to UNICODE |
501 if(aDesc.iRecognisedAndParsed == TUsbGenericDescriptor::ERecognised) |
452 if(aDesc.iRecognisedAndParsed == TUsbGenericDescriptor::ERecognised) |
502 { |
453 { |
503 OstTraceExt3(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP09, "%s+ length=%u, type=0x%02x", unicodeBuf, aDesc.ibLength, (TUint32)aDesc.ibDescriptorType); |
454 RDebug::Printf("%S+ length=%d, type=0x%02x", &unicodeBuf, aDesc.ibLength, aDesc.ibDescriptorType); |
504 iTreeBuffer.AppendFormat(_L8("%S+ length=%d, type=0x%02x\n"), &buf, aDesc.ibLength, aDesc.ibDescriptorType); |
455 iTreeBuffer.AppendFormat(_L8("%S+ length=%d, type=0x%02x\n"), &buf, aDesc.ibLength, aDesc.ibDescriptorType); |
505 } |
456 } |
506 else |
457 else |
507 { |
458 { |
508 OstTraceExt3(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP10, "%s- length=%u, type=0x%02x", unicodeBuf, aDesc.ibLength, (TUint32)aDesc.ibDescriptorType); |
459 RDebug::Printf("%S- length=%d, type=0x%02x", &unicodeBuf, aDesc.ibLength, aDesc.ibDescriptorType); |
509 iTreeBuffer.AppendFormat(_L8("%S- length=%d, type=0x%02x\n"), &buf, aDesc.ibLength, aDesc.ibDescriptorType); |
460 iTreeBuffer.AppendFormat(_L8("%S- length=%d, type=0x%02x\n"), &buf, aDesc.ibLength, aDesc.ibDescriptorType); |
510 } |
461 } |
511 |
462 |
512 PrintAndStoreBlob(buf ,aDesc.iBlob); |
463 PrintAndStoreBlob(buf ,aDesc.iBlob); |
513 |
464 |
514 if(aDesc.iFirstChild) |
465 if(aDesc.iFirstChild) |
515 { |
466 { |
516 OstTraceExt1(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP11, "%s \n", unicodeBuf); |
467 RDebug::Printf("%S \\ ", &unicodeBuf); |
517 iTreeBuffer.AppendFormat(_L8("%S \\ \n"), &buf); |
468 iTreeBuffer.AppendFormat(_L8("%S \\ \n"), &buf); |
518 |
469 |
519 PrintAndStoreTree(*(aDesc.iFirstChild), aDepth+1); |
470 PrintAndStoreTree(*(aDesc.iFirstChild), aDepth+1); |
520 |
471 |
521 OstTraceExt1(TRACE_NORMAL, CBASETESTCASE_GETENDPOINTADDRESS_DUP12, "%s \n", unicodeBuf); |
472 RDebug::Printf("%S / ", &unicodeBuf); |
522 iTreeBuffer.AppendFormat(_L8("%S / \n"), &buf); |
473 iTreeBuffer.AppendFormat(_L8("%S / \n"), &buf); |
523 } |
474 } |
524 if(aDesc.iNextPeer) |
475 if(aDesc.iNextPeer) |
525 { |
476 { |
526 PrintAndStoreTree(*(aDesc.iNextPeer), aDepth); |
477 PrintAndStoreTree(*(aDesc.iNextPeer), aDepth); |
527 } |
478 } |
528 OstTraceFunctionExit1( CBASETESTCASE_PRINTANDSTORETREE_EXIT, 0 ); |
|
529 } |
479 } |
530 |
480 |
531 void CBaseTestCase::PrintAndStoreBlob(TDes8& aBuf, TPtrC8& aBlob) |
481 void CBaseTestCase::PrintAndStoreBlob(TDes8& aBuf, TPtrC8& aBlob) |
532 { |
482 { |
533 OstTraceFunctionEntryExt( CBASETESTCASE_PRINTANDSTOREBLOB_ENTRY, this ); |
|
534 |
483 |
535 HBufC8* chunk = HBufC8::New(KChunkSize); |
484 HBufC8* chunk = HBufC8::New(KChunkSize); |
536 |
485 |
537 TUint nbIter = aBlob.Length()/(KChunkSize/2); |
486 TUint nbIter = aBlob.Length()/(KChunkSize/2); |
538 TUint remainderSize = aBlob.Length()%(KChunkSize/2); |
487 TUint remainderSize = aBlob.Length()%(KChunkSize/2); |
604 |
550 |
605 // compare tree to ref. |
551 // compare tree to ref. |
606 TBool isIdentical; |
552 TBool isIdentical; |
607 if(KErrNone != CompareCurrentTreeToRef(aFileName, isIdentical)) |
553 if(KErrNone != CompareCurrentTreeToRef(aFileName, isIdentical)) |
608 { |
554 { |
609 OstTrace0(TRACE_NORMAL, CBASETESTCASE_CHECKTREE, "CompareCurrentTreeToRef error"); |
555 RDebug::Printf("CompareCurrentTreeToRef error"); |
610 ret = KErrGeneral; |
556 ret = KErrGeneral; |
611 } |
557 } |
612 if(!isIdentical) |
558 if(!isIdentical) |
613 { |
559 { |
614 OstTrace0(TRACE_NORMAL, CBASETESTCASE_CHECKTREE_DUP01, "!isIdentical"); |
560 RDebug::Printf("!isIdentical"); |
615 ret = KErrGeneral; |
561 ret = KErrGeneral; |
616 } |
562 } |
617 OstTraceFunctionExitExt( CBASETESTCASE_CHECKTREE_EXIT, this, ret ); |
|
618 return ret; |
563 return ret; |
619 } |
564 } |
620 |
565 |
621 |
566 |
622 TInt CBaseTestCase::ParseConfigDescriptorAndCheckTree(TUsbDeviceDescriptor *devDesc, const TDesC8& configSet, TUint indexTest) |
567 TInt CBaseTestCase::ParseConfigDescriptorAndCheckTree(TUsbDeviceDescriptor *devDesc, const TDesC8& configSet, TUint indexTest) |
623 { |
568 { |
624 OstTraceFunctionEntryExt( CBASETESTCASE_PARSECONFIGDESCRIPTORANDCHECKTREE_ENTRY, this ); |
569 LOG_FUNC |
625 // Parse config. descriptor |
570 // Parse config. descriptor |
626 TUsbGenericDescriptor* parsed = NULL; |
571 TUsbGenericDescriptor* parsed = NULL; |
627 TInt err = UsbDescriptorParser::Parse(configSet, parsed); |
572 TInt err = UsbDescriptorParser::Parse(configSet, parsed); |
628 if(err != KErrNone) |
573 if(err != KErrNone) |
629 { |
574 { |
630 OstTrace0(TRACE_NORMAL, CBASETESTCASE_PARSECONFIGDESCRIPTORANDCHECKTREE, "parsing error : UsbDescriptorParser::Parse"); |
575 RDebug::Printf("parsing error : UsbDescriptorParser::Parse"); |
631 OstTraceFunctionExitExt( CBASETESTCASE_PARSECONFIGDESCRIPTORANDCHECKTREE_EXIT, this, err ); |
|
632 return err; |
576 return err; |
633 } |
577 } |
634 TUsbConfigurationDescriptor* configDesc = TUsbConfigurationDescriptor::Cast(parsed); |
578 TUsbConfigurationDescriptor* configDesc = TUsbConfigurationDescriptor::Cast(parsed); |
635 // checks |
579 // checks |
636 if(configDesc == 0) |
580 if(configDesc == 0) |
637 { |
581 { |
638 OstTrace0(TRACE_NORMAL, CBASETESTCASE_PARSECONFIGDESCRIPTORANDCHECKTREE_DUP01, "configDesc == 0"); |
582 RDebug::Printf("configDesc == 0"); |
639 OstTraceFunctionExitExt( CBASETESTCASE_PARSECONFIGDESCRIPTORANDCHECKTREE_EXIT_DUP01, this, KErrGeneral ); |
|
640 return KErrGeneral; |
583 return KErrGeneral; |
641 } |
584 } |
642 |
585 |
643 // checking tree |
586 // checking tree |
644 TBuf<KMaxName> fname(iTestCaseId); |
587 TBuf<KMaxName> fname(iTestCaseId); |