os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevVideo/src/TestStepDevVideoAllocFailNew.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // This file contains the implementation of the various 
    15 // ALLOC tests for DevVideo
    16 // 
    17 //
    18 
    19 // Test system includes
    20 #include <testframework.h>
    21 
    22 #include "TestDevVideoPlugins/decoder.h"
    23 #include "TestDevVideoPlugins/postproc.h"
    24 
    25 #include "TestDevVideoPlugins/encoder.h"
    26 #include "TestDevVideoPlugins/preproc.h"
    27 
    28 #include "TestStepDevVideoAllocFailNew.h"
    29 #include "TestDevVideoPlayTestData.h"
    30 
    31 
    32 // --------------------------------------------
    33 
    34 /**
    35  *
    36  * Test step constructor.
    37  * Each test step initialises its own name.
    38  *
    39  */
    40 CTestStepDevVideoPlayAllocFail::CTestStepDevVideoPlayAllocFail(const TDesC& aTestName)
    41 	{
    42 	// store the name of this test case
    43 	// this is the name that is used by the script file
    44 	iTestStepName = aTestName;
    45 	}
    46 
    47 /**
    48  *
    49  * Test step destructor.
    50  * 
    51  */
    52 CTestStepDevVideoPlayAllocFail::~CTestStepDevVideoPlayAllocFail()
    53 	{
    54 	}
    55 
    56 // MMMFDevVideoPlayObserver
    57 void CTestStepDevVideoPlayAllocFail::MdvpoNewBuffers()
    58 	{
    59 	INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoNewBuffers()"));
    60 	}
    61 
    62 void CTestStepDevVideoPlayAllocFail::MdvpoReturnPicture(TVideoPicture* /*aPicture*/)
    63 	{
    64 	INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoReturnPicture()"));
    65 	}
    66 
    67 void CTestStepDevVideoPlayAllocFail::MdvpoSupplementalInformation(const TDesC8& /*aData*/, 
    68 								  const TTimeIntervalMicroSeconds& /*aTimestamp*/, 
    69 								  const TPictureId& /*aPictureId*/)
    70 	{
    71 	INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoSupplementalInformation()"));
    72 	}
    73 
    74 void CTestStepDevVideoPlayAllocFail::MdvpoPictureLoss()
    75 	{
    76 	INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoPictureLoss()"));
    77 	}
    78 
    79 void CTestStepDevVideoPlayAllocFail::MdvpoPictureLoss(const TArray<TPictureId>& /*aPictures*/)
    80 	{
    81 	INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoPictureLoss(TArray)"));
    82 	}
    83 
    84 void CTestStepDevVideoPlayAllocFail::MdvpoSliceLoss(TUint /*aFirstMacroblock*/, TUint /*aNumMacroblocks*/, const TPictureId& /*aPicture*/)
    85 	{
    86 	INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoSliceLoss()"));
    87 	}
    88 
    89 void CTestStepDevVideoPlayAllocFail::MdvpoReferencePictureSelection(const TDesC8& /*aSelectionData*/)
    90 	{
    91 	INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoReferencePictureSelection()"));
    92 	}
    93 
    94 void CTestStepDevVideoPlayAllocFail::MdvpoTimedSnapshotComplete(TInt /*aError*/, 
    95 								TPictureData* /*aPictureData*/, 
    96 								const TTimeIntervalMicroSeconds& /*aPresentationTimestamp*/, 
    97 								const TPictureId& /*aPictureId*/)
    98 	{
    99 	INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoTimedSnapshotComplete()"));
   100 	}
   101 
   102 void CTestStepDevVideoPlayAllocFail::MdvpoNewPictures()
   103 	{
   104 	INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoNewPictures()"));
   105 	}
   106 
   107 void CTestStepDevVideoPlayAllocFail::MdvpoFatalError(TInt aError)
   108 	{
   109 	iError = aError;
   110 	INFO_PRINTF2(_L("CTestStepDevVideoPlayAllocFail::MdvpoFatalError()\nError = %d"), aError);
   111 	}
   112 
   113 void CTestStepDevVideoPlayAllocFail::MdvpoInitComplete(TInt aError)
   114 	{
   115 	iError = aError;
   116 	INFO_PRINTF2(_L("CTestStepDevVideoPlayAllocFail::MdvpoInitComplete():  Error = %d"), aError);
   117 	}
   118 
   119 void CTestStepDevVideoPlayAllocFail::MdvpoStreamEnd()
   120 	{
   121 	INFO_PRINTF1(_L("CTestStepDevVideoPlayAllocFail::MdvpoStreamEnd()"));
   122 	}
   123 
   124 /**
   125  *
   126  * Do the test step.
   127  * Each test step must supply an implementation for DoTestStepL.
   128  *
   129  * @return	"TVerdict"
   130  *			The result of the test step
   131  *
   132  */
   133 TVerdict CTestStepDevVideoPlayAllocFail::DoTestStepL()
   134 	{
   135 	TVerdict ret = EFail;
   136 
   137 	// do we want to do anything else in the base class?
   138 
   139 	// call alloc test step
   140 	ret = DoTestL();
   141 
   142 	return	ret;
   143 	}
   144 
   145 
   146 //----------------------------------------------------------------------------
   147 
   148 CTestStepDevVideoPlayAllocFailNew::CTestStepDevVideoPlayAllocFailNew(const TDesC& aTestName)
   149 	:CTestStepDevVideoPlayAllocFail(aTestName)
   150 	{
   151 	}
   152 
   153 CTestStepDevVideoPlayAllocFailNew* CTestStepDevVideoPlayAllocFailNew::NewL(const TDesC& aTestName)
   154 	{
   155 	CTestStepDevVideoPlayAllocFailNew* self = new(ELeave) CTestStepDevVideoPlayAllocFailNew(aTestName);
   156 	return self;
   157 	}
   158 
   159 CTestStepDevVideoPlayAllocFailNew::~CTestStepDevVideoPlayAllocFailNew()
   160 	{
   161 	}
   162 
   163 TVerdict CTestStepDevVideoPlayAllocFailNew::DoTestL()
   164 	{
   165 	iTestStepResult = EPass;
   166     TInt err       = KErrNone;
   167 
   168 	// Printing to the console and log file
   169 	INFO_PRINTF1(_L("this is an Alloc Failure test of initialising CMMFDevVideoPlay with NewL()"));
   170 
   171 	__UHEAP_MARK;
   172 	TRAP( err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this) );
   173 	delete iDevVideoPlay;
   174 	iDevVideoPlay = NULL;
   175 	__UHEAP_MARKEND;
   176 
   177 	if (err != KErrNone)
   178 		return EFail;
   179 
   180 	TInt failCount = 1;
   181 	TBool completed = EFalse;
   182 	TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
   183 	for(;;)	
   184 		{
   185 		__UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
   186 		__MM_HEAP_MARK;
   187 
   188 		TRAP( err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this);
   189 				   iDevVideoPlay->SelectDecoderL(KUidDevVideoTestDecodeHwDevice);
   190 				   iDevVideoPlay->SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice); );
   191 
   192 		completed = EFalse;
   193 		if (err == KErrNone)
   194 			{
   195 			TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
   196 			if (testAlloc==NULL)
   197 				{
   198 				reachedEnd = ETrue;
   199 				failCount--; // -= 1;
   200 				}
   201 			else
   202 				User::Free(testAlloc);
   203 			
   204 			}
   205 		else if (err != KErrNoMemory) // bad error code
   206 			completed = ETrue;
   207 
   208 		// see if valid result and break if wrong - might be premature result
   209 		if (iDevVideoPlay)
   210 			{
   211 			delete iDevVideoPlay;
   212 			iDevVideoPlay = NULL;
   213 			}
   214 		completed = reachedEnd;
   215 		__MM_HEAP_MARKEND;
   216 		__UHEAP_SETFAIL(RHeap::ENone ,0);
   217 
   218 		if (completed)
   219 			break; // exit loop
   220 
   221 		failCount++;
   222 		}
   223 
   224 	if (err != KErrNone)
   225 		{
   226 		INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
   227 		iTestStepResult = EFail;
   228 		}
   229 	else 
   230 		{
   231 		INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
   232 		iTestStepResult = EPass;
   233 		}
   234 
   235 	if (iDevVideoPlay)
   236 		{
   237 		delete iDevVideoPlay;
   238 		iDevVideoPlay = NULL;
   239 		}
   240 
   241 	INFO_PRINTF1(_L("finished with this test step"));
   242 	// test steps return a result
   243 	return iTestStepResult;
   244 	}
   245 
   246 //----------------------------------------------------------------------------
   247 
   248 
   249 CTestStepDevVideoPlayAllocFailFindPlugins::CTestStepDevVideoPlayAllocFailFindPlugins(const TDesC& aTestName)
   250 	:CTestStepDevVideoPlayAllocFail(aTestName)
   251 	{
   252 	}
   253 
   254 CTestStepDevVideoPlayAllocFailFindPlugins* CTestStepDevVideoPlayAllocFailFindPlugins::NewL(const TDesC& aTestName)
   255 	{
   256 	CTestStepDevVideoPlayAllocFailFindPlugins* self = new(ELeave) CTestStepDevVideoPlayAllocFailFindPlugins(aTestName);
   257 	return self;
   258 	}
   259 
   260 CTestStepDevVideoPlayAllocFailFindPlugins::~CTestStepDevVideoPlayAllocFailFindPlugins()
   261 	{
   262 	}
   263 
   264 TVerdict CTestStepDevVideoPlayAllocFailFindPlugins::DoTestL()
   265 	{
   266 	iTestStepResult = EPass;
   267     TInt err       = KErrNone;
   268 
   269 	// Printing to the console and log file
   270 	INFO_PRINTF1(_L("this is an Alloc Failure test of finding decoder and post processor plugins"));
   271 
   272 
   273 	TInt failCount = 1;
   274 	TBool completed = EFalse;
   275 	TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
   276 	for(;;)	
   277 		{
   278 		__UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
   279 		__MM_HEAP_MARK;
   280 
   281 		err = KErrNone;
   282 
   283 		if (!err)
   284 			TRAP(err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this));
   285 		if (!err)
   286 			TRAP(err, GetDecodersL());
   287 		if (!err)
   288 			TRAP(err, GetPostProcessorsL());
   289 		if (!err)
   290 			TRAP(err, FindDecodersL());
   291 		if (!err)
   292 			TRAP(err, FindPostProcessorsL());
   293 
   294 		REComSession::FinalClose();
   295 
   296 		completed = EFalse;
   297 		if (err == KErrNone)
   298 			{
   299 			TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
   300 			if (testAlloc==NULL)
   301 				{
   302 				reachedEnd = ETrue;
   303 				failCount--; // -= 1;
   304 				}
   305 			else
   306 				User::Free(testAlloc);
   307 			
   308 			}
   309 		else if (err != KErrNoMemory) // bad error code
   310 			completed = ETrue;
   311 
   312 		// see if valid result and break if wrong - might be premature result
   313 		delete iDevVideoPlay;
   314 		iDevVideoPlay = NULL;
   315 
   316 		__MM_HEAP_MARKEND;
   317 		__UHEAP_SETFAIL(RHeap::ENone ,0);
   318 
   319 		if (completed || reachedEnd)
   320 			break; // exit loop
   321 
   322 		failCount++;
   323 		}
   324 
   325 	if (err != KErrNone)
   326 		{
   327 		INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
   328 		iTestStepResult = EFail;
   329 		}
   330 	else 
   331 		{
   332 		INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
   333 		iTestStepResult = EPass;
   334 		}
   335 
   336 	delete iDevVideoPlay;
   337 	iDevVideoPlay = NULL;
   338 
   339 	INFO_PRINTF1(_L("finished with this test step"));
   340 	// test steps return a result
   341 	return iTestStepResult;
   342 	}
   343 
   344 void CTestStepDevVideoPlayAllocFailFindPlugins::CheckPluginsL(const RArray<TUid>& aFoundPlugins, const RArray<TUid>& aExpectedPlugins, const RArray<TUid>& aUnExpectedPlugins)
   345 	{
   346 	TBool foundUnExpected = EFalse;
   347 	TInt numberToBeFoundInExpectedPlugins = aExpectedPlugins.Count();
   348 
   349 	for (TInt i=0; i<aFoundPlugins.Count(); i++)
   350 		{
   351 		TUid uidToLookFor = aFoundPlugins[i];
   352 		TInt j;
   353 		for (j=0; j<aExpectedPlugins.Count(); j++)
   354 			{
   355 			if (aExpectedPlugins[j] == uidToLookFor)
   356 				{
   357 				numberToBeFoundInExpectedPlugins--;
   358 				break;//j
   359 				}
   360 			}
   361 		for (j=0; j<aUnExpectedPlugins.Count(); j++)
   362 			{
   363 			if (aUnExpectedPlugins[j] == uidToLookFor)
   364 				{
   365 				foundUnExpected = ETrue;
   366 				break;//j
   367 				}
   368 			}
   369 		}
   370 
   371 	if ((foundUnExpected) || (numberToBeFoundInExpectedPlugins!=0))
   372 		User::Leave(KErrGeneral);
   373 
   374 	}
   375 
   376 
   377 void CTestStepDevVideoPlayAllocFailFindPlugins::FindDecodersL()
   378 	{
   379 	RArray<TUid> foundDecoders;
   380 	CleanupClosePushL(foundDecoders);
   381 	RArray<TUid> expectedDecoders;
   382 	CleanupClosePushL(expectedDecoders);
   383 	RArray<TUid> unExpectedDecoders;
   384 	CleanupClosePushL(unExpectedDecoders);
   385 
   386 	
   387 	// Supported mime type and post proc type (by exact match)
   388 	_LIT8(KMimeType5, "video/zippyvideo");
   389 	TUint32 requestedPostProcType = EPpMirror|EPpInputCrop;
   390 	foundDecoders.Reset();
   391 	expectedDecoders.Reset();
   392 	unExpectedDecoders.Reset();
   393 	User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice1));
   394 	User::LeaveIfError(unExpectedDecoders.Append(KUidDevVideoTestDecodeHwDevice2));
   395 	User::LeaveIfError(unExpectedDecoders.Append(KUidDevVideoTestDecodeHwDevice3));
   396 	User::LeaveIfError(unExpectedDecoders.Append(KUidDevVideoTestDecodeHwDevice4));
   397 	User::LeaveIfError(unExpectedDecoders.Append(KUidDevVideoTestDecodeHwDevice5));
   398 
   399 	iDevVideoPlay->FindDecodersL(KMimeType5(), requestedPostProcType, foundDecoders, ETrue);
   400 	CheckPluginsL(foundDecoders, expectedDecoders, unExpectedDecoders);
   401 
   402 	CleanupStack::PopAndDestroy(3);
   403 	}
   404 
   405 void CTestStepDevVideoPlayAllocFailFindPlugins::FindPostProcessorsL()
   406 	{
   407 	RArray<TUid> foundPostProx;
   408 	CleanupClosePushL(foundPostProx);
   409 	RArray<TUid> expectedPostProx;
   410 	CleanupClosePushL(expectedPostProx);
   411 	RArray<TUid> unExpectedPostProx;
   412 	CleanupClosePushL(unExpectedPostProx);
   413 
   414 	TUint32	requestedPostProcType = EPpMirror|EPpInputCrop;
   415 	foundPostProx.Reset();
   416 	expectedPostProx.Reset();
   417 	User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice1));
   418 	User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice2));
   419 	User::LeaveIfError(unExpectedPostProx.Append(KUidDevVideoTestPostProcHwDevice3));
   420 	User::LeaveIfError(unExpectedPostProx.Append(KUidDevVideoTestPostProcHwDevice4));
   421 	User::LeaveIfError(unExpectedPostProx.Append(KUidDevVideoTestPostProcHwDevice5));
   422 
   423 	iDevVideoPlay->FindPostProcessorsL(requestedPostProcType, foundPostProx);
   424 	CheckPluginsL(foundPostProx, expectedPostProx, unExpectedPostProx);
   425 
   426 	CleanupStack::PopAndDestroy(3);
   427 	}
   428 
   429 void CTestStepDevVideoPlayAllocFailFindPlugins::GetDecodersL()
   430 	{
   431 	RArray<TUid> foundDecoders;
   432 	CleanupClosePushL(foundDecoders);
   433 	RArray<TUid> expectedDecoders;
   434 	CleanupClosePushL(expectedDecoders);
   435 	RArray<TUid> unExpectedDecoders;
   436 	CleanupClosePushL(unExpectedDecoders);
   437 
   438 	User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice1));
   439 	User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice2));
   440 	User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice3));
   441 	User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice4));
   442 	User::LeaveIfError(expectedDecoders.Append(KUidDevVideoTestDecodeHwDevice5));
   443 
   444 	iDevVideoPlay->GetDecoderListL(foundDecoders);
   445 
   446 	CheckPluginsL(foundDecoders, expectedDecoders, unExpectedDecoders);
   447 
   448 	CleanupStack::PopAndDestroy(3); //foundDecoders, expectedDecoders, unExpectedDecoders
   449 	}
   450 
   451 void CTestStepDevVideoPlayAllocFailFindPlugins::GetPostProcessorsL()
   452 	{
   453 	RArray<TUid> foundPostProx;
   454 	CleanupClosePushL(foundPostProx);
   455 	RArray<TUid> expectedPostProx;
   456 	CleanupClosePushL(expectedPostProx);
   457 	RArray<TUid> unExpectedPostProx;
   458 	CleanupClosePushL(unExpectedPostProx);
   459 
   460 	User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice1));
   461 	User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice2));
   462 	User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice3));
   463 	User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice4));
   464 	User::LeaveIfError(expectedPostProx.Append(KUidDevVideoTestPostProcHwDevice5));
   465 
   466 	iDevVideoPlay->GetPostProcessorListL(foundPostProx);
   467 
   468 	CheckPluginsL(foundPostProx, expectedPostProx, unExpectedPostProx);
   469 
   470 	CleanupStack::PopAndDestroy(3);//foundPostProx, expectedPostProx, unExpectedPostProx
   471 	}
   472 
   473 //----------------------------------------------------------------------------
   474 
   475 CTestStepDevVideoPlayAllocFailInfoDecoder::CTestStepDevVideoPlayAllocFailInfoDecoder(const TDesC& aTestName)
   476 	:CTestStepDevVideoPlayAllocFail(aTestName)
   477 	{
   478 	}
   479 
   480 CTestStepDevVideoPlayAllocFailInfoDecoder* CTestStepDevVideoPlayAllocFailInfoDecoder::NewL(const TDesC& aTestName)
   481 	{
   482 	CTestStepDevVideoPlayAllocFailInfoDecoder* self = new(ELeave) CTestStepDevVideoPlayAllocFailInfoDecoder(aTestName);
   483 	return self;
   484 	}
   485 
   486 CTestStepDevVideoPlayAllocFailInfoDecoder::~CTestStepDevVideoPlayAllocFailInfoDecoder()
   487 	{
   488 	}
   489 
   490 TVerdict CTestStepDevVideoPlayAllocFailInfoDecoder::DoTestL()
   491 	{
   492 	iTestStepResult = EPass;
   493     TInt err       = KErrNone;
   494 
   495 	// Printing to the console and log file
   496 	INFO_PRINTF1(_L("this is an Alloc Failure test of VideoDecoderInfoLC()"));
   497 
   498 	// moved creation and destruction of iDevVideoPlay inside the heap marks.
   499 	// reason :- VideoDecoderInfoLC may allocate onto it
   500 	
   501 	TInt failCount = 1;
   502 	TBool completed = EFalse;
   503 	TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
   504 	for(;;)	
   505 		{
   506 		__UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
   507 		__MM_HEAP_MARK;
   508 
   509 		TRAP (err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this));
   510 		if (err == KErrNone)
   511 			{
   512 
   513 			CVideoDecoderInfo* vidInfo = NULL;
   514 
   515 			TRAP( err, vidInfo = iDevVideoPlay->VideoDecoderInfoLC(KUidDevVideoTestDecodeHwDevice);
   516 					   CleanupStack::Pop(vidInfo); );
   517 
   518 			completed = EFalse;
   519 			if (err == KErrNone)
   520 				{
   521 				TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
   522 				if (testAlloc==NULL)
   523 					{
   524 					reachedEnd = ETrue;
   525 					failCount--; // -= 1;
   526 					}
   527 				else
   528 					User::Free(testAlloc);
   529 			
   530 				}
   531 			else if (err != KErrNoMemory) // bad error code
   532 				completed = ETrue;
   533 
   534 			// see if valid result and break if wrong - might be premature result
   535 		
   536 			if (vidInfo)
   537 				{
   538 				delete vidInfo;
   539 				vidInfo = NULL;
   540 				}
   541 			}
   542 		else if (err != KErrNoMemory) // bad error code
   543 			completed = ETrue;
   544 			
   545 		if (iDevVideoPlay)
   546 			{
   547 			delete iDevVideoPlay;
   548 			iDevVideoPlay = NULL;
   549 			}
   550 
   551 		completed = reachedEnd;
   552 
   553 		__MM_HEAP_MARKEND;
   554 		__UHEAP_SETFAIL(RHeap::ENone ,0);
   555 
   556 		if (completed)
   557 			break; // exit loop
   558 
   559 		failCount++;
   560 		}
   561 
   562 	if (err != KErrNone)
   563 		{
   564 		INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
   565 		iTestStepResult = EFail;
   566 		}
   567 	else 
   568 		{
   569 		INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
   570 		iTestStepResult = EPass;
   571 		}
   572 
   573 	INFO_PRINTF1(_L("finished with this test step"));
   574 	// test steps return a result
   575 	return iTestStepResult;
   576 	}
   577 
   578 
   579 //----------------------------------------------------------------------------
   580 
   581 CTestStepDevVideoPlayAllocFailInfoPostProc::CTestStepDevVideoPlayAllocFailInfoPostProc(const TDesC& aTestName)
   582 	:CTestStepDevVideoPlayAllocFail(aTestName)
   583 	{
   584 	}
   585 
   586 CTestStepDevVideoPlayAllocFailInfoPostProc* CTestStepDevVideoPlayAllocFailInfoPostProc::NewL(const TDesC& aTestName)
   587 	{
   588 	CTestStepDevVideoPlayAllocFailInfoPostProc* self = new(ELeave) CTestStepDevVideoPlayAllocFailInfoPostProc(aTestName);
   589 	return self;
   590 	}
   591 
   592 CTestStepDevVideoPlayAllocFailInfoPostProc::~CTestStepDevVideoPlayAllocFailInfoPostProc()
   593 	{
   594 	}
   595 
   596 TVerdict CTestStepDevVideoPlayAllocFailInfoPostProc::DoTestL()
   597 	{
   598 	iTestStepResult = EPass;
   599     TInt err       = KErrNone;
   600 
   601 	// Printing to the console and log file
   602 	INFO_PRINTF1(_L("this is an Alloc Failure test of PostProcessorInfoLC()"));
   603 
   604 	// will leave on error
   605 	TRAP (err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this));
   606 	
   607 	if (err != KErrNone)
   608 		{
   609 		ERR_PRINTF1(_L("Error - Couldn't construct CMMFDevVideoPlay!"));
   610 		return EInconclusive;
   611 		}
   612 
   613 	CPostProcessorInfo* postInfo = NULL;
   614 
   615 	TInt failCount = 1;
   616 	TBool completed = EFalse;
   617 	TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
   618 	for(;;)	
   619 		{
   620 		__UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
   621 		__MM_HEAP_MARK;
   622 
   623 		TRAP( err, postInfo = iDevVideoPlay->PostProcessorInfoLC(KUidDevVideoTestPostProcHwDevice);
   624 				   CleanupStack::Pop(postInfo); );
   625 
   626 		REComSession::FinalClose();
   627 
   628 		completed = EFalse;
   629 		if (err == KErrNone)
   630 			{
   631 			TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
   632 			if (testAlloc==NULL)
   633 				{
   634 				reachedEnd = ETrue;
   635 				failCount--; // -= 1;
   636 				}
   637 			else
   638 				User::Free(testAlloc);
   639 			
   640 			}
   641 		else if (err != KErrNoMemory) // bad error code
   642 			completed = ETrue;
   643 
   644 		// see if valid result and break if wrong - might be premature result
   645 		
   646 		if (postInfo)
   647 			{
   648 			delete postInfo;
   649 			postInfo = NULL;
   650 			}
   651 
   652 		completed = reachedEnd;
   653 
   654 		__MM_HEAP_MARKEND;
   655 		__UHEAP_SETFAIL(RHeap::ENone ,0);
   656 
   657 		if (completed)
   658 			break; // exit loop
   659 
   660 		failCount++;
   661 		}
   662 
   663 	if (err != KErrNone)
   664 		{
   665 		INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
   666 		iTestStepResult = EFail;
   667 		}
   668 	else 
   669 		{
   670 		INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
   671 		iTestStepResult = EPass;
   672 		}
   673 
   674 	if (iDevVideoPlay)
   675 		{
   676 		delete iDevVideoPlay;
   677 		iDevVideoPlay = NULL;
   678 		}
   679 
   680 	INFO_PRINTF1(_L("finished with this test step"));
   681 	// test steps return a result
   682 	return iTestStepResult;
   683 	}
   684 
   685 
   686 //----------------------------------------------------------------------------
   687 
   688 
   689 CTestStepDevVideoPlayAllocFailGetPictures::CTestStepDevVideoPlayAllocFailGetPictures(const TDesC& aTestName)
   690 	:CTestStepDevVideoPlayAllocFail(aTestName)
   691 	{
   692 	}
   693 
   694 CTestStepDevVideoPlayAllocFailGetPictures* CTestStepDevVideoPlayAllocFailGetPictures::NewL(const TDesC& aTestName)
   695 	{
   696 	CTestStepDevVideoPlayAllocFailGetPictures* self = new(ELeave) CTestStepDevVideoPlayAllocFailGetPictures(aTestName);
   697 	return self;
   698 	}
   699 
   700 CTestStepDevVideoPlayAllocFailGetPictures::~CTestStepDevVideoPlayAllocFailGetPictures()
   701 	{
   702 	}
   703 
   704 TVerdict CTestStepDevVideoPlayAllocFailGetPictures::DoTestL()
   705 	{
   706 	iTestStepResult = EPass;
   707     TInt err       = KErrNone;
   708 
   709 	// Printing to the console and log file
   710 	INFO_PRINTF1(_L("this is an Alloc Failure test of retrieving and returning pictures to the plugin"));
   711 
   712 
   713 	TInt failCount = 1;
   714 	TBool completed = EFalse;
   715 	TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
   716 	for(;;)	
   717 		{
   718 		__UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
   719 		__MM_HEAP_MARK;
   720 
   721 		TRAP(err, iDevVideoPlay = CMMFDevVideoPlay::NewL(*this));
   722 		if (!err)
   723 			TRAP(err, PerformTestL());
   724 
   725 		REComSession::FinalClose();
   726 
   727 		completed = EFalse;
   728 		if (err == KErrNone)
   729 			{
   730 			TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
   731 			if (testAlloc==NULL)
   732 				{
   733 				reachedEnd = ETrue;
   734 				failCount--; // -= 1;
   735 				}
   736 			else
   737 				User::Free(testAlloc);
   738 			
   739 			}
   740 		else if (err != KErrNoMemory) // bad error code
   741 			completed = ETrue;
   742 
   743 		// see if valid result and break if wrong - might be premature result
   744 		delete iDevVideoPlay;
   745 		iDevVideoPlay = NULL;
   746 
   747 		__MM_HEAP_MARKEND;
   748 		__UHEAP_SETFAIL(RHeap::ENone ,0);
   749 
   750 		if (completed || reachedEnd)
   751 			break; // exit loop
   752 
   753 		failCount++;
   754 		}
   755 
   756 	if (err != KErrNone)
   757 		{
   758 		INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
   759 		iTestStepResult = EFail;
   760 		}
   761 	else 
   762 		{
   763 		INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
   764 		iTestStepResult = EPass;
   765 		}
   766 
   767 	delete iDevVideoPlay;
   768 	iDevVideoPlay = NULL;
   769 
   770 	INFO_PRINTF1(_L("finished with this test step"));
   771 	// test steps return a result
   772 	return iTestStepResult;
   773 	}
   774 
   775 
   776 void CTestStepDevVideoPlayAllocFailGetPictures::PerformTestL()
   777 	{
   778 	iTestError = KErrNone;
   779 
   780 	// select decoder
   781 	iDevVideoPlay->SelectDecoderL(KUidDevVideoTestDecodeHwDevice);
   782 
   783 	// select post-processor
   784 	iDevVideoPlay->SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice);
   785 
   786 	//Tell plugin to start creating pictures.
   787 	iDevVideoPlay->SetVideoDestScreenL(EFalse);
   788 
   789 	// initialize CDevVideoPlay and wait for response
   790 	iDevVideoPlay->Initialize();
   791 
   792 	User::LeaveIfError(iTestError);
   793 
   794 	iDevVideoPlay->Start();//Tell plugin to start creating pictures.
   795 	// We should now get a series of NewPicture() callbacks.
   796 
   797 	User::LeaveIfError(iTestError);
   798 	}
   799 
   800 void CTestStepDevVideoPlayAllocFailGetPictures::MdvpoInitComplete(TInt aError)
   801 	{
   802 	iTestError = aError;
   803 	}
   804 
   805 void CTestStepDevVideoPlayAllocFailGetPictures::MdvpoNewPictures()
   806 	{
   807 	TRAP(iTestError, DoNewPicturesL());
   808 	}
   809 
   810 void CTestStepDevVideoPlayAllocFailGetPictures::CheckNewPictureInfoL(TUint aNumPictures, const TTimeIntervalMicroSeconds& aFirst, const TTimeIntervalMicroSeconds& aLast)
   811 	{
   812 	TUint numPictures = 0;
   813 	TTimeIntervalMicroSeconds first(0);
   814 	TTimeIntervalMicroSeconds last(0);
   815 	iDevVideoPlay->GetNewPictureInfo(numPictures, first, last);
   816 
   817 	if ((numPictures!=aNumPictures) || (first!=aFirst) || (last!=aLast))
   818 		{
   819 		User::Leave(KErrGeneral);
   820 		}
   821 	}
   822 
   823 void CTestStepDevVideoPlayAllocFailGetPictures::DoNewPicturesL()
   824 	{
   825 	User::LeaveIfError(iTestError);//Don't go any further if we have an error
   826 	switch (iCurrentPictureNumber)
   827 		{
   828 		case 0:
   829 			{
   830 			iCurrentPictureNumber++;
   831 			CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
   832 			TVideoPicture* picture = iDevVideoPlay->NextPictureL();
   833 			CheckNewPictureInfoL(0, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
   834 			iDevVideoPlay->ReturnPicture(picture);
   835 			break;
   836 			}
   837 		case 1:
   838 			{
   839 			iCurrentPictureNumber++;
   840 			CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(1), TTimeIntervalMicroSeconds(1));
   841 			TVideoPicture* picture = iDevVideoPlay->NextPictureL();
   842 			CheckNewPictureInfoL(0, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
   843 			iDevVideoPlay->ReturnPicture(picture);
   844 			break;
   845 			}
   846 		case 2:
   847 			{
   848 			iCurrentPictureNumber++;
   849 			CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(2), TTimeIntervalMicroSeconds(2));
   850 			TVideoPicture* picture = iDevVideoPlay->NextPictureL();
   851 			CheckNewPictureInfoL(0, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
   852 			iDevVideoPlay->ReturnPicture(picture);
   853 			break;
   854 			}
   855 		case 3:
   856 			{
   857 			iCurrentPictureNumber++;
   858 			CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(3), TTimeIntervalMicroSeconds(3));
   859 			TVideoPicture* picture = iDevVideoPlay->NextPictureL();
   860 			iDevVideoPlay->ReturnPicture(picture);
   861 			break;
   862 			}
   863 		case 4:
   864 			{
   865 			iCurrentPictureNumber++;
   866 			CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(4), TTimeIntervalMicroSeconds(4));
   867 			TVideoPicture* picture = iDevVideoPlay->NextPictureL();
   868 			iDevVideoPlay->ReturnPicture(picture);
   869 			break;
   870 			}
   871 		case 5:
   872 			{
   873 			iCurrentPictureNumber++;
   874 			CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(5), TTimeIntervalMicroSeconds(5));
   875 			TVideoPicture* picture = iDevVideoPlay->NextPictureL();
   876 			iDevVideoPlay->ReturnPicture(picture);
   877 			break;
   878 			}
   879 		case 6:
   880 			{
   881 			iCurrentPictureNumber++;
   882 			CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(6), TTimeIntervalMicroSeconds(6));
   883 			break;
   884 			}
   885 		case 7:
   886 			{
   887 			iCurrentPictureNumber++;
   888 			CheckNewPictureInfoL(2, TTimeIntervalMicroSeconds(6), TTimeIntervalMicroSeconds(7));
   889 			break;
   890 			}
   891 		case 8:
   892 			{
   893 			iCurrentPictureNumber++;
   894 			CheckNewPictureInfoL(3, TTimeIntervalMicroSeconds(6), TTimeIntervalMicroSeconds(8));
   895 			break;
   896 			}
   897 		case 9:
   898 			{
   899 			iCurrentPictureNumber++;
   900 			CheckNewPictureInfoL(4, TTimeIntervalMicroSeconds(6), TTimeIntervalMicroSeconds(9));
   901 			TVideoPicture* picture = iDevVideoPlay->NextPictureL();
   902 			iDevVideoPlay->ReturnPicture(picture);
   903 			CheckNewPictureInfoL(3, TTimeIntervalMicroSeconds(7), TTimeIntervalMicroSeconds(9));
   904 			picture = iDevVideoPlay->NextPictureL();
   905 			iDevVideoPlay->ReturnPicture(picture);
   906 			CheckNewPictureInfoL(2, TTimeIntervalMicroSeconds(8), TTimeIntervalMicroSeconds(9));
   907 			picture = iDevVideoPlay->NextPictureL();
   908 			iDevVideoPlay->ReturnPicture(picture);
   909 			CheckNewPictureInfoL(1, TTimeIntervalMicroSeconds(9), TTimeIntervalMicroSeconds(9));
   910 			picture = iDevVideoPlay->NextPictureL();
   911 			iDevVideoPlay->ReturnPicture(picture);
   912 			CheckNewPictureInfoL(0, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
   913 			break;
   914 			}
   915 		default:
   916 			User::Leave(KErrGeneral);
   917 			break;
   918 		};
   919 	}
   920 
   921 
   922 //----------------------------------------------------------------------------
   923 
   924 // DEVVIDEORECORD //
   925 
   926 /**
   927  *
   928  * Test step constructor.
   929  * Each test step initialises its own name.
   930  *
   931  * 
   932  */
   933 CTestStepDevVideoRecordAllocFail::CTestStepDevVideoRecordAllocFail(const TDesC& aTestName)
   934 	{
   935 	// store the name of this test case
   936 	// this is the name that is used by the script file
   937 	iTestStepName = aTestName;
   938 	}
   939 
   940 /**
   941  *
   942  * Test step destructor.
   943  *
   944  * 
   945  */
   946 CTestStepDevVideoRecordAllocFail::~CTestStepDevVideoRecordAllocFail()
   947 	{
   948 	}
   949 
   950 // MMMFDevVideoRecordObserver
   951 void CTestStepDevVideoRecordAllocFail::MdvroNewBuffers()
   952 	{
   953 	INFO_PRINTF1(_L("CTestStepDevVideoRecordAllocFail::MdvroNewBuffers()"));
   954 	}
   955 
   956 void CTestStepDevVideoRecordAllocFail::MdvroReturnPicture(TVideoPicture* /*aPicture*/)
   957 	{
   958 	INFO_PRINTF1(_L("CTestStepDevVideoRecordAllocFail::MdvroReturnPicture()"));
   959 	}
   960 
   961 void CTestStepDevVideoRecordAllocFail::MdvroSupplementalInfoSent()
   962 	{
   963 	INFO_PRINTF1(_L("CTestStepDevVideoRecordAllocFail::MdvroSupplementalInfoSent()"));
   964 	}
   965 
   966 void CTestStepDevVideoRecordAllocFail::MdvroFatalError(TInt aError)
   967 	{
   968 	iError = aError;
   969 	INFO_PRINTF2(_L("CTestStepDevVideoRecordAllocFail::MdvroFatalError()\nError = %d"), aError);
   970 	}
   971 
   972 void CTestStepDevVideoRecordAllocFail::MdvroInitializeComplete(TInt aError)
   973 	{
   974 	iError = aError;
   975 	INFO_PRINTF2(_L("CTestStepDevVideoRecordAllocFail::MdvroInitializeComplete():  Error = %d"), aError);
   976 	}
   977 
   978 void CTestStepDevVideoRecordAllocFail::MdvroStreamEnd()
   979 	{
   980 	INFO_PRINTF1(_L("CTestStepDevVideoRecordAllocFail::MdvroStreamEnd()"));
   981 	}
   982 
   983 /**
   984  *
   985  * Do the test step.
   986  * Each test step must supply an implementation for DoTestStepL.
   987  *
   988  * @return	"TVerdict"
   989  *			The result of the test step
   990  *
   991  */
   992 TVerdict CTestStepDevVideoRecordAllocFail::DoTestStepL()
   993 	{
   994 	TVerdict ret = EFail;
   995 
   996 	// call alloc test step
   997 	ret = DoTestL();
   998 
   999 	return	ret;
  1000 	}
  1001 
  1002 //----------------------------------------------------------------------------
  1003 
  1004 CTestStepDevVideoRecordAllocFailNew::CTestStepDevVideoRecordAllocFailNew(const TDesC& aTestName)
  1005 	:CTestStepDevVideoRecordAllocFail(aTestName)
  1006 	{
  1007 	}
  1008 
  1009 CTestStepDevVideoRecordAllocFailNew* CTestStepDevVideoRecordAllocFailNew::NewL(const TDesC& aTestName)
  1010 	{
  1011 	CTestStepDevVideoRecordAllocFailNew* self = new(ELeave) CTestStepDevVideoRecordAllocFailNew(aTestName);
  1012 	return self;
  1013 	}
  1014 
  1015 CTestStepDevVideoRecordAllocFailNew::~CTestStepDevVideoRecordAllocFailNew()
  1016 	{
  1017 	}
  1018 
  1019 TVerdict CTestStepDevVideoRecordAllocFailNew::DoTestL()
  1020 	{
  1021 	iTestStepResult = EPass;
  1022     TInt err       = KErrNone;
  1023 
  1024 	// Printing to the console and log file
  1025 	INFO_PRINTF1(_L("this is an Alloc Failure test of initialising CMMFDevVideoRecord with NewL()"));
  1026 
  1027 	__MM_HEAP_MARK;
  1028 	TRAP( err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this) );
  1029 	delete iDevVideoRecord;
  1030 	iDevVideoRecord = NULL;
  1031 	__MM_HEAP_MARKEND;
  1032 
  1033 	if (err != KErrNone)
  1034 		return EFail;
  1035 
  1036 	TInt failCount = 1;
  1037 	TBool completed = EFalse;
  1038 	TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
  1039 	for(;;)	
  1040 		{
  1041 		__UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
  1042 		__MM_HEAP_MARK;
  1043 
  1044 		TRAP( err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this);
  1045 				   iDevVideoRecord->SelectEncoderL(KUidDevVideoTestEncodeHwDevice);
  1046 				   iDevVideoRecord->SelectPreProcessorL(KUidDevVideoTestPreProcHwDevice); );
  1047 
  1048 		completed = EFalse;
  1049 		if (err == KErrNone)
  1050 			{
  1051 			TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
  1052 			if (testAlloc==NULL)
  1053 				{
  1054 				reachedEnd = ETrue;
  1055 				failCount--; // -= 1;
  1056 				}
  1057 			else
  1058 				User::Free(testAlloc);
  1059 			
  1060 			}
  1061 		else if (err != KErrNoMemory) // bad error code
  1062 			completed = ETrue;
  1063 
  1064 		// see if valid result and break if wrong - might be premature result
  1065 		if (iDevVideoRecord)
  1066 			{
  1067 			delete iDevVideoRecord;
  1068 			iDevVideoRecord = NULL;
  1069 			}
  1070 		completed = reachedEnd;
  1071 		__MM_HEAP_MARKEND;
  1072 		__UHEAP_SETFAIL(RHeap::ENone ,0);
  1073 
  1074 		if (completed)
  1075 			break; // exit loop
  1076 
  1077 		failCount++;
  1078 		}
  1079 
  1080 	if (err != KErrNone)
  1081 		{
  1082 		INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
  1083 		iTestStepResult = EFail;
  1084 		}
  1085 	else 
  1086 		{
  1087 		INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
  1088 		iTestStepResult = EPass;
  1089 		}
  1090 
  1091 	if (iDevVideoRecord)
  1092 		{
  1093 		delete iDevVideoRecord;
  1094 		iDevVideoRecord = NULL;
  1095 		}
  1096 
  1097 	INFO_PRINTF1(_L("finished with this test step"));
  1098 	// test steps return a result
  1099 	return iTestStepResult;
  1100 	}
  1101 
  1102 //----------------------------------------------------------------------------
  1103 
  1104 CTestStepDevVideoRecordAllocFailInfoEncoder::CTestStepDevVideoRecordAllocFailInfoEncoder(const TDesC& aTestName)
  1105 	:CTestStepDevVideoRecordAllocFail(aTestName)
  1106 	{
  1107 	}
  1108 
  1109 CTestStepDevVideoRecordAllocFailInfoEncoder* CTestStepDevVideoRecordAllocFailInfoEncoder::NewL(const TDesC& aTestName)
  1110 	{
  1111 	CTestStepDevVideoRecordAllocFailInfoEncoder* self = new(ELeave) CTestStepDevVideoRecordAllocFailInfoEncoder(aTestName);
  1112 	return self;
  1113 	}
  1114 
  1115 CTestStepDevVideoRecordAllocFailInfoEncoder::~CTestStepDevVideoRecordAllocFailInfoEncoder()
  1116 	{
  1117 	}
  1118 
  1119 TVerdict CTestStepDevVideoRecordAllocFailInfoEncoder::DoTestL()
  1120 	{
  1121 	iTestStepResult = EPass;
  1122     TInt err       = KErrNone;
  1123 
  1124 	// Printing to the console and log file
  1125 	INFO_PRINTF1(_L("this is an Alloc Failure test of VideoEncoderInfoLC()"));
  1126 
  1127 	// moved creation and destruction of iDevVideoRecord inside the heap marks.
  1128 	// reason :- VideoEncoderInfoLC may allocate onto it
  1129 	
  1130 	TInt failCount = 1;
  1131 	TBool completed = EFalse;
  1132 	TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
  1133 	for(;;)	
  1134 		{
  1135 		__UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
  1136 		__MM_HEAP_MARK;
  1137 
  1138 		TRAP (err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this));
  1139 	
  1140 		if (err == KErrNone)
  1141 			{
  1142 			CVideoEncoderInfo* vidInfo = NULL;
  1143 
  1144 			TRAP( err, vidInfo = iDevVideoRecord->VideoEncoderInfoLC(KUidDevVideoTestEncodeHwDevice);
  1145 					   CleanupStack::Pop(vidInfo); );
  1146 
  1147 			completed = EFalse;
  1148 			if (err == KErrNone)
  1149 				{
  1150 				TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
  1151 				if (testAlloc==NULL)
  1152 					{
  1153 					reachedEnd = ETrue;
  1154 					failCount--; // -= 1;
  1155 					}
  1156 				else
  1157 					User::Free(testAlloc);
  1158 			
  1159 				}
  1160 			else if (err != KErrNoMemory) // bad error code
  1161 				completed = ETrue;
  1162 
  1163 			// see if valid result and break if wrong - might be premature result
  1164 		
  1165 			if (vidInfo)
  1166 				{
  1167 				delete vidInfo;
  1168 				vidInfo = NULL;
  1169 				}
  1170 			}
  1171 		else if (err != KErrNoMemory) // bad error code
  1172 			completed = ETrue;
  1173 			
  1174 		if (iDevVideoRecord)
  1175 			{
  1176 			delete iDevVideoRecord;
  1177 			iDevVideoRecord = NULL;
  1178 			}
  1179 
  1180 		completed = reachedEnd;
  1181 
  1182 		__MM_HEAP_MARKEND;
  1183 		__UHEAP_SETFAIL(RHeap::ENone ,0);
  1184 
  1185 		if (completed)
  1186 			break; // exit loop
  1187 
  1188 		failCount++;
  1189 		}
  1190 
  1191 	if (err != KErrNone)
  1192 		{
  1193 		INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
  1194 		iTestStepResult = EFail;
  1195 		}
  1196 	else 
  1197 		{
  1198 		INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
  1199 		iTestStepResult = EPass;
  1200 		}
  1201 
  1202 	INFO_PRINTF1(_L("finished with this test step"));
  1203 	// test steps return a result
  1204 	return iTestStepResult;
  1205 	}
  1206 
  1207 //----------------------------------------------------------------------------
  1208 
  1209 CTestStepDevVideoRecordAllocFailInfoPreProc::CTestStepDevVideoRecordAllocFailInfoPreProc(const TDesC& aTestName)
  1210 	:CTestStepDevVideoRecordAllocFail(aTestName)
  1211 	{
  1212 	}
  1213 
  1214 CTestStepDevVideoRecordAllocFailInfoPreProc* CTestStepDevVideoRecordAllocFailInfoPreProc::NewL(const TDesC& aTestName)
  1215 	{
  1216 	CTestStepDevVideoRecordAllocFailInfoPreProc* self = new(ELeave) CTestStepDevVideoRecordAllocFailInfoPreProc(aTestName);
  1217 	return self;
  1218 	}
  1219 
  1220 CTestStepDevVideoRecordAllocFailInfoPreProc::~CTestStepDevVideoRecordAllocFailInfoPreProc()
  1221 	{
  1222 	}
  1223 
  1224 TVerdict CTestStepDevVideoRecordAllocFailInfoPreProc::DoTestL()
  1225 	{
  1226 	iTestStepResult = EPass;
  1227     TInt err       = KErrNone;
  1228 
  1229 	// Printing to the console and log file
  1230 	INFO_PRINTF1(_L("this is an Alloc Failure test of PreProcessorInfoLC()"));
  1231 
  1232 	// will leave on error
  1233 	TRAP (err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this));
  1234 	
  1235 	if (err != KErrNone)
  1236 		{
  1237 		ERR_PRINTF1(_L("Error - Couldn't construct CMMFDevVideoRecord!"));
  1238 		return EInconclusive;
  1239 		}
  1240 
  1241 	CPreProcessorInfo* preInfo = NULL;
  1242 
  1243 	TInt failCount = 1;
  1244 	TBool completed = EFalse;
  1245 	TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
  1246 	for(;;)	
  1247 		{
  1248 		__UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
  1249 		__MM_HEAP_MARK;
  1250 
  1251 		TRAP( err, preInfo = iDevVideoRecord->PreProcessorInfoLC(KUidDevVideoTestPreProcHwDevice);
  1252 				   CleanupStack::Pop(preInfo); );
  1253 
  1254 		REComSession::FinalClose();
  1255 
  1256 		completed = EFalse;
  1257 		if (err == KErrNone)
  1258 			{
  1259 			TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
  1260 			if (testAlloc==NULL)
  1261 				{
  1262 				reachedEnd = ETrue;
  1263 				failCount--; // -= 1;
  1264 				}
  1265 			else
  1266 				User::Free(testAlloc);
  1267 			
  1268 			}
  1269 		else if (err != KErrNoMemory) // bad error code
  1270 			completed = ETrue;
  1271 
  1272 		// see if valid result and break if wrong - might be premature result
  1273 		
  1274 		if (preInfo)
  1275 			{
  1276 			delete preInfo;
  1277 			preInfo = NULL;
  1278 			}
  1279 
  1280 		completed = reachedEnd;
  1281 
  1282 		__MM_HEAP_MARKEND;
  1283 		__UHEAP_SETFAIL(RHeap::ENone ,0);
  1284 
  1285 		if (completed)
  1286 			break; // exit loop
  1287 
  1288 		failCount++;
  1289 		}
  1290 
  1291 	if (err != KErrNone)
  1292 		{
  1293 		INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
  1294 		iTestStepResult = EFail;
  1295 		}
  1296 	else 
  1297 		{
  1298 		INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
  1299 		iTestStepResult = EPass;
  1300 		}
  1301 
  1302 	if (iDevVideoRecord)
  1303 		{
  1304 		delete iDevVideoRecord;
  1305 		iDevVideoRecord = NULL;
  1306 		}
  1307 
  1308 	INFO_PRINTF1(_L("finished with this test step"));
  1309 	// test steps return a result
  1310 	return iTestStepResult;
  1311 	}
  1312 
  1313 //----------------------------------------------------------------------------
  1314 
  1315 
  1316 CTestStepDevVideoRecordAllocFailFindPlugins::CTestStepDevVideoRecordAllocFailFindPlugins(const TDesC& aTestName)
  1317 	:CTestStepDevVideoRecordAllocFail(aTestName)
  1318 	{
  1319 	}
  1320 
  1321 CTestStepDevVideoRecordAllocFailFindPlugins* CTestStepDevVideoRecordAllocFailFindPlugins::NewL(const TDesC& aTestName)
  1322 	{
  1323 	CTestStepDevVideoRecordAllocFailFindPlugins* self = new(ELeave) CTestStepDevVideoRecordAllocFailFindPlugins(aTestName);
  1324 	return self;
  1325 	}
  1326 
  1327 CTestStepDevVideoRecordAllocFailFindPlugins::~CTestStepDevVideoRecordAllocFailFindPlugins()
  1328 	{
  1329 	}
  1330 
  1331 TVerdict CTestStepDevVideoRecordAllocFailFindPlugins::DoTestL()
  1332 	{
  1333 	iTestStepResult = EPass;
  1334     TInt err       = KErrNone;
  1335 
  1336 	// Printing to the console and log file
  1337 	INFO_PRINTF1(_L("this is an Alloc Failure test of finding Encoder and Pre processor plugins"));
  1338 
  1339 
  1340 	TInt failCount = 1;
  1341 	TBool completed = EFalse;
  1342 	TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
  1343 	for(;;)	
  1344 		{
  1345 		__UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
  1346 		__MM_HEAP_MARK;
  1347 
  1348 		err = KErrNone;
  1349 
  1350 		if (!err)
  1351 			TRAP(err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this));
  1352 		if (!err)
  1353 			TRAP(err, GetEncodersL());
  1354 		if (!err)
  1355 			TRAP(err, GetPreProcessorsL());
  1356 		if (!err)
  1357 			TRAP(err, FindEncodersL());
  1358 		if (!err)
  1359 			TRAP(err, FindPreProcessorsL());
  1360 
  1361 		REComSession::FinalClose();
  1362 
  1363 		completed = EFalse;
  1364 		if (err == KErrNone)
  1365 			{
  1366 			TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
  1367 			if (testAlloc==NULL)
  1368 				{
  1369 				reachedEnd = ETrue;
  1370 				failCount--; // -= 1;
  1371 				}
  1372 			else
  1373 				User::Free(testAlloc);
  1374 			
  1375 			}
  1376 		else if (err != KErrNoMemory) // bad error code
  1377 			completed = ETrue;
  1378 
  1379 		// see if valid result and break if wrong - might be premature result
  1380 		delete iDevVideoRecord;
  1381 		iDevVideoRecord = NULL;
  1382 
  1383 		__MM_HEAP_MARKEND;
  1384 		__UHEAP_SETFAIL(RHeap::ENone ,0);
  1385 
  1386 		if (completed || reachedEnd)
  1387 			break; // exit loop
  1388 
  1389 		failCount++;
  1390 		}
  1391 
  1392 	if (err != KErrNone)
  1393 		{
  1394 		INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
  1395 		iTestStepResult = EFail;
  1396 		}
  1397 	else 
  1398 		{
  1399 		INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
  1400 		iTestStepResult = EPass;
  1401 		}
  1402 
  1403 	delete iDevVideoRecord;
  1404 	iDevVideoRecord = NULL;
  1405 
  1406 	INFO_PRINTF1(_L("finished with this test step"));
  1407 	// test steps return a result
  1408 	return iTestStepResult;
  1409 	}
  1410 
  1411 void CTestStepDevVideoRecordAllocFailFindPlugins::CheckPluginsL(const RArray<TUid>& aFoundPlugins, const RArray<TUid>& aExpectedPlugins, const RArray<TUid>& aUnExpectedPlugins)
  1412 	{
  1413 	TBool foundUnExpected = EFalse;
  1414 	TInt numberToBeFoundInExpectedPlugins = aExpectedPlugins.Count();
  1415 
  1416 	for (TInt i=0; i<aFoundPlugins.Count(); i++)
  1417 		{
  1418 		TUid uidToLookFor = aFoundPlugins[i];
  1419 		TInt j;
  1420 		for (j=0; j<aExpectedPlugins.Count(); j++)
  1421 			{
  1422 			if (aExpectedPlugins[j] == uidToLookFor)
  1423 				{
  1424 				numberToBeFoundInExpectedPlugins--;
  1425 				break;//j
  1426 				}
  1427 			}
  1428 		for (j=0; j<aUnExpectedPlugins.Count(); j++)
  1429 			{
  1430 			if (aUnExpectedPlugins[j] == uidToLookFor)
  1431 				{
  1432 				foundUnExpected = ETrue;
  1433 				break;//j
  1434 				}
  1435 			}
  1436 		}
  1437 
  1438 	if ((foundUnExpected) || (numberToBeFoundInExpectedPlugins!=0))
  1439 		User::Leave(KErrGeneral);
  1440 
  1441 	}
  1442 
  1443 
  1444 void CTestStepDevVideoRecordAllocFailFindPlugins::FindEncodersL()
  1445 	{
  1446 	RArray<TUid> foundEncoders;
  1447 	CleanupClosePushL(foundEncoders);
  1448 	RArray<TUid> expectedEncoders;
  1449 	CleanupClosePushL(expectedEncoders);
  1450 	RArray<TUid> unExpectedEncoders;
  1451 	CleanupClosePushL(unExpectedEncoders);
  1452 
  1453 	
  1454 	// Supported mime type and Pre proc type (by exact match)
  1455 	_LIT8(KMimeType5, "video/zippyvideo");
  1456 	TUint32 requestedPreProcType = EPpMirror|EPpInputCrop;
  1457 	foundEncoders.Reset();
  1458 	expectedEncoders.Reset();
  1459 	unExpectedEncoders.Reset();
  1460 	User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice1));
  1461 	User::LeaveIfError(unExpectedEncoders.Append(KUidDevVideoTestEncodeHwDevice2));
  1462 	User::LeaveIfError(unExpectedEncoders.Append(KUidDevVideoTestEncodeHwDevice3));
  1463 	User::LeaveIfError(unExpectedEncoders.Append(KUidDevVideoTestEncodeHwDevice4));
  1464 	User::LeaveIfError(unExpectedEncoders.Append(KUidDevVideoTestEncodeHwDevice5));
  1465 
  1466 	iDevVideoRecord->FindEncodersL(KMimeType5(), requestedPreProcType, foundEncoders, ETrue);
  1467 	CheckPluginsL(foundEncoders, expectedEncoders, unExpectedEncoders);
  1468 
  1469 	CleanupStack::PopAndDestroy(3);
  1470 	}
  1471 
  1472 void CTestStepDevVideoRecordAllocFailFindPlugins::FindPreProcessorsL()
  1473 	{
  1474 	RArray<TUid> foundPreProx;
  1475 	CleanupClosePushL(foundPreProx);
  1476 	RArray<TUid> expectedPreProx;
  1477 	CleanupClosePushL(expectedPreProx);
  1478 	RArray<TUid> unExpectedPreProx;
  1479 	CleanupClosePushL(unExpectedPreProx);
  1480 
  1481 	TUint32	requestedPreProcType = EPpMirror|EPpInputCrop;
  1482 	foundPreProx.Reset();
  1483 	expectedPreProx.Reset();
  1484 	User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice1));
  1485 	User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice2));
  1486 	User::LeaveIfError(unExpectedPreProx.Append(KUidDevVideoTestPreProcHwDevice3));
  1487 	User::LeaveIfError(unExpectedPreProx.Append(KUidDevVideoTestPreProcHwDevice4));
  1488 	User::LeaveIfError(unExpectedPreProx.Append(KUidDevVideoTestPreProcHwDevice5));
  1489 
  1490 	iDevVideoRecord->FindPreProcessorsL(requestedPreProcType, foundPreProx);
  1491 	CheckPluginsL(foundPreProx, expectedPreProx, unExpectedPreProx);
  1492 
  1493 	CleanupStack::PopAndDestroy(3);
  1494 	}
  1495 
  1496 void CTestStepDevVideoRecordAllocFailFindPlugins::GetEncodersL()
  1497 	{
  1498 	RArray<TUid> foundEncoders;
  1499 	CleanupClosePushL(foundEncoders);
  1500 	RArray<TUid> expectedEncoders;
  1501 	CleanupClosePushL(expectedEncoders);
  1502 	RArray<TUid> unExpectedEncoders;
  1503 	CleanupClosePushL(unExpectedEncoders);
  1504 
  1505 	User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice1));
  1506 	User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice2));
  1507 	User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice3));
  1508 	User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice4));
  1509 	User::LeaveIfError(expectedEncoders.Append(KUidDevVideoTestEncodeHwDevice5));
  1510 
  1511 	iDevVideoRecord->GetEncoderListL(foundEncoders);
  1512 
  1513 	CheckPluginsL(foundEncoders, expectedEncoders, unExpectedEncoders);
  1514 
  1515 	CleanupStack::PopAndDestroy(3); //foundEncoders, expectedEncoders, unExpectedEncoders
  1516 	}
  1517 
  1518 void CTestStepDevVideoRecordAllocFailFindPlugins::GetPreProcessorsL()
  1519 	{
  1520 	RArray<TUid> foundPreProx;
  1521 	CleanupClosePushL(foundPreProx);
  1522 	RArray<TUid> expectedPreProx;
  1523 	CleanupClosePushL(expectedPreProx);
  1524 	RArray<TUid> unExpectedPreProx;
  1525 	CleanupClosePushL(unExpectedPreProx);
  1526 
  1527 	User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice1));
  1528 	User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice2));
  1529 	User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice3));
  1530 	User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice4));
  1531 	User::LeaveIfError(expectedPreProx.Append(KUidDevVideoTestPreProcHwDevice5));
  1532 
  1533 	iDevVideoRecord->GetPreProcessorListL(foundPreProx);
  1534 
  1535 	CheckPluginsL(foundPreProx, expectedPreProx, unExpectedPreProx);
  1536 
  1537 	CleanupStack::PopAndDestroy(3);//foundPreProx, expectedPreProx, unExpectedPreProx
  1538 	}
  1539 
  1540 //----------------------------------------------------------------------------
  1541 
  1542 
  1543 CTestStepDevVideoRecordAllocFailGetBuffers::CTestStepDevVideoRecordAllocFailGetBuffers(const TDesC& aTestName)
  1544 	:CTestStepDevVideoRecordAllocFail(aTestName)
  1545 	{
  1546 	}
  1547 
  1548 CTestStepDevVideoRecordAllocFailGetBuffers* CTestStepDevVideoRecordAllocFailGetBuffers::NewL(const TDesC& aTestName)
  1549 	{
  1550 	CTestStepDevVideoRecordAllocFailGetBuffers* self = new(ELeave) CTestStepDevVideoRecordAllocFailGetBuffers(aTestName);
  1551 	return self;
  1552 	}
  1553 
  1554 CTestStepDevVideoRecordAllocFailGetBuffers::~CTestStepDevVideoRecordAllocFailGetBuffers()
  1555 	{
  1556 	}
  1557 
  1558 TVerdict CTestStepDevVideoRecordAllocFailGetBuffers::DoTestL()
  1559 	{
  1560 	iTestStepResult = EPass;
  1561     TInt err       = KErrNone;
  1562 
  1563 	// Printing to the console and log file
  1564 	INFO_PRINTF1(_L("this is an Alloc Failure test of retrieving and returning Buffers to the plugin"));
  1565 
  1566 
  1567 	TInt failCount = 1;
  1568 	TBool completed = EFalse;
  1569 	TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
  1570 	for(;;)	
  1571 		{
  1572 		__UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
  1573 		__MM_HEAP_MARK;
  1574 
  1575 		TRAP(err, iDevVideoRecord = CMMFDevVideoRecord::NewL(*this));
  1576 		if (!err)
  1577 			TRAP(err, PerformTestL());
  1578 
  1579 		REComSession::FinalClose();
  1580 
  1581 		completed = EFalse;
  1582 		if (err == KErrNone)
  1583 			{
  1584 			TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
  1585 			if (testAlloc==NULL)
  1586 				{
  1587 				reachedEnd = ETrue;
  1588 				failCount--; // -= 1;
  1589 				}
  1590 			else
  1591 				User::Free(testAlloc);
  1592 			
  1593 			}
  1594 		else if (err != KErrNoMemory) // bad error code
  1595 			completed = ETrue;
  1596 
  1597 		// see if valid result and break if wrong - might be premature result
  1598 		delete iDevVideoRecord;
  1599 		iDevVideoRecord = NULL;
  1600 
  1601 		__MM_HEAP_MARKEND;
  1602 		__UHEAP_SETFAIL(RHeap::ENone ,0);
  1603 
  1604 		if (completed || reachedEnd)
  1605 			break; // exit loop
  1606 
  1607 		failCount++;
  1608 		}
  1609 
  1610 	if (err != KErrNone)
  1611 		{
  1612 		INFO_PRINTF3(_L("Error(%d) with %d memory allocations tested"), err, failCount);
  1613 		iTestStepResult = EFail;
  1614 		}
  1615 	else 
  1616 		{
  1617 		INFO_PRINTF2(_L("Completed OK with %d memory allocations tested"), failCount);
  1618 		iTestStepResult = EPass;
  1619 		}
  1620 
  1621 	delete iDevVideoRecord;
  1622 	iDevVideoRecord = NULL;
  1623 
  1624 	INFO_PRINTF1(_L("finished with this test step"));
  1625 	// test steps return a result
  1626 	return iTestStepResult;
  1627 	}
  1628 
  1629 
  1630 void CTestStepDevVideoRecordAllocFailGetBuffers::PerformTestL()
  1631 	{
  1632 	iTestError = KErrNone;
  1633 
  1634 	// select Encoder
  1635 	iDevVideoRecord->SelectEncoderL(KUidDevVideoTestEncodeHwDevice);
  1636 
  1637 	// select Pre-processor
  1638 	iDevVideoRecord->SelectPreProcessorL(KUidDevVideoTestPreProcHwDevice);
  1639 
  1640 	//Tell plugin to start creating Buffers.
  1641 	iDevVideoRecord->SetImplementationSpecificEncoderOptionsL(KTestISEncBuffers);
  1642 
  1643 	// initialize CDevVideoRecord and wait for response
  1644 	iDevVideoRecord->Initialize();
  1645 
  1646 	User::LeaveIfError(iTestError);
  1647 
  1648 	iDevVideoRecord->Start();//Tell plugin to start creating Buffers.
  1649 	// We should now get a series of NewBuffer() callbacks.
  1650 
  1651 	User::LeaveIfError(iTestError);
  1652 	}
  1653 
  1654 void CTestStepDevVideoRecordAllocFailGetBuffers::MdvpoInitComplete(TInt aError)
  1655 	{
  1656 	iTestError = aError;
  1657 	}
  1658 
  1659 void CTestStepDevVideoRecordAllocFailGetBuffers::MdvpoNewBuffers()
  1660 	{
  1661 	TRAP(iTestError, DoNewBuffersL());
  1662 	}
  1663 
  1664 void CTestStepDevVideoRecordAllocFailGetBuffers::CheckNewBufferInfoL(TUint aNumBuffers)
  1665 	{
  1666 	TUint numBuffers = 0;
  1667 	numBuffers = iDevVideoRecord->NumDataBuffers();
  1668 
  1669 	if (numBuffers != aNumBuffers)
  1670 		{
  1671 		User::Leave(KErrGeneral);
  1672 		}
  1673 	}
  1674 
  1675 void CTestStepDevVideoRecordAllocFailGetBuffers::DoNewBuffersL()
  1676 	{
  1677 	User::LeaveIfError(iTestError);//Don't go any further if we have an error
  1678 	switch (iCurrentBufferNumber)
  1679 		{
  1680 		case 0:
  1681 			{
  1682 			iCurrentBufferNumber++;
  1683 			CheckNewBufferInfoL(1);
  1684 			TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
  1685 			CheckNewBufferInfoL(0);
  1686 			iDevVideoRecord->ReturnBuffer(buffer);
  1687 			break;
  1688 			}
  1689 		case 1:
  1690 			{
  1691 			iCurrentBufferNumber++;
  1692 			CheckNewBufferInfoL(1);
  1693 			TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
  1694 			CheckNewBufferInfoL(0);
  1695 			iDevVideoRecord->ReturnBuffer(buffer);
  1696 			break;
  1697 			}
  1698 		case 2:
  1699 			{
  1700 			iCurrentBufferNumber++;
  1701 			CheckNewBufferInfoL(1);
  1702 			TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
  1703 			CheckNewBufferInfoL(0);
  1704 			iDevVideoRecord->ReturnBuffer(buffer);
  1705 			break;
  1706 			}
  1707 		case 3:
  1708 			{
  1709 			iCurrentBufferNumber++;
  1710 			CheckNewBufferInfoL(1);
  1711 			TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
  1712 			iDevVideoRecord->ReturnBuffer(buffer);
  1713 			break;
  1714 			}
  1715 		case 4:
  1716 			{
  1717 			iCurrentBufferNumber++;
  1718 			CheckNewBufferInfoL(1);
  1719 			TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
  1720 			iDevVideoRecord->ReturnBuffer(buffer);
  1721 			break;
  1722 			}
  1723 		case 5:
  1724 			{
  1725 			iCurrentBufferNumber++;
  1726 			CheckNewBufferInfoL(1);
  1727 			TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
  1728 			iDevVideoRecord->ReturnBuffer(buffer);
  1729 			break;
  1730 			}
  1731 		case 6:
  1732 			{
  1733 			iCurrentBufferNumber++;
  1734 			CheckNewBufferInfoL(1);
  1735 			break;
  1736 			}
  1737 		case 7:
  1738 			{
  1739 			iCurrentBufferNumber++;
  1740 			CheckNewBufferInfoL(2);
  1741 			break;
  1742 			}
  1743 		case 8:
  1744 			{
  1745 			iCurrentBufferNumber++;
  1746 			CheckNewBufferInfoL(3);
  1747 			break;
  1748 			}
  1749 		case 9:
  1750 			{
  1751 			iCurrentBufferNumber++;
  1752 			CheckNewBufferInfoL(4);
  1753 			TVideoOutputBuffer* buffer = iDevVideoRecord->NextBufferL();
  1754 			iDevVideoRecord->ReturnBuffer(buffer);
  1755 			CheckNewBufferInfoL(3);
  1756 			buffer = iDevVideoRecord->NextBufferL();
  1757 			iDevVideoRecord->ReturnBuffer(buffer);
  1758 			CheckNewBufferInfoL(2);
  1759 			buffer = iDevVideoRecord->NextBufferL();
  1760 			iDevVideoRecord->ReturnBuffer(buffer);
  1761 			CheckNewBufferInfoL(1);
  1762 			buffer = iDevVideoRecord->NextBufferL();
  1763 			iDevVideoRecord->ReturnBuffer(buffer);
  1764 			CheckNewBufferInfoL(0);
  1765 			break;
  1766 			}
  1767 		default:
  1768 			User::Leave(KErrGeneral);
  1769 			break;
  1770 		};
  1771 	}
  1772 	
  1773