messagingfw/wappushfw/tpush/t_invalDTDMessage.cpp
changeset 22 bde600d88860
parent 0 8e480a14352b
equal deleted inserted replaced
21:08008ce8a6df 22:bde600d88860
       
     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 <txtrich.h>
       
    22 #include <msvids.h>
       
    23 #include <push/csipushmsgentry.h>
       
    24 #include <escapeutils.h>
       
    25 
       
    26 
       
    27 _LIT8 ( KXMLVersion, "<xml version=\"1.0\"?>\r\n\t");
       
    28 _LIT8 ( KDocType, "<!DOCTYPE sl PUBLIC \"-//WAPFORUM//DTD SL 1.0//EN\"\r\n");
       
    29 
       
    30 // XML document contains sl tag twice.
       
    31 _LIT8 (KInvalidDTD1, "<sl href=\"http://www.xyz.com/123.wml\"> </sl> <sl> </sl>");
       
    32 _LIT8 (KInvalidDTD2, "<indication href=\"http://www.xyz.com/abc.wml\"></indication>");
       
    33 
       
    34 /** set the test name for this test case
       
    35 	@param void
       
    36 	@return string
       
    37 		returns test name
       
    38 */
       
    39 const TDesC& CInvalidWAPDTDMessages::TestName()
       
    40 	{
       
    41 	_LIT(KTextSICMessageTest,"Invalid WAP DTD Messages");
       
    42 	return KTextSICMessageTest;
       
    43 	}
       
    44 
       
    45 
       
    46 /** specify the number of test messages to use */
       
    47 void CInvalidWAPDTDMessages::NumberTestCasesToRun()
       
    48 	{
       
    49 	iNumberOfTestCases = 2;
       
    50 	}
       
    51 
       
    52 
       
    53 /** create test messages to use where aTestCase represents the
       
    54 	message index for multiple messages.
       
    55 	Tests: 0 & 1- Chineese character encoding
       
    56 		   2- Message with Creation and Expires time
       
    57 
       
    58 	@param aTestCase message index value for selecting a test message
       
    59 	@return void
       
    60  */
       
    61 void CInvalidWAPDTDMessages::PrepareTestMessageL(TInt aTestCase)
       
    62 {
       
    63 	// create hardcoded SIC test message 
       
    64 	const TUint8 KMessageHeader[] = 
       
    65 		{
       
    66 		0xAF,	// Content type "application/vnd.wap.sl"
       
    67 		0x82,	// Accept-Charset  Short int - 0x02 represent x-wap-application:push.ua
       
    68 		};	
       
    69 	
       
    70 	iHeadersBuf.Append(KMessageHeader, sizeof(KMessageHeader));
       
    71 	
       
    72 	HBufC8* msg = HBufC8::NewLC ( KBufferSize );
       
    73 	TPtr8 ptr8 ( msg->Des() );
       
    74 	ptr8.Copy ( KXMLVersion() );
       
    75 	ptr8.Append ( KDocType() );
       
    76 
       
    77 	switch ( aTestCase )
       
    78 	{
       
    79 	case 0 :
       
    80 	ptr8.Append ( KInvalidDTD1() );
       
    81 	break;
       
    82 	
       
    83 	case 1:	
       
    84 	ptr8.Append ( KInvalidDTD2() );
       
    85 	break;	
       
    86 	}
       
    87 
       
    88 	// copy data to iBodyBuf
       
    89 	iBodyBuf.Delete(0,KBufferSize);
       
    90 	iBodyBuf = msg->Des();
       
    91 
       
    92 	CleanupStack::PopAndDestroy(1); // msg
       
    93 }
       
    94 
       
    95 /** confirm the message has been stored in the message store.
       
    96 	Writes confirmation of number of found messages to log file
       
    97 	if present.
       
    98 	@param void
       
    99 	@return TBool
       
   100 		ETrue = message(s) found
       
   101 		EFalse = no message(s) found
       
   102  */
       
   103 TBool CInvalidWAPDTDMessages::ConfirmMessagesSavedL()
       
   104 	{
       
   105 	return ETrue;
       
   106 	}
       
   107 		
       
   108 TInt CInvalidWAPDTDMessages::RunError(TInt /*aError*/)
       
   109 	{
       
   110 	return KErrNone;
       
   111 	}