os/textandloc/textrendering/texthandling/ttext/T_SCANDC.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #include <txtetext.h>
    20 #include "T_SCANDC.h"
    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))
    38 
    39 
    40 #define UNUSED_VAR(a) a = a
    41 
    42 LOCAL_D CTrapCleanup* TheTrapCleanup;
    43 
    44 template<class S,CEditableText::TDocumentStorage D>
    45 class CTestScan : public CPlainText
    46 	{
    47 public:
    48 	static CTestScan* NewL();
    49 	void Destruct();
    50 	void Test1L();  // Tests all operations of the class.
    51 	void Test2L();  // Test public methods of class.
    52 	void Test2aL();  // Tests for CountWords
    53 	void Test2bL();  // Tests for ScanWord
    54 	void Test2cL();  // Tests for CountParagraphs
    55 	void Test2dL();  // Tests for ScanParagraph
    56 	void TestHeapSpace();  // Test for memory leakage
    57 	void StoreTextL(TBuf<64>&);
    58 	void DoCountWords(TInt);
    59 	void DoCountParas(TInt);
    60 	void DoScanWords(TInt aPos,TUint aFlags,TInt aEndPos,TInt aCharCheck);
    61 	void DoScanParas(TInt aPos,TUint aFlags,TInt aEndPos,TInt aCharCheck);
    62 	void InsertL(TInt aPos,const TDesC& aBuf);
    63 public:
    64 	CPlainText *iDocument;
    65 	TInt iUnitCount;
    66 	TInt iCharsSkipped;
    67 	TChar iDelimiter;
    68 	TInt startAvail,endAvail,temp;
    69 private:
    70  CTestScan();  // Default constructor
    71  CTestScan(const CTestScan& aCTestScan);
    72  CTestScan& operator=(const CTestScan& aCTestScan);
    73 	};
    74 
    75 
    76 template<class S,CEditableText::TDocumentStorage D>
    77 GLDEF_C CTestScan<S,D>* CTestScan<S,D>::NewL()
    78 //
    79 // constructs a new instance of this class.
    80 //
    81 	{
    82 	CTestScan<S,D>* tmp=new(ELeave) CTestScan<S,D>;
    83 	tmp->ConstructL(D);
    84 	return tmp;
    85 	}
    86 
    87 
    88 template<class S,CEditableText::TDocumentStorage D>
    89 GLDEF_C CTestScan<S,D>::CTestScan()
    90 //
    91 // Default constructor
    92 //
    93 	:iDelimiter(EParagraphDelimiter)
    94 	{
    95 	TRAPD(ret,iDocument=CPlainText::NewL(D));
    96     UNUSED_VAR(ret);
    97 	}
    98 
    99 
   100 template<class S,CEditableText::TDocumentStorage D>
   101 void CTestScan<S,D>::Destruct()
   102 //
   103 //
   104 //
   105 	{
   106 	delete iDocument;
   107 	}
   108 
   109 
   110 template<class S,CEditableText::TDocumentStorage D>
   111 GLDEF_C void CTestScan<S,D>::InsertL(TInt aPos,const TDesC& aBuf)
   112 //
   113 	{CPlainText::InsertL(aPos,aBuf);}
   114 
   115 
   116 
   117 template<class S,CEditableText::TDocumentStorage D>
   118 GLDEF_C void CTestScan<S,D>::StoreTextL(TBuf<64>& aBuf)
   119 //
   120 // Insert from aBuf into document storage at position 0.
   121 //
   122 	{
   123 	TInt length=iDocument->DocumentLength();
   124 	if (length>0)
   125 		{
   126 		iDocument->DeleteL(0,(length));
   127 		}
   128 	TPtrC buf(aBuf);
   129 	iDocument->InsertL(0,buf);
   130 	iUnitCount=0;
   131 	}			
   132 
   133 
   134 template<class S,CEditableText::TDocumentStorage D>
   135 GLDEF_C void CTestScan<S,D>::DoCountWords(TInt aCount)
   136 //
   137 // Calls CountWords, and checks that number of words
   138 // counted, matches the known good value 'count'.
   139 //
   140 	{
   141 	iUnitCount=iDocument->WordCount();
   142 	test(aCount==iUnitCount);
   143 	}
   144 
   145 
   146 template<class S,CEditableText::TDocumentStorage D>
   147 GLDEF_C void CTestScan<S,D>::DoCountParas(TInt aCount)
   148 //
   149 // Calls CountParagraphs, and checks that number
   150 // counted, matches the known good value 'count'.
   151 //
   152 	{
   153 	iUnitCount=iDocument->ParagraphCount();
   154 	test(aCount==iUnitCount);
   155 	}
   156 
   157 
   158 template<class S,CEditableText::TDocumentStorage D>
   159 GLDEF_C void CTestScan<S,D>::DoScanWords(TInt aPos,TUint aFlags,TInt aEndPos,TInt aCharCheck)
   160 //
   161 // Calls ScanWords and tests results are as expected.
   162 //
   163 	{
   164 	iCharsSkipped=iDocument->ScanWords(aPos,aFlags);
   165 	test(iCharsSkipped==aCharCheck);
   166 	test(aPos==aEndPos);
   167 	iCharsSkipped=0;
   168 	}
   169 
   170 
   171 template<class S,CEditableText::TDocumentStorage D>
   172 GLDEF_C void CTestScan<S,D>::DoScanParas(TInt aPos,TUint aFlags,TInt aEndPos,TInt aCharCheck)
   173 //
   174 // Calls ScanParas and checks results are as expected.
   175 //
   176 	{
   177 	iCharsSkipped=iDocument->ScanParas(aPos,aFlags);
   178 	test(iCharsSkipped==aCharCheck);
   179 	test(aPos==aEndPos);
   180 	iCharsSkipped=0;
   181 	}
   182 
   183 
   184 template<class S,CEditableText::TDocumentStorage D>
   185 GLDEF_C void CTestScan<S,D>::Test1L()
   186 //
   187 // Tests all operations of the class.
   188 //
   189 	{
   190 	TBuf<64> temp1;
   191 	temp1.Append(_L("The world"));	//	Create a descriptor over some text
   192 	temp1.Append(iDelimiter);
   193 	temp1.Append(iDelimiter);
   194 	temp1.Append(_L("is a"));
   195 	StoreTextL(temp1);
   196 	iDocument->WordCount();
   197 	TInt pos=5;
   198 	TUint flags=(CPlainText::EScanToUnitStart|CPlainText::EScanJoinDelimiters|CPlainText::EScanStayIfBoundary);
   199 	((CTestScan*)iDocument)->ScanWords(pos,flags);
   200 	TBuf<64> temp2(_L("This is a paragraph"));
   201 	temp2.Append(iDelimiter);
   202 	iDocument->DeleteL(0,temp1.Length());
   203 	StoreTextL(temp2);
   204 	pos=0;
   205 	flags=(CPlainText::EScanToUnitStart|CPlainText::EScanJoinDelimiters);
   206 	((CTestScan*)iDocument)->ScanParas(pos,flags);
   207 	iDocument->ParagraphCount();
   208 	}
   209 
   210 template<class S,CEditableText::TDocumentStorage D>
   211 GLDEF_C void CTestScan<S,D>::Test2aL()
   212 //
   213 //	Tests the CountWords method with different cases
   214 //
   215 	{
   216 	TBuf<64> temp;
   217 	
   218 	//INFO_PRINTF1(_L("0 words"));
   219 	//iDocument->InsertL(0,buf.Ptr(),buf.Size());
   220 	//DoCountWords(0);
   221 	// This test has been removed since it is no longer feasible.
   222 	// The design currently inserts an end of document character
   223 	// as soon as the document is created, hence, there can not
   224 	// be 0 words.
   225 	
   226 	INFO_PRINTF1(_L("0 words, all delimiters"));
   227 	temp.Append(_L("   "));
   228 	temp.Append(iDelimiter);
   229 	temp.Append(_L("   "));
   230 	StoreTextL(temp);
   231 	DoCountWords(0);
   232 	
   233 	INFO_PRINTF1(_L("1 word, no delimiter"));
   234 	temp.Append(_L("This"));
   235 	StoreTextL(temp);
   236 	DoCountWords(1);
   237 
   238 	INFO_PRINTF1(_L("1 word, at start, no delimiter"));
   239 	temp.Delete(0,temp.Size());
   240 	temp.Append(_L("THIS"));
   241 	StoreTextL(temp);
   242 	DoCountWords(1);
   243 
   244 	INFO_PRINTF1(_L("1 word, with delimiter"));
   245 	temp.Append(' ');
   246 	StoreTextL(temp);
   247 	DoCountWords(1);
   248 
   249 	INFO_PRINTF1(_L("Many words, no delimiter"));
   250 	temp.Append(_L("  is a wonderful world"));
   251 	StoreTextL(temp);
   252 	DoCountWords(5);
   253 
   254 	INFO_PRINTF1(_L("Many words with delimiter"));
   255 	temp.Append(' ');
   256 	StoreTextL(temp);
   257 	DoCountWords(5);
   258 
   259 	
   260 	}
   261 
   262 
   263 template<class S,CEditableText::TDocumentStorage D>
   264 GLDEF_C void CTestScan<S,D>::Test2bL()
   265 //
   266 //	Tests the ScanWord method with different flag settings
   267 //
   268 	{
   269 	TBuf<64> buf;
   270 	buf.Append(_L(" This  tEsT  TeXT"));
   271 	StoreTextL(buf);  
   272 
   273 	iCharsSkipped=iUnitCount=0;
   274 	INFO_PRINTF1(_L("Forward scan"));
   275 
   276 	INFO_PRINTF1(_L("Stay at boundary:to unit start"));
   277 	TUint flags=(CPlainText::EScanStayIfBoundary | CPlainText::EScanToUnitStart);
   278 	DoScanWords(8,flags,12,4);
   279 	DoScanWords(7,flags,7,0);
   280 	DoScanWords(6,flags,6,0);
   281 	DoScanWords(5,flags,6,1);
   282 		
   283 	INFO_PRINTF1(_L("Stay at boundary:to unit end"));
   284 	flags |= CPlainText::EScanToUnitEnd;
   285 	flags &=~CPlainText::EScanToUnitStart;
   286 	DoScanWords(8,flags,11,3);
   287 	DoScanWords(7,flags,11,4);
   288 	DoScanWords(6,flags,6,0);
   289 	DoScanWords(5,flags,5,0);
   290 
   291 	INFO_PRINTF1(_L("Stay at boundary:to unit start:join delimiters"));
   292 	flags=(CPlainText::EScanStayIfBoundary|CPlainText::EScanToUnitStart|CPlainText::EScanJoinDelimiters);
   293 	DoScanWords(8,flags,13,5);
   294 	DoScanWords(7,flags,7,0);
   295 	DoScanWords(6,flags,7,1);
   296 	DoScanWords(5,flags,7,2);
   297 	
   298 	INFO_PRINTF1(_L("Stay at boundary:to unit end:join delimiters"));
   299 	flags |= CPlainText::EScanToUnitEnd;
   300 	flags &=~CPlainText::EScanToUnitStart;
   301 	DoScanWords(8,flags,11,3);
   302 	DoScanWords(7,flags,11,4);
   303 	DoScanWords(6,flags,11,5);
   304 	DoScanWords(5,flags,5,0);
   305 
   306 	INFO_PRINTF1(_L("To unit start"));
   307 	flags=CPlainText::EScanToUnitStart;
   308 	DoScanWords(8,flags,12,4);
   309 	DoScanWords(7,flags,12,5);
   310 	DoScanWords(6,flags,7,1);
   311 	DoScanWords(5,flags,6,1);
   312 	
   313 	INFO_PRINTF1(_L("To unit end"));
   314 	flags |= CPlainText::EScanToUnitEnd;
   315 	flags &=~CPlainText::EScanToUnitStart;
   316 	DoScanWords(8,flags,11,3);
   317 	DoScanWords(7,flags,11,4);
   318 	DoScanWords(6,flags,11,5);
   319 	DoScanWords(5,flags,6,1);
   320 
   321 	INFO_PRINTF1(_L("To unit start:join delimiters"));
   322 	flags=(CPlainText::EScanToUnitStart|CPlainText::EScanJoinDelimiters);
   323 	DoScanWords(8,flags,13,5);
   324 	DoScanWords(7,flags,13,6);
   325 	DoScanWords(6,flags,7,1);
   326 	DoScanWords(5,flags,7,2);
   327 
   328 	INFO_PRINTF1(_L("To unit end:join delimiters"));
   329 	flags |= CPlainText::EScanToUnitEnd;
   330 	flags &=~CPlainText::EScanToUnitStart;
   331 	DoScanWords(8,flags,11,3);
   332 	DoScanWords(7,flags,11,4);
   333 	DoScanWords(6,flags,11,5);
   334 	DoScanWords(5,flags,11,6);
   335 	
   336 	INFO_PRINTF1(_L("Backward scan"));
   337 	INFO_PRINTF1(_L("Stay at boundary:to unit start"));
   338 	flags=(CPlainText::EScanBackwards|CPlainText::EScanStayIfBoundary|CPlainText::EScanToUnitStart);
   339 	DoScanWords(9,flags,7,2);
   340 	DoScanWords(10,flags,7,3);
   341 	DoScanWords(11,flags,7,4);
   342 	DoScanWords(12,flags,12,0);
   343 	DoScanWords(13,flags,13,0);
   344 	
   345 	INFO_PRINTF1(_L("Stay at boundary:to unit end"));
   346 	flags |= CPlainText::EScanToUnitEnd;
   347 	flags &=~CPlainText::EScanToUnitStart;
   348 	DoScanWords(9,flags,6,3);
   349 	DoScanWords(10,flags,6,4);
   350 	DoScanWords(11,flags,11,0);
   351 	DoScanWords(12,flags,12,0);
   352 	DoScanWords(13,flags,12,1);
   353 
   354 	INFO_PRINTF1(_L("Stay at boundary:to unit start:join delimiters"));
   355 	flags=CPlainText::EScanBackwards|CPlainText::EScanStayIfBoundary|CPlainText::EScanToUnitStart|CPlainText::EScanJoinDelimiters;
   356 	DoScanWords(9,flags,7,2);
   357 	DoScanWords(10,flags,7,3);
   358 	DoScanWords(11,flags,7,4);
   359 	DoScanWords(12,flags,7,5);
   360 	DoScanWords(13,flags,13,0);
   361 
   362 	INFO_PRINTF1(_L("Stay at boundary:to unit end:join delimiters"));
   363 	flags |= CPlainText::EScanToUnitEnd;
   364 	flags &=~CPlainText::EScanToUnitStart;
   365 	DoScanWords(9,flags,5,4);
   366 	DoScanWords(10,flags,5,5);
   367 	DoScanWords(11,flags,11,0);
   368 	DoScanWords(12,flags,11,1);
   369 	DoScanWords(13,flags,11,2);
   370 	
   371 	INFO_PRINTF1(_L("To unit start"));
   372 	flags=CPlainText::EScanBackwards|CPlainText::EScanToUnitStart;
   373 	DoScanWords(9,flags,7,2);
   374 	DoScanWords(10,flags,7,3);
   375 	DoScanWords(11,flags,7,4);
   376 	DoScanWords(12,flags,7,5);
   377 	DoScanWords(13,flags,12,1);
   378 	
   379 	INFO_PRINTF1(_L("To unit end"));
   380 	flags |= CPlainText::EScanToUnitEnd;
   381 	flags &=~CPlainText::EScanToUnitStart;
   382 	DoScanWords(9,flags,6,3);
   383 	DoScanWords(10,flags,6,4);
   384 	DoScanWords(11,flags,6,5);
   385 	DoScanWords(12,flags,11,1);
   386 	DoScanWords(13,flags,12,1);
   387 
   388 	INFO_PRINTF1(_L("To unit start:join delimiters"));
   389 	flags=CPlainText::EScanBackwards|CPlainText::EScanToUnitStart|CPlainText::EScanJoinDelimiters;
   390 	DoScanWords(9,flags,7,2);
   391 	DoScanWords(10,flags,7,3);
   392 	DoScanWords(11,flags,7,4);
   393 	DoScanWords(12,flags,7,5);
   394 	DoScanWords(13,flags,7,6);
   395 
   396 	INFO_PRINTF1(_L("To unit end:join delimiters"));
   397 	flags=CPlainText::EScanToUnitEnd|CPlainText::EScanJoinDelimiters|CPlainText::EScanBackwards;
   398 	DoScanWords(9,flags,5,4);
   399 	DoScanWords(10,flags,5,5);
   400 	DoScanWords(11,flags,5,6);
   401 	DoScanWords(12,flags,11,1);
   402 	DoScanWords(13,flags,11,2);
   403 	
   404 	}
   405 
   406 
   407 template<class S,CEditableText::TDocumentStorage D>
   408 GLDEF_C void CTestScan<S,D>::Test2cL()
   409 //
   410 //	Tests the CountParagraphs method with different cases
   411 //
   412 	{
   413 	TBuf<64> buf;
   414 	
   415 	//INFO_PRINTF1(_L("0 paras"));
   416 	//iDocument->InsertL(0,buf.Ptr(),buf.Size());
   417 	//DoCountParagraphs(0);
   418 	// This test no longer applies, since documents are created with
   419 	// an end of document character.  ie, The document can not have
   420 	// 0 words.
   421 	
   422 	INFO_PRINTF1(_L("Empty text source"));
   423 //	buf.Append(iDelimiter);
   424 //	buf.Append(iDelimiter);
   425 	StoreTextL(buf);
   426 	DoCountParas(1);
   427 	
   428 	INFO_PRINTF1(_L("1 para. no delimiter"));
   429 	buf.Append(_L("This"));
   430 	StoreTextL(buf);
   431 	DoCountParas(1);
   432 
   433 	INFO_PRINTF1(_L("1 para. at start, no delimiter"));
   434 	buf.Delete(0,buf.Size());
   435 	buf.Append(_L(" THIS   "));
   436 	StoreTextL(buf);
   437 	DoCountParas(1);
   438 
   439 	INFO_PRINTF1(_L("1 para, with delimiter"));
   440 	buf.Append(iDelimiter);
   441 	StoreTextL(buf);
   442 	DoCountParas(2);
   443 
   444 	INFO_PRINTF1(_L("2 paras, no delimiter"));
   445 	buf.Append(' ');
   446 	StoreTextL(buf);
   447 	DoCountParas(2);
   448 
   449 	INFO_PRINTF1(_L("2 paras with delimiter"));
   450 	buf.Append(iDelimiter);
   451 	StoreTextL(buf);
   452 	DoCountParas(3);
   453 
   454 	
   455 	}
   456 
   457 
   458 template<class S,CEditableText::TDocumentStorage D>
   459 GLDEF_C void CTestScan<S,D>::Test2dL()
   460 //
   461 //	Tests the ScanParagraph method with different flag settings
   462 //
   463 	{
   464 	TBuf<64> buf;
   465 	buf.Append(_L(" This"));
   466 	buf.Append(iDelimiter);
   467 	buf.Append(iDelimiter);
   468 	buf.Append(_L("tEsT"));
   469 	buf.Append(iDelimiter);
   470 	buf.Append(iDelimiter);
   471 	buf.Append(_L("TeXT"));
   472 	StoreTextL(buf);  
   473 
   474 	iCharsSkipped=iUnitCount=0;
   475 	INFO_PRINTF1(_L("Forward scan"));
   476 
   477 	INFO_PRINTF1(_L("Stay at boundary:to unit start"));
   478 	TUint flags=(CPlainText::EScanStayIfBoundary|CPlainText::EScanToUnitStart);
   479 	DoScanParas(8,flags,12,4);
   480 	DoScanParas(7,flags,7,0);
   481 	DoScanParas(6,flags,6,0);
   482 	DoScanParas(5,flags,6,1);
   483 		
   484 	INFO_PRINTF1(_L("Stay at boundary:to unit end"));
   485 	flags |= CPlainText::EScanToUnitEnd;
   486 	flags &=~CPlainText::EScanToUnitStart;
   487 	DoScanParas(8,flags,11,3);
   488 	DoScanParas(7,flags,11,4);
   489 	DoScanParas(6,flags,6,0);
   490 	DoScanParas(5,flags,5,0);
   491 
   492 	INFO_PRINTF1(_L("Stay at boundary:to unit start:join delimiters"));
   493 	flags=(CPlainText::EScanStayIfBoundary | CPlainText::EScanToUnitStart | CPlainText::EScanJoinDelimiters);
   494 	DoScanParas(8,flags,13,5);
   495 	DoScanParas(7,flags,7,0);
   496 	DoScanParas(6,flags,7,1);
   497 	DoScanParas(5,flags,7,2);
   498 	
   499 	INFO_PRINTF1(_L("Stay at boundary:to unit end:join delimiters"));
   500 	flags |= CPlainText::EScanToUnitEnd;
   501 	flags &=~CPlainText::EScanToUnitStart;
   502 	DoScanParas(8,flags,11,3);
   503 	DoScanParas(7,flags,11,4);
   504 	DoScanParas(6,flags,11,5);
   505 	DoScanParas(5,flags,5,0);
   506 
   507 	INFO_PRINTF1(_L("To unit start"));
   508 	flags=CPlainText::EScanToUnitStart;
   509 	DoScanParas(8,flags,12,4);
   510 	DoScanParas(7,flags,12,5);
   511 	DoScanParas(6,flags,7,1);
   512 	DoScanParas(5,flags,6,1);
   513 	
   514 	INFO_PRINTF1(_L("To unit end"));
   515 	flags |= CPlainText::EScanToUnitEnd;
   516 	flags &=~CPlainText::EScanToUnitStart;
   517 	DoScanParas(8,flags,11,3);
   518 	DoScanParas(7,flags,11,4);
   519 	DoScanParas(6,flags,11,5);
   520 	DoScanParas(5,flags,6,1);
   521 
   522 	INFO_PRINTF1(_L("To unit start:join delimiters"));
   523 	flags=(CPlainText::EScanToUnitStart | CPlainText::EScanJoinDelimiters);
   524 	DoScanParas(8,flags,13,5);
   525 	DoScanParas(7,flags,13,6);
   526 	DoScanParas(6,flags,7,1);
   527 	DoScanParas(5,flags,7,2);
   528 
   529 	INFO_PRINTF1(_L("To unit end:join delimiters"));
   530 	flags |= CPlainText::EScanToUnitEnd;
   531 	flags &=~CPlainText::EScanToUnitStart;
   532 	DoScanParas(8,flags,11,3);
   533 	DoScanParas(7,flags,11,4);
   534 	DoScanParas(6,flags,11,5);
   535 	DoScanParas(5,flags,11,6);
   536 	
   537 	INFO_PRINTF1(_L("Backward scan"));
   538 	INFO_PRINTF1(_L("Stay at boundary:to unit start"));
   539 	flags=(CPlainText::EScanBackwards|CPlainText::EScanStayIfBoundary|CPlainText::EScanToUnitStart);
   540 	DoScanParas(9,flags,7,2);
   541 	DoScanParas(10,flags,7,3);
   542 	DoScanParas(11,flags,7,4);
   543 	DoScanParas(12,flags,12,0);
   544 	DoScanParas(13,flags,13,0);
   545 	DoScanParas(7,flags,7,0);
   546 	DoScanParas(1,flags,0,1);
   547 	DoScanParas(5,flags,0,5);
   548 	DoScanParas(4,flags,0,4);
   549 	DoScanParas(3,flags,0,3);
   550 	DoScanParas(2,flags,0,2);
   551 	DoScanParas(1,flags,0,1);
   552 	INFO_PRINTF1(_L("Testing at buffer boundaries."));
   553 	DoScanParas(0,flags,0,0);
   554 	DoScanParas(16,flags,13,3);
   555 	
   556 
   557 	INFO_PRINTF1(_L("Stay at boundary:to unit end"));
   558 	flags |= CPlainText::EScanToUnitEnd;
   559 	flags &=~CPlainText::EScanToUnitStart;
   560 	DoScanParas(9,flags,6,3);
   561 	DoScanParas(10,flags,6,4);
   562 	DoScanParas(11,flags,11,0);
   563 	DoScanParas(12,flags,12,0);
   564 	DoScanParas(13,flags,12,1);
   565 
   566 	INFO_PRINTF1(_L("Stay at boundary:to unit start:join delimiters"));
   567 	flags=CPlainText::EScanBackwards|CPlainText::EScanStayIfBoundary|CPlainText::EScanToUnitStart|CPlainText::EScanJoinDelimiters;
   568 	DoScanParas(9,flags,7,2);
   569 	DoScanParas(10,flags,7,3);
   570 	DoScanParas(11,flags,7,4);
   571 	DoScanParas(12,flags,7,5);
   572 	DoScanParas(13,flags,13,0);
   573 
   574 	INFO_PRINTF1(_L("Stay at boundary:to unit end:join delimiters"));
   575 	flags |= CPlainText::EScanToUnitEnd;
   576 	flags &=~CPlainText::EScanToUnitStart;
   577 	DoScanParas(9,flags,5,4);
   578 	DoScanParas(10,flags,5,5);
   579 	DoScanParas(11,flags,11,0);
   580 	DoScanParas(12,flags,11,1);
   581 	DoScanParas(13,flags,11,2);
   582 	
   583 	INFO_PRINTF1(_L("To unit start"));
   584 	flags=CPlainText::EScanBackwards|CPlainText::EScanToUnitStart;
   585 	DoScanParas(9,flags,7,2);
   586 	DoScanParas(10,flags,7,3);
   587 	DoScanParas(11,flags,7,4);
   588 	DoScanParas(12,flags,7,5);
   589 	DoScanParas(13,flags,12,1);
   590 	
   591 	INFO_PRINTF1(_L("To unit end"));
   592 	flags |= CPlainText::EScanToUnitEnd;
   593 	flags &=~CPlainText::EScanToUnitStart;
   594 	DoScanParas(9,flags,6,3);
   595 	DoScanParas(10,flags,6,4);
   596 	DoScanParas(11,flags,6,5);
   597 	DoScanParas(12,flags,11,1);
   598 	DoScanParas(13,flags,12,1);
   599 
   600 	INFO_PRINTF1(_L("To unit start:join delimiters"));
   601 	flags=CPlainText::EScanBackwards|CPlainText::EScanToUnitStart|CPlainText::EScanJoinDelimiters;
   602 	DoScanParas(9,flags,7,2);
   603 	DoScanParas(10,flags,7,3);
   604 	DoScanParas(11,flags,7,4);
   605 	DoScanParas(12,flags,7,5);
   606 	DoScanParas(13,flags,7,6);
   607 
   608 	INFO_PRINTF1(_L("To unit end:join delimiters"));
   609 	flags |= CPlainText::EScanToUnitEnd;
   610 	flags &=~CPlainText::EScanToUnitStart;
   611 	DoScanParas(9,flags,5,4);
   612 	DoScanParas(10,flags,5,5);
   613 	DoScanParas(11,flags,5,6);
   614 	DoScanParas(12,flags,11,1);
   615 	DoScanParas(13,flags,11,2);
   616 	
   617 	
   618 	}
   619 
   620 
   621 template<class S,CEditableText::TDocumentStorage D>
   622 GLDEF_C void CTestScan<S,D>::Test2L()
   623 //
   624 // Test all the methods of the class
   625 //
   626 	{
   627 	INFO_PRINTF1(_L("CountWords"));
   628 	Test2aL();
   629 
   630 	INFO_PRINTF1(_L("ScanWord"));
   631 	Test2bL();
   632 
   633 	INFO_PRINTF1(_L("Count Paragraphs"));
   634 	Test2cL();
   635 
   636 	INFO_PRINTF1(_L("Scan Paragraph"));
   637 	Test2dL();
   638 
   639 	
   640 	}
   641 
   642 CT_SCANDC::CT_SCANDC()
   643     {
   644     SetTestStepName(KTestStep_T_SCANDC);
   645     pTestStep = this;
   646     }
   647 
   648 TVerdict CT_SCANDC::doTestStepL()
   649     {
   650     SetTestStepResult(EFail);
   651 
   652     TheTrapCleanup=CTrapCleanup::New();
   653 
   654     INFO_PRINTF1(_L("SCANNING OF TEXT DOCUMENTS"));
   655     INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-TTEXT-LEGACY-T_SCANDC-0001 CPlainText - Flat ")); 
   656     typedef CTestScan<TText,CEditableText::EFlatStorage> instance1;
   657     typedef CTestScan<TText,CEditableText::ESegmentedStorage> instance2;
   658     
   659     instance1* aa=NULL;
   660     TRAPD(ret1, aa=instance1::NewL());
   661 
   662     INFO_PRINTF1(_L("Registering all methods"));
   663 
   664     TRAPD(ret2,aa->Test1L());
   665 
   666     INFO_PRINTF1(_L("Testing all methods"));
   667 
   668     TRAPD(ret3,aa->Test2L());
   669 
   670     __UHEAP_MARK;
   671     delete aa;
   672     __UHEAP_MARKEND;
   673 
   674     INFO_PRINTF1(_L("CPlainText - Segmented"));
   675 
   676     instance2* bb=NULL;
   677     TRAPD(ret4, bb=instance2::NewL());
   678 
   679     __UHEAP_MARK;
   680     INFO_PRINTF1(_L("Registering all methods"));
   681     TRAPD(ret5,bb->Test1L());
   682     INFO_PRINTF1(_L("Testing all methods"));
   683     TRAPD(ret6,bb->Test2L());
   684     delete bb;
   685     __UHEAP_MARKEND;
   686     
   687     delete TheTrapCleanup;
   688 
   689     if (ret1 == KErrNone && ret2 == KErrNone && ret3 == KErrNone && ret4 == KErrNone && ret5 == KErrNone && ret6 == KErrNone)
   690         {
   691         SetTestStepResult(EPass);
   692         }
   693 
   694     return TestStepResult();
   695     }