os/mm/imagingandcamerafws/cameraunittest/src/TSU_ECM_ADV/ECamImageProcessingTest.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 
     2 // ECamImageProcessingTest.cpp
     3 
     4 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     5 // All rights reserved.
     6 // This component and the accompanying materials are made available
     7 // under the terms of "Eclipse Public License v1.0"
     8 // which accompanies this distribution, and is available
     9 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    10 //
    11 // Initial Contributors:
    12 // Nokia Corporation - initial contribution.
    13 //
    14 // Contributors:
    15 //
    16 // Description:
    17 //
    18 
    19 #include "ECamImageProcessingTest.h"
    20 #include <ecamadvsettings.h>
    21 #include <ecam/ecamplugin.h>
    22 #include <ecamuids.hrh>
    23 #include <ecom/ecomresolverparams.h>
    24 #include "ECamUnitTestPluginUids.hrh"
    25 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    26 #include <ecamimageprocessingconst.h>
    27 #endif
    28 
    29 
    30 
    31 //const TRect KRect1(100, 50, 600, 200);
    32 const TInt  KValue = 100; 
    33 const TInt  KBaselinedEffects = 0x000001FF;
    34 //
    35 // RECamImageProcessingTest
    36 //
    37 
    38 RECamImageProcessingTest* RECamImageProcessingTest::NewL(TBool aAllocTest)
    39 	{
    40 	RECamImageProcessingTest* self = new (ELeave) RECamImageProcessingTest(aAllocTest);
    41 	return self;	
    42 	}
    43 	
    44 RECamImageProcessingTest::RECamImageProcessingTest(TBool /*aAllocTest*/)
    45 	{
    46 	iTestStepName = _L("MM-ECM-ADV-U-007-HP");
    47 	}
    48 
    49 TVerdict RECamImageProcessingTest::DoTestStepL()	
    50 	{
    51 	TVerdict verdict = EFail;
    52 	INFO_PRINTF1(_L("Alloc test"));
    53 	TInt i;
    54 	TInt err;
    55 	for (i = 1 ; ; i++)
    56 		{
    57 		__MM_HEAP_MARK;
    58 		
    59 		if (i % 5 == 0)
    60 			{
    61 			INFO_PRINTF2(_L("Fail count = %d"), i);
    62 			}
    63 
    64 		__UHEAP_SETFAIL(RHeap::EFailNext, i);
    65 
    66 		TRAP(err, verdict = DoImageProcessingTestStepL());
    67 
    68 		TAny* testAlloc = User::Alloc(1);
    69 		TBool heapTestingComplete = (testAlloc == NULL) && (err==KErrNone);
    70 		User::Free(testAlloc);
    71 
    72 		__UHEAP_RESET;
    73 		__MM_HEAP_MARKEND;
    74 
    75 		if ((err != KErrNoMemory ) || heapTestingComplete)
    76 			{
    77 			INFO_PRINTF4(_L("err = %d, verdict = %d, Fail count = %d"), err, verdict, i);
    78 			INFO_PRINTF1(_L("Alloc testing completed successfully"));
    79 			verdict = EPass;
    80 			break;
    81 			}
    82 		}
    83 	return verdict;
    84 	}
    85 	
    86 TVerdict RECamImageProcessingTest::DoImageProcessingTestStepL()
    87 	{	
    88 	TVerdict result = EPass;
    89 	CCamera* camera = NULL;
    90 	
    91 	TInt error = KErrNone;
    92 	CCamera::CCameraImageProcessing* imageprocess = NULL;
    93 	
    94 	// using observer 2 
    95 	MCameraObserver2* observer2 = NULL;
    96 	
    97 	__MM_HEAP_MARK;
    98 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
    99 	
   100 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
   101 	
   102 	if (error==KErrNone)
   103 		{
   104 		CleanupStack::PushL(camera);
   105 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   106 		imageprocess = 	static_cast<CCamera::CCameraImageProcessing*> (camera->CustomInterface(KECamImageProcessingUid));
   107 	    if (imageprocess!= NULL)
   108 	    	{
   109 	    	CleanupStack::PushL(imageprocess);
   110 	    	INFO_PRINTF1(_L("CCameraImageProcessing object was created")); 
   111 	    	CleanupStack::PopAndDestroy(imageprocess);
   112 	    	}
   113 	    else
   114     		{
   115     		result = EFail;
   116     		User::Leave(KErrNoMemory);
   117     		}	
   118 		CleanupStack::PopAndDestroy(camera);
   119 		}
   120 	else 
   121 		{
   122 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
   123 		result = EFail;		
   124 		User::Leave(KErrNoMemory);
   125 		}
   126 	__MM_HEAP_MARKEND;
   127 
   128 	// create a imageprocessing object using New2L
   129 	__MM_HEAP_MARK;
   130 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
   131 	
   132 	TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
   133 
   134 	if (error==KErrNone)
   135 		{
   136 		CleanupStack::PushL(camera);
   137 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   138 		TRAP(error, imageprocess  = CCamera::CCameraImageProcessing::NewL(*camera));
   139 		
   140 		if (error==KErrNone)	
   141 	    	{
   142 	    	CleanupStack::PushL(imageprocess);
   143 	  		INFO_PRINTF1(_L("CCameraImageProcessing object was created using NewL")); 
   144 	    	CleanupStack::PopAndDestroy(imageprocess);
   145 	    	}
   146 	    else
   147     		{
   148     		INFO_PRINTF1(_L("CCameraImageProcessing object was not created using NewL")); 
   149     		result = EFail;
   150     		User::Leave(KErrNoMemory);
   151     		}	
   152 		CleanupStack::PopAndDestroy(camera);
   153 		}
   154 	else 
   155 		{
   156 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
   157 		result = EFail;		
   158 		User::Leave(KErrNoMemory);
   159 		}
   160 	__MM_HEAP_MARKEND;
   161    
   162 	return result;
   163 	}
   164 	
   165 //
   166 // RECamImageProcDefaultsTest //
   167 //
   168 
   169 RECamImageProcDefaultsTest* RECamImageProcDefaultsTest::NewL(TBool aAllocTest)
   170 	{
   171 	RECamImageProcDefaultsTest* self = new (ELeave) RECamImageProcDefaultsTest(aAllocTest);
   172 	return self;	
   173 	}
   174 	
   175 RECamImageProcDefaultsTest::RECamImageProcDefaultsTest(TBool)
   176 	{
   177 	iTestStepName = _L("MM-ECM-ADV-U-012-HP");
   178 	}
   179 	
   180 TBool RECamImageProcDefaultsTest::CompareUidArrays(RArray<TUid>& firstArray, RArray<TUid>& secondArray)
   181 	{
   182 	TBool result = ETrue;
   183 	
   184 	if (firstArray.Count() != secondArray.Count())
   185 		{
   186 		result = EFalse;
   187 		}
   188 	else
   189 		{
   190 		for (TInt expected = 0; expected < firstArray.Count(); expected++)
   191 		    {
   192 			result = EFalse;
   193 			for (TInt actual = 0; actual < secondArray.Count(); actual++)
   194 				{
   195 				if (secondArray[actual] == firstArray[expected])
   196 					{
   197 					result = ETrue;
   198 					break;
   199 					}				
   200 				}
   201 			}
   202 		}
   203 	return result;
   204 	}	
   205 	
   206 TVerdict RECamImageProcDefaultsTest::DoTestStepL()
   207 	{	
   208 	TVerdict result = EPass;
   209 	CCamera* camera = NULL;
   210 	
   211 	TInt error = KErrNone;
   212 	CCamera::CCameraImageProcessing* imageprocess = NULL;
   213 	
   214 	__MM_HEAP_MARK;
   215 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
   216 	
   217 	TRAP(error, camera = CCamera::New2L(*this,0,0));
   218 	
   219 	if (error==KErrNone)
   220 		{
   221 		CleanupStack::PushL(camera);
   222 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   223 		imageprocess = 	static_cast<CCamera::CCameraImageProcessing*> (camera->CustomInterface(KECamImageProcessingUid));
   224 	    if (imageprocess!= NULL)
   225 	    	{
   226 	    	CleanupStack::PushL(imageprocess);
   227 
   228 	    	// Supported Transformations
   229 			RArray<TUid> expectedTransfUids;	    	
   230 			CleanupClosePushL(expectedTransfUids);
   231 	    	expectedTransfUids.Reset();	    			
   232 	    	// set the expected UIDS
   233 			expectedTransfUids.AppendL(KUidECamEventImageProcessingAdjustBrightness);
   234 			expectedTransfUids.AppendL(KUidECamEventImageProcessingAdjustContrast);
   235 			expectedTransfUids.AppendL(KUidECamEventImageProcessingEffect);	    	
   236 	    	RArray<TUid> suppTransfUids; 
   237 	    	CleanupClosePushL(suppTransfUids);
   238 	    	imageprocess->GetSupportedTransformationsL(suppTransfUids);
   239 	    	if (CompareUidArrays(expectedTransfUids, suppTransfUids) == EFalse)
   240 				{
   241 				INFO_PRINTF1(_L("GetSupportedTransformationsL failed"));
   242 				result = EFail;
   243 				}
   244 	    	expectedTransfUids.Reset();
   245 	    	suppTransfUids.Reset();	    		    	
   246 			CleanupStack::PopAndDestroy(2, &expectedTransfUids); //suppTransfUids
   247 
   248 		    // Active Transformations
   249 	    	RArray<TUid> expectedActTransfUids; 
   250 	    	CleanupClosePushL(expectedActTransfUids);
   251 	    	expectedActTransfUids.Reset();	    
   252 	    	// set the expected UIDS
   253 			expectedActTransfUids.AppendL(KUidECamEventImageProcessingAdjustBrightness);
   254 			expectedActTransfUids.AppendL(KUidECamEventImageProcessingAdjustContrast);
   255 			expectedActTransfUids.AppendL(KUidECamEventImageProcessingEffect);	    	
   256 	    	RArray<TUid> actTransfUids; 
   257 	    	CleanupClosePushL(actTransfUids);
   258 	    	actTransfUids.Reset();	 	    	
   259 	    	imageprocess->GetActiveTransformationsL(actTransfUids);
   260  	    	if (CompareUidArrays(expectedActTransfUids, actTransfUids) == EFalse)
   261 				{
   262 				INFO_PRINTF1(_L("GetActiveTransformationsL failed"));
   263 				result = EFail;
   264 				}
   265 			CleanupStack::PopAndDestroy(2, &expectedActTransfUids); //actTransfUids
   266 		    
   267 		    // Set & Get Active Transformation Sequence
   268 	    	RArray<TUid> expectedTransfSequence; 
   269 	    	CleanupClosePushL(expectedTransfSequence);
   270 	    	expectedTransfSequence.Reset();	    	
   271 			expectedTransfSequence.Append(KUidECamEventImageProcessingAdjustBrightness);	   
   272 
   273 			imageprocess->SetActiveTransformSequenceL(expectedTransfSequence);
   274 			
   275 	    	RArray<TUid> actTransfSequence; 
   276 	    	CleanupClosePushL(actTransfSequence);
   277 	    	actTransfSequence.Reset();    		    		    	
   278 			imageprocess->GetActiveTransformSequenceL(actTransfSequence);
   279  	    	if (CompareUidArrays(expectedTransfSequence, actTransfSequence) == EFalse)
   280 				{
   281 				INFO_PRINTF1(_L("GetActiveTransformSequenceL failed"));
   282 				result = EFail;
   283 				}
   284 			CleanupStack::PopAndDestroy(2, &expectedTransfSequence); //actTransfSequence
   285 
   286 		    // Get & Set Transformation
   287 	    	TUid iInputEventUid = KUidECamEventImageProcessingAdjustBrightness;
   288 	        TInt aSetValue = 4;
   289 	    	imageprocess->SetTransformationValue(iInputEventUid, aSetValue);
   290 
   291 	    	CheckNotification(iInputEventUid, result);
   292     			
   293 		    // Check that value has actually changed.
   294 	    	TInt aGetValue = imageprocess->TransformationValue(iInputEventUid);
   295  	    	if (aSetValue != aGetValue)
   296 				{
   297 				INFO_PRINTF3(_L("Got wrong TransformationValue set %d, got %d"), aSetValue, aGetValue);
   298 				result = EFail;
   299 				}
   300 			else
   301 				{
   302 				INFO_PRINTF2(_L("Transformation value set to %d"), aSetValue);					
   303 				}	    
   304 				
   305 			TInt aGetValue1 = 0;
   306 			TInt err = imageprocess->GetTransformationValue(iInputEventUid, aGetValue1);
   307 			
   308 			if(err)
   309 				{
   310 				INFO_PRINTF2(_L("New method for Getting Transformation value returned error %d"), err);
   311 				result = EFail;
   312 				}
   313 				
   314 			if(aGetValue1 != aGetValue)
   315 				{
   316 				INFO_PRINTF1(_L("New and old method for Getting Transformation value  retrieves wrong/dissimilar values"));
   317 				result = EFail;
   318 				}
   319 				
   320 			//Set Effect Transformation with color swap
   321 			iInputEventUid = KUidECamEventImageProcessingEffect;
   322 			RArray<TInt> supportedEffects;
   323 					
   324 	    	TValueInfo info = ENotActive;
   325 	    	imageprocess->GetTransformationSupportedValuesL(iInputEventUid, supportedEffects, info);
   326 	    	
   327 	    	TInt effects = supportedEffects[0];
   328 			supportedEffects.Close();
   329 	    	
   330 	    	if(info != EBitField)
   331 	    		{
   332 	    		INFO_PRINTF1(_L("Incorrect TValueInfo provided"));
   333 				result = EFail;
   334 	    		}
   335 	    		
   336 	    	if(effects & CCamera::CCameraImageProcessing::EEffectColorSwap)
   337 	        	{	
   338 	        	imageprocess->SetTransformationValue(iInputEventUid, CCamera::CCameraImageProcessing::EEffectColorSwap);	
   339 	        	
   340 	        	CheckNotification(iInputEventUid, result);
   341 	        	}
   342 	       
   343 	        // Check that value has actually changed.
   344 	    	aGetValue = imageprocess->TransformationValue(iInputEventUid);
   345  	    	if (aGetValue != static_cast<TInt>(CCamera::CCameraImageProcessing::EEffectColorSwap))
   346 				{
   347 				INFO_PRINTF1(_L("Got wrong TransformationValue set"));
   348 				result = EFail;
   349 				}
   350 			else
   351 				{
   352 				INFO_PRINTF1(_L("Transformation value set to EEffectColorSwap"));					
   353 				}
   354 			
   355 			TInt concurrentColorSwappingSupported=0;	
   356 			imageprocess->GetConcurrentColorSwappingsSupportedL(concurrentColorSwappingSupported);
   357 	        
   358 	        if(concurrentColorSwappingSupported > 0)
   359 	        	{
   360 	        	TestColorSwapL(imageprocess, result);
   361 	        	}
   362 	        	
   363 			//Set Effect Transformation with color accent
   364 			iInputEventUid = iInputEventUid = KUidECamEventImageProcessingEffect;
   365 			if(effects & CCamera::CCameraImageProcessing::EEffectColorAccent)
   366 	        	{	
   367 	        	imageprocess->SetTransformationValue(iInputEventUid, CCamera::CCameraImageProcessing::EEffectColorAccent);	
   368 	        
   369 	        	CheckNotification(iInputEventUid, result);
   370 	        	}
   371 	        	
   372 	        // Check that value has actually changed.
   373 	    	aGetValue = imageprocess->TransformationValue(iInputEventUid);
   374  	    	if (aGetValue != static_cast<TInt>(CCamera::CCameraImageProcessing::EEffectColorAccent))
   375 				{
   376 				INFO_PRINTF1(_L("Got wrong TransformationValue set"));
   377 				result = EFail;
   378 				}
   379 			else
   380 				{
   381 				INFO_PRINTF1(_L("Transformation value set to EEffectColorAccent"));					
   382 				}
   383 			
   384 			TInt concurrentColorAccentSupported=0;	
   385 			imageprocess->GetConcurrentColorAccentSupportedL(concurrentColorAccentSupported);
   386 	        
   387 	        if(concurrentColorAccentSupported > 0)
   388 	        	{
   389 	        	TestColorAccentL(imageprocess, result);
   390 	        	}
   391 	    	
   392 		    // Get & Set Source Rect
   393 			TRect setRect(100, 50, 600, 200);
   394 			TRect getRect;
   395 	    	imageprocess->SetSourceRect(setRect);
   396 			imageprocess->GetSourceRect(getRect);
   397 			if (setRect != getRect)
   398 				{
   399 				INFO_PRINTF1(_L("Did not get the same rect"));
   400 				result = EFail;
   401 				}
   402 			
   403 			CCamera::CCameraImageProcessing::TOrientationReference orientationReference = 
   404 						CCamera::CCameraImageProcessing::EOrientationReferenceCameraSensorOrientation;	
   405 			TUint supportedRelativeRotation=0;
   406 			TUint supportedRelativeMirroring=0;
   407 			TUint supportedRelativeFlipping=0;
   408 			
   409 			INFO_PRINTF1(_L("GetSupportedRelativeOrientationOptionsL method invocation"));
   410 
   411 			TRAP(err,imageprocess->GetSupportedRelativeOrientationOptionsL(orientationReference, 
   412 		supportedRelativeRotation, supportedRelativeMirroring, supportedRelativeFlipping));	
   413 			
   414 			if(err!= KErrNotSupported)
   415 				{
   416 				INFO_PRINTF1(_L("GetSupportedRelativeOrientationOptionsL did not leave with KErrNotSupported"));
   417 				result = EFail;
   418 				}
   419 			
   420 			CCamera::CCameraImageProcessing::TRelativeRotation relativeRotation = 
   421 					CCamera::CCameraImageProcessing::ERelativeRotation0Degrees;
   422 			
   423 			CCamera::CCameraImageProcessing::TRelativeMirror relativeMirror = 
   424 					CCamera::CCameraImageProcessing::ERelativeMirrorNone;
   425 					
   426 			CCamera::CCameraImageProcessing::TRelativeFlipping relativeFlipping = 
   427 					CCamera::CCameraImageProcessing::ERelativeFlippingNone;
   428 			
   429 			INFO_PRINTF1(_L("GetCurrentRelativeOrientationOptionsL method invocation"));
   430 			TRAP(err,imageprocess->GetCurrentRelativeOrientationOptionsL(orientationReference, 
   431 								relativeRotation, relativeMirror, relativeFlipping));	
   432 			
   433 			if(err!= KErrNotSupported)
   434 				{
   435 				INFO_PRINTF1(_L("GetCurrentRelativeOrientationOptionsL did not leave with KErrNotSupported"));
   436 				result = EFail;
   437 				}
   438 			
   439 			INFO_PRINTF1(_L("SetRelativeOrientationOptionsL method invocation"));
   440 			iInputEventUid = KUidECamEventImageProcessingTransformRelativeOrientation;
   441 			imageprocess->SetRelativeOrientationOptionsL(orientationReference, 
   442 						relativeRotation, relativeMirror, relativeFlipping);
   443 	    	
   444 	    	CheckNotificationNeg(iInputEventUid, result);
   445 	    	
   446 	    	CleanupStack::PopAndDestroy(imageprocess);
   447 	    	}
   448 	    else
   449     		{
   450     		result = EFail;
   451     		}	
   452 		CleanupStack::PopAndDestroy(camera);
   453 		}
   454 	else 
   455 		{
   456 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
   457 		result = EFail;		
   458 		}
   459 	__MM_HEAP_MARKEND;
   460 
   461 	return result;
   462 	}
   463 	
   464 void RECamImageProcDefaultsTest::TestColorSwapL(CCamera::CCameraImageProcessing* aImageProcess, TVerdict& aResult)
   465 	{
   466 	CCamera::CCameraImageProcessing::TColorOperationCapabilities colorSwapCapabilities;
   467 	aImageProcess->GetColorSwapCapabilitiesL(0, colorSwapCapabilities);
   468 	
   469 	if(!colorSwapCapabilities.iIsCapabilityUniform)
   470 		{
   471 		INFO_PRINTF1(_L("Non Uniform entries for color swap"));
   472 		}
   473 		        	
   474 	//fill the parameters for color swap entry 
   475 	CCamera::CCameraImageProcessing::TColorOperationEntry colorSwapParameters;
   476 	
   477 	colorSwapParameters.iSourceColor.SetGreen(KValue);
   478 	colorSwapParameters.iTargetColor.SetBlue(KValue);
   479 
   480 	colorSwapParameters.iSourceColorRepresentation = CCamera::CCameraImageProcessing::ERepresentationSingle;
   481 	colorSwapParameters.iTargetColorRepresentation = CCamera::CCameraImageProcessing::ERepresentationSingle;
   482 	
   483 	colorSwapParameters.iColorOperationSourceRgbGroupingMode = CCamera::CCameraImageProcessing::ERgbGroupingFixed;
   484 	colorSwapParameters.iColorOperationTargetRgbGroupingMode = CCamera::CCameraImageProcessing::ERgbGroupingFixed;
   485 	
   486 	//set the entry
   487 	iInputEventUid = KUidECamEvent2CIPSetColorSwapEntry;
   488 	aImageProcess->SetColorSwapEntryL(0, colorSwapParameters);
   489 	
   490 	CheckNotificationImgProc(iInputEventUid, 0, aResult);
   491 	
   492 	//check the entry status
   493 	CCamera::CCameraImageProcessing::TColorOperationEntry getColorSwapParameters;
   494 	aImageProcess->GetColorSwapEntryL(0, getColorSwapParameters);
   495 	
   496 	if(getColorSwapParameters.iEntryStatus != EDiscreteSteps)
   497 		{
   498 		INFO_PRINTF1(_L("Entry status set incorrectly"));
   499 		aResult = EFail;
   500 		}
   501 	else
   502 		{
   503 		INFO_PRINTF1(_L("Entry status set correctly"));	
   504 		}
   505 	
   506 	//start the color swap process
   507 	iInputEventUid = KUidECamEventCIPStartColorSwap;
   508 	aImageProcess->StartColorSwappingL();
   509 	
   510 	//try to cancel it
   511 	aImageProcess->CancelColorSwappingL();
   512 	
   513 	CheckNotification(iInputEventUid, aResult);
   514 	
   515 	//remove the entry
   516 	iInputEventUid = KUidECamEventCIPRemoveColorSwapEntry;
   517 	aImageProcess->RemoveColorSwapEntryL(0);
   518 	CheckNotificationImgProc(iInputEventUid, 0, aResult);
   519 	
   520 	//check the entry status
   521 	aImageProcess->GetColorSwapEntryL(0, getColorSwapParameters);
   522 	
   523 	if(getColorSwapParameters.iEntryStatus != ENotActive)
   524 		{
   525 		INFO_PRINTF1(_L("Entry status set incorrectly"));
   526 		aResult = EFail;
   527 		}
   528 	else
   529 		{
   530 		INFO_PRINTF1(_L("Entry status set correctly"));	
   531 		}
   532 	}
   533 	
   534 void RECamImageProcDefaultsTest::TestColorAccentL(CCamera::CCameraImageProcessing* aImageProcess, TVerdict& aResult)
   535 	{
   536 	CCamera::CCameraImageProcessing::TColorOperationCapabilities colorAccentCapabilities;
   537 	aImageProcess->GetColorAccentCapabilitiesL(0, colorAccentCapabilities);
   538 	
   539 	if(!colorAccentCapabilities.iIsCapabilityUniform)
   540 		{
   541 		INFO_PRINTF1(_L("Non Uniform entries for color accent"));
   542 		}
   543 	
   544 	//fill the parameters for color swap entry 
   545 	CCamera::CCameraImageProcessing::TColorOperationEntry colorAccentParameters;
   546 	
   547 	colorAccentParameters.iSourceColor.SetGreen(KValue);
   548 	colorAccentParameters.iSourceColorRepresentation = CCamera::CCameraImageProcessing::ERepresentationSingle;
   549 	colorAccentParameters.iColorOperationSourceRgbGroupingMode = CCamera::CCameraImageProcessing::ERgbGroupingFixed;
   550 	
   551 	//set the entry
   552 	iInputEventUid = KUidECamEventCIPSetColorAccentEntry;
   553 	aImageProcess->SetColorAccentEntryL(0, colorAccentParameters);
   554 	
   555 	CheckNotificationImgProc(iInputEventUid, 0, aResult);
   556 	
   557 	//check the entry status
   558 	CCamera::CCameraImageProcessing::TColorOperationEntry getColorAccentParameters;
   559 	aImageProcess->GetColorAccentEntryL(0, getColorAccentParameters);
   560 	
   561 	if(getColorAccentParameters.iEntryStatus != EDiscreteSteps)
   562 		{
   563 		INFO_PRINTF1(_L("Entry status set incorrectly"));
   564 		aResult = EFail;
   565 		}
   566 	else
   567 		{
   568 		INFO_PRINTF1(_L("Entry status set correctly"));	
   569 		}
   570 	
   571 	//start the color accent process
   572 	iInputEventUid = KUidECamEventCIPStartColorAccent;
   573 	aImageProcess->StartColorAccentL();
   574 	
   575 	//try to cancel it
   576 	aImageProcess->CancelColorAccentL();
   577 	
   578 	CheckNotification(iInputEventUid, aResult);
   579 	
   580 	//remove the entry
   581 	iInputEventUid = KUidECamEventCIPRemoveColorAccentEntry;
   582 	aImageProcess->RemoveColorAccentEntryL(0);
   583 	CheckNotificationImgProc(iInputEventUid, 0, aResult);
   584 	
   585 	//check the entry status
   586 	aImageProcess->GetColorAccentEntryL(0, getColorAccentParameters);
   587 	
   588 	if(getColorAccentParameters.iEntryStatus != ENotActive)
   589 		{
   590 		INFO_PRINTF1(_L("Entry status set incorrectly"));
   591 		aResult = EFail;
   592 		}
   593 	else
   594 		{
   595 		INFO_PRINTF1(_L("Entry status set correctly"));	
   596 		}
   597 	}
   598 	
   599 //
   600 // RECamImageProcRangesTest //
   601 //
   602 
   603 RECamImageProcRangesTest* RECamImageProcRangesTest::NewL(TBool aAllocTest)
   604 	{
   605 	RECamImageProcRangesTest* self = new (ELeave) RECamImageProcRangesTest(aAllocTest);
   606 	return self;	
   607 	}
   608 	
   609 RECamImageProcRangesTest::RECamImageProcRangesTest(TBool)
   610 	{
   611 	iTestStepName = _L("MM-ECM-ADV-U-013-HP");
   612 	}
   613 	
   614 TVerdict RECamImageProcRangesTest::DoTestStepL()
   615 	{	
   616 	TVerdict result = EPass;
   617 	CCamera* camera = NULL;
   618 	
   619 	TInt error = KErrNone;
   620 	CCamera::CCameraImageProcessing* imageprocess = NULL;
   621 	
   622 	__MM_HEAP_MARK;
   623 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
   624 	
   625 	TRAP(error, camera = CCamera::New2L(*this,0,0));
   626 	
   627 	if (error==KErrNone)
   628 		{
   629 		CleanupStack::PushL(camera);
   630 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   631 		imageprocess = 	static_cast<CCamera::CCameraImageProcessing*> (camera->CustomInterface(KECamImageProcessingUid));
   632 	    if (imageprocess!= NULL)
   633 	    	{
   634 	    	CleanupStack::PushL(imageprocess);
   635 	    
   636 		    // Get Transformation Supported Values for brightness
   637 	    	iInputEventUid = KUidECamEventImageProcessingAdjustBrightness;
   638 	    	RArray<TInt> transfSuppValues; 
   639 	    	CleanupClosePushL(transfSuppValues);
   640 	    	transfSuppValues.Reset();	 	    	
   641 			TValueInfo valueInfo;
   642 			imageprocess->GetTransformationSupportedValuesL(iInputEventUid, transfSuppValues, valueInfo);
   643 
   644 		    // Set a non supported Transformation value
   645 	        TInt aSetValue = 0;
   646 	    	imageprocess->SetTransformationValue(iInputEventUid, aSetValue);
   647 
   648 	        CheckNotification(iInputEventUid, result);
   649     				    	
   650 	    	TInt aGetValue =imageprocess->TransformationValue(iInputEventUid);
   651  	    	if (aSetValue != aGetValue)
   652 				{
   653 				INFO_PRINTF3(_L("Set unsupported TransformationValue set %d, get %d"), aSetValue, aGetValue);
   654 				result = EFail;
   655 				}	    
   656 			CleanupStack::PopAndDestroy(&transfSuppValues); 
   657 				
   658 	    	CleanupStack::PopAndDestroy(imageprocess);
   659 		  	}
   660 	    else
   661     		{
   662     		result = EFail;
   663     		}	
   664 		CleanupStack::PopAndDestroy(camera);
   665 		}
   666 	else 
   667 		{
   668 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
   669 		result = EFail;		
   670 		}
   671 	__MM_HEAP_MARKEND;
   672 
   673 	return result;
   674 	}
   675 	
   676 //
   677 // RECamPresetsNegTest //
   678 //
   679 RECamImageProcNegTest* RECamImageProcNegTest::NewL(TBool aAllocTest)
   680 	{
   681 	RECamImageProcNegTest* self = new (ELeave) RECamImageProcNegTest(aAllocTest);
   682 	return self;	
   683 	}
   684 	
   685 RECamImageProcNegTest::RECamImageProcNegTest(TBool /*aAllocTest*/)
   686 	{
   687 	iTestStepName = _L("MM-ECM-ADV-U-0103-HP");
   688 	}
   689 	
   690 TVerdict RECamImageProcNegTest::DoTestStepL()
   691 	{	
   692 	TVerdict result = EPass;
   693 	CCamera* camera = NULL;
   694 	
   695 	TInt error = KErrNone;
   696 	CCamera::CCameraImageProcessing* imageprocess = NULL;
   697 	
   698 	
   699 	__MM_HEAP_MARK;
   700 	INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
   701 	
   702 	TRAP(error, camera = CCamera::New2L(*this,0,0));
   703 	
   704 	if (error==KErrNone)
   705 		{
   706 		CleanupStack::PushL(camera);
   707 		INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
   708 		imageprocess = 	static_cast<CCamera::CCameraImageProcessing*> (camera->CustomInterface(KECamImageProcessingUid));
   709 	    if (imageprocess!= NULL)
   710 	    	{
   711 	    	CleanupStack::PushL(imageprocess);
   712 
   713 	    	// Supported Transformations
   714 	    	RArray<TUid> suppTransfUids; 
   715 	    	CleanupClosePushL(suppTransfUids);
   716 	    	suppTransfUids.Reset();
   717 	    	imageprocess->GetSupportedTransformationsL(suppTransfUids);
   718 		    // Get Supported Values for chosen transformation
   719 	 	    iInputEventUid = KUidECamEventImageProcessingAdjustBrightness;
   720 	    	RArray<TInt> transfSuppValues; 
   721 	    	CleanupClosePushL(transfSuppValues);
   722 	    	transfSuppValues.Reset();	    	
   723 			TValueInfo valueInfo;
   724 			imageprocess->GetTransformationSupportedValuesL(iInputEventUid, transfSuppValues, valueInfo);
   725 		    // Set a non supported Transformation value.
   726 	        TInt aSetValue = KValue;
   727 	    	imageprocess->SetTransformationValue(iInputEventUid, aSetValue);
   728 				
   729 	        CheckNotificationNeg(iInputEventUid, result);
   730     			
   731 		    // Check that value has not changed.
   732    	    	TInt aGetValue =imageprocess->TransformationValue(iInputEventUid);
   733  	    	if (aSetValue == aGetValue)
   734 				{
   735 				INFO_PRINTF2(_L("Set unsupported TransformationValue set %d"), aSetValue);
   736 				result = EFail;
   737 				} 
   738 			
   739 			CCamera::CCameraImageProcessing::TOrientationReference orientationReference = 
   740 						CCamera::CCameraImageProcessing::EOrientationReferenceCameraSensorOrientation;	
   741 
   742 			CCamera::CCameraImageProcessing::TRelativeRotation relativeRotation = 
   743 					CCamera::CCameraImageProcessing::ERelativeRotation0Degrees;
   744 			
   745 			CCamera::CCameraImageProcessing::TRelativeMirror relativeMirror = 
   746 					CCamera::CCameraImageProcessing::ERelativeMirrorNone;
   747 					
   748 			CCamera::CCameraImageProcessing::TRelativeFlipping relativeFlipping = 
   749 					CCamera::CCameraImageProcessing::ERelativeFlippingNone;
   750 	
   751 			INFO_PRINTF1(_L("SetRelativeOrientationOptionsL method invocation"));
   752 			iInputEventUid = KUidECamEventImageProcessingTransformRelativeOrientation;
   753 			imageprocess->SetRelativeOrientationOptionsL(orientationReference, 
   754 						relativeRotation, relativeMirror, relativeFlipping);
   755 	    	
   756 	    	CheckNotificationNeg(iInputEventUid, result);
   757  								    	    
   758 			CleanupStack::PopAndDestroy(2, &suppTransfUids); //transfSuppValues
   759 
   760 	    	CleanupStack::PopAndDestroy(imageprocess);
   761 	    	}
   762 	    else
   763     		{
   764     		result = EFail;
   765     		}	
   766 		CleanupStack::PopAndDestroy(camera);
   767 		}
   768 	else 
   769 		{
   770 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
   771 		result = EFail;		
   772 		}
   773 	__MM_HEAP_MARKEND;
   774 
   775 	return result;
   776 	}
   777 	
   778 //
   779 // RECamImageProcBaselineTest //
   780 //
   781 
   782 RECamImageProcBaselineTest* RECamImageProcBaselineTest::NewL(TBool aAllocTest)
   783 	{
   784 	RECamImageProcBaselineTest* self = new (ELeave) RECamImageProcBaselineTest(aAllocTest);
   785 	return self;	
   786 	}
   787 	
   788 RECamImageProcBaselineTest::RECamImageProcBaselineTest(TBool)
   789 	{
   790 	iTestStepName = _L("MM-ECM-ADV-U-047-HP");
   791 	}
   792 	
   793 TBool RECamImageProcBaselineTest::CompareUidArrays(RArray<TUid>& firstArray, RArray<TUid>& secondArray)
   794 	{
   795 	TBool result = ETrue;
   796 	
   797 	if (firstArray.Count() != secondArray.Count())
   798 		{
   799 		result = EFalse;
   800 		}
   801 	else
   802 		{
   803 		for (TInt expected = 0; expected < firstArray.Count(); expected++)
   804 		    {
   805 			result = EFalse;
   806 			for (TInt actual = 0; actual < secondArray.Count(); actual++)
   807 				{
   808 				if (secondArray[actual] == firstArray[expected])
   809 					{
   810 					result = ETrue;
   811 					break;
   812 					}				
   813 				}
   814 			}
   815 		}
   816 	return result;
   817 	}	
   818 	
   819 TVerdict RECamImageProcBaselineTest::DoTestStepL()
   820 	{	
   821 	TVerdict result = EPass;
   822 	CCamera* camera = NULL;
   823 	
   824 	TInt error = KErrNone;
   825 	CCamera::CCameraImageProcessing* imageprocess = NULL;
   826 	
   827 	__MM_HEAP_MARK;
   828 	INFO_PRINTF1(_L("Create camera using Camera::NewL() and MCameraObserver2"));
   829 	
   830 	TRAP(error, camera = CCamera::NewL(*this,0,0));
   831 	
   832 	if (error==KErrNone)
   833 		{
   834 		CleanupStack::PushL(camera);
   835 		INFO_PRINTF1(_L("KErrNone return from CCamera::NewL()"));
   836 		imageprocess = 	static_cast<CCamera::CCameraImageProcessing*> (camera->CustomInterface(KECamImageProcessingUid));
   837 	    if (imageprocess!= NULL)
   838 	    	{
   839 	    	CleanupStack::PushL(imageprocess);
   840 
   841 	    	// Supported Transformations
   842 			RArray<TUid> expectedTransfUids;	    	
   843 			CleanupClosePushL(expectedTransfUids);
   844 	    	expectedTransfUids.Reset();	    			
   845 	    	// set the expected UIDS
   846 			expectedTransfUids.AppendL(KUidECamEventImageProcessingAdjustBrightness);
   847 			expectedTransfUids.AppendL(KUidECamEventImageProcessingAdjustContrast);
   848 			expectedTransfUids.AppendL(KUidECamEventImageProcessingEffect);	    	
   849 	    	RArray<TUid> suppTransfUids; 
   850 	    	CleanupClosePushL(suppTransfUids);
   851 	    	imageprocess->GetSupportedTransformationsL(suppTransfUids);
   852 	    	if (CompareUidArrays(expectedTransfUids, suppTransfUids) == EFalse)
   853 				{
   854 				INFO_PRINTF1(_L("GetSupportedTransformationsL failed"));
   855 				result = EFail;
   856 				}
   857 	    	expectedTransfUids.Reset();
   858 	    	suppTransfUids.Reset();	    		    	
   859 			CleanupStack::PopAndDestroy(2, &expectedTransfUids); //suppTransfUids
   860 
   861 		    // Active Transformations
   862 	    	RArray<TUid> expectedActTransfUids; 
   863 	    	CleanupClosePushL(expectedActTransfUids);
   864 	    	expectedActTransfUids.Reset();	    
   865 	    	// set the expected UIDS
   866 			expectedActTransfUids.AppendL(KUidECamEventImageProcessingAdjustBrightness);
   867 			expectedActTransfUids.AppendL(KUidECamEventImageProcessingAdjustContrast);
   868 			expectedActTransfUids.AppendL(KUidECamEventImageProcessingEffect);	    	
   869 	    	RArray<TUid> actTransfUids; 
   870 	    	CleanupClosePushL(actTransfUids);
   871 	    	actTransfUids.Reset();	 	    	
   872 	    	imageprocess->GetActiveTransformationsL(actTransfUids);
   873  	    	if (CompareUidArrays(expectedActTransfUids, actTransfUids) == EFalse)
   874 				{
   875 				INFO_PRINTF1(_L("GetActiveTransformationsL failed"));
   876 				result = EFail;
   877 				}
   878 			CleanupStack::PopAndDestroy(2, &expectedActTransfUids); //actTransfUids
   879 		    
   880 		    // check baseline
   881 	    	RArray<TUid> expectedTransfSequence; 
   882 	    	CleanupClosePushL(expectedTransfSequence);
   883 	    	expectedTransfSequence.Reset();	    	
   884 			expectedTransfSequence.Append(KUidECamEventImageProcessingEffect);	   
   885 
   886 			imageprocess->SetActiveTransformSequenceL(expectedTransfSequence);
   887 			
   888 	    	RArray<TUid> actTransfSequence; 
   889 	    	CleanupClosePushL(actTransfSequence);
   890 	    	actTransfSequence.Reset();    		    		    	
   891 			imageprocess->GetActiveTransformSequenceL(actTransfSequence);
   892  	    	if (CompareUidArrays(expectedTransfSequence, actTransfSequence) == EFalse)
   893 				{
   894 				INFO_PRINTF1(_L("GetActiveTransformSequenceL failed"));
   895 				result = EFail;
   896 				}
   897 			CleanupStack::PopAndDestroy(2, &expectedTransfSequence); //actTransfSequence
   898 
   899 		    				
   900 			//Set Effect Transformation with color swap
   901 			iInputEventUid = KUidECamEventImageProcessingEffect;
   902 			RArray<TInt> supportedEffects;
   903 					
   904 	    	TValueInfo info = ENotActive;
   905 	    	imageprocess->GetTransformationSupportedValuesL(iInputEventUid, supportedEffects, info);
   906 	    	
   907 	    	TInt effects = supportedEffects[0];
   908 			supportedEffects.Close();
   909 	    	
   910 	    	if(info != EBitField)
   911 	    		{
   912 	    		INFO_PRINTF1(_L("Incorrect TValueInfo provided"));
   913 				result = EFail;
   914 	    		}
   915 	    		
   916 	    	if(effects > KBaselinedEffects)
   917 	        	{	
   918 	        	INFO_PRINTF1(_L("Unfamiliar enum value returned"));
   919 				result = EFail;
   920 	        	}
   921 	        	
   922 	        imageprocess->SetTransformationValue(iInputEventUid, CCamera::CCameraImageProcessing::EEffectColorSwap);	
   923 	        CheckNotification(iInputEventUid, result);
   924 	       
   925 	        // Check that value has actually changed to EEffectNone due to baselining.
   926 	    	TInt getValue = imageprocess->TransformationValue(iInputEventUid);
   927  	    	if (getValue != static_cast<TInt>(CCamera::CCameraImageProcessing::EEffectNone))
   928 				{
   929 				INFO_PRINTF1(_L("Got unfamiliar TransformationValue"));
   930 				result = EFail;
   931 				}
   932 			else
   933 				{
   934 				INFO_PRINTF1(_L("Transformation value set to EEffectNone due to baselining"));					
   935 				}
   936 			
   937 	    	CleanupStack::PopAndDestroy(imageprocess);
   938 	    	}
   939 	    else
   940     		{
   941     		result = EFail;
   942     		}	
   943 		CleanupStack::PopAndDestroy(camera);
   944 		}
   945 	else 
   946 		{
   947 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL(): observer 2"), error);
   948 		result = EFail;		
   949 		}
   950 	__MM_HEAP_MARKEND;
   951 
   952 	return result;
   953 	}