1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericservices/taskscheduler/Test/Year2k/TC_TSCH_YEAR2000_UTC.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,578 @@
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 - UTC"));
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(TTsTime& aTime)
1.34 + {
1.35 + // TTsTime class can return UTC or Local time values.
1.36 + // to ensure these are calculated based on the correct offset,
1.37 + // use GetLocalTime() for local time based TTsTime values,
1.38 + // and GetUtcTime() for UTC based TTsTime values.
1.39 +
1.40 + TTime time;
1.41 + TTimeIntervalSeconds secs(1);
1.42 + TBuf<30> dateString;
1.43 +
1.44 + // If time is UTC based, use UTC apis. If time is local time based, use local time APIs.
1.45 + if(aTime.IsUtc())
1.46 + {
1.47 + time = aTime.GetUtcTime() - secs;
1.48 + SchSvrHelpers::SetUTCTimeL(time);
1.49 +
1.50 + time.FormatL(dateString,(_L("%H%:1%T:%S %*E%*D %X%*N%Y %1 %2 %3")));
1.51 + TheTest.Printf(_L("current UTC time: %S\n"), &dateString);
1.52 + }
1.53 + else // due time is local time based
1.54 + {
1.55 + time = aTime.GetLocalTime() - secs;
1.56 + SchSvrHelpers::SetHomeTimeL(time);
1.57 +
1.58 + time.FormatL(dateString,(_L("%H%:1%T:%S %*E%*D %X%*N%Y %1 %2 %3")));
1.59 + TheTest.Printf(_L("current local time: %S\n"), &dateString);
1.60 + }
1.61 + }
1.62 +
1.63 +LOCAL_D void SetTime(TDateTime& aDateTime)
1.64 + {
1.65 + TTime time(aDateTime);
1.66 + SchSvrHelpers::SetHomeTimeL(time);
1.67 + }
1.68 +
1.69 +LOCAL_D TTsTime ShowDueTime(TInt aScheduleId)
1.70 + {
1.71 + TScheduleState2 state;
1.72 + TTsTime dueTime;
1.73 + CArrayFixFlat<TScheduleEntryInfo2>* entries = new CArrayFixFlat<TScheduleEntryInfo2> (3);
1.74 + CArrayFixFlat<TTaskInfo>* tasks = new CArrayFixFlat<TTaskInfo> (3);
1.75 + TInt res = TheScheduler.GetScheduleL(aScheduleId, state, *entries, *tasks, dueTime);
1.76 + TEST2(res, KErrNone);
1.77 +
1.78 + delete tasks;
1.79 + delete entries;
1.80 +
1.81 + TBuf<30> dateString;
1.82 + state.DueTime().GetUtcTime().FormatL(dateString,(_L("%H%:1%T%*E%*D%X%*N%Y %1 %2 %3")));
1.83 + TheTest.Printf(_L("due at:%S\n"), &dateString);
1.84 + return state.DueTime();
1.85 + }
1.86 +
1.87 +LOCAL_D void AppendHourlyEntry(CArrayFixFlat<TScheduleEntryInfo2>& aEntries, TInt aInterval,TInt aYear,
1.88 + TMonth aMonth, TInt aDay, TInt aHour, TInt aMinute)
1.89 + {
1.90 + TTime ttime(TDateTime(aYear, aMonth, aDay, aHour, aMinute, 0,0));
1.91 + TTsTime startTime (ttime,ETrue);
1.92 + TScheduleEntryInfo2 entry1 (startTime, EHourly, aInterval, 0);
1.93 + aEntries.AppendL(entry1);
1.94 + }
1.95 +
1.96 +LOCAL_D void AppendDailyEntry(CArrayFixFlat<TScheduleEntryInfo2>& aEntries, TInt aInterval,TInt aYear,
1.97 + TMonth aMonth, TInt aDay, TInt aHour, TInt aMinute)
1.98 + {
1.99 + TTime ttime(TDateTime(aYear, aMonth, aDay, aHour, aMinute, 0,0));
1.100 + TTsTime startTime (ttime,ETrue);
1.101 + TScheduleEntryInfo2 entry1 (startTime, EDaily, aInterval, 0);
1.102 + aEntries.AppendL(entry1);
1.103 + }
1.104 +
1.105 +LOCAL_D void AppendMonthlyEntry(CArrayFixFlat<TScheduleEntryInfo2>& aEntries, TInt aInterval,
1.106 + TInt aYear, TMonth aMonth, TInt aDate, TInt aHour,TInt aMinute)
1.107 + {
1.108 + TTime ttime(TDateTime(aYear, aMonth, aDate, aHour, aMinute, 0,0));
1.109 + TTsTime startTime (ttime,ETrue);
1.110 + TScheduleEntryInfo2 entry1 (startTime, EMonthly, aInterval, 0);
1.111 + aEntries.AppendL(entry1);
1.112 + }
1.113 +
1.114 +LOCAL_D void AppendYearlyEntry(CArrayFixFlat<TScheduleEntryInfo2>& aEntries, TInt aInterval,
1.115 + TInt aYear, TMonth aMonth,TInt aDate, TInt aHour, TInt aMinute)
1.116 + {
1.117 + TTime ttime(TDateTime(aYear, aMonth, aDate, aHour, aMinute, 0,0));
1.118 + TTsTime startTime (ttime,ETrue);
1.119 + TScheduleEntryInfo2 entry1 (startTime, EYearly, aInterval, 0);
1.120 + aEntries.AppendL(entry1);
1.121 + }
1.122 +
1.123 +
1.124 +LOCAL_D TInt testCreateBoundarySchedule1(TSchedulerItemRef& aRef)
1.125 + {
1.126 + CArrayFixFlat<TScheduleEntryInfo2>* entryList;
1.127 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
1.128 + TName name(_L("and another off-peak"));
1.129 + aRef.iName = name;
1.130 +
1.131 +//times post-boundary (to show boundary crossed properly)
1.132 + AppendYearlyEntry(*entryList, 10, 1999, EJanuary, 0, 0, 0);
1.133 + AppendYearlyEntry(*entryList, 10, 1999, EFebruary, 27, 0, 0);
1.134 + AppendYearlyEntry(*entryList, 10, 1999, EMarch, 0, 0, 0);
1.135 + AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 0, 0, 0);
1.136 + AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 8, 0, 0);
1.137 + AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 9, 0, 0);
1.138 + AppendYearlyEntry(*entryList, 10, 2000, EJanuary, 0, 0, 0);
1.139 + AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 27, 0, 0);
1.140 + AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 28, 0, 0);
1.141 + AppendYearlyEntry(*entryList, 10, 2000, EMarch, 0, 0, 0);
1.142 + AppendYearlyEntry(*entryList, 10, 2001, EJanuary, 0, 0, 0);
1.143 + AppendYearlyEntry(*entryList, 10, 2001, EMarch, 0, 0, 0);
1.144 + AppendYearlyEntry(*entryList, 10, 2004, EFebruary, 28, 0, 0);
1.145 + AppendYearlyEntry(*entryList, 10, 2004, EMarch, 0, 0, 0);
1.146 +
1.147 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.148 + TEST2(res, KErrNone);
1.149 + TInt count = entryList->Count();
1.150 + delete entryList;
1.151 + return count;
1.152 + }
1.153 +
1.154 +LOCAL_D TInt testCreateBoundarySchedule2(TSchedulerItemRef& aRef)
1.155 + {
1.156 + CArrayFixFlat<TScheduleEntryInfo2>* entryList;
1.157 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
1.158 + TName name(_L("and another off-peak"));
1.159 + aRef.iName = name;
1.160 +
1.161 + //times on pre-boundary dates(to show they're recognized as valid)
1.162 + //commented-out lines are handled below
1.163 + AppendYearlyEntry(*entryList, 10, 1998, EDecember, 30, 0, 0);
1.164 + AppendYearlyEntry(*entryList, 10, 1999, EFebruary, 26, 0, 0);
1.165 +// AppendYearlyEntry(*entryList, 10, 1999, EFebruary, 27, 0, 0);
1.166 + AppendYearlyEntry(*entryList, 10, 1999, EAugust, 30, 0, 0);
1.167 + AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 7, 0, 0);
1.168 +// AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 8, 0, 0);
1.169 + AppendYearlyEntry(*entryList, 10, 1999, EDecember, 30, 0, 0);
1.170 + AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 26, 0, 0);
1.171 +// AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 27, 0, 0);
1.172 +// AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 28, 0, 0);
1.173 + AppendYearlyEntry(*entryList, 10, 2000, EDecember, 30, 0, 0);
1.174 + AppendYearlyEntry(*entryList, 10, 2001, EFebruary, 27, 0, 0);
1.175 + AppendYearlyEntry(*entryList, 10, 2004, EFebruary, 27, 0, 0);
1.176 + //AppendYearlyEntry(*entryList, 10, 2004, EFebruary, 28, 0, 0);
1.177 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.178 + TEST2(res, KErrNone);
1.179 +
1.180 + TInt count = entryList->Count();
1.181 + delete entryList;
1.182 + return count;
1.183 + }
1.184 +
1.185 +LOCAL_D TInt testCreateHourlyTimeSpanSchedule1(TSchedulerItemRef& aRef)
1.186 + {
1.187 + CArrayFixFlat<TScheduleEntryInfo2>* entryList;
1.188 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
1.189 + TName name(_L("and another off-peak"));
1.190 + aRef.iName = name;
1.191 +
1.192 + AppendHourlyEntry(*entryList, 213*24, 1999, EJune, 0, 0, 0);
1.193 + AppendHourlyEntry(*entryList, 214*24, 1999, EJune, 0, 0, 0);
1.194 + AppendHourlyEntry(*entryList, 273*24, 1999, EJune, 0, 0, 0);
1.195 + AppendHourlyEntry(*entryList, 274*24, 1999, EJune, 0, 0, 0);
1.196 + AppendHourlyEntry(*entryList, 305*24, 1999, EJune, 0, 0, 0);
1.197 + AppendHourlyEntry(*entryList, 366*24, 1999, EJuly, 0, 0, 0);
1.198 +
1.199 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.200 + TEST2(res, KErrNone);
1.201 +
1.202 + TInt count = entryList->Count();
1.203 + delete entryList;
1.204 + return count;
1.205 + }
1.206 +
1.207 +LOCAL_D TInt testCreateHourlyTimeSpanSchedule2(TSchedulerItemRef& aRef)
1.208 + {
1.209 + CArrayFixFlat<TScheduleEntryInfo2>* entryList;
1.210 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
1.211 + TName name(_L("and another off-peak"));
1.212 + aRef.iName = name;
1.213 +
1.214 + AppendHourlyEntry(*entryList, 365*24, 2000, EAugust, 0, 0, 0);
1.215 +
1.216 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.217 + TEST2(res, KErrNone);
1.218 +
1.219 + TInt count = entryList->Count();
1.220 + delete entryList;
1.221 + return count;
1.222 + }
1.223 +
1.224 +LOCAL_D TInt testCreateDailyTimeSpanSchedule1(TSchedulerItemRef& aRef)
1.225 + {
1.226 + CArrayFixFlat<TScheduleEntryInfo2>* entryList;
1.227 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
1.228 + TName name(_L("and another off-peak"));
1.229 + aRef.iName = name;
1.230 +
1.231 + AppendDailyEntry(*entryList, 213, 1999, EJune, 0, 0, 0);
1.232 + AppendDailyEntry(*entryList, 214, 1999, EJune, 0, 0, 0);
1.233 + AppendDailyEntry(*entryList, 273, 1999, EJune, 0, 0, 0);
1.234 + AppendDailyEntry(*entryList, 274, 1999, EJune, 0, 0, 0);
1.235 + AppendDailyEntry(*entryList, 305, 1999, EJune, 0, 0, 0);
1.236 + AppendDailyEntry(*entryList, 366, 1999, EJuly, 0, 0, 0);
1.237 +
1.238 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.239 + TEST2(res, KErrNone);
1.240 +
1.241 + TInt count = entryList->Count();
1.242 + delete entryList;
1.243 + return count;
1.244 + }
1.245 +
1.246 +LOCAL_D TInt testCreateDailyTimeSpanSchedule2(TSchedulerItemRef& aRef)
1.247 + {
1.248 + CArrayFixFlat<TScheduleEntryInfo2>* entryList;
1.249 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
1.250 + TName name(_L("and another off-peak"));
1.251 + aRef.iName = name;
1.252 +
1.253 + AppendDailyEntry(*entryList, 365, 2000, EAugust, 0, 0, 0);
1.254 +
1.255 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.256 + TEST2(res, KErrNone);
1.257 +
1.258 + TInt count = entryList->Count();
1.259 + delete entryList;
1.260 + return count;
1.261 + }
1.262 +
1.263 +LOCAL_D TInt testCreateMonthlyTimeSpanSchedule1(TSchedulerItemRef& aRef)
1.264 + {
1.265 + CArrayFixFlat<TScheduleEntryInfo2>* entryList;
1.266 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
1.267 + TName name(_L("and another off-peak"));
1.268 + aRef.iName = name;
1.269 +
1.270 + AppendMonthlyEntry(*entryList, 7, 1999, EMay, 30, 0, 0);
1.271 + AppendMonthlyEntry(*entryList, 7, 1999, EJune, 0, 0, 0);
1.272 + AppendMonthlyEntry(*entryList, 8, 1999, EJune, 29, 0, 0);
1.273 + AppendMonthlyEntry(*entryList, 8, 1999, EJuly, 0, 0, 0);
1.274 + AppendMonthlyEntry(*entryList, 9, 1999, EJuly, 0, 0, 0);
1.275 + AppendMonthlyEntry(*entryList, 12, 1999, EJuly, 0, 0, 0);
1.276 +
1.277 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.278 + TEST2(res, KErrNone);
1.279 +
1.280 + TInt count = entryList->Count();
1.281 + delete entryList;
1.282 + return count;
1.283 + }
1.284 +
1.285 +
1.286 +LOCAL_D TInt testCreateMonthlyTimeSpanSchedule2(TSchedulerItemRef& aRef)
1.287 + {
1.288 + CArrayFixFlat<TScheduleEntryInfo2>* entryList;
1.289 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
1.290 + TName name(_L("and another off-peak"));
1.291 + aRef.iName = name;
1.292 +
1.293 + AppendMonthlyEntry(*entryList, 12, 2000, EAugust, 0, 0, 0);
1.294 +
1.295 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.296 + TEST2(res, KErrNone);
1.297 +
1.298 + TInt count = entryList->Count();
1.299 + delete entryList;
1.300 + return count;
1.301 + }
1.302 +
1.303 +LOCAL_D TInt testCreateYearlyTimeSpanSchedule1(TSchedulerItemRef& aRef)
1.304 + {
1.305 + CArrayFixFlat<TScheduleEntryInfo2>* entryList;
1.306 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
1.307 + TName name(_L("and another off-peak"));
1.308 + aRef.iName = name;
1.309 +
1.310 + AppendYearlyEntry(*entryList, 1, 1998, EDecember, 30, 0, 0);
1.311 + AppendYearlyEntry(*entryList, 1, 1999, EJanuary, 0, 0, 0);
1.312 + AppendYearlyEntry(*entryList, 1, 1999, EFebruary, 27, 0, 0);
1.313 + AppendYearlyEntry(*entryList, 1, 1999, EMarch, 0, 0, 0);
1.314 + AppendYearlyEntry(*entryList, 1, 1999, EApril, 0, 0, 0);
1.315 + AppendYearlyEntry(*entryList, 1, 1999, EJuly, 0, 0, 0);
1.316 +
1.317 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.318 + TEST2(res, KErrNone);
1.319 +
1.320 + TInt count = entryList->Count();
1.321 + delete entryList;
1.322 + return count;
1.323 + }
1.324 +
1.325 +
1.326 +LOCAL_D TInt testCreateYearlyTimeSpanSchedule2(TSchedulerItemRef& aRef)
1.327 + {
1.328 + CArrayFixFlat<TScheduleEntryInfo2>* entryList;
1.329 + entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(3);
1.330 + TName name(_L("and another off-peak"));
1.331 + aRef.iName = name;
1.332 +
1.333 + AppendYearlyEntry(*entryList, 1, 2000, EAugust, 0, 0, 0);
1.334 +
1.335 + TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList);
1.336 + TEST2(res, KErrNone);
1.337 +
1.338 + TInt count = entryList->Count();
1.339 + delete entryList;
1.340 + return count;
1.341 + }
1.342 +
1.343 +
1.344 +LOCAL_D TInt testScheduleTask(TInt aScheduleId)
1.345 + {
1.346 + HBufC* data = HBufC::NewL(20);
1.347 + *data = _L("the data");
1.348 + TTaskInfo taskInfo;
1.349 + taskInfo.iTaskId = 0;
1.350 + taskInfo.iName = (_L("Y2K testing"));
1.351 + taskInfo.iPriority = 2;
1.352 + taskInfo.iRepeat = -1;
1.353 + TInt res = TheScheduler.ScheduleTask(taskInfo, *data, aScheduleId);
1.354 + TEST2(res, KErrNone);
1.355 + delete data;
1.356 + return taskInfo.iTaskId;
1.357 + }
1.358 +
1.359 +LOCAL_D void doTestLoopL(TInt aId, TInt aCount)
1.360 + {
1.361 + TTsTime time = ShowDueTime(aId);
1.362 + for (TInt i=0;i<aCount;i++)
1.363 + {
1.364 + SetTimeTo1SecBefore(time);
1.365 + //wait for exe to launch
1.366 + TEST2(STaskSemaphore::WaitL(KDefaultTimeout), KErrNone);
1.367 + CleanupHelpers::KillProcess(KMinimalTaskHandler);
1.368 + //
1.369 + if (i<(aCount-1))//i.e. if it's going to execute
1.370 + time = ShowDueTime(aId);
1.371 + }
1.372 + }
1.373 +
1.374 +/**
1.375 +@file
1.376 +@SYMTestCaseID SYSLIB-SCHSVR-CT-0275
1.377 +@SYMTestCaseDesc Year2000 replicated test, boundary test - UTC
1.378 +@SYMTestPriority High
1.379 +@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
1.380 +@SYMTestExpectedResults The test must not fail.
1.381 +@SYMPREQ PREQ234
1.382 +*/
1.383 +LOCAL_D void doBoundaryTestL()
1.384 + {
1.385 + TDateTime dateTime(1998, EAugust, 1, 17, 0, 0, 0);
1.386 + SetTime(dateTime);
1.387 + TSchedulerItemRef ref;
1.388 + TInt count = testCreateBoundarySchedule1(ref);
1.389 + TInt taskId;
1.390 + taskId = testScheduleTask(ref.iHandle);
1.391 + doTestLoopL(ref.iHandle, count);
1.392 + TInt res = TheScheduler.DeleteTask(taskId);
1.393 + TEST2(res, KErrNone);
1.394 + res = TheScheduler.DeleteSchedule(ref.iHandle);
1.395 + TEST2(res, KErrNone);
1.396 +
1.397 + SetTime(dateTime);
1.398 + count = testCreateBoundarySchedule2(ref);
1.399 + taskId = testScheduleTask(ref.iHandle);
1.400 + doTestLoopL(ref.iHandle, count);
1.401 + TheScheduler.DeleteTask(taskId);
1.402 + TheScheduler.DeleteSchedule(ref.iHandle);
1.403 + }
1.404 +
1.405 +LOCAL_D void doHourlyTimeSpanTestL()
1.406 + {
1.407 + TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0);
1.408 + SetTime(dateTime);
1.409 + TSchedulerItemRef ref;
1.410 + TInt count = testCreateHourlyTimeSpanSchedule1(ref);
1.411 + TInt taskId;
1.412 + taskId = testScheduleTask(ref.iHandle);
1.413 + doTestLoopL(ref.iHandle, count);
1.414 + TInt res = TheScheduler.DeleteTask(taskId);
1.415 + TEST2(res, KErrNone);
1.416 + res = TheScheduler.DeleteSchedule(ref.iHandle);
1.417 + TEST2(res, KErrNone);
1.418 +
1.419 + TDateTime dt2(2000, EAugust,1,17,0,0,0);
1.420 + SetTime(dt2);
1.421 + count = testCreateHourlyTimeSpanSchedule2(ref);
1.422 + taskId = testScheduleTask(ref.iHandle);
1.423 + doTestLoopL(ref.iHandle, count);
1.424 + TheScheduler.DeleteTask(taskId);
1.425 + TheScheduler.DeleteSchedule(ref.iHandle);
1.426 + }
1.427 +
1.428 +LOCAL_D void doDailyTimeSpanTestL()
1.429 + {
1.430 + TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0);
1.431 + SetTime(dateTime);
1.432 + TSchedulerItemRef ref;
1.433 + TInt count = testCreateDailyTimeSpanSchedule1(ref);
1.434 + TInt taskId;
1.435 + taskId = testScheduleTask(ref.iHandle);
1.436 + doTestLoopL(ref.iHandle, count);
1.437 + TInt res = TheScheduler.DeleteTask(taskId);
1.438 + TEST2(res, KErrNone);
1.439 + res = TheScheduler.DeleteSchedule(ref.iHandle);
1.440 + TEST2(res, KErrNone);
1.441 +
1.442 + TDateTime dt2(2000, EAugust,1,17,0,0,0);
1.443 + SetTime(dt2);
1.444 + count = testCreateDailyTimeSpanSchedule2(ref);
1.445 + taskId = testScheduleTask(ref.iHandle);
1.446 + doTestLoopL(ref.iHandle, count);
1.447 + TheScheduler.DeleteTask(taskId);
1.448 + TheScheduler.DeleteSchedule(ref.iHandle);
1.449 + }
1.450 +
1.451 +LOCAL_D void doMonthlyTimeSpanTestL()
1.452 + {
1.453 +
1.454 + TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0);
1.455 + SetTime(dateTime);
1.456 + TSchedulerItemRef ref;
1.457 + TInt count = testCreateMonthlyTimeSpanSchedule1(ref);
1.458 + TInt taskId;
1.459 + taskId = testScheduleTask(ref.iHandle);
1.460 + doTestLoopL(ref.iHandle, count);
1.461 + TInt res = TheScheduler.DeleteTask(taskId);
1.462 + TEST2(res, KErrNone);
1.463 + res = TheScheduler.DeleteSchedule(ref.iHandle);
1.464 + TEST2(res, KErrNone);
1.465 +
1.466 + TDateTime dt2(2000, EAugust,1,17,0,0,0);
1.467 + SetTime(dt2);
1.468 + count = testCreateMonthlyTimeSpanSchedule2(ref);
1.469 + taskId = testScheduleTask(ref.iHandle);
1.470 + doTestLoopL(ref.iHandle, count);
1.471 + TheScheduler.DeleteTask(taskId);
1.472 + TheScheduler.DeleteSchedule(ref.iHandle);
1.473 + }
1.474 +
1.475 +LOCAL_D void doYearlyTimeSpanTestL()
1.476 + {
1.477 +
1.478 + TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0);
1.479 + SetTime(dateTime);
1.480 + TSchedulerItemRef ref;
1.481 + TInt count = testCreateYearlyTimeSpanSchedule1(ref);
1.482 + TInt taskId;
1.483 + taskId = testScheduleTask(ref.iHandle);
1.484 + doTestLoopL(ref.iHandle, count);
1.485 + TInt res = TheScheduler.DeleteTask(taskId);
1.486 + TEST2(res, KErrNone);
1.487 + res = TheScheduler.DeleteSchedule(ref.iHandle);
1.488 + TEST2(res, KErrNone);
1.489 +
1.490 + TDateTime dt2(2000, EAugust,1,17,0,0,0);
1.491 + SetTime(dt2);
1.492 + count = testCreateYearlyTimeSpanSchedule2(ref);
1.493 + taskId = testScheduleTask(ref.iHandle);
1.494 + doTestLoopL(ref.iHandle, count);
1.495 + TheScheduler.DeleteTask(taskId);
1.496 + TheScheduler.DeleteSchedule(ref.iHandle);
1.497 + }
1.498 +
1.499 +/**
1.500 +@file
1.501 +@SYMTestCaseID SYSLIB-SCHSVR-CT-0276
1.502 +@SYMTestCaseDesc Year2000 replicated test, time span test - UTC
1.503 +@SYMTestPriority High
1.504 +@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
1.505 +@SYMTestExpectedResults The test must not fail.
1.506 +@SYMPREQ PREQ234
1.507 +*/
1.508 +LOCAL_D void doTimeSpanTestL()
1.509 + {
1.510 + TheTest.Printf(_L("\nTesting time-spans...\n"));
1.511 + TheTest.Printf(_L("Hourly time-spans...\n"));
1.512 + doHourlyTimeSpanTestL();
1.513 + TheTest.Printf(_L("Daily time-spans...\n"));
1.514 + doDailyTimeSpanTestL();
1.515 + TheTest.Printf(_L("Monthly time-spans...\n"));
1.516 + doMonthlyTimeSpanTestL();
1.517 + TheTest.Printf(_L("Yearly time-spans...\n"));
1.518 + doYearlyTimeSpanTestL();
1.519 + }
1.520 +
1.521 +static void DoTestsL()
1.522 + {
1.523 + TheTest.Next(_L("Delete old files"));
1.524 + SchSvrHelpers::DeleteScheduleFilesL();
1.525 +
1.526 + TheTest.Next(_L("Connect to Scheduler"));
1.527 + TInt res=TheScheduler.Connect();
1.528 + TEST2(res, KErrNone);
1.529 +
1.530 + TheTest.Next(_L("Registering Client"));
1.531 + res = SchSvrHelpers::RegisterClientL(TheScheduler);
1.532 + TEST2(res, KErrNone);
1.533 +
1.534 + // Create exe Semaphore
1.535 + STaskSemaphore sem;
1.536 + sem.CreateL();
1.537 +
1.538 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0275 Boundary/valid dates testing "));
1.539 + doBoundaryTestL();
1.540 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0276 Time span testing "));
1.541 + doTimeSpanTestL();
1.542 +
1.543 + // close exe Semaphore
1.544 + sem.Close();
1.545 +
1.546 + //Tidying up so next test will be clear.
1.547 + TheTest.Next(_L("Delete all schedules"));
1.548 + SchSvrHelpers::DeleteAllSchedulesL(TheScheduler);
1.549 + TheScheduler.Close();
1.550 + }
1.551 +
1.552 +GLDEF_C TInt E32Main()
1.553 + {
1.554 + __UHEAP_MARK;
1.555 +
1.556 + CTrapCleanup* cleanup = CTrapCleanup::New();
1.557 + TEST(cleanup != NULL);
1.558 +
1.559 + TEST2(TheFsSession.Connect(), KErrNone);
1.560 +
1.561 + TheTest.Title();
1.562 + TheTest.Start(_L("Year 2000 - UTC"));
1.563 +
1.564 + //If the previous test fails, SCHSVR.exe may stay in memory.
1.565 + TRAPD(err,CleanupHelpers::TestCleanupL());
1.566 + TEST2(err, KErrNone);
1.567 +
1.568 + TRAP(err, DoTestsL());
1.569 + TEST2(err,KErrNone);
1.570 + TRAP(err,CleanupHelpers::TestCleanupL());
1.571 + TEST2(err, KErrNone);
1.572 +
1.573 + TheTest.End();
1.574 + TheFsSession.Close();
1.575 + TheTest.Close();
1.576 +
1.577 + delete cleanup;
1.578 +
1.579 + __UHEAP_MARKEND;
1.580 + return KErrNone;
1.581 + }