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 Case 001.01 |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 |
|
21 // Test system includes |
|
22 #include <networking/log.h> |
|
23 #include <networking/teststep.h> |
|
24 #include "Teststepcommdb.h" |
|
25 #include "TestSuiteCommdb.h" |
|
26 #include "step_001_01.h" |
|
27 |
|
28 #include <commdb.h> |
|
29 |
|
30 // constructor |
|
31 CCommDbTest001_01::CCommDbTest001_01() |
|
32 { |
|
33 // store the name of this test case |
|
34 iTestStepName = _L("step_001_01"); |
|
35 } |
|
36 |
|
37 // destructor |
|
38 CCommDbTest001_01::~CCommDbTest001_01() |
|
39 { |
|
40 } |
|
41 |
|
42 TVerdict CCommDbTest001_01::doTestStepPreambleL() |
|
43 { |
|
44 return EPass; |
|
45 } |
|
46 |
|
47 TInt CCommDbTest001_01::executeStepL() |
|
48 { |
|
49 CCommsDatabase* TheDb = NULL; |
|
50 TRAPD( err, TheDb=CCommsDatabase::NewL() ); |
|
51 delete TheDb; |
|
52 return err; |
|
53 } |
|
54 |
|
55 // do Test step 001.01 |
|
56 TVerdict CCommDbTest001_01::doTestStepL( ) |
|
57 { |
|
58 TInt res; |
|
59 Log(_L("Step 001.01 called ")); |
|
60 res = executeStepL(); |
|
61 if (res == KErrNone) |
|
62 { |
|
63 iTestStepResult = EPass; |
|
64 } |
|
65 else |
|
66 { |
|
67 Log(_L("Step 001.01 failed with error: %d"),res); |
|
68 iTestStepResult = EFail; |
|
69 } |
|
70 |
|
71 return iTestStepResult; |
|
72 } |
|
73 |
|
74 // constructor |
|
75 CCommDbTest001_03::CCommDbTest001_03() |
|
76 { |
|
77 // store the name of this test case |
|
78 iTestStepName = _L("step_001_03"); |
|
79 } |
|
80 |
|
81 // destructor |
|
82 CCommDbTest001_03::~CCommDbTest001_03() |
|
83 { |
|
84 } |
|
85 |
|
86 TInt CCommDbTest001_03::executeStepL() |
|
87 { |
|
88 TInt ret = KErrNone; |
|
89 |
|
90 CCommsDatabase* TheDb = NULL; |
|
91 TRAPD( err, TheDb=CCommsDatabase::NewL() ); |
|
92 if (err != KErrNone) |
|
93 ret = err; |
|
94 |
|
95 delete TheDb; |
|
96 return ret; |
|
97 } |
|
98 |
|
99 // do Test step 001.03 |
|
100 TVerdict CCommDbTest001_03::doTestStepL( ) |
|
101 { |
|
102 |
|
103 Log(_L("Step 001.03 called ")); |
|
104 |
|
105 if (executeStepL() == KErrNone) |
|
106 iTestStepResult = EPass; |
|
107 else |
|
108 iTestStepResult = EFail; |
|
109 |
|
110 return iTestStepResult; |
|
111 } |
|
112 |
|
113 // constructor |
|
114 CCommDbTest001_04::CCommDbTest001_04() |
|
115 { |
|
116 // store the name of this test case |
|
117 iTestStepName = _L("step_001_04"); |
|
118 } |
|
119 |
|
120 // destructor |
|
121 CCommDbTest001_04::~CCommDbTest001_04() |
|
122 { |
|
123 } |
|
124 |
|
125 TVerdict CCommDbTest001_04::doTestStepPreambleL() |
|
126 { |
|
127 return EPass; |
|
128 } |
|
129 |
|
130 TInt CCommDbTest001_04::executeStepL() |
|
131 { |
|
132 CCommsDatabase* TheDb = NULL; |
|
133 TRAPD( err, TheDb=CCommsDatabase::NewL() ); |
|
134 |
|
135 delete TheDb; |
|
136 |
|
137 return err; |
|
138 } |
|
139 |
|
140 // do Test step 001.04 |
|
141 TVerdict CCommDbTest001_04::doTestStepL( ) |
|
142 { |
|
143 |
|
144 Log(_L("Step 001.04 called ")); |
|
145 if (executeStepL() == KErrNone) |
|
146 iTestStepResult = EPass; |
|
147 else |
|
148 iTestStepResult = EFail; |
|
149 |
|
150 |
|
151 return iTestStepResult; |
|
152 } |
|
153 |
|
154 // constructor |
|
155 CCommDbTest001_05::CCommDbTest001_05() |
|
156 { |
|
157 // store the name of this test case |
|
158 iTestStepName = _L("step_001_05"); |
|
159 } |
|
160 |
|
161 // destructor |
|
162 CCommDbTest001_05::~CCommDbTest001_05() |
|
163 { |
|
164 } |
|
165 |
|
166 TVerdict CCommDbTest001_05::doTestStepPreambleL() |
|
167 { |
|
168 // delete database file before running this test |
|
169 return EPass; |
|
170 } |
|
171 |
|
172 TInt CCommDbTest001_05::executeStepL() |
|
173 { |
|
174 TInt ret = KErrGeneral; |
|
175 |
|
176 CCommsDatabase* TheDb; |
|
177 TCommDbOpeningMethod openingMethod; |
|
178 TheDb=CCommsDatabase::NewL(openingMethod); |
|
179 |
|
180 if ( openingMethod == ECommDbOpened ) |
|
181 ret = KErrNone; |
|
182 |
|
183 delete TheDb; |
|
184 |
|
185 return ret; |
|
186 } |
|
187 |
|
188 // do Test step 001.05 |
|
189 TVerdict CCommDbTest001_05::doTestStepL( ) |
|
190 { |
|
191 |
|
192 Log(_L("Step 001.05 called ")); |
|
193 |
|
194 if (executeStepL() == KErrNone) |
|
195 iTestStepResult = EPass; |
|
196 else |
|
197 iTestStepResult = EFail; |
|
198 |
|
199 return iTestStepResult; |
|
200 } |
|
201 |
|
202 // constructor |
|
203 CCommDbTest001_07::CCommDbTest001_07() |
|
204 { |
|
205 // store the name of this test case |
|
206 iTestStepName = _L("step_001_07"); |
|
207 } |
|
208 |
|
209 // destructor |
|
210 CCommDbTest001_07::~CCommDbTest001_07() |
|
211 { |
|
212 } |
|
213 |
|
214 TInt CCommDbTest001_07::executeStepL() |
|
215 { |
|
216 // make sure database exists before running this test |
|
217 TInt ret = KErrGeneral; |
|
218 |
|
219 copyTestDatabase( EDatabase_1 ); |
|
220 |
|
221 CCommsDatabase* TheDb; |
|
222 TCommDbOpeningMethod openingMethod; |
|
223 TheDb=CCommsDatabase::NewL(openingMethod); |
|
224 |
|
225 if ( openingMethod == ECommDbOpened ) |
|
226 ret = KErrNone; |
|
227 |
|
228 delete TheDb; |
|
229 |
|
230 return ret; |
|
231 } |
|
232 |
|
233 // do Test step 001.07 |
|
234 TVerdict CCommDbTest001_07::doTestStepL( ) |
|
235 { |
|
236 |
|
237 Log(_L("Step 001.07 called ")); |
|
238 |
|
239 if (executeStepL() == KErrNone) |
|
240 iTestStepResult = EPass; |
|
241 else |
|
242 iTestStepResult = EFail; |
|
243 |
|
244 return iTestStepResult; |
|
245 } |
|
246 |
|
247 // constructor |
|
248 CCommDbTest001_08::CCommDbTest001_08() |
|
249 { |
|
250 // store the name of this test case |
|
251 iTestStepName = _L("step_001_08"); |
|
252 } |
|
253 |
|
254 // destructor |
|
255 CCommDbTest001_08::~CCommDbTest001_08() |
|
256 { |
|
257 } |
|
258 |
|
259 TInt CCommDbTest001_08::executeStepL() |
|
260 { |
|
261 TInt ret = KErrNone; |
|
262 |
|
263 CCommsDatabase* TheDb = NULL; |
|
264 TRAPD( err, TheDb=CCommsDatabase::NewL(EFalse) ); |
|
265 if (err != KErrNone) |
|
266 ret = err; |
|
267 |
|
268 // if we get here, test was successful |
|
269 delete TheDb; |
|
270 |
|
271 return ret; |
|
272 } |
|
273 |
|
274 // do Test step 001.08 |
|
275 TVerdict CCommDbTest001_08::doTestStepL( ) |
|
276 { |
|
277 |
|
278 Log(_L("Step 001.08 called ")); |
|
279 |
|
280 if (executeStepL() == KErrNone) |
|
281 iTestStepResult = EPass; |
|
282 else |
|
283 iTestStepResult = EFail; |
|
284 |
|
285 return iTestStepResult; |
|
286 } |
|
287 |
|
288 // constructor |
|
289 CCommDbTest001_09::CCommDbTest001_09() |
|
290 { |
|
291 // store the name of this test case |
|
292 iTestStepName = _L("step_001_09"); |
|
293 } |
|
294 |
|
295 // destructor |
|
296 CCommDbTest001_09::~CCommDbTest001_09() |
|
297 { |
|
298 } |
|
299 |
|
300 TInt CCommDbTest001_09::executeStepL() |
|
301 { |
|
302 TInt ret = KErrNone; |
|
303 |
|
304 CCommsDatabase* TheDb = NULL; |
|
305 TRAPD( err, TheDb=CCommsDatabase::NewL(ETrue) ); |
|
306 if (err != KErrNone) |
|
307 ret = err; |
|
308 |
|
309 // if we get here, test was successful |
|
310 delete TheDb; |
|
311 |
|
312 return ret; |
|
313 } |
|
314 |
|
315 // do Test step 001.09 |
|
316 TVerdict CCommDbTest001_09::doTestStepL( ) |
|
317 { |
|
318 |
|
319 Log(_L("Step 001.09 called ")); |
|
320 |
|
321 if (executeStepL() == KErrNone) |
|
322 iTestStepResult = EPass; |
|
323 else |
|
324 iTestStepResult = EFail; |
|
325 |
|
326 return iTestStepResult; |
|
327 } |
|
328 |
|
329 // constructor |
|
330 CCommDbTest001_10::CCommDbTest001_10() |
|
331 { |
|
332 // store the name of this test case |
|
333 iTestStepName = _L("step_001_10"); |
|
334 } |
|
335 |
|
336 // destructor |
|
337 CCommDbTest001_10::~CCommDbTest001_10() |
|
338 { |
|
339 } |
|
340 |
|
341 // do Test step 001.10 |
|
342 TVerdict CCommDbTest001_10::doTestStepL( ) |
|
343 { |
|
344 |
|
345 Log(_L("Step 001.10 called ")); |
|
346 |
|
347 iTestStepResult = EPass; |
|
348 |
|
349 //Heap test for 001.01 |
|
350 |
|
351 CCommDbTest001_01* step001_01 = new CCommDbTest001_01; |
|
352 CleanupStack::PushL(step001_01); |
|
353 step001_01->iSuite = iSuite; |
|
354 doTestStepWithHeapFailureL( *step001_01, KErrNone); |
|
355 if( step001_01->iTestStepResult == EFail ) |
|
356 iTestStepResult = EFail; |
|
357 CleanupStack::PopAndDestroy(step001_01); |
|
358 |
|
359 //Heap test for 001.03 |
|
360 |
|
361 CCommDbTest001_03* step001_03 = new CCommDbTest001_03; |
|
362 CleanupStack::PushL(step001_03); |
|
363 step001_03->iSuite = iSuite; |
|
364 doTestStepWithHeapFailureL( *step001_03, KErrNone); |
|
365 if( step001_03->iTestStepResult == EFail ) |
|
366 iTestStepResult = EFail; |
|
367 CleanupStack::PopAndDestroy(step001_03); |
|
368 |
|
369 //Heap test for 001.04 |
|
370 |
|
371 CCommDbTest001_04* step001_04 = new CCommDbTest001_04; |
|
372 CleanupStack::PushL(step001_04); |
|
373 step001_04->iSuite = iSuite; |
|
374 doTestStepWithHeapFailureL( *step001_04, KErrNone); |
|
375 if( step001_04->iTestStepResult == EFail ) |
|
376 iTestStepResult = EFail; |
|
377 CleanupStack::PopAndDestroy(step001_04); |
|
378 |
|
379 //Heap test for 001.05 |
|
380 |
|
381 CCommDbTest001_05* step001_05 = new CCommDbTest001_05; |
|
382 CleanupStack::PushL(step001_05); |
|
383 step001_05->iSuite = iSuite; |
|
384 doTestStepWithHeapFailureL( *step001_05, KErrNone); |
|
385 if( step001_05->iTestStepResult == EFail ) |
|
386 iTestStepResult = EFail; |
|
387 CleanupStack::PopAndDestroy(step001_05); |
|
388 |
|
389 //Heap test for 001.07 |
|
390 |
|
391 CCommDbTest001_07* step001_07 = new CCommDbTest001_07; |
|
392 CleanupStack::PushL(step001_07); |
|
393 step001_07->iSuite = iSuite; |
|
394 doTestStepWithHeapFailureL( *step001_07, KErrNone); |
|
395 if( step001_07->iTestStepResult == EFail ) |
|
396 iTestStepResult = EFail; |
|
397 CleanupStack::PopAndDestroy(step001_07); |
|
398 |
|
399 //Heap test for 001.08 |
|
400 |
|
401 CCommDbTest001_08* step001_08 = new CCommDbTest001_08; |
|
402 CleanupStack::PushL(step001_08); |
|
403 step001_08->iSuite = iSuite; |
|
404 doTestStepWithHeapFailureL( *step001_08, KErrNone); |
|
405 if( step001_08->iTestStepResult == EFail ) |
|
406 iTestStepResult = EFail; |
|
407 CleanupStack::PopAndDestroy(step001_08); |
|
408 |
|
409 //Heap test for 001.09 |
|
410 |
|
411 CCommDbTest001_09* step001_09 = new CCommDbTest001_09; |
|
412 CleanupStack::PushL(step001_09); |
|
413 step001_09->iSuite = iSuite; |
|
414 doTestStepWithHeapFailureL( *step001_09, KErrNone); |
|
415 if( step001_09->iTestStepResult == EFail ) |
|
416 iTestStepResult = EFail; |
|
417 CleanupStack::PopAndDestroy(step001_09); |
|
418 |
|
419 return iTestStepResult; |
|
420 } |
|