|
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 Cases 010.XX |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 #include <commdb.h> |
|
21 |
|
22 |
|
23 // Test system includes |
|
24 #include <networking/log.h> |
|
25 #include <networking/teststep.h> |
|
26 #include "Teststepcommdb.h" |
|
27 #include "TestSuiteCommdb.h" |
|
28 #include "Step_010_xx.h" |
|
29 |
|
30 |
|
31 |
|
32 // |
|
33 // Test step 010.001 |
|
34 // |
|
35 |
|
36 // constructor |
|
37 CCommDbTest010_01::CCommDbTest010_01() |
|
38 { |
|
39 // store the name of this test case |
|
40 iTestStepName = _L("step_010_01"); |
|
41 } |
|
42 |
|
43 // destructor |
|
44 CCommDbTest010_01::~CCommDbTest010_01() |
|
45 { |
|
46 } |
|
47 |
|
48 TVerdict CCommDbTest010_01::doTestStepPreambleL() |
|
49 { |
|
50 openDbAndViewL(TPtrC(DIAL_OUT_ISP)); |
|
51 return EPass; |
|
52 } |
|
53 |
|
54 |
|
55 TInt CCommDbTest010_01::executeStepL() |
|
56 { |
|
57 TInt ret=KErrGeneral; |
|
58 |
|
59 |
|
60 //This test must be executed on a populated table |
|
61 CDBLEAVE( ret = iTheView->GotoFirstRecord(), KErrNone ); |
|
62 |
|
63 |
|
64 //Move through the records in the table until the last record is reached |
|
65 while( ret == KErrNone ) |
|
66 { |
|
67 TRAPD(r, ret = iTheView->GotoNextRecord() ); |
|
68 if ( r!= KErrNone ) |
|
69 User::Leave(r); |
|
70 } |
|
71 |
|
72 |
|
73 |
|
74 return ret; |
|
75 } |
|
76 |
|
77 |
|
78 TVerdict CCommDbTest010_01::doTestStepL( ) |
|
79 { |
|
80 Log(_L("Step 010.01 called ")); |
|
81 |
|
82 |
|
83 if ( executeStepL() == KErrNotFound ) |
|
84 iTestStepResult = EPass; |
|
85 else |
|
86 iTestStepResult = EFail; |
|
87 |
|
88 |
|
89 return iTestStepResult; |
|
90 } |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 // |
|
96 // Test step 010.02 |
|
97 // |
|
98 |
|
99 // constructor |
|
100 CCommDbTest010_02::CCommDbTest010_02() |
|
101 { |
|
102 // store the name of this test case |
|
103 iTestStepName = _L("step_010_02"); |
|
104 } |
|
105 |
|
106 // destructor |
|
107 CCommDbTest010_02::~CCommDbTest010_02() |
|
108 { |
|
109 } |
|
110 |
|
111 TVerdict CCommDbTest010_02::doTestStepPreambleL() |
|
112 { |
|
113 openDbAndViewL(TPtrC(DIAL_OUT_ISP)); |
|
114 return EPass; |
|
115 } |
|
116 |
|
117 TInt CCommDbTest010_02::executeStepL() |
|
118 { |
|
119 TInt ret=KErrGeneral; |
|
120 |
|
121 //Move through the records in the table from the last to the first |
|
122 |
|
123 CDBLEAVE ( ret = iTheView->GotoFirstRecord(), KErrNone); |
|
124 |
|
125 while( ret == KErrNone ) |
|
126 { |
|
127 TRAPD(r, ret = iTheView->GotoNextRecord() ); |
|
128 if ( r!= KErrNone ) |
|
129 User::Leave(r); |
|
130 } |
|
131 //We should be at the end of the records in this table, |
|
132 //and ret == KErrNotFound |
|
133 |
|
134 CDBLEAVE( ret, KErrNotFound ); |
|
135 |
|
136 //Now move back to the first record |
|
137 CDBLEAVE ( ret = iTheView->GotoPreviousRecord(), KErrNone); |
|
138 |
|
139 while( ret == KErrNone ) |
|
140 { |
|
141 TRAPD(r, ret = iTheView->GotoPreviousRecord() ); |
|
142 if ( r!=KErrNone ) |
|
143 User::Leave(r); |
|
144 } |
|
145 |
|
146 |
|
147 return ret; |
|
148 } |
|
149 |
|
150 |
|
151 TVerdict CCommDbTest010_02::doTestStepL( ) |
|
152 { |
|
153 Log(_L("Step 010.02 called ")); |
|
154 |
|
155 |
|
156 if ( executeStepL() == KErrNotFound ) |
|
157 iTestStepResult = EPass; |
|
158 else |
|
159 iTestStepResult = EFail; |
|
160 |
|
161 |
|
162 return iTestStepResult; |
|
163 } |
|
164 |
|
165 |
|
166 // |
|
167 // Test step 010.03 |
|
168 // |
|
169 |
|
170 // constructor |
|
171 CCommDbTest010_03::CCommDbTest010_03() |
|
172 { |
|
173 // store the name of this test case |
|
174 iTestStepName = _L("step_010_03"); |
|
175 } |
|
176 |
|
177 // destructor |
|
178 CCommDbTest010_03::~CCommDbTest010_03() |
|
179 { |
|
180 } |
|
181 |
|
182 TVerdict CCommDbTest010_03::doTestStepPreambleL() |
|
183 { |
|
184 openDbAndViewL(TPtrC(DIAL_OUT_ISP)); |
|
185 return EPass; |
|
186 } |
|
187 |
|
188 |
|
189 TInt CCommDbTest010_03::executeStepL() |
|
190 { |
|
191 TInt ret=KErrGeneral; |
|
192 |
|
193 //The view must contain zero records |
|
194 |
|
195 TRAPD(r, ret = iTheView->GotoFirstRecord() ); |
|
196 if( r!=KErrNone ) |
|
197 ret =r; |
|
198 |
|
199 return ret; |
|
200 } |
|
201 |
|
202 |
|
203 TVerdict CCommDbTest010_03::doTestStepL( ) |
|
204 { |
|
205 Log(_L("Step 010.03 called ")); |
|
206 |
|
207 |
|
208 if ( executeStepL() == KErrNotFound ) |
|
209 iTestStepResult = EPass; |
|
210 else |
|
211 iTestStepResult = EFail; |
|
212 |
|
213 |
|
214 return iTestStepResult; |
|
215 } |
|
216 |
|
217 |
|
218 |
|
219 // |
|
220 // Test step 010.04 |
|
221 // |
|
222 |
|
223 // constructor |
|
224 CCommDbTest010_04::CCommDbTest010_04() |
|
225 { |
|
226 // store the name of this test case |
|
227 iTestStepName = _L("step_010_04"); |
|
228 } |
|
229 |
|
230 // destructor |
|
231 CCommDbTest010_04::~CCommDbTest010_04() |
|
232 { |
|
233 } |
|
234 |
|
235 |
|
236 TVerdict CCommDbTest010_04::doTestStepPreambleL() |
|
237 { |
|
238 openDbAndViewL(TPtrC(DIAL_OUT_ISP)); |
|
239 return EPass; |
|
240 } |
|
241 |
|
242 TInt CCommDbTest010_04::executeStepL() |
|
243 { |
|
244 TInt ret=KErrGeneral; |
|
245 |
|
246 //The view must contain zero records |
|
247 |
|
248 TRAPD( r, ret = iTheView->GotoNextRecord() ); |
|
249 |
|
250 if ( r!= KErrNone ) |
|
251 ret = r; |
|
252 |
|
253 |
|
254 return ret; |
|
255 } |
|
256 |
|
257 |
|
258 TVerdict CCommDbTest010_04::doTestStepL( ) |
|
259 { |
|
260 Log(_L("Step 010.04 called ")); |
|
261 |
|
262 |
|
263 if ( executeStepL() == KErrNotFound ) |
|
264 iTestStepResult = EPass; |
|
265 else |
|
266 iTestStepResult = EFail; |
|
267 |
|
268 |
|
269 return iTestStepResult; |
|
270 } |
|
271 |
|
272 |
|
273 |
|
274 // |
|
275 // Test step 010.05 |
|
276 // |
|
277 |
|
278 // constructor |
|
279 CCommDbTest010_05::CCommDbTest010_05() |
|
280 { |
|
281 // store the name of this test case |
|
282 iTestStepName = _L("step_010_05"); |
|
283 } |
|
284 |
|
285 // destructor |
|
286 CCommDbTest010_05::~CCommDbTest010_05() |
|
287 { |
|
288 } |
|
289 |
|
290 |
|
291 TVerdict CCommDbTest010_05::doTestStepL( ) |
|
292 { |
|
293 Log(_L("Step 010.05 called ")); |
|
294 |
|
295 iTestStepResult = EPass; |
|
296 |
|
297 // Heap test for 010.01 |
|
298 |
|
299 CCommDbTest010_01* step010_01 = new CCommDbTest010_01; |
|
300 CleanupStack::PushL(step010_01); |
|
301 step010_01->iSuite = iSuite; |
|
302 if ( doTestStepWithHeapFailureL( *step010_01, KErrNotFound) == EFail ) |
|
303 iTestStepResult = EFail; |
|
304 CleanupStack::PopAndDestroy(step010_01); |
|
305 |
|
306 //Heap test for 010.02 |
|
307 |
|
308 CCommDbTest010_02* step010_02 = new CCommDbTest010_02; |
|
309 CleanupStack::PushL(step010_02); |
|
310 step010_02->iSuite = iSuite; |
|
311 if ( doTestStepWithHeapFailureL( *step010_02, KErrNotFound) == EFail ) |
|
312 iTestStepResult = EFail; |
|
313 CleanupStack::PopAndDestroy(step010_02); |
|
314 |
|
315 //Heap test for 010.03 |
|
316 |
|
317 CCommDbTest010_03* step010_03 = new CCommDbTest010_03; |
|
318 CleanupStack::PushL(step010_03); |
|
319 step010_03->iSuite = iSuite; |
|
320 if ( doTestStepWithHeapFailureL( *step010_03, KErrNotFound) == EFail ) |
|
321 iTestStepResult = EFail; |
|
322 CleanupStack::PopAndDestroy(step010_03); |
|
323 |
|
324 //Heap test for 010.04 |
|
325 |
|
326 CCommDbTest010_04* step010_04 = new CCommDbTest010_04; |
|
327 CleanupStack::PushL(step010_04); |
|
328 step010_04->iSuite = iSuite; |
|
329 if ( doTestStepWithHeapFailureL( *step010_04, KErrNotFound) == EFail ) |
|
330 iTestStepResult = EFail; |
|
331 CleanupStack::PopAndDestroy(step010_04); |
|
332 |
|
333 |
|
334 |
|
335 return iTestStepResult; |
|
336 } |