|
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 003.01 - 003.07 |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 #include <commdb.h> |
|
21 |
|
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_003_xx.h" |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 // |
|
34 // Test step 003.001 |
|
35 // |
|
36 |
|
37 // constructor |
|
38 CCommDbTest003_01::CCommDbTest003_01() |
|
39 { |
|
40 // store the name of this test case |
|
41 iTestStepName = _L("step_003_01"); |
|
42 } |
|
43 |
|
44 // destructor |
|
45 CCommDbTest003_01::~CCommDbTest003_01() |
|
46 { |
|
47 } |
|
48 |
|
49 |
|
50 TVerdict CCommDbTest003_01::doTestStepPreambleL() |
|
51 { |
|
52 openDbL(); |
|
53 return EPass; |
|
54 } |
|
55 |
|
56 TInt CCommDbTest003_01::myOpenTableL() |
|
57 { |
|
58 |
|
59 // Because OpenTableLC puts an object on the cleanup stack, |
|
60 // we cant use TRAP() on it as this causes a Panic during the |
|
61 // UnTrap cleanup, so we write our own leaving wrapper function. |
|
62 iTheView=iTheDb->OpenTableLC(TPtrC(DIAL_OUT_ISP)); |
|
63 CleanupStack::Pop(); |
|
64 |
|
65 //if this test does not trap, it can only ever return KErrNone |
|
66 return KErrNone; |
|
67 |
|
68 } |
|
69 |
|
70 TInt CCommDbTest003_01::executeStepL() |
|
71 { |
|
72 TInt ret=KErrNone; |
|
73 |
|
74 TRAPD(r, ret = myOpenTableL() ); |
|
75 |
|
76 if ( r==KErrNone ) |
|
77 { |
|
78 //if there were no traps, return the value call to the api |
|
79 r=ret; |
|
80 } |
|
81 |
|
82 return r; |
|
83 } |
|
84 |
|
85 |
|
86 TVerdict CCommDbTest003_01::doTestStepL( ) |
|
87 { |
|
88 |
|
89 Log(_L("Step 003.01 called ")); |
|
90 |
|
91 if ( executeStepL() == KErrNone ) |
|
92 iTestStepResult = EPass; |
|
93 else |
|
94 iTestStepResult = EFail; |
|
95 |
|
96 |
|
97 return iTestStepResult; |
|
98 } |
|
99 |
|
100 |
|
101 |
|
102 // |
|
103 // Test step 003.002 |
|
104 // |
|
105 |
|
106 // constructor |
|
107 CCommDbTest003_02::CCommDbTest003_02() |
|
108 { |
|
109 // store the name of this test case |
|
110 iTestStepName = _L("step_003_02"); |
|
111 } |
|
112 |
|
113 // destructor |
|
114 CCommDbTest003_02::~CCommDbTest003_02() |
|
115 { |
|
116 } |
|
117 |
|
118 |
|
119 TVerdict CCommDbTest003_02::doTestStepPreambleL() |
|
120 { |
|
121 openDbL(); |
|
122 return EPass; |
|
123 } |
|
124 |
|
125 #define INVALID_TABLE_NAME _S("Inval") |
|
126 |
|
127 |
|
128 TInt CCommDbTest003_02::myOpenTableL() |
|
129 { |
|
130 |
|
131 // Because OpenTableLC puts an object on the cleanup stack, |
|
132 // we cant use TRAP() on it as this causes a Panic during the |
|
133 // UnTrap cleanup, so we write our own leaving wrapper function. |
|
134 iTheView=iTheDb->OpenTableLC(TPtrC(INVALID_TABLE_NAME)); |
|
135 CleanupStack::Pop(); |
|
136 |
|
137 //This test should trap, if it gets here then something has gone wrong |
|
138 return KErrGeneral; |
|
139 |
|
140 } |
|
141 |
|
142 |
|
143 TInt CCommDbTest003_02::executeStepL() |
|
144 { |
|
145 TInt ret=KErrNone; |
|
146 |
|
147 TRAPD(r, ret = myOpenTableL() ); |
|
148 |
|
149 if ( r==KErrNone ) |
|
150 { |
|
151 //if there were no traps, return the value call to the api |
|
152 r=ret; |
|
153 } |
|
154 |
|
155 return r; |
|
156 } |
|
157 |
|
158 |
|
159 |
|
160 TVerdict CCommDbTest003_02::doTestStepL( ) |
|
161 { |
|
162 Log(_L("Step 003.02 called ")); |
|
163 |
|
164 |
|
165 //Test for the expected return value |
|
166 if ( executeStepL() == KErrNotFound ) |
|
167 iTestStepResult = EPass; |
|
168 else |
|
169 iTestStepResult = EFail; |
|
170 |
|
171 |
|
172 return iTestStepResult; |
|
173 } |
|
174 |
|
175 |
|
176 |
|
177 // |
|
178 // Test step 003.003 |
|
179 // |
|
180 |
|
181 // constructor |
|
182 CCommDbTest003_03::CCommDbTest003_03() |
|
183 { |
|
184 // store the name of this test case |
|
185 iTestStepName = _L("step_003_03"); |
|
186 } |
|
187 |
|
188 // destructor |
|
189 CCommDbTest003_03::~CCommDbTest003_03() |
|
190 { |
|
191 } |
|
192 |
|
193 |
|
194 TVerdict CCommDbTest003_03::doTestStepPreambleL() |
|
195 { |
|
196 openDbL(); |
|
197 return EPass; |
|
198 } |
|
199 |
|
200 #define ZERO_LENGTH_TABLE_NAME _S("") |
|
201 |
|
202 TInt CCommDbTest003_03::myOpenTableL() |
|
203 { |
|
204 |
|
205 // Because OpenTableLC puts an object on the cleanup stack, |
|
206 // we cant use TRAP() on it as this causes a Panic during the |
|
207 // UnTrap cleanup, so we write our own leaving wrapper function. |
|
208 |
|
209 iTheView = iTheDb->OpenTableLC(TPtrC(ZERO_LENGTH_TABLE_NAME)); |
|
210 CleanupStack::Pop(); |
|
211 |
|
212 //This test should trap, if we get here something has gone wrong |
|
213 return KErrGeneral; |
|
214 } |
|
215 |
|
216 |
|
217 TInt CCommDbTest003_03::executeStepL() |
|
218 { |
|
219 TInt ret=KErrNone; |
|
220 |
|
221 TRAPD(r, ret = myOpenTableL() ); |
|
222 |
|
223 if ( r==KErrNone ) |
|
224 { |
|
225 //if there were no traps, return the value call to the api |
|
226 r=ret; |
|
227 } |
|
228 |
|
229 return r; |
|
230 } |
|
231 |
|
232 |
|
233 TVerdict CCommDbTest003_03::doTestStepL( ) |
|
234 { |
|
235 Log(_L("Step 003.03 called ")); |
|
236 |
|
237 |
|
238 //Test for the expected return value |
|
239 if ( executeStepL() == KErrArgument ) |
|
240 iTestStepResult = EPass; |
|
241 else |
|
242 iTestStepResult = EFail; |
|
243 |
|
244 |
|
245 return iTestStepResult; |
|
246 } |
|
247 |
|
248 // |
|
249 // Test step 003.04 |
|
250 // |
|
251 |
|
252 // constructor |
|
253 CCommDbTest003_04::CCommDbTest003_04() |
|
254 { |
|
255 // store the name of this test case |
|
256 iTestStepName = _L("step_003_04"); |
|
257 } |
|
258 |
|
259 // destructor |
|
260 CCommDbTest003_04::~CCommDbTest003_04() |
|
261 { |
|
262 } |
|
263 |
|
264 TVerdict CCommDbTest003_04::doTestStepPreambleL() |
|
265 { |
|
266 openDbL(); |
|
267 return EPass; |
|
268 } |
|
269 |
|
270 #define LONG_TABLE_NAME _S("aVeryVeryLongTableNameThatIsLongerThanFiftyCharacters") |
|
271 |
|
272 |
|
273 TInt CCommDbTest003_04::myOpenTableL() |
|
274 { |
|
275 |
|
276 // Because OpenTableLC puts an object on the cleanup stack, |
|
277 // we cant use TRAP() on it as this causes a Panic during the |
|
278 // UnTrap cleanup, so we write our own leaving wrapper function. |
|
279 iTheView=iTheDb->OpenTableLC(TPtrC(LONG_TABLE_NAME)); |
|
280 CleanupStack::Pop(); |
|
281 |
|
282 //This test will cause a PANIC, so we will never get here |
|
283 return KErrGeneral; |
|
284 } |
|
285 |
|
286 |
|
287 TInt CCommDbTest003_04::executeStepL() |
|
288 { |
|
289 TInt ret=KErrNone; |
|
290 |
|
291 TRAPD(r, myOpenTableL() ); |
|
292 |
|
293 if ( r==KErrNone ) |
|
294 { |
|
295 //if there were no traps, return the value call to the api |
|
296 r=ret; |
|
297 } |
|
298 |
|
299 return r; |
|
300 } |
|
301 |
|
302 |
|
303 TVerdict CCommDbTest003_04::doTestStepL( ) |
|
304 { |
|
305 |
|
306 User::SetJustInTime(EFalse); |
|
307 |
|
308 if ( executeStepL() == KErrArgument ) |
|
309 iTestStepResult = EPass; |
|
310 else |
|
311 iTestStepResult = EFail; |
|
312 |
|
313 return iTestStepResult; |
|
314 } |
|
315 // |
|
316 // Test step 003.05 |
|
317 // |
|
318 |
|
319 // constructor |
|
320 CCommDbTest003_05::CCommDbTest003_05() |
|
321 { |
|
322 // store the name of this test case |
|
323 iTestStepName = _L("step_003_05"); |
|
324 } |
|
325 |
|
326 // destructor |
|
327 CCommDbTest003_05::~CCommDbTest003_05() |
|
328 { |
|
329 } |
|
330 |
|
331 |
|
332 TVerdict CCommDbTest003_05::doTestStepPreambleL() |
|
333 { |
|
334 openDbL(); |
|
335 return EPass; |
|
336 } |
|
337 |
|
338 //The CONNECTION_PREFERENCES table isn't really a public table, |
|
339 //but someone still could try to open it. |
|
340 #define CONNECTION_PREFERENCES _S("ConnectionPreferences") |
|
341 |
|
342 TInt CCommDbTest003_05::myOpenTableL() |
|
343 { |
|
344 |
|
345 // Because OpenTableLC puts an object on the cleanup stack, |
|
346 // we cant use TRAP() on it as this causes a Panic during the |
|
347 // UnTrap cleanup, so we write our own leaving wrapper function. |
|
348 iTheView=iTheDb->OpenTableLC(TPtrC( CONNECTION_PREFERENCES )); |
|
349 CleanupStack::Pop(); |
|
350 |
|
351 //This test should leave, so we will never reach here |
|
352 return KErrGeneral; |
|
353 } |
|
354 |
|
355 TInt CCommDbTest003_05::executeStepL() |
|
356 { |
|
357 TInt ret=KErrNone; |
|
358 |
|
359 TRAPD(r, ret = myOpenTableL() ); |
|
360 |
|
361 if ( r==KErrNone ) |
|
362 { |
|
363 //if there were no traps, return the value call to the api |
|
364 r=ret; |
|
365 } |
|
366 |
|
367 return r; |
|
368 } |
|
369 |
|
370 |
|
371 |
|
372 TVerdict CCommDbTest003_05::doTestStepL( ) |
|
373 { |
|
374 Log(_L("Step 003.05 called ")); |
|
375 |
|
376 |
|
377 if ( executeStepL() == KErrAccessDenied ) |
|
378 iTestStepResult = EPass; |
|
379 else |
|
380 iTestStepResult = EFail; |
|
381 |
|
382 return iTestStepResult; |
|
383 } |
|
384 |
|
385 // |
|
386 // Test step 003.006 |
|
387 // |
|
388 |
|
389 // constructor |
|
390 CCommDbTest003_06::CCommDbTest003_06() |
|
391 { |
|
392 // store the name of this test case |
|
393 iTestStepName = _L("step_003_06"); |
|
394 } |
|
395 |
|
396 // destructor |
|
397 CCommDbTest003_06::~CCommDbTest003_06() |
|
398 { |
|
399 } |
|
400 |
|
401 |
|
402 TVerdict CCommDbTest003_06::doTestStepPreambleL() |
|
403 { |
|
404 openDbL(); |
|
405 return EPass; |
|
406 } |
|
407 |
|
408 #define GLOBAL_SETTINGS _S("GlobalSettings") |
|
409 |
|
410 TInt CCommDbTest003_06::myOpenTableL() |
|
411 { |
|
412 |
|
413 // Because OpenTableLC puts an object on the cleanup stack, |
|
414 // we cant use TRAP() on it as this causes a Panic during the |
|
415 // UnTrap cleanup, so we write our own leaving wrapper function. |
|
416 iTheView=iTheDb->OpenTableLC(TPtrC( GLOBAL_SETTINGS )); |
|
417 CleanupStack::Pop(); |
|
418 |
|
419 //This test should leave, so we will never reach here |
|
420 return KErrGeneral; |
|
421 } |
|
422 |
|
423 TInt CCommDbTest003_06::executeStepL() |
|
424 { |
|
425 TInt ret=KErrNone; |
|
426 |
|
427 |
|
428 TRAPD(r, ret = myOpenTableL() ); |
|
429 |
|
430 if ( r==KErrNone ) |
|
431 { |
|
432 //if there were no traps, return the value call to the api |
|
433 r=ret; |
|
434 } |
|
435 |
|
436 return r; |
|
437 } |
|
438 |
|
439 |
|
440 TVerdict CCommDbTest003_06::doTestStepL( ) |
|
441 { |
|
442 Log(_L("Step 003.06 called ")); |
|
443 |
|
444 |
|
445 if ( executeStepL() == KErrNotFound ) |
|
446 iTestStepResult = EPass; |
|
447 else |
|
448 iTestStepResult = EFail; |
|
449 |
|
450 return iTestStepResult; |
|
451 } |
|
452 |
|
453 // |
|
454 // Test step 003.07 |
|
455 // |
|
456 |
|
457 // constructor |
|
458 CCommDbTest003_07::CCommDbTest003_07() |
|
459 { |
|
460 // store the name of this test case |
|
461 iTestStepName = _L("step_003_07"); |
|
462 } |
|
463 |
|
464 // destructor |
|
465 CCommDbTest003_07::~CCommDbTest003_07() |
|
466 { |
|
467 } |
|
468 |
|
469 TVerdict CCommDbTest003_07::doTestStepL( ) |
|
470 { |
|
471 Log(_L("Step 003.07 called ")); |
|
472 |
|
473 iTestStepResult = EPass; |
|
474 |
|
475 //Heap test for 003.01 |
|
476 |
|
477 CCommDbTest003_01* step003_01 = new CCommDbTest003_01; |
|
478 CleanupStack::PushL(step003_01); |
|
479 step003_01->iSuite = iSuite; |
|
480 doTestStepWithHeapFailureL( *step003_01, KErrNone); |
|
481 if( step003_01->iTestStepResult == EFail ) |
|
482 iTestStepResult = EFail; |
|
483 CleanupStack::PopAndDestroy(step003_01); |
|
484 |
|
485 |
|
486 //Heap test for 003.02 |
|
487 |
|
488 CCommDbTest003_02* step003_02 = new CCommDbTest003_02; |
|
489 CleanupStack::PushL(step003_02); |
|
490 step003_02->iSuite = iSuite; |
|
491 doTestStepWithHeapFailureL( *step003_02, KErrNotFound); |
|
492 if( step003_02->iTestStepResult == EFail ) |
|
493 iTestStepResult = EFail; |
|
494 CleanupStack::PopAndDestroy(step003_02); |
|
495 |
|
496 |
|
497 //Heap test for 003.03 |
|
498 |
|
499 CCommDbTest003_03* step003_03 = new CCommDbTest003_03; |
|
500 CleanupStack::PushL(step003_03); |
|
501 step003_03->iSuite = iSuite; |
|
502 doTestStepWithHeapFailureL( *step003_03, KErrArgument); |
|
503 if( step003_03->iTestStepResult == EFail ) |
|
504 iTestStepResult = EFail; |
|
505 CleanupStack::PopAndDestroy(step003_03); |
|
506 |
|
507 //Heap test for 003.04 - see test step 3.08 |
|
508 |
|
509 //Heap test for 003.05 |
|
510 |
|
511 CCommDbTest003_05* step003_05 = new CCommDbTest003_05; |
|
512 CleanupStack::PushL(step003_05); |
|
513 step003_05->iSuite = iSuite; |
|
514 doTestStepWithHeapFailureL( *step003_05, KErrAccessDenied); |
|
515 if( step003_05->iTestStepResult == EFail ) |
|
516 iTestStepResult = EFail; |
|
517 CleanupStack::PopAndDestroy(step003_05); |
|
518 |
|
519 |
|
520 //Heap test for 003.06 |
|
521 |
|
522 CCommDbTest003_06* step003_06 = new CCommDbTest003_06; |
|
523 CleanupStack::PushL(step003_06); |
|
524 step003_06->iSuite = iSuite; |
|
525 doTestStepWithHeapFailureL( *step003_06, KErrNotFound); |
|
526 if( step003_06->iTestStepResult == EFail ) |
|
527 iTestStepResult = EFail; |
|
528 CleanupStack::PopAndDestroy(step003_06); |
|
529 |
|
530 |
|
531 return iTestStepResult; |
|
532 } |
|
533 |
|
534 // |
|
535 // Test step 003.08 |
|
536 // |
|
537 |
|
538 // constructor |
|
539 CCommDbTest003_08::CCommDbTest003_08() |
|
540 { |
|
541 // store the name of this test case |
|
542 iTestStepName = _L("step_003_08"); |
|
543 } |
|
544 |
|
545 // destructor |
|
546 CCommDbTest003_08::~CCommDbTest003_08() |
|
547 { |
|
548 } |
|
549 |
|
550 TVerdict CCommDbTest003_08::doTestStepL( ) |
|
551 { |
|
552 |
|
553 iTestStepResult = EPass; |
|
554 |
|
555 //Heap test for 003.04 - a panic test |
|
556 |
|
557 CCommDbTest003_04* step003_04 = new CCommDbTest003_04; |
|
558 CleanupStack::PushL(step003_04); |
|
559 step003_04->iSuite = iSuite; |
|
560 if ( doTestStepWithHeapFailureL( *step003_04, KErrNotFound) == EFail ) |
|
561 iTestStepResult = EFail; |
|
562 CleanupStack::PopAndDestroy(step003_04); |
|
563 |
|
564 return iTestStepResult; |
|
565 } |