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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "chrome/browser/ui/views/toolbar/toolbar_button.h" | 7 #include "chrome/browser/ui/views/toolbar/toolbar_button.h" |
8 #include "chrome/test/base/interactive_test_utils.h" | 8 #include "chrome/test/base/interactive_test_utils.h" |
9 #include "chrome/test/base/ui_test_utils.h" | 9 #include "chrome/test/base/ui_test_utils.h" |
10 #include "chrome/test/base/view_event_test_base.h" | 10 #include "chrome/test/base/view_event_test_base.h" |
11 #include "ui/base/models/simple_menu_model.h" | 11 #include "ui/base/models/simple_menu_model.h" |
12 #include "ui/base/test/ui_controls.h" | 12 #include "ui/base/test/ui_controls.h" |
13 | 13 |
14 class ToolbarButtonDragTest : public ViewEventTestBase, | 14 class ToolbarButtonDragTest : public ViewEventTestBase, |
15 ui::SimpleMenuModel::Delegate { | 15 ui::SimpleMenuModel::Delegate { |
16 public: | 16 public: |
17 ToolbarButtonDragTest() | 17 ToolbarButtonDragTest() |
18 : button_(NULL), | 18 : button_(NULL), |
19 menu_shown_(false), | 19 menu_shown_(false), |
20 menu_closed_(false) { | 20 menu_closed_(false) { |
21 } | 21 } |
22 | 22 |
23 virtual ~ToolbarButtonDragTest() { | 23 virtual ~ToolbarButtonDragTest() { |
24 } | 24 } |
25 | 25 |
26 // ViewEventTestBase implementation. | 26 // ViewEventTestBase implementation. |
27 virtual void SetUp() OVERRIDE { | 27 virtual void SetUp() override { |
28 button_ = new ToolbarButton(NULL, new ui::SimpleMenuModel(this)); | 28 button_ = new ToolbarButton(NULL, new ui::SimpleMenuModel(this)); |
29 | 29 |
30 ViewEventTestBase::SetUp(); | 30 ViewEventTestBase::SetUp(); |
31 } | 31 } |
32 | 32 |
33 virtual void TearDown() OVERRIDE { | 33 virtual void TearDown() override { |
34 ViewEventTestBase::TearDown(); | 34 ViewEventTestBase::TearDown(); |
35 } | 35 } |
36 | 36 |
37 virtual views::View* CreateContentsView() OVERRIDE { | 37 virtual views::View* CreateContentsView() override { |
38 return button_; | 38 return button_; |
39 } | 39 } |
40 | 40 |
41 virtual gfx::Size GetPreferredSize() const OVERRIDE { | 41 virtual gfx::Size GetPreferredSize() const override { |
42 return button_->GetPreferredSize(); | 42 return button_->GetPreferredSize(); |
43 } | 43 } |
44 | 44 |
45 // ui::SimpleMenuModel::Delegate implementation. | 45 // ui::SimpleMenuModel::Delegate implementation. |
46 virtual bool IsCommandIdChecked(int id) const OVERRIDE { | 46 virtual bool IsCommandIdChecked(int id) const override { |
47 return false; | 47 return false; |
48 } | 48 } |
49 | 49 |
50 virtual bool IsCommandIdEnabled(int id) const OVERRIDE { | 50 virtual bool IsCommandIdEnabled(int id) const override { |
51 return true; | 51 return true; |
52 } | 52 } |
53 | 53 |
54 virtual bool GetAcceleratorForCommandId( | 54 virtual bool GetAcceleratorForCommandId( |
55 int id, | 55 int id, |
56 ui::Accelerator* accelerator) OVERRIDE { | 56 ui::Accelerator* accelerator) override { |
57 return false; | 57 return false; |
58 } | 58 } |
59 | 59 |
60 virtual void ExecuteCommand(int id, int event_flags) OVERRIDE { | 60 virtual void ExecuteCommand(int id, int event_flags) override { |
61 } | 61 } |
62 | 62 |
63 virtual void MenuWillShow(ui::SimpleMenuModel* /*source*/) OVERRIDE { | 63 virtual void MenuWillShow(ui::SimpleMenuModel* /*source*/) override { |
64 menu_shown_ = true; | 64 menu_shown_ = true; |
65 } | 65 } |
66 | 66 |
67 virtual void MenuClosed(ui::SimpleMenuModel* /*source*/) OVERRIDE { | 67 virtual void MenuClosed(ui::SimpleMenuModel* /*source*/) override { |
68 menu_closed_ = true; | 68 menu_closed_ = true; |
69 } | 69 } |
70 | 70 |
71 // ViewEventTestBase implementation. | 71 // ViewEventTestBase implementation. |
72 virtual void DoTestOnMessageLoop() OVERRIDE { | 72 virtual void DoTestOnMessageLoop() override { |
73 // Click on the ToolbarButton. | 73 // Click on the ToolbarButton. |
74 ui_test_utils::MoveMouseToCenterAndPress( | 74 ui_test_utils::MoveMouseToCenterAndPress( |
75 button_, | 75 button_, |
76 ui_controls::LEFT, | 76 ui_controls::LEFT, |
77 ui_controls::DOWN, | 77 ui_controls::DOWN, |
78 CreateEventTask(this, &ToolbarButtonDragTest::Step1)); | 78 CreateEventTask(this, &ToolbarButtonDragTest::Step1)); |
79 } | 79 } |
80 | 80 |
81 void Step1() { | 81 void Step1() { |
82 // Drag to invoke the menu. | 82 // Drag to invoke the menu. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 123 } |
124 | 124 |
125 private: | 125 private: |
126 ToolbarButton* button_; | 126 ToolbarButton* button_; |
127 bool menu_shown_; | 127 bool menu_shown_; |
128 bool menu_closed_; | 128 bool menu_closed_; |
129 }; | 129 }; |
130 | 130 |
131 // Broken since landed. crbug.com/325055 | 131 // Broken since landed. crbug.com/325055 |
132 VIEW_TEST(ToolbarButtonDragTest, DISABLED_DragActivation) | 132 VIEW_TEST(ToolbarButtonDragTest, DISABLED_DragActivation) |
OLD | NEW |