1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericservices/taskscheduler/Test/Year2k/TC_TSCH_YEAR2000.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,643 @@
1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <e32base.h>
1.20 +#include <e32test.h>
1.21 +#include <csch_cli.h>
1.22 +#include <f32file.h>
1.23 +#include "Thelpers.h"
1.24 +#include "TestUtils.h"
1.25 +
1.26 +RTest TheTest(_L("TC_TSCH_YEAR2000"));
1.27 +LOCAL_D RFs TheFsSession;
1.28 +
1.29 +LOCAL_D RScheduler TheScheduler;
1.30 +
1.31 +_LIT(KMinimalTaskHandler, "MinimalTaskHandler");
1.32 +
1.33 +LOCAL_D void SetTimeTo1SecBefore(TTime& aTime)
1.34 + {
1.35 + TTimeIntervalSeconds secs(1);
1.36 + TTime time = aTime-secs;
1.37 + SchSvrHelpers::SetHomeTimeL(time);
1.38 + TBuf<30> dateString;
1.39 + time.FormatL(dateString,(_L("%H%:1%T:%S %*E%*D %X%*N%Y %1 %2 %3")));
1.40 + TheTest.Printf(_L("current time:%S\n"), &dateString);
1.41 + }
1.42 +
1.43 +LOCAL_D void SetTime(TDateTime& aDateTime)
1.44 + {
1.45 + TTime time(aDateTime);
1.46 + SchSvrHelpers::SetHomeTimeL(time);
1.47 + }
1.48 +
1.49 +LOCAL_D TTime ShowDueTime(TInt aScheduleId)
1.50 + {
1.51 + TScheduleState state;
1.52 + TTime dueTime;
1.53 + CArrayFixFlat<TScheduleEntryInfo>* entries = new CArrayFixFlat<TScheduleEntryInfo> (3);
1.54 + CArrayFixFlat<TTaskInfo>* tasks = new CArrayFixFlat<TTaskInfo> (3);
1.55 + TInt res = TheScheduler.GetScheduleL(aScheduleId, state, *entries, *tasks, dueTime);
1.56 + TEST2(res, KErrNone);
1.57 +
1.58 + delete tasks;
1.59 + delete entries;
1.60 +
1.61 + TBuf<30> dateString;
1.62 + state.iDueTime.FormatL(dateString,(_L("%H%:1%T%*E%*D%X%*N%Y %1 %2 %3")));
1.63 + TheTest.Printf(_L("due at:%S\n"), &dateString);
1.64 + return state.iDueTime;
1.65 + }
1.66 +
1.67 +LOCAL_D void AppendHourlyEntry(CArrayFixFlat<TScheduleEntryInfo>& aEntries, TInt aInterval,TInt aYear,
1.68 + TMonth aMonth, TInt aDay, TInt aHour, TInt aMinute)
1.69 + {
1.70 + TScheduleEntryInfo entry1;
1.71 + TTime time;
1.72 + time.HomeTime();
1.73 + TDateTime dateTime1 (aYear, aMonth, aDay, aHour, aMinute, 0,0);
1.74 + entry1.iStartTime = dateTime1;
1.75 + entry1.iInterval = aInterval;
1.76 + entry1.iIntervalType = EHourly;
1.77 + entry1.iValidityPeriod = 0;
1.78 + aEntries.AppendL(entry1);
1.79 + }
1.80 +
1.81 +LOCAL_D void AppendDailyEntry(CArrayFixFlat<TScheduleEntryInfo>& aEntries, TInt aInterval,TInt aYear,
1.82 + TMonth aMonth, TInt aDay, TInt aHour, TInt aMinute)
1.83 + {
1.84 + TScheduleEntryInfo entry1;
1.85 + TTime time;
1.86 + time.HomeTime();
1.87 + TDateTime dateTime1 (aYear, aMonth, aDay, aHour, aMinute, 0,0);
1.88 + entry1.iStartTime = dateTime1;
1.89 + entry1.iInterval = aInterval;
1.90 + entry1.iIntervalType = EDaily;
1.91 + entry1.iValidityPeriod = 0;
1.92 + aEntries.AppendL(entry1);
1.93 + }
1.94 +
1.95 +LOCAL_D void AppendMonthlyEntry(CArrayFixFlat<TScheduleEntryInfo>& aEntries, TInt aInterval,
1.96 + TInt aYear, TMonth aMonth, TInt aDate, TInt aHour,TInt aMinute)
1.97 + {
1.98 + TScheduleEntryInfo entry1;
1.99 + TTime time;
1.100 + time.HomeTime();
1.101 + TDateTime dateTime1 (aYear, aMonth, aDate, aHour, aMinute, 0,0);
1.102 + entry1.iStartTime = dateTime1;
1.103 + entry1.iInterval = aInterval;
1.104 + entry1.iIntervalType = EMonthly;
1.105 + entry1.iValidityPeriod = 0;
1.106 + aEntries.AppendL(entry1);
1.107 + }
1.108 +
1.109 +LOCAL_D void AppendYearlyEntry(CArrayFixFlat<TScheduleEntryInfo>& aEntries, TInt aInterval,
1.110 + TInt aYear, TMonth aMonth,TInt aDate, TInt aHour, TInt aMinute)
1.111 + {
1.112 + TScheduleEntryInfo entry1;
1.113 + TDateTime dateTime1 (aYear, aMonth, aDate, aHour, aMinute, 0,0);
1.114 + entry1.iStartTime = dateTime1;
1.115 + entry1.iInterval = aInterval;
1.116 + entry1.iIntervalType = EYearly;
1.117 + entry1.iValidityPeriod = 0;
1.118 + aEntries.AppendL(entry1);
1.119 + }
1.120 +
1.121 +
1.122 +LOCAL_D TInt testCreateBoundarySchedule1(TSchedulerItemRef& aRef)
1.123 + {
1.124 + CArrayFixFlat<TScheduleEntryInfo>* entryList;
1.125 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3);
1.126 + TName name(_L("and another off-peak"));
1.127 + aRef.iName = name;
1.128 +
1.129 +//times post-boundary (to show boundary crossed properly)
1.130 + AppendYearlyEntry(*entryList, 10, 1999, EJanuary, 0, 0, 0);
1.131 + AppendYearlyEntry(*entryList, 10, 1999, EFebruary, 27, 0, 0);
1.132 + AppendYearlyEntry(*entryList, 10, 1999, EMarch, 0, 0, 0);
1.133 + AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 0, 0, 0);
1.134 + AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 8, 0, 0);
1.135 + AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 9, 0, 0);
1.136 + AppendYearlyEntry(*entryList, 10, 2000, EJanuary, 0, 0, 0);
1.137 + AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 27, 0, 0);
1.138 + AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 28, 0, 0);
1.139 + AppendYearlyEntry(*entryList, 10, 2000, EMarch, 0, 0, 0);
1.140 + AppendYearlyEntry(*entryList, 10, 2001, EJanuary, 0, 0, 0);
1.141 + AppendYearlyEntry(*entryList, 10, 2001, EMarch, 0, 0, 0);
1.142 + AppendYearlyEntry(*entryList, 10, 2004, EFebruary, 28, 0, 0);
1.143 + AppendYearlyEntry(*entryList, 10, 2004, EMarch, 0, 0, 0);
1.144 +
1.145 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.146 + TEST2(res, KErrNone);
1.147 + TInt count = entryList->Count();
1.148 + delete entryList;
1.149 + return count;
1.150 + }
1.151 +
1.152 +LOCAL_D TInt testCreateBoundarySchedule2(TSchedulerItemRef& aRef)
1.153 + {
1.154 + CArrayFixFlat<TScheduleEntryInfo>* entryList;
1.155 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3);
1.156 + TName name(_L("and another off-peak"));
1.157 + aRef.iName = name;
1.158 +
1.159 + //times on pre-boundary dates(to show they're recognized as valid)
1.160 + //commented-out lines are handled below
1.161 + AppendYearlyEntry(*entryList, 10, 1998, EDecember, 30, 0, 0);
1.162 + AppendYearlyEntry(*entryList, 10, 1999, EFebruary, 26, 0, 0);
1.163 +// AppendYearlyEntry(*entryList, 10, 1999, EFebruary, 27, 0, 0);
1.164 + AppendYearlyEntry(*entryList, 10, 1999, EAugust, 30, 0, 0);
1.165 + AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 7, 0, 0);
1.166 +// AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 8, 0, 0);
1.167 + AppendYearlyEntry(*entryList, 10, 1999, EDecember, 30, 0, 0);
1.168 + AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 26, 0, 0);
1.169 +// AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 27, 0, 0);
1.170 +// AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 28, 0, 0);
1.171 + AppendYearlyEntry(*entryList, 10, 2000, EDecember, 30, 0, 0);
1.172 + AppendYearlyEntry(*entryList, 10, 2001, EFebruary, 27, 0, 0);
1.173 + AppendYearlyEntry(*entryList, 10, 2004, EFebruary, 27, 0, 0);
1.174 + //AppendYearlyEntry(*entryList, 10, 2004, EFebruary, 28, 0, 0);
1.175 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.176 + TEST2(res, KErrNone);
1.177 +
1.178 + TInt count = entryList->Count();
1.179 + delete entryList;
1.180 + return count;
1.181 + }
1.182 +
1.183 +LOCAL_D TInt testCreateHourlyTimeSpanSchedule1(TSchedulerItemRef& aRef)
1.184 + {
1.185 + CArrayFixFlat<TScheduleEntryInfo>* entryList;
1.186 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3);
1.187 + TName name(_L("and another off-peak"));
1.188 + aRef.iName = name;
1.189 +
1.190 + AppendHourlyEntry(*entryList, 213*24, 1999, EJune, 0, 0, 0);
1.191 + AppendHourlyEntry(*entryList, 214*24, 1999, EJune, 0, 0, 0);
1.192 + AppendHourlyEntry(*entryList, 273*24, 1999, EJune, 0, 0, 0);
1.193 + AppendHourlyEntry(*entryList, 274*24, 1999, EJune, 0, 0, 0);
1.194 + AppendHourlyEntry(*entryList, 305*24, 1999, EJune, 0, 0, 0);
1.195 + AppendHourlyEntry(*entryList, 366*24, 1999, EJuly, 0, 0, 0);
1.196 +
1.197 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.198 + TEST2(res, KErrNone);
1.199 +
1.200 + TInt count = entryList->Count();
1.201 + delete entryList;
1.202 + return count;
1.203 + }
1.204 +
1.205 +LOCAL_D TInt testCreateHourlyTimeSpanSchedule2(TSchedulerItemRef& aRef)
1.206 + {
1.207 + CArrayFixFlat<TScheduleEntryInfo>* entryList;
1.208 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3);
1.209 + TName name(_L("and another off-peak"));
1.210 + aRef.iName = name;
1.211 +
1.212 + AppendHourlyEntry(*entryList, 365*24, 2000, EAugust, 0, 0, 0);
1.213 +
1.214 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.215 + TEST2(res, KErrNone);
1.216 +
1.217 + TInt count = entryList->Count();
1.218 + delete entryList;
1.219 + return count;
1.220 + }
1.221 +
1.222 +LOCAL_D TInt testCreateDailyTimeSpanSchedule1(TSchedulerItemRef& aRef)
1.223 + {
1.224 + CArrayFixFlat<TScheduleEntryInfo>* entryList;
1.225 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3);
1.226 + TName name(_L("and another off-peak"));
1.227 + aRef.iName = name;
1.228 +
1.229 + AppendDailyEntry(*entryList, 213, 1999, EJune, 0, 0, 0);
1.230 + AppendDailyEntry(*entryList, 214, 1999, EJune, 0, 0, 0);
1.231 + AppendDailyEntry(*entryList, 273, 1999, EJune, 0, 0, 0);
1.232 + AppendDailyEntry(*entryList, 274, 1999, EJune, 0, 0, 0);
1.233 + AppendDailyEntry(*entryList, 305, 1999, EJune, 0, 0, 0);
1.234 + AppendDailyEntry(*entryList, 366, 1999, EJuly, 0, 0, 0);
1.235 +
1.236 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.237 + TEST2(res, KErrNone);
1.238 +
1.239 + TInt count = entryList->Count();
1.240 + delete entryList;
1.241 + return count;
1.242 + }
1.243 +
1.244 +LOCAL_D TInt testCreateDailyTimeSpanSchedule2(TSchedulerItemRef& aRef)
1.245 + {
1.246 + CArrayFixFlat<TScheduleEntryInfo>* entryList;
1.247 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3);
1.248 + TName name(_L("and another off-peak"));
1.249 + aRef.iName = name;
1.250 +
1.251 + AppendDailyEntry(*entryList, 365, 2000, EAugust, 0, 0, 0);
1.252 +
1.253 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.254 + TEST2(res, KErrNone);
1.255 +
1.256 + TInt count = entryList->Count();
1.257 + delete entryList;
1.258 + return count;
1.259 + }
1.260 +
1.261 +LOCAL_D TInt testCreateMonthlyTimeSpanSchedule1(TSchedulerItemRef& aRef)
1.262 + {
1.263 + CArrayFixFlat<TScheduleEntryInfo>* entryList;
1.264 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3);
1.265 + TName name(_L("and another off-peak"));
1.266 + aRef.iName = name;
1.267 +
1.268 + AppendMonthlyEntry(*entryList, 7, 1999, EMay, 30, 0, 0);
1.269 + AppendMonthlyEntry(*entryList, 7, 1999, EJune, 0, 0, 0);
1.270 + AppendMonthlyEntry(*entryList, 8, 1999, EJune, 29, 0, 0);
1.271 + AppendMonthlyEntry(*entryList, 8, 1999, EJuly, 0, 0, 0);
1.272 + AppendMonthlyEntry(*entryList, 9, 1999, EJuly, 0, 0, 0);
1.273 + AppendMonthlyEntry(*entryList, 12, 1999, EJuly, 0, 0, 0);
1.274 +
1.275 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.276 + TEST2(res, KErrNone);
1.277 +
1.278 + TInt count = entryList->Count();
1.279 + delete entryList;
1.280 + return count;
1.281 + }
1.282 +
1.283 +
1.284 +LOCAL_D TInt testCreateMonthlyTimeSpanSchedule2(TSchedulerItemRef& aRef)
1.285 + {
1.286 + CArrayFixFlat<TScheduleEntryInfo>* entryList;
1.287 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3);
1.288 + TName name(_L("and another off-peak"));
1.289 + aRef.iName = name;
1.290 +
1.291 + AppendMonthlyEntry(*entryList, 12, 2000, EAugust, 0, 0, 0);
1.292 +
1.293 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.294 + TEST2(res, KErrNone);
1.295 +
1.296 + TInt count = entryList->Count();
1.297 + delete entryList;
1.298 + return count;
1.299 + }
1.300 +
1.301 +LOCAL_D TInt testCreateYearlyTimeSpanSchedule1(TSchedulerItemRef& aRef)
1.302 + {
1.303 + CArrayFixFlat<TScheduleEntryInfo>* entryList;
1.304 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3);
1.305 + TName name(_L("and another off-peak"));
1.306 + aRef.iName = name;
1.307 +
1.308 + AppendYearlyEntry(*entryList, 1, 1998, EDecember, 30, 0, 0);
1.309 + AppendYearlyEntry(*entryList, 1, 1999, EJanuary, 0, 0, 0);
1.310 + AppendYearlyEntry(*entryList, 1, 1999, EFebruary, 27, 0, 0);
1.311 + AppendYearlyEntry(*entryList, 1, 1999, EMarch, 0, 0, 0);
1.312 + AppendYearlyEntry(*entryList, 1, 1999, EApril, 0, 0, 0);
1.313 + AppendYearlyEntry(*entryList, 1, 1999, EJuly, 0, 0, 0);
1.314 +
1.315 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.316 + TEST2(res, KErrNone);
1.317 +
1.318 + TInt count = entryList->Count();
1.319 + delete entryList;
1.320 + return count;
1.321 + }
1.322 +
1.323 +
1.324 +LOCAL_D TInt testCreateYearlyTimeSpanSchedule2(TSchedulerItemRef& aRef)
1.325 + {
1.326 + CArrayFixFlat<TScheduleEntryInfo>* entryList;
1.327 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3);
1.328 + TName name(_L("and another off-peak"));
1.329 + aRef.iName = name;
1.330 +
1.331 + AppendYearlyEntry(*entryList, 1, 2000, EAugust, 0, 0, 0);
1.332 +
1.333 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.334 + TEST2(res, KErrNone);
1.335 +
1.336 + TInt count = entryList->Count();
1.337 + delete entryList;
1.338 + return count;
1.339 + }
1.340 +
1.341 +
1.342 +LOCAL_D TInt testScheduleTask(TInt aScheduleId)
1.343 + {
1.344 + HBufC* data = HBufC::NewL(20);
1.345 + *data = _L("the data");
1.346 + TTaskInfo taskInfo;
1.347 + taskInfo.iTaskId = 0;
1.348 + taskInfo.iName = (_L("Y2K testing"));
1.349 + taskInfo.iPriority = 2;
1.350 + taskInfo.iRepeat = -1;
1.351 + TInt res = TheScheduler.ScheduleTask(taskInfo, *data, aScheduleId);
1.352 + TEST2(res, KErrNone);
1.353 + delete data;
1.354 + return taskInfo.iTaskId;
1.355 + }
1.356 +
1.357 +LOCAL_D void doTestLoopL(TInt aId, TInt aCount)
1.358 + {
1.359 + TTime time = ShowDueTime(aId);
1.360 + for (TInt i=0;i<aCount;i++)
1.361 + {
1.362 + SetTimeTo1SecBefore(time);
1.363 + //wait for exe to launch
1.364 + TEST2(STaskSemaphore::WaitL(KDefaultTimeout), KErrNone);
1.365 + CleanupHelpers::KillProcess(KMinimalTaskHandler);
1.366 + //
1.367 + if (i<(aCount-1))//i.e. if it's going to execute
1.368 + time = ShowDueTime(aId);
1.369 + }
1.370 + }
1.371 +
1.372 +/**
1.373 +@SYMTestCaseID SYSLIB-SCHSVR-CT-1029
1.374 +@SYMTestCaseDesc Tests for boundary/valid dates testing
1.375 +@SYMTestPriority High
1.376 +@SYMTestActions Create a schedules, with one entry for each boundary pair and with a task to execute
1.377 + immediately after boundary.Set time to 5 seconds before each boundary, task should be
1.378 + executed in 5 seconds.Ensure pre and post boundary times are valid.
1.379 + also reports the day on each of these dates
1.380 + Expected output:
1.381 + due at:Thu 31 Dec 1998
1.382 + press any key to continue"
1.383 + -then task should execute in 2 seconds
1.384 + due at:Fri 1 Jan 1999
1.385 + press any key to continue"
1.386 + -then task should execute in 2 seconds
1.387 + due at:Sat 27 Feb 1999
1.388 + press any key to continue"
1.389 + -task in 2 seconds
1.390 + etc etc for all times listed in doc
1.391 +@SYMTestExpectedResults Test must not fail
1.392 +@SYMREQ REQ0000
1.393 +*/
1.394 +LOCAL_D void doBoundaryTestL()
1.395 +//*3.4.1.1 -create a schedules, with one entry for each boundary pair,
1.396 +// & with a task to execute immediately after boundary
1.397 +// set time to 5 seconds before each boundary, task should be executed in 5 seconds
1.398 +//*3.4.2.1 -also ensures all (pre-and-)post boundary times are valid
1.399 +//*3.4.2.4.8-also reports the day on each of these dates
1.400 +
1.401 +//expected output:
1.402 +//
1.403 +//"due at:Thu 31 Dec 1998
1.404 +//press any key to continue"
1.405 +// -then task should execute in 2 seconds
1.406 +//"due at:Fri 1 Jan 1999
1.407 +//press any key to continue"
1.408 +// -then task should execute in 2 seconds
1.409 +//"due at:Sat 27 Feb 1999
1.410 +//press any key to continue"
1.411 +// -task in 2 seconds
1.412 +//etc etc for all times listed in doc
1.413 + {
1.414 +
1.415 + TDateTime dateTime(1998, EAugust, 1, 17, 0, 0, 0);
1.416 + SetTime(dateTime);
1.417 + TSchedulerItemRef ref;
1.418 + TInt count = testCreateBoundarySchedule1(ref);
1.419 + TInt taskId;
1.420 + taskId = testScheduleTask(ref.iHandle);
1.421 + doTestLoopL(ref.iHandle, count);
1.422 + TInt res = TheScheduler.DeleteTask(taskId);
1.423 + TEST2(res, KErrNone);
1.424 + res = TheScheduler.DeleteSchedule(ref.iHandle);
1.425 + TEST2(res, KErrNone);
1.426 +
1.427 + SetTime(dateTime);
1.428 + count = testCreateBoundarySchedule2(ref);
1.429 + taskId = testScheduleTask(ref.iHandle);
1.430 + doTestLoopL(ref.iHandle, count);
1.431 + TheScheduler.DeleteTask(taskId);
1.432 + TheScheduler.DeleteSchedule(ref.iHandle);
1.433 + }
1.434 +/**
1.435 +@SYMTestCaseID SYSLIB-SCHSVR-CT-1030
1.436 +@SYMTestCaseDesc Tests for hourly time span test
1.437 +@SYMTestPriority High
1.438 +@SYMTestActions Create a hourly time span schedule and execute the test
1.439 +@SYMTestExpectedResults Test must not fail
1.440 +@SYMREQ REQ0000
1.441 +*/
1.442 +LOCAL_D void doHourlyTimeSpanTestL()
1.443 + {
1.444 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1030 "));
1.445 + TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0);
1.446 + SetTime(dateTime);
1.447 + TSchedulerItemRef ref;
1.448 + TInt count = testCreateHourlyTimeSpanSchedule1(ref);
1.449 + TInt taskId;
1.450 + taskId = testScheduleTask(ref.iHandle);
1.451 + doTestLoopL(ref.iHandle, count);
1.452 + TInt res = TheScheduler.DeleteTask(taskId);
1.453 + TEST2(res, KErrNone);
1.454 + res = TheScheduler.DeleteSchedule(ref.iHandle);
1.455 + TEST2(res, KErrNone);
1.456 +
1.457 + TDateTime dt2(2000, EAugust,1,17,0,0,0);
1.458 + SetTime(dt2);
1.459 + count = testCreateHourlyTimeSpanSchedule2(ref);
1.460 + taskId = testScheduleTask(ref.iHandle);
1.461 + doTestLoopL(ref.iHandle, count);
1.462 + TheScheduler.DeleteTask(taskId);
1.463 + TheScheduler.DeleteSchedule(ref.iHandle);
1.464 + }
1.465 +
1.466 +/**
1.467 +@SYMTestCaseID SYSLIB-SCHSVR-CT-1338
1.468 +@SYMTestCaseDesc Tests for daily time span test
1.469 +@SYMTestPriority High
1.470 +@SYMTestActions Create a daily time span schedule and execute the test
1.471 +@SYMTestExpectedResults Test must not fail
1.472 +@SYMREQ REQ0000
1.473 +*/
1.474 +LOCAL_D void doDailyTimeSpanTestL()
1.475 + {
1.476 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1338 "));
1.477 + TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0);
1.478 + SetTime(dateTime);
1.479 + TSchedulerItemRef ref;
1.480 + TInt count = testCreateDailyTimeSpanSchedule1(ref);
1.481 + TInt taskId;
1.482 + taskId = testScheduleTask(ref.iHandle);
1.483 + doTestLoopL(ref.iHandle, count);
1.484 + TInt res = TheScheduler.DeleteTask(taskId);
1.485 + TEST2(res, KErrNone);
1.486 + res = TheScheduler.DeleteSchedule(ref.iHandle);
1.487 + TEST2(res, KErrNone);
1.488 +
1.489 + TDateTime dt2(2000, EAugust,1,17,0,0,0);
1.490 + SetTime(dt2);
1.491 + count = testCreateDailyTimeSpanSchedule2(ref);
1.492 + taskId = testScheduleTask(ref.iHandle);
1.493 + doTestLoopL(ref.iHandle, count);
1.494 + TheScheduler.DeleteTask(taskId);
1.495 + TheScheduler.DeleteSchedule(ref.iHandle);
1.496 + }
1.497 +
1.498 +/**
1.499 +@SYMTestCaseID SYSLIB-SCHSVR-CT-1339
1.500 +@SYMTestCaseDesc Tests for monthly time span test
1.501 +@SYMTestPriority High
1.502 +@SYMTestActions Create a monthly time span schedule and execute the test
1.503 +@SYMTestExpectedResults Test must not fail
1.504 +@SYMREQ REQ0000
1.505 +*/
1.506 +LOCAL_D void doMonthlyTimeSpanTestL()
1.507 + {
1.508 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1339 "));
1.509 +
1.510 + TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0);
1.511 + SetTime(dateTime);
1.512 + TSchedulerItemRef ref;
1.513 + TInt count = testCreateMonthlyTimeSpanSchedule1(ref);
1.514 + TInt taskId;
1.515 + taskId = testScheduleTask(ref.iHandle);
1.516 + doTestLoopL(ref.iHandle, count);
1.517 + TInt res = TheScheduler.DeleteTask(taskId);
1.518 + TEST2(res, KErrNone);
1.519 + res = TheScheduler.DeleteSchedule(ref.iHandle);
1.520 + TEST2(res, KErrNone);
1.521 +
1.522 + TDateTime dt2(2000, EAugust,1,17,0,0,0);
1.523 + SetTime(dt2);
1.524 + count = testCreateMonthlyTimeSpanSchedule2(ref);
1.525 + taskId = testScheduleTask(ref.iHandle);
1.526 + doTestLoopL(ref.iHandle, count);
1.527 + TheScheduler.DeleteTask(taskId);
1.528 + TheScheduler.DeleteSchedule(ref.iHandle);
1.529 + }
1.530 +
1.531 +/**
1.532 +@SYMTestCaseID SYSLIB-SCHSVR-CT-1340
1.533 +@SYMTestCaseDesc Tests for yearly time span test
1.534 +@SYMTestPriority High
1.535 +@SYMTestActions Create a yearly time span schedule and execute the test
1.536 +@SYMTestExpectedResults Test must not fail
1.537 +@SYMREQ REQ0000
1.538 +*/
1.539 +LOCAL_D void doYearlyTimeSpanTestL()
1.540 + {
1.541 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1340 "));
1.542 +
1.543 + TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0);
1.544 + SetTime(dateTime);
1.545 + TSchedulerItemRef ref;
1.546 + TInt count = testCreateYearlyTimeSpanSchedule1(ref);
1.547 + TInt taskId;
1.548 + taskId = testScheduleTask(ref.iHandle);
1.549 + doTestLoopL(ref.iHandle, count);
1.550 + TInt res = TheScheduler.DeleteTask(taskId);
1.551 + TEST2(res, KErrNone);
1.552 + res = TheScheduler.DeleteSchedule(ref.iHandle);
1.553 + TEST2(res, KErrNone);
1.554 +
1.555 + TDateTime dt2(2000, EAugust,1,17,0,0,0);
1.556 + SetTime(dt2);
1.557 + count = testCreateYearlyTimeSpanSchedule2(ref);
1.558 + taskId = testScheduleTask(ref.iHandle);
1.559 + doTestLoopL(ref.iHandle, count);
1.560 + TheScheduler.DeleteTask(taskId);
1.561 + TheScheduler.DeleteSchedule(ref.iHandle);
1.562 + }
1.563 +
1.564 +LOCAL_D void doTimeSpanTestL()
1.565 +//*3.4.2.7 -for each time-span, a set of schedules with the interval defined in terms of
1.566 +// hours, days, weeks, months, whose interval=the time span: then set time to some
1.567 +// time in between start of span & end: schedules should be next due at end of each
1.568 +// respective time-span
1.569 +
1.570 +// -test time-spans measured in days & months.
1.571 +// -so, 1 schedule for each of these, including 1 entry for each span.
1.572 +// -each entry starts at start of span, repeats at end(defined in terms of x days/weeks/months.)
1.573 +// -for each entry, set time to just before end of span, check it goes off
1.574 + {
1.575 + TheTest.Printf(_L("\nTesting time-spans...\n"));
1.576 + TheTest.Printf(_L("Hourly time-spans...\n"));
1.577 + doHourlyTimeSpanTestL();
1.578 + TheTest.Printf(_L("Daily time-spans...\n"));
1.579 + doDailyTimeSpanTestL();
1.580 + TheTest.Printf(_L("Monthly time-spans...\n"));
1.581 + doMonthlyTimeSpanTestL();
1.582 + TheTest.Printf(_L("Yearly time-spans...\n"));
1.583 + doYearlyTimeSpanTestL();
1.584 + }
1.585 +
1.586 +static void DoTestsL()
1.587 + {
1.588 + TheTest.Next(_L("Delete old files"));
1.589 + SchSvrHelpers::DeleteScheduleFilesL();
1.590 +
1.591 + TheTest.Next(_L("Connect to Scheduler"));
1.592 + TInt res=TheScheduler.Connect();
1.593 + TEST2(res, KErrNone);
1.594 +
1.595 + TheTest.Next(_L("Registering Client"));
1.596 + res = SchSvrHelpers::RegisterClientL(TheScheduler);
1.597 + TEST2(res, KErrNone);
1.598 +
1.599 + // Create exe Semaphore
1.600 + STaskSemaphore sem;
1.601 + sem.CreateL();
1.602 +
1.603 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1029 Boundary/valid dates testing"));
1.604 + doBoundaryTestL();
1.605 + TheTest.Next(_L("Time span testing"));
1.606 + doTimeSpanTestL();
1.607 +
1.608 + // close exe Semaphore
1.609 + sem.Close();
1.610 +
1.611 + //Tidying up so next test will be clear.
1.612 + TheTest.Next(_L("Delete all schedules"));
1.613 + SchSvrHelpers::DeleteAllSchedulesL(TheScheduler);
1.614 + TheScheduler.Close();
1.615 + }
1.616 +
1.617 +GLDEF_C TInt E32Main()
1.618 + {
1.619 + __UHEAP_MARK;
1.620 +
1.621 + CTrapCleanup* cleanup = CTrapCleanup::New();
1.622 + TEST(cleanup != NULL);
1.623 +
1.624 + TEST2(TheFsSession.Connect(), KErrNone);
1.625 +
1.626 + TheTest.Title();
1.627 + TheTest.Start(_L("Year 2000"));
1.628 +
1.629 + //If the previous test fails, SCHSVR.exe may stay in memory.
1.630 + TRAPD(err,CleanupHelpers::TestCleanupL());
1.631 + TEST2(err, KErrNone);
1.632 +
1.633 + TRAP(err, DoTestsL());
1.634 + TEST2(err,KErrNone);
1.635 + TRAP(err,CleanupHelpers::TestCleanupL());
1.636 + TEST2(err, KErrNone);
1.637 +
1.638 + TheTest.End();
1.639 + TheFsSession.Close();
1.640 + TheTest.Close();
1.641 +
1.642 + delete cleanup;
1.643 +
1.644 + __UHEAP_MARKEND;
1.645 + return KErrNone;
1.646 + }