messagingfw/wappushfw/tpush/INC081489.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2006-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  <push/sislpushmsgutils.h>
       
    17 
       
    18 #include "pushtests.h"
       
    19 #include "dummywapstack.h"
       
    20 #include "wappushmsggen.h"
       
    21 #include <push/csipushmsgentry.h>
       
    22 
       
    23 
       
    24 // si text message data
       
    25 
       
    26 _LIT8(KSIHref1, "http://www.xyz.com/ppaid/1231/abc.wml");
       
    27 _LIT8(KSIHref4, "http://www.xyz.com/ppaid/1234/abc.wml");
       
    28 _LIT8(KSIHref5, "http://www.xyz.com/ppaid/1236/abc.wml");
       
    29 _LIT8(KDate1,	"2006-02-22T07:58:01Z");
       
    30 _LIT8(KDate2,	"2006-02-22T08:58:01Z");
       
    31 _LIT8(KDate3,	"2006-02-22T09:58:01Z");
       
    32 _LIT8(KDate4,	"2006-02-22T10:58:01Z");
       
    33 _LIT8(KDate5,	"2006-02-22T11:58:01Z");
       
    34 _LIT8(KDate6,	"2006-02-22T12:58:01Z");
       
    35 _LIT8(KDate7,	"2006-02-22T13:58:01Z");
       
    36 _LIT8(KDate8,	"2006-02-22T14:58:01Z");
       
    37 _LIT8(KDate9,	"2006-02-22T15:58:01Z");
       
    38 _LIT8(KDate10,	"2006-02-22T16:58:01Z");
       
    39 _LIT8(KDate11,	"2006-02-22T17:58:01Z");
       
    40 _LIT8(KSISiId1, "http://www.xyz.com/ppaid/1231/abc.wml");
       
    41 _LIT8(KSISiId2, "http://www.xyz.com/ppaid/1232/abc.wml");
       
    42 _LIT8(KSISiId3, "http://www.xyz.com/ppaid/1233/abc.wml");
       
    43 _LIT8(KSISiId5, "http://www.xyz.com/ppaid/1235/abc.wml");
       
    44 
       
    45 /** set test name to 'Duplicate SI messages [CINC081489]'
       
    46 	@param void
       
    47 	@return string
       
    48 		string represents test name
       
    49 */
       
    50 const TDesC& CINC081489::TestName()
       
    51 {
       
    52 	_LIT(KTextSIMessageTest, "Duplicate SI messages [CINC081489]");
       
    53 	return KTextSIMessageTest;
       
    54 }
       
    55 
       
    56 /** set the number of test messages to use */
       
    57 void CINC081489::NumberTestCasesToRun()
       
    58 {
       
    59 	iNumberOfTestCases = 16;
       
    60 }
       
    61 
       
    62 /** build different test messages to test specific SI reception aspects
       
    63 	in the SI content handler processing code.
       
    64 	@param TInt
       
    65 		the number of test messages to create and use
       
    66 	@return void
       
    67 */
       
    68 void CINC081489::PrepareTestMessageL(TInt aTestCase)
       
    69 {
       
    70 	// this set of test messages adds a test message
       
    71 	// to the store for the match cases, 
       
    72 	// replaces the stored message and ends with no stored si message 	
       
    73 	const TUint8 KMessageHeader2[] = 
       
    74 		{
       
    75 		//0xB0,  //Content type "application/vnd.wap.slc"
       
    76 		0xAD,  //Content type "application/vnd.wap.si" 
       
    77 		0x92,  // Date
       
    78 		0x04,  // length of field
       
    79 		0x39,  // Monday 15 August 2000 10:41:37 GMT
       
    80 		0x90,	
       
    81 		0x6a,
       
    82 		0xd0,
       
    83 		0x94,  // Expires 
       
    84 		0x04,  // length of field
       
    85 		0x39,  // Monday 15 August 2000 10:41:37 GMT
       
    86 		0x9a,	
       
    87 		0x6a,
       
    88 		0xd0,
       
    89 		0xAF,  //X-Wap-Application-ID
       
    90 		0x82  // Short int - 0x02 represent x-wap-application:push.ua
       
    91 		};	
       
    92 
       
    93 	TBuf8<40> tempBuf;
       
    94 	TUint8 value;
       
    95 	for (TInt i = 0; i < 15; i++)
       
    96 		{
       
    97 		value = KMessageHeader2[i];
       
    98 		tempBuf.Append(value);
       
    99 		}
       
   100 
       
   101 	iHeadersBuf.Copy(tempBuf);
       
   102 	tempBuf.Copy(_L8(""));
       
   103 
       
   104 	iBodyBuf.Delete(0,KBufferSize);
       
   105 	//iBodyBuf.Zero();
       
   106 		
       
   107 	CWapPushMsgGen* msgGen = CWapPushMsgGen::NewL();
       
   108 	CleanupStack::PushL(msgGen);
       
   109 
       
   110 	msgGen->StartNewMsgL(CWapPushMsgGen::EServiceIndication);
       
   111 		
       
   112 	switch (aTestCase)
       
   113 		{
       
   114 	// INC081489 - part 1
       
   115 	// Three messages with same EHRef, EServiceIndicationID and different EServiceIndicationCreated
       
   116 	case 0 :
       
   117 		msgGen->AppendFieldL(CWapPushMsgGen::EHRef, KSIHref1);
       
   118 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationID, KSISiId1);
       
   119 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationCreated, KDate1);
       
   120 		break;
       
   121 	case 1 :
       
   122 		msgGen->AppendFieldL(CWapPushMsgGen::EHRef, KSIHref1);
       
   123 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationID, KSISiId1);
       
   124 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationCreated, KDate2);
       
   125 		break;	
       
   126 	case 2 :
       
   127 		msgGen->AppendFieldL(CWapPushMsgGen::EHRef, KSIHref1);
       
   128 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationID, KSISiId1);
       
   129 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationCreated, KDate3);
       
   130 		break;
       
   131 	case 3 :// INC081489 - part 2
       
   132 			//Three messages with same EHRef, EServiceIndicationID and EServiceIndicationCreated
       
   133 	case 4 :
       
   134 	case 5 :
       
   135 		msgGen->AppendFieldL(CWapPushMsgGen::EHRef, KSIHref1);
       
   136 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationID, KSISiId2);
       
   137 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationCreated, KDate1);
       
   138 		break;
       
   139 	case 6 : // INC081568 - part 1
       
   140 			 // Same "si-id","created" and no value for the "href" attribute.
       
   141 	case 7 :
       
   142 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationID, KSISiId3);
       
   143 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationCreated, KDate4);
       
   144 		break;
       
   145 	case 8 : // INC082189
       
   146 			 // Two Push SI messages,the same "href"and "created",no "si-id",
       
   147 	case 9 : // 
       
   148 		msgGen->AppendFieldL(CWapPushMsgGen::EHRef, KSIHref4);
       
   149 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationCreated, KDate5);
       
   150 		break;
       
   151 		
       
   152 	 // INC082190: Three Push SI msgs, the same "si-id",different "created",no "href" 	
       
   153 	case 10 :
       
   154 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationID, KSISiId5);
       
   155 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationCreated, KDate6);
       
   156 		break;
       
   157 	case 11 : 
       
   158 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationID, KSISiId5);
       
   159 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationCreated, KDate7);
       
   160 		break;
       
   161 	case 12 :
       
   162 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationID, KSISiId5);
       
   163 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationCreated, KDate8);
       
   164 		break;
       
   165 		
       
   166 	 // INC082191: Three Push SI msgs, the same "href",different "created",no "si-id" 	
       
   167 	case 13 :
       
   168 		msgGen->AppendFieldL(CWapPushMsgGen::EHRef, KSIHref5);
       
   169 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationCreated, KDate9);
       
   170 		break;
       
   171 	case 14 : 
       
   172 		msgGen->AppendFieldL(CWapPushMsgGen::EHRef, KSIHref5);
       
   173 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationCreated, KDate10);
       
   174 		break;
       
   175 	case 15 :
       
   176 		msgGen->AppendFieldL(CWapPushMsgGen::EHRef, KSIHref5);
       
   177 		msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationCreated, KDate11);
       
   178 		break;
       
   179 
       
   180 	default: 
       
   181 		// do nothing
       
   182 		break;
       
   183 	}
       
   184 	msgGen->AppendFieldL(CWapPushMsgGen::EServiceIndicationText, _L8("You have 4 new e-mails"));
       
   185 
       
   186 	HBufC8* msg = msgGen->CreateMsgLC();
       
   187 	iBodyBuf = msg->Des(); 
       
   188 	CleanupStack::PopAndDestroy(2); //msgGen, msg
       
   189 }
       
   190 
       
   191 /** confirm the message has been stored.
       
   192 	Writes the number of stored messages found to the log file - if present.
       
   193 	@param void
       
   194 	@return TBool
       
   195 		returns ETrue if messages found
       
   196 		returns EFalse if no messages found 
       
   197 */
       
   198 TBool CINC081489::ConfirmMessagesSavedL()
       
   199 	{
       
   200 	CSISLPushMsgUtils* wapPushUtils = CSISLPushMsgUtils::NewL();
       
   201 	CleanupStack::PushL(wapPushUtils);
       
   202 	
       
   203 	TMsvId localFolderId;
       
   204 	wapPushUtils->GetPushMsgFolderIdL(localFolderId);
       
   205 	
       
   206 	const TDesC& siId1 = _L("http://www.xyz.com/ppaid/1231/abc.wml");
       
   207 	const TDesC& siId2 = _L("http://www.xyz.com/ppaid/1232/abc.wml");
       
   208 	const TDesC& siId3 = _L("http://www.xyz.com/ppaid/1233/abc.wml");
       
   209 	const TDesC& siId4 = _L("http://www.xyz.com/ppaid/1234/abc.wml");
       
   210 	const TDesC& siId5 = _L("http://www.xyz.com/ppaid/1235/abc.wml");
       
   211 	const TDesC& siId6 = _L("http://www.xyz.com/ppaid/1236/abc.wml");
       
   212 
       
   213 	CMsvEntrySelection* matchingIdList = wapPushUtils->FindSiIdLC(siId1);
       
   214 
       
   215 	// INC081489 - part 1
       
   216 	// Three messages with same EHRef, EServiceIndicationID and different EServiceIndicationCreated
       
   217 	TInt foundCount;
       
   218 	if (matchingIdList) 
       
   219 		{
       
   220 		foundCount = matchingIdList->Count(); 
       
   221 		}
       
   222 	else
       
   223 		foundCount = 0;
       
   224 	
       
   225 	CleanupStack::PopAndDestroy(matchingIdList
       
   226 	);
       
   227 	
       
   228 	// INC081489 - part 2
       
   229 	// Three messages with same EHRef, EServiceIndicationID and EServiceIndicationCreated
       
   230 	matchingIdList = wapPushUtils->FindSiIdLC(siId2);
       
   231 
       
   232 	if (matchingIdList) 
       
   233 		{
       
   234 		foundCount += matchingIdList->Count(); 
       
   235 		}
       
   236 	
       
   237 	CleanupStack::PopAndDestroy(matchingIdList);
       
   238 	
       
   239 	// INC081568 - part 1
       
   240 	// Same "si-id","created" and no value for the "href" attribute.
       
   241 	matchingIdList = wapPushUtils->FindSiIdLC(siId3);
       
   242 
       
   243 	if (matchingIdList) 
       
   244 		{
       
   245 		foundCount += matchingIdList->Count(); 
       
   246 		}
       
   247 	CleanupStack::PopAndDestroy(matchingIdList);
       
   248 	
       
   249 	//INC082189 - Two Push SI messages,the same "href"and "created",no "si-id",
       
   250 	matchingIdList = wapPushUtils->FindSiIdLC(siId4);
       
   251 
       
   252 	if (matchingIdList) 
       
   253 		{
       
   254 		foundCount += matchingIdList->Count(); 
       
   255 		}
       
   256 	CleanupStack::PopAndDestroy(matchingIdList);
       
   257 	
       
   258 	// INC082190: Three Push SI msgs, the same "si-id",different "created",no "href"
       
   259 	matchingIdList = wapPushUtils->FindSiIdLC(siId5);
       
   260 
       
   261 	if (matchingIdList) 
       
   262 		{
       
   263 		foundCount += matchingIdList->Count(); 
       
   264 		}
       
   265 
       
   266 	CleanupStack::PopAndDestroy(matchingIdList);
       
   267 	
       
   268 	// INC082191: Three Push SI msgs, the same "href",different "created",no "si-id"
       
   269 	matchingIdList = wapPushUtils->FindSiIdLC(siId6);
       
   270 
       
   271 	if (matchingIdList) 
       
   272 		{
       
   273 		foundCount += matchingIdList->Count(); 
       
   274 		}
       
   275 	
       
   276 	TBuf<KPushLogBuffer> buf;
       
   277 	_LIT(KLogSICount,"SI messages stored:\t%d");
       
   278 	buf.Format(KLogSICount,foundCount);
       
   279 	WPLPrintf(buf);	
       
   280 
       
   281 	CleanupStack::PopAndDestroy(2);  // wapPushUtils, matchingIdList
       
   282 	return foundCount;
       
   283 	}
       
   284