camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxeautofocuscontrolsymbian/unittest_cxeautofocuscontrolsymbian.cpp
changeset 56 01e205c615b9
parent 48 42ba2d16bf40
equal deleted inserted replaced
48:42ba2d16bf40 56:01e205c615b9
   104     // no state changes
   104     // no state changes
   105     QVERIFY(!CxeTestUtils::waitForSignal(stateSpy, 1000));
   105     QVERIFY(!CxeTestUtils::waitForSignal(stateSpy, 1000));
   106     QCOMPARE(mAutoFocusControl->state(), CxeAutoFocusControl::Unknown);
   106     QCOMPARE(mAutoFocusControl->state(), CxeAutoFocusControl::Unknown);
   107 
   107 
   108     // 2) Input parameter false is handled correctly
   108     // 2) Input parameter false is handled correctly
   109     // prequisites: not fixed mode & unknown state -> normal functionality
   109     // prerequisites : not fixed mode & unknown state -> normal functionality
   110     mAutoFocusControl->setMode(CxeAutoFocusControl::Auto); // non-fixed
   110     mAutoFocusControl->setMode(CxeAutoFocusControl::Auto); // non-fixed
   111     // function call
   111     // function call
   112     returnValue = mAutoFocusControl->start(false);
   112     returnValue = mAutoFocusControl->start(false);
   113     // verifying the result:
   113     // verifying the result:
   114     QCOMPARE(mAutoFocusControl->state(), CxeAutoFocusControl::InProgress);
   114     QCOMPARE(mAutoFocusControl->state(), CxeAutoFocusControl::InProgress);
   115     QCOMPARE(returnValue, CxeError::None);
   115     QCOMPARE(returnValue, CxeError::None);
   116     QCOMPARE(mAutoFocusControl->isSoundEnabled(), false); // check for input parameter
   116     QCOMPARE(mAutoFocusControl->isSoundEnabled(), false); // check for input parameter
   117 
   117 
   118     // 3) Autofocus is not ready (state is cancelling or in progress)
   118     // 3) Autofocus is not ready (state is cancelling or in progress)
   119     // prequisites:
   119     // prerequisites :
   120     mAutoFocusControl->setMode(CxeAutoFocusControl::Macro); // non-fixed mode
   120     mAutoFocusControl->setMode(CxeAutoFocusControl::Macro); // non-fixed mode
   121     QCOMPARE(mAutoFocusControl->state(), CxeAutoFocusControl::InProgress);
   121     QCOMPARE(mAutoFocusControl->state(), CxeAutoFocusControl::InProgress);
   122     // start should return CxeError::InUse
   122     // start should return CxeError::InUse
   123     returnValue = mAutoFocusControl->start();
   123     returnValue = mAutoFocusControl->start();
   124     QCOMPARE(returnValue, CxeError::InUse);
   124     QCOMPARE(returnValue, CxeError::InUse);
   125 
   125 
   126     // 4) Camera has been released
   126     // 4) Camera has been released
   127     mAutoFocusControl->prepareForCameraDelete();
   127     // Cannot be tested like this since assertion crashes the function
       
   128     // AFTER prepareForCameraDelete CALL.
       
   129     /*mAutoFocusControl->prepareForCameraDelete();
   128     stateSpy.clear();
   130     stateSpy.clear();
   129     returnValue = mAutoFocusControl->start();
   131     returnValue = mAutoFocusControl->start();
   130     // result: no signal should be emitted
   132     // result: no signal should be emitted
   131     QVERIFY(!CxeTestUtils::waitForSignal(stateSpy, 1000));
   133     QVERIFY(!CxeTestUtils::waitForSignal(stateSpy, 1000));
   132     QCOMPARE(returnValue, CxeError::None); // should there be and error here?
   134     QCOMPARE(returnValue, CxeError::None); // should there be and error here?
       
   135     */
   133 }
   136 }
   134 
   137 
   135 void UnitTestCxeAutoFocusControlSymbian::testCancel()
   138 void UnitTestCxeAutoFocusControlSymbian::testCancel()
   136 {
   139 {
   137     // create signalspy to monitor that state changed signal
   140     // create signalspy to monitor that state changed signal
   268 void UnitTestCxeAutoFocusControlSymbian::testPrepareForRelease()
   271 void UnitTestCxeAutoFocusControlSymbian::testPrepareForRelease()
   269 {
   272 {
   270     // see testPrepareForCameraDelete
   273     // see testPrepareForCameraDelete
   271 }
   274 }
   272 
   275 
   273 void UnitTestCxeAutoFocusControlSymbian::testHandleCameraEvent()
   276 void UnitTestCxeAutoFocusControlSymbian::testHandleCameraEventOptimalFocus()
   274 {
   277 {
   275     // handleCameraEvent handles callbacks and gets information about
   278     // handleCameraEvent handles callbacks and gets information about
   276     // focus events. handleCameraEvent calls private method handleAfEvent
   279     // focus events. handleCameraEvent calls private method handleAfEvent
   277     // for the focusing events that CxeAutoFocusControlSymbian needs
   280     // for the focusing events that CxeAutoFocusControlSymbian needs
   278 
   281 
   319     stateSpy.clear();
   322     stateSpy.clear();
   320     mAutoFocusControl->handleCameraEvent(eventUid, symbianError);
   323     mAutoFocusControl->handleCameraEvent(eventUid, symbianError);
   321     // => state should change to Unknown
   324     // => state should change to Unknown
   322     QVERIFY(CxeTestUtils::waitForSignal(stateSpy, 1000));
   325     QVERIFY(CxeTestUtils::waitForSignal(stateSpy, 1000));
   323     QCOMPARE(mAutoFocusControl->state(), CxeAutoFocusControl::Unknown);
   326     QCOMPARE(mAutoFocusControl->state(), CxeAutoFocusControl::Unknown);
   324 
   327 }
   325     // cleanup and init to make sure that the dummy engine is not messed up
   328 
   326     // and we get to initial state
   329 void UnitTestCxeAutoFocusControlSymbian::testHandleCameraEventAutofocusChanged()
   327     cleanup();
   330 {
   328     init();
   331     QSignalSpy stateSpy(mAutoFocusControl,
   329 
   332                         SIGNAL(stateChanged(CxeAutoFocusControl::State,
       
   333                                             CxeError::Id)));
   330     // Input 2 -----------------------------------------------------
   334     // Input 2 -----------------------------------------------------
   331     // Notifies a change in autofocus type
   335     // Notifies a change in autofocus type
   332     eventUid = KUidECamEventCameraSettingAutoFocusType2UidValue;
   336     int eventUid = KUidECamEventCameraSettingAutoFocusType2UidValue;
   333     symbianError = -18; // == KErrNotReady
   337     int symbianError = -18; // == KErrNotReady
   334 
   338 
   335     // InProgress: event is ignored
   339     // InProgress: event is ignored
   336     mAutoFocusControl->setMode(CxeAutoFocusControl::Auto); // not fixed focus
   340     mAutoFocusControl->setMode(CxeAutoFocusControl::Auto); // not fixed focus
   337     mAutoFocusControl->start();
   341     mAutoFocusControl->start();
   338     QCOMPARE(mAutoFocusControl->state(), CxeAutoFocusControl::InProgress); //verify start state
   342     QCOMPARE(mAutoFocusControl->state(), CxeAutoFocusControl::InProgress); //verify start state
   346     QCOMPARE(mAutoFocusControl->state(), CxeAutoFocusControl::Canceling); //verify start state
   350     QCOMPARE(mAutoFocusControl->state(), CxeAutoFocusControl::Canceling); //verify start state
   347     stateSpy.clear();
   351     stateSpy.clear();
   348     mAutoFocusControl->handleCameraEvent(eventUid, symbianError);
   352     mAutoFocusControl->handleCameraEvent(eventUid, symbianError);
   349     QVERIFY(!CxeTestUtils::waitForSignal(stateSpy, 1000));
   353     QVERIFY(!CxeTestUtils::waitForSignal(stateSpy, 1000));
   350 
   354 
   351     // cleanup and init to make sure that the dummy engine is not messed up
   355 }
   352     // and we get to initial state
   356 
   353     cleanup();
   357 void UnitTestCxeAutoFocusControlSymbian::testHandleCameraEventFocusRangeChanged()
   354     init();
   358 {
       
   359     QSignalSpy stateSpy(mAutoFocusControl,
       
   360                         SIGNAL(stateChanged(CxeAutoFocusControl::State,
       
   361                                             CxeError::Id)));
   355 
   362 
   356     // Input 3 -----------------------------------------------------
   363     // Input 3 -----------------------------------------------------
   357     // Focus range have changed
   364     // Focus range have changed
   358     eventUid = KUidECamEventCameraSettingFocusRangeUidValue;
   365     int eventUid = KUidECamEventCameraSettingFocusRangeUidValue;
   359     symbianError = -2; // == KErrGeneral
   366     int symbianError = -2; // == KErrGeneral
   360 
   367 
   361     // In any other state than InProgress this event is ignored
   368     // In any other state than InProgress this event is ignored
   362     stateSpy.clear();
   369     stateSpy.clear();
   363     mAutoFocusControl->handleCameraEvent(eventUid, symbianError);
   370     mAutoFocusControl->handleCameraEvent(eventUid, symbianError);
   364     QVERIFY(!CxeTestUtils::waitForSignal(stateSpy, 1000));
   371     QVERIFY(!CxeTestUtils::waitForSignal(stateSpy, 1000));