47 delete mFeatureManager; |
54 delete mFeatureManager; |
48 mFeatureManager = 0; |
55 mFeatureManager = 0; |
49 } |
56 } |
50 |
57 |
51 // Testing that isFeatureSupported function returns correct values |
58 // Testing that isFeatureSupported function returns correct values |
52 void UnitTestCxeFeatureManager::testSupportedKeys() |
59 void UnitTestCxeFeatureManager::testIsFeatureSupported() |
53 { |
60 { |
54 // Create a key that won't be added to test data |
|
55 QString falseKey = QString("testKeyFalse"); |
|
56 bool isSupported; |
61 bool isSupported; |
57 CxeError::Id err; |
62 CxeError::Id err; |
|
63 QString key; |
58 |
64 |
59 // Test that key that is not added to test data is not found |
65 // test that invalid key is not found. |
60 // also boolean value isSupported should return false as key is not found |
66 err = mFeatureManager->isFeatureSupported(INVALID_KEY, isSupported); |
61 err = mFeatureManager->isFeatureSupported(falseKey, isSupported); |
67 QVERIFY(!isSupported); |
|
68 QCOMPARE(err, CxeError::NotFound); |
|
69 |
|
70 // try with empty key |
|
71 err = mFeatureManager->isFeatureSupported(EMPTY_KEY, isSupported); |
62 QVERIFY(!isSupported); |
72 QVERIFY(!isSupported); |
63 QCOMPARE(err, CxeError::NotFound); |
73 QCOMPARE(err, CxeError::NotFound); |
64 |
74 |
65 // create and set test data with "testKeyTrue" key |
75 // test with right key |
66 QString trueKey = QString("testKeyTrue"); |
76 key = CxeRuntimeKeys::PRIMARY_CAMERA_CAPTURE_KEYS; |
67 QList<QVariant> value; |
77 err = mFeatureManager->isFeatureSupported(key, isSupported); |
68 value.append(1); |
|
69 value.append(2); |
|
70 value.append(3); |
|
71 mFakeSettingsModel->set(trueKey, value); |
|
72 |
|
73 // the false key should return the same values as before adding true key to test data |
|
74 err = mFeatureManager->isFeatureSupported(falseKey, isSupported); |
|
75 QVERIFY(!isSupported); |
|
76 QCOMPARE(err, CxeError::NotFound); |
|
77 |
|
78 // check that just added key can be found from test data and no error occurs |
|
79 err = mFeatureManager->isFeatureSupported(trueKey, isSupported); |
|
80 QVERIFY(isSupported); |
78 QVERIFY(isSupported); |
81 QCOMPARE(err, CxeError::None); |
79 QCOMPARE(err, CxeError::None); |
82 |
80 |
83 } |
81 } |
84 |
82 |
85 // test that configuredValues function returns a correct error code and not any values |
83 // test that configuredValues function returns a correct error code and not any values |
86 // with any arbitrary key when there is no data set |
84 // with any arbitrary key when there is no data set |
87 void UnitTestCxeFeatureManager::testConfiguredValuesEmptyData() |
85 void UnitTestCxeFeatureManager::testconfiguredValues() |
88 { |
86 { |
89 QString falseKey = QString("testKeyFalse"); |
|
90 QList<int> values; |
87 QList<int> values; |
91 CxeError::Id err; |
88 CxeError::Id err; |
|
89 QString key; |
92 |
90 |
93 // no data |
91 // case 1: test with invalid key |
94 err = mFeatureManager->configuredValues(falseKey,values); |
92 err = mFeatureManager->configuredValues(INVALID_KEY, values); |
95 QCOMPARE(err, CxeError::NotFound); |
93 QCOMPARE(err, CxeError::NotFound); |
96 QCOMPARE(values.count(), 0); |
94 QCOMPARE(values.count(), 0); |
97 |
95 |
|
96 // case 2: test with empty key |
|
97 err = mFeatureManager->configuredValues(EMPTY_KEY, values); |
|
98 QCOMPARE(err, CxeError::NotFound); |
|
99 QCOMPARE(values.count(), 0); |
|
100 |
|
101 // case 3: test with right key |
|
102 key = CxeRuntimeKeys::VIDEO_MAX_ZOOM_LIMITS; |
|
103 err = mFeatureManager->configuredValues(key, values); |
|
104 QCOMPARE(err, CxeError::None); |
|
105 QVERIFY(values.count() > 0); |
|
106 |
98 } |
107 } |
99 |
108 |
100 // test that configuredValues function returns a correct error code and not any values |
|
101 // with any arbitrary key when there is data set but not for false key |
|
102 void UnitTestCxeFeatureManager::testConfiguredValuesFalseKey() |
|
103 { |
|
104 QString falseKey = QString("testKeyFalse"); |
|
105 QString trueKey = QString("testKeyTrue"); |
|
106 QList<QVariant> value; |
|
107 value.append(1); |
|
108 value.append(2); |
|
109 value.append(3); |
|
110 mFakeSettingsModel->set(trueKey, value); |
|
111 |
|
112 CxeError::Id err; |
|
113 QList<int> values; |
|
114 |
|
115 // false key |
|
116 err = mFeatureManager->configuredValues(falseKey, values); |
|
117 QCOMPARE(err, CxeError::NotFound); |
|
118 // as key is not found values list should be empty |
|
119 QCOMPARE(values.count(), 0); |
|
120 } |
|
121 |
|
122 // test data is set with the same key that is used for fetching configured values |
|
123 // Now error code should be None as the key should be found from the data |
|
124 // Also value count should match with the amount of set values |
|
125 void UnitTestCxeFeatureManager::testConfiguredValuesTrueKeyAndData() |
|
126 { |
|
127 QString trueKey = QString("testKeyTrue"); |
|
128 QList<QVariant> value; |
|
129 // values added to key |
|
130 value.append(1); |
|
131 value.append(2); |
|
132 value.append(3); |
|
133 mFakeSettingsModel->set(trueKey, value); |
|
134 |
|
135 CxeError::Id err; |
|
136 QList<int> values; |
|
137 |
|
138 // true key |
|
139 err = mFeatureManager->configuredValues(trueKey, values); |
|
140 QCOMPARE(err, CxeError::None); |
|
141 QCOMPARE(values.count(), 3); |
|
142 } |
|
143 |
|
144 // Currently only integer type values can be fetched with configuredValues-function. |
|
145 // Test that proper error code is returned when data values are something else than integers |
|
146 void UnitTestCxeFeatureManager::testConfiguredValuesFalseData() |
|
147 { |
|
148 QString trueKey = QString("testKeyTrue"); |
|
149 QList<QVariant> value; |
|
150 value.append(1); |
|
151 value.append(2); |
|
152 value.append(true); // add boolean value which is not supported |
|
153 mFakeSettingsModel->set(trueKey, value); |
|
154 |
|
155 CxeError::Id err; |
|
156 QList<int> values; |
|
157 |
|
158 // getting configured values should fail as boolean values are not supported |
|
159 err = mFeatureManager->configuredValues(trueKey, values); |
|
160 QCOMPARE(err, CxeError::NotSupported); |
|
161 |
|
162 } |
|
163 |
109 |
164 // main() function non-GUI testing |
110 // main() function non-GUI testing |
165 QTEST_MAIN(UnitTestCxeFeatureManager); |
111 QTEST_MAIN(UnitTestCxeFeatureManager); |