1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <commdbconnpref.h> |
|
17 #include <e32test.h> |
|
18 |
|
19 #include "TS_ConnPrefSteps.h" |
|
20 |
|
21 CTS_ConstructAndVersion::CTS_ConstructAndVersion() |
|
22 { |
|
23 iTestStepName = KConstructAndVersion; |
|
24 } |
|
25 |
|
26 CTS_ConstructAndVersion::~CTS_ConstructAndVersion() |
|
27 { |
|
28 } |
|
29 |
|
30 enum TVerdict CTS_ConstructAndVersion::doTestStepL() |
|
31 { |
|
32 |
|
33 TCommDbConnPref connPref; |
|
34 |
|
35 Test(connPref.ExtensionId() == TConnPref::EConnPrefCommDb); |
|
36 TVersion ver = connPref.Version(); |
|
37 Test(ver.iMajor == TCommDbMultiConnPref::KMajorVersionNumber); |
|
38 Test(ver.iMinor == TCommDbMultiConnPref::TCommDbMultiConnPref::KMinorVersionNumber); |
|
39 Test(ver.iBuild == TCommDbMultiConnPref::TCommDbMultiConnPref::KBuildVersionNumber); |
|
40 Test(connPref.BearerSet() == KCommDbBearerUnknown); |
|
41 Test(connPref.DialogPreference() == ECommDbDialogPrefUnknown); |
|
42 Test(connPref.Direction() == ECommDbConnectionDirectionUnknown); |
|
43 Test(connPref.IapId() == 0); |
|
44 Test(connPref.NetId() == 0); |
|
45 |
|
46 return EPass; |
|
47 } |
|
48 |
|
49 CTS_SetAndGetConnPrefs::CTS_SetAndGetConnPrefs() |
|
50 { |
|
51 iTestStepName = KSetAndGetConnPrefs; |
|
52 } |
|
53 |
|
54 CTS_SetAndGetConnPrefs::~CTS_SetAndGetConnPrefs() |
|
55 { |
|
56 } |
|
57 |
|
58 enum TVerdict CTS_SetAndGetConnPrefs::doTestStepL() |
|
59 { |
|
60 |
|
61 TCommDbConnPref connPref; |
|
62 |
|
63 connPref.SetBearerSet((KCommDbBearerWcdma | KCommDbBearerLAN)); |
|
64 Test(connPref.BearerSet() == (KCommDbBearerWcdma | KCommDbBearerLAN)); |
|
65 |
|
66 connPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); |
|
67 Test(connPref.DialogPreference() == ECommDbDialogPrefDoNotPrompt); |
|
68 |
|
69 connPref.SetDirection(ECommDbConnectionDirectionOutgoing); |
|
70 Test(connPref.Direction() == ECommDbConnectionDirectionOutgoing); |
|
71 |
|
72 connPref.SetIapId(123); |
|
73 Test(connPref.IapId() == 123); |
|
74 |
|
75 connPref.SetNetId(456); |
|
76 Test(connPref.NetId() == 456); |
|
77 |
|
78 return EPass; |
|
79 } |
|
80 |
|
81 |
|
82 CTS_ComparePrefs::CTS_ComparePrefs() |
|
83 { |
|
84 iTestStepName = KComparePrefs; |
|
85 } |
|
86 |
|
87 CTS_ComparePrefs::~CTS_ComparePrefs() |
|
88 { |
|
89 } |
|
90 |
|
91 enum TVerdict CTS_ComparePrefs::doTestStepL() |
|
92 { |
|
93 |
|
94 TCommDbConnPref connPref1; |
|
95 connPref1.SetBearerSet((KCommDbBearerWcdma | KCommDbBearerLAN)); |
|
96 connPref1.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); |
|
97 connPref1.SetDirection(ECommDbConnectionDirectionOutgoing); |
|
98 connPref1.SetIapId(123); |
|
99 connPref1.SetNetId(456); |
|
100 |
|
101 TCommDbConnPref connPref2; |
|
102 connPref2.SetBearerSet((KCommDbBearerWcdma | KCommDbBearerLAN)); |
|
103 connPref2.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); |
|
104 connPref2.SetDirection(ECommDbConnectionDirectionOutgoing); |
|
105 connPref2.SetIapId(123); |
|
106 connPref2.SetNetId(456); |
|
107 |
|
108 TCommDbConnPref connPref3; |
|
109 connPref3.SetBearerSet(KCommDbBearerCSD); |
|
110 connPref3.SetDialogPreference(ECommDbDialogPrefWarn); |
|
111 connPref3.SetDirection(ECommDbConnectionDirectionIncoming); |
|
112 connPref3.SetIapId(987); |
|
113 connPref3.SetNetId(654); |
|
114 |
|
115 TCommDbConnPref connPref4; |
|
116 connPref4.SetBearerSet(KCommDbBearerCSD); |
|
117 connPref4.SetDirection(ECommDbConnectionDirectionIncoming); |
|
118 connPref4.SetNetId(654); |
|
119 |
|
120 Test(connPref2.Compare(connPref1) == 0); |
|
121 Test(connPref2 == connPref1); |
|
122 |
|
123 Test(connPref1.Compare(connPref2) == 0); |
|
124 Test(connPref1 == connPref2); |
|
125 |
|
126 Test(connPref1.Compare(connPref1) == 0); |
|
127 Test(connPref1 == connPref1); |
|
128 |
|
129 Test(connPref3.Compare(connPref1) != 0); |
|
130 Test(connPref3 != connPref1); |
|
131 |
|
132 Test(connPref1.Compare(connPref3) != 0); |
|
133 Test(connPref1 != connPref3); |
|
134 |
|
135 Test(connPref4 == connPref3); |
|
136 Test(connPref3 == connPref4); |
|
137 |
|
138 Test(connPref4 != connPref2); |
|
139 Test(connPref2 != connPref4); |
|
140 |
|
141 return EPass; |
|
142 } |
|
143 |
|
144 CTS_AssignAndCopyConstruct::CTS_AssignAndCopyConstruct() |
|
145 { |
|
146 iTestStepName = KAssignAndCopyConstruct; |
|
147 } |
|
148 |
|
149 CTS_AssignAndCopyConstruct::~CTS_AssignAndCopyConstruct() |
|
150 { |
|
151 } |
|
152 |
|
153 enum TVerdict CTS_AssignAndCopyConstruct::doTestStepL() |
|
154 { |
|
155 |
|
156 TCommDbConnPref connPref1; |
|
157 connPref1.SetBearerSet((KCommDbBearerWcdma | KCommDbBearerLAN)); |
|
158 connPref1.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); |
|
159 connPref1.SetDirection(ECommDbConnectionDirectionOutgoing); |
|
160 connPref1.SetIapId(123); |
|
161 connPref1.SetNetId(456); |
|
162 |
|
163 TCommDbConnPref connPref2(connPref1); |
|
164 Test(connPref2.Compare(connPref1) == 0); |
|
165 Test(connPref1.Compare(connPref2) == 0); |
|
166 |
|
167 TCommDbConnPref connPref3 = connPref1; |
|
168 Test(connPref3.Compare(connPref1) == 0); |
|
169 Test(connPref1.Compare(connPref3) == 0); |
|
170 |
|
171 TCommDbConnPref connPref4; |
|
172 connPref4 = connPref1; |
|
173 Test(connPref4.Compare(connPref1) == 0); |
|
174 Test(connPref1.Compare(connPref4) == 0); |
|
175 |
|
176 return EPass; |
|
177 } |
|
178 |
|
179 CTS_ExtensionIdAndCast::CTS_ExtensionIdAndCast() |
|
180 { |
|
181 iTestStepName = KExtensionIdAndCast; |
|
182 } |
|
183 |
|
184 CTS_ExtensionIdAndCast::~CTS_ExtensionIdAndCast() |
|
185 { |
|
186 } |
|
187 |
|
188 enum TVerdict CTS_ExtensionIdAndCast::doTestStepL() |
|
189 { |
|
190 |
|
191 TCommDbConnPref commdbPref1; |
|
192 commdbPref1.SetBearerSet((KCommDbBearerWcdma | KCommDbBearerLAN)); |
|
193 commdbPref1.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); |
|
194 commdbPref1.SetDirection(ECommDbConnectionDirectionOutgoing); |
|
195 commdbPref1.SetIapId(123); |
|
196 commdbPref1.SetNetId(456); |
|
197 |
|
198 TConnPref basePref(commdbPref1); |
|
199 Test(basePref.ExtensionId() == TConnPref::EConnPrefCommDb); |
|
200 |
|
201 TCommDbConnPref commdbPref2 = TCommDbConnPref::Cast(basePref); |
|
202 Test(commdbPref2 == commdbPref1); |
|
203 |
|
204 return EPass; |
|
205 } |
|
206 |
|
207 |
|
208 CTS_MultiConnPref::CTS_MultiConnPref() |
|
209 { |
|
210 iTestStepName = KMultiConnPref; |
|
211 } |
|
212 |
|
213 CTS_MultiConnPref::~CTS_MultiConnPref() |
|
214 { |
|
215 } |
|
216 |
|
217 enum TVerdict CTS_MultiConnPref::doTestStepL() |
|
218 { |
|
219 |
|
220 TCommDbConnPref connPref1; |
|
221 connPref1.SetBearerSet((KCommDbBearerWcdma | KCommDbBearerLAN)); |
|
222 connPref1.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); |
|
223 connPref1.SetDirection(ECommDbConnectionDirectionOutgoing); |
|
224 connPref1.SetIapId(123); |
|
225 connPref1.SetNetId(456); |
|
226 |
|
227 TCommDbConnPref connPref2; |
|
228 connPref2.SetBearerSet(KCommDbBearerCSD); |
|
229 connPref2.SetDialogPreference(ECommDbDialogPrefWarn); |
|
230 connPref2.SetDirection(ECommDbConnectionDirectionIncoming); |
|
231 connPref2.SetIapId(987); |
|
232 connPref2.SetNetId(654); |
|
233 |
|
234 TCommDbMultiConnPref multiPref; |
|
235 TInt err(KErrNone); |
|
236 |
|
237 err = multiPref.SetPreference(0, connPref1); |
|
238 Test(err == KErrArgument); |
|
239 |
|
240 err = multiPref.SetPreference(1, connPref1); |
|
241 Test(err == KErrNone); |
|
242 |
|
243 err = multiPref.SetPreference(2, connPref2); |
|
244 Test(err == KErrNone); |
|
245 |
|
246 err = multiPref.SetPreference(3, connPref2); |
|
247 Test(err == KErrArgument); |
|
248 |
|
249 TCommDbConnPref connPref3; |
|
250 |
|
251 err = multiPref.GetPreference(0, connPref3); |
|
252 Test(err == KErrArgument); |
|
253 |
|
254 err = multiPref.GetPreference(1, connPref3); |
|
255 Test(err == KErrNone); |
|
256 Test(connPref3 == connPref1); |
|
257 |
|
258 err = multiPref.GetPreference(2, connPref3); |
|
259 Test(err == KErrNone); |
|
260 Test(connPref3 == connPref2); |
|
261 |
|
262 err = multiPref.GetPreference(3, connPref3); |
|
263 Test(err == KErrArgument); |
|
264 |
|
265 TConnPref basePref(multiPref); |
|
266 Test(basePref.ExtensionId() == TConnPref::EConnPrefCommDbMulti); |
|
267 |
|
268 TCommDbMultiConnPref multiPref2; |
|
269 TCommDbConnPref connPref4; |
|
270 err = multiPref2.GetPreference(1, connPref4); |
|
271 Test(err == KErrNone); |
|
272 Test(connPref4 == connPref1); |
|
273 |
|
274 TCommDbConnPref connPref5; |
|
275 err = multiPref2.GetPreference(2, connPref5); |
|
276 Test(err == KErrNone); |
|
277 Test(connPref5 == connPref2); |
|
278 |
|
279 Test(multiPref.ConnectionAttempts()==TCommDbMultiConnPref::KMaxMultiConnPrefCount); |
|
280 |
|
281 multiPref.SetConnectionAttempts(0); |
|
282 Test(multiPref.ConnectionAttempts()==TCommDbMultiConnPref::KMaxMultiConnPrefCount); |
|
283 |
|
284 multiPref.SetConnectionAttempts(1); |
|
285 Test(multiPref.ConnectionAttempts()==1); |
|
286 |
|
287 multiPref.SetConnectionAttempts(2); |
|
288 Test(multiPref.ConnectionAttempts()==2); |
|
289 |
|
290 multiPref.SetConnectionAttempts(TCommDbMultiConnPref::KMaxMultiConnPrefCount+1); |
|
291 Test(multiPref.ConnectionAttempts()==TCommDbMultiConnPref::KMaxMultiConnPrefCount); |
|
292 |
|
293 return EPass; |
|
294 } |
|
295 |
|
296 // |
|
297 // Test step CTS_MultiConnPrefVersion |
|
298 // |
|
299 |
|
300 // constructor |
|
301 CTS_MultiConnPrefVersion::CTS_MultiConnPrefVersion() |
|
302 { |
|
303 // store the name of this test case |
|
304 iTestStepName = KMultiConnPrefVersion; |
|
305 } |
|
306 |
|
307 // destructor |
|
308 CTS_MultiConnPrefVersion::~CTS_MultiConnPrefVersion() |
|
309 { |
|
310 } |
|
311 |
|
312 // do Test step CTS_MultiConnPrefVersion |
|
313 TVerdict CTS_MultiConnPrefVersion::doTestStepL() |
|
314 { |
|
315 Log(_L("CTS_MultiConnPrefVersion called ")); |
|
316 iTestStepResult = EFail; |
|
317 TCommDbMultiConnPref pref; |
|
318 TVersion dbVersion = pref.Version(); |
|
319 Log(_L("TCommDbMultiConnPref::Version -> Major=%d, Minor=%d, Build=%d"), TCommDbMultiConnPref::KMajorVersionNumber, TCommDbMultiConnPref::KMinorVersionNumber, TCommDbMultiConnPref::KBuildVersionNumber); |
|
320 //Test for the expected return value |
|
321 if ( dbVersion.iMinor == TCommDbMultiConnPref::KMinorVersionNumber && |
|
322 dbVersion.iMajor == TCommDbMultiConnPref::KMajorVersionNumber && |
|
323 dbVersion.iBuild == TCommDbMultiConnPref::KBuildVersionNumber ) |
|
324 { |
|
325 iTestStepResult = EPass; |
|
326 } |
|
327 return iTestStepResult; |
|
328 } |
|
329 |
|
330 |
|
331 // |
|
332 // Test step CTS_MultiConnectionAttempts |
|
333 // |
|
334 |
|
335 // constructor |
|
336 CTS_MultiConnectionAttempts::CTS_MultiConnectionAttempts() |
|
337 { |
|
338 // store the name of this test case |
|
339 iTestStepName = KMultiConnectionAttempts; |
|
340 } |
|
341 |
|
342 // destructor |
|
343 CTS_MultiConnectionAttempts::~CTS_MultiConnectionAttempts() |
|
344 { |
|
345 } |
|
346 |
|
347 // do Test step CTS_MultiConnectionAttempts |
|
348 TVerdict CTS_MultiConnectionAttempts::doTestStepL( ) |
|
349 { |
|
350 Log(_L("Step CTS_MultiConnectionAttempts called ")); |
|
351 iTestStepResult = EFail; |
|
352 TCommDbMultiConnPref prefPtr; |
|
353 TInt numAttempts = prefPtr.ConnectionAttempts(); |
|
354 Log(_L("Expected NumAttempts:= %d, Actual NumAttempts:=%d"), TCommDbMultiConnPref::KMaxMultiConnPrefCount,numAttempts); |
|
355 if(numAttempts != TCommDbMultiConnPref::KMaxMultiConnPrefCount ) |
|
356 { |
|
357 return iTestStepResult; |
|
358 } |
|
359 numAttempts = 3 ; |
|
360 prefPtr.SetConnectionAttempts(numAttempts); |
|
361 TInt attempsCheck = prefPtr.ConnectionAttempts(); |
|
362 Log(_L("Expected NumAttempts:= %d, Actual NumAttempts:=%d"), TCommDbMultiConnPref::KMaxMultiConnPrefCount,attempsCheck); |
|
363 Log(_L("This test fails because no. of attempts is > 2")); |
|
364 if(numAttempts == attempsCheck ) |
|
365 { |
|
366 iTestStepResult = EFail; |
|
367 } |
|
368 return iTestStepResult; |
|
369 } |
|
370 |
|
371 |
|
372 |
|
373 |
|