os/ossrv/genericservices/taskscheduler/Test/Year2k/TC_TSCH_YEAR2000_HOMETIME.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 - hometime"));
    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().GetLocalTime().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, EFalse);
    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,EFalse);
    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, EFalse);
   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,EFalse);
   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-0273
   374 @SYMTestCaseDesc 			Year2000 replicated test, boundary test - Hometime
   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 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0273 "));
   383 	TDateTime dateTime(1998, EAugust, 1, 17, 0, 0, 0);
   384 	SetTime(dateTime);
   385 	TSchedulerItemRef ref;
   386 	TInt count = testCreateBoundarySchedule1(ref);
   387 	TInt taskId;
   388 	taskId = testScheduleTask(ref.iHandle);
   389 	doTestLoopL(ref.iHandle, count);
   390 	TInt res = TheScheduler.DeleteTask(taskId);
   391 	TEST2(res, KErrNone);
   392 	res = TheScheduler.DeleteSchedule(ref.iHandle);
   393 	TEST2(res, KErrNone);
   394 
   395 	SetTime(dateTime);
   396 	count = testCreateBoundarySchedule2(ref);
   397 	taskId = testScheduleTask(ref.iHandle);
   398 	doTestLoopL(ref.iHandle, count);
   399 	TheScheduler.DeleteTask(taskId);
   400 	TheScheduler.DeleteSchedule(ref.iHandle);
   401 	}
   402 
   403 LOCAL_D void doHourlyTimeSpanTestL()
   404 	{
   405 	TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0);
   406 	SetTime(dateTime);
   407 	TSchedulerItemRef ref;
   408 	TInt count = testCreateHourlyTimeSpanSchedule1(ref);
   409 	TInt taskId;
   410 	taskId = testScheduleTask(ref.iHandle);
   411 	doTestLoopL(ref.iHandle, count);
   412 	TInt res = TheScheduler.DeleteTask(taskId);
   413 	TEST2(res, KErrNone);
   414 	res = TheScheduler.DeleteSchedule(ref.iHandle);
   415 	TEST2(res, KErrNone);
   416 
   417 	TDateTime dt2(2000, EAugust,1,17,0,0,0);
   418 	SetTime(dt2);
   419 	count = testCreateHourlyTimeSpanSchedule2(ref);
   420 	taskId = testScheduleTask(ref.iHandle);
   421 	doTestLoopL(ref.iHandle, count);
   422 	TheScheduler.DeleteTask(taskId);
   423 	TheScheduler.DeleteSchedule(ref.iHandle);
   424 	}
   425 
   426 LOCAL_D void doDailyTimeSpanTestL()
   427 	{
   428 	TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0);
   429 	SetTime(dateTime);
   430 	TSchedulerItemRef ref;
   431 	TInt count = testCreateDailyTimeSpanSchedule1(ref);
   432 	TInt taskId;
   433 	taskId = testScheduleTask(ref.iHandle);
   434 	doTestLoopL(ref.iHandle, count);
   435 	TInt res = TheScheduler.DeleteTask(taskId);
   436 	TEST2(res, KErrNone);
   437 	res = TheScheduler.DeleteSchedule(ref.iHandle);
   438 	TEST2(res, KErrNone);
   439 
   440 	TDateTime dt2(2000, EAugust,1,17,0,0,0);
   441 	SetTime(dt2);
   442 	count = testCreateDailyTimeSpanSchedule2(ref);
   443 	taskId = testScheduleTask(ref.iHandle);
   444 	doTestLoopL(ref.iHandle, count);
   445 	TheScheduler.DeleteTask(taskId);
   446 	TheScheduler.DeleteSchedule(ref.iHandle);
   447 	}
   448 
   449 LOCAL_D void doMonthlyTimeSpanTestL()
   450 	{
   451 
   452 	TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0);
   453 	SetTime(dateTime);
   454 	TSchedulerItemRef ref;
   455 	TInt count = testCreateMonthlyTimeSpanSchedule1(ref);
   456 	TInt taskId;
   457 	taskId = testScheduleTask(ref.iHandle);
   458 	doTestLoopL(ref.iHandle, count);
   459 	TInt res = TheScheduler.DeleteTask(taskId);
   460 	TEST2(res, KErrNone);
   461 	res = TheScheduler.DeleteSchedule(ref.iHandle);
   462 	TEST2(res, KErrNone);
   463 
   464 	TDateTime dt2(2000, EAugust,1,17,0,0,0);
   465 	SetTime(dt2);
   466 	count = testCreateMonthlyTimeSpanSchedule2(ref);
   467 	taskId = testScheduleTask(ref.iHandle);
   468 	doTestLoopL(ref.iHandle, count);
   469 	TheScheduler.DeleteTask(taskId);
   470 	TheScheduler.DeleteSchedule(ref.iHandle);
   471 	}
   472 
   473 LOCAL_D void doYearlyTimeSpanTestL()
   474 	{
   475 
   476 	TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0);
   477 	SetTime(dateTime);
   478 	TSchedulerItemRef ref;
   479 	TInt count = testCreateYearlyTimeSpanSchedule1(ref);
   480 	TInt taskId;
   481 	taskId = testScheduleTask(ref.iHandle);
   482 	doTestLoopL(ref.iHandle, count);
   483 	TInt res = TheScheduler.DeleteTask(taskId);
   484 	TEST2(res, KErrNone);
   485 	res = TheScheduler.DeleteSchedule(ref.iHandle);
   486 	TEST2(res, KErrNone);
   487 
   488 	TDateTime dt2(2000, EAugust,1,17,0,0,0);
   489 	SetTime(dt2);
   490 	count = testCreateYearlyTimeSpanSchedule2(ref);
   491 	taskId = testScheduleTask(ref.iHandle);
   492 	doTestLoopL(ref.iHandle, count);
   493 	TheScheduler.DeleteTask(taskId);
   494 	TheScheduler.DeleteSchedule(ref.iHandle);
   495 	}
   496 
   497 /**
   498 @file
   499 @SYMTestCaseID				SYSLIB-SCHSVR-CT-0274
   500 @SYMTestCaseDesc 			Year2000 replicated test, time span test - Hometime
   501 @SYMTestPriority 			High
   502 @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
   503 @SYMTestExpectedResults		The test must not fail.
   504 @SYMPREQ					PREQ234
   505 */
   506 LOCAL_D void doTimeSpanTestL()
   507 
   508 	{
   509 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0274 "));
   510 	TheTest.Printf(_L("\nTesting time-spans...\n"));
   511 	TheTest.Printf(_L("Hourly time-spans...\n"));
   512 	doHourlyTimeSpanTestL();
   513 	TheTest.Printf(_L("Daily time-spans...\n"));
   514 	doDailyTimeSpanTestL();
   515 	TheTest.Printf(_L("Monthly time-spans...\n"));
   516 	doMonthlyTimeSpanTestL();
   517 	TheTest.Printf(_L("Yearly time-spans...\n"));
   518 	doYearlyTimeSpanTestL();
   519 	}
   520 
   521 static void DoTestsL()
   522 	{
   523 	TheTest.Next(_L("Delete old files"));
   524 	SchSvrHelpers::DeleteScheduleFilesL();
   525 
   526 	TheTest.Next(_L("Connect to Scheduler"));
   527 	TInt res=TheScheduler.Connect();
   528 	TEST2(res, KErrNone);
   529 
   530 	TheTest.Next(_L("Registering Client"));
   531 	res = SchSvrHelpers::RegisterClientL(TheScheduler);
   532 	TEST2(res, KErrNone);
   533 	
   534 	// Create exe Semaphore
   535 	STaskSemaphore sem;
   536 	sem.CreateL();
   537 
   538 	TheTest.Next(_L("Boundary/valid dates testing"));
   539 	doBoundaryTestL();
   540 	TheTest.Next(_L("Time span testing"));
   541 	doTimeSpanTestL();
   542 	
   543 	// close exe Semaphore
   544 	sem.Close();
   545 	
   546 	//Tidying up so next test will be clear.
   547 	TheTest.Next(_L("Delete all schedules"));
   548 	SchSvrHelpers::DeleteAllSchedulesL(TheScheduler);
   549  	TheScheduler.Close();	
   550 	}
   551 
   552 GLDEF_C TInt E32Main()
   553     {
   554 	__UHEAP_MARK;
   555 
   556 	CTrapCleanup* cleanup = CTrapCleanup::New();
   557 	TEST(cleanup != NULL);
   558 	
   559 	TEST2(TheFsSession.Connect(), KErrNone);
   560 
   561 	TheTest.Title();
   562 	TheTest.Start(_L("Year 2000 - hometime"));
   563 
   564 	//If the previous test fails, SCHSVR.exe may stay in memory.
   565 	TRAPD(err,CleanupHelpers::TestCleanupL());
   566 	TEST2(err, KErrNone);
   567 
   568 	TRAP(err, DoTestsL());
   569 	TEST2(err,KErrNone);
   570 	TRAP(err,CleanupHelpers::TestCleanupL());
   571 	TEST2(err, KErrNone);
   572 	
   573 	TheTest.End();
   574 	TheFsSession.Close();
   575 	TheTest.Close();
   576 	
   577 	delete cleanup;	
   578 
   579 	__UHEAP_MARKEND;
   580 	return KErrNone;
   581 	}