|
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 012.XX |
|
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_012_xx.h" |
|
29 |
|
30 |
|
31 |
|
32 // |
|
33 // Test step 012.001 |
|
34 // |
|
35 |
|
36 // constructor |
|
37 CCommDbTest012_01::CCommDbTest012_01() |
|
38 { |
|
39 // store the name of this test case |
|
40 iTestStepName = _L("step_012_01"); |
|
41 } |
|
42 |
|
43 // destructor |
|
44 CCommDbTest012_01::~CCommDbTest012_01() |
|
45 { |
|
46 } |
|
47 |
|
48 |
|
49 TVerdict CCommDbTest012_01::doTestStepPreambleL() |
|
50 { |
|
51 openDbL(); |
|
52 return EPass; |
|
53 } |
|
54 |
|
55 |
|
56 TInt CCommDbTest012_01::executeStepL() |
|
57 { |
|
58 TInt ret=KErrNone; |
|
59 |
|
60 //This query should select 3 records |
|
61 iTheView = iTheDb->OpenViewLC( TPtrC(DIAL_IN_ISP),_L("select * from DialInISP where Ifname='PPP'") ); |
|
62 CleanupStack::Pop(); |
|
63 |
|
64 //Now check that the records are what we expect |
|
65 CDBLEAVE( iTheView->GotoFirstRecord(), KErrNone ); |
|
66 |
|
67 //Read the value from the field and compare it to the expected value |
|
68 TBuf<KCommsDbSvrMaxFieldLength> value; |
|
69 iTheView->ReadTextL( TPtrC(COMMDB_NAME), value ); |
|
70 if( value.Compare(_L("Record #1")) ) |
|
71 { |
|
72 ret = KErrGeneral; |
|
73 } |
|
74 |
|
75 CDBLEAVE( iTheView->GotoNextRecord(), KErrNone ); |
|
76 iTheView->ReadTextL( TPtrC(COMMDB_NAME), value ); |
|
77 if( value.Compare(_L("Record #2")) ) |
|
78 { |
|
79 ret = KErrGeneral; |
|
80 } |
|
81 |
|
82 CDBLEAVE( iTheView->GotoNextRecord(), KErrNone ); |
|
83 iTheView->ReadTextL( TPtrC(COMMDB_NAME), value ); |
|
84 if( value.Compare(_L("Record #5 (Read Only)")) ) |
|
85 { |
|
86 ret = KErrGeneral; |
|
87 } |
|
88 |
|
89 CDBLEAVE( ret = iTheView->GotoNextRecord(), KErrNotFound); |
|
90 |
|
91 return ret; |
|
92 } |
|
93 |
|
94 |
|
95 |
|
96 TVerdict CCommDbTest012_01::doTestStepL( ) |
|
97 { |
|
98 Log(_L("Step 012.01 called ")); |
|
99 |
|
100 |
|
101 if ( executeStepL() == KErrNotFound ) |
|
102 iTestStepResult = EPass; |
|
103 else |
|
104 iTestStepResult = EFail; |
|
105 |
|
106 |
|
107 return iTestStepResult; |
|
108 } |
|
109 |
|
110 |
|
111 // |
|
112 // Test step 012.02 |
|
113 // |
|
114 |
|
115 // constructor |
|
116 CCommDbTest012_02::CCommDbTest012_02() |
|
117 { |
|
118 // store the name of this test case |
|
119 iTestStepName = _L("step_012_02"); |
|
120 |
|
121 } |
|
122 |
|
123 // destructor |
|
124 CCommDbTest012_02::~CCommDbTest012_02() |
|
125 { |
|
126 } |
|
127 |
|
128 TVerdict CCommDbTest012_02::doTestStepPreambleL() |
|
129 { |
|
130 openDbL(); |
|
131 return EPass; |
|
132 } |
|
133 |
|
134 |
|
135 TInt CCommDbTest012_02::executeStepL() |
|
136 { |
|
137 TInt ret=KErrNone; |
|
138 |
|
139 //This query should select 0 records |
|
140 iTheView = iTheDb->OpenViewLC( TPtrC(DIAL_IN_ISP),_L("select * from DialInISP where Ifname='XXX'") ); |
|
141 CleanupStack::Pop(); |
|
142 |
|
143 CDBLEAVE(ret = iTheView->GotoFirstRecord(), KErrNotFound ); |
|
144 |
|
145 return ret; |
|
146 } |
|
147 |
|
148 |
|
149 |
|
150 TVerdict CCommDbTest012_02::doTestStepL( ) |
|
151 { |
|
152 Log(_L("Step 012.02 called ")); |
|
153 |
|
154 if ( executeStepL() == KErrNotFound ) |
|
155 iTestStepResult = EPass; |
|
156 else |
|
157 iTestStepResult = EFail; |
|
158 |
|
159 return iTestStepResult; |
|
160 } |
|
161 |
|
162 |
|
163 // |
|
164 // Test step 012.03 |
|
165 // |
|
166 |
|
167 // constructor |
|
168 CCommDbTest012_03::CCommDbTest012_03() |
|
169 { |
|
170 // store the name of this test case |
|
171 iTestStepName = _L("step_012_03"); |
|
172 |
|
173 } |
|
174 |
|
175 // destructor |
|
176 CCommDbTest012_03::~CCommDbTest012_03() |
|
177 { |
|
178 } |
|
179 |
|
180 |
|
181 TVerdict CCommDbTest012_03::doTestStepPreambleL() |
|
182 { |
|
183 openDbL(); |
|
184 return EPass; |
|
185 } |
|
186 |
|
187 TInt CCommDbTest012_03::executeStepL() |
|
188 { |
|
189 TInt ret=KErrNone; |
|
190 |
|
191 //This query should select 1 record |
|
192 iTheView = iTheDb->OpenViewLC( TPtrC(DIAL_IN_ISP),_L("select * from DialInISP where Name='Record #3'") ); |
|
193 CleanupStack::Pop(); |
|
194 |
|
195 //Read the value from the field and compare it to the expected value |
|
196 CDBLEAVE( iTheView->GotoFirstRecord(), KErrNone ); |
|
197 TBuf<KCommsDbSvrMaxFieldLength> value; |
|
198 iTheView->ReadTextL( TPtrC(COMMDB_NAME), value ); |
|
199 if( value.Compare(_L("Record #3")) ) |
|
200 { |
|
201 ret = KErrGeneral; |
|
202 } |
|
203 |
|
204 //Check that there was only one record |
|
205 CDBLEAVE( ret = iTheView->GotoNextRecord(), KErrNotFound ); |
|
206 |
|
207 return ret; |
|
208 } |
|
209 |
|
210 |
|
211 |
|
212 TVerdict CCommDbTest012_03::doTestStepL( ) |
|
213 { |
|
214 Log(_L("Step 012.03 called ")); |
|
215 |
|
216 if ( executeStepL() == KErrNotFound ) |
|
217 iTestStepResult = EPass; |
|
218 else |
|
219 iTestStepResult = EFail; |
|
220 |
|
221 return iTestStepResult; |
|
222 } |
|
223 |
|
224 |
|
225 // |
|
226 // Test step 012.04 |
|
227 // |
|
228 |
|
229 // constructor |
|
230 CCommDbTest012_04::CCommDbTest012_04() |
|
231 { |
|
232 // store the name of this test case |
|
233 iTestStepName = _L("step_012_04"); |
|
234 // default to no local objects allocated |
|
235 iLocalObjects = EFalse; |
|
236 } |
|
237 |
|
238 // destructor |
|
239 CCommDbTest012_04::~CCommDbTest012_04() |
|
240 { |
|
241 } |
|
242 |
|
243 TVerdict CCommDbTest012_04::doTestStepPreambleL() |
|
244 { |
|
245 openDbL(); |
|
246 return EPass; |
|
247 } |
|
248 |
|
249 |
|
250 TInt CCommDbTest012_04::executeStepL() |
|
251 { |
|
252 TInt ret=KErrNone; |
|
253 |
|
254 //This query should select al1 records |
|
255 iTheView = iTheDb->OpenViewLC( TPtrC(DIAL_IN_ISP),_L("select * from DialInISP") ); |
|
256 CleanupStack::Pop(); |
|
257 |
|
258 //For each expected record read the value from the field and compare it to the expected value |
|
259 CDBLEAVE( iTheView->GotoFirstRecord(), KErrNone ); |
|
260 TBuf<KCommsDbSvrMaxFieldLength> value; |
|
261 iTheView->ReadTextL( TPtrC(COMMDB_NAME), value ); |
|
262 if( value.Compare(_L("Record #1")) ) |
|
263 { |
|
264 ret = KErrGeneral; |
|
265 } |
|
266 |
|
267 CDBLEAVE( iTheView->GotoNextRecord(), KErrNone ); |
|
268 iTheView->ReadTextL( TPtrC(COMMDB_NAME), value ); |
|
269 if( value.Compare(_L("Record #2")) ) |
|
270 { |
|
271 ret = KErrGeneral; |
|
272 } |
|
273 |
|
274 CDBLEAVE( iTheView->GotoNextRecord(), KErrNone ); |
|
275 iTheView->ReadTextL( TPtrC(COMMDB_NAME), value ); |
|
276 if( value.Compare(_L("Record #3")) ) |
|
277 { |
|
278 ret = KErrGeneral; |
|
279 } |
|
280 |
|
281 CDBLEAVE( iTheView->GotoNextRecord(), KErrNone ); |
|
282 iTheView->ReadTextL( TPtrC(COMMDB_NAME), value ); |
|
283 if( value.Compare(_L("Record #4")) ) |
|
284 { |
|
285 ret = KErrGeneral; |
|
286 } |
|
287 |
|
288 CDBLEAVE( iTheView->GotoNextRecord(), KErrNone ); |
|
289 iTheView->ReadTextL( TPtrC(COMMDB_NAME), value ); |
|
290 if( value.Compare(_L("Record #5")) ) |
|
291 { |
|
292 ret = KErrGeneral; |
|
293 } |
|
294 //Check there no more records |
|
295 |
|
296 CDBLEAVE( ret = iTheView->GotoNextRecord(), KErrNotFound ); |
|
297 |
|
298 return ret; |
|
299 } |
|
300 |
|
301 |
|
302 |
|
303 TVerdict CCommDbTest012_04::doTestStepL( ) |
|
304 { |
|
305 Log(_L("Step 012.04 called ")); |
|
306 |
|
307 if ( executeStepL() == KErrNotFound ) |
|
308 iTestStepResult = EPass; |
|
309 else |
|
310 iTestStepResult = EFail; |
|
311 |
|
312 |
|
313 return iTestStepResult; |
|
314 } |
|
315 |
|
316 |
|
317 // |
|
318 // Test step 012.05 |
|
319 // |
|
320 |
|
321 // constructor |
|
322 CCommDbTest012_05::CCommDbTest012_05() |
|
323 { |
|
324 // store the name of this test case |
|
325 iTestStepName = _L("step_012_05"); |
|
326 // default to no local objects allocated |
|
327 iLocalObjects = EFalse; |
|
328 } |
|
329 |
|
330 // destructor |
|
331 CCommDbTest012_05::~CCommDbTest012_05() |
|
332 { |
|
333 } |
|
334 |
|
335 TVerdict CCommDbTest012_05::doTestStepPreambleL() |
|
336 { |
|
337 openDbL(); |
|
338 return EPass; |
|
339 } |
|
340 |
|
341 TInt CCommDbTest012_05::myOpenViewL() |
|
342 { |
|
343 //This query contains an erroneous query |
|
344 // TRAPD( r, iTheView = iTheDb->OpenViewLC( TPtrC(DIAL_IN_ISP),_L("select * from DialInISP where") ) ); |
|
345 iTheView = iTheDb->OpenViewLC( TPtrC(DIAL_IN_ISP),_L("select * from DialInISP where") ) ; |
|
346 |
|
347 |
|
348 return 0; |
|
349 } |
|
350 |
|
351 |
|
352 TInt CCommDbTest012_05::executeStepL() |
|
353 { |
|
354 TInt ret=KErrGeneral; |
|
355 |
|
356 TRAPD(r, myOpenViewL() ); |
|
357 |
|
358 if ( r!=KErrNone ) |
|
359 ret = r; |
|
360 |
|
361 |
|
362 |
|
363 return ret; |
|
364 } |
|
365 |
|
366 |
|
367 |
|
368 TVerdict CCommDbTest012_05::doTestStepL( ) |
|
369 { |
|
370 Log(_L("Step 012.05 called ")); |
|
371 |
|
372 |
|
373 if ( executeStepL() == KErrArgument ) |
|
374 iTestStepResult = EPass; |
|
375 else |
|
376 iTestStepResult = EFail; |
|
377 |
|
378 |
|
379 |
|
380 return iTestStepResult; |
|
381 } |
|
382 |
|
383 |
|
384 // |
|
385 // Test step 012.06 |
|
386 // |
|
387 |
|
388 // constructor |
|
389 CCommDbTest012_06::CCommDbTest012_06() |
|
390 { |
|
391 // store the name of this test case |
|
392 iTestStepName = _L("step_012_06"); |
|
393 } |
|
394 |
|
395 // destructor |
|
396 CCommDbTest012_06::~CCommDbTest012_06() |
|
397 { |
|
398 } |
|
399 |
|
400 TVerdict CCommDbTest012_06::doTestStepPreambleL() |
|
401 { |
|
402 openDbL(); |
|
403 return EPass; |
|
404 } |
|
405 |
|
406 TInt CCommDbTest012_06::myOpenViewL() |
|
407 { |
|
408 //This query contains an erroneous query |
|
409 iTheView = iTheDb->OpenViewLC( TPtrC(DIAL_IN_ISP),_L("") ); |
|
410 |
|
411 |
|
412 return 0; |
|
413 } |
|
414 |
|
415 |
|
416 TInt CCommDbTest012_06::executeStepL() |
|
417 { |
|
418 TInt ret=KErrGeneral; |
|
419 |
|
420 TRAPD(r, myOpenViewL() ); |
|
421 |
|
422 if (r!=KErrNone ) |
|
423 ret = r; |
|
424 |
|
425 return ret; |
|
426 } |
|
427 |
|
428 |
|
429 |
|
430 TVerdict CCommDbTest012_06::doTestStepL( ) |
|
431 { |
|
432 Log(_L("Step 012.06 called ")); |
|
433 |
|
434 if ( executeStepL() == KErrArgument ) |
|
435 iTestStepResult = EPass; |
|
436 else |
|
437 iTestStepResult = EFail; |
|
438 |
|
439 return iTestStepResult; |
|
440 } |
|
441 |
|
442 |
|
443 |
|
444 // |
|
445 // Test step 012.07 |
|
446 // |
|
447 |
|
448 // constructor |
|
449 CCommDbTest012_07::CCommDbTest012_07() |
|
450 { |
|
451 // store the name of this test case |
|
452 iTestStepName = _L("step_012_07"); |
|
453 } |
|
454 |
|
455 // destructor |
|
456 CCommDbTest012_07::~CCommDbTest012_07() |
|
457 { |
|
458 } |
|
459 |
|
460 TVerdict CCommDbTest012_07::doTestStepL( ) |
|
461 { |
|
462 Log(_L("Step 012.07 called ")); |
|
463 |
|
464 iTestStepResult = EPass; |
|
465 |
|
466 /* // Heap test for 012.01 |
|
467 |
|
468 #if 1 |
|
469 CCommDbTest012_01* step012_01 = new CCommDbTest012_01; |
|
470 CleanupStack::PushL(step012_01); |
|
471 step012_01->iSuite = iSuite; |
|
472 doTestStepWithHeapFailureL( *step012_01, KErrNotFound); |
|
473 if ( step012_01->iTestStepResult == EFail ) |
|
474 iTestStepResult = EFail; |
|
475 CleanupStack::PopAndDestroy(step012_01); |
|
476 #endif |
|
477 |
|
478 // Heap test for 012.02 |
|
479 |
|
480 CCommDbTest012_02* step012_02 = new CCommDbTest012_02; |
|
481 CleanupStack::PushL(step012_02); |
|
482 step012_02->iSuite = iSuite; |
|
483 doTestStepWithHeapFailureL( *step012_02, KErrNotFound); |
|
484 if ( step012_02->iTestStepResult == EFail ) |
|
485 iTestStepResult = EFail; |
|
486 CleanupStack::PopAndDestroy(step012_02); |
|
487 |
|
488 */ // Heap test for 012.03 |
|
489 |
|
490 CCommDbTest012_03* step012_03 = new CCommDbTest012_03; |
|
491 CleanupStack::PushL(step012_03); |
|
492 step012_03->iSuite = iSuite; |
|
493 doTestStepWithHeapFailureL( *step012_03, KErrNotFound); |
|
494 if ( step012_03->iTestStepResult == EFail ) |
|
495 iTestStepResult = EFail; |
|
496 CleanupStack::PopAndDestroy(step012_03); |
|
497 |
|
498 // Heap test for 012.04 |
|
499 |
|
500 CCommDbTest012_04* step012_04 = new CCommDbTest012_04; |
|
501 CleanupStack::PushL(step012_04); |
|
502 step012_04->iSuite = iSuite; |
|
503 doTestStepWithHeapFailureL( *step012_04, KErrNotFound); |
|
504 if( step012_04->iTestStepResult == EFail ) |
|
505 iTestStepResult = EFail; |
|
506 CleanupStack::PopAndDestroy(step012_04); |
|
507 |
|
508 // Heap test for 012.05 |
|
509 |
|
510 CCommDbTest012_05* step012_05 = new CCommDbTest012_05; |
|
511 CleanupStack::PushL(step012_05); |
|
512 step012_05->iSuite = iSuite; |
|
513 doTestStepWithHeapFailureL( *step012_05, KErrArgument); |
|
514 if( step012_05->iTestStepResult == EFail ) |
|
515 iTestStepResult = EFail; |
|
516 CleanupStack::PopAndDestroy(step012_05); |
|
517 |
|
518 |
|
519 // Heap test for 012.06 |
|
520 |
|
521 CCommDbTest012_06* step012_06 = new CCommDbTest012_06; |
|
522 CleanupStack::PushL(step012_06); |
|
523 step012_06->iSuite = iSuite; |
|
524 doTestStepWithHeapFailureL( *step012_06, KErrArgument); |
|
525 if( step012_06->iTestStepResult == EFail ) |
|
526 iTestStepResult = EFail; |
|
527 CleanupStack::PopAndDestroy(step012_06); |
|
528 |
|
529 return iTestStepResult; |
|
530 |
|
531 } |