messagingappbase/smsmtm/test/inc/T_SmsSendRecv.h
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 27 e4592d119491
child 37 518b245aa84c
child 79 2981cb3aa489
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
     1 // Copyright (c) 1999-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 #include <smstestbase.h>
       
    17 
       
    18 #include <msvapi.h>
       
    19 #include <smsuaddr.h>
       
    20 
       
    21 _LIT(KSmsSendRecvTestName, "Send and Receive");
       
    22 
       
    23 class CEntryObserver : public CBase, public MMsvEntryObserver
       
    24 	{
       
    25 public:
       
    26 	void HandleEntryEventL(TMsvEntryEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3);
       
    27 	~CEntryObserver();
       
    28 public:
       
    29 
       
    30 	static CEntryObserver* NewL(CSmsTestUtils& aTestUtils, const TInt& aCurrentMessageNum);
       
    31 	const CMsvEntrySelection& Received() const {return *iReceived;}
       
    32 	TMsvId Received(TInt aItem) const {return iReceived->At(aItem);}
       
    33 	TInt Count() const {return iReceived->Count();}
       
    34 	TMsvId LastReceived() const {return Count() ? Received(Count() - 1) : KErrNotFound;}
       
    35 	TMsvId ItemReceived(TInt aItem) const {return Count() ? Received(aItem) : KErrNotFound;}
       
    36 
       
    37 private:
       
    38 
       
    39 	void CheckReceivedMessageL(TMsvId aId);
       
    40 	CEntryObserver(CSmsTestUtils& aTestUtils, const TInt& aCurrentMessageNum);
       
    41 	
       
    42 	CMsvEntrySelection* iReceived;			//< An array containing the received messages
       
    43 	const TInt& iCurrentMessageNum;			//< Number of the current message
       
    44 	CSmsTestUtils& iSmsTest;				//< Sms Test Util
       
    45 	};
       
    46 
       
    47 const TTimeIntervalMicroSeconds32 KWaitForReceiveIteration = 2000000;
       
    48 const TTimeIntervalMicroSeconds32 KMaxWaitForMsg = 90000000;
       
    49 const TTimeIntervalMicroSeconds32 KWaitForWatchersToStart = 20000000;
       
    50 
       
    51 const TTimeIntervalMicroSeconds32 KWaitForWatchersToStartDisplayInterval = 5000000;
       
    52 const TTimeIntervalMicroSeconds32 KWaitForWatchersToDie = 2000000;
       
    53 
       
    54 //Command Line Switches
       
    55 _LIT(KParseAfterReceive, "/p");
       
    56 _LIT(KSaveAfterReceive, "/s");
       
    57 _LIT(KWaitForever, "/w");
       
    58 _LIT(KTestBifs, "/b");
       
    59 _LIT(KRunEmsTests, "/e"); // if on, uses ems script instead
       
    60 
       
    61 //Test Bifs
       
    62 _LIT(KSendRecvScript, "sendrecv.script");
       
    63 _LIT(KSendRecvEmsScript, "sendrecv_ems.script");
       
    64 _LIT(KTestBif1, "Koala.rsc");
       
    65 _LIT(KTestBif2, "Giraffe.rsc");
       
    66 _LIT(KBifDir, "c:\\system\\bif\\"); 
       
    67 const TTimeIntervalMicroSeconds32 KBifWait = 4000000;
       
    68 
       
    69 class CSmsSendRecvTest : public CSmsTestBase
       
    70 	{
       
    71 public:
       
    72 	static CSmsSendRecvTest* NewLC(CSmsTestUtils& aSmsTest, const TDesC& aScriptFile, TInt& aNextTest);
       
    73 	~CSmsSendRecvTest();
       
    74 
       
    75 private:
       
    76 	CSmsSendRecvTest(CSmsTestUtils& aSmsTest, const TDesC& aScriptFile, TInt& aNextTest);
       
    77 
       
    78 	TBool WatchersAlreadyRunningL();
       
    79 
       
    80 	void TestSendingL();
       
    81 	TBool SendNextMessageL();
       
    82 	void StartWatcherL();
       
    83 	void TestWaitForReceiveL();
       
    84 	void TestParseL();
       
    85 	void DoRunTestParseL();
       
    86 
       
    87 	void TestBifsL();
       
    88 	void TestAddBifL(const TDesC& aBifName);
       
    89 	void TestRemoveBifL(const TDesC& aBifName);
       
    90 
       
    91 	void ConstructL();
       
    92 
       
    93 	void RunL();
       
    94 	void DoCancel();
       
    95 
       
    96 	TInt RunError(TInt aError);
       
    97 	void RunComplete();
       
    98 
       
    99 	void ShowMenuL();
       
   100 	void RunAutoL();
       
   101 
       
   102 	void DoRunSendingL();
       
   103 	void DoRunWaitingToReceiveL();
       
   104 	void DoWaitL();
       
   105 
       
   106 	void WaitForExtraL();
       
   107 	void DoRunWaitForExtraL();
       
   108 
       
   109 	TInt CountRecipientsL(TMsvId aId);
       
   110 	void StoreMessageL(TMsvId aId, const CSmsHeader& aHeader);
       
   111 
       
   112 	void SendMessageIndicationL(TUint8 aMessageType = TSmsUtilities::EVoiceMessageWaiting, TUint8 aMessageCount=1);
       
   113 	void SendReplaceTypeMessageL();
       
   114 	TInt GetIndexOfSectionL(const TDesC& aSectionName);
       
   115 	void TestReplyL();
       
   116  	void SetSmsSettingsL();
       
   117 
       
   118 
       
   119 	CEntryObserver* iEntryObserver;			//< An Entry Observer
       
   120 
       
   121 	TInt iSent;								//< Total number of messages sent
       
   122 	TInt iTotal;							//< Total number of messages received
       
   123 
       
   124 	TInt iCountWaits;						//< Count to wait 
       
   125 	
       
   126 	CTestUtilsWatcherStarter* iWatchers;	//< A Watcher
       
   127 	CMsvEntry* iEntryForObserver;			//< A Msv Entry
       
   128 	TInt iCurrentMessageNum;				//< The number of the current message
       
   129 	TBool iParse;							//< A boolean
       
   130 	TBool iSaveToFile;						//< A boolean
       
   131 	TBool iWaitForever;						//< A boolean
       
   132 	TInt iMsgVCalenderIndex;				//< store the index of vCalender received message
       
   133 	
       
   134 	enum TSmsSendTestState
       
   135 	/**	@enum	TSmsSendTestState
       
   136 	 *	Enum defining the states of this test harness
       
   137 	 */
       
   138 		{
       
   139 		EStateWaiting,
       
   140 		EStateSending,
       
   141 		EStateWaitingToReceive,
       
   142 		EStateParsing,
       
   143 		EStateMessageReceived,
       
   144 		EStateWaitingToReceiveAnyExtra
       
   145 		} iState;
       
   146 
       
   147 	RSocketServ iSocketServ;	//< A Socket Server
       
   148 	RSocket iSocket;			//< A Socket
       
   149 	TBool iTestBifs;			
       
   150 	};