uifw/AvKon/tsrc/bc/S60_SDK3.0/bctestptieng/src/bctestlandb.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 <ptilanguagedatabase.h>
       
    23 #include <ptiuids.hrh>
       
    24 
       
    25 #include "BCTestLanDB.h"
       
    26 #include "BCTestPtiEngcontainer.h"
       
    27 #include "BCTestPtiEng.hrh"
       
    28 #include "bctestqwertymap.h"
       
    29 #include "bctestkeymap.h"
       
    30 #include "streamlogger.h"
       
    31 
       
    32 // ======== MEMBER FUNCTIONS ========
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // Symbian 2nd static Constructor
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 CBCTestLanDB* CBCTestLanDB::NewL()
       
    39     {
       
    40     CBCTestLanDB* self = new( ELeave ) CBCTestLanDB();
       
    41     CleanupStack::PushL( self );
       
    42     self->ConstructL();
       
    43     CleanupStack::Pop( self );
       
    44     return self;
       
    45     }
       
    46     
       
    47 // ---------------------------------------------------------------------------
       
    48 // C++ default constructor
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CBCTestLanDB::CBCTestLanDB():iDB(NULL)
       
    52     {    
       
    53     }
       
    54     
       
    55 // ---------------------------------------------------------------------------
       
    56 // Destructor
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CBCTestLanDB::~CBCTestLanDB()
       
    60     {
       
    61     Teardown();
       
    62     }
       
    63     
       
    64 // ---------------------------------------------------------------------------
       
    65 // Symbian 2nd Constructor
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 void CBCTestLanDB::ConstructL()
       
    69     {    
       
    70     BuildScriptL();    
       
    71     }
       
    72     
       
    73 // ---------------------------------------------------------------------------
       
    74 // CBCTestLanDB::BuildScriptL
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 void CBCTestLanDB::BuildScriptL()
       
    78     { 
       
    79     // Add script as your need.   
       
    80     AddTestL( LeftCBA, 
       
    81         REP(Down, 4),
       
    82         KeyOK, TEND );    
       
    83     }
       
    84     
       
    85 // ---------------------------------------------------------------------------
       
    86 // CBCTestLanDB::RunL
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 void CBCTestLanDB::RunL( TInt aCmd )
       
    90     {
       
    91     if ( aCmd != EBCTestCmdLanDB)
       
    92         {
       
    93         return;
       
    94         }
       
    95     
       
    96     TestFunctionL();
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // CBCTestLanDB::TestLayoutDecorator
       
   101 // ---------------------------------------------------------------------------
       
   102 //    
       
   103 void CBCTestLanDB::TestFunctionL()
       
   104     {
       
   105     SetupL();
       
   106     TestDBInfoL();
       
   107     TestImplL();
       
   108 	TestOthersL();
       
   109     }
       
   110     
       
   111 
       
   112 void CBCTestLanDB::SetupL()
       
   113 {
       
   114     // language impl uid(s) are defined in ptiuids.hrh
       
   115     iDB = CPtiLanguageDatabase::CreateDatabaseL(TUid::Uid(EPtiLangImplUidEnglish));
       
   116     AssertNotNullL(iDB, _L("english Pti language base create"));
       
   117 }
       
   118 
       
   119 void CBCTestLanDB::Teardown()
       
   120     {
       
   121     delete iDB;
       
   122 	iDB = NULL;
       
   123     }
       
   124 
       
   125 
       
   126 void CBCTestLanDB::TestImplL()
       
   127 {
       
   128 
       
   129     // #languages
       
   130     AssertTrueL(iDB->NumLanguages() != 0, _L("NumLanguages got"));
       
   131     CERR<<_L("Num of Languages: ")<<iDB->NumLanguages()<<endl<<end;
       
   132 
       
   133     // lan code[]
       
   134     AssertTrueL(iDB->LanguageCode(0)==1, _L("1st lan code got"));
       
   135 
       
   136     // sub lan code[]
       
   137     AssertTrueL(iDB->SubLanguageCode(0)==0, _L("sub lan code at 0 got"));
       
   138     CERR<<_L("sub lan code at 0: ")<<iDB->SubLanguageCode(0)<<endl<<end;
       
   139 
       
   140     // lan data[]
       
   141     AssertTrueL(iDB->LangData(0)==NULL, _L("lan data at 0 got"));
       
   142     AssertTrueL(iDB->LangData(0, NULL)==NULL, _L("lan data at 0 with param NULL got"));
       
   143     
       
   144     //
       
   145     AssertTrueL(iDB->PinyinPhraseData() == NULL, _L("pinyin phrase data got"));
       
   146     AssertTrueL(iDB->ZhuyinPhraseData() == NULL, _L("zhuyin phrase data got"));
       
   147     AssertTrueL(iDB->NativeId(0) == 9, _L("native id at 0 got"));
       
   148     CERR<<_L("nativeID[0]: ")<<iDB->NativeId(0)<<endl<<end;
       
   149 }
       
   150 
       
   151 void CBCTestLanDB::TestDBInfoL()
       
   152     {
       
   153 
       
   154     //language code for uid
       
   155     AssertIntL( CPtiLanguageDatabase::LanguageCodeForUid(EPtiLangImplUidEnglish),
       
   156         ELangEnglish, _L("language code for english is OK"));
       
   157 
       
   158     }
       
   159 
       
   160 // a helper class
       
   161 class CMockLanDB: public CPtiLanguageDatabase
       
   162 	{
       
   163 public:
       
   164 	//
       
   165 	};
       
   166 
       
   167 void CBCTestLanDB::TestOthersL()
       
   168 	{
       
   169 	CMockLanDB* ptr = new (ELeave) CMockLanDB;
       
   170 	CleanupStack::PushL(ptr);
       
   171 
       
   172 	AssertIntL(0, ptr->CoreUID(), _L("Empty CoreUID returned"));
       
   173 
       
   174 	AssertTrueL(ptr->LangData(0)==NULL, _L("Empty LangData1 returned"));
       
   175 
       
   176 	AssertTrueL(ptr->LangData(0, NULL)==NULL, _L("Empty LangData2 returned"));
       
   177 
       
   178 	AssertIntL(0, ptr->LanguageCode(0), _L("Empty Language code returned"));
       
   179 
       
   180 	AssertIntL(0, ptr->NativeId(0), _L("Empty NativeId returned"));
       
   181 
       
   182 	AssertIntL(0, ptr->NumLanguages(), _L("Empty NumLanguages returned"));
       
   183 
       
   184 	CleanupStack::PopAndDestroy();	//ptr;
       
   185 	}
       
   186 //end of file