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 014.XX |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 #include <commdb.h> |
|
21 #include <d32comm.h> |
|
22 |
|
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_014_xx.h" |
|
30 |
|
31 |
|
32 |
|
33 // |
|
34 // Test step 014.01 |
|
35 // |
|
36 |
|
37 // constructor |
|
38 CCommDbTest014_01::CCommDbTest014_01() |
|
39 { |
|
40 // store the name of this test case |
|
41 iTestStepName = _L("step_014_01"); |
|
42 } |
|
43 |
|
44 // destructor |
|
45 CCommDbTest014_01::~CCommDbTest014_01() |
|
46 { |
|
47 } |
|
48 |
|
49 TVerdict CCommDbTest014_01::doTestStepPreambleL() |
|
50 { |
|
51 openDbAndViewL(TPtrC(MODEM_BEARER)); |
|
52 return EPass; |
|
53 } |
|
54 |
|
55 |
|
56 TInt CCommDbTest014_01::executeStepL() |
|
57 { |
|
58 TInt ret=KErrGeneral; |
|
59 TUint32 id; |
|
60 |
|
61 //Create a record and cancel it |
|
62 //NB. This test assumes the Modem table will be empty |
|
63 |
|
64 CDBLEAVE( iTheView->InsertRecord( id ), KErrNone ); |
|
65 |
|
66 _LIT(KModem,"US Robotics Sportster"); |
|
67 _LIT(KTsy,"HAYES"); |
|
68 _LIT8(KModemInitString,"AT&F1"); |
|
69 _LIT8(KModemFaxInitString,"AT&d2"); |
|
70 //Write some sample data into the table |
|
71 iTheView->WriteTextL(TPtrC(COMMDB_NAME),KModem); |
|
72 iTheView->WriteTextL(TPtrC(MODEM_NIF_NAME),_L("PPP")); |
|
73 iTheView->WriteTextL(TPtrC(MODEM_TSY_NAME),KTsy); |
|
74 iTheView->WriteUintL(TPtrC(MODEM_RATE),(TUint32)EBps57600); |
|
75 iTheView->WriteUintL(TPtrC(MODEM_DATA_BITS),(TUint32)EData8); |
|
76 iTheView->WriteUintL(TPtrC(MODEM_STOP_BITS),(TUint32)EStop1); |
|
77 iTheView->WriteUintL(TPtrC(MODEM_PARITY),(TUint32)EParityNone); |
|
78 iTheView->WriteUintL(TPtrC(MODEM_HANDSHAKING),(TUint32)(KConfigObeyCTS|KConfigObeyDSR|KConfigFailDSR|KConfigObeyDCD|KConfigFailDCD)); //KConfigObeyCTS; |
|
79 iTheView->WriteUintL(TPtrC(MODEM_SPECIAL_RATE),(TUint32)0); |
|
80 iTheView->WriteUintL(TPtrC(MODEM_XON_CHAR),(TUint32)0); |
|
81 iTheView->WriteUintL(TPtrC(MODEM_XOFF_CHAR),(TUint32)0); |
|
82 iTheView->WriteTextL(TPtrC(MODEM_MODEM_INIT_STRING),KModemInitString); |
|
83 iTheView->WriteTextL(TPtrC(MODEM_DATA_INIT_STRING),KNullDesC8); |
|
84 iTheView->WriteTextL(TPtrC(MODEM_FAX_INIT_STRING),KModemFaxInitString); |
|
85 iTheView->WriteUintL(TPtrC(MODEM_SPEAKER_PREF),(TUint32)EModemSpeakerSettingAfterDialUntilAnswer); |
|
86 iTheView->WriteUintL(TPtrC(MODEM_SPEAKER_VOL_PREF),(TUint32)EModemSpeakerVolumeQuiet); |
|
87 |
|
88 //Now cancel the insert and close the view |
|
89 iTheView->CancelRecordChanges(); |
|
90 |
|
91 delete iTheView; |
|
92 iTheView = 0; |
|
93 |
|
94 //Open a view and check record was not written into the database |
|
95 iTheView = iTheDb->OpenViewMatchingTextLC( TPtrC(MODEM_BEARER), TPtrC(COMMDB_NAME), KModem); |
|
96 CleanupStack::Pop(); |
|
97 |
|
98 CDBLEAVE( ret = iTheView->GotoFirstRecord(), KErrNotFound ); |
|
99 |
|
100 return ret; |
|
101 } |
|
102 |
|
103 |
|
104 |
|
105 TVerdict CCommDbTest014_01::doTestStepL( ) |
|
106 { |
|
107 Log(_L("Step 014.01 called ")); |
|
108 |
|
109 if ( executeStepL() == KErrNotFound ) |
|
110 iTestStepResult = EPass; |
|
111 else |
|
112 iTestStepResult = EFail; |
|
113 |
|
114 return iTestStepResult; |
|
115 } |
|
116 |
|
117 |
|
118 // |
|
119 // Test step 014.02 |
|
120 // |
|
121 |
|
122 // constructor |
|
123 CCommDbTest014_02::CCommDbTest014_02() |
|
124 { |
|
125 // store the name of this test case |
|
126 iTestStepName = _L("step_014_02"); |
|
127 } |
|
128 |
|
129 // destructor |
|
130 CCommDbTest014_02::~CCommDbTest014_02() |
|
131 { |
|
132 } |
|
133 |
|
134 TVerdict CCommDbTest014_02::doTestStepPreambleL() |
|
135 { |
|
136 openDbAndViewL(TPtrC(MODEM_BEARER)); |
|
137 return EPass; |
|
138 } |
|
139 |
|
140 |
|
141 TInt CCommDbTest014_02::executeStepL() |
|
142 { |
|
143 TInt ret=KErrGeneral; |
|
144 TUint32 id; |
|
145 |
|
146 |
|
147 //Insert a new record, try to update it and cancel the update |
|
148 //NB. This test assumes the Modem table will be empty |
|
149 |
|
150 CDBLEAVE( iTheView->InsertRecord( id ), KErrNone ); |
|
151 |
|
152 _LIT(KModem,"US Robotics Sportster"); |
|
153 _LIT(KTsy,"HAYES"); |
|
154 _LIT8(KModemInitString,"AT&F1"); |
|
155 _LIT8(KModemFaxInitString,"AT&d2"); |
|
156 //Write some sample data into the table |
|
157 iTheView->WriteTextL(TPtrC(COMMDB_NAME),KModem); |
|
158 iTheView->WriteTextL(TPtrC(MODEM_NIF_NAME),_L("PPP")); |
|
159 iTheView->WriteTextL(TPtrC(MODEM_TSY_NAME),KTsy); |
|
160 iTheView->WriteUintL(TPtrC(MODEM_RATE),(TUint32)EBps57600); |
|
161 iTheView->WriteUintL(TPtrC(MODEM_DATA_BITS),(TUint32)EData8); |
|
162 iTheView->WriteUintL(TPtrC(MODEM_STOP_BITS),(TUint32)EStop1); |
|
163 iTheView->WriteUintL(TPtrC(MODEM_PARITY),(TUint32)EParityNone); |
|
164 iTheView->WriteUintL(TPtrC(MODEM_HANDSHAKING),(TUint32)(KConfigObeyCTS|KConfigObeyDSR|KConfigFailDSR|KConfigObeyDCD|KConfigFailDCD)); //KConfigObeyCTS; |
|
165 iTheView->WriteUintL(TPtrC(MODEM_SPECIAL_RATE),(TUint32)0); |
|
166 iTheView->WriteUintL(TPtrC(MODEM_XON_CHAR),(TUint32)0); |
|
167 iTheView->WriteUintL(TPtrC(MODEM_XOFF_CHAR),(TUint32)0); |
|
168 iTheView->WriteTextL(TPtrC(MODEM_MODEM_INIT_STRING),KModemInitString); |
|
169 iTheView->WriteTextL(TPtrC(MODEM_DATA_INIT_STRING),KNullDesC8); |
|
170 iTheView->WriteTextL(TPtrC(MODEM_FAX_INIT_STRING),KModemFaxInitString); |
|
171 iTheView->WriteUintL(TPtrC(MODEM_SPEAKER_PREF),(TUint32)EModemSpeakerSettingAfterDialUntilAnswer); |
|
172 iTheView->WriteUintL(TPtrC(MODEM_SPEAKER_VOL_PREF),(TUint32)EModemSpeakerVolumeQuiet); |
|
173 |
|
174 //Insert the record and destroy the view |
|
175 CDBLEAVE( iTheView->PutRecordChanges(), KErrNone ); |
|
176 |
|
177 delete iTheView; |
|
178 iTheView = 0; |
|
179 |
|
180 //Open a view and make a change to the record just written |
|
181 iTheView = iTheDb->OpenViewMatchingTextLC( TPtrC(MODEM_BEARER), TPtrC(COMMDB_NAME), KModem); |
|
182 CleanupStack::Pop(); |
|
183 |
|
184 CDBLEAVE( ret = iTheView->GotoFirstRecord(), KErrNone ); |
|
185 CDBLEAVE( iTheView->UpdateRecord(), KErrNone ); |
|
186 _LIT(KModem2,"Another US Robotics Sportster"); |
|
187 iTheView->WriteTextL(TPtrC(COMMDB_NAME), KModem2 ); |
|
188 |
|
189 //Cancel the changes made and destroy the view |
|
190 iTheView->CancelRecordChanges(); |
|
191 |
|
192 delete iTheView; |
|
193 iTheView = 0; |
|
194 |
|
195 //Open a view to check that the record was not modified |
|
196 iTheView = iTheDb->OpenViewMatchingTextLC( TPtrC(MODEM_BEARER), TPtrC(COMMDB_NAME), KModem); |
|
197 CleanupStack::Pop(); |
|
198 |
|
199 CDBLEAVE( ret = iTheView->GotoFirstRecord(), KErrNone ); |
|
200 |
|
201 return ret; |
|
202 } |
|
203 |
|
204 |
|
205 |
|
206 TVerdict CCommDbTest014_02::doTestStepL( ) |
|
207 { |
|
208 Log(_L("Step 014.02 called ")); |
|
209 |
|
210 if ( executeStepL() == KErrNone ) |
|
211 iTestStepResult = EPass; |
|
212 else |
|
213 iTestStepResult = EFail; |
|
214 |
|
215 |
|
216 |
|
217 return iTestStepResult; |
|
218 } |
|
219 |
|
220 |
|
221 // |
|
222 // Test step 014.03 |
|
223 // |
|
224 |
|
225 // constructor |
|
226 CCommDbTest014_03::CCommDbTest014_03() |
|
227 { |
|
228 // store the name of this test case |
|
229 iTestStepName = _L("step_014_03"); |
|
230 } |
|
231 |
|
232 // destructor |
|
233 CCommDbTest014_03::~CCommDbTest014_03() |
|
234 { |
|
235 } |
|
236 |
|
237 TVerdict CCommDbTest014_03::doTestStepL( ) |
|
238 { |
|
239 Log(_L("Step 014.03 called ")); |
|
240 |
|
241 iTestStepResult = EPass; |
|
242 |
|
243 // Heap test for 014.01 |
|
244 |
|
245 CCommDbTest014_01* step014_01 = new CCommDbTest014_01; |
|
246 CleanupStack::PushL(step014_01); |
|
247 step014_01->iSuite = iSuite; |
|
248 doTestStepWithHeapFailureL( *step014_01, KErrNotFound); |
|
249 if ( step014_01->iTestStepResult == EFail ) |
|
250 iTestStepResult = EFail; |
|
251 CleanupStack::PopAndDestroy(step014_01); |
|
252 |
|
253 // Heap test for 014.02 |
|
254 |
|
255 CCommDbTest014_02* step014_02 = new CCommDbTest014_02; |
|
256 CleanupStack::PushL(step014_02); |
|
257 step014_02->iSuite = iSuite; |
|
258 doTestStepWithHeapFailureL( *step014_02, KErrNone); |
|
259 if ( step014_02->iTestStepResult == EFail ) |
|
260 iTestStepResult = EFail; |
|
261 CleanupStack::PopAndDestroy(step014_02); |
|
262 |
|
263 return iTestStepResult; |
|
264 |
|
265 } |
|
266 |
|
267 // |
|
268 // Test step 014.04 |
|
269 // |
|
270 |
|
271 // constructor |
|
272 CCommDbTest014_04::CCommDbTest014_04() |
|
273 { |
|
274 // store the name of this test case |
|
275 iTestStepName = _L("step_014_04"); |
|
276 } |
|
277 |
|
278 // destructor |
|
279 CCommDbTest014_04::~CCommDbTest014_04() |
|
280 { |
|
281 } |
|
282 |
|
283 TVerdict CCommDbTest014_04::doTestStepL( ) |
|
284 { |
|
285 Log(_L("Step 014_04 called ")); |
|
286 |
|
287 iTestStepResult = EPass; |
|
288 |
|
289 __UHEAP_MARK; |
|
290 |
|
291 |
|
292 CCommsDatabase* db = CCommsDatabase::NewL( ); |
|
293 CleanupStack::PushL( db ); |
|
294 |
|
295 CCommsDbTableView* v = |
|
296 db->OpenTableLC( TPtrC(WAP_ACCESS_POINT ) ); |
|
297 |
|
298 TUint32 dummyUid( 0 ); |
|
299 |
|
300 |
|
301 TInt err = v->InsertRecord( dummyUid ); |
|
302 User::LeaveIfError( err ); |
|
303 v->CancelRecordChanges(); |
|
304 |
|
305 |
|
306 CleanupStack::PopAndDestroy( v ); |
|
307 CleanupStack::PopAndDestroy( db ); |
|
308 |
|
309 __UHEAP_MARKEND; |
|
310 |
|
311 return iTestStepResult; |
|
312 |
|
313 } |
|