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