|
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 029.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_029_xx.h" |
|
28 |
|
29 |
|
30 CCommDbTest029_01::CCommDbTest029_01() |
|
31 { |
|
32 // store the name of this test case |
|
33 SetTestStepName(_L("step_029_01")); |
|
34 } |
|
35 |
|
36 CCommDbTest029_01::~CCommDbTest029_01() |
|
37 {} |
|
38 |
|
39 TVerdict CCommDbTest029_01::doTestStepL( void ) |
|
40 { |
|
41 if(executeStepL()!=KErrNotFound) |
|
42 SetTestStepResult(EFail); SetTestStepResult(EPass); return TestStepResult(); |
|
43 } |
|
44 |
|
45 TVerdict CCommDbTest029_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 CCommDbTest029_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 User::LeaveIfError(iPrefView->GotoFirstRecord()); |
|
67 |
|
68 iPrefView->DeleteConnectionPreferenceL(); |
|
69 |
|
70 return iPrefView->GotoFirstRecord(); //There should now be no records in the connection pref table, so this should be KErrNotFound |
|
71 } |
|
72 |
|
73 TVerdict CCommDbTest029_01::doTestStepPostambleL() |
|
74 { |
|
75 delete iPrefView; |
|
76 iPrefView = NULL; |
|
77 delete iTheDb; |
|
78 iTheDb=NULL; |
|
79 SetTestStepResult(EPass); return TestStepResult(); |
|
80 } |
|
81 |
|
82 /////////////////////////////////////////////////////////////////////////////////// |
|
83 |
|
84 CCommDbTest029_02::CCommDbTest029_02() |
|
85 { |
|
86 // store the name of this test case |
|
87 SetTestStepName(_L("step_029_02")); |
|
88 } |
|
89 |
|
90 CCommDbTest029_02::~CCommDbTest029_02() |
|
91 {} |
|
92 |
|
93 TVerdict CCommDbTest029_02::doTestStepL( void ) |
|
94 { |
|
95 if(executeStepL()!=KErrAccessDenied) |
|
96 SetTestStepResult(EFail); SetTestStepResult(EPass); return TestStepResult(); |
|
97 } |
|
98 |
|
99 TVerdict CCommDbTest029_02::doTestStepPreambleL() |
|
100 { |
|
101 iTheDb=CCommsDatabase::NewL(); |
|
102 |
|
103 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
104 CleanupStack::Pop(); |
|
105 |
|
106 SetTestStepResult(EPass); return TestStepResult(); |
|
107 } |
|
108 |
|
109 TInt CCommDbTest029_02::executeStepL() |
|
110 { |
|
111 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref1; |
|
112 pref1.iRanking = 1; |
|
113 pref1.iDirection = ECommDbConnectionDirectionOutgoing; |
|
114 pref1.iDialogPref = ECommDbDialogPrefPrompt; |
|
115 pref1.iBearer.iBearerSet = KCommDbBearerCSD; |
|
116 pref1.iBearer.iIapId = 1; |
|
117 |
|
118 iPrefView->InsertConnectionPreferenceL(pref1, ETrue); |
|
119 |
|
120 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref2; |
|
121 pref2.iRanking = 2; |
|
122 pref2.iDirection = ECommDbConnectionDirectionOutgoing; |
|
123 pref2.iDialogPref = ECommDbDialogPrefPrompt; |
|
124 pref2.iBearer.iBearerSet = KCommDbBearerCSD; |
|
125 pref2.iBearer.iIapId = 2; |
|
126 |
|
127 iPrefView->InsertConnectionPreferenceL(pref2, ETrue); |
|
128 |
|
129 User::LeaveIfError(iPrefView->GotoFirstRecord()); |
|
130 |
|
131 TRAPD(err, iPrefView->UpdateDialogPrefL(ECommDbDialogPrefDoNotPrompt)); //Trying to edit a read only entry |
|
132 |
|
133 return err; |
|
134 } |
|
135 |
|
136 TVerdict CCommDbTest029_02::doTestStepPostambleL() |
|
137 { |
|
138 delete iPrefView; |
|
139 iPrefView = NULL; |
|
140 delete iTheDb; |
|
141 iTheDb=NULL; |
|
142 SetTestStepResult(EPass); return TestStepResult(); |
|
143 } |
|
144 |
|
145 /////////////////////////////////////////////////////////////////////////////////// |
|
146 |
|
147 CCommDbTest029_03::CCommDbTest029_03() |
|
148 { |
|
149 // store the name of this test case |
|
150 SetTestStepName(_L("step_029_03")); |
|
151 } |
|
152 |
|
153 CCommDbTest029_03::~CCommDbTest029_03() |
|
154 {} |
|
155 |
|
156 TVerdict CCommDbTest029_03::doTestStepL( void ) |
|
157 { |
|
158 if (executeStepL() != KErrNotFound) |
|
159 { |
|
160 SetTestStepResult(EFail); } |
|
161 |
|
162 return TestStepResult(); |
|
163 } |
|
164 |
|
165 TVerdict CCommDbTest029_03::doTestStepPreambleL() |
|
166 { |
|
167 iTheDb=CCommsDatabase::NewL(); |
|
168 |
|
169 iPrefView = iTheDb->OpenConnectionPrefTableLC(); |
|
170 CleanupStack::Pop(); |
|
171 |
|
172 SetTestStepResult(EPass); return TestStepResult(); |
|
173 } |
|
174 |
|
175 TInt CCommDbTest029_03::executeStepL() |
|
176 { |
|
177 TRAPD(err, iPrefView->DeleteConnectionPreferenceL()); //This should leave with KErrNotFound |
|
178 |
|
179 return err; |
|
180 } |
|
181 |
|
182 TVerdict CCommDbTest029_03::doTestStepPostambleL() |
|
183 { |
|
184 delete iPrefView; |
|
185 iPrefView = NULL; |
|
186 delete iTheDb; |
|
187 iTheDb=NULL; |
|
188 SetTestStepResult(EPass); return TestStepResult(); |
|
189 } |
|
190 |
|
191 ////////////////////////////////////////////////////////////////////////// |
|
192 |
|
193 CCommDbTest029_04::CCommDbTest029_04() |
|
194 { |
|
195 // store the name of this test case |
|
196 SetTestStepName(_L("step_029_04")); |
|
197 } |
|
198 |
|
199 CCommDbTest029_04::~CCommDbTest029_04() |
|
200 {} |
|
201 |
|
202 TVerdict CCommDbTest029_04::doTestStepL( void ) |
|
203 { |
|
204 INFO_PRINTF1(_L("Step 029.04 called ")); |
|
205 |
|
206 SetTestStepResult(EPass); |
|
207 CCommDbTest029_01* step029_01 = new(ELeave) CCommDbTest029_01; |
|
208 CleanupStack::PushL(step029_01); |
|
209 doTestStepWithHeapFailureL( *step029_01, KErrNotFound); |
|
210 CleanupStack::PopAndDestroy(step029_01); |
|
211 |
|
212 CCommDbTest029_02* step029_02 = new(ELeave) CCommDbTest029_02; |
|
213 CleanupStack::PushL(step029_02); |
|
214 doTestStepWithHeapFailureL( *step029_02, KErrAccessDenied); |
|
215 CleanupStack::PopAndDestroy(step029_02); |
|
216 |
|
217 //Don't bother with step 3, since it's a panic test. |
|
218 |
|
219 return TestStepResult(); |
|
220 } |