sl@0
|
1 |
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <d32dbms.h>
|
sl@0
|
17 |
#include <s32file.h>
|
sl@0
|
18 |
#include <e32test.h>
|
sl@0
|
19 |
|
sl@0
|
20 |
LOCAL_D RTest test(_L("t_dbwindow: Testing the 'window' stage"));
|
sl@0
|
21 |
LOCAL_D CTrapCleanup* TheTrapCleanup;
|
sl@0
|
22 |
LOCAL_D CFileStore* TheStore;
|
sl@0
|
23 |
LOCAL_D RDbStoreDatabase TheDatabase;
|
sl@0
|
24 |
LOCAL_D RDbView TheView;
|
sl@0
|
25 |
LOCAL_D RFs TheFs;
|
sl@0
|
26 |
|
sl@0
|
27 |
const TInt KTestCleanupStack=0x20;
|
sl@0
|
28 |
const TPtrC KTestDir=_S("C:\\DBMS-TST\\");
|
sl@0
|
29 |
const TPtrC KTestFile=_S("T_WINDOW.DB");
|
sl@0
|
30 |
const TPtrC KTableName=_S("TestTable");
|
sl@0
|
31 |
const TPtrC KColumnID=_S("id");
|
sl@0
|
32 |
const TPtrC KIndexName=_S("TestIndex");
|
sl@0
|
33 |
const TInt KRecords=10;
|
sl@0
|
34 |
const TPtrC KCreateTable=_L("CREATE TABLE TestTable (id INTEGER NOT NULL)");
|
sl@0
|
35 |
const TPtrC KCreateIndex=_L("CREATE UNIQUE INDEX TestIndex ON TestTable (id)");
|
sl@0
|
36 |
const TPtrC KEmptyQuery=_L("select * from TestTable where id is null");
|
sl@0
|
37 |
const TPtrC KOrderQuery=_L("select * from TestTable order by id");
|
sl@0
|
38 |
const TDbWindow KSingleSlotWindow(0,0);
|
sl@0
|
39 |
const TDbWindow KSmallWindow(2,2);
|
sl@0
|
40 |
const TDbWindow KLargeWindow(20,0);
|
sl@0
|
41 |
|
sl@0
|
42 |
//
|
sl@0
|
43 |
// Create the database-in-a-store
|
sl@0
|
44 |
//
|
sl@0
|
45 |
LOCAL_C void CreateDatabaseL()
|
sl@0
|
46 |
{
|
sl@0
|
47 |
CFileStore* store=CPermanentFileStore::ReplaceLC(TheFs,KTestFile,EFileRead|EFileWrite);
|
sl@0
|
48 |
store->SetTypeL(KPermanentFileStoreLayoutUid);
|
sl@0
|
49 |
TStreamId id;
|
sl@0
|
50 |
id=TheDatabase.CreateL(store);
|
sl@0
|
51 |
store->SetRootL(id);
|
sl@0
|
52 |
store->CommitL();
|
sl@0
|
53 |
CleanupStack::Pop();
|
sl@0
|
54 |
TheStore=store;
|
sl@0
|
55 |
}
|
sl@0
|
56 |
|
sl@0
|
57 |
LOCAL_C void CloseDatabaseL()
|
sl@0
|
58 |
{
|
sl@0
|
59 |
// cannot evaluate size info for store database
|
sl@0
|
60 |
RDbDatabase::TSize size=TheDatabase.Size();
|
sl@0
|
61 |
test (size.iSize<0);
|
sl@0
|
62 |
test (size.iUsage<0);
|
sl@0
|
63 |
test (TheDatabase.UpdateStats()==KErrNone);
|
sl@0
|
64 |
size=TheDatabase.Size();
|
sl@0
|
65 |
test (size.iSize<0);
|
sl@0
|
66 |
test (size.iUsage<0);
|
sl@0
|
67 |
TheDatabase.Close();
|
sl@0
|
68 |
delete TheStore;
|
sl@0
|
69 |
}
|
sl@0
|
70 |
|
sl@0
|
71 |
LOCAL_C void CreateTableL()
|
sl@0
|
72 |
{
|
sl@0
|
73 |
TheDatabase.Begin();
|
sl@0
|
74 |
test(TheDatabase.Execute(KCreateTable)==KErrNone);
|
sl@0
|
75 |
RDbTable table;
|
sl@0
|
76 |
test(table.Open(TheDatabase,KTableName,table.EInsertOnly)==KErrNone);
|
sl@0
|
77 |
for (TInt ii=0;ii<KRecords;++ii)
|
sl@0
|
78 |
{
|
sl@0
|
79 |
table.InsertL();
|
sl@0
|
80 |
table.SetColL(1,ii);
|
sl@0
|
81 |
table.PutL();
|
sl@0
|
82 |
}
|
sl@0
|
83 |
table.Close();
|
sl@0
|
84 |
test(TheDatabase.Execute(KCreateIndex)==KErrNone);
|
sl@0
|
85 |
test (TheDatabase.Commit()==KErrNone);
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
LOCAL_C void InitL()
|
sl@0
|
89 |
{
|
sl@0
|
90 |
CreateDatabaseL();
|
sl@0
|
91 |
CreateTableL();
|
sl@0
|
92 |
}
|
sl@0
|
93 |
|
sl@0
|
94 |
/**
|
sl@0
|
95 |
@SYMTestCaseID SYSLIB-DBMS-CT-0638
|
sl@0
|
96 |
@SYMTestCaseDesc Tests for navigation
|
sl@0
|
97 |
@SYMTestPriority Medium
|
sl@0
|
98 |
@SYMTestActions Tests for navigation in an empty window
|
sl@0
|
99 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
100 |
@SYMREQ REQ0000
|
sl@0
|
101 |
*/
|
sl@0
|
102 |
LOCAL_C void TestEmptyL()
|
sl@0
|
103 |
{
|
sl@0
|
104 |
test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0638 Unevaluated "));
|
sl@0
|
105 |
test(TheView.Prepare(TheDatabase,KEmptyQuery,TDbWindow::EUnlimited)==KErrNone);
|
sl@0
|
106 |
test(TheView.CountL(TheView.EQuick)==0);
|
sl@0
|
107 |
test(!TheView.FirstL());
|
sl@0
|
108 |
test(TheView.AtEnd());
|
sl@0
|
109 |
test(!TheView.PreviousL());
|
sl@0
|
110 |
test(TheView.AtBeginning());
|
sl@0
|
111 |
test(!TheView.LastL());
|
sl@0
|
112 |
test(TheView.AtBeginning());
|
sl@0
|
113 |
test(!TheView.NextL());
|
sl@0
|
114 |
test(TheView.AtEnd());
|
sl@0
|
115 |
test.Next(_L("Evaluated"));
|
sl@0
|
116 |
test(TheView.EvaluateAll()==KErrNone);
|
sl@0
|
117 |
test(TheView.CountL()==0);
|
sl@0
|
118 |
test(!TheView.FirstL());
|
sl@0
|
119 |
test(TheView.AtEnd());
|
sl@0
|
120 |
test(!TheView.PreviousL());
|
sl@0
|
121 |
test(TheView.AtBeginning());
|
sl@0
|
122 |
test(!TheView.LastL());
|
sl@0
|
123 |
test(TheView.AtBeginning());
|
sl@0
|
124 |
test(!TheView.NextL());
|
sl@0
|
125 |
test(TheView.AtEnd());
|
sl@0
|
126 |
test.End();
|
sl@0
|
127 |
TheView.Close();
|
sl@0
|
128 |
}
|
sl@0
|
129 |
|
sl@0
|
130 |
/**
|
sl@0
|
131 |
@SYMTestCaseID SYSLIB-DBMS-CT-0639
|
sl@0
|
132 |
@SYMTestCaseDesc Tests for navigation
|
sl@0
|
133 |
@SYMTestPriority Medium
|
sl@0
|
134 |
@SYMTestActions Tests for the unlimited (dynaset) window
|
sl@0
|
135 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
136 |
@SYMREQ REQ0000
|
sl@0
|
137 |
*/
|
sl@0
|
138 |
LOCAL_C void TestUnlimitedL()
|
sl@0
|
139 |
{
|
sl@0
|
140 |
test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0639 EvaluateAll "));
|
sl@0
|
141 |
test(TheView.Prepare(TheDatabase,KOrderQuery,TDbWindow::EUnlimited)==KErrNone);
|
sl@0
|
142 |
test(TheView.EvaluateAll()==KErrNone);
|
sl@0
|
143 |
test(!TheView.Unevaluated());
|
sl@0
|
144 |
test(TheView.CountL()==KRecords);
|
sl@0
|
145 |
TInt cc=0;
|
sl@0
|
146 |
for (TheView.BeginningL();TheView.NextL();)
|
sl@0
|
147 |
++cc;
|
sl@0
|
148 |
test(cc==KRecords);
|
sl@0
|
149 |
for (TheView.EndL();TheView.PreviousL();)
|
sl@0
|
150 |
--cc;
|
sl@0
|
151 |
test(cc==0);
|
sl@0
|
152 |
test(!TheView.Unevaluated());
|
sl@0
|
153 |
test.Next(_L("Incremental evaluate"));
|
sl@0
|
154 |
TheView.Reset();
|
sl@0
|
155 |
cc=TheView.CountL(TheView.EQuick);
|
sl@0
|
156 |
test(cc==0);
|
sl@0
|
157 |
test(!TheView.FirstL());
|
sl@0
|
158 |
while (TheView.Unevaluated())
|
sl@0
|
159 |
{
|
sl@0
|
160 |
test(TheView.Evaluate()>=KErrNone);
|
sl@0
|
161 |
TInt ii=TheView.CountL()-cc;
|
sl@0
|
162 |
test(ii>=0);
|
sl@0
|
163 |
cc+=ii;
|
sl@0
|
164 |
while (--ii>=0)
|
sl@0
|
165 |
{
|
sl@0
|
166 |
test(TheView.AtRow());
|
sl@0
|
167 |
TheView.NextL();
|
sl@0
|
168 |
}
|
sl@0
|
169 |
test(!TheView.AtRow());
|
sl@0
|
170 |
}
|
sl@0
|
171 |
test(cc==KRecords);
|
sl@0
|
172 |
test.Next(_L("Insert"));
|
sl@0
|
173 |
// The new records should go on the end of the set
|
sl@0
|
174 |
TheView.InsertL();
|
sl@0
|
175 |
TheView.SetColL(1,TInt(-1));
|
sl@0
|
176 |
TheView.PutL();
|
sl@0
|
177 |
test(TheView.CountL()==KRecords+1);
|
sl@0
|
178 |
test(TheView.LastL());
|
sl@0
|
179 |
TheView.GetL();
|
sl@0
|
180 |
test(TheView.ColInt(1)==-1);
|
sl@0
|
181 |
// because of order, it should appear at beginning on re-evaluation
|
sl@0
|
182 |
TheView.Reset();
|
sl@0
|
183 |
test(TheView.EvaluateAll()==KErrNone);
|
sl@0
|
184 |
test(TheView.CountL()==KRecords+1);
|
sl@0
|
185 |
test(TheView.FirstL());
|
sl@0
|
186 |
TheView.GetL();
|
sl@0
|
187 |
test(TheView.ColInt(1)==-1);
|
sl@0
|
188 |
test.Next(_L("Update"));
|
sl@0
|
189 |
// updated records should not move (or disappear) in the set
|
sl@0
|
190 |
TheView.UpdateL();
|
sl@0
|
191 |
TheView.SetColL(1,KRecords);
|
sl@0
|
192 |
TheView.PutL();
|
sl@0
|
193 |
test(TheView.CountL()==KRecords+1);
|
sl@0
|
194 |
test(TheView.FirstL());
|
sl@0
|
195 |
TheView.GetL();
|
sl@0
|
196 |
test(TheView.ColInt(1)==KRecords);
|
sl@0
|
197 |
// because of order, it should appear at end on re-evaluation
|
sl@0
|
198 |
TheView.Reset();
|
sl@0
|
199 |
test(TheView.EvaluateAll()==KErrNone);
|
sl@0
|
200 |
test(TheView.CountL()==KRecords+1);
|
sl@0
|
201 |
test(TheView.LastL());
|
sl@0
|
202 |
TheView.GetL();
|
sl@0
|
203 |
test(TheView.ColInt(1)==KRecords);
|
sl@0
|
204 |
test.Next(_L("Bookmarks"));
|
sl@0
|
205 |
TDbBookmark mark=TheView.Bookmark();
|
sl@0
|
206 |
TheView.BeginningL();
|
sl@0
|
207 |
TRAPD(r,TheView.GotoL(mark));
|
sl@0
|
208 |
test(r==KErrNone);
|
sl@0
|
209 |
TheView.GetL();
|
sl@0
|
210 |
test(TheView.ColInt(1)==KRecords);
|
sl@0
|
211 |
test(!TheView.NextL());
|
sl@0
|
212 |
test(TheView.PreviousL());
|
sl@0
|
213 |
test.Next(_L("Delete"));
|
sl@0
|
214 |
// should disappear from the set
|
sl@0
|
215 |
TheView.DeleteL();
|
sl@0
|
216 |
test(TheView.CountL()==KRecords);
|
sl@0
|
217 |
for (TheView.BeginningL();TheView.NextL();)
|
sl@0
|
218 |
{
|
sl@0
|
219 |
TheView.GetL();
|
sl@0
|
220 |
test(TheView.ColInt(1)!=KRecords);
|
sl@0
|
221 |
}
|
sl@0
|
222 |
TRAP(r,TheView.GotoL(mark));
|
sl@0
|
223 |
test(r!=KErrNone);
|
sl@0
|
224 |
TheView.Reset();
|
sl@0
|
225 |
test(TheView.EvaluateAll()==KErrNone);
|
sl@0
|
226 |
test(TheView.CountL()==KRecords);
|
sl@0
|
227 |
for (TheView.BeginningL();TheView.NextL();)
|
sl@0
|
228 |
{
|
sl@0
|
229 |
TheView.GetL();
|
sl@0
|
230 |
test(TheView.ColInt(1)!=KRecords);
|
sl@0
|
231 |
}
|
sl@0
|
232 |
TRAP(r,TheView.GotoL(mark));
|
sl@0
|
233 |
test(r!=KErrNone);
|
sl@0
|
234 |
test.End();
|
sl@0
|
235 |
TheView.Close();
|
sl@0
|
236 |
}
|
sl@0
|
237 |
|
sl@0
|
238 |
//
|
sl@0
|
239 |
// do as much incremental evaluation as possible
|
sl@0
|
240 |
//
|
sl@0
|
241 |
LOCAL_C void Evaluate()
|
sl@0
|
242 |
{
|
sl@0
|
243 |
test(TheView.EvaluateAll()==KErrNone);
|
sl@0
|
244 |
}
|
sl@0
|
245 |
|
sl@0
|
246 |
//
|
sl@0
|
247 |
// get to the true end of set
|
sl@0
|
248 |
//
|
sl@0
|
249 |
LOCAL_C void GotoEndL()
|
sl@0
|
250 |
{
|
sl@0
|
251 |
for (;;)
|
sl@0
|
252 |
{
|
sl@0
|
253 |
while (TheView.AtRow())
|
sl@0
|
254 |
TheView.NextL();
|
sl@0
|
255 |
if (!TheView.Unevaluated())
|
sl@0
|
256 |
break;
|
sl@0
|
257 |
Evaluate();
|
sl@0
|
258 |
}
|
sl@0
|
259 |
}
|
sl@0
|
260 |
|
sl@0
|
261 |
LOCAL_C void CheckWindowL(TInt forward,TInt back)
|
sl@0
|
262 |
{
|
sl@0
|
263 |
TInt ii;
|
sl@0
|
264 |
for (ii=0;ii<forward;++ii)
|
sl@0
|
265 |
test(TheView.NextL());
|
sl@0
|
266 |
test(!TheView.NextL());
|
sl@0
|
267 |
for (ii=0;ii<forward+back+1;++ii)
|
sl@0
|
268 |
test(TheView.PreviousL());
|
sl@0
|
269 |
test(!TheView.PreviousL());
|
sl@0
|
270 |
for (ii=0;ii<back+1;++ii)
|
sl@0
|
271 |
test(TheView.NextL());
|
sl@0
|
272 |
}
|
sl@0
|
273 |
|
sl@0
|
274 |
/**
|
sl@0
|
275 |
@SYMTestCaseID SYSLIB-DBMS-CT-0640
|
sl@0
|
276 |
@SYMTestCaseDesc Tests for RDbView
|
sl@0
|
277 |
@SYMTestPriority Medium
|
sl@0
|
278 |
@SYMTestActions Tests for a restricted sized window
|
sl@0
|
279 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
280 |
@SYMREQ REQ0000
|
sl@0
|
281 |
*/
|
sl@0
|
282 |
LOCAL_C void TestRestrictedL()
|
sl@0
|
283 |
{
|
sl@0
|
284 |
test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0640 Behaviour at start of set "));
|
sl@0
|
285 |
test(TheView.Prepare(TheDatabase,KOrderQuery,KSingleSlotWindow)==KErrNone);
|
sl@0
|
286 |
test(TheView.EvaluateAll()==KErrNone);
|
sl@0
|
287 |
test(TheView.CountL()==1);
|
sl@0
|
288 |
test(!TheView.Unevaluated());
|
sl@0
|
289 |
test(TheView.NextL());
|
sl@0
|
290 |
test(!TheView.Unevaluated());
|
sl@0
|
291 |
TheView.GetL();
|
sl@0
|
292 |
TInt id=TheView.ColInt(1);
|
sl@0
|
293 |
test(!TheView.NextL());
|
sl@0
|
294 |
test(TheView.Unevaluated());
|
sl@0
|
295 |
Evaluate();
|
sl@0
|
296 |
test(TheView.CountL()==1);
|
sl@0
|
297 |
test(TheView.AtRow());
|
sl@0
|
298 |
test(!TheView.PreviousL());
|
sl@0
|
299 |
test(TheView.Unevaluated());
|
sl@0
|
300 |
Evaluate();
|
sl@0
|
301 |
test(TheView.CountL()==1);
|
sl@0
|
302 |
test(TheView.AtRow());
|
sl@0
|
303 |
TheView.GetL();
|
sl@0
|
304 |
test(TheView.ColInt(1)==id);
|
sl@0
|
305 |
test(!TheView.PreviousL());
|
sl@0
|
306 |
test(TheView.Unevaluated());
|
sl@0
|
307 |
Evaluate();
|
sl@0
|
308 |
test(TheView.CountL()==1);
|
sl@0
|
309 |
test(TheView.AtBeginning());
|
sl@0
|
310 |
test(TheView.NextL());
|
sl@0
|
311 |
TheView.GetL();
|
sl@0
|
312 |
test(TheView.ColInt(1)==id);
|
sl@0
|
313 |
test(!TheView.Unevaluated());
|
sl@0
|
314 |
test.Next(_L("Behaviour at end of set"));
|
sl@0
|
315 |
GotoEndL();
|
sl@0
|
316 |
test(TheView.LastL());
|
sl@0
|
317 |
test(!TheView.Unevaluated());
|
sl@0
|
318 |
TheView.GetL();
|
sl@0
|
319 |
id=TheView.ColInt(1);
|
sl@0
|
320 |
test(!TheView.PreviousL());
|
sl@0
|
321 |
test(TheView.Unevaluated());
|
sl@0
|
322 |
Evaluate();
|
sl@0
|
323 |
test(TheView.CountL()==1);
|
sl@0
|
324 |
test(TheView.AtRow());
|
sl@0
|
325 |
test(!TheView.NextL());
|
sl@0
|
326 |
test(TheView.Unevaluated());
|
sl@0
|
327 |
Evaluate();
|
sl@0
|
328 |
test(TheView.CountL()==1);
|
sl@0
|
329 |
test(TheView.AtRow());
|
sl@0
|
330 |
TheView.GetL();
|
sl@0
|
331 |
test(TheView.ColInt(1)==id);
|
sl@0
|
332 |
test(!TheView.NextL());
|
sl@0
|
333 |
test(TheView.Unevaluated());
|
sl@0
|
334 |
Evaluate();
|
sl@0
|
335 |
test(TheView.CountL()==1);
|
sl@0
|
336 |
test(TheView.AtEnd());
|
sl@0
|
337 |
test(TheView.PreviousL());
|
sl@0
|
338 |
TheView.GetL();
|
sl@0
|
339 |
test(TheView.ColInt(1)==id);
|
sl@0
|
340 |
test(!TheView.Unevaluated());
|
sl@0
|
341 |
TheView.Close();
|
sl@0
|
342 |
//
|
sl@0
|
343 |
test.Next(_L("Forward and backwards slots"));
|
sl@0
|
344 |
test(TheView.Prepare(TheDatabase,KOrderQuery,KSmallWindow)==KErrNone);
|
sl@0
|
345 |
test(TheView.EvaluateAll()==KErrNone);
|
sl@0
|
346 |
test(TheView.CountL()==5);
|
sl@0
|
347 |
test(TheView.FirstL());
|
sl@0
|
348 |
CheckWindowL(4,0);
|
sl@0
|
349 |
test(TheView.NextL());
|
sl@0
|
350 |
test(TheView.NextL()); // now on preferred slot (id=2)
|
sl@0
|
351 |
test(!TheView.Unevaluated());
|
sl@0
|
352 |
test(TheView.NextL());
|
sl@0
|
353 |
test(TheView.Unevaluated());
|
sl@0
|
354 |
Evaluate();
|
sl@0
|
355 |
CheckWindowL(2,2);
|
sl@0
|
356 |
test(TheView.LastL()); // id=5
|
sl@0
|
357 |
Evaluate();
|
sl@0
|
358 |
test(TheView.LastL()); // id=7
|
sl@0
|
359 |
Evaluate(); // should now have last five rows
|
sl@0
|
360 |
CheckWindowL(2,2);
|
sl@0
|
361 |
test(TheView.LastL()); // id=9
|
sl@0
|
362 |
Evaluate(); // no more rows
|
sl@0
|
363 |
CheckWindowL(0,4); // all behind us now
|
sl@0
|
364 |
TheView.GetL();
|
sl@0
|
365 |
test(TheView.ColInt(1)==9);
|
sl@0
|
366 |
TheView.FirstL(); // id=5
|
sl@0
|
367 |
Evaluate();
|
sl@0
|
368 |
TheView.FirstL(); // id=3
|
sl@0
|
369 |
Evaluate();
|
sl@0
|
370 |
TheView.FirstL(); // id=1
|
sl@0
|
371 |
Evaluate();
|
sl@0
|
372 |
CheckWindowL(3,1);
|
sl@0
|
373 |
//
|
sl@0
|
374 |
test.Next(_L("Bookmarks"));
|
sl@0
|
375 |
TDbBookmark mark=TheView.Bookmark();
|
sl@0
|
376 |
test(TheView.NextL());
|
sl@0
|
377 |
test(TheView.NextL());
|
sl@0
|
378 |
test(TheView.NextL());
|
sl@0
|
379 |
Evaluate();
|
sl@0
|
380 |
TRAPD(r,TheView.GotoL(mark));
|
sl@0
|
381 |
test(r!=KErrNone);
|
sl@0
|
382 |
TheView.FirstL();
|
sl@0
|
383 |
Evaluate();
|
sl@0
|
384 |
TRAP(r,TheView.GotoL(mark));
|
sl@0
|
385 |
test(r==KErrNone);
|
sl@0
|
386 |
test.Next(_L("Delete"));
|
sl@0
|
387 |
test(TheView.FirstL());
|
sl@0
|
388 |
TheView.GetL();
|
sl@0
|
389 |
test(TheView.ColInt(1)==0);
|
sl@0
|
390 |
TheView.DeleteL();
|
sl@0
|
391 |
test(TheView.CountL()==4);
|
sl@0
|
392 |
TheView.FirstL();
|
sl@0
|
393 |
CheckWindowL(3,0);
|
sl@0
|
394 |
test.Next(_L("Insert"));
|
sl@0
|
395 |
TheView.InsertL();
|
sl@0
|
396 |
TheView.SetColL(1,TInt(0));
|
sl@0
|
397 |
TheView.PutL();
|
sl@0
|
398 |
test(TheView.CountL()==4);
|
sl@0
|
399 |
TheView.FirstL();
|
sl@0
|
400 |
TheView.GetL();
|
sl@0
|
401 |
test(TheView.ColInt(1)==1);
|
sl@0
|
402 |
TheView.Reset();
|
sl@0
|
403 |
test(TheView.EvaluateAll()==KErrNone);
|
sl@0
|
404 |
test(TheView.FirstL());
|
sl@0
|
405 |
TheView.GetL();
|
sl@0
|
406 |
test(TheView.ColInt(1)==0);
|
sl@0
|
407 |
//
|
sl@0
|
408 |
test.End();
|
sl@0
|
409 |
TheView.Close();
|
sl@0
|
410 |
}
|
sl@0
|
411 |
|
sl@0
|
412 |
LOCAL_C void TestL()
|
sl@0
|
413 |
{
|
sl@0
|
414 |
__UHEAP_MARK;
|
sl@0
|
415 |
test.Start(_L("Setting up test table"));
|
sl@0
|
416 |
TRAPD(r,InitL();)
|
sl@0
|
417 |
test(r==KErrNone);
|
sl@0
|
418 |
test.Next(_L("Empty Window"));
|
sl@0
|
419 |
TRAP(r,TestEmptyL();)
|
sl@0
|
420 |
test(r==KErrNone);
|
sl@0
|
421 |
test.Next(_L("Unlimited Window"));
|
sl@0
|
422 |
TRAP(r,TestUnlimitedL();)
|
sl@0
|
423 |
test(r==KErrNone);
|
sl@0
|
424 |
test.Next(_L("Sized window"));
|
sl@0
|
425 |
TRAP(r,TestRestrictedL();)
|
sl@0
|
426 |
test(r==KErrNone);
|
sl@0
|
427 |
test.Next(_L("Cleanup"));
|
sl@0
|
428 |
TRAP(r,CloseDatabaseL();)
|
sl@0
|
429 |
test(r==KErrNone);
|
sl@0
|
430 |
test.End();
|
sl@0
|
431 |
__UHEAP_MARKEND;
|
sl@0
|
432 |
}
|
sl@0
|
433 |
|
sl@0
|
434 |
//
|
sl@0
|
435 |
// Prepare the test directory.
|
sl@0
|
436 |
//
|
sl@0
|
437 |
LOCAL_C void setupTestDirectory()
|
sl@0
|
438 |
{
|
sl@0
|
439 |
TInt r=TheFs.Connect();
|
sl@0
|
440 |
test(r==KErrNone);
|
sl@0
|
441 |
//
|
sl@0
|
442 |
r=TheFs.MkDir(KTestDir);
|
sl@0
|
443 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
444 |
r=TheFs.SetSessionPath(KTestDir);
|
sl@0
|
445 |
test(r==KErrNone);
|
sl@0
|
446 |
}
|
sl@0
|
447 |
|
sl@0
|
448 |
//
|
sl@0
|
449 |
// Initialise the cleanup stack.
|
sl@0
|
450 |
//
|
sl@0
|
451 |
LOCAL_C void setupCleanup()
|
sl@0
|
452 |
{
|
sl@0
|
453 |
TheTrapCleanup=CTrapCleanup::New();
|
sl@0
|
454 |
test(TheTrapCleanup!=NULL);
|
sl@0
|
455 |
TRAPD(r,\
|
sl@0
|
456 |
{\
|
sl@0
|
457 |
for (TInt i=KTestCleanupStack;i>0;i--)\
|
sl@0
|
458 |
CleanupStack::PushL((TAny*)0);\
|
sl@0
|
459 |
CleanupStack::Pop(KTestCleanupStack);\
|
sl@0
|
460 |
});
|
sl@0
|
461 |
test(r==KErrNone);
|
sl@0
|
462 |
}
|
sl@0
|
463 |
|
sl@0
|
464 |
LOCAL_C void DeleteDataFile(const TDesC& aFullName)
|
sl@0
|
465 |
{
|
sl@0
|
466 |
RFs fsSession;
|
sl@0
|
467 |
TInt err = fsSession.Connect();
|
sl@0
|
468 |
if(err == KErrNone)
|
sl@0
|
469 |
{
|
sl@0
|
470 |
TEntry entry;
|
sl@0
|
471 |
if(fsSession.Entry(aFullName, entry) == KErrNone)
|
sl@0
|
472 |
{
|
sl@0
|
473 |
RDebug::Print(_L("Deleting \"%S\" file.\n"), &aFullName);
|
sl@0
|
474 |
err = fsSession.SetAtt(aFullName, 0, KEntryAttReadOnly);
|
sl@0
|
475 |
if(err != KErrNone)
|
sl@0
|
476 |
{
|
sl@0
|
477 |
RDebug::Print(_L("Error %d changing \"%S\" file attributes.\n"), err, &aFullName);
|
sl@0
|
478 |
}
|
sl@0
|
479 |
err = fsSession.Delete(aFullName);
|
sl@0
|
480 |
if(err != KErrNone)
|
sl@0
|
481 |
{
|
sl@0
|
482 |
RDebug::Print(_L("Error %d deleting \"%S\" file.\n"), err, &aFullName);
|
sl@0
|
483 |
}
|
sl@0
|
484 |
}
|
sl@0
|
485 |
fsSession.Close();
|
sl@0
|
486 |
}
|
sl@0
|
487 |
else
|
sl@0
|
488 |
{
|
sl@0
|
489 |
RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName);
|
sl@0
|
490 |
}
|
sl@0
|
491 |
}
|
sl@0
|
492 |
|
sl@0
|
493 |
//
|
sl@0
|
494 |
// Test streaming conversions.
|
sl@0
|
495 |
//
|
sl@0
|
496 |
GLDEF_C TInt E32Main()
|
sl@0
|
497 |
{
|
sl@0
|
498 |
test.Title();
|
sl@0
|
499 |
setupTestDirectory();
|
sl@0
|
500 |
setupCleanup();
|
sl@0
|
501 |
//
|
sl@0
|
502 |
test.Start(_L("TDbWindow - database test"));
|
sl@0
|
503 |
TRAPD(err, TestL());
|
sl@0
|
504 |
test(err == KErrNone);
|
sl@0
|
505 |
|
sl@0
|
506 |
//deletion of data files must be done before call to end - DEF047652
|
sl@0
|
507 |
_LIT(KTestDbName, "C:\\DBMS-TST\\T_WINDOW.DB");
|
sl@0
|
508 |
::DeleteDataFile(KTestDbName);
|
sl@0
|
509 |
test.End();
|
sl@0
|
510 |
//
|
sl@0
|
511 |
|
sl@0
|
512 |
delete TheTrapCleanup;
|
sl@0
|
513 |
TheFs.Close();
|
sl@0
|
514 |
test.Close();
|
sl@0
|
515 |
return 0;
|
sl@0
|
516 |
}
|