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 020.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_020_xx.h" |
|
29 |
|
30 // |
|
31 // Test step 020.01 |
|
32 // |
|
33 |
|
34 // constructor |
|
35 CCommDbTest020_01::CCommDbTest020_01() |
|
36 { |
|
37 // store the name of this test case |
|
38 iTestStepName = _L("step_020_01"); |
|
39 } |
|
40 |
|
41 // destructor |
|
42 CCommDbTest020_01::~CCommDbTest020_01() |
|
43 { |
|
44 } |
|
45 |
|
46 |
|
47 TVerdict CCommDbTest020_01::doTestStepPreambleL() |
|
48 { |
|
49 openDbL(); |
|
50 return EPass; |
|
51 } |
|
52 |
|
53 TInt CCommDbTest020_01::executeStepL() |
|
54 { |
|
55 TInt ret=KErrGeneral; |
|
56 TBuf<64> buffer; |
|
57 |
|
58 _LIT(KAgent,"Agent"); |
|
59 |
|
60 TRAPD(r1,iTheDb->SetAgentL(TPtrC(DIAL_OUT_ISP),KAgent)); |
|
61 TRAPD(r2,iTheDb->GetAgentL(TPtrC(DIAL_OUT_ISP),buffer)); |
|
62 |
|
63 if(r1==KErrNotSupported && r2==KErrNotSupported) |
|
64 { |
|
65 return KErrNotSupported; |
|
66 } |
|
67 |
|
68 return ret; |
|
69 } |
|
70 |
|
71 |
|
72 |
|
73 TVerdict CCommDbTest020_01::doTestStepL( ) |
|
74 { |
|
75 Log(_L("Step 020.01 called ")); |
|
76 |
|
77 |
|
78 if ( executeStepL() == KErrNotSupported ) |
|
79 iTestStepResult = EPass; |
|
80 else |
|
81 iTestStepResult = EFail; |
|
82 |
|
83 return iTestStepResult; |
|
84 } |
|
85 |
|
86 // |
|
87 // Test step 020.02 |
|
88 // |
|
89 |
|
90 // constructor |
|
91 CCommDbTest020_02::CCommDbTest020_02() |
|
92 { |
|
93 // store the name of this test case |
|
94 iTestStepName = _L("step_020_02"); |
|
95 } |
|
96 |
|
97 // destructor |
|
98 CCommDbTest020_02::~CCommDbTest020_02() |
|
99 { |
|
100 } |
|
101 |
|
102 |
|
103 TVerdict CCommDbTest020_02::doTestStepPreambleL() |
|
104 { |
|
105 openDbL(); |
|
106 return EPass; |
|
107 } |
|
108 |
|
109 |
|
110 TInt CCommDbTest020_02::executeStepL() |
|
111 { |
|
112 TInt ret=KErrGeneral; |
|
113 TBuf<64> buffer; |
|
114 |
|
115 _LIT(KAgent1,"Agent1"); |
|
116 _LIT(KAgentExt,"Csd"); |
|
117 |
|
118 TRAPD(r1,iTheDb->SetAgentL(TPtrC(DIAL_OUT_ISP),KAgent1)); |
|
119 |
|
120 TRAPD(r2,iTheDb->SetAgentExtL(TPtrC(DIAL_OUT_ISP),KAgentExt)); |
|
121 TRAPD(r3,iTheDb->GetAgentExtL(TPtrC(DIAL_OUT_ISP),buffer)); |
|
122 if(r3 != KErrNone) |
|
123 { |
|
124 return r3; |
|
125 } |
|
126 |
|
127 if(r1==KErrNotSupported && r2==KErrNotSupported) |
|
128 { |
|
129 return KErrNotSupported; |
|
130 } |
|
131 |
|
132 return ret; |
|
133 } |
|
134 |
|
135 |
|
136 |
|
137 TVerdict CCommDbTest020_02::doTestStepL( ) |
|
138 { |
|
139 Log(_L("Step 020.02 called ")); |
|
140 |
|
141 |
|
142 if ( executeStepL() == KErrNotSupported ) |
|
143 iTestStepResult = EPass; |
|
144 else |
|
145 iTestStepResult = EFail; |
|
146 |
|
147 return iTestStepResult; |
|
148 } |
|
149 |
|
150 |
|
151 // |
|
152 // Test step 020.03 |
|
153 // |
|
154 |
|
155 // constructor |
|
156 CCommDbTest020_03::CCommDbTest020_03() |
|
157 { |
|
158 // store the name of this test case |
|
159 iTestStepName = _L("step_020_03"); |
|
160 } |
|
161 |
|
162 // destructor |
|
163 CCommDbTest020_03::~CCommDbTest020_03() |
|
164 { |
|
165 } |
|
166 |
|
167 |
|
168 TVerdict CCommDbTest020_03::doTestStepPreambleL() |
|
169 { |
|
170 openDbL(); |
|
171 return EPass; |
|
172 } |
|
173 |
|
174 |
|
175 TInt CCommDbTest020_03::executeStepL() |
|
176 { |
|
177 TInt ret=KErrGeneral; |
|
178 |
|
179 //Try to set the agent for a non-service table |
|
180 _LIT(KAgent1,"Agent1"); |
|
181 |
|
182 TRAPD( r, iTheDb->SetAgentL(TPtrC(LOCATION),KAgent1) ); |
|
183 if (r==KErrNotSupported ) |
|
184 ret = r; |
|
185 |
|
186 return ret; |
|
187 } |
|
188 |
|
189 |
|
190 |
|
191 TVerdict CCommDbTest020_03::doTestStepL( ) |
|
192 { |
|
193 Log(_L("Step 020.03 called ")); |
|
194 |
|
195 |
|
196 if ( executeStepL() == KErrNotSupported ) |
|
197 iTestStepResult = EPass; |
|
198 else |
|
199 iTestStepResult = EFail; |
|
200 |
|
201 return iTestStepResult; |
|
202 } |
|
203 |
|
204 |
|
205 |
|
206 // |
|
207 // Test step 020.04 |
|
208 // |
|
209 |
|
210 // constructor |
|
211 CCommDbTest020_04::CCommDbTest020_04() |
|
212 { |
|
213 // store the name of this test case |
|
214 iTestStepName = _L("step_020_04"); |
|
215 } |
|
216 |
|
217 // destructor |
|
218 CCommDbTest020_04::~CCommDbTest020_04() |
|
219 { |
|
220 } |
|
221 |
|
222 |
|
223 TVerdict CCommDbTest020_04::doTestStepPreambleL() |
|
224 { |
|
225 openDbL(); |
|
226 return EPass; |
|
227 } |
|
228 |
|
229 |
|
230 TInt CCommDbTest020_04::executeStepL() |
|
231 { |
|
232 TInt ret=KErrGeneral; |
|
233 |
|
234 |
|
235 //Try to set the agent extension for a non-service table |
|
236 |
|
237 _LIT(KAgentExt,"Csd"); |
|
238 |
|
239 TRAPD(r, iTheDb->SetAgentExtL(TPtrC(LOCATION), KAgentExt) ); |
|
240 if ( r==KErrNotSupported ) |
|
241 ret = r; |
|
242 |
|
243 return ret; |
|
244 } |
|
245 |
|
246 |
|
247 |
|
248 TVerdict CCommDbTest020_04::doTestStepL( ) |
|
249 { |
|
250 Log(_L("Step 020.04 called ")); |
|
251 |
|
252 |
|
253 if ( executeStepL() == KErrNotSupported ) |
|
254 iTestStepResult = EPass; |
|
255 else |
|
256 iTestStepResult = EFail; |
|
257 |
|
258 return iTestStepResult; |
|
259 } |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 // |
|
267 // Test step 020.05 |
|
268 // |
|
269 |
|
270 // constructor |
|
271 CCommDbTest020_05::CCommDbTest020_05() |
|
272 { |
|
273 // store the name of this test case |
|
274 iTestStepName = _L("step_020_05"); |
|
275 } |
|
276 |
|
277 // destructor |
|
278 CCommDbTest020_05::~CCommDbTest020_05() |
|
279 { |
|
280 } |
|
281 |
|
282 |
|
283 TVerdict CCommDbTest020_05::doTestStepPreambleL() |
|
284 { |
|
285 openDbL(); |
|
286 return EPass; |
|
287 } |
|
288 |
|
289 |
|
290 TInt CCommDbTest020_05::executeStepL() |
|
291 { |
|
292 TInt ret=KErrGeneral; |
|
293 |
|
294 //Try to open a view on the agent table |
|
295 |
|
296 TRAPD(r, iTheView = iTheDb->OpenTableLC(_L("NonExisting")); CleanupStack::Pop(); ); |
|
297 |
|
298 if ( r==KErrNotFound ) |
|
299 ret = r; |
|
300 |
|
301 return ret; |
|
302 } |
|
303 |
|
304 |
|
305 |
|
306 TVerdict CCommDbTest020_05::doTestStepL( ) |
|
307 { |
|
308 |
|
309 if ( executeStepL() == KErrNotFound ) |
|
310 iTestStepResult = EPass; |
|
311 else |
|
312 iTestStepResult = EFail; |
|
313 |
|
314 return iTestStepResult; |
|
315 } |
|
316 |
|
317 |
|
318 |
|
319 // |
|
320 // Test step 020.06 |
|
321 // |
|
322 |
|
323 // constructor |
|
324 CCommDbTest020_06::CCommDbTest020_06() |
|
325 { |
|
326 // store the name of this test case |
|
327 iTestStepName = _L("step_020_06"); |
|
328 } |
|
329 |
|
330 // destructor |
|
331 CCommDbTest020_06::~CCommDbTest020_06() |
|
332 { |
|
333 } |
|
334 |
|
335 |
|
336 TVerdict CCommDbTest020_06::doTestStepPreambleL() |
|
337 { |
|
338 openDbL(); |
|
339 return EPass; |
|
340 } |
|
341 |
|
342 TInt CCommDbTest020_06::executeStepL() |
|
343 { |
|
344 TInt ret=KErrGeneral; |
|
345 TBuf<64> buffer; |
|
346 |
|
347 //Check that the agent setting can be overridden |
|
348 |
|
349 _LIT(KAgent1,"Agent1"); |
|
350 _LIT(KAgent2,"Agent2"); |
|
351 |
|
352 //Set the agent |
|
353 TRAPD(r1,iTheDb->SetAgentL(TPtrC(DIAL_OUT_ISP),KAgent1)); |
|
354 //Add a new agent and verify |
|
355 TRAPD(r2,iTheDb->SetAgentL(TPtrC(DIAL_OUT_ISP),KAgent2)); |
|
356 TRAPD(r3,iTheDb->GetAgentL(TPtrC(DIAL_OUT_ISP),buffer)); |
|
357 if (r1==KErrNotSupported && r2==KErrNotSupported && r3==KErrNotSupported) |
|
358 ret = KErrNotSupported; |
|
359 |
|
360 return ret; |
|
361 } |
|
362 |
|
363 |
|
364 |
|
365 TVerdict CCommDbTest020_06::doTestStepL( ) |
|
366 { |
|
367 Log(_L("Step 020.06 called ")); |
|
368 |
|
369 |
|
370 if ( executeStepL() == KErrNotSupported ) |
|
371 iTestStepResult = EPass; |
|
372 else |
|
373 iTestStepResult = EFail; |
|
374 |
|
375 return iTestStepResult; |
|
376 } |
|
377 |
|
378 |
|
379 // |
|
380 // Test step 020.07 |
|
381 // |
|
382 |
|
383 // constructor |
|
384 CCommDbTest020_07::CCommDbTest020_07() |
|
385 { |
|
386 // store the name of this test case |
|
387 iTestStepName = _L("step_020_07"); |
|
388 } |
|
389 |
|
390 // destructor |
|
391 CCommDbTest020_07::~CCommDbTest020_07() |
|
392 { |
|
393 } |
|
394 |
|
395 |
|
396 TVerdict CCommDbTest020_07::doTestStepPreambleL() |
|
397 { |
|
398 openDbL(); |
|
399 return EPass; |
|
400 } |
|
401 |
|
402 TInt CCommDbTest020_07::executeStepL() |
|
403 { |
|
404 TInt ret=KErrGeneral; |
|
405 TBuf<64> buffer; |
|
406 |
|
407 //Check that the agent settings can be deleted |
|
408 |
|
409 _LIT(KAgent,"Agent"); |
|
410 _LIT(KExtension,"psd"); |
|
411 |
|
412 //Set the agent |
|
413 TRAPD(r1,iTheDb->SetAgentL(TPtrC(DIAL_OUT_ISP),KAgent)); |
|
414 TRAPD(r2,iTheDb->SetAgentExtL(TPtrC(DIAL_OUT_ISP),KExtension)); |
|
415 |
|
416 //Clear the settings |
|
417 TRAPD(r3,iTheDb->ClearAgentAndExtL( TPtrC(DIAL_OUT_ISP))); |
|
418 |
|
419 //Now try to read the settings |
|
420 TRAPD( r4, iTheDb->GetAgentL(TPtrC(DIAL_OUT_ISP),buffer) ); |
|
421 TRAPD( r5, iTheDb->GetAgentExtL(TPtrC(DIAL_OUT_ISP),buffer) ); |
|
422 |
|
423 if(r1==KErrNotSupported && r2==KErrNotSupported && r3==KErrNotSupported |
|
424 && r4==KErrNotSupported && r5==KErrNotSupported) |
|
425 { |
|
426 ret = KErrNotSupported; |
|
427 } |
|
428 |
|
429 return ret; |
|
430 } |
|
431 |
|
432 |
|
433 |
|
434 TVerdict CCommDbTest020_07::doTestStepL( ) |
|
435 { |
|
436 Log(_L("Step 020.07 called ")); |
|
437 |
|
438 |
|
439 if ( executeStepL() == KErrNotSupported ) |
|
440 iTestStepResult = EPass; |
|
441 else |
|
442 iTestStepResult = EFail; |
|
443 |
|
444 return iTestStepResult; |
|
445 } |
|
446 |
|
447 |
|
448 |
|
449 // |
|
450 // Test step 020.08 |
|
451 // |
|
452 |
|
453 // constructor |
|
454 CCommDbTest020_08::CCommDbTest020_08() |
|
455 { |
|
456 // store the name of this test case |
|
457 iTestStepName = _L("step_020_08"); |
|
458 } |
|
459 |
|
460 // destructor |
|
461 CCommDbTest020_08::~CCommDbTest020_08() |
|
462 { |
|
463 } |
|
464 |
|
465 TVerdict CCommDbTest020_08::doTestStepL( ) |
|
466 { |
|
467 Log(_L("Step 020.08 called ")); |
|
468 |
|
469 iTestStepResult = EPass; |
|
470 |
|
471 // Heap test for 020.01 |
|
472 |
|
473 CCommDbTest020_01* step020_01 = new(ELeave) CCommDbTest020_01; |
|
474 CleanupStack::PushL(step020_01); |
|
475 step020_01->iSuite = iSuite; |
|
476 if ( doTestStepWithHeapFailureL( *step020_01, KErrNotSupported) == EFail ) |
|
477 iTestStepResult = EFail; |
|
478 CleanupStack::PopAndDestroy(step020_01); |
|
479 |
|
480 |
|
481 // Heap test for 020.02 |
|
482 |
|
483 CCommDbTest020_02* step020_02 = new CCommDbTest020_02; |
|
484 CleanupStack::PushL(step020_02); |
|
485 step020_02->iSuite = iSuite; |
|
486 if ( doTestStepWithHeapFailureL( *step020_02, KErrNotSupported) == EFail ) |
|
487 iTestStepResult = EFail; |
|
488 CleanupStack::PopAndDestroy(step020_02); |
|
489 |
|
490 // Heap test for 020.03 |
|
491 |
|
492 CCommDbTest020_03* step020_03 = new CCommDbTest020_03; |
|
493 CleanupStack::PushL(step020_03); |
|
494 step020_03->iSuite = iSuite; |
|
495 if ( doTestStepWithHeapFailureL( *step020_03, KErrNotSupported) == EFail ) |
|
496 iTestStepResult = EFail; |
|
497 CleanupStack::PopAndDestroy(step020_03); |
|
498 |
|
499 |
|
500 // Heap test for 020.04 |
|
501 |
|
502 CCommDbTest020_04* step020_04 = new CCommDbTest020_04; |
|
503 CleanupStack::PushL(step020_04); |
|
504 step020_04->iSuite = iSuite; |
|
505 if ( doTestStepWithHeapFailureL( *step020_04, KErrNotSupported) == EFail ) |
|
506 iTestStepResult = EFail; |
|
507 CleanupStack::PopAndDestroy(step020_04); |
|
508 |
|
509 |
|
510 // Heap test for 020.06 |
|
511 |
|
512 CCommDbTest020_06* step020_06 = new CCommDbTest020_06; |
|
513 CleanupStack::PushL(step020_06); |
|
514 step020_06->iSuite = iSuite; |
|
515 if ( doTestStepWithHeapFailureL( *step020_06, KErrNotSupported) == EFail ) |
|
516 iTestStepResult = EFail; |
|
517 CleanupStack::PopAndDestroy(step020_06); |
|
518 |
|
519 |
|
520 |
|
521 // Heap test for 020.07 |
|
522 |
|
523 CCommDbTest020_07* step020_07 = new CCommDbTest020_07; |
|
524 CleanupStack::PushL(step020_07); |
|
525 step020_07->iSuite = iSuite; |
|
526 if ( doTestStepWithHeapFailureL( *step020_07, KErrNotSupported) == EFail ) |
|
527 iTestStepResult = EFail; |
|
528 CleanupStack::PopAndDestroy(step020_07); |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 return iTestStepResult; |
|
534 |
|
535 } |
|