1 // Copyright (c) 2001-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 // This contains CommDb Unit Test Cases 043.XX |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 #include <commdb.h> |
|
21 #include <d32comm.h> |
|
22 |
|
23 // Test system includes |
|
24 #include <networking/log.h> |
|
25 #include <networking/teststep.h> |
|
26 #include "Teststepcommdb.h" |
|
27 #include "TestSuiteCommdb.h" |
|
28 #include "Step_043_xx.h" |
|
29 |
|
30 |
|
31 CCommDbTest043_01::CCommDbTest043_01() |
|
32 { |
|
33 // store the name of this test case |
|
34 iTestStepName = _L("step_043_01"); |
|
35 } |
|
36 |
|
37 CCommDbTest043_01::~CCommDbTest043_01() |
|
38 {} |
|
39 |
|
40 TVerdict CCommDbTest043_01::doTestStepL( void ) |
|
41 { |
|
42 if(executeStepL()!=KErrNone) |
|
43 return EFail; |
|
44 return EPass; |
|
45 } |
|
46 |
|
47 TVerdict CCommDbTest043_01::doTestStepPreambleL() |
|
48 { |
|
49 iTheDb=CCommsDatabase::NewL(); |
|
50 |
|
51 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
52 CleanupStack::Pop(); |
|
53 |
|
54 return EPass; |
|
55 } |
|
56 |
|
57 TInt CCommDbTest043_01::executeStepL() |
|
58 { |
|
59 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref1; |
|
60 pref1.iRanking = 1; |
|
61 pref1.iDirection = ECommDbConnectionDirectionOutgoing; |
|
62 pref1.iDialogPref = ECommDbDialogPrefPrompt; |
|
63 pref1.iBearer.iBearerSet = KCommDbBearerCSD; |
|
64 pref1.iBearer.iIapId = 1; |
|
65 |
|
66 iPrefView->InsertConnectionPreferenceL(pref1, ETrue); |
|
67 |
|
68 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref2; |
|
69 pref2.iRanking = 2; |
|
70 pref2.iDirection = ECommDbConnectionDirectionOutgoing; |
|
71 pref2.iDialogPref = ECommDbDialogPrefPrompt; |
|
72 pref2.iBearer.iBearerSet = KCommDbBearerCSD; |
|
73 pref2.iBearer.iIapId = 2; |
|
74 |
|
75 iPrefView->InsertConnectionPreferenceL(pref2, ETrue); |
|
76 |
|
77 CCommDbOverrideSettings* overSet=CCommDbOverrideSettings::NewL(CCommDbOverrideSettings::EParamListPartial); |
|
78 CleanupStack::PushL(overSet); |
|
79 |
|
80 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref overPref; |
|
81 overPref.iRanking = 1; |
|
82 overPref.iDirection = ECommDbConnectionDirectionOutgoing; |
|
83 overPref.iDialogPref = ECommDbDialogPrefDoNotPrompt; |
|
84 overPref.iBearer.iBearerSet = KCommDbBearerCSD; |
|
85 overPref.iBearer.iIapId = 2; |
|
86 |
|
87 User::LeaveIfError(overSet->SetConnectionPreferenceOverride(overPref)); |
|
88 |
|
89 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref overPref2; |
|
90 overPref2.iRanking = 1; |
|
91 overPref2.iDirection = ECommDbConnectionDirectionOutgoing; |
|
92 overPref2.iDialogPref = ECommDbDialogPrefUnknown; |
|
93 overPref2.iBearer.iBearerSet = 0; |
|
94 overPref2.iBearer.iIapId = 0; |
|
95 |
|
96 User::LeaveIfError(overSet->GetConnectionPreferenceOverride(overPref2)); |
|
97 CleanupStack::PopAndDestroy(overSet); |
|
98 |
|
99 if(!(overPref==overPref2)) |
|
100 return KErrGeneral; |
|
101 |
|
102 return KErrNone; |
|
103 } |
|
104 |
|
105 TVerdict CCommDbTest043_01::doTestStepPostambleL() |
|
106 { |
|
107 //Get rid of our view |
|
108 if(iPrefView) |
|
109 { |
|
110 delete iPrefView; |
|
111 } |
|
112 iPrefView=0; |
|
113 |
|
114 //Create a new view that should have the record that was added in executeStepL and |
|
115 // may have been left in by a leave condition |
|
116 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
117 CleanupStack::Pop(); |
|
118 |
|
119 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
120 { |
|
121 iPrefView->DeleteConnectionPreferenceL(); |
|
122 } |
|
123 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
124 { |
|
125 iPrefView->DeleteConnectionPreferenceL(); |
|
126 } |
|
127 |
|
128 // Cleanup after test run |
|
129 CTestStepCommDb::doTestStepPostambleL(); |
|
130 return EPass; |
|
131 } |
|
132 |
|
133 // |
|
134 |
|
135 CCommDbTest043_02::CCommDbTest043_02() |
|
136 { |
|
137 // store the name of this test case |
|
138 iTestStepName = _L("step_043_02"); |
|
139 } |
|
140 |
|
141 CCommDbTest043_02::~CCommDbTest043_02() |
|
142 {} |
|
143 |
|
144 TVerdict CCommDbTest043_02::doTestStepL( void ) |
|
145 { |
|
146 if(executeStepL()!=KErrAlreadyExists) |
|
147 return EFail; |
|
148 return EPass; |
|
149 } |
|
150 |
|
151 TVerdict CCommDbTest043_02::doTestStepPreambleL() |
|
152 { |
|
153 iTheDb=CCommsDatabase::NewL(); |
|
154 |
|
155 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
156 CleanupStack::Pop(); |
|
157 |
|
158 return EPass; |
|
159 } |
|
160 |
|
161 TInt CCommDbTest043_02::executeStepL() |
|
162 { |
|
163 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref1; |
|
164 pref1.iRanking = 1; |
|
165 pref1.iDirection = ECommDbConnectionDirectionOutgoing; |
|
166 pref1.iDialogPref = ECommDbDialogPrefPrompt; |
|
167 pref1.iBearer.iBearerSet = KCommDbBearerCSD; |
|
168 pref1.iBearer.iIapId = 1; |
|
169 |
|
170 iPrefView->InsertConnectionPreferenceL(pref1, ETrue); |
|
171 |
|
172 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref2; |
|
173 pref2.iRanking = 2; |
|
174 pref2.iDirection = ECommDbConnectionDirectionOutgoing; |
|
175 pref2.iDialogPref = ECommDbDialogPrefPrompt; |
|
176 pref2.iBearer.iBearerSet = KCommDbBearerCSD; |
|
177 pref2.iBearer.iIapId = 2; |
|
178 |
|
179 iPrefView->InsertConnectionPreferenceL(pref2, ETrue); |
|
180 |
|
181 CCommDbOverrideSettings* overSet=CCommDbOverrideSettings::NewL(CCommDbOverrideSettings::EParamListPartial); |
|
182 CleanupStack::PushL(overSet); |
|
183 |
|
184 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref overPref; |
|
185 overPref.iRanking = 1; |
|
186 overPref.iDirection = ECommDbConnectionDirectionOutgoing; |
|
187 overPref.iDialogPref = ECommDbDialogPrefDoNotPrompt; |
|
188 overPref.iBearer.iBearerSet = KCommDbBearerCSD; |
|
189 overPref.iBearer.iIapId = 2; |
|
190 |
|
191 User::LeaveIfError(overSet->SetConnectionPreferenceOverride(overPref)); |
|
192 |
|
193 overPref.iDialogPref = ECommDbDialogPrefPrompt; |
|
194 overPref.iBearer.iBearerSet = KCommDbBearerCSD; |
|
195 overPref.iBearer.iIapId = 2; |
|
196 |
|
197 TInt err = overSet->SetConnectionPreferenceOverride(overPref); |
|
198 CleanupStack::PopAndDestroy(overSet); |
|
199 |
|
200 return err; |
|
201 } |
|
202 |
|
203 TVerdict CCommDbTest043_02::doTestStepPostambleL() |
|
204 { |
|
205 //Get rid of our view |
|
206 if(iPrefView) |
|
207 { |
|
208 delete iPrefView; |
|
209 } |
|
210 iPrefView=0; |
|
211 |
|
212 //Create a new view that should have the record that was added in executeStepL and |
|
213 // may have been left in by a leave condition |
|
214 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
215 CleanupStack::Pop(); |
|
216 |
|
217 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
218 { |
|
219 iPrefView->DeleteConnectionPreferenceL(); |
|
220 } |
|
221 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
222 { |
|
223 iPrefView->DeleteConnectionPreferenceL(); |
|
224 } |
|
225 |
|
226 // Cleanup after test run |
|
227 CTestStepCommDb::doTestStepPostambleL(); |
|
228 return EPass; |
|
229 } |
|
230 |
|
231 // |
|
232 |
|
233 CCommDbTest043_03::CCommDbTest043_03() |
|
234 { |
|
235 // store the name of this test case |
|
236 iTestStepName = _L("step_043_03"); |
|
237 } |
|
238 |
|
239 CCommDbTest043_03::~CCommDbTest043_03() |
|
240 {} |
|
241 |
|
242 TVerdict CCommDbTest043_03::doTestStepL( void ) |
|
243 { |
|
244 if(executeStepL()!=KErrNone) |
|
245 return EFail; |
|
246 return EPass; |
|
247 } |
|
248 |
|
249 TVerdict CCommDbTest043_03::doTestStepPreambleL() |
|
250 { |
|
251 iTheDb=CCommsDatabase::NewL(); |
|
252 |
|
253 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
254 CleanupStack::Pop(); |
|
255 |
|
256 return EPass; |
|
257 } |
|
258 |
|
259 TInt CCommDbTest043_03::executeStepL() |
|
260 { |
|
261 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref1; |
|
262 pref1.iRanking = 1; |
|
263 pref1.iDirection = ECommDbConnectionDirectionOutgoing; |
|
264 pref1.iDialogPref = ECommDbDialogPrefPrompt; |
|
265 pref1.iBearer.iBearerSet = KCommDbBearerCSD; |
|
266 pref1.iBearer.iIapId = 1; |
|
267 |
|
268 iPrefView->InsertConnectionPreferenceL(pref1, ETrue); |
|
269 |
|
270 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref2; |
|
271 pref2.iRanking = 2; |
|
272 pref2.iDirection = ECommDbConnectionDirectionOutgoing; |
|
273 pref2.iDialogPref = ECommDbDialogPrefPrompt; |
|
274 pref2.iBearer.iBearerSet = KCommDbBearerCSD; |
|
275 pref2.iBearer.iIapId = 2; |
|
276 |
|
277 iPrefView->InsertConnectionPreferenceL(pref2, ETrue); |
|
278 |
|
279 CCommDbOverrideSettings* overSet=CCommDbOverrideSettings::NewL(CCommDbOverrideSettings::EParamListPartial); |
|
280 CleanupStack::PushL(overSet); |
|
281 |
|
282 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref overPref; |
|
283 overPref.iRanking = 1; |
|
284 overPref.iDirection = ECommDbConnectionDirectionOutgoing; |
|
285 overPref.iDialogPref = ECommDbDialogPrefDoNotPrompt; |
|
286 overPref.iBearer.iBearerSet = KCommDbBearerCSD; |
|
287 overPref.iBearer.iIapId = 2; |
|
288 |
|
289 User::LeaveIfError(overSet->SetConnectionPreferenceOverride(overPref)); |
|
290 |
|
291 overPref.iRanking = 0; |
|
292 overPref.iDirection = ECommDbConnectionDirectionUnknown; |
|
293 overPref.iDialogPref = ECommDbDialogPrefUnknown; |
|
294 overPref.iBearer.iBearerSet = 0; |
|
295 overPref.iBearer.iIapId = 0; |
|
296 |
|
297 TInt err = overSet->GetConnectionPreferenceOverride(overPref); |
|
298 |
|
299 CleanupStack::PopAndDestroy(overSet); |
|
300 |
|
301 if(err==KErrArgument) //Have to map errors to different ones so we can do heap failure tests |
|
302 return KErrNone; //Nasty, but not a lot else we can do. |
|
303 |
|
304 if(err==KErrNone) |
|
305 return KErrGeneral; |
|
306 |
|
307 return err; |
|
308 } |
|
309 |
|
310 TVerdict CCommDbTest043_03::doTestStepPostambleL() |
|
311 { |
|
312 //Get rid of our view |
|
313 if(iPrefView) |
|
314 { |
|
315 delete iPrefView; |
|
316 } |
|
317 iPrefView=0; |
|
318 |
|
319 //Create a new view that should have the record that was added in executeStepL and |
|
320 // may have been left in by a leave condition |
|
321 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
322 CleanupStack::Pop(); |
|
323 |
|
324 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
325 { |
|
326 iPrefView->DeleteConnectionPreferenceL(); |
|
327 } |
|
328 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
329 { |
|
330 iPrefView->DeleteConnectionPreferenceL(); |
|
331 } |
|
332 |
|
333 // Cleanup after test run |
|
334 CTestStepCommDb::doTestStepPostambleL(); |
|
335 return EPass; |
|
336 } |
|
337 |
|
338 // |
|
339 |
|
340 CCommDbTest043_04::CCommDbTest043_04() |
|
341 { |
|
342 // store the name of this test case |
|
343 iTestStepName = _L("step_043_04"); |
|
344 } |
|
345 |
|
346 CCommDbTest043_04::~CCommDbTest043_04() |
|
347 {} |
|
348 |
|
349 TVerdict CCommDbTest043_04::doTestStepL( void ) |
|
350 { |
|
351 if(executeStepL()!=KErrNotFound) |
|
352 return EFail; |
|
353 return EPass; |
|
354 } |
|
355 |
|
356 TVerdict CCommDbTest043_04::doTestStepPreambleL() |
|
357 { |
|
358 iTheDb=CCommsDatabase::NewL(); |
|
359 |
|
360 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
361 CleanupStack::Pop(); |
|
362 |
|
363 return EPass; |
|
364 } |
|
365 |
|
366 TInt CCommDbTest043_04::executeStepL() |
|
367 { |
|
368 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref1; |
|
369 pref1.iRanking = 1; |
|
370 pref1.iDirection = ECommDbConnectionDirectionOutgoing; |
|
371 pref1.iDialogPref = ECommDbDialogPrefPrompt; |
|
372 pref1.iBearer.iBearerSet = KCommDbBearerCSD; |
|
373 pref1.iBearer.iIapId = 1; |
|
374 |
|
375 iPrefView->InsertConnectionPreferenceL(pref1, ETrue); |
|
376 |
|
377 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref2; |
|
378 pref2.iRanking = 2; |
|
379 pref2.iDirection = ECommDbConnectionDirectionOutgoing; |
|
380 pref2.iDialogPref = ECommDbDialogPrefPrompt; |
|
381 pref2.iBearer.iBearerSet = KCommDbBearerCSD; |
|
382 pref2.iBearer.iIapId = 2; |
|
383 |
|
384 iPrefView->InsertConnectionPreferenceL(pref2, ETrue); |
|
385 |
|
386 CCommDbOverrideSettings* overSet=CCommDbOverrideSettings::NewL(CCommDbOverrideSettings::EParamListPartial); |
|
387 CleanupStack::PushL(overSet); |
|
388 |
|
389 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref overPref; |
|
390 overPref.iRanking = 1; |
|
391 overPref.iDirection = ECommDbConnectionDirectionOutgoing; |
|
392 overPref.iDialogPref = ECommDbDialogPrefUnknown; |
|
393 overPref.iBearer.iBearerSet = 0; |
|
394 overPref.iBearer.iIapId = 0; |
|
395 |
|
396 TInt err = overSet->GetConnectionPreferenceOverride(overPref); |
|
397 |
|
398 CleanupStack::PopAndDestroy(overSet); |
|
399 |
|
400 return err; |
|
401 } |
|
402 |
|
403 TVerdict CCommDbTest043_04::doTestStepPostambleL() |
|
404 { |
|
405 //Get rid of our view |
|
406 if(iPrefView) |
|
407 { |
|
408 delete iPrefView; |
|
409 } |
|
410 iPrefView=0; |
|
411 |
|
412 //Create a new view that should have the record that was added in executeStepL and |
|
413 // may have been left in by a leave condition |
|
414 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
415 CleanupStack::Pop(); |
|
416 |
|
417 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
418 { |
|
419 iPrefView->DeleteConnectionPreferenceL(); |
|
420 } |
|
421 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
422 { |
|
423 iPrefView->DeleteConnectionPreferenceL(); |
|
424 } |
|
425 |
|
426 // Cleanup after test run |
|
427 CTestStepCommDb::doTestStepPostambleL(); |
|
428 return EPass; |
|
429 } |
|
430 |
|
431 // |
|
432 |
|
433 CCommDbTest043_05::CCommDbTest043_05() |
|
434 { |
|
435 // store the name of this test case |
|
436 iTestStepName = _L("step_043_05"); |
|
437 } |
|
438 |
|
439 CCommDbTest043_05::~CCommDbTest043_05() |
|
440 {} |
|
441 |
|
442 TVerdict CCommDbTest043_05::doTestStepL( void ) |
|
443 { |
|
444 Log(_L("Step 043.05 called ")); |
|
445 |
|
446 iTestStepResult = EPass; |
|
447 |
|
448 CCommDbTest043_01* step043_01 = new(ELeave) CCommDbTest043_01; |
|
449 CleanupStack::PushL(step043_01); |
|
450 step043_01->iSuite = iSuite; |
|
451 doTestStepWithHeapFailureL( *step043_01, KErrNone); |
|
452 CleanupStack::PopAndDestroy(step043_01); |
|
453 |
|
454 CCommDbTest043_02* step043_02 = new(ELeave) CCommDbTest043_02; |
|
455 CleanupStack::PushL(step043_02); |
|
456 step043_02->iSuite = iSuite; |
|
457 doTestStepWithHeapFailureL( *step043_02, KErrAlreadyExists); |
|
458 CleanupStack::PopAndDestroy(step043_02); |
|
459 |
|
460 CCommDbTest043_03* step043_03 = new(ELeave) CCommDbTest043_03; |
|
461 CleanupStack::PushL(step043_03); |
|
462 step043_03->iSuite = iSuite; |
|
463 doTestStepWithHeapFailureL( *step043_03, KErrNone); |
|
464 CleanupStack::PopAndDestroy(step043_03); |
|
465 |
|
466 CCommDbTest043_04* step043_04 = new(ELeave) CCommDbTest043_04; |
|
467 CleanupStack::PushL(step043_04); |
|
468 step043_04->iSuite = iSuite; |
|
469 doTestStepWithHeapFailureL( *step043_04, KErrNotFound); |
|
470 CleanupStack::PopAndDestroy(step043_04); |
|
471 |
|
472 return iTestStepResult; |
|
473 } |
|