|
1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32test\window\t_keyrepeat.cpp |
|
15 // Overview: |
|
16 // Test the TRawEvent APIS and events related to keyrepeat |
|
17 // Tests both user and kernel side functions |
|
18 // API Information: |
|
19 // UserSvr, TRawEvent |
|
20 // Details: |
|
21 // Platforms/Drives/Compatibility: |
|
22 // All. |
|
23 // Assumptions/Requirement/Pre-requisites: |
|
24 // Failures and causes: |
|
25 // |
|
26 // |
|
27 |
|
28 #define __E32TEST_EXTENSION__ |
|
29 |
|
30 #include <e32test.h> |
|
31 #include <e32svr.h> |
|
32 #include <e32cmn.h> |
|
33 #include <e32cmn_private.h> |
|
34 #include "d_keyrepeat.h" |
|
35 |
|
36 LOCAL_D RTest test(_L("T_KEYREPEAT")); |
|
37 |
|
38 RTestKeyRepeatLdd gLdd; |
|
39 |
|
40 // default constructor |
|
41 RKeyEvent::RKeyEvent() |
|
42 { |
|
43 } |
|
44 |
|
45 // constructor for RKeyEvent |
|
46 RKeyEvent::RKeyEvent(TStdScanCode aKey, TInt aRepeatCount) |
|
47 : iKey(aKey), iRepeatCount(aRepeatCount) |
|
48 { |
|
49 } |
|
50 |
|
51 void LoadDeviceDriver() |
|
52 { |
|
53 TInt r; |
|
54 |
|
55 r=User::LoadLogicalDevice(KLddName); |
|
56 test_KErrNone(r); |
|
57 |
|
58 r=gLdd.Open(); |
|
59 test_KErrNone(r); |
|
60 } |
|
61 |
|
62 void UnloadDeviceDriver() |
|
63 { |
|
64 TInt r; |
|
65 gLdd.Close(); |
|
66 |
|
67 r = User::FreeLogicalDevice(KLddName); |
|
68 test_KErrNone(r); |
|
69 User::After(100000); |
|
70 } |
|
71 |
|
72 |
|
73 GLDEF_C TInt E32Main() |
|
74 // |
|
75 // |
|
76 { |
|
77 test.Title(); |
|
78 test.Start(_L("Testing user side TRawEvent::SetRepeat and ::Repeats API")); |
|
79 TInt numRepeats=10; |
|
80 |
|
81 // create event objects |
|
82 RKeyEvent theKeyEvent(EStdKeySpace, numRepeats); |
|
83 TRawEvent theEvent; |
|
84 // set repeat |
|
85 theEvent.SetRepeat(TRawEvent::EKeyRepeat, theKeyEvent.iKey, theKeyEvent.iRepeatCount); |
|
86 // send event |
|
87 test_KErrNone(UserSvr::AddEvent(theEvent)); |
|
88 // check repeat value |
|
89 test_Equal(theKeyEvent.iRepeatCount, theEvent.Repeats()); |
|
90 test.Printf(_L("T_KEYREPEAT: USER SIDE TEST Successfully Completed\n")); |
|
91 |
|
92 test.Next(_L("Testing kernel side TRawEvent::SetRepeat and ::Repeats API")); |
|
93 |
|
94 LoadDeviceDriver(); |
|
95 // call kernel side to set repeat values and send the event |
|
96 test_KErrNone(gLdd.SetRepeat(theKeyEvent)); |
|
97 // call kernel side to check that the repeat count was set correctly |
|
98 test_KErrNone(gLdd.Repeats()); |
|
99 |
|
100 UnloadDeviceDriver(); |
|
101 test.Printf(_L("T_KEYREPEAT: KERNEL SIDE TEST Successfully Completed\n")); |
|
102 |
|
103 test.End(); |
|
104 test.Close(); |
|
105 return KErrNone; |
|
106 } |
|
107 |