messagingfw/scheduledsendmtm/test/unit/inc/t_schedulesendutc.h
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2004-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 // T_ScheduleSend.h
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __T_SCHEDULESEND_H__
       
    19 #define __T_SCHEDULESEND_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 #include "msvtestutils.h"
       
    23 
       
    24 
       
    25 class RTest;
       
    26 
       
    27 class CScheduleSendTestUtils : public CMsvTestUtils
       
    28 	{
       
    29 public:
       
    30 
       
    31 	static CScheduleSendTestUtils* NewL(RTest& aTest, TUint aCreationFlags = ETuMinimalClientSide);
       
    32 	virtual ~CScheduleSendTestUtils();
       
    33 	
       
    34 	void DeletePigeonMessagesL(TMsvId aFolder);
       
    35 	TMsvId ServiceId();
       
    36 	
       
    37 	void NotifySaPhoneOnL();
       
    38 	void NotifySaPhoneOffL();
       
    39 	
       
    40 	void NotifySaSimOkL();
       
    41 	void NotifySaSimNotPresentL();
       
    42 	
       
    43 	void NotifySaNetworkAvailableL();
       
    44 	void NotifySaNetworkUnAvailableL();
       
    45 	
       
    46 	void UpdateSysAgentConditionsL();
       
    47 	void UpdatePendingConditionsTimeoutL(TTimeIntervalMinutes aTimeout);
       
    48 	
       
    49 public:	// methods from CMsvTestUtils
       
    50 
       
    51 	virtual void InstantiateClientMtmsL(){};
       
    52 	virtual void InstantiateServerMtmsL(){};
       
    53 	virtual void DeleteServicesL();
       
    54 	virtual void CreateServicesL();
       
    55 	virtual void FindExistingServicesL(){};
       
    56 	virtual void InstallMtmGroupsL();
       
    57 	virtual void CreateServerMtmRegsL();
       
    58 	
       
    59 public:	// methods from CTestUtils
       
    60 
       
    61 	virtual void Panic(TInt aPanic);
       
    62 
       
    63 private:
       
    64 
       
    65 	CScheduleSendTestUtils(RTest& aTest);
       
    66 	void ConstructL(TUint aCreationFlags);
       
    67 	
       
    68 	void InstallPigeonMtmGroupL();
       
    69 	void CreatePigeonServerMtmRegL();
       
    70 	
       
    71 private:
       
    72 
       
    73 	TMsvId				iServiceId;
       
    74 	};
       
    75 	
       
    76 class CTestEngine : public CBase
       
    77 	{
       
    78 public:
       
    79 
       
    80 	static CTestEngine* NewL(RTest& aTest);
       
    81 	virtual ~CTestEngine();
       
    82 	
       
    83 	void DoTestsL();
       
    84 	
       
    85 private:
       
    86 
       
    87 	CTestEngine();
       
    88 	void ConstructL(RTest& aTest);
       
    89 	
       
    90 private:
       
    91 
       
    92 	CScheduleSendTestUtils* iTestUtils;
       
    93 	
       
    94 	};
       
    95 	
       
    96 class MTestFolderObserverCallback
       
    97 	{
       
    98 public:
       
    99 	virtual void UpdatedMessageL(TMsvId aFolderId, TMsvId aMessage) =0;
       
   100 	virtual CMsvEntry* CreateEntryL(TMsvId aFolderId) =0;
       
   101 	};		
       
   102 
       
   103 class CTestFolderObserver : public CBase,
       
   104 							public MMsvEntryObserver
       
   105 	{
       
   106 public:
       
   107 
       
   108 	static CTestFolderObserver* NewL(MTestFolderObserverCallback& aCallback, TMsvId aFolderId);
       
   109 	virtual ~CTestFolderObserver();
       
   110 	
       
   111 	void StartObserverL();
       
   112 	void StopObserver();
       
   113 	
       
   114 private:	// methods from MMsvEntryObserver
       
   115 
       
   116 	virtual void HandleEntryEventL(TMsvEntryEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3);
       
   117 	
       
   118 private:
       
   119 
       
   120 	CTestFolderObserver(MTestFolderObserverCallback& aCallback, TMsvId aFolderId);
       
   121 	void ConstructL();
       
   122 
       
   123 private:
       
   124 	
       
   125 	MTestFolderObserverCallback&	iCallback;
       
   126 	TMsvId							iFolderId;
       
   127 	CMsvEntry*						iEntryForObserver;	
       
   128 	};							
       
   129 
       
   130 	
       
   131 /**
       
   132 Base class for test cases.
       
   133 
       
   134 Runs through state machine. Testing is done on sending state, schedule flag and 
       
   135 the pending conditions flag. 
       
   136 
       
   137 NOTE - the pending conditions should be checked only if the message has been
       
   138 scheduled for pending conditions. In this test harness, this indicated by the
       
   139 error value of the messsage being KErrorActionConditions.
       
   140 
       
   141 The values are checked after the messages are created - message created done by
       
   142 derived test cases. Then after the scheduling - again derived classed do the
       
   143 scheduling. The values are then checked after SchSendExe actually runs the schedule
       
   144 and then after the pigeon MTM does the send.
       
   145 
       
   146 NOTE - after the post-scheduling check, the test may may stop - the derived class
       
   147 controls this.
       
   148 
       
   149 Sending state and schedule flag values and whether to check the pending conditions
       
   150 flag or not - 
       
   151 
       
   152 Post creation 	- KMsvSendStateWaiting, false, false
       
   153 
       
   154 Post scheduling	- test-case dependent, true, false
       
   155 
       
   156 Pre-sending		- KMsvSendStateWaiting, true, false
       
   157 
       
   158 Post-sending	- KMsvSendStateSent, true, false
       
   159 
       
   160 Also, during the post-sending check, the schedule time is compared against the 
       
   161 current time. In most cases, the current time should be the same or later than
       
   162 the schedule time. In the cases where the message was scheduled for pending 
       
   163 conditions and the conditions were met, then the current time should be before 
       
   164 the scheduled time. Although for messages scheduled for pending conditions but
       
   165 the conditions have not been met, then the current time should be the same or
       
   166 later than the schedule time.
       
   167 */	
       
   168 class CTestScheduleSendBase : public CActive,
       
   169 							  public MTestFolderObserverCallback
       
   170 	{
       
   171 public:
       
   172 
       
   173 	virtual ~CTestScheduleSendBase();
       
   174 	void Start();
       
   175 	
       
   176 private:	// methods from CActive
       
   177 
       
   178 	virtual void RunL();
       
   179 	virtual void DoCancel();
       
   180 	virtual TInt RunError(TInt aError);
       
   181 	
       
   182 private:	// methods from MTestFolderObserverCallback
       
   183 
       
   184 	virtual void UpdatedMessageL(TMsvId aFolderId, TMsvId aMessage);
       
   185 	virtual CMsvEntry* CreateEntryL(TMsvId aFolderId);
       
   186 
       
   187 protected:
       
   188 
       
   189 	CTestScheduleSendBase(CScheduleSendTestUtils& aTestUtils);
       
   190 	void ConstructL();
       
   191 
       
   192 	void CompleteSelf();
       
   193 	void ClearFoldersL();
       
   194 	void TestComplete();
       
   195 	TMsvId CreateMessageL(TTime& aTime, TInt aError);
       
   196 	void TransferCommandL(TInt aCommand);
       
   197 	void CheckMessageDetailsL(TMsvId aId, TInt aState, TBool aScheduled, TBool aPendingConditions);
       
   198 		
       
   199 	CMsvSession& Session();
       
   200 	CMsvEntry& MsvEntry();
       
   201 	
       
   202 protected:
       
   203 
       
   204 	CScheduleSendTestUtils&	iTestUtils;
       
   205 	CMsvEntrySelection*		iSelection;
       
   206 	CMsvEntrySelection*		iPendingSent;
       
   207 	CMsvOperation*			iOperation;
       
   208 	TInt					iMessagesDone;
       
   209 	TBool					iConditionsMet;
       
   210 
       
   211 private:
       
   212 
       
   213 	const TDesC& GetStateText(TInt aState) const;
       
   214 	const TDesC& GetBoolText(TBool aBool) const;
       
   215 
       
   216 	TBool ConditionsMet() const;
       
   217 
       
   218 	virtual void UpdateSysAgentConditionsL();
       
   219 	virtual void CheckCreatedMessagesL();
       
   220 	virtual void CheckScheduledMessagesL();
       
   221 	virtual TBool NotifyMessagesScheduledL();
       
   222 	
       
   223 	virtual void CheckPreSendMessageL(TMsvId aId);
       
   224 	virtual void CheckSentMessageL(TMsvId aId);
       
   225 
       
   226 	virtual TInt PreSendState();	
       
   227 	virtual TInt SentState();
       
   228 
       
   229 	virtual void CreateMessagesL() =0;
       
   230 	virtual void ScheduleMessagesL() =0;
       
   231 	virtual TInt ScheduledState() =0;
       
   232 	virtual const TDesC& TestName() =0;
       
   233 
       
   234 private:
       
   235 
       
   236 	enum TScheduleSendTestState
       
   237 		{
       
   238 		EClearFolders,
       
   239 		EUpdateSysAgentConditions,
       
   240 		ECreateMessages,
       
   241 		ECheckCreatedMessages,
       
   242 		EScheduleMessages,
       
   243 		ECheckScheduledMessages,
       
   244 		EPendingMessagesSent,
       
   245 		EDone
       
   246 		};			
       
   247 	
       
   248 private:
       
   249 	
       
   250 	CTestFolderObserver*	iOutboxObserver;
       
   251 	CTestFolderObserver*	iSentFolderObserver;
       
   252 	TScheduleSendTestState	iState;
       
   253 	
       
   254 	};
       
   255 	
       
   256 /**
       
   257 Tests the CMsvScheduleSend::ScheduleL API.
       
   258 
       
   259 Creates 2 pigeon messages that are both schedule for immediate sending.
       
   260 
       
   261 Post scheduling sending state values - KMsvSendStateScheduled.
       
   262 */
       
   263 class CTestSchedule : public CTestScheduleSendBase
       
   264 	{
       
   265 public:
       
   266 
       
   267 	static CTestSchedule* NewL(CScheduleSendTestUtils& aTestUtils);
       
   268 	virtual ~CTestSchedule();
       
   269 	
       
   270 private:	// methods from CTestScheduleSendBase
       
   271 	
       
   272 	virtual void CreateMessagesL();
       
   273 	virtual void ScheduleMessagesL();
       
   274 	virtual TInt ScheduledState();
       
   275 	virtual const TDesC& TestName();
       
   276 
       
   277 private:
       
   278 	
       
   279 	CTestSchedule(CScheduleSendTestUtils& aTestUtils);
       
   280 	
       
   281 	};
       
   282 	
       
   283 /**
       
   284 Tests the CMsvScheduleSend::ReScheduleL API.
       
   285 
       
   286 Creates 2 pigeon messages that are both re-schedule for immediate sending.
       
   287 
       
   288 Post scheduling sending state values - KMsvSendStateResend.
       
   289 */
       
   290 class CTestReScheduleTime_1 : public CTestScheduleSendBase
       
   291 	{
       
   292 public:
       
   293 
       
   294 	static CTestReScheduleTime_1* NewL(CScheduleSendTestUtils& aTestUtils);
       
   295 	virtual ~CTestReScheduleTime_1();
       
   296 	
       
   297 private:	// methods from CTestScheduleSendBase
       
   298 	
       
   299 	virtual void CreateMessagesL();
       
   300 	virtual void ScheduleMessagesL();
       
   301 	virtual TInt ScheduledState();
       
   302 	virtual const TDesC& TestName();
       
   303 
       
   304 private:
       
   305 	
       
   306 	CTestReScheduleTime_1(CScheduleSendTestUtils& aTestUtils);
       
   307 	
       
   308 	};
       
   309 	
       
   310 /**
       
   311 Tests the CMsvScheduleSend::ReScheduleL API.
       
   312 
       
   313 Creates 2 pigeon messages - one is scheduled for immeduate sending and the other
       
   314 is scheduled for later sending.
       
   315 
       
   316 Post scheduling sending state values - KMsvSendStateResend.
       
   317 */
       
   318 class CTestReScheduleTime_2 : public CTestScheduleSendBase
       
   319 	{
       
   320 public:
       
   321 
       
   322 	static CTestReScheduleTime_2* NewL(CScheduleSendTestUtils& aTestUtils);
       
   323 	virtual ~CTestReScheduleTime_2();
       
   324 	
       
   325 private:	// methods from CTestScheduleSendBase
       
   326 	
       
   327 	virtual void CreateMessagesL();
       
   328 	virtual void ScheduleMessagesL();
       
   329 	virtual TInt ScheduledState();
       
   330 	virtual const TDesC& TestName();
       
   331 
       
   332 private:
       
   333 	
       
   334 	CTestReScheduleTime_2(CScheduleSendTestUtils& aTestUtils);
       
   335 	
       
   336 	};
       
   337 	
       
   338 /**
       
   339 Tests the CMsvScheduleSend::ReScheduleL API.
       
   340 
       
   341 Creates 2 pigeon messages that are both re-schedule for pending conditions. No
       
   342 timeout value is specified. The conditions are met.
       
   343 
       
   344 Post scheduling sending state values - KMsvSendStateResend.
       
   345 */
       
   346 class CTestRescheduleConditions_1 : public CTestScheduleSendBase
       
   347 	{
       
   348 public:
       
   349 
       
   350 	static CTestRescheduleConditions_1* NewL(CScheduleSendTestUtils& aTestUtils);
       
   351 	virtual ~CTestRescheduleConditions_1();
       
   352 	
       
   353 private:	// methods from CTestScheduleSendBase
       
   354 	
       
   355 	virtual void UpdateSysAgentConditionsL();
       
   356 	virtual TBool NotifyMessagesScheduledL();
       
   357 	virtual void CreateMessagesL();
       
   358 	virtual void ScheduleMessagesL();
       
   359 	virtual TInt ScheduledState();
       
   360 	virtual const TDesC& TestName();
       
   361 	
       
   362 private:
       
   363 	
       
   364 	CTestRescheduleConditions_1(CScheduleSendTestUtils& aTestUtils);
       
   365 
       
   366 	};
       
   367 	
       
   368 /**
       
   369 Tests the CMsvScheduleSend::ReScheduleL API.
       
   370 
       
   371 Creates 2 pigeon messages that are both re-schedule for pending conditions. A
       
   372 short timeout value is specified. The conditions are met.
       
   373 
       
   374 Post scheduling sending state values - KMsvSendStateResend.
       
   375 */
       
   376 class CTestRescheduleConditions_2 : public CTestScheduleSendBase
       
   377 	{
       
   378 public:
       
   379 
       
   380 	static CTestRescheduleConditions_2* NewL(CScheduleSendTestUtils& aTestUtils);
       
   381 	virtual ~CTestRescheduleConditions_2();
       
   382 	
       
   383 private:	// methods from CTestScheduleSendBase
       
   384 	
       
   385 	virtual void UpdateSysAgentConditionsL();
       
   386 	virtual TBool NotifyMessagesScheduledL();
       
   387 	virtual void CreateMessagesL();
       
   388 	virtual void ScheduleMessagesL();
       
   389 	virtual TInt ScheduledState();
       
   390 	virtual const TDesC& TestName();
       
   391 	
       
   392 private:
       
   393 	
       
   394 	CTestRescheduleConditions_2(CScheduleSendTestUtils& aTestUtils);
       
   395 
       
   396 	};
       
   397 	
       
   398 /**
       
   399 Tests the CMsvScheduleSend::ReScheduleL API.
       
   400 
       
   401 Creates 2 pigeon messages that are both re-schedule for pending conditions. A
       
   402 short timeout value is specified. Only one conditions is met - therefore timeout
       
   403 should occur.
       
   404 
       
   405 Post scheduling sending state values - KMsvSendStateResend.
       
   406 */
       
   407 class CTestRescheduleConditions_3 : public CTestScheduleSendBase
       
   408 	{
       
   409 public:
       
   410 
       
   411 	static CTestRescheduleConditions_3* NewL(CScheduleSendTestUtils& aTestUtils);
       
   412 	virtual ~CTestRescheduleConditions_3();
       
   413 	
       
   414 private:	// methods from CTestScheduleSendBase
       
   415 	
       
   416 	virtual void UpdateSysAgentConditionsL();
       
   417 	virtual TBool NotifyMessagesScheduledL();
       
   418 	virtual void CreateMessagesL();
       
   419 	virtual void ScheduleMessagesL();
       
   420 	virtual TInt ScheduledState();
       
   421 	virtual const TDesC& TestName();
       
   422 	
       
   423 private:
       
   424 	
       
   425 	CTestRescheduleConditions_3(CScheduleSendTestUtils& aTestUtils);
       
   426 
       
   427 	};
       
   428 
       
   429 /**
       
   430 Tests the CMsvScheduleSend::ReScheduleL API.
       
   431 
       
   432 Creates 2 pigeon messages - one is scheduled for immeduate sending and the other
       
   433 is scheduled for pending conditions.  A short timeout value is specified. The 
       
   434 conditions are met.
       
   435 
       
   436 Post scheduling sending state values - KMsvSendStateResend.
       
   437 */
       
   438 class CTestRescheduleMixed_1 : public CTestScheduleSendBase
       
   439 	{
       
   440 public:
       
   441 
       
   442 	static CTestRescheduleMixed_1* NewL(CScheduleSendTestUtils& aTestUtils);
       
   443 	virtual ~CTestRescheduleMixed_1();
       
   444 	
       
   445 private:	// methods from CTestScheduleSendBase
       
   446 	
       
   447 	virtual void UpdateSysAgentConditionsL();
       
   448 	virtual TBool NotifyMessagesScheduledL();
       
   449 	virtual void CreateMessagesL();
       
   450 	virtual void ScheduleMessagesL();
       
   451 	virtual TInt ScheduledState();
       
   452 	virtual const TDesC& TestName();
       
   453 	
       
   454 private:
       
   455 	
       
   456 	CTestRescheduleMixed_1(CScheduleSendTestUtils& aTestUtils);
       
   457 
       
   458 	};
       
   459 	
       
   460 /**
       
   461 Tests the CMsvScheduleSend::ReScheduleL API.
       
   462 
       
   463 Creates 2 pigeon messages that are both re-schedule to fail. 
       
   464 
       
   465 Post scheduling sending state values - KMsvSendStateWaiting. The schedule send
       
   466 component does not alter messages that are not re-scheduled.
       
   467 */
       
   468 class CTestFailed_1 : public CTestScheduleSendBase
       
   469 	{
       
   470 public:
       
   471 
       
   472 	static CTestFailed_1* NewL(CScheduleSendTestUtils& aTestUtils);
       
   473 	virtual ~CTestFailed_1();
       
   474 	
       
   475 private:	// methods from CTestScheduleSendBase
       
   476 	
       
   477 	virtual TBool NotifyMessagesScheduledL();
       
   478 	virtual void CreateMessagesL();
       
   479 	virtual void ScheduleMessagesL();
       
   480 	virtual TInt ScheduledState();
       
   481 	virtual const TDesC& TestName();
       
   482 	
       
   483 private:
       
   484 	
       
   485 	CTestFailed_1(CScheduleSendTestUtils& aTestUtils);
       
   486 	
       
   487 	};
       
   488 
       
   489 /**
       
   490 Tests the CMsvScheduleSend::ReScheduleL API.
       
   491 
       
   492 Creates 2 pigeon messages that are both re-schedule to fail, but on a second re-schedule. 
       
   493 
       
   494 Post scheduling sending state values	- KMsvSendStateResend.
       
   495 Sent sending state value			 	- KMsvSendStateWaiting. The schedule send
       
   496 component does not alter messages that are not re-scheduled.
       
   497 */
       
   498 class CTestFailed_2 : public CTestScheduleSendBase
       
   499 	{
       
   500 public:
       
   501 
       
   502 	static CTestFailed_2* NewL(CScheduleSendTestUtils& aTestUtils);
       
   503 	virtual ~CTestFailed_2();
       
   504 	
       
   505 private:	// methods from CTestScheduleSendBase
       
   506 	
       
   507 	virtual TBool NotifyMessagesScheduledL();
       
   508 	virtual void CreateMessagesL();
       
   509 	virtual void ScheduleMessagesL();
       
   510 	virtual TInt ScheduledState();
       
   511 	virtual TInt SentState();
       
   512 	virtual const TDesC& TestName();
       
   513 	
       
   514 private:
       
   515 	
       
   516 	CTestFailed_2(CScheduleSendTestUtils& aTestUtils);
       
   517 	
       
   518 	};
       
   519 
       
   520 #endif	// __T_SCHEDULESEND_H__