phonebookengines/contactsmodel/tsrc/cntplsql/src/t_cpcskeymap.cpp
changeset 46 efe85016a067
parent 31 2a11b5b00470
equal deleted inserted replaced
40:b46a585f6909 46:efe85016a067
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Unit test class for testing CPcsKeyMap
    14 * Description:  Unit test class for testing C12keyKeyMap
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // INTERNAL INCLUDES
    18 // INTERNAL INCLUDES
    19 #include "t_cpcskeymap.h"
    19 #include "t_cpcskeymap.h"
    20 #include "cpcskeymap.h"
    20 #include "c12keykeymap.h"
       
    21 #include <QString>
       
    22 #include <QTextCodec>
    21 
    23 
    22 // SYSTEM INCLUDES
    24 // SYSTEM INCLUDES
    23 #include <digia/eunit/eunitmacros.h>
    25 #include <digia/eunit/eunitmacros.h>
    24 #if defined(USE_ORBIT_KEYMAP)
    26 #if defined(USE_ORBIT_KEYMAP)
    25 #include <hbinputkeymapfactory.h>
    27 #include <hbinputkeymapfactory.h>
    26 #endif
    28 #endif
    27 
    29 
       
    30 
       
    31 // 10.1 wk12 SDK's Thai keymap does not map anything to *,# keys
       
    32 // so must use either a hardcoded keymap, or replace the SDK's keymap
       
    33 // with a newer one by copying the keymap file 120.txt to
       
    34 // \epoc32\release\winscw\udeb\z\resource\keymaps
       
    35 
       
    36 /* New Thai keymap, not yet present in the wk12 SDK
       
    37 1   x0E01\x0E02\x0E03\x0E04\x0E05\x0031\t\x0E01\x0E02\x0E03\x0E04\x0E05\x0031"
       
    38 2   x0E06\x0E07\x0E08\x0E09\x0032\t\x0E06\x0E07\x0E08\x0E09\x0032"
       
    39 3   x0E0A\x0E0B\x0E0C\x0E0D\x0033\t\x0E0A\x0E0B\x0E0C\x0E0D\x0033"
       
    40 4   x0E0E\x0E0F\x0E10\x0E11\x0E12\x0E13\x0034\t\x0E0E\x0E0F\x0E10\x0E11\x0E12\x0E13\x0034"
       
    41 5   x0E14\x0E15\x0E16\x0E17\x0E18\x0035\t\x0E14\x0E15\x0E16\x0E17\x0E18\x0035"
       
    42 6   x0E19\x0E1A\x0E1B\x0E1C\x0E1D\x0036\t\x0E19\x0E1A\x0E1B\x0E1C\x0E1D\x0036"
       
    43 7   x0E1E\x0E1F\x0E20\x0E21\x0E22\x0037\t\x0E1E\x0E1F\x0E20\x0E21\x0E22\x0037"
       
    44 8   x0E23\x0E24\x0E25\x0E26\x0E27\x0E28\x0E29\x0038\t\x0E23\x0E24\x0E25\x0E26\x0E27\x0E28\x0E29\x0038"
       
    45 9   x0E2A\x0E2B\x0E2C\x0E2D\x0E2E\x0039\t\x0E2A\x0E2B\x0E2C\x0E2D\x0E2E\x0039"
       
    46 0   0\x21B2\t 0\x21B2"
       
    47 *   x0E2F\x0E3F\x0E31\x0E34\x0E35\x0E36\x0E37\x0E38\x0E39\x0E46\x0E47\x0E48\x0E49\x0E4A\x0E4B\x0E4C\t\x0E2F\x0E3F\x0E31\x0E34\x0E35\x0E36\x0E37\x0E38\x0E39\x0E46\x0E47\x0E48\x0E49\x0E4A\x0E4B\x0E4C"
       
    48 #   x0E30\x0E32\x0E33\x0E40\x0E41\x0E42\x0E43\x0E44\t\x0E30\x0E32\x0E33\x0E40\x0E41\x0E42\x0E43\x0E44" */
       
    49 const TChar KThaiChar0 = 0x21B2; // char from key-0
       
    50 const TChar KThaiChar1 = 0x0E05; // char from key-1
       
    51 const TChar KThaiChar2 = 0x0E06; // char from key-2
       
    52 const TChar KThaiChar3 = 0x0E0A; // char from key-3
       
    53 const TChar KThaiChar4 = 0x0E0E; // char from key-4
       
    54 const TChar KThaiChar5 = 0x0E14; // char from key-5
       
    55 const TChar KThaiChar6 = 0x0E19; // char from key-6
       
    56 const TChar KThaiChar7 = 0x0E1E; // char from key-7
       
    57 const TChar KThaiChar8 = 0x0E23; // char from key-8
       
    58 const TChar KThaiChar9 = 0x0E2A; // char from key-9
       
    59 const TChar KThaiChar10 = 0x0E34; // char from key-*
       
    60 const TChar KThaiChar11 = 0x0E41; // char from key-#
       
    61 
       
    62     
    28 // -----------------------------------------------------------------------------
    63 // -----------------------------------------------------------------------------
    29 // UT_CPcsKeyMap::NewL
    64 // UT_CPcsKeyMap::NewL
    30 // -----------------------------------------------------------------------------
    65 // -----------------------------------------------------------------------------
    31 //
    66 //
    32 UT_CPcsKeyMap* UT_CPcsKeyMap::NewL()
    67 UT_CPcsKeyMap* UT_CPcsKeyMap::NewL()
    76     // It generates the test case table.
   111     // It generates the test case table.
    77     CEUnitTestSuiteClass::ConstructL();
   112     CEUnitTestSuiteClass::ConstructL();
    78     
   113     
    79     
   114     
    80     // When instantiating keymap was moved to here, it removed a resource leak.
   115     // When instantiating keymap was moved to here, it removed a resource leak.
    81     iKeyMap = CPcsKeyMap::NewL();
   116     iKeyMap = C12keyKeyMap::NewL();
       
   117     
       
   118     
       
   119     
       
   120     // EUnit shows that the first call to Thai text codec's canEncode() leaks
       
   121     // 10 cells. That's why we call canEncode() here, so when the actual test
       
   122     // calls canEncode(), the leak no longer happens.
       
   123     const int KThaiLanguage = 2259; // Thai Industrial Standards Institute
       
   124     QTextCodec* thaiCodec = QTextCodec::codecForMib(KThaiLanguage);
       
   125     if (thaiCodec)
       
   126         {
       
   127         thaiCodec->canEncode('a');
       
   128         }
    82     }
   129     }
    83 
   130 
    84 // -----------------------------------------------------------------------------
   131 // -----------------------------------------------------------------------------
    85 // UT_CPcsKeyMap::SetupL
   132 // UT_CPcsKeyMap::SetupL
    86 // -----------------------------------------------------------------------------
   133 // -----------------------------------------------------------------------------
    91     // Create singleton outside actual test cases so that it is not treated as
   138     // Create singleton outside actual test cases so that it is not treated as
    92     // resource leak, since it can't be deleted.
   139     // resource leak, since it can't be deleted.
    93     HbKeymapFactory::instance();
   140     HbKeymapFactory::instance();
    94 #endif
   141 #endif
    95     }
   142     }
    96     
   143 
    97 // -----------------------------------------------------------------------------
   144 // -----------------------------------------------------------------------------
    98 // UT_CPcsKeyMap::Teardown
   145 // UT_CPcsKeyMap::Teardown
    99 // -----------------------------------------------------------------------------
   146 // -----------------------------------------------------------------------------
   100 //
   147 //
   101 void UT_CPcsKeyMap::Teardown()
   148 void UT_CPcsKeyMap::Teardown()
   110 // -----------------------------------------------------------------------------
   157 // -----------------------------------------------------------------------------
   111 //
   158 //
   112 void UT_CPcsKeyMap::UT_NewLL()
   159 void UT_CPcsKeyMap::UT_NewLL()
   113     {
   160     {
   114 #if defined(USE_ORBIT_KEYMAP)
   161 #if defined(USE_ORBIT_KEYMAP)
   115 	// Must be same as in cpcskeymap.cpp
   162 	// Must be same as in c12keykeymap.cpp
   116 	const TInt KAmountOfKeys = 12;
   163 	const TInt KAmountOfKeys = 12;
   117 	// Note that * and # keys do not have mappings in most languages
       
   118     const TInt KAmountOfNumberKeys = 10;
       
   119 
   164 
   120     // Each numeric key has been mapped
   165     // Each numeric key has been mapped
   121     EUNIT_ASSERT_EQUALS( KAmountOfKeys, iKeyMap->iKeyMapping.count() );
   166     EUNIT_ASSERT_EQUALS( KAmountOfKeys, iKeyMap->iKeyMapping.count() );
   122     for (TInt i = 0; i < KAmountOfNumberKeys; ++i)
   167     for (TInt i = 0; i < KAmountOfKeys; ++i)
   123         {
   168         {
   124         EUNIT_ASSERT( iKeyMap->iKeyMapping.at(i).length() > 0 );
   169         EUNIT_ASSERT( iKeyMap->iKeyMapping.at(i).length() > 0 );
   125         }
   170         }
   126 #endif
   171 #endif
   127     }
   172     }
   128 
   173 
   129 // -----------------------------------------------------------------------------
   174 // -----------------------------------------------------------------------------
   130 // UT_CPcsKeyMap::UT_GetNumericKeyStringL
   175 // UT_CPcsKeyMap::UT_GetMappedStringL
   131 // -----------------------------------------------------------------------------
   176 // -----------------------------------------------------------------------------
   132 //
   177 //
   133 void UT_CPcsKeyMap::UT_GetNumericKeyStringL()
   178 void UT_CPcsKeyMap::UT_GetMappedStringL()
   134 	{
   179 	{
   135 	_LIT( KAlpha, "abjqmca" );
   180 	_LIT( KAlpha, "abjqmca" );
   136 	_LIT( KNumeric, "2257622" );
   181 	_LIT( KNumeric, "2257622" );
   137 	HBufC* numericBuf = iKeyMap->GetNumericKeyStringL( KAlpha, ETrue );
   182 	HBufC* numericBuf = iKeyMap->GetMappedStringL( KAlpha );
   138 	CleanupStack::PushL( numericBuf );
   183 	CleanupStack::PushL( numericBuf );
   139 	EUNIT_ASSERT_EQUALS( *numericBuf, KNumeric );
   184 	EUNIT_ASSERT_EQUALS( *numericBuf, KNumeric );
   140 	CleanupStack::PopAndDestroy( numericBuf );
   185 	CleanupStack::PopAndDestroy( numericBuf );
   141 	numericBuf = NULL;
   186 	numericBuf = NULL;
   142 
   187 
   143 	
   188 	
   144 	_LIT( KAlphaOneChar, "m" );
   189 	_LIT( KAlphaOneChar, "m" );
   145 	_LIT( KNumericOneChar, "6" );
   190 	_LIT( KNumericOneChar, "6" );
   146 	numericBuf = iKeyMap->GetNumericKeyStringL( KAlphaOneChar, ETrue );
   191 	numericBuf = iKeyMap->GetMappedStringL( KAlphaOneChar );
   147 	CleanupStack::PushL( numericBuf );
   192 	CleanupStack::PushL( numericBuf );
   148 	EUNIT_ASSERT_EQUALS( *numericBuf, KNumericOneChar );
   193 	EUNIT_ASSERT_EQUALS( *numericBuf, KNumericOneChar );
   149 	CleanupStack::PopAndDestroy( numericBuf );
   194 	CleanupStack::PopAndDestroy( numericBuf );
   150 	numericBuf = NULL;
   195 	numericBuf = NULL;
   151 	
   196 	
   152 
   197 
   153 	_LIT( KAlphaWithSpaces, "kjhgfdsa qwert " );
   198 	_LIT( KAlphaWithSpaces, "kjhgfdsa qwert " );
   154 	_LIT( KNumericWithSpaces, "554433720793780" );	
   199 	_LIT( KNumericWithSpaces, "55443372 79378 " );
   155 	numericBuf = iKeyMap->GetNumericKeyStringL( KAlphaWithSpaces, ETrue );
   200 	numericBuf = iKeyMap->GetMappedStringL( KAlphaWithSpaces );
   156     CleanupStack::PushL( numericBuf );
   201     CleanupStack::PushL( numericBuf );
   157     EUNIT_ASSERT_EQUALS( *numericBuf, KNumericWithSpaces );
   202     EUNIT_ASSERT_EQUALS( *numericBuf, KNumericWithSpaces );
   158     CleanupStack::PopAndDestroy( numericBuf );
   203     CleanupStack::PopAndDestroy( numericBuf );
   159     
   204     
   160     
   205     
   161     _LIT( KAlphaLongString, "adg   1230 0zbzb0 0 e56e101at 00  " );
   206     _LIT( KAlphaLongString, "adg   1230 0zbzb0 0 e56e101at 00  " );
   162     _LIT( KNumericLongString, "2340001230009292000035631012800000" );
   207     _LIT( KNumericLongString, "234   1230 092920 0 356310128 00  " );
   163     numericBuf = iKeyMap->GetNumericKeyStringL( KAlphaLongString, ETrue );
   208     numericBuf = iKeyMap->GetMappedStringL( KAlphaLongString );
   164     CleanupStack::PushL( numericBuf );
   209     CleanupStack::PushL( numericBuf );
   165     EUNIT_ASSERT_EQUALS( *numericBuf, KNumericLongString );
   210     EUNIT_ASSERT_EQUALS( *numericBuf, KNumericLongString );
   166     CleanupStack::PopAndDestroy( numericBuf );
   211     CleanupStack::PopAndDestroy( numericBuf );
   167 	}
   212 	}
   168 
   213 
   169 // -----------------------------------------------------------------------------
   214 // -----------------------------------------------------------------------------
   170 // UT_CPcsKeyMap::UT_GetNumericKeyStringSeparatorL
   215 // UT_CPcsKeyMap::UT_GetMappedStringSeparatorL
   171 // -----------------------------------------------------------------------------
   216 // -----------------------------------------------------------------------------
   172 //
   217 //
   173 void UT_CPcsKeyMap::UT_GetNumericKeyStringSeparatorL()
   218 void UT_CPcsKeyMap::UT_GetMappedStringSeparatorL()
   174     {
   219     {
   175     _LIT( KAlpha, "abjqmca" );
   220     _LIT( KAlpha, "abjqmca" );
   176     _LIT( KNumeric, "2257622" );
   221     _LIT( KNumeric, "2257622" );
   177     HBufC* numericBuf = iKeyMap->GetNumericKeyStringL( KAlpha, EFalse );
   222     HBufC* numericBuf = iKeyMap->GetMappedStringL( KAlpha );
   178     CleanupStack::PushL( numericBuf );
   223     CleanupStack::PushL( numericBuf );
   179     EUNIT_ASSERT_EQUALS( *numericBuf, KNumeric );
   224     EUNIT_ASSERT_EQUALS( *numericBuf, KNumeric );
   180     CleanupStack::PopAndDestroy( numericBuf );
   225     CleanupStack::PopAndDestroy( numericBuf );
   181     numericBuf = NULL;
   226     numericBuf = NULL;
   182 
   227 
   183 
   228 
   184     _LIT( KAlphaOneChar, "m" );
   229     _LIT( KAlphaOneChar, "m" );
   185     _LIT( KNumericOneChar, "6" );
   230     _LIT( KNumericOneChar, "6" );
   186     numericBuf = iKeyMap->GetNumericKeyStringL( KAlphaOneChar, EFalse );
   231     numericBuf = iKeyMap->GetMappedStringL( KAlphaOneChar );
   187     CleanupStack::PushL( numericBuf );
   232     CleanupStack::PushL( numericBuf );
   188     EUNIT_ASSERT_EQUALS( *numericBuf, KNumericOneChar );
   233     EUNIT_ASSERT_EQUALS( *numericBuf, KNumericOneChar );
   189     CleanupStack::PopAndDestroy( numericBuf );
   234     CleanupStack::PopAndDestroy( numericBuf );
   190     numericBuf = NULL;
   235     numericBuf = NULL;
   191     
   236     
   192 
   237 
   193     _LIT( KAlphaWithSpaces, " kjh gfdsa qwert " );
   238     _LIT( KAlphaWithSpaces, " kjh gfdsa qwert " );
   194     _LIT( KNumericWithSpaces, " 554 43372 79378 " ); // The leading space remains
   239     _LIT( KNumericWithSpaces, " 554 43372 79378 " ); // The leading space remains
   195     numericBuf = iKeyMap->GetNumericKeyStringL( KAlphaWithSpaces, EFalse );
   240     numericBuf = iKeyMap->GetMappedStringL( KAlphaWithSpaces );
   196     CleanupStack::PushL( numericBuf );
   241     CleanupStack::PushL( numericBuf );
   197     EUNIT_ASSERT_EQUALS( *numericBuf, KNumericWithSpaces );
   242     EUNIT_ASSERT_EQUALS( *numericBuf, KNumericWithSpaces );
   198     CleanupStack::PopAndDestroy( numericBuf );
   243     CleanupStack::PopAndDestroy( numericBuf );
   199     
   244     
   200 
   245 
   201     _LIT( KAlphaLongString, "adg   1230 0zbzb0 0 e56e101at 00  " );
   246     _LIT( KAlphaLongString, "adg   1230 0zbzb0 0 e56e101at 00  " );
   202     _LIT( KNumericLongString, "234   1230 092920 0 356310128 00  " );  
   247     _LIT( KNumericLongString, "234   1230 092920 0 356310128 00  " );  
   203     numericBuf = iKeyMap->GetNumericKeyStringL( KAlphaLongString, EFalse );
   248     numericBuf = iKeyMap->GetMappedStringL( KAlphaLongString );
   204     CleanupStack::PushL( numericBuf );
   249     CleanupStack::PushL( numericBuf );
   205     EUNIT_ASSERT_EQUALS( *numericBuf, KNumericLongString );
   250     EUNIT_ASSERT_EQUALS( *numericBuf, KNumericLongString );
   206     CleanupStack::PopAndDestroy( numericBuf );
   251     CleanupStack::PopAndDestroy( numericBuf );
   207     }
   252     }
   208 
   253 
   209 // -----------------------------------------------------------------------------
   254 // -----------------------------------------------------------------------------
   210 // UT_CPcsKeyMap::UT_GetNumericKeyStringWithNumbersL
   255 // UT_CPcsKeyMap::UT_GetMappedStringWithNumbersL
   211 // Source string contains numbers
   256 // Source string contains numbers
   212 // -----------------------------------------------------------------------------
   257 // -----------------------------------------------------------------------------
   213 //
   258 //
   214 void UT_CPcsKeyMap::UT_GetNumericKeyStringWithNumbersL()
   259 void UT_CPcsKeyMap::UT_GetMappedStringWithNumbersL()
   215     {
   260     {
   216     _LIT( KAlpha, "11098" );
   261     _LIT( KAlpha, "11098" );
   217     _LIT( KNumeric, "11098" );
   262     _LIT( KNumeric, "11098" );
   218     HBufC* numericBuf = iKeyMap->GetNumericKeyStringL( KAlpha, EFalse );
   263     HBufC* numericBuf = iKeyMap->GetMappedStringL( KAlpha );
   219     CleanupStack::PushL( numericBuf );
   264     CleanupStack::PushL( numericBuf );
   220     EUNIT_ASSERT_EQUALS( *numericBuf, KNumeric );
   265     EUNIT_ASSERT_EQUALS( *numericBuf, KNumeric );
   221     CleanupStack::PopAndDestroy(numericBuf);
   266     CleanupStack::PopAndDestroy(numericBuf);
   222     }
   267     }
   223 
   268 
   224 // -----------------------------------------------------------------------------
   269 // -----------------------------------------------------------------------------
   225 // UT_CPcsKeyMap::UT_GetNumericKeyStringWithSpecialCharactersL
   270 // UT_CPcsKeyMap::UT_GetMappedStringWithSpecialCharactersL
   226 // Source string contains numbers
   271 // Source string contains numbers
   227 // -----------------------------------------------------------------------------
   272 // -----------------------------------------------------------------------------
   228 //
   273 //
   229 void UT_CPcsKeyMap::UT_GetNumericKeyStringWithSpecialCharactersL()
   274 void UT_CPcsKeyMap::UT_GetMappedStringWithSpecialCharactersL()
   230     {
   275     {
   231 	_LIT( KAlpha, " +g-*[#5]?t" );
   276 	_LIT( KAlpha, " +g-*[#5]?t" );
   232 #if defined(USE_ORBIT_KEYMAP)
       
   233 	_LIT( KNumeric, " a41afb5f18" );
   277 	_LIT( KNumeric, " a41afb5f18" );
   234 #else
   278     HBufC* numericBuf = iKeyMap->GetMappedStringL( KAlpha );
   235     _LIT( KNumeric, " a4-a[b5]?8" );
       
   236 #endif
       
   237     HBufC* numericBuf = iKeyMap->GetNumericKeyStringL( KAlpha, EFalse );
       
   238     CleanupStack::PushL( numericBuf );
   279     CleanupStack::PushL( numericBuf );
   239     EUNIT_ASSERT_EQUALS( *numericBuf, KNumeric );
   280     EUNIT_ASSERT_EQUALS( *numericBuf, KNumeric );
   240     CleanupStack::PopAndDestroy(numericBuf);
   281     CleanupStack::PopAndDestroy(numericBuf);
   241     }
   282     }
   242 
   283 
       
   284 // -----------------------------------------------------------------------------
       
   285 // UT_CPcsKeyMap::UT_GetMappedStringThaiLanguageOneCharL
       
   286 // Source string contains one Thai character.
       
   287 // -----------------------------------------------------------------------------
       
   288 //
       
   289 void UT_CPcsKeyMap::UT_GetMappedStringThaiLanguageOneCharL()
       
   290     {
       
   291     HBufC* thaiText = HBufC::NewLC(1);
       
   292     TPtr16 p = thaiText->Des();
       
   293     p.Append(KThaiChar2);
       
   294     _LIT(KNumeric, "2");
       
   295     HBufC* numericBuf = iKeyMap->GetMappedStringL(*thaiText);
       
   296     CleanupStack::PopAndDestroy(thaiText);
       
   297     CleanupStack::PushL(numericBuf);
       
   298     EUNIT_ASSERT_EQUALS(*numericBuf, KNumeric);
       
   299     CleanupStack::PopAndDestroy(numericBuf);
       
   300     
       
   301     
       
   302     QString source;
       
   303     QChar thaiChar3(KThaiChar3);
       
   304     QChar thaiChar5(KThaiChar5);
       
   305     source.append(thaiChar3);
       
   306     source.append(thaiChar5);
       
   307     QString result = iKeyMap->GetMappedString(source);
       
   308     EUNIT_ASSERT(result == "35");
       
   309     }
       
   310 
       
   311 
       
   312 // -----------------------------------------------------------------------------
       
   313 // UT_CPcsKeyMap::UT_GetMappedStringThaiLanguageL
       
   314 // Source string is Thai.
       
   315 // -----------------------------------------------------------------------------
       
   316 //
       
   317 void UT_CPcsKeyMap::UT_GetMappedStringThaiLanguageL()
       
   318     {
       
   319     HBufC* thaiText = HBufC::NewLC(20);
       
   320     TPtr16 p = thaiText->Des();
       
   321     p.Append(KThaiChar10);
       
   322     p.Append(KThaiChar1);
       
   323     p.Append(KThaiChar2);
       
   324     p.Append(KThaiChar3);
       
   325     p.Append(KThaiChar11);
       
   326     p.Append(KThaiChar4);
       
   327     p.Append(KThaiChar5);
       
   328     p.Append(KThaiChar6);
       
   329     p.Append(KThaiChar11);
       
   330     p.Append(KThaiChar10);
       
   331     p.Append(KThaiChar7);
       
   332     p.Append(KThaiChar8);
       
   333     p.Append(KThaiChar9);
       
   334     p.Append(KThaiChar11);
       
   335     // For some reason, the Thai text codec indicates KThaiChar0 as invalid
       
   336     // character, so that's why it is not used here.
       
   337 
       
   338     _LIT(KNumeric, "123456789"); // keys * and # are skipped from result
       
   339     HBufC* numericBuf = iKeyMap->GetMappedStringL(*thaiText);
       
   340     CleanupStack::PopAndDestroy(thaiText);
       
   341     CleanupStack::PushL(numericBuf);
       
   342 
       
   343     EUNIT_ASSERT_EQUALS(*numericBuf, KNumeric);
       
   344     CleanupStack::PopAndDestroy(numericBuf);
       
   345     }
       
   346 
       
   347 // -----------------------------------------------------------------------------
       
   348 // UT_CPcsKeyMap::UT_GetMappedStringThaiLanguageEmptyResultL
       
   349 // Input string only contains characters that map to * and # keys.
       
   350 // -----------------------------------------------------------------------------
       
   351 //
       
   352 void UT_CPcsKeyMap::UT_GetMappedStringThaiLanguageEmptyResultL()
       
   353     {
       
   354     HBufC* thaiText = HBufC::NewLC(20);
       
   355     TPtr16 p = thaiText->Des();
       
   356     p.Append(KThaiChar11);
       
   357     p.Append(KThaiChar10);
       
   358     p.Append(KThaiChar10);
       
   359     p.Append(KThaiChar11);
       
   360     p.Append(KThaiChar11);
       
   361     p.Append(KThaiChar11);
       
   362     p.Append(KThaiChar10);
       
   363     p.Append(KThaiChar11);
       
   364     p.Append(KThaiChar10);
       
   365     p.Append(KThaiChar10);
       
   366     p.Append(KThaiChar11);
       
   367     p.Append(KThaiChar10);
       
   368 
       
   369     HBufC* numericBuf = iKeyMap->GetMappedStringL(*thaiText);
       
   370     CleanupStack::PopAndDestroy(thaiText);
       
   371     CleanupStack::PushL(numericBuf);
       
   372 
       
   373     EUNIT_ASSERT_EQUALS(*numericBuf, KNullDesC);
       
   374     CleanupStack::PopAndDestroy(numericBuf);
       
   375     }
       
   376 
       
   377 // -----------------------------------------------------------------------------
       
   378 // UT_CPcsKeyMap::UT_GetNumericLimitsL
       
   379 // -----------------------------------------------------------------------------
       
   380 //
       
   381 void UT_CPcsKeyMap::UT_GetNumericLimitsL()
       
   382 	{
       
   383 	QString lowerLimit;
       
   384 	QString upperLimit;
       
   385 	TInt err = iKeyMap->GetNumericLimits("123", lowerLimit, upperLimit);
       
   386 	QString expectedLowerLimit("81909218222800895");
       
   387 	QString expectedUpperLimit("82190693199511552");
       
   388 	EUNIT_ASSERT(lowerLimit == expectedLowerLimit);
       
   389 	EUNIT_ASSERT(upperLimit == expectedUpperLimit);
       
   390 	}
       
   391 
       
   392 // -----------------------------------------------------------------------------
       
   393 // UT_CPcsKeyMap::UT_GetNumericLimitsLongInputL
       
   394 // -----------------------------------------------------------------------------
       
   395 //
       
   396 void UT_CPcsKeyMap::UT_GetNumericLimitsLongInputL()
       
   397     {
       
   398     QString lowerLimit;
       
   399     QString upperLimit;
       
   400     TInt err = iKeyMap->GetNumericLimits("1234567890ab123456789", lowerLimit, upperLimit);
       
   401     QString expectedLowerLimit("81985529205928226");
       
   402     QString expectedUpperLimit("81985529205928228");
       
   403     EUNIT_ASSERT(lowerLimit == expectedLowerLimit);
       
   404     EUNIT_ASSERT(upperLimit == expectedUpperLimit);
       
   405     }
       
   406 
   243 
   407 
   244 //  TEST TABLE
   408 //  TEST TABLE
   245 
   409 
   246 EUNIT_BEGIN_TEST_TABLE(
   410 EUNIT_BEGIN_TEST_TABLE(
   247     UT_CPcsKeyMap,
   411     UT_CPcsKeyMap,
   254     "NewL",
   418     "NewL",
   255     "FUNCTIONALITY",
   419     "FUNCTIONALITY",
   256     SetupL, UT_NewLL, Teardown )
   420     SetupL, UT_NewLL, Teardown )
   257 
   421 
   258 EUNIT_TEST(
   422 EUNIT_TEST(
   259     "GetNumericKeyString - test ",
   423     "GetMappedString - test ",
   260     "UT_CPcsKeyMap",
   424     "UT_CPcsKeyMap",
   261     "GetNumericKeyString",
   425     "GetMappedStringL",
   262     "FUNCTIONALITY",
   426     "FUNCTIONALITY",
   263     SetupL, UT_GetNumericKeyStringL, Teardown )
   427     SetupL, UT_GetMappedStringL, Teardown )
   264 
   428 
   265 EUNIT_TEST(
   429 EUNIT_TEST(
   266     "GetNumericKeyString - test separator",
   430     "GetMappedString - test separator",
   267     "UT_CPcsKeyMap",
   431     "UT_CPcsKeyMap",
   268     "GetNumericKeyString",
   432     "GetMappedStringL",
   269     "FUNCTIONALITY",
   433     "FUNCTIONALITY",
   270     SetupL, UT_GetNumericKeyStringSeparatorL, Teardown )
   434     SetupL, UT_GetMappedStringSeparatorL, Teardown )
   271 
   435 
   272 EUNIT_TEST(
   436 EUNIT_TEST(
   273     "GetNumericKeyString - test numbers",
   437     "GetMappedString - test numbers",
   274     "UT_CPcsKeyMap",
   438     "UT_CPcsKeyMap",
   275     "GetNumericKeyString",
   439     "GetMappedStringL",
   276     "FUNCTIONALITY",
   440     "FUNCTIONALITY",
   277     SetupL, UT_GetNumericKeyStringWithNumbersL, Teardown )
   441     SetupL, UT_GetMappedStringWithNumbersL, Teardown )
   278 
   442 
   279 EUNIT_TEST(
   443 EUNIT_TEST(
   280     "GetNumericKeyString - test special characters",
   444     "GetMappedString - test special characters",
   281     "UT_CPcsKeyMap",
   445     "UT_CPcsKeyMap",
   282     "GetNumericKeyString",
   446     "GetMappedStringL",
   283     "FUNCTIONALITY",
   447     "FUNCTIONALITY",
   284     SetupL, UT_GetNumericKeyStringWithSpecialCharactersL, Teardown )
   448     SetupL, UT_GetMappedStringWithSpecialCharactersL, Teardown )
       
   449 
       
   450 EUNIT_TEST(
       
   451     "GetMappedString - Thai, test one character input",
       
   452     "UT_CPcsKeyMap",
       
   453     "GetMappedStringL",
       
   454     "FUNCTIONALITY",
       
   455     SetupL, UT_GetMappedStringThaiLanguageOneCharL, Teardown )
       
   456 
       
   457 EUNIT_TEST(
       
   458     "GetMappedString - test Thai language",
       
   459     "UT_CPcsKeyMap",
       
   460     "GetMappedStringL",
       
   461     "FUNCTIONALITY",
       
   462     SetupL, UT_GetMappedStringThaiLanguageL, Teardown )
       
   463 
       
   464 EUNIT_TEST(
       
   465     "GetMappedString - Thai, empty result",
       
   466     "UT_CPcsKeyMap",
       
   467     "GetMappedStringL",
       
   468     "FUNCTIONALITY",
       
   469     SetupL, UT_GetMappedStringThaiLanguageEmptyResultL, Teardown )
       
   470 
       
   471 EUNIT_TEST(
       
   472     "GetNumericLimits",
       
   473     "UT_CPcsKeyMap",
       
   474     "GetNumericLimits",
       
   475     "FUNCTIONALITY",
       
   476     SetupL, UT_GetNumericLimitsL, Teardown )
       
   477 
       
   478 EUNIT_TEST(
       
   479     "GetNumericLimits - too long input",
       
   480     "UT_CPcsKeyMap",
       
   481     "GetNumericLimits",
       
   482     "FUNCTIONALITY",
       
   483     SetupL, UT_GetNumericLimitsLongInputL, Teardown )
   285 
   484 
   286 EUNIT_END_TEST_TABLE
   485 EUNIT_END_TEST_TABLE
   287 
   486 
   288 //  END OF FILE
   487 //  END OF FILE