xml/xmlexpatparser/test/rtest/tsrc/t_xmldefect.cpp
changeset 0 e35f40988205
child 24 74f0b3eb154c
equal deleted inserted replaced
-1:000000000000 0:e35f40988205
       
     1 // Copyright (c) 2005-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 <e32test.h>
       
    17 #include <ecom/ecom.h>
       
    18 
       
    19 #include <xml/contentprocessor.h>
       
    20 #include <xml/documentparameters.h>
       
    21 #include <xml/parser.h>
       
    22 #include <xml/parserfeature.h>
       
    23 #include <xml/stringdictionarycollection.h>
       
    24 #include <xml/xmlframeworkerrors.h>
       
    25 
       
    26 #include "unzip.h"
       
    27 
       
    28 LOCAL_D RTest 				test(_L("t_xmldefect.exe"));
       
    29 
       
    30 LOCAL_D RFs					TheFs;
       
    31 
       
    32 LOCAL_D CTrapCleanup* 		TheTrapCleanup 		= NULL;
       
    33 
       
    34 LOCAL_D TBool				TheCorruptedXmlFileTest = EFalse;
       
    35 
       
    36 LOCAL_D TInt    			TheCorruptedXmlFileTestErrorCount = 0;
       
    37 
       
    38 // Installed via bld.inf test exports
       
    39 _LIT(KSimpleFile, "c:\\system\\data\\xml\\xml\\another_simple.xml");
       
    40 _LIT(KNsAndBindingFile, "c:\\system\\data\\xml\\xml\\default_namespace_and_unbinding.xml");
       
    41 
       
    42 _LIT(KZipTestFile, "z:\\system\\data\\xml\\xmldefect.zip");
       
    43 _LIT(KXmlTestDir, "c:\\system\\data\\xml");
       
    44 
       
    45 
       
    46 _LIT8(KXmlParserDataType, "text/xml");
       
    47 
       
    48 
       
    49 typedef void (*TestFunc) (void);
       
    50 
       
    51 
       
    52 //----------------------------------------------------------------------------
       
    53 // The Content Handler
       
    54 
       
    55 using namespace Xml;
       
    56 
       
    57 class RDefectTests : public MContentHandler
       
    58 	{
       
    59 public:
       
    60 	RDefectTests() {/*do nothing*/};
       
    61 	virtual ~RDefectTests() {/*do nothing*/};
       
    62 
       
    63 	void Open() {/*do nothing*/};
       
    64 	void Close() {/*do nothing*/};
       
    65 
       
    66 	// From MContentHandler
       
    67 	void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode);
       
    68 	void OnEndDocumentL(TInt aErrorCode);
       
    69 	void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttribute, TInt aErrorCode);
       
    70 	void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
       
    71 	void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
       
    72 	void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
       
    73 	void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
       
    74 	void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode) ;
       
    75 	void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
       
    76 	void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
       
    77 	TAny* GetExtendedInterface(const TInt32 aUid);
       
    78 
       
    79 	void OnError(TInt aErrorCode);
       
    80 
       
    81 	};
       
    82 
       
    83 
       
    84 
       
    85 // From MContentHandler
       
    86 
       
    87 // maps to SAX 2.0 startDocument method.
       
    88 void RDefectTests::OnStartDocumentL(const RDocumentParameters& /*aDocParam*/, TInt aErrorCode)
       
    89 	{
       
    90 	test(aErrorCode == KErrNone);
       
    91 	}
       
    92 
       
    93 
       
    94 	// maps to SAX 2.0 endDocument method.
       
    95 void RDefectTests::OnEndDocumentL(TInt aErrorCode)
       
    96 	{
       
    97 	test(aErrorCode == KErrNone);
       
    98 	}
       
    99 
       
   100 
       
   101 // maps to SAX 2.0 startElement method.
       
   102 void RDefectTests::OnStartElementL(const RTagInfo& /*aElement*/, const RAttributeArray& /*aAttribute*/, TInt aErrorCode)
       
   103 	{
       
   104 	test(aErrorCode == KErrNone);
       
   105 	}
       
   106 
       
   107 
       
   108 // maps to SAX 2.0 endElement method.
       
   109 void RDefectTests::OnEndElementL(const RTagInfo& /*aElement*/, TInt aErrorCode)
       
   110 	{
       
   111 	test(aErrorCode == KErrNone);
       
   112 	}
       
   113 
       
   114 
       
   115 // maps to SAX 2.0 characters method.
       
   116 void RDefectTests::OnContentL(const TDesC8& /*aBytes*/, TInt aErrorCode)
       
   117 	{
       
   118 	test(aErrorCode == KErrNone);
       
   119 	}
       
   120 
       
   121 
       
   122 // maps to SAX 2.0 startPrefixMapping method.
       
   123 void RDefectTests::OnStartPrefixMappingL(const RString& /*aPrefix*/, const RString& /*aUri*/, TInt aErrorCode)
       
   124 	{
       
   125 	test.Next(_L("Entered OnStartPrefixMappingL"));
       
   126 	test(aErrorCode == KErrNone);
       
   127 	}
       
   128 
       
   129 
       
   130 // maps to SAX 2.0 endPrefixMapping method.
       
   131 void RDefectTests::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt aErrorCode)
       
   132 	{
       
   133 	test(aErrorCode == KErrNone);
       
   134 	}
       
   135 
       
   136 
       
   137 // maps to SAX 2.0 ignorableWhitespace method.
       
   138 void RDefectTests::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt aErrorCode)
       
   139 	{
       
   140 	test(aErrorCode == KErrNone);
       
   141 	}
       
   142 
       
   143 
       
   144 // maps to SAX 2.0 skippedEntity method.
       
   145 void RDefectTests::OnSkippedEntityL(const RString& /*aName*/, TInt aErrorCode)
       
   146 	{
       
   147 	test(aErrorCode == KErrNone);
       
   148 	}
       
   149 
       
   150 
       
   151 // maps to SAX 2.0 processingInstruction method.
       
   152 void RDefectTests::OnProcessingInstructionL(const TDesC8& /*aTarget*/, const TDesC8& /*aData*/, TInt aErrorCode)
       
   153 	{
       
   154 	test(aErrorCode == KErrNone);
       
   155 	}
       
   156 
       
   157 
       
   158 // Note that Oom tests between Xml and Wbxml behave differently.
       
   159 // Xml has a preallocated block of memory allocated upfront that
       
   160 // it uses to obtain internal memory allocations from.
       
   161 // In this manner out of memory allocations happen BEFORE parsing.
       
   162 // Therefore, OnError() is never called due to KErrNoMemory. However,
       
   163 // the parser will leave and fall into the oom TRAP block.
       
   164 // With Wbxml there is no such preallocation so an OnError will occur.
       
   165 void RDefectTests::OnError(TInt aErrorCode)
       
   166 	{
       
   167 	//This is done for the test DEF101097L which parses 2 corrupted xml file
       
   168 	//in a sequence & thus to check if OnError is called for both the files
       
   169 	//& avoid those errors by checking if the error is not KErrNone.
       
   170 	if(TheCorruptedXmlFileTest)
       
   171 	{
       
   172 		test(aErrorCode != KErrNone);
       
   173 		++TheCorruptedXmlFileTestErrorCount;
       
   174 	}
       
   175 	else
       
   176 		test (aErrorCode == KErrEof || aErrorCode == KErrNoMemory);
       
   177 	}
       
   178 
       
   179 
       
   180 TAny* RDefectTests::GetExtendedInterface(const TInt32 aUid)
       
   181 /**
       
   182 This method obtains the interface matching the specified uid.
       
   183 @return				0 if no interface matching the uid is found.
       
   184 					Otherwise, the this pointer cast to that interface.
       
   185 @param				aUid the uid identifying the required interface.
       
   186 */
       
   187 	{
       
   188 	if (aUid == 0)
       
   189 		{
       
   190 
       
   191 		}
       
   192 	return 0;
       
   193 	}
       
   194 
       
   195 
       
   196 //----------------------------------------------------------------------------
       
   197 // The Defect Tests
       
   198 
       
   199 LOCAL_C void SetupL()
       
   200 	{
       
   201 	test.Printf(_L("Unziping test xml files for defects\n"));
       
   202 
       
   203 	CUnzip* unzip = CUnzip::NewLC(TheFs, KZipTestFile);
       
   204 	unzip->ExtractL(KXmlTestDir);
       
   205 	CleanupStack::PopAndDestroy(unzip);
       
   206 
       
   207 	//Getch();
       
   208 	}
       
   209 
       
   210 
       
   211 //----------------------------------------------------------------------------
       
   212 
       
   213 
       
   214 /**
       
   215 @SYMTestCaseID 		 		SYSLIB-XML-CT-3750
       
   216 @SYMTestCaseDesc		    OOM Testing.
       
   217 @SYMTestPriority 		    Medium
       
   218 @SYMTestActions  		    Runs a set of test in oom conditions.
       
   219 @SYMTestExpectedResults 	The component(s) should fucntion as expected and the tests should pass.
       
   220 @SYMDEF					 	DEF060070
       
   221 */
       
   222 LOCAL_C void DoOomTestL(TestFunc testFuncL, const TDesC& /*aDesc*/)
       
   223 	{
       
   224 	test.Printf(_L(" @SYMTestCaseID:SYSLIB-XML-CT-3750    OOM test \n "));
       
   225 
       
   226 	TInt err, tryCount = 0;
       
   227 	do
       
   228 		{
       
   229 		User::__DbgSetAllocFail(RHeap::EUser, RHeap::EFailNext, ++tryCount);
       
   230 		User::__DbgMarkStart(RHeap::EUser);
       
   231 		TRAP(err, (*testFuncL)());
       
   232 		User::__DbgMarkEnd(RHeap::EUser, 0);
       
   233 		} while(err==KErrNoMemory);
       
   234 
       
   235 	if(err==KErrNone)
       
   236 		{
       
   237 		// Reset
       
   238 		User::__DbgSetAllocFail(RHeap::EUser,RHeap::ENone,1);
       
   239 		}
       
   240 	else
       
   241 		{
       
   242 		User::Panic(_L("Unexpected leave reason\n"),err);
       
   243 		}
       
   244 
       
   245 	test.Printf(_L("- succeeded with rate %i\r\n"), tryCount);
       
   246 	}
       
   247 
       
   248 
       
   249 //----------------------------------------------------------------------------
       
   250 
       
   251 
       
   252 LOCAL_C void DoTestL(TestFunc aTestFuncL, const TDesC& aDesc)
       
   253 	{
       
   254 	test.Next(aDesc);
       
   255 
       
   256 	// Set up for heap leak checking
       
   257 	__UHEAP_MARK;
       
   258 
       
   259 	// and leaking thread handles
       
   260 	TInt startProcessHandleCount;
       
   261 	TInt startThreadHandleCount;
       
   262 	TInt endProcessHandleCount;
       
   263 	TInt endThreadHandleCount;
       
   264 
       
   265 	// Test Starts...
       
   266 
       
   267 	RThread thisThread;
       
   268 	thisThread.HandleCount(startProcessHandleCount, startThreadHandleCount);
       
   269 
       
   270 	(*aTestFuncL)();
       
   271 
       
   272 	REComSession::FinalClose(); // Don't want leaks outside the test
       
   273 
       
   274 	//--------------
       
   275 	// Check for open handles
       
   276 	thisThread.HandleCount(endProcessHandleCount, endThreadHandleCount);
       
   277 
       
   278 	test(startThreadHandleCount == endThreadHandleCount);
       
   279 
       
   280 	__UHEAP_MARKEND;
       
   281 
       
   282 	DoOomTestL(aTestFuncL, aDesc);
       
   283 
       
   284 	}
       
   285 
       
   286 
       
   287 //----------------------------------------------------------------------------
       
   288 
       
   289 
       
   290 /**
       
   291 @SYMTestCaseID 		 		SYSLIB-XML-CT-1571
       
   292 @SYMTestCaseDesc		    Testing Prop: Symbian XML
       
   293 							Framework-MContentHandler::OnStartPrefixMappingL()never called
       
   294 @SYMTestPriority 		    Medium
       
   295 @SYMTestActions  		    Parsing a xml file and check whether framework calls
       
   296 							MContentHandler::OnStartPrefixMappingL() function
       
   297 @SYMTestExpectedResults 	Test output should show  "Entered OnStartPrefixMappingL".
       
   298 @SYMDEF 		 		 	DEF074797
       
   299 */
       
   300 
       
   301 
       
   302 LOCAL_C void DEF074797L()
       
   303 	{
       
   304 
       
   305 	_LIT8 (KXmlNamespace,"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\
       
   306 			<group xmlns=\"urn:oma:params:xml:ns:list-service\" xmlns:rl=\"urn:ietf:params:xml:ns:resource-lists\" xmlns:cr=\"urn:ietf:params:xml:ns:common-policy\">\
       
   307 			<list-service uri=\"sip:prearranged3+s60test.user24@ims3.so.noklab.net\">\
       
   308 			<display-name>prearranged3</display-name>\
       
   309 			<list>\
       
   310 			<entry uri=\"sip:s60test.user24@ims3.so.noklab.net\">\
       
   311 			<rl:display-name>tr</rl:display-name>\
       
   312 			</entry>\
       
   313 			</list>\
       
   314 			<invite-members>true</invite-members>\
       
   315 			<max-participant-count>10</max-participant-count>\
       
   316 			<cr:ruleset>\
       
   317 			<cr:rule id=\"0\">\
       
   318 			<cr:conditions>\
       
   319 			<is-list-member>true</is-list-member>\
       
   320 			</cr:conditions>\
       
   321 			<cr:actions>\
       
   322 			<join-handling>allow</join-handling>\
       
   323 			<allow-anonymity>true</allow-anonymity>\
       
   324 			<allow-initiate-conference>true</allow-initiate-conference>\
       
   325 			<allow-conference-state>true</allow-conference-state>\
       
   326 			</cr:actions>\
       
   327 			<cr:transformations />\
       
   328 			</cr:rule>\
       
   329 			</cr:ruleset>\
       
   330 			</list-service>\
       
   331 			</group>");
       
   332 
       
   333 
       
   334 	TBuf16<128> ucs4_0041;
       
   335 
       
   336 	// <wml>A</wml>
       
   337 	// 0x01, 0x04, 0x6A, 0x00, 0x7F, 0x02, 0x80, 0x41, 0x01
       
   338 
       
   339 	ucs4_0041.Append(0x01);
       
   340 	ucs4_0041.Append(0x04);
       
   341 	ucs4_0041.Append(0x6A);
       
   342 	ucs4_0041.Append(0x00);
       
   343 	ucs4_0041.Append(0x7F);
       
   344 	ucs4_0041.Append(0x02);
       
   345 	ucs4_0041.Append(0x80);
       
   346 	ucs4_0041.Append(0x41);
       
   347 	ucs4_0041.Append(0x01);
       
   348 
       
   349 	_LIT8 (KWbxmlParserDataType, "text/wbxml");
       
   350 
       
   351 	RDefectTests handler;
       
   352 	CleanupClosePushL (handler);
       
   353 
       
   354 	CParser* parser = CParser::NewL(KXmlParserDataType, handler);
       
   355 	CleanupStack::PushL (parser);
       
   356 
       
   357 	User::LeaveIfError( parser->EnableFeature( EReportNamespaces ) );
       
   358 	User::LeaveIfError( parser->EnableFeature( EReportNamespaceMapping ) );
       
   359 	User::LeaveIfError( parser->EnableFeature( EReportNamespacePrefixes ) );
       
   360 
       
   361 	// Parse the xml document
       
   362 	ParseL(*parser, KXmlNamespace);
       
   363 
       
   364 	// Now switch to a different parser (wbxml)
       
   365 	parser->ParseBeginL (KWbxmlParserDataType);
       
   366 
       
   367 	TBuf8<256> buf8;
       
   368 	// Copy will ignore the upper byte if the byte-pair < 256, otherwise the value 1 is used.
       
   369 	buf8.Copy(ucs4_0041);
       
   370 
       
   371 	parser->ParseL(buf8);
       
   372 
       
   373 	// Now switch back to the default parser (xml)
       
   374 	ParseL(*parser, KXmlNamespace);
       
   375 
       
   376 	CleanupStack::PopAndDestroy (parser);
       
   377 	CleanupStack::PopAndDestroy (&handler);
       
   378 
       
   379 	}
       
   380 
       
   381 
       
   382 //----------------------------------------------------------------------------
       
   383 
       
   384 
       
   385 /**
       
   386 @SYMTestCaseID 		 		SYSLIB-XML-CT-3749
       
   387 @SYMTestCaseDesc		    Swapping parsers back and forth between parsing the same document twice.
       
   388 @SYMTestPriority 		    Medium
       
   389 @SYMTestActions  		    Parse an xml document, swap to the wbxml parser, then swap back to the xml parser and parse.
       
   390 @SYMTestExpectedResults 	The test completes successfully.
       
   391 @SYMDEF 		 		 	INC063222
       
   392 */
       
   393 LOCAL_C void INC063222L()
       
   394 	{
       
   395 	_LIT8 (KXmlNamespace, "<RootElement rabbits:att=\"value\">\
       
   396 		   <Element xmlns=\"http://www.symbian.com\" att=\"value\">\
       
   397 		   <elprefix:Element xmlns:elprefix=\"http://element.uri\" att=\"value\">\
       
   398 		   <Element xmlns:attprefix=\"http://attribute.uri\" attprefix:att=\"value\"/>\
       
   399 		   <Element attprefix:att=\"value\"/>\
       
   400 		   </elprefix:Element>\
       
   401 		   </Element>\
       
   402 		   </RootElement>");
       
   403 
       
   404 	TBuf16<128> ucs4_0041;
       
   405 
       
   406 	// <wml>A</wml>
       
   407 	// 0x01, 0x04, 0x6A, 0x00, 0x7F, 0x02, 0x80, 0x41, 0x01
       
   408 
       
   409 	ucs4_0041.Append(0x01);
       
   410 	ucs4_0041.Append(0x04);
       
   411 	ucs4_0041.Append(0x6A);
       
   412 	ucs4_0041.Append(0x00);
       
   413 	ucs4_0041.Append(0x7F);
       
   414 	ucs4_0041.Append(0x02);
       
   415 	ucs4_0041.Append(0x80);
       
   416 	ucs4_0041.Append(0x41);
       
   417 	ucs4_0041.Append(0x01);
       
   418 
       
   419 	_LIT8 (KWbxmlParserDataType, "text/wbxml");
       
   420 
       
   421 	RDefectTests handler;
       
   422 	CleanupClosePushL (handler);
       
   423 
       
   424 	CParser* parser = CParser::NewL(KXmlParserDataType, handler);
       
   425 	CleanupStack::PushL (parser);
       
   426 
       
   427 	User::LeaveIfError(parser->EnableFeature(EReportNamespaceMapping));
       
   428 
       
   429 	// Parse the xml document
       
   430 	ParseL(*parser, KXmlNamespace);
       
   431 
       
   432 	// Now switch to a different parser (wbxml)
       
   433 	parser->ParseBeginL (KWbxmlParserDataType);
       
   434 
       
   435 	TBuf8<256> buf8;
       
   436 	// Copy will ignore the upper byte if the byte-pair < 256, otherwise the value 1 is used.
       
   437 	buf8.Copy(ucs4_0041);
       
   438 
       
   439 	parser->ParseL(buf8);
       
   440 
       
   441 	// Now switch back to the default parser (xml)
       
   442 	ParseL(*parser, KXmlNamespace);
       
   443 
       
   444 	CleanupStack::PopAndDestroy (parser);
       
   445 	CleanupStack::PopAndDestroy (&handler);
       
   446 	}
       
   447 
       
   448 
       
   449 //----------------------------------------------------------------------------
       
   450 
       
   451 /**
       
   452 @SYMTestCaseID 		 		SYSLIB-XML-CT-3747
       
   453 @SYMTestCaseDesc		    Parsing a document supplied via a file handle.
       
   454 @SYMTestPriority 		    Medium
       
   455 @SYMTestActions  		    Creating a parser and opening file handle to a xml document and then parsing the document.
       
   456 @SYMTestExpectedResults 	The document is parsed.
       
   457 @SYMDEF 		 		 	DEF060070
       
   458 */
       
   459 LOCAL_C void DEF060070L()
       
   460 	{
       
   461 	RDefectTests handler;
       
   462 	CleanupClosePushL (handler);
       
   463 
       
   464 	CParser* parser = CParser::NewLC(KXmlParserDataType, handler);
       
   465 
       
   466 	RFile handle;
       
   467 	handle.Open(TheFs, KSimpleFile, EFileShareReadersOnly);
       
   468 	CleanupClosePushL (handle);
       
   469 
       
   470 	ParseL(*parser, handle);
       
   471 
       
   472 	CleanupStack::PopAndDestroy (&handle);
       
   473 	CleanupStack::PopAndDestroy (parser);
       
   474 	CleanupStack::PopAndDestroy (&handler);
       
   475 	}
       
   476 
       
   477 
       
   478 //----------------------------------------------------------------------------
       
   479 
       
   480 /**
       
   481 @SYMTestCaseID 		 		SYSLIB-XML-CT-3748
       
   482 @SYMTestCaseDesc		    Processing namespaces.
       
   483 @SYMTestPriority 		    Medium
       
   484 @SYMTestActions  		    Creating an xml parser and enabling namespace mapping reporting, before parsing a document.
       
   485 @SYMTestExpectedResults 	The document is parsed with the namespace mapping reporting enabled.
       
   486 @SYMDEF 		 		 	INC059062
       
   487 */
       
   488 LOCAL_C void INC059062L()
       
   489 	{
       
   490 	RDefectTests handler;
       
   491 	CleanupClosePushL (handler);
       
   492 
       
   493 	CParser* parser = CParser::NewLC(KXmlParserDataType, handler);
       
   494 
       
   495 	User::LeaveIfError(parser->EnableFeature(EReportNamespaceMapping));
       
   496 
       
   497 	RFile handle;
       
   498 	handle.Open(TheFs, KNsAndBindingFile, EFileShareReadersOnly);
       
   499 	CleanupClosePushL (handle);
       
   500 
       
   501 	ParseL(*parser, handle);
       
   502 
       
   503 	CleanupStack::PopAndDestroy (&handle);
       
   504 	CleanupStack::PopAndDestroy (parser);
       
   505 	CleanupStack::PopAndDestroy (&handler);
       
   506 	}
       
   507 
       
   508 
       
   509 //----------------------------------------------------------------------------
       
   510 
       
   511 
       
   512 /*
       
   513 @SYMTestCaseID          SYSLIB-XML-UT-3366
       
   514 @SYMTestCaseDesc	    DEF101097: The XML parser don't leave twice when it parse several invalid xml files
       
   515 @SYMTestPriority 	    Low
       
   516 @SYMTestActions  	    Tests that the xml parser returns an error each time it parses the same corrupted xml file.
       
   517 @SYMTestExpectedResults Test must not fail
       
   518 @SYMDEF                 DEF101097
       
   519 */
       
   520 LOCAL_C void DEF101097L()
       
   521 	{
       
   522 	TheCorruptedXmlFileTest = ETrue;
       
   523 
       
   524 	_LIT  (KTestDocument1, "c:\\system\\data\\xml\\xml\\Corruptedbackupreg.xml");
       
   525 
       
   526 	RDefectTests handler;
       
   527 	CleanupClosePushL (handler);
       
   528 
       
   529 	CParser* parser = CParser::NewLC(KXmlParserDataType, handler);
       
   530 
       
   531 	// Parse the first xml doc.
       
   532 	ParseL(*parser,TheFs, KTestDocument1);
       
   533 
       
   534 	// Parse the second xml doc i.e. same data.
       
   535 	ParseL(*parser,TheFs, KTestDocument1);
       
   536 
       
   537 	test(TheCorruptedXmlFileTestErrorCount == 2);
       
   538 
       
   539 	TheCorruptedXmlFileTest = EFalse;
       
   540 	TheCorruptedXmlFileTestErrorCount = 0;
       
   541 
       
   542 	CleanupStack::PopAndDestroy (parser);
       
   543 	CleanupStack::PopAndDestroy (&handler);
       
   544 	}
       
   545 
       
   546 
       
   547 //----------------------------------------------------------------------------
       
   548 
       
   549 
       
   550 
       
   551 /*
       
   552 @SYMTestCaseID          SYSLIB-XML-UT-4937
       
   553 @SYMTestCaseDesc	   	Xml::ParseL()  Shouldn't Leave with KErrNoMemory for Non-Well formed Large XML file
       
   554 @SYMTestPriority 	    Medium
       
   555 @SYMTestActions  	    Tests that the Xml parser doesn't leave with KErrNoMemory from ParseL each time it parses the same Corrupted Large Xml file.
       
   556 @SYMTestExpectedResults Test must not fail
       
   557 @SYMDEF                 INC134125	
       
   558 */
       
   559 
       
   560 LOCAL_C void INC134125L()
       
   561 	{
       
   562 		TheCorruptedXmlFileTest = ETrue;
       
   563 		
       
   564 		_LIT  (KTestDocument1, "c:\\system\\data\\xml\\xml\\Corruptbigfile.xml");
       
   565 		RDefectTests handler;
       
   566 		CleanupClosePushL (handler);
       
   567 		CParser* parser = CParser::NewLC(KXmlParserDataType, handler);
       
   568 		// Parse the Corrupt Big Xml file.
       
   569 		ParseL(*parser,TheFs, KTestDocument1);
       
   570 		test(TheCorruptedXmlFileTestErrorCount == 1);
       
   571 		TheCorruptedXmlFileTest = EFalse;
       
   572 		TheCorruptedXmlFileTestErrorCount = 0;
       
   573 		CleanupStack::PopAndDestroy (parser);
       
   574 		CleanupStack::PopAndDestroy (&handler);
       
   575 	}
       
   576 
       
   577 
       
   578 //----------------------------------------------------------------------------
       
   579 
       
   580 LOCAL_C void DoTestsL()
       
   581 	{
       
   582 	DoTestL(DEF060070L, _L(" @SYMTestCaseID:SYSLIB-XML-CT-3747 DEF060070 - XML parser cannot parse a file supplied by handle...\n "));
       
   583 	DoTestL(INC059062L, _L(" @SYMTestCaseID:SYSLIB-XML-CT-3748 INC059062 - XML Parser Integration - namespaces not processing properly...\n "));
       
   584 	DoTestL(INC063222L, _L(" @SYMTestCaseID:SYSLIB-XML-CT-3749 INC063222 - Symbian XML Framework - MContentHandler::OnStartPrefixMappingL() is never called...\n "));
       
   585 	DoTestL(DEF074797L, _L(" @SYMTestCaseID:SYSLIB-XML-CT-1571 DEF074797 - Prop: Symbian XML Framework-MContentHandler::OnStartPrefixMappingL()never called...\n "));
       
   586 	DoTestL(DEF101097L, _L(" @SYMTestCaseID:SYSLIB-XML-UT-3366 DEF101097 - The XML parser don't leave twice when it parse several invalid xml files...\n "));
       
   587 	DoTestL(INC134125L, _L("INC134125 - Xml::ParseL()  Shouldn't Leave with KErrNoMemory for Non-Well formed Large XML file...\n"));
       
   588 	}
       
   589 
       
   590 
       
   591 //----------------------------------------------------------------------------
       
   592 
       
   593 
       
   594 TInt E32Main()
       
   595     {
       
   596 	__UHEAP_MARK;
       
   597 
       
   598 	test.Printf(_L("\n"));
       
   599 	test.Title();
       
   600 	test.Start(_L("XML Defect tests\n"));
       
   601 
       
   602 	// Connect the file server instance
       
   603 	User::LeaveIfError(TheFs.Connect());
       
   604 
       
   605 	TheTrapCleanup = CTrapCleanup::New();
       
   606 
       
   607 	TRAPD(err, SetupL());
       
   608 	test(err == KErrNone);
       
   609 
       
   610 	TRAP(err, DoTestsL());
       
   611 	test(err == KErrNone);
       
   612 
       
   613 	delete TheTrapCleanup;
       
   614 
       
   615 	TheFs.Close();
       
   616 
       
   617 	test.End();
       
   618 	test.Close();
       
   619 
       
   620 	__UHEAP_MARKEND;
       
   621 	return (KErrNone);
       
   622     }
       
   623