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" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
15 #include "base/posix/eintr_wrapper.h" | 16 #include "base/posix/eintr_wrapper.h" |
16 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "ui/events/devices/device_data_manager.h" | 20 #include "ui/events/devices/device_data_manager.h" |
| 21 #include "ui/events/event_switches.h" |
20 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" | 22 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" |
| 23 #include "ui/events/ozone/evdev/touch_evdev_types.h" |
21 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h" | 24 #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" |
22 #include "ui/events/platform/platform_event_dispatcher.h" | 27 #include "ui/events/platform/platform_event_dispatcher.h" |
23 #include "ui/events/platform/platform_event_source.h" | 28 #include "ui/events/platform/platform_event_source.h" |
24 | 29 |
| 30 namespace ui { |
| 31 |
25 namespace { | 32 namespace { |
26 | 33 |
27 static int SetNonBlocking(int fd) { | 34 static int SetNonBlocking(int fd) { |
28 int flags = fcntl(fd, F_GETFL, 0); | 35 int flags = fcntl(fd, F_GETFL, 0); |
29 if (flags == -1) | 36 if (flags == -1) |
30 flags = 0; | 37 flags = 0; |
31 return fcntl(fd, F_SETFL, flags | O_NONBLOCK); | 38 return fcntl(fd, F_SETFL, flags | O_NONBLOCK); |
32 } | 39 } |
33 | 40 |
34 const char kTestDevicePath[] = "/dev/input/test-device"; | 41 const char kTestDevicePath[] = "/dev/input/test-device"; |
35 | 42 |
36 } // namespace | 43 } // namespace |
37 | 44 |
38 namespace ui { | |
39 | |
40 class MockTouchEventConverterEvdev : public TouchEventConverterEvdev { | 45 class MockTouchEventConverterEvdev : public TouchEventConverterEvdev { |
41 public: | 46 public: |
42 MockTouchEventConverterEvdev(int fd, | 47 MockTouchEventConverterEvdev(int fd, |
43 base::FilePath path, | 48 base::FilePath path, |
44 DeviceEventDispatcherEvdev* dispatcher); | 49 DeviceEventDispatcherEvdev* dispatcher); |
45 ~MockTouchEventConverterEvdev() override {} | 50 ~MockTouchEventConverterEvdev() override {} |
46 | 51 |
47 void ConfigureReadMock(struct input_event* queue, | 52 void ConfigureReadMock(struct input_event* queue, |
48 long read_this_many, | 53 long read_this_many, |
49 long queue_index); | 54 long queue_index); |
50 | 55 |
51 // Actually dispatch the event reader code. | 56 // Actually dispatch the event reader code. |
52 void ReadNow() { | 57 void ReadNow() { |
53 OnFileCanReadWithoutBlocking(read_pipe_); | 58 OnFileCanReadWithoutBlocking(read_pipe_); |
54 base::RunLoop().RunUntilIdle(); | 59 base::RunLoop().RunUntilIdle(); |
55 } | 60 } |
56 | 61 |
57 void Initialize(const EventDeviceInfo& device_info) override {} | 62 void Initialize(const EventDeviceInfo& device_info) override {} |
58 bool Reinitialize() override { return true; } | 63 bool Reinitialize() override { return true; } |
59 | 64 |
| 65 TouchNoiseFinder* touch_noise_finder() { return touch_noise_finder_.get(); } |
| 66 |
60 private: | 67 private: |
61 int read_pipe_; | 68 int read_pipe_; |
62 int write_pipe_; | 69 int write_pipe_; |
63 | 70 |
64 DISALLOW_COPY_AND_ASSIGN(MockTouchEventConverterEvdev); | 71 DISALLOW_COPY_AND_ASSIGN(MockTouchEventConverterEvdev); |
65 }; | 72 }; |
66 | 73 |
67 class MockDeviceEventDispatcherEvdev : public DeviceEventDispatcherEvdev { | 74 class MockDeviceEventDispatcherEvdev : public DeviceEventDispatcherEvdev { |
68 public: | 75 public: |
69 MockDeviceEventDispatcherEvdev( | 76 MockDeviceEventDispatcherEvdev( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 120 |
114 if (pipe(fds)) | 121 if (pipe(fds)) |
115 PLOG(FATAL) << "failed pipe"; | 122 PLOG(FATAL) << "failed pipe"; |
116 | 123 |
117 EXPECT_FALSE(SetNonBlocking(fds[0]) || SetNonBlocking(fds[1])) | 124 EXPECT_FALSE(SetNonBlocking(fds[0]) || SetNonBlocking(fds[1])) |
118 << "failed to set non-blocking: " << strerror(errno); | 125 << "failed to set non-blocking: " << strerror(errno); |
119 | 126 |
120 read_pipe_ = fds[0]; | 127 read_pipe_ = fds[0]; |
121 write_pipe_ = fds[1]; | 128 write_pipe_ = fds[1]; |
122 | 129 |
123 events_.resize(MAX_FINGERS); | 130 events_.resize(ui::kNumTouchEvdevSlots); |
| 131 for (size_t i = 0; i < events_.size(); ++i) |
| 132 events_[i].slot = i; |
124 } | 133 } |
125 | 134 |
126 void MockTouchEventConverterEvdev::ConfigureReadMock(struct input_event* queue, | 135 void MockTouchEventConverterEvdev::ConfigureReadMock(struct input_event* queue, |
127 long read_this_many, | 136 long read_this_many, |
128 long queue_index) { | 137 long queue_index) { |
129 int nwrite = HANDLE_EINTR(write(write_pipe_, | 138 int nwrite = HANDLE_EINTR(write(write_pipe_, |
130 queue + queue_index, | 139 queue + queue_index, |
131 sizeof(struct input_event) * read_this_many)); | 140 sizeof(struct input_event) * read_this_many)); |
132 DCHECK(nwrite == | 141 DCHECK(nwrite == |
133 static_cast<int>(sizeof(struct input_event) * read_this_many)) | 142 static_cast<int>(sizeof(struct input_event) * read_this_many)) |
134 << "write() failed, errno: " << errno; | 143 << "write() failed, errno: " << errno; |
135 } | 144 } |
136 | 145 |
137 } // namespace ui | |
138 | |
139 // Test fixture. | 146 // Test fixture. |
140 class TouchEventConverterEvdevTest : public testing::Test { | 147 class TouchEventConverterEvdevTest : public testing::Test { |
141 public: | 148 public: |
142 TouchEventConverterEvdevTest() {} | 149 TouchEventConverterEvdevTest() {} |
143 | 150 |
144 // Overridden from testing::Test: | 151 // Overridden from testing::Test: |
145 void SetUp() override { | 152 void SetUp() override { |
146 // Set up pipe to satisfy message pump (unused). | 153 // Set up pipe to satisfy message pump (unused). |
147 int evdev_io[2]; | 154 int evdev_io[2]; |
148 if (pipe(evdev_io)) | 155 if (pipe(evdev_io)) |
(...skipping 20 matching lines...) Expand all Loading... |
169 } | 176 } |
170 | 177 |
171 ui::MockTouchEventConverterEvdev* device() { return device_; } | 178 ui::MockTouchEventConverterEvdev* device() { return device_; } |
172 | 179 |
173 unsigned size() { return dispatched_events_.size(); } | 180 unsigned size() { return dispatched_events_.size(); } |
174 const ui::TouchEventParams& dispatched_event(unsigned index) { | 181 const ui::TouchEventParams& dispatched_event(unsigned index) { |
175 DCHECK_GT(dispatched_events_.size(), index); | 182 DCHECK_GT(dispatched_events_.size(), index); |
176 return dispatched_events_[index]; | 183 return dispatched_events_[index]; |
177 } | 184 } |
178 | 185 |
| 186 void ClearDispatchedEvents() { |
| 187 dispatched_events_.clear(); |
| 188 } |
| 189 |
179 private: | 190 private: |
180 base::MessageLoop* loop_; | 191 base::MessageLoop* loop_; |
181 ui::MockTouchEventConverterEvdev* device_; | 192 ui::MockTouchEventConverterEvdev* device_; |
182 scoped_ptr<ui::MockDeviceEventDispatcherEvdev> dispatcher_; | 193 scoped_ptr<ui::MockDeviceEventDispatcherEvdev> dispatcher_; |
183 | 194 |
184 int events_out_; | 195 int events_out_; |
185 int events_in_; | 196 int events_in_; |
186 | 197 |
187 void DispatchCallback(const ui::TouchEventParams& params) { | 198 void DispatchCallback(const ui::TouchEventParams& params) { |
188 dispatched_events_.push_back(params); | 199 dispatched_events_.push_back(params); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 ev1 = dispatched_event(8); | 452 ev1 = dispatched_event(8); |
442 | 453 |
443 EXPECT_EQ(ui::ET_TOUCH_RELEASED, ev1.type); | 454 EXPECT_EQ(ui::ET_TOUCH_RELEASED, ev1.type); |
444 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev1.timestamp); | 455 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev1.timestamp); |
445 EXPECT_EQ(38, ev1.location.x()); | 456 EXPECT_EQ(38, ev1.location.x()); |
446 EXPECT_EQ(102, ev1.location.y()); | 457 EXPECT_EQ(102, ev1.location.y()); |
447 EXPECT_EQ(1, ev1.touch_id); | 458 EXPECT_EQ(1, ev1.touch_id); |
448 EXPECT_FLOAT_EQ(.5f, ev1.pressure); | 459 EXPECT_FLOAT_EQ(.5f, ev1.pressure); |
449 } | 460 } |
450 | 461 |
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 | |
473 TEST_F(TouchEventConverterEvdevTest, Unsync) { | 462 TEST_F(TouchEventConverterEvdevTest, Unsync) { |
474 ui::MockTouchEventConverterEvdev* dev = device(); | 463 ui::MockTouchEventConverterEvdev* dev = device(); |
475 | 464 |
476 struct input_event mock_kernel_queue_press0[] = { | 465 struct input_event mock_kernel_queue_press0[] = { |
477 {{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, 684}, | 466 {{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, 684}, |
478 {{0, 0}, EV_ABS, ABS_MT_TOUCH_MAJOR, 3}, | 467 {{0, 0}, EV_ABS, ABS_MT_TOUCH_MAJOR, 3}, |
479 {{0, 0}, EV_ABS, ABS_MT_PRESSURE, 45}, | 468 {{0, 0}, EV_ABS, ABS_MT_PRESSURE, 45}, |
480 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 42}, | 469 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 42}, |
481 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 51}, {{0, 0}, EV_SYN, SYN_REPORT, 0} | 470 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 51}, {{0, 0}, EV_SYN, SYN_REPORT, 0} |
482 }; | 471 }; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 | 542 |
554 // crbug.com/446939 | 543 // crbug.com/446939 |
555 TEST_F(TouchEventConverterEvdevTest, CheckSlotLimit) { | 544 TEST_F(TouchEventConverterEvdevTest, CheckSlotLimit) { |
556 ui::MockTouchEventConverterEvdev* dev = device(); | 545 ui::MockTouchEventConverterEvdev* dev = device(); |
557 | 546 |
558 struct input_event mock_kernel_queue[] = { | 547 struct input_event mock_kernel_queue[] = { |
559 {{0, 0}, EV_ABS, ABS_MT_SLOT, 0}, | 548 {{0, 0}, EV_ABS, ABS_MT_SLOT, 0}, |
560 {{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, 100}, | 549 {{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, 100}, |
561 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 999}, | 550 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 999}, |
562 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 888}, | 551 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 888}, |
563 {{0, 0}, EV_ABS, ABS_MT_SLOT, ui::TouchEventConverterEvdev::MAX_FINGERS}, | 552 {{0, 0}, EV_ABS, ABS_MT_SLOT, ui::kNumTouchEvdevSlots}, |
564 {{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, 200}, | 553 {{0, 0}, EV_ABS, ABS_MT_TRACKING_ID, 200}, |
565 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 777}, | 554 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 777}, |
566 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 666}, | 555 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 666}, |
567 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | 556 {{0, 0}, EV_SYN, SYN_REPORT, 0}, |
568 }; | 557 }; |
569 | 558 |
570 // Check that one 1 event is generated | 559 // Check that one 1 event is generated |
571 dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0); | 560 dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0); |
572 dev->ReadNow(); | 561 dev->ReadNow(); |
573 EXPECT_EQ(1u, size()); | 562 EXPECT_EQ(1u, size()); |
574 } | 563 } |
| 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 |