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 |
// This contains CommDb Unit Test Cases 031.XX
|
|
18 |
|
|
19 |
// EPOC includes
|
|
20 |
#include <e32base.h>
|
|
21 |
#include <commdb.h>
|
|
22 |
#include <d32comm.h>
|
|
23 |
|
|
24 |
// Test system includes
|
|
25 |
#include "Teststepcommdb.h"
|
|
26 |
#include "Step_031_xx.h"
|
|
27 |
|
|
28 |
|
|
29 |
CCommDbTest031_01::CCommDbTest031_01()
|
|
30 |
{
|
|
31 |
// store the name of this test case
|
|
32 |
SetTestStepName(_L("step_031_01"));
|
|
33 |
}
|
|
34 |
|
|
35 |
CCommDbTest031_01::~CCommDbTest031_01()
|
|
36 |
{}
|
|
37 |
|
|
38 |
TVerdict CCommDbTest031_01::doTestStepL( void )
|
|
39 |
{
|
|
40 |
if(executeStepL()!=KErrNone)
|
|
41 |
SetTestStepResult(EFail); SetTestStepResult(EPass); return TestStepResult();
|
|
42 |
}
|
|
43 |
|
|
44 |
TVerdict CCommDbTest031_01::doTestStepPreambleL()
|
|
45 |
{
|
|
46 |
iTheDb=CCommsDatabase::NewL();
|
|
47 |
|
|
48 |
iPrefView = iTheDb->OpenConnectionPrefTableLC();
|
|
49 |
CleanupStack::Pop();
|
|
50 |
|
|
51 |
SetTestStepResult(EPass); return TestStepResult();
|
|
52 |
}
|
|
53 |
|
|
54 |
TInt CCommDbTest031_01::executeStepL()
|
|
55 |
{
|
|
56 |
CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref1;
|
|
57 |
pref1.iRanking = 2;
|
|
58 |
pref1.iDirection = ECommDbConnectionDirectionOutgoing;
|
|
59 |
pref1.iDialogPref = ECommDbDialogPrefPrompt;
|
|
60 |
pref1.iBearer.iBearerSet = KCommDbBearerCSD;
|
|
61 |
pref1.iBearer.iIapId = 2;
|
|
62 |
|
|
63 |
iPrefView->InsertConnectionPreferenceL(pref1, EFalse);
|
|
64 |
|
|
65 |
CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref2;
|
|
66 |
pref2.iRanking = 1;
|
|
67 |
pref2.iDirection = ECommDbConnectionDirectionOutgoing;
|
|
68 |
pref2.iDialogPref = ECommDbDialogPrefPrompt;
|
|
69 |
pref2.iBearer.iBearerSet = KCommDbBearerCSD;
|
|
70 |
pref2.iBearer.iIapId = 1;
|
|
71 |
|
|
72 |
iPrefView->InsertConnectionPreferenceL(pref2, EFalse);
|
|
73 |
|
|
74 |
delete iPrefView; //Open a new view in rank order
|
|
75 |
iPrefView=NULL;
|
|
76 |
iPrefView=iTheDb->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionOutgoing);
|
|
77 |
CleanupStack::Pop(iPrefView);
|
|
78 |
|
|
79 |
User::LeaveIfError(iPrefView->GotoFirstRecord());
|
|
80 |
|
|
81 |
CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref retrievedPref;
|
|
82 |
iPrefView->ReadConnectionPreferenceL(retrievedPref);
|
|
83 |
if(!(retrievedPref==pref2))
|
|
84 |
return KErrGeneral;
|
|
85 |
|
|
86 |
User::LeaveIfError(iPrefView->GotoNextRecord());
|
|
87 |
iPrefView->ReadConnectionPreferenceL(retrievedPref);
|
|
88 |
if(!(retrievedPref==pref1))
|
|
89 |
return KErrGeneral;
|
|
90 |
|
|
91 |
return KErrNone;
|
|
92 |
}
|
|
93 |
|
|
94 |
TVerdict CCommDbTest031_01::doTestStepPostambleL()
|
|
95 |
{
|
|
96 |
//Get rid of our view
|
|
97 |
if(iPrefView)
|
|
98 |
{
|
|
99 |
delete iPrefView;
|
|
100 |
}
|
|
101 |
iPrefView=0;
|
|
102 |
|
|
103 |
//Create a new view that should have the record that was added in executeStepL and
|
|
104 |
// may have been left in by a leave condition
|
|
105 |
iPrefView = iTheDb->OpenConnectionPrefTableLC();
|
|
106 |
CleanupStack::Pop();
|
|
107 |
|
|
108 |
if(iPrefView->GotoFirstRecord() == KErrNone)
|
|
109 |
{
|
|
110 |
iPrefView->DeleteConnectionPreferenceL();
|
|
111 |
}
|
|
112 |
if(iPrefView->GotoFirstRecord() == KErrNone)
|
|
113 |
{
|
|
114 |
iPrefView->DeleteConnectionPreferenceL();
|
|
115 |
}
|
|
116 |
|
|
117 |
// Cleanup after test run
|
|
118 |
CTestStepCommDb::doTestStepPostambleL();
|
|
119 |
SetTestStepResult(EPass); return TestStepResult();
|
|
120 |
}
|
|
121 |
|
|
122 |
/////////////////////////////////////////////////////////////////////////////////
|
|
123 |
|
|
124 |
CCommDbTest031_02::CCommDbTest031_02()
|
|
125 |
{
|
|
126 |
// store the name of this test case
|
|
127 |
SetTestStepName(_L("step_031_02"));
|
|
128 |
}
|
|
129 |
|
|
130 |
CCommDbTest031_02::~CCommDbTest031_02()
|
|
131 |
{}
|
|
132 |
|
|
133 |
TVerdict CCommDbTest031_02::doTestStepL( void )
|
|
134 |
{
|
|
135 |
executeStepL();
|
|
136 |
SetTestStepResult(EPass); return TestStepResult(); //if we get to here we must have passed.
|
|
137 |
}
|
|
138 |
|
|
139 |
TVerdict CCommDbTest031_02::doTestStepPreambleL()
|
|
140 |
{
|
|
141 |
iTheDb=CCommsDatabase::NewL();
|
|
142 |
|
|
143 |
iPrefView = iTheDb->OpenConnectionPrefTableLC();
|
|
144 |
CleanupStack::Pop();
|
|
145 |
|
|
146 |
SetTestStepResult(EPass); return TestStepResult();
|
|
147 |
}
|
|
148 |
|
|
149 |
TInt CCommDbTest031_02::executeStepL()
|
|
150 |
{
|
|
151 |
CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref1;
|
|
152 |
pref1.iRanking = 2;
|
|
153 |
pref1.iDirection = ECommDbConnectionDirectionOutgoing;
|
|
154 |
pref1.iDialogPref = ECommDbDialogPrefPrompt;
|
|
155 |
pref1.iBearer.iBearerSet = KCommDbBearerCSD;
|
|
156 |
pref1.iBearer.iIapId = 2;
|
|
157 |
|
|
158 |
iPrefView->InsertConnectionPreferenceL(pref1, EFalse);
|
|
159 |
|
|
160 |
CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref2;
|
|
161 |
pref2.iRanking = 1;
|
|
162 |
pref2.iDirection = ECommDbConnectionDirectionOutgoing;
|
|
163 |
pref2.iDialogPref = ECommDbDialogPrefPrompt;
|
|
164 |
pref2.iBearer.iBearerSet = KCommDbBearerCSD;
|
|
165 |
pref2.iBearer.iIapId = 1;
|
|
166 |
|
|
167 |
iPrefView->InsertConnectionPreferenceL(pref2, EFalse);
|
|
168 |
|
|
169 |
delete iPrefView; //Open a new view in rank order looking at incoming only
|
|
170 |
iPrefView=NULL;
|
|
171 |
iPrefView=iTheDb->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionIncoming);
|
|
172 |
CleanupStack::Pop(iPrefView);
|
|
173 |
|
|
174 |
return KErrNone;
|
|
175 |
}
|
|
176 |
|
|
177 |
TVerdict CCommDbTest031_02::doTestStepPostambleL()
|
|
178 |
{
|
|
179 |
//Get rid of our view
|
|
180 |
if(iPrefView)
|
|
181 |
{
|
|
182 |
delete iPrefView;
|
|
183 |
}
|
|
184 |
iPrefView=0;
|
|
185 |
|
|
186 |
//Create a new view that should have the record that was added in executeStepL and
|
|
187 |
// may have been left in by a leave condition
|
|
188 |
iPrefView = iTheDb->OpenConnectionPrefTableLC();
|
|
189 |
CleanupStack::Pop();
|
|
190 |
|
|
191 |
if(iPrefView->GotoFirstRecord() == KErrNone)
|
|
192 |
{
|
|
193 |
iPrefView->DeleteConnectionPreferenceL();
|
|
194 |
}
|
|
195 |
if(iPrefView->GotoFirstRecord() == KErrNone)
|
|
196 |
{
|
|
197 |
iPrefView->DeleteConnectionPreferenceL();
|
|
198 |
}
|
|
199 |
|
|
200 |
// Cleanup after test run
|
|
201 |
CTestStepCommDb::doTestStepPostambleL();
|
|
202 |
SetTestStepResult(EPass); return TestStepResult();
|
|
203 |
}
|
|
204 |
|
|
205 |
/////////////////////////////////////////////////////////////////////////////////
|
|
206 |
|
|
207 |
CCommDbTest031_03::CCommDbTest031_03()
|
|
208 |
{
|
|
209 |
// store the name of this test case
|
|
210 |
SetTestStepName(_L("step_031_03"));
|
|
211 |
}
|
|
212 |
|
|
213 |
CCommDbTest031_03::~CCommDbTest031_03()
|
|
214 |
{}
|
|
215 |
|
|
216 |
TVerdict CCommDbTest031_03::doTestStepL( void )
|
|
217 |
{
|
|
218 |
if(executeStepL()!=KErrNone)
|
|
219 |
SetTestStepResult(EFail); SetTestStepResult(EPass); return TestStepResult(); //if we get to here we must have passed.
|
|
220 |
}
|
|
221 |
|
|
222 |
TVerdict CCommDbTest031_03::doTestStepPreambleL()
|
|
223 |
{
|
|
224 |
iTheDb=CCommsDatabase::NewL();
|
|
225 |
|
|
226 |
iPrefView = iTheDb->OpenConnectionPrefTableLC();
|
|
227 |
CleanupStack::Pop();
|
|
228 |
|
|
229 |
SetTestStepResult(EPass); return TestStepResult();
|
|
230 |
}
|
|
231 |
|
|
232 |
TInt CCommDbTest031_03::executeStepL()
|
|
233 |
{
|
|
234 |
CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref1;
|
|
235 |
pref1.iRanking = 2;
|
|
236 |
pref1.iDirection = ECommDbConnectionDirectionOutgoing;
|
|
237 |
pref1.iDialogPref = ECommDbDialogPrefPrompt;
|
|
238 |
pref1.iBearer.iBearerSet = KCommDbBearerCSD;
|
|
239 |
pref1.iBearer.iIapId = 2;
|
|
240 |
|
|
241 |
iPrefView->InsertConnectionPreferenceL(pref1, EFalse);
|
|
242 |
|
|
243 |
CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref2;
|
|
244 |
pref2.iRanking = 1;
|
|
245 |
pref2.iDirection = ECommDbConnectionDirectionOutgoing;
|
|
246 |
pref2.iDialogPref = ECommDbDialogPrefPrompt;
|
|
247 |
pref2.iBearer.iBearerSet = KCommDbBearerCSD;
|
|
248 |
pref2.iBearer.iIapId = 1;
|
|
249 |
|
|
250 |
iPrefView->InsertConnectionPreferenceL(pref2, EFalse);
|
|
251 |
|
|
252 |
delete iPrefView; //Open a new view to look at rank 1 outgoing only
|
|
253 |
iPrefView=NULL;
|
|
254 |
iPrefView=iTheDb->OpenConnectionPrefTableViewOnRankLC(ECommDbConnectionDirectionOutgoing, 1);
|
|
255 |
CleanupStack::Pop(iPrefView);
|
|
256 |
|
|
257 |
User::LeaveIfError(iPrefView->GotoFirstRecord());
|
|
258 |
|
|
259 |
CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref retrievedPref;
|
|
260 |
iPrefView->ReadConnectionPreferenceL(retrievedPref);
|
|
261 |
|
|
262 |
if(!(retrievedPref==pref2))
|
|
263 |
return KErrGeneral;
|
|
264 |
|
|
265 |
return KErrNone;
|
|
266 |
}
|
|
267 |
|
|
268 |
TVerdict CCommDbTest031_03::doTestStepPostambleL()
|
|
269 |
{
|
|
270 |
//Get rid of our view
|
|
271 |
if(iPrefView)
|
|
272 |
{
|
|
273 |
delete iPrefView;
|
|
274 |
}
|
|
275 |
iPrefView=0;
|
|
276 |
|
|
277 |
//Create a new view that should have the record that was added in executeStepL and
|
|
278 |
// may have been left in by a leave condition
|
|
279 |
iPrefView = iTheDb->OpenConnectionPrefTableLC();
|
|
280 |
CleanupStack::Pop();
|
|
281 |
|
|
282 |
if(iPrefView->GotoFirstRecord() == KErrNone)
|
|
283 |
{
|
|
284 |
iPrefView->DeleteConnectionPreferenceL();
|
|
285 |
}
|
|
286 |
if(iPrefView->GotoFirstRecord() == KErrNone)
|
|
287 |
{
|
|
288 |
iPrefView->DeleteConnectionPreferenceL();
|
|
289 |
}
|
|
290 |
|
|
291 |
// Cleanup after test run
|
|
292 |
CTestStepCommDb::doTestStepPostambleL();
|
|
293 |
SetTestStepResult(EPass); return TestStepResult();
|
|
294 |
}
|
|
295 |
|
|
296 |
/////////////////////////////////////////////////////////////////////////////////
|
|
297 |
|
|
298 |
CCommDbTest031_04::CCommDbTest031_04()
|
|
299 |
{
|
|
300 |
// store the name of this test case
|
|
301 |
SetTestStepName(_L("step_031_04"));
|
|
302 |
}
|
|
303 |
|
|
304 |
CCommDbTest031_04::~CCommDbTest031_04()
|
|
305 |
{}
|
|
306 |
|
|
307 |
TVerdict CCommDbTest031_04::doTestStepL( void )
|
|
308 |
{
|
|
309 |
if(executeStepL()!=KErrOverflow)
|
|
310 |
SetTestStepResult(EFail); SetTestStepResult(EPass); return TestStepResult(); //if we get to here we must have passed.
|
|
311 |
}
|
|
312 |
|
|
313 |
TVerdict CCommDbTest031_04::doTestStepPreambleL()
|
|
314 |
{
|
|
315 |
iTheDb=CCommsDatabase::NewL();
|
|
316 |
|
|
317 |
iPrefView = iTheDb->OpenConnectionPrefTableLC();
|
|
318 |
CleanupStack::Pop();
|
|
319 |
|
|
320 |
SetTestStepResult(EPass); return TestStepResult();
|
|
321 |
}
|
|
322 |
|
|
323 |
TInt CCommDbTest031_04::executeStepL()
|
|
324 |
{
|
|
325 |
CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref1;
|
|
326 |
pref1.iRanking = 2;
|
|
327 |
pref1.iDirection = ECommDbConnectionDirectionOutgoing;
|
|
328 |
pref1.iDialogPref = ECommDbDialogPrefPrompt;
|
|
329 |
pref1.iBearer.iBearerSet = KCommDbBearerCSD;
|
|
330 |
pref1.iBearer.iIapId = 2;
|
|
331 |
|
|
332 |
iPrefView->InsertConnectionPreferenceL(pref1, EFalse);
|
|
333 |
|
|
334 |
CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref2;
|
|
335 |
pref2.iRanking = 1;
|
|
336 |
pref2.iDirection = ECommDbConnectionDirectionOutgoing;
|
|
337 |
pref2.iDialogPref = ECommDbDialogPrefPrompt;
|
|
338 |
pref2.iBearer.iBearerSet = KCommDbBearerCSD;
|
|
339 |
pref2.iBearer.iIapId = 1;
|
|
340 |
|
|
341 |
iPrefView->InsertConnectionPreferenceL(pref2, EFalse);
|
|
342 |
|
|
343 |
delete iPrefView; //Open a new view with invalid rank;
|
|
344 |
iPrefView=NULL;
|
|
345 |
TRAPD(err, iPrefView=iTheDb->OpenConnectionPrefTableViewOnRankLC(ECommDbConnectionDirectionOutgoing, 5));
|
|
346 |
if (err==KErrNone) //This should never happen, but better safe than sorry
|
|
347 |
CleanupStack::Pop(iPrefView);
|
|
348 |
|
|
349 |
return err;
|
|
350 |
}
|
|
351 |
|
|
352 |
TVerdict CCommDbTest031_04::doTestStepPostambleL()
|
|
353 |
{
|
|
354 |
//Get rid of our view
|
|
355 |
if(iPrefView)
|
|
356 |
{
|
|
357 |
delete iPrefView;
|
|
358 |
}
|
|
359 |
iPrefView=0;
|
|
360 |
|
|
361 |
//Create a new view that should have the record that was added in executeStepL and
|
|
362 |
// may have been left in by a leave condition
|
|
363 |
iPrefView = iTheDb->OpenConnectionPrefTableLC();
|
|
364 |
CleanupStack::Pop();
|
|
365 |
|
|
366 |
if(iPrefView->GotoFirstRecord() == KErrNone)
|
|
367 |
{
|
|
368 |
iPrefView->DeleteConnectionPreferenceL();
|
|
369 |
}
|
|
370 |
if(iPrefView->GotoFirstRecord() == KErrNone)
|
|
371 |
{
|
|
372 |
iPrefView->DeleteConnectionPreferenceL();
|
|
373 |
}
|
|
374 |
|
|
375 |
// Cleanup after test run
|
|
376 |
CTestStepCommDb::doTestStepPostambleL();
|
|
377 |
SetTestStepResult(EPass); return TestStepResult();
|
|
378 |
}
|
|
379 |
|
|
380 |
//////////////////////////////////////////////////////////////////////////
|
|
381 |
|
|
382 |
CCommDbTest031_05::CCommDbTest031_05()
|
|
383 |
{
|
|
384 |
// store the name of this test case
|
|
385 |
SetTestStepName(_L("step_031_05"));
|
|
386 |
}
|
|
387 |
|
|
388 |
CCommDbTest031_05::~CCommDbTest031_05()
|
|
389 |
{}
|
|
390 |
|
|
391 |
TVerdict CCommDbTest031_05::doTestStepL( void )
|
|
392 |
{
|
|
393 |
INFO_PRINTF1(_L("Step 031.05 called "));
|
|
394 |
|
|
395 |
SetTestStepResult(EPass);
|
|
396 |
CCommDbTest031_01* step031_01 = new(ELeave) CCommDbTest031_01;
|
|
397 |
CleanupStack::PushL(step031_01);
|
|
398 |
doTestStepWithHeapFailureL( *step031_01, KErrNone);
|
|
399 |
CleanupStack::PopAndDestroy(step031_01);
|
|
400 |
|
|
401 |
CCommDbTest031_02* step031_02 = new(ELeave) CCommDbTest031_02;
|
|
402 |
CleanupStack::PushL(step031_02);
|
|
403 |
doTestStepWithHeapFailureL( *step031_02, KErrNone);
|
|
404 |
CleanupStack::PopAndDestroy(step031_02);
|
|
405 |
|
|
406 |
CCommDbTest031_03* step031_03 = new(ELeave) CCommDbTest031_03;
|
|
407 |
CleanupStack::PushL(step031_03);
|
|
408 |
doTestStepWithHeapFailureL( *step031_03, KErrNone);
|
|
409 |
CleanupStack::PopAndDestroy(step031_03);
|
|
410 |
|
|
411 |
CCommDbTest031_04* step031_04 = new(ELeave) CCommDbTest031_04;
|
|
412 |
CleanupStack::PushL(step031_04);
|
|
413 |
doTestStepWithHeapFailureL( *step031_04, KErrOverflow);
|
|
414 |
CleanupStack::PopAndDestroy(step031_04);
|
|
415 |
|
|
416 |
|
|
417 |
return TestStepResult();
|
|
418 |
}
|
|
419 |
|