Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: chrome/browser/ui/views/button_dropdown_test.cc

Issue 9390038: Move automation/ui_controls to ui/ui_controls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win_aura fix, sync Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "base/message_loop.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/automation/ui_controls.h"
8 #include "chrome/test/base/view_event_test_base.h" 7 #include "chrome/test/base/view_event_test_base.h"
8 #include "chrome/test/base/ui_test_utils.h"
9 #include "ui/base/models/simple_menu_model.h" 9 #include "ui/base/models/simple_menu_model.h"
10 #include "ui/ui_controls/ui_controls.h"
10 #include "ui/views/controls/button/button_dropdown.h" 11 #include "ui/views/controls/button/button_dropdown.h"
11 12
12 class ButtonDropDownDragTest : public ViewEventTestBase, 13 class ButtonDropDownDragTest : public ViewEventTestBase,
13 ui::SimpleMenuModel::Delegate { 14 ui::SimpleMenuModel::Delegate {
14 public: 15 public:
15 ButtonDropDownDragTest() 16 ButtonDropDownDragTest()
16 : button_(NULL), 17 : button_(NULL),
17 ALLOW_THIS_IN_INITIALIZER_LIST(menu_model_(this)), 18 ALLOW_THIS_IN_INITIALIZER_LIST(menu_model_(this)),
18 menu_shown_(false), 19 menu_shown_(false),
19 menu_closed_(false) { 20 menu_closed_(false) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 menu_shown_ = true; 64 menu_shown_ = true;
64 } 65 }
65 66
66 virtual void MenuClosed(ui::SimpleMenuModel* /*source*/) OVERRIDE { 67 virtual void MenuClosed(ui::SimpleMenuModel* /*source*/) OVERRIDE {
67 menu_closed_ = true; 68 menu_closed_ = true;
68 } 69 }
69 70
70 // ViewEventTestBase implementation. 71 // ViewEventTestBase implementation.
71 virtual void DoTestOnMessageLoop() OVERRIDE { 72 virtual void DoTestOnMessageLoop() OVERRIDE {
72 // Click on the ButtonDropDown. 73 // Click on the ButtonDropDown.
73 ui_controls::MoveMouseToCenterAndPress( 74 ui_test_utils::MoveMouseToCenterAndPress(
74 button_, 75 button_,
75 ui_controls::LEFT, 76 ui_controls::LEFT,
76 ui_controls::DOWN, 77 ui_controls::DOWN,
77 CreateEventTask(this, &ButtonDropDownDragTest::Step1)); 78 CreateEventTask(this, &ButtonDropDownDragTest::Step1));
78 } 79 }
79 80
80 void Step1() { 81 void Step1() {
81 // Drag to invoke the menu. 82 // Drag to invoke the menu.
82 gfx::Point view_center; 83 gfx::Point view_center;
83 views::View::ConvertPointToScreen(button_, &view_center); 84 views::View::ConvertPointToScreen(button_, &view_center);
(...skipping 10 matching lines...) Expand all
94 // Release. 95 // Release.
95 ui_controls::SendMouseEventsNotifyWhenDone( 96 ui_controls::SendMouseEventsNotifyWhenDone(
96 ui_controls::LEFT, 97 ui_controls::LEFT,
97 ui_controls::UP, 98 ui_controls::UP,
98 CreateEventTask(this, &ButtonDropDownDragTest::Step3)); 99 CreateEventTask(this, &ButtonDropDownDragTest::Step3));
99 } 100 }
100 101
101 void Step3() { 102 void Step3() {
102 // Click mouse to dismiss menu. The views menu does not dismiss the 103 // Click mouse to dismiss menu. The views menu does not dismiss the
103 // menu on click-drag-release unless an item is selected. 104 // menu on click-drag-release unless an item is selected.
104 ui_controls::MoveMouseToCenterAndPress( 105 ui_test_utils::MoveMouseToCenterAndPress(
105 button_, 106 button_,
106 ui_controls::LEFT, 107 ui_controls::LEFT,
107 ui_controls::DOWN | ui_controls::UP, 108 ui_controls::DOWN | ui_controls::UP,
108 CreateEventTask(this, &ButtonDropDownDragTest::Step4)); 109 CreateEventTask(this, &ButtonDropDownDragTest::Step4));
109 } 110 }
110 111
111 void Step4() { 112 void Step4() {
112 // One more hop is required because ui::SimpleMenuModel calls 113 // One more hop is required because ui::SimpleMenuModel calls
113 // ui::SimpleMenuModel::Delegate::MenuClosed() via a posted 114 // ui::SimpleMenuModel::Delegate::MenuClosed() via a posted
114 // task. 115 // task.
115 MessageLoopForUI::current()->PostTask( 116 MessageLoopForUI::current()->PostTask(
116 FROM_HERE, 117 FROM_HERE,
117 CreateEventTask(this, &ButtonDropDownDragTest::Step5)); 118 CreateEventTask(this, &ButtonDropDownDragTest::Step5));
118 } 119 }
119 120
120 void Step5() { 121 void Step5() {
121 ASSERT_TRUE(menu_closed_); 122 ASSERT_TRUE(menu_closed_);
122 Done(); 123 Done();
123 } 124 }
124 125
125 private: 126 private:
126 views::ButtonDropDown* button_; 127 views::ButtonDropDown* button_;
127 ui::SimpleMenuModel menu_model_; 128 ui::SimpleMenuModel menu_model_;
128 bool menu_shown_; 129 bool menu_shown_;
129 bool menu_closed_; 130 bool menu_closed_;
130 }; 131 };
131 132
132 VIEW_TEST(ButtonDropDownDragTest, DragActivation) 133 VIEW_TEST(ButtonDropDownDragTest, DragActivation)
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698