messagingfw/wappushfw/tpush/t_multimessage.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     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 //
       
    15 
       
    16 #include "pushtests.h"
       
    17 #include "dummywapstack.h"
       
    18 #include "wappushmsggen.h"
       
    19 #include <push/cwappushmsgutils.h>
       
    20 
       
    21 /** set the test name.
       
    22 	@param void
       
    23 	@return string
       
    24 		name for test returned
       
    25 */
       
    26 const TDesC& CWapPushMMMessageTest::TestName()
       
    27 {
       
    28 	_LIT(KTextMMMessageTest, "Multi-part Mixed Message Test");
       
    29 	return KTextMMMessageTest;
       
    30 }
       
    31 
       
    32 
       
    33 /** set the number of test messages to pass to wap stack */
       
    34 void CWapPushMMMessageTest::NumberTestCasesToRun()
       
    35 	{
       
    36 	iNumberOfTestCases = 1;
       
    37 	}
       
    38 
       
    39 
       
    40 /** create test messages to use.
       
    41 	@param TInt
       
    42 		number of the test message to use
       
    43 	@return void
       
    44  */
       
    45 void CWapPushMMMessageTest::PrepareTestMessageL(TInt /*aTestCase*/)
       
    46 {
       
    47 	const TUint8 KMessageHeaderMultipart[]=
       
    48 		{
       
    49 		0xA3,  //Content type "application/vnd.wap.multipart.mixed"
       
    50 		0x94,  // Date
       
    51 		0x04,  // length of field
       
    52 		0x35,  // Thur 23 Apr 1998 13:41:37 GMT
       
    53 		0x3F,	
       
    54 		0x45,
       
    55 		0x11,
       
    56 		0xAF,  //X-Wap-Application-ID
       
    57 		0x82  // Short int - 0x02 represent x-wap-application:push.ua
       
    58 		};
       
    59 
       
    60 	iHeadersBuf.Copy(KMessageHeaderMultipart, sizeof(KMessageHeaderMultipart));	
       
    61 
       
    62 	iBodyBuf.Delete(0,KBufferSize);
       
    63 	
       
    64 	const TUint8 KMessageBodyMultipart[]=
       
    65 		{
       
    66 		0x02,	// number of parts
       
    67 		0x0A,	// part 1 header size
       
    68 		0x1D,	// part 1 body size
       
    69 		0xB0,	// content type application/vnd.wap.slc ... the headers:
       
    70 		0x94,	// Date
       
    71 		0x04,	// length of field
       
    72 		0x35,	// Thur 23 Apr 1998 13:41:37 GMT
       
    73 		0x3F,	
       
    74 		0x45,
       
    75 		0x11,
       
    76 		0x3F,	
       
    77 		0x45,
       
    78 		0x11,
       
    79 		0x01,	// Body - slc (www.schmookie.com)
       
    80 		0x06,
       
    81 		0x6A,
       
    82 		0x00,
       
    83 		0x85,
       
    84 		0x09,
       
    85 		0x03,
       
    86 		0x6D,
       
    87 		0x6D,
       
    88 		0x6D,
       
    89 		0x2E,
       
    90 		0x73,
       
    91 		0x63,
       
    92 		0x68,
       
    93 		0x6D,
       
    94 		0x6F,
       
    95 		0x6F,
       
    96 		0x6B,
       
    97 		0x69,
       
    98 		0x65,
       
    99 		0x2E,
       
   100 		0x63,
       
   101 		0x6F,
       
   102 		0x64,
       
   103 		0x65,
       
   104 		0x2F,
       
   105 		0x00,
       
   106 		0x06,
       
   107 		0x01,
       
   108 		0x0A,	// part 2 header size
       
   109 		0x1D,	// part 2 body size
       
   110 		0xB0,	// content type application/vnd.wap.slc ... the headers:
       
   111 		0x94,	// Date
       
   112 		0x04,	// length of field
       
   113 		0x35,	// Thur 23 Apr 1998 13:41:37 GMT
       
   114 		0x3F,	
       
   115 		0x45,
       
   116 		0x11,
       
   117 		0x3F,	
       
   118 		0x45,
       
   119 		0x11,
       
   120 		0x01,	// Body - slc (www.schmookie.com)
       
   121 		0x06,
       
   122 		0x6A,
       
   123 		0x00,
       
   124 		0x85,
       
   125 		0x09,
       
   126 		0x03,
       
   127 		0x6D,
       
   128 		0x6D,
       
   129 		0x6D,
       
   130 		0x2E,
       
   131 		0x73,
       
   132 		0x63,
       
   133 		0x68,
       
   134 		0x6D,
       
   135 		0x6F,
       
   136 		0x6F,
       
   137 		0x6B,
       
   138 		0x69,
       
   139 		0x65,
       
   140 		0x2E,
       
   141 		0x63,
       
   142 		0x6F,
       
   143 		0x64,
       
   144 		0x65,
       
   145 		0x2F,
       
   146 		0x00,
       
   147 		0x06,
       
   148 		0x01,
       
   149 	};
       
   150 
       
   151 	iBodyBuf.Append(KMessageBodyMultipart, sizeof(KMessageBodyMultipart));
       
   152 
       
   153 }
       
   154 
       
   155 /** confirm the message has been stored in the message store.
       
   156 	@param void
       
   157 	@return TBool
       
   158 		ETrue = message found
       
   159 		EFalse = message not found
       
   160 */
       
   161 TBool CWapPushMMMessageTest::ConfirmMessagesSavedL()
       
   162 	{
       
   163 	// TODO - Quite a bit of work is required here. Creating the WapPushUtils
       
   164 	// can generate a -15 (KErrServerTerminated) from the message server. So
       
   165 	// care has to be taken. Suggest creating the Push Utils in the base class
       
   166 	// and not deleting till the test is done. Also, the other thing that could
       
   167 	// be changed is that the base class sets the priority of the active object
       
   168 	// down to Idle when in state EFinished. Suggest renaming EFinished to
       
   169 	// ETestsDone and adding EConfirmMessageSaved and EComplete states.
       
   170 	
       
   171 	//	CWapPushMsgUtils* wapPushUtils= CWapPushMsgUtils::NewL();
       
   172 	//	CleanupStack::PushL(wapPushUtils);
       
   173 	//	TO DO: check multiparts in store by looking up..???
       
   174 	//	TMsvId msgEntryId = wapPushUtils->FindUrlL(KSISiId(), KUidWapPushMsgSI);
       
   175 	
       
   176 	//	CleanupStack::PopAndDestroy();  // wapPushUtils
       
   177 	return EFalse/*msgEntryId*/;
       
   178 	}
       
   179 
       
   180 
       
   181 /** set the test name.
       
   182 	@param void
       
   183 	@return string
       
   184 		name for test returned
       
   185 */
       
   186 const TDesC& CWapPushMAMessageTest::TestName()
       
   187 {
       
   188 	_LIT(KTextMAMessageTest, "Multi-part Alternative Message Test");
       
   189 	return KTextMAMessageTest;
       
   190 }
       
   191 
       
   192 
       
   193 /** set the number of test messages to pass to wap stack */
       
   194 void CWapPushMAMessageTest::NumberTestCasesToRun()
       
   195 	{
       
   196 	iNumberOfTestCases = 1;
       
   197 	}
       
   198 
       
   199 
       
   200 /** create test messages to use.
       
   201 	@param TInt
       
   202 		number of the test message to use
       
   203 	@return void
       
   204  */
       
   205 void CWapPushMAMessageTest::PrepareTestMessageL(TInt /*aTestCase*/)
       
   206 	{
       
   207 	const TUint8 KMessageHeaderMultipart[]=
       
   208 		{
       
   209 		0xA6,  //Content type "application/vnd.wap.multipart.alternative"
       
   210 		0x94,  // Date
       
   211 		0x04,  // length of field
       
   212 		0x35,  // Thur 23 Apr 1998 13:41:37 GMT
       
   213 		0x3F,	
       
   214 		0x45,
       
   215 		0x11,
       
   216 		0xAF,  //X-Wap-Application-ID
       
   217 		0x82  // Short int - 0x02 represent x-wap-application:push.ua
       
   218 		};
       
   219 
       
   220 	
       
   221 	iHeadersBuf.Copy(KMessageHeaderMultipart, sizeof(KMessageHeaderMultipart));	
       
   222 	iBodyBuf.Delete(0,KBufferSize);
       
   223 	
       
   224 	const TUint8 KMessageBodyMultipart[]=
       
   225 		{
       
   226 		0x02,	// number of parts
       
   227 		0x0A,	// part 1 header size
       
   228 		0x1D,	// part 1 body size
       
   229 		0xB0,	// content type application/vnd.wap.slc ... the headers:
       
   230 		0x94,	// Date
       
   231 		0x04,	// length of field
       
   232 		0x35,	// Thur 23 Apr 1998 13:41:37 GMT
       
   233 		0x3F,	
       
   234 		0x45,
       
   235 		0x11,
       
   236 		0x3F,	
       
   237 		0x45,
       
   238 		0x11,
       
   239 		0x01,	// Body - slc (www.schmookie.com)
       
   240 		0x06,
       
   241 		0x6A,
       
   242 		0x00,
       
   243 		0x85,
       
   244 		0x09,
       
   245 		0x03,
       
   246 		0x6D,
       
   247 		0x6D,
       
   248 		0x6D,
       
   249 		0x2E,
       
   250 		0x73,
       
   251 		0x63,
       
   252 		0x68,
       
   253 		0x6D,
       
   254 		0x6F,
       
   255 		0x6F,
       
   256 		0x6B,
       
   257 		0x69,
       
   258 		0x65,
       
   259 		0x2E,
       
   260 		0x63,
       
   261 		0x6F,
       
   262 		0x64,
       
   263 		0x65,
       
   264 		0x2F,
       
   265 		0x00,
       
   266 		0x06,
       
   267 		0x01,
       
   268 		0x0A,	// part 2 header size
       
   269 		0x1D,	// part 2 body size
       
   270 		0xB0,	// content type application/vnd.wap.slc ... the headers:
       
   271 		0x94,	// Date
       
   272 		0x04,	// length of field
       
   273 		0x35,	// Thur 23 Apr 1998 13:41:37 GMT
       
   274 		0x3F,	
       
   275 		0x45,
       
   276 		0x11,
       
   277 		0x3F,	
       
   278 		0x45,
       
   279 		0x11,
       
   280 		0x01,	// Body - slc (www.schmookie.com)
       
   281 		0x06,
       
   282 		0x6A,
       
   283 		0x00,
       
   284 		0x85,
       
   285 		0x09,
       
   286 		0x03,
       
   287 		0x6D,
       
   288 		0x6D,
       
   289 		0x6D,
       
   290 		0x2E,
       
   291 		0x73,
       
   292 		0x63,
       
   293 		0x68,
       
   294 		0x6D,
       
   295 		0x6F,
       
   296 		0x6F,
       
   297 		0x6B,
       
   298 		0x69,
       
   299 		0x65,
       
   300 		0x2E,
       
   301 		0x63,
       
   302 		0x6F,
       
   303 		0x64,
       
   304 		0x65,
       
   305 		0x2F,
       
   306 		0x00,
       
   307 		0x06,
       
   308 		0x01,
       
   309 	};
       
   310 
       
   311 	iBodyBuf.Append(KMessageBodyMultipart, sizeof(KMessageBodyMultipart));
       
   312 
       
   313 }
       
   314 
       
   315 /** confirm the message has been stored in the message store.
       
   316 	@param void
       
   317 	@return TBool
       
   318 		ETrue = message found
       
   319 		EFalse = message not found
       
   320 */
       
   321 TBool CWapPushMAMessageTest::ConfirmMessagesSavedL()
       
   322 	{
       
   323 	// TODO - Quite a bit of work is required here. Creating the WapPushUtils
       
   324 	// can generate a -15 (KErrServerTerminated) from the message server. So
       
   325 	// care has to be taken. Suggest creating the Push Utils in the base class
       
   326 	// and not deleting till the test is done. Also, the other thing that could
       
   327 	// be changed is that the base class sets the priority of the active object
       
   328 	// down to Idle when in state EFinished. Suggest renaming EFinished to
       
   329 	// ETestsDone and adding EConfirmMessageSaved and EComplete states.
       
   330 	
       
   331 	//	CWapPushMsgUtils* wapPushUtils= CWapPushMsgUtils::NewL();
       
   332 	//	CleanupStack::PushL(wapPushUtils);
       
   333 	//	TO DO: check multiparts in store by looking up..???
       
   334 	//	TMsvId msgEntryId = wapPushUtils->FindUrlL(KSISiId(), KUidWapPushMsgSI);
       
   335 	
       
   336 	//	CleanupStack::PopAndDestroy();  // wapPushUtils
       
   337 	return EFalse/*msgEntryId*/;
       
   338 	}
       
   339 
       
   340 /** set the test name.
       
   341 	@param void
       
   342 	@return string
       
   343 		name for test returned
       
   344 */
       
   345 const TDesC& CWapPushMRMessageTest::TestName()
       
   346 {
       
   347 	_LIT(KTextMRMessageTest, "Multi-part Related Message Test");
       
   348 	return KTextMRMessageTest;
       
   349 }
       
   350 
       
   351 
       
   352 /** set the number of test messages to pass to wap stack */
       
   353 void CWapPushMRMessageTest::NumberTestCasesToRun()
       
   354 	{
       
   355 	iNumberOfTestCases = 1;
       
   356 	}
       
   357 
       
   358 
       
   359 /** create test messages to use.
       
   360 	@param TInt
       
   361 		number of the test message to use
       
   362 	@return void
       
   363  */
       
   364 void CWapPushMRMessageTest::PrepareTestMessageL(TInt /*aTestCase*/)
       
   365 {
       
   366 	const TUint8 KMessageHeaderMultipart[]=
       
   367 		{
       
   368 		0xB3,  //Content type "application/vnd.wap.multipart.related"
       
   369 		0x94,  // Date
       
   370 		0x04,  // length of field
       
   371 		0x35,  // Thur 23 Apr 1998 13:41:37 GMT
       
   372 		0x3F,	
       
   373 		0x45,
       
   374 		0x11,
       
   375 		0xAF,  //X-Wap-Application-ID
       
   376 		0x82  // Short int - 0x02 represent x-wap-application:push.ua
       
   377 		};
       
   378 
       
   379 
       
   380 	iHeadersBuf.Copy(KMessageHeaderMultipart, sizeof(KMessageHeaderMultipart));	
       
   381 	iBodyBuf.Delete(0,KBufferSize);
       
   382 	
       
   383 	const TUint8 KMessageBodyMultipart[]=
       
   384 		{
       
   385 		0x02,	// number of parts
       
   386 		0x0A,	// part 1 header size
       
   387 		0x1D,	// part 1 body size
       
   388 		0xB0,	// content type application/vnd.wap.slc ... the headers:
       
   389 		0x94,	// Date
       
   390 		0x04,	// length of field
       
   391 		0x35,	// Thur 23 Apr 1998 13:41:37 GMT
       
   392 		0x3F,	
       
   393 		0x45,
       
   394 		0x11,
       
   395 		0x3F,	
       
   396 		0x45,
       
   397 		0x11,
       
   398 		0x01,	// Body - slc (www.schmookie.com)
       
   399 		0x06,
       
   400 		0x6A,
       
   401 		0x00,
       
   402 		0x85,
       
   403 		0x09,
       
   404 		0x03,
       
   405 		0x6D,
       
   406 		0x6D,
       
   407 		0x6D,
       
   408 		0x2E,
       
   409 		0x73,
       
   410 		0x63,
       
   411 		0x68,
       
   412 		0x6D,
       
   413 		0x6F,
       
   414 		0x6F,
       
   415 		0x6B,
       
   416 		0x69,
       
   417 		0x65,
       
   418 		0x2E,
       
   419 		0x63,
       
   420 		0x6F,
       
   421 		0x64,
       
   422 		0x65,
       
   423 		0x2F,
       
   424 		0x00,
       
   425 		0x06,
       
   426 		0x01,
       
   427 		0x0A,	// part 2 header size
       
   428 		0x1D,	// part 2 body size
       
   429 		0xB0,	// content type application/vnd.wap.slc ... the headers:
       
   430 		0x94,	// Date
       
   431 		0x04,	// length of field
       
   432 		0x35,	// Thur 23 Apr 1998 13:41:37 GMT
       
   433 		0x3F,	
       
   434 		0x45,
       
   435 		0x11,
       
   436 		0x3F,	
       
   437 		0x45,
       
   438 		0x11,
       
   439 		0x01,	// Body - slc (www.schmookie.com)
       
   440 		0x06,
       
   441 		0x6A,
       
   442 		0x00,
       
   443 		0x85,
       
   444 		0x09,
       
   445 		0x03,
       
   446 		0x6D,
       
   447 		0x6D,
       
   448 		0x6D,
       
   449 		0x2E,
       
   450 		0x73,
       
   451 		0x63,
       
   452 		0x68,
       
   453 		0x6D,
       
   454 		0x6F,
       
   455 		0x6F,
       
   456 		0x6B,
       
   457 		0x69,
       
   458 		0x65,
       
   459 		0x2E,
       
   460 		0x63,
       
   461 		0x6F,
       
   462 		0x64,
       
   463 		0x65,
       
   464 		0x2F,
       
   465 		0x00,
       
   466 		0x06,
       
   467 		0x01,
       
   468 	};
       
   469 
       
   470 	iBodyBuf.Append(KMessageBodyMultipart, sizeof(KMessageBodyMultipart));
       
   471 
       
   472 }
       
   473 
       
   474 /** confirm the message has been stored in the message store.
       
   475 	@param void
       
   476 	@return TBool
       
   477 		ETrue = message found
       
   478 		EFalse = message not found
       
   479 */
       
   480 TBool CWapPushMRMessageTest::ConfirmMessagesSavedL()
       
   481 	{
       
   482 	// TODO - Quite a bit of work is required here. Creating the WapPushUtils
       
   483 	// can generate a -15 (KErrServerTerminated) from the message server. So
       
   484 	// care has to be taken. Suggest creating the Push Utils in the base class
       
   485 	// and not deleting till the test is done. Also, the other thing that could
       
   486 	// be changed is that the base class sets the priority of the active object
       
   487 	// down to Idle when in state EFinished. Suggest renaming EFinished to
       
   488 	// ETestsDone and adding EConfirmMessageSaved and EComplete states.
       
   489 	
       
   490 	//	CWapPushMsgUtils* wapPushUtils= CWapPushMsgUtils::NewL();
       
   491 	//	CleanupStack::PushL(wapPushUtils);
       
   492 	//	TO DO: check multiparts in store by looking up..???
       
   493 	//	TMsvId msgEntryId = wapPushUtils->FindUrlL(KSISiId(), KUidWapPushMsgSI);
       
   494 	
       
   495 	//	CleanupStack::PopAndDestroy();  // wapPushUtils
       
   496 	return EFalse/*msgEntryId*/;
       
   497 	}