| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } | 46 } |
| 47 | 47 |
| 48 CloseWidgetView::CloseWidgetView(ui::EventType event_type) | 48 CloseWidgetView::CloseWidgetView(ui::EventType event_type) |
| 49 : event_type_(event_type) { | 49 : event_type_(event_type) { |
| 50 } | 50 } |
| 51 | 51 |
| 52 void CloseWidgetView::OnEvent(ui::Event* event) { | 52 void CloseWidgetView::OnEvent(ui::Event* event) { |
| 53 if (event->type() == event_type_) { | 53 if (event->type() == event_type_) { |
| 54 // Go through NativeWidgetPrivate to simulate what happens if the OS | 54 // Go through NativeWidgetPrivate to simulate what happens if the OS |
| 55 // deletes the NativeWindow out from under us. | 55 // deletes the NativeWindow out from under us. |
| 56 // TODO(tapted): Change this to WidgetTest::SimulateNativeDestroy for a more | 56 // TODO(tapted): Change this to ViewsTestBase::SimulateNativeDestroy for a |
| 57 // authentic test on Mac. | 57 // more authentic test on Mac. |
| 58 GetWidget()->native_widget_private()->CloseNow(); | 58 GetWidget()->native_widget_private()->CloseNow(); |
| 59 } else { | 59 } else { |
| 60 View::OnEvent(event); | 60 View::OnEvent(event); |
| 61 if (!event->IsTouchEvent()) | 61 if (!event->IsTouchEvent()) |
| 62 event->SetHandled(); | 62 event->SetHandled(); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 EventCountView::EventCountView() | 66 EventCountView::EventCountView() |
| 67 : last_flags_(0), handle_mode_(PROPAGATE_EVENTS) {} | 67 : last_flags_(0), handle_mode_(PROPAGATE_EVENTS) {} |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 99 } |
| 100 | 100 |
| 101 void EventCountView::RecordEvent(ui::Event* event) { | 101 void EventCountView::RecordEvent(ui::Event* event) { |
| 102 ++event_count_[event->type()]; | 102 ++event_count_[event->type()]; |
| 103 last_flags_ = event->flags(); | 103 last_flags_ = event->flags(); |
| 104 if (handle_mode_ == CONSUME_EVENTS) | 104 if (handle_mode_ == CONSUME_EVENTS) |
| 105 event->SetHandled(); | 105 event->SetHandled(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace views | 108 } // namespace views |
| OLD | NEW |