os/ossrv/genericservices/taskscheduler/Test/TSUtils/Thelpers.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1997-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
#ifndef __THELPERS_H__
sl@0
    17
#define __THELPERS_H__
sl@0
    18
sl@0
    19
// User includes
sl@0
    20
#include <e32test.h>
sl@0
    21
#include <schinfo.h>
sl@0
    22
#include <schinfointernal.h>
sl@0
    23
#include <csch_cli.h>
sl@0
    24
sl@0
    25
class RFs;
sl@0
    26
sl@0
    27
// Numerical constants
sl@0
    28
const TInt KPausePeriod						= 1; // 1 second
sl@0
    29
const TInt KOneSecond = 1000000;
sl@0
    30
const TInt KDefaultTimeout = KOneSecond * 120; // 2 Minutes
sl@0
    31
sl@0
    32
class SchSvrHelpers
sl@0
    33
	{
sl@0
    34
sl@0
    35
public:							// STATIC COMPARISON FUNCTIONS
sl@0
    36
	IMPORT_C static TBool	IsTimeTheSame(const TTime& aTime1, const TTime& aTime2);
sl@0
    37
	IMPORT_C static TBool	IsDateTheSame(const TTime& aTime1, const TTime& aTime2);
sl@0
    38
	IMPORT_C static TBool	IsTaskInfoTheSame(const TTaskInfo& aTaskInfo1, const TTaskInfo& aTaskInfo2);
sl@0
    39
	IMPORT_C static TBool	IsItemRefTheSame(const TSchedulerItemRef& aItemRef1, const TSchedulerItemRef& aItemRef2);
sl@0
    40
	IMPORT_C static TBool	IsScheduleStateTheSame(const TScheduleState& aScheduleState1, const TScheduleState& aScheduleState2);
sl@0
    41
sl@0
    42
sl@0
    43
public:							// STATIC OBJECT CREATION FUNCTIONS
sl@0
    44
	IMPORT_C static TScheduleEntryInfo		RandomScheduleEntryInfo(TInt64& aSeed);
sl@0
    45
	IMPORT_C static TScheduleEntryInfo		ScheduleEntryInfo(TIntervalType aType, const TTime& aStartTime, TInt aInterval, TTimeIntervalMinutes aValidPeriod = 0);
sl@0
    46
	IMPORT_C static TTaskInfo				TaskInfo(const TDesC& aName, TInt aPriority, TInt aRepeat = 1);
sl@0
    47
sl@0
    48
sl@0
    49
public:							// STATIC COMPARISON FUNCTIONS - PREQ234 SUPPORT
sl@0
    50
	IMPORT_C static TBool	IsTimeTheSame(const TTsTime& aTime1, const TTsTime& aTime2);
sl@0
    51
	IMPORT_C static TBool	IsDateTheSame(const TTsTime& aTime1, const TTsTime& aTime2);
sl@0
    52
	IMPORT_C static TBool	IsTimeTheSameNoSeconds(const TTsTime& aTime1, const TTsTime& aTime2);
sl@0
    53
	IMPORT_C static TBool	IsScheduleStateTheSame(const TScheduleState2& aScheduleState1, const TScheduleState2& aScheduleState2);
sl@0
    54
	
sl@0
    55
public:							// STATIC OBJECT CREATION FUNCTIONS - PREQ234 SUPPORT
sl@0
    56
	IMPORT_C static TScheduleEntryInfo2		RandomScheduleEntryInfoHometime(TInt64& aSeed);
sl@0
    57
	IMPORT_C static TScheduleEntryInfo2		RandomScheduleEntryInfoUtc(TInt64& aSeed);
sl@0
    58
	IMPORT_C static TScheduleEntryInfo2		ScheduleEntryInfo(TIntervalType aType, const TTsTime& aStartTime, TInt aInterval, TTimeIntervalMinutes aValidPeriod = 0);
sl@0
    59
sl@0
    60
public:							// STATIC PRINTING FUNCTIONS - PREQ234 SUPPORT
sl@0
    61
	IMPORT_C static void	Pause(TInt aPauseAmount = KPausePeriod);
sl@0
    62
sl@0
    63
public:							// STATIC NEW TIME HANDLING FUNCTIONS - DEF061625 
sl@0
    64
	IMPORT_C static TInt SetHomeTimeL(const TTime& aLocalTime);
sl@0
    65
	IMPORT_C static TInt SetUTCTimeL(const TTime& aUTCTime);
sl@0
    66
	
sl@0
    67
public:							// STATIC PRINTING FUNCTIONS
sl@0
    68
	IMPORT_C static TInt	Rand(const TInt aLow, const TInt aHigh, TInt64& aSeed);
sl@0
    69
	IMPORT_C static void	Pause(RTest& aTest, TInt aPauseAmount = KPausePeriod);
sl@0
    70
sl@0
    71
sl@0
    72
public:							// SCHEDULE DELETION FUNCTIONS
sl@0
    73
	IMPORT_C static void DeleteScheduleFilesL();
sl@0
    74
	IMPORT_C static void DeleteAllSchedulesL(RScheduler& aScheduler);
sl@0
    75
sl@0
    76
sl@0
    77
public:							// client registration
sl@0
    78
	IMPORT_C static TInt RegisterClientL(RScheduler& aScheduler);	
sl@0
    79
	IMPORT_C static TInt RegisterPanicingClient(RScheduler& aScheduler);
sl@0
    80
	IMPORT_C static TInt RegisterNonExistentClient(RScheduler& aScheduler);
sl@0
    81
	
sl@0
    82
sl@0
    83
public:							// MISC FUNCTIONS
sl@0
    84
	IMPORT_C static TDateTime	TimeBasedOnOffset(TInt aSeconds, 
sl@0
    85
												TInt aMinutes = 0, 
sl@0
    86
												TInt aHours = 0, 
sl@0
    87
												TInt aDays = 0, 
sl@0
    88
												TInt aMonths = 0, 
sl@0
    89
												TInt aYears = 0);	
sl@0
    90
	IMPORT_C static TDateTime	UtcTimeBasedOnOffset(TInt aSeconds, 
sl@0
    91
												TInt aMinutes = 0, 
sl@0
    92
												TInt aHours = 0, 
sl@0
    93
												TInt aDays = 0, 
sl@0
    94
												TInt aMonths = 0, 
sl@0
    95
												TInt aYears = 0);	
sl@0
    96
	IMPORT_C static TInt CheckTaskFilesL();
sl@0
    97
	IMPORT_C static TInt CreateTaskFilesL();
sl@0
    98
	
sl@0
    99
	IMPORT_C static  TInt LaunchTaskSchedulerL();
sl@0
   100
	};
sl@0
   101
	
sl@0
   102
sl@0
   103
class CleanupHelpers
sl@0
   104
	{
sl@0
   105
	public:
sl@0
   106
	//This function is used in the test code to kill SCHSVR or MinimalTaskHandler
sl@0
   107
	//processes (or some other) when they leftover and may cause OOM condinitons.
sl@0
   108
	IMPORT_C static TInt KillProcess(const TDesC& aProcessName);
sl@0
   109
	
sl@0
   110
	//Call this method before "TheTest(error == KErrNone);" statement.
sl@0
   111
	//Otherwise if the error code is not KErrNone and the check fails, your 
sl@0
   112
	//cleanup code never gets called - probably you will have low memory condition on the 
sl@0
   113
	//test hardware and the rest of SCHSVR unit tests will fail sometimes and it will be very 
sl@0
   114
	//hard to find out what is going on there.
sl@0
   115
	IMPORT_C static void TestCleanupL();
sl@0
   116
	};	
sl@0
   117
												
sl@0
   118
sl@0
   119
// Used for signaling between launched exe and test to check that the exe is launched.
sl@0
   120
class STaskSemaphore
sl@0
   121
	{
sl@0
   122
public:
sl@0
   123
	IMPORT_C void CreateL();
sl@0
   124
	IMPORT_C static void WaitL();
sl@0
   125
	IMPORT_C static TInt WaitL(TInt aTimeout);
sl@0
   126
	IMPORT_C void Close();
sl@0
   127
private:
sl@0
   128
	RSemaphore iSemaphore;	
sl@0
   129
	};
sl@0
   130
sl@0
   131
#endif
sl@0
   132