Update contrib.
4 // Copyright (c) 2005-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".
11 // Initial Contributors:
12 // Nokia Corporation - initial contribution.
19 #include <ecamuids.hrh>
20 #include <ecom/ecomresolverparams.h>
21 #include "ECamPresetsTest.h"
22 #include "ECamUnitTestPluginUids.hrh"
23 #include "ECamUnitTestPlugin.h"
24 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
25 #include <ecamadvsettingsuidsconst.hrh>
26 #include <ecamadvsettingsconst.h>
27 #include <ecamimageprocessingconst.h>
32 RECamPresetsTest* RECamPresetsTest::NewL(TBool aAllocTest)
34 RECamPresetsTest* self = new (ELeave) RECamPresetsTest(aAllocTest);
38 RECamPresetsTest::RECamPresetsTest(TBool /*aAllocTest*/)
40 iTestStepName = _L("MM-ECM-ADV-U-006-HP");
43 TVerdict RECamPresetsTest::DoTestStepL()
45 TVerdict verdict = EFail;
46 INFO_PRINTF1(_L("Alloc test"));
55 INFO_PRINTF2(_L("Fail count = %d"), i);
58 __UHEAP_SETFAIL(RHeap::EFailNext, i);
60 TRAP(err, verdict = DoPresetsTestStepL());
62 TAny* testAlloc = User::Alloc(1);
63 TBool heapTestingComplete = (testAlloc == NULL) && (err==KErrNone);
64 User::Free(testAlloc);
69 if ((err != KErrNoMemory ) || heapTestingComplete)
71 INFO_PRINTF4(_L("err = %d, verdict = %d, Fail count = %d"), err, verdict, i);
72 INFO_PRINTF1(_L("Alloc testing completed successfully"));
80 TVerdict RECamPresetsTest::DoPresetsTestStepL()
82 TVerdict result = EPass;
83 CCamera* camera = NULL;
85 TInt error = KErrNone;
86 CCamera::CCameraPresets* presets = NULL;
89 MCameraObserver2* observer2 = NULL;
92 INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
94 TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
98 CleanupStack::PushL(camera);
99 INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
100 presets = static_cast<CCamera::CCameraPresets*> (camera->CustomInterface(KECamPresetsUid));
103 CleanupStack::PushL(presets);
104 INFO_PRINTF1(_L("CCameraPresets object was created"));
105 CleanupStack::PopAndDestroy(presets);
110 User::Leave(KErrNoMemory);
112 CleanupStack::PopAndDestroy(camera);
116 INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
118 User::Leave(KErrNoMemory);
122 // create a presets object using NewL
124 INFO_PRINTF1(_L("Create camera using Camera::NewL() and MCameraObserver2"));
126 TRAP(error, camera = CCamera::New2L(*observer2, 0,0));
130 CleanupStack::PushL(camera);
131 INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
132 TRAP(error, presets = CCamera::CCameraPresets::NewL(*camera));
136 CleanupStack::PushL(presets);
137 INFO_PRINTF1(_L("CCameraPresets object was created using NewL"));
138 CleanupStack::PopAndDestroy(presets);
142 INFO_PRINTF1(_L("CCameraPresets object was not created using NewL"));
144 User::Leave(KErrNoMemory);
146 CleanupStack::PopAndDestroy(camera);
150 INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
152 User::Leave(KErrNoMemory);
160 // RECamPresetsNotificationTest
162 RECamPresetsNotificationTest* RECamPresetsNotificationTest::NewL(TBool aAllocTest)
164 RECamPresetsNotificationTest* self = new (ELeave) RECamPresetsNotificationTest(aAllocTest);
165 CleanupStack::PushL(self);
167 CleanupStack::Pop(self);
171 void RECamPresetsNotificationTest::ConstructL()
173 iOriginalSet.Reset();
177 RECamPresetsNotificationTest::RECamPresetsNotificationTest(TBool /*aAllocTest*/)
179 iTestStepName = _L("MM-ECM-ADV-U-008-HP");
182 TVerdict RECamPresetsNotificationTest::DoTestStepL()
184 TVerdict result = EPass;
185 CCamera* camera = NULL;
187 TInt error = KErrNone;
188 CCamera::CCameraPresets* presets = NULL;
191 INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
193 TRAP(error, camera = CCamera::New2L(*this,0,0));
197 CleanupStack::PushL(camera);
198 // CCamUnitTestPlugin* camera1 = static_cast<CCamUnitTestPlugin*>(camera);
199 // rely on public member, done for simplfication of an external
200 // initialization as it is the simplest way
201 // camera1->iPresets = iOriginalSet;
202 INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
203 presets = static_cast<CCamera::CCameraPresets*> (camera->CustomInterface(KECamPresetsUid));
206 CleanupStack::PushL(presets);
208 // get the supported set of values
209 presets->GetSupportedPresetsL(iResultSet);
211 //verify that the input and output are the same
212 INFO_PRINTF2(_L("camera supports %d presets"), iResultSet.Count());
214 // the array should not be empty
215 if (iResultSet.Count()==0)
224 INFO_PRINTF1(_L("Current preset shall be KUidECamPresetNone"));
225 TUid currentPreset = presets->Preset();
227 // Current Preset shall be KUidECamPresetNone.
228 if(currentPreset.iUid != KUidECamPresetNoneUidValue)
230 INFO_PRINTF1(_L("Current preset wrongly set"));
235 iInputEventUid = KUidECamPresetBeach;
236 INFO_PRINTF2(_L("Select a new preset %d"), iInputEventUid.iUid);
237 presets->SetPreset(iInputEventUid);
239 CheckNotification(iInputEventUid, result);
241 presets->GetAffectedSettingsL(iResultSet);
242 INFO_PRINTF2(_L("This preset affected %d settings"), iResultSet.Count());
244 // get the alternative function
245 RArray<TUid> associatedSettings;
246 CleanupClosePushL(associatedSettings);
247 associatedSettings.Reset();
248 INFO_PRINTF1(_L("Get associated settings for the selected preset"));
249 TRAP(error,presets->GetAssociatedSettingsL(iInputEventUid, associatedSettings));
250 if(error != KErrNone)
252 CleanupStack::PopAndDestroy(&associatedSettings);
255 if (iResultSet.Count()!=associatedSettings.Count())
263 CleanupStack::PopAndDestroy(&associatedSettings);
265 // set KUidECamPresetOutdoor to get range restricted settings.
266 iInputEventUid = KUidECamPresetOutdoor;
267 INFO_PRINTF2(_L("Select the Outdoor preset %d"), iInputEventUid.iUid);
268 presets->SetPreset(iInputEventUid);
270 INFO_PRINTF1(_L("Check the RangeRestricted notification"));
271 CheckNotification(KUidECamEventRangeRestricted, result);
275 INFO_PRINTF1(_L("Retrieve the RangeRestricted settings"));
276 // get the range restricted settings
277 RArray<TUid> rangeRestrictedSettings;
278 presets->GetRangeRestrictedSettingsL(rangeRestrictedSettings);
279 if (rangeRestrictedSettings.Count() == 0)
281 INFO_PRINTF1(_L("RangeRestricted settings are Zero"));
284 rangeRestrictedSettings.Close();
287 INFO_PRINTF1(_L("Check the FeatureRestricted settings"));
288 // get the feature restricted settings
289 RArray<TUid> featureRestrictedSettings;
290 presets->GetFeatureRestrictedSettingsL(featureRestrictedSettings);
291 if (featureRestrictedSettings.Count() != 0)
293 INFO_PRINTF1(_L("FeatureRestricted settings are not Zero"));
296 featureRestrictedSettings.Close();
298 TBool unlockSupported = EFalse;
299 presets->IsPresetUnlockSupportedL(unlockSupported);
302 INFO_PRINTF1(_L("Preset Unlock not supported"));
306 INFO_PRINTF1(_L("Unlock Preset"));
307 presets->UnlockPresetL();
308 CheckNotification(KUidECamEventPresetUnlocked, result);
310 INFO_PRINTF1(_L("Lock Preset"));
311 presets->LockPresetL();
312 CheckNotification(KUidECamEventPresetLocked, result);
314 CleanupStack::PopAndDestroy(presets);
319 User::Leave(KErrNoMemory);
322 CleanupStack::PopAndDestroy(camera);
326 INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
328 User::Leave(KErrNoMemory);
337 // RECamPresetsNegTest //
339 RECamPresetsNegTest* RECamPresetsNegTest::NewL(TBool aAllocTest)
341 RECamPresetsNegTest* self = new (ELeave) RECamPresetsNegTest(aAllocTest);
345 RECamPresetsNegTest::RECamPresetsNegTest(TBool /*aAllocTest*/)
347 iTestStepName = _L("MM-ECM-ADV-U-0101-HP");
350 TVerdict RECamPresetsNegTest::DoTestStepL()
352 TVerdict result = EPass;
353 CCamera* camera = NULL;
355 TInt error = KErrNone;
356 CCamera::CCameraPresets* presets = NULL;
360 INFO_PRINTF1(_L("Create camera using Camera::New2L() and MCameraObserver2"));
362 TRAP(error, camera = CCamera::New2L(*this,0,0));
366 CleanupStack::PushL(camera);
367 INFO_PRINTF1(_L("KErrNone return from CCamera::New2L()"));
368 presets = static_cast<CCamera::CCameraPresets*> (camera->CustomInterface(KECamPresetsUid));
371 CleanupStack::PushL(presets);
373 TUid aCurrentPreset = presets->Preset();
374 // get the current value
375 INFO_PRINTF2(_L("Current preset %x"), aCurrentPreset.iUid);
377 // get the supported set of values
378 RArray<TUid> aResultSet;
379 CleanupClosePushL(aResultSet);
381 presets->GetSupportedPresetsL(aResultSet);
383 // Setting a non supported preset should be rejected
384 // In the test plugin only KUidECamPresetOutdoor, KUidECamPresetNightPartyIndoor & KUidECamPresetBeach are supported
385 iInputEventUid = KUidECamPresetIndoorSport;
386 presets->SetPreset(iInputEventUid);
388 CheckNotificationNeg(iInputEventUid, result);
390 // Setting a non supported preset should be rejected
391 // In the test plugin only KUidECamPresetOutdoor, KUidECamPresetNightPartyIndoor & KUidECamPresetBeach are supported
392 iInputEventUid = KUidECamPresetVideoTelephony;
393 presets->SetPreset(iInputEventUid);
395 CheckNotificationNeg(iInputEventUid, result);
397 TUid aGetPreset = presets->Preset();
399 if ((aCurrentPreset == aGetPreset) && (aGetPreset == KUidECamPresetNone))
401 INFO_PRINTF2(_L("Current preset has not changed %x"), aGetPreset.iUid);
405 INFO_PRINTF1(_L("Expected no affected settings"));
409 // get the affected settings
410 RArray<TUid> aAffectedSet;
411 CleanupClosePushL(aAffectedSet);
412 presets->GetAffectedSettingsL(aAffectedSet);
413 // the list of affected settings should be empty
414 if (aAffectedSet.Count()!=0)
416 INFO_PRINTF1(_L("Expected no affected settings"));
421 INFO_PRINTF1(_L("No affected settings"));
424 CleanupStack::PopAndDestroy(2, &aResultSet); //aAffectedSet
426 CleanupStack::PopAndDestroy(presets);
428 else // preset is NULL
432 CleanupStack::PopAndDestroy(camera);
434 else // error != KErrNone
436 INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L(): observer 2"), error);
445 // RECamPresetsBaselineTest
447 RECamPresetsBaselineTest* RECamPresetsBaselineTest::NewL(TBool aAllocTest)
449 RECamPresetsBaselineTest* self = new (ELeave) RECamPresetsBaselineTest(aAllocTest);
450 CleanupStack::PushL(self);
452 CleanupStack::Pop(self);
456 void RECamPresetsBaselineTest::ConstructL()
458 iOriginalSet.Reset();
462 RECamPresetsBaselineTest::RECamPresetsBaselineTest(TBool /*aAllocTest*/)
464 iTestStepName = _L("MM-ECM-ADV-U-046-HP");
467 TVerdict RECamPresetsBaselineTest::DoTestStepL()
469 TVerdict result = EPass;
470 CCamera* camera = NULL;
472 TInt error = KErrNone;
473 CCamera::CCameraPresets* presets = NULL;
476 INFO_PRINTF1(_L("Create camera using Camera::NewL() and MCameraObserver2"));
478 TRAP(error, camera = CCamera::NewL(*this,0,0));
482 CleanupStack::PushL(camera);
483 // CCamUnitTestPlugin* camera1 = static_cast<CCamUnitTestPlugin*>(camera);
484 // rely on public member, done for simplfication of an external
485 // initialization as it is the simplest way
486 // camera1->iPresets = iOriginalSet;
487 INFO_PRINTF1(_L("KErrNone return from CCamera::NewL()"));
488 presets = static_cast<CCamera::CCameraPresets*> (camera->CustomInterface(KECamPresetsUid));
491 CleanupStack::PushL(presets);
493 // get the supported set of values
494 presets->GetSupportedPresetsL(iResultSet);
496 //verify that the input and output are the same
497 INFO_PRINTF2(_L("camera supports %d presets"), iResultSet.Count());
499 // the array should not contain any unfamiliar uid for preset(after baseline)
500 for(TInt index =0; index < iResultSet.Count(); index++)
502 /** KUidECamPresetFactoryDefaultUidValue is the baseline. Any preset with greater uid value means that it has
503 been added in later versions */
504 if(iResultSet[index].iUid > KUidECamPresetFactoryDefaultUidValue)
513 // set new unfamiliar value
514 iInputEventUid = KUidECamPresetNightPartyIndoor;
515 INFO_PRINTF2(_L("Select a new preset %d"), iInputEventUid.iUid);
516 presets->SetPreset(iInputEventUid);
518 CheckNotification(iInputEventUid, result);
520 if(presets->Preset().iUid != KUidECamPresetFactoryDefaultUidValue)
525 presets->GetAffectedSettingsL(iResultSet);
526 INFO_PRINTF2(_L("This preset affected %d settings"), iResultSet.Count());
528 // the array should not contain any unfamiliar uid for settings(after baseline)
529 for(TInt index =0; index < iResultSet.Count(); index++)
531 /** KUidECamEventCameraSettingAutoFocusType2UidValue is the baseline. Any settings with greater uid value means that it has
532 been added in later versions */
533 if(iResultSet[index].iUid > KUidECamEventCameraSettingAutoFocusType2UidValue)
539 // get the alternative function
540 RArray<TUid> associatedSettings;
542 presets->GetAssociatedSettingsL(iInputEventUid, associatedSettings);
544 if (iResultSet.Count()!=associatedSettings.Count())
552 associatedSettings.Close();
553 CleanupStack::PopAndDestroy(presets);
559 CleanupStack::PopAndDestroy(camera);
563 INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL(): observer 2"), error);