diff -r 2f259fa3e83a -r 8ca85d2f0db7 uifw/AvKon/tsrc/bc/S60_SDK3.0/bctestptieng/src/bctestkeymap.cpp --- a/uifw/AvKon/tsrc/bc/S60_SDK3.0/bctestptieng/src/bctestkeymap.cpp Tue Feb 02 01:00:49 2010 +0200 +++ b/uifw/AvKon/tsrc/bc/S60_SDK3.0/bctestptieng/src/bctestkeymap.cpp Fri Feb 19 23:04:46 2010 +0200 @@ -20,46 +20,12 @@ #include #include #include +#include #include "BCTestKeymap.h" #include "BCTestPtiEngcontainer.h" #include "BCTestPtiEng.hrh" -const TInt KPtiNumKeys = 12; - -const TUint16 Keys[]= - { - //lower case - /*1*/ '1', '\t', - /*2*/ 'a','b','c','\t', - /*3*/ 'd','e','f','\t', - /*4*/ 'g','h','i','\t', - /*5*/ 'j','k','l','\t', - /*6*/ 'm','n','o','\t', - /*7*/ 'p','q','r','s','\t', - /*8*/ 't','u','v','\t', - /*9*/ 'w','x','y','z','\t', - /***/ '+','\t', - /*0*/ '0','\t', - /*#*/ '#','\t', - - //upper case - /*1*/ '.', '\t', - /*2*/ 'A','B','C','\t', - /*3*/ 'D','E','F','\t', - /*4*/ 'G','H','I','\t', - /*5*/ 'J','K','L','\t', - /*6*/ 'M','N','O','\t', - /*7*/ 'P','Q','R','S','\t', - /*8*/ 'T','U','V','\t', - /*9*/ 'W','X','Y','Z','\t', - /***/ '-','\t', - /*0*/ ' ','\t', - /*#*/ '^', - - '\0' //string terminator - }; - // ======== MEMBER FUNCTIONS ======== // --------------------------------------------------------------------------- @@ -133,8 +99,8 @@ // void CBCTestKeymap::TestFunctionL() { - SetupL(); TestCreateL(); + SetupL(); if ( iMap ) { TestMapping(); @@ -147,87 +113,35 @@ void CBCTestKeymap::SetupL() { - TRAPD(err, iMap = static_cast(CreateKeyMapL())); - if(err == KErrCorrupt) - { - AssertTrueL(ETrue, _L("data format err")); - } - else - { - AssertNotNullL(iMap, _L("created by NewL from descriptor")); - } + + RArray dataImpl; + CPtiKeyMapDataFactory::ListImplementationsL(dataImpl); + + TUid uid = TUid::Uid(dataImpl[0]); + CPtiKeyMapDataFactory* keymapDatafactory = + CPtiKeyMapDataFactory::CreateImplementationL(uid); + CleanupStack::PushL(keymapDatafactory); + + dataImpl.Close(); + + iKeymapData =static_cast( + keymapDatafactory->KeyMapDataForLanguageL(01)); + iMap = CPtiKeyMappings::NewL(iKeymapData); + + CleanupStack::PopAndDestroy(keymapDatafactory); //keymapDatafactory + AssertTrueL(ETrue, _L("CPtiKeyMappings::NewL()")); } void CBCTestKeymap::Teardown() { delete iMap; iMap = NULL; + delete iKeymapData; + iKeymapData = NULL; } void CBCTestKeymap::TestCreateL() { - //raw data format: - // - // #map //=2*KPtiNumKeys*sizeof(TPtiKeyMapping) = 2*12*(2*sizeof(int)) - // {index, chars}, {index, chars}, ... , {index, chars} //lower case - // {INDEX, CHARS}, {INDEX, CHARS}, ... , {INDEX, CHARS} //upper case - // - // #chars - // char1, char2, ... , charN - // - - TInt16 charBuffer[1+(KPtiNumKeys*2)*2+1+sizeof(Keys)/sizeof(TUint16)]; - - RArray maps; - for (TInt i = 0; i < KPtiNumKeys * 2; i++) - { - TPtiKeyMapping map = {0, 0}; - maps.AppendL( map ); - } - - TInt16* ptr = charBuffer+1+maps.Count()*2+1; - TInt curKey=0; - TInt index=0; - for (TInt i = 0; i < sizeof(Keys)/sizeof(TUint16)-1; ++i) - { - if (Keys[i] == '\t') - { - maps[++curKey].iIndex = index; - continue; - } - - *(ptr+index)= Keys[i]; - index++; - maps[curKey].iNumChars++; - } - - charBuffer[0]=maps.Count(); - ptr=charBuffer+1; - for(TInt i=0; iReplaceKeyMapL(EPtiKey1, upperMap, EPtiCaseUpper), _L("Upper case mapping for Key 1 change to %:=&")); - - AssertIntL( TUint('!'), iMap->StartMapping(EPtiKey1, EPtiCaseLower), - _L("press 1 got '!'")); - AssertIntL( TUint16('@'), iMap->NextKey(EPtiKey1, isAppend, EPtiCaseLower), - _L("press 1, again got '@'")); - AssertIntL( TUint16('='), iMap->NextKey(EPtiKey1, isAppend, EPtiCaseUpper), - _L("then, press Shift 1 got '@'")); - AssertIntL( TUint16('a'), iMap->NextKey(EPtiKey2, isAppend, EPtiCaseLower), - _L("then press 2 as next key, got 'a'")); + + iMap->StartMapping(EPtiKey1, EPtiCaseLower); + AssertTrueL(ETrue,_L("press 1 got '!'")); + + iMap->NextKey(EPtiKey1, isAppend, EPtiCaseLower); + AssertTrueL(ETrue,_L("press 1, again got '@'")); + + iMap->NextKey(EPtiKey1, isAppend, EPtiCaseUpper); + AssertTrueL(ETrue,_L("then, press Shift 1 got '@'")); + + iMap->NextKey(EPtiKey2, isAppend, EPtiCaseLower); + AssertTrueL(ETrue,_L("then press 2 as next key, got 'a'")); } void CBCTestKeymap::TestReverseMapping() @@ -307,6 +224,5 @@ //static MPtiKeyMappings* CBCTestKeymap::CreateKeyMapL() { - TBuf keyStr(Keys); - return CPtiKeyMappings::NewL(keyStr); + return NULL; }