1 // Copyright (c) 2006-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 063.XX |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <commdb.h> |
|
20 #include <d32dbms.h> |
|
21 #include <badesca.h> |
|
22 #include <cdbstore.h> |
|
23 |
|
24 #ifdef SYMBIAN_OLD_EXPORT_LOCATION |
|
25 #include <comms-infras/commdb/protection/protectdb.h> |
|
26 #include <comms-infras/commdb/protection/protectcpdb.h> |
|
27 #else |
|
28 //these headers are user includes in the new env. |
|
29 #include "protectdb.h" |
|
30 #include "protectcpdb.h" |
|
31 #endif |
|
32 |
|
33 // Test system includes |
|
34 #include <networking/log.h> |
|
35 #include <networking/teststep.h> |
|
36 #include "Teststepcommdb.h" |
|
37 #include "TestSuiteCommdb.h" |
|
38 #include "step_063_xx.h" |
|
39 |
|
40 // |
|
41 // Test step 063.01 |
|
42 // |
|
43 |
|
44 // constructor |
|
45 CCommDbTest063_01::CCommDbTest063_01() |
|
46 { |
|
47 // store the name of this test case |
|
48 iTestStepName = _L("step_063_01"); |
|
49 } |
|
50 |
|
51 // destructor |
|
52 CCommDbTest063_01::~CCommDbTest063_01() |
|
53 {} |
|
54 |
|
55 enum TVerdict CCommDbTest063_01::doTestStepL( void ) |
|
56 { |
|
57 iTestStepResult = EPass; |
|
58 |
|
59 iTheProtectedDb = CCommsDatabaseProtect::NewL(); |
|
60 |
|
61 if(iTheProtectedDb->ProtectTable(TPtrC(DIAL_OUT_ISP))!=KErrNone) |
|
62 {iTestStepResult = EFail;} |
|
63 |
|
64 RDbRowSet::TAccess rowSet = RDbRowSet::EUpdatable; |
|
65 TRAPD(ret, rowSet = iTheProtectedDb->GetTableAccessL(TPtrC(DIAL_OUT_ISP))); |
|
66 |
|
67 if (ret != KErrNone || rowSet != RDbRowSet::EReadOnly) |
|
68 { |
|
69 iTestStepResult = EFail; |
|
70 } |
|
71 |
|
72 delete iTheProtectedDb; |
|
73 iTheProtectedDb=NULL; |
|
74 |
|
75 return iTestStepResult; |
|
76 } |
|
77 |
|
78 // |
|
79 // Test step 063.02 |
|
80 // |
|
81 |
|
82 // constructor |
|
83 CCommDbTest063_02::CCommDbTest063_02() |
|
84 { |
|
85 // store the name of this test case |
|
86 iTestStepName = _L("step_063_02"); |
|
87 } |
|
88 |
|
89 // destructor |
|
90 CCommDbTest063_02::~CCommDbTest063_02() |
|
91 {} |
|
92 |
|
93 enum TVerdict CCommDbTest063_02::doTestStepL( void ) |
|
94 { |
|
95 iTestStepResult = EPass; |
|
96 |
|
97 iTheProtectedDb = CCommsDatabaseProtect::NewL(); |
|
98 |
|
99 if(iTheProtectedDb->UnProtectTable(TPtrC(DIAL_OUT_ISP))!=KErrNone) |
|
100 { |
|
101 iTestStepResult = EFail; |
|
102 } |
|
103 |
|
104 RDbRowSet::TAccess rowSet = RDbRowSet::EReadOnly; |
|
105 TRAPD(ret, rowSet = iTheProtectedDb->GetTableAccessL(TPtrC(DIAL_OUT_ISP))); |
|
106 |
|
107 if (ret != KErrNone || rowSet != RDbRowSet::EUpdatable) |
|
108 { |
|
109 iTestStepResult = EFail; |
|
110 } |
|
111 |
|
112 delete iTheProtectedDb; |
|
113 iTheProtectedDb=NULL; |
|
114 |
|
115 return iTestStepResult; |
|
116 } |
|
117 |
|
118 // |
|
119 // Test step 063.03 |
|
120 // |
|
121 |
|
122 // constructor |
|
123 CCommDbTest063_03::CCommDbTest063_03() |
|
124 { |
|
125 // store the name of this test case |
|
126 iTestStepName = _L("step_063_03"); |
|
127 } |
|
128 |
|
129 // destructor |
|
130 CCommDbTest063_03::~CCommDbTest063_03() |
|
131 {} |
|
132 |
|
133 enum TVerdict CCommDbTest063_03::doTestStepL( void ) |
|
134 { |
|
135 iTestStepResult = EPass; |
|
136 |
|
137 iTheProtectedDb = CCommsDatabaseProtect::NewL(); |
|
138 |
|
139 //Construct table list |
|
140 CPtrCArray* tableArray; |
|
141 tableArray = new (ELeave) CPtrCArray(2); |
|
142 CleanupStack::PushL(tableArray); |
|
143 |
|
144 TRAPD(ret, tableArray->InsertL(0,DIAL_OUT_ISP)); |
|
145 if (ret != KErrNone) |
|
146 { |
|
147 iTestStepResult = EFail; |
|
148 CleanupStack::PopAndDestroy(tableArray); |
|
149 delete iTheProtectedDb; |
|
150 iTheProtectedDb=NULL; |
|
151 return iTestStepResult; |
|
152 } |
|
153 |
|
154 TRAP(ret, tableArray->InsertL(1,DIAL_IN_ISP)); |
|
155 if (ret != KErrNone) |
|
156 { |
|
157 iTestStepResult = EFail; |
|
158 CleanupStack::PopAndDestroy(tableArray); |
|
159 delete iTheProtectedDb; |
|
160 iTheProtectedDb=NULL; |
|
161 return iTestStepResult; |
|
162 } |
|
163 |
|
164 if(iTheProtectedDb->ProtectTables(*tableArray) != KErrNone) |
|
165 { |
|
166 iTestStepResult = EFail; |
|
167 CleanupStack::PopAndDestroy(tableArray); |
|
168 delete iTheProtectedDb; |
|
169 iTheProtectedDb=NULL; |
|
170 return iTestStepResult; |
|
171 } |
|
172 |
|
173 RDbRowSet::TAccess rowSet = RDbRowSet::EUpdatable; |
|
174 TRAP(ret, rowSet = iTheProtectedDb->GetTableAccessL(TPtrC(DIAL_IN_ISP))); |
|
175 |
|
176 if (ret != KErrNone || rowSet != RDbRowSet::EReadOnly) |
|
177 { |
|
178 iTestStepResult = EFail; |
|
179 } |
|
180 |
|
181 CleanupStack::PopAndDestroy(tableArray); |
|
182 |
|
183 delete iTheProtectedDb; |
|
184 iTheProtectedDb=NULL; |
|
185 |
|
186 return iTestStepResult; |
|
187 } |
|
188 |
|
189 // |
|
190 // Test step 063.04 |
|
191 // |
|
192 |
|
193 // constructor |
|
194 CCommDbTest063_04::CCommDbTest063_04() |
|
195 { |
|
196 // store the name of this test case |
|
197 iTestStepName = _L("step_063_04"); |
|
198 } |
|
199 |
|
200 // destructor |
|
201 CCommDbTest063_04::~CCommDbTest063_04() |
|
202 {} |
|
203 |
|
204 enum TVerdict CCommDbTest063_04::doTestStepL( void ) |
|
205 { |
|
206 iTestStepResult = EPass; |
|
207 |
|
208 iTheProtectedDb = CCommsDatabaseProtect::NewL(); |
|
209 |
|
210 //Construct table list |
|
211 CPtrCArray* tableArray; |
|
212 tableArray = new (ELeave) CPtrCArray(2); |
|
213 CleanupStack::PushL(tableArray); |
|
214 |
|
215 TRAPD(ret, tableArray->InsertL(0,DIAL_OUT_ISP)); |
|
216 if (ret != KErrNone) |
|
217 { |
|
218 iTestStepResult = EFail; |
|
219 CleanupStack::PopAndDestroy(tableArray); |
|
220 delete iTheProtectedDb; |
|
221 iTheProtectedDb=NULL; |
|
222 return iTestStepResult; |
|
223 } |
|
224 |
|
225 TRAP(ret, tableArray->InsertL(1,DIAL_IN_ISP)); |
|
226 if (ret != KErrNone) |
|
227 { |
|
228 iTestStepResult = EFail; |
|
229 CleanupStack::PopAndDestroy(tableArray); |
|
230 delete iTheProtectedDb; |
|
231 iTheProtectedDb=NULL; |
|
232 return iTestStepResult; |
|
233 } |
|
234 |
|
235 if(iTheProtectedDb->UnprotectTables(*tableArray) != KErrNone) |
|
236 { |
|
237 iTestStepResult = EFail; |
|
238 CleanupStack::PopAndDestroy(tableArray); |
|
239 delete iTheProtectedDb; |
|
240 iTheProtectedDb=NULL; |
|
241 return iTestStepResult; |
|
242 } |
|
243 |
|
244 RDbRowSet::TAccess rowSet = RDbRowSet::EReadOnly; |
|
245 TRAP(ret, rowSet = iTheProtectedDb->GetTableAccessL(TPtrC(DIAL_IN_ISP))); |
|
246 |
|
247 if (ret != KErrNone || rowSet != RDbRowSet::EUpdatable) |
|
248 { |
|
249 iTestStepResult = EFail; |
|
250 } |
|
251 |
|
252 CleanupStack::PopAndDestroy(tableArray); |
|
253 |
|
254 delete iTheProtectedDb; |
|
255 iTheProtectedDb=NULL; |
|
256 |
|
257 return iTestStepResult; |
|
258 } |
|
259 |
|
260 // |
|
261 // Test step 063.05 |
|
262 // |
|
263 |
|
264 // constructor |
|
265 CCommDbTest063_05::CCommDbTest063_05() |
|
266 { |
|
267 // store the name of this test case |
|
268 iTestStepName = _L("step_063_05"); |
|
269 } |
|
270 |
|
271 // destructor |
|
272 CCommDbTest063_05::~CCommDbTest063_05() |
|
273 { |
|
274 } |
|
275 |
|
276 enum TVerdict CCommDbTest063_05::doTestStepL( void ) |
|
277 { |
|
278 iTestStepResult = EPass; |
|
279 TBool val=0; |
|
280 iTheProtectedDb = CCommsDatabaseProtect::NewL(val); |
|
281 if(iTheProtectedDb->ProtectTable(TPtrC(DIAL_OUT_ISP)) != KErrNone) |
|
282 { |
|
283 iTestStepResult = EFail; |
|
284 } |
|
285 RDbRowSet::TAccess rowSet = RDbRowSet::EUpdatable; |
|
286 TRAPD(ret, rowSet = iTheProtectedDb->GetTableAccessL(TPtrC(DIAL_OUT_ISP))); |
|
287 if (ret != KErrNone || rowSet != RDbRowSet::EReadOnly) |
|
288 { |
|
289 iTestStepResult = EFail; |
|
290 } |
|
291 delete iTheProtectedDb; |
|
292 iTheProtectedDb=NULL; |
|
293 return iTestStepResult; |
|
294 } |
|
295 |
|
296 // |
|
297 // Test step 063.06 |
|
298 // |
|
299 |
|
300 // constructor |
|
301 CCommDbTest063_06::CCommDbTest063_06() |
|
302 { |
|
303 // store the name of this test case |
|
304 iTestStepName = _L("step_063_06"); |
|
305 } |
|
306 |
|
307 // destructor |
|
308 CCommDbTest063_06::~CCommDbTest063_06() |
|
309 { |
|
310 } |
|
311 |
|
312 enum TVerdict CCommDbTest063_06::doTestStepL( void ) |
|
313 { |
|
314 iTestStepResult = EPass; |
|
315 TBool val=0; |
|
316 iTheProtectedDb = CCommsDatabaseProtect::NewL(val); |
|
317 if(iTheProtectedDb->UnProtectTable(TPtrC(DIAL_OUT_ISP)) != KErrNone) |
|
318 { |
|
319 iTestStepResult = EFail; |
|
320 } |
|
321 RDbRowSet::TAccess rowSet = RDbRowSet::EReadOnly; |
|
322 TRAPD(ret, rowSet = iTheProtectedDb->GetTableAccessL(TPtrC(DIAL_OUT_ISP))); |
|
323 if (ret != KErrNone || rowSet != RDbRowSet::EUpdatable) |
|
324 { |
|
325 iTestStepResult = EFail; |
|
326 } |
|
327 delete iTheProtectedDb; |
|
328 iTheProtectedDb=NULL; |
|
329 return iTestStepResult; |
|
330 } |
|
331 |
|
332 // |
|
333 // Test step 063.07 |
|
334 // |
|
335 |
|
336 // constructor |
|
337 CCommDbTest063_07::CCommDbTest063_07() |
|
338 { |
|
339 // store the name of this test case |
|
340 iTestStepName = _L("step_063_07"); |
|
341 } |
|
342 |
|
343 // destructor |
|
344 CCommDbTest063_07::~CCommDbTest063_07() |
|
345 { |
|
346 } |
|
347 |
|
348 enum TVerdict CCommDbTest063_07::doTestStepL( void ) |
|
349 { |
|
350 iTestStepResult = EPass; |
|
351 TBool val=0; |
|
352 iTheProtectedDb = CCommsDatabaseProtect::NewL(val); |
|
353 //Construct table list |
|
354 CPtrCArray* tableArray = new (ELeave) CPtrCArray(2); |
|
355 CleanupStack::PushL(tableArray); |
|
356 TRAPD(ret, tableArray->InsertL(0,DIAL_OUT_ISP)); |
|
357 if (ret != KErrNone) |
|
358 { |
|
359 iTestStepResult = EFail; |
|
360 CleanupStack::PopAndDestroy(tableArray); |
|
361 delete iTheProtectedDb; |
|
362 iTheProtectedDb=NULL; |
|
363 return iTestStepResult; |
|
364 } |
|
365 TRAP(ret, tableArray->InsertL(1,DIAL_IN_ISP)); |
|
366 if (ret != KErrNone) |
|
367 { |
|
368 iTestStepResult = EFail; |
|
369 CleanupStack::PopAndDestroy(tableArray); |
|
370 delete iTheProtectedDb; |
|
371 iTheProtectedDb=NULL; |
|
372 return iTestStepResult; |
|
373 } |
|
374 if(iTheProtectedDb->ProtectTables(*tableArray) != KErrNone) |
|
375 { |
|
376 iTestStepResult = EFail; |
|
377 CleanupStack::PopAndDestroy(tableArray); |
|
378 delete iTheProtectedDb; |
|
379 iTheProtectedDb=NULL; |
|
380 return iTestStepResult; |
|
381 } |
|
382 RDbRowSet::TAccess rowSet = RDbRowSet::EUpdatable; |
|
383 TRAP(ret, rowSet = iTheProtectedDb->GetTableAccessL(TPtrC(DIAL_IN_ISP))); |
|
384 if (ret != KErrNone || rowSet != RDbRowSet::EReadOnly) |
|
385 { |
|
386 iTestStepResult = EFail; |
|
387 } |
|
388 CleanupStack::PopAndDestroy(tableArray); |
|
389 delete iTheProtectedDb; |
|
390 iTheProtectedDb=NULL; |
|
391 return iTestStepResult; |
|
392 } |
|
393 |
|
394 // |
|
395 // Test step 063.08 |
|
396 // |
|
397 |
|
398 // constructor |
|
399 CCommDbTest063_08::CCommDbTest063_08() |
|
400 { |
|
401 // store the name of this test case |
|
402 iTestStepName = _L("step_063_08"); |
|
403 } |
|
404 |
|
405 // destructor |
|
406 CCommDbTest063_08::~CCommDbTest063_08() |
|
407 { |
|
408 } |
|
409 |
|
410 enum TVerdict CCommDbTest063_08::doTestStepL( void ) |
|
411 { |
|
412 iTestStepResult = EPass; |
|
413 TBool val=0; |
|
414 iTheProtectedDb = CCommsDatabaseProtect::NewL(val); |
|
415 //Construct table list |
|
416 CPtrCArray* tableArray = new (ELeave) CPtrCArray(2); |
|
417 CleanupStack::PushL(tableArray); |
|
418 TRAPD(ret, tableArray->InsertL(0,DIAL_OUT_ISP)); |
|
419 if (ret != KErrNone) |
|
420 { |
|
421 iTestStepResult = EFail; |
|
422 CleanupStack::PopAndDestroy(tableArray); |
|
423 delete iTheProtectedDb; |
|
424 iTheProtectedDb=NULL; |
|
425 return iTestStepResult; |
|
426 } |
|
427 TRAP(ret, tableArray->InsertL(1,DIAL_IN_ISP)); |
|
428 if (ret != KErrNone) |
|
429 { |
|
430 iTestStepResult = EFail; |
|
431 CleanupStack::PopAndDestroy(tableArray); |
|
432 delete iTheProtectedDb; |
|
433 iTheProtectedDb=NULL; |
|
434 return iTestStepResult; |
|
435 } |
|
436 if(iTheProtectedDb->UnprotectTables(*tableArray) != KErrNone) |
|
437 { |
|
438 iTestStepResult = EFail; |
|
439 CleanupStack::PopAndDestroy(tableArray); |
|
440 delete iTheProtectedDb; |
|
441 iTheProtectedDb=NULL; |
|
442 return iTestStepResult; |
|
443 } |
|
444 RDbRowSet::TAccess rowSet = RDbRowSet::EReadOnly; |
|
445 TRAP(ret, rowSet = iTheProtectedDb->GetTableAccessL(TPtrC(DIAL_IN_ISP))); |
|
446 if (ret != KErrNone || rowSet != RDbRowSet::EUpdatable) |
|
447 { |
|
448 iTestStepResult = EFail; |
|
449 } |
|
450 CleanupStack::PopAndDestroy(tableArray); |
|
451 delete iTheProtectedDb; |
|
452 iTheProtectedDb=NULL; |
|
453 return iTestStepResult; |
|
454 } |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|