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 011.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_011_xx.h" |
|
29 |
|
30 |
|
31 |
|
32 // |
|
33 // Test step 011.001 |
|
34 // |
|
35 |
|
36 // constructor |
|
37 CCommDbTest011_01::CCommDbTest011_01() |
|
38 { |
|
39 // store the name of this test case |
|
40 iTestStepName = _L("step_011_01"); |
|
41 } |
|
42 |
|
43 // destructor |
|
44 CCommDbTest011_01::~CCommDbTest011_01() |
|
45 { |
|
46 } |
|
47 |
|
48 |
|
49 TVerdict CCommDbTest011_01::doTestStepPreambleL() |
|
50 { |
|
51 openDbAndViewL(TPtrC(DIAL_OUT_ISP)); |
|
52 return EPass; |
|
53 } |
|
54 |
|
55 |
|
56 #define HIDDEN_RECORD_TEST_VALUE _L("This is a hidden record") |
|
57 |
|
58 TInt CCommDbTest011_01::executeStepL() |
|
59 { |
|
60 TInt ret=KErrGeneral; |
|
61 TUint32 id; |
|
62 |
|
63 //Create a hidden record in the database |
|
64 //NB. This step will panic if the bale used is empty, so use a |
|
65 //populated table to simplify things. |
|
66 |
|
67 //Try to insert a record |
|
68 CDBLEAVE( iTheView->InsertRecord( id ), KErrNone ); |
|
69 |
|
70 //Insert some text |
|
71 iTheView->WriteTextL( TPtrC(COMMDB_NAME), HIDDEN_RECORD_TEST_VALUE ) ; |
|
72 |
|
73 //Must write to these columns as they cannot hold null values |
|
74 iTheView->WriteBoolL(TPtrC(ISP_DIAL_RESOLUTION),ETrue); |
|
75 iTheView->WriteBoolL(TPtrC(ISP_USE_LOGIN_SCRIPT),ETrue); |
|
76 iTheView->WriteBoolL(TPtrC(ISP_PROMPT_FOR_LOGIN),EFalse); |
|
77 // iTheView->WriteTextL(TPtrC(ISP_IF_NAME), _L("PPP") ); |
|
78 iTheView->WriteBoolL(TPtrC(ISP_IF_PROMPT_FOR_AUTH),EFalse); |
|
79 iTheView->WriteBoolL(TPtrC(ISP_IP_ADDR_FROM_SERVER),ETrue); |
|
80 iTheView->WriteBoolL(TPtrC(ISP_IP_DNS_ADDR_FROM_SERVER),ETrue); |
|
81 iTheView->WriteBoolL(TPtrC(ISP_IP6_DNS_ADDR_FROM_SERVER),ETrue); |
|
82 |
|
83 //Store the record as hidden |
|
84 CDBLEAVE( iTheView->PutRecordChanges(ETrue), KErrNone ); |
|
85 |
|
86 //Now search through the table looking for this record |
|
87 CDBLEAVE( iTheView->GotoFirstRecord(), KErrNone ); |
|
88 |
|
89 TBuf<KCommsDbSvrMaxFieldLength> value; |
|
90 do { |
|
91 |
|
92 iTheView->ReadTextL( TPtrC(COMMDB_NAME), value ); |
|
93 if ( !value.Compare(HIDDEN_RECORD_TEST_VALUE) ) |
|
94 { |
|
95 //Found the record, even though it is hidden |
|
96 ret = KErrGeneral; |
|
97 break; |
|
98 } |
|
99 //Move on to the next record |
|
100 TRAPD(r, ret = iTheView->GotoNextRecord() ); |
|
101 if( r!= KErrNone ) |
|
102 User::Leave( r ); |
|
103 } while (ret == KErrNone ) ; |
|
104 |
|
105 return ret; |
|
106 } |
|
107 |
|
108 |
|
109 |
|
110 TVerdict CCommDbTest011_01::doTestStepL( ) |
|
111 { |
|
112 Log(_L("Step 011.01 called ")); |
|
113 |
|
114 |
|
115 if ( executeStepL() == KErrNotFound ) |
|
116 iTestStepResult = EPass; |
|
117 else |
|
118 iTestStepResult = EFail; |
|
119 |
|
120 |
|
121 return iTestStepResult; |
|
122 } |
|
123 |
|
124 // |
|
125 // Test step 011.02 |
|
126 // |
|
127 |
|
128 // constructor |
|
129 CCommDbTest011_02::CCommDbTest011_02() |
|
130 { |
|
131 // store the name of this test case |
|
132 iTestStepName = _L("step_011_02"); |
|
133 } |
|
134 |
|
135 // destructor |
|
136 CCommDbTest011_02::~CCommDbTest011_02() |
|
137 { |
|
138 } |
|
139 |
|
140 TVerdict CCommDbTest011_02::doTestStepPreambleL() |
|
141 { |
|
142 openDbAndViewL(TPtrC(DIAL_OUT_ISP)); |
|
143 return EPass; |
|
144 } |
|
145 |
|
146 |
|
147 TInt CCommDbTest011_02::executeStepL() |
|
148 { |
|
149 TInt ret=KErrGeneral; |
|
150 TUint32 id; |
|
151 |
|
152 //Create a hidden record in the database, try to find it, |
|
153 //make a call to ShowHiddenRecords the try to find the record again |
|
154 |
|
155 //Try to insert a test record |
|
156 CDBLEAVE( iTheView->InsertRecord( id ), KErrNone ); |
|
157 |
|
158 //Insert some text |
|
159 iTheView->WriteTextL( TPtrC(COMMDB_NAME), HIDDEN_RECORD_TEST_VALUE ); |
|
160 |
|
161 //Must write to these columns as they cannot hold null values |
|
162 iTheView->WriteBoolL(TPtrC(ISP_DIAL_RESOLUTION),ETrue); |
|
163 iTheView->WriteBoolL(TPtrC(ISP_USE_LOGIN_SCRIPT),ETrue); |
|
164 iTheView->WriteBoolL(TPtrC(ISP_PROMPT_FOR_LOGIN),EFalse); |
|
165 // iTheView->WriteTextL(TPtrC(ISP_IF_NAME), _L("PPP") ); |
|
166 iTheView->WriteBoolL(TPtrC(ISP_IF_PROMPT_FOR_AUTH),EFalse); |
|
167 iTheView->WriteBoolL(TPtrC(ISP_IP_ADDR_FROM_SERVER),ETrue); |
|
168 iTheView->WriteBoolL(TPtrC(ISP_IP_DNS_ADDR_FROM_SERVER),ETrue); |
|
169 iTheView->WriteBoolL(TPtrC(ISP_IP6_DNS_ADDR_FROM_SERVER),ETrue); |
|
170 |
|
171 //Store the record as hidden |
|
172 CDBLEAVE( iTheView->PutRecordChanges(ETrue), KErrNone ); |
|
173 |
|
174 //Now search through the table looking for this record |
|
175 CDBLEAVE( iTheView->GotoFirstRecord(), KErrNone ); |
|
176 |
|
177 //This first search through the table should not find the hidden record |
|
178 TBuf<KCommsDbSvrMaxFieldLength> value; |
|
179 do { |
|
180 |
|
181 iTheView->ReadTextL( TPtrC(COMMDB_NAME), value ); |
|
182 if ( !value.Compare(HIDDEN_RECORD_TEST_VALUE) ) |
|
183 { |
|
184 //Found the record |
|
185 ret = KErrGeneral; |
|
186 break; |
|
187 } |
|
188 //Move on to the next record |
|
189 TRAPD(r, ret= iTheView->GotoNextRecord() ); |
|
190 if ( r!=KErrNone ) |
|
191 User::Leave( r ); |
|
192 |
|
193 }while(ret == KErrNone ); |
|
194 |
|
195 if ( ret == KErrNotFound ) |
|
196 { |
|
197 |
|
198 //Search again, but this this time we'll show the hidden records |
|
199 delete iTheView; |
|
200 iTheView = 0; |
|
201 |
|
202 iTheDb->ShowHiddenRecords(); |
|
203 iTheView=iTheDb->OpenTableLC( TPtrC(DIAL_OUT_ISP) ); |
|
204 CleanupStack::Pop(); |
|
205 |
|
206 CDBLEAVE( iTheView->GotoFirstRecord(), KErrNone ); |
|
207 TBuf<KCommsDbSvrMaxFieldLength> value; |
|
208 |
|
209 do { |
|
210 iTheView->ReadTextL( TPtrC(COMMDB_NAME), value ); |
|
211 if ( !value.Compare(HIDDEN_RECORD_TEST_VALUE) ) |
|
212 { |
|
213 //Found the record |
|
214 ret = KErrNone; |
|
215 |
|
216 //Change the record not to be hidden for the test 11_03 |
|
217 CDBLEAVE( iTheView->UpdateRecord(), KErrNone ); |
|
218 CDBLEAVE( iTheView->PutRecordChanges(), KErrNone ); |
|
219 break; |
|
220 } |
|
221 //Move on to the next record |
|
222 TRAPD(r, ret = iTheView->GotoNextRecord() ) |
|
223 if ( r!=KErrNone ) |
|
224 User::Leave( r ); |
|
225 |
|
226 }while( ret == KErrNone ); |
|
227 } |
|
228 |
|
229 return ret; |
|
230 } |
|
231 |
|
232 TVerdict CCommDbTest011_02::doTestStepL( ) |
|
233 { |
|
234 Log(_L("Step 011.02 called ")); |
|
235 |
|
236 if ( executeStepL() == KErrNone ) |
|
237 iTestStepResult = EPass; |
|
238 else |
|
239 iTestStepResult = EFail; |
|
240 |
|
241 |
|
242 return iTestStepResult; |
|
243 } |
|
244 |
|
245 |
|
246 // |
|
247 // Test step 011.03 |
|
248 // |
|
249 |
|
250 // constructor |
|
251 CCommDbTest011_03::CCommDbTest011_03() |
|
252 { |
|
253 // store the name of this test case |
|
254 iTestStepName = _L("step_011_03"); |
|
255 } |
|
256 |
|
257 // destructor |
|
258 CCommDbTest011_03::~CCommDbTest011_03() |
|
259 { |
|
260 } |
|
261 |
|
262 TVerdict CCommDbTest011_03::doTestStepPreambleL() |
|
263 { |
|
264 openDbAndViewL(TPtrC(DIAL_OUT_ISP)); |
|
265 return EPass; |
|
266 } |
|
267 |
|
268 |
|
269 TInt CCommDbTest011_03::executeStepL() |
|
270 { |
|
271 TInt ret=KErrGeneral; |
|
272 |
|
273 //Check if a record from test 11_02 is readable again |
|
274 |
|
275 //Now search through the table looking for this record |
|
276 CDBLEAVE( iTheView->GotoFirstRecord(), KErrNone ); |
|
277 |
|
278 //This first search through the table should not find the hidden record |
|
279 TBuf<KCommsDbSvrMaxFieldLength> value; |
|
280 do { |
|
281 |
|
282 iTheView->ReadTextL( TPtrC(COMMDB_NAME), value ); |
|
283 if ( !value.Compare(HIDDEN_RECORD_TEST_VALUE) ) |
|
284 { |
|
285 //Found the record |
|
286 ret = KErrNone; |
|
287 break; |
|
288 } |
|
289 //Move on to the next record |
|
290 TRAPD(r, ret= iTheView->GotoNextRecord() ); |
|
291 if ( r!=KErrNone ) |
|
292 User::Leave( r ); |
|
293 |
|
294 }while(ret == KErrNone ); |
|
295 |
|
296 return ret; |
|
297 } |
|
298 |
|
299 |
|
300 TVerdict CCommDbTest011_03::doTestStepL( ) |
|
301 { |
|
302 Log(_L("Step 011.03 called ")); |
|
303 |
|
304 if ( executeStepL() == KErrNone ) |
|
305 iTestStepResult = EPass; |
|
306 else |
|
307 iTestStepResult = EFail; |
|
308 |
|
309 |
|
310 return iTestStepResult; |
|
311 } |
|
312 |
|
313 |
|
314 // |
|
315 // Test step 011.04 |
|
316 // |
|
317 |
|
318 // constructor |
|
319 CCommDbTest011_04::CCommDbTest011_04() |
|
320 { |
|
321 // store the name of this test case |
|
322 iTestStepName = _L("step_011_04"); |
|
323 } |
|
324 |
|
325 // destructor |
|
326 CCommDbTest011_04::~CCommDbTest011_04() |
|
327 { |
|
328 } |
|
329 |
|
330 TVerdict CCommDbTest011_04::doTestStepL( ) |
|
331 { |
|
332 Log(_L("Step 011.04 called ")); |
|
333 |
|
334 iTestStepResult = EPass; |
|
335 |
|
336 // Heap test for 011.01 |
|
337 |
|
338 CCommDbTest011_01* step011_01 = new CCommDbTest011_01; |
|
339 CleanupStack::PushL(step011_01); |
|
340 step011_01->iSuite = iSuite; |
|
341 if ( doTestStepWithHeapFailureL( *step011_01, KErrNotFound) == EFail ) |
|
342 iTestStepResult = EFail; |
|
343 CleanupStack::PopAndDestroy(step011_01); |
|
344 |
|
345 |
|
346 // Heap test for 011.02 |
|
347 CCommDbTest011_02* step011_02 = new CCommDbTest011_02; |
|
348 CleanupStack::PushL(step011_02); |
|
349 step011_02->iSuite = iSuite; |
|
350 if ( doTestStepWithHeapFailureL( *step011_02, KErrNone) == EFail ) |
|
351 iTestStepResult = EFail; |
|
352 CleanupStack::PopAndDestroy(step011_02); |
|
353 |
|
354 // Heap test for 011.03 |
|
355 CCommDbTest011_03* step011_03 = new CCommDbTest011_03; |
|
356 CleanupStack::PushL(step011_03); |
|
357 step011_03->iSuite = iSuite; |
|
358 if ( doTestStepWithHeapFailureL( *step011_03, KErrNone) == EFail ) |
|
359 iTestStepResult = EFail; |
|
360 CleanupStack::PopAndDestroy(step011_03); |
|
361 |
|
362 return iTestStepResult; |
|
363 |
|
364 } |
|