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