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 004.01 - 004.04
|
|
19 |
|
|
20 |
// EPOC includes
|
|
21 |
#include <e32base.h>
|
|
22 |
#include <commdb.h>
|
|
23 |
|
|
24 |
|
|
25 |
// Test system includes
|
|
26 |
#include "Teststepcommdb.h"
|
|
27 |
#include "step_004_xx.h"
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
/////////////////////
|
|
33 |
// Test step 004.001
|
|
34 |
/////////////////////
|
|
35 |
|
|
36 |
// constructor
|
|
37 |
CCommDbTest004_01::CCommDbTest004_01()
|
|
38 |
{
|
|
39 |
// store the name of this test case
|
|
40 |
SetTestStepName(_L("step_004_01"));
|
|
41 |
}
|
|
42 |
|
|
43 |
// destructor
|
|
44 |
CCommDbTest004_01::~CCommDbTest004_01()
|
|
45 |
{
|
|
46 |
}
|
|
47 |
|
|
48 |
TVerdict CCommDbTest004_01::doTestStepPreambleL()
|
|
49 |
{
|
|
50 |
openDbAndViewL(TPtrC(DIAL_OUT_ISP));
|
|
51 |
SetTestStepResult(EPass); return TestStepResult();
|
|
52 |
}
|
|
53 |
|
|
54 |
TInt CCommDbTest004_01::executeStepL()
|
|
55 |
{
|
|
56 |
TInt ret = KErrGeneral;
|
|
57 |
|
|
58 |
TBuf<KCommsDbSvrMaxColumnNameLength> tableName;
|
|
59 |
|
|
60 |
// Get the table name and check it matches with the known value
|
|
61 |
iTheView->GetTableName( tableName );
|
|
62 |
if ( tableName.Compare( TPtrC(DIAL_OUT_ISP)) == 0 )
|
|
63 |
ret = KErrNone;
|
|
64 |
|
|
65 |
return ret;
|
|
66 |
}
|
|
67 |
|
|
68 |
TVerdict CCommDbTest004_01::doTestStepL( )
|
|
69 |
{
|
|
70 |
INFO_PRINTF1(_L("Step 004.01 called "));
|
|
71 |
|
|
72 |
|
|
73 |
if ( executeStep()== KErrNone )
|
|
74 |
{
|
|
75 |
SetTestStepResult(EPass); }
|
|
76 |
else
|
|
77 |
{
|
|
78 |
SetTestStepResult(EFail); }
|
|
79 |
|
|
80 |
|
|
81 |
return TestStepResult();
|
|
82 |
}
|
|
83 |
|
|
84 |
|
|
85 |
/////////////////////
|
|
86 |
// Test step 004.002
|
|
87 |
/////////////////////
|
|
88 |
|
|
89 |
// constructor
|
|
90 |
CCommDbTest004_02::CCommDbTest004_02()
|
|
91 |
{
|
|
92 |
// store the name of this test case
|
|
93 |
SetTestStepName(_L("step_004_02"));
|
|
94 |
}
|
|
95 |
|
|
96 |
// destructor
|
|
97 |
CCommDbTest004_02::~CCommDbTest004_02( )
|
|
98 |
{
|
|
99 |
}
|
|
100 |
|
|
101 |
TVerdict CCommDbTest004_02::doTestStepPreambleL()
|
|
102 |
{
|
|
103 |
openDbAndViewL(TPtrC(DIAL_OUT_ISP));
|
|
104 |
SetTestStepResult(EPass); return TestStepResult();
|
|
105 |
}
|
|
106 |
|
|
107 |
|
|
108 |
#define BUFFER_TOO_SMALL 5 //Must be smaller than the length of the DAIL_OUT_ISP table name
|
|
109 |
|
|
110 |
TBool CCommDbTest004_02::executeStepL()
|
|
111 |
{
|
|
112 |
TBuf<BUFFER_TOO_SMALL> tableName;
|
|
113 |
|
|
114 |
//NB. This should cause a Panic!
|
|
115 |
|
|
116 |
iTheView->GetTableName( tableName );
|
|
117 |
|
|
118 |
if ( tableName.Compare( TPtrC(DIAL_OUT_ISP)) == 0 )
|
|
119 |
{
|
|
120 |
SetTestStepResult(EPass); }
|
|
121 |
else
|
|
122 |
{
|
|
123 |
SetTestStepResult(EFail); }
|
|
124 |
|
|
125 |
SetTestStepResult(EFail); return TestStepResult();
|
|
126 |
}
|
|
127 |
|
|
128 |
|
|
129 |
TVerdict CCommDbTest004_02::doTestStepL( )
|
|
130 |
{
|
|
131 |
if ( executeStep() )
|
|
132 |
SetTestStepResult(EPass); else
|
|
133 |
SetTestStepResult(EFail);
|
|
134 |
|
|
135 |
return TestStepResult();
|
|
136 |
}
|
|
137 |
|
|
138 |
|
|
139 |
/////////////////////
|
|
140 |
// Test step 004.003
|
|
141 |
/////////////////////
|
|
142 |
|
|
143 |
// constructor
|
|
144 |
CCommDbTest004_03::CCommDbTest004_03()
|
|
145 |
{
|
|
146 |
// store the name of this test case
|
|
147 |
SetTestStepName(_L("step_004_03"));
|
|
148 |
}
|
|
149 |
|
|
150 |
// destructor
|
|
151 |
CCommDbTest004_03::~CCommDbTest004_03()
|
|
152 |
{
|
|
153 |
}
|
|
154 |
|
|
155 |
TVerdict CCommDbTest004_03::doTestStepPreambleL()
|
|
156 |
{
|
|
157 |
copyTestDatabase( EDatabase_1 );
|
|
158 |
openDbAndViewL(TPtrC(DIAL_OUT_ISP));
|
|
159 |
SetTestStepResult(EPass); return TestStepResult();
|
|
160 |
}
|
|
161 |
|
|
162 |
//NB. If a zero size buffer is used this will cause an ARM compiler error
|
|
163 |
#define BUFFER_VERYSMALL 1
|
|
164 |
|
|
165 |
TBool CCommDbTest004_03::executeStepL()
|
|
166 |
{
|
|
167 |
|
|
168 |
TBuf<BUFFER_VERYSMALL> tableName;
|
|
169 |
|
|
170 |
//NB. This should cause a Panic
|
|
171 |
|
|
172 |
iTheView->GetTableName( tableName );
|
|
173 |
|
|
174 |
if ( tableName.Compare( TPtrC(DIAL_OUT_ISP)) == 0 )
|
|
175 |
{
|
|
176 |
SetTestStepResult(EPass); }
|
|
177 |
else
|
|
178 |
{
|
|
179 |
SetTestStepResult(EFail); }
|
|
180 |
|
|
181 |
SetTestStepResult(EFail); return TestStepResult();
|
|
182 |
}
|
|
183 |
|
|
184 |
TVerdict CCommDbTest004_03::doTestStepL( )
|
|
185 |
{
|
|
186 |
|
|
187 |
if ( executeStep() )
|
|
188 |
{
|
|
189 |
SetTestStepResult(EPass); }
|
|
190 |
else
|
|
191 |
{
|
|
192 |
SetTestStepResult(EFail); }
|
|
193 |
|
|
194 |
|
|
195 |
return TestStepResult();
|
|
196 |
}
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
/////////////////////
|
|
201 |
// Test step 004.004
|
|
202 |
/////////////////////
|
|
203 |
|
|
204 |
// constructor
|
|
205 |
CCommDbTest004_04::CCommDbTest004_04()
|
|
206 |
{
|
|
207 |
// store the name of this test case
|
|
208 |
SetTestStepName(_L("step_004_04"));
|
|
209 |
}
|
|
210 |
|
|
211 |
// destructor
|
|
212 |
CCommDbTest004_04::~CCommDbTest004_04()
|
|
213 |
{
|
|
214 |
}
|
|
215 |
|
|
216 |
|
|
217 |
TVerdict CCommDbTest004_04::doTestStepL( )
|
|
218 |
{
|
|
219 |
INFO_PRINTF1(_L("Step 004.04 called "));
|
|
220 |
|
|
221 |
SetTestStepResult(EPass);
|
|
222 |
//Heap test for 004.01
|
|
223 |
|
|
224 |
CCommDbTest004_01* step004_01 = new CCommDbTest004_01;
|
|
225 |
CleanupStack::PushL(step004_01);
|
|
226 |
doTestStepWithHeapFailureL( *step004_01, KErrNone);
|
|
227 |
if( step004_01->TestStepResult() == EFail )
|
|
228 |
SetTestStepResult(EFail); CleanupStack::PopAndDestroy(step004_01);
|
|
229 |
|
|
230 |
return TestStepResult();
|
|
231 |
}
|
|
232 |
|
|
233 |
/////////////////////
|
|
234 |
// Test step 004.005
|
|
235 |
/////////////////////
|
|
236 |
|
|
237 |
// constructor
|
|
238 |
CCommDbTest004_05::CCommDbTest004_05()
|
|
239 |
{
|
|
240 |
// store the name of this test case
|
|
241 |
SetTestStepName(_L("step_004_05"));
|
|
242 |
}
|
|
243 |
|
|
244 |
// destructor
|
|
245 |
CCommDbTest004_05::~CCommDbTest004_05()
|
|
246 |
{
|
|
247 |
}
|
|
248 |
|
|
249 |
|
|
250 |
TVerdict CCommDbTest004_05::doTestStepL( )
|
|
251 |
{
|
|
252 |
|
|
253 |
SetTestStepResult(EPass);
|
|
254 |
//Heap test for 004.02
|
|
255 |
// a panic is expected
|
|
256 |
CCommDbTest004_02* step004_02 = new CCommDbTest004_02;
|
|
257 |
CleanupStack::PushL(step004_02);
|
|
258 |
doTestStepWithHeapFailureL( *step004_02, KErrNone);
|
|
259 |
if( step004_02->TestStepResult() == EFail )
|
|
260 |
SetTestStepResult(EFail); CleanupStack::PopAndDestroy(step004_02);
|
|
261 |
|
|
262 |
return TestStepResult();
|
|
263 |
}
|
|
264 |
|
|
265 |
|
|
266 |
/////////////////////
|
|
267 |
// Test step 004.006
|
|
268 |
/////////////////////
|
|
269 |
|
|
270 |
// constructor
|
|
271 |
CCommDbTest004_06::CCommDbTest004_06()
|
|
272 |
{
|
|
273 |
// store the name of this test case
|
|
274 |
SetTestStepName(_L("step_004_06"));
|
|
275 |
}
|
|
276 |
|
|
277 |
// destructor
|
|
278 |
CCommDbTest004_06::~CCommDbTest004_06()
|
|
279 |
{
|
|
280 |
}
|
|
281 |
|
|
282 |
|
|
283 |
TVerdict CCommDbTest004_06::doTestStepL( )
|
|
284 |
{
|
|
285 |
|
|
286 |
SetTestStepResult(EPass); //Heap test for 004.03
|
|
287 |
|
|
288 |
// a panic is expected
|
|
289 |
CCommDbTest004_03* step004_03 = new CCommDbTest004_03;
|
|
290 |
CleanupStack::PushL(step004_03);
|
|
291 |
doTestStepWithHeapFailureL( *step004_03, KErrNone);
|
|
292 |
if( step004_03->TestStepResult() == EFail )
|
|
293 |
SetTestStepResult(EFail); CleanupStack::PopAndDestroy(step004_03);
|
|
294 |
|
|
295 |
return TestStepResult();
|
|
296 |
}
|