camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxestillimagesymbian/unittest_cxestillimagesymbian.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 #include <QTest>
       
    18 
       
    19 #include <QImage>
       
    20 #include "cxutils.h"
       
    21 
       
    22 #include "unittest_cxestillimagesymbian.h"
       
    23 #include "cxestillimagesymbian.h"
       
    24 #include "cxeimagedataitemsymbian.h"
       
    25 
       
    26 // Enums
       
    27 
       
    28 
       
    29 UnitTestCxeStillImageSymbian::UnitTestCxeStillImageSymbian()
       
    30     : mCxeStillImageSymbian(0)
       
    31 {
       
    32 }
       
    33 
       
    34 UnitTestCxeStillImageSymbian::~UnitTestCxeStillImageSymbian()
       
    35 {
       
    36     cleanup();
       
    37 }
       
    38 
       
    39 // Run before each individual test case
       
    40 void UnitTestCxeStillImageSymbian::init()
       
    41 {
       
    42     CX_DEBUG_ENTER_FUNCTION();
       
    43     mCxeStillImageSymbian = new CxeStillImageSymbian();
       
    44     CX_DEBUG_EXIT_FUNCTION();
       
    45 }
       
    46 
       
    47 // Run after each individual test case
       
    48 void UnitTestCxeStillImageSymbian::cleanup()
       
    49 {
       
    50     CX_DEBUG_ENTER_FUNCTION();
       
    51     delete mCxeStillImageSymbian;
       
    52     mCxeStillImageSymbian = 0;
       
    53     CX_DEBUG_EXIT_FUNCTION();
       
    54 }
       
    55 
       
    56 void UnitTestCxeStillImageSymbian::testdataItem()
       
    57 {
       
    58     CX_DEBUG_ENTER_FUNCTION();
       
    59     QVERIFY(!mCxeStillImageSymbian->dataItem());
       
    60     CX_DEBUG_EXIT_FUNCTION();
       
    61 }
       
    62 
       
    63 void UnitTestCxeStillImageSymbian::testfilename()
       
    64 {
       
    65     CX_DEBUG_ENTER_FUNCTION();
       
    66     QVERIFY(mCxeStillImageSymbian->filename() == QString(""));
       
    67     CX_DEBUG_EXIT_FUNCTION();
       
    68 }
       
    69 
       
    70 void UnitTestCxeStillImageSymbian::testsnapshot()
       
    71 {
       
    72     CX_DEBUG_ENTER_FUNCTION();
       
    73     QVERIFY(!mCxeStillImageSymbian->snapshot());
       
    74     CX_DEBUG_EXIT_FUNCTION();
       
    75 }
       
    76 
       
    77 void UnitTestCxeStillImageSymbian::testsaved()
       
    78 {
       
    79     CX_DEBUG_ENTER_FUNCTION();
       
    80     QVERIFY(mCxeStillImageSymbian->saved() == false);
       
    81     CX_DEBUG_EXIT_FUNCTION();
       
    82 }
       
    83 
       
    84 void UnitTestCxeStillImageSymbian::testsetSnapshot()
       
    85 {
       
    86     CX_DEBUG_ENTER_FUNCTION();
       
    87     QVERIFY(!mCxeStillImageSymbian->snapshot());
       
    88 
       
    89     QPixmap snapshot(3,3);
       
    90     mCxeStillImageSymbian->setSnapshot(snapshot);
       
    91     QCOMPARE(mCxeStillImageSymbian->snapshot(), snapshot);
       
    92     CX_DEBUG_EXIT_FUNCTION();
       
    93 }
       
    94 
       
    95 void UnitTestCxeStillImageSymbian::testsetFilename()
       
    96 {
       
    97     CX_DEBUG_ENTER_FUNCTION();
       
    98     QVERIFY(mCxeStillImageSymbian->filename().isEmpty());
       
    99     QString imagename = QString("imagefile01.jpg");
       
   100     mCxeStillImageSymbian->setFilename(imagename);
       
   101     //QVERIFY(mCxeStillImageSymbian->filename().compare(QString("imagefile01.jpg")) == 0);
       
   102     QCOMPARE(mCxeStillImageSymbian->filename(), imagename);
       
   103     CX_DEBUG_EXIT_FUNCTION();
       
   104 }
       
   105 
       
   106 void UnitTestCxeStillImageSymbian::testsetSaved()
       
   107 {
       
   108     CX_DEBUG_ENTER_FUNCTION();
       
   109     QVERIFY(mCxeStillImageSymbian->saved() == false);
       
   110     mCxeStillImageSymbian->setSaved(true);
       
   111     QVERIFY(mCxeStillImageSymbian->saved() == true);
       
   112     CX_DEBUG_EXIT_FUNCTION();
       
   113 }
       
   114 
       
   115 void UnitTestCxeStillImageSymbian::testsetDataItem()
       
   116 {
       
   117     CX_DEBUG_ENTER_FUNCTION();
       
   118     QVERIFY(!mCxeStillImageSymbian->dataItem());
       
   119     QByteArray data("124343423423456e74576");
       
   120     QString path = "\\Images\\Camera\\blaah.jpg";
       
   121     CxeImageDataItemSymbian* dataItem = new CxeImageDataItemSymbian(data, path, mCxeStillImageSymbian->id(), false);
       
   122     mCxeStillImageSymbian->setDataItem(dataItem);
       
   123     QVERIFY(mCxeStillImageSymbian->dataItem() == dataItem);
       
   124     CX_DEBUG_EXIT_FUNCTION();
       
   125 }
       
   126 
       
   127 
       
   128 // main() function
       
   129 // QPixmap needs QApplication for QPaintDevice,
       
   130 // so can't use QTEST_APPLESS_MAIN.
       
   131 QTEST_MAIN(UnitTestCxeStillImageSymbian);
       
   132 
       
   133 // end of file
       
   134