email/pop3andsmtpmtm/popservermtm/test/inc/T_mtmcmd.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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 // Generic MTM Test Harness
       
    15 // 
       
    16 //
       
    17 
       
    18 class CMtmTestCommand;
       
    19 class CMtmTestHarness : public CActive
       
    20 	{
       
    21 public:
       
    22 	static CMtmTestHarness* NewL(CBaseServerMtm& aServerMtm, CTestUtils& aTestUtils);
       
    23 	
       
    24 	// Test harness set up
       
    25 	void Reset();
       
    26 	void AddCommandL(CMtmTestCommand* aCommand);
       
    27 	TInt RunError(TInt aError);
       
    28 
       
    29 	// Run the test harness
       
    30 	void StartL(const TDesC& aTestName, TRequestStatus& aStatus);	// async
       
    31 	TInt StartL(const TDesC& aTestName);							// sync
       
    32 
       
    33 	// Status information
       
    34 	const TDesC8& Progress();
       
    35 	CBaseServerMtm&	ServerMtm();
       
    36 	TInt CommandError() const {return iCommandError;};
       
    37 
       
    38 	// Constructor & destructor
       
    39 	CMtmTestHarness(CBaseServerMtm& aServerMtm, CTestUtils& aTestUtils);
       
    40 	~CMtmTestHarness();
       
    41 	void ConstructL();
       
    42 
       
    43 	void DoCancel();
       
    44 	void RunL();
       
    45 
       
    46 private:
       
    47 	void RunCurrentCommandL();
       
    48 
       
    49 private:
       
    50 	CBaseServerMtm&						iServerMtm;
       
    51 	CArrayFixFlat<CMtmTestCommand*>*	iCommandList;
       
    52 	CMtmTestCommand*					iCurrentCommand;
       
    53 	TInt								iCommandIndex;
       
    54 	TRequestStatus*						iReportStatus;
       
    55 	TBool								iFailed;
       
    56 	CTestUtils&							iTestUtils;	
       
    57 	TInt								iCommandError;
       
    58 	};
       
    59 
       
    60 //
       
    61 
       
    62 class MCommandTester
       
    63 // This class can be used to check the state of the MTM before, during
       
    64 // and after a command has been issued.
       
    65 // In can be used to check that the message tree is as expected, or
       
    66 // could be combined with a timer to check progress as an operation is
       
    67 // being run.
       
    68 	{
       
    69 public:
       
    70 	virtual void InitialiseL() = 0;
       
    71 	// Called just before the command is started.
       
    72 
       
    73 	virtual void StartL() = 0;
       
    74 	// Called just after the command has been started.
       
    75 
       
    76 	virtual TBool EndL() = 0; 
       
    77 	// Called after the MTM command has completed.
       
    78 	// Returns ETrue if the results were as expected, otherwise return EFalse.
       
    79 	
       
    80 	virtual HBufC* TextInfoL() = 0;
       
    81 	// Returns some text to describe what (if anything) has failed.
       
    82 	};
       
    83 
       
    84 //
       
    85 
       
    86 class CMtmTestCommand : public CActive
       
    87 	{
       
    88 public:
       
    89 	// Run this command
       
    90 	virtual void ExecuteCommandL(TRequestStatus& aStatus) = 0;
       
    91 	TPtrC DetailsL();
       
    92 
       
    93 	void Queue(TRequestStatus& aReportStatus);
       
    94 
       
    95 	void DoCancel();
       
    96 	void RunL();
       
    97 	TInt RunError(TInt aError);
       
    98 
       
    99 	virtual ~CMtmTestCommand();
       
   100 	void CopySelectionL(const CMsvEntrySelection* aSelection);
       
   101 
       
   102 	void SetCommandTester(MCommandTester* aTester);
       
   103 	MCommandTester* Tester();
       
   104 
       
   105 protected:
       
   106 	virtual HBufC* CommandDetailsL() = 0;
       
   107 	CMtmTestCommand(CBaseServerMtm& aServerMtm);
       
   108 
       
   109 public:
       
   110 
       
   111 protected:
       
   112 	CMsvEntrySelection* iSelection;
       
   113 	TRequestStatus*		iReportStatus;
       
   114 	TInt				iError;
       
   115 	CBaseServerMtm&		iServerMtm;
       
   116 	MCommandTester*		iTester;
       
   117 	HBufC*				iDetails;
       
   118 	};
       
   119 
       
   120 //
       
   121 
       
   122 class CMtmTestChange : public CMtmTestCommand
       
   123 	{
       
   124 public:
       
   125 	void ExecuteCommandL(TRequestStatus& aStatus);
       
   126 	HBufC* CommandDetailsL();
       
   127 	static CMtmTestChange* NewL(CBaseServerMtm& aServerMtm, TMsvEntry aNewEntry);
       
   128 	CMtmTestChange(CBaseServerMtm& aServerMtm, TMsvEntry aNewEntry);
       
   129 
       
   130 private:
       
   131 	TMsvEntry iNewEntry;
       
   132 	};
       
   133 
       
   134 //
       
   135 
       
   136 class CMtmTestDeleteAll : public CMtmTestCommand
       
   137 	{
       
   138 public:
       
   139 	void ExecuteCommandL(TRequestStatus& aStatus);
       
   140 	HBufC* CommandDetailsL();
       
   141 	static CMtmTestDeleteAll* NewL(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection);
       
   142 	CMtmTestDeleteAll(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection);
       
   143 	};
       
   144 
       
   145 //
       
   146 
       
   147 class CMtmTestCopyToLocal : public CMtmTestCommand
       
   148 	{
       
   149 public:
       
   150 	void ExecuteCommandL(TRequestStatus& aStatus);
       
   151 	HBufC* CommandDetailsL();
       
   152 	static CMtmTestCopyToLocal* NewL(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection, TMsvId aDest);
       
   153 	CMtmTestCopyToLocal(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection, TMsvId aDest);
       
   154 
       
   155 private:
       
   156 	TMsvId iDest;
       
   157 	};
       
   158 
       
   159 //
       
   160 
       
   161 class CMtmTestCopyFromLocal : public CMtmTestCommand
       
   162 	{
       
   163 public:
       
   164 	void ExecuteCommandL(TRequestStatus& aStatus);
       
   165 	HBufC* CommandDetailsL();
       
   166 	static CMtmTestCopyFromLocal* NewL(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection, TMsvId aDest);
       
   167 	CMtmTestCopyFromLocal(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection, TMsvId aDest);
       
   168 
       
   169 private:
       
   170 	TMsvId iDest;
       
   171 	};
       
   172 
       
   173 //
       
   174 
       
   175 class CMtmTestTopPopulate : public CMtmTestCommand
       
   176 	{
       
   177 public:
       
   178 	void ExecuteCommandL(TRequestStatus& aStatus);
       
   179 	HBufC* CommandDetailsL();
       
   180 	static CMtmTestTopPopulate* NewL(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection, TMsvId aDest);
       
   181 	CMtmTestTopPopulate(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection, TMsvId aDest);
       
   182 
       
   183 private:
       
   184 	TMsvId iDest;
       
   185 	};
       
   186 
       
   187 //
       
   188 
       
   189 class CMtmTestCopyWithinService : public CMtmTestCommand
       
   190 	{
       
   191 public:
       
   192 	void ExecuteCommandL(TRequestStatus& aStatus);
       
   193 	HBufC* CommandDetailsL();
       
   194 	static CMtmTestCopyWithinService* NewL(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection, TMsvId aDest);
       
   195 	CMtmTestCopyWithinService(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection, TMsvId aDest);
       
   196 
       
   197 private:
       
   198 	TMsvId iDest;
       
   199 	};
       
   200 
       
   201 //
       
   202 
       
   203 class CMtmTestMoveToLocal : public CMtmTestCommand
       
   204 	{
       
   205 public:
       
   206 	void ExecuteCommandL(TRequestStatus& aStatus);
       
   207 	HBufC* CommandDetailsL();
       
   208 	static CMtmTestMoveToLocal* NewL(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection, TMsvId aDest);
       
   209 	CMtmTestMoveToLocal(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection, TMsvId aDest);
       
   210 
       
   211 private:
       
   212 	TMsvId iDest;
       
   213 	};
       
   214 
       
   215 //
       
   216 
       
   217 class CMtmTestMoveFromLocal : public CMtmTestCommand
       
   218 	{
       
   219 public:
       
   220 	void ExecuteCommandL(TRequestStatus& aStatus);
       
   221 	HBufC* CommandDetailsL();
       
   222 	static CMtmTestMoveFromLocal* NewL(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection, TMsvId aDest);
       
   223 	CMtmTestMoveFromLocal(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection, TMsvId aDest);
       
   224 
       
   225 private:
       
   226 	TMsvId iDest;
       
   227 	};
       
   228 
       
   229 //
       
   230 
       
   231 class CMtmTestMoveWithinService : public CMtmTestCommand
       
   232 	{
       
   233 public:
       
   234 	void ExecuteCommandL(TRequestStatus& aStatus);
       
   235 	HBufC* CommandDetailsL();
       
   236 	static CMtmTestMoveWithinService* NewL(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection, TMsvId aDest);
       
   237 	CMtmTestMoveWithinService(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection, TMsvId aDest);
       
   238 
       
   239 private:
       
   240 	TMsvId iDest;
       
   241 	};
       
   242 
       
   243 //
       
   244 
       
   245 class CMtmTestStartCommand : public CMtmTestCommand
       
   246 	{
       
   247 public:
       
   248 	void ExecuteCommandL(TRequestStatus& aStatus);
       
   249 	HBufC* CommandDetailsL();
       
   250 	static CMtmTestStartCommand* NewL(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection, TInt aCommandId, TDesC8& aParamter);
       
   251 	~CMtmTestStartCommand();
       
   252 	CMtmTestStartCommand(CBaseServerMtm& aServerMtm, const CMsvEntrySelection* aSelection, TInt aCommandId, TDesC8& aParamter);
       
   253 
       
   254 private:
       
   255 	TInt iCommandId;
       
   256 	HBufC8* iParameter;
       
   257 	};
       
   258 
       
   259 //
       
   260 
       
   261 class CMtmTestCommandOnAllMessages : public CMtmTestCommand
       
   262 // Runs a command on all messages directly under a given message entry.
       
   263 // This command object takes ownership of the given command.
       
   264 // The given command should have all of it's parameters set before
       
   265 // this command is created, with the exception of it's selection
       
   266 // parameter.
       
   267 	{
       
   268 public:
       
   269 	void ExecuteCommandL(TRequestStatus& aStatus);
       
   270 	HBufC* CommandDetailsL();
       
   271 	static CMtmTestCommandOnAllMessages* NewL(CBaseServerMtm& aServerMtm, CMtmTestCommand* aCommand, TMsvId aRootId, CMsvServerEntry& aEntry);
       
   272 	~CMtmTestCommandOnAllMessages();
       
   273 	CMtmTestCommandOnAllMessages(CBaseServerMtm& aServerMtm, CMtmTestCommand* aCommand, TMsvId aRootId, CMsvServerEntry& aEntry);
       
   274 
       
   275 private:
       
   276 	CMtmTestCommand* iRealCommand;
       
   277 	TMsvId iRootId;
       
   278 	CMsvServerEntry& iServerEntry;
       
   279 	};
       
   280 
       
   281 //
       
   282 
       
   283 class CMtmTestCommandOnSecondMessage : public CMtmTestCommand
       
   284 // Runs a command on the second message directly under a given message entry.
       
   285 // This command object takes ownership of the given command.
       
   286 // The given command should have all of it's parameters set before
       
   287 // this command is created, with the exception of it's selection
       
   288 // parameter.
       
   289 	{
       
   290 public:
       
   291 	void ExecuteCommandL(TRequestStatus& aStatus);
       
   292 	HBufC* CommandDetailsL();
       
   293 	static CMtmTestCommandOnSecondMessage* NewL(CBaseServerMtm& aServerMtm, CMtmTestCommand* aCommand, TMsvId aRootId, CMsvServerEntry& aEntry);
       
   294 	~CMtmTestCommandOnSecondMessage();
       
   295 	CMtmTestCommandOnSecondMessage(CBaseServerMtm& aServerMtm, CMtmTestCommand* aCommand, TMsvId aRootId, CMsvServerEntry& aEntry);
       
   296 
       
   297 private:
       
   298 	CMtmTestCommand* iRealCommand;
       
   299 	TMsvId iRootId;
       
   300 	CMsvServerEntry& iServerEntry;
       
   301 	};
       
   302 
       
   303 //
       
   304 
       
   305 class CMtmTestCommandOnChildrenOf2ndMsg : public CMtmTestCommand
       
   306 // Runs a command on the children of the second message directly under a given message entry.
       
   307 // This command object takes ownership of the given command.
       
   308 // The given command should have all of it's parameters set before
       
   309 // this command is created, with the exception of it's selection
       
   310 // parameter.	
       
   311 	{
       
   312 public:
       
   313 	void ExecuteCommandL(TRequestStatus& aStatus);
       
   314 	HBufC* CommandDetailsL();
       
   315 	static CMtmTestCommandOnChildrenOf2ndMsg* NewL(CBaseServerMtm& aServerMtm, CMtmTestCommand* aCommand, TMsvId aRootId, CMsvServerEntry& aEntry);
       
   316 	~CMtmTestCommandOnChildrenOf2ndMsg();
       
   317 	CMtmTestCommandOnChildrenOf2ndMsg(CBaseServerMtm& aServerMtm, CMtmTestCommand* aCommand, TMsvId aRootId, CMsvServerEntry& aEntry);
       
   318 
       
   319 private:
       
   320 	CMtmTestCommand* iRealCommand;
       
   321 	TMsvId iRootId;
       
   322 	CMsvServerEntry& iServerEntry;
       
   323 	};
       
   324 
       
   325 //
       
   326 
       
   327 class CMtmTestCommandOnSpecifiedMessages : public CMtmTestCommand
       
   328 // Runs a command on the specified messages directly under a given message entry.
       
   329 // This command object takes ownership of the given command.
       
   330 // The given command should have all of it's parameters set before
       
   331 // this command is created, with the exception of it's selection
       
   332 // parameter.
       
   333 	{
       
   334 public:
       
   335 	void ExecuteCommandL(TRequestStatus& aStatus);
       
   336 	HBufC* CommandDetailsL();
       
   337 	static CMtmTestCommandOnSpecifiedMessages* NewL(CBaseServerMtm& aServerMtm, CMtmTestCommand* aCommand, TMsvId aRootId, CMsvServerEntry& aEntry, CMsvEntrySelection* aSpecifiedEntries);
       
   338 	~CMtmTestCommandOnSpecifiedMessages();
       
   339 	CMtmTestCommandOnSpecifiedMessages(CBaseServerMtm& aServerMtm, CMtmTestCommand* aCommand, TMsvId aRootId, CMsvServerEntry& aEntry, CMsvEntrySelection* aSpecifiedEntries);
       
   340 
       
   341 private:
       
   342 	CMtmTestCommand* iRealCommand;
       
   343 	TMsvId iRootId;
       
   344 	CMsvServerEntry& iServerEntry;
       
   345 	CMsvEntrySelection* iSpecifiedEntries;
       
   346 	};
       
   347 
       
   348 //
       
   349 
       
   350 class CMtmTestCommandOnSingleMessage : public CMtmTestCommand
       
   351 // Runs a command on the specified message passed in the constructor
       
   352 // This command object takes ownership of the given command.
       
   353 // The given command should have all of it's parameters set before
       
   354 // this command is created, with the exception of it's selection
       
   355 // parameter.
       
   356 	{
       
   357 public:
       
   358 	void ExecuteCommandL(TRequestStatus& aStatus);
       
   359 	HBufC* CommandDetailsL();
       
   360 	static CMtmTestCommandOnSingleMessage* NewL(CBaseServerMtm& aServerMtm, CMtmTestCommand* aCommand, TMsvId aRootId, CMsvServerEntry& aEntry, TMsvId aSpecifiedEntry);
       
   361 	~CMtmTestCommandOnSingleMessage();
       
   362 	CMtmTestCommandOnSingleMessage(CBaseServerMtm& aServerMtm, CMtmTestCommand* aCommand, TMsvId aRootId, CMsvServerEntry& aEntry, TMsvId aSpecifiedEntry);
       
   363 
       
   364 private:
       
   365 	CMtmTestCommand* iRealCommand;
       
   366 	TMsvId iRootId;
       
   367 	CMsvServerEntry& iServerEntry;
       
   368 	TMsvId iSpecifiedEntry;
       
   369 	};
       
   370 /*
       
   371 class CMtmTestCommandOnSingleMessage : public CMtmTestCommand
       
   372 
       
   373 	{
       
   374 public:
       
   375 	void ExecuteCommandL(TRequestStatus& aStatus);
       
   376 	HBufC* CommandDetailsL();
       
   377 	static CMtmTestCommandOnSingleMessage* NewL(CBaseServerMtm& aServerMtm, CMtmTestCommand* aCommand, TUint aSpecificEntry);
       
   378 	~CMtmTestCommandOnSingleMessage();
       
   379 	CMtmTestCommandOnSingleMessage(CBaseServerMtm& aServerMtm, CMtmTestCommand* aCommand, TUint	aSpecificEntry);
       
   380 
       
   381 private:
       
   382 	CMtmTestCommand* iRealCommand;
       
   383 	TUint iSpecifiedEntry;
       
   384 	};
       
   385 */
       
   386 //