camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxefeaturemanagerimp/unittest_cxefeaturemanagerimp.cpp
changeset 37 64817133cd1d
parent 19 d9aefe59d544
child 46 c826656d6714
--- a/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxefeaturemanagerimp/unittest_cxefeaturemanagerimp.cpp	Wed Jun 23 17:59:54 2010 +0300
+++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxefeaturemanagerimp/unittest_cxefeaturemanagerimp.cpp	Tue Jul 06 14:04:02 2010 +0300
@@ -20,6 +20,12 @@
 #include "unittest_cxefeaturemanagerimp.h"
 #include "cxefakesettingsmodel.h"
 #include "cxefeaturemanagerimp.h"
+#include "cxenamespace.h"
+
+
+static const char* INVALID_KEY = "invalid key";
+static const char* EMPTY_KEY = "";
+
 
 UnitTestCxeFeatureManager::UnitTestCxeFeatureManager()
 : mFakeSettingsModel(NULL), mFeatureManager(NULL)
@@ -34,6 +40,7 @@
 // Run before each individual test case
 void UnitTestCxeFeatureManager::init()
 {
+    // fake model contains initialized test data.
     mFakeSettingsModel = new CxeFakeSettingsModel();
     mFeatureManager = new CxeFeatureManagerImp(*mFakeSettingsModel);
 }
@@ -49,34 +56,25 @@
 }
 
 // Testing that isFeatureSupported function returns correct values
-void UnitTestCxeFeatureManager::testSupportedKeys()
+void UnitTestCxeFeatureManager::testIsFeatureSupported()
 {
-    // Create a key that won't be added to test data
-    QString falseKey = QString("testKeyFalse");
     bool isSupported;
     CxeError::Id err;
+    QString key;
 
-    // Test that key that is not added to test data is not found
-    // also boolean value isSupported should return false as key is not found
-    err = mFeatureManager->isFeatureSupported(falseKey, isSupported);
+    // test that invalid key is not found.
+    err = mFeatureManager->isFeatureSupported(INVALID_KEY, isSupported);
+    QVERIFY(!isSupported);
+    QCOMPARE(err, CxeError::NotFound);
+        
+    // try with empty key
+    err = mFeatureManager->isFeatureSupported(EMPTY_KEY, isSupported);
     QVERIFY(!isSupported);
     QCOMPARE(err, CxeError::NotFound);
 
-    // create and set test data with "testKeyTrue" key
-    QString trueKey = QString("testKeyTrue");
-    QList<QVariant> value;
-    value.append(1);
-    value.append(2);
-    value.append(3);
-    mFakeSettingsModel->set(trueKey, value);
-
-    // the false key should return the same values as before adding true key to test data
-    err = mFeatureManager->isFeatureSupported(falseKey, isSupported);
-    QVERIFY(!isSupported);
-    QCOMPARE(err, CxeError::NotFound);
-
-    // check that just added key can be found from test data and no error occurs
-    err = mFeatureManager->isFeatureSupported(trueKey, isSupported);
+    // test with right key
+    key = CxeRuntimeKeys::PRIMARY_CAMERA_CAPTURE_KEYS;
+    err = mFeatureManager->isFeatureSupported(key, isSupported);
     QVERIFY(isSupported);
     QCOMPARE(err, CxeError::None);
 
@@ -84,82 +82,30 @@
 
 // test that configuredValues function returns a correct error code and not any values
 // with any arbitrary key when there is no data set
-void UnitTestCxeFeatureManager::testConfiguredValuesEmptyData()
+void UnitTestCxeFeatureManager::testconfiguredValues()
 {
-    QString falseKey = QString("testKeyFalse");
     QList<int> values;
     CxeError::Id err;
+    QString key;
 
-    // no data
-    err = mFeatureManager->configuredValues(falseKey,values);
+    // case 1: test with invalid key
+    err = mFeatureManager->configuredValues(INVALID_KEY, values);
     QCOMPARE(err, CxeError::NotFound);
     QCOMPARE(values.count(), 0);
-
-}
-
-// test that configuredValues function returns a correct error code and not any values
-// with any arbitrary key when there is data set but not for false key
-void UnitTestCxeFeatureManager::testConfiguredValuesFalseKey()
-{
-    QString falseKey = QString("testKeyFalse");
-    QString trueKey = QString("testKeyTrue");
-    QList<QVariant> value;
-    value.append(1);
-    value.append(2);
-    value.append(3);
-    mFakeSettingsModel->set(trueKey, value);
-
-    CxeError::Id err;
-    QList<int> values;
-
-    // false key
-    err = mFeatureManager->configuredValues(falseKey, values);
+    
+    // case 2: test with empty key
+    err = mFeatureManager->configuredValues(EMPTY_KEY, values);
     QCOMPARE(err, CxeError::NotFound);
-    // as key is not found values list should be empty
     QCOMPARE(values.count(), 0);
+    
+    // case 3: test with right key
+    key = CxeRuntimeKeys::VIDEO_MAX_ZOOM_LIMITS;
+    err = mFeatureManager->configuredValues(key, values);
+    QCOMPARE(err, CxeError::None);
+    QVERIFY(values.count() > 0);
+  
 }
 
-// test data is set with the same key that is used for fetching configured values
-// Now error code should be None as the key should be found from the data
-// Also value count should match with the amount of set values
-void UnitTestCxeFeatureManager::testConfiguredValuesTrueKeyAndData()
-{
-    QString trueKey = QString("testKeyTrue");
-    QList<QVariant> value;
-    // values added to key
-    value.append(1);
-    value.append(2);
-    value.append(3);
-    mFakeSettingsModel->set(trueKey, value);
-
-    CxeError::Id err;
-    QList<int> values;
-
-    // true key
-    err = mFeatureManager->configuredValues(trueKey, values);
-    QCOMPARE(err, CxeError::None);
-    QCOMPARE(values.count(), 3);
-}
-
-// Currently only integer type values can be fetched with configuredValues-function.
-// Test that proper error code is returned when data values are something else than integers
-void UnitTestCxeFeatureManager::testConfiguredValuesFalseData()
-{
-    QString trueKey = QString("testKeyTrue");
-    QList<QVariant> value;
-    value.append(1);
-    value.append(2);
-    value.append(true); // add boolean value which is not supported
-    mFakeSettingsModel->set(trueKey, value);
-
-    CxeError::Id err;
-    QList<int> values;
-
-    // getting configured values should fail as boolean values are not supported
-    err = mFeatureManager->configuredValues(trueKey, values);
-    QCOMPARE(err, CxeError::NotSupported);
-
-}
 
 // main() function non-GUI testing
 QTEST_MAIN(UnitTestCxeFeatureManager);