|
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 037.XX |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 #include <commdb.h> |
|
21 #include <d32comm.h> |
|
22 #include <cdbtemp.h> |
|
23 |
|
24 // Test system includes |
|
25 #include <networking/log.h> |
|
26 #include <networking/teststep.h> |
|
27 #include "Teststepcommdb.h" |
|
28 #include "TestSuiteCommdb.h" |
|
29 #include "Step_037_xx.h" |
|
30 |
|
31 |
|
32 CCommDbTest037_01::CCommDbTest037_01() |
|
33 { |
|
34 // store the name of this test case |
|
35 iTestStepName = _L("step_037_01"); |
|
36 } |
|
37 |
|
38 CCommDbTest037_01::~CCommDbTest037_01() |
|
39 {} |
|
40 |
|
41 TVerdict CCommDbTest037_01::doTestStepL( void ) |
|
42 { |
|
43 if(executeStepL()!=KErrNone) |
|
44 return EFail; |
|
45 return EPass; |
|
46 } |
|
47 |
|
48 TVerdict CCommDbTest037_01::doTestStepPreambleL() |
|
49 { |
|
50 iTheDb=CCommsDatabase::NewL(); |
|
51 |
|
52 return EPass; |
|
53 } |
|
54 |
|
55 TInt CCommDbTest037_01::executeStepL() |
|
56 { |
|
57 //alter something in the template |
|
58 CCommsDbTemplateRecord* templateRecord = CCommsDbTemplateRecord::NewL(iTheDb, TPtrC(MODEM_BEARER)); |
|
59 CleanupStack::PushL(templateRecord); |
|
60 |
|
61 User::LeaveIfError(templateRecord->Modify()); |
|
62 templateRecord->WriteTextL(TPtrC(COMMDB_NAME), _L("DummyName")); |
|
63 TBufC8<KCommsDbSvrMaxFieldLength> firstInputString = _L8("first string"); |
|
64 |
|
65 templateRecord->WriteTextL(TPtrC(MODEM_FAX_INIT_STRING), firstInputString); |
|
66 User::LeaveIfError(templateRecord->StoreModifications()); |
|
67 //Now start to overwrite initial change, but don't commit, cancel instead. |
|
68 User::LeaveIfError(templateRecord->Modify()); |
|
69 |
|
70 TBufC8<KCommsDbSvrMaxFieldLength> secondInputString = _L8("second string"); |
|
71 templateRecord->WriteTextL(TPtrC(MODEM_FAX_INIT_STRING), secondInputString); |
|
72 templateRecord->CancelModifications(); |
|
73 |
|
74 TBuf8<KCommsDbSvrMaxFieldLength> retrievedString; |
|
75 templateRecord->ReadTextL(TPtrC(MODEM_FAX_INIT_STRING), retrievedString); |
|
76 CleanupStack::PopAndDestroy(templateRecord); |
|
77 |
|
78 if(retrievedString!=firstInputString) |
|
79 return KErrGeneral; |
|
80 |
|
81 return KErrNone; |
|
82 } |
|
83 |
|
84 TVerdict CCommDbTest037_01::doTestStepPostambleL() |
|
85 { |
|
86 delete iTheDb; |
|
87 iTheDb=NULL; |
|
88 return EPass; |
|
89 } |
|
90 |
|
91 // |
|
92 |
|
93 CCommDbTest037_02::CCommDbTest037_02() |
|
94 { |
|
95 // store the name of this test case |
|
96 iTestStepName = _L("step_037_02"); |
|
97 } |
|
98 |
|
99 CCommDbTest037_02::~CCommDbTest037_02() |
|
100 {} |
|
101 |
|
102 TVerdict CCommDbTest037_02::doTestStepL( void ) |
|
103 { |
|
104 executeStepL(); |
|
105 return EPass; //If we get here we've passed |
|
106 } |
|
107 |
|
108 TVerdict CCommDbTest037_02::doTestStepPreambleL() |
|
109 { |
|
110 iTheDb=CCommsDatabase::NewL(); |
|
111 |
|
112 return EPass; |
|
113 } |
|
114 |
|
115 TInt CCommDbTest037_02::executeStepL() |
|
116 { |
|
117 //alter something in the template |
|
118 CCommsDbTemplateRecord* templateRecord = CCommsDbTemplateRecord::NewL(iTheDb, TPtrC(MODEM_BEARER)); |
|
119 CleanupStack::PushL(templateRecord); |
|
120 |
|
121 templateRecord->CancelModifications(); |
|
122 |
|
123 CleanupStack::PopAndDestroy(templateRecord); |
|
124 |
|
125 return KErrNone; |
|
126 } |
|
127 |
|
128 TVerdict CCommDbTest037_02::doTestStepPostambleL() |
|
129 { |
|
130 delete iTheDb; |
|
131 iTheDb=NULL; |
|
132 return EPass; |
|
133 } |
|
134 |
|
135 // |
|
136 |
|
137 CCommDbTest037_03::CCommDbTest037_03() |
|
138 { |
|
139 // store the name of this test case |
|
140 iTestStepName = _L("step_037_03"); |
|
141 } |
|
142 |
|
143 CCommDbTest037_03::~CCommDbTest037_03() |
|
144 {} |
|
145 |
|
146 TVerdict CCommDbTest037_03::doTestStepL( void ) |
|
147 { |
|
148 Log(_L("Step 037.03 called ")); |
|
149 |
|
150 iTestStepResult = EPass; |
|
151 |
|
152 CCommDbTest037_01* step037_01 = new(ELeave) CCommDbTest037_01; |
|
153 CleanupStack::PushL(step037_01); |
|
154 step037_01->iSuite = iSuite; |
|
155 doTestStepWithHeapFailureL( *step037_01, KErrNone); |
|
156 CleanupStack::PopAndDestroy(step037_01); |
|
157 |
|
158 CCommDbTest037_02* step037_02 = new(ELeave) CCommDbTest037_02; |
|
159 CleanupStack::PushL(step037_02); |
|
160 step037_02->iSuite = iSuite; |
|
161 doTestStepWithHeapFailureL( *step037_02, KErrNone); |
|
162 CleanupStack::PopAndDestroy(step037_02); |
|
163 |
|
164 return iTestStepResult; |
|
165 } |