|
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 <ptilanguage.h> |
|
23 #include <ptidefs.h> |
|
24 |
|
25 #include "BCTestLan.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 CBCTestLanguage* CBCTestLanguage::NewL() |
|
39 { |
|
40 CBCTestLanguage* self = new( ELeave ) CBCTestLanguage(); |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL(); |
|
43 CleanupStack::Pop( self ); |
|
44 return self; |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // C++ default constructor |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CBCTestLanguage::CBCTestLanguage():iLan(NULL) |
|
52 { |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // Destructor |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CBCTestLanguage::~CBCTestLanguage() |
|
60 { |
|
61 Teardown(); |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // Symbian 2nd Constructor |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void CBCTestLanguage::ConstructL() |
|
69 { |
|
70 BuildScriptL(); |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // CBCTestLanguage::BuildScriptL |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 void CBCTestLanguage::BuildScriptL() |
|
78 { |
|
79 // Add script as your need. |
|
80 AddTestL( LeftCBA, |
|
81 REP(Down, 1), |
|
82 KeyOK, TEND ); |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // CBCTestLanguage::RunL |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 void CBCTestLanguage::RunL( TInt aCmd ) |
|
90 { |
|
91 if ( aCmd != EBCTestCmdPtiLanguage) |
|
92 { |
|
93 return; |
|
94 } |
|
95 |
|
96 TestFunctionL(); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CBCTestLanguage::TestLayoutDecorator |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 void CBCTestLanguage::TestFunctionL() |
|
104 { |
|
105 SetupL(); |
|
106 TestL12nL(); |
|
107 TestSetKeyMap(); |
|
108 TestOthers(); |
|
109 } |
|
110 |
|
111 |
|
112 void CBCTestLanguage::SetupL() |
|
113 { |
|
114 iLan = CPtiCoreLanguage::NewL(); |
|
115 AssertNotNullL(iLan, _L("created by NewL")); |
|
116 } |
|
117 |
|
118 void CBCTestLanguage::Teardown() |
|
119 { |
|
120 delete iLan; |
|
121 iLan = NULL; |
|
122 } |
|
123 |
|
124 void CBCTestLanguage::TestSetKeyMap() |
|
125 { |
|
126 iLan->SetKeyMappings(CBCTestKeymap::CreateKeyMapL()); |
|
127 AssertNotNullL(iLan->GetKeymappings(), _L("Key mapping set and got.")); |
|
128 |
|
129 if( CBCTestQwertyMap::ValidQwertyMode() ) |
|
130 { |
|
131 iLan->SetQwertyKeyMappings(CBCTestQwertyMap::CreateKeyMapL()); |
|
132 AssertNotNullL(iLan->GetQwertyKeymappings(), _L("Qwerty key mapping set and got.")); |
|
133 iLan->ClearQwerty(); |
|
134 AssertTrueL(NULL == iLan->GetQwertyKeymappings(), _L("Qwerty key mapping cleared.")); |
|
135 } |
|
136 |
|
137 //clear them all |
|
138 iLan->ClearMultitapping(); |
|
139 AssertTrueL(NULL == iLan->GetKeymappings(), _L("Key mapping cleared.")); |
|
140 } |
|
141 |
|
142 void CBCTestLanguage::TestL12nL() |
|
143 { |
|
144 //short name |
|
145 _LIT(KShortL12nName, "en"); |
|
146 iLan->SetLocalizedName(KShortL12nName); |
|
147 AssertTrueL(iLan->LocalizedNameDes() == KShortL12nName, _L("short i12n name en set and got")); |
|
148 |
|
149 //long name |
|
150 _LIT(KLongL12nName, "English, use in both western Eroup and north America"); |
|
151 iLan->SetLocalizedName(KLongL12nName); |
|
152 TBuf<KMaxLanguageNameLength> cutName; |
|
153 const TDesC& ref = KLongL12nName; |
|
154 cutName.Copy(ref.Left(KMaxLanguageNameLength)); |
|
155 AssertTrueL(iLan->LocalizedNameDes() == cutName, _L("long i12n name set and cut")); |
|
156 |
|
157 //lan code |
|
158 TInt oldCode = iLan->LanguageCode(); |
|
159 iLan->SetLanguageCode(31); // chinese |
|
160 iLan->SetLanguageCode(31); // set same code again |
|
161 AssertIntL(iLan->LanguageCode(), 31, _L("set lan code to 31")); |
|
162 iLan->SetLanguageCode(1); // set another code |
|
163 AssertIntL(iLan->LanguageCode(), 1, _L("set lan code to 1")); |
|
164 iLan->SetLanguageCode(oldCode); // reset |
|
165 } |
|
166 |
|
167 void CBCTestLanguage::TestOthers() |
|
168 { |
|
169 RArray<TInt> inputModes; |
|
170 iLan->GetAvailableInputModesL(inputModes); |
|
171 AssertTrueL(ETrue, _L("available input modes are got into RArray")); |
|
172 inputModes.Close(); |
|
173 |
|
174 CArrayFixFlat<TInt>* modes = new (ELeave) CArrayFixFlat<TInt>(10); |
|
175 CleanupStack::PushL(modes); |
|
176 iLan->GetAvailableInputModesL(modes); |
|
177 AssertTrueL(ETrue, _L("available input modes are got into CArrayFix")); |
|
178 CleanupStack::PopAndDestroy(); // modes |
|
179 |
|
180 iLan->RemoveCore(NULL); |
|
181 AssertTrueL(ETrue, _L("NULL core removed")); |
|
182 } |
|
183 //end of file |