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

Side by Side Diff: ui/views/touchui/touch_selection_menu_runner_views_unittest.cc

Issue 2611773002: Removes code using mus client lib (Closed)
Patch Set: dont run on linux Created 3 years, 11 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/macros.h" 5 #include "base/macros.h"
6 #include "ui/events/event_utils.h" 6 #include "ui/events/event_utils.h"
7 #include "ui/strings/grit/ui_strings.h" 7 #include "ui/strings/grit/ui_strings.h"
8 #include "ui/touch_selection/touch_selection_menu_runner.h" 8 #include "ui/touch_selection/touch_selection_menu_runner.h"
9 #include "ui/views/controls/button/button.h" 9 #include "ui/views/controls/button/button.h"
10 #include "ui/views/test/views_test_base.h" 10 #include "ui/views/test/views_test_base.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 int last_executed_command_id_; 61 int last_executed_command_id_;
62 62
63 DISALLOW_COPY_AND_ASSIGN(TouchSelectionMenuRunnerViewsTest); 63 DISALLOW_COPY_AND_ASSIGN(TouchSelectionMenuRunnerViewsTest);
64 }; 64 };
65 65
66 // Tests that the default touch selection menu runner is installed and opening 66 // Tests that the default touch selection menu runner is installed and opening
67 // and closing the menu works properly. 67 // and closing the menu works properly.
68 TEST_F(TouchSelectionMenuRunnerViewsTest, InstalledAndWorksProperly) { 68 TEST_F(TouchSelectionMenuRunnerViewsTest, InstalledAndWorksProperly) {
69 // See comment in SetUp(). 69 // See comment in SetUp().
70 if (IsAuraMusClient()) 70 if (IsMus())
71 return; 71 return;
72 72
73 gfx::Rect menu_anchor(0, 0, 10, 10); 73 gfx::Rect menu_anchor(0, 0, 10, 10);
74 gfx::Size handle_size(10, 10); 74 gfx::Size handle_size(10, 10);
75 75
76 // Menu runner instance should be installed, but no menu should be running. 76 // Menu runner instance should be installed, but no menu should be running.
77 EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()); 77 EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance());
78 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); 78 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
79 79
80 // Run menu. Since commands are available, this should bring up menus. 80 // Run menu. Since commands are available, this should bring up menus.
(...skipping 10 matching lines...) Expand all
91 set_no_commmand_available(true); 91 set_no_commmand_available(true);
92 ui::TouchSelectionMenuRunner::GetInstance()->OpenMenu( 92 ui::TouchSelectionMenuRunner::GetInstance()->OpenMenu(
93 this, menu_anchor, handle_size, GetContext()); 93 this, menu_anchor, handle_size, GetContext());
94 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); 94 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
95 } 95 }
96 96
97 // Tests that anchor rect for the quick menu is adjusted correctly based on the 97 // Tests that anchor rect for the quick menu is adjusted correctly based on the
98 // distance of handles. 98 // distance of handles.
99 TEST_F(TouchSelectionMenuRunnerViewsTest, QuickMenuAdjustsAnchorRect) { 99 TEST_F(TouchSelectionMenuRunnerViewsTest, QuickMenuAdjustsAnchorRect) {
100 // See comment in SetUp(). 100 // See comment in SetUp().
101 if (IsAuraMusClient()) 101 if (IsMus())
102 return; 102 return;
103 103
104 gfx::Size handle_size(10, 10); 104 gfx::Size handle_size(10, 10);
105 TouchSelectionMenuRunnerViews::TestApi test_api( 105 TouchSelectionMenuRunnerViews::TestApi test_api(
106 static_cast<TouchSelectionMenuRunnerViews*>( 106 static_cast<TouchSelectionMenuRunnerViews*>(
107 ui::TouchSelectionMenuRunner::GetInstance())); 107 ui::TouchSelectionMenuRunner::GetInstance()));
108 108
109 // Calculate the width of quick menu. In addition to |kMenuCommandCount| 109 // Calculate the width of quick menu. In addition to |kMenuCommandCount|
110 // commands, there is an item for ellipsis. 110 // commands, there is an item for ellipsis.
111 int quick_menu_width = 111 int quick_menu_width =
(...skipping 15 matching lines...) Expand all
127 this, anchor_rect, handle_size, GetContext()); 127 this, anchor_rect, handle_size, GetContext());
128 EXPECT_EQ(anchor_rect, test_api.GetAnchorRect()); 128 EXPECT_EQ(anchor_rect, test_api.GetAnchorRect());
129 129
130 ui::TouchSelectionMenuRunner::GetInstance()->CloseMenu(); 130 ui::TouchSelectionMenuRunner::GetInstance()->CloseMenu();
131 RunPendingMessages(); 131 RunPendingMessages();
132 } 132 }
133 133
134 // Tests that running one of menu actions closes the menu properly. 134 // Tests that running one of menu actions closes the menu properly.
135 TEST_F(TouchSelectionMenuRunnerViewsTest, RunningActionClosesProperly) { 135 TEST_F(TouchSelectionMenuRunnerViewsTest, RunningActionClosesProperly) {
136 // See comment in SetUp(). 136 // See comment in SetUp().
137 if (IsAuraMusClient()) 137 if (IsMus())
138 return; 138 return;
139 139
140 gfx::Rect menu_anchor(0, 0, 10, 10); 140 gfx::Rect menu_anchor(0, 0, 10, 10);
141 gfx::Size handle_size(10, 10); 141 gfx::Size handle_size(10, 10);
142 TouchSelectionMenuRunnerViews::TestApi test_api( 142 TouchSelectionMenuRunnerViews::TestApi test_api(
143 static_cast<TouchSelectionMenuRunnerViews*>( 143 static_cast<TouchSelectionMenuRunnerViews*>(
144 ui::TouchSelectionMenuRunner::GetInstance())); 144 ui::TouchSelectionMenuRunner::GetInstance()));
145 145
146 // Initially, no menu should be running. 146 // Initially, no menu should be running.
147 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); 147 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
(...skipping 14 matching lines...) Expand all
162 ui::EventTimeForNow(), details); 162 ui::EventTimeForNow(), details);
163 button->OnGestureEvent(&tap); 163 button->OnGestureEvent(&tap);
164 RunPendingMessages(); 164 RunPendingMessages();
165 EXPECT_NE(0, last_executed_command_id()); 165 EXPECT_NE(0, last_executed_command_id());
166 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); 166 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
167 } 167 }
168 168
169 // Tests that closing the menu widget cleans up the menu runner state properly. 169 // Tests that closing the menu widget cleans up the menu runner state properly.
170 TEST_F(TouchSelectionMenuRunnerViewsTest, ClosingWidgetClosesProperly) { 170 TEST_F(TouchSelectionMenuRunnerViewsTest, ClosingWidgetClosesProperly) {
171 // See comment in SetUp(). 171 // See comment in SetUp().
172 if (IsAuraMusClient()) 172 if (IsMus())
173 return; 173 return;
174 174
175 gfx::Rect menu_anchor(0, 0, 10, 10); 175 gfx::Rect menu_anchor(0, 0, 10, 10);
176 gfx::Size handle_size(10, 10); 176 gfx::Size handle_size(10, 10);
177 TouchSelectionMenuRunnerViews::TestApi test_api( 177 TouchSelectionMenuRunnerViews::TestApi test_api(
178 static_cast<TouchSelectionMenuRunnerViews*>( 178 static_cast<TouchSelectionMenuRunnerViews*>(
179 ui::TouchSelectionMenuRunner::GetInstance())); 179 ui::TouchSelectionMenuRunner::GetInstance()));
180 180
181 // Initially, no menu should be running. 181 // Initially, no menu should be running.
182 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); 182 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
183 183
184 // Run menu. Since commands are available, this should bring up menus. 184 // Run menu. Since commands are available, this should bring up menus.
185 ui::TouchSelectionMenuRunner::GetInstance()->OpenMenu( 185 ui::TouchSelectionMenuRunner::GetInstance()->OpenMenu(
186 this, menu_anchor, handle_size, GetContext()); 186 this, menu_anchor, handle_size, GetContext());
187 EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); 187 EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
188 188
189 // Close the menu widget and check that menu runner correctly knows that menu 189 // Close the menu widget and check that menu runner correctly knows that menu
190 // is not running anymore. 190 // is not running anymore.
191 Widget* widget = test_api.GetWidget(); 191 Widget* widget = test_api.GetWidget();
192 DCHECK(widget); 192 DCHECK(widget);
193 widget->Close(); 193 widget->Close();
194 RunPendingMessages(); 194 RunPendingMessages();
195 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); 195 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
196 } 196 }
197 197
198 } // namespace views 198 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/touchui/touch_selection_controller_impl_unittest.cc ('k') | ui/views/view_unittest_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698