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