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 005.01 - 005.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_005_xx.h"
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
/////////////////////
|
|
33 |
// Test step 005.001
|
|
34 |
/////////////////////
|
|
35 |
|
|
36 |
// constructor
|
|
37 |
CCommDbTest005_01::CCommDbTest005_01()
|
|
38 |
{
|
|
39 |
// store the name of this test case
|
|
40 |
SetTestStepName(_L("step_005_01"));
|
|
41 |
}
|
|
42 |
|
|
43 |
// destructor
|
|
44 |
CCommDbTest005_01::~CCommDbTest005_01()
|
|
45 |
{
|
|
46 |
}
|
|
47 |
|
|
48 |
|
|
49 |
TVerdict CCommDbTest005_01::doTestStepPreambleL()
|
|
50 |
{
|
|
51 |
openDbAndViewL(TPtrC(DIAL_IN_ISP));
|
|
52 |
SetTestStepResult(EPass); return TestStepResult();
|
|
53 |
}
|
|
54 |
|
|
55 |
|
|
56 |
TBool CCommDbTest005_01::executeStepL()
|
|
57 |
{
|
|
58 |
TDbColType colType;
|
|
59 |
TUint32 attrib;
|
|
60 |
TBool ret=EFail;
|
|
61 |
|
|
62 |
//NB this step is design NOT to leave.
|
|
63 |
|
|
64 |
//Read column type attibutes and check against the known true values
|
|
65 |
iTheView->ReadTypeAttribL( TPtrC(ISP_DESCRIPTION), colType, attrib );
|
|
66 |
if ( colType == EDbColText && attrib == 0 )
|
|
67 |
ret = EPass;
|
|
68 |
|
|
69 |
if ( ret == EPass )
|
|
70 |
{
|
|
71 |
iTheView->ReadTypeAttribL( TPtrC(ISP_LOGIN_SCRIPT), colType, attrib );
|
|
72 |
if ( !(colType == EDbColLongText && attrib == 0) )
|
|
73 |
ret = EFail;
|
|
74 |
}
|
|
75 |
|
|
76 |
if ( ret == EPass )
|
|
77 |
{
|
|
78 |
iTheView->ReadTypeAttribL( TPtrC(ISP_TYPE), colType, attrib );
|
|
79 |
if ( !(colType == EDbColUint32 && attrib == 0) )
|
|
80 |
ret = EFail;
|
|
81 |
}
|
|
82 |
|
|
83 |
if ( ret == EPass )
|
|
84 |
{
|
|
85 |
iTheView->ReadTypeAttribL( TPtrC(ISP_USE_LOGIN_SCRIPT), colType, attrib );
|
|
86 |
if ( !(colType == EDbColBit && attrib == 0) )
|
|
87 |
ret = EFail;
|
|
88 |
}
|
|
89 |
|
|
90 |
return ret;
|
|
91 |
}
|
|
92 |
|
|
93 |
TVerdict CCommDbTest005_01::doTestStepL( )
|
|
94 |
{
|
|
95 |
INFO_PRINTF1(_L("Step 005.01 called "));
|
|
96 |
|
|
97 |
if ( executeStep() )
|
|
98 |
{
|
|
99 |
SetTestStepResult(EFail); }
|
|
100 |
else
|
|
101 |
{
|
|
102 |
SetTestStepResult(EPass); }
|
|
103 |
|
|
104 |
return TestStepResult();
|
|
105 |
}
|
|
106 |
|
|
107 |
|
|
108 |
/////////////////////
|
|
109 |
// Test step 005.002
|
|
110 |
/////////////////////
|
|
111 |
|
|
112 |
// constructor
|
|
113 |
CCommDbTest005_02::CCommDbTest005_02()
|
|
114 |
{
|
|
115 |
// store the name of this test case
|
|
116 |
SetTestStepName(_L("step_005_02"));
|
|
117 |
}
|
|
118 |
|
|
119 |
// destructor
|
|
120 |
CCommDbTest005_02::~CCommDbTest005_02()
|
|
121 |
{
|
|
122 |
}
|
|
123 |
|
|
124 |
TVerdict CCommDbTest005_02::doTestStepPreambleL()
|
|
125 |
{
|
|
126 |
openDbAndViewL(TPtrC(DIAL_OUT_ISP));
|
|
127 |
SetTestStepResult(EPass); return TestStepResult();
|
|
128 |
}
|
|
129 |
|
|
130 |
|
|
131 |
TBool CCommDbTest005_02::executeStepL()
|
|
132 |
{
|
|
133 |
TDbColType colType;
|
|
134 |
TUint32 attrib;
|
|
135 |
TBool ret=EFail;
|
|
136 |
|
|
137 |
|
|
138 |
//NB. This step is designed not to leave
|
|
139 |
|
|
140 |
//Read attributes for columns, and check against known correct values
|
|
141 |
iTheView->ReadTypeAttribL( TPtrC(COMMDB_ID), colType, attrib );
|
|
142 |
|
|
143 |
if ( colType == EDbColUint32 && attrib == (TDbCol::EAutoIncrement|TDbCol::ENotNull) )
|
|
144 |
ret = EPass;
|
|
145 |
|
|
146 |
if ( ret == EPass )
|
|
147 |
{
|
|
148 |
iTheView->ReadTypeAttribL( TPtrC(COMMDB_NAME), colType, attrib );
|
|
149 |
if ( !(colType == EDbColText && attrib == TDbCol::ENotNull) )
|
|
150 |
ret = EFail;
|
|
151 |
}
|
|
152 |
|
|
153 |
return ret;
|
|
154 |
|
|
155 |
}
|
|
156 |
|
|
157 |
TVerdict CCommDbTest005_02::doTestStepL( )
|
|
158 |
{
|
|
159 |
INFO_PRINTF1(_L("Step 005.02 called "));
|
|
160 |
|
|
161 |
if ( executeStep() )
|
|
162 |
{
|
|
163 |
SetTestStepResult(EFail); }
|
|
164 |
else
|
|
165 |
{
|
|
166 |
SetTestStepResult(EPass); }
|
|
167 |
|
|
168 |
|
|
169 |
return TestStepResult();
|
|
170 |
}
|
|
171 |
|
|
172 |
|
|
173 |
/////////////////////
|
|
174 |
// Test step 005.003
|
|
175 |
/////////////////////
|
|
176 |
|
|
177 |
// constructor
|
|
178 |
CCommDbTest005_03::CCommDbTest005_03()
|
|
179 |
{
|
|
180 |
// store the name of this test case
|
|
181 |
SetTestStepName(_L("step_005_03"));
|
|
182 |
}
|
|
183 |
|
|
184 |
// destructor
|
|
185 |
CCommDbTest005_03::~CCommDbTest005_03()
|
|
186 |
{
|
|
187 |
}
|
|
188 |
|
|
189 |
TVerdict CCommDbTest005_03::doTestStepPreambleL()
|
|
190 |
{
|
|
191 |
openDbAndViewL(TPtrC(DIAL_OUT_ISP));
|
|
192 |
SetTestStepResult(EPass); return TestStepResult();
|
|
193 |
}
|
|
194 |
|
|
195 |
|
|
196 |
TInt CCommDbTest005_03::executeStepL()
|
|
197 |
{
|
|
198 |
TDbColType colType;
|
|
199 |
TUint32 attrib;
|
|
200 |
|
|
201 |
//NB. This test should leave
|
|
202 |
TRAPD(ret, iTheView->ReadTypeAttribL( KInvalidColumnName, colType, attrib ) );
|
|
203 |
|
|
204 |
return ret;
|
|
205 |
}
|
|
206 |
|
|
207 |
TVerdict CCommDbTest005_03::doTestStepL( )
|
|
208 |
{
|
|
209 |
INFO_PRINTF1(_L("Step 005.03 called "));
|
|
210 |
|
|
211 |
SetTestStepResult(EFail);
|
|
212 |
if ( executeStep() == KErrNotFound )
|
|
213 |
SetTestStepResult(EPass);
|
|
214 |
return TestStepResult();
|
|
215 |
}
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
/////////////////////
|
|
220 |
// Test step 005.004
|
|
221 |
/////////////////////
|
|
222 |
|
|
223 |
// constructor
|
|
224 |
CCommDbTest005_04::CCommDbTest005_04()
|
|
225 |
{
|
|
226 |
// store the name of this test case
|
|
227 |
SetTestStepName(_L("step_005_04"));
|
|
228 |
}
|
|
229 |
|
|
230 |
// destructor
|
|
231 |
CCommDbTest005_04::~CCommDbTest005_04()
|
|
232 |
{
|
|
233 |
}
|
|
234 |
|
|
235 |
|
|
236 |
|
|
237 |
TVerdict CCommDbTest005_04::doTestStepL( )
|
|
238 |
{
|
|
239 |
INFO_PRINTF1(_L("Step 005.04 called "));
|
|
240 |
|
|
241 |
SetTestStepResult(EPass);
|
|
242 |
//Heap test for 005.01
|
|
243 |
|
|
244 |
CCommDbTest005_01* step005_01 = new CCommDbTest005_01;
|
|
245 |
CleanupStack::PushL(step005_01);
|
|
246 |
doTestStepWithHeapFailureL( *step005_01, KErrNone);
|
|
247 |
if( step005_01->TestStepResult() == EFail )
|
|
248 |
SetTestStepResult(EFail); CleanupStack::PopAndDestroy(step005_01);
|
|
249 |
|
|
250 |
//Heap test for 005.02
|
|
251 |
|
|
252 |
CCommDbTest005_02* step005_02 = new CCommDbTest005_02;
|
|
253 |
CleanupStack::PushL(step005_02);
|
|
254 |
doTestStepWithHeapFailureL( *step005_02, KErrNone);
|
|
255 |
if( step005_02->TestStepResult() == EFail )
|
|
256 |
SetTestStepResult(EFail); CleanupStack::PopAndDestroy(step005_02);
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
//Heap test for 005.03
|
|
261 |
|
|
262 |
|
|
263 |
CCommDbTest005_03* step005_03 = new CCommDbTest005_03;
|
|
264 |
CleanupStack::PushL(step005_03);
|
|
265 |
doTestStepWithHeapFailureL( *step005_03, KErrNotFound);
|
|
266 |
if( step005_03->TestStepResult() == EFail )
|
|
267 |
SetTestStepResult(EFail); CleanupStack::PopAndDestroy(step005_03);
|
|
268 |
|
|
269 |
return TestStepResult();
|
|
270 |
}
|