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