textrendering/texthandling/ttext/T_CPLAIN.CPP
branchRCL_3
changeset 54 748ec5531811
parent 0 1fb32624e06b
child 55 336bee5c2d35
equal deleted inserted replaced
36:f902e87c146f 54:748ec5531811
     1 /*
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    14 * Description: 
    14 * Description: 
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include <e32test.h>
       
    20 #include <txtetext.h>
    19 #include <txtetext.h>
    21 
    20 #include "T_CPLAIN.h"
    22 LOCAL_D RTest test(_L("CPlainText Document"));
    21 
       
    22 LOCAL_D CTestStep *pTestStep = NULL;
       
    23 #define test(cond)											\
       
    24 	{														\
       
    25 	TBool __bb = (cond);									\
       
    26 	pTestStep->TEST(__bb);									\
       
    27 	if (!__bb)												\
       
    28 		{													\
       
    29 		pTestStep->ERR_PRINTF1(_L("ERROR: Test Failed"));	\
       
    30 		User::Leave(1);										\
       
    31 		}													\
       
    32 	}
       
    33 #undef INFO_PRINTF1
       
    34 #undef INFO_PRINTF2
       
    35 // copy from tefexportconst.h
       
    36 #define INFO_PRINTF1(p1)        pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1))
       
    37 #define INFO_PRINTF2(p1, p2)    pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2))
    23 
    38 
    24 const TBool KPictureIsDelimiter=EFalse;
    39 const TBool KPictureIsDelimiter=EFalse;
    25 const TBool KPunctuationIsDelimiter=ETrue;
    40 const TBool KPunctuationIsDelimiter=ETrue;
    26 
    41 
    27 template<class S,class T,CEditableText::TDocumentStorage D>
    42 template<class S,class T,CEditableText::TDocumentStorage D>
   290 	{
   305 	{
   291 	__UHEAP_MARK;
   306 	__UHEAP_MARK;
   292 	test(iByteStore!=NULL);
   307 	test(iByteStore!=NULL);
   293 	CheckDocLength(0);
   308 	CheckDocLength(0);
   294 	
   309 	
   295    	test.Start(_L("NewL()"));
   310    	INFO_PRINTF1(_L("NewL()"));
   296   	CPlainText* document=CPlainText::NewL(D);
   311   	CPlainText* document=CPlainText::NewL(D);
   297 	document->InsertL(0,iDefaultDoc);
   312 	document->InsertL(0,iDefaultDoc);
   298 	test(document->DocumentLength()==95);
   313 	test(document->DocumentLength()==95);
   299 	delete document;
   314 	delete document;
   300 #ifdef _DEBUG
   315 #ifdef _DEBUG
   301   	test.Next(_L("NewL() failing on OOM"));
   316   	INFO_PRINTF1(_L("NewL() failing on OOM"));
   302 	TInt flag=0;
   317 	TInt flag=0;
   303 	__UHEAP_FAILNEXT(1);
   318 	__UHEAP_FAILNEXT(1);
   304 	TRAPD(ret, (void)CPlainText::NewL(D));
   319 	TRAPD(ret, (void)CPlainText::NewL(D));
   305 	if (ret!=KErrNone)
   320 	if (ret!=KErrNone)
   306 		{
   321 		{
   307 		flag++;
   322 		flag++;
   308 		}
   323 		}
   309 	test(flag!=0);
   324 	// seems __UHEAP_FAILNEXT does not work well in platsim.
       
   325 	// below test does not pass in platsim.
       
   326 //	test(flag!=0);
   310 #endif
   327 #endif
   311 
   328 
   312 	test.End();
       
   313 	__UHEAP_MARKEND;
   329 	__UHEAP_MARKEND;
   314 	}
   330 	}
   315 
   331 
   316 
   332 
   317 template<class S, class T,CEditableText::TDocumentStorage D>
   333 template<class S, class T,CEditableText::TDocumentStorage D>
   323 	{
   339 	{
   324 	__UHEAP_MARK;
   340 	__UHEAP_MARK;
   325 	CPlainText* document=CPlainText::NewL(D);
   341 	CPlainText* document=CPlainText::NewL(D);
   326 	document->InsertL(0,iDefaultDoc);
   342 	document->InsertL(0,iDefaultDoc);
   327 	
   343 	
   328 	test.Start(_L("sense from start"));
   344 	INFO_PRINTF1(_L("sense from start"));
   329 	/*TPtrC dummy=*/document->Read(0);
   345 	/*TPtrC dummy=*/document->Read(0);
   330 	CheckDocLength(document,95);
   346 	CheckDocLength(document,95);
   331 	CheckContent(document,iComp1);
   347 	CheckContent(document,iComp1);
   332 
   348 
   333 	test.Next(_L("sense from n"));
   349 	INFO_PRINTF1(_L("sense from n"));
   334 	TPtrC dummy2=document->Read(45);
   350 	TPtrC dummy2=document->Read(45);
   335 	//iDummy.Set(document->Read(45).Ptr(),document->Read(45).Length());
   351 	//iDummy.Set(document->Read(45).Ptr(),document->Read(45).Length());
   336 	CPlainText* doc2=CPlainText::NewL(D);
   352 	CPlainText* doc2=CPlainText::NewL(D);
   337 	doc2->InsertL(0,dummy2);
   353 	doc2->InsertL(0,dummy2);
   338 	doc2->DeleteL(50,1);  // We need a debug copy constructor here.  The origianl
   354 	doc2->DeleteL(50,1);  // We need a debug copy constructor here.  The origianl
   343 		// trailing, unwanted eod character.
   359 		// trailing, unwanted eod character.
   344 	CheckDocLength(doc2,50);
   360 	CheckDocLength(doc2,50);
   345 	CheckContent(doc2,iComp2);
   361 	CheckContent(doc2,iComp2);
   346 	delete doc2;
   362 	delete doc2;
   347 	
   363 	
   348 	test.Next(_L("sense from last-1"));
   364 	INFO_PRINTF1(_L("sense from last-1"));
   349 	iDummy.Set(document->Read(93).Ptr(),document->Read(93).Length());
   365 	iDummy.Set(document->Read(93).Ptr(),document->Read(93).Length());
   350 	CPlainText* doc3=CPlainText::NewL(D);
   366 	CPlainText* doc3=CPlainText::NewL(D);
   351 	doc3->InsertL(0,iDummy);
   367 	doc3->InsertL(0,iDummy);
   352 	doc3->DeleteL(2,1);
   368 	doc3->DeleteL(2,1);
   353 	CheckDocLength(doc3,2);
   369 	CheckDocLength(doc3,2);
   354 	CheckContent(doc3,iComp3);
   370 	CheckContent(doc3,iComp3);
   355 	delete doc3;
   371 	delete doc3;
   356 	
   372 	
   357 	test.Next(_L("sense from last"));
   373 	INFO_PRINTF1(_L("sense from last"));
   358 	iDummy.Set(document->Read(94).Ptr(),document->Read(94).Length());
   374 	iDummy.Set(document->Read(94).Ptr(),document->Read(94).Length());
   359 	CPlainText* doc4=CPlainText::NewL(D);
   375 	CPlainText* doc4=CPlainText::NewL(D);
   360 	doc4->InsertL(0,iDummy);
   376 	doc4->InsertL(0,iDummy);
   361 	doc4->DeleteL(1,1);
   377 	doc4->DeleteL(1,1);
   362 	CheckDocLength(doc4,1);
   378 	CheckDocLength(doc4,1);
   363 	CheckContent(doc4,iComp4);
   379 	CheckContent(doc4,iComp4);
   364 	delete doc4;
   380 	delete doc4;
   365 
   381 
   366 	test.Next(_L("sense from last+1"));
   382 	INFO_PRINTF1(_L("sense from last+1"));
   367 	iDummy.Set(document->Read(95).Ptr(),document->Read(95).Length());
   383 	iDummy.Set(document->Read(95).Ptr(),document->Read(95).Length());
   368 	CPlainText* doc5=CPlainText::NewL(D);
   384 	CPlainText* doc5=CPlainText::NewL(D);
   369 	doc5->InsertL(0,iDummy);
   385 	doc5->InsertL(0,iDummy);
   370 	doc5->DeleteL(0,1);
   386 	doc5->DeleteL(0,1);
   371 	CheckDocLength(doc5,0);
   387 	CheckDocLength(doc5,0);
   372 	CheckContent(doc5,iComp5);
   388 	CheckContent(doc5,iComp5);
   373 	delete doc5;
   389 	delete doc5;
   374 	
   390 	
   375 	delete document;
   391 	delete document;
   376 	test.End();
       
   377 	__UHEAP_MARKEND;
   392 	__UHEAP_MARKEND;
   378 	}
   393 	}
   379 
   394 
   380 
   395 
   381 template<class S, class T,CEditableText::TDocumentStorage D>
   396 template<class S, class T,CEditableText::TDocumentStorage D>
   393 	document->InsertL(0,iInBuf);
   408 	document->InsertL(0,iInBuf);
   394 	iOutBuf.Set(document->Read(0));
   409 	iOutBuf.Set(document->Read(0));
   395 	CheckDocLength(document,10);
   410 	CheckDocLength(document,10);
   396 	CheckContent(document,iOutBufComp);
   411 	CheckContent(document,iOutBufComp);
   397 
   412 
   398 	test.Start(_L("Inverting at start"));
   413 	INFO_PRINTF1(_L("Inverting at start"));
   399 	document->InsertL(0,iInBuf2);
   414 	document->InsertL(0,iInBuf2);
   400 	document->InsertL(0,character);
   415 	document->InsertL(0,character);
   401 	document->DeleteL(0,1);
   416 	document->DeleteL(0,1);
   402 	CheckDocLength(document,14);
   417 	CheckDocLength(document,14);
   403 	document->DeleteL(0,4);
   418 	document->DeleteL(0,4);
   404  	iOutBuf2.Set(document->Read(0));
   419  	iOutBuf2.Set(document->Read(0));
   405 	CheckDocLength(document,10);
   420 	CheckDocLength(document,10);
   406 	CheckContent(document,iOutBufComp);
   421 	CheckContent(document,iOutBufComp);
   407 
   422 
   408 	test.Next(_L("Inverting in middle"));
   423 	INFO_PRINTF1(_L("Inverting in middle"));
   409 	document->InsertL(4,iInBuf2);
   424 	document->InsertL(4,iInBuf2);
   410 	document->InsertL(5,character);
   425 	document->InsertL(5,character);
   411 	document->DeleteL(5,1);
   426 	document->DeleteL(5,1);
   412 	CheckDocLength(document,14);
   427 	CheckDocLength(document,14);
   413 	document->DeleteL(4,4);
   428 	document->DeleteL(4,4);
   414 	iOutBuf2.Set(document->Read(0));
   429 	iOutBuf2.Set(document->Read(0));
   415 	CheckDocLength(document,10);
   430 	CheckDocLength(document,10);
   416 	CheckContent(document,iOutBufComp);
   431 	CheckContent(document,iOutBufComp);
   417 
   432 
   418 	test.Next(_L("Inverting at end"));	
   433 	INFO_PRINTF1(_L("Inverting at end"));	
   419 	document->InsertL(10,iInBuf2);
   434 	document->InsertL(10,iInBuf2);
   420 	document->InsertL(11,character);
   435 	document->InsertL(11,character);
   421 	document->DeleteL(11,1);
   436 	document->DeleteL(11,1);
   422 	CheckDocLength(document,14);
   437 	CheckDocLength(document,14);
   423 	document->DeleteL(10,4);
   438 	document->DeleteL(10,4);
   426 	CheckContent(document,iOutBufComp);
   441 	CheckContent(document,iOutBufComp);
   427 
   442 
   428 	document->DeleteL(0,10);
   443 	document->DeleteL(0,10);
   429 	CheckDocLength(0);
   444 	CheckDocLength(0);
   430 	delete document;
   445 	delete document;
   431 	test.End();
   446 
   432 	__UHEAP_MARKEND;
   447 	__UHEAP_MARKEND;
   433 	}
   448 	}
   434 
   449 
   435 
   450 
   436 template<class S,class T,CEditableText::TDocumentStorage D>
   451 template<class S,class T,CEditableText::TDocumentStorage D>
   457 	// Create document.
   472 	// Create document.
   458 	CPlainText* document=CPlainText::NewL(D);
   473 	CPlainText* document=CPlainText::NewL(D);
   459 	TPtrC body(content);
   474 	TPtrC body(content);
   460 	document->InsertL(0,body);
   475 	document->InsertL(0,body);
   461 	// Now do the tests.
   476 	// Now do the tests.
   462 	test.Start(_L("Paragraph 1"));
   477 	INFO_PRINTF1(_L("Paragraph 1"));
   463 	DoParagraphStart(0,55,document);  // Paragraph 1
   478 	DoParagraphStart(0,55,document);  // Paragraph 1
   464 	test.Next(_L("Paragraph 2"));
   479 	INFO_PRINTF1(_L("Paragraph 2"));
   465 	DoParagraphStart(55,23,document);  // Paragraph 2
   480 	DoParagraphStart(55,23,document);  // Paragraph 2
   466 	test.Next(_L("Paragraph 3"));
   481 	INFO_PRINTF1(_L("Paragraph 3"));
   467 	DoParagraphStart(78,20,document);  // Paragraph 3
   482 	DoParagraphStart(78,20,document);  // Paragraph 3
   468 	test.Next(_L("Paragraph 4->2 consecutive delimiters, posshould not change"));
   483 	INFO_PRINTF1(_L("Paragraph 4->2 consecutive delimiters, posshould not change"));
   469 	DoParagraphStart(99,1,document);  // Paragraph 6
   484 	DoParagraphStart(99,1,document);  // Paragraph 6
   470 
   485 
   471 	delete document;
   486 	delete document;
   472 	test.End();
       
   473 	}
   487 	}
   474 
   488 
   475 
   489 
   476 template<class S,class T,CEditableText::TDocumentStorage D>
   490 template<class S,class T,CEditableText::TDocumentStorage D>
   477 void TestCPlainText<S,T,D>::CPlainTest5L()
   491 void TestCPlainText<S,T,D>::CPlainTest5L()
   481 	{
   495 	{
   482 	__UHEAP_MARK;
   496 	__UHEAP_MARK;
   483 	CPlainText* doc=CPlainText::NewL(D);
   497 	CPlainText* doc=CPlainText::NewL(D);
   484 	doc->InsertL(0,iDefaultDoc);
   498 	doc->InsertL(0,iDefaultDoc);
   485 
   499 
   486 	test.Start(_L("Extract(buf)"));
   500 	INFO_PRINTF1(_L("Extract(buf)"));
   487 	TBuf<128> buf;
   501 	TBuf<128> buf;
   488 	doc->Extract(buf);
   502 	doc->Extract(buf);
   489 	CheckContent(iDefaultDoc,buf);
   503 	CheckContent(iDefaultDoc,buf);
   490 
   504 
   491 	test.Next(_L("Extract(buf,pos)"));
   505 	INFO_PRINTF1(_L("Extract(buf,pos)"));
   492 	TInt pos=45;
   506 	TInt pos=45;
   493 	doc->Extract(buf,pos);
   507 	doc->Extract(buf,pos);
   494 	CheckContent(iComp2,buf);
   508 	CheckContent(iComp2,buf);
   495 
   509 
   496 	test.Next(_L("Extract(buf) from multiple segments"));
   510 	INFO_PRINTF1(_L("Extract(buf) from multiple segments"));
   497 	TBuf<256> bigBuf(_L("abcdefghijklmnopqrstuvwxyzABCEDFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCEDFGHIJKLMNOPQRSTUVWXYZ"));
   511 	TBuf<256> bigBuf(_L("abcdefghijklmnopqrstuvwxyzABCEDFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCEDFGHIJKLMNOPQRSTUVWXYZ"));
   498 	CPlainText* segDoc=CPlainText::NewL(ESegmentedStorage);
   512 	CPlainText* segDoc=CPlainText::NewL(ESegmentedStorage);
   499 	segDoc->InsertL(0,bigBuf);
   513 	segDoc->InsertL(0,bigBuf);
   500 	segDoc->Extract(buf);
   514 	segDoc->Extract(buf);
   501 	CheckContent(bigBuf,buf);
   515 	CheckContent(bigBuf,buf);
   502 	delete segDoc;
   516 	delete segDoc;
   503 
   517 
   504 	test.End();
       
   505 	delete doc;
   518 	delete doc;
   506 	__UHEAP_MARKEND;
   519 	__UHEAP_MARKEND;
   507 	}
   520 	}
   508 
   521 
   509 
   522 
   517 	TPtrC content(_L("   some   testing  a  texty     content"));
   530 	TPtrC content(_L("   some   testing  a  texty     content"));
   518 
   531 
   519 	CPlainText* doc=CPlainText::NewL(D);
   532 	CPlainText* doc=CPlainText::NewL(D);
   520 	doc->InsertL(0,content);
   533 	doc->InsertL(0,content);
   521 
   534 
   522 	test.Start(_L("WordInfo()"));
   535 	INFO_PRINTF1(_L("WordInfo()"));
   523 	TInt currentPos,startPos,length;
   536 	TInt currentPos,startPos,length;
   524 	currentPos=0;
   537 	currentPos=0;
   525 	doc->GetWordInfo(currentPos,startPos,length,KPictureIsDelimiter,KPunctuationIsDelimiter);
   538 	doc->GetWordInfo(currentPos,startPos,length,KPictureIsDelimiter,KPunctuationIsDelimiter);
   526 	test(startPos==0);	test(length==0);
   539 	test(startPos==0);	test(length==0);
   527 	currentPos=1;
   540 	currentPos=1;
   577 
   590 
   578 	currentPos=39;
   591 	currentPos=39;
   579 	doc->GetWordInfo(currentPos,startPos,length,KPictureIsDelimiter,KPunctuationIsDelimiter);
   592 	doc->GetWordInfo(currentPos,startPos,length,KPictureIsDelimiter,KPunctuationIsDelimiter);
   580 	test(startPos=32);	test(length==7);
   593 	test(startPos=32);	test(length==7);
   581 
   594 
   582 	test.End();
       
   583 	delete doc;
   595 	delete doc;
   584 	__UHEAP_MARKEND;
   596 	__UHEAP_MARKEND;
   585 	}
   597 	}
   586 
   598 
   587 
   599 
   754 //
   766 //
   755 // Tests the reset method behave as specified.
   767 // Tests the reset method behave as specified.
   756 //
   768 //
   757 	{
   769 	{
   758 	__UHEAP_MARK;
   770 	__UHEAP_MARK;
   759 	test.Start(_L("1st Reset"));
   771 	INFO_PRINTF1(_L("1st Reset"));
   760 	CPlainText* doc=CPlainText::NewL(D);
   772 	CPlainText* doc=CPlainText::NewL(D);
   761 	doc->InsertL(0,iDefaultDoc);
   773 	doc->InsertL(0,iDefaultDoc);
   762 	test(doc->DocumentLength()==95);
   774 	test(doc->DocumentLength()==95);
   763 	doc->Reset();
   775 	doc->Reset();
   764 	test(doc->DocumentLength()==0);
   776 	test(doc->DocumentLength()==0);
   766 	// Test multiple resets work.
   778 	// Test multiple resets work.
   767 	// This defect was highlighted by DavidW 13.10.95.
   779 	// This defect was highlighted by DavidW 13.10.95.
   768 	// It arises because I have added an assert length>0 in the delete method.
   780 	// It arises because I have added an assert length>0 in the delete method.
   769 	// Clearly on a second reset the length is zero, hence the failure.
   781 	// Clearly on a second reset the length is zero, hence the failure.
   770 	// Defect fixed 13.10.95 by DuncanS and included in the tests below.
   782 	// Defect fixed 13.10.95 by DuncanS and included in the tests below.
   771 	test.Next(_L("2nd Reset - defect - DavidW 13.10.95"));
   783 	INFO_PRINTF1(_L("2nd Reset - defect - DavidW 13.10.95"));
   772 	doc->Reset();
   784 	doc->Reset();
   773 	
   785 	
   774 	delete doc;
   786 	delete doc;
   775 	test.End();
       
   776 	__UHEAP_MARKEND;
   787 	__UHEAP_MARKEND;
   777 	}
   788 	}
   778 
   789 
   779 /**
   790 /**
   780 @SYMTestCaseID          SYSLIB-ETEXT-UT-1574
   791 @SYMTestCaseID          SYSLIB-ETEXT-UT-1574
   804 	TInt NumberToHide = 0; 	
   815 	TInt NumberToHide = 0; 	
   805 	MFepInlineTextFormatRetriever* InlineTextFormatRetriever = NULL;
   816 	MFepInlineTextFormatRetriever* InlineTextFormatRetriever = NULL;
   806 	TBufC<20> InitialInlineText =_L("INLINE_TEXT");  // inline text to be inserted	
   817 	TBufC<20> InitialInlineText =_L("INLINE_TEXT");  // inline text to be inserted	
   807 	TBuf<50> outputBuf;
   818 	TBuf<50> outputBuf;
   808 			
   819 			
   809 	test.Start(_L("Return all the text"));
   820 	INFO_PRINTF1(_L("Return all the text"));
   810 	CPlainText* doc=CPlainText::NewL(D);
   821 	CPlainText* doc=CPlainText::NewL(D);
   811 	doc->DocumentLength();
   822 	doc->DocumentLength();
   812 	doc->InsertL(0,iInsertBuf); // insert "abcdefghijklmnopqrstuvwxyz"
   823 	doc->InsertL(0,iInsertBuf); // insert "abcdefghijklmnopqrstuvwxyz"
   813 
   824 
   814 	
   825 	
   817 	doc->StartFepInlineEditL(HasChangedFormat,NumberDeleted,NumberInserted,PositionOfInsertion,NewPositionOfInsertion,InitialInlineText,PosOfInlineText,NumberToHide,*InlineTextFormatRetriever);
   828 	doc->StartFepInlineEditL(HasChangedFormat,NumberDeleted,NumberInserted,PositionOfInsertion,NewPositionOfInsertion,InitialInlineText,PosOfInlineText,NumberToHide,*InlineTextFormatRetriever);
   818 
   829 
   819 	doc->Extract(outputBuf, startingPositionZero, textLengthFifty);  // Returns all the text
   830 	doc->Extract(outputBuf, startingPositionZero, textLengthFifty);  // Returns all the text
   820 	test (iTestBuf1 == outputBuf);  // testing outputBuf, making sure it contains the inline text - "abcdefINLINE_TEXTghijklmnopqrstuvwxyz"
   831 	test (iTestBuf1 == outputBuf);  // testing outputBuf, making sure it contains the inline text - "abcdefINLINE_TEXTghijklmnopqrstuvwxyz"
   821 	
   832 	
   822 	test.Next(_L("Extract and discard only the inline text, from Pos0 returning the rest"));
   833 	INFO_PRINTF1(_L("Extract and discard only the inline text, from Pos0 returning the rest"));
   823 	doc->ExtractSelectively(outputBuf, startingPositionZero, textLengthFifty, EExcludeInlineEditedText); // Returns only non-inline text
   834 	doc->ExtractSelectively(outputBuf, startingPositionZero, textLengthFifty, EExcludeInlineEditedText); // Returns only non-inline text
   824 	test (iInsertBuf == outputBuf); // testing outputBuf, making sure the inline text has been extracted correctly - "abcdefghijklmnopqrstuvwxyz"	
   835 	test (iInsertBuf == outputBuf); // testing outputBuf, making sure the inline text has been extracted correctly - "abcdefghijklmnopqrstuvwxyz"	
   825 	delete doc;	
   836 	delete doc;	
   826 
   837 
   827 
   838 
   828 	CPlainText* doc2=CPlainText::NewL(D);	
   839 	CPlainText* doc2=CPlainText::NewL(D);	
   829 	doc2->DocumentLength();
   840 	doc2->DocumentLength();
   830 	doc2->InsertL(0,iInsertBuf); // insert "abcdefghijklmnopqrstuvwxyz"
   841 	doc2->InsertL(0,iInsertBuf); // insert "abcdefghijklmnopqrstuvwxyz"
   831 	
   842 	
   832 	test.Next(_L("Extract upto 50 character, from Pos10, within the range (no inline editting set)"));
   843 	INFO_PRINTF1(_L("Extract upto 50 character, from Pos10, within the range (no inline editting set)"));
   833 	// Returns upto 50 characters starting from Pos10
   844 	// Returns upto 50 characters starting from Pos10
   834 	doc2->ExtractSelectively(outputBuf, startingPositionTen, textLengthFifty, EExcludeInlineEditedText);
   845 	doc2->ExtractSelectively(outputBuf, startingPositionTen, textLengthFifty, EExcludeInlineEditedText);
   835 	test (iTestBuf2 == outputBuf);  // "klmnopqrstuvwxyz"		
   846 	test (iTestBuf2 == outputBuf);  // "klmnopqrstuvwxyz"		
   836 	
   847 	
   837 	test.Next(_L("Extract upto 10 characters, from Pos10, within the range (no inline editting set)"));
   848 	INFO_PRINTF1(_L("Extract upto 10 characters, from Pos10, within the range (no inline editting set)"));
   838 	// Returns upto 10 characters starting from Pos10
   849 	// Returns upto 10 characters starting from Pos10
   839 	doc2->ExtractSelectively(outputBuf, startingPositionTen, textLengthTen, EExcludeInlineEditedText); 
   850 	doc2->ExtractSelectively(outputBuf, startingPositionTen, textLengthTen, EExcludeInlineEditedText); 
   840 	test (iTestBuf2a == outputBuf); // "klmnopqrst"		
   851 	test (iTestBuf2a == outputBuf); // "klmnopqrst"		
   841 
   852 
   842 	test.Next(_L("Extract upto 50 character, from Pos0, 'EExtractAll' flag selected"));	
   853 	INFO_PRINTF1(_L("Extract upto 50 character, from Pos0, 'EExtractAll' flag selected"));	
   843 	// Returns upto 50 characters starting from Pos0.
   854 	// Returns upto 50 characters starting from Pos0.
   844 	doc2->ExtractSelectively(outputBuf, startingPositionZero, textLengthFifty, EExtractAll); 
   855 	doc2->ExtractSelectively(outputBuf, startingPositionZero, textLengthFifty, EExtractAll); 
   845 	test (iInsertBuf == outputBuf); // "abcdefghijklmnopqrstuvwxyz"
   856 	test (iInsertBuf == outputBuf); // "abcdefghijklmnopqrstuvwxyz"
   846 	delete doc2;
   857 	delete doc2;
   847 
   858 
   852  
   863  
   853 	PosOfInlineText = 4;
   864 	PosOfInlineText = 4;
   854 	
   865 	
   855 	doc3->StartFepInlineEditL(HasChangedFormat,NumberDeleted,NumberInserted,PositionOfInsertion,NewPositionOfInsertion,InitialInlineText,PosOfInlineText,NumberToHide,*InlineTextFormatRetriever);
   866 	doc3->StartFepInlineEditL(HasChangedFormat,NumberDeleted,NumberInserted,PositionOfInsertion,NewPositionOfInsertion,InitialInlineText,PosOfInlineText,NumberToHide,*InlineTextFormatRetriever);
   856 
   867 
   857 	test.Next(_L("Extract all the non-inline text, from Pos10, within the range (inline editting on)"));
   868 	INFO_PRINTF1(_L("Extract all the non-inline text, from Pos10, within the range (inline editting on)"));
   858 	doc3->ExtractSelectively(outputBuf, startingPositionTen, textLengthTen, EExcludeInlineEditedText); // Returns only non-inline text.
   869 	doc3->ExtractSelectively(outputBuf, startingPositionTen, textLengthTen, EExcludeInlineEditedText); // Returns only non-inline text.
   859 	test (iTestBuf3 == outputBuf); // testing outputBuf, making sure the inline text has been extracted correctly	- "efghi".	
   870 	test (iTestBuf3 == outputBuf); // testing outputBuf, making sure the inline text has been extracted correctly	- "efghi".	
   860 	delete doc3;	
   871 	delete doc3;	
   861 	
   872 
   862 	test.End();
       
   863 	
       
   864 	__UHEAP_MARKEND;
   873 	__UHEAP_MARKEND;
   865 	}
   874 	}
   866 	  
   875 	  
   867 
   876 
   868 template<class S,class T,CEditableText::TDocumentStorage D>
   877 template<class S,class T,CEditableText::TDocumentStorage D>
   869 void TestCPlainText<S,T,D>::TestSegmentedL()
   878 void TestCPlainText<S,T,D>::TestSegmentedL()
   870 //
   879 //
   871 // Controls testing of the segmented storage case.
   880 // Controls testing of the segmented storage case.
   872 //
   881 //
   873 	{
   882 	{
   874 	test.Start(_L("All methods"));
   883     INFO_PRINTF1(_L("All methods"));
   875 	CPlainTest0L();
   884 	CPlainTest0L();
   876 	test.Next(_L("Construction"));
   885 	INFO_PRINTF1(_L("Construction"));
   877 	CPlainTest1L();
   886 	CPlainTest1L();
   878 	test.Next(_L("Read"));
   887 	INFO_PRINTF1(_L("Read"));
   879 	test.Start(_L("Not yet implemented"));
   888 	INFO_PRINTF1(_L("Not yet implemented"));
   880 	test.End();
   889 
   881  	test.Next(_L("Inverse Testing using InsertL&Delete: content left intact"));
   890  	INFO_PRINTF1(_L("Inverse Testing using InsertL&Delete: content left intact"));
   882 	CPlainTest3L();
   891 	CPlainTest3L();
   883  	test.Next(_L("Paragraph Start"));
   892  	INFO_PRINTF1(_L("Paragraph Start"));
   884 	CPlainTest4L();
   893 	CPlainTest4L();
   885  	test.Next(_L("Extract"));
   894  	INFO_PRINTF1(_L("Extract"));
   886 	CPlainTest5L();
   895 	CPlainTest5L();
   887 	test.Next(_L("WordInfo"));
   896 	INFO_PRINTF1(_L("WordInfo"));
   888 	CPlainTest5aL();
   897 	CPlainTest5aL();
   889 	test.Next(_L("CharPosOfParagraph"));
   898 	INFO_PRINTF1(_L("CharPosOfParagraph"));
   890 	CPlainTest5bL();
   899 	CPlainTest5bL();
   891 	test.Next(_L("ParagraphNumberForPos"));
   900 	INFO_PRINTF1(_L("ParagraphNumberForPos"));
   892 	CPlainTest5cL();
   901 	CPlainTest5cL();
   893  	test.Next(_L("CountWords"));
   902  	INFO_PRINTF1(_L("CountWords"));
   894 	CPlainTest6L();
   903 	CPlainTest6L();
   895 	test.Next(_L("CountParas"));
   904 	INFO_PRINTF1(_L("CountParas"));
   896 	CPlainTest7L();
   905 	CPlainTest7L();
   897  	test.Next(_L("Reset"));
   906  	INFO_PRINTF1(_L("Reset"));
   898 	CPlainTest8L();
   907 	CPlainTest8L();
   899 	test.End();
       
   900 	}
   908 	}
   901 
   909 
   902 
   910 
   903 
   911 
   904 template<class S,class T,CEditableText::TDocumentStorage D>
   912 template<class S,class T,CEditableText::TDocumentStorage D>
   905 void TestCPlainText<S,T,D>::TestL()
   913 void TestCPlainText<S,T,D>::TestL()
   906 //
   914 //
   907 // Test the CPlainText methods
   915 // Test the CPlainText methods
   908 //
   916 //
   909 	{
   917 	{
   910 	test.Start(_L("All methods"));
   918 	INFO_PRINTF1(_L("All methods"));
   911 	CPlainTest0L();
   919 	CPlainTest0L();
   912 	test.Next(_L("Construction"));
   920 	INFO_PRINTF1(_L("Construction"));
   913 	CPlainTest1L();
   921 	CPlainTest1L();
   914 	test.Next(_L("Read"));
   922 	INFO_PRINTF1(_L("Read"));
   915 	CPlainTest2L();
   923 	CPlainTest2L();
   916 	test.Next(_L("Inverse Testing using InsertL&Delete: content left intact"));
   924 	INFO_PRINTF1(_L("Inverse Testing using InsertL&Delete: content left intact"));
   917 	CPlainTest3L();
   925 	CPlainTest3L();
   918 	test.Next(_L("Paragraph Start"));
   926 	INFO_PRINTF1(_L("Paragraph Start"));
   919 	CPlainTest4L();
   927 	CPlainTest4L();
   920 	test.Next(_L("Extract"));
   928 	INFO_PRINTF1(_L("Extract"));
   921 	CPlainTest5L();
   929 	CPlainTest5L();
   922 	test.Next(_L("WordInfo"));
   930 	INFO_PRINTF1(_L("WordInfo"));
   923 	CPlainTest5aL();
   931 	CPlainTest5aL();
   924 	test.Next(_L("CharPosOfParagraph"));
   932 	INFO_PRINTF1(_L("CharPosOfParagraph"));
   925 	CPlainTest5bL();
   933 	CPlainTest5bL();
   926 	test.Next(_L("ParagraphNumberForPos"));
   934 	INFO_PRINTF1(_L("ParagraphNumberForPos"));
   927 	CPlainTest5cL();
   935 	CPlainTest5cL();
   928 	test.Next(_L("CountWords"));
   936 	INFO_PRINTF1(_L("CountWords"));
   929 	CPlainTest6L();
   937 	CPlainTest6L();
   930 	test.Next(_L("CountParas"));
   938 	INFO_PRINTF1(_L("CountParas"));
   931 	CPlainTest7L();
   939 	CPlainTest7L();
   932 	test.Next(_L("Reset"));
   940 	INFO_PRINTF1(_L("Reset"));
   933 	CPlainTest8L();
   941 	CPlainTest8L();
   934 	test.End();
       
   935 	}
   942 	}
   936 
   943 
   937 
   944 
   938 
   945 
   939 template<class S,class T,CEditableText::TDocumentStorage D>
   946 template<class S,class T,CEditableText::TDocumentStorage D>
   940 void TestCPlainText<S,T,D>::DefectsL()
   947 void TestCPlainText<S,T,D>::DefectsL()
   941 //
   948 //
   942 // Defect Fixes
   949 // Defect Fixes
   943 //
   950 //
   944 	{
   951 	{
   945 	test.Start(_L(" @SYMTestCaseID:SYSLIB-ETEXT-UT-1574 INC070807 "));
   952 	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-ETEXT-UT-1574 INC070807 "));
   946 	INC070807L();
   953 	INC070807L();
   947 	test.End();
   954 	}
   948 	}
   955 
   949 
   956 CT_CPLAIN::CT_CPLAIN()
   950 
       
   951 
       
   952 GLDEF_C TInt E32Main()
       
   953 //
       
   954 // Test the Document Model Services.
       
   955 //
       
   956     {
   957     {
   957 	CTrapCleanup* cleanup=CTrapCleanup::New();
   958     SetTestStepName(KTestStep_T_CPLAIN);
   958 	
   959     pTestStep = this;
   959 	__UHEAP_MARK;
   960     }
   960 	
   961 
   961 	typedef TestCPlainText<TText,TPtrC,CEditableText::EFlatStorage> instance1;
   962 TVerdict CT_CPLAIN::doTestStepL()
   962 	typedef TestCPlainText<TText,TPtrC,CEditableText::ESegmentedStorage> instance2;
   963     {
   963 	typedef TestCPlainText<TText,TPtrC,CEditableText::EFlatStorage> instance3;
   964     SetTestStepResult(EFail);
   964 
   965 
   965 	instance1* doctest=NULL;
   966     CTrapCleanup* cleanup=CTrapCleanup::New();
   966 
       
   967 	TRAPD(ret, doctest=instance1::NewL());
       
   968     test(ret == KErrNone);
       
   969 
       
   970 	test.Start(_L("CPlainText - Flat"));
       
   971 
       
   972 	TRAP(ret,doctest->TestL());
       
   973     test(ret == KErrNone);
       
   974  	delete doctest;
       
   975 
       
   976 	test.Next(_L("CPlainText - Segmented"));
       
   977 	instance2* doctest1=NULL;
       
   978 
       
   979 	TRAP(ret, doctest1=instance2::NewL());
       
   980     test(ret == KErrNone);
       
   981 
       
   982 	TRAP(ret, doctest1->TestSegmentedL());
       
   983     test(ret == KErrNone);
       
   984 	delete doctest1;
       
   985 
       
   986 	test.Next(_L("Defect..."));
       
   987 	instance3* doctest2=NULL;
       
   988 	
       
   989 	TRAP(ret, doctest2=instance3::NewL());
       
   990     test(ret == KErrNone);
       
   991     
   967     
   992    	TRAP(ret, doctest2->DefectsL());
   968     __UHEAP_MARK;
   993     test(ret == KErrNone);	
   969     
   994 	delete doctest2;
   970     typedef TestCPlainText<TText,TPtrC,CEditableText::EFlatStorage> instance1;
   995 
   971     typedef TestCPlainText<TText,TPtrC,CEditableText::ESegmentedStorage> instance2;
   996 	test.End();
   972     typedef TestCPlainText<TText,TPtrC,CEditableText::EFlatStorage> instance3;
   997 	test.Close();
   973 
   998 	
   974     instance1* doctest=NULL;
   999 	__UHEAP_MARKEND;
   975 
  1000 	
   976     TRAPD(ret1, doctest=instance1::NewL());
  1001 	delete cleanup;
   977 
  1002 
   978     INFO_PRINTF1(_L("CPlainText - Flat"));
  1003 	return(0);
   979     TRAPD(ret2, doctest->TestL());
       
   980     delete doctest;
       
   981 
       
   982     INFO_PRINTF1(_L("CPlainText - Segmented"));
       
   983     instance2* doctest1=NULL;
       
   984     TRAPD(ret3, doctest1=instance2::NewL());
       
   985     TRAPD(ret4, doctest1->TestSegmentedL());
       
   986     delete doctest1;
       
   987 
       
   988     INFO_PRINTF1(_L("Defect..."));
       
   989     instance3* doctest2=NULL;
       
   990     TRAPD(ret5, doctest2=instance3::NewL());
       
   991     TRAPD(ret6, doctest2->DefectsL());
       
   992     delete doctest2;
       
   993 
       
   994     __UHEAP_MARKEND;
       
   995     
       
   996     delete cleanup;
       
   997 
       
   998     if (ret1 == KErrNone && ret2 == KErrNone && ret3 == KErrNone && ret4 == KErrNone && ret5 == KErrNone && ret6 == KErrNone)
       
   999         {
       
  1000         SetTestStepResult(EPass);
       
  1001         }
       
  1002 
       
  1003     return TestStepResult();
  1004     }
  1004     }