uifw/AvKon/tsrc/bc/S60_SDK3.0/bctestptieng/src/bctestpticore.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  test case
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <w32std.h>
       
    20 #include <coecntrl.h>
       
    21 #include <eikenv.h>
       
    22 #include <ptiuids.hrh>
       
    23 #include <ptiuserdicentry.h>
       
    24 
       
    25 #include "BCTestPtiCore.h"
       
    26 #include "BCTestPtiEngcontainer.h"
       
    27 #include "BCTestPtiEng.hrh"
       
    28 #include "streamlogger.h"
       
    29 
       
    30 
       
    31 // ======== MEMBER FUNCTIONS ========
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // Symbian 2nd static Constructor
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CBCTestPtiCore* CBCTestPtiCore::NewL()
       
    38     {
       
    39     CBCTestPtiCore* self = new( ELeave ) CBCTestPtiCore();
       
    40     CleanupStack::PushL( self );
       
    41     self->ConstructL();
       
    42     CleanupStack::Pop( self );
       
    43     return self;
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // C++ default constructor
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CBCTestPtiCore::CBCTestPtiCore():iCore(NULL)
       
    51     {
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // Destructor
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 CBCTestPtiCore::~CBCTestPtiCore()
       
    59     {
       
    60     Teardown();
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // Symbian 2nd Constructor
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 void CBCTestPtiCore::ConstructL()
       
    68     {
       
    69     BuildScriptL();
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CBCTestPtiCore::BuildScriptL
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 void CBCTestPtiCore::BuildScriptL()
       
    77     {
       
    78     // Add script as your need.
       
    79     AddTestL( LeftCBA,
       
    80         REP(Down, 4),
       
    81         KeyOK, TEND );
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // CBCTestPtiCore::RunL
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 void CBCTestPtiCore::RunL( TInt aCmd )
       
    89     {
       
    90     if ( aCmd != EBCTestCmdPtiCore)
       
    91         {
       
    92         return;
       
    93         }
       
    94 
       
    95     TestFunctionL();
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // CBCTestPtiCore::TestLayoutDecorator
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 void CBCTestPtiCore::TestFunctionL()
       
   103     {
       
   104     SetupL();
       
   105     TestGeneralL();
       
   106     TestPredictiveLatinL();
       
   107     TestUserDictL();
       
   108     TestChineseL();
       
   109     TestJapaneseL();
       
   110     }
       
   111 
       
   112 
       
   113 void CBCTestPtiCore::SetupL()
       
   114     {
       
   115     iCore = CPtiCore::CreateCoreL(TUid::Uid(TestListCoreL()));
       
   116     AssertNotNullL(iCore, _L("Pti core create from core list"));
       
   117     }
       
   118 
       
   119 void CBCTestPtiCore::Teardown()
       
   120     {
       
   121     delete iCore;
       
   122     iCore = NULL;
       
   123     }
       
   124 
       
   125 //static
       
   126 TInt CBCTestPtiCore::TestListCoreL()
       
   127     {
       
   128     CArrayFix<TInt>* list = CPtiCore::ListCoresLC();
       
   129     TInt firstUID = (*list)[0] ;
       
   130     CleanupStack::PopAndDestroy();  //list
       
   131     return firstUID;
       
   132     }
       
   133 
       
   134 void CBCTestPtiCore::TestGeneralL()
       
   135     {
       
   136     Teardown();
       
   137     iCore = new (ELeave) MonkCore;
       
   138 
       
   139     AssertIntL(  KErrNotSupported, iCore->Convert(EPtiSimplifiedToComplex, NULL, 0, NULL),
       
   140         _L("Convert hasn't been supported yet"));
       
   141 
       
   142     TPtrC8 dummy(KNullDesC8);
       
   143     AssertTrueL( iCore->SetCurrentInputSequence(dummy) == KErrNotSupported,
       
   144         _L("SetCurrentImputSequence() is not support"));
       
   145 
       
   146     TBuf<5> output;
       
   147     AssertIntL( KErrNotSupported, iCore->GetSpelling('a', output, EPtiStrokes),
       
   148         _L("GetSpelling returns General Err"));
       
   149 
       
   150     _LIT(KNewMapLower, "!@#$");
       
   151     TBuf<5> lowerMap(KNewMapLower);
       
   152     AssertIntL( KErrNotSupported,
       
   153         iCore->SetExternalKeyMapL(EPtiEngineMultitapping, EPtiKey1, lowerMap, EPtiCaseLower),
       
   154         _L("SetExternalKeyMapL hasn't been supported"));
       
   155 
       
   156     AssertIntL( KErrNotSupported, iCore->CommitCurrentWord(),
       
   157         _L("CommitCurrentWord"));
       
   158 
       
   159     AssertTrueL( TPtrC() == iCore->GetCurrentWord(),
       
   160         _L("GetCurrentWord"));
       
   161     }
       
   162 
       
   163 void CBCTestPtiCore::TestPredictiveLatinL()
       
   164     {
       
   165     AssertIntL( 0, iCore->NumberOfCandidates(),
       
   166         _L("NumberOfCandidates not implemented"));
       
   167 
       
   168     CDesCArray* cands = new (ELeave) CDesCArrayFlat(2);
       
   169     CleanupStack::PushL(cands);
       
   170     AssertIntL(KErrNotSupported, iCore->GetCandidateListL(*cands), _L("Get CandidateList not supported"));
       
   171     AssertIntL(KErrNotSupported, iCore->GetNextWordCandidateListL(*cands), _L("Get Next word CandidateList not supported"));
       
   172     CleanupStack::PopAndDestroy();  //cands
       
   173 
       
   174     TBuf<5> res;
       
   175     AssertIntL(KErrNotSupported, iCore->GetFirstCandidate(res), _L("Get first cnadiate not supported"));
       
   176     AssertIntL(KErrNotSupported, iCore->GetNextCandidate(res), _L("Get next cnadiate not supported"));
       
   177     AssertIntL(KErrNotSupported, iCore->GetPreviousCandidate(res), _L("Get prev cnadiate not supported"));
       
   178     }
       
   179 
       
   180 void CBCTestPtiCore::TestUserDictL()
       
   181     {
       
   182     TPtiUserDictionaryEntry entry(_L("foobar"));
       
   183     AssertIntL(KErrNotSupported, iCore->AddUserDictionaryEntry(entry, NULL), _L("Add user dict entry not supported"));
       
   184     AssertIntL(KErrNotSupported, iCore->RemoveUserDictionaryEntry(entry, NULL), _L("Remove user dict entry not supported"));
       
   185     AssertIntL(0, iCore->NumberOfEntriesInUserDictionary(NULL), _L("NumberOfEntries in user dict got"));
       
   186     AssertIntL(KErrNotSupported, iCore->GetUserDictionaryEntry(0, entry, NULL), _L("get user dict entry not supported"));
       
   187     CPtiUserDictionary* dict=iCore->CreateEmptyUserDictionaryL(32);
       
   188     CleanupStack::PushL(dict);
       
   189     AssertNotNullL(dict, _L("Create empty user dict"));
       
   190     AssertIntL(KErrNotSupported, iCore->AttachUserDictionary(dict), _L("attach user dict not supported"));
       
   191     AssertTrueL(!iCore->DetachUserDictionary(dict), _L("detach user dict"));
       
   192     CleanupStack::PopAndDestroy();  //dict
       
   193     }
       
   194 
       
   195 void CBCTestPtiCore::TestChineseL()
       
   196     {
       
   197     AssertTrueL(TPtrC() == iCore->GetCandidatePage(), _L("Get candidate page"));
       
   198     AssertTrueL(!iCore->NextCandidatePage(), _L("no next candidate page"));
       
   199     AssertTrueL(!iCore->PreviousCandidatePage(), _L("no prev candidate page"));
       
   200     AssertTrueL(!iCore->MoreCandidatePages(), _L("no more candidate page"));
       
   201     iCore->SetCandidatePageLength(0);
       
   202     AssertTrueL(ETrue, _L("set cnadidate page length do nothing"));
       
   203     AssertTrueL(TPtrC() == iCore->GetPhoneticSpelling(0), _L("Get phonetic spelling"));
       
   204     AssertIntL(0, iCore->PhoneticSpellingCount(), _L("phonetic spelling count returns 0"));
       
   205     AssertTrueL(!iCore->SelectPhoneticSpelling(0), _L("select phonetic spelling returns false"));
       
   206     AssertIntL(KErrNotSupported, iCore->SelectedPhoneticSpelling(), _L("selected phonetic spelling not supported"));
       
   207     TText mark='a';
       
   208     AssertTrueL(!iCore->ToneMark(mark), _L("tone mark returns false"));
       
   209     AssertTrueL(!iCore->IsToneMarkValidForSpelling(), _L("tone mark is invalid for spelling"));
       
   210     AssertTrueL(!iCore->SetPredictiveChineseChar(_L("")), _L("set predictive chinese char returns false"));
       
   211     AssertTrueL(!iCore->SetToneMark(0), _L("set tone mark returns false"));
       
   212     }
       
   213 
       
   214 void CBCTestPtiCore::TestJapaneseL()
       
   215     {
       
   216     AssertTrueL(TPtrC() == iCore->ReadingTextL(), _L("reading text"));
       
   217     AssertTrueL(NULL == iCore->CompositionData(), _L("composition data got"));
       
   218     }