messagingfw/msgtest/testutils/base/inc/MsvTestUtils.h
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2000-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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef MSV_TEST_UTILS_H_
       
    17 #define MSV_TEST_UTILS_H_
       
    18 
       
    19 #include "msvtestutilsbase.h"
       
    20 #include <mtclreg.h>
       
    21 #include <msventry.h>
       
    22 #include <msvids.h>
       
    23 
       
    24 //	Forward Declarations
       
    25 
       
    26 class CBaseServerMtm;
       
    27 class CServerMtmDllRegistry;
       
    28 class CMtmRegistryControl;
       
    29 class TTaskInfo;
       
    30 
       
    31 //	Constants
       
    32 
       
    33 #define KMtmDir					_L("c:\\system\\mtm\\")
       
    34 
       
    35 // used for writing to logs
       
    36 #define KFileNameBodies			_L("Entry_RichTextBodies.txt")
       
    37 #define KFileNameFiles			_L("Entry_Files.txt")
       
    38 #define	KFileNameEntryStructure	_L("Entry_Structure.txt")
       
    39 
       
    40 #define KRfc822Files			_L("c:\\mailtest\\rfc822\\Rfc_*.txt")
       
    41 
       
    42 _LIT(KMsvTestUtilsNewLine, "\n");
       
    43 
       
    44 
       
    45 /**
       
    46 @internalComponent
       
    47 */
       
    48 const TInt KMsvTestUidPhonePwrValue=0x100052C5;
       
    49 const TUid KMsvTestUidPhonePwr={KMsvTestUidPhonePwrValue};
       
    50 
       
    51 /**
       
    52 @internalComponent
       
    53 */
       
    54 enum TMsvTestPhoneStatus
       
    55 	{
       
    56 	EMsvTestPhoneOff = 0,
       
    57 	EMsvTestPhoneOn
       
    58 	};
       
    59 
       
    60 /**
       
    61 @internalComponent
       
    62 */
       
    63 const TInt KMsvTestUidSIMStatusValue	=0x100052C6;
       
    64 const TUid KMsvTestUidSIMStatus		={KMsvTestUidSIMStatusValue};
       
    65 
       
    66 /**
       
    67 @internalComponent
       
    68 */
       
    69 enum TMsvTestSIMStatus
       
    70 	{
       
    71 	EMsvTestSimOk,
       
    72 	EMsvTestSimNotPresent,
       
    73 	EMsvTestSimRejected
       
    74 	};
       
    75 
       
    76 /**
       
    77 @internalComponent
       
    78 */
       
    79 const TInt KMsvTestUidNetworkStatusValue=0x100052C7;
       
    80 const TUid KMsvTestUidNetworkStatus	={KMsvTestUidNetworkStatusValue};
       
    81 
       
    82 /**
       
    83 @internalComponent
       
    84 */
       
    85 enum TMsvTestNetworkStatus
       
    86 	{
       
    87 	EMsvTestNetworkAvailable,
       
    88 	EMsvTestNetworkUnAvailable
       
    89 	};
       
    90 
       
    91 
       
    92 //
       
    93 //
       
    94 //	TestMsvOperationTimer
       
    95 //
       
    96 //
       
    97 
       
    98 class TestMsvOperationTimer : public CTimer
       
    99 	{
       
   100 public:
       
   101 	IMPORT_C static TestMsvOperationTimer* NewLC(CConsoleBase* aConsole, CMsvOperation* aMsvOperation, RTest& aRTest);
       
   102 
       
   103 	IMPORT_C void RunL();
       
   104 	IMPORT_C void DoCancel();
       
   105 	IMPORT_C void ConstructL();
       
   106 	IMPORT_C void IssueRequest();
       
   107 	
       
   108 	CConsoleBase*				iConsole;
       
   109 	CMsvOperation*				iMsvOperation;
       
   110 	TTimeIntervalMicroSeconds32 iPeriod;
       
   111 
       
   112 protected:
       
   113 	TInt iCount;
       
   114 	TBool iClosing;
       
   115 	RTest iRTest;
       
   116 	IMPORT_C TestMsvOperationTimer(CConsoleBase* aConsole, CMsvOperation* aMsvOperation, RTest& aRTest);
       
   117 	};
       
   118 
       
   119 //
       
   120 //
       
   121 //	TMsvTestDllInfo
       
   122 //
       
   123 //
       
   124 
       
   125 class TMsvTestDllInfo
       
   126 	{
       
   127 	public:
       
   128 		inline TMsvTestDllInfo(const TDesC& aFileName, TInt aOrdinal = 1, TVersion aVersion = TVersion(2,0,0));
       
   129 		TFileName iFileName;
       
   130 		TInt iOrdinal;
       
   131 		TVersion iVersion;
       
   132 	};
       
   133 
       
   134 //
       
   135 //
       
   136 // enum TMsvTestUtilsCreationFlags
       
   137 //
       
   138 //
       
   139 
       
   140 enum TMsvTestUtilsCreationFlags
       
   141 	{
       
   142 	ETuNone						= 0x0000,
       
   143 	ETuCreateTestDirectories	= 0x0001,
       
   144 	ETuCleanMessageFolder		= 0x0002,
       
   145 	ETuDeleteMtmRegistry		= 0x0004,
       
   146 	ETuCreateServerMtmReg		= 0x0008,
       
   147 	ETuInstallMtmGroup			= 0x0010,
       
   148 	ETuDeleteService			= 0x0020,
       
   149 	ETuCreateService			= 0x0040, //NewL may leave if service already exists
       
   150 	ETuGoClientSide				= 0x0080,
       
   151 	ETuGoServerSide				= 0x0100,
       
   152 	ETuAllClientSide			= ETuCleanMessageFolder
       
   153 									| ETuDeleteMtmRegistry
       
   154 									| ETuCreateTestDirectories
       
   155 									| ETuDeleteService
       
   156 									| ETuCreateService
       
   157 									| ETuGoClientSide,
       
   158 	ETuAllServerSide			= ETuAllClientSide
       
   159 									& ~ETuGoClientSide
       
   160 									| ETuGoServerSide,
       
   161 	ETuMinimalClientSide		= ETuCreateTestDirectories
       
   162 									| ETuDeleteService
       
   163 									| ETuCreateService
       
   164 									| ETuGoClientSide,
       
   165 	ETuMinimalServerSide		= ETuMinimalClientSide
       
   166 									& ~ETuGoClientSide
       
   167 									| ETuGoServerSide,
       
   168 	ETuKeepLogFile				= 0x10000
       
   169 	};
       
   170 
       
   171 //
       
   172 //
       
   173 //	CMsvTestUtils
       
   174 //
       
   175 //
       
   176 
       
   177 class CMsvTestUtils : public CTestUtils
       
   178 	{
       
   179 public:
       
   180 	IMPORT_C void GoClientSideL();
       
   181 	IMPORT_C void GoServerSideL();
       
   182 	IMPORT_C virtual void Reset();
       
   183 	IMPORT_C void CreateRegistryObjectAndControlL();
       
   184 	IMPORT_C void CleanMessageFolderL();
       
   185 	IMPORT_C void CreateAllTestDirectories();
       
   186 
       
   187 	IMPORT_C void FindChildrenL(TMsvId aFolderToTraverse, TBool aReplace = ETrue, TBool aOtherFiles = ETrue);
       
   188 	IMPORT_C void FindChildrenL(TMsvId aFolderToTraverse, const TFileName& aFilepath, TBool aReplace = ETrue, TBool aOtherFiles = ETrue);
       
   189 
       
   190 	//CMsvEntry and CMsvServerEntry functions
       
   191 	inline void CreateEntryL(TMsvEntry& aEntry);
       
   192 	inline void CreateAndSetEntryL(TMsvEntry& aEntry);
       
   193 	inline void DeleteEntryL(TMsvId aId);
       
   194 	inline void ChangeEntryL(TMsvEntry& aEntry);
       
   195 	inline void SetEntryL(TMsvId aId);
       
   196 	inline TMsvEntry Entry();
       
   197 	inline CMsvStore* EditStoreL();
       
   198 	inline CMsvStore* ReadStoreL();
       
   199 	inline CMsvEntrySelection* ChildrenWithTypeLC(TUid aType);
       
   200 	inline CMsvEntrySelection* ChildrenWithMtmLC(TUid aMtm);
       
   201 	inline void SetSortTypeL(TMsvSelectionOrdering aOrder);
       
   202 
       
   203 	virtual void InstantiateClientMtmsL() = 0;
       
   204 	virtual void InstantiateServerMtmsL() = 0;
       
   205 	virtual void DeleteServicesL() = 0;
       
   206 	virtual void CreateServicesL() = 0;
       
   207 	virtual void FindExistingServicesL() = 0;
       
   208 	virtual void InstallMtmGroupsL() = 0;
       
   209 	virtual void CreateServerMtmRegsL() = 0;
       
   210 
       
   211 	//Returns TMsvEntry.iDate for aEntryId, and the time it is scheduled for on the task scheduler
       
   212 	IMPORT_C TInt ScheduleTime(TMsvId aEntryId, TTime& rEntryTime, TTime& rTaskSchedulerTime, TTaskInfo& rTaskInfo);
       
   213 	IMPORT_C TInt AppendScheduleTimeL(TMsvId aEntryId, TDes& rOutput);
       
   214 	IMPORT_C void SpecifyRfc822Dir(const TFileName& aFilePath);
       
   215 	
       
   216 	IMPORT_C void NavigateMessageStoreL(TMsvId aStart = KMsvRootIndexEntryId);
       
   217 
       
   218 protected:
       
   219 	IMPORT_C CMsvTestUtils(RTest& aRTest);
       
   220 	IMPORT_C ~CMsvTestUtils();
       
   221 
       
   222 	IMPORT_C virtual void ConstructL(TUint aCreationFlags = ETuNone);
       
   223 
       
   224 	//MTM Functions
       
   225 	IMPORT_C void InstallMtmGroupL(const TDesC& aDatFile);
       
   226 	IMPORT_C void CreateServerMtmRegL(const TUid aMsgType, const TDesC& aHumanReadableName, const TMsvTestDllInfo& aServerMtm, const TMsvTestDllInfo& aClientMtm, const TMsvTestDllInfo& aUiMtm, const TMsvTestDllInfo& aUiDataMtm, const TUid aGroup, const TDesC& aDatFile);
       
   227 	IMPORT_C CBaseMtm* InstantiateClientMtmL(TUid aMtmType, TMsvId aServiceId);
       
   228 	IMPORT_C CBaseServerMtm* InstantiateServerMtmL(TUid aMtmType, TMsvId aServiceId);
       
   229 
       
   230 	//Service Functions
       
   231 	IMPORT_C TMsvId CreateServiceL(const TUid aMtm, TBool aReadOnly = EFalse, TBool aVisible = EFalse);
       
   232 	IMPORT_C void DeleteServiceL(TUid aMtm);
       
   233 	IMPORT_C void ServiceIdL(TUid aMtm, TMsvId& rFirstId, CMsvEntrySelection* rServiceIds = NULL);
       
   234 
       
   235 	IMPORT_C void WriteBodyDataL(TMsvId aId, const TFileName& aFilepath, CMsvStore& fileStore, TBool aReplace);
       
   236 	IMPORT_C void WriteFileDataL(TMsvId aId, const TFileName& aFileName, const TFileName& aLogFilepath, TBool aReplace);
       
   237 	IMPORT_C virtual void ListChildrenL(RFile& aFile, CDir& rfcFileList, TInt& aCount, TInt& aEntryCount, TBool aReplace = ETrue, TBool aOtherFiles = ETrue);
       
   238 	IMPORT_C void SpecifyLogsDir(const TFileName& aFilePath); 
       
   239 
       
   240 	IMPORT_C virtual void SetFolderType(TMsvEntry& entry, TPtrC& type);
       
   241 
       
   242 	virtual void DisplayChildDetailsL(const TMsvEntry& /*aEntry*/) {};
       
   243 	IMPORT_C void DisplayChildL(const TMsvEntry& entry);
       
   244 
       
   245 private:
       
   246 	void ListChildrenL(TBool aReplace, TBool aOtherFiles, RFile& aFile, CDir& rfcFileList);
       
   247 	void DoScheduleTimeL(TMsvId aEntryId, TTime& rEntryTime, TTime& rTaskSchedulerTime, TTaskInfo& rTaskInfo);
       
   248 
       
   249 	void ShowChildrenL(const CMsvEntry& aEntry, TInt aStart, TInt& aMore, TInt aMaxCount = 10);
       
   250 	TInt DoNavigateMessageStoreL(TMsvId& aParent, TInt& aStart);
       
   251 
       
   252 public:
       
   253 	CMsvSession*			iMsvSession;
       
   254 	CMsvEntry*				iMsvEntry;
       
   255 	CMsvServerEntry*		iServerEntry;
       
   256 	CClientMtmRegistry*		iClientMtmRegistry;
       
   257 	TBuf<2> 				iDriveName ;
       
   258 
       
   259 protected:
       
   260 	enum TClientOrServerSide
       
   261 		{
       
   262 		ENeither,
       
   263 		EClientSide,
       
   264 		EServerSide
       
   265 		} iClientServer;
       
   266 
       
   267 	TBool					iRegistryObjectAndControlCreated;
       
   268 	CMsvServer*				iMsvServer;
       
   269 	CServerMtmDllRegistry*	iServerMtmDllRegistry;
       
   270 	CMtmRegistryControl*	iMtmRegistryControl;
       
   271 	TMsvDummyObserver*		iDummyObserver;
       
   272 	TFileName				iLogsDir;
       
   273 	TFileName				iRfc822Dir;
       
   274 	TInt					iFileCount;
       
   275 
       
   276 	};
       
   277 
       
   278 #include <msvtestutils.inl>
       
   279 
       
   280 #endif