camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxethumbnailmanagersymbian/unittest_cxethumbnailmanagersymbian.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 
       
    21 #include "unittest_cxethumbnailmanagersymbian.h"
       
    22 #include "cxethumbnailmanagersymbian.h"
       
    23 #include "cxutils.h"
       
    24 
       
    25 UnitTestCxeThumbnailManagerSymbian::UnitTestCxeThumbnailManagerSymbian()
       
    26 {
       
    27 }
       
    28 
       
    29 
       
    30 UnitTestCxeThumbnailManagerSymbian::~UnitTestCxeThumbnailManagerSymbian()
       
    31 {
       
    32     cleanup();
       
    33 }
       
    34 
       
    35 
       
    36 void UnitTestCxeThumbnailManagerSymbian::init()
       
    37 {
       
    38     mThumbnailManager = new CxeThumbnailManagerSymbian();
       
    39 }
       
    40 
       
    41 void UnitTestCxeThumbnailManagerSymbian::cleanup()
       
    42 {
       
    43     delete mThumbnailManager;
       
    44     mThumbnailManager = NULL;
       
    45 }
       
    46 
       
    47 void UnitTestCxeThumbnailManagerSymbian::testCreateThumbnail()
       
    48 {
       
    49     CX_DEBUG_ENTER_FUNCTION();
       
    50 
       
    51     QSignalSpy thumbnailReadySpy(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, int)));
       
    52     QString filename;
       
    53 
       
    54     QVERIFY(thumbnailReadySpy.isValid()); 
       
    55 
       
    56     // case 1: testing with wrong dummy file, we should get an error code with thumbnailready
       
    57     // since filename is invalid
       
    58     mThumbnailManager->createThumbnail(filename, QPixmap());
       
    59  
       
    60     QCOMPARE(thumbnailReadySpy.count(), 1 );
       
    61     if (thumbnailReadySpy.count() > 0) {
       
    62         QList<QVariant> initModeArguments = thumbnailReadySpy.takeFirst();
       
    63         // we are only interested in error code in this case 1
       
    64         QCOMPARE(initModeArguments.at(1).toInt(), KErrNotFound);
       
    65     }
       
    66 
       
    67     // case 1: testing with proper file name, we shouldnt get an error code with thumbnailready
       
    68     // since filename is valid
       
    69     filename = QString("c:\\test.jpg");    
       
    70     mThumbnailManager->createThumbnail(filename, QPixmap());
       
    71  
       
    72     QCOMPARE( thumbnailReadySpy.count(), 1 );
       
    73     if (thumbnailReadySpy.count() > 0) {
       
    74         QList<QVariant> initModeArguments = thumbnailReadySpy.takeFirst();
       
    75         // we are only interested in error code in this case 1
       
    76         QCOMPARE(initModeArguments.at(1).toInt(), KErrNone);
       
    77     }
       
    78 
       
    79     CX_DEBUG_EXIT_FUNCTION();
       
    80 }
       
    81 
       
    82 
       
    83 void UnitTestCxeThumbnailManagerSymbian::testCancelThumbnail()
       
    84 {
       
    85     CX_DEBUG_ENTER_FUNCTION();
       
    86 
       
    87     mThumbnailManager->cancelThumbnail(QString("filename"));
       
    88 
       
    89     CX_DEBUG_EXIT_FUNCTION();
       
    90 }
       
    91 
       
    92 // main() function non-GUI testing
       
    93 QTEST_MAIN(UnitTestCxeThumbnailManagerSymbian);
       
    94 
       
    95 // End of file