1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevVideo/src/TestStepDevVideoAllocFailNew.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1773 @@
1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// This file contains the implementation of the various
1.18 +// ALLOC tests for DevVideo
1.19 +//
1.20 +//
1.21 +
1.22 +// Test system includes
1.23 +#include <testframework.h>
1.24 +
1.25 +#include "TestDevVideoPlugins/decoder.h"
1.26 +#include "TestDevVideoPlugins/postproc.h"
1.27 +
1.28 +#include "TestDevVideoPlugins/encoder.h"
1.29 +#include "TestDevVideoPlugins/preproc.h"
1.30 +
1.31 +#include "TestStepDevVideoAllocFailNew.h"
1.32 +#include "TestDevVideoPlayTestData.h"
1.33 +
1.34 +
1.35 +// --------------------------------------------
1.36 +
1.37 +/**
1.38 + *
1.39 + * Test step constructor.
1.40 + * Each test step initialises its own name.
1.41 + *
1.42 + */
1.43 +CTestStepDevVideoPlayAllocFail::CTestStepDevVideoPlayAllocFail(const TDesC& aTestName)
1.44 + {
1.45 + // store the name of this test case
1.46 + // this is the name that is used by the script file
1.47 + iTestStepName = aTestName;
1.48 + }
1.49 +
1.50 +/**
1.51 + *
1.52 + * Test step destructor.
1.53 + *
1.54 + */
1.55 +CTestStepDevVideoPlayAllocFail::~CTestStepDevVideoPlayAllocFail()
1.56 + {
1.57 + }
1.58 +
1.59 +// MMMFDevVideoPlayObserver
1.60 +void CTestStepDevVideoPlayAllocFail::MdvpoNewBuffers()
1.61 + {
1.62 + INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoNewBuffers()"));
1.63 + }
1.64 +
1.65 +void CTestStepDevVideoPlayAllocFail::MdvpoReturnPicture(TVideoPicture* /*aPicture*/)
1.66 + {
1.67 + INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoReturnPicture()"));
1.68 + }
1.69 +
1.70 +void CTestStepDevVideoPlayAllocFail::MdvpoSupplementalInformation(const TDesC8& /*aData*/,
1.71 + const TTimeIntervalMicroSeconds& /*aTimestamp*/,
1.72 + const TPictureId& /*aPictureId*/)
1.73 + {
1.74 + INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoSupplementalInformation()"));
1.75 + }
1.76 +
1.77 +void CTestStepDevVideoPlayAllocFail::MdvpoPictureLoss()
1.78 + {
1.79 + INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoPictureLoss()"));
1.80 + }
1.81 +
1.82 +void CTestStepDevVideoPlayAllocFail::MdvpoPictureLoss(const TArray<TPictureId>& /*aPictures*/)
1.83 + {
1.84 + INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoPictureLoss(TArray)"));
1.85 + }
1.86 +
1.87 +void CTestStepDevVideoPlayAllocFail::MdvpoSliceLoss(TUint /*aFirstMacroblock*/, TUint /*aNumMacroblocks*/, const TPictureId& /*aPicture*/)
1.88 + {
1.89 + INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoSliceLoss()"));
1.90 + }
1.91 +
1.92 +void CTestStepDevVideoPlayAllocFail::MdvpoReferencePictureSelection(const TDesC8& /*aSelectionData*/)
1.93 + {
1.94 + INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoReferencePictureSelection()"));
1.95 + }
1.96 +
1.97 +void CTestStepDevVideoPlayAllocFail::MdvpoTimedSnapshotComplete(TInt /*aError*/,
1.98 + TPictureData* /*aPictureData*/,
1.99 + const TTimeIntervalMicroSeconds& /*aPresentationTimestamp*/,
1.100 + const TPictureId& /*aPictureId*/)
1.101 + {
1.102 + INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoTimedSnapshotComplete()"));
1.103 + }
1.104 +
1.105 +void CTestStepDevVideoPlayAllocFail::MdvpoNewPictures()
1.106 + {
1.107 + INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoNewPictures()"));
1.108 + }
1.109 +
1.110 +void CTestStepDevVideoPlayAllocFail::MdvpoFatalError(TInt aError)
1.111 + {
1.112 + iError = aError;
1.113 + INFO_PRINTF2(_L("CTestStepDevVideoPlayAllocFail::MdvpoFatalError()\nError = %d"), aError);
1.114 + }
1.115 +
1.116 +void CTestStepDevVideoPlayAllocFail::MdvpoInitComplete(TInt aError)
1.117 + {
1.118 + iError = aError;
1.119 + INFO_PRINTF2(_L("CTestStepDevVideoPlayAllocFail::MdvpoInitComplete(): Error = %d"), aError);
1.120 + }
1.121 +
1.122 +void CTestStepDevVideoPlayAllocFail::MdvpoStreamEnd()
1.123 + {
1.124 + INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoStreamEnd()"));
1.125 + }
1.126 +
1.127 +/**
1.128 + *
1.129 + * Do the test step.
1.130 + * Each test step must supply an implementation for DoTestStepL.
1.131 + *
1.132 + * @return "TVerdict"
1.133 + * The result of the test step
1.134 + *
1.135 + */
1.136 +TVerdict CTestStepDevVideoPlayAllocFail::DoTestStepL()
1.137 + {
1.138 + TVerdict ret = EFail;
1.139 +
1.140 + // do we want to do anything else in the base class?
1.141 +
1.142 + // call alloc test step
1.143 + ret = DoTestL();
1.144 +
1.145 + return ret;
1.146 + }
1.147 +
1.148 +
1.149 +//----------------------------------------------------------------------------
1.150 +
1.151 +CTestStepDevVideoPlayAllocFailNew::CTestStepDevVideoPlayAllocFailNew(const TDesC& aTestName)
1.152 + :CTestStepDevVideoPlayAllocFail(aTestName)
1.153 + {
1.154 + }
1.155 +
1.156 +CTestStepDevVideoPlayAllocFailNew* CTestStepDevVideoPlayAllocFailNew::NewL(const TDesC& aTestName)
1.157 + {
1.158 + CTestStepDevVideoPlayAllocFailNew* self = new(ELeave) CTestStepDevVideoPlayAllocFailNew(aTestName);
1.159 + return self;
1.160 + }
1.161 +
1.162 +CTestStepDevVideoPlayAllocFailNew::~CTestStepDevVideoPlayAllocFailNew()
1.163 + {
1.164 + }
1.165 +
1.166 +TVerdict CTestStepDevVideoPlayAllocFailNew::DoTestL()
1.167 + {
1.168 + iTestStepResult = EPass;
1.169 + TInt err = KErrNone;
1.170 +
1.171 + // Printing to the console and log file
1.172 + INFO_PRINTF1(_L("this is an Alloc Failure test of initialising CMMFDevVideoPlay with NewL()"));
1.173 +
1.174 + __UHEAP_MARK;
1.175 + TRAP( err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this) );
1.176 + delete iDevVideoPlay;
1.177 + iDevVideoPlay = NULL;
1.178 + __UHEAP_MARKEND;
1.179 +
1.180 + if (err != KErrNone)
1.181 + return EFail;
1.182 +
1.183 + TInt failCount = 1;
1.184 + TBool completed = EFalse;
1.185 + TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1.186 + for(;;)
1.187 + {
1.188 + __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
1.189 + __MM_HEAP_MARK;
1.190 +
1.191 + TRAP( err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this);
1.192 + iDevVideoPlay->SelectDecoderL(KUidDevVideoTestDecodeHwDevice);
1.193 + iDevVideoPlay->SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice); );
1.194 +
1.195 + completed = EFalse;
1.196 + if (err == KErrNone)
1.197 + {
1.198 + TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1.199 + if (testAlloc==NULL)
1.200 + {
1.201 + reachedEnd = ETrue;
1.202 + failCount--; // -= 1;
1.203 + }
1.204 + else
1.205 + User::Free(testAlloc);
1.206 +
1.207 + }
1.208 + else if (err != KErrNoMemory) // bad error code
1.209 + completed = ETrue;
1.210 +
1.211 + // see if valid result and break if wrong - might be premature result
1.212 + if (iDevVideoPlay)
1.213 + {
1.214 + delete iDevVideoPlay;
1.215 + iDevVideoPlay = NULL;
1.216 + }
1.217 + completed = reachedEnd;
1.218 + __MM_HEAP_MARKEND;
1.219 + __UHEAP_SETFAIL(RHeap::ENone ,0);
1.220 +
1.221 + if (completed)
1.222 + break; // exit loop
1.223 +
1.224 + failCount++;
1.225 + }
1.226 +
1.227 + if (err != KErrNone)
1.228 + {
1.229 + INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
1.230 + iTestStepResult = EFail;
1.231 + }
1.232 + else
1.233 + {
1.234 + INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
1.235 + iTestStepResult = EPass;
1.236 + }
1.237 +
1.238 + if (iDevVideoPlay)
1.239 + {
1.240 + delete iDevVideoPlay;
1.241 + iDevVideoPlay = NULL;
1.242 + }
1.243 +
1.244 + INFO_PRINTF1(_L("finished with this test step"));
1.245 + // test steps return a result
1.246 + return iTestStepResult;
1.247 + }
1.248 +
1.249 +//----------------------------------------------------------------------------
1.250 +
1.251 +
1.252 +CTestStepDevVideoPlayAllocFailFindPlugins::CTestStepDevVideoPlayAllocFailFindPlugins(const TDesC& aTestName)
1.253 + :CTestStepDevVideoPlayAllocFail(aTestName)
1.254 + {
1.255 + }
1.256 +
1.257 +CTestStepDevVideoPlayAllocFailFindPlugins* CTestStepDevVideoPlayAllocFailFindPlugins::NewL(const TDesC& aTestName)
1.258 + {
1.259 + CTestStepDevVideoPlayAllocFailFindPlugins* self = new(ELeave) CTestStepDevVideoPlayAllocFailFindPlugins(aTestName);
1.260 + return self;
1.261 + }
1.262 +
1.263 +CTestStepDevVideoPlayAllocFailFindPlugins::~CTestStepDevVideoPlayAllocFailFindPlugins()
1.264 + {
1.265 + }
1.266 +
1.267 +TVerdict CTestStepDevVideoPlayAllocFailFindPlugins::DoTestL()
1.268 + {
1.269 + iTestStepResult = EPass;
1.270 + TInt err = KErrNone;
1.271 +
1.272 + // Printing to the console and log file
1.273 + INFO_PRINTF1(_L("this is an Alloc Failure test of finding decoder and post processor plugins"));
1.274 +
1.275 +
1.276 + TInt failCount = 1;
1.277 + TBool completed = EFalse;
1.278 + TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1.279 + for(;;)
1.280 + {
1.281 + __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
1.282 + __MM_HEAP_MARK;
1.283 +
1.284 + err = KErrNone;
1.285 +
1.286 + if (!err)
1.287 + TRAP(err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this));
1.288 + if (!err)
1.289 + TRAP(err, GetDecodersL());
1.290 + if (!err)
1.291 + TRAP(err, GetPostProcessorsL());
1.292 + if (!err)
1.293 + TRAP(err, FindDecodersL());
1.294 + if (!err)
1.295 + TRAP(err, FindPostProcessorsL());
1.296 +
1.297 + REComSession::FinalClose();
1.298 +
1.299 + completed = EFalse;
1.300 + if (err == KErrNone)
1.301 + {
1.302 + TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1.303 + if (testAlloc==NULL)
1.304 + {
1.305 + reachedEnd = ETrue;
1.306 + failCount--; // -= 1;
1.307 + }
1.308 + else
1.309 + User::Free(testAlloc);
1.310 +
1.311 + }
1.312 + else if (err != KErrNoMemory) // bad error code
1.313 + completed = ETrue;
1.314 +
1.315 + // see if valid result and break if wrong - might be premature result
1.316 + delete iDevVideoPlay;
1.317 + iDevVideoPlay = NULL;
1.318 +
1.319 + __MM_HEAP_MARKEND;
1.320 + __UHEAP_SETFAIL(RHeap::ENone ,0);
1.321 +
1.322 + if (completed || reachedEnd)
1.323 + break; // exit loop
1.324 +
1.325 + failCount++;
1.326 + }
1.327 +
1.328 + if (err != KErrNone)
1.329 + {
1.330 + INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
1.331 + iTestStepResult = EFail;
1.332 + }
1.333 + else
1.334 + {
1.335 + INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
1.336 + iTestStepResult = EPass;
1.337 + }
1.338 +
1.339 + delete iDevVideoPlay;
1.340 + iDevVideoPlay = NULL;
1.341 +
1.342 + INFO_PRINTF1(_L("finished with this test step"));
1.343 + // test steps return a result
1.344 + return iTestStepResult;
1.345 + }
1.346 +
1.347 +void CTestStepDevVideoPlayAllocFailFindPlugins::CheckPluginsL(const RArray<TUid>& aFoundPlugins, const RArray<TUid>& aExpectedPlugins, const RArray<TUid>& aUnExpectedPlugins)
1.348 + {
1.349 + TBool foundUnExpected = EFalse;
1.350 + TInt numberToBeFoundInExpectedPlugins = aExpectedPlugins.Count();
1.351 +
1.352 + for (TInt i=0; i<aFoundPlugins.Count(); i++)
1.353 + {
1.354 + TUid uidToLookFor = aFoundPlugins[i];
1.355 + TInt j;
1.356 + for (j=0; j<aExpectedPlugins.Count(); j++)
1.357 + {
1.358 + if (aExpectedPlugins[j] == uidToLookFor)
1.359 + {
1.360 + numberToBeFoundInExpectedPlugins--;
1.361 + break;//j
1.362 + }
1.363 + }
1.364 + for (j=0; j<aUnExpectedPlugins.Count(); j++)
1.365 + {
1.366 + if (aUnExpectedPlugins[j] == uidToLookFor)
1.367 + {
1.368 + foundUnExpected = ETrue;
1.369 + break;//j
1.370 + }
1.371 + }
1.372 + }
1.373 +
1.374 + if ((foundUnExpected) || (numberToBeFoundInExpectedPlugins!=0))
1.375 + User::Leave(KErrGeneral);
1.376 +
1.377 + }
1.378 +
1.379 +
1.380 +void CTestStepDevVideoPlayAllocFailFindPlugins::FindDecodersL()
1.381 + {
1.382 + RArray<TUid> foundDecoders;
1.383 + CleanupClosePushL(foundDecoders);
1.384 + RArray<TUid> expectedDecoders;
1.385 + CleanupClosePushL(expectedDecoders);
1.386 + RArray<TUid> unExpectedDecoders;
1.387 + CleanupClosePushL(unExpectedDecoders);
1.388 +
1.389 +
1.390 + // Supported mime type and post proc type (by exact match)
1.391 + _LIT8(KMimeType5, "video/zippyvideo");
1.392 + TUint32 requestedPostProcType = EPpMirror|EPpInputCrop;
1.393 + foundDecoders.Reset();
1.394 + expectedDecoders.Reset();
1.395 + unExpectedDecoders.Reset();
1.396 + User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice1));
1.397 + User::LeaveIfError(unExpectedDecoders.Append(KUidDevVideoTestDecodeHwDevice2));
1.398 + User::LeaveIfError(unExpectedDecoders.Append(KUidDevVideoTestDecodeHwDevice3));
1.399 + User::LeaveIfError(unExpectedDecoders.Append(KUidDevVideoTestDecodeHwDevice4));
1.400 + User::LeaveIfError(unExpectedDecoders.Append(KUidDevVideoTestDecodeHwDevice5));
1.401 +
1.402 + iDevVideoPlay->FindDecodersL(KMimeType5(), requestedPostProcType, foundDecoders, ETrue);
1.403 + CheckPluginsL(foundDecoders, expectedDecoders, unExpectedDecoders);
1.404 +
1.405 + CleanupStack::PopAndDestroy(3);
1.406 + }
1.407 +
1.408 +void CTestStepDevVideoPlayAllocFailFindPlugins::FindPostProcessorsL()
1.409 + {
1.410 + RArray<TUid> foundPostProx;
1.411 + CleanupClosePushL(foundPostProx);
1.412 + RArray<TUid> expectedPostProx;
1.413 + CleanupClosePushL(expectedPostProx);
1.414 + RArray<TUid> unExpectedPostProx;
1.415 + CleanupClosePushL(unExpectedPostProx);
1.416 +
1.417 + TUint32 requestedPostProcType = EPpMirror|EPpInputCrop;
1.418 + foundPostProx.Reset();
1.419 + expectedPostProx.Reset();
1.420 + User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice1));
1.421 + User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice2));
1.422 + User::LeaveIfError(unExpectedPostProx.Append(KUidDevVideoTestPostProcHwDevice3));
1.423 + User::LeaveIfError(unExpectedPostProx.Append(KUidDevVideoTestPostProcHwDevice4));
1.424 + User::LeaveIfError(unExpectedPostProx.Append(KUidDevVideoTestPostProcHwDevice5));
1.425 +
1.426 + iDevVideoPlay->FindPostProcessorsL(requestedPostProcType, foundPostProx);
1.427 + CheckPluginsL(foundPostProx, expectedPostProx, unExpectedPostProx);
1.428 +
1.429 + CleanupStack::PopAndDestroy(3);
1.430 + }
1.431 +
1.432 +void CTestStepDevVideoPlayAllocFailFindPlugins::GetDecodersL()
1.433 + {
1.434 + RArray<TUid> foundDecoders;
1.435 + CleanupClosePushL(foundDecoders);
1.436 + RArray<TUid> expectedDecoders;
1.437 + CleanupClosePushL(expectedDecoders);
1.438 + RArray<TUid> unExpectedDecoders;
1.439 + CleanupClosePushL(unExpectedDecoders);
1.440 +
1.441 + User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice1));
1.442 + User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice2));
1.443 + User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice3));
1.444 + User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice4));
1.445 + User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice5));
1.446 +
1.447 + iDevVideoPlay->GetDecoderListL(foundDecoders);
1.448 +
1.449 + CheckPluginsL(foundDecoders, expectedDecoders, unExpectedDecoders);
1.450 +
1.451 + CleanupStack::PopAndDestroy(3); //foundDecoders, expectedDecoders, unExpectedDecoders
1.452 + }
1.453 +
1.454 +void CTestStepDevVideoPlayAllocFailFindPlugins::GetPostProcessorsL()
1.455 + {
1.456 + RArray<TUid> foundPostProx;
1.457 + CleanupClosePushL(foundPostProx);
1.458 + RArray<TUid> expectedPostProx;
1.459 + CleanupClosePushL(expectedPostProx);
1.460 + RArray<TUid> unExpectedPostProx;
1.461 + CleanupClosePushL(unExpectedPostProx);
1.462 +
1.463 + User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice1));
1.464 + User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice2));
1.465 + User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice3));
1.466 + User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice4));
1.467 + User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice5));
1.468 +
1.469 + iDevVideoPlay->GetPostProcessorListL(foundPostProx);
1.470 +
1.471 + CheckPluginsL(foundPostProx, expectedPostProx, unExpectedPostProx);
1.472 +
1.473 + CleanupStack::PopAndDestroy(3);//foundPostProx, expectedPostProx, unExpectedPostProx
1.474 + }
1.475 +
1.476 +//----------------------------------------------------------------------------
1.477 +
1.478 +CTestStepDevVideoPlayAllocFailInfoDecoder::CTestStepDevVideoPlayAllocFailInfoDecoder(const TDesC& aTestName)
1.479 + :CTestStepDevVideoPlayAllocFail(aTestName)
1.480 + {
1.481 + }
1.482 +
1.483 +CTestStepDevVideoPlayAllocFailInfoDecoder* CTestStepDevVideoPlayAllocFailInfoDecoder::NewL(const TDesC& aTestName)
1.484 + {
1.485 + CTestStepDevVideoPlayAllocFailInfoDecoder* self = new(ELeave) CTestStepDevVideoPlayAllocFailInfoDecoder(aTestName);
1.486 + return self;
1.487 + }
1.488 +
1.489 +CTestStepDevVideoPlayAllocFailInfoDecoder::~CTestStepDevVideoPlayAllocFailInfoDecoder()
1.490 + {
1.491 + }
1.492 +
1.493 +TVerdict CTestStepDevVideoPlayAllocFailInfoDecoder::DoTestL()
1.494 + {
1.495 + iTestStepResult = EPass;
1.496 + TInt err = KErrNone;
1.497 +
1.498 + // Printing to the console and log file
1.499 + INFO_PRINTF1(_L("this is an Alloc Failure test of VideoDecoderInfoLC()"));
1.500 +
1.501 + // moved creation and destruction of iDevVideoPlay inside the heap marks.
1.502 + // reason :- VideoDecoderInfoLC may allocate onto it
1.503 +
1.504 + TInt failCount = 1;
1.505 + TBool completed = EFalse;
1.506 + TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1.507 + for(;;)
1.508 + {
1.509 + __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
1.510 + __MM_HEAP_MARK;
1.511 +
1.512 + TRAP (err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this));
1.513 + if (err == KErrNone)
1.514 + {
1.515 +
1.516 + CVideoDecoderInfo* vidInfo = NULL;
1.517 +
1.518 + TRAP( err, vidInfo = iDevVideoPlay->VideoDecoderInfoLC(KUidDevVideoTestDecodeHwDevice);
1.519 + CleanupStack::Pop(vidInfo); );
1.520 +
1.521 + completed = EFalse;
1.522 + if (err == KErrNone)
1.523 + {
1.524 + TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1.525 + if (testAlloc==NULL)
1.526 + {
1.527 + reachedEnd = ETrue;
1.528 + failCount--; // -= 1;
1.529 + }
1.530 + else
1.531 + User::Free(testAlloc);
1.532 +
1.533 + }
1.534 + else if (err != KErrNoMemory) // bad error code
1.535 + completed = ETrue;
1.536 +
1.537 + // see if valid result and break if wrong - might be premature result
1.538 +
1.539 + if (vidInfo)
1.540 + {
1.541 + delete vidInfo;
1.542 + vidInfo = NULL;
1.543 + }
1.544 + }
1.545 + else if (err != KErrNoMemory) // bad error code
1.546 + completed = ETrue;
1.547 +
1.548 + if (iDevVideoPlay)
1.549 + {
1.550 + delete iDevVideoPlay;
1.551 + iDevVideoPlay = NULL;
1.552 + }
1.553 +
1.554 + completed = reachedEnd;
1.555 +
1.556 + __MM_HEAP_MARKEND;
1.557 + __UHEAP_SETFAIL(RHeap::ENone ,0);
1.558 +
1.559 + if (completed)
1.560 + break; // exit loop
1.561 +
1.562 + failCount++;
1.563 + }
1.564 +
1.565 + if (err != KErrNone)
1.566 + {
1.567 + INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
1.568 + iTestStepResult = EFail;
1.569 + }
1.570 + else
1.571 + {
1.572 + INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
1.573 + iTestStepResult = EPass;
1.574 + }
1.575 +
1.576 + INFO_PRINTF1(_L("finished with this test step"));
1.577 + // test steps return a result
1.578 + return iTestStepResult;
1.579 + }
1.580 +
1.581 +
1.582 +//----------------------------------------------------------------------------
1.583 +
1.584 +CTestStepDevVideoPlayAllocFailInfoPostProc::CTestStepDevVideoPlayAllocFailInfoPostProc(const TDesC& aTestName)
1.585 + :CTestStepDevVideoPlayAllocFail(aTestName)
1.586 + {
1.587 + }
1.588 +
1.589 +CTestStepDevVideoPlayAllocFailInfoPostProc* CTestStepDevVideoPlayAllocFailInfoPostProc::NewL(const TDesC& aTestName)
1.590 + {
1.591 + CTestStepDevVideoPlayAllocFailInfoPostProc* self = new(ELeave) CTestStepDevVideoPlayAllocFailInfoPostProc(aTestName);
1.592 + return self;
1.593 + }
1.594 +
1.595 +CTestStepDevVideoPlayAllocFailInfoPostProc::~CTestStepDevVideoPlayAllocFailInfoPostProc()
1.596 + {
1.597 + }
1.598 +
1.599 +TVerdict CTestStepDevVideoPlayAllocFailInfoPostProc::DoTestL()
1.600 + {
1.601 + iTestStepResult = EPass;
1.602 + TInt err = KErrNone;
1.603 +
1.604 + // Printing to the console and log file
1.605 + INFO_PRINTF1(_L("this is an Alloc Failure test of PostProcessorInfoLC()"));
1.606 +
1.607 + // will leave on error
1.608 + TRAP (err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this));
1.609 +
1.610 + if (err != KErrNone)
1.611 + {
1.612 + ERR_PRINTF1(_L("Error - Couldn't construct CMMFDevVideoPlay!"));
1.613 + return EInconclusive;
1.614 + }
1.615 +
1.616 + CPostProcessorInfo* postInfo = NULL;
1.617 +
1.618 + TInt failCount = 1;
1.619 + TBool completed = EFalse;
1.620 + TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1.621 + for(;;)
1.622 + {
1.623 + __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
1.624 + __MM_HEAP_MARK;
1.625 +
1.626 + TRAP( err, postInfo = iDevVideoPlay->PostProcessorInfoLC(KUidDevVideoTestPostProcHwDevice);
1.627 + CleanupStack::Pop(postInfo); );
1.628 +
1.629 + REComSession::FinalClose();
1.630 +
1.631 + completed = EFalse;
1.632 + if (err == KErrNone)
1.633 + {
1.634 + TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1.635 + if (testAlloc==NULL)
1.636 + {
1.637 + reachedEnd = ETrue;
1.638 + failCount--; // -= 1;
1.639 + }
1.640 + else
1.641 + User::Free(testAlloc);
1.642 +
1.643 + }
1.644 + else if (err != KErrNoMemory) // bad error code
1.645 + completed = ETrue;
1.646 +
1.647 + // see if valid result and break if wrong - might be premature result
1.648 +
1.649 + if (postInfo)
1.650 + {
1.651 + delete postInfo;
1.652 + postInfo = NULL;
1.653 + }
1.654 +
1.655 + completed = reachedEnd;
1.656 +
1.657 + __MM_HEAP_MARKEND;
1.658 + __UHEAP_SETFAIL(RHeap::ENone ,0);
1.659 +
1.660 + if (completed)
1.661 + break; // exit loop
1.662 +
1.663 + failCount++;
1.664 + }
1.665 +
1.666 + if (err != KErrNone)
1.667 + {
1.668 + INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
1.669 + iTestStepResult = EFail;
1.670 + }
1.671 + else
1.672 + {
1.673 + INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
1.674 + iTestStepResult = EPass;
1.675 + }
1.676 +
1.677 + if (iDevVideoPlay)
1.678 + {
1.679 + delete iDevVideoPlay;
1.680 + iDevVideoPlay = NULL;
1.681 + }
1.682 +
1.683 + INFO_PRINTF1(_L("finished with this test step"));
1.684 + // test steps return a result
1.685 + return iTestStepResult;
1.686 + }
1.687 +
1.688 +
1.689 +//----------------------------------------------------------------------------
1.690 +
1.691 +
1.692 +CTestStepDevVideoPlayAllocFailGetPictures::CTestStepDevVideoPlayAllocFailGetPictures(const TDesC& aTestName)
1.693 + :CTestStepDevVideoPlayAllocFail(aTestName)
1.694 + {
1.695 + }
1.696 +
1.697 +CTestStepDevVideoPlayAllocFailGetPictures* CTestStepDevVideoPlayAllocFailGetPictures::NewL(const TDesC& aTestName)
1.698 + {
1.699 + CTestStepDevVideoPlayAllocFailGetPictures* self = new(ELeave) CTestStepDevVideoPlayAllocFailGetPictures(aTestName);
1.700 + return self;
1.701 + }
1.702 +
1.703 +CTestStepDevVideoPlayAllocFailGetPictures::~CTestStepDevVideoPlayAllocFailGetPictures()
1.704 + {
1.705 + }
1.706 +
1.707 +TVerdict CTestStepDevVideoPlayAllocFailGetPictures::DoTestL()
1.708 + {
1.709 + iTestStepResult = EPass;
1.710 + TInt err = KErrNone;
1.711 +
1.712 + // Printing to the console and log file
1.713 + INFO_PRINTF1(_L("this is an Alloc Failure test of retrieving and returning pictures to the plugin"));
1.714 +
1.715 +
1.716 + TInt failCount = 1;
1.717 + TBool completed = EFalse;
1.718 + TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1.719 + for(;;)
1.720 + {
1.721 + __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
1.722 + __MM_HEAP_MARK;
1.723 +
1.724 + TRAP(err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this));
1.725 + if (!err)
1.726 + TRAP(err, PerformTestL());
1.727 +
1.728 + REComSession::FinalClose();
1.729 +
1.730 + completed = EFalse;
1.731 + if (err == KErrNone)
1.732 + {
1.733 + TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1.734 + if (testAlloc==NULL)
1.735 + {
1.736 + reachedEnd = ETrue;
1.737 + failCount--; // -= 1;
1.738 + }
1.739 + else
1.740 + User::Free(testAlloc);
1.741 +
1.742 + }
1.743 + else if (err != KErrNoMemory) // bad error code
1.744 + completed = ETrue;
1.745 +
1.746 + // see if valid result and break if wrong - might be premature result
1.747 + delete iDevVideoPlay;
1.748 + iDevVideoPlay = NULL;
1.749 +
1.750 + __MM_HEAP_MARKEND;
1.751 + __UHEAP_SETFAIL(RHeap::ENone ,0);
1.752 +
1.753 + if (completed || reachedEnd)
1.754 + break; // exit loop
1.755 +
1.756 + failCount++;
1.757 + }
1.758 +
1.759 + if (err != KErrNone)
1.760 + {
1.761 + INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
1.762 + iTestStepResult = EFail;
1.763 + }
1.764 + else
1.765 + {
1.766 + INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
1.767 + iTestStepResult = EPass;
1.768 + }
1.769 +
1.770 + delete iDevVideoPlay;
1.771 + iDevVideoPlay = NULL;
1.772 +
1.773 + INFO_PRINTF1(_L("finished with this test step"));
1.774 + // test steps return a result
1.775 + return iTestStepResult;
1.776 + }
1.777 +
1.778 +
1.779 +void CTestStepDevVideoPlayAllocFailGetPictures::PerformTestL()
1.780 + {
1.781 + iTestError = KErrNone;
1.782 +
1.783 + // select decoder
1.784 + iDevVideoPlay->SelectDecoderL(KUidDevVideoTestDecodeHwDevice);
1.785 +
1.786 + // select post-processor
1.787 + iDevVideoPlay->SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice);
1.788 +
1.789 + //Tell plugin to start creating pictures.
1.790 + iDevVideoPlay->SetVideoDestScreenL(EFalse);
1.791 +
1.792 + // initialize CDevVideoPlay and wait for response
1.793 + iDevVideoPlay->Initialize();
1.794 +
1.795 + User::LeaveIfError(iTestError);
1.796 +
1.797 + iDevVideoPlay->Start();//Tell plugin to start creating pictures.
1.798 + // We should now get a series of NewPicture() callbacks.
1.799 +
1.800 + User::LeaveIfError(iTestError);
1.801 + }
1.802 +
1.803 +void CTestStepDevVideoPlayAllocFailGetPictures::MdvpoInitComplete(TInt aError)
1.804 + {
1.805 + iTestError = aError;
1.806 + }
1.807 +
1.808 +void CTestStepDevVideoPlayAllocFailGetPictures::MdvpoNewPictures()
1.809 + {
1.810 + TRAP(iTestError, DoNewPicturesL());
1.811 + }
1.812 +
1.813 +void CTestStepDevVideoPlayAllocFailGetPictures::CheckNewPictureInfoL(TUint aNumPictures, const TTimeIntervalMicroSeconds& aFirst, const TTimeIntervalMicroSeconds& aLast)
1.814 + {
1.815 + TUint numPictures = 0;
1.816 + TTimeIntervalMicroSeconds first(0);
1.817 + TTimeIntervalMicroSeconds last(0);
1.818 + iDevVideoPlay->GetNewPictureInfo(numPictures, first, last);
1.819 +
1.820 + if ((numPictures!=aNumPictures) || (first!=aFirst) || (last!=aLast))
1.821 + {
1.822 + User::Leave(KErrGeneral);
1.823 + }
1.824 + }
1.825 +
1.826 +void CTestStepDevVideoPlayAllocFailGetPictures::DoNewPicturesL()
1.827 + {
1.828 + User::LeaveIfError(iTestError);//Don't go any further if we have an error
1.829 + switch (iCurrentPictureNumber)
1.830 + {
1.831 + case 0:
1.832 + {
1.833 + iCurrentPictureNumber++;
1.834 + CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
1.835 + TVideoPicture* picture = iDevVideoPlay->NextPictureL();
1.836 + CheckNewPictureInfoL(0, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
1.837 + iDevVideoPlay->ReturnPicture(picture);
1.838 + break;
1.839 + }
1.840 + case 1:
1.841 + {
1.842 + iCurrentPictureNumber++;
1.843 + CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(1), TTimeIntervalMicroSeconds(1));
1.844 + TVideoPicture* picture = iDevVideoPlay->NextPictureL();
1.845 + CheckNewPictureInfoL(0, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
1.846 + iDevVideoPlay->ReturnPicture(picture);
1.847 + break;
1.848 + }
1.849 + case 2:
1.850 + {
1.851 + iCurrentPictureNumber++;
1.852 + CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(2), TTimeIntervalMicroSeconds(2));
1.853 + TVideoPicture* picture = iDevVideoPlay->NextPictureL();
1.854 + CheckNewPictureInfoL(0, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
1.855 + iDevVideoPlay->ReturnPicture(picture);
1.856 + break;
1.857 + }
1.858 + case 3:
1.859 + {
1.860 + iCurrentPictureNumber++;
1.861 + CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(3), TTimeIntervalMicroSeconds(3));
1.862 + TVideoPicture* picture = iDevVideoPlay->NextPictureL();
1.863 + iDevVideoPlay->ReturnPicture(picture);
1.864 + break;
1.865 + }
1.866 + case 4:
1.867 + {
1.868 + iCurrentPictureNumber++;
1.869 + CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(4), TTimeIntervalMicroSeconds(4));
1.870 + TVideoPicture* picture = iDevVideoPlay->NextPictureL();
1.871 + iDevVideoPlay->ReturnPicture(picture);
1.872 + break;
1.873 + }
1.874 + case 5:
1.875 + {
1.876 + iCurrentPictureNumber++;
1.877 + CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(5), TTimeIntervalMicroSeconds(5));
1.878 + TVideoPicture* picture = iDevVideoPlay->NextPictureL();
1.879 + iDevVideoPlay->ReturnPicture(picture);
1.880 + break;
1.881 + }
1.882 + case 6:
1.883 + {
1.884 + iCurrentPictureNumber++;
1.885 + CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(6), TTimeIntervalMicroSeconds(6));
1.886 + break;
1.887 + }
1.888 + case 7:
1.889 + {
1.890 + iCurrentPictureNumber++;
1.891 + CheckNewPictureInfoL(2, TTimeIntervalMicroSeconds(6), TTimeIntervalMicroSeconds(7));
1.892 + break;
1.893 + }
1.894 + case 8:
1.895 + {
1.896 + iCurrentPictureNumber++;
1.897 + CheckNewPictureInfoL(3, TTimeIntervalMicroSeconds(6), TTimeIntervalMicroSeconds(8));
1.898 + break;
1.899 + }
1.900 + case 9:
1.901 + {
1.902 + iCurrentPictureNumber++;
1.903 + CheckNewPictureInfoL(4, TTimeIntervalMicroSeconds(6), TTimeIntervalMicroSeconds(9));
1.904 + TVideoPicture* picture = iDevVideoPlay->NextPictureL();
1.905 + iDevVideoPlay->ReturnPicture(picture);
1.906 + CheckNewPictureInfoL(3, TTimeIntervalMicroSeconds(7), TTimeIntervalMicroSeconds(9));
1.907 + picture = iDevVideoPlay->NextPictureL();
1.908 + iDevVideoPlay->ReturnPicture(picture);
1.909 + CheckNewPictureInfoL(2, TTimeIntervalMicroSeconds(8), TTimeIntervalMicroSeconds(9));
1.910 + picture = iDevVideoPlay->NextPictureL();
1.911 + iDevVideoPlay->ReturnPicture(picture);
1.912 + CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(9), TTimeIntervalMicroSeconds(9));
1.913 + picture = iDevVideoPlay->NextPictureL();
1.914 + iDevVideoPlay->ReturnPicture(picture);
1.915 + CheckNewPictureInfoL(0, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
1.916 + break;
1.917 + }
1.918 + default:
1.919 + User::Leave(KErrGeneral);
1.920 + break;
1.921 + };
1.922 + }
1.923 +
1.924 +
1.925 +//----------------------------------------------------------------------------
1.926 +
1.927 +// DEVVIDEORECORD //
1.928 +
1.929 +/**
1.930 + *
1.931 + * Test step constructor.
1.932 + * Each test step initialises its own name.
1.933 + *
1.934 + *
1.935 + */
1.936 +CTestStepDevVideoRecordAllocFail::CTestStepDevVideoRecordAllocFail(const TDesC& aTestName)
1.937 + {
1.938 + // store the name of this test case
1.939 + // this is the name that is used by the script file
1.940 + iTestStepName = aTestName;
1.941 + }
1.942 +
1.943 +/**
1.944 + *
1.945 + * Test step destructor.
1.946 + *
1.947 + *
1.948 + */
1.949 +CTestStepDevVideoRecordAllocFail::~CTestStepDevVideoRecordAllocFail()
1.950 + {
1.951 + }
1.952 +
1.953 +// MMMFDevVideoRecordObserver
1.954 +void CTestStepDevVideoRecordAllocFail::MdvroNewBuffers()
1.955 + {
1.956 + INFO_PRINTF1(_L("CTestStepDevVideoRecordAllocFail::MdvroNewBuffers()"));
1.957 + }
1.958 +
1.959 +void CTestStepDevVideoRecordAllocFail::MdvroReturnPicture(TVideoPicture* /*aPicture*/)
1.960 + {
1.961 + INFO_PRINTF1(_L("CTestStepDevVideoRecordAllocFail::MdvroReturnPicture()"));
1.962 + }
1.963 +
1.964 +void CTestStepDevVideoRecordAllocFail::MdvroSupplementalInfoSent()
1.965 + {
1.966 + INFO_PRINTF1(_L("CTestStepDevVideoRecordAllocFail::MdvroSupplementalInfoSent()"));
1.967 + }
1.968 +
1.969 +void CTestStepDevVideoRecordAllocFail::MdvroFatalError(TInt aError)
1.970 + {
1.971 + iError = aError;
1.972 + INFO_PRINTF2(_L("CTestStepDevVideoRecordAllocFail::MdvroFatalError()\nError = %d"), aError);
1.973 + }
1.974 +
1.975 +void CTestStepDevVideoRecordAllocFail::MdvroInitializeComplete(TInt aError)
1.976 + {
1.977 + iError = aError;
1.978 + INFO_PRINTF2(_L("CTestStepDevVideoRecordAllocFail::MdvroInitializeComplete(): Error = %d"), aError);
1.979 + }
1.980 +
1.981 +void CTestStepDevVideoRecordAllocFail::MdvroStreamEnd()
1.982 + {
1.983 + INFO_PRINTF1(_L("CTestStepDevVideoRecordAllocFail::MdvroStreamEnd()"));
1.984 + }
1.985 +
1.986 +/**
1.987 + *
1.988 + * Do the test step.
1.989 + * Each test step must supply an implementation for DoTestStepL.
1.990 + *
1.991 + * @return "TVerdict"
1.992 + * The result of the test step
1.993 + *
1.994 + */
1.995 +TVerdict CTestStepDevVideoRecordAllocFail::DoTestStepL()
1.996 + {
1.997 + TVerdict ret = EFail;
1.998 +
1.999 + // call alloc test step
1.1000 + ret = DoTestL();
1.1001 +
1.1002 + return ret;
1.1003 + }
1.1004 +
1.1005 +//----------------------------------------------------------------------------
1.1006 +
1.1007 +CTestStepDevVideoRecordAllocFailNew::CTestStepDevVideoRecordAllocFailNew(const TDesC& aTestName)
1.1008 + :CTestStepDevVideoRecordAllocFail(aTestName)
1.1009 + {
1.1010 + }
1.1011 +
1.1012 +CTestStepDevVideoRecordAllocFailNew* CTestStepDevVideoRecordAllocFailNew::NewL(const TDesC& aTestName)
1.1013 + {
1.1014 + CTestStepDevVideoRecordAllocFailNew* self = new(ELeave) CTestStepDevVideoRecordAllocFailNew(aTestName);
1.1015 + return self;
1.1016 + }
1.1017 +
1.1018 +CTestStepDevVideoRecordAllocFailNew::~CTestStepDevVideoRecordAllocFailNew()
1.1019 + {
1.1020 + }
1.1021 +
1.1022 +TVerdict CTestStepDevVideoRecordAllocFailNew::DoTestL()
1.1023 + {
1.1024 + iTestStepResult = EPass;
1.1025 + TInt err = KErrNone;
1.1026 +
1.1027 + // Printing to the console and log file
1.1028 + INFO_PRINTF1(_L("this is an Alloc Failure test of initialising CMMFDevVideoRecord with NewL()"));
1.1029 +
1.1030 + __MM_HEAP_MARK;
1.1031 + TRAP( err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this) );
1.1032 + delete iDevVideoRecord;
1.1033 + iDevVideoRecord = NULL;
1.1034 + __MM_HEAP_MARKEND;
1.1035 +
1.1036 + if (err != KErrNone)
1.1037 + return EFail;
1.1038 +
1.1039 + TInt failCount = 1;
1.1040 + TBool completed = EFalse;
1.1041 + TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1.1042 + for(;;)
1.1043 + {
1.1044 + __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
1.1045 + __MM_HEAP_MARK;
1.1046 +
1.1047 + TRAP( err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this);
1.1048 + iDevVideoRecord->SelectEncoderL(KUidDevVideoTestEncodeHwDevice);
1.1049 + iDevVideoRecord->SelectPreProcessorL(KUidDevVideoTestPreProcHwDevice); );
1.1050 +
1.1051 + completed = EFalse;
1.1052 + if (err == KErrNone)
1.1053 + {
1.1054 + TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1.1055 + if (testAlloc==NULL)
1.1056 + {
1.1057 + reachedEnd = ETrue;
1.1058 + failCount--; // -= 1;
1.1059 + }
1.1060 + else
1.1061 + User::Free(testAlloc);
1.1062 +
1.1063 + }
1.1064 + else if (err != KErrNoMemory) // bad error code
1.1065 + completed = ETrue;
1.1066 +
1.1067 + // see if valid result and break if wrong - might be premature result
1.1068 + if (iDevVideoRecord)
1.1069 + {
1.1070 + delete iDevVideoRecord;
1.1071 + iDevVideoRecord = NULL;
1.1072 + }
1.1073 + completed = reachedEnd;
1.1074 + __MM_HEAP_MARKEND;
1.1075 + __UHEAP_SETFAIL(RHeap::ENone ,0);
1.1076 +
1.1077 + if (completed)
1.1078 + break; // exit loop
1.1079 +
1.1080 + failCount++;
1.1081 + }
1.1082 +
1.1083 + if (err != KErrNone)
1.1084 + {
1.1085 + INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
1.1086 + iTestStepResult = EFail;
1.1087 + }
1.1088 + else
1.1089 + {
1.1090 + INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
1.1091 + iTestStepResult = EPass;
1.1092 + }
1.1093 +
1.1094 + if (iDevVideoRecord)
1.1095 + {
1.1096 + delete iDevVideoRecord;
1.1097 + iDevVideoRecord = NULL;
1.1098 + }
1.1099 +
1.1100 + INFO_PRINTF1(_L("finished with this test step"));
1.1101 + // test steps return a result
1.1102 + return iTestStepResult;
1.1103 + }
1.1104 +
1.1105 +//----------------------------------------------------------------------------
1.1106 +
1.1107 +CTestStepDevVideoRecordAllocFailInfoEncoder::CTestStepDevVideoRecordAllocFailInfoEncoder(const TDesC& aTestName)
1.1108 + :CTestStepDevVideoRecordAllocFail(aTestName)
1.1109 + {
1.1110 + }
1.1111 +
1.1112 +CTestStepDevVideoRecordAllocFailInfoEncoder* CTestStepDevVideoRecordAllocFailInfoEncoder::NewL(const TDesC& aTestName)
1.1113 + {
1.1114 + CTestStepDevVideoRecordAllocFailInfoEncoder* self = new(ELeave) CTestStepDevVideoRecordAllocFailInfoEncoder(aTestName);
1.1115 + return self;
1.1116 + }
1.1117 +
1.1118 +CTestStepDevVideoRecordAllocFailInfoEncoder::~CTestStepDevVideoRecordAllocFailInfoEncoder()
1.1119 + {
1.1120 + }
1.1121 +
1.1122 +TVerdict CTestStepDevVideoRecordAllocFailInfoEncoder::DoTestL()
1.1123 + {
1.1124 + iTestStepResult = EPass;
1.1125 + TInt err = KErrNone;
1.1126 +
1.1127 + // Printing to the console and log file
1.1128 + INFO_PRINTF1(_L("this is an Alloc Failure test of VideoEncoderInfoLC()"));
1.1129 +
1.1130 + // moved creation and destruction of iDevVideoRecord inside the heap marks.
1.1131 + // reason :- VideoEncoderInfoLC may allocate onto it
1.1132 +
1.1133 + TInt failCount = 1;
1.1134 + TBool completed = EFalse;
1.1135 + TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1.1136 + for(;;)
1.1137 + {
1.1138 + __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
1.1139 + __MM_HEAP_MARK;
1.1140 +
1.1141 + TRAP (err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this));
1.1142 +
1.1143 + if (err == KErrNone)
1.1144 + {
1.1145 + CVideoEncoderInfo* vidInfo = NULL;
1.1146 +
1.1147 + TRAP( err, vidInfo = iDevVideoRecord->VideoEncoderInfoLC(KUidDevVideoTestEncodeHwDevice);
1.1148 + CleanupStack::Pop(vidInfo); );
1.1149 +
1.1150 + completed = EFalse;
1.1151 + if (err == KErrNone)
1.1152 + {
1.1153 + TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1.1154 + if (testAlloc==NULL)
1.1155 + {
1.1156 + reachedEnd = ETrue;
1.1157 + failCount--; // -= 1;
1.1158 + }
1.1159 + else
1.1160 + User::Free(testAlloc);
1.1161 +
1.1162 + }
1.1163 + else if (err != KErrNoMemory) // bad error code
1.1164 + completed = ETrue;
1.1165 +
1.1166 + // see if valid result and break if wrong - might be premature result
1.1167 +
1.1168 + if (vidInfo)
1.1169 + {
1.1170 + delete vidInfo;
1.1171 + vidInfo = NULL;
1.1172 + }
1.1173 + }
1.1174 + else if (err != KErrNoMemory) // bad error code
1.1175 + completed = ETrue;
1.1176 +
1.1177 + if (iDevVideoRecord)
1.1178 + {
1.1179 + delete iDevVideoRecord;
1.1180 + iDevVideoRecord = NULL;
1.1181 + }
1.1182 +
1.1183 + completed = reachedEnd;
1.1184 +
1.1185 + __MM_HEAP_MARKEND;
1.1186 + __UHEAP_SETFAIL(RHeap::ENone ,0);
1.1187 +
1.1188 + if (completed)
1.1189 + break; // exit loop
1.1190 +
1.1191 + failCount++;
1.1192 + }
1.1193 +
1.1194 + if (err != KErrNone)
1.1195 + {
1.1196 + INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
1.1197 + iTestStepResult = EFail;
1.1198 + }
1.1199 + else
1.1200 + {
1.1201 + INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
1.1202 + iTestStepResult = EPass;
1.1203 + }
1.1204 +
1.1205 + INFO_PRINTF1(_L("finished with this test step"));
1.1206 + // test steps return a result
1.1207 + return iTestStepResult;
1.1208 + }
1.1209 +
1.1210 +//----------------------------------------------------------------------------
1.1211 +
1.1212 +CTestStepDevVideoRecordAllocFailInfoPreProc::CTestStepDevVideoRecordAllocFailInfoPreProc(const TDesC& aTestName)
1.1213 + :CTestStepDevVideoRecordAllocFail(aTestName)
1.1214 + {
1.1215 + }
1.1216 +
1.1217 +CTestStepDevVideoRecordAllocFailInfoPreProc* CTestStepDevVideoRecordAllocFailInfoPreProc::NewL(const TDesC& aTestName)
1.1218 + {
1.1219 + CTestStepDevVideoRecordAllocFailInfoPreProc* self = new(ELeave) CTestStepDevVideoRecordAllocFailInfoPreProc(aTestName);
1.1220 + return self;
1.1221 + }
1.1222 +
1.1223 +CTestStepDevVideoRecordAllocFailInfoPreProc::~CTestStepDevVideoRecordAllocFailInfoPreProc()
1.1224 + {
1.1225 + }
1.1226 +
1.1227 +TVerdict CTestStepDevVideoRecordAllocFailInfoPreProc::DoTestL()
1.1228 + {
1.1229 + iTestStepResult = EPass;
1.1230 + TInt err = KErrNone;
1.1231 +
1.1232 + // Printing to the console and log file
1.1233 + INFO_PRINTF1(_L("this is an Alloc Failure test of PreProcessorInfoLC()"));
1.1234 +
1.1235 + // will leave on error
1.1236 + TRAP (err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this));
1.1237 +
1.1238 + if (err != KErrNone)
1.1239 + {
1.1240 + ERR_PRINTF1(_L("Error - Couldn't construct CMMFDevVideoRecord!"));
1.1241 + return EInconclusive;
1.1242 + }
1.1243 +
1.1244 + CPreProcessorInfo* preInfo = NULL;
1.1245 +
1.1246 + TInt failCount = 1;
1.1247 + TBool completed = EFalse;
1.1248 + TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1.1249 + for(;;)
1.1250 + {
1.1251 + __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
1.1252 + __MM_HEAP_MARK;
1.1253 +
1.1254 + TRAP( err, preInfo = iDevVideoRecord->PreProcessorInfoLC(KUidDevVideoTestPreProcHwDevice);
1.1255 + CleanupStack::Pop(preInfo); );
1.1256 +
1.1257 + REComSession::FinalClose();
1.1258 +
1.1259 + completed = EFalse;
1.1260 + if (err == KErrNone)
1.1261 + {
1.1262 + TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1.1263 + if (testAlloc==NULL)
1.1264 + {
1.1265 + reachedEnd = ETrue;
1.1266 + failCount--; // -= 1;
1.1267 + }
1.1268 + else
1.1269 + User::Free(testAlloc);
1.1270 +
1.1271 + }
1.1272 + else if (err != KErrNoMemory) // bad error code
1.1273 + completed = ETrue;
1.1274 +
1.1275 + // see if valid result and break if wrong - might be premature result
1.1276 +
1.1277 + if (preInfo)
1.1278 + {
1.1279 + delete preInfo;
1.1280 + preInfo = NULL;
1.1281 + }
1.1282 +
1.1283 + completed = reachedEnd;
1.1284 +
1.1285 + __MM_HEAP_MARKEND;
1.1286 + __UHEAP_SETFAIL(RHeap::ENone ,0);
1.1287 +
1.1288 + if (completed)
1.1289 + break; // exit loop
1.1290 +
1.1291 + failCount++;
1.1292 + }
1.1293 +
1.1294 + if (err != KErrNone)
1.1295 + {
1.1296 + INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
1.1297 + iTestStepResult = EFail;
1.1298 + }
1.1299 + else
1.1300 + {
1.1301 + INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
1.1302 + iTestStepResult = EPass;
1.1303 + }
1.1304 +
1.1305 + if (iDevVideoRecord)
1.1306 + {
1.1307 + delete iDevVideoRecord;
1.1308 + iDevVideoRecord = NULL;
1.1309 + }
1.1310 +
1.1311 + INFO_PRINTF1(_L("finished with this test step"));
1.1312 + // test steps return a result
1.1313 + return iTestStepResult;
1.1314 + }
1.1315 +
1.1316 +//----------------------------------------------------------------------------
1.1317 +
1.1318 +
1.1319 +CTestStepDevVideoRecordAllocFailFindPlugins::CTestStepDevVideoRecordAllocFailFindPlugins(const TDesC& aTestName)
1.1320 + :CTestStepDevVideoRecordAllocFail(aTestName)
1.1321 + {
1.1322 + }
1.1323 +
1.1324 +CTestStepDevVideoRecordAllocFailFindPlugins* CTestStepDevVideoRecordAllocFailFindPlugins::NewL(const TDesC& aTestName)
1.1325 + {
1.1326 + CTestStepDevVideoRecordAllocFailFindPlugins* self = new(ELeave) CTestStepDevVideoRecordAllocFailFindPlugins(aTestName);
1.1327 + return self;
1.1328 + }
1.1329 +
1.1330 +CTestStepDevVideoRecordAllocFailFindPlugins::~CTestStepDevVideoRecordAllocFailFindPlugins()
1.1331 + {
1.1332 + }
1.1333 +
1.1334 +TVerdict CTestStepDevVideoRecordAllocFailFindPlugins::DoTestL()
1.1335 + {
1.1336 + iTestStepResult = EPass;
1.1337 + TInt err = KErrNone;
1.1338 +
1.1339 + // Printing to the console and log file
1.1340 + INFO_PRINTF1(_L("this is an Alloc Failure test of finding Encoder and Pre processor plugins"));
1.1341 +
1.1342 +
1.1343 + TInt failCount = 1;
1.1344 + TBool completed = EFalse;
1.1345 + TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1.1346 + for(;;)
1.1347 + {
1.1348 + __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
1.1349 + __MM_HEAP_MARK;
1.1350 +
1.1351 + err = KErrNone;
1.1352 +
1.1353 + if (!err)
1.1354 + TRAP(err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this));
1.1355 + if (!err)
1.1356 + TRAP(err, GetEncodersL());
1.1357 + if (!err)
1.1358 + TRAP(err, GetPreProcessorsL());
1.1359 + if (!err)
1.1360 + TRAP(err, FindEncodersL());
1.1361 + if (!err)
1.1362 + TRAP(err, FindPreProcessorsL());
1.1363 +
1.1364 + REComSession::FinalClose();
1.1365 +
1.1366 + completed = EFalse;
1.1367 + if (err == KErrNone)
1.1368 + {
1.1369 + TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1.1370 + if (testAlloc==NULL)
1.1371 + {
1.1372 + reachedEnd = ETrue;
1.1373 + failCount--; // -= 1;
1.1374 + }
1.1375 + else
1.1376 + User::Free(testAlloc);
1.1377 +
1.1378 + }
1.1379 + else if (err != KErrNoMemory) // bad error code
1.1380 + completed = ETrue;
1.1381 +
1.1382 + // see if valid result and break if wrong - might be premature result
1.1383 + delete iDevVideoRecord;
1.1384 + iDevVideoRecord = NULL;
1.1385 +
1.1386 + __MM_HEAP_MARKEND;
1.1387 + __UHEAP_SETFAIL(RHeap::ENone ,0);
1.1388 +
1.1389 + if (completed || reachedEnd)
1.1390 + break; // exit loop
1.1391 +
1.1392 + failCount++;
1.1393 + }
1.1394 +
1.1395 + if (err != KErrNone)
1.1396 + {
1.1397 + INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
1.1398 + iTestStepResult = EFail;
1.1399 + }
1.1400 + else
1.1401 + {
1.1402 + INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
1.1403 + iTestStepResult = EPass;
1.1404 + }
1.1405 +
1.1406 + delete iDevVideoRecord;
1.1407 + iDevVideoRecord = NULL;
1.1408 +
1.1409 + INFO_PRINTF1(_L("finished with this test step"));
1.1410 + // test steps return a result
1.1411 + return iTestStepResult;
1.1412 + }
1.1413 +
1.1414 +void CTestStepDevVideoRecordAllocFailFindPlugins::CheckPluginsL(const RArray<TUid>& aFoundPlugins, const RArray<TUid>& aExpectedPlugins, const RArray<TUid>& aUnExpectedPlugins)
1.1415 + {
1.1416 + TBool foundUnExpected = EFalse;
1.1417 + TInt numberToBeFoundInExpectedPlugins = aExpectedPlugins.Count();
1.1418 +
1.1419 + for (TInt i=0; i<aFoundPlugins.Count(); i++)
1.1420 + {
1.1421 + TUid uidToLookFor = aFoundPlugins[i];
1.1422 + TInt j;
1.1423 + for (j=0; j<aExpectedPlugins.Count(); j++)
1.1424 + {
1.1425 + if (aExpectedPlugins[j] == uidToLookFor)
1.1426 + {
1.1427 + numberToBeFoundInExpectedPlugins--;
1.1428 + break;//j
1.1429 + }
1.1430 + }
1.1431 + for (j=0; j<aUnExpectedPlugins.Count(); j++)
1.1432 + {
1.1433 + if (aUnExpectedPlugins[j] == uidToLookFor)
1.1434 + {
1.1435 + foundUnExpected = ETrue;
1.1436 + break;//j
1.1437 + }
1.1438 + }
1.1439 + }
1.1440 +
1.1441 + if ((foundUnExpected) || (numberToBeFoundInExpectedPlugins!=0))
1.1442 + User::Leave(KErrGeneral);
1.1443 +
1.1444 + }
1.1445 +
1.1446 +
1.1447 +void CTestStepDevVideoRecordAllocFailFindPlugins::FindEncodersL()
1.1448 + {
1.1449 + RArray<TUid> foundEncoders;
1.1450 + CleanupClosePushL(foundEncoders);
1.1451 + RArray<TUid> expectedEncoders;
1.1452 + CleanupClosePushL(expectedEncoders);
1.1453 + RArray<TUid> unExpectedEncoders;
1.1454 + CleanupClosePushL(unExpectedEncoders);
1.1455 +
1.1456 +
1.1457 + // Supported mime type and Pre proc type (by exact match)
1.1458 + _LIT8(KMimeType5, "video/zippyvideo");
1.1459 + TUint32 requestedPreProcType = EPpMirror|EPpInputCrop;
1.1460 + foundEncoders.Reset();
1.1461 + expectedEncoders.Reset();
1.1462 + unExpectedEncoders.Reset();
1.1463 + User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice1));
1.1464 + User::LeaveIfError(unExpectedEncoders.Append(KUidDevVideoTestEncodeHwDevice2));
1.1465 + User::LeaveIfError(unExpectedEncoders.Append(KUidDevVideoTestEncodeHwDevice3));
1.1466 + User::LeaveIfError(unExpectedEncoders.Append(KUidDevVideoTestEncodeHwDevice4));
1.1467 + User::LeaveIfError(unExpectedEncoders.Append(KUidDevVideoTestEncodeHwDevice5));
1.1468 +
1.1469 + iDevVideoRecord->FindEncodersL(KMimeType5(), requestedPreProcType, foundEncoders, ETrue);
1.1470 + CheckPluginsL(foundEncoders, expectedEncoders, unExpectedEncoders);
1.1471 +
1.1472 + CleanupStack::PopAndDestroy(3);
1.1473 + }
1.1474 +
1.1475 +void CTestStepDevVideoRecordAllocFailFindPlugins::FindPreProcessorsL()
1.1476 + {
1.1477 + RArray<TUid> foundPreProx;
1.1478 + CleanupClosePushL(foundPreProx);
1.1479 + RArray<TUid> expectedPreProx;
1.1480 + CleanupClosePushL(expectedPreProx);
1.1481 + RArray<TUid> unExpectedPreProx;
1.1482 + CleanupClosePushL(unExpectedPreProx);
1.1483 +
1.1484 + TUint32 requestedPreProcType = EPpMirror|EPpInputCrop;
1.1485 + foundPreProx.Reset();
1.1486 + expectedPreProx.Reset();
1.1487 + User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice1));
1.1488 + User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice2));
1.1489 + User::LeaveIfError(unExpectedPreProx.Append(KUidDevVideoTestPreProcHwDevice3));
1.1490 + User::LeaveIfError(unExpectedPreProx.Append(KUidDevVideoTestPreProcHwDevice4));
1.1491 + User::LeaveIfError(unExpectedPreProx.Append(KUidDevVideoTestPreProcHwDevice5));
1.1492 +
1.1493 + iDevVideoRecord->FindPreProcessorsL(requestedPreProcType, foundPreProx);
1.1494 + CheckPluginsL(foundPreProx, expectedPreProx, unExpectedPreProx);
1.1495 +
1.1496 + CleanupStack::PopAndDestroy(3);
1.1497 + }
1.1498 +
1.1499 +void CTestStepDevVideoRecordAllocFailFindPlugins::GetEncodersL()
1.1500 + {
1.1501 + RArray<TUid> foundEncoders;
1.1502 + CleanupClosePushL(foundEncoders);
1.1503 + RArray<TUid> expectedEncoders;
1.1504 + CleanupClosePushL(expectedEncoders);
1.1505 + RArray<TUid> unExpectedEncoders;
1.1506 + CleanupClosePushL(unExpectedEncoders);
1.1507 +
1.1508 + User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice1));
1.1509 + User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice2));
1.1510 + User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice3));
1.1511 + User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice4));
1.1512 + User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice5));
1.1513 +
1.1514 + iDevVideoRecord->GetEncoderListL(foundEncoders);
1.1515 +
1.1516 + CheckPluginsL(foundEncoders, expectedEncoders, unExpectedEncoders);
1.1517 +
1.1518 + CleanupStack::PopAndDestroy(3); //foundEncoders, expectedEncoders, unExpectedEncoders
1.1519 + }
1.1520 +
1.1521 +void CTestStepDevVideoRecordAllocFailFindPlugins::GetPreProcessorsL()
1.1522 + {
1.1523 + RArray<TUid> foundPreProx;
1.1524 + CleanupClosePushL(foundPreProx);
1.1525 + RArray<TUid> expectedPreProx;
1.1526 + CleanupClosePushL(expectedPreProx);
1.1527 + RArray<TUid> unExpectedPreProx;
1.1528 + CleanupClosePushL(unExpectedPreProx);
1.1529 +
1.1530 + User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice1));
1.1531 + User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice2));
1.1532 + User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice3));
1.1533 + User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice4));
1.1534 + User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice5));
1.1535 +
1.1536 + iDevVideoRecord->GetPreProcessorListL(foundPreProx);
1.1537 +
1.1538 + CheckPluginsL(foundPreProx, expectedPreProx, unExpectedPreProx);
1.1539 +
1.1540 + CleanupStack::PopAndDestroy(3);//foundPreProx, expectedPreProx, unExpectedPreProx
1.1541 + }
1.1542 +
1.1543 +//----------------------------------------------------------------------------
1.1544 +
1.1545 +
1.1546 +CTestStepDevVideoRecordAllocFailGetBuffers::CTestStepDevVideoRecordAllocFailGetBuffers(const TDesC& aTestName)
1.1547 + :CTestStepDevVideoRecordAllocFail(aTestName)
1.1548 + {
1.1549 + }
1.1550 +
1.1551 +CTestStepDevVideoRecordAllocFailGetBuffers* CTestStepDevVideoRecordAllocFailGetBuffers::NewL(const TDesC& aTestName)
1.1552 + {
1.1553 + CTestStepDevVideoRecordAllocFailGetBuffers* self = new(ELeave) CTestStepDevVideoRecordAllocFailGetBuffers(aTestName);
1.1554 + return self;
1.1555 + }
1.1556 +
1.1557 +CTestStepDevVideoRecordAllocFailGetBuffers::~CTestStepDevVideoRecordAllocFailGetBuffers()
1.1558 + {
1.1559 + }
1.1560 +
1.1561 +TVerdict CTestStepDevVideoRecordAllocFailGetBuffers::DoTestL()
1.1562 + {
1.1563 + iTestStepResult = EPass;
1.1564 + TInt err = KErrNone;
1.1565 +
1.1566 + // Printing to the console and log file
1.1567 + INFO_PRINTF1(_L("this is an Alloc Failure test of retrieving and returning Buffers to the plugin"));
1.1568 +
1.1569 +
1.1570 + TInt failCount = 1;
1.1571 + TBool completed = EFalse;
1.1572 + TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1.1573 + for(;;)
1.1574 + {
1.1575 + __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
1.1576 + __MM_HEAP_MARK;
1.1577 +
1.1578 + TRAP(err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this));
1.1579 + if (!err)
1.1580 + TRAP(err, PerformTestL());
1.1581 +
1.1582 + REComSession::FinalClose();
1.1583 +
1.1584 + completed = EFalse;
1.1585 + if (err == KErrNone)
1.1586 + {
1.1587 + TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1.1588 + if (testAlloc==NULL)
1.1589 + {
1.1590 + reachedEnd = ETrue;
1.1591 + failCount--; // -= 1;
1.1592 + }
1.1593 + else
1.1594 + User::Free(testAlloc);
1.1595 +
1.1596 + }
1.1597 + else if (err != KErrNoMemory) // bad error code
1.1598 + completed = ETrue;
1.1599 +
1.1600 + // see if valid result and break if wrong - might be premature result
1.1601 + delete iDevVideoRecord;
1.1602 + iDevVideoRecord = NULL;
1.1603 +
1.1604 + __MM_HEAP_MARKEND;
1.1605 + __UHEAP_SETFAIL(RHeap::ENone ,0);
1.1606 +
1.1607 + if (completed || reachedEnd)
1.1608 + break; // exit loop
1.1609 +
1.1610 + failCount++;
1.1611 + }
1.1612 +
1.1613 + if (err != KErrNone)
1.1614 + {
1.1615 + INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
1.1616 + iTestStepResult = EFail;
1.1617 + }
1.1618 + else
1.1619 + {
1.1620 + INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
1.1621 + iTestStepResult = EPass;
1.1622 + }
1.1623 +
1.1624 + delete iDevVideoRecord;
1.1625 + iDevVideoRecord = NULL;
1.1626 +
1.1627 + INFO_PRINTF1(_L("finished with this test step"));
1.1628 + // test steps return a result
1.1629 + return iTestStepResult;
1.1630 + }
1.1631 +
1.1632 +
1.1633 +void CTestStepDevVideoRecordAllocFailGetBuffers::PerformTestL()
1.1634 + {
1.1635 + iTestError = KErrNone;
1.1636 +
1.1637 + // select Encoder
1.1638 + iDevVideoRecord->SelectEncoderL(KUidDevVideoTestEncodeHwDevice);
1.1639 +
1.1640 + // select Pre-processor
1.1641 + iDevVideoRecord->SelectPreProcessorL(KUidDevVideoTestPreProcHwDevice);
1.1642 +
1.1643 + //Tell plugin to start creating Buffers.
1.1644 + iDevVideoRecord->SetImplementationSpecificEncoderOptionsL(KTestISEncBuffers);
1.1645 +
1.1646 + // initialize CDevVideoRecord and wait for response
1.1647 + iDevVideoRecord->Initialize();
1.1648 +
1.1649 + User::LeaveIfError(iTestError);
1.1650 +
1.1651 + iDevVideoRecord->Start();//Tell plugin to start creating Buffers.
1.1652 + // We should now get a series of NewBuffer() callbacks.
1.1653 +
1.1654 + User::LeaveIfError(iTestError);
1.1655 + }
1.1656 +
1.1657 +void CTestStepDevVideoRecordAllocFailGetBuffers::MdvpoInitComplete(TInt aError)
1.1658 + {
1.1659 + iTestError = aError;
1.1660 + }
1.1661 +
1.1662 +void CTestStepDevVideoRecordAllocFailGetBuffers::MdvpoNewBuffers()
1.1663 + {
1.1664 + TRAP(iTestError, DoNewBuffersL());
1.1665 + }
1.1666 +
1.1667 +void CTestStepDevVideoRecordAllocFailGetBuffers::CheckNewBufferInfoL(TUint aNumBuffers)
1.1668 + {
1.1669 + TUint numBuffers = 0;
1.1670 + numBuffers = iDevVideoRecord->NumDataBuffers();
1.1671 +
1.1672 + if (numBuffers != aNumBuffers)
1.1673 + {
1.1674 + User::Leave(KErrGeneral);
1.1675 + }
1.1676 + }
1.1677 +
1.1678 +void CTestStepDevVideoRecordAllocFailGetBuffers::DoNewBuffersL()
1.1679 + {
1.1680 + User::LeaveIfError(iTestError);//Don't go any further if we have an error
1.1681 + switch (iCurrentBufferNumber)
1.1682 + {
1.1683 + case 0:
1.1684 + {
1.1685 + iCurrentBufferNumber++;
1.1686 + CheckNewBufferInfoL(1);
1.1687 + TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
1.1688 + CheckNewBufferInfoL(0);
1.1689 + iDevVideoRecord->ReturnBuffer(buffer);
1.1690 + break;
1.1691 + }
1.1692 + case 1:
1.1693 + {
1.1694 + iCurrentBufferNumber++;
1.1695 + CheckNewBufferInfoL(1);
1.1696 + TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
1.1697 + CheckNewBufferInfoL(0);
1.1698 + iDevVideoRecord->ReturnBuffer(buffer);
1.1699 + break;
1.1700 + }
1.1701 + case 2:
1.1702 + {
1.1703 + iCurrentBufferNumber++;
1.1704 + CheckNewBufferInfoL(1);
1.1705 + TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
1.1706 + CheckNewBufferInfoL(0);
1.1707 + iDevVideoRecord->ReturnBuffer(buffer);
1.1708 + break;
1.1709 + }
1.1710 + case 3:
1.1711 + {
1.1712 + iCurrentBufferNumber++;
1.1713 + CheckNewBufferInfoL(1);
1.1714 + TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
1.1715 + iDevVideoRecord->ReturnBuffer(buffer);
1.1716 + break;
1.1717 + }
1.1718 + case 4:
1.1719 + {
1.1720 + iCurrentBufferNumber++;
1.1721 + CheckNewBufferInfoL(1);
1.1722 + TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
1.1723 + iDevVideoRecord->ReturnBuffer(buffer);
1.1724 + break;
1.1725 + }
1.1726 + case 5:
1.1727 + {
1.1728 + iCurrentBufferNumber++;
1.1729 + CheckNewBufferInfoL(1);
1.1730 + TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
1.1731 + iDevVideoRecord->ReturnBuffer(buffer);
1.1732 + break;
1.1733 + }
1.1734 + case 6:
1.1735 + {
1.1736 + iCurrentBufferNumber++;
1.1737 + CheckNewBufferInfoL(1);
1.1738 + break;
1.1739 + }
1.1740 + case 7:
1.1741 + {
1.1742 + iCurrentBufferNumber++;
1.1743 + CheckNewBufferInfoL(2);
1.1744 + break;
1.1745 + }
1.1746 + case 8:
1.1747 + {
1.1748 + iCurrentBufferNumber++;
1.1749 + CheckNewBufferInfoL(3);
1.1750 + break;
1.1751 + }
1.1752 + case 9:
1.1753 + {
1.1754 + iCurrentBufferNumber++;
1.1755 + CheckNewBufferInfoL(4);
1.1756 + TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
1.1757 + iDevVideoRecord->ReturnBuffer(buffer);
1.1758 + CheckNewBufferInfoL(3);
1.1759 + buffer = iDevVideoRecord->NextBufferL();
1.1760 + iDevVideoRecord->ReturnBuffer(buffer);
1.1761 + CheckNewBufferInfoL(2);
1.1762 + buffer = iDevVideoRecord->NextBufferL();
1.1763 + iDevVideoRecord->ReturnBuffer(buffer);
1.1764 + CheckNewBufferInfoL(1);
1.1765 + buffer = iDevVideoRecord->NextBufferL();
1.1766 + iDevVideoRecord->ReturnBuffer(buffer);
1.1767 + CheckNewBufferInfoL(0);
1.1768 + break;
1.1769 + }
1.1770 + default:
1.1771 + User::Leave(KErrGeneral);
1.1772 + break;
1.1773 + };
1.1774 + }
1.1775 +
1.1776 +