/** * Verifies that 15 digit phone numbers are matched correctly. */ LOCAL_C void Test15DigitMatchingL() { ResetDatabaseL(); _LIT(K15DigitTestNumber1,"0086 207 3453 3454"); _LIT(K15DigitTestNumber2,"8186 207 3453 3454"); _LIT(K15DigitTestNumber3,"8620 734 5334 5400"); CreateContactL(KCntName,KCntSurname,K15DigitTestNumber1,KNullDesC); CreateContactL(KCntName,KCntSurname,K15DigitTestNumber2,KNullDesC); CreateContactL(KCntName,KCntSurname,K15DigitTestNumber3,KNullDesC); //Match numbers _LIT(K15DigitMatch1,"0086 207 3453 3454"); _LIT(K15DigitMatch2,"86 207 3453 3454"); _LIT(K15DigitMatch3,"8186 207 3453 3454"); _LIT(K15DigitMatch4,"08186 207 3453 3454"); CheckPhoneMatchL(K15DigitMatch1,KMatch15Digits,1); CheckPhoneMatchL(K15DigitMatch1,KMatch14Digits,1); CheckPhoneMatchL(K15DigitMatch1,KMatch13Digits,2); CheckPhoneMatchL(K15DigitMatch2,KMatch13Digits,2); CheckPhoneMatchL(K15DigitMatch3,KMatch15Digits,1); CheckPhoneMatchL(K15DigitMatch4,KMatch16Digits,1); CheckPhoneMatchL(K15DigitMatch4,KMatch15Digits,1); }
LOCAL_D TLogContactItemId TestMatchContactL(CLogCntModel* aCntModel) { // Read back a contact Id using the plugin interface, should be null TLogContactItemId contactId = KLogNullContactId; if(!OomTesting) theTest.Next(_L("@SYMTESTCaseID:PIM-APPENG-CNTMODEL-EC021-CIT-0003 Check that correct id read back when no contact exists using contact matching plugin")); TRAPD(err, contactId=aCntModel->MatchPhoneNumberL(KNumber1, 7)); if(OomTesting && err==KErrNoMemory) User::Leave(KErrNoMemory); TEST(KErrNone==err); TEST2(contactId,KLogNullContactId); // Create a contact if(!OomTesting) theTest.Next(_L("Create a test entry to match")); TLogContactItemId id1 = CreateContactL(KFirstName1, KLastName1, KNumber1); // Read back the contact Id using the plugin interface contactId = KLogNullContactId; if(!OomTesting) theTest.Next(_L("Check that correct id read back using contact matching plugin")); TRAP(err, contactId=aCntModel->MatchPhoneNumberL(KNumber1, 7)); if(OomTesting && err==KErrNoMemory) User::Leave(KErrNoMemory); TEST(KErrNone==err); TEST2(id1,contactId); return contactId; }
// Regression testcode for // DUG-4ZVNBW "MatchPhoneNumberL doesn't match correctly without CNTPHONE.DLL" // // Remove CNTPHONE.DLL before running this test to verify // LOCAL_C void TestNoPhoneMatchLibraryL() { ResetDatabaseL(); _LIT(KCntNumberWithSpaces,"+44 020 7563 2000"); _LIT(KCntNumberWithoutSpaces,"02075632000"); CreateContactL(KCntName,KCntSurname,KCntNumberWithSpaces,KNullDesC); CheckPhoneMatchL(KCntNumberWithoutSpaces,KMatch7Digits,1); }
/** * Verifies that matching of 11-digit phone number matching works correctly */ LOCAL_C void Test11DigitMatchingL() { ResetDatabaseL(); _LIT(K11DigitTestNumber1,"20 7582 24220"); _LIT(K11DigitTestNumber2,"020 7582 2422"); _LIT(K11DigitTestNumber3,"020 7582 2381"); _LIT(K11DigitTestNumber4,"120 7582 2381"); _LIT(K11DigitTestNumber5,"9120 7582 2381"); CreateContactL(KCntName,KCntSurname,K11DigitTestNumber1,KNullDesC); CreateContactL(KCntName,KCntSurname,K11DigitTestNumber2,KNullDesC); CreateContactL(KCntName,KCntSurname,K11DigitTestNumber3,KNullDesC); CreateContactL(KCntName,KCntSurname,K11DigitTestNumber4,KNullDesC); CreateContactL(KCntName,KCntSurname,K11DigitTestNumber5,KNullDesC); //Match numbers _LIT(K11DigitMatch1,"020 7582 2422"); _LIT(K11DigitMatch2,"20 7582 24220"); _LIT(K11DigitMatch3,"020 7582 2381"); _LIT(K11DigitMatch4,"120 7582 2381"); _LIT(K11DigitMatch5,"9120 7582 2381"); _LIT(K11DigitMatch6,"20 7582 2381"); CheckPhoneMatchL(K11DigitMatch1,KMatch10Digits,1); CheckPhoneMatchL(K11DigitMatch1,KMatch11Digits,1); CheckPhoneMatchL(K11DigitMatch2,KMatch10Digits,1); CheckPhoneMatchL(K11DigitMatch2,KMatch11Digits,1); CheckPhoneMatchL(K11DigitMatch3,KMatch10Digits,3); CheckPhoneMatchL(K11DigitMatch3,KMatch11Digits,1); CheckPhoneMatchL(K11DigitMatch4,KMatch10Digits,3); CheckPhoneMatchL(K11DigitMatch4,KMatch11Digits,2); CheckPhoneMatchL(K11DigitMatch5,KMatch12Digits,1); CheckPhoneMatchL(K11DigitMatch5,KMatch13Digits,1); CheckPhoneMatchL(K11DigitMatch6,KMatch10Digits,3); CheckPhoneMatchL(K11DigitMatch6,KMatch11Digits,1); }
LOCAL_D void TestMultiContactMatchL(CLogCntModel* aCntModel) { // Check that NULL Id is returned for phone number with > 1 contact if(!OomTesting) theTest.Next(_L("@SYMTESTCaseID:PIM-APPENG-CNTMODEL-EC021-CIT-0006 Test contacts matching for a phone number with multiple contacts defined")); // Create another contact with the same number (void)CreateContactL(KFirstName2, KLastName2, KNumber1); aCntModel->OpenContactsL(); TLogContactItemId contactId=KLogNullContactId; TRAPD(err, contactId=aCntModel->MatchPhoneNumberL(KNumber1, 7)); if(OomTesting && err==KErrNoMemory) User::Leave(KErrNoMemory); TEST(KErrNone==err); // Check no contact is returned TEST(KLogNullContactId==contactId); }
//as the porting on SQLite database allows the thorough DC break and //doesn't support the feature of database update from old database on //Symbian DBMS. void TestDbUpdateL() { RPIMTestServer serv; User::LeaveIfError(serv.Connect()); serv.CopyFileL(KSrcDatabaseName, KDatabaseName); serv.Close(); // Contact model must open and upgrade database test.Printf(_L("Opening and upgrading database\n")); CContactDatabase* db = NULL; db = CContactDatabase::OpenL(KDatabaseOpenName); // Add a contact with a 15 digit phone number and match the same number _LIT(K15DigitTestNumber,"0086 207 3453 1212"); _LIT(K15DigitMatch,"0086 207 3453 1212"); CreateContactL(KCntName,KCntSurname,K15DigitTestNumber,KNullDesC); CheckPhoneMatchL(K15DigitMatch,KMatch15Digits,1); delete db; db = NULL; }
/** * Verifies that phone numbers are matched correctly if they * have leading, trailing and embedded zeroes. */ LOCAL_C void TestEmbeddedZeroesL() { ResetDatabaseL(); _LIT(KEmbeddedZeroesTestNumber1,"9999 9990 0999 999"); _LIT(KEmbeddedZeroesTestNumber2,"9000 0000 0000 000"); _LIT(KEmbeddedZeroesTestNumber3,"0000 0000 0000 000"); _LIT(KEmbeddedZeroesTestNumber4,"0000 0000 0000 009"); _LIT(KEmbeddedZeroesTestNumber5,"9 9000 000"); _LIT(KEmbeddedZeroesTestNumber6,"9000 000"); CreateContactL(KCntName,KCntSurname,KEmbeddedZeroesTestNumber1,KNullDesC); CreateContactL(KCntName,KCntSurname,KEmbeddedZeroesTestNumber2,KNullDesC); CreateContactL(KCntName,KCntSurname,KEmbeddedZeroesTestNumber3,KNullDesC); CreateContactL(KCntName,KCntSurname,KEmbeddedZeroesTestNumber4,KNullDesC); CreateContactL(KCntName,KCntSurname,KEmbeddedZeroesTestNumber5,KNullDesC); CreateContactL(KCntName,KCntSurname,KEmbeddedZeroesTestNumber6,KNullDesC); //Match numbers _LIT(KEmbeddedZeroMatch1,"9999 9990 0999 999"); _LIT(KEmbeddedZeroMatch2,"9000 0000 0000 000"); _LIT(KEmbeddedZeroMatch3,"0000 0000 0000 000"); _LIT(KEmbeddedZeroMatch4,"0000 0000 0000 009"); _LIT(KEmbeddedZeroMatch5,"9 9000 000"); _LIT(KEmbeddedZeroMatch6,"9000 000"); _LIT(KEmbeddedZeroMatch7,"0000 000"); CheckPhoneMatchL(KEmbeddedZeroMatch1,KMatch15Digits,1); CheckPhoneMatchL(KEmbeddedZeroMatch2,KMatch15Digits,1); CheckPhoneMatchL(KEmbeddedZeroMatch3,KMatch15Digits,1); CheckPhoneMatchL(KEmbeddedZeroMatch4,KMatch15Digits,1); CheckPhoneMatchL(KEmbeddedZeroMatch5,KMatch15Digits,1); CheckPhoneMatchL(KEmbeddedZeroMatch5,KMatch8Digits,1); CheckPhoneMatchL(KEmbeddedZeroMatch6,KMatch7Digits,2); CheckPhoneMatchL(KEmbeddedZeroMatch7,KMatch7Digits,1); CheckPhoneMatchL(KEmbeddedZeroMatch6,KMatch6Digits,2); }
/** @SYMTestCaseID PIM-APPENG-CNTMODEL-EC021-CIT-0011 @SYMTestCaseDesc Performance measurement test @SYMTestType CIT @SYMTestPriority High @SYMTestActions Make 100 calls to all the interface methods and report the average time for each call. @SYMTestExpectedResults No errors should occur. The average time taken for all the API’s should be printed to epocwind.out. @SYMTestStatus Implemented @SYMTestCaseDependencies Plug-in implementation must exist. The contacts DB should contain some contact items for test purposes. @SYMEC EC021 Break dependency of Log engine (Syslibs/Logeng) on Contacts model (App-engines/Cntmodel) */ LOCAL_D void PerformanceTestContactMatchingPluginL() { TIMERINSTALL; TInt i; // Delete the contacts DB so when we open it teh 1st time the DB will be created theTest.Printf(_L("Delete the contacts DB\n")); TRAPD(err, CContactDatabase::DeleteDefaultFileL()); TEST(err == KErrNone || err == KErrNotFound); CLogCntModel *cntModel=NULL; for (i = 0; i < KMaxIterations; i++) { TIMERSTART; // Don't trap open, want the load time only cntModel=CLogCntModel::NewL(); TIMERSTOP; TIMERPRINT; // Delete to allow next create delete cntModel; } theTest.Printf(_L("Average: Plugin load (us) %08d\n"), TIMERAVERAGE); // Load the plug-in for the rest of the test cntModel=CLogCntModel::NewL(); CleanupStack::PushL(cntModel); TIMERRESET; TIMERSTART; // Open contacts DB - this will create the DB because it doesn't exist cntModel->OpenContactsL(); TIMERSTOP; theTest.Printf(_L("First open of contacts DB (us) %08d\n"), delta); // Close DB so we can reopen it in the test below. cntModel->CloseContacts(); TIMERRESET; for (i = 0; i < KMaxIterations; i++) { TIMERSTART; // Don't trap open, want the load time only cntModel->OpenContactsL(); TIMERSTOP; TIMERPRINT; // Close to allow next open cntModel->CloseContacts(); } theTest.Printf(_L("Average: Open contacts DB (us) %08d\n"), TIMERAVERAGE); // Open the contacts DB for the rest of the test. cntModel->OpenContactsL(); // Create a contact TLogContactItemId id1 = CreateContactL(KFirstName1, KLastName1, KNumber1); // Setup buffer to contain concatenated result TBuf<128> buf; // Separator TBufC<2> separator(KRemotePartyNameSeparator); // Get average time to read the contact Id using the plugin interface TIMERRESET; for (i = 0; i < KMaxIterations; i++) { TLogContactItemId contactId; TIMERSTART; contactId=cntModel->MatchPhoneNumberL(KNumber1, 7); TIMERSTOP; TIMERPRINT; TEST2(id1,contactId); } theTest.Printf(_L("Average: Match phone number (us) %08d\n"), TIMERAVERAGE); // Get average time to read the text information using the plugin interface TIMERRESET; for (i = 0; i < KMaxIterations; i++) { TIMERSTART; cntModel->ReadContactNameL(id1, buf, ELogWesternFormat); TIMERSTOP; TIMERPRINT; } theTest.Printf(_L("Average: Read contact info (us) %08d\n"), TIMERAVERAGE); // Get average time to close the DB using the plugin interface TIMERRESET; for (i = 0; i < KMaxIterations; i++) { TIMERSTART; cntModel->CloseContacts(); TIMERSTOP; TIMERPRINT; // Reopen to allow next close cntModel->OpenContactsL(); } theTest.Printf(_L("Average: Close contacts DB (us) %08d\n"), TIMERAVERAGE); cntModel->CloseContacts(); CleanupStack::PopAndDestroy(); // cntModel; // Check memory usage for plugin. At this stage ECOM and contacts are running so the HEAP usage // detected by loading the plugin should be just due to the plugin // Save initial heap available size TInt largestBlock; TInt initialSize=User::Heap().Available(largestBlock); // Load plugin and save heap available size cntModel=CLogCntModel::NewL(); TInt size=User::Heap().Available(largestBlock); // Delete the plugin and check that the heap size reverts to the initial size delete cntModel; TEST(initialSize==User::Heap().Available(largestBlock)); // Print heap used by plugin load theTest.Printf(_L("Plugin load uses %08d bytes on the heap\n"), initialSize-size); }
/** Testcode for Graham's new API These all match 1234567: *#42# 0401234567 p123 *#42# +358401234567 p123 *61 0401234567 *61 +358401234567 +358401234567 +3 +358401234567 p123 */ LOCAL_C void TestNewMatchingL() { ResetDatabaseL(); const TInt KLastThreeDigits =3; //These numbers match 1234567 _LIT(KCntDTMFNumber1,"*#42# 0401234567 p123"); _LIT(KCntDTMFNumber2,"*#42#+358401234567 p123"); _LIT(KCntDTMFNumber3,"*61 0401234567"); _LIT(KCntDTMFNumber4,"*61 +358401234567"); _LIT(KCntDTMFNumber5,"+358401234567 +3"); _LIT(KCntDTMFNumber6,"+358401234567 p123"); _LIT(KCntMatch1to7ExtraCharacters,"mobile 12 345-67"); _LIT(KCntMatch1to7Brackets,"(020) 0123-4567"); _LIT(KCntMatch1to7TooManyNumbers,"123456789012345678901234567"); //These shouldn't match 1234567 _LIT(KCntDTMFNumber7,"*#42# 0401234567#p123");//empty _LIT(KCntDTMFNumber8,"*12345+0401234567"); //matches 12345 _LIT(KCntDTMFNumber9,"*+123+456+++++++++++"); //matches 123 //Graham's possible defects _LIT(KCntPossibleDefect,"70000"); _LIT(KCntZeroAtEnd,"020 5632700"); //Match numbers _LIT(KCntMatch1to7,"1234567"); _LIT(KCntMatch1to3,"123"); _LIT(KCntMatch700,"700"); //Spaces at the start _LIT(KCntSpaceInNumber," 0 2 0 7 1 2 0 5 6 7 8 "); _LIT(KCntSpaceMatch,"02071205678"); _LIT(KCntSpaceInNumberIntl," +44 7447 065 472"); _LIT(KCntSpaceInNumberIntlMatch,"+446447065472"); _LIT(KCntSpaceWorstCase," "); _LIT(KCntNoRealDigitsInNumber,"Lycos SMS"); _LIT(KCntShortNumber1,"789"); _LIT(KCntShortNumber2,"456"); _LIT(KCntEndingByShortNumber1,"+44(0)32465764789"); _LIT(KCntEndingByShortNumber2,"+443216568731456"); _LIT(KCntMatchShortNumber1,"789"); // must not match other number ending with 789 _LIT(KCntMatchShortNumber2,"456"); // must not match other number ending with 456 CreateContactL(KCntName,KCntSurname,KCntShortNumber1,KNullDesC); CreateContactL(KCntName,KCntSurname,KCntShortNumber2,KNullDesC); CreateContactL(KCntName,KCntSurname,KCntEndingByShortNumber1,KNullDesC); CreateContactL(KCntName,KCntSurname,KCntEndingByShortNumber2,KNullDesC); CreateContactL(KCntName,KCntSurname,KCntDTMFNumber1,KNullDesC); CreateContactL(KCntName,KCntSurname,KCntDTMFNumber2,KNullDesC); CreateContactL(KCntName,KCntSurname,KCntDTMFNumber3,KNullDesC); CreateContactL(KCntName,KCntSurname,KCntDTMFNumber4,KNullDesC); CreateContactL(KCntName,KCntSurname,KCntDTMFNumber5,KNullDesC); CreateContactL(KCntName,KCntSurname,KCntDTMFNumber6,KNullDesC); CreateContactL(KCntName,KCntSurname,KCntDTMFNumber7,KNullDesC); CreateContactL(KCntName,KCntSurname,KCntDTMFNumber8,KNullDesC); CreateContactL(KCntName,KCntSurname,KCntDTMFNumber9,KNullDesC); CreateContactL(KCntName,KCntSurname,KCntPossibleDefect,KNullDesC); CreateContactL(KCntName,KCntSurname,KCntMatch1to7ExtraCharacters,KNullDesC); CreateContactL(KCntName,KCntSurname,KCntMatch1to7Brackets,KNullDesC); CreateContactL(KCntName,KCntSurname,KCntMatch1to7TooManyNumbers,KNullDesC); TContactItemId id = CreateContactL(KCntName,KCntSurname,KCntZeroAtEnd,KNullDesC); CheckPhoneMatchL(KCntMatch1to7,KMatch7Digits,9); CheckPhoneMatchL(KCntMatch1to7,KLastThreeDigits,9); // no contact with 567 as phone number CheckPhoneMatchL(KCntMatch1to7,KMatch7Digits,9); CheckPhoneMatchL(KCntMatch1to7,KLastThreeDigits,9); // no contact with 567 as phone number CheckPhoneMatchL(KCntMatch1to3,KMatch7Digits,1); CheckPhoneMatchL(KCntMatch1to3,KMatch7Digits,1); CheckPhoneMatchL(KCntPossibleDefect,KMatch7Digits,1); CheckPhoneMatchL(KCntZeroAtEnd,KMatch7Digits,1); CheckPhoneMatchL(KCntMatch700,KLastThreeDigits,0); // no contact with 700 as phone number at this point CheckPhoneMatchL(KCntZeroAtEnd,KMatch7Digits,1); CheckPhoneMatchL(KCntNoRealDigitsInNumber,KMatch7Digits,0); CheckPhoneMatchL(KCntMatchShortNumber1,KLastThreeDigits,1); // CheckPhoneMatchL(KCntMatchShortNumber2,KLastThreeDigits,1); // // Simulate a synchronisation (increment the access count) CContactItem* item = CntTest->Db()->OpenContactLX(id); item->IncAccessCount(); CntTest->Db()->CommitContactL(*item); CleanupStack::PopAndDestroy(); //lock record delete item; // Delete the contact and verify that it has been removed from the phone match table CntTest->Db()->DeleteContactL(id); CheckPhoneMatchL(KCntZeroAtEnd,KMatch7Digits,0); CreateContactL(KCntName,KCntSurname,KCntSpaceInNumber,KNullDesC); CheckPhoneMatchL(KCntSpaceMatch,KMatch7Digits,1); CreateContactL(KCntName,KCntSurname,KCntSpaceInNumberIntl,KNullDesC); CheckPhoneMatchL(KCntSpaceInNumberIntlMatch,KMatch7Digits,1); CreateContactL(KCntName,KCntSurname,KCntSpaceWorstCase,KNullDesC); }