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