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

Side by Side Diff: ui/views/controls/button/menu_button_unittest.cc

Issue 404213003: [WIP] Allow scroll events to permanently change the default gesture handler in RootView (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: friend test Created 6 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/controls/button/menu_button.h" 5 #include "ui/views/controls/button/menu_button.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/events/test/event_generator.h" 8 #include "ui/events/test/event_generator.h"
9 #include "ui/views/controls/button/menu_button_listener.h" 9 #include "ui/views/controls/button/menu_button_listener.h"
10 #include "ui/views/test/views_test_base.h" 10 #include "ui/views/test/views_test_base.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // Tests if the listener is notified correctly when a gesture tap happens on a 142 // Tests if the listener is notified correctly when a gesture tap happens on a
143 // MenuButton that has a regular ButtonListener. 143 // MenuButton that has a regular ButtonListener.
144 TEST_F(MenuButtonTest, ActivateNonDropDownOnGestureTap) { 144 TEST_F(MenuButtonTest, ActivateNonDropDownOnGestureTap) {
145 scoped_ptr<TestButtonListener> button_listener(new TestButtonListener); 145 scoped_ptr<TestButtonListener> button_listener(new TestButtonListener);
146 CreateMenuButtonWithButtonListener(button_listener.get()); 146 CreateMenuButtonWithButtonListener(button_listener.get());
147 147
148 ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow()); 148 ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow());
149 generator.GestureTapAt(gfx::Point(10, 10)); 149 generator.GestureTapAt(gfx::Point(10, 10));
150 150
151 // Check that MenuButton has notified the listener on gesture tap event, while 151 // Check that MenuButton has notified the listener on gesture tap event, while
152 // it was in hovered state. 152 // it was in the normal state.
153 EXPECT_EQ(button(), button_listener->last_sender()); 153 EXPECT_EQ(button(), button_listener->last_sender());
154 EXPECT_EQ(ui::ET_GESTURE_TAP, button_listener->last_event_type()); 154 EXPECT_EQ(ui::ET_GESTURE_TAP, button_listener->last_event_type());
155 EXPECT_EQ(Button::STATE_HOVERED, button_listener->last_sender_state()); 155 EXPECT_EQ(Button::STATE_NORMAL, button_listener->last_sender_state());
156 } 156 }
157 157
158 // Tests if the listener is notified correctly when a mouse click happens on a 158 // Tests if the listener is notified correctly when a mouse click happens on a
159 // MenuButton that has a MenuButtonListener. 159 // MenuButton that has a MenuButtonListener.
160 TEST_F(MenuButtonTest, ActivateDropDownOnMouseClick) { 160 TEST_F(MenuButtonTest, ActivateDropDownOnMouseClick) {
161 scoped_ptr<TestMenuButtonListener> menu_button_listener( 161 scoped_ptr<TestMenuButtonListener> menu_button_listener(
162 new TestMenuButtonListener); 162 new TestMenuButtonListener);
163 CreateMenuButtonWithMenuButtonListener(menu_button_listener.get()); 163 CreateMenuButtonWithMenuButtonListener(menu_button_listener.get());
164 164
165 ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow()); 165 ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow());
(...skipping 17 matching lines...) Expand all
183 ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow()); 183 ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow());
184 generator.GestureTapAt(gfx::Point(10, 10)); 184 generator.GestureTapAt(gfx::Point(10, 10));
185 185
186 // Check that MenuButton has notified the listener, while it was in pressed 186 // Check that MenuButton has notified the listener, while it was in pressed
187 // state. 187 // state.
188 EXPECT_EQ(button(), menu_button_listener->last_source()); 188 EXPECT_EQ(button(), menu_button_listener->last_source());
189 EXPECT_EQ(Button::STATE_PRESSED, menu_button_listener->last_source_state()); 189 EXPECT_EQ(Button::STATE_PRESSED, menu_button_listener->last_source_state());
190 } 190 }
191 191
192 } // namespace views 192 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698