Update contrib.
1 // Copyright (c) 1997-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __THELPERS_H__
17 #define __THELPERS_H__
22 #include <schinfointernal.h>
27 // Numerical constants
28 const TInt KPausePeriod = 1; // 1 second
29 const TInt KOneSecond = 1000000;
30 const TInt KDefaultTimeout = KOneSecond * 120; // 2 Minutes
35 public: // STATIC COMPARISON FUNCTIONS
36 IMPORT_C static TBool IsTimeTheSame(const TTime& aTime1, const TTime& aTime2);
37 IMPORT_C static TBool IsDateTheSame(const TTime& aTime1, const TTime& aTime2);
38 IMPORT_C static TBool IsTaskInfoTheSame(const TTaskInfo& aTaskInfo1, const TTaskInfo& aTaskInfo2);
39 IMPORT_C static TBool IsItemRefTheSame(const TSchedulerItemRef& aItemRef1, const TSchedulerItemRef& aItemRef2);
40 IMPORT_C static TBool IsScheduleStateTheSame(const TScheduleState& aScheduleState1, const TScheduleState& aScheduleState2);
43 public: // STATIC OBJECT CREATION FUNCTIONS
44 IMPORT_C static TScheduleEntryInfo RandomScheduleEntryInfo(TInt64& aSeed);
45 IMPORT_C static TScheduleEntryInfo ScheduleEntryInfo(TIntervalType aType, const TTime& aStartTime, TInt aInterval, TTimeIntervalMinutes aValidPeriod = 0);
46 IMPORT_C static TTaskInfo TaskInfo(const TDesC& aName, TInt aPriority, TInt aRepeat = 1);
49 public: // STATIC COMPARISON FUNCTIONS - PREQ234 SUPPORT
50 IMPORT_C static TBool IsTimeTheSame(const TTsTime& aTime1, const TTsTime& aTime2);
51 IMPORT_C static TBool IsDateTheSame(const TTsTime& aTime1, const TTsTime& aTime2);
52 IMPORT_C static TBool IsTimeTheSameNoSeconds(const TTsTime& aTime1, const TTsTime& aTime2);
53 IMPORT_C static TBool IsScheduleStateTheSame(const TScheduleState2& aScheduleState1, const TScheduleState2& aScheduleState2);
55 public: // STATIC OBJECT CREATION FUNCTIONS - PREQ234 SUPPORT
56 IMPORT_C static TScheduleEntryInfo2 RandomScheduleEntryInfoHometime(TInt64& aSeed);
57 IMPORT_C static TScheduleEntryInfo2 RandomScheduleEntryInfoUtc(TInt64& aSeed);
58 IMPORT_C static TScheduleEntryInfo2 ScheduleEntryInfo(TIntervalType aType, const TTsTime& aStartTime, TInt aInterval, TTimeIntervalMinutes aValidPeriod = 0);
60 public: // STATIC PRINTING FUNCTIONS - PREQ234 SUPPORT
61 IMPORT_C static void Pause(TInt aPauseAmount = KPausePeriod);
63 public: // STATIC NEW TIME HANDLING FUNCTIONS - DEF061625
64 IMPORT_C static TInt SetHomeTimeL(const TTime& aLocalTime);
65 IMPORT_C static TInt SetUTCTimeL(const TTime& aUTCTime);
67 public: // STATIC PRINTING FUNCTIONS
68 IMPORT_C static TInt Rand(const TInt aLow, const TInt aHigh, TInt64& aSeed);
69 IMPORT_C static void Pause(RTest& aTest, TInt aPauseAmount = KPausePeriod);
72 public: // SCHEDULE DELETION FUNCTIONS
73 IMPORT_C static void DeleteScheduleFilesL();
74 IMPORT_C static void DeleteAllSchedulesL(RScheduler& aScheduler);
77 public: // client registration
78 IMPORT_C static TInt RegisterClientL(RScheduler& aScheduler);
79 IMPORT_C static TInt RegisterPanicingClient(RScheduler& aScheduler);
80 IMPORT_C static TInt RegisterNonExistentClient(RScheduler& aScheduler);
83 public: // MISC FUNCTIONS
84 IMPORT_C static TDateTime TimeBasedOnOffset(TInt aSeconds,
90 IMPORT_C static TDateTime UtcTimeBasedOnOffset(TInt aSeconds,
96 IMPORT_C static TInt CheckTaskFilesL();
97 IMPORT_C static TInt CreateTaskFilesL();
99 IMPORT_C static TInt LaunchTaskSchedulerL();
106 //This function is used in the test code to kill SCHSVR or MinimalTaskHandler
107 //processes (or some other) when they leftover and may cause OOM condinitons.
108 IMPORT_C static TInt KillProcess(const TDesC& aProcessName);
110 //Call this method before "TheTest(error == KErrNone);" statement.
111 //Otherwise if the error code is not KErrNone and the check fails, your
112 //cleanup code never gets called - probably you will have low memory condition on the
113 //test hardware and the rest of SCHSVR unit tests will fail sometimes and it will be very
114 //hard to find out what is going on there.
115 IMPORT_C static void TestCleanupL();
119 // Used for signaling between launched exe and test to check that the exe is launched.
123 IMPORT_C void CreateL();
124 IMPORT_C static void WaitL();
125 IMPORT_C static TInt WaitL(TInt aTimeout);
126 IMPORT_C void Close();
128 RSemaphore iSemaphore;