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: Implementation of T_CSPSettings class. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "T_CSPSettings.h" |
|
19 #include <EUnitMacros.h> |
|
20 #include <EUnitDecorators.h> |
|
21 |
|
22 #include <spentry.h> |
|
23 #include <spproperty.h> |
|
24 #include "spsettings.h" |
|
25 #include "TestData.h" |
|
26 |
|
27 // - Construction ----------------------------------------------------------- |
|
28 |
|
29 T_CSPSettings* T_CSPSettings::NewL() |
|
30 { |
|
31 T_CSPSettings* self = T_CSPSettings::NewLC(); |
|
32 CleanupStack::Pop(); |
|
33 return self; |
|
34 } |
|
35 |
|
36 T_CSPSettings* T_CSPSettings::NewLC() |
|
37 { |
|
38 T_CSPSettings* self = new( ELeave ) T_CSPSettings(); |
|
39 CleanupStack::PushL( self ); |
|
40 self->ConstructL(); |
|
41 return self; |
|
42 } |
|
43 |
|
44 T_CSPSettings::~T_CSPSettings() |
|
45 { |
|
46 } |
|
47 |
|
48 T_CSPSettings::T_CSPSettings() |
|
49 { |
|
50 } |
|
51 |
|
52 void T_CSPSettings::ConstructL() |
|
53 { |
|
54 CEUnitTestSuiteClass::ConstructL(); |
|
55 } |
|
56 |
|
57 // - Test methods ----------------------------------------------------------- |
|
58 |
|
59 |
|
60 |
|
61 void T_CSPSettings::SetupL( ) |
|
62 { |
|
63 iCSPSettings = CSPSettings::NewL(); |
|
64 } |
|
65 |
|
66 void T_CSPSettings::Setup2L( ) |
|
67 { |
|
68 TestData::iCheckSupportedCase = ETrue; |
|
69 iCSPSettings = CSPSettings::NewL(); |
|
70 } |
|
71 |
|
72 |
|
73 void T_CSPSettings::Teardown( ) |
|
74 { |
|
75 delete iCSPSettings; |
|
76 iCSPSettings = NULL; |
|
77 } |
|
78 |
|
79 void T_CSPSettings::T_CSPSettings_AddEntryLL( ) |
|
80 { |
|
81 CSPEntry* entry = CSPEntry::NewLC(); |
|
82 User::LeaveIfError( entry->SetServiceName( _L("Nimi") ) ); |
|
83 |
|
84 EUNIT_ASSERT( KErrNone == iCSPSettings->AddEntryL( *entry ) ); |
|
85 |
|
86 CleanupStack::PopAndDestroy( entry ); |
|
87 } |
|
88 |
|
89 void T_CSPSettings::T_CSPSettings_FindEntryLL( ) |
|
90 { |
|
91 CSPEntry* entry = CSPEntry::NewLC(); |
|
92 User::LeaveIfError( entry->SetServiceName( _L("Nimi") ) ); |
|
93 TInt id = entry->GetServiceId(); |
|
94 |
|
95 EUNIT_ASSERT( KErrNotFound == iCSPSettings->FindEntryL( id, *entry ) ); |
|
96 |
|
97 iCSPSettings->AddEntryL( *entry ); |
|
98 id = entry->GetServiceId(); |
|
99 EUNIT_ASSERT( KErrNone == iCSPSettings->FindEntryL( id, *entry ) ); |
|
100 |
|
101 CleanupStack::PopAndDestroy( entry ); |
|
102 } |
|
103 |
|
104 void T_CSPSettings::T_CSPSettings_UpdateEntryLL( ) |
|
105 { |
|
106 CSPEntry* entry = CSPEntry::NewLC(); |
|
107 |
|
108 EUNIT_ASSERT_LEAVE( iCSPSettings->UpdateEntryL( *entry ) ); |
|
109 |
|
110 User::LeaveIfError( entry->SetServiceName( _L("Nimi") ) ); |
|
111 iCSPSettings->AddEntryL( *entry ); |
|
112 EUNIT_ASSERT( KErrNone == iCSPSettings->UpdateEntryL( *entry ) ); |
|
113 |
|
114 CleanupStack::PopAndDestroy( entry ); |
|
115 } |
|
116 |
|
117 void T_CSPSettings::T_CSPSettings_DeleteEntryLL( ) |
|
118 { |
|
119 CSPEntry* entry = CSPEntry::NewLC(); |
|
120 User::LeaveIfError( entry->SetServiceName( _L("Nimi") ) ); |
|
121 TInt id = entry->GetServiceId(); |
|
122 |
|
123 EUNIT_ASSERT( KErrNotFound == iCSPSettings->DeleteEntryL( id ) ); |
|
124 |
|
125 iCSPSettings->AddEntryL( *entry ); |
|
126 id = entry->GetServiceId(); |
|
127 EUNIT_ASSERT( KErrNone == iCSPSettings->DeleteEntryL( id ) ); |
|
128 CleanupStack::PopAndDestroy( entry ); |
|
129 } |
|
130 |
|
131 void T_CSPSettings::T_CSPSettings_FindPropertyLL( ) |
|
132 { |
|
133 CSPProperty* property = CSPProperty::NewLC(); |
|
134 property->SetName( EPropertyVoIPSubServicePluginId ); |
|
135 TInt profId( 15 ); |
|
136 User::LeaveIfError( property->SetValue( profId )); |
|
137 |
|
138 EUNIT_ASSERT( KErrNotFound == iCSPSettings->FindPropertyL( |
|
139 0, EPropertyVoIPSubServicePluginId, *property ) ); |
|
140 |
|
141 EUNIT_ASSERT( KErrNone == iCSPSettings->FindPropertyL( |
|
142 profId, EPropertyVoIPSubServicePluginId, *property ) ); |
|
143 |
|
144 CleanupStack::PopAndDestroy( property ); |
|
145 } |
|
146 |
|
147 void T_CSPSettings::T_CSPSettings_AddOrUpdatePropertiesLL( ) |
|
148 { |
|
149 // iCSPSettings->AddOrUpdatePropertiesL( <add parameters here > ); |
|
150 EUNIT_ASSERT_DESC( EFalse, "Generated assert, replace with real"); |
|
151 } |
|
152 |
|
153 void T_CSPSettings::T_CSPSettings_AddOrUpdatePropertyLL( ) |
|
154 { |
|
155 CSPProperty* property = CSPProperty::NewLC(); |
|
156 property->SetName( EPropertyVoIPSubServicePluginId ); |
|
157 TInt profId( 15 ); |
|
158 User::LeaveIfError( property->SetValue( profId )); |
|
159 |
|
160 EUNIT_ASSERT( KErrNone == iCSPSettings->AddOrUpdatePropertyL( profId, *property ) ); |
|
161 |
|
162 CleanupStack::PopAndDestroy( property ); |
|
163 } |
|
164 |
|
165 void T_CSPSettings::T_CSPSettings_SettingsCountLL( ) |
|
166 { |
|
167 TInt count = iCSPSettings->SettingsCountL( ); |
|
168 EUNIT_ASSERT( count ); |
|
169 } |
|
170 |
|
171 void T_CSPSettings::T_CSPSettings_FindServiceIdsLL( ) |
|
172 { |
|
173 RIdArray ids; |
|
174 CleanupClosePushL( ids ); |
|
175 |
|
176 EUNIT_ASSERT( KErrNone == iCSPSettings->FindServiceIdsL( ids ) ); |
|
177 TInt count( ids.Count() ); |
|
178 EUNIT_ASSERT( count ); |
|
179 |
|
180 CleanupStack::PopAndDestroy( &ids ); |
|
181 } |
|
182 |
|
183 void T_CSPSettings::T_CSPSettings_FindServiceNamesLL( ) |
|
184 { |
|
185 RIdArray ids; |
|
186 CleanupClosePushL( ids ); |
|
187 iCSPSettings->FindServiceIdsL( ids ); |
|
188 |
|
189 CDesCArrayFlat* names = new ( ELeave ) CDesCArrayFlat( 10 ); |
|
190 CleanupStack::PushL( names ); |
|
191 EUNIT_ASSERT( KErrNone == iCSPSettings->FindServiceNamesL( ids, *names ) ); |
|
192 TInt count = names->MdcaCount(); |
|
193 EUNIT_ASSERT( count ); |
|
194 |
|
195 CleanupStack::PopAndDestroy( names ); |
|
196 CleanupStack::PopAndDestroy( &ids ); |
|
197 } |
|
198 |
|
199 void T_CSPSettings::T_CSPSettings_FindSubServicePropertiesLL( ) |
|
200 { |
|
201 RPropertyArray* propertyArray = new (ELeave) RPropertyArray( 3 ); |
|
202 CleanupStack::PushL( propertyArray ); |
|
203 |
|
204 iCSPSettings->FindSubServicePropertiesL( 0, EItemTypeVMBXSubProperty, *propertyArray ); |
|
205 TInt count = propertyArray->Count(); |
|
206 EUNIT_ASSERT( !count ); |
|
207 |
|
208 CleanupStack::PopAndDestroy( propertyArray ); |
|
209 } |
|
210 |
|
211 void T_CSPSettings::T_CSPSettings_DeleteServicePropertiesLL( ) |
|
212 { |
|
213 RPropertyNameArray names; |
|
214 CleanupClosePushL( names ); |
|
215 |
|
216 EUNIT_ASSERT( KErrNone == iCSPSettings->DeleteServicePropertiesL( 0, names ) ); |
|
217 |
|
218 CleanupStack::PopAndDestroy( &names ); |
|
219 } |
|
220 |
|
221 void T_CSPSettings::T_CSPSettings_FindServiceIdsFromPropertiesLL( ) |
|
222 { |
|
223 RIdArray serviceIds; |
|
224 CleanupClosePushL( serviceIds ); |
|
225 RPropertyArray properties; |
|
226 CleanupClosePushL( properties ); |
|
227 |
|
228 EUNIT_ASSERT( KErrNone == iCSPSettings->FindServiceIdsFromPropertiesL( properties, serviceIds ) ); |
|
229 |
|
230 CleanupStack::PopAndDestroy( &properties ); |
|
231 CleanupStack::PopAndDestroy( &serviceIds ); |
|
232 } |
|
233 |
|
234 void T_CSPSettings::T_CSPSettings_GetSIPVoIPSWVersionL( ) |
|
235 { |
|
236 EUNIT_ASSERT( _L("3.1") == iCSPSettings->GetSIPVoIPSWVersion() ); |
|
237 } |
|
238 |
|
239 void T_CSPSettings::T_CSPSettings_IsFeatureSupportedL( ) |
|
240 { |
|
241 EUNIT_ASSERT( !iCSPSettings->IsFeatureSupported( ESupportInternetCallFeature ) ); |
|
242 } |
|
243 |
|
244 void T_CSPSettings::T_CSPSettings_CheckSupportedLsL( ) |
|
245 { |
|
246 // Test CheckSupportedL( TServiceId aServiceId, const RPropertyNameArray& aNameArray ) |
|
247 |
|
248 CSPProperty* property = CSPProperty::NewLC(); |
|
249 iCSPSettings->FindPropertyL( 0, EPropertyVoIPSubServicePluginId, *property ); |
|
250 iCSPSettings->FindPropertyL( 2, EPropertyVoIPSubServicePluginId, *property ); |
|
251 CleanupStack::PopAndDestroy( property ); |
|
252 |
|
253 |
|
254 // Test CheckSupportedL( TServiceId aServiceId ) |
|
255 |
|
256 CSPEntry* entry = CSPEntry::NewLC(); |
|
257 iCSPSettings->FindEntryL( 0, *entry ); |
|
258 entry->SetServiceId( 2 ); |
|
259 iCSPSettings->FindEntryL( 2, *entry ); |
|
260 CleanupStack::PopAndDestroy( entry ); |
|
261 |
|
262 |
|
263 // Test CheckSupportedL( TSPItemType aPropertyType ) |
|
264 |
|
265 RPropertyArray* propertyArray = new (ELeave) RPropertyArray( 3 ); |
|
266 CleanupStack::PushL( propertyArray ); |
|
267 iCSPSettings->FindSubServicePropertiesL( 0, EItemTypeVMBXSubProperty, *propertyArray ); |
|
268 |
|
269 |
|
270 // Test CheckSupportedL( const RPropertyArray& aPropertyArray ) |
|
271 |
|
272 RIdArray serviceIds; |
|
273 CleanupClosePushL( serviceIds ); |
|
274 iCSPSettings->FindServiceIdsFromPropertiesL( *propertyArray, serviceIds ); |
|
275 |
|
276 CleanupStack::PopAndDestroy( &serviceIds ); |
|
277 CleanupStack::PopAndDestroy( propertyArray ); |
|
278 } |
|
279 |
|
280 |
|
281 // - EUnit test table ------------------------------------------------------- |
|
282 |
|
283 EUNIT_BEGIN_TEST_TABLE( |
|
284 T_CSPSettings, |
|
285 "Add test suite description here.", |
|
286 "UNIT" ) |
|
287 |
|
288 EUNIT_TEST( |
|
289 "AddEntryL - test", |
|
290 "CSPSettings", |
|
291 "AddEntryL - test", |
|
292 "FUNCTIONALITY", |
|
293 SetupL, T_CSPSettings_AddEntryLL, Teardown) |
|
294 |
|
295 EUNIT_TEST( |
|
296 "FindEntryL - test", |
|
297 "CSPSettings", |
|
298 "FindEntryL - test", |
|
299 "FUNCTIONALITY", |
|
300 SetupL, T_CSPSettings_FindEntryLL, Teardown) |
|
301 |
|
302 EUNIT_TEST( |
|
303 "UpdateEntryL - test", |
|
304 "CSPSettings", |
|
305 "UpdateEntryL - test", |
|
306 "FUNCTIONALITY", |
|
307 SetupL, T_CSPSettings_UpdateEntryLL, Teardown) |
|
308 |
|
309 EUNIT_TEST( |
|
310 "DeleteEntryL - test", |
|
311 "CSPSettings", |
|
312 "DeleteEntryL - test", |
|
313 "FUNCTIONALITY", |
|
314 SetupL, T_CSPSettings_DeleteEntryLL, Teardown) |
|
315 |
|
316 EUNIT_TEST( |
|
317 "FindPropertyL - test", |
|
318 "CSPSettings", |
|
319 "FindPropertyL - test", |
|
320 "FUNCTIONALITY", |
|
321 SetupL, T_CSPSettings_FindPropertyLL, Teardown) |
|
322 /* |
|
323 EUNIT_TEST( |
|
324 "AddOrUpdatePropertiesL - test", |
|
325 "CSPSettings", |
|
326 "AddOrUpdatePropertiesL - test", |
|
327 "FUNCTIONALITY", |
|
328 SetupL, T_CSPSettings_AddOrUpdatePropertiesLL, Teardown) |
|
329 */ |
|
330 EUNIT_TEST( |
|
331 "AddOrUpdatePropertyL - test", |
|
332 "CSPSettings", |
|
333 "AddOrUpdatePropertyL - test", |
|
334 "FUNCTIONALITY", |
|
335 SetupL, T_CSPSettings_AddOrUpdatePropertyLL, Teardown) |
|
336 |
|
337 EUNIT_TEST( |
|
338 "SettingsCountL - test", |
|
339 "CSPSettings", |
|
340 "SettingsCountL - test", |
|
341 "FUNCTIONALITY", |
|
342 SetupL, T_CSPSettings_SettingsCountLL, Teardown) |
|
343 |
|
344 EUNIT_TEST( |
|
345 "FindServiceIdsL - test", |
|
346 "CSPSettings", |
|
347 "FindServiceIdsL - test", |
|
348 "FUNCTIONALITY", |
|
349 SetupL, T_CSPSettings_FindServiceIdsLL, Teardown) |
|
350 |
|
351 EUNIT_TEST( |
|
352 "FindServiceNamesL - test", |
|
353 "CSPSettings", |
|
354 "FindServiceNamesL - test", |
|
355 "FUNCTIONALITY", |
|
356 SetupL, T_CSPSettings_FindServiceNamesLL, Teardown) |
|
357 |
|
358 EUNIT_TEST( |
|
359 "FindSubServicePropertiesL - test", |
|
360 "CSPSettings", |
|
361 "FindSubServicePropertiesL - test", |
|
362 "FUNCTIONALITY", |
|
363 SetupL, T_CSPSettings_FindSubServicePropertiesLL, Teardown) |
|
364 |
|
365 EUNIT_TEST( |
|
366 "DeleteServicePropertiesL - test", |
|
367 "CSPSettings", |
|
368 "DeleteServicePropertiesL - test", |
|
369 "FUNCTIONALITY", |
|
370 SetupL, T_CSPSettings_DeleteServicePropertiesLL, Teardown) |
|
371 |
|
372 EUNIT_TEST( |
|
373 "FindServiceIdsFromPropertiesL - test", |
|
374 "CSPSettings", |
|
375 "FindServiceIdsFromPropertiesL - test", |
|
376 "FUNCTIONALITY", |
|
377 SetupL, T_CSPSettings_FindServiceIdsFromPropertiesLL, Teardown) |
|
378 |
|
379 EUNIT_TEST( |
|
380 "GetSIPVoIPSWVersion - test", |
|
381 "CSPSettings", |
|
382 "GetSIPVoIPSWVersion - test", |
|
383 "FUNCTIONALITY", |
|
384 SetupL, T_CSPSettings_GetSIPVoIPSWVersionL, Teardown) |
|
385 |
|
386 EUNIT_TEST( |
|
387 "IsFeatureSupported - test", |
|
388 "CSPSettings", |
|
389 "IsFeatureSupported - test", |
|
390 "FUNCTIONALITY", |
|
391 SetupL, T_CSPSettings_IsFeatureSupportedL, Teardown) |
|
392 |
|
393 EUNIT_TEST( |
|
394 "CheckSupportedLs - test", |
|
395 "CSPSettings", |
|
396 "CheckSupportedLs - test", |
|
397 "FUNCTIONALITY", |
|
398 Setup2L, T_CSPSettings_CheckSupportedLsL, Teardown) |
|
399 |
|
400 EUNIT_END_TEST_TABLE |
|