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

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

Issue 2178163002: Add ink drop ripple to shelf overflow button (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed scoped task runner Created 4 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/custom_button.h" 5 #include "ui/views/controls/button/custom_button.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 // The button should no longer notify on mouse release. 246 // The button should no longer notify on mouse release.
247 button()->Reset(); 247 button()->Reset();
248 button()->OnMouseReleased(ui::MouseEvent( 248 button()->OnMouseReleased(ui::MouseEvent(
249 ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(), 249 ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(),
250 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 250 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
251 EXPECT_EQ(CustomButton::STATE_HOVERED, button()->state()); 251 EXPECT_EQ(CustomButton::STATE_HOVERED, button()->state());
252 EXPECT_FALSE(button()->pressed()); 252 EXPECT_FALSE(button()->pressed());
253 } 253 }
254 254
255 // Tests that OnClickCanceled gets called when NotifyClick is not expected 255 // Tests that OnClickCanceled gets called when NotifyClick is not expected
256 // anymore. 256 // anymore (e.g., release happens outside of the button).
257 TEST_F(CustomButtonTest, NotifyActionNoClick) { 257 TEST_F(CustomButtonTest, NotifyActionNoClick) {
258 gfx::Point center(10, 10); 258 gfx::Point center(10, 10);
259 gfx::Point outside(10 + button()->width(), 10);
259 260
260 // By default the button should notify its listener on mouse release. 261 // By default the button should notify its listener on mouse release.
261 button()->OnMousePressed(ui::MouseEvent( 262 button()->OnMousePressed(ui::MouseEvent(
262 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), 263 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(),
263 ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON)); 264 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
264 EXPECT_FALSE(button()->canceled()); 265 EXPECT_FALSE(button()->canceled());
265 266
266 button()->OnMouseReleased(ui::MouseEvent( 267 button()->OnMouseReleased(ui::MouseEvent(
267 ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(), 268 ui::ET_MOUSE_RELEASED, outside, outside, ui::EventTimeForNow(),
268 ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON)); 269 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
269 EXPECT_TRUE(button()->canceled()); 270 EXPECT_TRUE(button()->canceled());
270 271
271 // Set the notify action to its listener on mouse press. 272 // Set the notify action to its listener on mouse press.
272 button()->Reset(); 273 button()->Reset();
273 button()->set_notify_action(CustomButton::NOTIFY_ON_PRESS); 274 button()->set_notify_action(CustomButton::NOTIFY_ON_PRESS);
274 button()->OnMousePressed(ui::MouseEvent( 275 button()->OnMousePressed(ui::MouseEvent(
275 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), 276 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(),
276 ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON)); 277 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
277 // OnClickCanceled is only sent on mouse release. 278 // OnClickCanceled is only sent on mouse release.
278 EXPECT_FALSE(button()->canceled()); 279 EXPECT_FALSE(button()->canceled());
279 280
280 // The button should no longer notify on mouse release. 281 // The button should no longer notify on mouse release.
281 button()->Reset(); 282 button()->Reset();
282 button()->OnMouseReleased(ui::MouseEvent( 283 button()->OnMouseReleased(ui::MouseEvent(
283 ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(), 284 ui::ET_MOUSE_RELEASED, outside, outside, ui::EventTimeForNow(),
284 ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON)); 285 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
285 EXPECT_FALSE(button()->canceled()); 286 EXPECT_FALSE(button()->canceled());
286 } 287 }
287 288
288 // No touch on desktop Mac. Tracked in http://crbug.com/445520. 289 // No touch on desktop Mac. Tracked in http://crbug.com/445520.
289 #if !defined(OS_MACOSX) || defined(USE_AURA) 290 #if !defined(OS_MACOSX) || defined(USE_AURA)
290 291
291 namespace { 292 namespace {
292 293
293 void PerformGesture(CustomButton* button, ui::EventType event_type) { 294 void PerformGesture(CustomButton* button, ui::EventType event_type) {
294 ui::GestureEventDetails gesture_details(event_type); 295 ui::GestureEventDetails gesture_details(event_type);
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 EXPECT_EQ(CustomButton::STATE_PRESSED, button()->state()); 586 EXPECT_EQ(CustomButton::STATE_PRESSED, button()->state());
586 EXPECT_FALSE(button()->pressed()); 587 EXPECT_FALSE(button()->pressed());
587 588
588 ui::KeyEvent space_release(ui::ET_KEY_RELEASED, ui::VKEY_SPACE, ui::EF_NONE); 589 ui::KeyEvent space_release(ui::ET_KEY_RELEASED, ui::VKEY_SPACE, ui::EF_NONE);
589 SimulateKeyEvent(&space_release); 590 SimulateKeyEvent(&space_release);
590 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); 591 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state());
591 EXPECT_TRUE(button()->pressed()); 592 EXPECT_TRUE(button()->pressed());
592 } 593 }
593 594
594 } // namespace views 595 } // namespace views
OLDNEW
« ui/views/animation/ink_drop_host_view.cc ('K') | « ui/views/controls/button/custom_button.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698