os/mm/imagingandcamerafws/cameraunittest/src/TSU_ECM_ADV/ECamImageProcessingTest.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/imagingandcamerafws/cameraunittest/src/TSU_ECM_ADV/ECamImageProcessingTest.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,953 @@
1.4 +
1.5 +// ECamImageProcessingTest.cpp
1.6 +
1.7 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.8 +// All rights reserved.
1.9 +// This component and the accompanying materials are made available
1.10 +// under the terms of "Eclipse Public License v1.0"
1.11 +// which accompanies this distribution, and is available
1.12 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.13 +//
1.14 +// Initial Contributors:
1.15 +// Nokia Corporation - initial contribution.
1.16 +//
1.17 +// Contributors:
1.18 +//
1.19 +// Description:
1.20 +//
1.21 +
1.22 +#include "ECamImageProcessingTest.h"
1.23 +#include <ecamadvsettings.h>
1.24 +#include <ecam/ecamplugin.h>
1.25 +#include <ecamuids.hrh>
1.26 +#include <ecom/ecomresolverparams.h>
1.27 +#include "ECamUnitTestPluginUids.hrh"
1.28 +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
1.29 +#include <ecamimageprocessingconst.h>
1.30 +#endif
1.31 +
1.32 +
1.33 +
1.34 +//const TRect KRect1(100, 50, 600, 200);
1.35 +const TInt KValue = 100;
1.36 +const TInt KBaselinedEffects = 0x000001FF;
1.37 +//
1.38 +// RECamImageProcessingTest
1.39 +//
1.40 +
1.41 +RECamImageProcessingTest* RECamImageProcessingTest::NewL(TBool aAllocTest)
1.42 + {
1.43 + RECamImageProcessingTest* self = new (ELeave) RECamImageProcessingTest(aAllocTest);
1.44 + return self;
1.45 + }
1.46 +
1.47 +RECamImageProcessingTest::RECamImageProcessingTest(TBool /*aAllocTest*/)
1.48 + {
1.49 + iTestStepName = _L("MM-ECM-ADV-U-007-HP");
1.50 + }
1.51 +
1.52 +TVerdict RECamImageProcessingTest::DoTestStepL()
1.53 + {
1.54 + TVerdict verdict = EFail;
1.55 + INFO_PRINTF1(_L("Alloc test"));
1.56 + TInt i;
1.57 + TInt err;
1.58 + for (i = 1 ; ; i++)
1.59 + {
1.60 + __MM_HEAP_MARK;
1.61 +
1.62 + if (i % 5 == 0)
1.63 + {
1.64 + INFO_PRINTF2(_L("Fail count = %d"), i);
1.65 + }
1.66 +
1.67 + __UHEAP_SETFAIL(RHeap::EFailNext, i);
1.68 +
1.69 + TRAP(err, verdict = DoImageProcessingTestStepL());
1.70 +
1.71 + TAny* testAlloc = User::Alloc(1);
1.72 + TBool heapTestingComplete = (testAlloc == NULL) && (err==KErrNone);
1.73 + User::Free(testAlloc);
1.74 +
1.75 + __UHEAP_RESET;
1.76 + __MM_HEAP_MARKEND;
1.77 +
1.78 + if ((err != KErrNoMemory ) || heapTestingComplete)
1.79 + {
1.80 + INFO_PRINTF4(_L("err = %d, verdict = %d, Fail count = %d"), err, verdict, i);
1.81 + INFO_PRINTF1(_L("Alloc testing completed successfully"));
1.82 + verdict = EPass;
1.83 + break;
1.84 + }
1.85 + }
1.86 + return verdict;
1.87 + }
1.88 +
1.89 +TVerdict RECamImageProcessingTest::DoImageProcessingTestStepL()
1.90 + {
1.91 + TVerdict result = EPass;
1.92 + CCamera* camera = NULL;
1.93 +
1.94 + TInt error = KErrNone;
1.95 + CCamera::CCameraImageProcessing* imageprocess = NULL;
1.96 +
1.97 + // using observer 2
1.98 + MCameraObserver2* observer2 = NULL;
1.99 +
1.100 + __MM_HEAP_MARK;
1.101 + INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
1.102 +
1.103 + TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
1.104 +
1.105 + if (error==KErrNone)
1.106 + {
1.107 + CleanupStack::PushL(camera);
1.108 + INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
1.109 + imageprocess = static_cast<CCamera::CCameraImageProcessing*> (camera->CustomInterface(KECamImageProcessingUid));
1.110 + if (imageprocess!= NULL)
1.111 + {
1.112 + CleanupStack::PushL(imageprocess);
1.113 + INFO_PRINTF1(_L("CCameraImageProcessing object was created"));
1.114 + CleanupStack::PopAndDestroy(imageprocess);
1.115 + }
1.116 + else
1.117 + {
1.118 + result = EFail;
1.119 + User::Leave(KErrNoMemory);
1.120 + }
1.121 + CleanupStack::PopAndDestroy(camera);
1.122 + }
1.123 + else
1.124 + {
1.125 + INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
1.126 + result = EFail;
1.127 + User::Leave(KErrNoMemory);
1.128 + }
1.129 + __MM_HEAP_MARKEND;
1.130 +
1.131 + // create a imageprocessing object using New2L
1.132 + __MM_HEAP_MARK;
1.133 + INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
1.134 +
1.135 + TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
1.136 +
1.137 + if (error==KErrNone)
1.138 + {
1.139 + CleanupStack::PushL(camera);
1.140 + INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
1.141 + TRAP(error, imageprocess = CCamera::CCameraImageProcessing::NewL(*camera));
1.142 +
1.143 + if (error==KErrNone)
1.144 + {
1.145 + CleanupStack::PushL(imageprocess);
1.146 + INFO_PRINTF1(_L("CCameraImageProcessing object was created using NewL"));
1.147 + CleanupStack::PopAndDestroy(imageprocess);
1.148 + }
1.149 + else
1.150 + {
1.151 + INFO_PRINTF1(_L("CCameraImageProcessing object was not created using NewL"));
1.152 + result = EFail;
1.153 + User::Leave(KErrNoMemory);
1.154 + }
1.155 + CleanupStack::PopAndDestroy(camera);
1.156 + }
1.157 + else
1.158 + {
1.159 + INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
1.160 + result = EFail;
1.161 + User::Leave(KErrNoMemory);
1.162 + }
1.163 + __MM_HEAP_MARKEND;
1.164 +
1.165 + return result;
1.166 + }
1.167 +
1.168 +//
1.169 +// RECamImageProcDefaultsTest //
1.170 +//
1.171 +
1.172 +RECamImageProcDefaultsTest* RECamImageProcDefaultsTest::NewL(TBool aAllocTest)
1.173 + {
1.174 + RECamImageProcDefaultsTest* self = new (ELeave) RECamImageProcDefaultsTest(aAllocTest);
1.175 + return self;
1.176 + }
1.177 +
1.178 +RECamImageProcDefaultsTest::RECamImageProcDefaultsTest(TBool)
1.179 + {
1.180 + iTestStepName = _L("MM-ECM-ADV-U-012-HP");
1.181 + }
1.182 +
1.183 +TBool RECamImageProcDefaultsTest::CompareUidArrays(RArray<TUid>& firstArray, RArray<TUid>& secondArray)
1.184 + {
1.185 + TBool result = ETrue;
1.186 +
1.187 + if (firstArray.Count() != secondArray.Count())
1.188 + {
1.189 + result = EFalse;
1.190 + }
1.191 + else
1.192 + {
1.193 + for (TInt expected = 0; expected < firstArray.Count(); expected++)
1.194 + {
1.195 + result = EFalse;
1.196 + for (TInt actual = 0; actual < secondArray.Count(); actual++)
1.197 + {
1.198 + if (secondArray[actual] == firstArray[expected])
1.199 + {
1.200 + result = ETrue;
1.201 + break;
1.202 + }
1.203 + }
1.204 + }
1.205 + }
1.206 + return result;
1.207 + }
1.208 +
1.209 +TVerdict RECamImageProcDefaultsTest::DoTestStepL()
1.210 + {
1.211 + TVerdict result = EPass;
1.212 + CCamera* camera = NULL;
1.213 +
1.214 + TInt error = KErrNone;
1.215 + CCamera::CCameraImageProcessing* imageprocess = NULL;
1.216 +
1.217 + __MM_HEAP_MARK;
1.218 + INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
1.219 +
1.220 + TRAP(error, camera = CCamera::New2L(*this,0,0));
1.221 +
1.222 + if (error==KErrNone)
1.223 + {
1.224 + CleanupStack::PushL(camera);
1.225 + INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
1.226 + imageprocess = static_cast<CCamera::CCameraImageProcessing*> (camera->CustomInterface(KECamImageProcessingUid));
1.227 + if (imageprocess!= NULL)
1.228 + {
1.229 + CleanupStack::PushL(imageprocess);
1.230 +
1.231 + // Supported Transformations
1.232 + RArray<TUid> expectedTransfUids;
1.233 + CleanupClosePushL(expectedTransfUids);
1.234 + expectedTransfUids.Reset();
1.235 + // set the expected UIDS
1.236 + expectedTransfUids.AppendL(KUidECamEventImageProcessingAdjustBrightness);
1.237 + expectedTransfUids.AppendL(KUidECamEventImageProcessingAdjustContrast);
1.238 + expectedTransfUids.AppendL(KUidECamEventImageProcessingEffect);
1.239 + RArray<TUid> suppTransfUids;
1.240 + CleanupClosePushL(suppTransfUids);
1.241 + imageprocess->GetSupportedTransformationsL(suppTransfUids);
1.242 + if (CompareUidArrays(expectedTransfUids, suppTransfUids) == EFalse)
1.243 + {
1.244 + INFO_PRINTF1(_L("GetSupportedTransformationsL failed"));
1.245 + result = EFail;
1.246 + }
1.247 + expectedTransfUids.Reset();
1.248 + suppTransfUids.Reset();
1.249 + CleanupStack::PopAndDestroy(2, &expectedTransfUids); //suppTransfUids
1.250 +
1.251 + // Active Transformations
1.252 + RArray<TUid> expectedActTransfUids;
1.253 + CleanupClosePushL(expectedActTransfUids);
1.254 + expectedActTransfUids.Reset();
1.255 + // set the expected UIDS
1.256 + expectedActTransfUids.AppendL(KUidECamEventImageProcessingAdjustBrightness);
1.257 + expectedActTransfUids.AppendL(KUidECamEventImageProcessingAdjustContrast);
1.258 + expectedActTransfUids.AppendL(KUidECamEventImageProcessingEffect);
1.259 + RArray<TUid> actTransfUids;
1.260 + CleanupClosePushL(actTransfUids);
1.261 + actTransfUids.Reset();
1.262 + imageprocess->GetActiveTransformationsL(actTransfUids);
1.263 + if (CompareUidArrays(expectedActTransfUids, actTransfUids) == EFalse)
1.264 + {
1.265 + INFO_PRINTF1(_L("GetActiveTransformationsL failed"));
1.266 + result = EFail;
1.267 + }
1.268 + CleanupStack::PopAndDestroy(2, &expectedActTransfUids); //actTransfUids
1.269 +
1.270 + // Set & Get Active Transformation Sequence
1.271 + RArray<TUid> expectedTransfSequence;
1.272 + CleanupClosePushL(expectedTransfSequence);
1.273 + expectedTransfSequence.Reset();
1.274 + expectedTransfSequence.Append(KUidECamEventImageProcessingAdjustBrightness);
1.275 +
1.276 + imageprocess->SetActiveTransformSequenceL(expectedTransfSequence);
1.277 +
1.278 + RArray<TUid> actTransfSequence;
1.279 + CleanupClosePushL(actTransfSequence);
1.280 + actTransfSequence.Reset();
1.281 + imageprocess->GetActiveTransformSequenceL(actTransfSequence);
1.282 + if (CompareUidArrays(expectedTransfSequence, actTransfSequence) == EFalse)
1.283 + {
1.284 + INFO_PRINTF1(_L("GetActiveTransformSequenceL failed"));
1.285 + result = EFail;
1.286 + }
1.287 + CleanupStack::PopAndDestroy(2, &expectedTransfSequence); //actTransfSequence
1.288 +
1.289 + // Get & Set Transformation
1.290 + TUid iInputEventUid = KUidECamEventImageProcessingAdjustBrightness;
1.291 + TInt aSetValue = 4;
1.292 + imageprocess->SetTransformationValue(iInputEventUid, aSetValue);
1.293 +
1.294 + CheckNotification(iInputEventUid, result);
1.295 +
1.296 + // Check that value has actually changed.
1.297 + TInt aGetValue = imageprocess->TransformationValue(iInputEventUid);
1.298 + if (aSetValue != aGetValue)
1.299 + {
1.300 + INFO_PRINTF3(_L("Got wrong TransformationValue set %d, got %d"), aSetValue, aGetValue);
1.301 + result = EFail;
1.302 + }
1.303 + else
1.304 + {
1.305 + INFO_PRINTF2(_L("Transformation value set to %d"), aSetValue);
1.306 + }
1.307 +
1.308 + TInt aGetValue1 = 0;
1.309 + TInt err = imageprocess->GetTransformationValue(iInputEventUid, aGetValue1);
1.310 +
1.311 + if(err)
1.312 + {
1.313 + INFO_PRINTF2(_L("New method for Getting Transformation value returned error %d"), err);
1.314 + result = EFail;
1.315 + }
1.316 +
1.317 + if(aGetValue1 != aGetValue)
1.318 + {
1.319 + INFO_PRINTF1(_L("New and old method for Getting Transformation value retrieves wrong/dissimilar values"));
1.320 + result = EFail;
1.321 + }
1.322 +
1.323 + //Set Effect Transformation with color swap
1.324 + iInputEventUid = KUidECamEventImageProcessingEffect;
1.325 + RArray<TInt> supportedEffects;
1.326 +
1.327 + TValueInfo info = ENotActive;
1.328 + imageprocess->GetTransformationSupportedValuesL(iInputEventUid, supportedEffects, info);
1.329 +
1.330 + TInt effects = supportedEffects[0];
1.331 + supportedEffects.Close();
1.332 +
1.333 + if(info != EBitField)
1.334 + {
1.335 + INFO_PRINTF1(_L("Incorrect TValueInfo provided"));
1.336 + result = EFail;
1.337 + }
1.338 +
1.339 + if(effects & CCamera::CCameraImageProcessing::EEffectColorSwap)
1.340 + {
1.341 + imageprocess->SetTransformationValue(iInputEventUid, CCamera::CCameraImageProcessing::EEffectColorSwap);
1.342 +
1.343 + CheckNotification(iInputEventUid, result);
1.344 + }
1.345 +
1.346 + // Check that value has actually changed.
1.347 + aGetValue = imageprocess->TransformationValue(iInputEventUid);
1.348 + if (aGetValue != static_cast<TInt>(CCamera::CCameraImageProcessing::EEffectColorSwap))
1.349 + {
1.350 + INFO_PRINTF1(_L("Got wrong TransformationValue set"));
1.351 + result = EFail;
1.352 + }
1.353 + else
1.354 + {
1.355 + INFO_PRINTF1(_L("Transformation value set to EEffectColorSwap"));
1.356 + }
1.357 +
1.358 + TInt concurrentColorSwappingSupported=0;
1.359 + imageprocess->GetConcurrentColorSwappingsSupportedL(concurrentColorSwappingSupported);
1.360 +
1.361 + if(concurrentColorSwappingSupported > 0)
1.362 + {
1.363 + TestColorSwapL(imageprocess, result);
1.364 + }
1.365 +
1.366 + //Set Effect Transformation with color accent
1.367 + iInputEventUid = iInputEventUid = KUidECamEventImageProcessingEffect;
1.368 + if(effects & CCamera::CCameraImageProcessing::EEffectColorAccent)
1.369 + {
1.370 + imageprocess->SetTransformationValue(iInputEventUid, CCamera::CCameraImageProcessing::EEffectColorAccent);
1.371 +
1.372 + CheckNotification(iInputEventUid, result);
1.373 + }
1.374 +
1.375 + // Check that value has actually changed.
1.376 + aGetValue = imageprocess->TransformationValue(iInputEventUid);
1.377 + if (aGetValue != static_cast<TInt>(CCamera::CCameraImageProcessing::EEffectColorAccent))
1.378 + {
1.379 + INFO_PRINTF1(_L("Got wrong TransformationValue set"));
1.380 + result = EFail;
1.381 + }
1.382 + else
1.383 + {
1.384 + INFO_PRINTF1(_L("Transformation value set to EEffectColorAccent"));
1.385 + }
1.386 +
1.387 + TInt concurrentColorAccentSupported=0;
1.388 + imageprocess->GetConcurrentColorAccentSupportedL(concurrentColorAccentSupported);
1.389 +
1.390 + if(concurrentColorAccentSupported > 0)
1.391 + {
1.392 + TestColorAccentL(imageprocess, result);
1.393 + }
1.394 +
1.395 + // Get & Set Source Rect
1.396 + TRect setRect(100, 50, 600, 200);
1.397 + TRect getRect;
1.398 + imageprocess->SetSourceRect(setRect);
1.399 + imageprocess->GetSourceRect(getRect);
1.400 + if (setRect != getRect)
1.401 + {
1.402 + INFO_PRINTF1(_L("Did not get the same rect"));
1.403 + result = EFail;
1.404 + }
1.405 +
1.406 + CCamera::CCameraImageProcessing::TOrientationReference orientationReference =
1.407 + CCamera::CCameraImageProcessing::EOrientationReferenceCameraSensorOrientation;
1.408 + TUint supportedRelativeRotation=0;
1.409 + TUint supportedRelativeMirroring=0;
1.410 + TUint supportedRelativeFlipping=0;
1.411 +
1.412 + INFO_PRINTF1(_L("GetSupportedRelativeOrientationOptionsL method invocation"));
1.413 +
1.414 + TRAP(err,imageprocess->GetSupportedRelativeOrientationOptionsL(orientationReference,
1.415 + supportedRelativeRotation, supportedRelativeMirroring, supportedRelativeFlipping));
1.416 +
1.417 + if(err!= KErrNotSupported)
1.418 + {
1.419 + INFO_PRINTF1(_L("GetSupportedRelativeOrientationOptionsL did not leave with KErrNotSupported"));
1.420 + result = EFail;
1.421 + }
1.422 +
1.423 + CCamera::CCameraImageProcessing::TRelativeRotation relativeRotation =
1.424 + CCamera::CCameraImageProcessing::ERelativeRotation0Degrees;
1.425 +
1.426 + CCamera::CCameraImageProcessing::TRelativeMirror relativeMirror =
1.427 + CCamera::CCameraImageProcessing::ERelativeMirrorNone;
1.428 +
1.429 + CCamera::CCameraImageProcessing::TRelativeFlipping relativeFlipping =
1.430 + CCamera::CCameraImageProcessing::ERelativeFlippingNone;
1.431 +
1.432 + INFO_PRINTF1(_L("GetCurrentRelativeOrientationOptionsL method invocation"));
1.433 + TRAP(err,imageprocess->GetCurrentRelativeOrientationOptionsL(orientationReference,
1.434 + relativeRotation, relativeMirror, relativeFlipping));
1.435 +
1.436 + if(err!= KErrNotSupported)
1.437 + {
1.438 + INFO_PRINTF1(_L("GetCurrentRelativeOrientationOptionsL did not leave with KErrNotSupported"));
1.439 + result = EFail;
1.440 + }
1.441 +
1.442 + INFO_PRINTF1(_L("SetRelativeOrientationOptionsL method invocation"));
1.443 + iInputEventUid = KUidECamEventImageProcessingTransformRelativeOrientation;
1.444 + imageprocess->SetRelativeOrientationOptionsL(orientationReference,
1.445 + relativeRotation, relativeMirror, relativeFlipping);
1.446 +
1.447 + CheckNotificationNeg(iInputEventUid, result);
1.448 +
1.449 + CleanupStack::PopAndDestroy(imageprocess);
1.450 + }
1.451 + else
1.452 + {
1.453 + result = EFail;
1.454 + }
1.455 + CleanupStack::PopAndDestroy(camera);
1.456 + }
1.457 + else
1.458 + {
1.459 + INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
1.460 + result = EFail;
1.461 + }
1.462 + __MM_HEAP_MARKEND;
1.463 +
1.464 + return result;
1.465 + }
1.466 +
1.467 +void RECamImageProcDefaultsTest::TestColorSwapL(CCamera::CCameraImageProcessing* aImageProcess, TVerdict& aResult)
1.468 + {
1.469 + CCamera::CCameraImageProcessing::TColorOperationCapabilities colorSwapCapabilities;
1.470 + aImageProcess->GetColorSwapCapabilitiesL(0, colorSwapCapabilities);
1.471 +
1.472 + if(!colorSwapCapabilities.iIsCapabilityUniform)
1.473 + {
1.474 + INFO_PRINTF1(_L("Non Uniform entries for color swap"));
1.475 + }
1.476 +
1.477 + //fill the parameters for color swap entry
1.478 + CCamera::CCameraImageProcessing::TColorOperationEntry colorSwapParameters;
1.479 +
1.480 + colorSwapParameters.iSourceColor.SetGreen(KValue);
1.481 + colorSwapParameters.iTargetColor.SetBlue(KValue);
1.482 +
1.483 + colorSwapParameters.iSourceColorRepresentation = CCamera::CCameraImageProcessing::ERepresentationSingle;
1.484 + colorSwapParameters.iTargetColorRepresentation = CCamera::CCameraImageProcessing::ERepresentationSingle;
1.485 +
1.486 + colorSwapParameters.iColorOperationSourceRgbGroupingMode = CCamera::CCameraImageProcessing::ERgbGroupingFixed;
1.487 + colorSwapParameters.iColorOperationTargetRgbGroupingMode = CCamera::CCameraImageProcessing::ERgbGroupingFixed;
1.488 +
1.489 + //set the entry
1.490 + iInputEventUid = KUidECamEvent2CIPSetColorSwapEntry;
1.491 + aImageProcess->SetColorSwapEntryL(0, colorSwapParameters);
1.492 +
1.493 + CheckNotificationImgProc(iInputEventUid, 0, aResult);
1.494 +
1.495 + //check the entry status
1.496 + CCamera::CCameraImageProcessing::TColorOperationEntry getColorSwapParameters;
1.497 + aImageProcess->GetColorSwapEntryL(0, getColorSwapParameters);
1.498 +
1.499 + if(getColorSwapParameters.iEntryStatus != EDiscreteSteps)
1.500 + {
1.501 + INFO_PRINTF1(_L("Entry status set incorrectly"));
1.502 + aResult = EFail;
1.503 + }
1.504 + else
1.505 + {
1.506 + INFO_PRINTF1(_L("Entry status set correctly"));
1.507 + }
1.508 +
1.509 + //start the color swap process
1.510 + iInputEventUid = KUidECamEventCIPStartColorSwap;
1.511 + aImageProcess->StartColorSwappingL();
1.512 +
1.513 + //try to cancel it
1.514 + aImageProcess->CancelColorSwappingL();
1.515 +
1.516 + CheckNotification(iInputEventUid, aResult);
1.517 +
1.518 + //remove the entry
1.519 + iInputEventUid = KUidECamEventCIPRemoveColorSwapEntry;
1.520 + aImageProcess->RemoveColorSwapEntryL(0);
1.521 + CheckNotificationImgProc(iInputEventUid, 0, aResult);
1.522 +
1.523 + //check the entry status
1.524 + aImageProcess->GetColorSwapEntryL(0, getColorSwapParameters);
1.525 +
1.526 + if(getColorSwapParameters.iEntryStatus != ENotActive)
1.527 + {
1.528 + INFO_PRINTF1(_L("Entry status set incorrectly"));
1.529 + aResult = EFail;
1.530 + }
1.531 + else
1.532 + {
1.533 + INFO_PRINTF1(_L("Entry status set correctly"));
1.534 + }
1.535 + }
1.536 +
1.537 +void RECamImageProcDefaultsTest::TestColorAccentL(CCamera::CCameraImageProcessing* aImageProcess, TVerdict& aResult)
1.538 + {
1.539 + CCamera::CCameraImageProcessing::TColorOperationCapabilities colorAccentCapabilities;
1.540 + aImageProcess->GetColorAccentCapabilitiesL(0, colorAccentCapabilities);
1.541 +
1.542 + if(!colorAccentCapabilities.iIsCapabilityUniform)
1.543 + {
1.544 + INFO_PRINTF1(_L("Non Uniform entries for color accent"));
1.545 + }
1.546 +
1.547 + //fill the parameters for color swap entry
1.548 + CCamera::CCameraImageProcessing::TColorOperationEntry colorAccentParameters;
1.549 +
1.550 + colorAccentParameters.iSourceColor.SetGreen(KValue);
1.551 + colorAccentParameters.iSourceColorRepresentation = CCamera::CCameraImageProcessing::ERepresentationSingle;
1.552 + colorAccentParameters.iColorOperationSourceRgbGroupingMode = CCamera::CCameraImageProcessing::ERgbGroupingFixed;
1.553 +
1.554 + //set the entry
1.555 + iInputEventUid = KUidECamEventCIPSetColorAccentEntry;
1.556 + aImageProcess->SetColorAccentEntryL(0, colorAccentParameters);
1.557 +
1.558 + CheckNotificationImgProc(iInputEventUid, 0, aResult);
1.559 +
1.560 + //check the entry status
1.561 + CCamera::CCameraImageProcessing::TColorOperationEntry getColorAccentParameters;
1.562 + aImageProcess->GetColorAccentEntryL(0, getColorAccentParameters);
1.563 +
1.564 + if(getColorAccentParameters.iEntryStatus != EDiscreteSteps)
1.565 + {
1.566 + INFO_PRINTF1(_L("Entry status set incorrectly"));
1.567 + aResult = EFail;
1.568 + }
1.569 + else
1.570 + {
1.571 + INFO_PRINTF1(_L("Entry status set correctly"));
1.572 + }
1.573 +
1.574 + //start the color accent process
1.575 + iInputEventUid = KUidECamEventCIPStartColorAccent;
1.576 + aImageProcess->StartColorAccentL();
1.577 +
1.578 + //try to cancel it
1.579 + aImageProcess->CancelColorAccentL();
1.580 +
1.581 + CheckNotification(iInputEventUid, aResult);
1.582 +
1.583 + //remove the entry
1.584 + iInputEventUid = KUidECamEventCIPRemoveColorAccentEntry;
1.585 + aImageProcess->RemoveColorAccentEntryL(0);
1.586 + CheckNotificationImgProc(iInputEventUid, 0, aResult);
1.587 +
1.588 + //check the entry status
1.589 + aImageProcess->GetColorAccentEntryL(0, getColorAccentParameters);
1.590 +
1.591 + if(getColorAccentParameters.iEntryStatus != ENotActive)
1.592 + {
1.593 + INFO_PRINTF1(_L("Entry status set incorrectly"));
1.594 + aResult = EFail;
1.595 + }
1.596 + else
1.597 + {
1.598 + INFO_PRINTF1(_L("Entry status set correctly"));
1.599 + }
1.600 + }
1.601 +
1.602 +//
1.603 +// RECamImageProcRangesTest //
1.604 +//
1.605 +
1.606 +RECamImageProcRangesTest* RECamImageProcRangesTest::NewL(TBool aAllocTest)
1.607 + {
1.608 + RECamImageProcRangesTest* self = new (ELeave) RECamImageProcRangesTest(aAllocTest);
1.609 + return self;
1.610 + }
1.611 +
1.612 +RECamImageProcRangesTest::RECamImageProcRangesTest(TBool)
1.613 + {
1.614 + iTestStepName = _L("MM-ECM-ADV-U-013-HP");
1.615 + }
1.616 +
1.617 +TVerdict RECamImageProcRangesTest::DoTestStepL()
1.618 + {
1.619 + TVerdict result = EPass;
1.620 + CCamera* camera = NULL;
1.621 +
1.622 + TInt error = KErrNone;
1.623 + CCamera::CCameraImageProcessing* imageprocess = NULL;
1.624 +
1.625 + __MM_HEAP_MARK;
1.626 + INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
1.627 +
1.628 + TRAP(error, camera = CCamera::New2L(*this,0,0));
1.629 +
1.630 + if (error==KErrNone)
1.631 + {
1.632 + CleanupStack::PushL(camera);
1.633 + INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
1.634 + imageprocess = static_cast<CCamera::CCameraImageProcessing*> (camera->CustomInterface(KECamImageProcessingUid));
1.635 + if (imageprocess!= NULL)
1.636 + {
1.637 + CleanupStack::PushL(imageprocess);
1.638 +
1.639 + // Get Transformation Supported Values for brightness
1.640 + iInputEventUid = KUidECamEventImageProcessingAdjustBrightness;
1.641 + RArray<TInt> transfSuppValues;
1.642 + CleanupClosePushL(transfSuppValues);
1.643 + transfSuppValues.Reset();
1.644 + TValueInfo valueInfo;
1.645 + imageprocess->GetTransformationSupportedValuesL(iInputEventUid, transfSuppValues, valueInfo);
1.646 +
1.647 + // Set a non supported Transformation value
1.648 + TInt aSetValue = 0;
1.649 + imageprocess->SetTransformationValue(iInputEventUid, aSetValue);
1.650 +
1.651 + CheckNotification(iInputEventUid, result);
1.652 +
1.653 + TInt aGetValue =imageprocess->TransformationValue(iInputEventUid);
1.654 + if (aSetValue != aGetValue)
1.655 + {
1.656 + INFO_PRINTF3(_L("Set unsupported TransformationValue set %d, get %d"), aSetValue, aGetValue);
1.657 + result = EFail;
1.658 + }
1.659 + CleanupStack::PopAndDestroy(&transfSuppValues);
1.660 +
1.661 + CleanupStack::PopAndDestroy(imageprocess);
1.662 + }
1.663 + else
1.664 + {
1.665 + result = EFail;
1.666 + }
1.667 + CleanupStack::PopAndDestroy(camera);
1.668 + }
1.669 + else
1.670 + {
1.671 + INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
1.672 + result = EFail;
1.673 + }
1.674 + __MM_HEAP_MARKEND;
1.675 +
1.676 + return result;
1.677 + }
1.678 +
1.679 +//
1.680 +// RECamPresetsNegTest //
1.681 +//
1.682 +RECamImageProcNegTest* RECamImageProcNegTest::NewL(TBool aAllocTest)
1.683 + {
1.684 + RECamImageProcNegTest* self = new (ELeave) RECamImageProcNegTest(aAllocTest);
1.685 + return self;
1.686 + }
1.687 +
1.688 +RECamImageProcNegTest::RECamImageProcNegTest(TBool /*aAllocTest*/)
1.689 + {
1.690 + iTestStepName = _L("MM-ECM-ADV-U-0103-HP");
1.691 + }
1.692 +
1.693 +TVerdict RECamImageProcNegTest::DoTestStepL()
1.694 + {
1.695 + TVerdict result = EPass;
1.696 + CCamera* camera = NULL;
1.697 +
1.698 + TInt error = KErrNone;
1.699 + CCamera::CCameraImageProcessing* imageprocess = NULL;
1.700 +
1.701 +
1.702 + __MM_HEAP_MARK;
1.703 + INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
1.704 +
1.705 + TRAP(error, camera = CCamera::New2L(*this,0,0));
1.706 +
1.707 + if (error==KErrNone)
1.708 + {
1.709 + CleanupStack::PushL(camera);
1.710 + INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
1.711 + imageprocess = static_cast<CCamera::CCameraImageProcessing*> (camera->CustomInterface(KECamImageProcessingUid));
1.712 + if (imageprocess!= NULL)
1.713 + {
1.714 + CleanupStack::PushL(imageprocess);
1.715 +
1.716 + // Supported Transformations
1.717 + RArray<TUid> suppTransfUids;
1.718 + CleanupClosePushL(suppTransfUids);
1.719 + suppTransfUids.Reset();
1.720 + imageprocess->GetSupportedTransformationsL(suppTransfUids);
1.721 + // Get Supported Values for chosen transformation
1.722 + iInputEventUid = KUidECamEventImageProcessingAdjustBrightness;
1.723 + RArray<TInt> transfSuppValues;
1.724 + CleanupClosePushL(transfSuppValues);
1.725 + transfSuppValues.Reset();
1.726 + TValueInfo valueInfo;
1.727 + imageprocess->GetTransformationSupportedValuesL(iInputEventUid, transfSuppValues, valueInfo);
1.728 + // Set a non supported Transformation value.
1.729 + TInt aSetValue = KValue;
1.730 + imageprocess->SetTransformationValue(iInputEventUid, aSetValue);
1.731 +
1.732 + CheckNotificationNeg(iInputEventUid, result);
1.733 +
1.734 + // Check that value has not changed.
1.735 + TInt aGetValue =imageprocess->TransformationValue(iInputEventUid);
1.736 + if (aSetValue == aGetValue)
1.737 + {
1.738 + INFO_PRINTF2(_L("Set unsupported TransformationValue set %d"), aSetValue);
1.739 + result = EFail;
1.740 + }
1.741 +
1.742 + CCamera::CCameraImageProcessing::TOrientationReference orientationReference =
1.743 + CCamera::CCameraImageProcessing::EOrientationReferenceCameraSensorOrientation;
1.744 +
1.745 + CCamera::CCameraImageProcessing::TRelativeRotation relativeRotation =
1.746 + CCamera::CCameraImageProcessing::ERelativeRotation0Degrees;
1.747 +
1.748 + CCamera::CCameraImageProcessing::TRelativeMirror relativeMirror =
1.749 + CCamera::CCameraImageProcessing::ERelativeMirrorNone;
1.750 +
1.751 + CCamera::CCameraImageProcessing::TRelativeFlipping relativeFlipping =
1.752 + CCamera::CCameraImageProcessing::ERelativeFlippingNone;
1.753 +
1.754 + INFO_PRINTF1(_L("SetRelativeOrientationOptionsL method invocation"));
1.755 + iInputEventUid = KUidECamEventImageProcessingTransformRelativeOrientation;
1.756 + imageprocess->SetRelativeOrientationOptionsL(orientationReference,
1.757 + relativeRotation, relativeMirror, relativeFlipping);
1.758 +
1.759 + CheckNotificationNeg(iInputEventUid, result);
1.760 +
1.761 + CleanupStack::PopAndDestroy(2, &suppTransfUids); //transfSuppValues
1.762 +
1.763 + CleanupStack::PopAndDestroy(imageprocess);
1.764 + }
1.765 + else
1.766 + {
1.767 + result = EFail;
1.768 + }
1.769 + CleanupStack::PopAndDestroy(camera);
1.770 + }
1.771 + else
1.772 + {
1.773 + INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
1.774 + result = EFail;
1.775 + }
1.776 + __MM_HEAP_MARKEND;
1.777 +
1.778 + return result;
1.779 + }
1.780 +
1.781 +//
1.782 +// RECamImageProcBaselineTest //
1.783 +//
1.784 +
1.785 +RECamImageProcBaselineTest* RECamImageProcBaselineTest::NewL(TBool aAllocTest)
1.786 + {
1.787 + RECamImageProcBaselineTest* self = new (ELeave) RECamImageProcBaselineTest(aAllocTest);
1.788 + return self;
1.789 + }
1.790 +
1.791 +RECamImageProcBaselineTest::RECamImageProcBaselineTest(TBool)
1.792 + {
1.793 + iTestStepName = _L("MM-ECM-ADV-U-047-HP");
1.794 + }
1.795 +
1.796 +TBool RECamImageProcBaselineTest::CompareUidArrays(RArray<TUid>& firstArray, RArray<TUid>& secondArray)
1.797 + {
1.798 + TBool result = ETrue;
1.799 +
1.800 + if (firstArray.Count() != secondArray.Count())
1.801 + {
1.802 + result = EFalse;
1.803 + }
1.804 + else
1.805 + {
1.806 + for (TInt expected = 0; expected < firstArray.Count(); expected++)
1.807 + {
1.808 + result = EFalse;
1.809 + for (TInt actual = 0; actual < secondArray.Count(); actual++)
1.810 + {
1.811 + if (secondArray[actual] == firstArray[expected])
1.812 + {
1.813 + result = ETrue;
1.814 + break;
1.815 + }
1.816 + }
1.817 + }
1.818 + }
1.819 + return result;
1.820 + }
1.821 +
1.822 +TVerdict RECamImageProcBaselineTest::DoTestStepL()
1.823 + {
1.824 + TVerdict result = EPass;
1.825 + CCamera* camera = NULL;
1.826 +
1.827 + TInt error = KErrNone;
1.828 + CCamera::CCameraImageProcessing* imageprocess = NULL;
1.829 +
1.830 + __MM_HEAP_MARK;
1.831 + INFO_PRINTF1(_L("Create camera using Camera::NewL() and MCameraObserver2"));
1.832 +
1.833 + TRAP(error, camera = CCamera::NewL(*this,0,0));
1.834 +
1.835 + if (error==KErrNone)
1.836 + {
1.837 + CleanupStack::PushL(camera);
1.838 + INFO_PRINTF1(_L("KErrNone return from CCamera::NewL()"));
1.839 + imageprocess = static_cast<CCamera::CCameraImageProcessing*> (camera->CustomInterface(KECamImageProcessingUid));
1.840 + if (imageprocess!= NULL)
1.841 + {
1.842 + CleanupStack::PushL(imageprocess);
1.843 +
1.844 + // Supported Transformations
1.845 + RArray<TUid> expectedTransfUids;
1.846 + CleanupClosePushL(expectedTransfUids);
1.847 + expectedTransfUids.Reset();
1.848 + // set the expected UIDS
1.849 + expectedTransfUids.AppendL(KUidECamEventImageProcessingAdjustBrightness);
1.850 + expectedTransfUids.AppendL(KUidECamEventImageProcessingAdjustContrast);
1.851 + expectedTransfUids.AppendL(KUidECamEventImageProcessingEffect);
1.852 + RArray<TUid> suppTransfUids;
1.853 + CleanupClosePushL(suppTransfUids);
1.854 + imageprocess->GetSupportedTransformationsL(suppTransfUids);
1.855 + if (CompareUidArrays(expectedTransfUids, suppTransfUids) == EFalse)
1.856 + {
1.857 + INFO_PRINTF1(_L("GetSupportedTransformationsL failed"));
1.858 + result = EFail;
1.859 + }
1.860 + expectedTransfUids.Reset();
1.861 + suppTransfUids.Reset();
1.862 + CleanupStack::PopAndDestroy(2, &expectedTransfUids); //suppTransfUids
1.863 +
1.864 + // Active Transformations
1.865 + RArray<TUid> expectedActTransfUids;
1.866 + CleanupClosePushL(expectedActTransfUids);
1.867 + expectedActTransfUids.Reset();
1.868 + // set the expected UIDS
1.869 + expectedActTransfUids.AppendL(KUidECamEventImageProcessingAdjustBrightness);
1.870 + expectedActTransfUids.AppendL(KUidECamEventImageProcessingAdjustContrast);
1.871 + expectedActTransfUids.AppendL(KUidECamEventImageProcessingEffect);
1.872 + RArray<TUid> actTransfUids;
1.873 + CleanupClosePushL(actTransfUids);
1.874 + actTransfUids.Reset();
1.875 + imageprocess->GetActiveTransformationsL(actTransfUids);
1.876 + if (CompareUidArrays(expectedActTransfUids, actTransfUids) == EFalse)
1.877 + {
1.878 + INFO_PRINTF1(_L("GetActiveTransformationsL failed"));
1.879 + result = EFail;
1.880 + }
1.881 + CleanupStack::PopAndDestroy(2, &expectedActTransfUids); //actTransfUids
1.882 +
1.883 + // check baseline
1.884 + RArray<TUid> expectedTransfSequence;
1.885 + CleanupClosePushL(expectedTransfSequence);
1.886 + expectedTransfSequence.Reset();
1.887 + expectedTransfSequence.Append(KUidECamEventImageProcessingEffect);
1.888 +
1.889 + imageprocess->SetActiveTransformSequenceL(expectedTransfSequence);
1.890 +
1.891 + RArray<TUid> actTransfSequence;
1.892 + CleanupClosePushL(actTransfSequence);
1.893 + actTransfSequence.Reset();
1.894 + imageprocess->GetActiveTransformSequenceL(actTransfSequence);
1.895 + if (CompareUidArrays(expectedTransfSequence, actTransfSequence) == EFalse)
1.896 + {
1.897 + INFO_PRINTF1(_L("GetActiveTransformSequenceL failed"));
1.898 + result = EFail;
1.899 + }
1.900 + CleanupStack::PopAndDestroy(2, &expectedTransfSequence); //actTransfSequence
1.901 +
1.902 +
1.903 + //Set Effect Transformation with color swap
1.904 + iInputEventUid = KUidECamEventImageProcessingEffect;
1.905 + RArray<TInt> supportedEffects;
1.906 +
1.907 + TValueInfo info = ENotActive;
1.908 + imageprocess->GetTransformationSupportedValuesL(iInputEventUid, supportedEffects, info);
1.909 +
1.910 + TInt effects = supportedEffects[0];
1.911 + supportedEffects.Close();
1.912 +
1.913 + if(info != EBitField)
1.914 + {
1.915 + INFO_PRINTF1(_L("Incorrect TValueInfo provided"));
1.916 + result = EFail;
1.917 + }
1.918 +
1.919 + if(effects > KBaselinedEffects)
1.920 + {
1.921 + INFO_PRINTF1(_L("Unfamiliar enum value returned"));
1.922 + result = EFail;
1.923 + }
1.924 +
1.925 + imageprocess->SetTransformationValue(iInputEventUid, CCamera::CCameraImageProcessing::EEffectColorSwap);
1.926 + CheckNotification(iInputEventUid, result);
1.927 +
1.928 + // Check that value has actually changed to EEffectNone due to baselining.
1.929 + TInt getValue = imageprocess->TransformationValue(iInputEventUid);
1.930 + if (getValue != static_cast<TInt>(CCamera::CCameraImageProcessing::EEffectNone))
1.931 + {
1.932 + INFO_PRINTF1(_L("Got unfamiliar TransformationValue"));
1.933 + result = EFail;
1.934 + }
1.935 + else
1.936 + {
1.937 + INFO_PRINTF1(_L("Transformation value set to EEffectNone due to baselining"));
1.938 + }
1.939 +
1.940 + CleanupStack::PopAndDestroy(imageprocess);
1.941 + }
1.942 + else
1.943 + {
1.944 + result = EFail;
1.945 + }
1.946 + CleanupStack::PopAndDestroy(camera);
1.947 + }
1.948 + else
1.949 + {
1.950 + INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL(): observer 2"), error);
1.951 + result = EFail;
1.952 + }
1.953 + __MM_HEAP_MARKEND;
1.954 +
1.955 + return result;
1.956 + }