OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <errno.h> | 5 #include <errno.h> |
6 #include <fcntl.h> | 6 #include <fcntl.h> |
7 #include <linux/input.h> | 7 #include <linux/input.h> |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | |
14 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
16 #include "base/posix/eintr_wrapper.h" | 15 #include "base/posix/eintr_wrapper.h" |
17 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
18 #include "base/time/time.h" | 17 #include "base/time/time.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "ui/events/devices/device_data_manager.h" | 19 #include "ui/events/devices/device_data_manager.h" |
21 #include "ui/events/event_switches.h" | |
22 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" | 20 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" |
23 #include "ui/events/ozone/evdev/touch_evdev_types.h" | |
24 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h" | 21 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h" |
25 #include "ui/events/ozone/evdev/touch_noise/touch_noise_filter.h" | |
26 #include "ui/events/ozone/evdev/touch_noise/touch_noise_finder.h" | |
27 #include "ui/events/platform/platform_event_dispatcher.h" | 22 #include "ui/events/platform/platform_event_dispatcher.h" |
28 #include "ui/events/platform/platform_event_source.h" | 23 #include "ui/events/platform/platform_event_source.h" |
29 | 24 |
30 namespace ui { | |
31 | |
32 namespace { | 25 namespace { |
33 | 26 |
34 static int SetNonBlocking(int fd) { | 27 static int SetNonBlocking(int fd) { |
35 int flags = fcntl(fd, F_GETFL, 0); | 28 int flags = fcntl(fd, F_GETFL, 0); |
36 if (flags == -1) | 29 if (flags == -1) |
37 flags = 0; | 30 flags = 0; |
38 return fcntl(fd, F_SETFL, flags | O_NONBLOCK); | 31 return fcntl(fd, F_SETFL, flags | O_NONBLOCK); |
39 } | 32 } |
40 | 33 |
41 const char kTestDevicePath[] = "/dev/input/test-device"; | 34 const char kTestDevicePath[] = "/dev/input/test-device"; |
42 | 35 |
43 } // namespace | 36 } // namespace |
44 | 37 |
| 38 namespace ui { |
| 39 |
45 class MockTouchEventConverterEvdev : public TouchEventConverterEvdev { | 40 class MockTouchEventConverterEvdev : public TouchEventConverterEvdev { |
46 public: | 41 public: |
47 MockTouchEventConverterEvdev(int fd, | 42 MockTouchEventConverterEvdev(int fd, |
48 base::FilePath path, | 43 base::FilePath path, |
49 DeviceEventDispatcherEvdev* dispatcher); | 44 DeviceEventDispatcherEvdev* dispatcher); |
50 ~MockTouchEventConverterEvdev() override {} | 45 ~MockTouchEventConverterEvdev() override {} |
51 | 46 |
52 void ConfigureReadMock(struct input_event* queue, | 47 void ConfigureReadMock(struct input_event* queue, |
53 long read_this_many, | 48 long read_this_many, |
54 long queue_index); | 49 long queue_index); |
55 | 50 |
56 // Actually dispatch the event reader code. | 51 // Actually dispatch the event reader code. |
57 void ReadNow() { | 52 void ReadNow() { |
58 OnFileCanReadWithoutBlocking(read_pipe_); | 53 OnFileCanReadWithoutBlocking(read_pipe_); |
59 base::RunLoop().RunUntilIdle(); | 54 base::RunLoop().RunUntilIdle(); |
60 } | 55 } |
61 | 56 |
62 void Initialize(const EventDeviceInfo& device_info) override {} | 57 void Initialize(const EventDeviceInfo& device_info) override {} |
63 bool Reinitialize() override { return true; } | 58 bool Reinitialize() override { return true; } |
64 | 59 |
65 TouchNoiseFinder* touch_noise_finder() { return touch_noise_finder_.get(); } | |
66 | |
67 private: | 60 private: |
68 int read_pipe_; | 61 int read_pipe_; |
69 int write_pipe_; | 62 int write_pipe_; |
70 | 63 |
71 DISALLOW_COPY_AND_ASSIGN(MockTouchEventConverterEvdev); | 64 DISALLOW_COPY_AND_ASSIGN(MockTouchEventConverterEvdev); |
72 }; | 65 }; |
73 | 66 |
74 class MockDeviceEventDispatcherEvdev : public DeviceEventDispatcherEvdev { | 67 class MockDeviceEventDispatcherEvdev : public DeviceEventDispatcherEvdev { |
75 public: | 68 public: |
76 MockDeviceEventDispatcherEvdev( | 69 MockDeviceEventDispatcherEvdev( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 113 |
121 if (pipe(fds)) | 114 if (pipe(fds)) |
122 PLOG(FATAL) << "failed pipe"; | 115 PLOG(FATAL) << "failed pipe"; |
123 | 116 |
124 EXPECT_FALSE(SetNonBlocking(fds[0]) || SetNonBlocking(fds[1])) | 117 EXPECT_FALSE(SetNonBlocking(fds[0]) || SetNonBlocking(fds[1])) |
125 << "failed to set non-blocking: " << strerror(errno); | 118 << "failed to set non-blocking: " << strerror(errno); |
126 | 119 |
127 read_pipe_ = fds[0]; | 120 read_pipe_ = fds[0]; |
128 write_pipe_ = fds[1]; | 121 write_pipe_ = fds[1]; |
129 | 122 |
130 events_.resize(ui::kNumTouchEvdevSlots); | 123 events_.resize(MAX_FINGERS); |
131 for (size_t i = 0; i < events_.size(); ++i) | |
132 events_[i].slot = i; | |
133 } | 124 } |
134 | 125 |
135 void MockTouchEventConverterEvdev::ConfigureReadMock(struct input_event* queue, | 126 void MockTouchEventConverterEvdev::ConfigureReadMock(struct input_event* queue, |
136 long read_this_many, | 127 long read_this_many, |
137 long queue_index) { | 128 long queue_index) { |
138 int nwrite = HANDLE_EINTR(write(write_pipe_, | 129 int nwrite = HANDLE_EINTR(write(write_pipe_, |
139 queue + queue_index, | 130 queue + queue_index, |
140 sizeof(struct input_event) * read_this_many)); | 131 sizeof(struct input_event) * read_this_many)); |
141 DCHECK(nwrite == | 132 DCHECK(nwrite == |
142 static_cast<int>(sizeof(struct input_event) * read_this_many)) | 133 static_cast<int>(sizeof(struct input_event) * read_this_many)) |
143 << "write() failed, errno: " << errno; | 134 << "write() failed, errno: " << errno; |
144 } | 135 } |
145 | 136 |
| 137 } // namespace ui |
| 138 |
146 // Test fixture. | 139 // Test fixture. |
147 class TouchEventConverterEvdevTest : public testing::Test { | 140 class TouchEventConverterEvdevTest : public testing::Test { |
148 public: | 141 public: |
149 TouchEventConverterEvdevTest() {} | 142 TouchEventConverterEvdevTest() {} |
150 | 143 |
151 // Overridden from testing::Test: | 144 // Overridden from testing::Test: |
152 void SetUp() override { | 145 void SetUp() override { |
153 // Set up pipe to satisfy message pump (unused). | 146 // Set up pipe to satisfy message pump (unused). |
154 int evdev_io[2]; | 147 int evdev_io[2]; |
155 if (pipe(evdev_io)) | 148 if (pipe(evdev_io)) |
(...skipping 20 matching lines...) Expand all Loading... |
176 } | 169 } |
177 | 170 |
178 ui::MockTouchEventConverterEvdev* device() { return device_; } | 171 ui::MockTouchEventConverterEvdev* device() { return device_; } |
179 | 172 |
180 unsigned size() { return dispatched_events_.size(); } | 173 unsigned size() { return dispatched_events_.size(); } |
181 const ui::TouchEventParams& dispatched_event(unsigned index) { | 174 const ui::TouchEventParams& dispatched_event(unsigned index) { |
182 DCHECK_GT(dispatched_events_.size(), index); | 175 DCHECK_GT(dispatched_events_.size(), index); |
183 return dispatched_events_[index]; | 176 return dispatched_events_[index]; |
184 } | 177 } |
185 | 178 |
186 void ClearDispatchedEvents() { | |
187 dispatched_events_.clear(); | |
188 } | |
189 | |
190 private: | 179 private: |
191 base::MessageLoop* loop_; | 180 base::MessageLoop* loop_; |
192 ui::MockTouchEventConverterEvdev* device_; | 181 ui::MockTouchEventConverterEvdev* device_; |
193 scoped_ptr<ui::MockDeviceEventDispatcherEvdev> dispatcher_; | 182 scoped_ptr<ui::MockDeviceEventDispatcherEvdev> dispatcher_; |
194 | 183 |
195 int events_out_; | 184 int events_out_; |
196 int events_in_; | 185 int events_in_; |
197 | 186 |
198 void DispatchCallback(const ui::TouchEventParams& params) { | 187 void DispatchCallback(const ui::TouchEventParams& params) { |
199 dispatched_events_.push_back(params); | 188 dispatched_events_.push_back(params); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 ev1 = dispatched_event(8); | 441 ev1 = dispatched_event(8); |
453 | 442 |
454 EXPECT_EQ(ui::ET_TOUCH_RELEASED, ev1.type); | 443 EXPECT_EQ(ui::ET_TOUCH_RELEASED, ev1.type); |
455 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev1.timestamp); | 444 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev1.timestamp); |
456 EXPECT_EQ(38, ev1.location.x()); | 445 EXPECT_EQ(38, ev1.location.x()); |
457 EXPECT_EQ(102, ev1.location.y()); | 446 EXPECT_EQ(102, ev1.location.y()); |
458 EXPECT_EQ(1, ev1.touch_id); | 447 EXPECT_EQ(1, ev1.touch_id); |
459 EXPECT_FLOAT_EQ(.5f, ev1.pressure); | 448 EXPECT_FLOAT_EQ(.5f, ev1.pressure); |
460 } | 449 } |
461 | 450 |
| 451 TEST_F(TouchEventConverterEvdevTest, TypeA) { |
| 452 ui::MockTouchEventConverterEvdev* dev = device(); |
| 453 |
| 454 struct input_event mock_kernel_queue_press0[] = { |
| 455 {{0, 0}, EV_ABS, ABS_MT_TOUCH_MAJOR, 3}, |
| 456 {{0, 0}, EV_ABS, ABS_MT_PRESSURE, 45}, |
| 457 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 42}, |
| 458 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 51}, |
| 459 {{0, 0}, EV_SYN, SYN_MT_REPORT, 0}, |
| 460 {{0, 0}, EV_ABS, ABS_MT_PRESSURE, 45}, |
| 461 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 61}, |
| 462 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 71}, |
| 463 {{0, 0}, EV_SYN, SYN_MT_REPORT, 0}, |
| 464 {{0, 0}, EV_SYN, SYN_REPORT, 0} |
| 465 }; |
| 466 |
| 467 // Check that two events are generated. |
| 468 dev->ConfigureReadMock(mock_kernel_queue_press0, 10, 0); |
| 469 dev->ReadNow(); |
| 470 EXPECT_EQ(2u, size()); |
| 471 } |
| 472 |
462 TEST_F(TouchEventConverterEvdevTest, Unsync) { | 473 TEST_F(TouchEventConverterEvdevTest, Unsync) { |
463 ui::MockTouchEventConverterEvdev* dev = device(); | 474 ui::MockTouchEventConverterEvdev* dev = device(); |
464 | 475 |
465 struct input_event mock_kernel_queue_press0[] = { | 476 struct input_event mock_kernel_queue_press0[] = { |
466 {{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, 684}, | 477 {{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, 684}, |
467 {{0, 0}, EV_ABS, ABS_MT_TOUCH_MAJOR, 3}, | 478 {{0, 0}, EV_ABS, ABS_MT_TOUCH_MAJOR, 3}, |
468 {{0, 0}, EV_ABS, ABS_MT_PRESSURE, 45}, | 479 {{0, 0}, EV_ABS, ABS_MT_PRESSURE, 45}, |
469 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 42}, | 480 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 42}, |
470 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 51}, {{0, 0}, EV_SYN, SYN_REPORT, 0} | 481 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 51}, {{0, 0}, EV_SYN, SYN_REPORT, 0} |
471 }; | 482 }; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 | 553 |
543 // crbug.com/446939 | 554 // crbug.com/446939 |
544 TEST_F(TouchEventConverterEvdevTest, CheckSlotLimit) { | 555 TEST_F(TouchEventConverterEvdevTest, CheckSlotLimit) { |
545 ui::MockTouchEventConverterEvdev* dev = device(); | 556 ui::MockTouchEventConverterEvdev* dev = device(); |
546 | 557 |
547 struct input_event mock_kernel_queue[] = { | 558 struct input_event mock_kernel_queue[] = { |
548 {{0, 0}, EV_ABS, ABS_MT_SLOT, 0}, | 559 {{0, 0}, EV_ABS, ABS_MT_SLOT, 0}, |
549 {{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, 100}, | 560 {{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, 100}, |
550 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 999}, | 561 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 999}, |
551 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 888}, | 562 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 888}, |
552 {{0, 0}, EV_ABS, ABS_MT_SLOT, ui::kNumTouchEvdevSlots}, | 563 {{0, 0}, EV_ABS, ABS_MT_SLOT, ui::TouchEventConverterEvdev::MAX_FINGERS}, |
553 {{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, 200}, | 564 {{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, 200}, |
554 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 777}, | 565 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 777}, |
555 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 666}, | 566 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 666}, |
556 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | 567 {{0, 0}, EV_SYN, SYN_REPORT, 0}, |
557 }; | 568 }; |
558 | 569 |
559 // Check that one 1 event is generated | 570 // Check that one 1 event is generated |
560 dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0); | 571 dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0); |
561 dev->ReadNow(); | 572 dev->ReadNow(); |
562 EXPECT_EQ(1u, size()); | 573 EXPECT_EQ(1u, size()); |
563 } | 574 } |
564 | |
565 namespace { | |
566 | |
567 // TouchNoiseFilter which: | |
568 // - Considers all events of type |noise_event_type| as noise. | |
569 // - Keeps track of the events that it receives. | |
570 class EventTypeTouchNoiseFilter : public TouchNoiseFilter { | |
571 public: | |
572 explicit EventTypeTouchNoiseFilter(EventType noise_event_type) | |
573 : noise_event_type_(noise_event_type) {} | |
574 ~EventTypeTouchNoiseFilter() override {} | |
575 | |
576 // TouchNoiseFilter: | |
577 void Filter(const std::vector<InProgressTouchEvdev>& touches, | |
578 base::TimeDelta time, | |
579 std::bitset<kNumTouchEvdevSlots>* slots_with_noise) override { | |
580 for (const InProgressTouchEvdev& touch : touches) { | |
581 EventType event_type = EventTypeFromTouch(touch); | |
582 ++counts_[event_type]; | |
583 if (event_type == noise_event_type_) | |
584 slots_with_noise->set(touch.slot); | |
585 } | |
586 } | |
587 | |
588 // Returns the number of received events of |type|. | |
589 size_t num_events(EventType type) const { | |
590 std::map<EventType, size_t>::const_iterator it = counts_.find(type); | |
591 return it == counts_.end() ? 0u : it->second; | |
592 } | |
593 | |
594 private: | |
595 EventType EventTypeFromTouch(const InProgressTouchEvdev& touch) const { | |
596 if (touch.touching) | |
597 return touch.was_touching ? ET_TOUCH_MOVED : ET_TOUCH_PRESSED; | |
598 return touch.was_touching ? ET_TOUCH_RELEASED : ET_UNKNOWN; | |
599 } | |
600 | |
601 EventType noise_event_type_; | |
602 std::map<EventType, size_t> counts_; | |
603 | |
604 DISALLOW_COPY_AND_ASSIGN(EventTypeTouchNoiseFilter); | |
605 }; | |
606 | |
607 } // namespace | |
608 | |
609 class TouchEventConverterEvdevTouchNoiseTest | |
610 : public TouchEventConverterEvdevTest { | |
611 public: | |
612 TouchEventConverterEvdevTouchNoiseTest() {} | |
613 ~TouchEventConverterEvdevTouchNoiseTest() override {} | |
614 | |
615 // Makes the TouchNoiseFinder use |filter| and only |filter| to filter out | |
616 // touch noise. | |
617 void SetTouchNoiseFilter(scoped_ptr<TouchNoiseFilter> filter) { | |
618 TouchNoiseFinder* finder = device()->touch_noise_finder(); | |
619 finder->filters_.clear(); | |
620 finder->filters_.push_back(filter.release()); | |
621 } | |
622 | |
623 // Returns the first of TouchNoiseFinder's filters. | |
624 ui::TouchNoiseFilter* first_filter() { | |
625 TouchNoiseFinder* finder = device()->touch_noise_finder(); | |
626 return finder->filters_.empty() ? nullptr : *finder->filters_.begin(); | |
627 } | |
628 | |
629 // TouchEventConverterEvdevTest: | |
630 void SetUp() override { | |
631 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
632 switches::kExtraTouchNoiseFiltering); | |
633 TouchEventConverterEvdevTest::SetUp(); | |
634 } | |
635 | |
636 private: | |
637 DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdevTouchNoiseTest); | |
638 }; | |
639 | |
640 // Test that if TouchNoiseFinder identifies an event for an in-progress touch as | |
641 // noise, that the event is converted to ET_TOUCH_CANCELLED and that all | |
642 // subsequent events for the in-progress touch are cancelled. | |
643 TEST_F(TouchEventConverterEvdevTouchNoiseTest, TouchNoiseFiltering) { | |
644 struct input_event mock_kernel_queue[] = { | |
645 {{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, 684}, | |
646 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 40}, | |
647 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 41}, | |
648 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | |
649 | |
650 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 42}, | |
651 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 43}, | |
652 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | |
653 | |
654 {{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, -1}, | |
655 {{0, 0}, EV_SYN, SYN_REPORT, 0} | |
656 }; | |
657 | |
658 MockTouchEventConverterEvdev* dev = device(); | |
659 SetTouchNoiseFilter(scoped_ptr<TouchNoiseFilter>( | |
660 new EventTypeTouchNoiseFilter(ET_TOUCH_PRESSED))); | |
661 dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0); | |
662 dev->ReadNow(); | |
663 ASSERT_EQ(0u, size()); | |
664 | |
665 ClearDispatchedEvents(); | |
666 SetTouchNoiseFilter(scoped_ptr<TouchNoiseFilter>( | |
667 new EventTypeTouchNoiseFilter(ET_TOUCH_MOVED))); | |
668 dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0); | |
669 dev->ReadNow(); | |
670 ASSERT_EQ(2u, size()); | |
671 TouchEventParams event0 = dispatched_event(0); | |
672 EXPECT_EQ(ET_TOUCH_PRESSED, event0.type); | |
673 EXPECT_EQ(40, event0.location.x()); | |
674 EXPECT_EQ(41, event0.location.y()); | |
675 EXPECT_EQ(ET_TOUCH_CANCELLED, dispatched_event(1).type); | |
676 | |
677 ClearDispatchedEvents(); | |
678 SetTouchNoiseFilter(scoped_ptr<TouchNoiseFilter>( | |
679 new EventTypeTouchNoiseFilter(ET_TOUCH_RELEASED))); | |
680 dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0); | |
681 dev->ReadNow(); | |
682 ASSERT_EQ(3u, size()); | |
683 event0 = dispatched_event(0); | |
684 EXPECT_EQ(ET_TOUCH_PRESSED, event0.type); | |
685 EXPECT_EQ(40, event0.location.x()); | |
686 EXPECT_EQ(41, event0.location.y()); | |
687 TouchEventParams event1 = dispatched_event(1); | |
688 EXPECT_EQ(ET_TOUCH_MOVED, event1.type); | |
689 EXPECT_EQ(42, event1.location.x()); | |
690 EXPECT_EQ(43, event1.location.y()); | |
691 EXPECT_EQ(ET_TOUCH_CANCELLED, dispatched_event(2).type); | |
692 } | |
693 | |
694 // Test that TouchEventConverterEvdev keeps sending events to | |
695 // TouchNoiseFinder after the touch is canceled. | |
696 TEST_F(TouchEventConverterEvdevTouchNoiseTest, | |
697 DoNotSendTouchCancelsToTouchNoiseFinder) { | |
698 struct input_event mock_kernel_queue[] = { | |
699 {{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, 684}, | |
700 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 40}, | |
701 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 41}, | |
702 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | |
703 | |
704 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 42}, | |
705 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 43}, | |
706 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | |
707 | |
708 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 43}, | |
709 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 44}, | |
710 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | |
711 | |
712 {{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, -1}, | |
713 {{0, 0}, EV_SYN, SYN_REPORT, 0} | |
714 }; | |
715 | |
716 MockTouchEventConverterEvdev* dev = device(); | |
717 SetTouchNoiseFilter(scoped_ptr<TouchNoiseFilter>( | |
718 new EventTypeTouchNoiseFilter(ET_TOUCH_PRESSED))); | |
719 dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0); | |
720 dev->ReadNow(); | |
721 ASSERT_EQ(0u, size()); | |
722 | |
723 EventTypeTouchNoiseFilter* filter = | |
724 static_cast<EventTypeTouchNoiseFilter*>(first_filter()); | |
725 EXPECT_EQ(1u, filter->num_events(ET_TOUCH_PRESSED)); | |
726 EXPECT_EQ(2u, filter->num_events(ET_TOUCH_MOVED)); | |
727 EXPECT_EQ(1u, filter->num_events(ET_TOUCH_RELEASED)); | |
728 } | |
729 | |
730 } // namespace ui | |
OLD | NEW |