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