|
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 034.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_034_xx.h" |
|
28 |
|
29 |
|
30 CCommDbTest034_01::CCommDbTest034_01() |
|
31 { |
|
32 // store the name of this test case |
|
33 SetTestStepName(_L("step_034_01")); |
|
34 } |
|
35 |
|
36 CCommDbTest034_01::~CCommDbTest034_01() |
|
37 {} |
|
38 |
|
39 TVerdict CCommDbTest034_01::doTestStepL( void ) |
|
40 { |
|
41 executeStepL(); |
|
42 SetTestStepResult(EPass); return TestStepResult(); //If we've got this far we've passed |
|
43 } |
|
44 |
|
45 TVerdict CCommDbTest034_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 CCommDbTest034_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, EFalse); |
|
65 |
|
66 User::LeaveIfError(iPrefView->GotoFirstRecord()); |
|
67 iPrefView->ChangeConnectionPreferenceRankL(2); |
|
68 |
|
69 return KErrNone; |
|
70 } |
|
71 |
|
72 TVerdict CCommDbTest034_01::doTestStepPostambleL() |
|
73 { |
|
74 //Get rid of our view |
|
75 if(iPrefView) |
|
76 { |
|
77 delete iPrefView; |
|
78 } |
|
79 iPrefView=0; |
|
80 |
|
81 //Create a new view that should have the record that was added in executeStepL and |
|
82 // may have been left in by a leave condition |
|
83 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
84 CleanupStack::Pop(); |
|
85 |
|
86 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
87 { |
|
88 iPrefView->DeleteConnectionPreferenceL(); |
|
89 } |
|
90 |
|
91 // Cleanup after test run |
|
92 CTestStepCommDb::doTestStepPostambleL(); |
|
93 SetTestStepResult(EPass); return TestStepResult(); |
|
94 } |
|
95 |
|
96 //////////////////////////////////////////////////////////////////////////////// |
|
97 |
|
98 CCommDbTest034_02::CCommDbTest034_02() |
|
99 { |
|
100 // store the name of this test case |
|
101 SetTestStepName(_L("step_034_02")); |
|
102 } |
|
103 |
|
104 CCommDbTest034_02::~CCommDbTest034_02() |
|
105 {} |
|
106 |
|
107 TVerdict CCommDbTest034_02::doTestStepL( void ) |
|
108 { |
|
109 if(executeStepL()!=KErrNone) |
|
110 SetTestStepResult(EFail); SetTestStepResult(EPass); return TestStepResult(); |
|
111 } |
|
112 |
|
113 TVerdict CCommDbTest034_02::doTestStepPreambleL() |
|
114 { |
|
115 iTheDb=CCommsDatabase::NewL(); |
|
116 |
|
117 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
118 CleanupStack::Pop(); |
|
119 |
|
120 SetTestStepResult(EPass); return TestStepResult(); |
|
121 } |
|
122 |
|
123 TInt CCommDbTest034_02::executeStepL() |
|
124 { |
|
125 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref1; |
|
126 pref1.iRanking = 1; |
|
127 pref1.iDirection = ECommDbConnectionDirectionOutgoing; |
|
128 pref1.iDialogPref = ECommDbDialogPrefPrompt; |
|
129 pref1.iBearer.iBearerSet = KCommDbBearerCSD; |
|
130 pref1.iBearer.iIapId = 1; |
|
131 |
|
132 iPrefView->InsertConnectionPreferenceL(pref1, EFalse); |
|
133 |
|
134 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref2; |
|
135 pref2.iRanking = 2; |
|
136 pref2.iDirection = ECommDbConnectionDirectionOutgoing; |
|
137 pref2.iDialogPref = ECommDbDialogPrefPrompt; |
|
138 pref2.iBearer.iBearerSet = KCommDbBearerCSD; |
|
139 pref2.iBearer.iIapId = 2; |
|
140 |
|
141 iPrefView->InsertConnectionPreferenceL(pref2, EFalse); |
|
142 |
|
143 User::LeaveIfError(iPrefView->GotoFirstRecord()); |
|
144 iPrefView->ChangeConnectionPreferenceRankL(2); |
|
145 |
|
146 User::LeaveIfError(iPrefView->GotoNextRecord()); |
|
147 |
|
148 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref retrievedPref; |
|
149 iPrefView->ReadConnectionPreferenceL(retrievedPref); |
|
150 |
|
151 if(retrievedPref.iRanking!=0) |
|
152 return KErrGeneral; //pref2 should have it's ranking displaced to 0 by ChangeConnectionPreferenceRankL |
|
153 |
|
154 return KErrNone; |
|
155 } |
|
156 |
|
157 TVerdict CCommDbTest034_02::doTestStepPostambleL() |
|
158 { |
|
159 //Get rid of our view |
|
160 if(iPrefView) |
|
161 { |
|
162 delete iPrefView; |
|
163 } |
|
164 iPrefView=0; |
|
165 |
|
166 //Create a new view that should have the record that was added in executeStepL and |
|
167 // may have been left in by a leave condition |
|
168 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
169 CleanupStack::Pop(); |
|
170 |
|
171 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
172 { |
|
173 iPrefView->DeleteConnectionPreferenceL(); |
|
174 } |
|
175 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
176 { |
|
177 iPrefView->DeleteConnectionPreferenceL(); |
|
178 } |
|
179 |
|
180 // Cleanup after test run |
|
181 CTestStepCommDb::doTestStepPostambleL(); |
|
182 SetTestStepResult(EPass); return TestStepResult(); |
|
183 } |
|
184 |
|
185 //////////////////////////////////////////////////////////////////////////////// |
|
186 |
|
187 CCommDbTest034_03::CCommDbTest034_03() |
|
188 { |
|
189 // store the name of this test case |
|
190 SetTestStepName(_L("step_034_03")); |
|
191 } |
|
192 |
|
193 CCommDbTest034_03::~CCommDbTest034_03() |
|
194 {} |
|
195 |
|
196 TVerdict CCommDbTest034_03::doTestStepL( void ) |
|
197 { |
|
198 if(executeStepL()!=KErrNone) |
|
199 SetTestStepResult(EFail); SetTestStepResult(EPass); return TestStepResult(); |
|
200 } |
|
201 |
|
202 TVerdict CCommDbTest034_03::doTestStepPreambleL() |
|
203 { |
|
204 iTheDb=CCommsDatabase::NewL(); |
|
205 |
|
206 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
207 CleanupStack::Pop(); |
|
208 |
|
209 SetTestStepResult(EPass); return TestStepResult(); |
|
210 } |
|
211 |
|
212 TInt CCommDbTest034_03::executeStepL() |
|
213 { |
|
214 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref1; |
|
215 pref1.iRanking = 1; |
|
216 pref1.iDirection = ECommDbConnectionDirectionOutgoing; |
|
217 pref1.iDialogPref = ECommDbDialogPrefPrompt; |
|
218 pref1.iBearer.iBearerSet = KCommDbBearerCSD; |
|
219 pref1.iBearer.iIapId = 1; |
|
220 |
|
221 iPrefView->InsertConnectionPreferenceL(pref1, EFalse); |
|
222 |
|
223 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref2; |
|
224 pref2.iRanking = 2; |
|
225 pref2.iDirection = ECommDbConnectionDirectionOutgoing; |
|
226 pref2.iDialogPref = ECommDbDialogPrefPrompt; |
|
227 pref2.iBearer.iBearerSet = KCommDbBearerCSD; |
|
228 pref2.iBearer.iIapId = 2; |
|
229 |
|
230 iPrefView->InsertConnectionPreferenceL(pref2, EFalse); |
|
231 |
|
232 User::LeaveIfError(iPrefView->GotoFirstRecord()); |
|
233 TRAPD(err, iPrefView->ChangeConnectionPreferenceRankL(5)); |
|
234 if (err!=KErrOverflow) |
|
235 { |
|
236 if(err==KErrNone) //This is horrible, but need to make sure that if this returns with KErrNone we catch it. |
|
237 err=KErrGeneral; |
|
238 return err; |
|
239 } |
|
240 |
|
241 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref retrievedPref; |
|
242 iPrefView->ReadConnectionPreferenceL(retrievedPref); |
|
243 |
|
244 if(retrievedPref.iRanking!=1) |
|
245 return KErrGeneral; //pref1 should still have ranking 1 |
|
246 |
|
247 return KErrNone; |
|
248 } |
|
249 |
|
250 TVerdict CCommDbTest034_03::doTestStepPostambleL() |
|
251 { |
|
252 //Get rid of our view |
|
253 if(iPrefView) |
|
254 { |
|
255 delete iPrefView; |
|
256 } |
|
257 iPrefView=0; |
|
258 |
|
259 //Create a new view that should have the record that was added in executeStepL and |
|
260 // may have been left in by a leave condition |
|
261 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
262 CleanupStack::Pop(); |
|
263 |
|
264 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
265 { |
|
266 iPrefView->DeleteConnectionPreferenceL(); |
|
267 } |
|
268 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
269 { |
|
270 iPrefView->DeleteConnectionPreferenceL(); |
|
271 } |
|
272 |
|
273 // Cleanup after test run |
|
274 CTestStepCommDb::doTestStepPostambleL(); |
|
275 SetTestStepResult(EPass); return TestStepResult(); |
|
276 } |
|
277 |
|
278 //////////////////////////////////////////////////////////////////////////////// |
|
279 |
|
280 CCommDbTest034_04::CCommDbTest034_04() |
|
281 { |
|
282 // store the name of this test case |
|
283 SetTestStepName(_L("step_034_04")); |
|
284 } |
|
285 |
|
286 CCommDbTest034_04::~CCommDbTest034_04() |
|
287 {} |
|
288 |
|
289 TVerdict CCommDbTest034_04::doTestStepL( void ) |
|
290 { |
|
291 if (executeStepL() != KErrNotFound) |
|
292 { |
|
293 SetTestStepResult(EFail); } |
|
294 |
|
295 return TestStepResult(); |
|
296 } |
|
297 |
|
298 TVerdict CCommDbTest034_04::doTestStepPreambleL() |
|
299 { |
|
300 iTheDb=CCommsDatabase::NewL(); |
|
301 |
|
302 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
303 CleanupStack::Pop(); |
|
304 |
|
305 SetTestStepResult(EPass); return TestStepResult(); |
|
306 } |
|
307 |
|
308 TInt CCommDbTest034_04::executeStepL() |
|
309 { |
|
310 // |
|
311 // Previously (I guess) CommDB would have been able to create two |
|
312 // Conn Pref entries and then the fresh view would not have seen them |
|
313 // and it would panic. Now CommsDAT does see them and returns |
|
314 // KErrNotFound, so now we no longer inserted in this test allowing |
|
315 // the test to actually test the expected scenario. |
|
316 // |
|
317 delete iPrefView; //Create a fresh view |
|
318 iPrefView=NULL; |
|
319 iPrefView=iTheDb->OpenConnectionPrefTableLC(); |
|
320 CleanupStack::Pop(); |
|
321 TRAPD(err, iPrefView->ChangeConnectionPreferenceRankL(2)); |
|
322 |
|
323 return err; |
|
324 } |
|
325 |
|
326 TVerdict CCommDbTest034_04::doTestStepPostambleL() |
|
327 { |
|
328 //Get rid of our view |
|
329 if(iPrefView) |
|
330 { |
|
331 delete iPrefView; |
|
332 } |
|
333 iPrefView=0; |
|
334 |
|
335 //Create a new view that should have the record that was added in executeStepL and |
|
336 // may have been left in by a leave condition |
|
337 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
338 CleanupStack::Pop(); |
|
339 |
|
340 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
341 { |
|
342 iPrefView->DeleteConnectionPreferenceL(); |
|
343 } |
|
344 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
345 { |
|
346 iPrefView->DeleteConnectionPreferenceL(); |
|
347 } |
|
348 |
|
349 // Cleanup after test run |
|
350 CTestStepCommDb::doTestStepPostambleL(); |
|
351 SetTestStepResult(EPass); return TestStepResult(); |
|
352 } |
|
353 |
|
354 //////////////////////////////////////////////////////////////////////////////// |
|
355 |
|
356 CCommDbTest034_05::CCommDbTest034_05() |
|
357 { |
|
358 // store the name of this test case |
|
359 SetTestStepName(_L("step_034_05")); |
|
360 } |
|
361 |
|
362 CCommDbTest034_05::~CCommDbTest034_05() |
|
363 {} |
|
364 |
|
365 TVerdict CCommDbTest034_05::doTestStepL( void ) |
|
366 { |
|
367 if(executeStepL()!=KErrNone) |
|
368 SetTestStepResult(EFail); SetTestStepResult(EPass); return TestStepResult(); |
|
369 } |
|
370 |
|
371 TVerdict CCommDbTest034_05::doTestStepPreambleL() |
|
372 { |
|
373 iTheDb=CCommsDatabase::NewL(); |
|
374 |
|
375 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
376 CleanupStack::Pop(); |
|
377 |
|
378 SetTestStepResult(EPass); return TestStepResult(); |
|
379 } |
|
380 |
|
381 TInt CCommDbTest034_05::executeStepL() |
|
382 { |
|
383 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref1; |
|
384 pref1.iRanking = 1; |
|
385 pref1.iDirection = ECommDbConnectionDirectionOutgoing; |
|
386 pref1.iDialogPref = ECommDbDialogPrefPrompt; |
|
387 pref1.iBearer.iBearerSet = KCommDbBearerCSD; |
|
388 pref1.iBearer.iIapId = 1; |
|
389 |
|
390 iPrefView->InsertConnectionPreferenceL(pref1, ETrue); |
|
391 |
|
392 User::LeaveIfError(iPrefView->GotoFirstRecord()); |
|
393 |
|
394 TRAPD(err, iPrefView->ChangeConnectionPreferenceRankL(2)); |
|
395 if(err!=KErrAccessDenied) |
|
396 { |
|
397 if(err==KErrNone) //Need to do some maping here otherwise if this returns KErrNone the test will pass!! |
|
398 err=KErrGeneral; |
|
399 return err; |
|
400 } |
|
401 |
|
402 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref retrievedPref; |
|
403 iPrefView->ReadConnectionPreferenceL(retrievedPref); |
|
404 |
|
405 if(retrievedPref.iRanking!=1) //The ranking has been changed for a read only entry |
|
406 return KErrGeneral; |
|
407 |
|
408 return KErrNone; |
|
409 } |
|
410 |
|
411 TVerdict CCommDbTest034_05::doTestStepPostambleL() |
|
412 { |
|
413 //Get rid of our view |
|
414 if(iPrefView) |
|
415 { |
|
416 delete iPrefView; |
|
417 } |
|
418 iPrefView=0; |
|
419 |
|
420 //Create a new view that should have the record that was added in executeStepL and |
|
421 // may have been left in by a leave condition |
|
422 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
423 CleanupStack::Pop(); |
|
424 |
|
425 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
426 { |
|
427 iPrefView->DeleteConnectionPreferenceL(); |
|
428 } |
|
429 |
|
430 // Cleanup after test run |
|
431 CTestStepCommDb::doTestStepPostambleL(); |
|
432 SetTestStepResult(EPass); return TestStepResult(); |
|
433 } |
|
434 |
|
435 ////////////////////////////////////////////////////////////////////////// |
|
436 |
|
437 CCommDbTest034_06::CCommDbTest034_06() |
|
438 { |
|
439 // store the name of this test case |
|
440 SetTestStepName(_L("step_034_06")); |
|
441 } |
|
442 |
|
443 CCommDbTest034_06::~CCommDbTest034_06() |
|
444 {} |
|
445 |
|
446 TVerdict CCommDbTest034_06::doTestStepL( void ) |
|
447 { |
|
448 INFO_PRINTF1(_L("Step 034.06 called ")); |
|
449 |
|
450 SetTestStepResult(EPass); |
|
451 CCommDbTest034_01* step034_01 = new(ELeave) CCommDbTest034_01; |
|
452 CleanupStack::PushL(step034_01); |
|
453 doTestStepWithHeapFailureL( *step034_01, KErrNone); |
|
454 CleanupStack::PopAndDestroy(step034_01); |
|
455 |
|
456 CCommDbTest034_02* step034_02 = new(ELeave) CCommDbTest034_02; |
|
457 CleanupStack::PushL(step034_02); |
|
458 doTestStepWithHeapFailureL( *step034_02, KErrNone); |
|
459 CleanupStack::PopAndDestroy(step034_02); |
|
460 |
|
461 CCommDbTest034_03* step034_03 = new(ELeave) CCommDbTest034_03; |
|
462 CleanupStack::PushL(step034_03); |
|
463 doTestStepWithHeapFailureL( *step034_03, KErrNone); |
|
464 CleanupStack::PopAndDestroy(step034_03); |
|
465 |
|
466 CCommDbTest034_04* step034_04 = new(ELeave) CCommDbTest034_04; |
|
467 CleanupStack::PushL(step034_04); |
|
468 doTestStepWithHeapFailureL( *step034_04, KErrNotFound); |
|
469 CleanupStack::PopAndDestroy(step034_04); |
|
470 |
|
471 CCommDbTest034_05* step034_05 = new(ELeave) CCommDbTest034_05; |
|
472 CleanupStack::PushL(step034_05); |
|
473 doTestStepWithHeapFailureL( *step034_05, KErrNone); |
|
474 CleanupStack::PopAndDestroy(step034_05); |
|
475 |
|
476 return TestStepResult(); |
|
477 } |