OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/menu_test_utils.h" | 5 #include "ui/views/test/menu_test_utils.h" |
6 | 6 |
7 #include "ui/views/controls/menu/menu_controller.h" | 7 #include "ui/views/controls/menu/menu_controller.h" |
8 | 8 |
9 namespace views { | 9 namespace views { |
10 namespace test { | 10 namespace test { |
11 | 11 |
12 // TestMenuDelegate ----------------------------------------------------------- | 12 // TestMenuDelegate ----------------------------------------------------------- |
13 | 13 |
14 TestMenuDelegate::TestMenuDelegate() | 14 TestMenuDelegate::TestMenuDelegate() |
15 : execute_command_id_(0), | 15 : execute_command_id_(0), |
16 on_menu_closed_called_count_(0), | 16 on_menu_closed_called_count_(0), |
17 on_menu_closed_menu_(nullptr), | 17 on_menu_closed_menu_(nullptr), |
18 on_menu_closed_run_result_(MenuRunner::MENU_DELETED), | |
19 on_perform_drop_called_(false) {} | 18 on_perform_drop_called_(false) {} |
20 | 19 |
21 TestMenuDelegate::~TestMenuDelegate() {} | 20 TestMenuDelegate::~TestMenuDelegate() {} |
22 | 21 |
23 bool TestMenuDelegate::ShowContextMenu(MenuItemView* source, | 22 bool TestMenuDelegate::ShowContextMenu(MenuItemView* source, |
24 int id, | 23 int id, |
25 const gfx::Point& p, | 24 const gfx::Point& p, |
26 ui::MenuSourceType source_type) { | 25 ui::MenuSourceType source_type) { |
27 show_context_menu_count_++; | 26 show_context_menu_count_++; |
28 show_context_menu_source_ = source; | 27 show_context_menu_source_ = source; |
29 return true; | 28 return true; |
30 } | 29 } |
31 | 30 |
32 void TestMenuDelegate::ExecuteCommand(int id) { | 31 void TestMenuDelegate::ExecuteCommand(int id) { |
33 execute_command_id_ = id; | 32 execute_command_id_ = id; |
34 } | 33 } |
35 | 34 |
36 void TestMenuDelegate::OnMenuClosed(MenuItemView* menu, | 35 void TestMenuDelegate::OnMenuClosed(MenuItemView* menu) { |
37 MenuRunner::RunResult result) { | |
38 on_menu_closed_called_count_++; | 36 on_menu_closed_called_count_++; |
39 on_menu_closed_menu_ = menu; | 37 on_menu_closed_menu_ = menu; |
40 on_menu_closed_run_result_ = result; | |
41 } | 38 } |
42 | 39 |
43 int TestMenuDelegate::OnPerformDrop(MenuItemView* menu, | 40 int TestMenuDelegate::OnPerformDrop(MenuItemView* menu, |
44 DropPosition position, | 41 DropPosition position, |
45 const ui::DropTargetEvent& event) { | 42 const ui::DropTargetEvent& event) { |
46 on_perform_drop_called_ = true; | 43 on_perform_drop_called_ = true; |
47 return ui::DragDropTypes::DRAG_COPY; | 44 return ui::DragDropTypes::DRAG_COPY; |
48 } | 45 } |
49 | 46 |
50 int TestMenuDelegate::GetDragOperations(MenuItemView* sender) { | 47 int TestMenuDelegate::GetDragOperations(MenuItemView* sender) { |
(...skipping 22 matching lines...) Expand all Loading... |
73 } | 70 } |
74 | 71 |
75 void MenuControllerTestApi::SetShowing(bool showing) { | 72 void MenuControllerTestApi::SetShowing(bool showing) { |
76 if (!controller_) | 73 if (!controller_) |
77 return; | 74 return; |
78 controller_->showing_ = showing; | 75 controller_->showing_ = showing; |
79 } | 76 } |
80 | 77 |
81 } // namespace test | 78 } // namespace test |
82 } // namespace views | 79 } // namespace views |
OLD | NEW |