|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 // EPOC includes |
|
17 #include <e32base.h> |
|
18 #include <imagedisplay.h> |
|
19 #include <icl/imagedisplayplugin.h> |
|
20 #include "TestHelperIface.h" |
|
21 |
|
22 // Test system includes |
|
23 #include <testframework.h> |
|
24 #include <imageconversion.h> |
|
25 |
|
26 #include "TestStepImageDisplay.h" |
|
27 #include "TestSuiteImageDisplay.h" |
|
28 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
29 #include <iclrecognizerutil.h> |
|
30 #endif |
|
31 // Heap size for these tests. |
|
32 const TInt KHeapSize = 0x100000; |
|
33 |
|
34 _LIT(KIclPanicCategory, "TS_ImageDisplay"); |
|
35 |
|
36 |
|
37 GLDEF_C void Panic(TS_ImageTransformPanic aError) |
|
38 { |
|
39 User::Panic(KIclPanicCategory, aError); |
|
40 } |
|
41 |
|
42 /** |
|
43 * |
|
44 * CTestStepImageDisplay constructor |
|
45 * |
|
46 * |
|
47 */ |
|
48 CTestStepImageDisplay::CTestStepImageDisplay() |
|
49 : iFs(), iImageDisplaySuite(NULL), iSourceFilename(), iScheduler(NULL) |
|
50 { |
|
51 } |
|
52 |
|
53 /** |
|
54 * |
|
55 * CTestStepImageDisplay destructor |
|
56 * |
|
57 * |
|
58 */ |
|
59 CTestStepImageDisplay::~CTestStepImageDisplay() |
|
60 { |
|
61 } |
|
62 |
|
63 /** |
|
64 * SetSuite is a set function |
|
65 * @param aPtr is a ptr to a CTestSuiteImageDisplay |
|
66 */ |
|
67 |
|
68 void CTestStepImageDisplay::SetSuite(CTestSuiteImageDisplay* aPtr) |
|
69 { |
|
70 iImageDisplaySuite = aPtr; |
|
71 } |
|
72 |
|
73 |
|
74 /** |
|
75 DoTestStepPreambleL is the preamble function for test steps |
|
76 It creates an active scheduler and installs it. This is necessary |
|
77 since we are multithreading and each test step runs in a separate thread. |
|
78 @returns TVerdict which is either EPass or Efail |
|
79 The function can leave if there is insufficient memeory |
|
80 */ |
|
81 TVerdict CTestStepImageDisplay::DoTestStepPreambleL() |
|
82 { |
|
83 //[ mark the heap and unmark at the end of postamble ] |
|
84 __MM_HEAP_MARK; |
|
85 |
|
86 iScheduler = new(ELeave)CActiveScheduler; |
|
87 //[ push the scheduler on the stack ] |
|
88 CleanupStack::PushL( iScheduler ); |
|
89 |
|
90 //[install the active scheduler ] |
|
91 CActiveScheduler::Install( iScheduler ); |
|
92 |
|
93 // [Pop iScheduler ] |
|
94 CleanupStack::Pop( iScheduler); |
|
95 |
|
96 User::LeaveIfError(iFs.Connect()); |
|
97 |
|
98 return EPass; |
|
99 } |
|
100 |
|
101 /** |
|
102 The post amble step cleans up the allocated memory in the preamble |
|
103 @returns TVerdict EPass or EFail |
|
104 @leaves can leave due to insufficient memory |
|
105 */ |
|
106 |
|
107 TVerdict CTestStepImageDisplay::DoTestStepPostambleL() |
|
108 { |
|
109 Cleanup(); |
|
110 |
|
111 iFs.Close(); |
|
112 |
|
113 //[ Destroy the scheduler ] |
|
114 delete iScheduler ; |
|
115 iScheduler = NULL; |
|
116 |
|
117 // [ umark the heap which was marked in preamble ] |
|
118 __MM_HEAP_MARKEND; |
|
119 |
|
120 return EPass; |
|
121 } |
|
122 |
|
123 |
|
124 /** |
|
125 * |
|
126 * CTestStepImageDisplay Suite accessor function |
|
127 * @returns CTestSuiteImageDisplay* |
|
128 */ |
|
129 |
|
130 CTestSuiteImageDisplay* CTestStepImageDisplay::Suite() |
|
131 { |
|
132 return iImageDisplaySuite; |
|
133 } |
|
134 |
|
135 |
|
136 /** |
|
137 * |
|
138 * CTestStepImageDisplay SetTestFilename |
|
139 * This method adds the filename to include the default path |
|
140 * @param aPathNameAndExtn const TDesC& afull file and path name |
|
141 * @returns void |
|
142 */ |
|
143 |
|
144 void CTestStepImageDisplay::DefaultPath(TFileName& aName) |
|
145 { |
|
146 Suite()->DefaultPath(aName); |
|
147 } |
|
148 |
|
149 void CTestStepImageDisplay::SetSourceFilename(const TDesC& aPathNameAndExtn) |
|
150 { |
|
151 //[ append the filename relative to the default path ] |
|
152 TFileName fileName; |
|
153 DefaultPath( fileName ); |
|
154 fileName.Append(aPathNameAndExtn); |
|
155 iSourceFilename = fileName ; |
|
156 } |
|
157 |
|
158 void CTestStepImageDisplay::SetDestFilenameL(const TDesC& aPathNameAndExtn) |
|
159 { |
|
160 //[ append the filename relative to the default path ] |
|
161 TFileName fileName; |
|
162 DefaultPath( fileName ); |
|
163 |
|
164 _LIT(KOutputFolder, "output\\"); |
|
165 fileName.Append(KOutputFolder); |
|
166 //create the output subfolder |
|
167 TInt err = iFs.MkDirAll(fileName); |
|
168 if (err != KErrNone && err != KErrAlreadyExists) |
|
169 { |
|
170 INFO_PRINTF2(_L("Unable to create output folder, err = %d"), err); |
|
171 User::Leave(err); |
|
172 } |
|
173 |
|
174 fileName.Append(aPathNameAndExtn); |
|
175 iDestFilename = fileName; |
|
176 |
|
177 } |
|
178 |
|
179 // delete the destination file |
|
180 void CTestStepImageDisplay::DeleteDestFilenameL() |
|
181 { |
|
182 TInt err = iFs.Delete(DestFilename()); |
|
183 if (err != KErrNone && err != KErrNotFound) |
|
184 { |
|
185 INFO_PRINTF2(_L("Unable to delete output file, err = %d"), err); |
|
186 User::Leave(err); |
|
187 } |
|
188 } |
|
189 |
|
190 |
|
191 void CTestStepImageDisplay::SetRefFilenameL(const TDesC& aPathNameAndExtn) |
|
192 { |
|
193 //[ append the filename relative to the default path ] |
|
194 TFileName fileName; |
|
195 DefaultPath( fileName ); |
|
196 _LIT(KRefFolder, "ref\\"); |
|
197 fileName.Append(KRefFolder); |
|
198 fileName.Append(aPathNameAndExtn); |
|
199 iRefFilename = fileName ; |
|
200 } |
|
201 |
|
202 |
|
203 /** |
|
204 * |
|
205 * CTestStepImageDisplay SourceFilename |
|
206 * |
|
207 * |
|
208 * |
|
209 */ |
|
210 TFileName& CTestStepImageDisplay::SourceFilename() |
|
211 { |
|
212 return iSourceFilename; |
|
213 } |
|
214 |
|
215 /** |
|
216 * |
|
217 * CTestStepImageDisplay DestFilename |
|
218 * |
|
219 * |
|
220 * |
|
221 */ |
|
222 TFileName& CTestStepImageDisplay::DestFilename() |
|
223 { |
|
224 return iDestFilename; |
|
225 } |
|
226 |
|
227 /** |
|
228 * |
|
229 * CTestStepImageDisplay RefFilename |
|
230 * |
|
231 * |
|
232 * |
|
233 */ |
|
234 TFileName& CTestStepImageDisplay::RefFilename() |
|
235 { |
|
236 return iRefFilename; |
|
237 } |
|
238 |
|
239 /** |
|
240 * |
|
241 * Compare two bitmap files |
|
242 * |
|
243 * @param "const TDesC& aFile1" |
|
244 * The first file to compare |
|
245 * @param "const TDesC& aFile2" |
|
246 * The second file to compare |
|
247 * @leave "" |
|
248 * Will leave with appropriate system codes if a problem is encountered reading either file |
|
249 * @return "TVerdict" |
|
250 * EPass if the files are identical |
|
251 * EFail otherwise |
|
252 * @xxxx |
|
253 * |
|
254 */ |
|
255 TVerdict CTestStepImageDisplay::CompareFilesL(const TDesC& aFile1,const TDesC& aFile2) |
|
256 { |
|
257 |
|
258 CFbsBitmap* refBitmap=new (ELeave) CFbsBitmap(); |
|
259 CleanupStack::PushL(refBitmap); |
|
260 User::LeaveIfError( refBitmap->Load(aFile1, 0) ); |
|
261 |
|
262 TVerdict result=CompareBitmapWithFileL(*refBitmap, aFile2); |
|
263 |
|
264 if (result != EPass) |
|
265 { |
|
266 INFO_PRINTF3(_L("Files do not match %S %S"), &aFile1, &aFile2); |
|
267 } |
|
268 |
|
269 CleanupStack::PopAndDestroy(refBitmap); |
|
270 |
|
271 return result; |
|
272 } |
|
273 |
|
274 TVerdict CTestStepImageDisplay::CompareBitmapWithFileL(const CFbsBitmap& aBitmap,const TDesC& aFile) const |
|
275 { |
|
276 CFbsBitmap* refBitmap=new (ELeave) CFbsBitmap(); |
|
277 CleanupStack::PushL(refBitmap); |
|
278 User::LeaveIfError( refBitmap->Load(aFile, 0) ); |
|
279 |
|
280 if (aBitmap.DisplayMode() != refBitmap->DisplayMode() || aBitmap.SizeInPixels() != refBitmap->SizeInPixels()) |
|
281 { |
|
282 CleanupStack::PopAndDestroy(refBitmap); |
|
283 return EFail; |
|
284 } |
|
285 const TInt srcScanlineLen=CFbsBitmap::ScanLineLength(refBitmap->SizeInPixels().iWidth, refBitmap->DisplayMode()); |
|
286 |
|
287 HBufC8* srcScanline = HBufC8::NewMaxLC(srcScanlineLen); |
|
288 TPtr8 src(srcScanline->Des()); |
|
289 HBufC8* refScanline = HBufC8::NewMaxLC(srcScanlineLen); |
|
290 TPtr8 ref(refScanline->Des()); |
|
291 |
|
292 const TUint8* pSrc=src.Ptr(); |
|
293 const TUint8* pRef=ref.Ptr(); |
|
294 |
|
295 TVerdict result = EPass; |
|
296 for (TInt y=aBitmap.SizeInPixels().iHeight; y; --y) |
|
297 { |
|
298 const TPoint pnt(0,y-1); |
|
299 aBitmap.GetScanLine(src,pnt,srcScanlineLen, aBitmap.DisplayMode()); |
|
300 refBitmap->GetScanLine(ref,pnt,srcScanlineLen, aBitmap.DisplayMode()); |
|
301 if (Mem::Compare(pSrc,src.Length(), pRef, src.Length()) !=0) |
|
302 { |
|
303 result = EFail; |
|
304 break; |
|
305 } |
|
306 } |
|
307 |
|
308 CleanupStack::PopAndDestroy(3,refBitmap); |
|
309 |
|
310 return result; |
|
311 } |
|
312 |
|
313 |
|
314 /** |
|
315 * |
|
316 * Test step constructor. |
|
317 * Each test step initialises its own name. |
|
318 * |
|
319 */ |
|
320 |
|
321 CTestStepImgDisplayGeneric::CTestStepImgDisplayGeneric(const TImageDisplayUnitTestParams& aTestParams) : |
|
322 iTestParams(&aTestParams), |
|
323 iCurrentUId(aTestParams.iUniqueId) |
|
324 { |
|
325 // Store the name of this test case |
|
326 iTestStepName = iTestParams->iTestName; |
|
327 |
|
328 // Increase the heap size for this test |
|
329 iHeapSize = KHeapSize; |
|
330 } |
|
331 |
|
332 /** |
|
333 * |
|
334 * Test step destructor. |
|
335 * |
|
336 */ |
|
337 CTestStepImgDisplayGeneric::~CTestStepImgDisplayGeneric() |
|
338 { |
|
339 } |
|
340 |
|
341 void CTestStepImgDisplayGeneric::Cleanup() |
|
342 { |
|
343 delete iImageDisplay; iImageDisplay= NULL; |
|
344 |
|
345 iFileHandle.Close(); |
|
346 delete iSourceBuf; iSourceBuf = NULL; |
|
347 |
|
348 if (iFbsConnection) |
|
349 RFbsSession::Disconnect(); |
|
350 iFbsConnection = EFalse; |
|
351 |
|
352 } |
|
353 |
|
354 /** |
|
355 * |
|
356 * Do the test step. |
|
357 * transform from file to file |
|
358 * @return "TVerdict" the status of the test |
|
359 * The result of the test step |
|
360 */ |
|
361 TVerdict CTestStepImgDisplayGeneric::DoTestStepL() |
|
362 { |
|
363 INFO_PRINTF2(_L("%S"), &iTestStepName); |
|
364 INFO_PRINTF2(_L("%s"), iTestParams->iTestDescription); |
|
365 |
|
366 TVerdict verdict = EFail; |
|
367 |
|
368 if (iTestParams->iTestType == TImageDisplayUnitTestParams::EAlloc) |
|
369 { |
|
370 INFO_PRINTF1(_L("Alloc test")); |
|
371 TInt i; |
|
372 TInt err; |
|
373 for (i = 1 ; ; i++) |
|
374 { |
|
375 __MM_HEAP_MARK; |
|
376 |
|
377 if (i % 5 == 0) |
|
378 INFO_PRINTF2(_L("Fail count = %d"), i); |
|
379 |
|
380 __UHEAP_SETFAIL(RHeap::EFailNext, i); |
|
381 |
|
382 TRAP(err, verdict = DoTestStepFbsL()); |
|
383 |
|
384 TAny* testAlloc = User::Alloc(1); |
|
385 TBool heapTestingComplete = (testAlloc == NULL); |
|
386 User::Free(testAlloc); |
|
387 |
|
388 Cleanup(); |
|
389 |
|
390 __UHEAP_RESET; |
|
391 __MM_HEAP_MARKEND; |
|
392 |
|
393 if ((err != KErrNoMemory) || heapTestingComplete) |
|
394 { |
|
395 INFO_PRINTF4(_L("err = %d, verdict = %d, Fail count = %d"), err, verdict, i); |
|
396 INFO_PRINTF1(_L("Alloc testing completed successfully")); |
|
397 break; |
|
398 } |
|
399 } |
|
400 } |
|
401 else |
|
402 { |
|
403 verdict = DoTestStepFbsL(); |
|
404 } |
|
405 |
|
406 return verdict; |
|
407 } |
|
408 |
|
409 TVerdict CTestStepImgDisplayGeneric::DoTestStepFbsL() |
|
410 { |
|
411 |
|
412 // [ connect to the bitmap server and check the error code] |
|
413 User::LeaveIfError(RFbsSession::Connect()); |
|
414 iFbsConnection = ETrue; |
|
415 |
|
416 TVerdict verdict = TestL(); |
|
417 |
|
418 |
|
419 return verdict; |
|
420 |
|
421 } |
|
422 |
|
423 void CTestStepImgDisplayGeneric::SetImageSourceL() |
|
424 { |
|
425 ASSERT(iImageDisplay); |
|
426 SetSourceFilename(TPtrC(iTestParams->iInputFilename)); |
|
427 |
|
428 TPtrC uniqueId(ContentAccess::KDefaultContentObject); |
|
429 if (iCurrentUId && *iCurrentUId) |
|
430 { |
|
431 uniqueId.Set(TPtrC(*iCurrentUId)); |
|
432 } |
|
433 |
|
434 switch (iTestParams->iSourceType) |
|
435 { |
|
436 case TImageDisplayUnitTestParams::ETypeFileName: |
|
437 { |
|
438 if (iTestParams->iUniqueId==NULL && iTestParams->iIntent==TImageDisplayUnitTestParams::KNoIntent) |
|
439 { |
|
440 iImageDisplay->SetImageSource(TMMFileSource(SourceFilename())); |
|
441 } |
|
442 else if (iTestParams->iIntent==TImageDisplayUnitTestParams::KNoIntent) |
|
443 { |
|
444 iImageDisplay->SetImageSource(TMMFileSource(SourceFilename(), uniqueId)); |
|
445 } |
|
446 else |
|
447 { |
|
448 iImageDisplay->SetImageSource(TMMFileSource(SourceFilename(), uniqueId, iTestParams->iIntent)); |
|
449 } |
|
450 } |
|
451 break; |
|
452 case TImageDisplayUnitTestParams::ETypeFileHandle: |
|
453 { |
|
454 iFileHandle.Close(); |
|
455 User::LeaveIfError(iFs.ShareProtected()); |
|
456 User::LeaveIfError( iFileHandle.Open(iFs, SourceFilename(), EFileRead | EFileShareExclusive) ); |
|
457 |
|
458 if (iTestParams->iUniqueId==NULL && iTestParams->iIntent==TImageDisplayUnitTestParams::KNoIntent) |
|
459 { |
|
460 iImageDisplay->SetImageSource(TMMFileHandleSource(iFileHandle)); |
|
461 } |
|
462 else if (iTestParams->iIntent==TImageDisplayUnitTestParams::KNoIntent) |
|
463 { |
|
464 iImageDisplay->SetImageSource(TMMFileHandleSource(iFileHandle, uniqueId)); |
|
465 } |
|
466 else |
|
467 { |
|
468 iImageDisplay->SetImageSource(TMMFileHandleSource(iFileHandle, uniqueId, iTestParams->iIntent)); |
|
469 } |
|
470 } |
|
471 break; |
|
472 case TImageDisplayUnitTestParams::ETypeData: |
|
473 { |
|
474 User::LeaveIfError( iFileHandle.Open(iFs, SourceFilename(), EFileRead | EFileShareReadersOnly) ); |
|
475 TInt length; |
|
476 User::LeaveIfError( iFileHandle.Size(length) ); |
|
477 delete iSourceBuf; iSourceBuf = NULL; |
|
478 iSourceBuf = HBufC8::NewL(length); |
|
479 TPtr8 buf(iSourceBuf->Des()); |
|
480 User::LeaveIfError( iFileHandle.Read(buf) ); |
|
481 iFileHandle.Close(); |
|
482 iImageDisplay->SetImageSource(TDescriptorDataSource(*iSourceBuf)); |
|
483 } |
|
484 break; |
|
485 default: |
|
486 ASSERT(FALSE); |
|
487 } |
|
488 } |
|
489 |
|
490 TBool CTestStepImgDisplayGeneric::ConsumeFrame(const CFbsBitmap* /*aBitmap*/) |
|
491 { |
|
492 ++iFrameNumber; |
|
493 return ETrue; |
|
494 } |
|
495 |
|
496 void CTestStepImgDisplayGeneric::MiidoImageReady(const CFbsBitmap* aBitmap, TUint aStatus, const TRect& /*aUpdatedArea*/, TInt aError) |
|
497 { |
|
498 INFO_PRINTF3(_L("ImgReadCb Status=%d Error=%d"), aStatus, aError); |
|
499 iLastError = aError; |
|
500 iLatestPlugintStatus= aStatus; |
|
501 if (KErrNone != iLastError || (aStatus & CImageDisplayPlugin::EStatusNoMoreToDecode)) |
|
502 { |
|
503 CActiveScheduler::Stop(); |
|
504 } |
|
505 else if (aStatus & CImageDisplayPlugin::EStatusFrameReady) |
|
506 { |
|
507 TBool ContinueDecoding=ConsumeFrame(aBitmap); |
|
508 if (ContinueDecoding && iLastError == KErrNone) |
|
509 { |
|
510 iImageDisplay->Play(); |
|
511 } |
|
512 else |
|
513 { |
|
514 CActiveScheduler::Stop(); |
|
515 } |
|
516 } |
|
517 } |
|
518 |
|
519 /** |
|
520 * |
|
521 * Do the test step. |
|
522 * transform from file to file |
|
523 * @return "TVerdict" the status of the test |
|
524 * The result of the test step |
|
525 */ |
|
526 TVerdict CTestStepImgDisplayGeneric::TestL() |
|
527 { |
|
528 // assume success |
|
529 TVerdict testStepResult = EPass; |
|
530 |
|
531 ASSERT(iImageDisplay == NULL); |
|
532 // create an ImageDisplay object |
|
533 iImageDisplay = CImageDisplay::NewL(*this, iFs); |
|
534 |
|
535 // "normal" operation using the mimetype |
|
536 SetupPluginL(); |
|
537 // |
|
538 // try to "reuse" framework |
|
539 // |
|
540 // PluginLoaded -> Configured |
|
541 iImageDisplay->Reset(); |
|
542 SetupPluginL(); |
|
543 iImageDisplay->Reset(); |
|
544 |
|
545 TBuf8<1> dummyBuffer; |
|
546 iImageDisplay->SetImageSource(TDescriptorDataSource(dummyBuffer)); |
|
547 // Configured -> Opened |
|
548 iImageDisplay->Reset(); |
|
549 // Opened -> Configured |
|
550 SetImageSourceL(); |
|
551 // "normal" operation using the file name |
|
552 iImageDisplay->SetSizeInPixels(TSize(iTestParams->iDestWidth, iTestParams->iDestHeight), iTestParams->iMaintainAspectRatio); |
|
553 iImageDisplay->SetOptions(CImageDisplay::EOptionMainImage); |
|
554 iImageDisplay->SetupL(); |
|
555 if (KErrNone != iLastError) |
|
556 { |
|
557 INFO_PRINTF2(_L("Error from SetupL() %d after reuse"),iLastError); |
|
558 return (testStepResult = EFail ); |
|
559 } |
|
560 // try PluginLoaded -> (Processing <-> Paused) -> PluginLoaded two times |
|
561 for(TInt i=2; i && KErrNone == iLastError; --i) |
|
562 { |
|
563 // start decoding |
|
564 iImageDisplay->Play(); |
|
565 CActiveScheduler::Start(); |
|
566 } |
|
567 if (KErrNone != iLastError && |
|
568 !(iTestParams->iTestType==TImageDisplayUnitTestParams::EAlloc && KErrNoMemory == iLastError)) |
|
569 testStepResult = EFail; |
|
570 iImageDisplay->StopPlay(); |
|
571 delete iImageDisplay; |
|
572 iImageDisplay = NULL; |
|
573 return testStepResult; |
|
574 } |
|
575 |
|
576 void CTestStepImgDisplayGeneric::SetupPluginL() |
|
577 { |
|
578 if (0 != iTestParams->iPluginUid) |
|
579 { |
|
580 iImageDisplay->SetPluginUid(TUid::Uid(iTestParams->iPluginUid)); |
|
581 } |
|
582 |
|
583 if (iTestParams->iDestWidth > 0) |
|
584 { |
|
585 iImageDisplay->SetSizeInPixels(TSize(iTestParams->iDestWidth, iTestParams->iDestHeight), |
|
586 iTestParams->iMaintainAspectRatio); |
|
587 } |
|
588 |
|
589 if (-1 != iTestParams->iDisplayMode) |
|
590 { |
|
591 iImageDisplay->SetDisplayMode(TDisplayMode(iTestParams->iDisplayMode)); |
|
592 } |
|
593 |
|
594 if (-1 != iTestParams->iImageOptions) |
|
595 { |
|
596 iImageDisplay->SetOptions(iTestParams->iImageOptions); |
|
597 } |
|
598 |
|
599 if (NULL != iTestParams->iMimeType) |
|
600 { |
|
601 iImageDisplay->SetSourceMimeType(TPtrC8(iTestParams->iMimeType)); |
|
602 } |
|
603 |
|
604 if (iTestParams->iImageType || iTestParams->iImageSubType) |
|
605 { |
|
606 iImageDisplay->SetSourceImageType(TUid::Uid(iTestParams->iImageType ), TUid::Uid(iTestParams->iImageSubType)); |
|
607 } |
|
608 |
|
609 if (TImageDisplayUnitTestParams::ETypeUndefined != iTestParams->iSourceType) |
|
610 { |
|
611 SetImageSourceL(); |
|
612 } |
|
613 } |
|
614 |
|
615 void CTestStepImgDisplayGeneric::SetFilenamesL(const TDesC& aSourceFilename) |
|
616 { |
|
617 // Define the source, destination & ref image file names |
|
618 // construct the output & reference filename from the source |
|
619 // filename by appending the size of the dest image to it |
|
620 SetSourceFilename(aSourceFilename); |
|
621 TParse parse; |
|
622 User::LeaveIfError(parse.Set(aSourceFilename, NULL, NULL)); |
|
623 TFileName outputFilename; |
|
624 outputFilename.Append(parse.Drive()); |
|
625 outputFilename.Append(parse.Name()); |
|
626 TBuf<20> suffix; |
|
627 suffix.Format(_L("_%dx%d"), iTestParams->iDestWidth, iTestParams->iDestHeight); |
|
628 outputFilename.Append(suffix); |
|
629 |
|
630 if (iTestParams->iMaintainAspectRatio) |
|
631 outputFilename.Append(_L("_m")); |
|
632 |
|
633 outputFilename.Append(parse.Ext()); |
|
634 SetDestFilenameL(outputFilename); |
|
635 DeleteDestFilenameL(); |
|
636 SetRefFilenameL(outputFilename); |
|
637 } |
|
638 |
|
639 TBool CTestStepDecode2Frames::ConsumeFrame(const CFbsBitmap* aBitmap) |
|
640 { |
|
641 if (++iFrameNumber <3) |
|
642 { |
|
643 TBuf<32> fileName ; |
|
644 fileName.AppendFormat(_L("frame_%d.mbm"),iFrameNumber); |
|
645 SetDestFilenameL(fileName); |
|
646 iLastError = const_cast<CFbsBitmap*>(aBitmap)->Save(DestFilename()); |
|
647 if (KErrNone == iLastError) |
|
648 { |
|
649 return ETrue; |
|
650 } |
|
651 } |
|
652 return EFalse; |
|
653 } |
|
654 |
|
655 TVerdict CTestStepDecode2Frames::TestL() |
|
656 { |
|
657 TVerdict testStepResult = EPass; |
|
658 // create an ImageDisplay object |
|
659 iImageDisplay = CImageDisplay::NewL(*this, iFs); |
|
660 |
|
661 SetupPluginL(); |
|
662 |
|
663 iImageDisplay->SetupL(); |
|
664 |
|
665 SetRefFilenameL(_L("frame_2.mbm")); |
|
666 for(TInt i=2; i && KErrNone == iLastError; --i) |
|
667 { |
|
668 // start decoding |
|
669 iImageDisplay->Play(); |
|
670 CActiveScheduler::Start(); |
|
671 } |
|
672 TVerdict res=EFail; |
|
673 if (iLastError==KErrNone) |
|
674 { |
|
675 TRAP(iLastError, res=CompareFilesL(RefFilename(), DestFilename())); |
|
676 } |
|
677 |
|
678 if (KErrNone != iLastError) |
|
679 { |
|
680 INFO_PRINTF2(_L("Got an error %d"), iLastError); |
|
681 if (!(iTestParams->iTestType==TImageDisplayUnitTestParams::EAlloc && KErrNoMemory == iLastError)) |
|
682 { |
|
683 testStepResult = EFail; |
|
684 } |
|
685 } |
|
686 else |
|
687 { |
|
688 testStepResult = res; |
|
689 } |
|
690 |
|
691 |
|
692 return testStepResult; |
|
693 } |
|
694 |
|
695 |
|
696 TVerdict CTestStepPanic_1::TestL() |
|
697 { |
|
698 iImageDisplay = CImageDisplay::NewL(*this, iFs); |
|
699 iImageDisplay->Play(); |
|
700 return EFail; |
|
701 } |
|
702 |
|
703 TVerdict CTestStepPanic_2::TestL() |
|
704 { |
|
705 iImageDisplay = CImageDisplay::NewL(*this, iFs); |
|
706 SetupPluginL(); |
|
707 iImageDisplay->SetupL(); |
|
708 return EFail; |
|
709 } |
|
710 |
|
711 TVerdict CTestStepPanic_3::TestL() |
|
712 { |
|
713 iImageDisplay = CImageDisplay::NewL(*this, iFs); |
|
714 SetupPluginL(); |
|
715 iImageDisplay->SetupL(); |
|
716 iImageDisplay->Play(); |
|
717 return EFail; |
|
718 } |
|
719 |
|
720 TVerdict CTestStepPanic_4::TestL() |
|
721 { |
|
722 iImageDisplay = CImageDisplay::NewL(*this, iFs); |
|
723 SetupPluginL(); |
|
724 iImageDisplay->SetupL(); |
|
725 MTestHelper* ExtIFace; |
|
726 if (KErrNone != iImageDisplay->ExtensionInterface(TUid::Uid(MTestHelper::KIFaceUidValue), |
|
727 *reinterpret_cast<TAny**>(&ExtIFace)) |
|
728 ) |
|
729 return EFail; |
|
730 ExtIFace->TriggerPanic_4(); |
|
731 return EFail; |
|
732 } |
|
733 |
|
734 TVerdict CTestStepPanic_6::TestL() |
|
735 { |
|
736 iImageDisplay = CImageDisplay::NewL(*this, iFs); |
|
737 SetupPluginL(); |
|
738 iImageDisplay->SetupL(); |
|
739 iImageDisplay->Play(); |
|
740 return EFail; |
|
741 } |
|
742 |
|
743 TBool CTestStepDrm::ConsumeFrame(const CFbsBitmap* /*aBitmap*/) |
|
744 { |
|
745 return EFalse; |
|
746 } |
|
747 |
|
748 TVerdict CTestStepDrm::TestL() |
|
749 { |
|
750 iImageDisplay = CImageDisplay::NewL(*this, iFs); |
|
751 do |
|
752 { |
|
753 TInt i=iTestParams->iPlayLoops+(iTestParams->iPlayLoops==0); |
|
754 TInt loopNum=1; |
|
755 INFO_PRINTF2(_L("Content unique ID '%s'"), *iCurrentUId); |
|
756 |
|
757 do |
|
758 { |
|
759 SetupPluginL(); |
|
760 TRAP(iLastError, |
|
761 iImageDisplay->SetupL(); |
|
762 ); |
|
763 if (iLastError==KErrNoMemory && iTestParams->iTestType == TImageDisplayUnitTestParams::EAlloc) |
|
764 { |
|
765 User::Leave(KErrNoMemory); |
|
766 } |
|
767 if (iLastError==KErrNone) |
|
768 { |
|
769 if (iTestParams->iDestWidth == 0) |
|
770 { |
|
771 iImageDisplay->SetSizeInPixels(iImageDisplay->RecommendedImageSizes()[0]); |
|
772 } |
|
773 iImageDisplay->Play(); |
|
774 CActiveScheduler::Start(); |
|
775 } |
|
776 if (iLastError==KErrNoMemory && iTestParams->iTestType == TImageDisplayUnitTestParams::EAlloc) |
|
777 { |
|
778 User::Leave(KErrNoMemory); |
|
779 } |
|
780 iImageDisplay->Reset(); |
|
781 if (iLastError!=KErrNone && i>1) |
|
782 { |
|
783 INFO_PRINTF3(_L("Got Error=%d during Loop=%d"), iLastError, loopNum); |
|
784 return EFail; |
|
785 } |
|
786 } while (++loopNum,--i); |
|
787 |
|
788 INFO_PRINTF3(_L("Got Error=%d Expected=%d"), iLastError, iTestParams->iExpectedError); |
|
789 if (iLastError==KErrNoMemory && iTestParams->iTestType == TImageDisplayUnitTestParams::EAlloc) |
|
790 { |
|
791 User::Leave(KErrNoMemory); |
|
792 } |
|
793 if (iLastError!=KErrNone && iLastError!=iTestParams->iExpectedError) |
|
794 { |
|
795 return EFail; |
|
796 } |
|
797 } while (iCurrentUId && *iCurrentUId && *(++iCurrentUId)); |
|
798 |
|
799 return EPass; |
|
800 } |
|
801 |
|
802 // MNG Mime Type recognition tests // |
|
803 CTestStepImageDisplayRecog::CTestStepImageDisplayRecog(const TMimeTypeRecogTestParam& aTestParam): |
|
804 iTestParam(aTestParam) |
|
805 { |
|
806 iTestStepName.Copy(iTestParam.iTestName); |
|
807 } |
|
808 |
|
809 TVerdict CTestStepImageDisplayRecog::DoTestStepPreambleL() |
|
810 { |
|
811 TVerdict v=CTestStepImageDisplay::DoTestStepPreambleL(); |
|
812 if (EPass!=v) |
|
813 { |
|
814 return v; |
|
815 } |
|
816 User::LeaveIfError( iApaLsSession.Connect() ); |
|
817 return EPass; |
|
818 } |
|
819 |
|
820 TVerdict CTestStepImageDisplayRecog::DoTestStepPostambleL() |
|
821 { |
|
822 iApaLsSession.Close(); |
|
823 return CTestStepImageDisplay::DoTestStepPostambleL(); |
|
824 } |
|
825 |
|
826 TVerdict CTestStepImageDisplayRecog::DoTestStepL() |
|
827 { |
|
828 INFO_PRINTF2(_L("%S"), &iTestStepName); |
|
829 INFO_PRINTF2(_L("%s"), iTestParam.iTestDescription); |
|
830 TInt error=KErrNone; |
|
831 TDataRecognitionResult result; |
|
832 result.Reset(); |
|
833 SetSourceFilename(TPtrC(iTestParam.iFileNameParam)); |
|
834 if (iTestParam.iParamType==TMimeTypeRecogTestParam::EParamIsFileName) |
|
835 { |
|
836 error=iApaLsSession.RecognizeData(SourceFilename(), KNullDesC8(), result); |
|
837 } |
|
838 else if (iTestParam.iParamType==TMimeTypeRecogTestParam::EParamIsDataBuffer) |
|
839 { |
|
840 TPtrC8 dataBuf; |
|
841 TBuf8<32> buffer; |
|
842 if (iTestParam.iDataBufferParam==NULL) |
|
843 { |
|
844 RFile f; |
|
845 if ((error=f.Open(iFs, SourceFilename(), EFileRead|EFileShareAny))==KErrNone) |
|
846 { |
|
847 error=f.Read(buffer); |
|
848 } |
|
849 dataBuf.Set(buffer); |
|
850 f.Close(); |
|
851 } |
|
852 else |
|
853 { |
|
854 dataBuf.Set(iTestParam.iDataBufferParam); |
|
855 } |
|
856 if (error==KErrNone) |
|
857 { |
|
858 error=iApaLsSession.RecognizeData(SourceFilename(), dataBuf, result); |
|
859 } |
|
860 } |
|
861 else |
|
862 { |
|
863 ASSERT(EFalse); |
|
864 } |
|
865 |
|
866 if (error!=KErrNone || result.iConfidence < iTestParam.iMinConfidence) |
|
867 { |
|
868 INFO_PRINTF3(_L("Got Failed to recognize data Error=%d Confidence=%d"), error,result.iConfidence); |
|
869 return EFail; |
|
870 } |
|
871 if (result.iDataType.Des8().Compare(TPtrC8(iTestParam.iExpectedMimeType))!=0) |
|
872 { |
|
873 TPtrC ptr(result.iDataType.Des()); |
|
874 TFileName mime; |
|
875 mime.Copy( TPtrC8(iTestParam.iExpectedMimeType) ); |
|
876 INFO_PRINTF3(_L("Got Wrong Mime type Got '%S' Expected '%S'"), &ptr, &mime); |
|
877 return EFail; |
|
878 } |
|
879 return EPass; |
|
880 } |
|
881 |
|
882 void CTestStepImageDisplayRecog::MiidoImageReady(const CFbsBitmap* /*aBitmap*/, TUint /*aStatus*/, const TRect& /*aUpdatedArea*/, TInt /*aError*/) |
|
883 { |
|
884 ASSERT(EFalse);// we mustn't be here |
|
885 } |
|
886 |
|
887 |
|
888 // |
|
889 // Regression test case for defect: DEF082108: Browsing to www.mobil.se will crash the phone |
|
890 CTestStepImageDisplayMimeCheck::CTestStepImageDisplayMimeCheck() |
|
891 { |
|
892 iTestStepName.Copy(_L("MM-ICL-IMGDISP-U-0306-HP")); |
|
893 } |
|
894 |
|
895 TVerdict CTestStepImageDisplayMimeCheck::DoTestStepPreambleL() |
|
896 { |
|
897 CTestStepImageDisplay::DoTestStepPreambleL(); |
|
898 |
|
899 return EPass; |
|
900 } |
|
901 |
|
902 TVerdict CTestStepImageDisplayMimeCheck::DoTestStepPostambleL() |
|
903 { |
|
904 CTestStepImageDisplay::DoTestStepPostambleL(); |
|
905 |
|
906 return EPass; |
|
907 } |
|
908 |
|
909 TVerdict CTestStepImageDisplayMimeCheck::DoTestStepL() |
|
910 { |
|
911 INFO_PRINTF1(_L("CTestStepImageDisplayMimeCheck::DoTestStepL()")); |
|
912 INFO_PRINTF1(_L("Regression test case for defect: DEF082108")); |
|
913 INFO_PRINTF1(_L("Checks that CIclRecognizerUtil::GetMimeTypeL() can handle aFileName > KMaxFileName")); |
|
914 |
|
915 TBuf8<4> KMimeType; |
|
916 TBuf<KMaxFileName*2> filename; |
|
917 filename.SetLength(KMaxFileName*2); |
|
918 |
|
919 CIclRecognizerUtil* temp = CIclRecognizerUtil::NewL(); |
|
920 CleanupStack::PushL(temp); |
|
921 |
|
922 HBufC8* header = HBufC8::NewL(32); |
|
923 |
|
924 CleanupStack::Pop(); |
|
925 TRAPD(err, temp->GetMimeTypeL(*header, filename, KMimeType)); |
|
926 |
|
927 delete temp; |
|
928 delete header; |
|
929 |
|
930 if ( err == KErrBadName ) |
|
931 { |
|
932 return EPass; |
|
933 } |
|
934 |
|
935 return EFail; |
|
936 } |
|
937 |
|
938 void CTestStepImageDisplayMimeCheck::MiidoImageReady(const CFbsBitmap* /*aBitmap*/, TUint /*aStatus*/, const TRect& /*aUpdatedArea*/, TInt /*aError*/) |
|
939 { |
|
940 ASSERT(EFalse);// we mustn't be here |
|
941 } |