os/ossrv/genericservices/taskscheduler/Test/Year2k/TC_TSCH_YEAR2000_UTC.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2003-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 "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 //
    15 
    16 #include <e32base.h>
    17 #include <e32test.h>
    18 #include <csch_cli.h>
    19 #include <f32file.h>
    20 #include "Thelpers.h"
    21 #include "TestUtils.h"
    22 
    23 RTest TheTest(_L("TC_TSCH_YEAR2000 - UTC"));
    24 LOCAL_D RFs TheFsSession;
    25 
    26 LOCAL_D RScheduler TheScheduler;
    27 
    28 _LIT(KMinimalTaskHandler, "MinimalTaskHandler");
    29 
    30 LOCAL_D void SetTimeTo1SecBefore(TTsTime& aTime)
    31 	{
    32 	// TTsTime class can return UTC or Local time values.
    33 	// to ensure these are calculated based on the correct offset,
    34 	// use GetLocalTime() for local time based TTsTime values, 
    35 	// and GetUtcTime() for UTC based TTsTime values.		
    36  	
    37 	TTime time;
    38 	TTimeIntervalSeconds secs(1);
    39 	TBuf<30> dateString;
    40 	
    41 	// If time is UTC based, use UTC apis. If time is local time based, use local time APIs.
    42 	if(aTime.IsUtc())
    43 		{
    44 		time = aTime.GetUtcTime() - secs;
    45 		SchSvrHelpers::SetUTCTimeL(time);
    46 		
    47 		time.FormatL(dateString,(_L("%H%:1%T:%S %*E%*D %X%*N%Y %1 %2 %3")));
    48 		TheTest.Printf(_L("current UTC time: %S\n"), &dateString);
    49 		}
    50 	else	// due time is local time based
    51 		{
    52 		time = aTime.GetLocalTime() - secs;
    53 		SchSvrHelpers::SetHomeTimeL(time);
    54 		
    55 		time.FormatL(dateString,(_L("%H%:1%T:%S %*E%*D %X%*N%Y %1 %2 %3")));
    56 		TheTest.Printf(_L("current local time: %S\n"), &dateString);
    57 		}
    58 	}
    59 
    60 LOCAL_D void SetTime(TDateTime& aDateTime)
    61 	{
    62 	TTime time(aDateTime);
    63 	SchSvrHelpers::SetHomeTimeL(time);
    64 	}
    65 
    66 LOCAL_D TTsTime ShowDueTime(TInt aScheduleId)
    67 	{
    68 	TScheduleState2 state;
    69 	TTsTime dueTime;
    70 	CArrayFixFlat<TScheduleEntryInfo2>* entries = new CArrayFixFlat<TScheduleEntryInfo2> (3);
    71 	CArrayFixFlat<TTaskInfo>* tasks = new CArrayFixFlat<TTaskInfo> (3);
    72 	TInt res = TheScheduler.GetScheduleL(aScheduleId, state, *entries, *tasks, dueTime);
    73 	TEST2(res, KErrNone);
    74 
    75 	delete tasks;
    76 	delete entries;
    77 
    78 	TBuf<30> dateString;
    79 	state.DueTime().GetUtcTime().FormatL(dateString,(_L("%H%:1%T%*E%*D%X%*N%Y %1 %2 %3")));
    80 	TheTest.Printf(_L("due at:%S\n"), &dateString);
    81 	return state.DueTime();
    82 	}
    83 
    84 LOCAL_D void AppendHourlyEntry(CArrayFixFlat<TScheduleEntryInfo2>& aEntries, TInt aInterval,TInt aYear,
    85 							  TMonth aMonth, TInt aDay, TInt aHour, TInt aMinute)
    86 	{
    87 	TTime ttime(TDateTime(aYear, aMonth, aDay, aHour, aMinute, 0,0));
    88 	TTsTime startTime (ttime,ETrue);
    89 	TScheduleEntryInfo2 entry1 (startTime, EHourly, aInterval, 0);
    90 	aEntries.AppendL(entry1);
    91 	}
    92 
    93 LOCAL_D void AppendDailyEntry(CArrayFixFlat<TScheduleEntryInfo2>& aEntries, TInt aInterval,TInt aYear,
    94 							  TMonth aMonth, TInt aDay, TInt aHour, TInt aMinute)
    95 	{
    96 	TTime ttime(TDateTime(aYear, aMonth, aDay, aHour, aMinute, 0,0));
    97 	TTsTime startTime (ttime,ETrue);
    98 	TScheduleEntryInfo2 entry1 (startTime, EDaily, aInterval, 0);
    99 	aEntries.AppendL(entry1);
   100 	}
   101 
   102 LOCAL_D void AppendMonthlyEntry(CArrayFixFlat<TScheduleEntryInfo2>& aEntries, TInt aInterval,
   103 				TInt aYear, TMonth aMonth, TInt aDate, TInt aHour,TInt aMinute)
   104 	{
   105 	TTime ttime(TDateTime(aYear, aMonth, aDate, aHour, aMinute, 0,0));
   106 	TTsTime startTime (ttime,ETrue);
   107 	TScheduleEntryInfo2 entry1 (startTime, EMonthly, aInterval, 0);
   108 	aEntries.AppendL(entry1);
   109 	}
   110 
   111 LOCAL_D void AppendYearlyEntry(CArrayFixFlat<TScheduleEntryInfo2>& aEntries, TInt aInterval,
   112 				TInt aYear, TMonth aMonth,TInt aDate, TInt aHour, TInt aMinute)
   113 	{
   114 	TTime ttime(TDateTime(aYear, aMonth, aDate, aHour, aMinute, 0,0));
   115 	TTsTime startTime (ttime,ETrue);	
   116 	TScheduleEntryInfo2 entry1 (startTime, EYearly, aInterval, 0);
   117 	aEntries.AppendL(entry1);
   118 	}
   119 
   120 
   121 LOCAL_D TInt testCreateBoundarySchedule1(TSchedulerItemRef& aRef)
   122 	{
   123 	CArrayFixFlat<TScheduleEntryInfo2>* entryList;
   124 	entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
   125 	TName name(_L("and another off-peak"));
   126 	aRef.iName = name;
   127 
   128 //times post-boundary (to show boundary crossed properly)
   129 	AppendYearlyEntry(*entryList, 10, 1999, EJanuary, 0, 0, 0);
   130 	AppendYearlyEntry(*entryList, 10, 1999, EFebruary, 27, 0, 0);
   131 	AppendYearlyEntry(*entryList, 10, 1999, EMarch, 0, 0, 0);
   132 	AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 0, 0, 0);
   133 	AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 8, 0, 0);
   134 	AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 9, 0, 0);
   135 	AppendYearlyEntry(*entryList, 10, 2000, EJanuary, 0, 0, 0);
   136 	AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 27, 0, 0);
   137 	AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 28, 0, 0);
   138 	AppendYearlyEntry(*entryList, 10, 2000, EMarch, 0, 0, 0);
   139 	AppendYearlyEntry(*entryList, 10, 2001, EJanuary, 0, 0, 0);
   140 	AppendYearlyEntry(*entryList, 10, 2001, EMarch, 0, 0, 0);
   141 	AppendYearlyEntry(*entryList, 10, 2004, EFebruary, 28, 0, 0);
   142 	AppendYearlyEntry(*entryList, 10, 2004, EMarch, 0, 0, 0);
   143 
   144 	TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
   145 	TEST2(res, KErrNone);
   146 	TInt count = entryList->Count();
   147 	delete entryList;
   148 	return count;
   149 	}
   150 
   151 LOCAL_D TInt testCreateBoundarySchedule2(TSchedulerItemRef& aRef)
   152 	{
   153 	CArrayFixFlat<TScheduleEntryInfo2>* entryList;
   154 	entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
   155 	TName name(_L("and another off-peak"));
   156 	aRef.iName = name;
   157 
   158 	//times on pre-boundary dates(to show they're recognized as valid)
   159 	//commented-out lines are handled below
   160 	AppendYearlyEntry(*entryList, 10, 1998, EDecember, 30, 0, 0);
   161 	AppendYearlyEntry(*entryList, 10, 1999, EFebruary, 26, 0, 0);
   162 //	AppendYearlyEntry(*entryList, 10, 1999, EFebruary, 27, 0, 0);
   163 	AppendYearlyEntry(*entryList, 10, 1999, EAugust, 30, 0, 0);
   164 	AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 7, 0, 0);
   165 //	AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 8, 0, 0);
   166 	AppendYearlyEntry(*entryList, 10, 1999, EDecember, 30, 0, 0);
   167 	AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 26, 0, 0);
   168 //	AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 27, 0, 0);
   169 //	AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 28, 0, 0);
   170 	AppendYearlyEntry(*entryList, 10, 2000, EDecember, 30, 0, 0);
   171 	AppendYearlyEntry(*entryList, 10, 2001, EFebruary, 27, 0, 0);
   172 	AppendYearlyEntry(*entryList, 10, 2004, EFebruary, 27, 0, 0);
   173 	//AppendYearlyEntry(*entryList, 10, 2004, EFebruary, 28, 0, 0);
   174 	TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
   175 	TEST2(res, KErrNone);
   176 
   177 	TInt count = entryList->Count();
   178 	delete entryList;
   179 	return count;
   180 	}
   181 
   182 LOCAL_D TInt testCreateHourlyTimeSpanSchedule1(TSchedulerItemRef& aRef)
   183 	{
   184 	CArrayFixFlat<TScheduleEntryInfo2>* entryList;
   185 	entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
   186 	TName name(_L("and another off-peak"));
   187 	aRef.iName = name;
   188 
   189 	AppendHourlyEntry(*entryList, 213*24, 1999, EJune, 0, 0, 0);
   190 	AppendHourlyEntry(*entryList, 214*24, 1999, EJune, 0, 0, 0);
   191 	AppendHourlyEntry(*entryList, 273*24, 1999, EJune, 0, 0, 0);
   192 	AppendHourlyEntry(*entryList, 274*24, 1999, EJune, 0, 0, 0);
   193 	AppendHourlyEntry(*entryList, 305*24, 1999, EJune, 0, 0, 0);
   194 	AppendHourlyEntry(*entryList, 366*24, 1999, EJuly, 0, 0, 0);
   195 
   196 	TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
   197 	TEST2(res, KErrNone);
   198 
   199 	TInt count = entryList->Count();
   200 	delete entryList;
   201 	return count;
   202 	}
   203 
   204 LOCAL_D TInt testCreateHourlyTimeSpanSchedule2(TSchedulerItemRef& aRef)
   205 	{
   206 	CArrayFixFlat<TScheduleEntryInfo2>* entryList;
   207 	entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
   208 	TName name(_L("and another off-peak"));
   209 	aRef.iName = name;
   210 
   211 	AppendHourlyEntry(*entryList, 365*24, 2000, EAugust, 0, 0, 0);
   212 
   213 	TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
   214 	TEST2(res, KErrNone);
   215 	
   216 	TInt count = entryList->Count();
   217 	delete entryList;
   218 	return count;
   219 	}
   220 
   221 LOCAL_D TInt testCreateDailyTimeSpanSchedule1(TSchedulerItemRef& aRef)
   222 	{
   223 	CArrayFixFlat<TScheduleEntryInfo2>* entryList;
   224 	entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
   225 	TName name(_L("and another off-peak"));
   226 	aRef.iName = name;
   227 
   228 	AppendDailyEntry(*entryList, 213, 1999, EJune, 0, 0, 0);
   229 	AppendDailyEntry(*entryList, 214, 1999, EJune, 0, 0, 0);
   230 	AppendDailyEntry(*entryList, 273, 1999, EJune, 0, 0, 0);
   231 	AppendDailyEntry(*entryList, 274, 1999, EJune, 0, 0, 0);
   232 	AppendDailyEntry(*entryList, 305, 1999, EJune, 0, 0, 0);
   233 	AppendDailyEntry(*entryList, 366, 1999, EJuly, 0, 0, 0);
   234 
   235 	TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
   236 	TEST2(res, KErrNone);
   237 
   238 	TInt count = entryList->Count();
   239 	delete entryList;
   240 	return count;
   241 	}
   242 
   243 LOCAL_D TInt testCreateDailyTimeSpanSchedule2(TSchedulerItemRef& aRef)
   244 	{
   245 	CArrayFixFlat<TScheduleEntryInfo2>* entryList;
   246 	entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
   247 	TName name(_L("and another off-peak"));
   248 	aRef.iName = name;
   249 
   250 	AppendDailyEntry(*entryList, 365, 2000, EAugust, 0, 0, 0);
   251 
   252 	TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
   253 	TEST2(res, KErrNone);
   254 
   255 	TInt count = entryList->Count();
   256 	delete entryList;
   257 	return count;
   258 	}
   259 
   260 LOCAL_D TInt testCreateMonthlyTimeSpanSchedule1(TSchedulerItemRef& aRef)
   261 	{
   262 	CArrayFixFlat<TScheduleEntryInfo2>* entryList;
   263 	entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
   264 	TName name(_L("and another off-peak"));
   265 	aRef.iName = name;
   266 
   267 	AppendMonthlyEntry(*entryList, 7, 1999, EMay, 30, 0, 0);
   268 	AppendMonthlyEntry(*entryList, 7, 1999, EJune, 0, 0, 0);
   269 	AppendMonthlyEntry(*entryList, 8, 1999, EJune, 29, 0, 0);
   270 	AppendMonthlyEntry(*entryList, 8, 1999, EJuly, 0, 0, 0);
   271 	AppendMonthlyEntry(*entryList, 9, 1999, EJuly, 0, 0, 0);
   272 	AppendMonthlyEntry(*entryList, 12, 1999, EJuly, 0, 0, 0);
   273 
   274 	TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
   275 	TEST2(res, KErrNone);
   276 
   277 	TInt count = entryList->Count();
   278 	delete entryList;
   279 	return count;
   280 	}
   281 
   282 
   283 LOCAL_D TInt testCreateMonthlyTimeSpanSchedule2(TSchedulerItemRef& aRef)
   284 	{
   285 	CArrayFixFlat<TScheduleEntryInfo2>* entryList;
   286 	entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
   287 	TName name(_L("and another off-peak"));
   288 	aRef.iName = name;
   289 
   290 	AppendMonthlyEntry(*entryList, 12, 2000, EAugust, 0, 0, 0);
   291 
   292 	TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
   293 	TEST2(res, KErrNone);
   294 
   295 	TInt count = entryList->Count();
   296 	delete entryList;
   297 	return count;
   298 	}
   299 
   300 LOCAL_D TInt testCreateYearlyTimeSpanSchedule1(TSchedulerItemRef& aRef)
   301 	{
   302 	CArrayFixFlat<TScheduleEntryInfo2>* entryList;
   303 	entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
   304 	TName name(_L("and another off-peak"));
   305 	aRef.iName = name;
   306 
   307 	AppendYearlyEntry(*entryList, 1, 1998, EDecember, 30, 0, 0);
   308 	AppendYearlyEntry(*entryList, 1, 1999, EJanuary, 0, 0, 0);
   309 	AppendYearlyEntry(*entryList, 1, 1999, EFebruary, 27, 0, 0);
   310 	AppendYearlyEntry(*entryList, 1, 1999, EMarch, 0, 0, 0);
   311 	AppendYearlyEntry(*entryList, 1, 1999, EApril, 0, 0, 0);
   312 	AppendYearlyEntry(*entryList, 1, 1999, EJuly, 0, 0, 0);
   313 
   314 	TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
   315 	TEST2(res, KErrNone);
   316 
   317 	TInt count = entryList->Count();
   318 	delete entryList;
   319 	return count;
   320 	}
   321 
   322 
   323 LOCAL_D TInt testCreateYearlyTimeSpanSchedule2(TSchedulerItemRef& aRef)
   324 	{
   325 	CArrayFixFlat<TScheduleEntryInfo2>* entryList;
   326 	entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
   327 	TName name(_L("and another off-peak"));
   328 	aRef.iName = name;
   329 
   330 	AppendYearlyEntry(*entryList, 1, 2000, EAugust, 0, 0, 0);
   331 
   332 	TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
   333 	TEST2(res, KErrNone);
   334 
   335 	TInt count = entryList->Count();
   336 	delete entryList;
   337 	return count;
   338 	}
   339 
   340 
   341 LOCAL_D TInt testScheduleTask(TInt aScheduleId)
   342 	{
   343 	HBufC* data = HBufC::NewL(20);
   344 	*data = _L("the data");
   345 	TTaskInfo taskInfo;
   346 	taskInfo.iTaskId = 0;
   347 	taskInfo.iName = (_L("Y2K testing"));
   348 	taskInfo.iPriority = 2;
   349 	taskInfo.iRepeat = -1;
   350 	TInt res = TheScheduler.ScheduleTask(taskInfo, *data, aScheduleId);
   351 	TEST2(res, KErrNone);
   352 	delete data;
   353 	return taskInfo.iTaskId;
   354 	}
   355 
   356 LOCAL_D void doTestLoopL(TInt aId, TInt aCount)
   357 	{
   358 	TTsTime time = ShowDueTime(aId);
   359 	for (TInt i=0;i<aCount;i++)
   360 		{
   361 		SetTimeTo1SecBefore(time);
   362 		//wait for exe to launch
   363 		TEST2(STaskSemaphore::WaitL(KDefaultTimeout), KErrNone); 
   364 		CleanupHelpers::KillProcess(KMinimalTaskHandler);
   365 		//	
   366 		if (i<(aCount-1))//i.e. if it's going to execute
   367 			time = ShowDueTime(aId);
   368 		}
   369 	}
   370 
   371 /**
   372 @file
   373 @SYMTestCaseID				SYSLIB-SCHSVR-CT-0275
   374 @SYMTestCaseDesc 			Year2000 replicated test, boundary test - UTC
   375 @SYMTestPriority 			High
   376 @SYMTestActions  			Create a schedules, with one entry for each boundary pair & with a task to execute immediately after boundary set time to 5 seconds before each boundary, task should be executed in 5 seconds - also ensures all (pre-and-)post boundary times are valid, also reports the day on each of these dates
   377 @SYMTestExpectedResults		The test must not fail.
   378 @SYMPREQ					PREQ234
   379 */
   380 LOCAL_D void doBoundaryTestL()
   381 	{	
   382 	TDateTime dateTime(1998, EAugust, 1, 17, 0, 0, 0);
   383 	SetTime(dateTime);
   384 	TSchedulerItemRef ref;
   385 	TInt count = testCreateBoundarySchedule1(ref);
   386 	TInt taskId;
   387 	taskId = testScheduleTask(ref.iHandle);
   388 	doTestLoopL(ref.iHandle, count);
   389 	TInt res = TheScheduler.DeleteTask(taskId);
   390 	TEST2(res, KErrNone);
   391 	res = TheScheduler.DeleteSchedule(ref.iHandle);
   392 	TEST2(res, KErrNone);
   393 
   394 	SetTime(dateTime);
   395 	count = testCreateBoundarySchedule2(ref);
   396 	taskId = testScheduleTask(ref.iHandle);
   397 	doTestLoopL(ref.iHandle, count);
   398 	TheScheduler.DeleteTask(taskId);
   399 	TheScheduler.DeleteSchedule(ref.iHandle);
   400 	}
   401 
   402 LOCAL_D void doHourlyTimeSpanTestL()
   403 	{
   404 	TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0);
   405 	SetTime(dateTime);
   406 	TSchedulerItemRef ref;
   407 	TInt count = testCreateHourlyTimeSpanSchedule1(ref);
   408 	TInt taskId;
   409 	taskId = testScheduleTask(ref.iHandle);
   410 	doTestLoopL(ref.iHandle, count);
   411 	TInt res = TheScheduler.DeleteTask(taskId);
   412 	TEST2(res, KErrNone);
   413 	res = TheScheduler.DeleteSchedule(ref.iHandle);
   414 	TEST2(res, KErrNone);
   415 
   416 	TDateTime dt2(2000, EAugust,1,17,0,0,0);
   417 	SetTime(dt2);
   418 	count = testCreateHourlyTimeSpanSchedule2(ref);
   419 	taskId = testScheduleTask(ref.iHandle);
   420 	doTestLoopL(ref.iHandle, count);
   421 	TheScheduler.DeleteTask(taskId);
   422 	TheScheduler.DeleteSchedule(ref.iHandle);
   423 	}
   424 
   425 LOCAL_D void doDailyTimeSpanTestL()
   426 	{
   427 	TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0);
   428 	SetTime(dateTime);
   429 	TSchedulerItemRef ref;
   430 	TInt count = testCreateDailyTimeSpanSchedule1(ref);
   431 	TInt taskId;
   432 	taskId = testScheduleTask(ref.iHandle);
   433 	doTestLoopL(ref.iHandle, count);
   434 	TInt res = TheScheduler.DeleteTask(taskId);
   435 	TEST2(res, KErrNone);
   436 	res = TheScheduler.DeleteSchedule(ref.iHandle);
   437 	TEST2(res, KErrNone);
   438 
   439 	TDateTime dt2(2000, EAugust,1,17,0,0,0);
   440 	SetTime(dt2);
   441 	count = testCreateDailyTimeSpanSchedule2(ref);
   442 	taskId = testScheduleTask(ref.iHandle);
   443 	doTestLoopL(ref.iHandle, count);
   444 	TheScheduler.DeleteTask(taskId);
   445 	TheScheduler.DeleteSchedule(ref.iHandle);
   446 	}
   447 
   448 LOCAL_D void doMonthlyTimeSpanTestL()
   449 	{
   450 
   451 	TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0);
   452 	SetTime(dateTime);
   453 	TSchedulerItemRef ref;
   454 	TInt count = testCreateMonthlyTimeSpanSchedule1(ref);
   455 	TInt taskId;
   456 	taskId = testScheduleTask(ref.iHandle);
   457 	doTestLoopL(ref.iHandle, count);
   458 	TInt res = TheScheduler.DeleteTask(taskId);
   459 	TEST2(res, KErrNone);
   460 	res = TheScheduler.DeleteSchedule(ref.iHandle);
   461 	TEST2(res, KErrNone);
   462 
   463 	TDateTime dt2(2000, EAugust,1,17,0,0,0);
   464 	SetTime(dt2);
   465 	count = testCreateMonthlyTimeSpanSchedule2(ref);
   466 	taskId = testScheduleTask(ref.iHandle);
   467 	doTestLoopL(ref.iHandle, count);
   468 	TheScheduler.DeleteTask(taskId);
   469 	TheScheduler.DeleteSchedule(ref.iHandle);
   470 	}
   471 
   472 LOCAL_D void doYearlyTimeSpanTestL()
   473 	{
   474 
   475 	TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0);
   476 	SetTime(dateTime);
   477 	TSchedulerItemRef ref;
   478 	TInt count = testCreateYearlyTimeSpanSchedule1(ref);
   479 	TInt taskId;
   480 	taskId = testScheduleTask(ref.iHandle);
   481 	doTestLoopL(ref.iHandle, count);
   482 	TInt res = TheScheduler.DeleteTask(taskId);
   483 	TEST2(res, KErrNone);
   484 	res = TheScheduler.DeleteSchedule(ref.iHandle);
   485 	TEST2(res, KErrNone);
   486 
   487 	TDateTime dt2(2000, EAugust,1,17,0,0,0);
   488 	SetTime(dt2);
   489 	count = testCreateYearlyTimeSpanSchedule2(ref);
   490 	taskId = testScheduleTask(ref.iHandle);
   491 	doTestLoopL(ref.iHandle, count);
   492 	TheScheduler.DeleteTask(taskId);
   493 	TheScheduler.DeleteSchedule(ref.iHandle);
   494 	}
   495 
   496 /**
   497 @file
   498 @SYMTestCaseID				SYSLIB-SCHSVR-CT-0276
   499 @SYMTestCaseDesc 			Year2000 replicated test, time span test - UTC
   500 @SYMTestPriority 			High
   501 @SYMTestActions  			For each time-span, a set of schedules with the interval defined in terms of hours, days, weeks, months, whose interval=the time span: then set time to some time in between start of span & end: schedules should be next due at end of each respective time-span. Test time-spans measured in days & months. So, 1 schedule for each of these, including 1 entry for each span. Each entry starts at start of span, repeats at end(defined in terms of x days/weeks/months.). For each entry, set time to just before end of span, check it goes off
   502 @SYMTestExpectedResults		The test must not fail.
   503 @SYMPREQ					PREQ234
   504 */
   505 LOCAL_D void doTimeSpanTestL()
   506 	{	
   507 	TheTest.Printf(_L("\nTesting time-spans...\n"));
   508 	TheTest.Printf(_L("Hourly time-spans...\n"));
   509 	doHourlyTimeSpanTestL();
   510 	TheTest.Printf(_L("Daily time-spans...\n"));
   511 	doDailyTimeSpanTestL();
   512 	TheTest.Printf(_L("Monthly time-spans...\n"));
   513 	doMonthlyTimeSpanTestL();
   514 	TheTest.Printf(_L("Yearly time-spans...\n"));
   515 	doYearlyTimeSpanTestL();
   516 	}
   517 
   518 static void DoTestsL()
   519 	{
   520 	TheTest.Next(_L("Delete old files"));
   521 	SchSvrHelpers::DeleteScheduleFilesL();
   522 
   523 	TheTest.Next(_L("Connect to Scheduler"));
   524 	TInt res=TheScheduler.Connect();
   525 	TEST2(res, KErrNone);
   526 
   527 	TheTest.Next(_L("Registering Client"));
   528 	res = SchSvrHelpers::RegisterClientL(TheScheduler);
   529 	TEST2(res, KErrNone);
   530 	
   531 	// Create exe Semaphore
   532 	STaskSemaphore sem;
   533 	sem.CreateL();
   534 
   535 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0275 Boundary/valid dates testing "));
   536 	doBoundaryTestL();
   537 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0276 Time span testing "));
   538 	doTimeSpanTestL();
   539 	
   540 	// close exe Semaphore
   541 	sem.Close();
   542 	
   543 	//Tidying up so next test will be clear.
   544 	TheTest.Next(_L("Delete all schedules"));
   545 	SchSvrHelpers::DeleteAllSchedulesL(TheScheduler);
   546  	TheScheduler.Close();	
   547 	}
   548 
   549 GLDEF_C TInt E32Main()
   550     {
   551 	__UHEAP_MARK;
   552 
   553 	CTrapCleanup* cleanup = CTrapCleanup::New();
   554 	TEST(cleanup != NULL);
   555 	
   556 	TEST2(TheFsSession.Connect(), KErrNone);
   557 
   558 	TheTest.Title();
   559 	TheTest.Start(_L("Year 2000 - UTC"));
   560 
   561 	//If the previous test fails, SCHSVR.exe may stay in memory.
   562 	TRAPD(err,CleanupHelpers::TestCleanupL());
   563 	TEST2(err, KErrNone);
   564 
   565 	TRAP(err, DoTestsL());
   566 	TEST2(err,KErrNone);
   567 	TRAP(err,CleanupHelpers::TestCleanupL());
   568 	TEST2(err, KErrNone);
   569 	
   570 	TheTest.End();
   571 	TheFsSession.Close();
   572 	TheTest.Close();
   573 	
   574 	delete cleanup;	
   575 
   576 	__UHEAP_MARKEND;
   577 	return KErrNone;
   578 	}