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