1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
12 // |
12 // |
13 // Description: |
13 // Description: |
14 // e32test\window\t_keys.cpp |
14 // e32test\window\t_keys.cpp |
15 // |
15 // |
16 // |
16 // |
17 |
17 #define __E32TEST_EXTENSION__ |
18 #include <e32test.h> |
18 #include <e32test.h> |
19 #include <e32hal.h> |
19 #include <e32hal.h> |
20 #include <e32twin.h> |
20 #include <e32twin.h> |
|
21 #include <e32keys.h> |
21 #include <e32svr.h> |
22 #include <e32svr.h> |
22 |
23 |
23 const TBool KEY_UP=ETrue; |
24 const TBool KEY_UP=ETrue; |
24 const TBool KEY_DOWN=EFalse; |
25 const TBool KEY_DOWN=EFalse; |
25 const TBool EXPECT_NO_KEY_PRESS=EFalse; |
26 const TBool EXPECT_NO_KEY_PRESS=EFalse; |
26 const TBool EXPECT_KEY_PRESS=ETrue; |
27 const TBool EXPECT_KEY_PRESS=ETrue; |
|
28 |
|
29 _LIT(REFKDATA, "REFKDATA"); |
27 |
30 |
28 LOCAL_D RTest test(_L("T_KEYS")); |
31 LOCAL_D RTest test(_L("T_KEYS")); |
29 LOCAL_D CKeyTranslator *KeyTranslator; |
32 LOCAL_D CKeyTranslator *KeyTranslator; |
30 LOCAL_D CCaptureKeys *CaptureKeys; |
33 LOCAL_D CCaptureKeys *CaptureKeys; |
31 |
34 |
133 KeyTranslator=CKeyTranslator::New(); |
136 KeyTranslator=CKeyTranslator::New(); |
134 CaptureKeys=new CCaptureKeys(); |
137 CaptureKeys=new CCaptureKeys(); |
135 |
138 |
136 CaptureKeys->Construct(); |
139 CaptureKeys->Construct(); |
137 |
140 |
|
141 |
|
142 test.Printf(_L("Load template EKData dll \n")); // Test with rfkdata.dll |
|
143 TInt res=KeyTranslator->ChangeKeyData(REFKDATA); |
|
144 test_KErrNone(res); |
|
145 |
|
146 /* Test the AddCapture failure case */ |
|
147 TCaptureKey ck; |
|
148 ck.iModifiers.iMask = 11; |
|
149 ck.iModifiers.iValue = 100; |
|
150 ck.iKeyCodePattern.iKeyCode = EKeyNull; |
|
151 ck.iKeyCodePattern.iPattern = EAnyKey; |
|
152 ck.iApp = 111; |
|
153 ck.iHandle = 123; |
|
154 |
|
155 TInt r = KErrNone; |
|
156 TRAP(r, CaptureKeys->AddCaptureKeyL(ck)); |
|
157 test_Equal(r, KErrArgument); |
|
158 |
|
159 /* Test the AddCapture success case */ |
|
160 ck.iModifiers.iMask = 11; |
|
161 ck.iModifiers.iValue = 1; |
|
162 |
|
163 TRAP(r, CaptureKeys->AddCaptureKeyL(ck)); |
|
164 test_KErrNone(r); |
|
165 |
|
166 /* Test the SetCapture case */ |
|
167 TCaptureKey replaceck; |
|
168 replaceck.iModifiers.iMask = 0; |
|
169 replaceck.iModifiers.iValue = 0; |
|
170 replaceck.iKeyCodePattern.iKeyCode = EKeyNull; |
|
171 replaceck.iKeyCodePattern.iPattern = EAnyKey; |
|
172 replaceck.iApp = 222; |
|
173 replaceck.iHandle = 456; |
|
174 |
|
175 /* Test the SetCapture failure case */ |
|
176 CaptureKeys->SetCaptureKey(replaceck.iHandle, ck); |
|
177 |
|
178 /* Test the SetCapture success case */ |
|
179 CaptureKeys->SetCaptureKey(ck.iHandle, replaceck, 0x80); |
|
180 |
|
181 /* Test the Cancelcapture failure case */ |
|
182 CaptureKeys->CancelCaptureKey(ck.iHandle); |
|
183 |
|
184 /* Let us add one more with a different set of mask to test ProcessCaptureKeys */ |
|
185 ck.iModifiers.iMask = 11; |
|
186 ck.iModifiers.iValue = 1; |
|
187 ck.iKeyCodePattern.iKeyCode = EKeyNull; |
|
188 ck.iKeyCodePattern.iPattern = EMatchLeftOrRight+1; |
|
189 ck.iApp = 111; |
|
190 ck.iHandle = 123; |
|
191 |
|
192 TRAP(r, CaptureKeys->AddCaptureKeyL(ck)); |
|
193 test_KErrNone(r); |
|
194 |
|
195 /* Let us add one more with a different set of mask to test ProcessCaptureKeys */ |
|
196 ck.iModifiers.iMask = 11; |
|
197 ck.iModifiers.iValue = 1; |
|
198 ck.iKeyCodePattern.iKeyCode = EKeyNull; |
|
199 ck.iKeyCodePattern.iPattern = EAnyKey; |
|
200 ck.iApp = 333; |
|
201 ck.iHandle = 789; |
|
202 |
|
203 TRAP(r, CaptureKeys->AddCaptureKeyL(ck)); |
|
204 test_KErrNone(r); |
|
205 |
138 TUint scancode=EStdKeyLeftArrow; |
206 TUint scancode=EStdKeyLeftArrow; |
|
207 |
139 // |
208 // |
140 // Test that the special keys pass through and anything after |
209 // Test that the special keys pass through and anything after |
141 // or before raises an error |
210 // or before raises an error |
142 // |
211 // |
143 testConv(_L("First Special key down"),KEY_DOWN,EXPECT_KEY_PRESS,ESpecialKeyBase,ESpecialKeyBase,0); |
212 testConv(_L("First Special key down"),KEY_DOWN,EXPECT_KEY_PRESS,ESpecialKeyBase,ESpecialKeyBase,0); |
257 testAccents('4','E',0xe9); |
326 testAccents('4','E',0xe9); |
258 testAccents('5','A',0xe3); |
327 testAccents('5','A',0xe3); |
259 testAccents('6','E',0xea); |
328 testAccents('6','E',0xea); |
260 |
329 |
261 */ |
330 */ |
|
331 |
|
332 /* Test the CancelAllCaptureKeys failure case */ |
|
333 CaptureKeys->CancelAllCaptureKeys(ck.iApp); |
|
334 |
|
335 /* Test the CancelCaptureKey success case */ |
|
336 CaptureKeys->CancelCaptureKey(replaceck.iHandle); |
|
337 |
|
338 /* Now add a CaptureKey to test CancelAllCaptureKeys success case */ |
|
339 ck.iModifiers.iMask = 11; |
|
340 ck.iModifiers.iValue = 1; |
|
341 ck.iKeyCodePattern.iKeyCode = EKeyNull; |
|
342 ck.iKeyCodePattern.iPattern = EAnyKey; |
|
343 ck.iApp = 111; |
|
344 ck.iHandle = 123; |
|
345 |
|
346 TRAP(r, CaptureKeys->AddCaptureKeyL(ck)); |
|
347 test_KErrNone(r); |
|
348 |
|
349 /* Test CancelAllCaptureKeys success case */ |
|
350 CaptureKeys->CancelAllCaptureKeys(ck.iApp); |
|
351 |
|
352 delete CaptureKeys; |
|
353 |
262 test.End(); |
354 test.End(); |
263 return(KErrNone); |
355 return(KErrNone); |
264 } |
356 } |
265 |
357 |