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