| OLD | NEW |
| 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 "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); | 214 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); |
| 215 } | 215 } |
| 216 #endif | 216 #endif |
| 217 | 217 |
| 218 // Disabling cursor events occurs for touch events and the Ash magnifier. There | 218 // Disabling cursor events occurs for touch events and the Ash magnifier. There |
| 219 // is no touch on desktop Mac. Tracked in http://crbug.com/445520. | 219 // is no touch on desktop Mac. Tracked in http://crbug.com/445520. |
| 220 #if !defined(OS_MACOSX) || defined(USE_AURA) | 220 #if !defined(OS_MACOSX) || defined(USE_AURA) |
| 221 aura::test::TestCursorClient cursor_client( | 221 aura::test::TestCursorClient cursor_client( |
| 222 widget()->GetNativeView()->GetRootWindow()); | 222 widget()->GetNativeView()->GetRootWindow()); |
| 223 | 223 |
| 224 // Mus doesn't support disabling mouse events. https://crbug.com/618321 | 224 // In Aura views, no new hover effects are invoked if mouse events |
| 225 if (!IsMus()) { | 225 // are disabled. |
| 226 // In Aura views, no new hover effects are invoked if mouse events | 226 cursor_client.DisableMouseEvents(); |
| 227 // are disabled. | |
| 228 cursor_client.DisableMouseEvents(); | |
| 229 | 227 |
| 230 button()->SetEnabled(false); | 228 button()->SetEnabled(false); |
| 231 EXPECT_EQ(CustomButton::STATE_DISABLED, button()->state()); | 229 EXPECT_EQ(CustomButton::STATE_DISABLED, button()->state()); |
| 232 | 230 |
| 233 button()->SetEnabled(true); | 231 button()->SetEnabled(true); |
| 234 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); | 232 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); |
| 235 | 233 |
| 236 button()->SetVisible(false); | 234 button()->SetVisible(false); |
| 237 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); | 235 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); |
| 238 | 236 |
| 239 button()->SetVisible(true); | 237 button()->SetVisible(true); |
| 240 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); | 238 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); |
| 241 } | |
| 242 #endif // !defined(OS_MACOSX) || defined(USE_AURA) | 239 #endif // !defined(OS_MACOSX) || defined(USE_AURA) |
| 243 } | 240 } |
| 244 | 241 |
| 245 // Tests the different types of NotifyActions. | 242 // Tests the different types of NotifyActions. |
| 246 TEST_F(CustomButtonTest, NotifyAction) { | 243 TEST_F(CustomButtonTest, NotifyAction) { |
| 247 gfx::Point center(10, 10); | 244 gfx::Point center(10, 10); |
| 248 | 245 |
| 249 // By default the button should notify its listener on mouse release. | 246 // By default the button should notify its listener on mouse release. |
| 250 button()->OnMousePressed(ui::MouseEvent( | 247 button()->OnMousePressed(ui::MouseEvent( |
| 251 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), | 248 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 EXPECT_EQ(CustomButton::STATE_PRESSED, button()->state()); | 640 EXPECT_EQ(CustomButton::STATE_PRESSED, button()->state()); |
| 644 EXPECT_FALSE(button()->pressed()); | 641 EXPECT_FALSE(button()->pressed()); |
| 645 | 642 |
| 646 ui::KeyEvent space_release(ui::ET_KEY_RELEASED, ui::VKEY_SPACE, ui::EF_NONE); | 643 ui::KeyEvent space_release(ui::ET_KEY_RELEASED, ui::VKEY_SPACE, ui::EF_NONE); |
| 647 SimulateKeyEvent(&space_release); | 644 SimulateKeyEvent(&space_release); |
| 648 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); | 645 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); |
| 649 EXPECT_TRUE(button()->pressed()); | 646 EXPECT_TRUE(button()->pressed()); |
| 650 } | 647 } |
| 651 | 648 |
| 652 } // namespace views | 649 } // namespace views |
| OLD | NEW |