camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxefeaturemanagerimp/unittest_cxefeaturemanagerimp.cpp
branchRCL_3
changeset 24 bac7acad7cb3
parent 23 61bc0f252b2b
child 25 2c87b2808fd7
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
     1 /*
       
     2 * Copyright (c) 2009-2010 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 
       
    20 #include "unittest_cxefeaturemanagerimp.h"
       
    21 #include "cxefeaturemanagerimp.h"
       
    22 #include "cxenamespace.h"
       
    23 #include "cxefakesettings.h"
       
    24 
       
    25 static const char* INVALID_KEY = "invalid key";
       
    26 static const char* EMPTY_KEY = "";
       
    27 
       
    28 
       
    29 UnitTestCxeFeatureManager::UnitTestCxeFeatureManager()
       
    30 : mFeatureManager(NULL), mFakeSettings(NULL)
       
    31 {
       
    32 }
       
    33 
       
    34 UnitTestCxeFeatureManager::~UnitTestCxeFeatureManager()
       
    35 {
       
    36 
       
    37 }
       
    38 
       
    39 // Run before each individual test case
       
    40 void UnitTestCxeFeatureManager::init()
       
    41 {
       
    42     mFakeSettings = new CxeFakeSettings();
       
    43     // fake model contains initialized test data.
       
    44     mFeatureManager = new CxeFeatureManagerImp(*mFakeSettings);
       
    45 }
       
    46 
       
    47 // Run after each individual test case
       
    48 void UnitTestCxeFeatureManager::cleanup()
       
    49 {
       
    50     delete mFeatureManager;
       
    51     mFeatureManager = 0;
       
    52     delete mFakeSettings;
       
    53     mFakeSettings = NULL;
       
    54 }
       
    55 
       
    56 // Testing that isFeatureSupported function returns correct values
       
    57 void UnitTestCxeFeatureManager::testIsFeatureSupported()
       
    58 {
       
    59     bool isSupported;
       
    60     CxeError::Id err;
       
    61     QString key;
       
    62 
       
    63     // test that invalid key is not found.
       
    64     err = mFeatureManager->isFeatureSupported(INVALID_KEY, isSupported);
       
    65     QVERIFY(!isSupported);
       
    66     QCOMPARE(err, CxeError::NotFound);
       
    67         
       
    68     // try with empty key
       
    69     err = mFeatureManager->isFeatureSupported(EMPTY_KEY, isSupported);
       
    70     QVERIFY(!isSupported);
       
    71     QCOMPARE(err, CxeError::NotFound);
       
    72 
       
    73     // test with right key
       
    74     key = CxeVariationKeys::STILL_MAX_ZOOM_LIMITS;
       
    75     err = mFeatureManager->isFeatureSupported(key, isSupported);
       
    76     QVERIFY(isSupported);
       
    77     QCOMPARE(err, CxeError::None);
       
    78 
       
    79 }
       
    80 
       
    81 // test that configuredValues function returns a correct error code and not any values
       
    82 // with any arbitrary key when there is no data set
       
    83 void UnitTestCxeFeatureManager::testconfiguredValues()
       
    84 {
       
    85     QList<int> values;
       
    86     CxeError::Id err;
       
    87     QString key;
       
    88 
       
    89     // case 1: test with invalid key
       
    90     err = mFeatureManager->configuredValues(INVALID_KEY, values);
       
    91     QCOMPARE(err, CxeError::NotFound);
       
    92     QCOMPARE(values.count(), 0);
       
    93     
       
    94     // case 2: test with empty key
       
    95     err = mFeatureManager->configuredValues(EMPTY_KEY, values);
       
    96     QCOMPARE(err, CxeError::NotFound);
       
    97     QCOMPARE(values.count(), 0);
       
    98     
       
    99     // case 3: test with right key
       
   100     key = CxeVariationKeys::VIDEO_MAX_ZOOM_LIMITS;
       
   101     err = mFeatureManager->configuredValues(key, values);
       
   102     QCOMPARE(err, CxeError::None);
       
   103     QVERIFY(values.count() > 0);
       
   104   
       
   105 }
       
   106 
       
   107 
       
   108 // main() function non-GUI testing
       
   109 QTEST_MAIN(UnitTestCxeFeatureManager);