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