19 #include "ut_logscntentry.h" |
19 #include "ut_logscntentry.h" |
20 #include "logscntentry.h" |
20 #include "logscntentry.h" |
21 #include "logspredictivetranslator.h" |
21 #include "logspredictivetranslator.h" |
22 |
22 |
23 #include <QtTest/QtTest> |
23 #include <QtTest/QtTest> |
|
24 #include "qtcontacts_stubs.h" |
24 |
25 |
25 #define PATTERN( pattern )\ |
26 #define PATTERN( pattern )\ |
26 LogsPredictiveTranslator::instance()->translatePattern( QString( pattern ) ) |
27 LogsPredictiveTranslator::instance()->preparePattern( QString( pattern ) ) |
27 |
28 |
28 |
29 |
29 void UT_LogsCntEntry::initTestCase() |
30 void UT_LogsCntEntry::initTestCase() |
30 { |
31 { |
31 mOrigLang = HbInputSettingProxy::instance()->globalInputLanguage(); |
|
32 |
32 |
33 } |
33 } |
34 |
34 |
35 void UT_LogsCntEntry::cleanupTestCase() |
35 void UT_LogsCntEntry::cleanupTestCase() |
36 { |
36 { |
37 HbInputSettingProxy::instance()->setGlobalInputLanguage( mOrigLang ); |
37 LOGS_CNTFINDER_SET_PHONE_LANGUAGE( QLocale::English ); |
38 |
38 |
39 } |
39 } |
40 |
40 |
41 |
41 |
42 void UT_LogsCntEntry::init() |
42 void UT_LogsCntEntry::init() |
43 { |
43 { |
|
44 LOGS_CNTFINDER_SET_PHONE_LANGUAGE( QLocale::English ); |
44 mEntry = new LogsCntEntry( 0 ); |
45 mEntry = new LogsCntEntry( 0 ); |
45 } |
46 } |
46 |
47 |
47 void UT_LogsCntEntry::cleanup() |
48 void UT_LogsCntEntry::cleanup() |
48 { |
49 { |
49 delete mEntry; |
50 delete mEntry; |
50 mEntry = 0; |
51 mEntry = 0; |
51 LogsPredictiveTranslator::deleteInstance(); |
|
52 HbInputSettingProxy::instance()->setGlobalInputLanguage( mOrigLang ); |
|
53 |
52 |
54 } |
53 } |
55 |
54 |
56 void UT_LogsCntEntry::testConstructor() |
55 void UT_LogsCntEntry::testConstructor() |
57 { |
56 { |
415 |
414 |
416 mEntry->setHighlights( PATTERN( "61" ) ); |
415 mEntry->setHighlights( PATTERN( "61" ) ); |
417 QVERIFY( mEntry->firstName()[0].highlights() == 0); |
416 QVERIFY( mEntry->firstName()[0].highlights() == 0); |
418 QVERIFY( mEntry->firstName()[1].highlights() == 0); |
417 QVERIFY( mEntry->firstName()[1].highlights() == 0); |
419 QVERIFY( mEntry->lastName()[0].highlights() == 0); |
418 QVERIFY( mEntry->lastName()[0].highlights() == 0); |
|
419 |
|
420 mEntry->setFirstName( QString( "Alice M%ing" ) ); |
|
421 mEntry->setHighlights( PATTERN( "6+" ) ); |
|
422 QVERIFY( mEntry->firstName()[0].highlights() == 0); |
|
423 QVERIFY( mEntry->firstName()[1].highlights() == 2); |
|
424 QVERIFY( mEntry->lastName()[0].highlights() == 0); |
|
425 |
|
426 mEntry->setHighlights( PATTERN( "6*" ) ); |
|
427 QVERIFY( mEntry->firstName()[0].highlights() == 0); |
|
428 QVERIFY( mEntry->firstName()[1].highlights() == 2); |
|
429 QVERIFY( mEntry->lastName()[0].highlights() == 0); |
|
430 |
|
431 mEntry->setHighlights( PATTERN( "6#" ) ); |
|
432 QVERIFY( mEntry->firstName()[0].highlights() == 0); |
|
433 QVERIFY( mEntry->firstName()[1].highlights() == 0); |
|
434 QVERIFY( mEntry->lastName()[0].highlights() == 0); |
|
435 |
|
436 mEntry->setHighlights( PATTERN( "6**" ) ); |
|
437 QVERIFY( mEntry->firstName()[0].highlights() == 0); |
|
438 QVERIFY( mEntry->firstName()[1].highlights() == 0); |
|
439 QVERIFY( mEntry->lastName()[0].highlights() == 0); |
|
440 |
|
441 mEntry->setHighlights( PATTERN( "61" ) ); |
|
442 QVERIFY( mEntry->firstName()[0].highlights() == 0); |
|
443 QVERIFY( mEntry->firstName()[1].highlights() == 0); |
|
444 QVERIFY( mEntry->lastName()[0].highlights() == 0); |
|
445 |
420 } |
446 } |
421 |
447 |
422 void UT_LogsCntEntry::testSetPhoneNumber() |
448 void UT_LogsCntEntry::testSetPhoneNumber() |
423 { |
449 { |
424 QString empty(""); |
450 QString empty(""); |
708 QVERIFY( mEntry->match( PATTERN( "002" ) ) ); |
734 QVERIFY( mEntry->match( PATTERN( "002" ) ) ); |
709 QVERIFY( mEntry->match( PATTERN( "0020" ) ) ); |
735 QVERIFY( mEntry->match( PATTERN( "0020" ) ) ); |
710 QVERIFY( !mEntry->match( PATTERN( "00202" ) ) ); |
736 QVERIFY( !mEntry->match( PATTERN( "00202" ) ) ); |
711 QVERIFY( mEntry->match( PATTERN( "0025000000000" ) ) ); |
737 QVERIFY( mEntry->match( PATTERN( "0025000000000" ) ) ); |
712 |
738 |
|
739 mEntry->setFirstName( QString("Alice") ); |
|
740 mEntry->setLastName( QString( "M[ng" ) ); |
|
741 QVERIFY( mEntry->match( PATTERN( "6" ) ) ); |
|
742 QVERIFY( mEntry->match( PATTERN( "6*" ) ) ); |
|
743 QVERIFY( mEntry->match( PATTERN( "6+" ) ) ); |
|
744 QVERIFY( !mEntry->match( PATTERN( "61" ) ) ); |
|
745 |
|
746 |
713 } |
747 } |
714 |
748 |
715 void UT_LogsCntEntry::testStartsWith_latin12k() |
749 void UT_LogsCntEntry::testStartsWith_latin12k() |
716 { |
750 { |
717 //just using numbers as name |
751 //just using numbers as name |
732 |
766 |
733 void UT_LogsCntEntry::testMatch_thai12k() |
767 void UT_LogsCntEntry::testMatch_thai12k() |
734 { |
768 { |
735 |
769 |
736 LogsPredictiveTranslator::deleteInstance(); |
770 LogsPredictiveTranslator::deleteInstance(); |
737 HbInputLanguage thai( QLocale::Thai ); |
771 LOGS_CNTFINDER_SET_PHONE_LANGUAGE( QLocale::Thai ); |
738 HbInputSettingProxy::instance()->setGlobalInputLanguage( thai ); |
772 |
|
773 |
|
774 QEXPECT_FAIL("", "No proper Thai keymap yet", Abort ); |
739 |
775 |
740 mEntry->mType = LogsCntEntry::EntryTypeHistory; |
776 mEntry->mType = LogsCntEntry::EntryTypeHistory; |
741 |
777 |
742 mEntry->setFirstName( QString( "5643" ) ); |
778 mEntry->setFirstName( QString( "5643" ) ); |
743 QVERIFY( !mEntry->match( PATTERN( "" ) ) ); |
779 QVERIFY( !mEntry->match( PATTERN( "" ) ) ); |
747 mEntry->setLastName( QString( "6787" ) ); |
783 mEntry->setLastName( QString( "6787" ) ); |
748 QVERIFY( mEntry->match( PATTERN( "5" ) ) ); |
784 QVERIFY( mEntry->match( PATTERN( "5" ) ) ); |
749 QVERIFY( mEntry->match( PATTERN( "05" ) ) ); |
785 QVERIFY( mEntry->match( PATTERN( "05" ) ) ); |
750 QVERIFY( mEntry->match( PATTERN( "6" ) ) ); |
786 QVERIFY( mEntry->match( PATTERN( "6" ) ) ); |
751 |
787 |
752 QEXPECT_FAIL("", "No proper Thai keymap yet", Abort ); |
|
753 |
788 |
754 QVERIFY( mEntry->match( PATTERN( "*#*#*#*5*#*#*#**#*#" ) ) ); |
789 QVERIFY( mEntry->match( PATTERN( "*#*#*#*5*#*#*#**#*#" ) ) ); |
755 QVERIFY( mEntry->match( PATTERN( "*#*#*****#6" ) ) ); |
790 QVERIFY( mEntry->match( PATTERN( "*#*#*****#6" ) ) ); |
756 QVERIFY( mEntry->match( PATTERN( "06" ) ) ); |
791 QVERIFY( mEntry->match( PATTERN( "06" ) ) ); |
757 |
792 |
767 void UT_LogsCntEntry::testSetHighlights_thai12k() |
802 void UT_LogsCntEntry::testSetHighlights_thai12k() |
768 { |
803 { |
769 QEXPECT_FAIL("", "No proper Thai keymap yet", Abort ); |
804 QEXPECT_FAIL("", "No proper Thai keymap yet", Abort ); |
770 |
805 |
771 LogsPredictiveTranslator::deleteInstance(); |
806 LogsPredictiveTranslator::deleteInstance(); |
772 HbInputLanguage thai( QLocale::Thai ); |
807 LOGS_CNTFINDER_SET_PHONE_LANGUAGE( QLocale::Thai ); |
773 HbInputSettingProxy::instance()->setGlobalInputLanguage( thai ); |
|
774 |
808 |
775 mEntry->mType = LogsCntEntry::EntryTypeHistory; |
809 mEntry->mType = LogsCntEntry::EntryTypeHistory; |
776 mEntry->setFirstName( QString( "5643 456456" ) ); |
810 mEntry->setFirstName( QString( "5643 456456" ) ); |
777 mEntry->setLastName( QString( "6787" ) ); |
811 mEntry->setLastName( QString( "6787" ) ); |
778 |
812 |