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