OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/views/test/test_views.h" | 5 #include "ui/views/test/test_views.h" |
6 | 6 |
7 #include "ui/events/event.h" | 7 #include "ui/events/event.h" |
8 #include "ui/views/widget/native_widget_private.h" | 8 #include "ui/views/widget/native_widget_private.h" |
9 #include "ui/views/widget/widget.h" | 9 #include "ui/views/widget/widget.h" |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // TODO(tapted): Change this to WidgetTest::SimulateNativeDestroy for a more | 57 // TODO(tapted): Change this to WidgetTest::SimulateNativeDestroy for a more |
58 // authentic test on Mac. | 58 // authentic test on Mac. |
59 GetWidget()->native_widget_private()->CloseNow(); | 59 GetWidget()->native_widget_private()->CloseNow(); |
60 } else { | 60 } else { |
61 View::OnEvent(event); | 61 View::OnEvent(event); |
62 if (!event->IsTouchEvent()) | 62 if (!event->IsTouchEvent()) |
63 event->SetHandled(); | 63 event->SetHandled(); |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
| 67 EventCountView::EventCountView() |
| 68 : last_flags_(0), handle_mode_(PROPAGATE_EVENTS) {} |
| 69 |
| 70 EventCountView::~EventCountView() {} |
| 71 |
| 72 int EventCountView::GetEventCount(ui::EventType type) { |
| 73 return event_count_[type]; |
| 74 } |
| 75 |
| 76 void EventCountView::ResetCounts() { |
| 77 event_count_.clear(); |
| 78 } |
| 79 |
| 80 void EventCountView::OnMouseMoved(const ui::MouseEvent& event) { |
| 81 // MouseMove events are not re-dispatched from the RootView. |
| 82 ++event_count_[ui::ET_MOUSE_MOVED]; |
| 83 last_flags_ = 0; |
| 84 } |
| 85 |
| 86 void EventCountView::OnKeyEvent(ui::KeyEvent* event) { |
| 87 RecordEvent(event); |
| 88 } |
| 89 |
| 90 void EventCountView::OnMouseEvent(ui::MouseEvent* event) { |
| 91 RecordEvent(event); |
| 92 } |
| 93 |
| 94 void EventCountView::OnScrollEvent(ui::ScrollEvent* event) { |
| 95 RecordEvent(event); |
| 96 } |
| 97 |
| 98 void EventCountView::OnGestureEvent(ui::GestureEvent* event) { |
| 99 RecordEvent(event); |
| 100 } |
| 101 |
| 102 void EventCountView::RecordEvent(ui::Event* event) { |
| 103 ++event_count_[event->type()]; |
| 104 last_flags_ = event->flags(); |
| 105 if (handle_mode_ == CONSUME_EVENTS) |
| 106 event->SetHandled(); |
| 107 } |
| 108 |
67 } // namespace views | 109 } // namespace views |
OLD | NEW |