|
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 CTestCase which is the base class for all the TestCase DLLs |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 #include <commdb.h> |
|
21 #include <f32file.h> |
|
22 // Test system includes |
|
23 |
|
24 #ifdef SYMBIAN_OLD_EXPORT_LOCATION |
|
25 #include <comms-infras/commdb/protection/protectdb.h> |
|
26 #include <comms-infras/commdb/protection/protectcpdb.h> |
|
27 #else |
|
28 //these headers are user includes in the new env. |
|
29 #include "protectdb.h" |
|
30 #include "protectcpdb.h" |
|
31 #endif |
|
32 |
|
33 #include <cdbpreftable.h> |
|
34 #include "CDBSTD.H" |
|
35 #include <networking/log.h> |
|
36 #include <networking/teststep.h> |
|
37 #include "Teststepcommdb.h" |
|
38 #include <networking/testsuite.h> |
|
39 #include "TestSuiteCommdb.h" |
|
40 |
|
41 |
|
42 // constructor |
|
43 CTestStepCommDb::CTestStepCommDb() |
|
44 { |
|
45 iRemoteObjects = EFalse; |
|
46 } |
|
47 |
|
48 // destructor |
|
49 CTestStepCommDb::~CTestStepCommDb() |
|
50 { |
|
51 popAndDestroyDatabaseObjects(); |
|
52 } |
|
53 |
|
54 // file copy |
|
55 void CTestStepCommDb::copyFileL(const TDesC& anOld,const TDesC& aNew) |
|
56 { |
|
57 // create a fileserver |
|
58 RFs fileSystem; |
|
59 |
|
60 // connect to file server |
|
61 User::LeaveIfError(fileSystem.Connect()); |
|
62 CleanupClosePushL(fileSystem); |
|
63 |
|
64 // create a file manager |
|
65 CFileMan * fileMan = CFileMan::NewL(fileSystem); |
|
66 CleanupStack::PushL(fileMan); |
|
67 |
|
68 // parse the filenames |
|
69 TParse source; |
|
70 User::LeaveIfError(source.Set(anOld, NULL, NULL)); |
|
71 |
|
72 // parse the filenames |
|
73 TParse target; |
|
74 User::LeaveIfError(target.Set(aNew, NULL, NULL)); |
|
75 |
|
76 // do the copy |
|
77 User::LeaveIfError(fileMan->Copy(source.FullName(), target.FullName(), CFileMan::EOverWrite)); |
|
78 |
|
79 // make read/write |
|
80 User::LeaveIfError(fileSystem.SetAtt(source.FullName(),NULL, KEntryAttReadOnly)); |
|
81 |
|
82 // clean up |
|
83 CleanupStack::PopAndDestroy(fileMan); |
|
84 CleanupStack::PopAndDestroy(&fileSystem); |
|
85 } |
|
86 |
|
87 void CTestStepCommDb::deleteFileL(const TDesC& aFileName) |
|
88 { |
|
89 // create a fileserver |
|
90 RFs fileSystem; |
|
91 |
|
92 User::LeaveIfError(fileSystem.Connect()); |
|
93 CleanupClosePushL(fileSystem); |
|
94 |
|
95 Log(_L("Set file to read-write in order to delete")); |
|
96 |
|
97 // Remove read only flag |
|
98 TInt ret = fileSystem.SetAtt(aFileName, 0, KEntryAttReadOnly); |
|
99 if (ret == KErrNotFound) |
|
100 { |
|
101 // If file already removed then no need to delete it |
|
102 Log(_L("File not found")); |
|
103 CleanupStack::PopAndDestroy(&fileSystem); |
|
104 return; |
|
105 } |
|
106 User::LeaveIfError(ret); |
|
107 |
|
108 // Delete file |
|
109 User::LeaveIfError(fileSystem.Delete(aFileName)); |
|
110 Log(_L("deleted file")); |
|
111 |
|
112 // clean up |
|
113 CleanupStack::PopAndDestroy(&fileSystem); |
|
114 } |
|
115 |
|
116 void CTestStepCommDb::DeleteCurrentDatabaseL() |
|
117 { |
|
118 RDbs rDbs; |
|
119 |
|
120 // User::LeaveIfError(rDbs.Connect()); |
|
121 TInt ret(KErrNone); |
|
122 ret = rDbs.Connect(); |
|
123 if(ret!=KErrNone) |
|
124 { |
|
125 Log(_L("CTestStepCommDb::DeleteCurrentDatabaseL : rDbs.Connect FAILED with %d"),ret ); |
|
126 User::Leave(ret); |
|
127 } |
|
128 |
|
129 CleanupClosePushL(rDbs); |
|
130 TName commDb(KCDrive); |
|
131 commDb.Append(KDbBaseName); |
|
132 TUid KCommsDbFileUid = { 0x10004e1d }; |
|
133 // May need to make several |
|
134 // attempts if it is transiently locked; report these and if |
|
135 // not successful after a number of attempts report this and abort |
|
136 TInt remainingTries = 5; |
|
137 // TInt ret (KErrNone); |
|
138 while(remainingTries-- > 0) |
|
139 { |
|
140 ret = rDbs.DeleteDatabase(commDb, KCommsDbFileUid); |
|
141 if(ret == KErrNone || ret == KErrPathNotFound || ret == KErrNotFound) |
|
142 { |
|
143 ret = KErrNone; |
|
144 break; |
|
145 } |
|
146 else |
|
147 { |
|
148 Log(_L("CTestStepCommDb::DeleteCurrentDatabaseL : rDbs.DeleteDatabase FAILED to delete %S %S with %d"),&KCDrive,&KDbBaseName,ret); |
|
149 } |
|
150 } |
|
151 User::LeaveIfError(ret); |
|
152 CleanupStack::PopAndDestroy(&rDbs); |
|
153 } |
|
154 |
|
155 void CTestStepCommDb::CopyDatabaseL(const TDesC& aSource) |
|
156 { |
|
157 RFs fs; |
|
158 User::LeaveIfError(fs.Connect()); |
|
159 CleanupClosePushL(fs); |
|
160 |
|
161 RDbs rDbs; |
|
162 User::LeaveIfError(rDbs.Connect()); |
|
163 CleanupClosePushL(rDbs); |
|
164 const TUid KCommsDbFileUid = {0x10004e1d}; |
|
165 |
|
166 TInt remainingTries = 5; |
|
167 TInt ret (KErrNone); |
|
168 DeleteCurrentDatabaseL(); |
|
169 while(remainingTries-- > 0) |
|
170 { |
|
171 ret = rDbs.CopyDatabase(aSource, KDbFileName, KCommsDbFileUid); |
|
172 if(ret == KErrNone || ret == KErrPathNotFound || ret == KErrNotFound) |
|
173 { |
|
174 break; |
|
175 } |
|
176 } |
|
177 User::LeaveIfError(ret); |
|
178 CleanupStack::PopAndDestroy(&rDbs); |
|
179 CleanupStack::PopAndDestroy(&fs); |
|
180 } |
|
181 |
|
182 |
|
183 TInt CTestStepCommDb::copyTestDatabase( TDatabaseNumber aDbNumber ) |
|
184 { |
|
185 (void)aDbNumber; |
|
186 return KErrNone; |
|
187 } |
|
188 |
|
189 TInt CTestStepCommDb::copyDatabaseToDefault( TDatabaseNumber aDbNumber ) |
|
190 { |
|
191 (void)aDbNumber; |
|
192 return KErrNone; |
|
193 } |
|
194 |
|
195 TBool CTestStepCommDb::openDbAndViewL( const TDesC16& aTable ) |
|
196 { |
|
197 TBool created = EFalse; |
|
198 |
|
199 //Only create Db and view objects if they're not already created |
|
200 if ( ! iTheDb ) |
|
201 { |
|
202 iTheDb=CCommsDatabase::NewL(); |
|
203 created = ETrue; |
|
204 } |
|
205 |
|
206 if ( !iTheView ) |
|
207 { |
|
208 iTheView=iTheDb->OpenTableLC( aTable ); |
|
209 CleanupStack::Pop(); //no need to put it on the cleanup stack |
|
210 } |
|
211 |
|
212 return created; |
|
213 } |
|
214 |
|
215 TVerdict CTestStepCommDb::doTestStepPostambleL() |
|
216 { |
|
217 if ( iTheView ) |
|
218 { |
|
219 delete iTheView; |
|
220 iTheView = 0; |
|
221 } |
|
222 |
|
223 if ( iTheDb ) |
|
224 { |
|
225 delete iTheDb; |
|
226 iTheDb = 0; |
|
227 } |
|
228 |
|
229 return EPass; |
|
230 } |
|
231 |
|
232 |
|
233 |
|
234 void CTestStepCommDb::popAndDestroyDatabaseObjects() |
|
235 { |
|
236 // doTestStepPostambleL(); |
|
237 } |
|
238 |
|
239 TBool CTestStepCommDb::openDbL() |
|
240 { |
|
241 |
|
242 TBool created = EFalse; |
|
243 |
|
244 if ( !iTheDb ) |
|
245 { |
|
246 //Only open the Db if its not already open |
|
247 TRAPD(ret,iTheDb=CCommsDatabase::NewL()); |
|
248 if(ret!=KErrNone) |
|
249 { |
|
250 Log(_L("CTestStepCommDb::openDbL : CCommsDatabase::NewL LEFT with %d"),ret); |
|
251 User::Leave(ret); |
|
252 } |
|
253 created = ETrue; |
|
254 } |
|
255 return created; |
|
256 |
|
257 } |
|
258 |
|
259 void CTestStepCommDb::setRemoteDatabaseObjects( CCommsDatabase* aDb, CCommsDbTableView* aDbView ) |
|
260 { |
|
261 if ( !iTheDb ) |
|
262 { |
|
263 //make sure that no-one else has already set the objects |
|
264 iTheDb = aDb; |
|
265 iTheView = aDbView; |
|
266 iRemoteObjects = ETrue; |
|
267 } |
|
268 } |
|
269 |
|
270 |
|
271 void CTestStepCommDb::clearRemoteDatabaseObjects() |
|
272 { |
|
273 if( iRemoteObjects ) |
|
274 { |
|
275 //Only clear objects if they were previously set remotly |
|
276 iTheDb = 0; |
|
277 iTheView = 0; |
|
278 } |
|
279 } |
|
280 |
|
281 TInt CTestStepCommDb::executeStepL() |
|
282 { |
|
283 return KErrGeneral; |
|
284 } |
|
285 |
|
286 |
|
287 TInt CTestStepCommDb::executeStep(CTestStepCommDb& aTestStep) |
|
288 { |
|
289 TInt r,ret= KErrNone; |
|
290 |
|
291 TRAP( r, ret = aTestStep.executeStepL() ); |
|
292 |
|
293 if ( r != KErrNone ) |
|
294 ret = r; |
|
295 |
|
296 return ret; |
|
297 } |
|
298 |
|
299 TInt CTestStepCommDb::executeStep( ) |
|
300 { |
|
301 TInt ret=0; |
|
302 |
|
303 TRAPD( r, ret = executeStepL() ); |
|
304 |
|
305 if ( r != KErrNone ) |
|
306 ret = r; |
|
307 |
|
308 return ret; |
|
309 } |
|
310 |
|
311 // |
|
312 //This heap failure member function is used when a test step needs a Database and a View |
|
313 //object. |
|
314 // |
|
315 TInt CTestStepCommDb::doTestStepWithHeapFailureL( CTestStepCommDb& aTestStep, TInt aReturnValue) |
|
316 { |
|
317 TInt ret=0; |
|
318 |
|
319 for (TInt i=1; i< KHeapFailure ; i++) |
|
320 { |
|
321 aTestStep.doTestStepPreambleL(); |
|
322 |
|
323 __UHEAP_FAILNEXT(i); |
|
324 |
|
325 ret = aTestStep.executeStep(); |
|
326 |
|
327 __UHEAP_RESET; |
|
328 |
|
329 aTestStep.doTestStepPostambleL(); |
|
330 |
|
331 if ( ret == KErrNoMemory ) |
|
332 { |
|
333 //The heap failure has been trapped correctly |
|
334 continue; |
|
335 } |
|
336 else if ( ret == aReturnValue ) |
|
337 { |
|
338 //Test step normal behaviour |
|
339 TPtrC ExpectedErrortxt = CLog::EpocErrorToText(ret); |
|
340 Log(_L("%s PASSED heap failure test, i = %d return code==%S"), |
|
341 aTestStep.iTestStepName.PtrZ(), i, &ExpectedErrortxt ); |
|
342 |
|
343 break; |
|
344 } |
|
345 else |
|
346 { |
|
347 // test step has not returned the exepected error value ( which was either KErrNoMemory or aReturnValue ) |
|
348 TPtrC unexpectedErrortxt = CLog::EpocErrorToText(ret); |
|
349 TPtrC Error = CLog::EpocErrorToText(aReturnValue); |
|
350 Log(_L("%s *FAILED* heap failure test, i=%d return code:%S expected:%S"), |
|
351 aTestStep.iTestStepName.PtrZ(), i, &unexpectedErrortxt, &Error ); |
|
352 iTestStepResult = EFail; |
|
353 break; |
|
354 } |
|
355 |
|
356 } |
|
357 |
|
358 return KErrNone; |
|
359 } |
|
360 |
|
361 void CTestStepCommDb::CheckTableIsProtectedL(CCommsDbProtectTableView* aTable) |
|
362 { |
|
363 |
|
364 TESTL(iTheDb->BeginTransaction()==KErrNone); |
|
365 |
|
366 if(aTable->GotoFirstRecord()==KErrNone) |
|
367 { |
|
368 // Check settings on Record |
|
369 RDbRowSet::TAccess tableAccess = RDbRowSet::EUpdatable; |
|
370 TInt ret = aTable->GetTableAccess(tableAccess); |
|
371 TESTL(ret == KErrNone); |
|
372 TESTL(tableAccess == RDbRowSet::EReadOnly); |
|
373 |
|
374 // Test that first record cannot be updated |
|
375 TRAP(ret,UpdateRecordL(aTable,KErrAccessDenied)); |
|
376 TESTL(ret == KErrNone); |
|
377 |
|
378 // Test that cannot delete first record |
|
379 TRAP(ret,DeleteRecordL(aTable,KErrAccessDenied)); |
|
380 TESTL(ret == KErrNone); |
|
381 |
|
382 // Test that cannot insert new record |
|
383 TRAP(ret,InsertRecordL(aTable,KErrAccessDenied)); |
|
384 TESTL(ret == KErrNone); |
|
385 |
|
386 aTable->GotoFirstRecord(); |
|
387 } |
|
388 TESTL(iTheDb->CommitTransaction()==KErrNone); |
|
389 } |
|
390 |
|
391 |
|
392 void CTestStepCommDb::CheckTableIsProtectedL(CCommsDbProtectConnectPrefTableView* aTable) |
|
393 { |
|
394 |
|
395 TESTL(iTheDb->BeginTransaction()==KErrNone); |
|
396 if(aTable->GotoFirstRecord()==KErrNone) |
|
397 { |
|
398 // Check settings on Record |
|
399 RDbRowSet::TAccess tableAccess = RDbRowSet::EUpdatable; |
|
400 TInt ret = aTable->GetTableAccess(tableAccess); |
|
401 TESTL(ret == KErrNone); |
|
402 TESTL(tableAccess == RDbRowSet::EReadOnly); |
|
403 |
|
404 // Test that first record cannot be updated |
|
405 TRAP(ret,UpdateRecordL(aTable,KErrAccessDenied)); |
|
406 TESTL(ret == KErrNone); |
|
407 |
|
408 // Test that cannot delete first record |
|
409 TRAP(ret,DeleteRecordL(aTable,KErrAccessDenied)); |
|
410 TESTL(ret == KErrNone); |
|
411 |
|
412 // Test that cannot insert new record |
|
413 TRAP(ret,InsertRecordL(aTable,KErrAccessDenied)); |
|
414 TESTL(ret == KErrNone); |
|
415 |
|
416 aTable->GotoFirstRecord(); |
|
417 } |
|
418 TESTL(iTheDb->CommitTransaction()==KErrNone); |
|
419 } |
|
420 |
|
421 void CTestStepCommDb::CheckTableIsNotProtectedL(CCommsDbProtectTableView* aTable) |
|
422 { |
|
423 TESTL(iTheDb->BeginTransaction()==KErrNone); |
|
424 if(aTable->GotoFirstRecord()==KErrNone) |
|
425 { |
|
426 // Check settings on Table |
|
427 RDbRowSet::TAccess tableAccess = RDbRowSet::EReadOnly; |
|
428 TInt ret = aTable->GetTableAccess(tableAccess); |
|
429 TESTL(ret == KErrNone); |
|
430 TESTL(tableAccess == RDbRowSet::EUpdatable); |
|
431 |
|
432 // Test can update first record |
|
433 TRAP(ret,UpdateRecordL(aTable,KErrNone)); |
|
434 TESTL(ret == KErrNone); |
|
435 |
|
436 // Test that can delete record |
|
437 TRAP(ret,DeleteRecordL(aTable,KErrNone)); |
|
438 TESTL(ret == KErrNone); |
|
439 |
|
440 // Test that can insert new record |
|
441 TRAP(ret,InsertRecordL(aTable,KErrNone)); |
|
442 TESTL(ret == KErrNone); |
|
443 |
|
444 aTable->GotoFirstRecord(); |
|
445 } |
|
446 TESTL(iTheDb->CommitTransaction()==KErrNone); |
|
447 } |
|
448 |
|
449 void CTestStepCommDb::CheckTableIsNotProtectedL(CCommsDbProtectConnectPrefTableView* aTable) |
|
450 { |
|
451 TESTL(iTheDb->BeginTransaction()==KErrNone); |
|
452 if(aTable->GotoFirstRecord()==KErrNone) |
|
453 { |
|
454 // Check settings on Table |
|
455 RDbRowSet::TAccess tableAccess = RDbRowSet::EReadOnly; |
|
456 TInt ret = aTable->GetTableAccess(tableAccess); |
|
457 TESTL(ret == KErrNone); |
|
458 TESTL(tableAccess == RDbRowSet::EUpdatable); |
|
459 |
|
460 // Test can update first record |
|
461 TRAP(ret,UpdateRecordL(aTable,KErrNone)); |
|
462 TESTL(ret == KErrNone); |
|
463 |
|
464 // Test that can delete record |
|
465 TRAP(ret,DeleteRecordL(aTable,KErrNone)); |
|
466 TESTL(ret == KErrNone); |
|
467 |
|
468 // Test that can insert new record |
|
469 TRAP(ret,InsertRecordL(aTable,KErrNone)); |
|
470 TESTL(ret == KErrNone); |
|
471 |
|
472 aTable->GotoFirstRecord(); |
|
473 } |
|
474 TESTL(iTheDb->CommitTransaction()==KErrNone); |
|
475 } |
|
476 |
|
477 void CTestStepCommDb::GoToPositionL(CCommsDbProtectTableView* aTable,TInt aPos) |
|
478 { |
|
479 TESTL(aTable->GotoFirstRecord()==KErrNone); |
|
480 for (TInt i = 0; i < aPos; i++) |
|
481 { |
|
482 TESTL(aTable->GotoNextRecord()==KErrNone); |
|
483 } |
|
484 } |
|
485 |
|
486 void CTestStepCommDb::ProtectRecordL(CCommsDbProtectTableView* aTable, TInt aResult) |
|
487 { |
|
488 TESTL(aTable->ProtectRecord()==aResult); |
|
489 } |
|
490 |
|
491 void CTestStepCommDb::ProtectRecordL(CCommsDbProtectConnectPrefTableView* aTable, TInt aResult) |
|
492 { |
|
493 TESTL(aTable->ProtectRecord()==aResult); |
|
494 } |
|
495 |
|
496 void CTestStepCommDb::UnprotectRecordL(CCommsDbProtectTableView* aTable, TInt aResult) |
|
497 { |
|
498 TESTL(aTable->UnprotectRecord()==aResult); |
|
499 } |
|
500 |
|
501 void CTestStepCommDb::UnprotectRecordL(CCommsDbProtectConnectPrefTableView* aTable, TInt aResult) |
|
502 { |
|
503 TESTL(aTable->UnprotectRecord()==aResult); |
|
504 } |
|
505 |
|
506 void CTestStepCommDb::UpdateRecordL(CCommsDbProtectTableView* aTable, TInt aResult) |
|
507 { |
|
508 |
|
509 TESTL(aTable->UpdateRecord()==aResult); |
|
510 if (aResult == KErrNone) |
|
511 { |
|
512 ModifyRecordL(aTable); |
|
513 TESTL(aTable->PutRecordChanges()==KErrNone); |
|
514 } |
|
515 } |
|
516 |
|
517 void CTestStepCommDb::UpdateRecordL(CCommsDbProtectConnectPrefTableView* aTable, TInt aExpectedResult) |
|
518 { |
|
519 |
|
520 TUint32 Ranking; |
|
521 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref RecordData; |
|
522 |
|
523 TInt ErrVal = ChangeCPRankingL(aTable, Ranking); // Try modifying a field. |
|
524 |
|
525 TESTL(ErrVal == aExpectedResult); |
|
526 |
|
527 if (ErrVal == KErrNone) |
|
528 { |
|
529 // The change was allowed, so check it actually happened. |
|
530 aTable->ReadConnectionPreferenceL(RecordData); |
|
531 TESTL(Ranking == RecordData.iRanking); |
|
532 } |
|
533 } |
|
534 |
|
535 void CTestStepCommDb::DeleteRecordL(CCommsDbProtectTableView* aTable, TInt aResult) |
|
536 { |
|
537 TESTL(aTable->DeleteRecord()==aResult); |
|
538 } |
|
539 |
|
540 void CTestStepCommDb::DeleteRecordL(CCommsDbProtectConnectPrefTableView* aTable, TInt aExpectedResult) |
|
541 { |
|
542 TRAPD(ErrVal, aTable->DeleteConnectionPreferenceL()); |
|
543 TESTL(ErrVal == aExpectedResult); |
|
544 } |
|
545 |
|
546 void CTestStepCommDb::InsertRecordL(CCommsDbProtectTableView* aTable, TInt aExpectedResult) |
|
547 { |
|
548 TUint32 recordId; |
|
549 TInt ret = aTable->InsertRecord(recordId); |
|
550 TESTL(ret==aExpectedResult||ret==KErrAlreadyExists); //for some tables insertion fails |
|
551 //because they can only have |
|
552 //one record (i.e. DEFAULT_GPRS) |
|
553 if (ret == KErrNone) |
|
554 { |
|
555 PopulateInsertedRecordL(aTable); |
|
556 TESTL(aTable->PutRecordChanges()==KErrNone); |
|
557 } |
|
558 } |
|
559 |
|
560 void CTestStepCommDb::InsertRecordL(CCommsDbProtectConnectPrefTableView* aTable, TInt aExpectedResult) |
|
561 { |
|
562 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref PrefData1, PrefData2; |
|
563 |
|
564 PrefData1.iRanking = 0; |
|
565 PrefData1.iDirection = ECommDbConnectionDirectionOutgoing; |
|
566 PrefData1.iDialogPref = ECommDbDialogPrefWarn; |
|
567 PrefData1.iBearer.iBearerSet = ECommDbBearerCSD; |
|
568 PrefData1.iBearer.iIapId = 1; |
|
569 |
|
570 TRAPD(ErrVal, aTable->InsertConnectionPreferenceL(PrefData1)); |
|
571 TESTL(ErrVal==aExpectedResult); //for some tables insertion fails |
|
572 //because they can only have |
|
573 //one record (i.e. DEFAULT_GPRS) |
|
574 if (ErrVal == KErrNone) |
|
575 { |
|
576 aTable->ReadConnectionPreferenceL(PrefData2); |
|
577 TESTL(PrefData1 == PrefData2); |
|
578 } |
|
579 } |
|
580 |
|
581 |
|
582 #define TEST_FCN(_F_) {TRAPD(ret,_F_); TESTL(ret == KErrNone);} |
|
583 |
|
584 void CTestStepCommDb::ModifyRecordL(CCommsDbProtectTableView* aTable) |
|
585 // |
|
586 // Modify some field in current record |
|
587 // |
|
588 { |
|
589 TEST_FCN(aTable->WriteTextL(TPtrC(COMMDB_NAME),_L("test"))); |
|
590 } |
|
591 // Extract the protection state for the current record, |
|
592 // and leave if it's not the state expected |
|
593 void CTestStepCommDb::CheckRecordAccessL(CCommsDbProtectConnectPrefTableView* aTable, TInt aExpectedAccess) |
|
594 { |
|
595 TInt FoundAccess; |
|
596 // Set the state to one not expected, so it will fail if not explicitly changed |
|
597 if (aExpectedAccess == RDbRowSet::EUpdatable) |
|
598 FoundAccess = RDbRowSet::EReadOnly; |
|
599 else |
|
600 FoundAccess = RDbRowSet::EUpdatable; |
|
601 |
|
602 TESTL(aTable->GetRecordAccess(FoundAccess) == KErrNone); |
|
603 TESTL(aExpectedAccess == FoundAccess); |
|
604 } |
|
605 void CTestStepCommDb::PopulateInsertedRecordL(CCommsDbProtectTableView* aTable) |
|
606 // |
|
607 // Populate minimal set of fields in current newly inserted record. |
|
608 // |
|
609 { |
|
610 TBuf<50> tableName; |
|
611 aTable->GetTableName(tableName); |
|
612 |
|
613 if (tableName == TPtrC(DIAL_OUT_ISP)) |
|
614 { |
|
615 TEST_FCN(aTable->WriteTextL(TPtrC(COMMDB_NAME),_L("Inserted Service"))); |
|
616 TEST_FCN(aTable->WriteBoolL(TPtrC(ISP_DIAL_RESOLUTION),ETrue)); |
|
617 TEST_FCN(aTable->WriteBoolL(TPtrC(ISP_USE_LOGIN_SCRIPT),EFalse)); |
|
618 TEST_FCN(aTable->WriteBoolL(TPtrC(ISP_PROMPT_FOR_LOGIN),ETrue)); |
|
619 TEST_FCN(aTable->WriteBoolL(TPtrC(ISP_IF_PROMPT_FOR_AUTH),ETrue)); |
|
620 TEST_FCN(aTable->WriteBoolL(TPtrC(ISP_IP_ADDR_FROM_SERVER),ETrue)); |
|
621 TEST_FCN(aTable->WriteBoolL(TPtrC(ISP_IP_DNS_ADDR_FROM_SERVER),ETrue)); |
|
622 TEST_FCN(aTable->WriteBoolL(TPtrC(ISP_IP6_DNS_ADDR_FROM_SERVER),ETrue)); |
|
623 } |
|
624 |
|
625 // EXTEND OR MODIFY this function if want to use different table |
|
626 } |
|
627 // Just a utility function - for checking the protection of the Connection Preferences |
|
628 // table and its records, we just try changing the ranking field of the first one. |
|
629 TInt CTestStepCommDb::ChangeCPRankingL(CCommsDbProtectConnectPrefTableView* aTable, TUint32& Ranking) |
|
630 { |
|
631 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref RecordData; |
|
632 |
|
633 aTable->ReadConnectionPreferenceL(RecordData); |
|
634 if(RecordData.iRanking == 1) |
|
635 Ranking = 0; |
|
636 else |
|
637 Ranking = 1; |
|
638 TRAPD(ErrVal, aTable->ChangeConnectionPreferenceRankL(Ranking)); |
|
639 return(ErrVal); |
|
640 } |
|
641 |
|
642 #undef TEST_FCN |