|
1 // Copyright (c) 2007-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 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 |
|
23 #include "t_addressstringtokenizer.h" |
|
24 |
|
25 // LOCAL CONSTANTS AND MACROS |
|
26 static const TInt KReadBufSize(256); |
|
27 static const TInt KFullBufSize(10000); |
|
28 |
|
29 _LIT(KTextToBeParsed, "http://www.google.com 23). 9p=71 jee elvis.presley@hotmail.com 07/00-123123? http://wap.google.com (123 45678910?) 127.0555.0555 roskaa 1.3.4.5.6.7.8.9 laatikos (127.0.0.1) a (0802345... ad (+0821898 (*02 +#098"); |
|
30 _LIT(KTextToBeParsedForPhNoWithMin15Nos, "tekstii... http://www.google.com jeba jee elvis.presley@hotmail.com 0700-12w312312345 habaha 123 45p1234678910 a 127.052355.052355 roskaa 1.3.4.5.6.7.8.9.1.2.3.4.5.6.7 laatikos a"); |
|
31 _LIT(KTextToBeParsedToCheckPositions, "tekstii... rtsp://www.abcd.com jeba jee elvis.presley@hotmail.com 0700-123123 habaha@luukku.com 123 45678910? lapalaa vielayksi@yahoo.com roskaa"); |
|
32 |
|
33 _LIT(KTextToBeParsedForEmailAndURL, "tekstii... https://www.google.com jeba jee ..elvis.presley@hotmail.com.. 127.0.0.1? roskaa ad!d#$?%&c*+-/d@g_mail-1.com"); |
|
34 _LIT(KTextToBeParsedForInvalidEMail, "tekstii... www.yahoo.com adsadf .@gmail.com akjdl adf@.$ya%hoo.com jeba jee 127.*.0.1 roskaa@"); |
|
35 _LIT(KPhoneNo1, "07/00-123123"); |
|
36 _LIT(KPhoneNo2, "123 45678910"); |
|
37 _LIT(KPhoneNo3, "127.0555.0555"); |
|
38 _LIT(KPhoneNo4, "1.3.4.5.6.7.8.9"); |
|
39 _LIT(KPhoneNo5, "0802345"); |
|
40 _LIT(KPhoneNo6, "+0821898"); |
|
41 _LIT(KPhoneNo7, "#098"); |
|
42 |
|
43 _LIT(KEMail, "elvis.presley@hotmail.com"); |
|
44 _LIT(KEMail1, "habaha@luukku.com"); |
|
45 _LIT(KEMail2, "vielayksi@yahoo.com"); |
|
46 _LIT(KEMail3, "ad!d#$?%&c*+-/d@g_mail-1.com"); |
|
47 |
|
48 _LIT(KURL1, "http://www.google.com"); |
|
49 _LIT(KURL2, "127.0.0.1"); |
|
50 _LIT(KURL3, "https://www.google.com"); |
|
51 _LIT(KURL4, "rtsp://www.abcd.com"); |
|
52 _LIT(KURL5, "http://wap.google.com"); |
|
53 |
|
54 /** |
|
55 Constructor |
|
56 */ |
|
57 CT_AddressStringTokenizerStep::CT_AddressStringTokenizerStep() |
|
58 { |
|
59 // Call base class method to set up the human readable name for logging*/ |
|
60 SetTestStepName(KT_AddressStringTokenizerStep); |
|
61 } |
|
62 |
|
63 /** |
|
64 Destructor |
|
65 */ |
|
66 CT_AddressStringTokenizerStep::~CT_AddressStringTokenizerStep() |
|
67 { |
|
68 } |
|
69 |
|
70 TVerdict CT_AddressStringTokenizerStep::doTestStepL() |
|
71 { |
|
72 INFO_PRINTF1(_L("Test Started")); |
|
73 __UHEAP_MARK; |
|
74 RunTestCases(); |
|
75 __UHEAP_MARKEND; |
|
76 INFO_PRINTF1(_L("Test Finished")); |
|
77 return TestStepResult(); |
|
78 } |
|
79 |
|
80 void CT_AddressStringTokenizerStep::RunTestCases() |
|
81 { |
|
82 TInt err; |
|
83 SetTestStepID(_L("UIF-ETUL-0001")); |
|
84 INFO_PRINTF1(_L("Test to search URLs")); |
|
85 TRAP(err, SearchURLsL()); |
|
86 TEST(err == KErrNone); |
|
87 RecordTestResultL(); |
|
88 |
|
89 SetTestStepID(_L("UIF-ETUL-0002")); |
|
90 INFO_PRINTF1(_L("Test to search EMailAddresses")); |
|
91 TRAP(err, SearchEMailAddressesL()); |
|
92 TEST(err == KErrNone); |
|
93 RecordTestResultL(); |
|
94 |
|
95 SetTestStepID(_L("UIF-ETUL-0003")); |
|
96 INFO_PRINTF1(_L("Test to search PhoneNumbers")); |
|
97 TRAP(err, SearchPhoneNumbersL()); |
|
98 TEST(err == KErrNone); |
|
99 RecordTestResultL(); |
|
100 |
|
101 SetTestStepID(_L("UIF-ETUL-0004")); |
|
102 INFO_PRINTF1(_L("Tests for PhoneNos with Min. 3 nos. in a string \n\t\t\t\t\t\t\t when the string is considered as a phone no.\n")); |
|
103 TRAP(err, SearchPhoneNumbersWithMin3NosL()); |
|
104 TEST(err == KErrNone); |
|
105 RecordTestResultL(); |
|
106 |
|
107 SetTestStepID(_L("UIF-ETUL-0005")); |
|
108 INFO_PRINTF1(_L("Tests for PhoneNos with Min. 8 nos. in a string \n\t\t\t\t\t\t\t when the string is considered as a phone no.\n")); |
|
109 TRAP(err, SearchPhoneNumbersWithMin8NosL()); |
|
110 TEST(err == KErrNone); |
|
111 RecordTestResultL(); |
|
112 |
|
113 SetTestStepID(_L("UIF-ETUL-0006")); |
|
114 INFO_PRINTF1(_L("Tests for PhoneNos with Min. 15 nos. in a string \n\t\t\t\t\t\t\t when the string is considered as a phone no.\n")); |
|
115 TRAP(err, SearchPhoneNumbersWithMin15NosL()); |
|
116 TEST(err == KErrNone); |
|
117 RecordTestResultL(); |
|
118 |
|
119 SetTestStepID(_L("UIF-ETUL-0007")); |
|
120 INFO_PRINTF1(_L("Test to search URL's, EMailAddresses, PhoneNumbers")); |
|
121 TRAP(err, SearchAllL()); |
|
122 TEST(err == KErrNone); |
|
123 RecordTestResultL(); |
|
124 |
|
125 SetTestStepID(_L("UIF-ETUL-0008")); |
|
126 INFO_PRINTF1(_L("Test to check the positions")); |
|
127 TRAP(err, CheckPositionsL()); |
|
128 TEST(err == KErrNone); |
|
129 RecordTestResultL(); |
|
130 |
|
131 SetTestStepID(_L("UIF-ETUL-0009")); |
|
132 INFO_PRINTF1(_L("Test to Parse URI file")); |
|
133 TRAP(err, ParseURIFileL()); |
|
134 TEST(err == KErrNone); |
|
135 RecordTestResultL(); |
|
136 |
|
137 TestOOMForAddressStringTokenizer(); |
|
138 |
|
139 SetTestStepID(_L("UIF-ETUL-0024")); |
|
140 INFO_PRINTF1(_L("Test Phone Search Separators")); |
|
141 TRAP(err, TestPhoneSearchSeparatorsL()); |
|
142 TEST(err == KErrNone); |
|
143 RecordTestResultL(); |
|
144 CloseTMSGraphicsStep(); |
|
145 } |
|
146 |
|
147 /** |
|
148 @SYMTestCaseID UIF-ETUL-0001 |
|
149 |
|
150 @SYMREQ 7736 |
|
151 |
|
152 @SYMTestCaseDesc Test to search for 2 URLs present in the string. |
|
153 |
|
154 @SYMTestPriority High |
|
155 |
|
156 @SYMTestStatus Implemented |
|
157 |
|
158 @SYMTestActions Constructs the CTulAddressStringTokenizer object with CTulAddressStringTokenizer::EFindItemSearchURLBin\n |
|
159 which parses the given string and creates an item array consisting of all the URL's found in the string.\n |
|
160 API Calls:\n |
|
161 CTulAddressStringTokenizer::NewL(const TDesC& aText, TInt aSearchCases);\n |
|
162 CTulAddressStringTokenizer::Item(SFoundItem& aItem); \n |
|
163 CTulAddressStringTokenizer::NextItem(SFoundItem& aItem); \n |
|
164 |
|
165 @SYMTestExpectedResults The test checks whether |
|
166 1. 2 URL's found by CTulAddressStringTokenizer are the correct ones. |
|
167 2. Returns zero URLs when text with Invalid URL's is used for parsing. |
|
168 3. CTulAddressStringTokenizer::addressString->ItemCount() returns two when the text with 2 valid URL's is parsed |
|
169 and returns zero when text with Invalid URL's is parsed. |
|
170 4. CTulAddressStringTokenizer::Item() returns EFalse when there are no found items in the addressString. |
|
171 */ |
|
172 void CT_AddressStringTokenizerStep::SearchURLsL() |
|
173 { |
|
174 TBufC<512> str(KTextToBeParsedForEmailAndURL); |
|
175 |
|
176 CTulAddressStringTokenizer* addressString = CTulAddressStringTokenizer::NewL(KTextToBeParsedForEmailAndURL, CTulAddressStringTokenizer::EFindItemSearchURLBin); |
|
177 |
|
178 // Get count of found URL's |
|
179 TInt count(addressString->ItemCount()); |
|
180 |
|
181 TEST(count == 2); |
|
182 |
|
183 // Get currently selected URL |
|
184 CTulAddressStringTokenizer::SFoundItem item; |
|
185 addressString->Item(item); |
|
186 TPtrC16 url(str.Mid(item.iStartPos, item.iLength)); |
|
187 TEST(url.Compare(KURL3) == 0); |
|
188 |
|
189 // Get next found URL |
|
190 addressString->NextItem(item); |
|
191 url.Set(str.Mid(item.iStartPos, item.iLength)); |
|
192 TEST(url.Compare(KURL2) == 0); |
|
193 |
|
194 delete addressString; |
|
195 |
|
196 INFO_PRINTF1(_L("Test to search the text with Invalid URLs")); |
|
197 |
|
198 _LIT(KTextToBeParsedForInvalidURL, "tekstii... htsp:\\yahoo.com adsadf wws.google.com akjdl httls://sww.google.com jeba jee 127.*.0.1 roskaa"); |
|
199 addressString = CTulAddressStringTokenizer::NewL(KTextToBeParsedForInvalidURL, CTulAddressStringTokenizer::EFindItemSearchURLBin); |
|
200 |
|
201 // Get count of found URL's |
|
202 count = addressString->ItemCount(); |
|
203 TEST(count == 0); |
|
204 TEST(!addressString->Item(item)); |
|
205 |
|
206 delete addressString; |
|
207 } |
|
208 |
|
209 /** |
|
210 @SYMTestCaseID UIF-ETUL-0002 |
|
211 |
|
212 @SYMREQ 7736 |
|
213 |
|
214 @SYMTestCaseDesc Test to search for Email Addresses in the string. |
|
215 |
|
216 @SYMTestPriority High |
|
217 |
|
218 @SYMTestStatus Implemented |
|
219 |
|
220 @SYMTestActions Constructs the CTulAddressStringTokenizer object with CTulAddressStringTokenizer::EFindItemSearchMailAddressBin\n |
|
221 which parses the given string and creates an item array consisting of all the Email Addresses found in the string.\n |
|
222 API Calls:\n |
|
223 CTulAddressStringTokenizer::NewL(const TDesC& aText, TInt aSearchCases);\n |
|
224 CTulAddressStringTokenizer::Item(SFoundItem& aItem); \n |
|
225 CTulAddressStringTokenizer::NextItem(SFoundItem& aItem); \n |
|
226 |
|
227 @SYMTestExpectedResults The test checks whether |
|
228 1. 2 email addresses found by CTulAddressStringTokenizer are the correct ones. |
|
229 2. CTulAddressStringTokenizer::NextItem() returns EFalse when no more email addresses are found in the addressString. |
|
230 3. Returns zero email addresses when text with Invalid email addresses is used for parsing. |
|
231 */ |
|
232 void CT_AddressStringTokenizerStep::SearchEMailAddressesL() |
|
233 { |
|
234 CTulAddressStringTokenizer* addressString = CTulAddressStringTokenizer::NewL(KTextToBeParsedForEmailAndURL, CTulAddressStringTokenizer::EFindItemSearchMailAddressBin); |
|
235 |
|
236 TBufC<512> str(KTextToBeParsedForEmailAndURL); |
|
237 |
|
238 // Get count of found email addresses |
|
239 TInt count(addressString->ItemCount()); |
|
240 TEST(count == 2); |
|
241 |
|
242 // Get currently selected email |
|
243 CTulAddressStringTokenizer::SFoundItem item; |
|
244 addressString->Item(item); |
|
245 TPtrC16 emailAddress(str.Mid(item.iStartPos, item.iLength)); |
|
246 TEST(emailAddress.Compare(KEMail) == 0); |
|
247 |
|
248 addressString->NextItem(item); |
|
249 emailAddress.Set(str.Mid(item.iStartPos, item.iLength)); |
|
250 TEST(emailAddress.Compare(KEMail3) == 0); |
|
251 |
|
252 // Try to get next email address, should fail |
|
253 TEST(addressString->NextItem(item) == EFalse); |
|
254 |
|
255 delete addressString; |
|
256 |
|
257 INFO_PRINTF1(_L("Test to search the text with Invalid EMail addresses")); |
|
258 addressString = CTulAddressStringTokenizer::NewL(KTextToBeParsedForInvalidEMail, CTulAddressStringTokenizer::EFindItemSearchMailAddressBin); |
|
259 |
|
260 // Get count of found EMail Addresses |
|
261 count = addressString->ItemCount(); |
|
262 TEST(count == 0); |
|
263 |
|
264 delete addressString; |
|
265 } |
|
266 |
|
267 /** |
|
268 @SYMTestCaseID UIF-ETUL-0003 |
|
269 |
|
270 @SYMREQ 7736 |
|
271 |
|
272 @SYMTestCaseDesc Test to search for phone numbers in the string. |
|
273 |
|
274 @SYMTestPriority High |
|
275 |
|
276 @SYMTestStatus Implemented |
|
277 |
|
278 @SYMTestActions Constructs the CTulAddressStringTokenizer object with CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin \n |
|
279 which parses the given string and creates an item array consisting of all the phone numbers found in the string.\n |
|
280 3 is the minimun count of numbers in a string that the string is considered as a phone number when phone numbers are |
|
281 searched.API Calls:\n |
|
282 CTulAddressStringTokenizer::NewL(const TDesC& aText, TInt aSearchCases);\n |
|
283 CTulAddressStringTokenizer::ItemArray(); \n |
|
284 |
|
285 @SYMTestExpectedResults The test checks whether |
|
286 1. 7 Phone numbers found by CTulAddressStringTokenizer are the correct ones. |
|
287 2. CTulAddressStringTokenizer::ItemArray() returns correct array of phone numbers. |
|
288 3. Returns zero phone numbers when text with Invalid phone numbers is used for parsing. |
|
289 */ |
|
290 void CT_AddressStringTokenizerStep::SearchPhoneNumbersL() |
|
291 { |
|
292 CTulAddressStringTokenizer* addressString = CTulAddressStringTokenizer::NewL(KTextToBeParsed, CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin); |
|
293 |
|
294 TBufC<512> str(KTextToBeParsed); |
|
295 |
|
296 const CArrayFixFlat<CTulAddressStringTokenizer::SFoundItem>* itemArray = addressString->ItemArray(); |
|
297 |
|
298 // Get count of found email addresses |
|
299 TInt count(addressString->ItemCount()); |
|
300 TEST(count == 7); |
|
301 |
|
302 // Get currently selected phone number |
|
303 TPtrC16 phoneNos(str.Mid((*itemArray)[0].iStartPos, (*itemArray)[0].iLength)); |
|
304 TEST(phoneNos.Compare(KPhoneNo1) == 0); |
|
305 |
|
306 // Get next found number |
|
307 phoneNos.Set(str.Mid((*itemArray)[1].iStartPos, (*itemArray)[1].iLength)); |
|
308 TEST(phoneNos.Compare(KPhoneNo2) == 0); |
|
309 |
|
310 // Get next found number |
|
311 phoneNos.Set(str.Mid((*itemArray)[2].iStartPos, (*itemArray)[2].iLength)); |
|
312 TEST(phoneNos.Compare(KPhoneNo3) == 0); |
|
313 |
|
314 // Get next found number |
|
315 phoneNos.Set(str.Mid((*itemArray)[3].iStartPos, (*itemArray)[3].iLength)); |
|
316 TEST(phoneNos.Compare(KPhoneNo4) == 0); |
|
317 |
|
318 // Get next found number |
|
319 phoneNos.Set(str.Mid((*itemArray)[4].iStartPos, (*itemArray)[4].iLength)); |
|
320 TEST(phoneNos.Compare(KPhoneNo5) == 0); |
|
321 |
|
322 // Get next found number |
|
323 phoneNos.Set(str.Mid((*itemArray)[5].iStartPos, (*itemArray)[5].iLength)); |
|
324 TEST(phoneNos.Compare(KPhoneNo6) == 0); |
|
325 |
|
326 // Get next found number |
|
327 phoneNos.Set(str.Mid((*itemArray)[6].iStartPos, (*itemArray)[6].iLength)); |
|
328 TEST(phoneNos.Compare(KPhoneNo7) == 0); |
|
329 |
|
330 // Get last found number again |
|
331 phoneNos.Set(str.Mid((*itemArray)[5].iStartPos, (*itemArray)[5].iLength)); |
|
332 TEST(phoneNos.Compare(KPhoneNo6) == 0); |
|
333 |
|
334 delete addressString; |
|
335 |
|
336 INFO_PRINTF1(_L("Test to search the text with Invalid Phone nos.")); |
|
337 _LIT(KTextToBeParsedForInvalidPhoneNos, "jeba jee 070@0-1231#23 habaha 123 456^78910? roskaa laatikos a"); |
|
338 |
|
339 addressString = CTulAddressStringTokenizer::NewL(KTextToBeParsedForInvalidPhoneNos, CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin, 8); |
|
340 |
|
341 count= addressString->ItemCount(); |
|
342 TEST(count == 0); |
|
343 |
|
344 delete addressString; |
|
345 } |
|
346 |
|
347 /** |
|
348 @SYMTestCaseID UIF-ETUL-0004 |
|
349 |
|
350 @SYMREQ 7736 |
|
351 |
|
352 @SYMTestCaseDesc Test to search for phone numbers containing minimum 3 numbers, in the string. |
|
353 |
|
354 @SYMTestPriority High |
|
355 |
|
356 @SYMTestStatus Implemented |
|
357 |
|
358 @SYMTestActions Constructs the CTulAddressStringTokenizer object with CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin\n |
|
359 which parses the given string and creates an item array consisting of all the phone numbers containing minimum 3 numbers, found in the string.\n |
|
360 API Calls:\n |
|
361 CTulAddressStringTokenizer::NewL(const TDesC& aText, TInt aSearchCases, TInt aMinNumbers);\n |
|
362 CTulAddressStringTokenizer::Item(SFoundItem& aItem); \n |
|
363 CTulAddressStringTokenizer::NextItem(SFoundItem& aItem); \n |
|
364 |
|
365 @SYMTestExpectedResults The test checks whether |
|
366 1. 7 Phone numbers found by CTulAddressStringTokenizer are the correct ones. |
|
367 */ |
|
368 void CT_AddressStringTokenizerStep::SearchPhoneNumbersWithMin3NosL() |
|
369 { |
|
370 CTulAddressStringTokenizer* addressString = CTulAddressStringTokenizer::NewL(KTextToBeParsed, CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin, 3); |
|
371 |
|
372 TBufC<512> str(KTextToBeParsed); |
|
373 |
|
374 // Get count of found email addresses |
|
375 TInt count(addressString->ItemCount()); |
|
376 TEST(count == 7); |
|
377 |
|
378 // Get currently selected phone number |
|
379 CTulAddressStringTokenizer::SFoundItem item; |
|
380 addressString->Item(item); |
|
381 TPtrC16 phoneNos(str.Mid(item.iStartPos, item.iLength)); |
|
382 TEST(phoneNos.Compare(KPhoneNo1) == 0); |
|
383 |
|
384 // Get next found number |
|
385 addressString->NextItem(item); |
|
386 phoneNos.Set(str.Mid(item.iStartPos, item.iLength)); |
|
387 TEST(phoneNos.Compare(KPhoneNo2) == 0); |
|
388 |
|
389 // Get next found number |
|
390 addressString->NextItem(item); |
|
391 phoneNos.Set(str.Mid(item.iStartPos, item.iLength)); |
|
392 TEST(phoneNos.Compare(KPhoneNo3) == 0); |
|
393 |
|
394 // Get next found number |
|
395 addressString->NextItem(item); |
|
396 phoneNos.Set(str.Mid(item.iStartPos, item.iLength)); |
|
397 TEST(phoneNos.Compare(KPhoneNo4) == 0); |
|
398 |
|
399 // Get next found number |
|
400 addressString->NextItem(item); |
|
401 phoneNos.Set(str.Mid(item.iStartPos, item.iLength)); |
|
402 TEST(phoneNos.Compare(KPhoneNo5) == 0); |
|
403 |
|
404 // Get next found number |
|
405 addressString->NextItem(item); |
|
406 phoneNos.Set(str.Mid(item.iStartPos, item.iLength)); |
|
407 TEST(phoneNos.Compare(KPhoneNo6) == 0); |
|
408 |
|
409 // Get next found number |
|
410 addressString->NextItem(item); |
|
411 phoneNos.Set(str.Mid(item.iStartPos, item.iLength)); |
|
412 TEST(phoneNos.Compare(KPhoneNo7) == 0); |
|
413 |
|
414 delete addressString; |
|
415 } |
|
416 |
|
417 /** |
|
418 @SYMTestCaseID UIF-ETUL-0005 |
|
419 |
|
420 @SYMREQ 7736 |
|
421 |
|
422 @SYMTestCaseDesc Test to search for phone numbers containing minimum 8 numbers, in the string. |
|
423 |
|
424 @SYMTestPriority High |
|
425 |
|
426 @SYMTestStatus Implemented |
|
427 |
|
428 @SYMTestActions Constructs the CTulAddressStringTokenizer object with CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin\n |
|
429 which parses the given string and creates an item array consisting of all the phone numbers containing minimum 8 numbers, found in the string.\n |
|
430 API Calls:\n |
|
431 CTulAddressStringTokenizer::NewL(const TDesC& aText, TInt aSearchCases, TInt aMinNumbers);\n |
|
432 CTulAddressStringTokenizer::Item(SFoundItem& aItem); \n |
|
433 CTulAddressStringTokenizer::NextItem(SFoundItem& aItem); \n |
|
434 CTulAddressStringTokenizer::PrevItem(SFoundItem& aItem); \n |
|
435 |
|
436 @SYMTestExpectedResults The test checks whether |
|
437 1. 4 Phone numbers found by CTulAddressStringTokenizer are the correct ones. |
|
438 2. CTulAddressStringTokenizer::PrevItem() returns EFalse when called for the first time on addressString |
|
439 array(ie., when addressString is pointing to the first item in the array). |
|
440 3. CTulAddressStringTokenizer::PrevItem() returns correct phone number if it is called after accessing |
|
441 the last item in the addressString array. |
|
442 */ |
|
443 void CT_AddressStringTokenizerStep::SearchPhoneNumbersWithMin8NosL() |
|
444 { |
|
445 CTulAddressStringTokenizer* addressString = CTulAddressStringTokenizer::NewL(KTextToBeParsed, CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin, 8); |
|
446 |
|
447 TBufC<512> str(KTextToBeParsed); |
|
448 |
|
449 // Get count of found email addresses |
|
450 TInt count(addressString->ItemCount()); |
|
451 TEST(count == 4); |
|
452 |
|
453 CTulAddressStringTokenizer::SFoundItem item; |
|
454 |
|
455 // Try to get a previous item |
|
456 TEST(!addressString->PrevItem(item)); |
|
457 |
|
458 // Get currently selected phone number |
|
459 addressString->Item(item); |
|
460 TPtrC16 phoneNos(str.Mid(item.iStartPos, item.iLength)); |
|
461 TEST(phoneNos.Compare(KPhoneNo1) == 0); |
|
462 |
|
463 // Get next found number |
|
464 addressString->NextItem(item); |
|
465 phoneNos.Set(str.Mid(item.iStartPos, item.iLength)); |
|
466 TEST(phoneNos.Compare(KPhoneNo2) == 0); |
|
467 |
|
468 // Get next found number |
|
469 addressString->NextItem(item); |
|
470 phoneNos.Set(str.Mid(item.iStartPos, item.iLength)); |
|
471 TEST(phoneNos.Compare(KPhoneNo3) == 0); |
|
472 |
|
473 // Get next found number |
|
474 addressString->NextItem(item); |
|
475 phoneNos.Set(str.Mid(item.iStartPos, item.iLength)); |
|
476 TEST(phoneNos.Compare(KPhoneNo4) == 0); |
|
477 |
|
478 // Get last found number again |
|
479 addressString->PrevItem(item); |
|
480 phoneNos.Set(str.Mid(item.iStartPos, item.iLength)); |
|
481 TEST(phoneNos.Compare(KPhoneNo3) == 0); |
|
482 |
|
483 delete addressString; |
|
484 } |
|
485 |
|
486 /** |
|
487 @SYMTestCaseID UIF-ETUL-0006 |
|
488 |
|
489 @SYMREQ 7736 |
|
490 |
|
491 @SYMTestCaseDesc Test to search for phone numbers containing minimum 15 numbers, in the string. |
|
492 |
|
493 @SYMTestPriority High |
|
494 |
|
495 @SYMTestStatus Implemented |
|
496 |
|
497 @SYMTestActions Constructs the CTulAddressStringTokenizer object with CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin\n |
|
498 which parses the given string and creates an item array consisting of all the phone numbers containing minimum 15 numbers, found in the string.\n |
|
499 API Calls:\n |
|
500 CTulAddressStringTokenizer::NewL(const TDesC& aText, TInt aSearchCases, TInt aMinNumbers);\n |
|
501 CTulAddressStringTokenizer::Item(SFoundItem& aItem); \n |
|
502 CTulAddressStringTokenizer::NextItem(SFoundItem& aItem); \n |
|
503 |
|
504 @SYMTestExpectedResults The test checks whether |
|
505 1. 4 Phone numbers found by CTulAddressStringTokenizer are the correct ones. |
|
506 2. CTulAddressStringTokenizer::PrevItem() returns correct phone number if it is called after accessing |
|
507 the last item in the addressString array. |
|
508 */ |
|
509 void CT_AddressStringTokenizerStep::SearchPhoneNumbersWithMin15NosL() |
|
510 { |
|
511 _LIT(KPhoneNoWithMin15no1, "0700-12w312312345"); |
|
512 _LIT(KPhoneNoWithMin15no2, "123 45p1234678910"); |
|
513 _LIT(KPhoneNoWithMin15no3, "127.052355.052355"); |
|
514 _LIT(KPhoneNoWithMin15no4, "1.3.4.5.6.7.8.9.1.2.3.4.5.6.7"); |
|
515 |
|
516 CTulAddressStringTokenizer* addressString = CTulAddressStringTokenizer::NewL(KTextToBeParsedForPhNoWithMin15Nos, CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin, 15); |
|
517 |
|
518 TBufC<512> str(KTextToBeParsedForPhNoWithMin15Nos); |
|
519 |
|
520 // Get count of found email addresses |
|
521 TInt count(addressString->ItemCount()); |
|
522 TEST(count == 4); |
|
523 |
|
524 // Get currently selected phone number |
|
525 CTulAddressStringTokenizer::SFoundItem item; |
|
526 addressString->Item(item); |
|
527 TPtrC16 phoneNos(str.Mid(item.iStartPos, item.iLength)); |
|
528 TEST(phoneNos.Compare(KPhoneNoWithMin15no1) == 0); |
|
529 |
|
530 // Get next found number |
|
531 addressString->NextItem(item); |
|
532 phoneNos.Set(str.Mid(item.iStartPos, item.iLength)); |
|
533 TEST(phoneNos.Compare(KPhoneNoWithMin15no2) == 0); |
|
534 |
|
535 // Get next found number |
|
536 addressString->NextItem(item); |
|
537 phoneNos.Set(str.Mid(item.iStartPos, item.iLength)); |
|
538 TEST(phoneNos.Compare(KPhoneNoWithMin15no3) == 0); |
|
539 |
|
540 // Get next found number |
|
541 addressString->NextItem(item); |
|
542 phoneNos.Set(str.Mid(item.iStartPos, item.iLength)); |
|
543 TEST(phoneNos.Compare(KPhoneNoWithMin15no4) == 0); |
|
544 |
|
545 // Get last found number again |
|
546 addressString->PrevItem(item); |
|
547 phoneNos.Set(str.Mid(item.iStartPos, item.iLength)); |
|
548 TEST(phoneNos.Compare(KPhoneNoWithMin15no3) == 0); |
|
549 |
|
550 delete addressString; |
|
551 } |
|
552 |
|
553 /** |
|
554 @SYMTestCaseID UIF-ETUL-0007 |
|
555 |
|
556 @SYMREQ 7736 |
|
557 |
|
558 @SYMTestCaseDesc Test to search for Phone numbers, Email addresses and URL's in the string. |
|
559 |
|
560 @SYMTestPriority High |
|
561 |
|
562 @SYMTestStatus Implemented |
|
563 |
|
564 @SYMTestActions Constructs three CTulAddressStringTokenizer objects with CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin\n |
|
565 CTulAddressStringTokenizer::EFindItemSearchMailAddressBin and CTulAddressStringTokenizer::EFindItemSearchURLBin, |
|
566 which parses the given string and creates an item array consisting of all the Phone numbers, Email addresses and URL's \n |
|
567 respectively found in the string.\n |
|
568 API Calls:\n |
|
569 CTulAddressStringTokenizer::NewL(const TDesC& aText, TInt aSearchCases);\n |
|
570 CTulAddressStringTokenizer::Item(SFoundItem& aItem); \n |
|
571 CTulAddressStringTokenizer::NextItem(SFoundItem& aItem); \n |
|
572 CTulAddressStringTokenizer::DoNewSearchL( const TDesC& aText, TInt aSearchCases); \n |
|
573 |
|
574 @SYMTestExpectedResults The test checks whether |
|
575 1. Phone numbers, Email addresses and URL's found by CTulAddressStringTokenizer are the correct ones. |
|
576 2. CTulAddressStringTokenizer::DoNewSearchL() returns correct addressString array. |
|
577 */ |
|
578 void CT_AddressStringTokenizerStep::SearchAllL() |
|
579 { |
|
580 CTulAddressStringTokenizer* addressString = CTulAddressStringTokenizer::NewL(KTextToBeParsed, CTulAddressStringTokenizer::EFindItemSearchMailAddressBin); |
|
581 |
|
582 TBufC<512> str(KTextToBeParsed); |
|
583 |
|
584 // Get count of found email addresses |
|
585 TInt count(addressString->ItemCount()); |
|
586 |
|
587 TEST(count == 1); |
|
588 |
|
589 // Get currently selected email |
|
590 CTulAddressStringTokenizer::SFoundItem item; |
|
591 addressString->Item(item); |
|
592 TPtrC16 result(str.Mid(item.iStartPos, item.iLength)); |
|
593 TEST(result.Compare(KEMail) == 0); |
|
594 |
|
595 //make a new search - search for URL |
|
596 addressString->DoNewSearchL(KTextToBeParsed, CTulAddressStringTokenizer::EFindItemSearchURLBin); |
|
597 |
|
598 count = addressString->ItemCount(); |
|
599 TEST(count == 3); |
|
600 |
|
601 // Get currently selected URL |
|
602 addressString->Item(item); |
|
603 result.Set(str.Mid(item.iStartPos, item.iLength)); |
|
604 TEST(result.Compare(KURL1) == 0); |
|
605 |
|
606 // Get next selected URL |
|
607 addressString->NextItem(item); |
|
608 result.Set(str.Mid(item.iStartPos, item.iLength)); |
|
609 TEST(result.Compare(KURL5) == 0); |
|
610 |
|
611 // Get next selected URL |
|
612 addressString->NextItem(item); |
|
613 result.Set(str.Mid(item.iStartPos, item.iLength)); |
|
614 TEST(result.Compare(KURL2) == 0); |
|
615 |
|
616 //make a new search - search for phone number |
|
617 addressString->DoNewSearchL(KTextToBeParsed, CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin); |
|
618 |
|
619 count = addressString->ItemCount(); |
|
620 TEST(count == 7); |
|
621 |
|
622 // Get selected phone number |
|
623 addressString->Item(item); |
|
624 result.Set(str.Mid(item.iStartPos, item.iLength)); |
|
625 TEST(result.Compare(KPhoneNo1) == 0); |
|
626 |
|
627 // Get next selected phone number |
|
628 addressString->NextItem(item); |
|
629 result.Set(str.Mid(item.iStartPos, item.iLength)); |
|
630 TEST(result.Compare(KPhoneNo2) == 0); |
|
631 |
|
632 // Get next selected phone number |
|
633 addressString->NextItem(item); |
|
634 result.Set(str.Mid(item.iStartPos, item.iLength)); |
|
635 TEST(result.Compare(KPhoneNo3) == 0); |
|
636 |
|
637 // Get next selected phone number |
|
638 addressString->NextItem(item); |
|
639 result.Set(str.Mid(item.iStartPos, item.iLength)); |
|
640 TEST(result.Compare(KPhoneNo4) == 0); |
|
641 |
|
642 // Get next selected phone number |
|
643 addressString->NextItem(item); |
|
644 result.Set(str.Mid(item.iStartPos, item.iLength)); |
|
645 TEST(result.Compare(KPhoneNo5) == 0); |
|
646 |
|
647 // Get next selected phone number |
|
648 addressString->NextItem(item); |
|
649 result.Set(str.Mid(item.iStartPos, item.iLength)); |
|
650 TEST(result.Compare(KPhoneNo6) == 0); |
|
651 |
|
652 // Get next selected phone number |
|
653 addressString->NextItem(item); |
|
654 result.Set(str.Mid(item.iStartPos, item.iLength)); |
|
655 TEST(result.Compare(KPhoneNo7) == 0); |
|
656 |
|
657 delete addressString; |
|
658 } |
|
659 |
|
660 /** |
|
661 @SYMTestCaseID UIF-ETUL-0008 |
|
662 |
|
663 @SYMREQ 7736 |
|
664 |
|
665 @SYMTestCaseDesc Test to search for email addresses in the string and verifies their positions. |
|
666 |
|
667 @SYMTestPriority High |
|
668 |
|
669 @SYMTestStatus Implemented |
|
670 |
|
671 @SYMTestActions Constructs CTulAddressStringTokenizer object with CTulAddressStringTokenizer::EFindItemSearchMailAddressBin|EFindItemSearchURLBin \n |
|
672 which parses the given string and creates an item array consisting of all the Email addresses and URL's\n |
|
673 API Calls:\n |
|
674 CTulAddressStringTokenizer::NewL(const TDesC& aText, TInt aSearchCases);\n |
|
675 CTulAddressStringTokenizer::Item(SFoundItem& aItem); \n |
|
676 CTulAddressStringTokenizer::NextItem(SFoundItem& aItem);\n |
|
677 CTulAddressStringTokenizer::ResetPosition();\n |
|
678 |
|
679 @SYMTestExpectedResults The test checks whether |
|
680 1. Phone numbers, Email addresses and URL's found by CTulAddressStringTokenizer are the correct ones. |
|
681 2. CTulAddressStringTokenizer::ResetPosition() resets the position of the addressString array to zero. |
|
682 */ |
|
683 void CT_AddressStringTokenizerStep::CheckPositionsL() |
|
684 { |
|
685 CTulAddressStringTokenizer* addressString = CTulAddressStringTokenizer::NewL(KTextToBeParsedToCheckPositions, (CTulAddressStringTokenizer::TTokenizerSearchCase)(CTulAddressStringTokenizer::EFindItemSearchMailAddressBin | CTulAddressStringTokenizer::EFindItemSearchURLBin)); |
|
686 |
|
687 TBufC<512> str(KTextToBeParsedToCheckPositions); |
|
688 |
|
689 //Get count of found email addresses |
|
690 TInt count(addressString->ItemCount()); |
|
691 TEST(count == 4); |
|
692 |
|
693 // Get currently selected email |
|
694 CTulAddressStringTokenizer::SFoundItem item; |
|
695 addressString->Item(item); |
|
696 TPtrC16 result(str.Mid(item.iStartPos, item.iLength)); |
|
697 TEST(result.Compare(KURL4) == 0); |
|
698 |
|
699 addressString->NextItem(item); |
|
700 TPtrC16 result1(str.Mid(item.iStartPos, item.iLength)); |
|
701 TEST(result1.Compare(KEMail) == 0); |
|
702 |
|
703 //move to next item |
|
704 addressString->NextItem(item); |
|
705 TPtrC16 result2(str.Mid(item.iStartPos, item.iLength)); |
|
706 TEST(result2.Compare(KEMail1) == 0); |
|
707 |
|
708 //check that position is correct |
|
709 TEST(addressString->Position() == 2); |
|
710 |
|
711 //move to next item |
|
712 addressString->NextItem(item); |
|
713 result2.Set(str.Mid(item.iStartPos, item.iLength)); |
|
714 TEST(result2.Compare(KEMail2) == 0); |
|
715 |
|
716 //Resets the position to zero |
|
717 addressString->ResetPosition(); |
|
718 //get the first item |
|
719 addressString->Item(item); |
|
720 |
|
721 TPtrC16 reset_result1(str.Mid(item.iStartPos, item.iLength)); |
|
722 TEST(reset_result1.Compare(KURL4) == 0); |
|
723 |
|
724 //verify that we are in first item |
|
725 TEST(result == reset_result1); |
|
726 |
|
727 delete addressString; |
|
728 } |
|
729 |
|
730 /** |
|
731 @SYMTestCaseID UIF-ETUL-0009 |
|
732 |
|
733 @SYMREQ 7736 |
|
734 |
|
735 @SYMTestCaseDesc Test to Parse for URI's, Email Addresses, Phone Numbers and URL's in a file and to verify them |
|
736 |
|
737 @SYMTestPriority High |
|
738 |
|
739 @SYMTestStatus Implemented |
|
740 |
|
741 @SYMTestActions Constructs CTulAddressStringTokenizer object with CTulAddressStringTokenizer::EFindItemSearchMailAddressBin \n |
|
742 which parses the given string and creates an item array consisting of all the Email addresses\n |
|
743 API Calls:\n |
|
744 CTulAddressStringTokenizer::NewL(const TDesC& aText, TInt aSearchCases);\n |
|
745 CTulAddressStringTokenizer::Item(SFoundItem& aItem); \n |
|
746 CTulAddressStringTokenizer::NextItem(SFoundItem& aItem); \n |
|
747 |
|
748 @SYMTestExpectedResults The test checks whether |
|
749 1. Phone numbers, Email addresses, URL's and URI's parsed by CTulAddressStringTokenizer are the correct ones. |
|
750 */ |
|
751 void CT_AddressStringTokenizerStep::ParseURIFileL() |
|
752 { |
|
753 INFO_PRINTF1(_L("Test begins")); |
|
754 __UHEAP_MARK; |
|
755 |
|
756 //load test case text to string |
|
757 RFs rfs; |
|
758 User::LeaveIfError(rfs.Connect()); |
|
759 CleanupClosePushL(rfs); |
|
760 _LIT(KParesTextFile, "z:\\system\\data\\addressstringtokenizertestappdata.txt"); |
|
761 _LIT(KParesTextFileRef, "z:\\system\\data\\addressstringtokenizertestappdataref.txt"); |
|
762 |
|
763 RFile file; |
|
764 HBufC* fullBuf = HBufC::NewMaxLC(KFullBufSize); |
|
765 TPtr fullBufPtr = fullBuf->Des(); |
|
766 fullBufPtr = KNullDesC; |
|
767 |
|
768 TFileText reader; |
|
769 TBuf<KReadBufSize> fileBuffer; |
|
770 |
|
771 if ((file.Open(rfs, KParesTextFile, EFileStreamText|EFileRead|EFileShareAny)) == KErrNone) |
|
772 { |
|
773 CleanupClosePushL(file); |
|
774 // use TFileText for reading file. There is probably better ways to do this tho. |
|
775 reader.Set(file); |
|
776 if (reader.Seek(ESeekStart)) |
|
777 { |
|
778 INFO_PRINTF1(_L("File corrupted")); |
|
779 User::Leave(KErrGeneral); // not cleaning up properly |
|
780 } |
|
781 |
|
782 while (!reader.Read(fileBuffer)) |
|
783 { |
|
784 fullBufPtr.Append(fileBuffer); |
|
785 fullBufPtr.Append('\n'); |
|
786 } |
|
787 CleanupStack::Pop(&file); |
|
788 file.Close(); |
|
789 } |
|
790 else |
|
791 { |
|
792 INFO_PRINTF1(_L("z:\\system\\data\\addressstringtokenizertestappdata.txt not found")); |
|
793 User::Leave(KErrNotFound); |
|
794 } |
|
795 |
|
796 if (file.Open(rfs, KParesTextFileRef, EFileStreamText|EFileRead|EFileShareAny) == KErrNone) |
|
797 { |
|
798 CleanupClosePushL(file); |
|
799 // use TFileText for reading file. There is probably better way to do this tho. |
|
800 reader.Set(file); |
|
801 if (reader.Seek(ESeekStart)) |
|
802 { |
|
803 INFO_PRINTF1(_L("File corrupted")); |
|
804 User::Leave(KErrGeneral); // not cleaning up properly |
|
805 } |
|
806 } |
|
807 else |
|
808 { |
|
809 INFO_PRINTF1(_L("z:\\system\\data\\addressstringtokenizertestappdataref.txt not found")); |
|
810 User::Leave(KErrNotFound); |
|
811 } |
|
812 |
|
813 INFO_PRINTF1(_L("Start searching...")); |
|
814 |
|
815 // Create an instance of Address String Tokenizer and search for URL's. |
|
816 CTulAddressStringTokenizer* addressString = CTulAddressStringTokenizer::NewL(fullBufPtr, CTulAddressStringTokenizer::EFindItemSearchURLBin); |
|
817 TestAddressStringTokenizers(addressString, reader, fullBufPtr); |
|
818 delete addressString; |
|
819 |
|
820 // find phone numbers from same text |
|
821 addressString = CTulAddressStringTokenizer::NewL(fullBufPtr, CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin); |
|
822 TestAddressStringTokenizers(addressString, reader, fullBufPtr); |
|
823 |
|
824 // test do new search with same instance |
|
825 TInt count = addressString->DoNewSearchL(fullBufPtr, CTulAddressStringTokenizer::EFindItemSearchMailAddressBin); |
|
826 TEST(count > 0); |
|
827 TestAddressStringTokenizers(addressString, reader, fullBufPtr); |
|
828 delete addressString; |
|
829 |
|
830 // find schemed URIs from same text |
|
831 addressString = CTulAddressStringTokenizer::NewL(fullBufPtr, CTulAddressStringTokenizer::EFindItemSearchScheme); |
|
832 TestAddressStringTokenizers(addressString, reader, fullBufPtr); |
|
833 delete addressString; |
|
834 |
|
835 // find everything from same text |
|
836 addressString = CTulAddressStringTokenizer::NewL(fullBufPtr, (CTulAddressStringTokenizer::TTokenizerSearchCase)(CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin | CTulAddressStringTokenizer::EFindItemSearchURLBin | CTulAddressStringTokenizer::EFindItemSearchMailAddressBin | CTulAddressStringTokenizer::EFindItemSearchScheme)); |
|
837 TestAddressStringTokenizers(addressString, reader, fullBufPtr); |
|
838 delete addressString; |
|
839 |
|
840 CleanupStack::PopAndDestroy(3, &rfs); |
|
841 __UHEAP_MARKEND; |
|
842 } |
|
843 |
|
844 /** |
|
845 @SYMTestCaseID UIF-ETUL-0010 |
|
846 |
|
847 @SYMREQ 7736 |
|
848 |
|
849 @SYMTestCaseDesc OOM test for CTulAddressStringTokenizer's NewL() and DoNewSearchL() methods. |
|
850 |
|
851 @SYMTestPriority High |
|
852 |
|
853 @SYMTestStatus Implemented |
|
854 |
|
855 @SYMTestActions Calls CTulAddressStringTokenizer's NewL() and DoNewSearchL() methods. |
|
856 |
|
857 @SYMTestExpectedResults Tests should complete without any memory leaks. |
|
858 */ |
|
859 void CT_AddressStringTokenizerStep::TestOOMForAddressStringTokenizer() |
|
860 { |
|
861 INFO_PRINTF1(_L("Start OOM test for Address String Tokenizer")); |
|
862 CTulAddressStringTokenizer* addressString = NULL; |
|
863 TInt count; |
|
864 TInt fail; |
|
865 |
|
866 //OOM test for CTulAddressStringTokenizer::NewL() method. |
|
867 for (fail = 1;; fail++) |
|
868 { |
|
869 __UHEAP_SETFAIL(RHeap::EDeterministic, fail); |
|
870 __UHEAP_MARK; |
|
871 TRAPD(err, addressString = CTulAddressStringTokenizer::NewL(KTextToBeParsedForEmailAndURL, CTulAddressStringTokenizer::EFindItemSearchURLBin)); |
|
872 TEST((err == KErrNone) || (err == KErrNoMemory)); |
|
873 if (err == KErrNone) |
|
874 { |
|
875 // Get count of found URL's |
|
876 count = addressString->ItemCount(); |
|
877 TEST(count == 2); |
|
878 delete addressString; |
|
879 addressString = NULL; |
|
880 __UHEAP_MARKEND; |
|
881 break; |
|
882 } |
|
883 __UHEAP_MARKEND; |
|
884 } |
|
885 |
|
886 //OOM test for CTulAddressStringTokenizer::DoNewSearchL() method. |
|
887 for (fail = 1; ; fail++) |
|
888 { |
|
889 __UHEAP_RESET; |
|
890 TRAPD(err, addressString = CTulAddressStringTokenizer::NewL(KTextToBeParsedForEmailAndURL, CTulAddressStringTokenizer::EFindItemSearchURLBin)); |
|
891 TEST(err == KErrNone); |
|
892 |
|
893 __UHEAP_SETFAIL(RHeap::EDeterministic, fail); |
|
894 __UHEAP_MARK; |
|
895 TRAP(err, count = addressString->CTulAddressStringTokenizer::DoNewSearchL(KTextToBeParsed, CTulAddressStringTokenizer::EFindItemSearchMailAddressBin)); |
|
896 TEST((err == KErrNone) || (err == KErrNoMemory)); |
|
897 if (err == KErrNone) |
|
898 { |
|
899 // Get count of found URL's |
|
900 count = addressString->ItemCount(); |
|
901 TEST(count == 1); |
|
902 delete addressString; |
|
903 __UHEAP_MARKEND; |
|
904 break; |
|
905 } |
|
906 else |
|
907 { |
|
908 delete addressString; |
|
909 __UHEAP_MARKEND; |
|
910 } |
|
911 } |
|
912 __UHEAP_RESET; |
|
913 INFO_PRINTF1(_L("OOM test for Address String Tokenizer Completed")); |
|
914 } |
|
915 |
|
916 void CT_AddressStringTokenizerStep::TestAddressStringTokenizers(CTulAddressStringTokenizer* aAddressStringTokenizer, TFileText& aReader, TDes& aText) |
|
917 { |
|
918 TBuf<KReadBufSize> fileBuffer; |
|
919 |
|
920 // Get count of found items. |
|
921 TInt count(aAddressStringTokenizer->ItemCount()); |
|
922 TEST(count > 0); |
|
923 TPtrC result; |
|
924 |
|
925 // SFoundItem instance |
|
926 CTulAddressStringTokenizer::SFoundItem item; |
|
927 |
|
928 TBool found = aAddressStringTokenizer->Item(item); |
|
929 TEST(found); |
|
930 for(TInt i = 0; i < count; i++) |
|
931 { |
|
932 result.Set(aText.Mid(item.iStartPos, item.iLength)); |
|
933 aReader.Read(fileBuffer); |
|
934 |
|
935 //Comparing parsed result to what read buffer reads from the file. |
|
936 TEST(!fileBuffer.Compare(result) ); |
|
937 if (fileBuffer.Compare(result)) |
|
938 { |
|
939 INFO_PRINTF2(_L("Buffer : %S"), &fileBuffer); |
|
940 INFO_PRINTF2(_L("Result : %S"), &result); |
|
941 } |
|
942 aAddressStringTokenizer->NextItem(item); |
|
943 } |
|
944 } |
|
945 |
|
946 /** |
|
947 @SYMTestCaseID UIF-ETUL-0024 |
|
948 |
|
949 @SYMREQ DEF114388 |
|
950 |
|
951 @SYMTestCaseDesc Test of CTulAddressStringTokenizer::SearchPhoneNumberL( const TDesC& aText ) |
|
952 with all the phone number separators. |
|
953 |
|
954 @SYMTestPriority Normal |
|
955 |
|
956 @SYMTestStatus Implemented |
|
957 |
|
958 @SYMTestActions There should be 5 phone numbers separators: |
|
959 - KCharLinefeed = 0x000A |
|
960 - KCharFormfeed = 0x000C |
|
961 - KCharCarriageReturn = 0x000D |
|
962 - KCharLineSeparator = 0x2028 |
|
963 - KCharParagraphSeparator = 0x2029 |
|
964 With a simple string _LIT16(KTestPhoneSeparator, "11111%c22222") |
|
965 and with all the separators above, we apply the tested function: |
|
966 CTulAddressStringTokenizer::SearchPhoneNumberL( const TDesC& aText ) |
|
967 |
|
968 |
|
969 @SYMTestExpectedResults On the 5 cases, the function should find 2 phone numbers |
|
970 i.e: multiSearch->ItemCount() should be equal to 2 |
|
971 otherwise the test fail. |
|
972 */ |
|
973 void CT_AddressStringTokenizerStep::TestPhoneSearchSeparatorsL() |
|
974 { |
|
975 TInt KCharLinefeed = 0x000A; |
|
976 TInt KCharFormfeed = 0x000C; |
|
977 TInt KCharCarriageReturn = 0x000D; |
|
978 TInt KCharLineSeparator = 0x2028; |
|
979 TInt KCharParagraphSeparator = 0x2029; |
|
980 TInt KSeparators[5]={KCharLinefeed,KCharFormfeed,KCharCarriageReturn,KCharLineSeparator,KCharParagraphSeparator}; |
|
981 _LIT16(KTestPhoneSeparator, "11111%c22222"); |
|
982 TBool succeed=ETrue; |
|
983 TBuf16<16> str; |
|
984 for (TInt k=0;k<5;k++) |
|
985 { |
|
986 str.Format(KTestPhoneSeparator,KSeparators[k]); |
|
987 CTulAddressStringTokenizer* multiSearch = CTulAddressStringTokenizer::NewL(str, |
|
988 CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin); |
|
989 |
|
990 if (multiSearch->ItemCount()!=2) |
|
991 { |
|
992 succeed=EFalse; |
|
993 } |
|
994 delete multiSearch; |
|
995 if (succeed==EFalse) |
|
996 { |
|
997 break; |
|
998 } |
|
999 } |
|
1000 TEST(succeed); |
|
1001 } |