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 030.XX |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 #include <commdb.h> |
|
21 #include <d32comm.h> |
|
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_030_xx.h" |
|
29 |
|
30 |
|
31 CCommDbTest030_01::CCommDbTest030_01() |
|
32 { |
|
33 // store the name of this test case |
|
34 iTestStepName = _L("step_030_01"); |
|
35 } |
|
36 |
|
37 CCommDbTest030_01::~CCommDbTest030_01() |
|
38 {} |
|
39 |
|
40 TVerdict CCommDbTest030_01::doTestStepL( void ) |
|
41 { |
|
42 if(executeStepL()!=KErrNone) |
|
43 return EFail; |
|
44 return EPass; |
|
45 } |
|
46 |
|
47 TVerdict CCommDbTest030_01::doTestStepPreambleL() |
|
48 { |
|
49 iTheDb=CCommsDatabase::NewL(); |
|
50 |
|
51 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
52 CleanupStack::Pop(); |
|
53 |
|
54 return EPass; |
|
55 } |
|
56 |
|
57 TInt CCommDbTest030_01::executeStepL() |
|
58 { |
|
59 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref1; |
|
60 pref1.iRanking = 1; |
|
61 pref1.iDirection = ECommDbConnectionDirectionOutgoing; |
|
62 pref1.iDialogPref = ECommDbDialogPrefPrompt; |
|
63 pref1.iBearer.iBearerSet = KCommDbBearerCSD; |
|
64 pref1.iBearer.iIapId = 1; |
|
65 |
|
66 iPrefView->InsertConnectionPreferenceL(pref1, EFalse); |
|
67 |
|
68 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref2; |
|
69 pref2.iRanking = 1; |
|
70 pref2.iDirection = ECommDbConnectionDirectionIncoming; |
|
71 pref2.iDialogPref = ECommDbDialogPrefPrompt; |
|
72 pref2.iBearer.iBearerSet = KCommDbBearerCSD; |
|
73 pref2.iBearer.iIapId = 3; |
|
74 |
|
75 iPrefView->InsertConnectionPreferenceL(pref2, EFalse); |
|
76 |
|
77 User::LeaveIfError(iPrefView->GotoFirstRecord()); |
|
78 |
|
79 CCommsDbConnectionPrefTableView::TCommDbIapBearer newBearer; //Set new bearer to point at other outgoing Iap in commdb |
|
80 newBearer.iBearerSet=KCommDbBearerLAN|KCommDbBearerCSD; |
|
81 newBearer.iIapId=2; |
|
82 |
|
83 iPrefView->UpdateBearerL(newBearer); |
|
84 |
|
85 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref retrievedPref; |
|
86 |
|
87 iPrefView->ReadConnectionPreferenceL(retrievedPref); |
|
88 |
|
89 if( (retrievedPref.iBearer.iBearerSet!=newBearer.iBearerSet) //Check that retrieved pref is what we would expect |
|
90 ||(retrievedPref.iBearer.iIapId!=newBearer.iIapId) |
|
91 ||(retrievedPref.iRanking!=pref1.iRanking) |
|
92 ||(retrievedPref.iDirection!=pref1.iDirection) |
|
93 ||(retrievedPref.iDialogPref!=pref1.iDialogPref)) |
|
94 return KErrGeneral; |
|
95 |
|
96 return KErrNone; |
|
97 } |
|
98 |
|
99 TVerdict CCommDbTest030_01::doTestStepPostambleL() |
|
100 { |
|
101 //Get rid of our view |
|
102 if(iPrefView) |
|
103 { |
|
104 delete iPrefView; |
|
105 } |
|
106 iPrefView=0; |
|
107 |
|
108 //Create a new view that should have the record that was added in executeStepL and |
|
109 // may have been left in by a leave condition |
|
110 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
111 CleanupStack::Pop(); |
|
112 |
|
113 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
114 { |
|
115 iPrefView->DeleteConnectionPreferenceL(); |
|
116 } |
|
117 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
118 { |
|
119 iPrefView->DeleteConnectionPreferenceL(); |
|
120 } |
|
121 |
|
122 // Cleanup after test run |
|
123 CTestStepCommDb::doTestStepPostambleL(); |
|
124 return EPass; |
|
125 } |
|
126 |
|
127 // |
|
128 |
|
129 CCommDbTest030_02::CCommDbTest030_02() |
|
130 { |
|
131 // store the name of this test case |
|
132 iTestStepName = _L("step_030_02"); |
|
133 } |
|
134 |
|
135 CCommDbTest030_02::~CCommDbTest030_02() |
|
136 {} |
|
137 |
|
138 TVerdict CCommDbTest030_02::doTestStepL( void ) |
|
139 { |
|
140 if(executeStepL()!=KErrAccessDenied) |
|
141 return EFail; |
|
142 return EPass; |
|
143 } |
|
144 |
|
145 TVerdict CCommDbTest030_02::doTestStepPreambleL() |
|
146 { |
|
147 iTheDb=CCommsDatabase::NewL(); |
|
148 |
|
149 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
150 CleanupStack::Pop(); |
|
151 |
|
152 return EPass; |
|
153 } |
|
154 |
|
155 TInt CCommDbTest030_02::executeStepL() |
|
156 { |
|
157 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref1; |
|
158 pref1.iRanking = 1; |
|
159 pref1.iDirection = ECommDbConnectionDirectionOutgoing; |
|
160 pref1.iDialogPref = ECommDbDialogPrefPrompt; |
|
161 pref1.iBearer.iBearerSet = KCommDbBearerCSD; |
|
162 pref1.iBearer.iIapId = 1; |
|
163 |
|
164 iPrefView->InsertConnectionPreferenceL(pref1, ETrue); |
|
165 |
|
166 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref2; |
|
167 pref2.iRanking = 1; |
|
168 pref2.iDirection = ECommDbConnectionDirectionIncoming; |
|
169 pref2.iDialogPref = ECommDbDialogPrefPrompt; |
|
170 pref2.iBearer.iBearerSet = KCommDbBearerCSD; |
|
171 pref2.iBearer.iIapId = 3; |
|
172 |
|
173 iPrefView->InsertConnectionPreferenceL(pref2, ETrue); |
|
174 |
|
175 User::LeaveIfError(iPrefView->GotoFirstRecord()); |
|
176 |
|
177 CCommsDbConnectionPrefTableView::TCommDbIapBearer newBearer; //Set new bearer to point at other outgoing Iap in commdb |
|
178 newBearer.iBearerSet=KCommDbBearerLAN|KCommDbBearerCSD; |
|
179 newBearer.iIapId=2; |
|
180 |
|
181 TRAPD(err, iPrefView->UpdateBearerL(newBearer)); |
|
182 return err; |
|
183 } |
|
184 |
|
185 TVerdict CCommDbTest030_02::doTestStepPostambleL() |
|
186 { |
|
187 //Get rid of our view |
|
188 if(iPrefView) |
|
189 { |
|
190 delete iPrefView; |
|
191 } |
|
192 iPrefView=0; |
|
193 |
|
194 //Create a new view that should have the record that was added in executeStepL and |
|
195 // may have been left in by a leave condition |
|
196 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
197 CleanupStack::Pop(); |
|
198 |
|
199 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
200 { |
|
201 iPrefView->DeleteConnectionPreferenceL(); |
|
202 } |
|
203 if(iPrefView->GotoFirstRecord() == KErrNone) |
|
204 { |
|
205 iPrefView->DeleteConnectionPreferenceL(); |
|
206 } |
|
207 |
|
208 // Cleanup after test run |
|
209 CTestStepCommDb::doTestStepPostambleL(); |
|
210 return EPass; |
|
211 } |
|
212 |
|
213 // |
|
214 |
|
215 CCommDbTest030_03::CCommDbTest030_03() |
|
216 { |
|
217 // store the name of this test case |
|
218 iTestStepName = _L("step_030_03"); |
|
219 } |
|
220 |
|
221 CCommDbTest030_03::~CCommDbTest030_03() |
|
222 {} |
|
223 |
|
224 TVerdict CCommDbTest030_03::doTestStepL( void ) |
|
225 { |
|
226 Log(_L("Step 030.03 called ")); |
|
227 |
|
228 iTestStepResult = EPass; |
|
229 |
|
230 CCommDbTest030_01* step030_01 = new(ELeave) CCommDbTest030_01; |
|
231 CleanupStack::PushL(step030_01); |
|
232 step030_01->iSuite = iSuite; |
|
233 doTestStepWithHeapFailureL( *step030_01, KErrNone); |
|
234 CleanupStack::PopAndDestroy(step030_01); |
|
235 |
|
236 CCommDbTest030_02* step030_02 = new(ELeave) CCommDbTest030_02; |
|
237 CleanupStack::PushL(step030_02); |
|
238 step030_02->iSuite = iSuite; |
|
239 doTestStepWithHeapFailureL( *step030_02, KErrAccessDenied); |
|
240 CleanupStack::PopAndDestroy(step030_02); |
|
241 |
|
242 return iTestStepResult; |
|
243 } |
|
244 |
|