sl@0: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // This file contains the implementation of the various sl@0: // ALLOC tests for DevVideo sl@0: // sl@0: // sl@0: sl@0: // Test system includes sl@0: #include sl@0: sl@0: #include "TestDevVideoPlugins/decoder.h" sl@0: #include "TestDevVideoPlugins/postproc.h" sl@0: sl@0: #include "TestDevVideoPlugins/encoder.h" sl@0: #include "TestDevVideoPlugins/preproc.h" sl@0: sl@0: #include "TestStepDevVideoAllocFailNew.h" sl@0: #include "TestDevVideoPlayTestData.h" sl@0: sl@0: sl@0: // -------------------------------------------- sl@0: sl@0: /** sl@0: * sl@0: * Test step constructor. sl@0: * Each test step initialises its own name. sl@0: * sl@0: */ sl@0: CTestStepDevVideoPlayAllocFail::CTestStepDevVideoPlayAllocFail(const TDesC& aTestName) sl@0: { sl@0: // store the name of this test case sl@0: // this is the name that is used by the script file sl@0: iTestStepName = aTestName; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Test step destructor. sl@0: * sl@0: */ sl@0: CTestStepDevVideoPlayAllocFail::~CTestStepDevVideoPlayAllocFail() sl@0: { sl@0: } sl@0: sl@0: // MMMFDevVideoPlayObserver sl@0: void CTestStepDevVideoPlayAllocFail::MdvpoNewBuffers() sl@0: { sl@0: INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoNewBuffers()")); sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFail::MdvpoReturnPicture(TVideoPicture* /*aPicture*/) sl@0: { sl@0: INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoReturnPicture()")); sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFail::MdvpoSupplementalInformation(const TDesC8& /*aData*/, sl@0: const TTimeIntervalMicroSeconds& /*aTimestamp*/, sl@0: const TPictureId& /*aPictureId*/) sl@0: { sl@0: INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoSupplementalInformation()")); sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFail::MdvpoPictureLoss() sl@0: { sl@0: INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoPictureLoss()")); sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFail::MdvpoPictureLoss(const TArray& /*aPictures*/) sl@0: { sl@0: INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoPictureLoss(TArray)")); sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFail::MdvpoSliceLoss(TUint /*aFirstMacroblock*/, TUint /*aNumMacroblocks*/, const TPictureId& /*aPicture*/) sl@0: { sl@0: INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoSliceLoss()")); sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFail::MdvpoReferencePictureSelection(const TDesC8& /*aSelectionData*/) sl@0: { sl@0: INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoReferencePictureSelection()")); sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFail::MdvpoTimedSnapshotComplete(TInt /*aError*/, sl@0: TPictureData* /*aPictureData*/, sl@0: const TTimeIntervalMicroSeconds& /*aPresentationTimestamp*/, sl@0: const TPictureId& /*aPictureId*/) sl@0: { sl@0: INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoTimedSnapshotComplete()")); sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFail::MdvpoNewPictures() sl@0: { sl@0: INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoNewPictures()")); sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFail::MdvpoFatalError(TInt aError) sl@0: { sl@0: iError = aError; sl@0: INFO_PRINTF2(_L("CTestStepDevVideoPlayAllocFail::MdvpoFatalError()\nError = %d"), aError); sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFail::MdvpoInitComplete(TInt aError) sl@0: { sl@0: iError = aError; sl@0: INFO_PRINTF2(_L("CTestStepDevVideoPlayAllocFail::MdvpoInitComplete(): Error = %d"), aError); sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFail::MdvpoStreamEnd() sl@0: { sl@0: INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoStreamEnd()")); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Do the test step. sl@0: * Each test step must supply an implementation for DoTestStepL. sl@0: * sl@0: * @return "TVerdict" sl@0: * The result of the test step sl@0: * sl@0: */ sl@0: TVerdict CTestStepDevVideoPlayAllocFail::DoTestStepL() sl@0: { sl@0: TVerdict ret = EFail; sl@0: sl@0: // do we want to do anything else in the base class? sl@0: sl@0: // call alloc test step sl@0: ret = DoTestL(); sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: sl@0: //---------------------------------------------------------------------------- sl@0: sl@0: CTestStepDevVideoPlayAllocFailNew::CTestStepDevVideoPlayAllocFailNew(const TDesC& aTestName) sl@0: :CTestStepDevVideoPlayAllocFail(aTestName) sl@0: { sl@0: } sl@0: sl@0: CTestStepDevVideoPlayAllocFailNew* CTestStepDevVideoPlayAllocFailNew::NewL(const TDesC& aTestName) sl@0: { sl@0: CTestStepDevVideoPlayAllocFailNew* self = new(ELeave) CTestStepDevVideoPlayAllocFailNew(aTestName); sl@0: return self; sl@0: } sl@0: sl@0: CTestStepDevVideoPlayAllocFailNew::~CTestStepDevVideoPlayAllocFailNew() sl@0: { sl@0: } sl@0: sl@0: TVerdict CTestStepDevVideoPlayAllocFailNew::DoTestL() sl@0: { sl@0: iTestStepResult = EPass; sl@0: TInt err = KErrNone; sl@0: sl@0: // Printing to the console and log file sl@0: INFO_PRINTF1(_L("this is an Alloc Failure test of initialising CMMFDevVideoPlay with NewL()")); sl@0: sl@0: __UHEAP_MARK; sl@0: TRAP( err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this) ); sl@0: delete iDevVideoPlay; sl@0: iDevVideoPlay = NULL; sl@0: __UHEAP_MARKEND; sl@0: sl@0: if (err != KErrNone) sl@0: return EFail; sl@0: sl@0: TInt failCount = 1; sl@0: TBool completed = EFalse; sl@0: TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging sl@0: for(;;) sl@0: { sl@0: __UHEAP_SETFAIL(RHeap::EFailNext ,failCount); sl@0: __MM_HEAP_MARK; sl@0: sl@0: TRAP( err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this); sl@0: iDevVideoPlay->SelectDecoderL(KUidDevVideoTestDecodeHwDevice); sl@0: iDevVideoPlay->SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice); ); sl@0: sl@0: completed = EFalse; sl@0: if (err == KErrNone) sl@0: { sl@0: TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test sl@0: if (testAlloc==NULL) sl@0: { sl@0: reachedEnd = ETrue; sl@0: failCount--; // -= 1; sl@0: } sl@0: else sl@0: User::Free(testAlloc); sl@0: sl@0: } sl@0: else if (err != KErrNoMemory) // bad error code sl@0: completed = ETrue; sl@0: sl@0: // see if valid result and break if wrong - might be premature result sl@0: if (iDevVideoPlay) sl@0: { sl@0: delete iDevVideoPlay; sl@0: iDevVideoPlay = NULL; sl@0: } sl@0: completed = reachedEnd; sl@0: __MM_HEAP_MARKEND; sl@0: __UHEAP_SETFAIL(RHeap::ENone ,0); sl@0: sl@0: if (completed) sl@0: break; // exit loop sl@0: sl@0: failCount++; sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount); sl@0: iTestStepResult = EFail; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount); sl@0: iTestStepResult = EPass; sl@0: } sl@0: sl@0: if (iDevVideoPlay) sl@0: { sl@0: delete iDevVideoPlay; sl@0: iDevVideoPlay = NULL; sl@0: } sl@0: sl@0: INFO_PRINTF1(_L("finished with this test step")); sl@0: // test steps return a result sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------- sl@0: sl@0: sl@0: CTestStepDevVideoPlayAllocFailFindPlugins::CTestStepDevVideoPlayAllocFailFindPlugins(const TDesC& aTestName) sl@0: :CTestStepDevVideoPlayAllocFail(aTestName) sl@0: { sl@0: } sl@0: sl@0: CTestStepDevVideoPlayAllocFailFindPlugins* CTestStepDevVideoPlayAllocFailFindPlugins::NewL(const TDesC& aTestName) sl@0: { sl@0: CTestStepDevVideoPlayAllocFailFindPlugins* self = new(ELeave) CTestStepDevVideoPlayAllocFailFindPlugins(aTestName); sl@0: return self; sl@0: } sl@0: sl@0: CTestStepDevVideoPlayAllocFailFindPlugins::~CTestStepDevVideoPlayAllocFailFindPlugins() sl@0: { sl@0: } sl@0: sl@0: TVerdict CTestStepDevVideoPlayAllocFailFindPlugins::DoTestL() sl@0: { sl@0: iTestStepResult = EPass; sl@0: TInt err = KErrNone; sl@0: sl@0: // Printing to the console and log file sl@0: INFO_PRINTF1(_L("this is an Alloc Failure test of finding decoder and post processor plugins")); sl@0: sl@0: sl@0: TInt failCount = 1; sl@0: TBool completed = EFalse; sl@0: TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging sl@0: for(;;) sl@0: { sl@0: __UHEAP_SETFAIL(RHeap::EFailNext ,failCount); sl@0: __MM_HEAP_MARK; sl@0: sl@0: err = KErrNone; sl@0: sl@0: if (!err) sl@0: TRAP(err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this)); sl@0: if (!err) sl@0: TRAP(err, GetDecodersL()); sl@0: if (!err) sl@0: TRAP(err, GetPostProcessorsL()); sl@0: if (!err) sl@0: TRAP(err, FindDecodersL()); sl@0: if (!err) sl@0: TRAP(err, FindPostProcessorsL()); sl@0: sl@0: REComSession::FinalClose(); sl@0: sl@0: completed = EFalse; sl@0: if (err == KErrNone) sl@0: { sl@0: TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test sl@0: if (testAlloc==NULL) sl@0: { sl@0: reachedEnd = ETrue; sl@0: failCount--; // -= 1; sl@0: } sl@0: else sl@0: User::Free(testAlloc); sl@0: sl@0: } sl@0: else if (err != KErrNoMemory) // bad error code sl@0: completed = ETrue; sl@0: sl@0: // see if valid result and break if wrong - might be premature result sl@0: delete iDevVideoPlay; sl@0: iDevVideoPlay = NULL; sl@0: sl@0: __MM_HEAP_MARKEND; sl@0: __UHEAP_SETFAIL(RHeap::ENone ,0); sl@0: sl@0: if (completed || reachedEnd) sl@0: break; // exit loop sl@0: sl@0: failCount++; sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount); sl@0: iTestStepResult = EFail; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount); sl@0: iTestStepResult = EPass; sl@0: } sl@0: sl@0: delete iDevVideoPlay; sl@0: iDevVideoPlay = NULL; sl@0: sl@0: INFO_PRINTF1(_L("finished with this test step")); sl@0: // test steps return a result sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFailFindPlugins::CheckPluginsL(const RArray& aFoundPlugins, const RArray& aExpectedPlugins, const RArray& aUnExpectedPlugins) sl@0: { sl@0: TBool foundUnExpected = EFalse; sl@0: TInt numberToBeFoundInExpectedPlugins = aExpectedPlugins.Count(); sl@0: sl@0: for (TInt i=0; i foundDecoders; sl@0: CleanupClosePushL(foundDecoders); sl@0: RArray expectedDecoders; sl@0: CleanupClosePushL(expectedDecoders); sl@0: RArray unExpectedDecoders; sl@0: CleanupClosePushL(unExpectedDecoders); sl@0: sl@0: sl@0: // Supported mime type and post proc type (by exact match) sl@0: _LIT8(KMimeType5, "video/zippyvideo"); sl@0: TUint32 requestedPostProcType = EPpMirror|EPpInputCrop; sl@0: foundDecoders.Reset(); sl@0: expectedDecoders.Reset(); sl@0: unExpectedDecoders.Reset(); sl@0: User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice1)); sl@0: User::LeaveIfError(unExpectedDecoders.Append(KUidDevVideoTestDecodeHwDevice2)); sl@0: User::LeaveIfError(unExpectedDecoders.Append(KUidDevVideoTestDecodeHwDevice3)); sl@0: User::LeaveIfError(unExpectedDecoders.Append(KUidDevVideoTestDecodeHwDevice4)); sl@0: User::LeaveIfError(unExpectedDecoders.Append(KUidDevVideoTestDecodeHwDevice5)); sl@0: sl@0: iDevVideoPlay->FindDecodersL(KMimeType5(), requestedPostProcType, foundDecoders, ETrue); sl@0: CheckPluginsL(foundDecoders, expectedDecoders, unExpectedDecoders); sl@0: sl@0: CleanupStack::PopAndDestroy(3); sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFailFindPlugins::FindPostProcessorsL() sl@0: { sl@0: RArray foundPostProx; sl@0: CleanupClosePushL(foundPostProx); sl@0: RArray expectedPostProx; sl@0: CleanupClosePushL(expectedPostProx); sl@0: RArray unExpectedPostProx; sl@0: CleanupClosePushL(unExpectedPostProx); sl@0: sl@0: TUint32 requestedPostProcType = EPpMirror|EPpInputCrop; sl@0: foundPostProx.Reset(); sl@0: expectedPostProx.Reset(); sl@0: User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice1)); sl@0: User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice2)); sl@0: User::LeaveIfError(unExpectedPostProx.Append(KUidDevVideoTestPostProcHwDevice3)); sl@0: User::LeaveIfError(unExpectedPostProx.Append(KUidDevVideoTestPostProcHwDevice4)); sl@0: User::LeaveIfError(unExpectedPostProx.Append(KUidDevVideoTestPostProcHwDevice5)); sl@0: sl@0: iDevVideoPlay->FindPostProcessorsL(requestedPostProcType, foundPostProx); sl@0: CheckPluginsL(foundPostProx, expectedPostProx, unExpectedPostProx); sl@0: sl@0: CleanupStack::PopAndDestroy(3); sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFailFindPlugins::GetDecodersL() sl@0: { sl@0: RArray foundDecoders; sl@0: CleanupClosePushL(foundDecoders); sl@0: RArray expectedDecoders; sl@0: CleanupClosePushL(expectedDecoders); sl@0: RArray unExpectedDecoders; sl@0: CleanupClosePushL(unExpectedDecoders); sl@0: sl@0: User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice1)); sl@0: User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice2)); sl@0: User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice3)); sl@0: User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice4)); sl@0: User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice5)); sl@0: sl@0: iDevVideoPlay->GetDecoderListL(foundDecoders); sl@0: sl@0: CheckPluginsL(foundDecoders, expectedDecoders, unExpectedDecoders); sl@0: sl@0: CleanupStack::PopAndDestroy(3); //foundDecoders, expectedDecoders, unExpectedDecoders sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFailFindPlugins::GetPostProcessorsL() sl@0: { sl@0: RArray foundPostProx; sl@0: CleanupClosePushL(foundPostProx); sl@0: RArray expectedPostProx; sl@0: CleanupClosePushL(expectedPostProx); sl@0: RArray unExpectedPostProx; sl@0: CleanupClosePushL(unExpectedPostProx); sl@0: sl@0: User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice1)); sl@0: User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice2)); sl@0: User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice3)); sl@0: User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice4)); sl@0: User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice5)); sl@0: sl@0: iDevVideoPlay->GetPostProcessorListL(foundPostProx); sl@0: sl@0: CheckPluginsL(foundPostProx, expectedPostProx, unExpectedPostProx); sl@0: sl@0: CleanupStack::PopAndDestroy(3);//foundPostProx, expectedPostProx, unExpectedPostProx sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------- sl@0: sl@0: CTestStepDevVideoPlayAllocFailInfoDecoder::CTestStepDevVideoPlayAllocFailInfoDecoder(const TDesC& aTestName) sl@0: :CTestStepDevVideoPlayAllocFail(aTestName) sl@0: { sl@0: } sl@0: sl@0: CTestStepDevVideoPlayAllocFailInfoDecoder* CTestStepDevVideoPlayAllocFailInfoDecoder::NewL(const TDesC& aTestName) sl@0: { sl@0: CTestStepDevVideoPlayAllocFailInfoDecoder* self = new(ELeave) CTestStepDevVideoPlayAllocFailInfoDecoder(aTestName); sl@0: return self; sl@0: } sl@0: sl@0: CTestStepDevVideoPlayAllocFailInfoDecoder::~CTestStepDevVideoPlayAllocFailInfoDecoder() sl@0: { sl@0: } sl@0: sl@0: TVerdict CTestStepDevVideoPlayAllocFailInfoDecoder::DoTestL() sl@0: { sl@0: iTestStepResult = EPass; sl@0: TInt err = KErrNone; sl@0: sl@0: // Printing to the console and log file sl@0: INFO_PRINTF1(_L("this is an Alloc Failure test of VideoDecoderInfoLC()")); sl@0: sl@0: // moved creation and destruction of iDevVideoPlay inside the heap marks. sl@0: // reason :- VideoDecoderInfoLC may allocate onto it sl@0: sl@0: TInt failCount = 1; sl@0: TBool completed = EFalse; sl@0: TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging sl@0: for(;;) sl@0: { sl@0: __UHEAP_SETFAIL(RHeap::EFailNext ,failCount); sl@0: __MM_HEAP_MARK; sl@0: sl@0: TRAP (err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this)); sl@0: if (err == KErrNone) sl@0: { sl@0: sl@0: CVideoDecoderInfo* vidInfo = NULL; sl@0: sl@0: TRAP( err, vidInfo = iDevVideoPlay->VideoDecoderInfoLC(KUidDevVideoTestDecodeHwDevice); sl@0: CleanupStack::Pop(vidInfo); ); sl@0: sl@0: completed = EFalse; sl@0: if (err == KErrNone) sl@0: { sl@0: TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test sl@0: if (testAlloc==NULL) sl@0: { sl@0: reachedEnd = ETrue; sl@0: failCount--; // -= 1; sl@0: } sl@0: else sl@0: User::Free(testAlloc); sl@0: sl@0: } sl@0: else if (err != KErrNoMemory) // bad error code sl@0: completed = ETrue; sl@0: sl@0: // see if valid result and break if wrong - might be premature result sl@0: sl@0: if (vidInfo) sl@0: { sl@0: delete vidInfo; sl@0: vidInfo = NULL; sl@0: } sl@0: } sl@0: else if (err != KErrNoMemory) // bad error code sl@0: completed = ETrue; sl@0: sl@0: if (iDevVideoPlay) sl@0: { sl@0: delete iDevVideoPlay; sl@0: iDevVideoPlay = NULL; sl@0: } sl@0: sl@0: completed = reachedEnd; sl@0: sl@0: __MM_HEAP_MARKEND; sl@0: __UHEAP_SETFAIL(RHeap::ENone ,0); sl@0: sl@0: if (completed) sl@0: break; // exit loop sl@0: sl@0: failCount++; sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount); sl@0: iTestStepResult = EFail; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount); sl@0: iTestStepResult = EPass; sl@0: } sl@0: sl@0: INFO_PRINTF1(_L("finished with this test step")); sl@0: // test steps return a result sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: sl@0: //---------------------------------------------------------------------------- sl@0: sl@0: CTestStepDevVideoPlayAllocFailInfoPostProc::CTestStepDevVideoPlayAllocFailInfoPostProc(const TDesC& aTestName) sl@0: :CTestStepDevVideoPlayAllocFail(aTestName) sl@0: { sl@0: } sl@0: sl@0: CTestStepDevVideoPlayAllocFailInfoPostProc* CTestStepDevVideoPlayAllocFailInfoPostProc::NewL(const TDesC& aTestName) sl@0: { sl@0: CTestStepDevVideoPlayAllocFailInfoPostProc* self = new(ELeave) CTestStepDevVideoPlayAllocFailInfoPostProc(aTestName); sl@0: return self; sl@0: } sl@0: sl@0: CTestStepDevVideoPlayAllocFailInfoPostProc::~CTestStepDevVideoPlayAllocFailInfoPostProc() sl@0: { sl@0: } sl@0: sl@0: TVerdict CTestStepDevVideoPlayAllocFailInfoPostProc::DoTestL() sl@0: { sl@0: iTestStepResult = EPass; sl@0: TInt err = KErrNone; sl@0: sl@0: // Printing to the console and log file sl@0: INFO_PRINTF1(_L("this is an Alloc Failure test of PostProcessorInfoLC()")); sl@0: sl@0: // will leave on error sl@0: TRAP (err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this)); sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF1(_L("Error - Couldn't construct CMMFDevVideoPlay!")); sl@0: return EInconclusive; sl@0: } sl@0: sl@0: CPostProcessorInfo* postInfo = NULL; sl@0: sl@0: TInt failCount = 1; sl@0: TBool completed = EFalse; sl@0: TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging sl@0: for(;;) sl@0: { sl@0: __UHEAP_SETFAIL(RHeap::EFailNext ,failCount); sl@0: __MM_HEAP_MARK; sl@0: sl@0: TRAP( err, postInfo = iDevVideoPlay->PostProcessorInfoLC(KUidDevVideoTestPostProcHwDevice); sl@0: CleanupStack::Pop(postInfo); ); sl@0: sl@0: REComSession::FinalClose(); sl@0: sl@0: completed = EFalse; sl@0: if (err == KErrNone) sl@0: { sl@0: TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test sl@0: if (testAlloc==NULL) sl@0: { sl@0: reachedEnd = ETrue; sl@0: failCount--; // -= 1; sl@0: } sl@0: else sl@0: User::Free(testAlloc); sl@0: sl@0: } sl@0: else if (err != KErrNoMemory) // bad error code sl@0: completed = ETrue; sl@0: sl@0: // see if valid result and break if wrong - might be premature result sl@0: sl@0: if (postInfo) sl@0: { sl@0: delete postInfo; sl@0: postInfo = NULL; sl@0: } sl@0: sl@0: completed = reachedEnd; sl@0: sl@0: __MM_HEAP_MARKEND; sl@0: __UHEAP_SETFAIL(RHeap::ENone ,0); sl@0: sl@0: if (completed) sl@0: break; // exit loop sl@0: sl@0: failCount++; sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount); sl@0: iTestStepResult = EFail; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount); sl@0: iTestStepResult = EPass; sl@0: } sl@0: sl@0: if (iDevVideoPlay) sl@0: { sl@0: delete iDevVideoPlay; sl@0: iDevVideoPlay = NULL; sl@0: } sl@0: sl@0: INFO_PRINTF1(_L("finished with this test step")); sl@0: // test steps return a result sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: sl@0: //---------------------------------------------------------------------------- sl@0: sl@0: sl@0: CTestStepDevVideoPlayAllocFailGetPictures::CTestStepDevVideoPlayAllocFailGetPictures(const TDesC& aTestName) sl@0: :CTestStepDevVideoPlayAllocFail(aTestName) sl@0: { sl@0: } sl@0: sl@0: CTestStepDevVideoPlayAllocFailGetPictures* CTestStepDevVideoPlayAllocFailGetPictures::NewL(const TDesC& aTestName) sl@0: { sl@0: CTestStepDevVideoPlayAllocFailGetPictures* self = new(ELeave) CTestStepDevVideoPlayAllocFailGetPictures(aTestName); sl@0: return self; sl@0: } sl@0: sl@0: CTestStepDevVideoPlayAllocFailGetPictures::~CTestStepDevVideoPlayAllocFailGetPictures() sl@0: { sl@0: } sl@0: sl@0: TVerdict CTestStepDevVideoPlayAllocFailGetPictures::DoTestL() sl@0: { sl@0: iTestStepResult = EPass; sl@0: TInt err = KErrNone; sl@0: sl@0: // Printing to the console and log file sl@0: INFO_PRINTF1(_L("this is an Alloc Failure test of retrieving and returning pictures to the plugin")); sl@0: sl@0: sl@0: TInt failCount = 1; sl@0: TBool completed = EFalse; sl@0: TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging sl@0: for(;;) sl@0: { sl@0: __UHEAP_SETFAIL(RHeap::EFailNext ,failCount); sl@0: __MM_HEAP_MARK; sl@0: sl@0: TRAP(err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this)); sl@0: if (!err) sl@0: TRAP(err, PerformTestL()); sl@0: sl@0: REComSession::FinalClose(); sl@0: sl@0: completed = EFalse; sl@0: if (err == KErrNone) sl@0: { sl@0: TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test sl@0: if (testAlloc==NULL) sl@0: { sl@0: reachedEnd = ETrue; sl@0: failCount--; // -= 1; sl@0: } sl@0: else sl@0: User::Free(testAlloc); sl@0: sl@0: } sl@0: else if (err != KErrNoMemory) // bad error code sl@0: completed = ETrue; sl@0: sl@0: // see if valid result and break if wrong - might be premature result sl@0: delete iDevVideoPlay; sl@0: iDevVideoPlay = NULL; sl@0: sl@0: __MM_HEAP_MARKEND; sl@0: __UHEAP_SETFAIL(RHeap::ENone ,0); sl@0: sl@0: if (completed || reachedEnd) sl@0: break; // exit loop sl@0: sl@0: failCount++; sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount); sl@0: iTestStepResult = EFail; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount); sl@0: iTestStepResult = EPass; sl@0: } sl@0: sl@0: delete iDevVideoPlay; sl@0: iDevVideoPlay = NULL; sl@0: sl@0: INFO_PRINTF1(_L("finished with this test step")); sl@0: // test steps return a result sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: sl@0: void CTestStepDevVideoPlayAllocFailGetPictures::PerformTestL() sl@0: { sl@0: iTestError = KErrNone; sl@0: sl@0: // select decoder sl@0: iDevVideoPlay->SelectDecoderL(KUidDevVideoTestDecodeHwDevice); sl@0: sl@0: // select post-processor sl@0: iDevVideoPlay->SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice); sl@0: sl@0: //Tell plugin to start creating pictures. sl@0: iDevVideoPlay->SetVideoDestScreenL(EFalse); sl@0: sl@0: // initialize CDevVideoPlay and wait for response sl@0: iDevVideoPlay->Initialize(); sl@0: sl@0: User::LeaveIfError(iTestError); sl@0: sl@0: iDevVideoPlay->Start();//Tell plugin to start creating pictures. sl@0: // We should now get a series of NewPicture() callbacks. sl@0: sl@0: User::LeaveIfError(iTestError); sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFailGetPictures::MdvpoInitComplete(TInt aError) sl@0: { sl@0: iTestError = aError; sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFailGetPictures::MdvpoNewPictures() sl@0: { sl@0: TRAP(iTestError, DoNewPicturesL()); sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFailGetPictures::CheckNewPictureInfoL(TUint aNumPictures, const TTimeIntervalMicroSeconds& aFirst, const TTimeIntervalMicroSeconds& aLast) sl@0: { sl@0: TUint numPictures = 0; sl@0: TTimeIntervalMicroSeconds first(0); sl@0: TTimeIntervalMicroSeconds last(0); sl@0: iDevVideoPlay->GetNewPictureInfo(numPictures, first, last); sl@0: sl@0: if ((numPictures!=aNumPictures) || (first!=aFirst) || (last!=aLast)) sl@0: { sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: } sl@0: sl@0: void CTestStepDevVideoPlayAllocFailGetPictures::DoNewPicturesL() sl@0: { sl@0: User::LeaveIfError(iTestError);//Don't go any further if we have an error sl@0: switch (iCurrentPictureNumber) sl@0: { sl@0: case 0: sl@0: { sl@0: iCurrentPictureNumber++; sl@0: CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0)); sl@0: TVideoPicture* picture = iDevVideoPlay->NextPictureL(); sl@0: CheckNewPictureInfoL(0, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0)); sl@0: iDevVideoPlay->ReturnPicture(picture); sl@0: break; sl@0: } sl@0: case 1: sl@0: { sl@0: iCurrentPictureNumber++; sl@0: CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(1), TTimeIntervalMicroSeconds(1)); sl@0: TVideoPicture* picture = iDevVideoPlay->NextPictureL(); sl@0: CheckNewPictureInfoL(0, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0)); sl@0: iDevVideoPlay->ReturnPicture(picture); sl@0: break; sl@0: } sl@0: case 2: sl@0: { sl@0: iCurrentPictureNumber++; sl@0: CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(2), TTimeIntervalMicroSeconds(2)); sl@0: TVideoPicture* picture = iDevVideoPlay->NextPictureL(); sl@0: CheckNewPictureInfoL(0, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0)); sl@0: iDevVideoPlay->ReturnPicture(picture); sl@0: break; sl@0: } sl@0: case 3: sl@0: { sl@0: iCurrentPictureNumber++; sl@0: CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(3), TTimeIntervalMicroSeconds(3)); sl@0: TVideoPicture* picture = iDevVideoPlay->NextPictureL(); sl@0: iDevVideoPlay->ReturnPicture(picture); sl@0: break; sl@0: } sl@0: case 4: sl@0: { sl@0: iCurrentPictureNumber++; sl@0: CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(4), TTimeIntervalMicroSeconds(4)); sl@0: TVideoPicture* picture = iDevVideoPlay->NextPictureL(); sl@0: iDevVideoPlay->ReturnPicture(picture); sl@0: break; sl@0: } sl@0: case 5: sl@0: { sl@0: iCurrentPictureNumber++; sl@0: CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(5), TTimeIntervalMicroSeconds(5)); sl@0: TVideoPicture* picture = iDevVideoPlay->NextPictureL(); sl@0: iDevVideoPlay->ReturnPicture(picture); sl@0: break; sl@0: } sl@0: case 6: sl@0: { sl@0: iCurrentPictureNumber++; sl@0: CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(6), TTimeIntervalMicroSeconds(6)); sl@0: break; sl@0: } sl@0: case 7: sl@0: { sl@0: iCurrentPictureNumber++; sl@0: CheckNewPictureInfoL(2, TTimeIntervalMicroSeconds(6), TTimeIntervalMicroSeconds(7)); sl@0: break; sl@0: } sl@0: case 8: sl@0: { sl@0: iCurrentPictureNumber++; sl@0: CheckNewPictureInfoL(3, TTimeIntervalMicroSeconds(6), TTimeIntervalMicroSeconds(8)); sl@0: break; sl@0: } sl@0: case 9: sl@0: { sl@0: iCurrentPictureNumber++; sl@0: CheckNewPictureInfoL(4, TTimeIntervalMicroSeconds(6), TTimeIntervalMicroSeconds(9)); sl@0: TVideoPicture* picture = iDevVideoPlay->NextPictureL(); sl@0: iDevVideoPlay->ReturnPicture(picture); sl@0: CheckNewPictureInfoL(3, TTimeIntervalMicroSeconds(7), TTimeIntervalMicroSeconds(9)); sl@0: picture = iDevVideoPlay->NextPictureL(); sl@0: iDevVideoPlay->ReturnPicture(picture); sl@0: CheckNewPictureInfoL(2, TTimeIntervalMicroSeconds(8), TTimeIntervalMicroSeconds(9)); sl@0: picture = iDevVideoPlay->NextPictureL(); sl@0: iDevVideoPlay->ReturnPicture(picture); sl@0: CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(9), TTimeIntervalMicroSeconds(9)); sl@0: picture = iDevVideoPlay->NextPictureL(); sl@0: iDevVideoPlay->ReturnPicture(picture); sl@0: CheckNewPictureInfoL(0, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0)); sl@0: break; sl@0: } sl@0: default: sl@0: User::Leave(KErrGeneral); sl@0: break; sl@0: }; sl@0: } sl@0: sl@0: sl@0: //---------------------------------------------------------------------------- sl@0: sl@0: // DEVVIDEORECORD // sl@0: sl@0: /** sl@0: * sl@0: * Test step constructor. sl@0: * Each test step initialises its own name. sl@0: * sl@0: * sl@0: */ sl@0: CTestStepDevVideoRecordAllocFail::CTestStepDevVideoRecordAllocFail(const TDesC& aTestName) sl@0: { sl@0: // store the name of this test case sl@0: // this is the name that is used by the script file sl@0: iTestStepName = aTestName; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Test step destructor. sl@0: * sl@0: * sl@0: */ sl@0: CTestStepDevVideoRecordAllocFail::~CTestStepDevVideoRecordAllocFail() sl@0: { sl@0: } sl@0: sl@0: // MMMFDevVideoRecordObserver sl@0: void CTestStepDevVideoRecordAllocFail::MdvroNewBuffers() sl@0: { sl@0: INFO_PRINTF1(_L("CTestStepDevVideoRecordAllocFail::MdvroNewBuffers()")); sl@0: } sl@0: sl@0: void CTestStepDevVideoRecordAllocFail::MdvroReturnPicture(TVideoPicture* /*aPicture*/) sl@0: { sl@0: INFO_PRINTF1(_L("CTestStepDevVideoRecordAllocFail::MdvroReturnPicture()")); sl@0: } sl@0: sl@0: void CTestStepDevVideoRecordAllocFail::MdvroSupplementalInfoSent() sl@0: { sl@0: INFO_PRINTF1(_L("CTestStepDevVideoRecordAllocFail::MdvroSupplementalInfoSent()")); sl@0: } sl@0: sl@0: void CTestStepDevVideoRecordAllocFail::MdvroFatalError(TInt aError) sl@0: { sl@0: iError = aError; sl@0: INFO_PRINTF2(_L("CTestStepDevVideoRecordAllocFail::MdvroFatalError()\nError = %d"), aError); sl@0: } sl@0: sl@0: void CTestStepDevVideoRecordAllocFail::MdvroInitializeComplete(TInt aError) sl@0: { sl@0: iError = aError; sl@0: INFO_PRINTF2(_L("CTestStepDevVideoRecordAllocFail::MdvroInitializeComplete(): Error = %d"), aError); sl@0: } sl@0: sl@0: void CTestStepDevVideoRecordAllocFail::MdvroStreamEnd() sl@0: { sl@0: INFO_PRINTF1(_L("CTestStepDevVideoRecordAllocFail::MdvroStreamEnd()")); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Do the test step. sl@0: * Each test step must supply an implementation for DoTestStepL. sl@0: * sl@0: * @return "TVerdict" sl@0: * The result of the test step sl@0: * sl@0: */ sl@0: TVerdict CTestStepDevVideoRecordAllocFail::DoTestStepL() sl@0: { sl@0: TVerdict ret = EFail; sl@0: sl@0: // call alloc test step sl@0: ret = DoTestL(); sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------- sl@0: sl@0: CTestStepDevVideoRecordAllocFailNew::CTestStepDevVideoRecordAllocFailNew(const TDesC& aTestName) sl@0: :CTestStepDevVideoRecordAllocFail(aTestName) sl@0: { sl@0: } sl@0: sl@0: CTestStepDevVideoRecordAllocFailNew* CTestStepDevVideoRecordAllocFailNew::NewL(const TDesC& aTestName) sl@0: { sl@0: CTestStepDevVideoRecordAllocFailNew* self = new(ELeave) CTestStepDevVideoRecordAllocFailNew(aTestName); sl@0: return self; sl@0: } sl@0: sl@0: CTestStepDevVideoRecordAllocFailNew::~CTestStepDevVideoRecordAllocFailNew() sl@0: { sl@0: } sl@0: sl@0: TVerdict CTestStepDevVideoRecordAllocFailNew::DoTestL() sl@0: { sl@0: iTestStepResult = EPass; sl@0: TInt err = KErrNone; sl@0: sl@0: // Printing to the console and log file sl@0: INFO_PRINTF1(_L("this is an Alloc Failure test of initialising CMMFDevVideoRecord with NewL()")); sl@0: sl@0: __MM_HEAP_MARK; sl@0: TRAP( err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this) ); sl@0: delete iDevVideoRecord; sl@0: iDevVideoRecord = NULL; sl@0: __MM_HEAP_MARKEND; sl@0: sl@0: if (err != KErrNone) sl@0: return EFail; sl@0: sl@0: TInt failCount = 1; sl@0: TBool completed = EFalse; sl@0: TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging sl@0: for(;;) sl@0: { sl@0: __UHEAP_SETFAIL(RHeap::EFailNext ,failCount); sl@0: __MM_HEAP_MARK; sl@0: sl@0: TRAP( err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this); sl@0: iDevVideoRecord->SelectEncoderL(KUidDevVideoTestEncodeHwDevice); sl@0: iDevVideoRecord->SelectPreProcessorL(KUidDevVideoTestPreProcHwDevice); ); sl@0: sl@0: completed = EFalse; sl@0: if (err == KErrNone) sl@0: { sl@0: TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test sl@0: if (testAlloc==NULL) sl@0: { sl@0: reachedEnd = ETrue; sl@0: failCount--; // -= 1; sl@0: } sl@0: else sl@0: User::Free(testAlloc); sl@0: sl@0: } sl@0: else if (err != KErrNoMemory) // bad error code sl@0: completed = ETrue; sl@0: sl@0: // see if valid result and break if wrong - might be premature result sl@0: if (iDevVideoRecord) sl@0: { sl@0: delete iDevVideoRecord; sl@0: iDevVideoRecord = NULL; sl@0: } sl@0: completed = reachedEnd; sl@0: __MM_HEAP_MARKEND; sl@0: __UHEAP_SETFAIL(RHeap::ENone ,0); sl@0: sl@0: if (completed) sl@0: break; // exit loop sl@0: sl@0: failCount++; sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount); sl@0: iTestStepResult = EFail; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount); sl@0: iTestStepResult = EPass; sl@0: } sl@0: sl@0: if (iDevVideoRecord) sl@0: { sl@0: delete iDevVideoRecord; sl@0: iDevVideoRecord = NULL; sl@0: } sl@0: sl@0: INFO_PRINTF1(_L("finished with this test step")); sl@0: // test steps return a result sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------- sl@0: sl@0: CTestStepDevVideoRecordAllocFailInfoEncoder::CTestStepDevVideoRecordAllocFailInfoEncoder(const TDesC& aTestName) sl@0: :CTestStepDevVideoRecordAllocFail(aTestName) sl@0: { sl@0: } sl@0: sl@0: CTestStepDevVideoRecordAllocFailInfoEncoder* CTestStepDevVideoRecordAllocFailInfoEncoder::NewL(const TDesC& aTestName) sl@0: { sl@0: CTestStepDevVideoRecordAllocFailInfoEncoder* self = new(ELeave) CTestStepDevVideoRecordAllocFailInfoEncoder(aTestName); sl@0: return self; sl@0: } sl@0: sl@0: CTestStepDevVideoRecordAllocFailInfoEncoder::~CTestStepDevVideoRecordAllocFailInfoEncoder() sl@0: { sl@0: } sl@0: sl@0: TVerdict CTestStepDevVideoRecordAllocFailInfoEncoder::DoTestL() sl@0: { sl@0: iTestStepResult = EPass; sl@0: TInt err = KErrNone; sl@0: sl@0: // Printing to the console and log file sl@0: INFO_PRINTF1(_L("this is an Alloc Failure test of VideoEncoderInfoLC()")); sl@0: sl@0: // moved creation and destruction of iDevVideoRecord inside the heap marks. sl@0: // reason :- VideoEncoderInfoLC may allocate onto it sl@0: sl@0: TInt failCount = 1; sl@0: TBool completed = EFalse; sl@0: TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging sl@0: for(;;) sl@0: { sl@0: __UHEAP_SETFAIL(RHeap::EFailNext ,failCount); sl@0: __MM_HEAP_MARK; sl@0: sl@0: TRAP (err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this)); sl@0: sl@0: if (err == KErrNone) sl@0: { sl@0: CVideoEncoderInfo* vidInfo = NULL; sl@0: sl@0: TRAP( err, vidInfo = iDevVideoRecord->VideoEncoderInfoLC(KUidDevVideoTestEncodeHwDevice); sl@0: CleanupStack::Pop(vidInfo); ); sl@0: sl@0: completed = EFalse; sl@0: if (err == KErrNone) sl@0: { sl@0: TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test sl@0: if (testAlloc==NULL) sl@0: { sl@0: reachedEnd = ETrue; sl@0: failCount--; // -= 1; sl@0: } sl@0: else sl@0: User::Free(testAlloc); sl@0: sl@0: } sl@0: else if (err != KErrNoMemory) // bad error code sl@0: completed = ETrue; sl@0: sl@0: // see if valid result and break if wrong - might be premature result sl@0: sl@0: if (vidInfo) sl@0: { sl@0: delete vidInfo; sl@0: vidInfo = NULL; sl@0: } sl@0: } sl@0: else if (err != KErrNoMemory) // bad error code sl@0: completed = ETrue; sl@0: sl@0: if (iDevVideoRecord) sl@0: { sl@0: delete iDevVideoRecord; sl@0: iDevVideoRecord = NULL; sl@0: } sl@0: sl@0: completed = reachedEnd; sl@0: sl@0: __MM_HEAP_MARKEND; sl@0: __UHEAP_SETFAIL(RHeap::ENone ,0); sl@0: sl@0: if (completed) sl@0: break; // exit loop sl@0: sl@0: failCount++; sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount); sl@0: iTestStepResult = EFail; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount); sl@0: iTestStepResult = EPass; sl@0: } sl@0: sl@0: INFO_PRINTF1(_L("finished with this test step")); sl@0: // test steps return a result sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------- sl@0: sl@0: CTestStepDevVideoRecordAllocFailInfoPreProc::CTestStepDevVideoRecordAllocFailInfoPreProc(const TDesC& aTestName) sl@0: :CTestStepDevVideoRecordAllocFail(aTestName) sl@0: { sl@0: } sl@0: sl@0: CTestStepDevVideoRecordAllocFailInfoPreProc* CTestStepDevVideoRecordAllocFailInfoPreProc::NewL(const TDesC& aTestName) sl@0: { sl@0: CTestStepDevVideoRecordAllocFailInfoPreProc* self = new(ELeave) CTestStepDevVideoRecordAllocFailInfoPreProc(aTestName); sl@0: return self; sl@0: } sl@0: sl@0: CTestStepDevVideoRecordAllocFailInfoPreProc::~CTestStepDevVideoRecordAllocFailInfoPreProc() sl@0: { sl@0: } sl@0: sl@0: TVerdict CTestStepDevVideoRecordAllocFailInfoPreProc::DoTestL() sl@0: { sl@0: iTestStepResult = EPass; sl@0: TInt err = KErrNone; sl@0: sl@0: // Printing to the console and log file sl@0: INFO_PRINTF1(_L("this is an Alloc Failure test of PreProcessorInfoLC()")); sl@0: sl@0: // will leave on error sl@0: TRAP (err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this)); sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF1(_L("Error - Couldn't construct CMMFDevVideoRecord!")); sl@0: return EInconclusive; sl@0: } sl@0: sl@0: CPreProcessorInfo* preInfo = NULL; sl@0: sl@0: TInt failCount = 1; sl@0: TBool completed = EFalse; sl@0: TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging sl@0: for(;;) sl@0: { sl@0: __UHEAP_SETFAIL(RHeap::EFailNext ,failCount); sl@0: __MM_HEAP_MARK; sl@0: sl@0: TRAP( err, preInfo = iDevVideoRecord->PreProcessorInfoLC(KUidDevVideoTestPreProcHwDevice); sl@0: CleanupStack::Pop(preInfo); ); sl@0: sl@0: REComSession::FinalClose(); sl@0: sl@0: completed = EFalse; sl@0: if (err == KErrNone) sl@0: { sl@0: TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test sl@0: if (testAlloc==NULL) sl@0: { sl@0: reachedEnd = ETrue; sl@0: failCount--; // -= 1; sl@0: } sl@0: else sl@0: User::Free(testAlloc); sl@0: sl@0: } sl@0: else if (err != KErrNoMemory) // bad error code sl@0: completed = ETrue; sl@0: sl@0: // see if valid result and break if wrong - might be premature result sl@0: sl@0: if (preInfo) sl@0: { sl@0: delete preInfo; sl@0: preInfo = NULL; sl@0: } sl@0: sl@0: completed = reachedEnd; sl@0: sl@0: __MM_HEAP_MARKEND; sl@0: __UHEAP_SETFAIL(RHeap::ENone ,0); sl@0: sl@0: if (completed) sl@0: break; // exit loop sl@0: sl@0: failCount++; sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount); sl@0: iTestStepResult = EFail; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount); sl@0: iTestStepResult = EPass; sl@0: } sl@0: sl@0: if (iDevVideoRecord) sl@0: { sl@0: delete iDevVideoRecord; sl@0: iDevVideoRecord = NULL; sl@0: } sl@0: sl@0: INFO_PRINTF1(_L("finished with this test step")); sl@0: // test steps return a result sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------- sl@0: sl@0: sl@0: CTestStepDevVideoRecordAllocFailFindPlugins::CTestStepDevVideoRecordAllocFailFindPlugins(const TDesC& aTestName) sl@0: :CTestStepDevVideoRecordAllocFail(aTestName) sl@0: { sl@0: } sl@0: sl@0: CTestStepDevVideoRecordAllocFailFindPlugins* CTestStepDevVideoRecordAllocFailFindPlugins::NewL(const TDesC& aTestName) sl@0: { sl@0: CTestStepDevVideoRecordAllocFailFindPlugins* self = new(ELeave) CTestStepDevVideoRecordAllocFailFindPlugins(aTestName); sl@0: return self; sl@0: } sl@0: sl@0: CTestStepDevVideoRecordAllocFailFindPlugins::~CTestStepDevVideoRecordAllocFailFindPlugins() sl@0: { sl@0: } sl@0: sl@0: TVerdict CTestStepDevVideoRecordAllocFailFindPlugins::DoTestL() sl@0: { sl@0: iTestStepResult = EPass; sl@0: TInt err = KErrNone; sl@0: sl@0: // Printing to the console and log file sl@0: INFO_PRINTF1(_L("this is an Alloc Failure test of finding Encoder and Pre processor plugins")); sl@0: sl@0: sl@0: TInt failCount = 1; sl@0: TBool completed = EFalse; sl@0: TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging sl@0: for(;;) sl@0: { sl@0: __UHEAP_SETFAIL(RHeap::EFailNext ,failCount); sl@0: __MM_HEAP_MARK; sl@0: sl@0: err = KErrNone; sl@0: sl@0: if (!err) sl@0: TRAP(err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this)); sl@0: if (!err) sl@0: TRAP(err, GetEncodersL()); sl@0: if (!err) sl@0: TRAP(err, GetPreProcessorsL()); sl@0: if (!err) sl@0: TRAP(err, FindEncodersL()); sl@0: if (!err) sl@0: TRAP(err, FindPreProcessorsL()); sl@0: sl@0: REComSession::FinalClose(); sl@0: sl@0: completed = EFalse; sl@0: if (err == KErrNone) sl@0: { sl@0: TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test sl@0: if (testAlloc==NULL) sl@0: { sl@0: reachedEnd = ETrue; sl@0: failCount--; // -= 1; sl@0: } sl@0: else sl@0: User::Free(testAlloc); sl@0: sl@0: } sl@0: else if (err != KErrNoMemory) // bad error code sl@0: completed = ETrue; sl@0: sl@0: // see if valid result and break if wrong - might be premature result sl@0: delete iDevVideoRecord; sl@0: iDevVideoRecord = NULL; sl@0: sl@0: __MM_HEAP_MARKEND; sl@0: __UHEAP_SETFAIL(RHeap::ENone ,0); sl@0: sl@0: if (completed || reachedEnd) sl@0: break; // exit loop sl@0: sl@0: failCount++; sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount); sl@0: iTestStepResult = EFail; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount); sl@0: iTestStepResult = EPass; sl@0: } sl@0: sl@0: delete iDevVideoRecord; sl@0: iDevVideoRecord = NULL; sl@0: sl@0: INFO_PRINTF1(_L("finished with this test step")); sl@0: // test steps return a result sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: void CTestStepDevVideoRecordAllocFailFindPlugins::CheckPluginsL(const RArray& aFoundPlugins, const RArray& aExpectedPlugins, const RArray& aUnExpectedPlugins) sl@0: { sl@0: TBool foundUnExpected = EFalse; sl@0: TInt numberToBeFoundInExpectedPlugins = aExpectedPlugins.Count(); sl@0: sl@0: for (TInt i=0; i foundEncoders; sl@0: CleanupClosePushL(foundEncoders); sl@0: RArray expectedEncoders; sl@0: CleanupClosePushL(expectedEncoders); sl@0: RArray unExpectedEncoders; sl@0: CleanupClosePushL(unExpectedEncoders); sl@0: sl@0: sl@0: // Supported mime type and Pre proc type (by exact match) sl@0: _LIT8(KMimeType5, "video/zippyvideo"); sl@0: TUint32 requestedPreProcType = EPpMirror|EPpInputCrop; sl@0: foundEncoders.Reset(); sl@0: expectedEncoders.Reset(); sl@0: unExpectedEncoders.Reset(); sl@0: User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice1)); sl@0: User::LeaveIfError(unExpectedEncoders.Append(KUidDevVideoTestEncodeHwDevice2)); sl@0: User::LeaveIfError(unExpectedEncoders.Append(KUidDevVideoTestEncodeHwDevice3)); sl@0: User::LeaveIfError(unExpectedEncoders.Append(KUidDevVideoTestEncodeHwDevice4)); sl@0: User::LeaveIfError(unExpectedEncoders.Append(KUidDevVideoTestEncodeHwDevice5)); sl@0: sl@0: iDevVideoRecord->FindEncodersL(KMimeType5(), requestedPreProcType, foundEncoders, ETrue); sl@0: CheckPluginsL(foundEncoders, expectedEncoders, unExpectedEncoders); sl@0: sl@0: CleanupStack::PopAndDestroy(3); sl@0: } sl@0: sl@0: void CTestStepDevVideoRecordAllocFailFindPlugins::FindPreProcessorsL() sl@0: { sl@0: RArray foundPreProx; sl@0: CleanupClosePushL(foundPreProx); sl@0: RArray expectedPreProx; sl@0: CleanupClosePushL(expectedPreProx); sl@0: RArray unExpectedPreProx; sl@0: CleanupClosePushL(unExpectedPreProx); sl@0: sl@0: TUint32 requestedPreProcType = EPpMirror|EPpInputCrop; sl@0: foundPreProx.Reset(); sl@0: expectedPreProx.Reset(); sl@0: User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice1)); sl@0: User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice2)); sl@0: User::LeaveIfError(unExpectedPreProx.Append(KUidDevVideoTestPreProcHwDevice3)); sl@0: User::LeaveIfError(unExpectedPreProx.Append(KUidDevVideoTestPreProcHwDevice4)); sl@0: User::LeaveIfError(unExpectedPreProx.Append(KUidDevVideoTestPreProcHwDevice5)); sl@0: sl@0: iDevVideoRecord->FindPreProcessorsL(requestedPreProcType, foundPreProx); sl@0: CheckPluginsL(foundPreProx, expectedPreProx, unExpectedPreProx); sl@0: sl@0: CleanupStack::PopAndDestroy(3); sl@0: } sl@0: sl@0: void CTestStepDevVideoRecordAllocFailFindPlugins::GetEncodersL() sl@0: { sl@0: RArray foundEncoders; sl@0: CleanupClosePushL(foundEncoders); sl@0: RArray expectedEncoders; sl@0: CleanupClosePushL(expectedEncoders); sl@0: RArray unExpectedEncoders; sl@0: CleanupClosePushL(unExpectedEncoders); sl@0: sl@0: User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice1)); sl@0: User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice2)); sl@0: User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice3)); sl@0: User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice4)); sl@0: User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice5)); sl@0: sl@0: iDevVideoRecord->GetEncoderListL(foundEncoders); sl@0: sl@0: CheckPluginsL(foundEncoders, expectedEncoders, unExpectedEncoders); sl@0: sl@0: CleanupStack::PopAndDestroy(3); //foundEncoders, expectedEncoders, unExpectedEncoders sl@0: } sl@0: sl@0: void CTestStepDevVideoRecordAllocFailFindPlugins::GetPreProcessorsL() sl@0: { sl@0: RArray foundPreProx; sl@0: CleanupClosePushL(foundPreProx); sl@0: RArray expectedPreProx; sl@0: CleanupClosePushL(expectedPreProx); sl@0: RArray unExpectedPreProx; sl@0: CleanupClosePushL(unExpectedPreProx); sl@0: sl@0: User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice1)); sl@0: User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice2)); sl@0: User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice3)); sl@0: User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice4)); sl@0: User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice5)); sl@0: sl@0: iDevVideoRecord->GetPreProcessorListL(foundPreProx); sl@0: sl@0: CheckPluginsL(foundPreProx, expectedPreProx, unExpectedPreProx); sl@0: sl@0: CleanupStack::PopAndDestroy(3);//foundPreProx, expectedPreProx, unExpectedPreProx sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------- sl@0: sl@0: sl@0: CTestStepDevVideoRecordAllocFailGetBuffers::CTestStepDevVideoRecordAllocFailGetBuffers(const TDesC& aTestName) sl@0: :CTestStepDevVideoRecordAllocFail(aTestName) sl@0: { sl@0: } sl@0: sl@0: CTestStepDevVideoRecordAllocFailGetBuffers* CTestStepDevVideoRecordAllocFailGetBuffers::NewL(const TDesC& aTestName) sl@0: { sl@0: CTestStepDevVideoRecordAllocFailGetBuffers* self = new(ELeave) CTestStepDevVideoRecordAllocFailGetBuffers(aTestName); sl@0: return self; sl@0: } sl@0: sl@0: CTestStepDevVideoRecordAllocFailGetBuffers::~CTestStepDevVideoRecordAllocFailGetBuffers() sl@0: { sl@0: } sl@0: sl@0: TVerdict CTestStepDevVideoRecordAllocFailGetBuffers::DoTestL() sl@0: { sl@0: iTestStepResult = EPass; sl@0: TInt err = KErrNone; sl@0: sl@0: // Printing to the console and log file sl@0: INFO_PRINTF1(_L("this is an Alloc Failure test of retrieving and returning Buffers to the plugin")); sl@0: sl@0: sl@0: TInt failCount = 1; sl@0: TBool completed = EFalse; sl@0: TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging sl@0: for(;;) sl@0: { sl@0: __UHEAP_SETFAIL(RHeap::EFailNext ,failCount); sl@0: __MM_HEAP_MARK; sl@0: sl@0: TRAP(err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this)); sl@0: if (!err) sl@0: TRAP(err, PerformTestL()); sl@0: sl@0: REComSession::FinalClose(); sl@0: sl@0: completed = EFalse; sl@0: if (err == KErrNone) sl@0: { sl@0: TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test sl@0: if (testAlloc==NULL) sl@0: { sl@0: reachedEnd = ETrue; sl@0: failCount--; // -= 1; sl@0: } sl@0: else sl@0: User::Free(testAlloc); sl@0: sl@0: } sl@0: else if (err != KErrNoMemory) // bad error code sl@0: completed = ETrue; sl@0: sl@0: // see if valid result and break if wrong - might be premature result sl@0: delete iDevVideoRecord; sl@0: iDevVideoRecord = NULL; sl@0: sl@0: __MM_HEAP_MARKEND; sl@0: __UHEAP_SETFAIL(RHeap::ENone ,0); sl@0: sl@0: if (completed || reachedEnd) sl@0: break; // exit loop sl@0: sl@0: failCount++; sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount); sl@0: iTestStepResult = EFail; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount); sl@0: iTestStepResult = EPass; sl@0: } sl@0: sl@0: delete iDevVideoRecord; sl@0: iDevVideoRecord = NULL; sl@0: sl@0: INFO_PRINTF1(_L("finished with this test step")); sl@0: // test steps return a result sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: sl@0: void CTestStepDevVideoRecordAllocFailGetBuffers::PerformTestL() sl@0: { sl@0: iTestError = KErrNone; sl@0: sl@0: // select Encoder sl@0: iDevVideoRecord->SelectEncoderL(KUidDevVideoTestEncodeHwDevice); sl@0: sl@0: // select Pre-processor sl@0: iDevVideoRecord->SelectPreProcessorL(KUidDevVideoTestPreProcHwDevice); sl@0: sl@0: //Tell plugin to start creating Buffers. sl@0: iDevVideoRecord->SetImplementationSpecificEncoderOptionsL(KTestISEncBuffers); sl@0: sl@0: // initialize CDevVideoRecord and wait for response sl@0: iDevVideoRecord->Initialize(); sl@0: sl@0: User::LeaveIfError(iTestError); sl@0: sl@0: iDevVideoRecord->Start();//Tell plugin to start creating Buffers. sl@0: // We should now get a series of NewBuffer() callbacks. sl@0: sl@0: User::LeaveIfError(iTestError); sl@0: } sl@0: sl@0: void CTestStepDevVideoRecordAllocFailGetBuffers::MdvpoInitComplete(TInt aError) sl@0: { sl@0: iTestError = aError; sl@0: } sl@0: sl@0: void CTestStepDevVideoRecordAllocFailGetBuffers::MdvpoNewBuffers() sl@0: { sl@0: TRAP(iTestError, DoNewBuffersL()); sl@0: } sl@0: sl@0: void CTestStepDevVideoRecordAllocFailGetBuffers::CheckNewBufferInfoL(TUint aNumBuffers) sl@0: { sl@0: TUint numBuffers = 0; sl@0: numBuffers = iDevVideoRecord->NumDataBuffers(); sl@0: sl@0: if (numBuffers != aNumBuffers) sl@0: { sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: } sl@0: sl@0: void CTestStepDevVideoRecordAllocFailGetBuffers::DoNewBuffersL() sl@0: { sl@0: User::LeaveIfError(iTestError);//Don't go any further if we have an error sl@0: switch (iCurrentBufferNumber) sl@0: { sl@0: case 0: sl@0: { sl@0: iCurrentBufferNumber++; sl@0: CheckNewBufferInfoL(1); sl@0: TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL(); sl@0: CheckNewBufferInfoL(0); sl@0: iDevVideoRecord->ReturnBuffer(buffer); sl@0: break; sl@0: } sl@0: case 1: sl@0: { sl@0: iCurrentBufferNumber++; sl@0: CheckNewBufferInfoL(1); sl@0: TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL(); sl@0: CheckNewBufferInfoL(0); sl@0: iDevVideoRecord->ReturnBuffer(buffer); sl@0: break; sl@0: } sl@0: case 2: sl@0: { sl@0: iCurrentBufferNumber++; sl@0: CheckNewBufferInfoL(1); sl@0: TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL(); sl@0: CheckNewBufferInfoL(0); sl@0: iDevVideoRecord->ReturnBuffer(buffer); sl@0: break; sl@0: } sl@0: case 3: sl@0: { sl@0: iCurrentBufferNumber++; sl@0: CheckNewBufferInfoL(1); sl@0: TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL(); sl@0: iDevVideoRecord->ReturnBuffer(buffer); sl@0: break; sl@0: } sl@0: case 4: sl@0: { sl@0: iCurrentBufferNumber++; sl@0: CheckNewBufferInfoL(1); sl@0: TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL(); sl@0: iDevVideoRecord->ReturnBuffer(buffer); sl@0: break; sl@0: } sl@0: case 5: sl@0: { sl@0: iCurrentBufferNumber++; sl@0: CheckNewBufferInfoL(1); sl@0: TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL(); sl@0: iDevVideoRecord->ReturnBuffer(buffer); sl@0: break; sl@0: } sl@0: case 6: sl@0: { sl@0: iCurrentBufferNumber++; sl@0: CheckNewBufferInfoL(1); sl@0: break; sl@0: } sl@0: case 7: sl@0: { sl@0: iCurrentBufferNumber++; sl@0: CheckNewBufferInfoL(2); sl@0: break; sl@0: } sl@0: case 8: sl@0: { sl@0: iCurrentBufferNumber++; sl@0: CheckNewBufferInfoL(3); sl@0: break; sl@0: } sl@0: case 9: sl@0: { sl@0: iCurrentBufferNumber++; sl@0: CheckNewBufferInfoL(4); sl@0: TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL(); sl@0: iDevVideoRecord->ReturnBuffer(buffer); sl@0: CheckNewBufferInfoL(3); sl@0: buffer = iDevVideoRecord->NextBufferL(); sl@0: iDevVideoRecord->ReturnBuffer(buffer); sl@0: CheckNewBufferInfoL(2); sl@0: buffer = iDevVideoRecord->NextBufferL(); sl@0: iDevVideoRecord->ReturnBuffer(buffer); sl@0: CheckNewBufferInfoL(1); sl@0: buffer = iDevVideoRecord->NextBufferL(); sl@0: iDevVideoRecord->ReturnBuffer(buffer); sl@0: CheckNewBufferInfoL(0); sl@0: break; sl@0: } sl@0: default: sl@0: User::Leave(KErrGeneral); sl@0: break; sl@0: }; sl@0: } sl@0: sl@0: