camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxeharvestercontrolsymbian/unittest_cxeharvestercontrolsymbian.cpp
branchRCL_3
changeset 54 bac7acad7cb3
parent 53 61bc0f252b2b
child 57 2c87b2808fd7
equal deleted inserted replaced
53:61bc0f252b2b 54:bac7acad7cb3
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QTest>
       
    19 #include <QSignalSpy>
       
    20 #include <QString>
       
    21 
       
    22 #include "unittest_cxeharvestercontrolsymbian.h"
       
    23 #include "cxeharvestercontrolsymbian.h"
       
    24 #include "cxutils.h"
       
    25 #include "cxeerror.h"
       
    26 
       
    27 UnitTestCxeHarvesterControlSymbian::UnitTestCxeHarvesterControlSymbian()
       
    28     : mHarvesterControl(NULL)
       
    29 {
       
    30     qRegisterMetaType<CxeError::Id>("CxeError::Id");
       
    31 }
       
    32 
       
    33 
       
    34 UnitTestCxeHarvesterControlSymbian::~UnitTestCxeHarvesterControlSymbian()
       
    35 {
       
    36     cleanup();
       
    37 }
       
    38 
       
    39 
       
    40 void UnitTestCxeHarvesterControlSymbian::init()
       
    41 {
       
    42     mHarvesterControl = new CxeHarvesterControlSymbian();
       
    43 }
       
    44 
       
    45 void UnitTestCxeHarvesterControlSymbian::cleanup()
       
    46 {
       
    47     delete mHarvesterControl;
       
    48     mHarvesterControl = NULL;
       
    49 }
       
    50 
       
    51 void UnitTestCxeHarvesterControlSymbian::testHarvestFile()
       
    52 {
       
    53     CX_DEBUG_ENTER_FUNCTION();
       
    54     
       
    55     QSignalSpy harvestCompleteSpy(mHarvesterControl, SIGNAL(fileHarvested(CxeError::Id, const QString&)));
       
    56     QString filename;
       
    57     QVariantList initModeArguments;
       
    58 
       
    59     QVERIFY(harvestCompleteSpy.isValid()); 
       
    60 
       
    61     // case 1: testing with wrong dummy file, we should get an error code with harvestcomplete
       
    62     // since filename is invalid
       
    63     mHarvesterControl->harvestFile(filename, 0, 0);
       
    64     QCOMPARE( harvestCompleteSpy.count(), 1 );
       
    65     initModeArguments = harvestCompleteSpy.takeFirst();
       
    66     // we are only interested in error code in this case 1
       
    67     QCOMPARE(initModeArguments.at(0).value<CxeError::Id>(), CxeError::NotFound);
       
    68     
       
    69     // case 2: testing with real filename, harvesting should go fine, callback without errors
       
    70     filename = QString("test.jpg");
       
    71     mHarvesterControl->harvestFile(filename, 0, 0);
       
    72  
       
    73     QCOMPARE( harvestCompleteSpy.count(), 1 );
       
    74     initModeArguments = harvestCompleteSpy.takeFirst();
       
    75     // we check both the filename, since in this case harvesting should go fine
       
    76     // and error returned is KErrNone.
       
    77     QCOMPARE(initModeArguments.at(0).value<CxeError::Id>(), CxeError::None);
       
    78     QCOMPARE(initModeArguments.at(1).toString(), filename);
       
    79 
       
    80     CX_DEBUG_EXIT_FUNCTION();
       
    81 }
       
    82 
       
    83 
       
    84 // main() function non-GUI testing
       
    85 QTEST_MAIN(UnitTestCxeHarvesterControlSymbian);
       
    86 
       
    87 // End of file