os/mm/imagingandcamerafws/cameraunittest/src/TSU_ECM_ADV/ECamEnhanceFuncTest.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2005-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 <ecom/ecomresolverparams.h>
    18 #include "ECamEnhanceFuncTest.h"
    19 #include "ECamUnitTestPluginUids.hrh"
    20 #include "ECamUnitTestPlugin.h"
    21 #include <ecam/ecamcommonuids.hrh>
    22 #include <fbs.h>
    23 
    24 /*------------------------------------------------------
    25  	Histogram : RECamHistTest
    26  *------------------------------------------------------*/
    27 RECamHistTest* RECamHistTest::NewL(const TDesC& aTestStep)
    28 	{
    29 	RECamHistTest* self = new (ELeave) RECamHistTest(aTestStep);
    30 	return self;	
    31 	}
    32 	
    33 RECamHistTest::RECamHistTest(const TDesC& aTestStep)
    34 	{
    35 	iTestStepName.Copy(aTestStep);
    36 	}
    37 	
    38 TVerdict RECamHistTest::DoTestStepL()
    39 	{
    40 	if(!iTestStepName.Compare(_L("MM-ECM-ADV-U-020-HP")))
    41 		{
    42 		return DoTestStep_20L();
    43 		}
    44 	else if(!iTestStepName.Compare(_L("MM-ECM-ADV-U-021-HP")))
    45 		{
    46 		return DoTestStep_21L();
    47 		}
    48 	else if(!iTestStepName.Compare(_L("MM-ECM-ADV-U-022-HP")))
    49 		{
    50 		return DoTestStep_22L();
    51 		}
    52 	return EInconclusive;	
    53 	}
    54 
    55 TVerdict RECamHistTest::DoTestStep_20L()	
    56 	{
    57 	TVerdict verdict = EFail;
    58 	INFO_PRINTF1(_L("Alloc test"));
    59 	TInt i;
    60 	TInt err;
    61 	for (i = 1 ; ; i++)
    62 		{
    63 		__MM_HEAP_MARK;
    64 		
    65 		if (i % 5 == 0)
    66 			{
    67 			INFO_PRINTF2(_L("Fail count = %d"), i);
    68 			}
    69 
    70 		__UHEAP_SETFAIL(RHeap::EFailNext, i);
    71 
    72 		TRAP(err, verdict = DoHistTestStepL());
    73 
    74 		TAny* testAlloc = User::Alloc(1);
    75 		TBool heapTestingComplete = (testAlloc == NULL) && (err==KErrNone);
    76 		User::Free(testAlloc);
    77 
    78 		__UHEAP_RESET;
    79 		__MM_HEAP_MARKEND;
    80 
    81 		if ((err != KErrNoMemory ) || heapTestingComplete)
    82 			{
    83 			INFO_PRINTF4(_L("err = %d, verdict = %d, Fail count = %d"), err, verdict, i);
    84 			INFO_PRINTF1(_L("Alloc testing completed successfully"));
    85 			verdict = EPass;
    86 			break;
    87 			}
    88 		}
    89 	return verdict;
    90 	}
    91 	
    92 TVerdict RECamHistTest::DoHistTestStepL()
    93 	{
    94 	TVerdict result = EPass;
    95 	CCamera* camera = NULL;
    96 	
    97 	TInt error = KErrNone;
    98 	CCamera::CCameraHistogram* hist = NULL;
    99 	
   100 	// using observer 2 
   101 	MCameraObserver2* observer2 = NULL; 
   102 	
   103 	__MM_HEAP_MARK;
   104 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
   105 	
   106 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
   107 
   108 	if (error==KErrNone)
   109 		{
   110 		CleanupStack::PushL(camera);
   111 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   112 		hist = 	static_cast<CCamera::CCameraHistogram*> (camera->CustomInterface(KECamHistogramUid));
   113 	    if (hist!= NULL)
   114 	    	{
   115 	    	CleanupStack::PushL(hist);
   116 	  		INFO_PRINTF1(_L("CCameraHistogram object was created")); 
   117 	    	CleanupStack::PopAndDestroy(hist);
   118 	    	}
   119 	    else
   120     		{
   121     		result = EFail;
   122     		User::Leave(KErrNoMemory);
   123     		}	
   124 		CleanupStack::PopAndDestroy(camera);
   125 		}
   126 	else 
   127 		{
   128 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
   129 		result = EFail;		
   130 		User::Leave(KErrNoMemory);
   131 		}
   132 	__MM_HEAP_MARKEND;
   133 	
   134 	// create a Hist object using New2L
   135 	__MM_HEAP_MARK;
   136 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
   137 	
   138 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
   139 
   140 	if (error==KErrNone)
   141 		{
   142 		CleanupStack::PushL(camera);
   143 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   144 		TRAP(error, hist  = CCamera::CCameraHistogram::NewL(*camera));	
   145 		
   146 		if (error==KErrNone)
   147 	    	{
   148 	    	CleanupStack::PushL(hist);
   149 	  		INFO_PRINTF1(_L("CCameraHistogram object was created using NewL")); 
   150 	    	CleanupStack::PopAndDestroy(hist);
   151 	    	}
   152 	    else
   153     		{
   154     		INFO_PRINTF1(_L("CCameraHistogram object was not created using NewL")); 
   155     		result = EFail;
   156     		User::Leave(KErrNoMemory);
   157     		}	
   158 		CleanupStack::PopAndDestroy(camera);
   159 		}
   160 	else 
   161 		{
   162 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
   163 		result = EFail;		
   164 		User::Leave(KErrNoMemory);
   165 		}
   166 	__MM_HEAP_MARKEND;
   167    
   168 	return result;
   169 	}
   170 	
   171 TVerdict RECamHistTest::DoTestStep_21L()
   172 	{
   173 	TVerdict result = EPass;
   174 	CCamera* camera = NULL;
   175 	
   176 	TInt error = KErrNone;
   177 	CCamera::CCameraHistogram* hist = NULL;
   178 		
   179 	// create a Hist object using New2L
   180 	__MM_HEAP_MARK;
   181 	MCameraObserver2* observer2 = NULL; 
   182 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
   183 	
   184 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
   185 
   186 	if (error==KErrNone)
   187 		{
   188 		CleanupStack::PushL(camera);
   189 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   190 		TRAP(error, hist  = CCamera::CCameraHistogram::NewL(*camera));	
   191 		
   192 		if (error==KErrNone)
   193 	    	{
   194 	  		INFO_PRINTF1(_L("CCameraHistogram object was created using NewL")); 
   195 	    	}
   196 	    else
   197     		{
   198     		INFO_PRINTF1(_L("CCameraHistogram object was not created using NewL")); 
   199     		return EFail;
   200     		}	
   201 		}
   202 	else 
   203 		{
   204 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
   205 		result = EFail;		
   206 		}
   207 	
   208 	if (hist!= NULL)
   209     	{
   210     	CleanupStack::PushL(hist);
   211     	
   212     	// get the supported set of values  
   213     	TUint32 suppformats = hist->SupportedHistograms();
   214 
   215     	// the array should not be empty 
   216         if (suppformats == 0)
   217         	{
   218         	result = EFail;
   219         	}
   220         // Preapare DSA Based Histogram	
   221         TUint histhandle = 0;
   222         TPoint orgPos(5,5);
   223         TSize orgSize(90,50);
   224         TRgb orgColor(100,100,100);
   225         
   226     	TRAP(error, histhandle = hist->PrepareDSAHistogramL(CCamera::CCameraHistogram::ELuminance, orgPos, orgSize, orgColor));
   227     	
   228     	if(error==KErrNone)
   229     		{
   230     		INFO_PRINTF1(_L("DSA Histogram Created"));
   231     		}
   232     	else
   233     		{
   234     		INFO_PRINTF2(_L("DSA Histogram Created- %d"), error);
   235     		return EFail;
   236     		}
   237     		
   238     	// set new value
   239     	TPoint curPos;
   240         TSize curSize;
   241         TRgb curColor;
   242     	TRAP(error, hist->GetDSAHistogramPropertiesL(histhandle, curPos, curSize, curColor));
   243     	
   244     	if(error==KErrNone)
   245     		{
   246     		INFO_PRINTF1(_L("Get Histogram Properties"));
   247     		}
   248     	else
   249     		{
   250     		INFO_PRINTF2(_L("Get Histogram Properties- %d"), error);
   251     		return EFail;
   252     		}
   253     		
   254     	if(curPos != orgPos || curSize != orgSize || curColor != orgColor)
   255     		{
   256     		INFO_PRINTF1(_L("Properties dont match"));
   257     		return EFail;
   258     		}
   259     		
   260     	// new values for properties
   261     	orgPos = TPoint(10,10);
   262         orgSize = TSize(80,40);
   263         orgColor = TRgb(90,90,90);
   264        	
   265        	// Lets try update
   266        	TRAP(error, hist->UpdateDSAHistogramPropertiesL(histhandle, orgPos, orgSize, orgColor));
   267 		if(error==KErrNone)
   268 			{
   269 			INFO_PRINTF1(_L("Update Histogram Proporties Successfull"));
   270 			}
   271     	else
   272     		{
   273     		INFO_PRINTF2(_L("Update Histogram Proporties- %d"), error);
   274     		return EFail;
   275     		}	
   276     		
   277     	// Get and verify with new values
   278     	TRAP(error, hist->GetDSAHistogramPropertiesL(histhandle, curPos, curSize, curColor));
   279     	
   280     	if(error==KErrNone)
   281     		{
   282     		INFO_PRINTF1(_L("Get Histogram Properties Successful"));
   283     		}
   284     	else
   285     		{
   286     		INFO_PRINTF2(_L("Get Histogram Properties- %d"), error);
   287     		return EFail;
   288     		}
   289     		
   290     	if(curPos != orgPos || curSize != orgSize || curColor != orgColor)
   291     		{
   292     		INFO_PRINTF1(_L("Properties dont match"));
   293     		return EFail;
   294     		}
   295     	
   296     	    			
   297 		TRAP(error, hist->DestroyHistogramL(histhandle));
   298 		if(error==KErrNone)
   299 			{
   300 			INFO_PRINTF1(_L("Destroy Histogram Successful"));
   301 			}
   302     	else
   303     		{
   304     		INFO_PRINTF2(_L("Destroy Histogram - %d"), error);
   305     		return EFail;
   306     		}
   307     	CleanupStack::PopAndDestroy(hist);
   308     	}
   309 	CleanupStack::PopAndDestroy(camera);
   310 	
   311 	__MM_HEAP_MARKEND;
   312    
   313 	return result;
   314 	}
   315 
   316 // Test step MM-ECM-ADV-U-022-HP 
   317 TVerdict RECamHistTest::DoTestStep_22L()
   318 	{
   319 	TVerdict result = EPass;
   320 	CCamera* camera = NULL;
   321 	
   322 	TInt error = KErrNone;
   323 	CCamera::CCameraHistogram* hist = NULL;
   324 		
   325 	// create a Hist object using NewL
   326 	__MM_HEAP_MARK;
   327 	MCameraObserver2* observer2 = NULL; 
   328 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
   329 	
   330 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
   331 
   332 	if (error==KErrNone)
   333 		{
   334 		CleanupStack::PushL(camera);
   335 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   336 		TRAP(error, hist  = CCamera::CCameraHistogram::NewL(*camera));	
   337 		
   338 		if (error==KErrNone)
   339 	    	{
   340 	  		INFO_PRINTF1(_L("CCameraHistogram object was created using NewL")); 
   341 	    	}
   342 	    else
   343     		{
   344     		INFO_PRINTF1(_L("CCameraHistogram object was not created using NewL")); 
   345     		return EFail;
   346     		}	
   347 		}
   348 	else 
   349 		{
   350 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
   351 		result = EFail;		
   352 		}
   353 	
   354 	if (hist!= NULL)
   355     	{
   356     	CleanupStack::PushL(hist);
   357     	
   358     	// get the supported set of values  
   359     	TUint32 suppformats = hist->SupportedHistograms();
   360 
   361     	// the array should not be empty 
   362         if (suppformats == 0)
   363         	{
   364         	result = EFail;
   365         	}
   366         // Preapare Non-DSA Based Histogram	
   367         TUint histhandle = 0;
   368         TPoint orgPos(5,5);
   369         TSize orgSize(90,50);
   370         TRgb orgColor(100,100,100);
   371         
   372     	TRAP(error, histhandle = hist->PrepareHistogramL(CCamera::CCameraHistogram::ELuminance));
   373     	
   374     	if(error==KErrNone)
   375     		{
   376     		INFO_PRINTF1(_L("Non-DSA Histogram Created Successful"));
   377     		}
   378     	else
   379     		{
   380     		INFO_PRINTF2(_L("Non-DSA Histogram Created- %d"), error);
   381     		return EFail;
   382     		}
   383     		
   384 	
   385 		hist->StartHistogramL(histhandle);
   386     	if(error==KErrNone)
   387     		{
   388     		INFO_PRINTF1(_L("Start Histogram Successful"));
   389     		}
   390     	else
   391     		{
   392     		INFO_PRINTF2(_L("Start Histogram - %d"), error);
   393     		return EFail;
   394     		}
   395     	
   396     	// Get a list of active histograms : This has not been implemented and so the count will be 0
   397     	RArray<TUint> activeHistograms;
   398         TRAP(error, hist->GetActiveHistogramsL(activeHistograms));
   399         if(error==KErrNone)
   400 			{
   401 			INFO_PRINTF1(_L("Stop Histogram Successful"));
   402 			}
   403     	else
   404     		{
   405     		INFO_PRINTF2(_L("Stop Histogram - %d"), error);
   406     		return EFail;
   407     		}
   408     			
   409 		TRAP(error, hist->StopHistogramL(histhandle));
   410 		if(error==KErrNone)
   411 			{
   412 			INFO_PRINTF1(_L("Stop Histogram Successful"));
   413 			}
   414     	else
   415     		{
   416     		INFO_PRINTF2(_L("Stop Histogram - %d"), error);
   417     		return EFail;
   418     		}    			
   419     		
   420 		TRAP(error, hist->DestroyHistogramL(histhandle));
   421 		if(error==KErrNone)
   422 			{
   423 			INFO_PRINTF1(_L("Destroy Histogram Successful"));
   424 			}
   425     	else
   426     		{
   427     		INFO_PRINTF2(_L("Destroy Histogram - %d"), error);
   428     		return EFail;
   429     		}
   430     	CleanupStack::PopAndDestroy(hist);
   431     	}
   432 	CleanupStack::PopAndDestroy(camera);
   433 	
   434 	__MM_HEAP_MARKEND;
   435    
   436 	return result;
   437 	}
   438 	
   439 //
   440 // RECamHistogramNotificationTest
   441 //
   442 RECamHistogramNotificationTest* RECamHistogramNotificationTest::NewL(TBool aAllocTest)
   443 	{
   444 	RECamHistogramNotificationTest* self = new (ELeave) RECamHistogramNotificationTest(aAllocTest);
   445 	CleanupStack::PushL(self);
   446 	self->ConstructL();
   447 	CleanupStack::Pop(self);
   448 	return self;	
   449 	}
   450 	
   451 void RECamHistogramNotificationTest::ConstructL()
   452 	{
   453 	iOriginalSet.Reset();
   454 	iResultSet.Reset();
   455 
   456 	}
   457 RECamHistogramNotificationTest::RECamHistogramNotificationTest(TBool /*aAllocTest*/)
   458 	{
   459 	iTestStepName = _L("MM-ECM-ADV-U-023-HP");
   460 	}
   461 
   462 TVerdict RECamHistogramNotificationTest::DoTestStepL()
   463 	{	
   464 	TVerdict result = EPass;
   465 	CCamera* camera = NULL;
   466 	
   467 	TInt error = KErrNone;
   468 	CCamera::CCameraHistogram* hist = NULL;
   469 		
   470 	__MM_HEAP_MARK;
   471 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
   472 	
   473 	TRAP(error, camera = CCamera::New2L(*this,0,0));
   474 
   475 	if (error==KErrNone)
   476 		{
   477 		CleanupStack::PushL(camera);
   478 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   479 		
   480 		TRAP(error, hist  = CCamera::CCameraHistogram::NewL(*camera));	
   481 		if (error==KErrNone)
   482 	    	{
   483 	  		INFO_PRINTF1(_L("CCameraHistogram object was created using NewL")); 
   484 	    	}
   485 	    else
   486     		{
   487     		INFO_PRINTF1(_L("CCameraHistogram object was not created using NewL")); 
   488     		result = EFail;
   489     		}	
   490     		
   491 	    if (hist!= NULL)
   492 	    	{
   493 	    	CleanupStack::PushL(hist);
   494 	    	
   495 	    	// get the supported set of values  
   496 	    	TUint32 suppformats = hist->SupportedHistograms();
   497 
   498 	    	// the array should not be empty 
   499 	        if (suppformats == 0)
   500 	        	{
   501 	        	result = EFail;
   502 	        	}
   503 	        TUint histhandle = 0;
   504         	TRAP(error, histhandle = hist->PrepareHistogramL(CCamera::CCameraHistogram::ELuminance));
   505         	
   506         	// set new value
   507 	    	iInputEventUid.iUid = KUidECamEventHistogramUidValue;
   508 	        	    	
   509 	    	hist->StartHistogramL(histhandle);
   510 	    	if(error==KErrNone)
   511 	    		{
   512 	    		INFO_PRINTF1(_L("Start Histogram Successful"));
   513 	    		}
   514 	    	else
   515 	    		{
   516 	    		INFO_PRINTF2(_L("Start Histogram - %d"), error);
   517 	    		result = EFail;
   518 	    		}
   519 	    	
   520 	        CheckNotification(iInputEventUid, result);
   521     		
   522     		// Ignore the Data - check the function
   523     		TRAP(error, hist->HistogramDataL());
   524     		if(error==KErrNone)
   525     			{
   526     			INFO_PRINTF1(_L("Histogram DataL Successful"));
   527     			}
   528 	    	else
   529 	    		{
   530 	    		INFO_PRINTF2(_L("Histogram DataL - %d"), error);
   531 	    		result = EFail;
   532 	    		}
   533 	    		
   534 	    	// Overload of HistogramDataL
   535 	    	TRAP(error, hist->HistogramDataL(histhandle));
   536     		if(error==KErrNone)
   537     			{
   538     			INFO_PRINTF1(_L("Histogram DataL Successful"));
   539     			}
   540 	    	else
   541 	    		{
   542 	    		INFO_PRINTF2(_L("Histogram DataL - %d"), error);
   543 	    		result = EFail;
   544 	    		}
   545     			
   546     		TRAP(error, hist->StopHistogramL(histhandle));
   547     		
   548     		if(error==KErrNone)
   549     			{
   550     			INFO_PRINTF1(_L("Stop Histogram Successful"));
   551     			}
   552 	    	else
   553 	    		{
   554 				INFO_PRINTF2(_L("Stop Histogram - %d"), error);
   555 	    		result = EFail;
   556 	    		}
   557 	    			
   558     		TRAP(error, hist->DestroyHistogramL(histhandle));
   559 			if(error==KErrNone)
   560     			{
   561     			INFO_PRINTF1(_L("Destroy Histogram Successful"));
   562     			}
   563 	    	else
   564 	    		{
   565 	    		INFO_PRINTF2(_L("Destroy Histogram - %d"), error);
   566 	    		result = EFail;
   567 	    		}
   568 	    	    		
   569     		CleanupStack::PopAndDestroy(hist);
   570 	    	}
   571 	    else
   572     		{
   573     		result = EFail;
   574     		}
   575 		CleanupStack::PopAndDestroy(camera);
   576 		}
   577 	else 
   578 		{
   579 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
   580 		result = EFail;		
   581 		}
   582 	
   583 	__MM_HEAP_MARKEND;
   584 
   585 	return result;
   586 	}
   587 
   588 /*------------------------------------------------------
   589  	Overlay : RECamOvrlayTest
   590  *------------------------------------------------------*/
   591 
   592 RECamOvrlayTest* RECamOvrlayTest::NewL(const TDesC& aTestStep)
   593 	{
   594 	RECamOvrlayTest* self = new (ELeave) RECamOvrlayTest(aTestStep);
   595 	return self;	
   596 	}
   597 	
   598 RECamOvrlayTest::RECamOvrlayTest(const TDesC& aTestStep)
   599 	{
   600 	iTestStepName.Copy(aTestStep);
   601 	}
   602 	
   603 TVerdict RECamOvrlayTest::DoTestStepL()
   604 	{
   605 	if(!iTestStepName.Compare(_L("MM-ECM-ADV-U-030-HP")))
   606 		{
   607 		return DoTestStep_30L();
   608 		}
   609 	else if(!iTestStepName.Compare(_L("MM-ECM-ADV-U-031-HP")))
   610 		{
   611 		return DoTestStep_31L();
   612 		}
   613 	return EFail;	
   614 	}
   615 	
   616 TVerdict RECamOvrlayTest::DoTestStep_30L()
   617 	{
   618 	TVerdict verdict = EFail;
   619 	INFO_PRINTF1(_L("Alloc test"));
   620 	TInt i;
   621 	TInt err;
   622 	for (i = 1 ; ; i++)
   623 		{
   624 		__MM_HEAP_MARK;
   625 		
   626 		if (i % 5 == 0)
   627 			{
   628 			INFO_PRINTF2(_L("Fail count = %d"), i);
   629 			}
   630 
   631 		__UHEAP_SETFAIL(RHeap::EFailNext, i);
   632 
   633 		TRAP(err, verdict = DoOverlayTestStepL());
   634 
   635 		TAny* testAlloc = User::Alloc(1);
   636 		TBool heapTestingComplete = (testAlloc == NULL) && (err==KErrNone);
   637 		User::Free(testAlloc);
   638 
   639 		__UHEAP_RESET;
   640 		__MM_HEAP_MARKEND;
   641 
   642 		if ((err != KErrNoMemory ) || heapTestingComplete)
   643 			{
   644 			INFO_PRINTF4(_L("err = %d, verdict = %d, Fail count = %d"), err, verdict, i);
   645 			INFO_PRINTF1(_L("Alloc testing completed successfully"));
   646 			verdict = EPass;
   647 			break;
   648 			}
   649 		}
   650 	return verdict;
   651 	}
   652 
   653 TVerdict RECamOvrlayTest::DoOverlayTestStepL()
   654 	{
   655 	TVerdict result = EPass;
   656 	CCamera* camera = NULL;
   657 	
   658 	TInt error = KErrNone;
   659 	CCamera::CCameraOverlay* ovrlay = NULL;
   660 	
   661 	// using observer 2 
   662 	MCameraObserver2* observer2 = NULL; 
   663 	
   664 	__MM_HEAP_MARK;
   665 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
   666 	
   667 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
   668 
   669 	if (error==KErrNone)
   670 		{
   671 		CleanupStack::PushL(camera);
   672 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   673 		ovrlay = 	static_cast<CCamera::CCameraOverlay*> (camera->CustomInterface(KECamOverlayUid));
   674 	    if (ovrlay!= NULL)
   675 	    	{
   676 	    	CleanupStack::PushL(ovrlay);
   677 	  		INFO_PRINTF1(_L("CCameraOverlay object was created")); 
   678 	    	CleanupStack::PopAndDestroy(ovrlay);
   679 	    	}
   680 	    else
   681     		{
   682     		result = EFail;
   683     		User::Leave(KErrNoMemory);
   684     		}	
   685 		CleanupStack::PopAndDestroy(camera);
   686 		}
   687 	else 
   688 		{
   689 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
   690 		result = EFail;	
   691 		User::Leave(KErrNoMemory);	
   692 		}
   693 	__MM_HEAP_MARKEND;
   694 	
   695 	// create overlay object using NewL
   696 	__MM_HEAP_MARK;
   697 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
   698 	
   699 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
   700 
   701 	if (error==KErrNone)
   702 		{
   703 		CleanupStack::PushL(camera);
   704 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   705 		TRAP(error, ovrlay  = CCamera::CCameraOverlay::NewL(*camera));	
   706 		
   707 		if (error==KErrNone)
   708 	    	{
   709 	    	CleanupStack::PushL(ovrlay);
   710 	  		INFO_PRINTF1(_L("CCameraOverlay object was created using NewL")); 
   711 	  		
   712 	  		CleanupStack::PopAndDestroy(ovrlay);
   713 	    	}
   714 	    else
   715     		{
   716     		INFO_PRINTF1(_L("CCameraOverlay object was not created using NewL")); 
   717     		result = EFail;
   718     		User::Leave(KErrNoMemory);
   719     		}	
   720 		CleanupStack::PopAndDestroy(camera);
   721 		}
   722 	else 
   723 		{
   724 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
   725 		result = EFail;	
   726 		User::Leave(KErrNoMemory);	
   727 		}
   728 	__MM_HEAP_MARKEND;
   729    
   730 	return result;
   731 	}
   732 
   733 TVerdict RECamOvrlayTest::DoTestStep_31L()
   734 	{
   735 	TVerdict result = EPass;
   736 	CCamera* camera = NULL;
   737 	TInt error = KErrNone;
   738 	CCamera::CCameraOverlay* ovrlay = NULL;
   739 		
   740 	// create a Overlay object using NewL
   741 	MCameraObserver2* observer2 = NULL; 
   742 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
   743 	
   744 	__MM_HEAP_MARK;
   745 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
   746 
   747 	if (error==KErrNone)
   748 		{
   749 		CleanupStack::PushL(camera);
   750 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   751 		TRAP(error, ovrlay  = CCamera::CCameraOverlay::NewL(*camera));	
   752 		
   753 		if (error==KErrNone)
   754 	    	{
   755 	    	INFO_PRINTF1(_L("CCameraOverlay object was created using NewL")); 
   756 	       	}
   757 	    else
   758     		{
   759     		INFO_PRINTF2(_L("CCameraOverlay object was not created using NewL - %d"), error); 
   760     		result = EFail;
   761     		}
   762     	CleanupStack::PushL(ovrlay);	
   763     	
   764     	
   765     	CCamera::CCameraOverlay::TOverlayParameters parameters;
   766     	parameters.iCurrentModes = CCamera::CCameraOverlay::EModeStillImage;
   767 		parameters.iCurrentTypes = CCamera::CCameraOverlay::EPerPixel;
   768 		parameters.iAlphaValue= 0;	
   769 		parameters.iPosition = TPoint(2,2);		
   770 		parameters.iZOrder = 1;	
   771  	 	
   772  	 	TInt err = RFbsSession::Connect();
   773     	if (err != KErrNone)
   774     		{
   775     		INFO_PRINTF2(_L("RFbsSession::Connect() failed, err = %d"), err);
   776 			return EInconclusive;
   777     		}   
   778  	 	
   779  	 	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
   780     	CleanupStack::PushL(bitmap);	
   781     	    	
   782     	TUint ovrhandle =0;	 
   783     	
   784     	TRAP(error, ovrhandle = ovrlay->CreateOverlayL(parameters, bitmap));
   785  	 	
   786  	 	if (error == KErrNone)
   787 	    	{
   788 	    	INFO_PRINTF1(_L("Create overlay was successful")); 
   789 	       	}
   790 	    else
   791     		{
   792     		INFO_PRINTF2(_L("Create overlay - Error - %d"), error); 
   793     		result = EFail;
   794     		}
   795    
   796  		TRAP(error, ovrlay->SetOverlayBitmapL(ovrhandle, bitmap));
   797  		if (error == KErrNone)
   798 	    	{
   799 	    	INFO_PRINTF1(_L("Set Overlay Bitmap was successful")); 
   800 	       	}
   801 	    else
   802     		{
   803     		INFO_PRINTF2(_L("Set Overlay Bitmap - Error - %d"), error); 
   804     		result = EFail;
   805     		}
   806     		
   807     	CFbsBitmap* modBitmap = new (ELeave) CFbsBitmap;
   808     	User::LeaveIfError(modBitmap->Create(TSize(1000,1000),EGray256)); 
   809     	CleanupStack::PushL(modBitmap);		
   810     	TRAP(error, ovrlay->SetModifiableOverlayBitmapL(ovrhandle, modBitmap));
   811  		if (error == KErrNone)
   812 	    	{
   813 	    	INFO_PRINTF1(_L("Set Modifiable Overlay Bitmap was successful")); 
   814 	       	}
   815 	    else
   816     		{
   817     		INFO_PRINTF2(_L("Set Modifiable Overlay Bitmap - Error - %d"), error); 
   818     		result = EFail;
   819     		}
   820    
   821        	CFbsBitmap* getBitmap = new (ELeave) CFbsBitmap;
   822     	User::LeaveIfError(getBitmap->Create(TSize(1000,1000),EGray256)); 
   823     	CleanupStack::PushL(getBitmap);
   824     	TRAP(error, ovrlay->GetOverlayBitmapL(ovrhandle, getBitmap));
   825     	if (error == KErrNone)
   826 	    	{
   827 	    	INFO_PRINTF1(_L("Get Overlay Bitmap was successful")); 
   828 	       	}
   829 	    else
   830     		{
   831     		INFO_PRINTF2(_L("Get Overlay Bitmap - Error - %d"), error); 
   832  	  		result = EFail;
   833     		}
   834 
   835     	TRAP(error, ovrlay->GetOverlayParametersL(ovrhandle, parameters));
   836     	if (error == KErrNone)
   837 	    	{
   838 	    	INFO_PRINTF1(_L("Get Overlay Parameters was successful")); 
   839 	       	}
   840 	    else
   841     		{
   842     		INFO_PRINTF2(_L("Get Overlay Parameters - Error - %d"), error); 
   843     		result = EFail;
   844     		}
   845    	  		 	
   846  		TRAP(error, ovrlay->SetOverlayParametersL(ovrhandle, parameters));
   847  		if (error == KErrNone)
   848 	    	{
   849 	    	INFO_PRINTF1(_L("Set Overlay Parameters  was successful")); 
   850 	       	}
   851 	    else
   852     		{
   853     		INFO_PRINTF2(_L("Set Overlay Parameters  - Error - %d"), error); 
   854     		result = EFail;
   855     		}
   856  		 
   857  		CCamera::CCameraOverlay::TOverlaySupportInfo SuppInfo;
   858  		TRAP(error, ovrlay->GetOverlaySupport(SuppInfo));
   859  		if (error == KErrNone)
   860 	    	{
   861 	    	INFO_PRINTF1(_L("Get Overlay support was successful")); 
   862 	       	}
   863 	    else
   864     		{
   865     		INFO_PRINTF2(_L("Get Overlay support - Error - %d"), error); 
   866     		result = EFail;
   867     		}
   868  		
   869  		RArray<TUint> overlayHandles;
   870     	TRAP(error, ovrlay->GetAllOverlaysInZOrderL(overlayHandles));
   871     	if (error == KErrNone)
   872 	    	{
   873 	    	INFO_PRINTF1(_L("Get All Overlays in Z order was successful")); 
   874 	       	}
   875 	    else
   876     		{
   877     		INFO_PRINTF2(_L("Get All Overlays in Z order - Error - %d"), error); 
   878     		result = EFail;
   879     		}
   880     		
   881     	TRAP(error, ovrlay->GetAllOverlaysInZOrderL(CCamera::CCameraOverlay::EModeStillImage,1,overlayHandles));
   882     	if (error == KErrNone)
   883 	    	{
   884 	    	INFO_PRINTF1(_L("Get 'Mode specific' All Overlays in Z order was successful")); 
   885 	       	}
   886 	    else
   887     		{
   888     		INFO_PRINTF2(_L("Get 'Mode specific' All Overlays in Z order - Error - %d"), error); 
   889     		result = EFail;
   890     		}
   891     		
   892     	
   893  		TRAP(error, ovrlay->SetAllOverlaysInZOrderL(overlayHandles));
   894  		if (error == KErrNone)
   895 	    	{
   896 	    	INFO_PRINTF1(_L("Set All Overlay in Z order was successful")); 
   897 	       	}
   898 	    else
   899     		{
   900     		INFO_PRINTF2(_L("Set All Overlay in Z order- Error - %d"), error); 
   901     		result = EFail;
   902     		}
   903     		
   904     	TRAP(error, ovrlay->SetAllOverlaysInZOrderL(CCamera::CCameraOverlay::EModeStillImage,1,overlayHandles));
   905  		if (error == KErrNone)
   906 	    	{
   907 	    	INFO_PRINTF1(_L("Set 'Mode specific' All Overlay in Z order was successful")); 
   908 	       	}
   909 	    else
   910     		{
   911     		INFO_PRINTF2(_L("Set 'Mode specific' All Overlay in Z order- Error - %d"), error); 
   912     		result = EFail;
   913     		}
   914     		
   915     	overlayHandles.Close();
   916     	
   917     	TRAP(error, ovrlay->ReleaseOverlay(ovrhandle));
   918  		if (error == KErrNone)
   919 	    	{
   920 	    	INFO_PRINTF1(_L("Release Overlay was successful")); 
   921 	       	}
   922 	    else
   923     		{
   924     		INFO_PRINTF2(_L("Release Overlay - Error - %d"), error); 
   925     		result = EFail;
   926     		}
   927     		
   928     	CleanupStack::PopAndDestroy(4, ovrlay); //bitmap, ovrlay	
   929     		
   930     	TRAP(error, ovrlay  = CCamera::CCameraOverlay::NewL(*camera));		
   931     	CleanupStack::PushL(ovrlay);	
   932         bitmap = new (ELeave) CFbsBitmap;
   933     	CleanupStack::PushL(bitmap);	
   934     	ovrhandle =0;	   	
   935 	   	
   936 	   	TRAP(error, ovrhandle = ovrlay->CreateOverlayL(parameters, bitmap));
   937     	TSize originalSize = bitmap->SizeInPixels();
   938     	
   939     	INFO_PRINTF1(_L("Test size change through CFbsbitmap")); 
   940     	TSize modifiedSize(640, 480);
   941     	CFbsBitmap* modifiedBitmap = new (ELeave) CFbsBitmap;    	
   942     	User::LeaveIfError(modifiedBitmap->Create(modifiedSize,EColor4K)); 
   943     	CleanupStack::PushL(modifiedBitmap);   	
   944     	originalSize = modifiedBitmap->SizeInPixels();
   945     	TRAP(error, ovrlay->SetModifiableOverlayBitmapL(ovrhandle,modifiedBitmap));   
   946      
   947     	CFbsBitmap* retrievedBitmap = new (ELeave) CFbsBitmap;
   948     	User::LeaveIfError(retrievedBitmap->Create(TSize(1000,1000),EGray256)); 
   949     	CleanupStack::PushL(retrievedBitmap);  
   950     	TRAP(error, ovrlay->GetOverlayBitmapL(ovrhandle, retrievedBitmap));
   951     	
   952     	TSize retrievedSize = retrievedBitmap->SizeInPixels();
   953     	
   954     	if(originalSize != retrievedSize)
   955     		{
   956     		INFO_PRINTF2(_L("Modifying overlay size - Error - %d"), error);
   957     		result = EFail;
   958     		}	
   959    	 	
   960  	 	CleanupStack::PopAndDestroy(4, ovrlay);
   961 		}
   962 	else 
   963 		{
   964 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
   965 		result = EFail;		
   966 		}
   967 
   968 	RFbsSession::Disconnect();
   969 	
   970 	CleanupStack::PopAndDestroy(camera);
   971 	__MM_HEAP_MARKEND;
   972 	
   973 	//
   974 	__MM_HEAP_MARK;
   975 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
   976 
   977 	if (error==KErrNone)
   978 		{
   979 		CleanupStack::PushL(camera);
   980 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   981 		TRAP(error, ovrlay  = CCamera::CCameraOverlay::NewL(*camera));	
   982 		
   983 		if (error==KErrNone)
   984 	    	{
   985 	    	INFO_PRINTF1(_L("CCameraOverlay object was created using NewL")); 
   986 	       	}
   987 	    else
   988     		{
   989     		INFO_PRINTF2(_L("CCameraOverlay object was not created using NewL - %d"), error); 
   990     		result = EFail;
   991     		}
   992     	CleanupStack::PushL(ovrlay);	
   993     	
   994     	
   995     	CCamera::CCameraOverlay::TOverlayParameters parameters;
   996     	parameters.iCurrentModes = CCamera::CCameraOverlay::EModeStillImage;
   997 		parameters.iCurrentTypes = CCamera::CCameraOverlay::EPerPixel;
   998 		parameters.iAlphaValue= 0;	
   999 		TSize size2(20,20);				
  1000 		parameters.iPosition = TPoint(2,2);		
  1001 		parameters.iZOrder = 1;	
  1002 				
  1003     	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
  1004     	CleanupStack::PushL(bitmap);
  1005     
  1006     	TUint ovrhandle =0;
  1007    
  1008     	TRAP(error, ovrhandle = ovrlay->CreateOverlayL(parameters, bitmap));
  1009     	if (error == KErrNone)
  1010 	    	{
  1011 	    	INFO_PRINTF1(_L("Create overlay was successful")); 
  1012 	       	}
  1013 	    else
  1014     		{
  1015     		INFO_PRINTF2(_L("Create overlay - Error - %d"), error); 
  1016     		result = EFail;
  1017     		}
  1018    
  1019  	   	TRAP(error, ovrlay->GetOverlayParametersL(ovrhandle, parameters));
  1020     	if (error == KErrNone)
  1021 	    	{
  1022 	    	INFO_PRINTF1(_L("Get Overlay Parameters was successful")); 
  1023 	       	}
  1024 	    else
  1025     		{
  1026     		INFO_PRINTF2(_L("Get Overlay Parameters - Error - %d"), error); 
  1027     		result = EFail;
  1028     		}
  1029     		
  1030     	if(parameters.iCurrentModes & CCamera::CCameraOverlay::EModeStillImageContinuous)
  1031     		{
  1032     		INFO_PRINTF1(_L("GetOverlayParametersL  was successful"));
  1033     		}
  1034     	else
  1035     		{
  1036     		INFO_PRINTF1(_L("Get Overlay Parameters  unexpected result")); 
  1037     		result = EFail;	
  1038     		}
  1039    	  		 	
  1040  		TRAP(error, ovrlay->SetOverlayParametersL(ovrhandle, parameters));
  1041  		if (error == KErrNone)
  1042 	    	{
  1043 	    	INFO_PRINTF1(_L("Set Overlay Parameters  was successful")); 
  1044 	       	}
  1045 	    else
  1046     		{
  1047     		INFO_PRINTF2(_L("Set Overlay Parameters  - Error - %d"), error); 
  1048     		result = EFail;
  1049     		}
  1050  		
  1051  		CCamera::CCameraOverlay::TOverlaySupportInfo SuppInfo;
  1052  		TRAP(error, ovrlay->GetOverlaySupport(SuppInfo));
  1053  		if (error == KErrNone)
  1054 	    	{
  1055 	    	INFO_PRINTF1(_L("Get Overlay support was successful")); 
  1056 	       	}
  1057 	    else
  1058     		{
  1059     		INFO_PRINTF2(_L("Get Overlay support - Error - %d"), error); 
  1060     		result = EFail;
  1061     		}
  1062     		
  1063     	if(SuppInfo.iSupportedModes & CCamera::CCameraOverlay::EModeStillImageContinuous)
  1064     		{
  1065     		INFO_PRINTF1(_L("GetOverlaySupport values were successful"));
  1066     		}
  1067     	else
  1068     		{
  1069     		INFO_PRINTF1(_L("GetOverlaySupport values unexpected result")); 
  1070     		result = EFail;	
  1071     		}
  1072     		
  1073     	//conditional coverage for SetOverlay Parameter
  1074     	parameters.iCurrentModes = CCamera::CCameraOverlay::EModeViewfinder;
  1075     	TRAP(error, ovrlay->SetOverlayParametersL(ovrhandle, parameters));
  1076  		if (error == KErrNone)
  1077 	    	{
  1078 	    	INFO_PRINTF1(_L("Set Overlay Parameters  was successful")); 
  1079 	       	}
  1080 	    else
  1081     		{
  1082     		INFO_PRINTF2(_L("Set Overlay Parameters  - Error - %d"), error); 
  1083     		result = EFail;
  1084     		}
  1085     	
  1086     	parameters.iCurrentModes = CCamera::CCameraOverlay::EModeNone;
  1087     	TRAP(error, ovrlay->GetOverlayParametersL(ovrhandle, parameters));
  1088  		if (error == KErrNone)
  1089 	    	{
  1090 	    	INFO_PRINTF1(_L("Get Overlay Parameters  was successful")); 
  1091 	       	}
  1092 	    else
  1093     		{
  1094     		INFO_PRINTF2(_L("Get Overlay Parameters  - Error - %d"), error); 
  1095     		result = EFail;
  1096     		}	
  1097     		
  1098     	if(parameters.iCurrentModes & CCamera::CCameraOverlay::EModeClientViewfinder)
  1099     		{
  1100     		INFO_PRINTF1(_L("GetOverlayParametersL  was successful"));
  1101     		}
  1102     	else
  1103     		{
  1104     		INFO_PRINTF1(_L("Get Overlay Parameters  unexpected result")); 
  1105     		result = EFail;	
  1106     		}
  1107     		
  1108       	TRAP(error, ovrlay->ReleaseOverlay(ovrhandle));
  1109  		if (error == KErrNone)
  1110 	    	{
  1111 	    	INFO_PRINTF1(_L("Release Overlay was successful")); 
  1112 	       	}
  1113 	    else
  1114     		{
  1115     		INFO_PRINTF2(_L("Release Overlay - Error - %d"), error); 
  1116     		result = EFail;
  1117     		}
  1118     	
  1119     	CleanupStack::PopAndDestroy(2, ovrlay); //bitmap, ovrlay
  1120 		}
  1121 	else 
  1122 		{
  1123 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
  1124 		result = EFail;		
  1125 		}
  1126 	CleanupStack::PopAndDestroy(camera);
  1127 	__MM_HEAP_MARKEND;
  1128 	//
  1129    
  1130 	return result;
  1131 	}
  1132 
  1133 /*------------------------------------------------------
  1134  	Snapshot : RECamSnapTest
  1135  *------------------------------------------------------*/
  1136 
  1137 RECamSnapTest* RECamSnapTest::NewL(const TDesC& aTestStep)
  1138 	{
  1139 	RECamSnapTest* self = new (ELeave) RECamSnapTest(aTestStep);
  1140 	return self;	
  1141 	}
  1142 	
  1143 RECamSnapTest::RECamSnapTest(const TDesC& aTestStep)
  1144 	{
  1145 	iTestStepName.Copy(aTestStep);
  1146 	}
  1147 	
  1148 TVerdict RECamSnapTest::DoTestStepL()
  1149 	{
  1150 	if(!iTestStepName.Compare(_L("MM-ECM-ADV-U-040-HP")))
  1151 		{
  1152 		return DoTestStep_40L();
  1153 		}
  1154 	else if(!iTestStepName.Compare(_L("MM-ECM-ADV-U-041-HP")))
  1155 		{
  1156 		return DoTestStep_41L();
  1157 		}
  1158 	else if(!iTestStepName.Compare(_L("MM-ECM-ADV-U-042-HP")))
  1159 		{
  1160 		return DoTestStep_42L();
  1161 		}	
  1162 	return EFail;
  1163 	}
  1164 
  1165 TVerdict RECamSnapTest::DoTestStep_40L()
  1166 	{
  1167 	TVerdict verdict = EFail;
  1168 	INFO_PRINTF1(_L("Alloc test"));
  1169 	TInt i;
  1170 	TInt err;
  1171 	for (i = 1 ; ; i++)
  1172 		{
  1173 		__MM_HEAP_MARK;
  1174 		
  1175 		if (i % 5 == 0)
  1176 			{
  1177 			INFO_PRINTF2(_L("Fail count = %d"), i);
  1178 			}
  1179 
  1180 		__UHEAP_SETFAIL(RHeap::EFailNext, i);
  1181 
  1182 		TRAP(err, verdict = DoSnapTestStepL());
  1183 
  1184 		TAny* testAlloc = User::Alloc(1);
  1185 		TBool heapTestingComplete = (testAlloc == NULL) && (err==KErrNone);
  1186 		User::Free(testAlloc);
  1187 
  1188 		__UHEAP_RESET;
  1189 		__MM_HEAP_MARKEND;
  1190 
  1191 		if ((err != KErrNoMemory ) || heapTestingComplete)
  1192 			{
  1193 			INFO_PRINTF4(_L("err = %d, verdict = %d, Fail count = %d"), err, verdict, i);
  1194 			INFO_PRINTF1(_L("Alloc testing completed successfully"));
  1195 			verdict = EPass;
  1196 			break;
  1197 			}
  1198 		}
  1199 	return verdict;
  1200 	}
  1201 	
  1202 TVerdict RECamSnapTest::DoSnapTestStepL()
  1203 	{
  1204 	TVerdict result = EPass;
  1205 	CCamera* camera = NULL;
  1206 	
  1207 	TInt error = KErrNone;
  1208 	CCamera::CCameraSnapshot* snap = NULL;
  1209 	
  1210 	// using observer 2 
  1211 	MCameraObserver2* observer2 = NULL; 
  1212 	
  1213 	__MM_HEAP_MARK;
  1214 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
  1215 	
  1216 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
  1217 
  1218 	if (error==KErrNone)
  1219 		{
  1220 		CleanupStack::PushL(camera);
  1221 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
  1222 		snap = 	static_cast<CCamera::CCameraSnapshot*> (camera->CustomInterface(KECamSnapshotUid));
  1223 	    if (snap!= NULL)
  1224 	    	{
  1225 	    	CleanupStack::PushL(snap);
  1226 	  		INFO_PRINTF1(_L("CCameraSnaphot object was created")); 
  1227 	    	CleanupStack::PopAndDestroy(snap);
  1228 	    	}
  1229 	    else
  1230     		{
  1231     		result = EFail;
  1232     		User::Leave(KErrNoMemory);
  1233     		}	
  1234 		CleanupStack::PopAndDestroy(camera);
  1235 		}
  1236 	else 
  1237 		{
  1238 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
  1239 		result = EFail;	
  1240 		User::Leave(KErrNoMemory);	
  1241 		}
  1242 	__MM_HEAP_MARKEND;
  1243 	
  1244 	// create a Snapshot object using NewL
  1245 	__MM_HEAP_MARK;
  1246 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
  1247 	
  1248 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
  1249 
  1250 	if (error==KErrNone)
  1251 		{
  1252 		CleanupStack::PushL(camera);
  1253 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
  1254 		TRAP(error, snap  = CCamera::CCameraSnapshot::NewL(*camera));	
  1255 		
  1256 		if (error==KErrNone)
  1257 	    	{
  1258 	    	CleanupStack::PushL(snap);
  1259 	  		INFO_PRINTF1(_L("CCameraSnapshot object was created using NewL")); 
  1260 	    	CleanupStack::PopAndDestroy(snap);
  1261 	    	}
  1262 	    else
  1263     		{
  1264     		INFO_PRINTF1(_L("CCameraSnapshot object was not created using NewL")); 
  1265     		result = EFail;
  1266     		User::Leave(KErrNoMemory);
  1267     		}	
  1268 		CleanupStack::PopAndDestroy(camera);
  1269 		}
  1270 	else 
  1271 		{
  1272 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
  1273 		result = EFail;	
  1274 		User::Leave(KErrNoMemory);	
  1275 		}
  1276 	__MM_HEAP_MARKEND;
  1277    
  1278 	return result;
  1279 	}
  1280 
  1281 TVerdict RECamSnapTest::DoTestStep_41L()
  1282 	{
  1283 	TVerdict result = EPass;
  1284 	CCamera* camera = NULL;
  1285 	
  1286 	TInt error = KErrNone;
  1287 	CCamera::CCameraSnapshot* snap = NULL;
  1288 		
  1289 	// create a snapshot object using NewL
  1290 	__MM_HEAP_MARK;
  1291 	MCameraObserver2* observer2 = NULL; 
  1292 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
  1293 	
  1294 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
  1295 
  1296 	if (error==KErrNone)
  1297 		{
  1298 		CleanupStack::PushL(camera);
  1299 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
  1300 		TRAP(error, snap  = CCamera::CCameraSnapshot::NewL(*camera));	
  1301 		
  1302 		if (error==KErrNone)
  1303 	    	{
  1304 	  		INFO_PRINTF1(_L("CCameraSnapshot object was created using NewL")); 
  1305 	    	}
  1306 	    else
  1307     		{
  1308     		INFO_PRINTF1(_L("CCameraSnapshot object was not created using NewL")); 
  1309     		return EFail;
  1310     		}	
  1311 		}
  1312 	else 
  1313 		{
  1314 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
  1315 		result = EFail;		
  1316 		}
  1317 	
  1318 	if (snap!= NULL)
  1319     	{
  1320     	CleanupStack::PushL(snap);
  1321     	
  1322     	// get the supported formats  
  1323     	TUint32 suppformats = snap->SupportedFormats();
  1324 		
  1325 		CCamera::TFormat format = CCamera::EFormatMonochrome;
  1326 		TSize orgSize(90,50);
  1327         TRgb orgColor(100,100,100);
  1328         TBool AspectRatio = ETrue;
  1329         TPoint orgPos(2,2);
  1330         
  1331     	TRAP(error, snap->PrepareSnapshotL(format, orgPos, orgSize, orgColor,AspectRatio));
  1332     	
  1333     	if(error==KErrNone)
  1334     		{
  1335     		INFO_PRINTF1(_L("Snapshot Creation Successful"));
  1336     		}
  1337     	else
  1338     		{
  1339     		INFO_PRINTF2(_L("Snapshot Creation Failed - %d"), error);
  1340     		result = EFail;
  1341     		}
  1342     		
  1343     	TBool isActive = EFalse;
  1344     	TRAP(error, isActive = snap->IsSnapshotActive());
  1345     	if(error==KErrNone)
  1346     		{
  1347     		INFO_PRINTF1(_L("Is Snapshot Active Successful"));
  1348     		}
  1349     	else
  1350     		{
  1351     		INFO_PRINTF2(_L("Is Snapshot Active Failed - %d"), error);
  1352     		result = EFail;
  1353     		}
  1354     		
  1355     	if(isActive)
  1356     		{
  1357     		INFO_PRINTF1(_L("Snapshot must not be active"));
  1358     		result = EFail;
  1359     		}
  1360     		
  1361     	// Start Snapshot    	
  1362        	TRAP(error, snap->StartSnapshot());
  1363 		if(error==KErrNone)
  1364 			{
  1365 			INFO_PRINTF1(_L("Start Snapshot Successful"));
  1366 			}
  1367     	else
  1368     		{
  1369     		INFO_PRINTF2(_L("Start Snapshot Failed - %d"), error);
  1370     		return EFail;
  1371     		}	
  1372     	
  1373     	TRAP(error, isActive = snap->IsSnapshotActive());
  1374     	if(error==KErrNone)
  1375     		{
  1376     		INFO_PRINTF1(_L("Is Snapshot Active Successful"));
  1377     		}
  1378     	else
  1379     		{
  1380     		INFO_PRINTF2(_L("Is Snapshot Active Failed - %d"), error);
  1381     		result = EFail;
  1382     		}	
  1383     	
  1384     	if(!isActive)
  1385     		{
  1386     		INFO_PRINTF1(_L("Snapshot must not be active"));
  1387     		result = EFail;
  1388     		}
  1389     	
  1390     	TRAP(error, snap->StopSnapshot());
  1391     	if(error==KErrNone)
  1392 			{
  1393 			INFO_PRINTF1(_L("Stop Snapshot Successful"));
  1394 			}
  1395     	else
  1396     		{
  1397     		INFO_PRINTF2(_L("Stop Snapshot Failed - %d"), error);
  1398     		return EFail;
  1399     		}	
  1400     		
  1401     	// Test new snapshot methods. They shall leave with KErrNotSupported
  1402     	INFO_PRINTF1(_L("Check New Snapshot methods leave with KErrNotSupported"));
  1403     	CCamera::CCameraSnapshot::TSnapshotParameters snapshotParameters;
  1404     	TRAP(error, snap->PrepareSnapshotL(snapshotParameters));
  1405     	if(error != KErrNotSupported)
  1406     		{
  1407     		INFO_PRINTF1(_L("PrepareSnapshotL unexpected result!"));
  1408     		return EFail;
  1409     		}
  1410 	
  1411 		TRAP(error, snap->GetSnapshotParametersL(snapshotParameters));
  1412     	if(error != KErrNotSupported)
  1413     		{
  1414     		INFO_PRINTF1(_L("GetSnapshotParametersL unexpected result!"));
  1415     		return EFail;
  1416     		}
  1417 	
  1418 		TRAP(error, snap->SetSnapshotParametersL(snapshotParameters));
  1419     	if(error != KErrNotSupported)
  1420     		{
  1421     		INFO_PRINTF1(_L("SetSnapshotParametersL unexpected result!"));
  1422     		return EFail;
  1423     		}
  1424     	
  1425     	CCamera::CCameraSnapshot::TSnapshotState snapshotState = CCamera::CCameraSnapshot::ESnapshotInactive;	
  1426 		TRAP(error, snap->GetSnapshotStatusL(snapshotState));
  1427     	if(error != KErrNotSupported)
  1428     		{
  1429     		INFO_PRINTF1(_L("GetSnapshotStatusL unexpected result!"));
  1430     		return EFail;
  1431     		}
  1432     		
  1433     	CCamera::CCameraSnapshot::TSnapshotVideoFrames snapshotVideoFrames = CCamera::CCameraSnapshot::ESnapshotVideoFirstFrame;	
  1434 		TRAP(error, snap->SelectSnapshotVideoFramesL(snapshotVideoFrames));
  1435     	if(error != KErrNotSupported)
  1436     		{
  1437     		INFO_PRINTF1(_L("SelectSnapshotVideoFramesL unexpected result!"));
  1438     		return EFail;
  1439     		}
  1440 		
  1441 		TRAP(error, snap->EnableSnapshotL());
  1442     	if(error != KErrNotSupported)
  1443     		{
  1444     		INFO_PRINTF1(_L("EnableSnapshotL unexpected result!"));
  1445     		return EFail;
  1446     		}
  1447     		
  1448     	TRAP(error, snap->DisableSnapshotL());
  1449     	if(error != KErrNotSupported)
  1450     		{
  1451     		INFO_PRINTF1(_L("DisableSnapshotL unexpected result!"));
  1452     		return EFail;
  1453     		}
  1454 	
  1455 		    			
  1456     	CleanupStack::PopAndDestroy(snap);
  1457     	}
  1458 	CleanupStack::PopAndDestroy(camera);
  1459 	
  1460 	__MM_HEAP_MARKEND;
  1461    
  1462 	return result;
  1463 	}
  1464 
  1465 TVerdict RECamSnapTest::DoTestStep_42L()
  1466 	{
  1467 	TVerdict result = EPass;
  1468 	CCamera* camera = NULL;
  1469 	
  1470 	TInt error = KErrNone;
  1471 	CCamera::CCameraSnapshot* snap = NULL;
  1472 		
  1473 	// create a Hist object using NewL
  1474 	__MM_HEAP_MARK;
  1475 	MCameraObserver2* observer2 = NULL; 
  1476 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
  1477 	
  1478 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
  1479 
  1480 	if (error==KErrNone)
  1481 		{
  1482 		CleanupStack::PushL(camera);
  1483 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
  1484 		TRAP(error, snap  = CCamera::CCameraSnapshot::NewL(*camera));	
  1485 		
  1486 		if (error==KErrNone)
  1487 	    	{
  1488 	  		INFO_PRINTF1(_L("CCameraSnapshot object was created using NewL")); 
  1489 	    	}
  1490 	    else
  1491     		{
  1492     		INFO_PRINTF1(_L("CCameraSnapshot object was not created using NewL")); 
  1493     		return EFail;
  1494     		}	
  1495 		}
  1496 	else 
  1497 		{
  1498 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
  1499 		result = EFail;		
  1500 		}
  1501 	
  1502 	if (snap!= NULL)
  1503     	{
  1504     	CleanupStack::PushL(snap);
  1505     	
  1506     	// get the supported formats  
  1507     	TUint32 suppformats = snap->SupportedFormats();
  1508 		
  1509 		CCamera::TFormat format = CCamera::EFormatMonochrome;
  1510 		TSize orgSize(90,50);
  1511         TRgb orgColor(100,100,100);
  1512         TBool AspectRatio = ETrue;
  1513         TPoint orgPos(2,2);
  1514         
  1515         // Test the other overload of PrepareSnapshotL
  1516     	TRAP(error, snap->PrepareSnapshotL(format, orgSize, AspectRatio));
  1517     	
  1518     	if(error==KErrNone)
  1519     		{
  1520     		INFO_PRINTF1(_L("Snapshot Creation Successful"));
  1521     		}
  1522     	else
  1523     		{
  1524     		INFO_PRINTF2(_L("Snapshot Creation Failed - %d"), error);
  1525     		result = EFail;
  1526     		}
  1527     	
  1528     	// Set Background color Snapshot    		
  1529     	TRAP(error, snap->SetBgColorL(orgColor));
  1530     	if(error==KErrNone)
  1531     		{
  1532     		INFO_PRINTF1(_L("Set Background Color Successful"));
  1533     		}
  1534     	else
  1535     		{
  1536     		INFO_PRINTF2(_L("Set Background Color Failed - %d"), error);
  1537     		result = EFail;
  1538     		}
  1539     	
  1540     	// Set Position
  1541     	TRAP(error, snap->SetPositionL(orgPos));
  1542        	if(error==KErrNone)
  1543     		{
  1544     		INFO_PRINTF1(_L("Set Snapshot Position Successful"));
  1545     		}
  1546     	else
  1547     		{
  1548     		INFO_PRINTF2(_L("Set Snapshot Position Failed - %d"), error);
  1549     		result = EFail;
  1550     		}
  1551     			
  1552     	// Start Snapshot    	
  1553        	TRAP(error, snap->StartSnapshot());
  1554 		if(error==KErrNone)
  1555 			{
  1556 			INFO_PRINTF1(_L("Start Snapshot Successful"));
  1557 			}
  1558     	else
  1559     		{
  1560     		INFO_PRINTF2(_L("Start Snapshot Failed - %d"), error);
  1561     		return EFail;
  1562     		}	
  1563     	
  1564     	// Is shapshot active	
  1565     	TBool isActive = EFalse;
  1566     	TRAP(error, isActive = snap->IsSnapshotActive());
  1567     	if(error==KErrNone)
  1568     		{
  1569     		INFO_PRINTF1(_L("Is Snapshot Active Successful"));
  1570     		}
  1571     	else
  1572     		{
  1573     		INFO_PRINTF2(_L("Is Snapshot Active Failed - %d"), error);
  1574     		result = EFail;
  1575     		}	
  1576     	
  1577     	if(!isActive)
  1578     		{
  1579     		INFO_PRINTF1(_L("Snapshot must not be active"));
  1580     		result = EFail;
  1581     		}
  1582     	
  1583     	// Stop Snapshot
  1584     	TRAP(error, snap->StopSnapshot());
  1585     	if(error==KErrNone)
  1586 			{
  1587 			INFO_PRINTF1(_L("Stop Snapshot Successful"));
  1588 			}
  1589     	else
  1590     		{
  1591     		INFO_PRINTF2(_L("Stop Snapshot Failed - %d"), error);
  1592     		return EFail;
  1593     		}	
  1594     	    			
  1595     	CleanupStack::PopAndDestroy(snap);
  1596     	}
  1597 	CleanupStack::PopAndDestroy(camera);
  1598 	
  1599 	__MM_HEAP_MARKEND;
  1600    
  1601 	return result;
  1602 	}
  1603 //
  1604 // RECamSnapNotificationTest
  1605 //
  1606 RECamSnapNotificationTest* RECamSnapNotificationTest::NewL(TBool aAllocTest)
  1607 	{
  1608 	RECamSnapNotificationTest* self = new (ELeave) RECamSnapNotificationTest(aAllocTest);
  1609 	CleanupStack::PushL(self);
  1610 	self->ConstructL();
  1611 	CleanupStack::Pop(self);
  1612 	return self;	
  1613 	}
  1614 	
  1615 void RECamSnapNotificationTest::ConstructL()
  1616 	{
  1617 	iOriginalSet.Reset();
  1618 	iResultSet.Reset();
  1619 
  1620 	}
  1621 RECamSnapNotificationTest::RECamSnapNotificationTest(TBool /*aAllocTest*/)
  1622 	{
  1623 	iTestStepName = _L("MM-ECM-ADV-U-043-HP");
  1624 	}
  1625 
  1626 TVerdict RECamSnapNotificationTest::DoTestStepL()
  1627 	{	
  1628 	TVerdict result = EPass;
  1629 	CCamera* camera = NULL;
  1630 	
  1631 	TInt error = KErrNone;
  1632 	CCamera::CCameraSnapshot* snap = NULL;
  1633 		
  1634 	__MM_HEAP_MARK;
  1635 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
  1636 	
  1637 	TRAP(error, camera = CCamera::New2L(*this,0,0));
  1638 
  1639 	if (error==KErrNone)
  1640 		{
  1641 		CleanupStack::PushL(camera);
  1642 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
  1643 		
  1644 		TRAP(error, snap  = CCamera::CCameraSnapshot::NewL(*camera));	
  1645 		if (error==KErrNone)
  1646 	    	{
  1647 	  		INFO_PRINTF1(_L("CCameraSnapshot object was created using NewL")); 
  1648 	    	}
  1649 	    else
  1650     		{
  1651     		INFO_PRINTF1(_L("CCameraSnapshot object was not created using NewL")); 
  1652     		result = EFail;
  1653     		}	
  1654     		
  1655 	    if (snap!= NULL)
  1656 			{
  1657 			CleanupStack::PushL(snap);
  1658 
  1659 			// get the supported set of values  
  1660 			TUint32 suppformats = snap->SupportedFormats();
  1661 
  1662 			CCamera::TFormat format = CCamera::EFormatMonochrome;
  1663 			TSize orgSize(90,50);
  1664 			TRgb orgColor(100,100,100);
  1665 			TPoint orgPos(2,2);
  1666 			TBool AspectRatio = ETrue;
  1667 
  1668 			TRAP(error, snap->PrepareSnapshotL(format, orgPos, orgSize, orgColor,AspectRatio));
  1669 
  1670 			if(error==KErrNone)
  1671 				{
  1672 				INFO_PRINTF1(_L("Snapshot Creation Successful"));
  1673 				}
  1674 			else
  1675 				{
  1676 				INFO_PRINTF2(_L("Snapshot Creation Failed - %d"), error);
  1677 				result = EFail;
  1678 				}
  1679 			
  1680 			// set new value
  1681 	    	iInputEventUid.iUid = KUidECamEventSnapshotUidValue;
  1682 	    		
  1683 			// Start Snapshot    	
  1684 			TRAP(error, snap->StartSnapshot());
  1685 			if(error==KErrNone)
  1686 				{
  1687 				INFO_PRINTF1(_L("Start Snapshot Successful"));
  1688 				}
  1689 			else
  1690 				{
  1691 				INFO_PRINTF2(_L("Start Snapshot Failed - %d"), error);
  1692 				return EFail;
  1693 				}	
  1694 			
  1695 			CheckNotification(iInputEventUid, result);
  1696 			
  1697 			RArray<TInt> FrameIndexOrder;
  1698 			
  1699 			// Ignore the data
  1700 			TRAP(error, snap->SnapshotDataL(FrameIndexOrder));
  1701 			if(error==KErrNone)
  1702 				{
  1703 				INFO_PRINTF1(_L("Snapshot DataL Successful"));
  1704 				}
  1705 			else
  1706 				{
  1707 				INFO_PRINTF2(_L("Snapshot DataL Failed - %d"), error);
  1708 				return EFail;
  1709 				}	
  1710 			FrameIndexOrder.Close();
  1711 			
  1712 			TBool isActive = EFalse;
  1713 			
  1714 			TRAP(error, isActive = snap->IsSnapshotActive());
  1715 			if(error==KErrNone)
  1716 				{
  1717 				INFO_PRINTF1(_L("Is Snapshot Active Successful"));
  1718 				}
  1719 			else
  1720 				{
  1721 				INFO_PRINTF2(_L("Is Snapshot Active Failed - %d"), error);
  1722 				return EFail;
  1723 				}
  1724 					
  1725 			if(!isActive)
  1726 				{
  1727 				INFO_PRINTF1(_L("Snapshot must not be active"));
  1728 				result = EFail;
  1729 				}
  1730 
  1731 			TRAP(error, snap->StopSnapshot());
  1732 			if(error==KErrNone)
  1733 				{
  1734 				INFO_PRINTF1(_L("Stop Snapshot Successful"));
  1735 				}
  1736 			else
  1737 				{
  1738 				INFO_PRINTF2(_L("Stop Snapshot Failed - %d"), error);
  1739 				return EFail;
  1740 				}	
  1741 			    			
  1742 			CleanupStack::PopAndDestroy(snap);
  1743 			}
  1744 	    else
  1745     		{
  1746     		result = EFail;
  1747     		}
  1748 		CleanupStack::PopAndDestroy(camera);
  1749 		}
  1750 	else 
  1751 		{
  1752 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
  1753 		result = EFail;		
  1754 		}
  1755 	
  1756 	__MM_HEAP_MARKEND;
  1757 
  1758 	return result;
  1759 	}
  1760