camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxeharvestercontrolsymbian/unittest_cxeharvestercontrolsymbian.cpp
changeset 19 d9aefe59d544
child 37 64817133cd1d
equal deleted inserted replaced
3:8b2d6d0384b0 19:d9aefe59d544
       
     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 
       
    26 UnitTestCxeHarvesterControlSymbian::UnitTestCxeHarvesterControlSymbian()
       
    27 {
       
    28 }
       
    29 
       
    30 
       
    31 UnitTestCxeHarvesterControlSymbian::~UnitTestCxeHarvesterControlSymbian()
       
    32 {
       
    33     cleanup();
       
    34 }
       
    35 
       
    36 
       
    37 void UnitTestCxeHarvesterControlSymbian::init()
       
    38 {
       
    39     mHarvesterControl = new CxeHarvesterControlSymbian();
       
    40 }
       
    41 
       
    42 void UnitTestCxeHarvesterControlSymbian::cleanup()
       
    43 {
       
    44     delete mHarvesterControl;
       
    45     mHarvesterControl = NULL;
       
    46 }
       
    47 
       
    48 void UnitTestCxeHarvesterControlSymbian::testHarvestFile()
       
    49 {
       
    50     CX_DEBUG_ENTER_FUNCTION();
       
    51     
       
    52     QSignalSpy harvestCompleteSpy(mHarvesterControl, SIGNAL(fileHarvested(const QString&, int)));
       
    53     QString filename;
       
    54 
       
    55     QVERIFY(harvestCompleteSpy.isValid()); 
       
    56 
       
    57     // case 1: testing with wrong dummy file, we should get an error code with harvestcomplete
       
    58     // since filename is invalid
       
    59     mHarvesterControl->harvestFile(filename, 0, 0);
       
    60  
       
    61     QCOMPARE( harvestCompleteSpy.count(), 1 );
       
    62     if (harvestCompleteSpy.count() > 0) {
       
    63         QList<QVariant> initModeArguments = harvestCompleteSpy.takeFirst();
       
    64         // we are only interested in error code in this case 1
       
    65         QCOMPARE(initModeArguments.at(1).toInt(), KErrNotFound);
       
    66     }
       
    67 
       
    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     if (harvestCompleteSpy.count() > 0) {
       
    75         QList<QVariant> initModeArguments = harvestCompleteSpy.takeFirst();
       
    76         // we check both the filename, since in this case harvesting should go fine
       
    77         // and error returned is KErrNone.
       
    78         QCOMPARE(initModeArguments.at(1).toString(), filename);
       
    79         QCOMPARE(initModeArguments.at(1).toInt(), KErrNone);
       
    80     }
       
    81 
       
    82     CX_DEBUG_EXIT_FUNCTION();
       
    83 }
       
    84 
       
    85 
       
    86 // main() function non-GUI testing
       
    87 QTEST_MAIN(UnitTestCxeHarvesterControlSymbian);
       
    88 
       
    89 // End of file