|
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 062.XX |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 #include <commdb.h> |
|
21 #include <d32comm.h> |
|
22 #include <cdbtemp.h> |
|
23 #include <cdbover.h> |
|
24 |
|
25 |
|
26 // Test system includes |
|
27 #include <networking/log.h> |
|
28 #include <networking/teststep.h> |
|
29 #include "Teststepcommdb.h" |
|
30 #include "TestSuiteCommdb.h" |
|
31 #include "Step_062_xx.h" |
|
32 |
|
33 // |
|
34 // Test step 062.01 |
|
35 // |
|
36 |
|
37 // constructor |
|
38 CCommDbTest062_01::CCommDbTest062_01() |
|
39 { |
|
40 // store the name of this test case |
|
41 iTestStepName = _L("step_062_01"); |
|
42 } |
|
43 |
|
44 // destructor |
|
45 CCommDbTest062_01::~CCommDbTest062_01() |
|
46 { |
|
47 } |
|
48 |
|
49 TVerdict CCommDbTest062_01::doTestStepPreambleL() |
|
50 { |
|
51 openDbAndViewL(_L("Modem")); |
|
52 return EPass; |
|
53 } |
|
54 |
|
55 TInt CCommDbTest062_01::executeStepL() |
|
56 { |
|
57 TInt ret=KErrGeneral; |
|
58 TUint32 id; |
|
59 |
|
60 |
|
61 //Insert a new record, |
|
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 //Insert the record and destroy the view |
|
88 CDBLEAVE( iTheView->PutRecordChanges(), KErrNone ); |
|
89 |
|
90 delete iTheView; |
|
91 iTheView = 0; |
|
92 |
|
93 //Open a view and make a change to the record just written |
|
94 iTheView = iTheDb->OpenViewMatchingTextLC( _L("Modem"), TPtrC(COMMDB_NAME), KModem); |
|
95 CleanupStack::Pop(); |
|
96 |
|
97 CDBLEAVE( ret = iTheView->GotoFirstRecord(), KErrNone ); |
|
98 CDBLEAVE( iTheView->UpdateRecord(), KErrNone ); |
|
99 _LIT(KModem2,"Another US Robotics Sportster"); |
|
100 iTheView->WriteTextL(TPtrC(COMMDB_NAME), KModem2 ); |
|
101 |
|
102 //Cancel the changes made and destroy the view |
|
103 iTheView->CancelRecordChanges(); |
|
104 |
|
105 delete iTheView; |
|
106 iTheView = 0; |
|
107 |
|
108 //Open a view to check that the record was not modified |
|
109 iTheView = iTheDb->OpenViewMatchingTextLC( _L("Modem"), TPtrC(COMMDB_NAME), KModem); |
|
110 CleanupStack::Pop(); |
|
111 |
|
112 CDBLEAVE( ret = iTheView->GotoFirstRecord(), KErrNone ); |
|
113 |
|
114 return ret; |
|
115 } |
|
116 |
|
117 |
|
118 |
|
119 TVerdict CCommDbTest062_01::doTestStepL( ) |
|
120 { |
|
121 Log(_L("Step 062.01 called ")); |
|
122 |
|
123 if ( executeStepL() == KErrNone ) |
|
124 iTestStepResult = EPass; |
|
125 else |
|
126 iTestStepResult = EFail; |
|
127 |
|
128 return iTestStepResult; |
|
129 } |
|
130 |
|
131 |
|
132 |
|
133 // |
|
134 // Test step 062.02 |
|
135 // |
|
136 |
|
137 // constructor |
|
138 CCommDbTest062_02::CCommDbTest062_02() |
|
139 { |
|
140 // store the name of this test case |
|
141 iTestStepName = _L("step_062_02"); |
|
142 } |
|
143 |
|
144 // destructor |
|
145 CCommDbTest062_02::~CCommDbTest062_02() |
|
146 { |
|
147 } |
|
148 |
|
149 TVerdict CCommDbTest062_02::doTestStepPreambleL() |
|
150 { |
|
151 openDbL(); |
|
152 // TInt ret = copyTestDatabase( EDatabase_1 ); |
|
153 // if(ret != KErrNone) // can't check this at the moment because copyTestDatabase returns |
|
154 // User::Leave(ret);// KErrGeneral when it passes!! |
|
155 return EPass; |
|
156 } |
|
157 |
|
158 |
|
159 |
|
160 TInt CCommDbTest062_02::executeStepL() |
|
161 { |
|
162 TInt ret=KErrGeneral; |
|
163 CCommsDbTableView* table = NULL; |
|
164 |
|
165 // Not much to this - in fact it's the specific case raised in the defect report |
|
166 // INC027976 which describes the BC break due to chenging the name of the Modem table |
|
167 // to ModemBearer |
|
168 |
|
169 __UHEAP_MARK; |
|
170 table = iTheDb->OpenViewLC(_L("Modem"),_L("select * from Modem where Hidden=0")); |
|
171 CleanupStack::Pop(); |
|
172 |
|
173 if(table != NULL) |
|
174 { |
|
175 ret = KErrNone; |
|
176 delete table; |
|
177 table = 0; |
|
178 } |
|
179 |
|
180 __UHEAP_MARKEND; |
|
181 return ret; |
|
182 } |
|
183 |
|
184 |
|
185 |
|
186 TVerdict CCommDbTest062_02::doTestStepL( ) |
|
187 { |
|
188 Log(_L("Step 062.02 called ")); |
|
189 |
|
190 TRAPD(ret, executeStepL()); |
|
191 if( ret == KErrNotSupported ) |
|
192 iTestStepResult = EPass; |
|
193 else |
|
194 iTestStepResult = EFail; |
|
195 |
|
196 return iTestStepResult; |
|
197 } |
|
198 |
|
199 // Test step 03 is the same as 37_01, except that the literal string 'Modem' |
|
200 // is used to verify that template handling is BC. |
|
201 |
|
202 |
|
203 |
|
204 CCommDbTest062_03::CCommDbTest062_03() |
|
205 { |
|
206 // store the name of this test case |
|
207 iTestStepName = _L("step_062_03"); |
|
208 } |
|
209 |
|
210 CCommDbTest062_03::~CCommDbTest062_03() |
|
211 {} |
|
212 |
|
213 TVerdict CCommDbTest062_03::doTestStepL( void ) |
|
214 { |
|
215 if(executeStepL()!=KErrNone) |
|
216 return EFail; |
|
217 return EPass; |
|
218 } |
|
219 |
|
220 TVerdict CCommDbTest062_03::doTestStepPreambleL() |
|
221 { |
|
222 iTheDb=CCommsDatabase::NewL(); |
|
223 |
|
224 return EPass; |
|
225 } |
|
226 |
|
227 TInt CCommDbTest062_03::executeStepL() |
|
228 { |
|
229 //alter something in the template |
|
230 CCommsDbTemplateRecord* templateRecord = CCommsDbTemplateRecord::NewL(iTheDb, _L("Modem")); |
|
231 CleanupStack::PushL(templateRecord); |
|
232 |
|
233 User::LeaveIfError(templateRecord->Modify()); |
|
234 templateRecord->WriteTextL(TPtrC(COMMDB_NAME), _L("DummyName")); |
|
235 TBufC8<KCommsDbSvrMaxFieldLength> firstInputString = _L8("first string"); |
|
236 |
|
237 templateRecord->WriteTextL(TPtrC(MODEM_FAX_INIT_STRING), firstInputString); |
|
238 User::LeaveIfError(templateRecord->StoreModifications()); |
|
239 //Now start to overwrite initial change, but don't commit, cancel instead. |
|
240 User::LeaveIfError(templateRecord->Modify()); |
|
241 |
|
242 TBufC8<KCommsDbSvrMaxFieldLength> secondInputString = _L8("second string"); |
|
243 templateRecord->WriteTextL(TPtrC(MODEM_FAX_INIT_STRING), secondInputString); |
|
244 templateRecord->CancelModifications(); |
|
245 |
|
246 TBuf8<KCommsDbSvrMaxFieldLength> retrievedString; |
|
247 templateRecord->ReadTextL(TPtrC(MODEM_FAX_INIT_STRING), retrievedString); |
|
248 CleanupStack::PopAndDestroy(templateRecord); |
|
249 |
|
250 if(retrievedString!=firstInputString) |
|
251 return KErrGeneral; |
|
252 |
|
253 return KErrNone; |
|
254 } |
|
255 |
|
256 TVerdict CCommDbTest062_03::doTestStepPostambleL() |
|
257 { |
|
258 delete iTheDb; |
|
259 iTheDb=NULL; |
|
260 return EPass; |
|
261 } |
|
262 |
|
263 // Test steps 04 & 05 are the same as 41_13 & 41_14, except that the literal string |
|
264 // 'Modem' is used to access the table to verify that the override handling is BC. |
|
265 // |
|
266 |
|
267 CCommDbTest062_04::CCommDbTest062_04() |
|
268 { |
|
269 // store the name of this test case |
|
270 iTestStepName = _L("step_062_04"); |
|
271 } |
|
272 |
|
273 CCommDbTest062_04::~CCommDbTest062_04() |
|
274 {} |
|
275 |
|
276 TVerdict CCommDbTest062_04::doTestStepL( void ) |
|
277 { |
|
278 if(executeStepL()!=KErrNone) |
|
279 return EFail; |
|
280 return EPass; |
|
281 } |
|
282 |
|
283 TVerdict CCommDbTest062_04::doTestStepPreambleL() |
|
284 { |
|
285 return EPass; |
|
286 } |
|
287 |
|
288 TInt CCommDbTest062_04::executeStepL() |
|
289 { |
|
290 iOverSet=CCommDbOverrideSettings::NewL(CCommDbOverrideSettings::EParamListPartial); |
|
291 TBuf<KCommsDbSvrMaxFieldLength> temp(_L("There's no place like home")); |
|
292 return iOverSet->SetDesOverride(_L("Modem"), TPtrC(MODEM_TSY_NAME), temp); |
|
293 } |
|
294 |
|
295 TVerdict CCommDbTest062_04::doTestStepPostambleL() |
|
296 { |
|
297 delete iOverSet; |
|
298 return EPass; |
|
299 } |
|
300 |
|
301 // |
|
302 |
|
303 CCommDbTest062_05::CCommDbTest062_05() |
|
304 { |
|
305 // store the name of this test case |
|
306 iTestStepName = _L("step_062_05"); |
|
307 } |
|
308 |
|
309 CCommDbTest062_05::~CCommDbTest062_05() |
|
310 {} |
|
311 |
|
312 TVerdict CCommDbTest062_05::doTestStepL( void ) |
|
313 { |
|
314 if(executeStepL()!=KErrNotSupported) |
|
315 return EFail; |
|
316 return EPass; |
|
317 } |
|
318 |
|
319 TVerdict CCommDbTest062_05::doTestStepPreambleL() |
|
320 { |
|
321 return EPass; |
|
322 } |
|
323 |
|
324 TInt CCommDbTest062_05::executeStepL() |
|
325 { |
|
326 iOverSet=CCommDbOverrideSettings::NewL(CCommDbOverrideSettings::EParamListPartial); |
|
327 |
|
328 return iOverSet->SetIntOverride(_L("Modem"), TPtrC(MODEM_STOP_BITS), 10); |
|
329 } |
|
330 |
|
331 TVerdict CCommDbTest062_05::doTestStepPostambleL() |
|
332 { |
|
333 delete iOverSet; |
|
334 return EPass; |
|
335 } |