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