Update contrib.
1 // Copyright (c) 2003-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // This file contains the implementation of the various
15 // ALLOC tests for DevVideo
19 // Test system includes
20 #include <testframework.h>
22 #include "TestDevVideoPlugins/decoder.h"
23 #include "TestDevVideoPlugins/postproc.h"
25 #include "TestDevVideoPlugins/encoder.h"
26 #include "TestDevVideoPlugins/preproc.h"
28 #include "TestStepDevVideoAllocFailNew.h"
29 #include "TestDevVideoPlayTestData.h"
32 // --------------------------------------------
36 * Test step constructor.
37 * Each test step initialises its own name.
40 CTestStepDevVideoPlayAllocFail::CTestStepDevVideoPlayAllocFail(const TDesC& aTestName)
42 // store the name of this test case
43 // this is the name that is used by the script file
44 iTestStepName = aTestName;
49 * Test step destructor.
52 CTestStepDevVideoPlayAllocFail::~CTestStepDevVideoPlayAllocFail()
56 // MMMFDevVideoPlayObserver
57 void CTestStepDevVideoPlayAllocFail::MdvpoNewBuffers()
59 INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoNewBuffers()"));
62 void CTestStepDevVideoPlayAllocFail::MdvpoReturnPicture(TVideoPicture* /*aPicture*/)
64 INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoReturnPicture()"));
67 void CTestStepDevVideoPlayAllocFail::MdvpoSupplementalInformation(const TDesC8& /*aData*/,
68 const TTimeIntervalMicroSeconds& /*aTimestamp*/,
69 const TPictureId& /*aPictureId*/)
71 INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoSupplementalInformation()"));
74 void CTestStepDevVideoPlayAllocFail::MdvpoPictureLoss()
76 INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoPictureLoss()"));
79 void CTestStepDevVideoPlayAllocFail::MdvpoPictureLoss(const TArray<TPictureId>& /*aPictures*/)
81 INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoPictureLoss(TArray)"));
84 void CTestStepDevVideoPlayAllocFail::MdvpoSliceLoss(TUint /*aFirstMacroblock*/, TUint /*aNumMacroblocks*/, const TPictureId& /*aPicture*/)
86 INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoSliceLoss()"));
89 void CTestStepDevVideoPlayAllocFail::MdvpoReferencePictureSelection(const TDesC8& /*aSelectionData*/)
91 INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoReferencePictureSelection()"));
94 void CTestStepDevVideoPlayAllocFail::MdvpoTimedSnapshotComplete(TInt /*aError*/,
95 TPictureData* /*aPictureData*/,
96 const TTimeIntervalMicroSeconds& /*aPresentationTimestamp*/,
97 const TPictureId& /*aPictureId*/)
99 INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoTimedSnapshotComplete()"));
102 void CTestStepDevVideoPlayAllocFail::MdvpoNewPictures()
104 INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoNewPictures()"));
107 void CTestStepDevVideoPlayAllocFail::MdvpoFatalError(TInt aError)
110 INFO_PRINTF2(_L("CTestStepDevVideoPlayAllocFail::MdvpoFatalError()\nError = %d"), aError);
113 void CTestStepDevVideoPlayAllocFail::MdvpoInitComplete(TInt aError)
116 INFO_PRINTF2(_L("CTestStepDevVideoPlayAllocFail::MdvpoInitComplete(): Error = %d"), aError);
119 void CTestStepDevVideoPlayAllocFail::MdvpoStreamEnd()
121 INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoStreamEnd()"));
127 * Each test step must supply an implementation for DoTestStepL.
130 * The result of the test step
133 TVerdict CTestStepDevVideoPlayAllocFail::DoTestStepL()
135 TVerdict ret = EFail;
137 // do we want to do anything else in the base class?
139 // call alloc test step
146 //----------------------------------------------------------------------------
148 CTestStepDevVideoPlayAllocFailNew::CTestStepDevVideoPlayAllocFailNew(const TDesC& aTestName)
149 :CTestStepDevVideoPlayAllocFail(aTestName)
153 CTestStepDevVideoPlayAllocFailNew* CTestStepDevVideoPlayAllocFailNew::NewL(const TDesC& aTestName)
155 CTestStepDevVideoPlayAllocFailNew* self = new(ELeave) CTestStepDevVideoPlayAllocFailNew(aTestName);
159 CTestStepDevVideoPlayAllocFailNew::~CTestStepDevVideoPlayAllocFailNew()
163 TVerdict CTestStepDevVideoPlayAllocFailNew::DoTestL()
165 iTestStepResult = EPass;
168 // Printing to the console and log file
169 INFO_PRINTF1(_L("this is an Alloc Failure test of initialising CMMFDevVideoPlay with NewL()"));
172 TRAP( err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this) );
173 delete iDevVideoPlay;
174 iDevVideoPlay = NULL;
181 TBool completed = EFalse;
182 TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
185 __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
188 TRAP( err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this);
189 iDevVideoPlay->SelectDecoderL(KUidDevVideoTestDecodeHwDevice);
190 iDevVideoPlay->SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice); );
195 TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
199 failCount--; // -= 1;
202 User::Free(testAlloc);
205 else if (err != KErrNoMemory) // bad error code
208 // see if valid result and break if wrong - might be premature result
211 delete iDevVideoPlay;
212 iDevVideoPlay = NULL;
214 completed = reachedEnd;
216 __UHEAP_SETFAIL(RHeap::ENone ,0);
226 INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
227 iTestStepResult = EFail;
231 INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
232 iTestStepResult = EPass;
237 delete iDevVideoPlay;
238 iDevVideoPlay = NULL;
241 INFO_PRINTF1(_L("finished with this test step"));
242 // test steps return a result
243 return iTestStepResult;
246 //----------------------------------------------------------------------------
249 CTestStepDevVideoPlayAllocFailFindPlugins::CTestStepDevVideoPlayAllocFailFindPlugins(const TDesC& aTestName)
250 :CTestStepDevVideoPlayAllocFail(aTestName)
254 CTestStepDevVideoPlayAllocFailFindPlugins* CTestStepDevVideoPlayAllocFailFindPlugins::NewL(const TDesC& aTestName)
256 CTestStepDevVideoPlayAllocFailFindPlugins* self = new(ELeave) CTestStepDevVideoPlayAllocFailFindPlugins(aTestName);
260 CTestStepDevVideoPlayAllocFailFindPlugins::~CTestStepDevVideoPlayAllocFailFindPlugins()
264 TVerdict CTestStepDevVideoPlayAllocFailFindPlugins::DoTestL()
266 iTestStepResult = EPass;
269 // Printing to the console and log file
270 INFO_PRINTF1(_L("this is an Alloc Failure test of finding decoder and post processor plugins"));
274 TBool completed = EFalse;
275 TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
278 __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
284 TRAP(err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this));
286 TRAP(err, GetDecodersL());
288 TRAP(err, GetPostProcessorsL());
290 TRAP(err, FindDecodersL());
292 TRAP(err, FindPostProcessorsL());
294 REComSession::FinalClose();
299 TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
303 failCount--; // -= 1;
306 User::Free(testAlloc);
309 else if (err != KErrNoMemory) // bad error code
312 // see if valid result and break if wrong - might be premature result
313 delete iDevVideoPlay;
314 iDevVideoPlay = NULL;
317 __UHEAP_SETFAIL(RHeap::ENone ,0);
319 if (completed || reachedEnd)
327 INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
328 iTestStepResult = EFail;
332 INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
333 iTestStepResult = EPass;
336 delete iDevVideoPlay;
337 iDevVideoPlay = NULL;
339 INFO_PRINTF1(_L("finished with this test step"));
340 // test steps return a result
341 return iTestStepResult;
344 void CTestStepDevVideoPlayAllocFailFindPlugins::CheckPluginsL(const RArray<TUid>& aFoundPlugins, const RArray<TUid>& aExpectedPlugins, const RArray<TUid>& aUnExpectedPlugins)
346 TBool foundUnExpected = EFalse;
347 TInt numberToBeFoundInExpectedPlugins = aExpectedPlugins.Count();
349 for (TInt i=0; i<aFoundPlugins.Count(); i++)
351 TUid uidToLookFor = aFoundPlugins[i];
353 for (j=0; j<aExpectedPlugins.Count(); j++)
355 if (aExpectedPlugins[j] == uidToLookFor)
357 numberToBeFoundInExpectedPlugins--;
361 for (j=0; j<aUnExpectedPlugins.Count(); j++)
363 if (aUnExpectedPlugins[j] == uidToLookFor)
365 foundUnExpected = ETrue;
371 if ((foundUnExpected) || (numberToBeFoundInExpectedPlugins!=0))
372 User::Leave(KErrGeneral);
377 void CTestStepDevVideoPlayAllocFailFindPlugins::FindDecodersL()
379 RArray<TUid> foundDecoders;
380 CleanupClosePushL(foundDecoders);
381 RArray<TUid> expectedDecoders;
382 CleanupClosePushL(expectedDecoders);
383 RArray<TUid> unExpectedDecoders;
384 CleanupClosePushL(unExpectedDecoders);
387 // Supported mime type and post proc type (by exact match)
388 _LIT8(KMimeType5, "video/zippyvideo");
389 TUint32 requestedPostProcType = EPpMirror|EPpInputCrop;
390 foundDecoders.Reset();
391 expectedDecoders.Reset();
392 unExpectedDecoders.Reset();
393 User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice1));
394 User::LeaveIfError(unExpectedDecoders.Append(KUidDevVideoTestDecodeHwDevice2));
395 User::LeaveIfError(unExpectedDecoders.Append(KUidDevVideoTestDecodeHwDevice3));
396 User::LeaveIfError(unExpectedDecoders.Append(KUidDevVideoTestDecodeHwDevice4));
397 User::LeaveIfError(unExpectedDecoders.Append(KUidDevVideoTestDecodeHwDevice5));
399 iDevVideoPlay->FindDecodersL(KMimeType5(), requestedPostProcType, foundDecoders, ETrue);
400 CheckPluginsL(foundDecoders, expectedDecoders, unExpectedDecoders);
402 CleanupStack::PopAndDestroy(3);
405 void CTestStepDevVideoPlayAllocFailFindPlugins::FindPostProcessorsL()
407 RArray<TUid> foundPostProx;
408 CleanupClosePushL(foundPostProx);
409 RArray<TUid> expectedPostProx;
410 CleanupClosePushL(expectedPostProx);
411 RArray<TUid> unExpectedPostProx;
412 CleanupClosePushL(unExpectedPostProx);
414 TUint32 requestedPostProcType = EPpMirror|EPpInputCrop;
415 foundPostProx.Reset();
416 expectedPostProx.Reset();
417 User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice1));
418 User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice2));
419 User::LeaveIfError(unExpectedPostProx.Append(KUidDevVideoTestPostProcHwDevice3));
420 User::LeaveIfError(unExpectedPostProx.Append(KUidDevVideoTestPostProcHwDevice4));
421 User::LeaveIfError(unExpectedPostProx.Append(KUidDevVideoTestPostProcHwDevice5));
423 iDevVideoPlay->FindPostProcessorsL(requestedPostProcType, foundPostProx);
424 CheckPluginsL(foundPostProx, expectedPostProx, unExpectedPostProx);
426 CleanupStack::PopAndDestroy(3);
429 void CTestStepDevVideoPlayAllocFailFindPlugins::GetDecodersL()
431 RArray<TUid> foundDecoders;
432 CleanupClosePushL(foundDecoders);
433 RArray<TUid> expectedDecoders;
434 CleanupClosePushL(expectedDecoders);
435 RArray<TUid> unExpectedDecoders;
436 CleanupClosePushL(unExpectedDecoders);
438 User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice1));
439 User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice2));
440 User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice3));
441 User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice4));
442 User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice5));
444 iDevVideoPlay->GetDecoderListL(foundDecoders);
446 CheckPluginsL(foundDecoders, expectedDecoders, unExpectedDecoders);
448 CleanupStack::PopAndDestroy(3); //foundDecoders, expectedDecoders, unExpectedDecoders
451 void CTestStepDevVideoPlayAllocFailFindPlugins::GetPostProcessorsL()
453 RArray<TUid> foundPostProx;
454 CleanupClosePushL(foundPostProx);
455 RArray<TUid> expectedPostProx;
456 CleanupClosePushL(expectedPostProx);
457 RArray<TUid> unExpectedPostProx;
458 CleanupClosePushL(unExpectedPostProx);
460 User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice1));
461 User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice2));
462 User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice3));
463 User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice4));
464 User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice5));
466 iDevVideoPlay->GetPostProcessorListL(foundPostProx);
468 CheckPluginsL(foundPostProx, expectedPostProx, unExpectedPostProx);
470 CleanupStack::PopAndDestroy(3);//foundPostProx, expectedPostProx, unExpectedPostProx
473 //----------------------------------------------------------------------------
475 CTestStepDevVideoPlayAllocFailInfoDecoder::CTestStepDevVideoPlayAllocFailInfoDecoder(const TDesC& aTestName)
476 :CTestStepDevVideoPlayAllocFail(aTestName)
480 CTestStepDevVideoPlayAllocFailInfoDecoder* CTestStepDevVideoPlayAllocFailInfoDecoder::NewL(const TDesC& aTestName)
482 CTestStepDevVideoPlayAllocFailInfoDecoder* self = new(ELeave) CTestStepDevVideoPlayAllocFailInfoDecoder(aTestName);
486 CTestStepDevVideoPlayAllocFailInfoDecoder::~CTestStepDevVideoPlayAllocFailInfoDecoder()
490 TVerdict CTestStepDevVideoPlayAllocFailInfoDecoder::DoTestL()
492 iTestStepResult = EPass;
495 // Printing to the console and log file
496 INFO_PRINTF1(_L("this is an Alloc Failure test of VideoDecoderInfoLC()"));
498 // moved creation and destruction of iDevVideoPlay inside the heap marks.
499 // reason :- VideoDecoderInfoLC may allocate onto it
502 TBool completed = EFalse;
503 TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
506 __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
509 TRAP (err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this));
513 CVideoDecoderInfo* vidInfo = NULL;
515 TRAP( err, vidInfo = iDevVideoPlay->VideoDecoderInfoLC(KUidDevVideoTestDecodeHwDevice);
516 CleanupStack::Pop(vidInfo); );
521 TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
525 failCount--; // -= 1;
528 User::Free(testAlloc);
531 else if (err != KErrNoMemory) // bad error code
534 // see if valid result and break if wrong - might be premature result
542 else if (err != KErrNoMemory) // bad error code
547 delete iDevVideoPlay;
548 iDevVideoPlay = NULL;
551 completed = reachedEnd;
554 __UHEAP_SETFAIL(RHeap::ENone ,0);
564 INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
565 iTestStepResult = EFail;
569 INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
570 iTestStepResult = EPass;
573 INFO_PRINTF1(_L("finished with this test step"));
574 // test steps return a result
575 return iTestStepResult;
579 //----------------------------------------------------------------------------
581 CTestStepDevVideoPlayAllocFailInfoPostProc::CTestStepDevVideoPlayAllocFailInfoPostProc(const TDesC& aTestName)
582 :CTestStepDevVideoPlayAllocFail(aTestName)
586 CTestStepDevVideoPlayAllocFailInfoPostProc* CTestStepDevVideoPlayAllocFailInfoPostProc::NewL(const TDesC& aTestName)
588 CTestStepDevVideoPlayAllocFailInfoPostProc* self = new(ELeave) CTestStepDevVideoPlayAllocFailInfoPostProc(aTestName);
592 CTestStepDevVideoPlayAllocFailInfoPostProc::~CTestStepDevVideoPlayAllocFailInfoPostProc()
596 TVerdict CTestStepDevVideoPlayAllocFailInfoPostProc::DoTestL()
598 iTestStepResult = EPass;
601 // Printing to the console and log file
602 INFO_PRINTF1(_L("this is an Alloc Failure test of PostProcessorInfoLC()"));
604 // will leave on error
605 TRAP (err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this));
609 ERR_PRINTF1(_L("Error - Couldn't construct CMMFDevVideoPlay!"));
610 return EInconclusive;
613 CPostProcessorInfo* postInfo = NULL;
616 TBool completed = EFalse;
617 TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
620 __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
623 TRAP( err, postInfo = iDevVideoPlay->PostProcessorInfoLC(KUidDevVideoTestPostProcHwDevice);
624 CleanupStack::Pop(postInfo); );
626 REComSession::FinalClose();
631 TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
635 failCount--; // -= 1;
638 User::Free(testAlloc);
641 else if (err != KErrNoMemory) // bad error code
644 // see if valid result and break if wrong - might be premature result
652 completed = reachedEnd;
655 __UHEAP_SETFAIL(RHeap::ENone ,0);
665 INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
666 iTestStepResult = EFail;
670 INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
671 iTestStepResult = EPass;
676 delete iDevVideoPlay;
677 iDevVideoPlay = NULL;
680 INFO_PRINTF1(_L("finished with this test step"));
681 // test steps return a result
682 return iTestStepResult;
686 //----------------------------------------------------------------------------
689 CTestStepDevVideoPlayAllocFailGetPictures::CTestStepDevVideoPlayAllocFailGetPictures(const TDesC& aTestName)
690 :CTestStepDevVideoPlayAllocFail(aTestName)
694 CTestStepDevVideoPlayAllocFailGetPictures* CTestStepDevVideoPlayAllocFailGetPictures::NewL(const TDesC& aTestName)
696 CTestStepDevVideoPlayAllocFailGetPictures* self = new(ELeave) CTestStepDevVideoPlayAllocFailGetPictures(aTestName);
700 CTestStepDevVideoPlayAllocFailGetPictures::~CTestStepDevVideoPlayAllocFailGetPictures()
704 TVerdict CTestStepDevVideoPlayAllocFailGetPictures::DoTestL()
706 iTestStepResult = EPass;
709 // Printing to the console and log file
710 INFO_PRINTF1(_L("this is an Alloc Failure test of retrieving and returning pictures to the plugin"));
714 TBool completed = EFalse;
715 TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
718 __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
721 TRAP(err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this));
723 TRAP(err, PerformTestL());
725 REComSession::FinalClose();
730 TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
734 failCount--; // -= 1;
737 User::Free(testAlloc);
740 else if (err != KErrNoMemory) // bad error code
743 // see if valid result and break if wrong - might be premature result
744 delete iDevVideoPlay;
745 iDevVideoPlay = NULL;
748 __UHEAP_SETFAIL(RHeap::ENone ,0);
750 if (completed || reachedEnd)
758 INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
759 iTestStepResult = EFail;
763 INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
764 iTestStepResult = EPass;
767 delete iDevVideoPlay;
768 iDevVideoPlay = NULL;
770 INFO_PRINTF1(_L("finished with this test step"));
771 // test steps return a result
772 return iTestStepResult;
776 void CTestStepDevVideoPlayAllocFailGetPictures::PerformTestL()
778 iTestError = KErrNone;
781 iDevVideoPlay->SelectDecoderL(KUidDevVideoTestDecodeHwDevice);
783 // select post-processor
784 iDevVideoPlay->SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice);
786 //Tell plugin to start creating pictures.
787 iDevVideoPlay->SetVideoDestScreenL(EFalse);
789 // initialize CDevVideoPlay and wait for response
790 iDevVideoPlay->Initialize();
792 User::LeaveIfError(iTestError);
794 iDevVideoPlay->Start();//Tell plugin to start creating pictures.
795 // We should now get a series of NewPicture() callbacks.
797 User::LeaveIfError(iTestError);
800 void CTestStepDevVideoPlayAllocFailGetPictures::MdvpoInitComplete(TInt aError)
805 void CTestStepDevVideoPlayAllocFailGetPictures::MdvpoNewPictures()
807 TRAP(iTestError, DoNewPicturesL());
810 void CTestStepDevVideoPlayAllocFailGetPictures::CheckNewPictureInfoL(TUint aNumPictures, const TTimeIntervalMicroSeconds& aFirst, const TTimeIntervalMicroSeconds& aLast)
812 TUint numPictures = 0;
813 TTimeIntervalMicroSeconds first(0);
814 TTimeIntervalMicroSeconds last(0);
815 iDevVideoPlay->GetNewPictureInfo(numPictures, first, last);
817 if ((numPictures!=aNumPictures) || (first!=aFirst) || (last!=aLast))
819 User::Leave(KErrGeneral);
823 void CTestStepDevVideoPlayAllocFailGetPictures::DoNewPicturesL()
825 User::LeaveIfError(iTestError);//Don't go any further if we have an error
826 switch (iCurrentPictureNumber)
830 iCurrentPictureNumber++;
831 CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
832 TVideoPicture* picture = iDevVideoPlay->NextPictureL();
833 CheckNewPictureInfoL(0, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
834 iDevVideoPlay->ReturnPicture(picture);
839 iCurrentPictureNumber++;
840 CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(1), TTimeIntervalMicroSeconds(1));
841 TVideoPicture* picture = iDevVideoPlay->NextPictureL();
842 CheckNewPictureInfoL(0, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
843 iDevVideoPlay->ReturnPicture(picture);
848 iCurrentPictureNumber++;
849 CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(2), TTimeIntervalMicroSeconds(2));
850 TVideoPicture* picture = iDevVideoPlay->NextPictureL();
851 CheckNewPictureInfoL(0, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
852 iDevVideoPlay->ReturnPicture(picture);
857 iCurrentPictureNumber++;
858 CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(3), TTimeIntervalMicroSeconds(3));
859 TVideoPicture* picture = iDevVideoPlay->NextPictureL();
860 iDevVideoPlay->ReturnPicture(picture);
865 iCurrentPictureNumber++;
866 CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(4), TTimeIntervalMicroSeconds(4));
867 TVideoPicture* picture = iDevVideoPlay->NextPictureL();
868 iDevVideoPlay->ReturnPicture(picture);
873 iCurrentPictureNumber++;
874 CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(5), TTimeIntervalMicroSeconds(5));
875 TVideoPicture* picture = iDevVideoPlay->NextPictureL();
876 iDevVideoPlay->ReturnPicture(picture);
881 iCurrentPictureNumber++;
882 CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(6), TTimeIntervalMicroSeconds(6));
887 iCurrentPictureNumber++;
888 CheckNewPictureInfoL(2, TTimeIntervalMicroSeconds(6), TTimeIntervalMicroSeconds(7));
893 iCurrentPictureNumber++;
894 CheckNewPictureInfoL(3, TTimeIntervalMicroSeconds(6), TTimeIntervalMicroSeconds(8));
899 iCurrentPictureNumber++;
900 CheckNewPictureInfoL(4, TTimeIntervalMicroSeconds(6), TTimeIntervalMicroSeconds(9));
901 TVideoPicture* picture = iDevVideoPlay->NextPictureL();
902 iDevVideoPlay->ReturnPicture(picture);
903 CheckNewPictureInfoL(3, TTimeIntervalMicroSeconds(7), TTimeIntervalMicroSeconds(9));
904 picture = iDevVideoPlay->NextPictureL();
905 iDevVideoPlay->ReturnPicture(picture);
906 CheckNewPictureInfoL(2, TTimeIntervalMicroSeconds(8), TTimeIntervalMicroSeconds(9));
907 picture = iDevVideoPlay->NextPictureL();
908 iDevVideoPlay->ReturnPicture(picture);
909 CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(9), TTimeIntervalMicroSeconds(9));
910 picture = iDevVideoPlay->NextPictureL();
911 iDevVideoPlay->ReturnPicture(picture);
912 CheckNewPictureInfoL(0, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
916 User::Leave(KErrGeneral);
922 //----------------------------------------------------------------------------
928 * Test step constructor.
929 * Each test step initialises its own name.
933 CTestStepDevVideoRecordAllocFail::CTestStepDevVideoRecordAllocFail(const TDesC& aTestName)
935 // store the name of this test case
936 // this is the name that is used by the script file
937 iTestStepName = aTestName;
942 * Test step destructor.
946 CTestStepDevVideoRecordAllocFail::~CTestStepDevVideoRecordAllocFail()
950 // MMMFDevVideoRecordObserver
951 void CTestStepDevVideoRecordAllocFail::MdvroNewBuffers()
953 INFO_PRINTF1(_L("CTestStepDevVideoRecordAllocFail::MdvroNewBuffers()"));
956 void CTestStepDevVideoRecordAllocFail::MdvroReturnPicture(TVideoPicture* /*aPicture*/)
958 INFO_PRINTF1(_L("CTestStepDevVideoRecordAllocFail::MdvroReturnPicture()"));
961 void CTestStepDevVideoRecordAllocFail::MdvroSupplementalInfoSent()
963 INFO_PRINTF1(_L("CTestStepDevVideoRecordAllocFail::MdvroSupplementalInfoSent()"));
966 void CTestStepDevVideoRecordAllocFail::MdvroFatalError(TInt aError)
969 INFO_PRINTF2(_L("CTestStepDevVideoRecordAllocFail::MdvroFatalError()\nError = %d"), aError);
972 void CTestStepDevVideoRecordAllocFail::MdvroInitializeComplete(TInt aError)
975 INFO_PRINTF2(_L("CTestStepDevVideoRecordAllocFail::MdvroInitializeComplete(): Error = %d"), aError);
978 void CTestStepDevVideoRecordAllocFail::MdvroStreamEnd()
980 INFO_PRINTF1(_L("CTestStepDevVideoRecordAllocFail::MdvroStreamEnd()"));
986 * Each test step must supply an implementation for DoTestStepL.
989 * The result of the test step
992 TVerdict CTestStepDevVideoRecordAllocFail::DoTestStepL()
994 TVerdict ret = EFail;
996 // call alloc test step
1002 //----------------------------------------------------------------------------
1004 CTestStepDevVideoRecordAllocFailNew::CTestStepDevVideoRecordAllocFailNew(const TDesC& aTestName)
1005 :CTestStepDevVideoRecordAllocFail(aTestName)
1009 CTestStepDevVideoRecordAllocFailNew* CTestStepDevVideoRecordAllocFailNew::NewL(const TDesC& aTestName)
1011 CTestStepDevVideoRecordAllocFailNew* self = new(ELeave) CTestStepDevVideoRecordAllocFailNew(aTestName);
1015 CTestStepDevVideoRecordAllocFailNew::~CTestStepDevVideoRecordAllocFailNew()
1019 TVerdict CTestStepDevVideoRecordAllocFailNew::DoTestL()
1021 iTestStepResult = EPass;
1022 TInt err = KErrNone;
1024 // Printing to the console and log file
1025 INFO_PRINTF1(_L("this is an Alloc Failure test of initialising CMMFDevVideoRecord with NewL()"));
1028 TRAP( err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this) );
1029 delete iDevVideoRecord;
1030 iDevVideoRecord = NULL;
1033 if (err != KErrNone)
1037 TBool completed = EFalse;
1038 TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1041 __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
1044 TRAP( err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this);
1045 iDevVideoRecord->SelectEncoderL(KUidDevVideoTestEncodeHwDevice);
1046 iDevVideoRecord->SelectPreProcessorL(KUidDevVideoTestPreProcHwDevice); );
1049 if (err == KErrNone)
1051 TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1052 if (testAlloc==NULL)
1055 failCount--; // -= 1;
1058 User::Free(testAlloc);
1061 else if (err != KErrNoMemory) // bad error code
1064 // see if valid result and break if wrong - might be premature result
1065 if (iDevVideoRecord)
1067 delete iDevVideoRecord;
1068 iDevVideoRecord = NULL;
1070 completed = reachedEnd;
1072 __UHEAP_SETFAIL(RHeap::ENone ,0);
1080 if (err != KErrNone)
1082 INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
1083 iTestStepResult = EFail;
1087 INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
1088 iTestStepResult = EPass;
1091 if (iDevVideoRecord)
1093 delete iDevVideoRecord;
1094 iDevVideoRecord = NULL;
1097 INFO_PRINTF1(_L("finished with this test step"));
1098 // test steps return a result
1099 return iTestStepResult;
1102 //----------------------------------------------------------------------------
1104 CTestStepDevVideoRecordAllocFailInfoEncoder::CTestStepDevVideoRecordAllocFailInfoEncoder(const TDesC& aTestName)
1105 :CTestStepDevVideoRecordAllocFail(aTestName)
1109 CTestStepDevVideoRecordAllocFailInfoEncoder* CTestStepDevVideoRecordAllocFailInfoEncoder::NewL(const TDesC& aTestName)
1111 CTestStepDevVideoRecordAllocFailInfoEncoder* self = new(ELeave) CTestStepDevVideoRecordAllocFailInfoEncoder(aTestName);
1115 CTestStepDevVideoRecordAllocFailInfoEncoder::~CTestStepDevVideoRecordAllocFailInfoEncoder()
1119 TVerdict CTestStepDevVideoRecordAllocFailInfoEncoder::DoTestL()
1121 iTestStepResult = EPass;
1122 TInt err = KErrNone;
1124 // Printing to the console and log file
1125 INFO_PRINTF1(_L("this is an Alloc Failure test of VideoEncoderInfoLC()"));
1127 // moved creation and destruction of iDevVideoRecord inside the heap marks.
1128 // reason :- VideoEncoderInfoLC may allocate onto it
1131 TBool completed = EFalse;
1132 TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1135 __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
1138 TRAP (err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this));
1140 if (err == KErrNone)
1142 CVideoEncoderInfo* vidInfo = NULL;
1144 TRAP( err, vidInfo = iDevVideoRecord->VideoEncoderInfoLC(KUidDevVideoTestEncodeHwDevice);
1145 CleanupStack::Pop(vidInfo); );
1148 if (err == KErrNone)
1150 TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1151 if (testAlloc==NULL)
1154 failCount--; // -= 1;
1157 User::Free(testAlloc);
1160 else if (err != KErrNoMemory) // bad error code
1163 // see if valid result and break if wrong - might be premature result
1171 else if (err != KErrNoMemory) // bad error code
1174 if (iDevVideoRecord)
1176 delete iDevVideoRecord;
1177 iDevVideoRecord = NULL;
1180 completed = reachedEnd;
1183 __UHEAP_SETFAIL(RHeap::ENone ,0);
1191 if (err != KErrNone)
1193 INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
1194 iTestStepResult = EFail;
1198 INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
1199 iTestStepResult = EPass;
1202 INFO_PRINTF1(_L("finished with this test step"));
1203 // test steps return a result
1204 return iTestStepResult;
1207 //----------------------------------------------------------------------------
1209 CTestStepDevVideoRecordAllocFailInfoPreProc::CTestStepDevVideoRecordAllocFailInfoPreProc(const TDesC& aTestName)
1210 :CTestStepDevVideoRecordAllocFail(aTestName)
1214 CTestStepDevVideoRecordAllocFailInfoPreProc* CTestStepDevVideoRecordAllocFailInfoPreProc::NewL(const TDesC& aTestName)
1216 CTestStepDevVideoRecordAllocFailInfoPreProc* self = new(ELeave) CTestStepDevVideoRecordAllocFailInfoPreProc(aTestName);
1220 CTestStepDevVideoRecordAllocFailInfoPreProc::~CTestStepDevVideoRecordAllocFailInfoPreProc()
1224 TVerdict CTestStepDevVideoRecordAllocFailInfoPreProc::DoTestL()
1226 iTestStepResult = EPass;
1227 TInt err = KErrNone;
1229 // Printing to the console and log file
1230 INFO_PRINTF1(_L("this is an Alloc Failure test of PreProcessorInfoLC()"));
1232 // will leave on error
1233 TRAP (err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this));
1235 if (err != KErrNone)
1237 ERR_PRINTF1(_L("Error - Couldn't construct CMMFDevVideoRecord!"));
1238 return EInconclusive;
1241 CPreProcessorInfo* preInfo = NULL;
1244 TBool completed = EFalse;
1245 TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1248 __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
1251 TRAP( err, preInfo = iDevVideoRecord->PreProcessorInfoLC(KUidDevVideoTestPreProcHwDevice);
1252 CleanupStack::Pop(preInfo); );
1254 REComSession::FinalClose();
1257 if (err == KErrNone)
1259 TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1260 if (testAlloc==NULL)
1263 failCount--; // -= 1;
1266 User::Free(testAlloc);
1269 else if (err != KErrNoMemory) // bad error code
1272 // see if valid result and break if wrong - might be premature result
1280 completed = reachedEnd;
1283 __UHEAP_SETFAIL(RHeap::ENone ,0);
1291 if (err != KErrNone)
1293 INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
1294 iTestStepResult = EFail;
1298 INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
1299 iTestStepResult = EPass;
1302 if (iDevVideoRecord)
1304 delete iDevVideoRecord;
1305 iDevVideoRecord = NULL;
1308 INFO_PRINTF1(_L("finished with this test step"));
1309 // test steps return a result
1310 return iTestStepResult;
1313 //----------------------------------------------------------------------------
1316 CTestStepDevVideoRecordAllocFailFindPlugins::CTestStepDevVideoRecordAllocFailFindPlugins(const TDesC& aTestName)
1317 :CTestStepDevVideoRecordAllocFail(aTestName)
1321 CTestStepDevVideoRecordAllocFailFindPlugins* CTestStepDevVideoRecordAllocFailFindPlugins::NewL(const TDesC& aTestName)
1323 CTestStepDevVideoRecordAllocFailFindPlugins* self = new(ELeave) CTestStepDevVideoRecordAllocFailFindPlugins(aTestName);
1327 CTestStepDevVideoRecordAllocFailFindPlugins::~CTestStepDevVideoRecordAllocFailFindPlugins()
1331 TVerdict CTestStepDevVideoRecordAllocFailFindPlugins::DoTestL()
1333 iTestStepResult = EPass;
1334 TInt err = KErrNone;
1336 // Printing to the console and log file
1337 INFO_PRINTF1(_L("this is an Alloc Failure test of finding Encoder and Pre processor plugins"));
1341 TBool completed = EFalse;
1342 TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1345 __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
1351 TRAP(err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this));
1353 TRAP(err, GetEncodersL());
1355 TRAP(err, GetPreProcessorsL());
1357 TRAP(err, FindEncodersL());
1359 TRAP(err, FindPreProcessorsL());
1361 REComSession::FinalClose();
1364 if (err == KErrNone)
1366 TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1367 if (testAlloc==NULL)
1370 failCount--; // -= 1;
1373 User::Free(testAlloc);
1376 else if (err != KErrNoMemory) // bad error code
1379 // see if valid result and break if wrong - might be premature result
1380 delete iDevVideoRecord;
1381 iDevVideoRecord = NULL;
1384 __UHEAP_SETFAIL(RHeap::ENone ,0);
1386 if (completed || reachedEnd)
1392 if (err != KErrNone)
1394 INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
1395 iTestStepResult = EFail;
1399 INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
1400 iTestStepResult = EPass;
1403 delete iDevVideoRecord;
1404 iDevVideoRecord = NULL;
1406 INFO_PRINTF1(_L("finished with this test step"));
1407 // test steps return a result
1408 return iTestStepResult;
1411 void CTestStepDevVideoRecordAllocFailFindPlugins::CheckPluginsL(const RArray<TUid>& aFoundPlugins, const RArray<TUid>& aExpectedPlugins, const RArray<TUid>& aUnExpectedPlugins)
1413 TBool foundUnExpected = EFalse;
1414 TInt numberToBeFoundInExpectedPlugins = aExpectedPlugins.Count();
1416 for (TInt i=0; i<aFoundPlugins.Count(); i++)
1418 TUid uidToLookFor = aFoundPlugins[i];
1420 for (j=0; j<aExpectedPlugins.Count(); j++)
1422 if (aExpectedPlugins[j] == uidToLookFor)
1424 numberToBeFoundInExpectedPlugins--;
1428 for (j=0; j<aUnExpectedPlugins.Count(); j++)
1430 if (aUnExpectedPlugins[j] == uidToLookFor)
1432 foundUnExpected = ETrue;
1438 if ((foundUnExpected) || (numberToBeFoundInExpectedPlugins!=0))
1439 User::Leave(KErrGeneral);
1444 void CTestStepDevVideoRecordAllocFailFindPlugins::FindEncodersL()
1446 RArray<TUid> foundEncoders;
1447 CleanupClosePushL(foundEncoders);
1448 RArray<TUid> expectedEncoders;
1449 CleanupClosePushL(expectedEncoders);
1450 RArray<TUid> unExpectedEncoders;
1451 CleanupClosePushL(unExpectedEncoders);
1454 // Supported mime type and Pre proc type (by exact match)
1455 _LIT8(KMimeType5, "video/zippyvideo");
1456 TUint32 requestedPreProcType = EPpMirror|EPpInputCrop;
1457 foundEncoders.Reset();
1458 expectedEncoders.Reset();
1459 unExpectedEncoders.Reset();
1460 User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice1));
1461 User::LeaveIfError(unExpectedEncoders.Append(KUidDevVideoTestEncodeHwDevice2));
1462 User::LeaveIfError(unExpectedEncoders.Append(KUidDevVideoTestEncodeHwDevice3));
1463 User::LeaveIfError(unExpectedEncoders.Append(KUidDevVideoTestEncodeHwDevice4));
1464 User::LeaveIfError(unExpectedEncoders.Append(KUidDevVideoTestEncodeHwDevice5));
1466 iDevVideoRecord->FindEncodersL(KMimeType5(), requestedPreProcType, foundEncoders, ETrue);
1467 CheckPluginsL(foundEncoders, expectedEncoders, unExpectedEncoders);
1469 CleanupStack::PopAndDestroy(3);
1472 void CTestStepDevVideoRecordAllocFailFindPlugins::FindPreProcessorsL()
1474 RArray<TUid> foundPreProx;
1475 CleanupClosePushL(foundPreProx);
1476 RArray<TUid> expectedPreProx;
1477 CleanupClosePushL(expectedPreProx);
1478 RArray<TUid> unExpectedPreProx;
1479 CleanupClosePushL(unExpectedPreProx);
1481 TUint32 requestedPreProcType = EPpMirror|EPpInputCrop;
1482 foundPreProx.Reset();
1483 expectedPreProx.Reset();
1484 User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice1));
1485 User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice2));
1486 User::LeaveIfError(unExpectedPreProx.Append(KUidDevVideoTestPreProcHwDevice3));
1487 User::LeaveIfError(unExpectedPreProx.Append(KUidDevVideoTestPreProcHwDevice4));
1488 User::LeaveIfError(unExpectedPreProx.Append(KUidDevVideoTestPreProcHwDevice5));
1490 iDevVideoRecord->FindPreProcessorsL(requestedPreProcType, foundPreProx);
1491 CheckPluginsL(foundPreProx, expectedPreProx, unExpectedPreProx);
1493 CleanupStack::PopAndDestroy(3);
1496 void CTestStepDevVideoRecordAllocFailFindPlugins::GetEncodersL()
1498 RArray<TUid> foundEncoders;
1499 CleanupClosePushL(foundEncoders);
1500 RArray<TUid> expectedEncoders;
1501 CleanupClosePushL(expectedEncoders);
1502 RArray<TUid> unExpectedEncoders;
1503 CleanupClosePushL(unExpectedEncoders);
1505 User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice1));
1506 User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice2));
1507 User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice3));
1508 User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice4));
1509 User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice5));
1511 iDevVideoRecord->GetEncoderListL(foundEncoders);
1513 CheckPluginsL(foundEncoders, expectedEncoders, unExpectedEncoders);
1515 CleanupStack::PopAndDestroy(3); //foundEncoders, expectedEncoders, unExpectedEncoders
1518 void CTestStepDevVideoRecordAllocFailFindPlugins::GetPreProcessorsL()
1520 RArray<TUid> foundPreProx;
1521 CleanupClosePushL(foundPreProx);
1522 RArray<TUid> expectedPreProx;
1523 CleanupClosePushL(expectedPreProx);
1524 RArray<TUid> unExpectedPreProx;
1525 CleanupClosePushL(unExpectedPreProx);
1527 User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice1));
1528 User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice2));
1529 User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice3));
1530 User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice4));
1531 User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice5));
1533 iDevVideoRecord->GetPreProcessorListL(foundPreProx);
1535 CheckPluginsL(foundPreProx, expectedPreProx, unExpectedPreProx);
1537 CleanupStack::PopAndDestroy(3);//foundPreProx, expectedPreProx, unExpectedPreProx
1540 //----------------------------------------------------------------------------
1543 CTestStepDevVideoRecordAllocFailGetBuffers::CTestStepDevVideoRecordAllocFailGetBuffers(const TDesC& aTestName)
1544 :CTestStepDevVideoRecordAllocFail(aTestName)
1548 CTestStepDevVideoRecordAllocFailGetBuffers* CTestStepDevVideoRecordAllocFailGetBuffers::NewL(const TDesC& aTestName)
1550 CTestStepDevVideoRecordAllocFailGetBuffers* self = new(ELeave) CTestStepDevVideoRecordAllocFailGetBuffers(aTestName);
1554 CTestStepDevVideoRecordAllocFailGetBuffers::~CTestStepDevVideoRecordAllocFailGetBuffers()
1558 TVerdict CTestStepDevVideoRecordAllocFailGetBuffers::DoTestL()
1560 iTestStepResult = EPass;
1561 TInt err = KErrNone;
1563 // Printing to the console and log file
1564 INFO_PRINTF1(_L("this is an Alloc Failure test of retrieving and returning Buffers to the plugin"));
1568 TBool completed = EFalse;
1569 TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1572 __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
1575 TRAP(err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this));
1577 TRAP(err, PerformTestL());
1579 REComSession::FinalClose();
1582 if (err == KErrNone)
1584 TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1585 if (testAlloc==NULL)
1588 failCount--; // -= 1;
1591 User::Free(testAlloc);
1594 else if (err != KErrNoMemory) // bad error code
1597 // see if valid result and break if wrong - might be premature result
1598 delete iDevVideoRecord;
1599 iDevVideoRecord = NULL;
1602 __UHEAP_SETFAIL(RHeap::ENone ,0);
1604 if (completed || reachedEnd)
1610 if (err != KErrNone)
1612 INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
1613 iTestStepResult = EFail;
1617 INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
1618 iTestStepResult = EPass;
1621 delete iDevVideoRecord;
1622 iDevVideoRecord = NULL;
1624 INFO_PRINTF1(_L("finished with this test step"));
1625 // test steps return a result
1626 return iTestStepResult;
1630 void CTestStepDevVideoRecordAllocFailGetBuffers::PerformTestL()
1632 iTestError = KErrNone;
1635 iDevVideoRecord->SelectEncoderL(KUidDevVideoTestEncodeHwDevice);
1637 // select Pre-processor
1638 iDevVideoRecord->SelectPreProcessorL(KUidDevVideoTestPreProcHwDevice);
1640 //Tell plugin to start creating Buffers.
1641 iDevVideoRecord->SetImplementationSpecificEncoderOptionsL(KTestISEncBuffers);
1643 // initialize CDevVideoRecord and wait for response
1644 iDevVideoRecord->Initialize();
1646 User::LeaveIfError(iTestError);
1648 iDevVideoRecord->Start();//Tell plugin to start creating Buffers.
1649 // We should now get a series of NewBuffer() callbacks.
1651 User::LeaveIfError(iTestError);
1654 void CTestStepDevVideoRecordAllocFailGetBuffers::MdvpoInitComplete(TInt aError)
1656 iTestError = aError;
1659 void CTestStepDevVideoRecordAllocFailGetBuffers::MdvpoNewBuffers()
1661 TRAP(iTestError, DoNewBuffersL());
1664 void CTestStepDevVideoRecordAllocFailGetBuffers::CheckNewBufferInfoL(TUint aNumBuffers)
1666 TUint numBuffers = 0;
1667 numBuffers = iDevVideoRecord->NumDataBuffers();
1669 if (numBuffers != aNumBuffers)
1671 User::Leave(KErrGeneral);
1675 void CTestStepDevVideoRecordAllocFailGetBuffers::DoNewBuffersL()
1677 User::LeaveIfError(iTestError);//Don't go any further if we have an error
1678 switch (iCurrentBufferNumber)
1682 iCurrentBufferNumber++;
1683 CheckNewBufferInfoL(1);
1684 TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
1685 CheckNewBufferInfoL(0);
1686 iDevVideoRecord->ReturnBuffer(buffer);
1691 iCurrentBufferNumber++;
1692 CheckNewBufferInfoL(1);
1693 TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
1694 CheckNewBufferInfoL(0);
1695 iDevVideoRecord->ReturnBuffer(buffer);
1700 iCurrentBufferNumber++;
1701 CheckNewBufferInfoL(1);
1702 TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
1703 CheckNewBufferInfoL(0);
1704 iDevVideoRecord->ReturnBuffer(buffer);
1709 iCurrentBufferNumber++;
1710 CheckNewBufferInfoL(1);
1711 TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
1712 iDevVideoRecord->ReturnBuffer(buffer);
1717 iCurrentBufferNumber++;
1718 CheckNewBufferInfoL(1);
1719 TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
1720 iDevVideoRecord->ReturnBuffer(buffer);
1725 iCurrentBufferNumber++;
1726 CheckNewBufferInfoL(1);
1727 TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
1728 iDevVideoRecord->ReturnBuffer(buffer);
1733 iCurrentBufferNumber++;
1734 CheckNewBufferInfoL(1);
1739 iCurrentBufferNumber++;
1740 CheckNewBufferInfoL(2);
1745 iCurrentBufferNumber++;
1746 CheckNewBufferInfoL(3);
1751 iCurrentBufferNumber++;
1752 CheckNewBufferInfoL(4);
1753 TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
1754 iDevVideoRecord->ReturnBuffer(buffer);
1755 CheckNewBufferInfoL(3);
1756 buffer = iDevVideoRecord->NextBufferL();
1757 iDevVideoRecord->ReturnBuffer(buffer);
1758 CheckNewBufferInfoL(2);
1759 buffer = iDevVideoRecord->NextBufferL();
1760 iDevVideoRecord->ReturnBuffer(buffer);
1761 CheckNewBufferInfoL(1);
1762 buffer = iDevVideoRecord->NextBufferL();
1763 iDevVideoRecord->ReturnBuffer(buffer);
1764 CheckNewBufferInfoL(0);
1768 User::Leave(KErrGeneral);