author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:46:39 +0100 | |
branch | GCC_SURGE |
changeset 221 | 39b39e1a406e |
parent 109 | b3a1d9898418 |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1998-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 the License "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 |
// f32test\server\t_fsy2k.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
18 |
#define __E32TEST_EXTENSION__ |
0 | 19 |
#include <f32file.h> |
20 |
#include <e32test.h> |
|
21 |
#include "t_server.h" |
|
22 |
#include <e32hal.h> |
|
23 |
#include <e32math.h> |
|
24 |
#include <f32dbg.h> |
|
25 |
||
26 |
GLDEF_D RTest test(_L("T_FSY2K")); |
|
27 |
GLDEF_D TBuf<128> gDateBuf; |
|
28 |
||
29 |
const TInt KMaxValidDateTimes=25; |
|
30 |
const TInt KMaxInvalidDateTimes=7; |
|
31 |
||
32 |
static void testRFsSetEntry(TDateTime* aDateTime, TTime* aTime, TBool validDate) |
|
33 |
// |
|
34 |
// Test RFs::SetEntry() and RFs::Entry() functions on both a file and a directory |
|
35 |
// |
|
36 |
{ |
|
37 |
MakeFile(_L("Y2KTEST.tst")); |
|
38 |
||
39 |
TInt r=TheFs.SetEntry(_L("Y2KTEST.tst"),*aTime,KEntryAttHidden,KEntryAttArchive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
40 |
test_KErrNone(r); |
0 | 41 |
|
42 |
TEntry entry; |
|
43 |
r=TheFs.Entry(_L("Y2KTEST.tst"),entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
44 |
test_KErrNone(r); |
0 | 45 |
|
46 |
TDateTime checkDateTime=(entry.iModified).DateTime(); |
|
47 |
test(checkDateTime.Year()==aDateTime->Year()); |
|
48 |
if (validDate) |
|
49 |
{ |
|
50 |
test(checkDateTime.Month()==aDateTime->Month()); |
|
51 |
test(checkDateTime.Day()==aDateTime->Day()); |
|
52 |
} |
|
53 |
else |
|
54 |
{ |
|
55 |
test(checkDateTime.Month()==aDateTime->Month()+1); |
|
56 |
test(checkDateTime.Day()==0); |
|
57 |
} |
|
58 |
||
59 |
(entry.iModified).FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
|
60 |
test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
|
61 |
||
62 |
r=TheFs.Delete(_L("Y2KTEST.tst")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
63 |
test_KErrNone(r); |
0 | 64 |
|
65 |
MakeDir(_L("\\Y2KTEST\\")); |
|
66 |
r=TheFs.SetEntry(_L("\\Y2KTEST\\"),*aTime,KEntryAttHidden,KEntryAttArchive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
67 |
test_KErrNone(r); |
0 | 68 |
|
69 |
r=TheFs.Entry(_L("\\Y2KTEST\\"),entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
70 |
test_KErrNone(r); |
0 | 71 |
|
72 |
checkDateTime=(entry.iModified).DateTime(); |
|
73 |
test(checkDateTime.Year()==aDateTime->Year()); |
|
74 |
if (validDate) |
|
75 |
{ |
|
76 |
test(checkDateTime.Month()==aDateTime->Month()); |
|
77 |
test(checkDateTime.Day()==aDateTime->Day()); |
|
78 |
} |
|
79 |
else |
|
80 |
{ |
|
81 |
test(checkDateTime.Month()==aDateTime->Month()+1); |
|
82 |
test(checkDateTime.Day()==0); |
|
83 |
} |
|
84 |
||
85 |
(entry.iModified).FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
|
86 |
test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
|
87 |
||
88 |
r=TheFs.RmDir(_L("\\Y2KTEST\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
89 |
test_KErrNone(r); |
0 | 90 |
|
91 |
} |
|
92 |
||
93 |
||
94 |
static void testRFsSetModified(TDateTime* aDateTime, TTime* aTime, TBool validDate) |
|
95 |
// |
|
96 |
// Test RFs::SetModified() and RFs::Modified() functions on both a file and a directory |
|
97 |
// |
|
98 |
{ |
|
99 |
MakeFile(_L("Y2KTEST.tst")); |
|
100 |
||
101 |
TInt r=TheFs.SetModified(_L("Y2KTEST.tst"),*aTime); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
102 |
test_KErrNone(r); |
0 | 103 |
|
104 |
TTime check; |
|
105 |
r=TheFs.Modified(_L("Y2KTEST.tst"),check); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
106 |
test_KErrNone(r); |
0 | 107 |
|
108 |
TDateTime checkDateTime=check.DateTime(); |
|
109 |
||
110 |
test(checkDateTime.Year()==aDateTime->Year()); |
|
111 |
if (validDate) |
|
112 |
{ |
|
113 |
test(checkDateTime.Month()==aDateTime->Month()); |
|
114 |
test(checkDateTime.Day()==aDateTime->Day()); |
|
115 |
} |
|
116 |
else |
|
117 |
{ |
|
118 |
test(checkDateTime.Month()==aDateTime->Month()+1); |
|
119 |
test(checkDateTime.Day()==0); |
|
120 |
} |
|
121 |
||
122 |
||
123 |
check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
|
124 |
test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
|
125 |
||
126 |
r=TheFs.Delete(_L("Y2KTEST.tst")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
127 |
test_KErrNone(r); |
0 | 128 |
|
129 |
MakeDir(_L("\\Y2KTEST\\")); |
|
130 |
r=TheFs.SetModified(_L("\\Y2KTEST\\"),*aTime); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
131 |
test_KErrNone(r); |
0 | 132 |
|
133 |
r=TheFs.Modified(_L("\\Y2KTEST\\"),check); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
134 |
test_KErrNone(r); |
0 | 135 |
|
136 |
checkDateTime=check.DateTime(); |
|
137 |
test(checkDateTime.Year()==aDateTime->Year()); |
|
138 |
if (validDate) |
|
139 |
{ |
|
140 |
test(checkDateTime.Month()==aDateTime->Month()); |
|
141 |
test(checkDateTime.Day()==aDateTime->Day()); |
|
142 |
} |
|
143 |
else |
|
144 |
{ |
|
145 |
test(checkDateTime.Month()==aDateTime->Month()+1); |
|
146 |
test(checkDateTime.Day()==0); |
|
147 |
} |
|
148 |
||
149 |
check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
|
150 |
test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
|
151 |
||
152 |
r=TheFs.RmDir(_L("\\Y2KTEST\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
153 |
test_KErrNone(r); |
0 | 154 |
} |
155 |
||
156 |
||
157 |
static void testRFileSet(TDateTime* aDateTime, TTime* aTime, TBool validDate) |
|
158 |
// |
|
159 |
// Test RFile::Set() and RFile::Modified() |
|
160 |
// |
|
161 |
{ |
|
162 |
RFile file; |
|
163 |
TInt r=file.Replace(TheFs,_L("Y2KTEST.tst"),0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
164 |
test_Value(r, r == KErrNone || r==KErrPathNotFound); |
0 | 165 |
|
166 |
r=file.Set(*aTime,KEntryAttHidden,KEntryAttNormal); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
167 |
test_KErrNone(r); |
0 | 168 |
file.Close(); |
169 |
||
170 |
TTime check; |
|
171 |
file.Open(TheFs,_L("Y2KTEST.tst"),EFileWrite); |
|
172 |
r=file.Modified(check); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
173 |
test_KErrNone(r); |
0 | 174 |
file.Close(); |
175 |
||
176 |
test.Printf(_L("Date set to ")); |
|
177 |
test.Printf(_L("Day %d "),aDateTime->Day()); |
|
178 |
test.Printf(_L("Month %d "),aDateTime->Month()); |
|
179 |
test.Printf(_L("Year %d \n"),aDateTime->Year()); |
|
180 |
||
181 |
TDateTime checkDateTime=check.DateTime(); |
|
182 |
if (checkDateTime.Year()!=aDateTime->Year()) |
|
183 |
{ |
|
184 |
// Failure occurs for F32 releases before 111 - due to a problem |
|
185 |
// in SFILE/SF_FILE DoFsFileSet() in which the TTime parameter |
|
186 |
// was being incorrectly obtained. Not a year 2000 issue. |
|
187 |
||
188 |
test.Printf(_L("ERROR!\n")); |
|
189 |
test.Printf(_L("Actually set to ")); |
|
190 |
test.Printf(_L("Day %d "),checkDateTime.Day()); |
|
191 |
test.Printf(_L("Month %d "),checkDateTime.Month()); |
|
192 |
test.Printf(_L("Year %d \n"),checkDateTime.Year()); |
|
193 |
// test.Printf(_L("Press any key to continue \n")); |
|
194 |
// test.Getch(); |
|
195 |
r=TheFs.Delete(_L("Y2KTEST.tst")); |
|
196 |
return; |
|
197 |
} |
|
198 |
else |
|
199 |
test(checkDateTime.Year()==aDateTime->Year()); |
|
200 |
if (validDate) |
|
201 |
{ |
|
202 |
test(checkDateTime.Month()==aDateTime->Month()); |
|
203 |
test(checkDateTime.Day()==aDateTime->Day()); |
|
204 |
} |
|
205 |
else |
|
206 |
{ |
|
207 |
test(checkDateTime.Month()==aDateTime->Month()+1); |
|
208 |
test(checkDateTime.Day()==0); |
|
209 |
} |
|
210 |
||
211 |
||
212 |
check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
|
213 |
test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
|
214 |
||
215 |
r=TheFs.Delete(_L("Y2KTEST.tst")); |
|
216 |
||
217 |
} |
|
218 |
||
219 |
||
220 |
static void testRFileSetModified(TDateTime* aDateTime, TTime* aTime, TBool validDate) |
|
221 |
// |
|
222 |
// Test RFile::SetModified() and RFile::Modified() |
|
223 |
// |
|
224 |
{ |
|
225 |
RFile file; |
|
226 |
TInt r=file.Replace(TheFs,_L("Y2KTEST.tst"),0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
227 |
test_Value(r, r == KErrNone || r==KErrPathNotFound); |
0 | 228 |
|
229 |
r=file.SetModified(*aTime); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
230 |
test_KErrNone(r); |
0 | 231 |
file.Close(); |
232 |
||
233 |
TTime check; |
|
234 |
file.Open(TheFs,_L("Y2KTEST.tst"),EFileWrite); |
|
235 |
r=file.Modified(check); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
236 |
test_KErrNone(r); |
0 | 237 |
file.Close(); |
238 |
||
239 |
TDateTime checkDateTime=check.DateTime(); |
|
240 |
||
241 |
test(checkDateTime.Year()==aDateTime->Year()); |
|
242 |
if (validDate) |
|
243 |
{ |
|
244 |
test(checkDateTime.Month()==aDateTime->Month()); |
|
245 |
test(checkDateTime.Day()==aDateTime->Day()); |
|
246 |
} |
|
247 |
else |
|
248 |
{ |
|
249 |
test(checkDateTime.Month()==aDateTime->Month()+1); |
|
250 |
test(checkDateTime.Day()==0); |
|
251 |
} |
|
252 |
||
253 |
check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
|
254 |
test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
|
255 |
||
256 |
r=TheFs.Delete(_L("Y2KTEST.tst")); |
|
257 |
||
258 |
} |
|
259 |
||
260 |
static void testCFileManAttribsL(TDateTime* aDateTime, TTime* aTime, TBool validDate) |
|
261 |
// |
|
262 |
// Test CFileMan::Attribs() |
|
263 |
// |
|
264 |
{ |
|
265 |
MakeFile(_L("Y2KTEST.tst")); |
|
266 |
||
267 |
CFileMan* fileMan=CFileMan::NewL(TheFs); |
|
268 |
||
269 |
TInt r=fileMan->Attribs(_L("Y2KTEST.tst"),KEntryAttHidden,KEntryAttNormal,*aTime); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
270 |
test_KErrNone(r); |
0 | 271 |
|
272 |
TEntry entry; |
|
273 |
r=TheFs.Entry(_L("Y2KTEST.tst"),entry); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
274 |
test_KErrNone(r); |
0 | 275 |
|
276 |
TTime check=entry.iModified; |
|
277 |
TDateTime checkDateTime=check.DateTime(); |
|
278 |
||
279 |
test(checkDateTime.Year()==aDateTime->Year()); |
|
280 |
if (validDate) |
|
281 |
{ |
|
282 |
test(checkDateTime.Month()==aDateTime->Month()); |
|
283 |
test(checkDateTime.Day()==aDateTime->Day()); |
|
284 |
} |
|
285 |
else |
|
286 |
{ |
|
287 |
test(checkDateTime.Month()==aDateTime->Month()+1); |
|
288 |
test(checkDateTime.Day()==0); |
|
289 |
} |
|
290 |
||
291 |
||
292 |
check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
|
293 |
test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
|
294 |
||
295 |
r=TheFs.Delete(_L("Y2KTEST.tst")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
296 |
test_KErrNone(r); |
0 | 297 |
|
298 |
delete fileMan; |
|
299 |
} |
|
300 |
||
301 |
// Valid dates to be tested for year 2000 compliance |
|
302 |
// Times are always set at 11.11.00 |
|
303 |
||
304 |
LOCAL_D TInt testYearValid[KMaxValidDateTimes] = |
|
305 |
{ |
|
306 |
1998, // December 31 1998 |
|
307 |
1999, // January 01 1999 |
|
308 |
1999, // February 27 1999 |
|
309 |
1999, // February 28 1999 |
|
310 |
1999, // March 01 1999 |
|
311 |
1999, // August 31 1999 |
|
312 |
1999, // September 01 1999 |
|
313 |
1999, // September 08 1999 |
|
314 |
1999, // September 09 1999 |
|
315 |
1999, // September 09 1999 |
|
316 |
1999, // December 31 1999 |
|
317 |
2000, // January 01 2000 |
|
318 |
2000, // February 27 2000 |
|
319 |
2000, // February 28 2000 |
|
320 |
2000, // February 29 2000 |
|
321 |
2000, // March 01 2000 |
|
322 |
2000, // December 31 2000 |
|
323 |
2001, // January 01 2001 |
|
324 |
2001, // February 28 2001 |
|
325 |
2001, // March 01 2001 |
|
326 |
2004, // February 28 2004 |
|
327 |
2004, // February 29 2004 |
|
328 |
2004, // March 01 2004 |
|
329 |
2098, // January 01 2098 |
|
330 |
2099 // January 01 2099 |
|
331 |
}; |
|
332 |
||
333 |
LOCAL_D TMonth testMonthValid[KMaxValidDateTimes] = |
|
334 |
{ |
|
335 |
EDecember, // December 31 1998 |
|
336 |
EJanuary, // January 01 1999 |
|
337 |
EFebruary, // February 27 1999 |
|
338 |
EFebruary, // February 28 1999 |
|
339 |
EMarch, // March 01 1999 |
|
340 |
EAugust, // August 31 1999 |
|
341 |
ESeptember, // September 01 1999 |
|
342 |
ESeptember, // September 08 1999 |
|
343 |
ESeptember, // September 09 1999 |
|
344 |
ESeptember, // September 10 1999 |
|
345 |
EDecember, // December 31 1999 |
|
346 |
EJanuary, // January 01 2000 |
|
347 |
EFebruary, // February 27 2000 |
|
348 |
EFebruary, // February 28 2000 |
|
349 |
EFebruary, // February 29 2000 |
|
350 |
EMarch, // March 01 2000 |
|
351 |
EDecember, // December 31 2000 |
|
352 |
EJanuary, // January 01 2001 |
|
353 |
EFebruary, // February 28 2001 |
|
354 |
EMarch, // March 01 2001 |
|
355 |
EFebruary, // February 28 2004 |
|
356 |
EFebruary, // February 29 2004 |
|
357 |
EMarch, // March 01 2004 |
|
358 |
EJanuary, // January 01 2098 |
|
359 |
EJanuary // January 01 2099 |
|
360 |
}; |
|
361 |
||
362 |
LOCAL_D TInt testDayValid[KMaxValidDateTimes] = |
|
363 |
{ |
|
364 |
30, // December 31 1998 |
|
365 |
0, // January 01 1999 |
|
366 |
26, // February 27 1999 |
|
367 |
27, // February 28 1999 |
|
368 |
0, // March 01 1999 |
|
369 |
30, // August 31 1999 |
|
370 |
0, // September 01 1999 |
|
371 |
7, // September 08 1999 |
|
372 |
8, // September 09 1999 |
|
373 |
8, // September 09 1999 |
|
374 |
30, // December 31 1999 |
|
375 |
0, // January 01 2000 |
|
376 |
26, // February 27 2000 |
|
377 |
27, // February 28 2000 |
|
378 |
28, // February 29 2000 |
|
379 |
0, // March 01 2000 |
|
380 |
30, // December 31 2000 |
|
381 |
0, // January 01 2001 |
|
382 |
27, // February 28 2001 |
|
383 |
0, // March 01 2001 |
|
384 |
27, // February 28 2004 |
|
385 |
28, // February 29 2004 |
|
386 |
0, // March 01 2004 |
|
387 |
0, // January 01 2098 |
|
388 |
0 // January 01 2099 |
|
389 |
}; |
|
390 |
||
391 |
||
392 |
// Invalid dates to be tested for year 2000 compliance |
|
393 |
// Times are always set at 11.11.00 |
|
394 |
||
395 |
LOCAL_D TInt testYearInvalid[KMaxInvalidDateTimes] = |
|
396 |
{ |
|
397 |
1998, // April 31 1998 |
|
398 |
1999, // February 29 1999 |
|
399 |
2000, // February 30 2000 |
|
400 |
2001, // February 29 2001 |
|
401 |
2002, // February 29 2002 |
|
402 |
2003, // February 29 2003 |
|
403 |
2004, // February 30 2004 |
|
404 |
}; |
|
405 |
||
406 |
LOCAL_D TMonth testMonthInvalid[KMaxValidDateTimes] = |
|
407 |
{ |
|
408 |
EApril, // April 31 1998 |
|
409 |
EFebruary, // February 29 1999 |
|
410 |
EFebruary, // February 30 2000 |
|
411 |
EFebruary, // February 29 2001 |
|
412 |
EFebruary, // February 29 2002 |
|
413 |
EFebruary, // February 29 2003 |
|
414 |
EFebruary, // February 30 2004 |
|
415 |
}; |
|
416 |
||
417 |
LOCAL_D TInt testDayInvalid[KMaxValidDateTimes] = |
|
418 |
{ |
|
419 |
30, // April 31 1998 |
|
420 |
28, // February 29 1999 |
|
421 |
29, // February 30 2000 |
|
422 |
28, // February 29 2001 |
|
423 |
28, // February 29 2002 |
|
424 |
28, // February 29 2003 |
|
425 |
29, // February 30 2004 |
|
426 |
}; |
|
427 |
||
428 |
LOCAL_D TPtrC invalidDates[KMaxValidDateTimes] = |
|
429 |
{ |
|
430 |
_L("31st April 1998"), |
|
431 |
_L("29th February 1999"), |
|
432 |
_L("30th February 2000"), |
|
433 |
_L("29th February 2001"), |
|
434 |
_L("29th February 2002"), |
|
435 |
_L("29th February 2003"), |
|
436 |
_L("30th February 2004"), |
|
437 |
}; |
|
438 |
||
439 |
||
440 |
static void TestValidDates(TDateTime* aDateTime, TTime* aTime) |
|
441 |
// |
|
442 |
// Test an array of valid dates for year 2000 compliance |
|
443 |
// |
|
444 |
{ |
|
445 |
test.Next(_L("Test RFs::SetEntry() and RFs::Entry()")); |
|
446 |
||
447 |
TDateTime* tempDateTime=aDateTime; |
|
448 |
TTime* tempTime=aTime; |
|
449 |
TInt i=0; |
|
450 |
||
451 |
for (;i<KMaxValidDateTimes;i++) |
|
452 |
{ |
|
453 |
testRFsSetEntry(tempDateTime, tempTime, ETrue); |
|
454 |
tempDateTime++; |
|
455 |
tempTime++; |
|
456 |
} |
|
457 |
||
458 |
test.Next(_L("Test RFs::SetModified() and RFs::Modified()")); |
|
459 |
||
460 |
tempDateTime=aDateTime; |
|
461 |
tempTime=aTime; |
|
462 |
for (i=0;i<KMaxValidDateTimes;i++) |
|
463 |
{ |
|
464 |
testRFsSetModified(tempDateTime, tempTime, ETrue); |
|
465 |
tempDateTime++; |
|
466 |
tempTime++; |
|
467 |
} |
|
468 |
||
469 |
test.Next(_L("Test RFile::Set() and RFile::Modified()")); |
|
470 |
||
471 |
tempDateTime=aDateTime; |
|
472 |
tempTime=aTime; |
|
473 |
for (i=0;i<KMaxValidDateTimes;i++) |
|
474 |
{ |
|
475 |
testRFileSet(tempDateTime, tempTime, ETrue); |
|
476 |
tempDateTime++; |
|
477 |
tempTime++; |
|
478 |
} |
|
479 |
||
480 |
test.Next(_L("Test RFile::SetModified() and RFile::Modified()")); |
|
481 |
||
482 |
tempDateTime=aDateTime; |
|
483 |
tempTime=aTime; |
|
484 |
for (i=0;i<KMaxValidDateTimes;i++) |
|
485 |
{ |
|
486 |
testRFileSetModified(tempDateTime, tempTime, ETrue); |
|
487 |
tempDateTime++; |
|
488 |
tempTime++; |
|
489 |
} |
|
490 |
||
491 |
test.Next(_L("Test CFileMan::Attribs()")); |
|
492 |
tempDateTime=aDateTime; |
|
493 |
tempTime=aTime; |
|
494 |
for (i=0;i<KMaxValidDateTimes;i++) |
|
495 |
{ |
|
496 |
TRAPD(error,testCFileManAttribsL(tempDateTime, tempTime, ETrue)); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
497 |
test_KErrNone(error); |
0 | 498 |
tempDateTime++; |
499 |
tempTime++; |
|
500 |
} |
|
501 |
} |
|
502 |
||
503 |
||
504 |
static void TestInvalidDates(TDateTime* aDateTime, TTime* aTime) |
|
505 |
// |
|
506 |
// Test an array of invalid dates for year 2000 compliance |
|
507 |
// aDateTime is set as one day less than the desired invalid |
|
508 |
// date, because TDateTime correctly prevents us setting invalid dates |
|
509 |
// aTime is set to TDateTime + 1 day, which should be the next |
|
510 |
// correct date after TDateTime, NOT the desired invalid date |
|
511 |
// |
|
512 |
{ |
|
513 |
test.Next(_L("Test RFs::SetEntry() and RFs::Entry()")); |
|
514 |
||
515 |
TDateTime* tempDateTime=aDateTime; |
|
516 |
TTime* tempTime=aTime; |
|
517 |
TInt i=0; |
|
518 |
||
519 |
for (;i<KMaxInvalidDateTimes;i++) |
|
520 |
{ |
|
521 |
test.Printf(_L("Invalid date: %S\n"),&invalidDates[i]); |
|
522 |
testRFsSetEntry(tempDateTime, tempTime, EFalse); |
|
523 |
tempDateTime++; |
|
524 |
tempTime++; |
|
525 |
} |
|
526 |
||
527 |
test.Next(_L("Test RFs::SetModified() and RFs::Modified()")); |
|
528 |
||
529 |
tempDateTime=aDateTime; |
|
530 |
tempTime=aTime; |
|
531 |
for (i=0;i<KMaxInvalidDateTimes;i++) |
|
532 |
{ |
|
533 |
test.Printf(_L("Invalid date: %S\n"),&invalidDates[i]); |
|
534 |
testRFsSetModified(tempDateTime, tempTime, EFalse); |
|
535 |
tempDateTime++; |
|
536 |
tempTime++; |
|
537 |
} |
|
538 |
||
539 |
test.Next(_L("Test RFile::Set() and RFile::Modified()")); |
|
540 |
||
541 |
tempDateTime=aDateTime; |
|
542 |
tempTime=aTime; |
|
543 |
for (i=0;i<KMaxInvalidDateTimes;i++) |
|
544 |
{ |
|
545 |
test.Printf(_L("Invalid date: %S\n"),&invalidDates[i]); |
|
546 |
testRFileSet(tempDateTime, tempTime, EFalse); |
|
547 |
tempDateTime++; |
|
548 |
tempTime++; |
|
549 |
} |
|
550 |
||
551 |
test.Next(_L("Test RFile::SetModified() and RFile::Modified()")); |
|
552 |
||
553 |
tempDateTime=aDateTime; |
|
554 |
tempTime=aTime; |
|
555 |
for (i=0;i<KMaxInvalidDateTimes;i++) |
|
556 |
{ |
|
557 |
test.Printf(_L("Invalid date: %S\n"),&invalidDates[i]); |
|
558 |
testRFileSetModified(tempDateTime, tempTime, EFalse); |
|
559 |
tempDateTime++; |
|
560 |
tempTime++; |
|
561 |
} |
|
562 |
||
563 |
test.Next(_L("Test CFileMan::Attribs()")); |
|
564 |
tempDateTime=aDateTime; |
|
565 |
tempTime=aTime; |
|
566 |
for (i=0;i<KMaxInvalidDateTimes;i++) |
|
567 |
{ |
|
568 |
test.Printf(_L("Invalid date: %S\n"),&invalidDates[i]); |
|
569 |
TRAPD(error,testCFileManAttribsL(tempDateTime, tempTime, EFalse)); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
570 |
test_KErrNone(error); |
0 | 571 |
tempDateTime++; |
572 |
tempTime++; |
|
573 |
} |
|
574 |
} |
|
575 |
||
576 |
||
577 |
static void CallTests() |
|
578 |
// |
|
579 |
// Do tests relative to session path |
|
580 |
// |
|
581 |
{ |
|
582 |
||
583 |
// Set up an array of valid TDateTimes and TTimes to be tested for Y2K compliance |
|
584 |
||
585 |
TDateTime validDateTime[KMaxValidDateTimes]; |
|
586 |
TTime validTime[KMaxValidDateTimes]; |
|
587 |
TInt r; |
|
588 |
TInt i=0; |
|
589 |
||
590 |
for (;i<KMaxValidDateTimes;i++) |
|
591 |
{ |
|
592 |
// Dummy time is used to initialise validDateTime[i] before calling SetX() |
|
593 |
r=validDateTime[i].Set(1998,EJune,23,11,11,11,0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
594 |
test_KErrNone(r); |
0 | 595 |
r=validDateTime[i].SetYear(testYearValid[i]); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
596 |
test_KErrNone(r); |
0 | 597 |
r=validDateTime[i].SetMonth(testMonthValid[i]); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
598 |
test_KErrNone(r); |
0 | 599 |
r=validDateTime[i].SetDay(testDayValid[i]); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
600 |
test_KErrNone(r); |
0 | 601 |
validTime[i]=validDateTime[i]; |
602 |
} |
|
603 |
||
604 |
// Set up an array of invalid TDateTimes and TTimes to be tested for Y2K compliance |
|
605 |
||
606 |
TDateTime invalidDateTime[KMaxInvalidDateTimes]; |
|
607 |
TTime invalidTime[KMaxInvalidDateTimes]; |
|
608 |
TTimeIntervalDays extraDay(1); |
|
609 |
||
610 |
for (i=0;i<KMaxInvalidDateTimes;i++) |
|
611 |
{ |
|
612 |
// Dummy time is used to initialise validDateTime[i] before calling SetX() |
|
613 |
r=invalidDateTime[i].Set(1998,EJune,22,11,11,11,0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
614 |
test_KErrNone(r); |
0 | 615 |
r=invalidDateTime[i].SetYear(testYearInvalid[i]); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
616 |
test_KErrNone(r); |
0 | 617 |
r=invalidDateTime[i].SetMonth(testMonthInvalid[i]); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
618 |
test_KErrNone(r); |
0 | 619 |
r=invalidDateTime[i].SetDay(testDayInvalid[i]); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
620 |
test_Value(r, r == KErrGeneral); // This will fail because it is an invalid date |
0 | 621 |
r=invalidDateTime[i].SetDay(testDayInvalid[i]-1); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
622 |
test_KErrNone(r); // Set it one day less |
0 | 623 |
invalidTime[i]=invalidDateTime[i]; |
624 |
invalidTime[i]+=extraDay; // Add on an extra day. This should bump the |
|
625 |
} // date onto the next month, NOT set the day |
|
626 |
// to the invalid date in invalidDateTime[i] |
|
627 |
||
628 |
TestValidDates(&validDateTime[0],&validTime[0]); |
|
629 |
TestInvalidDates(&invalidDateTime[0],&invalidTime[0]); |
|
630 |
} |
|
631 |
||
632 |
GLDEF_C void CallTestsL(void) |
|
633 |
// |
|
634 |
// Do testing on aDrive |
|
635 |
// |
|
636 |
{ |
|
637 |
||
638 |
TInt r=TheFs.MkDirAll(_L("\\F32-TST\\YEAR 2000 TESTS\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
639 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 640 |
TRAP(r,CallTests()); |
641 |
if (r==KErrNone) |
|
642 |
TheFs.ResourceCountMarkEnd(); |
|
643 |
else |
|
644 |
{ |
|
645 |
test.Printf(_L("Error: Leave %d\n"),r); |
|
646 |
test(0); |
|
647 |
} |
|
648 |
r=TheFs.RmDir(_L("\\F32-TST\\YEAR 2000 TESTS\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
649 |
test_KErrNone(r); |
0 | 650 |
} |