os/mm/imagingandcamerafws/cameraunittest/src/TSU_ECM_ADV/ecamextendedfunctest.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2007-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 //
    15 
    16 #include <ecamuids.hrh>
    17 #include <w32std.h>
    18 #include <ecom/ecomresolverparams.h>
    19 #include "ecamextendedfunctest.h"
    20 #include "ECamUnitTestPluginUids.hrh"
    21 #include "ECamUnitTestPlugin.h"
    22 #include <ecam/ecamcommonuids.hrh>
    23 #include <fbs.h>
    24 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    25 #include <ecamconst.h>
    26 #include "ecamdef.h"
    27 #include <ecamcapturecontrolconst.h>
    28 #endif
    29 /*------------------------------------------------------
    30  	Client ViewFinder : RECamClientViewFinderTest
    31  *------------------------------------------------------*/
    32 RECamClientViewFinderTest* RECamClientViewFinderTest::NewL(const TDesC& aTestStep)
    33 	{
    34 	RECamClientViewFinderTest* self = new (ELeave) RECamClientViewFinderTest(aTestStep);
    35 	return self;	
    36 	}
    37 	
    38 RECamClientViewFinderTest::RECamClientViewFinderTest(const TDesC& aTestStep)
    39 	{
    40 	iTestStepName.Copy(aTestStep);
    41 	}
    42 	
    43 TVerdict RECamClientViewFinderTest::DoTestStepL()
    44 	{
    45 	if(!iTestStepName.Compare(_L("MM-ECM-ADV-U-050-HP")))
    46 		{
    47 		return DoTestStep_50L();
    48 		}
    49 	return EInconclusive;	
    50 	}
    51 	
    52 TVerdict RECamClientViewFinderTest::DoTestStep_50L()
    53 	{	
    54 	TVerdict verdict = EFail;
    55 	INFO_PRINTF1(_L("Alloc test"));
    56 	TInt i;
    57 	TInt err;
    58 	for (i = 1 ; ; i++)
    59 		{
    60 		__MM_HEAP_MARK;
    61 		
    62 		if (i % 5 == 0)
    63 			{
    64 			INFO_PRINTF2(_L("Fail count = %d"), i);
    65 			}
    66 
    67 		__UHEAP_SETFAIL(RHeap::EFailNext, i);
    68 
    69 		TRAP(err, verdict = DoClientVFTestStepL());
    70 
    71 		TAny* testAlloc = User::Alloc(1);
    72 		TBool heapTestingComplete = (testAlloc == NULL) && (err==KErrNone);
    73 		User::Free(testAlloc);
    74 
    75 		__UHEAP_RESET;
    76 		__MM_HEAP_MARKEND;
    77 
    78 		if ((err != KErrNoMemory ) || heapTestingComplete)
    79 			{
    80 			INFO_PRINTF4(_L("err = %d, verdict = %d, Fail count = %d"), err, verdict, i);
    81 			INFO_PRINTF1(_L("Alloc testing completed successfully"));
    82 			verdict = EPass;
    83 			break;
    84 			}
    85 		}
    86 	return verdict;
    87 	}
    88 	
    89 TVerdict RECamClientViewFinderTest::DoClientVFTestStepL()
    90 	{
    91 	TVerdict result = EPass;
    92 	CCamera* camera = NULL;
    93 	
    94 	MClientViewFinderObserver *clientVFObserver = NULL;
    95 	TInt error = KErrNone;
    96 	CCamera::CCameraClientViewFinder* clientVF = NULL;
    97 	
    98 	MCameraObserver* observer = NULL; 
    99 		
   100 	// using observer 	
   101 	__MM_HEAP_MARK;
   102 	INFO_PRINTF1(_L("Create camera using Camera::NewL() and MCameraObserver"));
   103 	TRAP(error, camera = CCamera::NewL(*observer, 0));
   104 	if (error==KErrNone)
   105 		{
   106 		CleanupStack::PushL(camera);
   107 		INFO_PRINTF1(_L("Create client viewfinder from CCamera object"));
   108 		
   109 		TRAP(error, clientVF  = CCamera::CCameraClientViewFinder::NewL(*camera, *clientVFObserver));	
   110  		if (error==KErrExtensionNotSupported)
   111 	    	{
   112 	    	INFO_PRINTF1(_L("CCameraClientViewFinder object creation using old Observer failed with correct error"));
   113 	    	}
   114 	    else
   115     		{
   116     		INFO_PRINTF1(_L("CCameraClientViewFinder object creation using old Observer gave unexpected result"));
   117     		result = EFail;
   118     		}	
   119 		CleanupStack::PopAndDestroy(camera);
   120 		}
   121 	else 
   122 		{
   123 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL()"), error);
   124 		result = EFail;	
   125 		User::Leave(KErrNoMemory);	
   126 		}
   127 	__MM_HEAP_MARKEND;
   128 	
   129 	// using observer2 with NewL 
   130 	MCameraObserver2* observer2 = NULL;	
   131 	__MM_HEAP_MARK;
   132 	INFO_PRINTF1(_L("Create camera using Camera::NewL() and MCameraObserver2"));
   133 	TRAP(error, camera = CCamera::NewL(*observer2, 0,0));
   134 	if (error==KErrNone)
   135 		{
   136 		CleanupStack::PushL(camera);
   137 		INFO_PRINTF1(_L("Create client viewfinder from CCamera object"));
   138 		
   139 		TRAP(error, clientVF  = CCamera::CCameraClientViewFinder::NewL(*camera, *clientVFObserver));	
   140  		if (error==KErrExtensionNotSupported)
   141 	    	{
   142 	    	INFO_PRINTF1(_L("CCameraClientViewFinder object creation using Observer2 with NewL failed with correct error"));
   143 	    	}
   144 	    else
   145     		{
   146     		INFO_PRINTF1(_L("CCameraClientViewFinder object creation using Observer2 with NewL gave unexpected result"));
   147     		result = EFail;
   148     		}	
   149 		CleanupStack::PopAndDestroy(camera);
   150 		}
   151 	else 
   152 		{
   153 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL()"), error);
   154 		result = EFail;	
   155 		User::Leave(KErrNoMemory);	
   156 		}
   157 	__MM_HEAP_MARKEND;
   158 		
   159 	// create client viewfinder object using New2L
   160 	__MM_HEAP_MARK;
   161 	
   162 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
   163 	
   164 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
   165 	if (error==KErrNone)
   166 		{
   167 		CleanupStack::PushL(camera);
   168 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   169 		TRAP(error, clientVF  = CCamera::CCameraClientViewFinder::NewL(*camera, *clientVFObserver));	
   170 		
   171 		if (error==KErrNone)
   172 	    	{
   173 	    	CleanupStack::PushL(clientVF);
   174 	  		INFO_PRINTF1(_L("CCameraClientViewFinder object was created using NewL")); 
   175 	    	
   176 	    	INFO_PRINTF1(_L("Create Histogram for Client ViewFinder"));
   177 	  		CCamera::CCameraV2Histogram* histogram_CVF = clientVF->CreateHistogramHandleL();
   178 	  		if(!histogram_CVF)
   179 	  			{
   180 	  			INFO_PRINTF1(_L("Histogram creation for Client ViewFinder unsuccessful"));
   181 	  			result = EFail;
   182 	  			User::Leave(KErrNoMemory);
   183 	  			}
   184 	  			
   185 	  		CleanupStack::PushL(histogram_CVF);
   186 	  		INFO_PRINTF1(_L("Histogram object was created for Client ViewFinder"));
   187 	  		CleanupStack::PopAndDestroy(histogram_CVF);
   188 	    	
   189 	    	CleanupStack::PopAndDestroy(clientVF);
   190 	    	}
   191 	    else
   192     		{
   193     		INFO_PRINTF1(_L("CCameraClientViewFinder object was not created using NewL")); 
   194     		result = EFail;
   195     		User::Leave(KErrNoMemory);
   196     		}	
   197 		CleanupStack::PopAndDestroy(camera);
   198 		}
   199 	else 
   200 		{
   201 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
   202 		result = EFail;	
   203 		User::Leave(KErrNoMemory);	
   204 		}
   205 	__MM_HEAP_MARKEND;
   206    
   207 	return result;
   208 	}
   209 	
   210 /*------------------------------------------------------
   211  	Client ViewFinder : RECamClientVFNotificationTest
   212  *------------------------------------------------------*/
   213 RECamClientVFNotificationTest* RECamClientVFNotificationTest::NewL(TBool aAllocTest)
   214 	{
   215 	RECamClientVFNotificationTest* self = new (ELeave) RECamClientVFNotificationTest(aAllocTest);
   216 	CleanupStack::PushL(self);
   217 	self->ConstructL();
   218 	CleanupStack::Pop(self);
   219 	return self;	
   220 	}
   221 	
   222 void RECamClientVFNotificationTest::ConstructL()
   223 	{
   224 	}
   225 	
   226 RECamClientVFNotificationTest::RECamClientVFNotificationTest(TBool /*aAllocTest*/)
   227 	{
   228 	iTestStepName = _L("MM-ECM-ADV-U-051-HP");
   229 	}
   230 	
   231 void RECamClientVFNotificationTest::ViewFinderBufferReady(CCamera::CCameraClientViewFinder& aClientViewFinderHandle, TInt aErrorCode)
   232 	{
   233 	aClientViewFinderHandle.GetViewFinderHandleL(iVFHandle);
   234 	iError = aErrorCode;
   235 	}
   236 
   237 void RECamClientVFNotificationTest::DirectHistogramDisplayed(CCamera::CCameraClientViewFinder& aClientViewFinderHandle, CCamera::CCameraV2Histogram& /*aDirectHistogramDisplayed*/, TInt aErrorCode)
   238 	{
   239 	aClientViewFinderHandle.GetViewFinderHandleL(iVFHandle);
   240 	iError = aErrorCode;
   241 	}
   242 
   243 void RECamClientVFNotificationTest::ClientHistogramReady(CCamera::CCameraClientViewFinder& aClientViewFinderHandle, MHistogramV2Buffer* /*aClientHistogramBuffer*/, TInt aErrorCode)
   244 	{
   245 	aClientViewFinderHandle.GetViewFinderHandleL(iVFHandle);
   246 	iError = aErrorCode;
   247 	}
   248 	
   249 void RECamClientVFNotificationTest::ImageProcessingFailed(CCamera::CCameraClientViewFinder& aClientViewFinderHandle, TInt aErrorCode)
   250 	{
   251 	aClientViewFinderHandle.GetViewFinderHandleL(iVFHandle);
   252 	iError = aErrorCode;	
   253 	}
   254 	
   255 TInt RECamClientVFNotificationTest::CustomInterface(TUid /*aInterface*/, TAny*& /*aPtrInterface*/)
   256 	{
   257 	return KErrNone;
   258 	}
   259 
   260 void RECamClientVFNotificationTest::CheckViewFinderNegNotification(TInt aVFHandle, TVerdict& aResult)	
   261 	{
   262 	INFO_PRINTF4(_L("Expected ClientViewFinder Id %d, received event %x. Error %d."), aVFHandle, iVFHandle, iError); 
   263 	if (aVFHandle != iVFHandle || iError != KErrNotSupported)
   264 		{
   265 	    aResult = EFail;
   266 	    }
   267 	}
   268 	
   269 TVerdict RECamClientVFNotificationTest::DoTestStepL()
   270 	{
   271 	TVerdict verdict = EFail;
   272 	INFO_PRINTF1(_L("Alloc test"));
   273 	TInt i;
   274 	TInt err;
   275 	for (i = 1 ; ; i++)
   276 		{
   277 		__MM_HEAP_MARK;
   278 		
   279 		if (i % 5 == 0)
   280 			{
   281 			INFO_PRINTF2(_L("Fail count = %d"), i);
   282 			}
   283 
   284 		__UHEAP_SETFAIL(RHeap::EFailNext, i);
   285 
   286 		TRAP(err, verdict = DoTestStepL_51L());
   287 
   288 		TAny* testAlloc = User::Alloc(1);
   289 		TBool heapTestingComplete = (testAlloc == NULL) && (err==KErrNone);
   290 		User::Free(testAlloc);
   291 
   292 		__UHEAP_RESET;
   293 		__MM_HEAP_MARKEND;
   294 
   295 		if ((err != KErrNoMemory && verdict == EPass ) || heapTestingComplete)
   296 			{
   297 			INFO_PRINTF4(_L("err = %d, verdict = %d, Fail count = %d"), err, verdict, i);
   298 			INFO_PRINTF1(_L("Alloc testing completed successfully"));
   299 			verdict = EPass;
   300 			break;
   301 			}
   302 		}
   303 	return verdict;
   304 	}
   305 	
   306 TVerdict RECamClientVFNotificationTest::DoTestStepL_51L()
   307 	{
   308 	TVerdict result = EPass;
   309 	CCamera* camera = NULL;
   310 	
   311 	TInt error = KErrNone;
   312 	CCamera::CCameraClientViewFinder* clientVF = NULL;
   313 
   314 /**************************************************************/	
   315 	MCameraObserver2* observer2 = NULL;	
   316 	__MM_HEAP_MARK;
   317 	INFO_PRINTF1(_L("Create camera using Camera::NewL() and MCameraObserver2"));
   318 	TRAP(error, camera = CCamera::NewL(*observer2, 0,0));
   319 	if (error==KErrNone)
   320 		{
   321 		CleanupStack::PushL(camera);
   322 		INFO_PRINTF1(_L("Create client viewfinder from CCamera object"));
   323 		
   324 		TRAP(error, clientVF  = CCamera::CCameraClientViewFinder::NewL(*camera, *this));	
   325  		
   326  		if (error == KErrNone)
   327  			{
   328  			INFO_PRINTF1(_L("CCameraClientViewFinder object creation using Observer2 with NewL is successful."));
   329  			}
   330  		else if (error==KErrExtensionNotSupported)
   331 	    	{
   332 	    	INFO_PRINTF1(_L("CCameraClientViewFinder object creation using Observer2 with NewL failed with correct error"));
   333 	    	}
   334 	    else
   335     		{
   336     		INFO_PRINTF1(_L("CCameraClientViewFinder object creation using Observer2 with NewL gave unexpected result"));
   337     		result = EFail;
   338     		}
   339 		CleanupStack::PopAndDestroy(camera);
   340 		}
   341 	else 
   342 		{
   343 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL()"), error);
   344 		result = EFail;	
   345 		User::Leave(KErrNoMemory);	
   346 		}
   347 	__MM_HEAP_MARKEND;
   348 /**************************************************************/
   349 	
   350 	// create client viewfinder object using New2L
   351 	__MM_HEAP_MARK;
   352 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
   353 	
   354 	TRAP(error, camera = CCamera::New2L(*this, 0, 0));
   355 
   356 	if (error==KErrNone)
   357 		{
   358 		CleanupStack::PushL(camera);
   359 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   360 		TRAP(error, clientVF  = CCamera::CCameraClientViewFinder::NewL(*camera, *this));	
   361 		
   362 		if (error==KErrNone)
   363 	    	{
   364 	    	CleanupStack::PushL(clientVF);
   365 	  		INFO_PRINTF1(_L("CCameraClientViewFinder object was created using NewL")); 
   366 	  		//Test Client ViewFinder APIs
   367 	  		INFO_PRINTF1(_L("Create Histogram for Client ViewFinder"));
   368 	  		CCamera::CCameraV2Histogram* histogram_CVF = clientVF->CreateHistogramHandleL();
   369 	  		if(!histogram_CVF)
   370 	  			{
   371 	  			INFO_PRINTF1(_L("Histogram creation for Client ViewFinder unsuccessful"));
   372 	  			result = EFail;
   373 	  			}
   374 	  			
   375 	  		CleanupStack::PushL(histogram_CVF);
   376 	  			
   377 	  		INFO_PRINTF1(_L("Create ImageProcessing for Client ViewFinder"));
   378 	  		
   379 	  		TRAPD(err, clientVF->GetTransformationHandleL());
   380   			if(err != KErrNotSupported)
   381   				{
   382   				INFO_PRINTF1(_L("ImageProcessing creation for Client ViewFinder: unexpected result!"));
   383   				result = EFail;
   384   				}
   385 	  		
   386 	  		//set properties for client VF (base class)
   387 	  		INFO_PRINTF1(_L("GetViewFinderFadingCapabilitiesL for Client ViewFinder"));
   388 	  		CCameraViewFinder::TViewFinderFadingCapabilities fadingCapabilities;
   389 	  		TRAP(err,clientVF->GetViewFinderFadingCapabilitiesL(fadingCapabilities));
   390   			if(err != KErrNotSupported)
   391   				{
   392   				INFO_PRINTF1(_L("GetViewFinderFadingCapabilitiesL for Client ViewFinder: unexpected result!"));
   393   				result = EFail;
   394   				}
   395 	  			
   396 	  		INFO_PRINTF1(_L("GetViewFinderFadingEffectL for Client ViewFinder"));
   397 	  		CCameraViewFinder::TViewFinderFadingEffect fadingEffect;
   398 	  		TRAP(err,clientVF->GetViewFinderFadingEffectL(fadingEffect));
   399   			if(err != KErrNotSupported)
   400   				{
   401   				INFO_PRINTF1(_L("GetViewFinderFadingEffectL for Client ViewFinder: unexpected result!"));
   402   				result = EFail;
   403   				}
   404 	
   405 			INFO_PRINTF1(_L("SetViewFinderFadingEffectL for Client ViewFinder"));
   406 			iInputEventUid = KUidECamEvent2ViewFinderFadingEffect;
   407 			clientVF->SetViewFinderFadingEffectL(fadingEffect);
   408 			CheckNotificationNeg(iInputEventUid, result);
   409 			
   410 			TInt vfHandle=-1;
   411 			clientVF->GetViewFinderHandleL(vfHandle);
   412 	  	
   413 	  		//set properties for histogram (for viewfinder)
   414 	  		TUint supportedHistogramType=0;
   415 	  		histogram_CVF->GetSupportedHistogramsL(supportedHistogramType);
   416 	  		if(supportedHistogramType!=0)
   417 	  			{
   418 	  			INFO_PRINTF1(_L("unexpected GetSupportedHistogramsL"));
   419 	  			result = EFail;
   420 	  			}
   421 	  			
   422 	  		INFO_PRINTF1(_L("GetDirectHistogramSupportInfoL for Histogram for Client ViewFinder"));
   423 	  		TBool directHistogramSupported = EFalse;
   424 	  		TRAP(err,histogram_CVF->GetDirectHistogramSupportInfoL(directHistogramSupported));
   425   			if(err != KErrNotSupported)
   426   				{
   427   				INFO_PRINTF1(_L("GetDirectHistogramSupportInfoL for Histogram for Client ViewFinder: unexpected result!"));
   428   				result = EFail;
   429   				}
   430 	  			
   431 	  		INFO_PRINTF1(_L("PrepareClientHistogramL for Histogram for Client ViewFinder"));
   432 	  		CCamera::CCameraV2Histogram::THistogramType histogramType = CCamera::CCameraV2Histogram::EHistNone;
   433 	  		TRAP(err,histogram_CVF->PrepareClientHistogramL(histogramType));
   434   			if(err != KErrNotSupported)
   435   				{
   436   				INFO_PRINTF1(_L("PrepareClientHistogramL for Histogram for Client ViewFinder: unexpected result!"));
   437   				result = EFail;
   438   				}
   439 	  		
   440 	  		INFO_PRINTF1(_L("PrepareDirectHistogramL for Histogram for Client ViewFinder"));
   441 	  		CCamera::CCameraV2Histogram::TDirectHistogramParameters histogramParameters;
   442 	  		TRAP(err,histogram_CVF->PrepareDirectHistogramL(histogramParameters));
   443   			if(err != KErrNotSupported)
   444   				{
   445   				INFO_PRINTF1(_L("PrepareDirectHistogramL for Histogram for Client ViewFinder: unexpected result!"));
   446   				result = EFail;
   447   				}
   448 	  			
   449 	  		INFO_PRINTF1(_L("UpdateDirectHistogramPropertiesL for Histogram for Client ViewFinder"));
   450 	   		TRAP(err,histogram_CVF->UpdateDirectHistogramPropertiesL(histogramParameters));
   451   			if(err != KErrNotSupported)
   452   				{
   453   				INFO_PRINTF1(_L("UpdateDirectHistogramPropertiesL for Histogram for Client ViewFinder: unexpected result!"));
   454   				result = EFail;
   455   				}
   456 	  			
   457 	  		INFO_PRINTF1(_L("GetDirectHistogramPropertiesL for Histogram for Client ViewFinder"));
   458 	   		TRAP(err,histogram_CVF->GetDirectHistogramPropertiesL(histogramParameters));
   459   			if(err != KErrNotSupported)
   460   				{
   461   				INFO_PRINTF1(_L("GetDirectHistogramPropertiesL for Histogram for Client ViewFinder: unexpected result!"));
   462   				result = EFail;
   463   				}
   464 	  			
   465 			INFO_PRINTF1(_L("GetHistogramStateL for Histogram for Client ViewFinder"));
   466 	   		TBool histogramActive = EFalse;
   467 	   		TRAP(err,histogram_CVF->GetHistogramStateL(histogramActive));
   468   			if(err != KErrNotSupported)
   469   				{
   470   				INFO_PRINTF1(_L("GetHistogramStateL for Histogram for Client ViewFinder: unexpected result!"));
   471   				result = EFail;
   472   				}
   473 			
   474   			//viewfinder starting...
   475   			INFO_PRINTF1(_L("StartClientViewFinderL for Client ViewFinder"));
   476 			TSize size(320,240);
   477   			TRAP(err,clientVF->StartClientViewFinderL(0, CCamera::EFormatFbsBitmapColor64K, size));
   478   			if(err != KErrNone)
   479   				{
   480   				INFO_PRINTF1(_L("StartClientViewFinderL for Client ViewFinder: unexpected result!"));
   481   				result = EFail;
   482   				}
   483 			CheckViewFinderNegNotification(vfHandle, result);
   484 			
   485 			INFO_PRINTF1(_L("GetViewFinderBufferL for Client ViewFinder"));
   486 			CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
   487 			CleanupStack::PushL(bitmap);
   488 			RCamBuffer2 cameraVFBuffer(bitmap);
   489 			TRAP(err,clientVF->GetViewFinderBufferL(cameraVFBuffer));
   490 			if(err != KErrNotSupported)
   491   				{
   492   				INFO_PRINTF1(_L("GetViewFinderBufferL for Client ViewFinder: unexpected result!"));
   493   				result = EFail;
   494   				}
   495   			CleanupStack::PopAndDestroy(bitmap);
   496 			
   497 			TRect clipRect(TPoint(0,0),size);
   498 			TRAP(err,clientVF->StartClientViewFinderL(0, CCamera::EFormatFbsBitmapColor64K, size, clipRect));
   499 			if(err != KErrNone)
   500   				{
   501   				INFO_PRINTF1(_L("StartClientViewFinderL for Client ViewFinder: unexpected result!"));
   502   				result = EFail;
   503   				}
   504 			CheckViewFinderNegNotification(vfHandle, result);
   505 			
   506 			INFO_PRINTF1(_L("GetClientViewFinderStateL for Client ViewFinder"));
   507 			TBool activeVF = EFalse;;
   508 			TRAP(err,clientVF->GetClientViewFinderStateL(activeVF));
   509 			if(err != KErrNotSupported)
   510   				{
   511   				INFO_PRINTF1(_L("GetClientViewFinderStateL for Client ViewFinder: unexpected result!"));
   512   				result = EFail;
   513   				}
   514 			
   515 			INFO_PRINTF1(_L("StartHistogram for Client ViewFinder"));
   516 			histogram_CVF->StartHistogram();
   517 			CheckViewFinderNegNotification(vfHandle, result);
   518 	  		
   519 	  		INFO_PRINTF1(_L("StopHistogram for Client ViewFinder"));	
   520 			histogram_CVF->StopHistogram();
   521 			
   522 			INFO_PRINTF1(_L("GetClientViewFinderPropertiesL for Client ViewFinder"));	
   523 			TInt screenNumber=0;
   524 			CCamera::TFormat imageFormat=CCamera::EFormatFbsBitmapColor64K;
   525 			TRAP(err,clientVF->GetClientViewFinderPropertiesL(screenNumber, imageFormat, size, clipRect));
   526 			if(err != KErrNotSupported)
   527   				{
   528   				INFO_PRINTF1(_L("GetClientViewFinderPropertiesL for Client ViewFinder: unexpected result!"));
   529   				result = EFail;
   530   				}
   531   				
   532   			INFO_PRINTF1(_L("StopClientViewFinder for Client ViewFinder"));		
   533 			clientVF->StopClientViewFinder();
   534 	
   535   			CleanupStack::PopAndDestroy(histogram_CVF);
   536 	    	CleanupStack::PopAndDestroy(clientVF);
   537 	    	}
   538 	    else
   539     		{
   540     		INFO_PRINTF1(_L("CCameraClientViewFinder object not created")); 
   541     		result = EFail;
   542     		}	
   543 		CleanupStack::PopAndDestroy(camera);
   544 		}
   545 	else 
   546 		{
   547 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
   548 		result = EFail;		
   549 		}
   550 	__MM_HEAP_MARKEND;
   551    
   552 	return result;	
   553 	}
   554 	
   555 /*------------------------------------------------------
   556  	Direct ViewFinder : RECamV2DirectViewFinderTest
   557  *------------------------------------------------------*/
   558 RECamV2DirectViewFinderTest* RECamV2DirectViewFinderTest::NewL(const TDesC& aTestStep)
   559 	{
   560 	RECamV2DirectViewFinderTest* self = new (ELeave) RECamV2DirectViewFinderTest(aTestStep);
   561 	return self;	
   562 	}
   563 	
   564 RECamV2DirectViewFinderTest::RECamV2DirectViewFinderTest(const TDesC& aTestStep)
   565 	{
   566 	iTestStepName.Copy(aTestStep);
   567 	}
   568 	
   569 TVerdict RECamV2DirectViewFinderTest::DoTestStepL()
   570 	{
   571 	if(!iTestStepName.Compare(_L("MM-ECM-ADV-U-052-HP")))
   572 		{
   573 		return DoTestStep_52L();
   574 		}
   575 	return EInconclusive;	
   576 	}
   577 	
   578 TVerdict RECamV2DirectViewFinderTest::DoTestStep_52L()
   579 	{	
   580 	TVerdict verdict = EFail;
   581 	INFO_PRINTF1(_L("Alloc test"));
   582 	TInt i;
   583 	TInt err;
   584 	for (i = 1 ; ; i++)
   585 		{
   586 		__MM_HEAP_MARK;
   587 		
   588 		if (i % 5 == 0)
   589 			{
   590 			INFO_PRINTF2(_L("Fail count = %d"), i);
   591 			}
   592 
   593 		__UHEAP_SETFAIL(RHeap::EFailNext, i);
   594 
   595 		TRAP(err, verdict = DoV2DirectVFTestStepL());
   596 
   597 		TAny* testAlloc = User::Alloc(1);
   598 		TBool heapTestingComplete = (testAlloc == NULL) && (err==KErrNone);
   599 		User::Free(testAlloc);
   600 
   601 		__UHEAP_RESET;
   602 		__MM_HEAP_MARKEND;
   603 
   604 		if ((err != KErrNoMemory ) || heapTestingComplete)
   605 			{
   606 			INFO_PRINTF4(_L("err = %d, verdict = %d, Fail count = %d"), err, verdict, i);
   607 			INFO_PRINTF1(_L("Alloc testing completed successfully"));
   608 			verdict = EPass;
   609 			break;
   610 			}
   611 		}
   612 	return verdict;
   613 	}
   614 	
   615 TVerdict RECamV2DirectViewFinderTest::DoV2DirectVFTestStepL()
   616 	{
   617 	TVerdict result = EPass;
   618 	CCamera* camera = NULL;
   619 	
   620 	MCameraObserver* observer = NULL;
   621 	MDirectViewFinderObserver* directVFObserver = NULL;
   622 	
   623 	TInt error = KErrNone;
   624 	CCamera::CCameraV2DirectViewFinder* directVF = NULL;
   625 	
   626 	// using observer 	
   627 	__MM_HEAP_MARK;
   628 	INFO_PRINTF1(_L("Create camera using Camera::NewL() and MCameraObserver"));
   629 	TRAP(error, camera = CCamera::NewL(*observer, 0));
   630 	if (error==KErrNone)
   631 		{
   632 		CleanupStack::PushL(camera);
   633 		INFO_PRINTF1(_L("Create v2 direct viewfinder from CCamera object"));
   634 		
   635 		TRAP(error, directVF  = CCamera::CCameraV2DirectViewFinder::NewL(*camera, *directVFObserver));	
   636  		if (error==KErrExtensionNotSupported)
   637 	    	{
   638 	    	INFO_PRINTF1(_L("CCameraV2DirectViewFinder object creation using old Observer failed with correct error"));
   639 	    	}
   640 	    else
   641     		{
   642     		INFO_PRINTF1(_L("CCameraV2DirectViewFinder object creation using old Observer gave unexpected result"));
   643     		result = EFail;
   644     		}	
   645 		CleanupStack::PopAndDestroy(camera);
   646 		}
   647 	else 
   648 		{
   649 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL()"), error);
   650 		result = EFail;	
   651 		User::Leave(KErrNoMemory);	
   652 		}
   653 	__MM_HEAP_MARKEND;
   654 	
   655 	// using observer2 with NewL 
   656 	MCameraObserver2* observer2 = NULL;	
   657 	__MM_HEAP_MARK;
   658 	INFO_PRINTF1(_L("Create camera using Camera::NewL() and MCameraObserver2"));
   659 	TRAP(error, camera = CCamera::NewL(*observer2, 0,0));
   660 	if (error==KErrNone)
   661 		{
   662 		CleanupStack::PushL(camera);
   663 		INFO_PRINTF1(_L("Create v2 direct viewfinder from CCamera object"));
   664 		
   665 		TRAP(error, directVF  = CCamera::CCameraV2DirectViewFinder::NewL(*camera, *directVFObserver));	
   666  		if (error==KErrExtensionNotSupported)
   667 	    	{
   668 	    	INFO_PRINTF1(_L("CCameraV2DirectViewFinder object creation using Observer2 with NewL failed with correct error"));
   669 	    	}
   670 	    else
   671     		{
   672     		INFO_PRINTF1(_L("CCameraV2DirectViewFinder object creation using Observer2 with NewL gave unexpected result"));
   673     		result = EFail;
   674     		}	
   675 		CleanupStack::PopAndDestroy(camera);
   676 		}
   677 	else 
   678 		{
   679 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL()"), error);
   680 		result = EFail;	
   681 		User::Leave(KErrNoMemory);	
   682 		}
   683 	__MM_HEAP_MARKEND;
   684 	
   685 	// create v2 direct viewfinder object using New2L
   686 	__MM_HEAP_MARK;
   687 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
   688 	
   689 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
   690 	if (error==KErrNone)
   691 		{
   692 		CleanupStack::PushL(camera);
   693 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   694 		TRAP(error, directVF = CCamera::CCameraV2DirectViewFinder::NewL(*camera, *directVFObserver));	
   695 		
   696 		if (error==KErrNone)
   697 	    	{
   698 	    	CleanupStack::PushL(directVF);
   699 	  		INFO_PRINTF1(_L("CCameraV2DirectViewFinder object was created using NewL")); 
   700 	    	CleanupStack::PopAndDestroy(directVF);
   701 	    	}
   702 	    else
   703     		{
   704     		INFO_PRINTF1(_L("CCameraV2DirectViewFinder object was not created using NewL")); 
   705     		result = EFail;
   706     		User::Leave(KErrNoMemory);
   707     		}	
   708 		CleanupStack::PopAndDestroy(camera);
   709 		}
   710 	else 
   711 		{
   712 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
   713 		result = EFail;
   714 		User::Leave(KErrNoMemory);		
   715 		}
   716 	__MM_HEAP_MARKEND;
   717    
   718 	return result;
   719 	}
   720 
   721 /*------------------------------------------------------
   722  	Direct ViewFinder : RECamV2DirectVFNotificationTest
   723  *------------------------------------------------------*/
   724 RECamV2DirectVFNotificationTest* RECamV2DirectVFNotificationTest::NewL(TBool aAllocTest)
   725 	{
   726 	RECamV2DirectVFNotificationTest* self = new (ELeave) RECamV2DirectVFNotificationTest(aAllocTest);
   727 	CleanupStack::PushL(self);
   728 	self->ConstructL();
   729 	CleanupStack::Pop(self);
   730 	return self;	
   731 	}
   732 	
   733 void RECamV2DirectVFNotificationTest::ConstructL()
   734 	{
   735 	}
   736 	
   737 RECamV2DirectVFNotificationTest::RECamV2DirectVFNotificationTest(TBool /*aAllocTest*/)
   738 	{
   739 	iTestStepName = _L("MM-ECM-ADV-U-053-HP");
   740 	}
   741 	
   742 void RECamV2DirectVFNotificationTest::DirectViewFinderFirstFrameDisplayed(CCamera::CCameraV2DirectViewFinder& aDirectViewFinderHandle, TInt aErrorCode)
   743 	{
   744 	aDirectViewFinderHandle.GetViewFinderHandleL(iVFHandle);
   745 	iError = aErrorCode;
   746 	}
   747 
   748 void RECamV2DirectVFNotificationTest::DirectHistogramDisplayed(CCamera::CCameraV2DirectViewFinder& aDirectViewFinderHandle, CCamera::CCameraV2Histogram& /*aDirectHistogramDisplayed*/, TInt aErrorCode)
   749 	{
   750 	aDirectViewFinderHandle.GetViewFinderHandleL(iVFHandle);
   751 	iError = aErrorCode;
   752 	}
   753 
   754 void RECamV2DirectVFNotificationTest::ClientHistogramReady(CCamera::CCameraV2DirectViewFinder& aDirectViewFinderHandle, MHistogramV2Buffer* /*aClientHistogramBuffer*/, TInt aErrorCode)
   755 	{
   756 	aDirectViewFinderHandle.GetViewFinderHandleL(iVFHandle);
   757 	iError = aErrorCode;
   758 	}
   759 	
   760 void RECamV2DirectVFNotificationTest::DirectViewFinderFailed(CCamera::CCameraV2DirectViewFinder& aDirectViewFinderHandle, TInt aErrorCode)
   761 	{
   762 	aDirectViewFinderHandle.GetViewFinderHandleL(iVFHandle);
   763 	iError = aErrorCode;	
   764 	}
   765 	
   766 void RECamV2DirectVFNotificationTest::DirectSnapshotForImageDisplayed(CCamera::CCameraV2DirectViewFinder& aDirectViewFinderHandle, CCamera::CCameraImageCapture& /*aCaptureImageHandle*/, TPostCaptureControlId /*aPostCaptureControlId*/, TInt aErrorCode)
   767 	{
   768 	aDirectViewFinderHandle.GetViewFinderHandleL(iVFHandle);
   769 	iError = aErrorCode;
   770 	}
   771 	
   772 TInt RECamV2DirectVFNotificationTest::CustomInterface(TUid /*aInterface*/, TAny*& /*aPtrInterface*/)
   773 	{
   774 	return KErrNone;
   775 	}
   776 
   777 void RECamV2DirectVFNotificationTest::CheckViewFinderNegNotification(TInt aVFHandle, TVerdict& aResult)	
   778 	{
   779 	INFO_PRINTF4(_L("Expected DirectViewFinder Id %d, received event %x. Error %d."), aVFHandle, iVFHandle, iError); 
   780 	if (aVFHandle != iVFHandle || iError != KErrNotSupported)
   781 		{
   782 	    aResult = EFail;
   783 	    }
   784 	}
   785 	
   786 TVerdict RECamV2DirectVFNotificationTest::DoTestStepL()
   787 	{
   788 	TVerdict verdict = EFail;
   789 	INFO_PRINTF1(_L("Alloc test"));
   790 	
   791 	TInt i, err;
   792 	
   793 	for (i =1; ;i++)
   794 		{
   795 		if (i % 5 == 0)
   796 			{
   797 			INFO_PRINTF2(_L("Fail count = %d"), i);
   798 			}
   799 
   800 		__UHEAP_SETFAIL(RHeap::EFailNext,i);
   801 		__MM_HEAP_MARK;
   802 
   803 		TRAP(err,verdict = DoTestStep_53L());
   804 
   805 		TAny* testAlloc = User::Alloc(1);
   806 		TBool heapTestingComplete = ((testAlloc == NULL ) && (err == KErrNone));
   807 		User::Free(testAlloc);
   808 
   809 		if ((err != KErrNoMemory && verdict == EPass) || heapTestingComplete)
   810 			{
   811 			INFO_PRINTF4(_L("err = %d, verdict = %d, Fail count = %d"), err, verdict, i);
   812 			INFO_PRINTF1(_L("Alloc testing completed successfully"));
   813 			verdict = EPass;
   814 			break;
   815 			}
   816 
   817 		__MM_HEAP_MARKEND;
   818 		__UHEAP_RESET;
   819 		}
   820 	return verdict;	
   821 	}
   822 
   823 TVerdict RECamV2DirectVFNotificationTest::DoTestStep_53L()
   824 	{
   825 	TVerdict result = EPass;
   826 	CCamera* camera = NULL;
   827 	
   828 	TInt error = KErrNone;
   829 	CCamera::CCameraV2DirectViewFinder* directVF = NULL;
   830 	
   831 	// create client viewfinder object using New2L
   832 	__MM_HEAP_MARK;
   833 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
   834 	
   835 	TRAP(error, camera = CCamera::New2L(*this, 0, 0));
   836 
   837 	if (error==KErrNone)
   838 		{
   839 		CleanupStack::PushL(camera);
   840 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   841 		TRAP(error, directVF  = CCamera::CCameraV2DirectViewFinder::NewL(*camera, *this));	
   842 		
   843 		if (error==KErrNone)
   844 	    	{
   845 	    	CleanupStack::PushL(directVF);
   846 	  		INFO_PRINTF1(_L("CCameraV2DirectViewFinder object was created using NewL")); 
   847 	  		//Test Direct ViewFinder APIs
   848 	  		INFO_PRINTF1(_L("Create Histogram for Direct ViewFinder"));
   849 	  		CCamera::CCameraV2Histogram* histogram_DVF = directVF->CreateHistogramHandleL();
   850 	  		if(!histogram_DVF)
   851 	  			{
   852 	  			INFO_PRINTF1(_L("Histogram creation for Direct ViewFinder unsuccessful"));
   853 	  			result = EFail;
   854 	  			}
   855 	  			
   856 	  		CleanupStack::PushL(histogram_DVF);
   857 	  			
   858 	  		INFO_PRINTF1(_L("Create ImageProcessing for Direct ViewFinder"));
   859 	  		
   860 	  		TRAPD(err, directVF->GetTransformationHandleL());
   861   			if(err != KErrNotSupported)
   862   				{
   863   				INFO_PRINTF1(_L("ImageProcessing creation for Direct ViewFinder: unexpected result!"));
   864   				result = EFail;
   865   				}
   866 	  		
   867 	  		//set properties for direct VF (base class)
   868 	  		INFO_PRINTF1(_L("GetViewFinderFadingCapabilitiesL for Direct ViewFinder"));
   869 	  		CCameraViewFinder::TViewFinderFadingCapabilities fadingCapabilities;
   870 	  		TRAP(err,directVF->GetViewFinderFadingCapabilitiesL(fadingCapabilities));
   871   			if(err != KErrNotSupported)
   872   				{
   873   				INFO_PRINTF1(_L("GetViewFinderFadingCapabilitiesL for Direct ViewFinder: unexpected result!"));
   874   				result = EFail;
   875   				}
   876 	  			
   877 	  		INFO_PRINTF1(_L("GetViewFinderFadingEffectL for Direct ViewFinder"));
   878 	  		CCameraViewFinder::TViewFinderFadingEffect fadingEffect;
   879 	  		TRAP(err,directVF->GetViewFinderFadingEffectL(fadingEffect));
   880   			if(err != KErrNotSupported)
   881   				{
   882   				INFO_PRINTF1(_L("GetViewFinderFadingEffectL for Direct ViewFinder: unexpected result!"));
   883   				result = EFail;
   884   				}
   885 	
   886 			INFO_PRINTF1(_L("SetViewFinderFadingEffectL for Direct ViewFinder"));
   887 			iInputEventUid = KUidECamEvent2ViewFinderFadingEffect;
   888 			directVF->SetViewFinderFadingEffectL(fadingEffect);
   889 			CheckNotificationNeg(iInputEventUid, result);
   890 			
   891 			TInt vfHandle=-1;
   892 			directVF->GetViewFinderHandleL(vfHandle);
   893 	  	
   894 	  		//set properties for histogram (for viewfinder)
   895 	  		TUint supportedHistogramType=0;
   896 	  		histogram_DVF->GetSupportedHistogramsL(supportedHistogramType);
   897 	  		if(supportedHistogramType!=0)
   898 	  			{
   899 	  			INFO_PRINTF1(_L("unexpected GetSupportedHistogramsL"));
   900 	  			result = EFail;
   901 	  			}
   902 	  			
   903 	  		INFO_PRINTF1(_L("GetDirectHistogramSupportInfoL for Histogram for Direct ViewFinder"));
   904 	  		TBool directHistogramSupported = EFalse;
   905 	  		TRAP(err,histogram_DVF->GetDirectHistogramSupportInfoL(directHistogramSupported));
   906   			if(err != KErrNotSupported)
   907   				{
   908   				INFO_PRINTF1(_L("GetDirectHistogramSupportInfoL for Histogram for Direct ViewFinder: unexpected result!"));
   909   				result = EFail;
   910   				}
   911 	  			
   912 	  		INFO_PRINTF1(_L("PrepareClientHistogramL for Histogram for Direct ViewFinder"));
   913 	  		CCamera::CCameraV2Histogram::THistogramType histogramType = CCamera::CCameraV2Histogram::EHistNone;
   914 	  		TRAP(err,histogram_DVF->PrepareClientHistogramL(histogramType));
   915   			if(err != KErrNotSupported)
   916   				{
   917   				INFO_PRINTF1(_L("PrepareClientHistogramL for Histogram for Direct ViewFinder: unexpected result!"));
   918   				result = EFail;
   919   				}
   920 	  		
   921 	  		INFO_PRINTF1(_L("PrepareDirectHistogramL for Histogram for Direct ViewFinder"));
   922 	  		CCamera::CCameraV2Histogram::TDirectHistogramParameters histogramParameters;
   923 	  		TRAP(err,histogram_DVF->PrepareDirectHistogramL(histogramParameters));
   924   			if(err != KErrNotSupported)
   925   				{
   926   				INFO_PRINTF1(_L("PrepareDirectHistogramL for Histogram for Direct ViewFinder: unexpected result!"));
   927   				result = EFail;
   928   				}
   929 	  			
   930 	  		INFO_PRINTF1(_L("UpdateDirectHistogramPropertiesL for Histogram for Direct ViewFinder"));
   931 	   		TRAP(err,histogram_DVF->UpdateDirectHistogramPropertiesL(histogramParameters));
   932   			if(err != KErrNotSupported)
   933   				{
   934   				INFO_PRINTF1(_L("UpdateDirectHistogramPropertiesL for Histogram for Direct ViewFinder: unexpected result!"));
   935   				result = EFail;
   936   				}
   937 	  			
   938 	  		INFO_PRINTF1(_L("GetDirectHistogramPropertiesL for Histogram for Direct ViewFinder"));
   939 	   		TRAP(err,histogram_DVF->GetDirectHistogramPropertiesL(histogramParameters));
   940   			if(err != KErrNotSupported)
   941   				{
   942   				INFO_PRINTF1(_L("GetDirectHistogramPropertiesL for Histogram for Direct ViewFinder: unexpected result!"));
   943   				result = EFail;
   944   				}
   945 	  			
   946 			INFO_PRINTF1(_L("GetHistogramStateL for Histogram for Direct ViewFinder"));
   947 	   		TBool histogramActive = EFalse;
   948 	   		TRAP(err,histogram_DVF->GetHistogramStateL(histogramActive));
   949   			if(err != KErrNotSupported)
   950   				{
   951   				INFO_PRINTF1(_L("GetHistogramStateL for Histogram for Direct ViewFinder: unexpected result!"));
   952   				result = EFail;
   953   				}
   954 		
   955   			//viewfinder starting...
   956   			INFO_PRINTF1(_L("StartViewFinderDirectL for Direct ViewFinder"));
   957   			TSize size(320,240);
   958 			TRect rect(TPoint(0,0),size);
   959 			TRect cliprect(rect);
   960 			RWsSession ws;
   961 			CWsScreenDevice* screenDevice = NULL;
   962 			RWindow window;
   963   			TRAP(err,directVF->StartViewFinderDirectL(ws, *screenDevice, window, rect));
   964   			if(err != KErrNone)
   965   				{
   966   				INFO_PRINTF1(_L("StartViewFinderDirectL for Direct ViewFinder: unexpected result!"));
   967   				result = EFail;
   968   				}
   969 			CheckViewFinderNegNotification(vfHandle, result);
   970 			
   971 			TRAP(err,directVF->StartViewFinderDirectL(ws, *screenDevice, window, rect, cliprect));
   972   			if(err != KErrNone)
   973   				{
   974   				INFO_PRINTF1(_L("StartViewFinderDirectL (with cliprect) for Direct ViewFinder: unexpected result!"));
   975   				result = EFail;
   976   				}
   977 			CheckViewFinderNegNotification(vfHandle, result);
   978 			
   979 			INFO_PRINTF1(_L("GetDirectViewFinderPropertiesL for Direct ViewFinder"));
   980 			TInt screenNumber=0;
   981 			TRAP(err,directVF->GetDirectViewFinderPropertiesL(screenNumber, rect, cliprect));
   982 			if(err != KErrNotSupported)
   983   				{
   984   				INFO_PRINTF1(_L("GetDirectViewFinderPropertiesL for Direct ViewFinder: unexpected result!"));
   985   				result = EFail;
   986   				}
   987   				
   988   			INFO_PRINTF1(_L("PauseViewFinderDirect for Direct ViewFinder"));
   989 			directVF->PauseViewFinderDirect();
   990 			
   991 			INFO_PRINTF1(_L("ResumeViewFinderDirect for Direct ViewFinder"));
   992 			directVF->ResumeViewFinderDirect();
   993 			CheckViewFinderNegNotification(vfHandle, result);
   994 			
   995 			INFO_PRINTF1(_L("StartHistogram for Direct ViewFinder"));
   996 			histogram_DVF->StartHistogram();
   997 			CheckViewFinderNegNotification(vfHandle, result);
   998 	  		
   999 	  		INFO_PRINTF1(_L("StopHistogram for Direct ViewFinder"));	
  1000 			histogram_DVF->StopHistogram();
  1001 			
  1002 			INFO_PRINTF1(_L("GetViewFinderStateL for Direct ViewFinder"));
  1003 			CCamera::CCameraV2DirectViewFinder::TViewFinderState vfState = CCamera::CCameraV2DirectViewFinder::EViewFinderInActive;
  1004 			TRAP(err,directVF->GetViewFinderStateL(vfState));
  1005 			if(err != KErrNotSupported)
  1006   				{
  1007   				INFO_PRINTF1(_L("GetViewFinderStateL for Direct ViewFinder: unexpected result!"));
  1008   				result = EFail;
  1009   				}
  1010   				
  1011   			//access direct snapshot functionality
  1012   			INFO_PRINTF1(_L("Access direct snapshot functionality"));
  1013   			CCamera::CCameraDirectSnapshot* directSnapshot = directVF->GetDirectSnapshotHandleL();
  1014   			if(directSnapshot == NULL)
  1015 	  			{
  1016 	  			INFO_PRINTF1(_L("Direct Snapshot creation for Direct ViewFinder unsuccessful"));
  1017 	  			result = EFail;
  1018 	  			}
  1019 	  			
  1020 	  		CleanupStack::PushL(directSnapshot);
  1021 	  		
  1022 	  		INFO_PRINTF1(_L("Get parent viewfinder for direct snapshot"));
  1023 	  		CCamera::CCameraV2DirectViewFinder* directViewFinder = NULL;
  1024 	  		TRAP(err, directSnapshot->GetDirectViewFinderL(directViewFinder));
  1025   			if(err != KErrNone)
  1026   				{
  1027   				INFO_PRINTF1(_L("GetDirectViewFinderL for Direct ViewFinder Snapshot: unexpected result!"));
  1028   				result = EFail;
  1029   				}
  1030   			
  1031   			TInt viewfinderHandle = -1;
  1032   			directViewFinder->GetViewFinderHandleL(viewfinderHandle);
  1033   			if(vfHandle != viewfinderHandle)
  1034   				{
  1035   				INFO_PRINTF1(_L("Parent Viewfinder for Direct ViewFinder Snapshot: unexpected result!"));
  1036   				result = EFail;
  1037   				}
  1038   			
  1039   			CCamera::CCameraDirectSnapshot::TDirectSnapshotParameters directSnapshotParameters;
  1040   			
  1041   			if(directSnapshotParameters.Size() != sizeof(CCamera::CCameraDirectSnapshot::TDirectSnapshotParameters) ||
  1042   				directSnapshotParameters.Version() != KECamDirectSnapshotParametersCurrentVersion)
  1043   				{
  1044   				INFO_PRINTF1(_L("TDirectSnapshotParameters has different version for Direct Snapshot: unexpected result!"));
  1045   				result = EFail;
  1046   				}
  1047   			
  1048    			INFO_PRINTF1(_L("SetAspectRatioState for Direct Snapshot"));
  1049 			directSnapshotParameters.SetAspectRatioState(ETrue);
  1050 			TBool aspectRatioState = directSnapshotParameters.IsAspectRatioMaintained();
  1051 			if(!aspectRatioState)
  1052 				{
  1053 				INFO_PRINTF1(_L("AspectRatioState for Direct Snapshot: unexpected result!"));
  1054   				result = EFail;
  1055 				}
  1056 				
  1057 			directSnapshotParameters.SetAspectRatioState(EFalse);
  1058 			aspectRatioState = directSnapshotParameters.IsAspectRatioMaintained();
  1059 			if(aspectRatioState != EFalse)
  1060 				{
  1061 				INFO_PRINTF1(_L("AspectRatioState for Direct Snapshot: unexpected result!"));
  1062   				result = EFail;
  1063 				}
  1064 			
  1065 			INFO_PRINTF1(_L("EnableDirectSnapshotL for Direct Snapshot"));	
  1066   			TRAP(err, directSnapshot->EnableDirectSnapshotL(directSnapshotParameters));
  1067   			if(err != KErrNone)
  1068   				{
  1069   				INFO_PRINTF1(_L("EnableDirectSnapshotL for DirectSnapshot: unexpected result!"));
  1070   				result = EFail;
  1071   				}
  1072   			
  1073   			INFO_PRINTF1(_L("GetDirectSnapshotStateL for Direct Snapshot"));
  1074   			CCamera::CCameraDirectSnapshot::TDirectSnapshotState directSnapshotState;	
  1075   			TRAP(err, directSnapshot->GetDirectSnapshotStateL(directSnapshotState));
  1076   			if(err != KErrNone)
  1077   				{
  1078   				INFO_PRINTF1(_L("GetDirectSnapshotStateL for DirectSnapshot: unexpected result!"));
  1079   				result = EFail;
  1080   				}
  1081   				
  1082   			if(CCamera::CCameraDirectSnapshot::EDirectSnapshotEnabled != directSnapshotState)
  1083   				{
  1084   				INFO_PRINTF1(_L("DirectSnapshotState not set properly: unexpected result!"));
  1085   				result = EFail;
  1086   				}
  1087   			
  1088   			INFO_PRINTF1(_L("GetDirectSnapshotParametersL for Direct Snapshot"));
  1089   			CCamera::CCameraDirectSnapshot::TDirectSnapshotParameters directSnapshotParam;	
  1090   			TRAP(err, directSnapshot->GetDirectSnapshotParametersL(directSnapshotParam));
  1091   			if(err != KErrNone)
  1092   				{
  1093   				INFO_PRINTF1(_L("GetDirectSnapshotParametersL for DirectSnapshot: unexpected result!"));
  1094   				result = EFail;
  1095   				}
  1096   				
  1097   			if(directSnapshotParam.IsAspectRatioMaintained() != directSnapshotParameters.IsAspectRatioMaintained())
  1098   				{
  1099   				INFO_PRINTF1(_L("DirectSnapshotParameters for DirectSnapshot wrongly set: unexpected result!"));
  1100   				result = EFail;
  1101   				}
  1102   			
  1103   			INFO_PRINTF1(_L("SetDirectSnapshotParametersL for Direct Snapshot"));
  1104   			directSnapshotParameters.SetAspectRatioState(ETrue);	
  1105   			TRAP(err, directSnapshot->SetDirectSnapshotParametersL(directSnapshotParameters));
  1106 			if(err != KErrNone)
  1107 				{
  1108 				INFO_PRINTF1(_L("SetDirectSnapshotParametersL for DirectSnapshot: unexpected result!"));
  1109   				result = EFail;	
  1110 				}
  1111 			
  1112 			INFO_PRINTF1(_L("DisableDirectSnapshot for Direct Snapshot"));
  1113 			directSnapshot->DisableDirectSnapshot();
  1114 			TRAP(err, directSnapshot->GetDirectSnapshotStateL(directSnapshotState));
  1115   			if(err != KErrNone)
  1116   				{
  1117   				INFO_PRINTF1(_L("GetDirectSnapshotStateL for DirectSnapshot: unexpected result!"));
  1118   				result = EFail;
  1119   				}
  1120   			
  1121   			if(CCamera::CCameraDirectSnapshot::EDirectSnapshotDisabled != directSnapshotState)
  1122   				{
  1123   				INFO_PRINTF1(_L("GetDirectSnapshotStateL for DirectSnapshot: unexpected result!"));
  1124   				result = EFail;
  1125   				}
  1126 							
  1127 			INFO_PRINTF1(_L("StopDirectViewFinder for Direct ViewFinder"));
  1128 			directVF->StopDirectViewFinder();
  1129 			
  1130 			CleanupStack::PopAndDestroy(directSnapshot);
  1131 			CleanupStack::PopAndDestroy(histogram_DVF);
  1132 	    	CleanupStack::PopAndDestroy(directVF);
  1133 	    	}
  1134 	    else
  1135     		{
  1136     		INFO_PRINTF1(_L("CCameraV2DirectViewFinder object not created")); 
  1137     		result = EFail;
  1138     		}	
  1139 		CleanupStack::PopAndDestroy(camera);
  1140 		}
  1141 	else 
  1142 		{
  1143 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
  1144 		result = EFail;		
  1145 		}
  1146 	__MM_HEAP_MARKEND;
  1147    
  1148 	return result;	
  1149 	}
  1150 /*------------------------------------------------------------------
  1151  	Pre Image Capture Control : RECamPreImgCaptureNotificationTest
  1152  *-----------------------------------------------------------------*/
  1153 RECamPreImgCaptureNotificationTest* RECamPreImgCaptureNotificationTest::NewL(TBool aAllocTest)
  1154 	{
  1155 	return new (ELeave)RECamPreImgCaptureNotificationTest(aAllocTest);
  1156 	}
  1157 	
  1158 RECamPreImgCaptureNotificationTest::RECamPreImgCaptureNotificationTest(TBool /*aAllocTest*/)
  1159 	{
  1160 	iTestStepName = _L("MM-ECM-ADV-U-054-HP");
  1161 	iCaptureImageHandle = NULL;
  1162 	}
  1163 	
  1164 void RECamPreImgCaptureNotificationTest::PrepareImageComplete(CCamera::CCameraImageCapture* aCaptureImageHandle, TInt aErrorCode)
  1165 	{
  1166 	iCaptureImageHandle = aCaptureImageHandle;
  1167 	iError = aErrorCode;
  1168 	}
  1169 
  1170 TInt RECamPreImgCaptureNotificationTest::CustomInterface(TUid /*aInterface*/, TAny*& /*aPtrInterface*/)
  1171 	{
  1172 	return KErrNone;
  1173 	}
  1174 
  1175 void RECamPreImgCaptureNotificationTest::CheckCaptureNotification(CCamera::CCameraImageCapture*& aImageCapture, TVerdict& aResult)
  1176 	{
  1177 	INFO_PRINTF2(_L("Pre Image Capture Control Error %d, "), iError); 
  1178 	if (iError != KErrNone)
  1179 		{
  1180 	    aResult = EFail;
  1181 	    }
  1182 	else
  1183 		{
  1184 		aImageCapture = iCaptureImageHandle;
  1185 		}
  1186 	}
  1187 	
  1188 TVerdict RECamPreImgCaptureNotificationTest::DoTestStepL()
  1189 	{
  1190 	TVerdict verdict = EFail;
  1191 	INFO_PRINTF1(_L("Alloc test"));
  1192 	
  1193 	TInt i, err;
  1194 	
  1195 	for (i =1; ;i++)
  1196 		{
  1197 		if (i % 5 == 0)
  1198 			{
  1199 			INFO_PRINTF2(_L("Fail count = %d"), i);
  1200 			}
  1201 
  1202 		__UHEAP_SETFAIL(RHeap::EFailNext,i);
  1203 		__MM_HEAP_MARK;
  1204 
  1205 		TRAP(err,verdict = DoPreImgCaptureTestStepL());
  1206 
  1207 		TAny* testAlloc = User::Alloc(1);
  1208 		TBool heapTestingComplete = ((testAlloc == NULL ) && (err == KErrNone));
  1209 		User::Free(testAlloc);
  1210 
  1211 		if ((err != KErrNoMemory && verdict == EPass) || heapTestingComplete)
  1212 			{
  1213 			INFO_PRINTF4(_L("err = %d, verdict = %d, Fail count = %d"), err, verdict, i);
  1214 			INFO_PRINTF1(_L("Alloc testing completed successfully"));
  1215 			verdict = EPass;
  1216 			break;
  1217 			}
  1218 
  1219 		__MM_HEAP_MARKEND;
  1220 		__UHEAP_RESET;
  1221 		}
  1222 	return verdict;
  1223 	}
  1224 
  1225 TVerdict RECamPreImgCaptureNotificationTest::DoPreImgCaptureTestStepL()
  1226 	{
  1227 	TVerdict result = EPass;
  1228 	CCamera* camera = NULL;
  1229 	
  1230 	TInt error = KErrNone;
  1231 	CCamera::CCameraPreImageCaptureControl* preImgCapture = NULL;
  1232 	
  1233 	// using observer 	
  1234 	__MM_HEAP_MARK;
  1235 	MCameraObserver* observer=NULL;
  1236 	INFO_PRINTF1(_L("Create camera using Camera::NewL() and MCameraObserver"));
  1237 	TRAP(error, camera = CCamera::NewL(*observer, 0));
  1238 	if (error==KErrNone)
  1239 		{
  1240 		CleanupStack::PushL(camera);
  1241 		INFO_PRINTF1(_L("Create PreImageCaptureControl from CCamera object"));
  1242 		
  1243 		TRAP(error, preImgCapture  = CCamera::CCameraPreImageCaptureControl::NewL(*camera, *this));	
  1244  		if (error==KErrExtensionNotSupported)
  1245 	    	{
  1246 	    	INFO_PRINTF1(_L("CCameraPreImageCaptureControl object creation using old Observer failed with correct error"));
  1247 	    	}
  1248 	    else
  1249     		{
  1250     		INFO_PRINTF1(_L("CCameraPreImageCaptureControl object creation using old Observer gave unexpected result"));
  1251     		result = EFail;
  1252     		}	
  1253 		CleanupStack::PopAndDestroy(camera);
  1254 		}
  1255 	else 
  1256 		{
  1257 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL()"), error);
  1258 		result = EFail;	
  1259 		User::Leave(KErrNoMemory);	
  1260 		}
  1261 	__MM_HEAP_MARKEND;
  1262 	
  1263 	// using observer2 with NewL 
  1264 	__MM_HEAP_MARK;
  1265 	INFO_PRINTF1(_L("Create camera using Camera::NewL() and MCameraObserver2"));
  1266 	TRAP(error, camera = CCamera::NewL(*this, 0,0));
  1267 	if (error==KErrNone)
  1268 		{
  1269 		CleanupStack::PushL(camera);
  1270 		INFO_PRINTF1(_L("Create PreImageCaptureControl from CCamera object"));
  1271 		
  1272 		TRAP(error, preImgCapture  = CCamera::CCameraPreImageCaptureControl::NewL(*camera, *this));		
  1273  		if (error==KErrExtensionNotSupported)
  1274 	    	{
  1275 	    	INFO_PRINTF1(_L("CCameraPreImageCaptureControl object creation using Observer2 with NewL failed with correct error"));
  1276 	    	}
  1277 	    else
  1278     		{
  1279     		INFO_PRINTF1(_L("CCameraPreImageCaptureControl object creation using Observer2 with NewL gave unexpected result"));
  1280     		result = EFail;
  1281     		}	
  1282 		CleanupStack::PopAndDestroy(camera);
  1283 		}
  1284 	else 
  1285 		{
  1286 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL()"), error);
  1287 		result = EFail;	
  1288 		User::Leave(KErrNoMemory);	
  1289 		}
  1290 	__MM_HEAP_MARKEND;
  1291 	
  1292 	// create pre image control object using New2L
  1293 	__MM_HEAP_MARK;
  1294 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
  1295 	
  1296 	TRAP(error, camera = CCamera::New2L(*this, 0,0));
  1297 	if (error==KErrNone)
  1298 		{
  1299 		CleanupStack::PushL(camera);
  1300 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
  1301 		TRAP(error, preImgCapture = CCamera::CCameraPreImageCaptureControl::NewL(*camera, *this));	
  1302 		
  1303 		if (error==KErrNone)
  1304 	    	{
  1305 	    	CleanupStack::PushL(preImgCapture);
  1306 	  		INFO_PRINTF1(_L("CCameraPreImageCaptureControl object was created using NewL")); 
  1307 	  		
  1308 	  		INFO_PRINTF1(_L("GetDirectSnapshotSupportInfoL for PreImageCaptureControl"));
  1309 	  		TUint directSnapshotSupportInfo = 0;
  1310 	  		TRAPD(err, preImgCapture->GetDirectSnapshotSupportInfoL(directSnapshotSupportInfo));
  1311 	  		if(err != KErrNone)
  1312   				{
  1313   				INFO_PRINTF1(_L("GetDirectSnapshotSupportInfoL for PreImageCaptureControl : unexpected result!"));
  1314   				result = EFail;
  1315   				}
  1316 	    	
  1317 	    	INFO_PRINTF1(_L("GetSupportedEmbeddedStillCaptureSettingsL for PreImageCaptureControl"));
  1318 	  		RArray<TUid> supportedEmbeddedStillCaptureSettings;
  1319 	  		TRAP(err, preImgCapture->GetSupportedEmbeddedStillCaptureSettingsL(supportedEmbeddedStillCaptureSettings));
  1320   			if(err != KErrNone)
  1321   				{
  1322   				INFO_PRINTF1(_L("GetSupportedEmbeddedStillCaptureSettingsL for PreImageCaptureControl : unexpected result!"));
  1323   				result = EFail;
  1324   				}
  1325   			
  1326   			if(supportedEmbeddedStillCaptureSettings.Count() != 0)
  1327   				{
  1328   				INFO_PRINTF1(_L("Number of SupportedEmbeddedStillCaptureSettings for PreImageCaptureControl : unexpected result!"));
  1329   				result = EFail;
  1330   				}
  1331 	    	
  1332 	    	INFO_PRINTF1(_L("GetSupportedDirectSavingTypeL for PreImageCaptureControl"));
  1333 	  		CCamera::CCameraPreImageCaptureControl::TDirectSavingType supportedDirectSavingType 
  1334 	  				= CCamera::CCameraPreImageCaptureControl::EDirectSavingNotUsed;
  1335 	  		TRAP(err, preImgCapture->GetSupportedDirectSavingTypeL(supportedDirectSavingType));
  1336   			if(err != KErrNone)
  1337   				{
  1338   				INFO_PRINTF1(_L("GetSupportedDirectSavingTypeL for PreImageCaptureControl : unexpected result!"));
  1339   				result = EFail;
  1340   				}
  1341   				
  1342 			INFO_PRINTF1(_L("SetSequentialImageFilenameL for PreImageCaptureControl"));
  1343 	  		_LIT8(KDirectSavingFileName, "C:\\ECam.jpg");
  1344 	  		TInt seqNum = 0;
  1345 	  		TRAP(err, preImgCapture->SetSequentialImageFilenameL(KDirectSavingFileName, seqNum));
  1346   			if(err != KErrNotSupported)
  1347   				{
  1348   				INFO_PRINTF1(_L("SetSequentialImageFilenameL for PreImageCaptureControl : unexpected result!"));
  1349   				result = EFail;
  1350   				}
  1351 			
  1352 			INFO_PRINTF1(_L("SetLowerResolutionSequentialImageFilenameL for PreImageCaptureControl"));
  1353 	  		_LIT8(KLowResDirectSavingFileName, "C:\\ECamLowRes.jpg");
  1354 	  		TRAP(err, preImgCapture->SetLowerResolutionSequentialImageFilenameL(KLowResDirectSavingFileName, seqNum));
  1355   			if(err != KErrNotSupported)
  1356   				{
  1357   				INFO_PRINTF1(_L("SetLowerResolutionSequentialImageFilenameL for PreImageCaptureControl : unexpected result!"));
  1358   				result = EFail;
  1359   				}
  1360   				
  1361   			INFO_PRINTF1(_L("GetDirectSavingTypeL for PreImageCaptureControl"));
  1362 	  		CCamera::CCameraPreImageCaptureControl::TDirectSavingType directSavingType 
  1363 	  				= CCamera::CCameraPreImageCaptureControl::EDirectSavingNotUsed;
  1364 	  		TRAP(err, preImgCapture->GetDirectSavingTypeL(directSavingType));
  1365   			if(err != KErrNone)
  1366   				{
  1367   				INFO_PRINTF1(_L("GetDirectSavingTypeL for PreImageCaptureControl : unexpected result!"));
  1368   				result = EFail;
  1369   				}
  1370   				
  1371   			INFO_PRINTF1(_L("SetDirectSavingTypeL for PreImageCaptureControl"));
  1372   			TRAP(err, preImgCapture->SetDirectSavingTypeL(CCamera::CCameraPreImageCaptureControl::EDirectSavingHighResolutionFileOnly));
  1373   			if(err != KErrNotSupported)
  1374   				{
  1375   				INFO_PRINTF1(_L("SetDirectSavingTypeL for PreImageCaptureControl : unexpected result!"));
  1376   				result = EFail;
  1377   				}
  1378   				
  1379   			INFO_PRINTF1(_L("GetCaptureEventSupportInfoL for PreImageCaptureControl"));
  1380   			TUint supportedDriveModes = 0;
  1381   			TRAP(err, preImgCapture->GetCaptureEventSupportInfoL(supportedDriveModes));
  1382   			if(err != KErrNone)
  1383   				{
  1384   				INFO_PRINTF1(_L("GetCaptureEventSupportInfoL for PreImageCaptureControl : unexpected result!"));
  1385   				result = EFail;
  1386   				}
  1387   				
  1388   			INFO_PRINTF1(_L("GetImageFormatsSupportedL for PreImageCaptureControl"));
  1389   			TSize size(640,480);
  1390   			TUint imageFormatsSupported = 0;
  1391   			TRAP(err, preImgCapture->GetImageFormatsSupportedL(imageFormatsSupported, size));
  1392   			if(err != KErrNone)
  1393   				{
  1394   				INFO_PRINTF1(_L("GetImageFormatsSupportedL for PreImageCaptureControl : unexpected result!"));
  1395   				result = EFail;
  1396   				}
  1397   				
  1398   			INFO_PRINTF1(_L("GetPixelAspectsSupportedL for PreImageCaptureControl"));
  1399     			TUint pixelAspectsSupported = 0;
  1400   			TRAP(err, preImgCapture->GetPixelAspectsSupportedL(pixelAspectsSupported, CCamera::EFormatFbsBitmapColor16M, size));
  1401   			if(err != KErrNone)
  1402   				{
  1403   				INFO_PRINTF1(_L("GetPixelAspectsSupportedL for PreImageCaptureControl : unexpected result!"));
  1404   				result = EFail;
  1405   				}
  1406 			
  1407 			INFO_PRINTF1(_L("GetImageMaxMemorySizeSettingSupportInfoL for PreImageCaptureControl"));
  1408   			TBool maxMemorySizeSettingSupported = EFalse;
  1409   			TRAP(err, preImgCapture->GetImageMaxMemorySizeSettingSupportInfoL(maxMemorySizeSettingSupported));
  1410   			if(err != KErrNone)
  1411   				{
  1412   				INFO_PRINTF1(_L("GetImageMaxMemorySizeSettingSupportInfoL for PreImageCaptureControl : unexpected result!"));
  1413   				result = EFail;
  1414   				}
  1415   			
  1416   			INFO_PRINTF1(_L("GetImageMaxMemorySizeL for PreImageCaptureControl"));
  1417   			TUint memorySize = 0;
  1418   			TRAP(err, preImgCapture->GetImageMaxMemorySizeL(memorySize));
  1419   			if(err != KErrNotSupported)
  1420   				{
  1421   				INFO_PRINTF1(_L("GetImageMaxMemorySizeL for PreImageCaptureControl : unexpected result!"));
  1422   				result = EFail;
  1423   				}	
  1424 			
  1425 			INFO_PRINTF1(_L("GetSupportedProcessingOptionsL for PreImageCaptureControl"));
  1426 			TUint processingOptions = 0;
  1427 			TRAP(err, preImgCapture->GetSupportedProcessingOptionsL(processingOptions));
  1428 			if(err != KErrNotSupported)
  1429 				{
  1430 				INFO_PRINTF1(_L("GetSupportedProcessingOptionsL for PreImageCaptureControl : unexpected result!"));
  1431 				}
  1432 			
  1433   			INFO_PRINTF1(_L("PrepareImageCapture for PreImageCaptureControl"));
  1434   			CCamera::CCameraPreImageCaptureControl::TPrepareImageParameters prepareImageParameters;
  1435  
  1436   			INFO_PRINTF1(_L("Setting processing options member variable"));
  1437   			TUint options = 0;
  1438   			options |= CCamera::CCameraPreImageCaptureControl::EEcamNormalProcessing;
  1439   			prepareImageParameters.SetImageProcessingOptions(options);
  1440   			INFO_PRINTF1(_L("Getting processing options member variable"));
  1441   			TUint retrievedOptions = 0;
  1442   			prepareImageParameters.GetImageProcessingOptions(retrievedOptions);
  1443   			if(retrievedOptions != options)
  1444   				{
  1445   				INFO_PRINTF1(_L("Set image processing option does not match retrieved image processing option"));
  1446   				result = EFail;
  1447   				}
  1448   			else
  1449   				{
  1450   				INFO_PRINTF1(_L("Set image processing option matches retrieved image processing option"));
  1451   				}
  1452  
  1453   			MCaptureImageObserver* 	captureImageObserver = NULL;
  1454   			preImgCapture->PrepareImageCapture(prepareImageParameters, *captureImageObserver);
  1455   			CCamera::CCameraImageCapture* imageCapture = NULL;
  1456 			CheckCaptureNotification(imageCapture, result);	
  1457 			
  1458 			if(imageCapture == NULL)
  1459 				{
  1460 				INFO_PRINTF1(_L("CCameraImageCapture object not created!"));
  1461   				result = EFail;
  1462 				}
  1463 			else
  1464 			    {
  1465 				delete imageCapture;
  1466 				}
  1467 	    
  1468 	    	CleanupStack::PopAndDestroy(preImgCapture);
  1469 	    	}
  1470 	    else
  1471     		{
  1472     		INFO_PRINTF1(_L("CCameraPreImageCaptureControl object was not created using NewL")); 
  1473     		result = EFail;
  1474     		}	
  1475 		CleanupStack::PopAndDestroy(camera);
  1476 		}
  1477 	else 
  1478 		{
  1479 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
  1480 		result = EFail;		
  1481 		}
  1482 	__MM_HEAP_MARKEND;
  1483    
  1484 	return result;
  1485 	}
  1486 /*------------------------------------------------------------------
  1487  	Image Capture Control : RECamImgCaptureNotificationTest
  1488  *-----------------------------------------------------------------*/
  1489 RECamImgCaptureNotificationTest* RECamImgCaptureNotificationTest::NewL(TBool aAllocTest)
  1490 	{
  1491 	return new (ELeave)RECamImgCaptureNotificationTest(aAllocTest);
  1492 	}
  1493 	
  1494 RECamImgCaptureNotificationTest::RECamImgCaptureNotificationTest(TBool /*aAllocTest*/)
  1495 	{
  1496 	iTestStepName = _L("MM-ECM-ADV-U-055-HP");
  1497 	iCaptureImageHandle = NULL;
  1498 	}
  1499 	
  1500 void RECamImgCaptureNotificationTest::PrepareImageComplete(CCamera::CCameraImageCapture* aCaptureImageHandle, TInt aErrorCode)
  1501 	{
  1502 	iCaptureImageHandle = aCaptureImageHandle;
  1503 	iError = aErrorCode;
  1504 	}
  1505 
  1506 TInt RECamImgCaptureNotificationTest::CustomInterface(TUid /*aInterface*/, TAny*& /*aPtrInterface*/)
  1507 	{
  1508 	return KErrNone;
  1509 	}
  1510 
  1511 void RECamImgCaptureNotificationTest::CheckPreCaptureNotification(CCamera::CCameraImageCapture*& aImageCapture, TVerdict& aResult)
  1512 	{
  1513 	INFO_PRINTF2(_L("Pre Image Capture Control Error %d, "), iError); 
  1514 	if (iError != KErrNone)
  1515 		{
  1516 	    aResult = EFail;
  1517 	    }
  1518 	else
  1519 		{
  1520 		aImageCapture = iCaptureImageHandle;
  1521 		}
  1522 	}
  1523 	
  1524 void RECamImgCaptureNotificationTest::IndividualImageControlHandle(CCamera::CCameraImageCapture& aCaptureImageHandle, TPostCaptureControlId aPostCaptureControlId)
  1525 	{
  1526 	iCaptureImageHandle = &aCaptureImageHandle;
  1527 	iPostCaptureControlId = aPostCaptureControlId;
  1528 	}
  1529 	
  1530 void RECamImgCaptureNotificationTest::ImageBufferReady(CCamera::CCameraImageCapture& aCaptureImageHandle, TPostCaptureControlId aPostCaptureControlId, TInt aErrorCode)
  1531 	{
  1532 	iCaptureImageHandle = &aCaptureImageHandle;
  1533 	iPostCaptureControlId = aPostCaptureControlId;
  1534 	iError = aErrorCode;
  1535 	}
  1536 	
  1537 void RECamImgCaptureNotificationTest::ClientSnapshotForImageReady(CCamera::CCameraImageCapture& aCaptureImageHandle, TPostCaptureControlId aPostCaptureControlId, MCameraBuffer2* /*aSnapshotBuffer*/, TInt aErrorCode)
  1538 	{
  1539 	iCaptureImageHandle = &aCaptureImageHandle;
  1540 	iPostCaptureControlId = aPostCaptureControlId;
  1541 	iError = aErrorCode;
  1542 	}
  1543 	
  1544 void RECamImgCaptureNotificationTest::DirectSnapshotForImageDisplayed(CCamera::CCameraImageCapture& aCaptureImageHandle, TPostCaptureControlId aPostCaptureControlId, TInt aErrorCode)
  1545 	{
  1546 	iCaptureImageHandle = &aCaptureImageHandle;
  1547 	iPostCaptureControlId = aPostCaptureControlId;
  1548 	iError = aErrorCode;
  1549 	}
  1550 	
  1551 void RECamImgCaptureNotificationTest::CutDownImageDirectSavingCompleted(CCamera::CCameraImageCapture& aCaptureImageHandle, TPostCaptureControlId aPostCaptureControlId, TInt aErrorCode)
  1552 	{
  1553 	iCaptureImageHandle = &aCaptureImageHandle;
  1554 	iPostCaptureControlId = aPostCaptureControlId;
  1555 	iError = aErrorCode;	
  1556 	}
  1557 	
  1558 void RECamImgCaptureNotificationTest::ImageDirectSavingCompleted(CCamera::CCameraImageCapture& aCaptureImageHandle, TPostCaptureControlId aPostCaptureControlId, TInt aErrorCode)
  1559 	{
  1560 	iCaptureImageHandle = &aCaptureImageHandle;
  1561 	iPostCaptureControlId = aPostCaptureControlId;
  1562 	iError = aErrorCode;	
  1563 	}
  1564 	
  1565 void RECamImgCaptureNotificationTest::ImageCaptureComplete(CCamera::CCameraImageCapture& aCaptureImageHandle, TInt aErrorCode)
  1566 	{
  1567 	iCaptureImageHandle = &aCaptureImageHandle;
  1568 	iError = aErrorCode;	
  1569 	}
  1570 	
  1571 void RECamImgCaptureNotificationTest::ClientHistogramForImageReady(CCamera::CCameraImageCapture& aCaptureImageHandle, TPostCaptureControlId aPostCaptureControlId, MHistogramV2Buffer* /*aClientHistogramBuffer*/, TInt aErrorCode)
  1572 	{
  1573 	iCaptureImageHandle = &aCaptureImageHandle;
  1574 	iPostCaptureControlId = aPostCaptureControlId;
  1575 	iError = aErrorCode;		
  1576 	}
  1577 	
  1578 void RECamImgCaptureNotificationTest::ClientHistogramForSnapshotReady(CCamera::CCameraImageCapture& aCaptureImageHandle, TPostCaptureControlId aPostCaptureControlId, MHistogramV2Buffer* /*aClientHistogramBuffer*/, TInt aErrorCode)
  1579 	{
  1580 	iCaptureImageHandle = &aCaptureImageHandle;
  1581 	iPostCaptureControlId = aPostCaptureControlId;
  1582 	iError = aErrorCode;	
  1583 	}
  1584 	
  1585 void RECamImgCaptureNotificationTest::DirectHistogramForSnapshotDisplayed(CCamera::CCameraImageCapture& aCaptureImageHandle, TPostCaptureControlId aPostCaptureControlId, CCamera::CCameraV2Histogram& /*aDirectHistogramDisplayed*/, TInt aErrorCode)
  1586 	{
  1587 	iCaptureImageHandle = &aCaptureImageHandle;
  1588 	iPostCaptureControlId = aPostCaptureControlId;
  1589 	iError = aErrorCode;		
  1590 	}
  1591 	
  1592 void RECamImgCaptureNotificationTest::ProcessingFailed(CCamera::CCameraImageCapture& aCaptureImageHandle, TPostCaptureControlId aPostCaptureControlId, TUint aProcessingTypes, TInt aErrorCode)
  1593 	{
  1594 	iCaptureImageHandle = &aCaptureImageHandle;
  1595 	iPostCaptureControlId = aPostCaptureControlId;
  1596 	iProcessingTypes = aProcessingTypes;
  1597 	iError = aErrorCode;	
  1598 	}
  1599 
  1600 void RECamImgCaptureNotificationTest::CheckCaptureNotification(CCamera::CCameraImageCapture*& aImageCapture, TPostCaptureControlId& aPostCaptureControlId, TVerdict& aResult)
  1601 	{
  1602 	INFO_PRINTF2(_L("Image Capture Control Error %d, "), iError); 
  1603 	if (iError != KErrNotSupported)
  1604 		{
  1605 	    aResult = EFail;
  1606 	    }
  1607 	else
  1608 		{
  1609 		aImageCapture = iCaptureImageHandle;
  1610 		aPostCaptureControlId = iPostCaptureControlId;
  1611 		}
  1612 	}
  1613 	
  1614 void RECamImgCaptureNotificationTest::CheckCaptureCompletion(CCamera::CCameraImageCapture*& aImageCapture, TVerdict& aResult)
  1615 	{
  1616 	INFO_PRINTF2(_L("Image Capture Control Error %d, "), iError); 
  1617 	if (iError != KErrNotSupported)
  1618 		{
  1619 	    aResult = EFail;
  1620 	    }
  1621 	else
  1622 		{
  1623 		aImageCapture = iCaptureImageHandle;
  1624 		}
  1625 	}
  1626 	
  1627 TVerdict RECamImgCaptureNotificationTest::DoTestStepL()
  1628 	{
  1629 	TVerdict verdict = EFail;
  1630 	INFO_PRINTF1(_L("Alloc test"));
  1631 	
  1632 	TInt i,err;
  1633 	
  1634 	for (i = 1 ; ; i++)
  1635 		{
  1636 		__MM_HEAP_MARK;
  1637 		
  1638 		if (i % 5 == 0)
  1639 			{
  1640 			INFO_PRINTF2(_L("Fail count = %d"), i);
  1641 			}
  1642 
  1643 		__UHEAP_SETFAIL(RHeap::EFailNext, i);
  1644 
  1645 		TRAP(err, verdict = DoImgCaptureAdvFuncConstruction());
  1646 
  1647 		TAny* testAlloc = User::Alloc(1);
  1648 		TBool heapTestingComplete = (testAlloc == NULL) && (err==KErrNone);
  1649 		User::Free(testAlloc);
  1650 
  1651 		__UHEAP_RESET;
  1652 		__MM_HEAP_MARKEND;
  1653 
  1654 		if ((err != KErrNoMemory && verdict == EPass) || heapTestingComplete)
  1655 			{
  1656 			INFO_PRINTF4(_L("err = %d, verdict = %d, Fail count = %d"), err, verdict, i);
  1657 			INFO_PRINTF1(_L("Alloc testing completed successfully"));
  1658 			verdict = EPass;
  1659 			break;
  1660 			}
  1661 		}
  1662 	return verdict;
  1663 	}
  1664 	
  1665 TVerdict RECamImgCaptureNotificationTest::DoImgCaptureAdvFuncConstruction()
  1666 	{
  1667 	TVerdict result = EPass;
  1668 	CCamera* camera = NULL;
  1669 	
  1670 	TInt error = KErrNone;
  1671 	CCamera::CCameraPreImageCaptureControl* preImgCapture = NULL;
  1672 	
  1673 	// create pre image control object using New2L
  1674 	__MM_HEAP_MARK;
  1675 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
  1676 	
  1677 	TRAP(error, camera = CCamera::New2L(*this, 0,0));
  1678 	if (error==KErrNone)
  1679 		{
  1680 		CleanupStack::PushL(camera);
  1681 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
  1682 		TRAP(error, preImgCapture = CCamera::CCameraPreImageCaptureControl::NewL(*camera, *this));	
  1683 		
  1684 		if (error==KErrNone)
  1685 	    	{
  1686 	    	CleanupStack::PushL(preImgCapture);
  1687 	  		INFO_PRINTF1(_L("CCameraPreImageCaptureControl object was created using NewL")); 
  1688 	    	
  1689 	    	INFO_PRINTF1(_L("PrepareImageCapture for PreImageCaptureControl"));
  1690   			CCamera::CCameraPreImageCaptureControl::TPrepareImageParameters prepareImageParameters;
  1691    			preImgCapture->PrepareImageCapture(prepareImageParameters, *this);
  1692   			CCamera::CCameraImageCapture* imageCapture = NULL;
  1693 			CheckPreCaptureNotification(imageCapture, result);	
  1694 			
  1695 			if(imageCapture == NULL)
  1696 				{
  1697 				INFO_PRINTF1(_L("CCameraImageCapture object not created!"));
  1698   				result = EFail;
  1699 				}
  1700 			else
  1701 			    {
  1702 			    CleanupStack::PushL(imageCapture);
  1703 				// image capture opertions.
  1704 				
  1705 				INFO_PRINTF1(_L("Create Histogram for Image Capture"));
  1706 				CCamera::CCameraV2Histogram* histogram_IC = NULL;
  1707 		  		TRAP(error, histogram_IC = imageCapture->CreateHistogramHandleL());
  1708 		  		
  1709 		  		if(error != KErrNone /*|| !histogram_IC*/)
  1710 		  			{
  1711 		  			INFO_PRINTF1(_L("Histogram creation for Image Capture unsuccessful"));
  1712 		  			result = EFail;
  1713 		  			CleanupStack::PopAndDestroy(imageCapture);
  1714 		  			CleanupStack::PopAndDestroy(preImgCapture);
  1715 		  			CleanupStack::PopAndDestroy(camera);
  1716 		  			User::Leave(error);
  1717 		  			}
  1718 		  			
  1719 		  		CleanupStack::PushL(histogram_IC);
  1720 		  			
  1721 		  		INFO_PRINTF1(_L("Create ImageProcessing for Image Capture "));
  1722 		  		
  1723 		  		CCamera::CCameraImageProcessing* impProc = NULL;
  1724 		  		TRAP(error, impProc = imageCapture->GetTransformationHandleL());
  1725 	  			
  1726 	  			if(error != KErrNone /*|| !impProc*/)
  1727 	  				{
  1728 	  				INFO_PRINTF1(_L("ImageProcessing creation for Image Capture unsuccessful"));
  1729 	  				result = EFail;
  1730 	  				CleanupStack::PopAndDestroy(histogram_IC);
  1731 	  				CleanupStack::PopAndDestroy(imageCapture);
  1732 		  			CleanupStack::PopAndDestroy(preImgCapture);
  1733 		  			CleanupStack::PopAndDestroy(camera);
  1734 					User::Leave(error);
  1735 	  				}
  1736 	  				
  1737 	  			CleanupStack::PushL(impProc);
  1738 	  				
  1739 	  			INFO_PRINTF1(_L("Create snapshot for Image Capture"));
  1740 	  			TInt viewfinderID = 0;
  1741 	  			CCamera::CCameraSnapshot* snapshot_IC = NULL;
  1742 		  		TRAP(error,snapshot_IC = imageCapture->GetSnapshotHandleL(viewfinderID));
  1743 	  			
  1744 	  			if(error != KErrNone /*||!snapshot_IC*/)
  1745 	  				{
  1746 	  				INFO_PRINTF1(_L("snapshot creation for Image Capture : unexpected result!"));
  1747 	  				result = EFail;
  1748 	  				CleanupStack::PopAndDestroy(impProc);
  1749 	  				CleanupStack::PopAndDestroy(histogram_IC);
  1750 	  				CleanupStack::PopAndDestroy(imageCapture);
  1751 		  			CleanupStack::PopAndDestroy(preImgCapture);
  1752 		  			CleanupStack::PopAndDestroy(camera);
  1753 					User::Leave(error);
  1754 	  				}
  1755 				CleanupStack::PushL(snapshot_IC);
  1756 				
  1757 				INFO_PRINTF1(_L("Create histogram for snapshot for Image Capture"));
  1758 				CCamera::CCameraV2Histogram* histogram_snapshot_IC = NULL;
  1759 		  		
  1760 		  		TRAP(error, histogram_snapshot_IC = snapshot_IC->CreateHistogramHandleL());
  1761 		  		
  1762 		  		if(error != KErrNone /*|| !histogram_snapshot_IC*/)
  1763 		  			{
  1764 		  			INFO_PRINTF1(_L("Histogram creation for snapshot for Image Capture unsuccessful"));
  1765 		  			result = EFail;
  1766 		  			CleanupStack::PopAndDestroy(snapshot_IC);
  1767 	  				CleanupStack::PopAndDestroy(impProc);
  1768 	  				CleanupStack::PopAndDestroy(histogram_IC);
  1769 	  				CleanupStack::PopAndDestroy(imageCapture);
  1770 		  			CleanupStack::PopAndDestroy(preImgCapture);
  1771 		  			CleanupStack::PopAndDestroy(camera);
  1772 					User::Leave(error);
  1773 		  			}
  1774 		  		CleanupStack::PushL(histogram_snapshot_IC);
  1775 		  		
  1776 		  		//check img proc for image capture
  1777 		  		INFO_PRINTF1(_L("GetSupportedTransformationsL for imgProc for Image Capture"));
  1778 		  		RArray<TUid> transformations;
  1779 		  		TRAPD(err, impProc->GetSupportedTransformationsL(transformations));
  1780 		  		if(err != KErrNone)
  1781 		  			{
  1782 		  			INFO_PRINTF1(_L("GetSupportedTransformationsL for imgProc for Image Capture : unexpected result!"));
  1783 		  			result = EFail;
  1784 		  			CleanupStack::PopAndDestroy(histogram_snapshot_IC);
  1785 		  			CleanupStack::PopAndDestroy(snapshot_IC);
  1786 	  				CleanupStack::PopAndDestroy(impProc);
  1787 	  				CleanupStack::PopAndDestroy(histogram_IC);
  1788 	  				CleanupStack::PopAndDestroy(imageCapture);
  1789 		  			CleanupStack::PopAndDestroy(preImgCapture);
  1790 		  			CleanupStack::PopAndDestroy(camera);
  1791 					User::Leave(err);
  1792 		  			}
  1793 		  		if(transformations.Count() != 0)
  1794 		  			{
  1795 		  			INFO_PRINTF1(_L("Number of SupportedTransformations for imgProc for Image Capture : unexpected result!"));
  1796 		  			result = EFail;
  1797 		  			}
  1798 		  		transformations.Close();
  1799 		  		
  1800 		  		INFO_PRINTF1(_L("Check New Img Proc methods for Image Capture"));
  1801 		  		CCamera::CCameraImageProcessing::TOrientationReference orientationRef 
  1802 		  				= CCamera::CCameraImageProcessing::EOrientationReferenceTiltOrientation;
  1803 		  		TUint suppRelativeRotation=0;
  1804 		  		TUint supportedRelMirroring=0;
  1805 		  		TUint supportedRelFlipping=0;
  1806 		  		TRAP(err, impProc->GetSupportedRelativeOrientationOptionsL(orientationRef, suppRelativeRotation, supportedRelMirroring, supportedRelFlipping));
  1807 		  		if(err != KErrNotSupported)
  1808 		  			{
  1809 		  			INFO_PRINTF1(_L("GetSupportedRelativeOrientationOptionsL for imgProc for Image Capture : unexpected result!"));
  1810 		  			result = EFail;
  1811 		  			}
  1812 		  		
  1813 		  		CCamera::CCameraImageProcessing::TRelativeRotation relRotation = 
  1814 		  					CCamera::CCameraImageProcessing::ERelativeRotation0Degrees;
  1815 		  			
  1816 		  		CCamera::CCameraImageProcessing::TRelativeMirror relMirror =
  1817 		  					CCamera::CCameraImageProcessing::ERelativeMirrorNone;
  1818 		  					
  1819 		  		CCamera::CCameraImageProcessing::TRelativeFlipping relFlipping =
  1820 		  					CCamera::CCameraImageProcessing::ERelativeFlippingNone;
  1821 		  		
  1822 		  		TRAP(err, impProc->GetCurrentRelativeOrientationOptionsL(orientationRef, relRotation, relMirror, relFlipping));
  1823 		  		if(err != KErrNotSupported)
  1824 		  			{
  1825 		  			INFO_PRINTF1(_L("GetCurrentRelativeOrientationOptionsL for imgProc for Image Capture : unexpected result!"));
  1826 		  			result = EFail;
  1827 		  			CleanupStack::PopAndDestroy(histogram_snapshot_IC);
  1828 		  			CleanupStack::PopAndDestroy(snapshot_IC);
  1829 	  				CleanupStack::PopAndDestroy(impProc);
  1830 	  				CleanupStack::PopAndDestroy(histogram_IC);
  1831 	  				CleanupStack::PopAndDestroy(imageCapture);
  1832 		  			CleanupStack::PopAndDestroy(preImgCapture);
  1833 		  			CleanupStack::PopAndDestroy(camera);
  1834 					User::Leave(err);
  1835 		  			}
  1836 		  			
  1837 		  		TRAP(err, impProc->SetRelativeOrientationOptionsL(orientationRef, relRotation, relMirror, relFlipping));
  1838 		  		if(err != KErrNotSupported)
  1839 		  			{
  1840 		  			INFO_PRINTF1(_L("SetRelativeOrientationOptionsL for imgProc for Image Capture : unexpected result!"));
  1841 		  			result = EFail;
  1842 		  			CleanupStack::PopAndDestroy(histogram_snapshot_IC);
  1843 		  			CleanupStack::PopAndDestroy(snapshot_IC);
  1844 	  				CleanupStack::PopAndDestroy(impProc);
  1845 	  				CleanupStack::PopAndDestroy(histogram_IC);
  1846 	  				CleanupStack::PopAndDestroy(imageCapture);
  1847 		  			CleanupStack::PopAndDestroy(preImgCapture);
  1848 		  			CleanupStack::PopAndDestroy(camera);
  1849 					User::Leave(err);
  1850 		  			}
  1851 												
  1852 		  		//prepare histogram for image capture
  1853 		  		INFO_PRINTF1(_L("PrepareClientHistogramL for Histogram for Image Capture"));
  1854 		  		CCamera::CCameraV2Histogram::THistogramType histogramType = CCamera::CCameraV2Histogram::EHistNone;
  1855 		  		TRAP(err,histogram_IC->PrepareClientHistogramL(histogramType));
  1856 	  			if(err != KErrNotSupported)
  1857 	  				{
  1858 	  				INFO_PRINTF1(_L("PrepareClientHistogramL for Histogram for Image Capture: unexpected result!"));
  1859 	  				result = EFail;
  1860 	  				CleanupStack::PopAndDestroy(histogram_snapshot_IC);
  1861 		  			CleanupStack::PopAndDestroy(snapshot_IC);
  1862 	  				CleanupStack::PopAndDestroy(impProc);
  1863 	  				CleanupStack::PopAndDestroy(histogram_IC);
  1864 	  				CleanupStack::PopAndDestroy(imageCapture);
  1865 		  			CleanupStack::PopAndDestroy(preImgCapture);
  1866 		  			CleanupStack::PopAndDestroy(camera);
  1867 					User::Leave(err);
  1868 	  				}
  1869 	  				
  1870 	  			//prepare snapshot for image capture
  1871 	  			INFO_PRINTF1(_L("PrepareSnapshotL for Snapshot for Image Capture"));
  1872 				CCamera::CCameraSnapshot::TSnapshotParameters snapshotParam;
  1873 		   		TRAP(err,snapshot_IC->PrepareSnapshotL(snapshotParam));
  1874 		   		if(err != KErrNone)
  1875 		   			{
  1876 		   			INFO_PRINTF1(_L("PrepareSnapshotL for Snapshot for Image Capture: unexpected result!"));
  1877 	  				result = EFail;
  1878 	  				CleanupStack::PopAndDestroy(histogram_snapshot_IC);
  1879 		  			CleanupStack::PopAndDestroy(snapshot_IC);
  1880 	  				CleanupStack::PopAndDestroy(impProc);
  1881 	  				CleanupStack::PopAndDestroy(histogram_IC);
  1882 	  				CleanupStack::PopAndDestroy(imageCapture);
  1883 		  			CleanupStack::PopAndDestroy(preImgCapture);
  1884 		  			CleanupStack::PopAndDestroy(camera);
  1885 					User::Leave(err);
  1886 		   			}
  1887 		   			
  1888 		   		//prepare histogram for snapshot for image capture
  1889 		  		INFO_PRINTF1(_L("PrepareClientHistogramL for Histogram for snapshot for Image Capture"));
  1890 		  		TRAP(err,histogram_snapshot_IC->PrepareClientHistogramL(histogramType));
  1891 	  			if(err != KErrNotSupported)
  1892 	  				{
  1893 	  				INFO_PRINTF1(_L("PrepareClientHistogramL for Histogram for Snapshot for Image Capture: unexpected result!"));
  1894 	  				result = EFail;
  1895 	  				CleanupStack::PopAndDestroy(histogram_snapshot_IC);
  1896 		  			CleanupStack::PopAndDestroy(snapshot_IC);
  1897 	  				CleanupStack::PopAndDestroy(impProc);
  1898 	  				CleanupStack::PopAndDestroy(histogram_IC);
  1899 	  				CleanupStack::PopAndDestroy(imageCapture);
  1900 		  			CleanupStack::PopAndDestroy(preImgCapture);
  1901 		  			CleanupStack::PopAndDestroy(camera);
  1902 					User::Leave(err);
  1903 	  				}
  1904 	  				
  1905 	  			//image capture operations
  1906 	  			INFO_PRINTF1(_L("GetPrepareImageParametersL for Image Capture"));
  1907 	  			CCamera::CCameraPreImageCaptureControl::TPrepareImageParameters prepareImageParameters;
  1908 		  		TRAP(err,imageCapture->GetPrepareImageParametersL(prepareImageParameters));
  1909 	  			if(err != KErrNone)
  1910 	  				{
  1911 	  				INFO_PRINTF1(_L("GetPrepareImageParametersL for Image Capture: unexpected result!"));
  1912 	  				result = EFail;
  1913 	  				CleanupStack::PopAndDestroy(histogram_snapshot_IC);
  1914 		  			CleanupStack::PopAndDestroy(snapshot_IC);
  1915 	  				CleanupStack::PopAndDestroy(impProc);
  1916 	  				CleanupStack::PopAndDestroy(histogram_IC);
  1917 	  				CleanupStack::PopAndDestroy(imageCapture);
  1918 		  			CleanupStack::PopAndDestroy(preImgCapture);
  1919 		  			CleanupStack::PopAndDestroy(camera);
  1920 					User::Leave(err);
  1921 	  				}
  1922 	  				
  1923 	  			INFO_PRINTF1(_L("CaptureImage for Image Capture"));
  1924 	  			imageCapture->CaptureImage();
  1925 	  			
  1926 	  			CCamera::CCameraImageCapture* captImg = NULL;
  1927 	  			CCamera::CCameraPostImageCaptureControl* postImgCapt = NULL;
  1928 	  			TPostCaptureControlId postCaptureControlId = 0;
  1929 	  			
  1930 	  			TRAP(err, iCaptureImageHandle->GetPostCaptureControlHandleL(postImgCapt, iPostCaptureControlId));
  1931 	  			if(err != KErrNone)
  1932 	  				{
  1933 	  				INFO_PRINTF1(_L("GetPostCaptureControlHandleL for Image Capture: unexpected result!"));
  1934 	  				result = EFail;
  1935 	  				CleanupStack::PopAndDestroy(histogram_snapshot_IC);
  1936 		  			CleanupStack::PopAndDestroy(snapshot_IC);
  1937 	  				CleanupStack::PopAndDestroy(impProc);
  1938 	  				CleanupStack::PopAndDestroy(histogram_IC);
  1939 	  				CleanupStack::PopAndDestroy(imageCapture);
  1940 		  			CleanupStack::PopAndDestroy(preImgCapture);
  1941 		  			CleanupStack::PopAndDestroy(camera);
  1942 					User::Leave(err);
  1943 	  				}
  1944 	  				
  1945 	  			if(postImgCapt == NULL)
  1946 	  				{
  1947 	  				INFO_PRINTF1(_L("PostCaptureControl object was not provided for Image Capture: unexpected result!"));
  1948 	  				result = EFail;
  1949 	  				}
  1950 	  			else
  1951 	  				{
  1952 	  				CleanupStack::PushL(postImgCapt);
  1953 	  				//perform operations on post image capture control
  1954 	  				INFO_PRINTF1(_L("GetPostCaptureControlId for post imgCapt object for Image Capture"));
  1955 	  				TPostCaptureControlId postCaptCtrlId = 0;
  1956 	  				postImgCapt->GetPostCaptureControlId(postCaptCtrlId);
  1957 	  				if(postCaptCtrlId != iPostCaptureControlId)
  1958 	  					{
  1959 	  					INFO_PRINTF1(_L("PostCaptureControlId unexpected!"));
  1960 	  					result = EFail;
  1961 	  					}
  1962 	  				postCaptureControlId = postCaptCtrlId;
  1963 	  					
  1964 	  				INFO_PRINTF1(_L("ImageCaptureHandle for post imgCapt object for Image Capture"));
  1965 	  				TRAP(err, CCamera::CCameraImageCapture* captImg1 = postImgCapt->ImageCaptureHandle());
  1966 					if(err != KErrNone /*|| captImg1 == NULL*/)
  1967 						{
  1968 						INFO_PRINTF1(_L("CCameraImageCapture object from post image capture object is NULL and unexpected!"));
  1969 	  					result = EFail;
  1970 	  					CleanupStack::PopAndDestroy(postImgCapt);
  1971 						CleanupStack::PopAndDestroy(histogram_snapshot_IC);
  1972 			  			CleanupStack::PopAndDestroy(snapshot_IC);
  1973 		  				CleanupStack::PopAndDestroy(impProc);
  1974 		  				CleanupStack::PopAndDestroy(histogram_IC);
  1975 		  				CleanupStack::PopAndDestroy(imageCapture);
  1976 			  			CleanupStack::PopAndDestroy(preImgCapture);
  1977 			  			CleanupStack::PopAndDestroy(camera);
  1978 						User::Leave(err);
  1979 						}
  1980 						
  1981 					INFO_PRINTF1(_L("GetImageSequenceNumberL for post imgCapt object for Image Capture"));
  1982 	  				TUint seqNum = 0;
  1983 	  				TRAP(err, postImgCapt->GetImageSequenceNumberL(seqNum));
  1984 	  				if(err != KErrNotSupported)
  1985 						{
  1986 						INFO_PRINTF1(_L("GetImageSequenceNumberL for post image capture object unexpected!"));
  1987 	  					result = EFail;
  1988 						}
  1989 						
  1990 					INFO_PRINTF1(_L("SetImagePriorityL for post imgCapt object for Image Capture"));
  1991 	  				TECamImagePriority imagePriority = EECamImagePriorityLow;
  1992 	  				TRAP(err, postImgCapt->SetImagePriorityL(imagePriority));
  1993 	  				if(err != KErrNotSupported)
  1994 						{
  1995 						INFO_PRINTF1(_L("SetImagePriorityL for post image capture object unexpected!"));
  1996 	  					result = EFail;
  1997 						}
  1998 						
  1999 					INFO_PRINTF1(_L("GetImagePriorityL for post imgCapt object for Image Capture"));
  2000 	  				TRAP(err, postImgCapt->GetImagePriorityL(imagePriority));
  2001 	  				if(err != KErrNotSupported)
  2002 						{
  2003 						INFO_PRINTF1(_L("GetImagePriorityL for post image capture object unexpected!"));
  2004 	  					result = EFail;
  2005 						}
  2006 						
  2007 					INFO_PRINTF1(_L("PauseProcessing for post imgCapt object for Image Capture"));
  2008 	  				postImgCapt->PauseProcessing(0);
  2009 	  				
  2010 	  				INFO_PRINTF1(_L("ResumeProcessingL for post imgCapt object for Image Capture"));
  2011 	  				TRAP(err, postImgCapt->ResumeProcessingL(0));
  2012 	  				if(err != KErrNotSupported)
  2013 						{
  2014 						INFO_PRINTF1(_L("ResumeProcessingL for post image capture object unexpected!"));
  2015 	  					result = EFail;
  2016 						}
  2017 					
  2018 					INFO_PRINTF1(_L("GetImageStateL for post imgCapt object for Image Capture"));
  2019 	  				CCamera::CCameraPostImageCaptureControl::TImageState imgState = 
  2020 	  						CCamera::CCameraPostImageCaptureControl::EProcessingPending;
  2021 	  				TRAP(err, postImgCapt->GetImageStateL(imgState));
  2022 	  				if(err != KErrNotSupported)
  2023 						{
  2024 						INFO_PRINTF1(_L("GetImageStateL for post image capture object unexpected!"));
  2025 	  					result = EFail;
  2026 						}
  2027 						
  2028 					INFO_PRINTF1(_L("GetBufferStateL for post imgCapt object for Image Capture"));
  2029 	  				CCamera::CCameraPostImageCaptureControl::TBufferState bufferState = 
  2030 	  						CCamera::CCameraPostImageCaptureControl::EBufferNotPresent;
  2031 	  				TRAP(err, postImgCapt->GetBufferStateL(bufferState));
  2032 	  				if(err != KErrNotSupported)
  2033 						{
  2034 						INFO_PRINTF1(_L("GetBufferStateL for post image capture object unexpected!"));
  2035 	  					result = EFail;
  2036 						}
  2037 						
  2038 					INFO_PRINTF1(_L("GetImageBufferL for post imgCapt object for Image Capture"));
  2039 	  				MCameraImageBuffer* cameraImageBuffer = NULL;
  2040 	  				TRAP(err, postImgCapt->GetImageBufferL(*cameraImageBuffer));
  2041 	  				if(err != KErrNotSupported)
  2042 						{
  2043 						INFO_PRINTF1(_L("GetImageBufferL for post image capture object unexpected!"));
  2044 	  					result = EFail;
  2045 						}
  2046 						
  2047 					INFO_PRINTF1(_L("CancelImage for post imgCapt object for Image Capture"));
  2048 	  				postImgCapt->CancelImage();
  2049 	  				}
  2050 	  				
  2051 	  			CheckCaptureCompletion(captImg, result);
  2052 	  			
  2053 	  			//perform operations on image capture
  2054 	  			INFO_PRINTF1(_L("GetNumImagesExposedL for Image Capture"));
  2055 	  			TUint numImagesExposed = 0;
  2056 	  			TRAP(err, imageCapture->GetNumImagesExposedL(numImagesExposed));
  2057 	  			if(err != KErrNotSupported)
  2058 					{
  2059 					INFO_PRINTF1(_L("GetNumImagesExposedL for Image Capture unexpected!"));
  2060   					result = EFail;
  2061 					}
  2062 					
  2063 				INFO_PRINTF1(_L("GetNumTotalImagesL for Image Capture"));
  2064 	  			TRAP(err, imageCapture->GetNumTotalImagesL(numImagesExposed));
  2065 	  			if(err != KErrNone)
  2066 					{
  2067 					INFO_PRINTF1(_L("GetNumTotalImagesL for Image Capture unexpected!"));
  2068   					result = EFail;
  2069 					}
  2070 					
  2071 				INFO_PRINTF1(_L("SetCaptureImagePriorityL for Image Capture"));
  2072 				TECamImagePriority imagePriority = EECamImagePriorityLow;
  2073 	  			TRAP(err, imageCapture->SetCaptureImagePriorityL(imagePriority));
  2074 	  			if(err != KErrNotSupported)
  2075 					{
  2076 					INFO_PRINTF1(_L("SetCaptureImagePriorityL for Image Capture unexpected!"));
  2077   					result = EFail;
  2078 					}
  2079 				
  2080 				INFO_PRINTF1(_L("GetCaptureImagePriorityL for Image Capture"));
  2081 	  			TRAP(err, imageCapture->GetCaptureImagePriorityL(imagePriority));
  2082 	  			if(err != KErrNotSupported)
  2083 					{
  2084 					INFO_PRINTF1(_L("GetCaptureImagePriorityL for Image Capture unexpected!"));
  2085   					result = EFail;
  2086 					}
  2087 					
  2088 				INFO_PRINTF1(_L("PauseProcessing for Image Capture"));
  2089 	  			imageCapture->PauseProcessing(0);
  2090 	  			
  2091 	  			INFO_PRINTF1(_L("ResumeProcessingL for Image Capture"));
  2092   				TRAP(err, imageCapture->ResumeProcessingL(0));
  2093   				if(err != KErrNotSupported)
  2094 					{
  2095 					INFO_PRINTF1(_L("ResumeProcessingL for Image Capture unexpected!"));
  2096   					result = EFail;
  2097 					}
  2098 				
  2099 				INFO_PRINTF1(_L("CancelCaptureImage for Image Capture"));
  2100 	  			imageCapture->CancelCaptureImage();
  2101 	  			
  2102 	  			//start histogram for image capture
  2103 	  			INFO_PRINTF1(_L("StartHistogram for Image Capture"));
  2104 				histogram_IC->StartHistogram();
  2105 				CCamera::CCameraImageCapture* camImgCapture=NULL;
  2106 				TPostCaptureControlId postCaptCtrlId = 0;
  2107 				CheckCaptureNotification(camImgCapture, postCaptCtrlId, result);
  2108 				if(camImgCapture == NULL || postCaptCtrlId != postCaptureControlId)
  2109 					{
  2110 					INFO_PRINTF1(_L("StartHistogram for Histogram for Image Capture unexpected!"));
  2111   					result = EFail;	
  2112 					}
  2113 	  		
  2114 	  			INFO_PRINTF1(_L("StopHistogram for histogram for Image Capture"));	
  2115 				histogram_IC->StopHistogram();
  2116 				
  2117 				//start snapshot for image capture
  2118 				INFO_PRINTF1(_L("EnableSnapshotL for snapshot for Image Capture"));	
  2119 				TRAP(err,snapshot_IC->EnableSnapshotL());
  2120 				if(err != KErrNone)
  2121 					{
  2122 		   			INFO_PRINTF1(_L("EnableSnapshotL for snapshot for Image Capture: unexpected result!"));
  2123 	  				result = EFail;
  2124 		   			}
  2125 		   		camImgCapture = NULL;
  2126 		   		camImgCapture = 0;
  2127 		   		CheckCaptureNotification(camImgCapture, postCaptCtrlId, result);
  2128 				if(camImgCapture == NULL || postCaptCtrlId != postCaptureControlId)
  2129 					{
  2130 					INFO_PRINTF1(_L("EnableSnapshotL for snapshot for Image Capture unexpected!"));
  2131   					result = EFail;	
  2132 					}
  2133 					
  2134 				//start histogram for snapshot for image capture
  2135 	  			INFO_PRINTF1(_L("StartHistogram for snapshot for Image Capture"));
  2136 				histogram_snapshot_IC->StartHistogram();
  2137 				camImgCapture=NULL;
  2138 				postCaptCtrlId = 0;
  2139 				CheckCaptureNotification(camImgCapture, postCaptCtrlId, result);
  2140 				if(camImgCapture == NULL || postCaptCtrlId != postCaptureControlId)
  2141 					{
  2142 					INFO_PRINTF1(_L("StartHistogram for Histogram for snapshot for Image Capture unexpected!"));
  2143   					result = EFail;	
  2144 					}
  2145 	  		
  2146 	  			INFO_PRINTF1(_L("StopHistogram for histogram for snapshot for Image Capture"));	
  2147 				histogram_snapshot_IC->StopHistogram();	
  2148 				//
  2149 					
  2150 				INFO_PRINTF1(_L("DisableSnapshotL for snapshot for Image Capture"));	
  2151 				TRAP(err,snapshot_IC->DisableSnapshotL());
  2152 				if(err != KErrNone)
  2153 					{
  2154 		   			INFO_PRINTF1(_L("DisableSnapshotL for snapshot for Image Capture: unexpected result!"));
  2155 	  				result = EFail;
  2156 		   			}
  2157 	  		 	
  2158 				CleanupStack::PopAndDestroy(postImgCapt);
  2159 				CleanupStack::PopAndDestroy(histogram_snapshot_IC);
  2160 				CleanupStack::PopAndDestroy(snapshot_IC);
  2161 				CleanupStack::PopAndDestroy(impProc);
  2162 				CleanupStack::PopAndDestroy(histogram_IC);
  2163 				CleanupStack::PopAndDestroy(imageCapture);
  2164 				}
  2165 			CleanupStack::PopAndDestroy(preImgCapture);
  2166 	    	}
  2167 	    else
  2168     		{
  2169     		INFO_PRINTF1(_L("CCameraPreImageCaptureControl object was not created using NewL")); 
  2170     		result = EFail;
  2171     		}	
  2172 		CleanupStack::PopAndDestroy(camera);
  2173 		}
  2174 	else 
  2175 		{
  2176 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
  2177 		result = EFail;		
  2178 		}
  2179 	__MM_HEAP_MARKEND;
  2180    
  2181 	return result;	
  2182 	}
  2183 	
  2184 /*------------------------------------------------------
  2185  	Video Capture Control : RECamVideoCaptureControlTest
  2186  *------------------------------------------------------*/
  2187 RECamVideoCaptureControlTest* RECamVideoCaptureControlTest::NewL(const TDesC& aTestStep)
  2188 	{
  2189 	RECamVideoCaptureControlTest* self = new (ELeave) RECamVideoCaptureControlTest(aTestStep);
  2190 	return self;	
  2191 	}
  2192 	
  2193 RECamVideoCaptureControlTest::RECamVideoCaptureControlTest(const TDesC& aTestStep)
  2194 	{
  2195 	iTestStepName.Copy(aTestStep);
  2196 	}
  2197 	
  2198 TVerdict RECamVideoCaptureControlTest::DoTestStepL()
  2199 	{
  2200 	if(!iTestStepName.Compare(_L("MM-ECM-ADV-U-056-HP")))
  2201 		{
  2202 		return DoTestStep_56L();
  2203 		}
  2204 	return EInconclusive;	
  2205 	}
  2206 
  2207 TVerdict RECamVideoCaptureControlTest::DoTestStep_56L()
  2208 	{
  2209 	TVerdict verdict = EFail;
  2210 	INFO_PRINTF1(_L("Alloc test"));
  2211 	TInt i;
  2212 	TInt err;
  2213 	for (i = 1 ; ; i++)
  2214 		{
  2215 		__MM_HEAP_MARK;
  2216 		
  2217 		if (i % 5 == 0)
  2218 			{
  2219 			INFO_PRINTF2(_L("Fail count = %d"), i);
  2220 			}
  2221 
  2222 		__UHEAP_SETFAIL(RHeap::EFailNext, i);
  2223 
  2224 		TRAP(err, verdict = DoVideoCaptureTestStepL());
  2225 
  2226 		TAny* testAlloc = User::Alloc(1);
  2227 		TBool heapTestingComplete = (testAlloc == NULL) && (err==KErrNone);
  2228 		User::Free(testAlloc);
  2229 
  2230 		__UHEAP_RESET;
  2231 		__MM_HEAP_MARKEND;
  2232 
  2233 		if ((err != KErrNoMemory ) || heapTestingComplete)
  2234 			{
  2235 			INFO_PRINTF4(_L("err = %d, verdict = %d, Fail count = %d"), err, verdict, i);
  2236 			INFO_PRINTF1(_L("Alloc testing completed successfully"));
  2237 			verdict = EPass;
  2238 			break;
  2239 			}
  2240 		}
  2241 	return verdict;
  2242 	}
  2243 
  2244 TVerdict RECamVideoCaptureControlTest::DoVideoCaptureTestStepL()
  2245 	{
  2246 	TVerdict result = EPass;
  2247 	CCamera* camera = NULL;
  2248 
  2249 	MCaptureVideoObserver* videoCaptureObserver = NULL;
  2250 	
  2251 	TInt error = KErrNone;
  2252 	CCamera::CCameraVideoCaptureControl* videoCapture = NULL;
  2253 	
  2254 	// using observer 	
  2255 	__MM_HEAP_MARK;
  2256 	MCameraObserver* observer=NULL;
  2257 	INFO_PRINTF1(_L("Create camera using Camera::NewL() and MCameraObserver"));
  2258 	TRAP(error, camera = CCamera::NewL(*observer, 0));
  2259 	if (error==KErrNone)
  2260 		{
  2261 		CleanupStack::PushL(camera);
  2262 		INFO_PRINTF1(_L("Create VideoCaptureControl from CCamera object"));
  2263 		
  2264 		TRAP(error, videoCapture  = CCamera::CCameraVideoCaptureControl::NewL(*camera, *videoCaptureObserver));	
  2265  		if (error==KErrExtensionNotSupported)
  2266 	    	{
  2267 	    	INFO_PRINTF1(_L("CCameraVideoCaptureControl object creation using old Observer failed with correct error"));
  2268 	    	}
  2269 	    else
  2270     		{
  2271     		INFO_PRINTF1(_L("CCameraVideoCaptureControl object creation using old Observer gave unexpected result"));
  2272     		result = EFail;
  2273     		}	
  2274 		CleanupStack::PopAndDestroy(camera);
  2275 		}
  2276 	else 
  2277 		{
  2278 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL()"), error);
  2279 		result = EFail;	
  2280 		User::Leave(KErrNoMemory);	
  2281 		}
  2282 	__MM_HEAP_MARKEND;
  2283 	
  2284 	// using observer2 with NewL 
  2285 	MCameraObserver2* observer2 = NULL;	
  2286 	__MM_HEAP_MARK;
  2287 	INFO_PRINTF1(_L("Create camera using Camera::NewL() and MCameraObserver2"));
  2288 	TRAP(error, camera = CCamera::NewL(*observer2, 0,0));
  2289 	if (error==KErrNone)
  2290 		{
  2291 		CleanupStack::PushL(camera);
  2292 		INFO_PRINTF1(_L("Create VideoCaptureControl from CCamera object"));
  2293 		
  2294 		TRAP(error, videoCapture  = CCamera::CCameraVideoCaptureControl::NewL(*camera, *videoCaptureObserver));		
  2295  		if (error==KErrExtensionNotSupported)
  2296 	    	{
  2297 	    	INFO_PRINTF1(_L("CCameraVideoCaptureControl object creation using Observer2 with NewL failed with correct error"));
  2298 	    	}
  2299 	    else
  2300     		{
  2301     		INFO_PRINTF1(_L("CCameraVideoCaptureControl object creation using Observer2 with NewL gave unexpected result"));
  2302     		result = EFail;
  2303     		}	
  2304 		CleanupStack::PopAndDestroy(camera);
  2305 		}
  2306 	else 
  2307 		{
  2308 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL()"), error);
  2309 		result = EFail;	
  2310 		User::Leave(KErrNoMemory);	
  2311 		}
  2312 	__MM_HEAP_MARKEND;
  2313 	
  2314 	
  2315 	// create video capture control object using New2L
  2316 	__MM_HEAP_MARK;
  2317 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
  2318 	
  2319 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
  2320 	if (error==KErrNone)
  2321 		{
  2322 		CleanupStack::PushL(camera);
  2323 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
  2324 		TRAP(error, videoCapture = CCamera::CCameraVideoCaptureControl::NewL(*camera, *videoCaptureObserver));	
  2325 		
  2326 		if (error==KErrNone)
  2327 	    	{
  2328 	    	CleanupStack::PushL(videoCapture);
  2329 	  		INFO_PRINTF1(_L("CCameraVideoCaptureControl object was created using NewL")); 
  2330 	    	CleanupStack::PopAndDestroy(videoCapture);
  2331 	    	}
  2332 	    else
  2333     		{
  2334     		INFO_PRINTF1(_L("CCameraVideoCaptureControl object was not created using NewL")); 
  2335     		result = EFail;
  2336     		User::Leave(KErrNoMemory);
  2337     		}	
  2338 		CleanupStack::PopAndDestroy(camera);
  2339 		}
  2340 	else 
  2341 		{
  2342 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
  2343 		result = EFail;
  2344 		User::Leave(KErrNoMemory);		
  2345 		}
  2346 	__MM_HEAP_MARKEND;
  2347    
  2348 	return result;
  2349 	}
  2350 	
  2351 /*--------------------------------------------------------------
  2352  	Video Capture Control : RECamVideoCaptureNotificationTest
  2353  *--------------------------------------------------------------*/
  2354 RECamVideoCaptureNotificationTest* RECamVideoCaptureNotificationTest::NewL(TBool aAllocTest)
  2355 	{
  2356 	RECamVideoCaptureNotificationTest* self = new (ELeave) RECamVideoCaptureNotificationTest(aAllocTest);
  2357 	CleanupStack::PushL(self);
  2358 	self->ConstructL();
  2359 	CleanupStack::Pop(self);
  2360 	return self;	
  2361 	}
  2362 	
  2363 void RECamVideoCaptureNotificationTest::ConstructL()
  2364 	{
  2365 	}
  2366 	
  2367 RECamVideoCaptureNotificationTest::RECamVideoCaptureNotificationTest(TBool /*aAllocTest*/)
  2368 	{
  2369 	iTestStepName = _L("MM-ECM-ADV-U-057-HP");
  2370 	}
  2371 	
  2372 void RECamVideoCaptureNotificationTest::VideoBufferReady(MCameraBuffer2* /*aVideoBuffer*/, TInt aErrorCode)
  2373 	{
  2374 	iError = aErrorCode;
  2375 	}
  2376 
  2377 void RECamVideoCaptureNotificationTest::ClientSnapshotReady(MCameraBuffer2* /*aSnapshotBuffer*/, TInt aErrorCode)
  2378 	{
  2379 	iError = aErrorCode;
  2380 	}
  2381 
  2382 void RECamVideoCaptureNotificationTest::ClientHistogramReady(MHistogramV2Buffer* /*aClientHistogramBuffer*/, TInt aErrorCode)
  2383 	{
  2384 	iError = aErrorCode;
  2385 	}
  2386 	
  2387 void RECamVideoCaptureNotificationTest::ImageProcessingFailed(TInt aErrorCode)
  2388 	{
  2389 	iError = aErrorCode;	
  2390 	}
  2391 	
  2392 void RECamVideoCaptureNotificationTest::DirectVideoCaptureFailed(TInt aErrorCode)
  2393 	{
  2394 	iError = aErrorCode;
  2395 	}
  2396 	
  2397 TInt RECamVideoCaptureNotificationTest::CustomInterface(TUid /*aInterface*/, TAny*& /*aPtrInterface*/)
  2398 	{
  2399 	return KErrNone;
  2400 	}
  2401 
  2402 void RECamVideoCaptureNotificationTest::CheckVideoCaptureNegNotification(TInt aErrorCode, TVerdict& aResult)	
  2403 	{
  2404 	INFO_PRINTF3(_L("Expected Video Capture Control Error %d, received Error %d."), aErrorCode, iError); 
  2405 	if (iError != aErrorCode)
  2406 		{
  2407 	    aResult = EFail;
  2408 	    }
  2409 	}
  2410 	
  2411 TVerdict RECamVideoCaptureNotificationTest::DoTestStepL()
  2412 	{
  2413 	TVerdict result = EPass;
  2414 	CCamera* camera = NULL;
  2415 	
  2416 	TInt error = KErrNone;
  2417 	CCamera::CCameraVideoCaptureControl* videocapture = NULL;
  2418 	
  2419 	// create video capture control object using New2L
  2420 	__MM_HEAP_MARK;
  2421 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
  2422 	
  2423 	TRAP(error, camera = CCamera::New2L(*this, 0, 0));
  2424 
  2425 	if (error==KErrNone)
  2426 		{
  2427 		CleanupStack::PushL(camera);
  2428 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
  2429 		TRAP(error, videocapture  = CCamera::CCameraVideoCaptureControl::NewL(*camera, *this));	
  2430 		
  2431 		if (error==KErrNone)
  2432 	    	{
  2433 	    	CleanupStack::PushL(videocapture);
  2434 	  		INFO_PRINTF1(_L("CCameraVideoCaptureControl object was created using NewL")); 
  2435 	  		//Test Video Capture APIs
  2436 	  		INFO_PRINTF1(_L("Create Histogram for Direct ViewFinder"));
  2437 	  		CCamera::CCameraV2Histogram* histogram_VC = videocapture->CreateHistogramHandleL();
  2438 	  		if(!histogram_VC)
  2439 	  			{
  2440 	  			INFO_PRINTF1(_L("Histogram creation for Video Capture Control unsuccessful"));
  2441 	  			result = EFail;
  2442 	  			}
  2443 	  			
  2444 	  		CleanupStack::PushL(histogram_VC);
  2445 	  			
  2446 	  		INFO_PRINTF1(_L("Create ImageProcessing for Video Capture Control "));
  2447 	  		
  2448 	  		TRAPD(err, videocapture->GetTransformationHandleL());
  2449   			if(err != KErrNotSupported)
  2450   				{
  2451   				INFO_PRINTF1(_L("ImageProcessing creation for Video Capture Control : unexpected result!"));
  2452   				result = EFail;
  2453   				}
  2454   				
  2455   			INFO_PRINTF1(_L("Create snapshot for Video Capture Control "));
  2456   			TInt viewfinderID=0;
  2457 	  		CCamera::CCameraSnapshot* snapshot_VC = videocapture->GetSnapshotHandleL(viewfinderID);
  2458   			if(!snapshot_VC)
  2459   				{
  2460   				INFO_PRINTF1(_L("snapshot creation for Video Capture Control : unexpected result!"));
  2461   				result = EFail;
  2462   				}
  2463   			
  2464   			CleanupStack::PushL(snapshot_VC);
  2465 	  		
  2466 	  		//set properties for video capture
  2467 	  		INFO_PRINTF1(_L("GetVideoFormatsSupportedL for Video Capture Control"));
  2468 	  		TUint videoFormatsSupported=0;
  2469 	  		TSize size(320,240);
  2470 	  		TRAP(err,videocapture->GetVideoFormatsSupportedL(videoFormatsSupported, size));
  2471   			if(err != KErrNone)
  2472   				{
  2473   				INFO_PRINTF1(_L("GetVideoFormatsSupportedL for Video Capture Control: unexpected result!"));
  2474   				result = EFail;
  2475   				}
  2476 	  		
  2477 	  		if(videoFormatsSupported == 0)
  2478 	  			{
  2479 	  			INFO_PRINTF1(_L(" Number of VideoFormats Supported for Video Capture Control: unexpected result!"));
  2480 	  			}
  2481 	  		
  2482 	  		INFO_PRINTF1(_L("GetPixelAspectsSupportedL for Video Capture Control"));
  2483 	  		TUint pixelAspectsSupported=0;
  2484 	  		CCamera::TFormat format = CCamera::EFormatFbsBitmapColor16M;
  2485 	  		TRAP(err,videocapture->GetPixelAspectsSupportedL(pixelAspectsSupported, format, size));
  2486   			if(err != KErrNone)
  2487   				{
  2488   				INFO_PRINTF1(_L("GetPixelAspectsSupportedL for Video Capture Control: unexpected result!"));
  2489   				result = EFail;
  2490   				}
  2491 	  		
  2492 	  		if(pixelAspectsSupported == 0)
  2493 	  			{
  2494 	  			INFO_PRINTF1(_L(" Number of PixelAspects Supported for Video Capture Control: unexpected result!"));
  2495 	  			}	
  2496 	  			
  2497 			INFO_PRINTF1(_L("GetEmbeddedStillCaptureSupportInfoL for Video Capture Control"));
  2498 	  		TInt supportedEmbeddedStillCaptureTypes=0;
  2499 	  		TRAP(err,videocapture->GetEmbeddedStillCaptureSupportInfoL(supportedEmbeddedStillCaptureTypes));
  2500   			if(err != KErrNone)
  2501   				{
  2502   				INFO_PRINTF1(_L("GetEmbeddedStillCaptureSupportInfoL for Video Capture Control: unexpected result!"));
  2503   				result = EFail;
  2504   				}
  2505 	  		
  2506 	  		if(supportedEmbeddedStillCaptureTypes != 0)
  2507 	  			{
  2508 	  			INFO_PRINTF1(_L(" Supported Types of Embedded Still Capture for Video Capture Control: unexpected result!"));
  2509 	  			}	
  2510 	  			
  2511 			INFO_PRINTF1(_L("PrepareVideoCapture for Video Capture Control"));
  2512 			iInputEventUid = KUidECamEventVideoCaptureControlPrepareComplete;
  2513 			CCamera::CCameraVideoCaptureControl::TPrepareVideoParameters prepareVideoParameters;
  2514 			
  2515 			prepareVideoParameters.SetEmbeddedStillCaptureState(ETrue);
  2516 			
  2517 			if(!prepareVideoParameters.IsEmbeddedStillCaptureEnabled())
  2518 				{
  2519 				INFO_PRINTF1(_L("IsEmbeddedStillCaptureEnabled for Video Capture Control: unexpected result!"));
  2520   				result = EFail;
  2521 				}
  2522 				
  2523 			prepareVideoParameters.SetEmbeddedStillCaptureState(EFalse);
  2524 			
  2525 			if(prepareVideoParameters.IsEmbeddedStillCaptureEnabled() != EFalse)
  2526 				{
  2527 				INFO_PRINTF1(_L("IsEmbeddedStillCaptureEnabled for Video Capture Control: unexpected result!"));
  2528   				result = EFail;
  2529 				}
  2530 			
  2531 	  		videocapture->PrepareVideoCapture(prepareVideoParameters);
  2532 	  		
  2533 	  		CheckNotification(iInputEventUid, result);	
  2534 	
  2535     		INFO_PRINTF1(_L("GetRangeAffectedSettingsL for Video Capture Control"));
  2536 			RArray<TUid> affectedSettings;
  2537 			
  2538 			TRAP(err,videocapture->GetRangeAffectedSettingsL(affectedSettings));
  2539 			if(err != KErrNone)
  2540 				{
  2541 				INFO_PRINTF1(_L("GetRangeAffectedSettingsL for Video Capture Control: unexpected result!"));
  2542   				result = EFail;
  2543 				}
  2544 				
  2545 			if(affectedSettings.Count() != 0)
  2546 				{
  2547 				INFO_PRINTF1(_L("Number of RangeAffectedSettingsL for Video Capture Control: unexpected result!"));
  2548 				result = EFail;
  2549 				}
  2550 				
  2551 			INFO_PRINTF1(_L("GetValueAffectedSettingsL for Video Capture Control"));
  2552 			TRAP(err,videocapture->GetValueAffectedSettingsL(affectedSettings));
  2553 			if(err != KErrNone)
  2554 				{
  2555 				INFO_PRINTF1(_L("GetValueAffectedSettingsL for Video Capture Control: unexpected result!"));
  2556   				result = EFail;
  2557 				}
  2558 				
  2559 			if(affectedSettings.Count() != 0)
  2560 				{
  2561 				INFO_PRINTF1(_L("Number of ValueAffectedSettingsL for Video Capture Control: unexpected result!"));
  2562 				result = EFail;
  2563 				}
  2564 				
  2565 			INFO_PRINTF1(_L("GetDisabledSettingsL for Video Capture Control"));
  2566 			TRAP(err,videocapture->GetDisabledSettingsL(affectedSettings));
  2567 			if(err != KErrNone)
  2568 				{
  2569 				INFO_PRINTF1(_L("GetDisabledSettingsL for Video Capture Control: unexpected result!"));
  2570   				result = EFail;
  2571 				}
  2572 				
  2573 			if(affectedSettings.Count() != 0)
  2574 				{
  2575 				INFO_PRINTF1(_L("Number of DisabledSettingsL for Video Capture Control: unexpected result!"));
  2576 				result = EFail;
  2577 				}
  2578 				
  2579 			INFO_PRINTF1(_L("ReleaseVideoResource for Video Capture Control"));
  2580 			videocapture->ReleaseVideoResource();
  2581 			
  2582 			INFO_PRINTF1(_L("GetFadingEffectStateL for Video Capture Control"));
  2583 			CCamera::CCameraVideoCaptureControl::TFadingEffectState fadingEffectState = 
  2584 																CCamera::CCameraVideoCaptureControl::EFadingEffectDisabled;
  2585 			TRAP(err,videocapture->GetFadingEffectStateL(fadingEffectState));
  2586 			if(err != KErrNotSupported)
  2587 				{
  2588 				INFO_PRINTF1(_L("GetFadingEffectStateL for Video Capture Control: unexpected result!"));
  2589   				result = EFail;
  2590 				}
  2591 			
  2592 			INFO_PRINTF1(_L("SetFadingEffectState for Video Capture Control"));
  2593 			iInputEventUid = KUidECamEventVideoCaptureControlFadingEffect;
  2594 			videocapture->SetFadingEffectState(CCamera::CCameraVideoCaptureControl::EFadingEffectEnabled);
  2595 			CheckNotificationNeg(iInputEventUid, result);
  2596 			
  2597     		//set properties for histogram (for video capture)
  2598 	  		TUint supportedHistogramType=0;
  2599 	  		histogram_VC->GetSupportedHistogramsL(supportedHistogramType);
  2600 	  		if(supportedHistogramType!=0)
  2601 	  			{
  2602 	  			INFO_PRINTF1(_L("unexpected GetSupportedHistogramsL"));
  2603 	  			result = EFail;
  2604 	  			}
  2605 	  			
  2606 	  		INFO_PRINTF1(_L("GetDirectHistogramSupportInfoL for Histogram for Video Capture"));
  2607 	  		TBool directHistogramSupported = EFalse;
  2608 	  		TRAP(err,histogram_VC->GetDirectHistogramSupportInfoL(directHistogramSupported));
  2609   			if(err != KErrNotSupported)
  2610   				{
  2611   				INFO_PRINTF1(_L("GetDirectHistogramSupportInfoL for Histogram for Video Capture: unexpected result!"));
  2612   				result = EFail;
  2613   				}
  2614 	  			
  2615 	  		INFO_PRINTF1(_L("PrepareClientHistogramL for Histogram for Video Capture"));
  2616 	  		CCamera::CCameraV2Histogram::THistogramType histogramType = CCamera::CCameraV2Histogram::EHistNone;
  2617 	  		TRAP(err,histogram_VC->PrepareClientHistogramL(histogramType));
  2618   			if(err != KErrNotSupported)
  2619   				{
  2620   				INFO_PRINTF1(_L("PrepareClientHistogramL for Histogram for Video Capture: unexpected result!"));
  2621   				result = EFail;
  2622   				}
  2623 	  		
  2624 	  		INFO_PRINTF1(_L("PrepareDirectHistogramL for Histogram for Video Capture"));
  2625 	  		CCamera::CCameraV2Histogram::TDirectHistogramParameters histogramParameters;
  2626 	  		TRAP(err,histogram_VC->PrepareDirectHistogramL(histogramParameters));
  2627   			if(err != KErrNotSupported)
  2628   				{
  2629   				INFO_PRINTF1(_L("PrepareDirectHistogramL for Histogram for Video Capture: unexpected result!"));
  2630   				result = EFail;
  2631   				}
  2632 	  			
  2633 	  		INFO_PRINTF1(_L("UpdateDirectHistogramPropertiesL for Histogram for Video Capture"));
  2634 	   		TRAP(err,histogram_VC->UpdateDirectHistogramPropertiesL(histogramParameters));
  2635   			if(err != KErrNotSupported)
  2636   				{
  2637   				INFO_PRINTF1(_L("UpdateDirectHistogramPropertiesL for Histogram for Video Capture: unexpected result!"));
  2638   				result = EFail;
  2639   				}
  2640 	  			
  2641 	  		INFO_PRINTF1(_L("GetDirectHistogramPropertiesL for Histogram for Video Capture"));
  2642 	   		TRAP(err,histogram_VC->GetDirectHistogramPropertiesL(histogramParameters));
  2643   			if(err != KErrNotSupported)
  2644   				{
  2645   				INFO_PRINTF1(_L("GetDirectHistogramPropertiesL for Histogram for Video Capture: unexpected result!"));
  2646   				result = EFail;
  2647   				}
  2648 	  			
  2649 			INFO_PRINTF1(_L("GetHistogramStateL for Histogram for Video Capture"));
  2650 	   		TBool histogramActive = EFalse;
  2651 	   		TRAP(err,histogram_VC->GetHistogramStateL(histogramActive));
  2652   			if(err != KErrNotSupported)
  2653   				{
  2654   				INFO_PRINTF1(_L("GetHistogramStateL for Histogram for Video Capture: unexpected result!"));
  2655   				result = EFail;
  2656   				}
  2657 			
  2658 			//set properties for snapshot (for video capture)
  2659 			CCamera::CCameraSnapshot::TSnapshotParameters snapshotParam;
  2660 			
  2661 			INFO_PRINTF1(_L("SetAspectRatioState for Snapshot for Video Capture"));
  2662 			snapshotParam.SetAspectRatioState(ETrue);
  2663 			TBool aspectRatioState = snapshotParam.IsAspectRatioMaintained();
  2664 			if(!aspectRatioState)
  2665 				{
  2666 				INFO_PRINTF1(_L("AspectRatioState for Snapshot for Video Capture: unexpected result!"));
  2667   				result = EFail;
  2668 				}
  2669 			snapshotParam.SetAspectRatioState(EFalse);
  2670 			aspectRatioState = snapshotParam.IsAspectRatioMaintained();
  2671 			if(aspectRatioState != EFalse)
  2672 				{
  2673 				INFO_PRINTF1(_L("AspectRatioState for Snapshot for Video Capture: unexpected result!"));
  2674   				result = EFail;
  2675 				}
  2676 			
  2677 			INFO_PRINTF1(_L("PrepareSnapshotL for Snapshot for Video Capture"));
  2678 			TRAP(err,snapshot_VC->PrepareSnapshotL(snapshotParam));
  2679 	   		if(err != KErrNone)
  2680 	   			{
  2681 	   			INFO_PRINTF1(_L("PrepareSnapshotL for Snapshot for Video Capture: unexpected result!"));
  2682   				result = EFail;
  2683 	   			}
  2684 	   			
  2685 	   		INFO_PRINTF1(_L("GetSnapshotParametersL for Snapshot for Video Capture"));
  2686 			TRAP(err,snapshot_VC->GetSnapshotParametersL(snapshotParam));
  2687 	   		if(err != KErrNone)
  2688 	   			{
  2689 	   			INFO_PRINTF1(_L("GetSnapshotParametersL for Snapshot for Video Capture: unexpected result!"));
  2690   				result = EFail;
  2691 	   			}
  2692 	   		
  2693 	   		INFO_PRINTF1(_L("SetSnapshotParametersL for Snapshot for Video Capture"));
  2694 			TRAP(err,snapshot_VC->SetSnapshotParametersL(snapshotParam));
  2695 	   		if(err != KErrNone)
  2696 	   			{
  2697 	   			INFO_PRINTF1(_L("SetSnapshotParametersL for Snapshot for Video Capture: unexpected result!"));
  2698   				result = EFail;
  2699 	   			}
  2700 	   				
  2701 			INFO_PRINTF1(_L("SelectSnapshotVideoFramesL for Snapshot for Video Capture"));
  2702 			CCamera::CCameraSnapshot::TSnapshotVideoFrames snapshotVideoFrames = CCamera::CCameraSnapshot::ESnapshotVideoFirstFrame;
  2703 			TRAP(err,snapshot_VC->SelectSnapshotVideoFramesL(snapshotVideoFrames));
  2704 	   		if(err != KErrNotSupported)
  2705 	   			{
  2706 	   			INFO_PRINTF1(_L("SelectSnapshotVideoFramesL for Snapshot for Video Capture: unexpected result!"));
  2707   				result = EFail;
  2708 	   			}
  2709 	   			
  2710 			//Start video capture and other child objects
  2711 			INFO_PRINTF1(_L("StartVideoCaptureL for Video Capture"));
  2712 			TRAP(err,videocapture->StartVideoCaptureL());
  2713 			if(err != KErrNone)
  2714 				{
  2715 	   			INFO_PRINTF1(_L("StartVideoCaptureL for Video Capture: unexpected result!"));
  2716   				result = EFail;
  2717 	   			}
  2718 	   			
  2719 	   		CheckVideoCaptureNegNotification(KErrNotSupported, result);
  2720 	   		
  2721 	   		INFO_PRINTF1(_L("StartHistogram for Video Capture"));
  2722 			histogram_VC->StartHistogram();
  2723 			CheckVideoCaptureNegNotification(KErrNotSupported, result);
  2724 	  		
  2725 	  		INFO_PRINTF1(_L("StopHistogram for Video Capture"));	
  2726 			histogram_VC->StopHistogram();
  2727 			
  2728 			INFO_PRINTF1(_L("EnableSnapshotL for snapshot for Video Capture"));	
  2729 			TRAP(err,snapshot_VC->EnableSnapshotL());
  2730 			if(err != KErrNone)
  2731 				{
  2732 	   			INFO_PRINTF1(_L("EnableSnapshotL for snapshot for Video Capture: unexpected result!"));
  2733   				result = EFail;
  2734 	   			}
  2735 	   		CheckVideoCaptureNegNotification(KErrNotSupported, result);
  2736 	   		
  2737 			INFO_PRINTF1(_L("GetSnapshotStatusL for snapshot for Video Capture"));	
  2738 			CCamera::CCameraSnapshot::TSnapshotState snapshotState = CCamera::CCameraSnapshot::ESnapshotInactive;
  2739 			TRAP(err,snapshot_VC->GetSnapshotStatusL(snapshotState));
  2740 			if(err != KErrNotSupported)
  2741 				{
  2742 	   			INFO_PRINTF1(_L("GetSnapshotStatusL for snapshot for Video Capture: unexpected result!"));
  2743   				result = EFail;
  2744 	   			}
  2745 	   			
  2746 	   		INFO_PRINTF1(_L("DisableSnapshotL for snapshot for Video Capture"));	
  2747 			TRAP(err,snapshot_VC->DisableSnapshotL());
  2748 			if(err != KErrNone)
  2749 				{
  2750 	   			INFO_PRINTF1(_L("DisableSnapshotL for snapshot for Video Capture: unexpected result!"));
  2751   				result = EFail;
  2752 	   			}
  2753 	   			
  2754 	   		INFO_PRINTF1(_L("PauseVideoCapture for Video Capture"));
  2755 	   		videocapture->PauseVideoCapture();
  2756 	   			
  2757 	   		INFO_PRINTF1(_L("ResumeVideoCaptureL for Video Capture"));
  2758 			TRAP(err,videocapture->ResumeVideoCaptureL());
  2759 			if(err != KErrNotSupported)
  2760 				{
  2761 	   			INFO_PRINTF1(_L("ResumeVideoCaptureL for Video Capture: unexpected result!"));
  2762   				result = EFail;
  2763 	   			}
  2764 	   			
  2765 	   		INFO_PRINTF1(_L("GetVideoCaptureStateL for Video Capture"));
  2766 	   		CCamera::CCameraVideoCaptureControl::TVideoCaptureState videoCaptureState = 
  2767 	   				CCamera::CCameraVideoCaptureControl::EVideoCaptureInActive;
  2768 			TRAP(err,videocapture->GetVideoCaptureStateL(videoCaptureState));
  2769 			if(err != KErrNotSupported)
  2770 				{
  2771 	   			INFO_PRINTF1(_L("GetVideoCaptureStateL for Video Capture: unexpected result!"));
  2772   				result = EFail;
  2773 	   			}
  2774 	   			
  2775 	   		INFO_PRINTF1(_L("StopVideoCapture for Video Capture"));
  2776 	   		videocapture->StopVideoCapture();
  2777 	   			   		
  2778 	   		//Start Direct video capture and other child objects
  2779 	   		TInt supportedDVCType = -1;
  2780 	   		INFO_PRINTF1(_L("Check Direct Video Capture Support Info"));
  2781 	   		TRAP(err,videocapture->GetVideoCaptureSupportInfoL(supportedDVCType));
  2782 			if(err != KErrNone)
  2783 				{
  2784 	   			INFO_PRINTF1(_L("GetVideoCaptureSupportInfoL for Video Capture: unexpected result!"));
  2785   				result = EFail;
  2786 	   			}
  2787 	   			
  2788 	   		if(supportedDVCType != KSupportedDirectVCType)
  2789 	   			{
  2790 	   			INFO_PRINTF1(_L("GetVideoCaptureSupportInfoL for Video Capture: unexpected result!"));
  2791   				result = EFail;
  2792 	   			}
  2793 
  2794 			INFO_PRINTF1(_L("Test Set Client Video Capture in PrepareVideoParameters"));
  2795 	   		
  2796 	   		prepareVideoParameters.SetVideoCaptureType(CCamera::CCameraVideoCaptureControl::EClientVideoCapture);
  2797 			
  2798 			if(CCamera::CCameraVideoCaptureControl::EClientVideoCapture != prepareVideoParameters.VideoCaptureType())
  2799 				{
  2800 				INFO_PRINTF1(_L("iVideoCaptureType for TPrepareVideoParameters: unexpected result!"));
  2801   				result = EFail;
  2802 				}
  2803 	   		
  2804 	   		
  2805 			INFO_PRINTF1(_L("Set Video Capture in PrepareVideoParameters"));
  2806 			
  2807 			prepareVideoParameters.SetVideoCaptureType(CCamera::CCameraVideoCaptureControl::EDirectVideoCapture);
  2808 			
  2809 			if(CCamera::CCameraVideoCaptureControl::EDirectVideoCapture != prepareVideoParameters.VideoCaptureType())
  2810 				{
  2811 				INFO_PRINTF1(_L("iVideoCaptureType for TPrepareVideoParameters: unexpected result!"));
  2812   				result = EFail;
  2813 				}
  2814 				
  2815 			prepareVideoParameters.iFormat = CCamera::EFormatEncodedH264;
  2816 			prepareVideoParameters.iPixelAspectRatio = CCamera::CCameraAdvancedSettings::EEPixelAspect40To33;
  2817 			
  2818 			iInputEventUid = KUidECamEventVideoCaptureControlPrepareComplete;
  2819 			videocapture->PrepareVideoCapture(prepareVideoParameters);
  2820 	  		CheckNotification(iInputEventUid, result);
  2821 						
  2822 			INFO_PRINTF1(_L("StartVideoCaptureL for Direct Video Capture"));
  2823 			TRAP(err,videocapture->StartVideoCaptureL());
  2824 			if(err != KErrNone)
  2825 				{
  2826 	   			INFO_PRINTF1(_L("StartVideoCaptureL for Video Capture: unexpected result!"));
  2827   				result = EFail;
  2828 	   			}
  2829 	   			
  2830 	   		CheckVideoCaptureNegNotification(KErrNotSupported, result);
  2831 	   		
  2832 	   		INFO_PRINTF1(_L("StopVideoCapture for Direct Video Capture"));
  2833 	   		videocapture->StopVideoCapture();
  2834 	   		
  2835 	   		INFO_PRINTF1(_L("GetPrepareVideoParameters for Direct Video Capture"));
  2836 	   		CCamera::CCameraVideoCaptureControl::TPrepareVideoParameters retrievedVideoParam;
  2837 			TRAP(err,videocapture->GetPrepareVideoParametersL(retrievedVideoParam));
  2838 			if(err != KErrNone)
  2839 				{
  2840 	   			INFO_PRINTF1(_L("GetPrepareVideoParametersL for Video Capture: unexpected result!"));
  2841   				result = EFail;
  2842 	   			}
  2843 	   			
  2844 	   		if(CCamera::EFormatEncodedH264 != retrievedVideoParam.iFormat)
  2845 				{
  2846 	   			INFO_PRINTF1(_L("GetPrepareVideoParametersL for Video Capture: unexpected result!"));
  2847   				result = EFail;
  2848 	   			}
  2849 	   			
  2850 	   		INFO_PRINTF2(_L("retrievedVideoParam.iFormat: %d"),retrievedVideoParam.iFormat);
  2851 	   		INFO_PRINTF2(_L("retrievedVideoParam.iPixelAspectRatio: %d"),retrievedVideoParam.iPixelAspectRatio);
  2852 	   		
  2853 	   					
  2854 			CleanupStack::PopAndDestroy(snapshot_VC);
  2855 			CleanupStack::PopAndDestroy(histogram_VC);
  2856 			CleanupStack::PopAndDestroy(videocapture);
  2857 	    	}
  2858 	    else
  2859     		{
  2860     		INFO_PRINTF1(_L("CCameraVideoCaptureControl object not created")); 
  2861     		result = EFail;
  2862     		}	
  2863 		CleanupStack::PopAndDestroy(camera);
  2864 		}
  2865 	else 
  2866 		{
  2867 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
  2868 		result = EFail;		
  2869 		}
  2870 	__MM_HEAP_MARKEND;
  2871    
  2872 	return result;
  2873 	}