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> |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 if (pipe(fds)) | 114 if (pipe(fds)) |
115 PLOG(FATAL) << "failed pipe"; | 115 PLOG(FATAL) << "failed pipe"; |
116 | 116 |
117 DCHECK(SetNonBlocking(fds[0]) == 0) | 117 DCHECK(SetNonBlocking(fds[0]) == 0) |
118 << "SetNonBlocking for pipe fd[0] failed, errno: " << errno; | 118 << "SetNonBlocking for pipe fd[0] failed, errno: " << errno; |
119 DCHECK(SetNonBlocking(fds[1]) == 0) | 119 DCHECK(SetNonBlocking(fds[1]) == 0) |
120 << "SetNonBlocking for pipe fd[0] failed, errno: " << errno; | 120 << "SetNonBlocking for pipe fd[0] failed, errno: " << errno; |
121 read_pipe_ = fds[0]; | 121 read_pipe_ = fds[0]; |
122 write_pipe_ = fds[1]; | 122 write_pipe_ = fds[1]; |
| 123 |
| 124 events_.resize(MAX_FINGERS); |
123 } | 125 } |
124 | 126 |
125 void MockTouchEventConverterEvdev::ConfigureReadMock(struct input_event* queue, | 127 void MockTouchEventConverterEvdev::ConfigureReadMock(struct input_event* queue, |
126 long read_this_many, | 128 long read_this_many, |
127 long queue_index) { | 129 long queue_index) { |
128 int nwrite = HANDLE_EINTR(write(write_pipe_, | 130 int nwrite = HANDLE_EINTR(write(write_pipe_, |
129 queue + queue_index, | 131 queue + queue_index, |
130 sizeof(struct input_event) * read_this_many)); | 132 sizeof(struct input_event) * read_this_many)); |
131 DCHECK(nwrite == | 133 DCHECK(nwrite == |
132 static_cast<int>(sizeof(struct input_event) * read_this_many)) | 134 static_cast<int>(sizeof(struct input_event) * read_this_many)) |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 777}, | 566 {{0, 0}, EV_ABS, ABS_MT_POSITION_X, 777}, |
565 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 666}, | 567 {{0, 0}, EV_ABS, ABS_MT_POSITION_Y, 666}, |
566 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | 568 {{0, 0}, EV_SYN, SYN_REPORT, 0}, |
567 }; | 569 }; |
568 | 570 |
569 // Check that one 1 event is generated | 571 // Check that one 1 event is generated |
570 dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0); | 572 dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0); |
571 dev->ReadNow(); | 573 dev->ReadNow(); |
572 EXPECT_EQ(1u, size()); | 574 EXPECT_EQ(1u, size()); |
573 } | 575 } |
OLD | NEW |