|
20 | 20 |
|
21 | 21 | #include "InputMapperTest.h" |
22 | 22 | #include "InterfaceMocks.h" |
| 23 | +#include "TestEventMatchers.h" |
23 | 24 |
|
24 | 25 | #define TAG "KeyboardInputMapper_test" |
25 | 26 |
|
26 | 27 | namespace android { |
27 | 28 |
|
28 | 29 | using testing::_; |
| 30 | +using testing::AllOf; |
29 | 31 | using testing::Args; |
30 | 32 | using testing::DoAll; |
31 | 33 | using testing::Return; |
32 | 34 | using testing::SetArgPointee; |
| 35 | +using testing::VariantWith; |
33 | 36 |
|
34 | 37 | /** |
35 | 38 | * Unit tests for KeyboardInputMapper. |
@@ -86,4 +89,24 @@ TEST_F(KeyboardInputMapperUnitTest, KeyPressTimestampRecorded) { |
86 | 89 | } |
87 | 90 | } |
88 | 91 |
|
| 92 | +TEST_F(KeyboardInputMapperUnitTest, RepeatEventsDiscarded) { |
| 93 | + std::list<NotifyArgs> args; |
| 94 | + args += process(ARBITRARY_TIME, EV_KEY, KEY_0, 1); |
| 95 | + args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0); |
| 96 | + |
| 97 | + args += process(ARBITRARY_TIME, EV_KEY, KEY_0, 2); |
| 98 | + args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0); |
| 99 | + |
| 100 | + args += process(ARBITRARY_TIME, EV_KEY, KEY_0, 0); |
| 101 | + args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0); |
| 102 | + |
| 103 | + EXPECT_THAT(args, |
| 104 | + ElementsAre(VariantWith<NotifyKeyArgs>(AllOf(WithKeyAction(AKEY_EVENT_ACTION_DOWN), |
| 105 | + WithKeyCode(AKEYCODE_0), |
| 106 | + WithScanCode(KEY_0))), |
| 107 | + VariantWith<NotifyKeyArgs>(AllOf(WithKeyAction(AKEY_EVENT_ACTION_UP), |
| 108 | + WithKeyCode(AKEYCODE_0), |
| 109 | + WithScanCode(KEY_0))))); |
| 110 | +} |
| 111 | + |
89 | 112 | } // namespace android |
0 commit comments