1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericservices/taskscheduler/Test/TSUtils/Thelpers.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,132 @@
1.4 +// Copyright (c) 1997-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 +#ifndef __THELPERS_H__
1.20 +#define __THELPERS_H__
1.21 +
1.22 +// User includes
1.23 +#include <e32test.h>
1.24 +#include <schinfo.h>
1.25 +#include <schinfointernal.h>
1.26 +#include <csch_cli.h>
1.27 +
1.28 +class RFs;
1.29 +
1.30 +// Numerical constants
1.31 +const TInt KPausePeriod = 1; // 1 second
1.32 +const TInt KOneSecond = 1000000;
1.33 +const TInt KDefaultTimeout = KOneSecond * 120; // 2 Minutes
1.34 +
1.35 +class SchSvrHelpers
1.36 + {
1.37 +
1.38 +public: // STATIC COMPARISON FUNCTIONS
1.39 + IMPORT_C static TBool IsTimeTheSame(const TTime& aTime1, const TTime& aTime2);
1.40 + IMPORT_C static TBool IsDateTheSame(const TTime& aTime1, const TTime& aTime2);
1.41 + IMPORT_C static TBool IsTaskInfoTheSame(const TTaskInfo& aTaskInfo1, const TTaskInfo& aTaskInfo2);
1.42 + IMPORT_C static TBool IsItemRefTheSame(const TSchedulerItemRef& aItemRef1, const TSchedulerItemRef& aItemRef2);
1.43 + IMPORT_C static TBool IsScheduleStateTheSame(const TScheduleState& aScheduleState1, const TScheduleState& aScheduleState2);
1.44 +
1.45 +
1.46 +public: // STATIC OBJECT CREATION FUNCTIONS
1.47 + IMPORT_C static TScheduleEntryInfo RandomScheduleEntryInfo(TInt64& aSeed);
1.48 + IMPORT_C static TScheduleEntryInfo ScheduleEntryInfo(TIntervalType aType, const TTime& aStartTime, TInt aInterval, TTimeIntervalMinutes aValidPeriod = 0);
1.49 + IMPORT_C static TTaskInfo TaskInfo(const TDesC& aName, TInt aPriority, TInt aRepeat = 1);
1.50 +
1.51 +
1.52 +public: // STATIC COMPARISON FUNCTIONS - PREQ234 SUPPORT
1.53 + IMPORT_C static TBool IsTimeTheSame(const TTsTime& aTime1, const TTsTime& aTime2);
1.54 + IMPORT_C static TBool IsDateTheSame(const TTsTime& aTime1, const TTsTime& aTime2);
1.55 + IMPORT_C static TBool IsTimeTheSameNoSeconds(const TTsTime& aTime1, const TTsTime& aTime2);
1.56 + IMPORT_C static TBool IsScheduleStateTheSame(const TScheduleState2& aScheduleState1, const TScheduleState2& aScheduleState2);
1.57 +
1.58 +public: // STATIC OBJECT CREATION FUNCTIONS - PREQ234 SUPPORT
1.59 + IMPORT_C static TScheduleEntryInfo2 RandomScheduleEntryInfoHometime(TInt64& aSeed);
1.60 + IMPORT_C static TScheduleEntryInfo2 RandomScheduleEntryInfoUtc(TInt64& aSeed);
1.61 + IMPORT_C static TScheduleEntryInfo2 ScheduleEntryInfo(TIntervalType aType, const TTsTime& aStartTime, TInt aInterval, TTimeIntervalMinutes aValidPeriod = 0);
1.62 +
1.63 +public: // STATIC PRINTING FUNCTIONS - PREQ234 SUPPORT
1.64 + IMPORT_C static void Pause(TInt aPauseAmount = KPausePeriod);
1.65 +
1.66 +public: // STATIC NEW TIME HANDLING FUNCTIONS - DEF061625
1.67 + IMPORT_C static TInt SetHomeTimeL(const TTime& aLocalTime);
1.68 + IMPORT_C static TInt SetUTCTimeL(const TTime& aUTCTime);
1.69 +
1.70 +public: // STATIC PRINTING FUNCTIONS
1.71 + IMPORT_C static TInt Rand(const TInt aLow, const TInt aHigh, TInt64& aSeed);
1.72 + IMPORT_C static void Pause(RTest& aTest, TInt aPauseAmount = KPausePeriod);
1.73 +
1.74 +
1.75 +public: // SCHEDULE DELETION FUNCTIONS
1.76 + IMPORT_C static void DeleteScheduleFilesL();
1.77 + IMPORT_C static void DeleteAllSchedulesL(RScheduler& aScheduler);
1.78 +
1.79 +
1.80 +public: // client registration
1.81 + IMPORT_C static TInt RegisterClientL(RScheduler& aScheduler);
1.82 + IMPORT_C static TInt RegisterPanicingClient(RScheduler& aScheduler);
1.83 + IMPORT_C static TInt RegisterNonExistentClient(RScheduler& aScheduler);
1.84 +
1.85 +
1.86 +public: // MISC FUNCTIONS
1.87 + IMPORT_C static TDateTime TimeBasedOnOffset(TInt aSeconds,
1.88 + TInt aMinutes = 0,
1.89 + TInt aHours = 0,
1.90 + TInt aDays = 0,
1.91 + TInt aMonths = 0,
1.92 + TInt aYears = 0);
1.93 + IMPORT_C static TDateTime UtcTimeBasedOnOffset(TInt aSeconds,
1.94 + TInt aMinutes = 0,
1.95 + TInt aHours = 0,
1.96 + TInt aDays = 0,
1.97 + TInt aMonths = 0,
1.98 + TInt aYears = 0);
1.99 + IMPORT_C static TInt CheckTaskFilesL();
1.100 + IMPORT_C static TInt CreateTaskFilesL();
1.101 +
1.102 + IMPORT_C static TInt LaunchTaskSchedulerL();
1.103 + };
1.104 +
1.105 +
1.106 +class CleanupHelpers
1.107 + {
1.108 + public:
1.109 + //This function is used in the test code to kill SCHSVR or MinimalTaskHandler
1.110 + //processes (or some other) when they leftover and may cause OOM condinitons.
1.111 + IMPORT_C static TInt KillProcess(const TDesC& aProcessName);
1.112 +
1.113 + //Call this method before "TheTest(error == KErrNone);" statement.
1.114 + //Otherwise if the error code is not KErrNone and the check fails, your
1.115 + //cleanup code never gets called - probably you will have low memory condition on the
1.116 + //test hardware and the rest of SCHSVR unit tests will fail sometimes and it will be very
1.117 + //hard to find out what is going on there.
1.118 + IMPORT_C static void TestCleanupL();
1.119 + };
1.120 +
1.121 +
1.122 +// Used for signaling between launched exe and test to check that the exe is launched.
1.123 +class STaskSemaphore
1.124 + {
1.125 +public:
1.126 + IMPORT_C void CreateL();
1.127 + IMPORT_C static void WaitL();
1.128 + IMPORT_C static TInt WaitL(TInt aTimeout);
1.129 + IMPORT_C void Close();
1.130 +private:
1.131 + RSemaphore iSemaphore;
1.132 + };
1.133 +
1.134 +#endif
1.135 +