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