Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(606)

Side by Side Diff: ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc

Issue 661353006: ozone: evdev: Dispatch events in task (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/events/ozone/evdev/touch_event_converter_evdev.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 28 matching lines...) Expand all
39 class MockTouchEventConverterEvdev : public TouchEventConverterEvdev { 39 class MockTouchEventConverterEvdev : public TouchEventConverterEvdev {
40 public: 40 public:
41 MockTouchEventConverterEvdev(int fd, base::FilePath path); 41 MockTouchEventConverterEvdev(int fd, base::FilePath path);
42 virtual ~MockTouchEventConverterEvdev() {}; 42 virtual ~MockTouchEventConverterEvdev() {};
43 43
44 void ConfigureReadMock(struct input_event* queue, 44 void ConfigureReadMock(struct input_event* queue,
45 long read_this_many, 45 long read_this_many,
46 long queue_index); 46 long queue_index);
47 47
48 unsigned size() { return dispatched_events_.size(); } 48 unsigned size() { return dispatched_events_.size(); }
49 TouchEvent* event(unsigned index) { return dispatched_events_[index]; } 49 TouchEvent* event(unsigned index) {
50 DCHECK_GT(dispatched_events_.size(), index);
51 Event* ev = dispatched_events_[index];
52 DCHECK(ev->IsTouchEvent());
53 return static_cast<TouchEvent*>(ev);
54 }
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 DispatchCallback(Event* event) { 62 void DispatchCallback(scoped_ptr<Event> event) {
58 dispatched_events_.push_back( 63 dispatched_events_.push_back(event.release());
59 new TouchEvent(*static_cast<TouchEvent*>(event)));
60 } 64 }
61 65
62 virtual bool Reinitialize() override { return true; } 66 virtual bool Reinitialize() override { return true; }
63 67
64 private: 68 private:
65 int read_pipe_; 69 int read_pipe_;
66 int write_pipe_; 70 int write_pipe_;
67 71
68 ScopedVector<TouchEvent> dispatched_events_; 72 ScopedVector<Event> dispatched_events_;
69 73
70 DISALLOW_COPY_AND_ASSIGN(MockTouchEventConverterEvdev); 74 DISALLOW_COPY_AND_ASSIGN(MockTouchEventConverterEvdev);
71 }; 75 };
72 76
73 MockTouchEventConverterEvdev::MockTouchEventConverterEvdev(int fd, 77 MockTouchEventConverterEvdev::MockTouchEventConverterEvdev(int fd,
74 base::FilePath path) 78 base::FilePath path)
75 : TouchEventConverterEvdev( 79 : TouchEventConverterEvdev(
76 fd, 80 fd,
77 path, 81 path,
78 1, 82 1,
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 EXPECT_EQ(0, ev0->touch_id()); 524 EXPECT_EQ(0, ev0->touch_id());
521 EXPECT_EQ(999, ev0->x()); 525 EXPECT_EQ(999, ev0->x());
522 EXPECT_EQ(888, ev0->y()); 526 EXPECT_EQ(888, ev0->y());
523 EXPECT_FLOAT_EQ(0.8333333f, ev0->force()); 527 EXPECT_FLOAT_EQ(0.8333333f, ev0->force());
524 528
525 EXPECT_EQ(1, ev1->touch_id()); 529 EXPECT_EQ(1, ev1->touch_id());
526 EXPECT_EQ(777, ev1->x()); 530 EXPECT_EQ(777, ev1->x());
527 EXPECT_EQ(666, ev1->y()); 531 EXPECT_EQ(666, ev1->y());
528 EXPECT_FLOAT_EQ(0.4666666f, ev1->force()); 532 EXPECT_FLOAT_EQ(0.4666666f, ev1->force());
529 } 533 }
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/touch_event_converter_evdev.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698