messagingfw/wappushfw/PushMsgEntry/test/t_pushentry.h
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     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 // WAP Push - ConnectionManager Test Harness
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __T_PUSHMESSAGE_H__
       
    19 #define __T_PUSHMESSAGE_H__
       
    20 
       
    21 
       
    22 #include <msvapi.h>
       
    23 #include  <pushentry.h>
       
    24 #include  <push/cmultipartpushmsgentry.h>
       
    25 #include  <push/cunknownpushmsgentry.h>
       
    26 
       
    27 #include  <push/csipushmsgentry.h>
       
    28 #include  <push/cslpushmsgentry.h>
       
    29 #include  <push/sislpushmsgutils.h>
       
    30 
       
    31 // Forward references:
       
    32 
       
    33 class CSIPushMsgEntry;
       
    34 class CSLPushMsgEntry;
       
    35 class CUnknownPushMsgEntry;
       
    36 class CMultipartPushMsgEntry;
       
    37 
       
    38 const TUint8 KMessageHeader2[] = 
       
    39 	{
       
    40 	0xAF,  //Content type "text/vnd.wap.sl"
       
    41 	0x92,  // Date
       
    42 	0x04,  // length of field
       
    43 	0x39,  // Monday 15 August 2000 10:41:37 GMT
       
    44 	0x90,	
       
    45 	0x6a,
       
    46 	0xd0,
       
    47 	0x94,  // Expires 
       
    48 	0x04,  // length of field
       
    49 	0x39,  // Monday 15 August 2000 10:41:37 GMT
       
    50 	0x9a,	
       
    51 	0x6a,
       
    52 	0xd0,
       
    53 	0xAF,  //X-Wap-Application-ID
       
    54 	0x41,   // 'A'
       
    55 	0x4E,
       
    56 	0x20,
       
    57 	0x50,
       
    58 	0x50,
       
    59 	0x4C,
       
    60 	0x49,
       
    61 	0x43,
       
    62 	0x41,
       
    63 	0x54,
       
    64 	0x49,
       
    65 	0x4F,
       
    66 	0x4E, 
       
    67 	0x20,
       
    68 	0x46,
       
    69 	0x4F,
       
    70 	0x52,
       
    71 	0x20,
       
    72 	0x59,
       
    73 	0x4F,
       
    74 	0x57
       
    75 	};
       
    76 
       
    77 const TUint8 KMessageHeader3[]=
       
    78 	{
       
    79 	0xB4,  //Content type "text/vnd.wap.wml"
       
    80 	0x94,  // Date
       
    81 	0x04,  // length of field
       
    82 	0x35,  // Thur 23 Apr 1998 13:41:37 GMT
       
    83 	0x3F,	
       
    84 	0x45,
       
    85 	0x11,
       
    86 	0xAF,	// X-Wap-Application ID
       
    87 	0x83	// Id is short integer 3.
       
    88 	};
       
    89 
       
    90 //Literals
       
    91 const TTime KDateExpiry1(_L("19991130:235959.0000"));
       
    92 const TTime KDateExpiry2(_L("20000101:000000.0000"));
       
    93 const TTime KDateExpiry3(_L("20000625:235959.0000"));
       
    94 const TTime KDateExpiry4(_L("20011130:235959.0000"));
       
    95 const TTime KDateExpiry5(_L("20050610:120912.0001"));
       
    96 const TTime KDateExpiry6(_L("20000101:001000.0000"));
       
    97 const TTime KDateExpiry7(_L("20040212:010000.0001"));
       
    98 const TTime KDateExpiry8(_L("20020901:000000.0000"));
       
    99 const TTime KDateExpiry9(_L("20030415:200000.0001"));
       
   100 const TTime KDateExpiry10(_L("20000921:000000.0000"));
       
   101 
       
   102 _LIT8(KFrom, "Big Joe Bloggs in Peckham");
       
   103 _LIT8(KDummyBody, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz1234567890");
       
   104 _LIT8(KDummyBody2,"afsdaf9vbzc823rASF3safB..asdfm,ca\\k@#3fv-3tqas=`12'as,t,we;'t[!");
       
   105 
       
   106 _LIT(KUrl1, "http://www.here.com");
       
   107 _LIT(KUrl2,"mmm://www.bigcorp.com");
       
   108 _LIT(KUrl3, "http:://www.news.com");
       
   109 _LIT(KUrl4, "http://www.maybe.com");
       
   110 _LIT(KUrl5, "http://www.dontknow.com");
       
   111 _LIT(KUrl6, "http://www.somecompany.com");
       
   112 _LIT(KUrl7, "http://www.buyit.com");
       
   113 _LIT(KUrl8, "http://www.lemon.com");
       
   114 _LIT(KUrl9, "http://www.bigapple.com");
       
   115 _LIT(KUrl10, "http://www.manypcs.com");
       
   116 _LIT8(KUrl11, "http://www.zipadee.com");
       
   117 
       
   118 _LIT(KSiID1, "99228833@global.com");
       
   119 _LIT(KSiID2, "afhHIN1731@wappo.co.uk");
       
   120 _LIT(KSiID3, "HU124REQWR9UJAKM@nowhere.com");
       
   121 _LIT(KSiID4, "AJGAET941054@somewhere.com");
       
   122 _LIT(KSiID5, "bluragaeh@nowhere.com");
       
   123 _LIT(KSiID6, "asgdk9815@somecompany.com");
       
   124 _LIT(KSiID7, "abcdefgig@buyit.com");
       
   125 _LIT(KSiID8, "q1w2ew3r4@lemon.com");
       
   126 _LIT(KSiID9, "ft1jjf019@bigapple.com");
       
   127 _LIT(KSiID10, "afd09@manypcs.com");
       
   128 
       
   129 _LIT(KUknContent,"image/jpeg" );
       
   130 _LIT(KMultiContent, "multipart/related");
       
   131 
       
   132 
       
   133 //
       
   134 //          CExampleScheduler: INTERFACE        //
       
   135 //
       
   136 class CTestScheduler : public CActiveScheduler
       
   137 	{
       
   138 public:
       
   139 	void		Error(TInt anError) const;
       
   140 	};
       
   141 
       
   142 //
       
   143 //          CMessageDetails: INTERFACE          //
       
   144 //
       
   145 class CMessageDetails:public CBase
       
   146 	{
       
   147 public:
       
   148 	static CMessageDetails* NewL();
       
   149 	~CMessageDetails();
       
   150 	void ResetL();
       
   151 	TBool	iNullEntries;
       
   152 	TInt32  iMtm;
       
   153 	TInt32  iPushMsgType;   //Uid of message type goes in iBioType
       
   154 	TUint	iStatusFlag;
       
   155 	TUint	iActionFlag;
       
   156 	HBufC* 	iSiId;
       
   157 	TTime	iCreated;
       
   158 	TTime	iExpires;
       
   159 	HBufC*  iURL;
       
   160 	HBufC*  iText;
       
   161 	HBufC8* iFrom;
       
   162 	HBufC8* iHeader;
       
   163 	HBufC*  iContentType;
       
   164 	HBufC8* iMessageBody;
       
   165 
       
   166 	HBufC*  iMsgDetails;
       
   167 	HBufC*  iMsgDescription;
       
   168 	HBufC*	iFilename;
       
   169 
       
   170 private:
       
   171 	void ConstructL();
       
   172 	CMessageDetails();
       
   173 	};
       
   174 
       
   175 	
       
   176 
       
   177 
       
   178 //
       
   179 //          CPushEntryTester: INTERFACE          //
       
   180 //
       
   181 class CPushEntryTester: public CActive, public MMsvSessionObserver
       
   182 	{
       
   183 public:
       
   184 	
       
   185 	enum TEntryTestState 
       
   186 		{
       
   187 		ETestInitialising,
       
   188 	    ETestSIGetSet,
       
   189 		ETestSISaveRetrieve,
       
   190 		ETestSISaveRetrieveWithStringAppID,
       
   191 		ETestSISaveRetrieveWithIntAppID,
       
   192 		ETestSIGetSetNull,
       
   193 		ETestSISaveRetrieveNull,
       
   194 		ETestSIChangeEntry,
       
   195 		ETestSLGetSet,
       
   196 		ETestSLSaveRetrieve,
       
   197 		ETestSLGetSetNull,		
       
   198 		ETestSLSaveRetrieveNull,
       
   199 		ETestSLChangeEntry,
       
   200 		ETestMultiGetSet,
       
   201 		ETestMultiSaveRetrieve,
       
   202 		ETestMultiGetSetNull,
       
   203 		ETestMultiSaveRetrieveNull,
       
   204 		ETestUnknownGetSet,
       
   205 		ETestUnknownSaveRetrieve,
       
   206 		ETestUnknownSaveRetrieveWithFilename,
       
   207 		ETestUnknownGetSetNull,
       
   208 		ETestUnknownSaveRetrieveNull,
       
   209 		ETestUnknownSaveRetrieveNullWithFilename,
       
   210 		ETestUnknownChangeEntry,
       
   211 		ETestUnknownChangeEntryWithFilename,
       
   212 		ETestSIFindSiId,
       
   213 		ETestSIFindSiIdNull,
       
   214 		ETestSIFindSiUrl,
       
   215 		ETestSIFindSiUrlNull,
       
   216 		ETestSLFindUrl,
       
   217 		ETestSLFindUrlNull,
       
   218 		ETestSIGetHiAction,
       
   219 		ETestSLGetHiAction,
       
   220 		ETestGetExpiry,
       
   221 		ETestGetNextExpiry,
       
   222 		ETestComplete
       
   223 	};
       
   224 	static CPushEntryTester* NewL(MWapPushLog& aLog);
       
   225 	~CPushEntryTester();
       
   226 
       
   227 	void HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) {}
       
   228 	void StartL();
       
   229 	inline void SetPushServiceId(TMsvId aId) {iPushServiceId = aId;}
       
   230 	inline void SetPushFolderId(TMsvId aId) {iPushMsgFolderId = aId;}
       
   231 	
       
   232 
       
   233 
       
   234 private:
       
   235 	CPushEntryTester(MWapPushLog& aLog);
       
   236 	void ConstructL();
       
   237 
       
   238 	void RunL();
       
   239 	void DoCancel();
       
   240 	void QueueOperationAsync(TInt aErr);
       
   241 	TInt RunError(TInt aError);
       
   242 
       
   243 
       
   244 	void CreateMsvMembersL();
       
   245 	void CreateHeaders();
       
   246 	void CreateMsgDetailsL(TBool aNotNullFields);
       
   247 	void CreateMoreSiMessagesL();
       
   248 	void CreateMoreSLMessagesL();
       
   249 
       
   250 	
       
   251 	void OutputTMsvEntryDetailsL(const TMsvEntry& aEntry);
       
   252 	void OutputPushMsgDetailsL(const CPushMsgEntryBase& aSIEntry);
       
   253 
       
   254 	//Overloaded output functions
       
   255 	void OutputMessageDetailsL(CSIPushMsgEntry& aSIEntry);
       
   256 	void OutputMessageDetailsL(CSLPushMsgEntry& aSLEntry);
       
   257 	void OutputMessageDetailsL(CUnknownPushMsgEntry& aUnknownEntry);
       
   258 	void OutputMessageDetailsL(CMultiPartPushMsgEntry& aMultiEntry);
       
   259 
       
   260 	// Following tests get/Set, and Save/Retrieve with/without heap testing. 
       
   261 	void SiGetSetTestL();
       
   262 	void SiSaveRetrieveTestL();
       
   263 	// Following used for Get/Set and Save/Retrieve operations
       
   264 	CSIPushMsgEntry* DoSiCreateTestL();
       
   265 	void DoSiSetTestL(CSIPushMsgEntry& aSiEntry);
       
   266 	CSIPushMsgEntry* DoSiSaveTestL();
       
   267 	CSIPushMsgEntry* DoSiRetrieveTestL(TMsvId aMsgId);
       
   268 	
       
   269 	// Following tests get/Set, and Save/Retrieve with/without heap testing. 
       
   270 	void SlGetSetTestL();
       
   271 	void SlSaveRetrieveTestL();
       
   272 
       
   273 	CSLPushMsgEntry*  DoSlCreateTestL();
       
   274 	void DoSlSetTestL(CSLPushMsgEntry& aSlEntry);
       
   275 	CSLPushMsgEntry* DoSlSaveTestL();
       
   276 	CSLPushMsgEntry* DoSlRetrieveTestL(TMsvId aId);
       
   277 
       
   278 
       
   279 	void MultiGetSetTestL();
       
   280 	void MultiSaveRetrieveTestL();
       
   281 	CMultiPartPushMsgEntry* DoMultiCreateTestL();
       
   282 	void DoMultiSetTestL(CMultiPartPushMsgEntry& aMultiEntry);
       
   283 	CMultiPartPushMsgEntry* DoMultiSaveTestL();
       
   284 	CMultiPartPushMsgEntry*  DoMultiRetrieveTestL(TMsvId aId);
       
   285 
       
   286 	
       
   287 	void UnknownGetSetTestL();
       
   288 	void UnknownSaveRetrieveTestL(TBool aFilename);
       
   289 	CUnknownPushMsgEntry* DoUnknownCreateTestL();
       
   290 	void DoUnknownSetTestL(CUnknownPushMsgEntry& aUnknownEntry);
       
   291 	CUnknownPushMsgEntry* DoUnknownSaveTestL(TBool aFilename);
       
   292 	CUnknownPushMsgEntry* DoUnknownRetrieveTestL(TMsvId aId);
       
   293 
       
   294 	void ChangeSIEntryTestL();
       
   295 	void DoChangeSiEntryL(CSIPushMsgEntry& aSiMsg);
       
   296 	void ChangeSLEntryTestL();
       
   297 	void DoChangeSlEntryL(CSLPushMsgEntry& aSlMsg);
       
   298 	void ChangeUnknownEntryTestL(TBool aFilename);
       
   299 	void DoChangeUnknownEntryL(CUnknownPushMsgEntry& aUnkMsg, TBool aFilename);
       
   300 
       
   301 
       
   302 	void FindSiIdTestL(TBool aSearchForNullStr);
       
   303 	void FindUrlTestL(TBool aSearchForNullStr,  TUid aUid);
       
   304 	void GetActionTestL(TUid aPushType);
       
   305 	void GetExpiryTestL();
       
   306 	void DeleteEarliestExpiryL();
       
   307 
       
   308 	void DumpPushMessageDetailsL(TUid aPushType);
       
   309 	void CreateMultiChildrenL(TMsvId aEntry);
       
   310 
       
   311 	//Logging functions
       
   312 	void LogStr(const TDesC& aDes);
       
   313 	void LogFormatInt(const TDesC& aFormat, TInt aInt);
       
   314 	void LogFormatInt(const TDesC& aFormat, TInt aInt1, TInt aInt2);
       
   315 	void LogFormatStr(const TDesC& aFormat, const TDesC& aDes);
       
   316 
       
   317 	TBuf8<40> iDummyHeader1;
       
   318 	TBuf8<40> iDummyHeader2;
       
   319 	CSISLPushMsgUtils* iSISLPushUtilities;
       
   320 	CWapPushMsgUtils* iPushUtilities;
       
   321 	CMessageDetails* iDetails;
       
   322 	CPushMsgEntryBase* iPushEntry;
       
   323 	CMsvSession* iMsvSession;
       
   324 	CMsvEntry*	 iMsvEntry;
       
   325 	TInt		iState;
       
   326 	TMsvId iPushServiceId;
       
   327 	TMsvId iPushMsgFolderId;
       
   328 	// Following hold Ids so that the success 
       
   329 	// of find operations can be determined
       
   330 	TMsvId iTargetSiIDMsg;
       
   331 	TMsvId iTargetSIUrlMsg;
       
   332 	TMsvId iTargetSLUrlMsg;
       
   333 	TMsvId iHighestSIActionID;
       
   334 	TMsvId iHighestSLActionID;
       
   335 	TMsvId iSINullMsg;
       
   336 	TMsvId iSLNullMsg;
       
   337 	// These hold ids of the first of each type of message
       
   338 	// Used to locate the records to test update
       
   339 	TMsvId iSIToChange;
       
   340 	TMsvId iSLToChange;
       
   341 	TMsvId iUnknownToChange;
       
   342 	// Used to hold the id of a message to delete 
       
   343 	// - tests delete & find expiry again
       
   344 	TMsvId iExpired;
       
   345 	TInt   iFailures;
       
   346 	MWapPushLog& iLog;
       
   347 	TBuf<256> iFormatBuffer;
       
   348 	};
       
   349 
       
   350 
       
   351 #endif