phonebookengines/contactsmodel/tsrc/T_NOMACH.CPP
changeset 24 0ba2181d7c28
parent 0 e686773b3f54
equal deleted inserted replaced
0:e686773b3f54 24:0ba2181d7c28
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 /*
     2 // All rights reserved.
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 // This component and the accompanying materials are made available
     3 * All rights reserved.
     4 // under the terms of "Eclipse Public License v1.0"
     4 * This component and the accompanying materials are made available
     5 // which accompanies this distribution, and is available
     5 * under the terms of "Eclipse Public License v1.0"
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 * which accompanies this distribution, and is available
     7 //
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 // Initial Contributors:
     8 *
     9 // Nokia Corporation - initial contribution.
     9 * Initial Contributors:
    10 //
    10 * Nokia Corporation - initial contribution.
    11 // Contributors:
    11 *
    12 //
    12 * Contributors:
    13 // Description:
    13 *
    14 //
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
    15 
    18 
    16 #include <e32test.h>
    19 #include <e32test.h>
    17 #include <f32file.h>
    20 #include <f32file.h>
    18 #include "T_UTILS.H"
    21 #include "t_utils.h"
    19 #include <coreappstest/testserver.h>
    22 #include <coreappstest/testserver.h>
    20 
    23 
    21 _LIT(KCntTestTitle,"T_NOMACH");
    24 _LIT(KCntTestTitle,"T_NOMACH");
    22 _LIT(KDatabaseFileName,"c:T_NOMACH");
    25 _LIT(KDatabaseFileName,"c:T_NOMACH");
    23 
    26 
   210 
   213 
   211 /** 
   214 /** 
   212 Testcode for Graham's new API
   215 Testcode for Graham's new API
   213 
   216 
   214 These all match 1234567:
   217 These all match 1234567:
   215 *#42# 0201234567 p123
   218 *#42# 0401234567 p123
   216 *#42# +358201234567 p123
   219 *#42# +358401234567 p123
   217 *61 0201234567
   220 *61 0401234567
   218 *61 +358201234567
   221 *61 +358401234567
   219 +358201234567 +3
   222 +358401234567 +3
   220 +358201234567 p123
   223 +358401234567 p123
   221 
   224 
   222 */
   225 */
   223 LOCAL_C void TestNewMatchingL()
   226 LOCAL_C void TestNewMatchingL()
   224 	{
   227 	{
   225 	ResetDatabaseL();
   228 	ResetDatabaseL();
   226 
   229 
   227 	const TInt KLastThreeDigits =3;
   230 	const TInt KLastThreeDigits =3;
   228 	//These numbers match 1234567
   231 	//These numbers match 1234567
   229 	_LIT(KCntDTMFNumber1,"*#42# 0201234567 p123");
   232 	_LIT(KCntDTMFNumber1,"*#42# 0401234567 p123");
   230 	_LIT(KCntDTMFNumber2,"*#42#+358401234567 p123");
   233 	_LIT(KCntDTMFNumber2,"*#42#+358401234567 p123");
   231 	_LIT(KCntDTMFNumber3,"*61 0201234567");
   234 	_LIT(KCntDTMFNumber3,"*61 0401234567");
   232 	_LIT(KCntDTMFNumber4,"*61 +358201234567");
   235 	_LIT(KCntDTMFNumber4,"*61 +358401234567");
   233 	_LIT(KCntDTMFNumber5,"+358201234567 +3");
   236 	_LIT(KCntDTMFNumber5,"+358401234567 +3");
   234 	_LIT(KCntDTMFNumber6,"+358201234567 p123");
   237 	_LIT(KCntDTMFNumber6,"+358401234567 p123");
   235 	_LIT(KCntMatch1to7ExtraCharacters,"mobile 12 345-67");
   238 	_LIT(KCntMatch1to7ExtraCharacters,"mobile 12 345-67");
   236 	_LIT(KCntMatch1to7Brackets,"(020) 0123-4567");
   239 	_LIT(KCntMatch1to7Brackets,"(020) 0123-4567");
   237 	_LIT(KCntMatch1to7TooManyNumbers,"123456789012345678901234567");
   240 	_LIT(KCntMatch1to7TooManyNumbers,"123456789012345678901234567");
   238 	//These shouldn't match 1234567
   241 	//These shouldn't match 1234567
   239 	_LIT(KCntDTMFNumber7,"*#42# 0201234567#p123");//empty
   242 	_LIT(KCntDTMFNumber7,"*#42# 0401234567#p123");//empty
   240 	_LIT(KCntDTMFNumber8,"*12345+0201234567");    //matches 12345
   243 	_LIT(KCntDTMFNumber8,"*12345+0401234567");    //matches 12345
   241 	_LIT(KCntDTMFNumber9,"*+123+456+++++++++++"); //matches 123
   244 	_LIT(KCntDTMFNumber9,"*+123+456+++++++++++"); //matches 123
   242 	//Graham's possible defects
   245 	//Graham's possible defects
   243 	_LIT(KCntPossibleDefect,"70000");
   246 	_LIT(KCntPossibleDefect,"70000");
   244 	_LIT(KCntZeroAtEnd,"020 5632700");
   247 	_LIT(KCntZeroAtEnd,"020 5632700");
   245 	//Match numbers
   248 	//Match numbers
   246 	_LIT(KCntMatch1to7,"1234567");
   249 	_LIT(KCntMatch1to7,"1234567");
   247 	_LIT(KCntMatch1to3,"123");
   250 	_LIT(KCntMatch1to3,"123");
   248 	_LIT(KCntMatch700,"700");
   251 	_LIT(KCntMatch700,"700");
   249 	//Spaces at the start
   252 	//Spaces at the start
   250 	_LIT(KCntSpaceInNumber,"   0 2 0      7 9 4 6  5 6 7 8    ");
   253 	_LIT(KCntSpaceInNumber,"   0 2 0      7 1 2 0  5 6 7 8    ");
   251 	_LIT(KCntSpaceMatch,"02079465678");
   254 	_LIT(KCntSpaceMatch,"02071205678");
   252 	_LIT(KCntSpaceInNumberIntl,"   +44 7700 900 472");
   255 	_LIT(KCntSpaceInNumberIntl,"   +44 7447 065 472");
   253 	_LIT(KCntSpaceInNumberIntlMatch,"+447700900472");
   256 	_LIT(KCntSpaceInNumberIntlMatch,"+447747065472");
   254 	_LIT(KCntSpaceWorstCase,"              ");
   257 	_LIT(KCntSpaceWorstCase,"              ");
   255 	_LIT(KCntNoRealDigitsInNumber,"Lycos SMS");
   258 	_LIT(KCntNoRealDigitsInNumber,"Lycos SMS");
   256 
   259 
   257 	_LIT(KCntShortNumber1,"789");
   260 	_LIT(KCntShortNumber1,"789");
   258 	_LIT(KCntShortNumber2,"456");
   261 	_LIT(KCntShortNumber2,"456");
   259 
   262 
   260 	_LIT(KCntEndingByShortNumber1,"+44(0)79460064789");
   263 	_LIT(KCntEndingByShortNumber1,"+44(0)32465764789");
   261 	_LIT(KCntEndingByShortNumber2,"+447946008731456");
   264 	_LIT(KCntEndingByShortNumber2,"+443216568731456");
   262 
   265 
   263 	_LIT(KCntMatchShortNumber1,"789"); // must not match other number ending with 789
   266 	_LIT(KCntMatchShortNumber1,"789"); // must not match other number ending with 789
   264 	_LIT(KCntMatchShortNumber2,"456"); // must not match other number ending with 456
   267 	_LIT(KCntMatchShortNumber2,"456"); // must not match other number ending with 456
   265 
   268 
   266 	CreateContactL(KCntName,KCntSurname,KCntShortNumber1,KNullDesC);
   269 	CreateContactL(KCntName,KCntSurname,KCntShortNumber1,KNullDesC);
   327 // Remove CNTPHONE.DLL before running this test to verify
   330 // Remove CNTPHONE.DLL before running this test to verify
   328 //
   331 //
   329 LOCAL_C void TestNoPhoneMatchLibraryL()
   332 LOCAL_C void TestNoPhoneMatchLibraryL()
   330 	{
   333 	{
   331 	ResetDatabaseL();
   334 	ResetDatabaseL();
   332 	_LIT(KCntNumberWithSpaces,"+44  020 7946 0000");
   335 	_LIT(KCntNumberWithSpaces,"+44  020 7563 2000");
   333 	_LIT(KCntNumberWithoutSpaces,"02079460000");
   336 	_LIT(KCntNumberWithoutSpaces,"02075632000");
   334 	CreateContactL(KCntName,KCntSurname,KCntNumberWithSpaces,KNullDesC);
   337 	CreateContactL(KCntName,KCntSurname,KCntNumberWithSpaces,KNullDesC);
   335 	CheckPhoneMatchL(KCntNumberWithoutSpaces,KMatch7Digits,1);
   338 	CheckPhoneMatchL(KCntNumberWithoutSpaces,KMatch7Digits,1);
   336 	}
   339 	}
   337 
   340 
   338 
   341 
   356 */
   359 */
   357 LOCAL_C void TestFaxSMSMatchingL()
   360 LOCAL_C void TestFaxSMSMatchingL()
   358 	{
   361 	{
   359 	ResetDatabaseL();
   362 	ResetDatabaseL();
   360 
   363 
   361 	_LIT(KCntFaxNumber1,"020 79460585");
   364 	_LIT(KCntFaxNumber1,"020 85858585");
   362 	_LIT(KCntFaxNumber2,"020 79460432");
   365 	_LIT(KCntFaxNumber2,"020 85858432");
   363 	_LIT(KCntSMSNumber1,"+442079460432");
   366 	_LIT(KCntSMSNumber1,"+442085858432");
   364 	_LIT(KCntSMSNumber2,"+442079460585");
   367 	_LIT(KCntSMSNumber2,"+442085858585");
   365 	
   368 	
   366 	_LIT(KCntDuplicateNumber,"0207 9460585");
   369 	_LIT(KCntDuplicateNumber,"0208 5858585");
   367 	_LIT(KCntNewSMSNumber,"020 79460696");
   370 	_LIT(KCntNewSMSNumber,"020 85969696");
   368 	
   371 	
   369 	TContactItemId one = CreateFaxSMSContactL(KCntName,KCntSurname,KCntFaxNumber1,KCntSMSNumber1);
   372 	TContactItemId one = CreateFaxSMSContactL(KCntName,KCntSurname,KCntFaxNumber1,KCntSMSNumber1);
   370 	TContactItemId two = CreateFaxSMSContactL(KCntName,KCntSurname,KCntFaxNumber2,KCntSMSNumber2);
   373 	TContactItemId two = CreateFaxSMSContactL(KCntName,KCntSurname,KCntFaxNumber2,KCntSMSNumber2);
   371 	
   374 	
   372 	//check that there are only 2 matches
   375 	//check that there are only 2 matches
   570  */
   573  */
   571 LOCAL_C void Test11DigitMatchingL()
   574 LOCAL_C void Test11DigitMatchingL()
   572 	{
   575 	{
   573 	ResetDatabaseL();
   576 	ResetDatabaseL();
   574 
   577 
   575 	_LIT(K11DigitTestNumber1,"020 7700 9001");
   578 	_LIT(K11DigitTestNumber1,"20 7582 24220");
   576 	_LIT(K11DigitTestNumber2,"20 7700 90012");
   579 	_LIT(K11DigitTestNumber2,"020 7582 2422");
   577 	_LIT(K11DigitTestNumber3,"020 7700 9081");
   580 	_LIT(K11DigitTestNumber3,"020 7582 2381");
   578 	_LIT(K11DigitTestNumber4,"120 7700 9081");
   581 	_LIT(K11DigitTestNumber4,"120 7582 2381");
   579 	_LIT(K11DigitTestNumber5,"9120 7700 9081");
   582 	_LIT(K11DigitTestNumber5,"9120 7582 2381");
   580 
   583 
   581 	CreateContactL(KCntName,KCntSurname,K11DigitTestNumber1,KNullDesC);
   584 	CreateContactL(KCntName,KCntSurname,K11DigitTestNumber1,KNullDesC);
   582 	CreateContactL(KCntName,KCntSurname,K11DigitTestNumber2,KNullDesC);
   585 	CreateContactL(KCntName,KCntSurname,K11DigitTestNumber2,KNullDesC);
   583 	CreateContactL(KCntName,KCntSurname,K11DigitTestNumber3,KNullDesC);
   586 	CreateContactL(KCntName,KCntSurname,K11DigitTestNumber3,KNullDesC);
   584 	CreateContactL(KCntName,KCntSurname,K11DigitTestNumber4,KNullDesC);
   587 	CreateContactL(KCntName,KCntSurname,K11DigitTestNumber4,KNullDesC);
   585 	CreateContactL(KCntName,KCntSurname,K11DigitTestNumber5,KNullDesC);
   588 	CreateContactL(KCntName,KCntSurname,K11DigitTestNumber5,KNullDesC);
   586 
   589 
   587 	//Match numbers
   590 	//Match numbers
   588 	_LIT(K11DigitMatch1,"020 7700 9001");
   591 	_LIT(K11DigitMatch1,"020 7582 2422");
   589 	_LIT(K11DigitMatch2,"20 7700 90012");
   592 	_LIT(K11DigitMatch2,"20 7582 24220");
   590 	_LIT(K11DigitMatch3,"020 7700 9081");
   593 	_LIT(K11DigitMatch3,"020 7582 2381");
   591 	_LIT(K11DigitMatch4,"120 7700 9081");
   594 	_LIT(K11DigitMatch4,"120 7582 2381");
   592 	_LIT(K11DigitMatch5,"9120 7700 9081");
   595 	_LIT(K11DigitMatch5,"9120 7582 2381");
   593 	_LIT(K11DigitMatch6,"20 7700 9081");
   596 	_LIT(K11DigitMatch6,"20 7582 2381");
   594 
   597 
   595 	CheckPhoneMatchL(K11DigitMatch1,KMatch10Digits,1);
   598 	CheckPhoneMatchL(K11DigitMatch1,KMatch10Digits,1);
   596 	CheckPhoneMatchL(K11DigitMatch1,KMatch11Digits,1);
   599 	CheckPhoneMatchL(K11DigitMatch1,KMatch11Digits,1);
   597 
   600 
   598 	CheckPhoneMatchL(K11DigitMatch2,KMatch10Digits,1);
   601 	CheckPhoneMatchL(K11DigitMatch2,KMatch10Digits,1);
   616  */
   619  */
   617 LOCAL_C void Test15DigitMatchingL()
   620 LOCAL_C void Test15DigitMatchingL()
   618 	{
   621 	{
   619 	ResetDatabaseL();
   622 	ResetDatabaseL();
   620 
   623 
   621 	_LIT(K15DigitTestNumber1,"0086 207 9476 0454");
   624 	_LIT(K15DigitTestNumber1,"0086 207 3453 3454");
   622 	_LIT(K15DigitTestNumber2,"8186 207 9476 0454");
   625 	_LIT(K15DigitTestNumber2,"8186 207 3453 3454");
   623 	_LIT(K15DigitTestNumber3,"8620 794 7604 5400");
   626 	_LIT(K15DigitTestNumber3,"8620 734 5334 5400");
   624 
   627 
   625 	CreateContactL(KCntName,KCntSurname,K15DigitTestNumber1,KNullDesC);
   628 	CreateContactL(KCntName,KCntSurname,K15DigitTestNumber1,KNullDesC);
   626 	CreateContactL(KCntName,KCntSurname,K15DigitTestNumber2,KNullDesC);
   629 	CreateContactL(KCntName,KCntSurname,K15DigitTestNumber2,KNullDesC);
   627 	CreateContactL(KCntName,KCntSurname,K15DigitTestNumber3,KNullDesC);
   630 	CreateContactL(KCntName,KCntSurname,K15DigitTestNumber3,KNullDesC);
   628 
   631 
   629 	//Match numbers
   632 	//Match numbers
   630 	_LIT(K15DigitMatch1,"0086 207 9476 0454");
   633 	_LIT(K15DigitMatch1,"0086 207 3453 3454");
   631 	_LIT(K15DigitMatch2,"86 207 9476 0454");
   634 	_LIT(K15DigitMatch2,"86 207 3453 3454");
   632 	_LIT(K15DigitMatch3,"8186 207 9476 0454");
   635 	_LIT(K15DigitMatch3,"8186 207 3453 3454");
   633 	_LIT(K15DigitMatch4,"08186 207 9476 0454");
   636 	_LIT(K15DigitMatch4,"08186 207 3453 3454");
   634 
   637 
   635 	CheckPhoneMatchL(K15DigitMatch1,KMatch15Digits,1);
   638 	CheckPhoneMatchL(K15DigitMatch1,KMatch15Digits,1);
   636 	CheckPhoneMatchL(K15DigitMatch1,KMatch14Digits,1);
   639 	CheckPhoneMatchL(K15DigitMatch1,KMatch14Digits,1);
   637 	CheckPhoneMatchL(K15DigitMatch1,KMatch13Digits,2);
   640 	CheckPhoneMatchL(K15DigitMatch1,KMatch13Digits,2);
   638 
   641