camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxeharvestercontrolsymbian/unittest_cxeharvestercontrolsymbian.cpp
changeset 43 0e652f8f1fbd
parent 19 d9aefe59d544
equal deleted inserted replaced
28:3075d9b614e6 43:0e652f8f1fbd
    20 #include <QString>
    20 #include <QString>
    21 
    21 
    22 #include "unittest_cxeharvestercontrolsymbian.h"
    22 #include "unittest_cxeharvestercontrolsymbian.h"
    23 #include "cxeharvestercontrolsymbian.h"
    23 #include "cxeharvestercontrolsymbian.h"
    24 #include "cxutils.h"
    24 #include "cxutils.h"
       
    25 #include "cxeerror.h"
    25 
    26 
    26 UnitTestCxeHarvesterControlSymbian::UnitTestCxeHarvesterControlSymbian()
    27 UnitTestCxeHarvesterControlSymbian::UnitTestCxeHarvesterControlSymbian()
       
    28     : mHarvesterControl(NULL)
    27 {
    29 {
       
    30     qRegisterMetaType<CxeError::Id>("CxeError::Id");
    28 }
    31 }
    29 
    32 
    30 
    33 
    31 UnitTestCxeHarvesterControlSymbian::~UnitTestCxeHarvesterControlSymbian()
    34 UnitTestCxeHarvesterControlSymbian::~UnitTestCxeHarvesterControlSymbian()
    32 {
    35 {
    47 
    50 
    48 void UnitTestCxeHarvesterControlSymbian::testHarvestFile()
    51 void UnitTestCxeHarvesterControlSymbian::testHarvestFile()
    49 {
    52 {
    50     CX_DEBUG_ENTER_FUNCTION();
    53     CX_DEBUG_ENTER_FUNCTION();
    51     
    54     
    52     QSignalSpy harvestCompleteSpy(mHarvesterControl, SIGNAL(fileHarvested(const QString&, int)));
    55     QSignalSpy harvestCompleteSpy(mHarvesterControl, SIGNAL(fileHarvested(CxeError::Id, const QString&)));
    53     QString filename;
    56     QString filename;
       
    57     QVariantList initModeArguments;
    54 
    58 
    55     QVERIFY(harvestCompleteSpy.isValid()); 
    59     QVERIFY(harvestCompleteSpy.isValid()); 
    56 
    60 
    57     // case 1: testing with wrong dummy file, we should get an error code with harvestcomplete
    61     // case 1: testing with wrong dummy file, we should get an error code with harvestcomplete
    58     // since filename is invalid
    62     // since filename is invalid
    59     mHarvesterControl->harvestFile(filename, 0, 0);
    63     mHarvesterControl->harvestFile(filename, 0, 0);
    60  
       
    61     QCOMPARE( harvestCompleteSpy.count(), 1 );
    64     QCOMPARE( harvestCompleteSpy.count(), 1 );
    62     if (harvestCompleteSpy.count() > 0) {
    65     initModeArguments = harvestCompleteSpy.takeFirst();
    63         QList<QVariant> initModeArguments = harvestCompleteSpy.takeFirst();
    66     // we are only interested in error code in this case 1
    64         // we are only interested in error code in this case 1
    67     QCOMPARE(initModeArguments.at(0).value<CxeError::Id>(), CxeError::NotFound);
    65         QCOMPARE(initModeArguments.at(1).toInt(), KErrNotFound);
       
    66     }
       
    67 
       
    68     
    68     
    69     // case 2: testing with real filename, harvesting should go fine, callback without errors
    69     // case 2: testing with real filename, harvesting should go fine, callback without errors
    70     filename = QString("test.jpg");
    70     filename = QString("test.jpg");
    71     mHarvesterControl->harvestFile(filename, 0, 0);
    71     mHarvesterControl->harvestFile(filename, 0, 0);
    72  
    72  
    73     QCOMPARE( harvestCompleteSpy.count(), 1 );
    73     QCOMPARE( harvestCompleteSpy.count(), 1 );
    74     if (harvestCompleteSpy.count() > 0) {
    74     initModeArguments = harvestCompleteSpy.takeFirst();
    75         QList<QVariant> initModeArguments = harvestCompleteSpy.takeFirst();
    75     // we check both the filename, since in this case harvesting should go fine
    76         // we check both the filename, since in this case harvesting should go fine
    76     // and error returned is KErrNone.
    77         // and error returned is KErrNone.
    77     QCOMPARE(initModeArguments.at(0).value<CxeError::Id>(), CxeError::None);
    78         QCOMPARE(initModeArguments.at(1).toString(), filename);
    78     QCOMPARE(initModeArguments.at(1).toString(), filename);
    79         QCOMPARE(initModeArguments.at(1).toInt(), KErrNone);
       
    80     }
       
    81 
    79 
    82     CX_DEBUG_EXIT_FUNCTION();
    80     CX_DEBUG_EXIT_FUNCTION();
    83 }
    81 }
    84 
    82 
    85 
    83