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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 void ReadNow() { | 52 void ReadNow() { |
53 OnFileCanReadWithoutBlocking(read_pipe_); | 53 OnFileCanReadWithoutBlocking(read_pipe_); |
54 base::RunLoop().RunUntilIdle(); | 54 base::RunLoop().RunUntilIdle(); |
55 } | 55 } |
56 | 56 |
57 void DispatchCallback(Event* event) { | 57 void DispatchCallback(Event* event) { |
58 dispatched_events_.push_back( | 58 dispatched_events_.push_back( |
59 new TouchEvent(*static_cast<TouchEvent*>(event))); | 59 new TouchEvent(*static_cast<TouchEvent*>(event))); |
60 } | 60 } |
61 | 61 |
62 virtual bool Reinitialize() OVERRIDE { return true; } | 62 virtual bool Reinitialize() override { return true; } |
63 | 63 |
64 private: | 64 private: |
65 int read_pipe_; | 65 int read_pipe_; |
66 int write_pipe_; | 66 int write_pipe_; |
67 | 67 |
68 ScopedVector<TouchEvent> dispatched_events_; | 68 ScopedVector<TouchEvent> dispatched_events_; |
69 | 69 |
70 DISALLOW_COPY_AND_ASSIGN(MockTouchEventConverterEvdev); | 70 DISALLOW_COPY_AND_ASSIGN(MockTouchEventConverterEvdev); |
71 }; | 71 }; |
72 | 72 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } | 113 } |
114 | 114 |
115 } // namespace ui | 115 } // namespace ui |
116 | 116 |
117 // Test fixture. | 117 // Test fixture. |
118 class TouchEventConverterEvdevTest : public testing::Test { | 118 class TouchEventConverterEvdevTest : public testing::Test { |
119 public: | 119 public: |
120 TouchEventConverterEvdevTest() {} | 120 TouchEventConverterEvdevTest() {} |
121 | 121 |
122 // Overridden from testing::Test: | 122 // Overridden from testing::Test: |
123 virtual void SetUp() OVERRIDE { | 123 virtual void SetUp() override { |
124 // Set up pipe to satisfy message pump (unused). | 124 // Set up pipe to satisfy message pump (unused). |
125 int evdev_io[2]; | 125 int evdev_io[2]; |
126 if (pipe(evdev_io)) | 126 if (pipe(evdev_io)) |
127 PLOG(FATAL) << "failed pipe"; | 127 PLOG(FATAL) << "failed pipe"; |
128 events_in_ = evdev_io[0]; | 128 events_in_ = evdev_io[0]; |
129 events_out_ = evdev_io[1]; | 129 events_out_ = evdev_io[1]; |
130 | 130 |
131 loop_ = new base::MessageLoopForUI; | 131 loop_ = new base::MessageLoopForUI; |
132 device_ = new ui::MockTouchEventConverterEvdev( | 132 device_ = new ui::MockTouchEventConverterEvdev( |
133 events_in_, base::FilePath(kTestDevicePath)); | 133 events_in_, base::FilePath(kTestDevicePath)); |
134 } | 134 } |
135 | 135 |
136 virtual void TearDown() OVERRIDE { | 136 virtual void TearDown() override { |
137 delete device_; | 137 delete device_; |
138 delete loop_; | 138 delete loop_; |
139 } | 139 } |
140 | 140 |
141 ui::MockTouchEventConverterEvdev* device() { return device_; } | 141 ui::MockTouchEventConverterEvdev* device() { return device_; } |
142 | 142 |
143 private: | 143 private: |
144 base::MessageLoop* loop_; | 144 base::MessageLoop* loop_; |
145 ui::MockTouchEventConverterEvdev* device_; | 145 ui::MockTouchEventConverterEvdev* device_; |
146 | 146 |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 EXPECT_EQ(0, ev0->touch_id()); | 520 EXPECT_EQ(0, ev0->touch_id()); |
521 EXPECT_EQ(999, ev0->x()); | 521 EXPECT_EQ(999, ev0->x()); |
522 EXPECT_EQ(888, ev0->y()); | 522 EXPECT_EQ(888, ev0->y()); |
523 EXPECT_FLOAT_EQ(0.8333333f, ev0->force()); | 523 EXPECT_FLOAT_EQ(0.8333333f, ev0->force()); |
524 | 524 |
525 EXPECT_EQ(1, ev1->touch_id()); | 525 EXPECT_EQ(1, ev1->touch_id()); |
526 EXPECT_EQ(777, ev1->x()); | 526 EXPECT_EQ(777, ev1->x()); |
527 EXPECT_EQ(666, ev1->y()); | 527 EXPECT_EQ(666, ev1->y()); |
528 EXPECT_FLOAT_EQ(0.4666666f, ev1->force()); | 528 EXPECT_FLOAT_EQ(0.4666666f, ev1->force()); |
529 } | 529 } |
OLD | NEW |