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