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/widget/root_view.h" | 5 #include "ui/views/widget/root_view.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" |
8 #include "ui/events/event_utils.h" | 9 #include "ui/events/event_utils.h" |
9 #include "ui/views/context_menu_controller.h" | 10 #include "ui/views/context_menu_controller.h" |
10 #include "ui/views/test/views_test_base.h" | 11 #include "ui/views/test/views_test_base.h" |
11 #include "ui/views/view_targeter.h" | 12 #include "ui/views/view_targeter.h" |
12 #include "ui/views/widget/root_view.h" | 13 #include "ui/views/widget/root_view.h" |
13 #include "ui/views/widget/widget_deletion_observer.h" | 14 #include "ui/views/widget/widget_deletion_observer.h" |
14 | 15 |
15 namespace views { | 16 namespace views { |
16 namespace test { | 17 namespace test { |
17 | 18 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 View* child = new DeleteOnKeyEventView(&got_key_event); | 53 View* child = new DeleteOnKeyEventView(&got_key_event); |
53 content->AddChildView(child); | 54 content->AddChildView(child); |
54 | 55 |
55 // Give focus to |child| so that it will be the target of the key event. | 56 // Give focus to |child| so that it will be the target of the key event. |
56 child->SetFocusable(true); | 57 child->SetFocusable(true); |
57 child->RequestFocus(); | 58 child->RequestFocus(); |
58 | 59 |
59 internal::RootView* root_view = | 60 internal::RootView* root_view = |
60 static_cast<internal::RootView*>(widget.GetRootView()); | 61 static_cast<internal::RootView*>(widget.GetRootView()); |
61 ViewTargeter* view_targeter = new ViewTargeter(root_view); | 62 ViewTargeter* view_targeter = new ViewTargeter(root_view); |
62 root_view->SetEventTargeter(make_scoped_ptr(view_targeter)); | 63 root_view->SetEventTargeter(base::WrapUnique(view_targeter)); |
63 | 64 |
64 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_ESCAPE, ui::EF_NONE); | 65 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_ESCAPE, ui::EF_NONE); |
65 ui::EventDispatchDetails details = root_view->OnEventFromSource(&key_event); | 66 ui::EventDispatchDetails details = root_view->OnEventFromSource(&key_event); |
66 EXPECT_TRUE(details.target_destroyed); | 67 EXPECT_TRUE(details.target_destroyed); |
67 EXPECT_FALSE(details.dispatcher_destroyed); | 68 EXPECT_FALSE(details.dispatcher_destroyed); |
68 EXPECT_TRUE(got_key_event); | 69 EXPECT_TRUE(got_key_event); |
69 } | 70 } |
70 | 71 |
71 // Tracks whether a context menu is shown. | 72 // Tracks whether a context menu is shown. |
72 class TestContextMenuController : public ContextMenuController { | 73 class TestContextMenuController : public ContextMenuController { |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 // mouse exit event to |subchild| and destroy the widget. This should not | 551 // mouse exit event to |subchild| and destroy the widget. This should not |
551 // crash when the mouse exit handler returns from |subchild|. | 552 // crash when the mouse exit handler returns from |subchild|. |
552 ui::MouseEvent move_event2(ui::ET_MOUSE_MOVED, gfx::Point(15, 15), | 553 ui::MouseEvent move_event2(ui::ET_MOUSE_MOVED, gfx::Point(15, 15), |
553 gfx::Point(15, 15), ui::EventTimeForNow(), 0, 0); | 554 gfx::Point(15, 15), ui::EventTimeForNow(), 0, 0); |
554 root_view->OnMouseMoved(move_event2); | 555 root_view->OnMouseMoved(move_event2); |
555 EXPECT_FALSE(widget_deletion_observer.IsWidgetAlive()); | 556 EXPECT_FALSE(widget_deletion_observer.IsWidgetAlive()); |
556 } | 557 } |
557 | 558 |
558 } // namespace test | 559 } // namespace test |
559 } // namespace views | 560 } // namespace views |
OLD | NEW |